akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll LMAX=1000000000000001;

int h,w;
int m=0;
vector<string> s;

void solv(int x,int y){
  vector<int> dx={-1,0,1,0};
  vector<int> dy={0,1,0,-1};
  queue<int> X;
  queue<int> Y;
  vector<vector<bool>> memo(h,vector<bool>(w,0));
  vector<vector<int>> a(h,vector<int>(w,0));
  X.push(x);Y.push(y);
  memo[x][y]=1;
  while(!(X.empty())){
    int Xz=X.front();
    int Yz=Y.front();
    rep(i,4){
      int xz=Xz+dx[i];int yz=Yz+dy[i];
      if(xz<0||xz>=h||yz<0||yz>=w) continue;
      if(s[xz][yz]=='#'||memo[xz][yz]) continue;
      a[xz][yz]=a[Xz][Yz]+1;
      X.push(xz);Y.push(yz);
      memo[xz][yz]=1;
    }
    X.pop();Y.pop();
  }
  rep(k,h){
    rep(l,w){
      m=max(m,a[k][l]);
    }
  }
}

int main(){
  cin>>h>>w;
  rep(i,h){
    string S; cin>>S;
    s.pb(S);
  }

  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#') continue;
      solv(i,j);
    }
  }
  cout<<m<<endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C;
        C = N*A;
        if(C<B){
            System.out.println(C);
        }
        else{
            System.out.println(B);
        }

    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std ;
int main(){
  int n;
  cin>>n;
  string s,ans="";
  cin>>s;
  int m = s.length();
  for(int i=0;i<m;i++){
     int m = ((int)s[i] + n);
     if(m<=90){
         char c = (char)m;
        // cout<<m<<" ";
         ans = ans+c;
     }
     else{
         m = m - 90;
         m = m + 64;
         //cout<<m<<" ";
         char c = (char)m;
         ans = ans+c;
     }
  }
  cout<<ans;
}

Measured memory_bytes: 256
from collections import deque
from copy import copy,deepcopy
from itertools import permutations,combinations
from pprint import pprint

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

x,y,z = myinput()
print(z,x,y)

Measured memory_bytes: 38384
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""

# 最大公約数 と 最小公倍数
"""def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
def lcm(a,b):
  g = gcd(a,b)
  return (a * b) // g"""

# 二分探索
"""import bisect # 二分探索
print(A,bisect.bisect_left(A,4))
print(C,n - bisect.bisect_right(C,4))
print(sum(bisect.bisect_left(A,b) * (n-bisect.bisect_right(C,b)) for b in B))"""

# 円周率 pi
"""import math
pi_ = math.pi"""

# エラトステネスの篩
"""def Erato(n):
    prime = []
    is_prime = [True] * (n+1)
    p = 0
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,n+1):
      if is_prime[i] == True:
        prime.append(i)
        p += 1
        for j in range(2 * i,n+1,i):
          is_prime[j] = False
    return p"""

def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
  import math
  k = int(input())
  ans = 0
  BC = []
  for b in range(1,k+1):
    for c in range(1,k+1):
      BC.append(math.gcd(b,c))
  for a in range(1,k+1):
    for bc in BC:
      ans += math.gcd(a,bc)
  print(ans)
if __name__ == '__main__':
  main()

Measured memory_bytes: 9580
#include<stdio.h>
int main()
{
	int n,m,i,j,wb,br,min=2147483600,r;
	char f[64][64];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",f[i]);
	}
	for(wb=1;wb<n-1;wb++){
		for(br=wb+1;br<n;br++){
			r=0;
			for(i=0;i<wb;i++){
				for(j=0;j<m;j++){
					if(f[i][j]!='W'){
						r++;
					}
				}
			}
			for(i=wb;i<br;i++){
				for(j=0;j<m;j++){
					if(f[i][j]!='B'){
						r++;
					}
				}
			}
			for(i=br;i<n;i++){
				for(j=0;j<m;j++){
					if(f[i][j]!='R'){
						r++;
					}
				}
			}
			if(r<min){
				min=r;
			}
		}
	}
	printf("%d\n",min);
	return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  double ans = v[0];
  for (int i = 1; i < n; i++) ans = (ans+v[i])/2;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 256
import sys
from bisect import bisect_right as br
input = sys.stdin.readline
N = int(input())

def check(x):
  i = 2
  res = []
  while i * i <= x:
    while x % i == 0:
      x //= i
      res.append(i)
    i += 1
  if x > 1:
    res.append(x)
  return res
table = [0] * (N + 1)
for i in range(2, N + 1):
  for p in check(i):
    table[p] += 1
  #print(check(i))
t = [0]
#print(table)
for p in table:
  if p > 0: t.append(p)
t.sort()
#print(t)
k = len(t)
#print(k)
res = t[-1] >= 74
for i in range(k - 1):
  for j in range(i + 1, k):
    if t[i] + 1 >= 3 and (t[j] + 1 >= 25):
      res += 1
    if t[i] + 1 >= 5 and (t[j] + 1 >= 15):
      res += 1
    if t[i] + 1 >= 15 and (t[j] + 1 >= 5):
      res += 1
    if t[i] + 1 >= 25 and (t[j] + 1 >= 3):
      res += 1
#print(k, res)
for i in range(k - 2):
  for j in range(i + 1, k - 1):
    for l in range(j + 1, k):
      if (t[i] + 1) >= 3 and (t[j] + 1 >= 5) and (t[l] + 1 >= 5):
        res += 1
      if (t[i] + 1) >= 5 and (t[j] + 1 >= 3) and (t[l] + 1 >= 5):
        res += 1
      if (t[i] + 1) >= 5 and (t[j] + 1 >= 5) and (t[l] + 1 >= 3):
        res += 1
print(int(res))

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

int main() {
  cout << fixed << setprecision(4);
  int n;
  cin >> n;
  double a, count = 0.00;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> a >> s;
    if (s == "JPY") {
      count += a;
    }
    else {
      count += a*380000.00;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<double, double> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;

//ll bit[200010];
ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

/*ll sum(ll i)
{
	i += 1;
	ll t = 0;
	while (i > 0)
	{
		t = max(bit[i], t);
		i -= i & -i;
	}
	return t;
}

void update(ll i, ll x)
{
	i += 1;
	while (i <= 200005)
	{
		bit[i] = max(bit[i], x);
		i += i & -i;
	}
}*/

/*`ll SAIKI(ll S) {
	for (ll T = S; ; T = (T - 1) & S) {

	}
}*/

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
	//毎回オーダーlog(n)かかる
}

void kaijo() {
	kai[0] = 1;
	for (ll i = 1; i <= 3004; i++) {
		kai[i] = kai[i - 1] * i % mod;
	}
}

ll num[100010];
ll N;
vector<ll> E[100010];
ll ans[100010];
ll ri[100010], le[100010];
ll tmpr[100010], tmpl[100010];
ll saiki(ll ver, ll from) {
	ll nu = 1;
	for (ll v: E[ver])if(v != from) {
		(nu *= saiki(v, ver) + 1) %= mod;
	}
	return num[ver] = nu;
}

void sai(ll ver, ll from, ll score) {
	vector<ll> vec;
	ans[ver] = (score + 1) * num[ver] % mod;
	vector<ll> S;
	for (ll v : E[ver]) {
		if (v == from) S.pb(score + 1);
		else S.pb(num[v] + 1);
	}
	ri[0] = S[0], le[E[ver].size() - 1] = S[E[ver].size() - 1];
	if (E[ver].size() != 1) {
		for (ll i = 1; i < E[ver].size(); i++) ri[i] = ri[i - 1] * S[i] % mod;
		for (ll i = E[ver].size() - 2; i >= 0; i--) le[i] = le[i + 1] * S[i] % mod;
	}
	for (ll i = 0; i < E[ver].size(); i++) {
		ll v = E[ver][i];
		if (E[ver].size() == 1) vec.pb((score + 1) % mod);
		else if (i == 0) vec.pb(le[1]);
		else if (i == E[ver].size() - 1) vec.pb(ri[E[ver].size() - 2]);
		else vec.pb(ri[i - 1] * le[i + 1] % mod);
	}
	for (ll i = 0; i < E[ver].size(); i++) {
		ll v = E[ver][i];
		if (v == from) continue;
		sai(v, ver, vec[i]);
		/*if (E[ver].size() == 1) sai(v, ver, (score + 1) % mod);
		else if (i == 0) sai(v, ver, le[1]);
		else if (i == E[ver].size() - 1) sai(v, ver, ri[E[ver].size() - 2]);
		else {
			sai(v, ver, ri[i - 1] * le[i + 1] % mod);
			cout << ri[0] << ' ' << le[i + 1] << ' ' << i << endl;
		}*/
	}
}

void solve() {
	cin >> N >> mod;
	rep(i, N - 1) {
		ll x, y;
		cin >> x >> y;
		E[x].push_back(y);
		E[y].push_back(x);
	}
	if (N == 1) {
		cout << 1 << endl;
		return;
	}
	saiki(1, 0);
	sai(1, 0, 0);
	rep(i, N) cout << ans[i + 1] << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

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

using namespace std;

const int maxn = 1e5+5;
char s[maxn];

int main()
{
	scanf("%s",s);
	int ll = strlen(s);
	int ans = ll/2;
	int l,r;
	while (1) {
		l = ll-ans;
		r = ans+1;
		int flag = 1;
		int now = s[l-1];
		for (int i = l;i < r;i++) {
			if (s[i] != now) {
				flag = 0;
				break;
			}
		}
		if (!flag) {
			break;
		}
		ans++;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void){
  int a,b,c;
  int x[256];
  int n,i;
int t=1;
  scanf("%d",&n);
  
  for (i=0;i<n;i++){
scanf("%d ",&x[i]);
    if((x[i]%2==0)&&((x[i]%3!=0&&x[i]%5!=0))){
t=0;
    }
  }
  
  
  if(t==1){
printf("APPROVED\n");
  }else{
printf("DENIED\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD = 1000000007;

     signed main(){
   int n,d,ans=0;
   cin>>n>>d;
   int x,y;
   for(int i=0;i<n;i++){
       cin>>x>>y;
       if(x*x+y*y<=d*d)ans++;
   }
   cout<<ans<<endl;
     }


 


 






    





      

        


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int N;
  cin >> N;
  int m = 0;
  int sum = 0;
  rep(i,N){
    int A;
    cin >> A;
    m = max(m,A);
    sum += A;
  }
  if(2*m < sum){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/
#define rep(i,l,r) for(int i=l;i<=r;i++)

////////////////////////////////////////

double Abs(double a){
    if(a>0)return a;
    else return -a;
}


int main(){
    int n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    sort(a,a+n);
    cout<<a[n-1]<<" ";
    
    double m=(double)a[n-1]/2.0;
    double b[n];rep(i,0,n-2)b[i]=(double)a[i]-m;
    int c=lower_bound(b,b+n-1,0)-b;
    double d1,d2,d3;d1=d2=d3=-1000000000000;
    if(1<=c&&c<=n-3){
        d1=a[c-1];
        d2=a[c];
        d3=a[c+1];
    }else if(1<=c){
        d1=a[c-1];
        d2=a[c];
    }else if(c<=n-3){
        d2=a[c];
        d3=a[c+1];
    }else{
        d2=a[c];
    }
    if(Abs(m-d1)>Abs(m-d2)){
        swap(d1,d2);
    }
    if(Abs(m-d1)>Abs(m-d3)){
        swap(d1,d3);
    }
    cout<<(int)d1;
    
    return 0;
}






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

int main(){
    int N, K;
    cin >> N >> K;
    N--; K--;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
    }
    int ans = N / K + (N%K!=0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
   int H,W;
   while(1){
	   cin>> H >> W;
	   if(W == 0 && H == 0){ break; }
   for (int i=0 ; i<H ; i++){
	   for (int j=0 ; j<W ; j++){
		   cout<<"#";
	   };
	   cout << endl;
   };
   cout << endl;
  }
return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#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<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n, a, b;
  cin >> n >>a>>b;
  cout << min(a*n, b) << endl;
  return 0;
}


Measured memory_bytes: 256
class Main
  def self.run
    a, b, c = read_input
    puts ascending?(a, b, c)
  end

  private

  def self.read_input
    gets.split(" ").map {|x| x.to_i}
  end

  def self.ascending?(a, b, c)
    (a < b && b < c) ? "Yes" : "No"
  end
end

Main.run

Measured memory_bytes: 8552
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

maxkey = max([dic[i] for i in dic])

anslist = []

for i in dic:
    if dic[i] == maxkey:
        anslist.append(i)
anslist.sort()

for i in anslist:
    print(i)


Measured memory_bytes: 93860
class UnionFind(object):
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0 for i in range(n + 1)]

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        elif self.rank[x] > self.rank[y]:
            self.par[y] = x
        else:
            self.par[y] = x
            self.rank[x] += 1

n, m = map(int, input().split())
p = list(map(int, input().split()))
tree = UnionFind(n)
for i in range(m):
    x, y = map(int, input().split())
    tree.union(x, y)
ans = 0
for i, pi in enumerate(p):
    if tree.check(i + 1, pi):
        ans += 1
print(ans)


Measured memory_bytes: 14452
import java.util.*;
 
public 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+c >= 22) {
            System.out.println("bust");
        }else {
            System.out.println("win");
        }
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//
 

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll h , n;
  cin >> h >> n; 
  vector<pair<ll,ll>> a;
  ll b,d;
  rep(i,n){
    cin >> b >> d;
    a.pb(make_pair(b,d));
  }
  vector<ll> dp;
  ll i = 0;
  dp.pb(0);
  while(i<=h){
    i++;
    dp.pb(INF);
    rep(j,a.size()){
      ll ta = a[j].first;
      ll co = a[j].second;
      if(i<ta) ta=i;
      chmin(dp[i],dp[i-ta]+co);
    }
  }
  pri(dp[h]);

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int num;
    while(1)
    {
        for(int i=1;i<=5;i++)
        {
            cin>>num;
          if(num==0)
          {
            cout<<i<<endl;
            break;
          }
        }
      break;
    }
}


Measured memory_bytes: 3484
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
#define MOD 1e9 + 7
#define N 1e5 + 10
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a[5],k=0,i=0,j=0;
	for(i=0;i<5;i++)
	{
		cin>>a[i];
	}
	cin>>k;
  	for(i=1;i<5;i++)
    {
		if((a[i]-a[0])>k)
        {
          cout<<":(";
          return 0;
        }
    }
	cout<<"Yay!";
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

//累乗(nのk乗）
long long ruijou(ll n, ll k){
    if(k==0) return 1;
    int x=k/2;
    long long t=ruijou(n,x);
    
    if(k%2==1) return n*t*t;
    else return t*t;
}

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(d==b+1) cout<<0<<endl;
  else cout<<1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n;
	cin>>n;
	ll sum=0;
	for(ll i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0&&i%15!=0){
			sum+=i;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3608
"""
NTC here
"""
import sys
inp = sys.stdin.readline


def input(): return inp().strip()


flush = sys.stdout.flush
# import threading
# sys.setrecursionlimit(10**6)
# threading.stack_size(2**25)


def iin(): return int(input())


def lin(): return list(map(int, input().split()))

# range = xrange
# input = raw_input


def main():
    def fn(n):
        if n<0:return 0
        return (n*(n+1))//2
    n = iin()
    a = lin()
    dc = {}
    for i in a:
        try:
            dc[i]+=1
        except:
            dc[i] = 1
    sm = 0
    for i in dc:
        sm+= fn(dc[i]-1)
    for i in a:
        x = dc[i]
        ch = sm - fn(x-1) + fn(x-2)
        print(ch)

main()
# threading.Thread(target=main).start()


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

int main()
{
	int N,x,y,b,p;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x >> y >> b >> p;
		int normal = x*b + y*p;
		int discount=1000000;
		if (b >= 5 && p >= 2)
			normal*=0.8;
		else if (b >= 5)
			discount = x*b + y * 2;
		else if (p >= 2)
			discount = x * 5 + y*p;
		else
			discount = x * 5 + y * 2;
		discount *= 0.8;
		if (normal <= discount)
			cout << normal << endl;
		else
			cout << discount << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
//ABC067B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	string s;
	cin >> s;
	int n = s.size()-2;
	while(1){
		bool flag = true;
		for(int i=0;i<n/2;i++){
			if(s.at(i) != s.at(i+n/2)){
				flag = false;
			}
		}
		if(flag == true){
			cout << n << endl;
			return 0;
		}else{
			n -= 2;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long

int main(void) {
    ll a, b, c, k, ans;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &k);
    if (k % 2 == 1) ans = b - a;
    else ans = a - b;
    
    if (llabs(ans) > 1000000000000000000) printf("Unfair\n");
    else printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
// #include <bits/stdc++.h> // C++を満足に使えるようになったら
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

int const N_MAX = 100;

int N, X;
int m[N_MAX + 1];

int main() {
  scanf("%d %d", &N, &X);
  int min_x = 1001;
  rep(i, N) {
    scanf("%d", &m[i]);
    X -= m[i];
    min_x = min(min_x, m[i]);
  }
  printf("%d\n", N + X / min_x);
}


Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    K = int(input())

    if K % 2 == 0:
        print(-1)
        return

    tmp = 7
    ans = 1
    while tmp % K != 0:
        tmp = (tmp % K) * 10 + 7
        ans += 1
        if ans >= 10000000:
            print(-1)
            return

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 72856
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;


int32_t main()
{
    fast

   int test=1;
   //cin>>test;


  while(test--)
  {
  int n,k;
  cin>>n>>k;
 vi h(n),dp(n,INT_MAX);
 dp[0]=0;
 for(int i=0;i<n;i++)cin>>h[i];
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++)
  {
    for(int j=i-1;j>=i-k&&j>=0;j--)
    dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
    
  }
 cout<<dp[n-1];


  //while loop ending 
  }

return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int q; cin >> q;
    multiset<int> L, R;
    ll tot = 0;
    
    while(q--){
        int t; cin >> t;
        if(t == 1){
            int a, b; cin >> a >> b;
            tot += b;
            L.insert(a); R.insert(a); 
            auto itl = L.end(); itl--;
            auto itr = R.begin();
            int l = *itl; int r = *itr;
            if(l > r){
                tot += l - r;
                L.erase(itl); L.insert(r);
                R.erase(itr); R.insert(l);
            }
        }else{
            ll l = *L.rbegin();
            cout << l << " " << tot << endl;
        }
    }
    return;
}

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

Measured memory_bytes: 22344
n, m, x =  map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
ans = float("INF")
for i in range(2**n):
    d = [(i >> j) & 1 for j in range(n)]
    res = [0] * m
    ans_ = 0
    flag = True
    for i in range(n):
        if d[i]:
            ans_ += ca[i][0] 
            for j in range(1, m+1):
                res[j-1] += ca[i][j]
    for k in res:
        if k < x:
            flag = False
            break
    if flag: ans = min(ans, ans_)
if ans == float("INF"): print(-1)
else: print(ans)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int d[100000];
int root(int x){
	if (x != d[x]) d[x] = root(d[x]);
	return d[x];
}
int main(){
	int n, m, c, x, y;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) d[i] = i;
	c = n;
	for (int i = 0; i < m; i++){
		scanf("%d %d", &x, &y), x--, y--;
		x = root(x), y = root(y);
		if (x != y) d[x] = y, c--;
	}
	printf("%d\n", c - 1);
}

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

int main() {
    string s;
    cin >> s ;
    int plus = 0;
    int minus = 0;

    for(int i=0; i<4; ++i){
        if (s[i]=='+'){
            plus++;
        }
        else {
            minus++;
        }
    }

    cout << plus-minus << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
using namespace std;

long long N, A[200000], taken[200000];
long long sum, partner;
long long ans;
int main(void) {
	scanf("%lld", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}
	sort(A, A + N, greater<long long>());
	for (int i = 0; i < N; i++) {
		taken[i] = 0;
	}
	printf("\n");
	ans = 0;
	for (int i = 0; i < N; i++) {
		if (taken[i] == 1) {
			continue;
		}
		/*A[i]とペアになる値を見つける*/
		sum = 1;
		while (sum <= A[i]) {
			sum *= 2;
		}
		partner = sum - A[i];
		/*taken[i] == 0かつA[i]==partnerであるようなiのうち、最大のものは？*/
		int left = i+1;
		int right = N;
		while (right - left > 1) {
			int med = (left + right) / 2;
			if (A[med] < partner) {
				right = med;
			}
			else if (A[med] == partner && taken[med] == 1) {
				right = med;
			}
			else { 
				left = med;
			}
		}
		
		if (A[left] == partner && taken[left] == 0) {
			ans += 1;
			taken[i] = 1;
			taken[left] = 1;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3328
#define MYDEBUG
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}


int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	if(a[0]==5&&a[1]==5&&a[2]==7) cout << "YES" << endl;
	else cout << "NO" << endl;
}


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

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> A(H);
  for(int i=0;i<H;i++){
    cin >> A[i];
  }
  set<int> Hset,Wset;
  for(int i=0;i<H;i++){
    bool flag=true;
    for(int j=0;j<W;j++){
      if(A[i][j]=='#'){
        flag=false;
        break;
      }
    }
    if(flag){
      Hset.insert(i);
    }
  }
  for(int i=0;i<W;i++){
    bool flag=true;
    for(int j=0;j<H;j++){
      if(A[j][i]=='#'){
        flag=false;
        break;
      }
    }
    if(flag){
      Wset.insert(i);
    }
  }
  for(int i=0;i<H;i++){
    if(Hset.count(i)){
      continue;
    }
    for(int j=0;j<W;j++){
      if(Wset.count(j)){
        continue;
      }
      cout << A[i][j];
    }
    cout << endl;
  }
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
//#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

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


int main(){
    int n; cin >> n;
    vector<pair<int,int>> p;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        p.pb(make_pair(a,b));
    }
    sort(p.begin(),p.end(),compare_by_b);

    int tasks=0;
    string ans ="Yes";

    rep(i,n){
        tasks+=p[i].first;
        if(tasks>p[i].second){
            ans="No";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = sc.nextLong()
    println(problem148c(a, b))
}

fun problem148c(a: Long, b: Long): Long {
    /**
     * 最大公約数
     * @param big 2つの値の大きな方
     * @param small 2つの値の小さな方
     */
    fun computeGreatestCommonDivisor(big: Long, small: Long): Long {
        val rest = big % small
        return if (rest == 0L) small else computeGreatestCommonDivisor(small, rest)
    }

    /**
     * 最小公倍数
     * @param big 2つの値の大きな方
     * @param small 2つの値の小さな方
     */
    fun computeLeastCommonMultiple(small: Long, big: Long): Long {
        return small * big / computeGreatestCommonDivisor(big, small)
    }
    return computeLeastCommonMultiple(if (a > b) a else b, if (a > b) b else a)
}

Measured memory_bytes: 31508
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k, n;
  cin >> k >> n;
  VI A(n);
  INPUT(A);
  int dis = 0;
  REP(i, n-1) chmax(dis, A[i+1]-A[i]);
  chmax(dis, k - A[n-1] + A[0]);
  cout << k - dis << endl;

  return 0;
}


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

#define MAXN 123456
#define f first
#define s second
#define debug(x) cout << "DEBUG: " << x << endl

int n;
double resp;

int main(){
    cin >> n;

    if(n==1){
        resp=1;
    }
    else if(n%2==0){
        resp=(n/2*1.0)/n;
    }
    else{
        resp=((n/2*1.0)+1)/n;
    }

    cout << fixed << setprecision(10);
    cout << resp << endl;
}


Measured memory_bytes: 256
S = input()
X, Y = [int(_) for _ in input().split()]
V = [[0], [0]]
d = 0
f = 1
for s in S:
    if s == 'F':
        if f:
            X -= 1
        else:
            V[d][-1] += 1
    else:
        f = 0
        d = 1 - d
        if V[d][-1]:
            V[d] += [0]
V = [sorted(_) for _ in V]
xs = set()


def judge(diff, vs):
    se = set([0])
    for v in vs:
        sen = set()
        for s in se:
            sen.add(s + v)
            sen.add(s - v)
        se = sen
    if diff not in se:
        print('No')
        exit()


judge(X, V[0])
judge(Y, V[1])
print('Yes')


Measured memory_bytes: 45660
#include<iostream>
#include<string>
int N;
std::string S, T;
int main() {
	std::cin >> N;
	int lb = 0;
	int ub = N;
	std::cout << 0 << std::endl;
	std::cin >> S;
	if (S == "Vacant") {
		return 0;
	}
	while (ub - lb>1) {
		int mid = (lb + ub) / 2;
		std::cout << mid << std::endl;
		std::cin >> T;
		if (T == "Vacant") {
			return 0;
		}
		if (((mid % 2) && T != S) || (!(mid % 2) && T == S)) {
			lb = mid;
		}
		else {
			ub = mid;
		}
	}
	std::cout << lb << std::endl;
	std::cin >> T;
	return 0;
}


Measured memory_bytes: 852
import java.util.HashSet;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int times = sc.nextInt();  //くじ引きを行った回数
		//重複を許さないHashSetを宣言
		//くじの結果を入れる
		HashSet<String> kuji = new HashSet<String>();

		//くじを行う回数分、結果をkujiに入力する
		for(int i=0 ; i<times ; i++) {
			kuji.add(sc.next());
		}
		System.out.print(kuji.size());
		sc.close();
	}
}


Measured memory_bytes: 71128
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
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;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll t; cin >> t;
    while(t--){
        ll n,m; cin >> n >> m;
        ll a,b; cin >> a >> b;
        cout << floor_sum(n, m, a, b) << "\n";
    }
}

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007

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

  ll K,N; cin>>K>>N;

  vector<ll> A(N); rep(i,N) cin>>A[i];

  vector<ll> dist(N);
  ll maxv = 0;
  rep(i, N) {
    dist[i] = A[(i+1)%N] - A[i%N];
    if(dist[i] < 0) dist[i]+=K;
    maxv = max(maxv, dist[i]);
  }

  cout << K-maxv << endl;

  return 0;
}


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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    int n;
    cin >> n;

    vector<vector<int>> f(n, vector<int>(10));
    vector<vector<int>> p(n, vector<int>(11));
    // cout << f.at(0).size() << f.size() << endl;
    // cout << p.at(0).size() << p.size() << endl;
    for(int i=0;i<n;i++) {
        for(int j=0;j<10;j++) {
            cin >> f.at(i).at(j);
        }
    }
    for(int i=0;i<n;i++) {
        for(int j=0;j<11;j++) {
            cin >> p.at(i).at(j);
        }
    }

    vector<int> nowf(10);
    int count, ans_tmp, ans = -2147483648, memo;
    for(int i=1;i<(1<<10);i++) {
        for(int j=0;j<10;j++) {
            nowf.at(j)=(i>>j)&1;
        }

        ans_tmp = 0;
        for(int j=0;j<n;j++) {
            count = 0;
            for(int k=0;k<10;k++) {
                if(nowf.at(k)==1&&nowf.at(k)==f.at(j).at(k)) count++;
            }
            ans_tmp += p.at(j).at(count);
        }
        ans = max(ans, ans_tmp);
    }
    cout << ans << endl;
    return 0;
}


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

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
const int INF = 1e9;

struct edge{int to,cap,rev;};
const int MAX_V = 1e4;
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
    G[from].push_back({to,cap,(int)G[to].size()});
    G[to].push_back({from,0,(int)G[from].size()-1});
}

int dfs(int v,int t,int f){
    if(v == t) return f;
    used[v] = true;
    rep(i,G[v].size()){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to,t,min(f,e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    
    return 0;
}

int max_flow(int s,int t){
    int flow = 0;
    for(;;){
        memset(used,0,sizeof(used));
        int f = dfs(s,t,INF);
        if(f == 0) return flow;
        flow += f;
    }
}

int n;
vector<int> X,Y;

int main(){
    cin >> n;
    X.resize(2*n);
    Y.resize(2*n);
    rep(i,2*n){
        cin >> X[i] >> Y[i];
    }
    int s = 2*n+1 ,t = 2*n+2;
    rep(i,n){
        add_edge(s,i,1);//s -> 赤い点
        add_edge(i+n,t,1);//青い点-> t
    }
    rep(i,n){
        rep(j,n){
            if(X[i] < X[j+n] && Y[i] < Y[j+n]){
                add_edge(i,j+n,1);
            }
        }
    }
    cout << max_flow(s,t) << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

std::vector<std::vector<long long>> comb(ll n, ll r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

signed main(){
  int N;cin>>N;
  vector<int> arr(N);
  REP(i,0,N)cin>>arr[i];
  sort(ALL(arr));
  int n=arr[N-1];
  int k,diff=abs(arr[N-1]-arr[0]*2);
  REP(i,0,N-1){
    int diff2=abs(arr[N-1]-arr[i]*2);
    if(diff>diff2){
      diff=diff2;
      k=arr[i];
    }
  }
  print(n,k);

}


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

using namespace std;

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

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

    return gcd(b, a%b);
}

const ll L = 1e5+5;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll N, A, B;
    cin >> N >> A >> B;

    cout << min(N*A, B) << endl;


    return 0;
}

Measured memory_bytes: 256
s[9],c[9];main(n,m,b){for(;scanf("%d%d",&m,&n)*m;puts("")){int q[1024]={0},i,t,p=m;for(t=i=1;i<=n;i++){scanf("%s",s,*c=0);i%3||strcat(c,"Fizz");i%5||strcat(c,"Buzz");*c||sprintf(c,"%d",i);for(strcmp(s,c)&&p>1&&(q[t]=p--);q[t=t%m+1];);}for(t=i=1;i<=m;i++)q[i]||(t=!printf(" %d"+t,i));}}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define gc getchar
#define rint register int
#define rep(i,u,z) for(rint i=u;i<=z;++i)
#define reb(i,u,z) for(rint i=u;i>=z;--i)
#define inf 0x7fffffff

using namespace std;
typedef long long ll;

inline int readint(){
	int rt=0,sign=1;
	char ch=gc();
	while(ch<'0'||ch>'9'){
		if(ch=='-')sign=-1;
	    ch=gc();
	}
	while(ch>='0'&&ch<='9'){
		rt=(rt<<3)+(rt<<1)+(ch&15);
		ch=gc();
	}
	return rt*sign;
}
int main(){
	int x=readint();
	if(x==5||x==7||x==3)puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256