akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;
 
#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)
 
template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }
 
 
///////////////
 
#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])
 
template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;
 
int sgn(ld a, ld b = 0) {
    if (a > b + EPS) return 1;
    if (a < b - EPS) return -1;
    return 0;
}
 
ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }
 
int ccw(P a, P b, P c) {
    b -= a;
    c -= a;
    if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise(-1) or counter clockwise(1)
    if (sgn(dot(b, c)) == -1) return 2;            // c--a--b
    if (sgn(norm(b), norm(c)) == -1) return -2;    // a--b--c
    return 0;                                      // a--c--b
}
 
namespace std {
    bool operator < (P a, P b) {
        return sgn(real(a), real(b)) ? real(a) < real(b) : imag(a) < imag(b);
    }
}
G convex_hull(G g, bool strict = true){
    int n = g.size();
    assert(n >= 3);
 
    sort(ALL(g));
    G c(n*2);
    int k = 0;
    REP(i, n) {
        while(
			k>=2 && ccw(c[k-2], c[k-1], g[i]) != 1
			&& (!strict || ccw(c[k-2], c[k-1], g[i]) == -1)
		) k--; // x : {-1, (2, 0)},  o: {1},  ???: {-2}
        c[k++] = g[i];
    }
    int t = k + 1;
	REP(i, n - 1) {
        while (
			k >= t && ccw(c[k - 2], c[k - 1], g[n-2-i]) != 1
			&& (!strict || ccw(c[k - 2], c[k - 1], g[n-2-i]) == -1)
		) k--;
        c[k++] = g[n-2-i];
    }
    c.resize(k-1);
    return c;
}
 
//////////////
 
int main() {
#ifdef INPUT_FROM_FILE
    ifstream cin("sample.in");
    ofstream cout("sample.out");
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
    ll n; cin >> n;
 
    G g(n);
    REP(i,n){
        ld x, y;
        cin >> x >> y;
        g[i] = { x, y };
    }
 
    G g2 = convex_hull(move(g));
    ll under = 10001;
    REP(i, g2.size()) under = min<ll>(under, g2[i].imag());
    ll d = -1;
    REP(i, g2.size()) if (g2[i].imag() == under) if (d == -1 || g2[d].real() > g2[i].real()) d = i;
 
    cout << g2.size() << endl;
    REP(i, g2.size()) cout << (int)g2[(i+d)%g2.size()].real() << " " << (int)g2[(i+d)%g2.size()].imag() << endl;
    return 0;
}

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

using namespace std ; 

int main () { 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	
	int n ; 
	vector <string> s ; 
	cin >> n ; 
	while ( n-- ) {
		string a ; 
		cin >> a ; 
		s.push_back(a) ; 
	}
	int arr[26] ; 
	for ( int i = 'a' ; i <= 'z' ; i ++ ) { 
		char c = i ;
		int minimum = 51 ; 
	for ( auto & str : s ) {
		int x=  count(str.begin(),str.end(),c);
		minimum = minimum < x  ? minimum : x ;
	}
	arr[i-'a'] = minimum ; 
}
	for ( int i = 0 ; i < 26 ; i ++ ) {
		if ( arr[i] != 0 ) {
			for ( int j = 0 ; j < arr[i] ; j ++ ) {
				cout << char(i +'a') ;
			}
		}
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n + 1);
  for (int i = 1; i < n; ++i) {
    int x;
    cin >> x;
    v[x]++;
  }

  for (int i = 1; i <= n; ++i) {
    cout << v[i] << endl;
  }
}


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

int main(){
  char s,ex;
  
  cin >> s;

if(isupper(s)){
ex = 'A';
cout <<  ex<< endl; // 大文字に変換
}else{
ex = 'a';
cout << ex << endl; // 大文字に変換
}
return 0;
}

Measured memory_bytes: 3584
fn main() {
    let n: i32 = read();
    let m: i32 = read();
    let ans = (n-1) * (m-1);
    println!("{}", ans);
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::map<ll, ll> mc;
  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
    mc[va[i]]++;
  }

  ll ans = 0LL;
  std::vector<ll> vv;
  std::map<ll, ll>::iterator it;
  for (it = mc.begin(); it != mc.end(); it++) {
    ll num = it->first;
    ll cnt = it->second;
    if (cnt >= num) ans += cnt - num;
    else ans += cnt;
  }

  print(ans);
  return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

int solve(string& s) {
    int N = s.size();
    int h = N/2;
    int score = 0;
    for (int i=0; i<N; ++i) {
        if (i < N-h) {
            if (s[i] == 'p') --score;
        } else {
            if (s[i] == 'g') ++score;
        }
    }
    return score;
}

int main() {
    string s; cin >> s;
    cout << solve(s) << endl;
    return 0;
}


Measured memory_bytes: 512
N, X = map(int, input().split(' '))
xl = list(map(int, input().strip().split()))
for i in range(len(xl)):
    xl[i]=abs(xl[i]-X)
#print(xl)
ans=0
for i in range(len(xl)-1):
    while True:
        if xl[i]==0:
            break
            #ans = x[i]
        a=xl[i]
        xl[i]=xl[i+1]%xl[i]
        xl[i+1]=a
#    print(xl)

print(xl[len(xl)-1])

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define N 100003
#define endl "\n"

#define trace1(x)             	 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;

using namespace std;


int sum_digits(int n) {
	int sum = 0;
	while (n) {
		sum += n % 10;
		n /= 10;
	}

	return sum;
}

int main() {
	// for fast input output using cin cout
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	// size of array
	// input
	int n, a, b;
	cin >> n >> a >> b;
	long long ans = 0;
	for (int i = 1; i <= n; ++i) {
		int dig_sum = sum_digits(i);
		if (dig_sum <= b && dig_sum >= a)
			ans += i;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

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

  vector<llong> v;
  REP(i,n){
    llong tmp;
    scanf("%lld", &tmp);
    v.pb(tmp);
  }

  sort(ALL(v), greater<llong>());
  llong mx = v[0] / 2;
  llong num = 0;
  llong ans = 0;
  FOR(i,1,n){
    if(v[i] == mx){
      ans = mx;
      break;
    }else if(v[i] > mx){
      if(num < v[0] - v[i]){
        num = v[0] - v[i];
        ans = v[i];
      }
    }else{
      if(num < v[i]){
        num = v[i];
        ans = v[i];
      }
    }
  }

  printf("%lld %lld\n", v[0], ans);
  return 0;
}



Measured memory_bytes: 1400
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------

int n;
int a[100010];
int m[100010];
int mx;
int ans;
int main(){
    cin>>n;
    REP(i,n){
        cin>>a[i];
        m[a[i]]++;
        mx=max(mx,a[i]);
    }

    REP(i,mx+3){
        ans=max(ans,m[i]+m[i+1]+m[i+2]);
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 1024
def resolve():
	N = int(input())
	lst = [input() for _ in range(N)]
	print(f'AC x {lst.count("AC")}')
	print(f'WA x {lst.count("WA")}')
	print(f'TLE x {lst.count("TLE")}')
	print(f'RE x {lst.count("RE")}')
resolve()


Measured memory_bytes: 16220
#include<bits/stdc++.h>
namespace ZDY{
#define ll long long
#define db double
#define Fur(i,x,y) for(int i=x;i<=y;i++)
#define Fdr(i,x,y) for(int i=x;i>=y;i--)
#define in2(x,y) in(x),in(y)
#define in3(x,y,z) in2(x,y),in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
#define cpy(x,y) memcpy(x,y,sizeof(x))
#define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].next)
#define inf 2147483646
}
namespace FAST{
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
namespace fib{char b[300000]= {},*f=b;}
inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
inline void in(int &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}struct foce{~foce(){pob;fflush(stdout);}} _foce;namespace ib{char b[100];}
inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}inline void outn(ll x){out(x);pc('\n');}
inline void out(int x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}inline void outn(int x){out(x);pc('\n');}
inline char sc(){char c=gc;while(!(('A'<=c&&c<='Z')||('a'<=c&&c<='z')||('0'<=c<='9')))c=gc;return c;}
}using namespace FAST;using namespace ZDY;using namespace std;
#define N 101
int a[N],n,ans=0;
int main(){
	in(n);
	Fur(i,1,n)in(a[i]);
	Fur(i,2,n)if(a[i]==a[i-1])ans++,i++;
	outn(ans);
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin >> v[i];
    for(int i=n-1;abs(i) < n; i -= (n%2==0&&i==1 || n%2==1&&i==0) ? 1 : 2){
        cout << v[abs(i)] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
N = input()
A = map(int, raw_input().split())

mi = -1
mv = -1

for i in xrange(N):
    if abs(A[i]) > mv:
        mv = abs(A[i])
        mi = i

if mv == 0:
    print 0
    exit()

ans = []

for i in xrange(N):
    if i != mi:
        ans.append((mi+1, i+1))

if A[mi] > 0:
    for i in xrange(N-1):
        ans.append((i+1, i+2))
else:
    for i in xrange(N-1, 0, -1):
        ans.append((i+1, i))

print len(ans)
for a, b in ans:
    print a, b


Measured memory_bytes: 28780
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <array>

using namespace std;

int A[51];
int n,m,p,c;

int main(){
    while(true){
        cin >> n >> m;
        if(n+m == 0)break;
        for(int i = 0;i < n;i++)A[i] = n - i;
        for(int i = 0;i < m;i++){
            cin >> p >> c;
            rotate(A,A+p-1,A+p+c-1);
//            for(int k = 0;k < n;k++){
//                cout << A[k] << " ";
//            }
//            cout << endl;
        }
        cout << A[0] << endl;
    }
}

Measured memory_bytes: 3004
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else

#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n; scanf("%d",&n);
	int dp[n][3];
	memset(dp,MOD,sizeof(dp));
	scanf("%d%d%d",&dp[0][0],&dp[0][1],&dp[0][2]);
	for(int i=1;i<n;i++) {
			int a,b,c;
			scanf("%d%d%d",&a,&b,&c);
			dp[i][0] = a + max(dp[i-1][1],dp[i-1][2]);
			dp[i][1] = b + max(dp[i-1][0],dp[i-1][2]);
			dp[i][2] = c + max(dp[i-1][0],dp[i-1][1]);
	}
	printf("%d",max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])));
	

	return 0;
}





Measured memory_bytes: 1408
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; ++i) {
			for (int j = i + 1; j < N; ++j) {
				if (Math.abs(A[i] - A[j]) % (N - 1) == 0) {
					System.out.println(A[i] + " " + A[j]);
					return;
				}
			}
		}
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

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

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}



Measured memory_bytes: 25036
#include<stdio.h>
main(){
  int m,f,r,p;
  while(1){
    scanf("%d%d%d",&m,&f,&r);
    if(m==-1&&f==-1&&r==-1)
      break;
    p=m+f;
    if(m==-1||f==-1)
      printf("F\n");
    else if(p>=80)
      printf("A\n");
    else if(65<=p&&p<80)
      printf("B\n");
    else if(50<=p&&p<65)
      printf("C\n");
    else if(30<=p&&p<50){
      if(50<=r)
	printf("C\n");
      else
	printf("D\n");
    }
    else if(p<30)
      printf("F\n");
  }
  return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n, r;
    cin >> n >> r;
    cout << max(r, r + 100 * (10 - n));
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int value[] = new int[num];
        int cost[] = new int[num];
        int sumValue = 0;
        int sumCost = 0;

        for (int i = 0; i < num; i++) {
           value[i] = sc.nextInt(); 
        }
        for (int i = 0; i < num; i++) {
           cost[i] = sc.nextInt(); 
        }
        sc.close();
        for (int i = 0; i < num; i++) {
           if (value[i] - cost[i] > 0) {
               sumValue += value[i];
               sumCost += cost[i];
           }
        }
        System.out.println(sumValue - sumCost);
    }
}

Measured memory_bytes: 23124
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
using namespace std;

long long int h[100005],p[100005];

int main(){
	
	int d,n,m;
	while(1){
	cin>>d;
	if(d==0)break;
	cin>>n>>m;
	int sh[100006];
	sh[n]=d;
	sh[0]=0;
	for(int i=1;i<n;i++){
		cin>>sh[i];
	}
	sort(sh,sh+n);
	int ans=0;
	for(int i=0;i<m;i++){
		int x;
		cin>>x;
		int r=n,w=0;
		while(r-w>0){
			if(r-1==w)break;
			if(sh[w+(r-w)/2]==x)r=w=w+(r-w)/2;
			else if(sh[w+(r-w)/2]<x)w=w+(r-w)/2;
			else r=w+(r-w)/2;
		}
		if(abs(x-sh[w])>abs(sh[r]-x))ans+=abs(sh[r]-x);
		else ans+=abs(x-sh[w]);
	}
	cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 1564
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  long long N, T;
  long long ttl = 0;
  long long ans = 0;
  string s;

  cin >> N >> T;

  vector<long long> t(N);
  for(int i = 0; i < N; i++){
    cin >> t[i];
  }
  for(int i = 0; i < N; i++){
    if(i == (N-1)){
      ans += T;
      continue;
    }
    if(t[i+1] < (ttl+T)){
      ans += (t[i+1]-t[i]);
    }else{
      ans += T;
    }
    ttl+=(t[i+1]-t[i]);
  }

  cout << ans << endl;

}


Measured memory_bytes: 1792
n, m = map(int, input().split())
r = [0, 1]
mod = 1000000007
a = []
for i in range(m):
  a.append(int(input()))
j = 0
for i in range(n):
  if j < m and i == a[j] - 1:
    r = [r[1], 0]
    j += 1
  else:
    r = [r[1], (r[0] + r[1]) % mod]
print(r[-1])

Measured memory_bytes: 7056
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

LL a[200010];
LL b[200010];
int main(){
	LL n;
	cin>>n;
	LL ans=0;
	for(LL i=0;i<n;i++){cin>>a[i];a[i]+=i;b[i]=a[i];}
	sort(b,b+n);
	
	for(LL i=0;i<n;i++)
	{
		LL x=2*i-a[i]; 
		ans+=(LL)(upper_bound(b,b+n,x)-lower_bound(b,b+n,x));
		//cout<<(LL)(upper_bound(b,b+n,x)-lower_bound(b,b+n,x))<<"\n";
	}
	cout<<ans<<"\n";
	return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;

  scanf("%d", &n);

  vector<int> v(n);
  REP (i, n) {
    scanf("%d", &v[i]);
  }

  LL ans = 0;
  REP (i, n) {
    ans += v[i] / 2;
    if (v[i] % 2 == 0) {
      v[i] = 0;
    } else if (i < n - 1 && v[i + 1] > 0) {
      ans++;
      v[i] = 0;
      v[i + 1] -= 1;
    }
  }

  printf("%lld\n", ans);
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  ll K;
  cin >> K;
  vector<ll> A;
  for(ll i=0; i<K; i++){
    ll in;
    cin >> in;
    A.push_back(in);
  }
  reverse(A.begin(), A.end());
  ll N[K+1][2];
  N[0][0] = N[0][1] = 2;
  for(ll i=0; i<K+1; i++){
    ll tmpA = A[i];
    ll min = N[i][0], max = N[i][1];
    if(ceil(min*1.0/tmpA) > floor(max*1.0/tmpA)){
      cout << -1 << endl;
      return 0;
    } else {
      N[i+1][0] = tmpA*ceil(N[i][0]*1.0/tmpA);
      N[i+1][1] = tmpA*floor(N[i][1]*1.0/tmpA)+tmpA-1;
    }
  }
  cout << N[K][0] << ' ' << N[K][1] << endl;
  return 0;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()

{

    ll n, k;
    cin >> n >> k;
    vector<ll > v;
    k--;
    ll idx = 0;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
        if(x==1) idx = i;
    }
    ll cnt1 = 0, cnt2 = 0, i = 0;
    while(1)
    {

        if(i+k>=n)
        {

            if(i < n-1) cnt1++;
            break;
        }
        i+=k;
        cnt1++;
    }
    cout << cnt1+cnt2;
}


Measured memory_bytes: 1400
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
import random
import time
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def scorei(ti, i, last, minus):
        k = [i for i in last]
        mi = minus-(i+1-last[ti])*c[ti]
        v = s[i][ti]-mi
        mi += sum_
        k[ti] = i+1
        return v, k, mi

    def score(t):
        n = 26
        v = 0
        minus = sum_ = sum(c)
        last = [0]*n
        for i in range(d):
            ti = t[i]-1
            minus -= (i+1-last[ti])*c[ti]
            v += s[i][ti]-minus
            minus += sum_
            last[ti] = i+1
        return v
    start = time.time()
    d = I()
    c = LI()
    s = LIR(d)
    n = 26
    m = 10000
    sum_ = sum(c)
    q = [(0, 0, [0]*n, sum_)]
    pre = [[None]*n for i in range(d)]
    sc = [[float("inf")]*n for i in range(d)]
    argmax = 0
    for i in range(d):
        nq = []
        for _ in range(m):
            if not q:
                break
            v, x, last, minus = heappop(q)
            if i > 0 and v > sc[i-1][x]:
                continue
            for ti in range(n):
                vi,nl,nm = scorei(ti,i,last,minus)
                nv = v-vi
                heappush(nq,(nv,ti,nl,nm))
                if sc[i][ti] > nv:
                    sc[i][ti] = nv
                    pre[i][ti] = x
        q = [i for i in nq]
    t = []
    argmax = 0
    m = sc[-1][0]
    for i in range(1,n):
        sci = sc[-1][i]
        if m > sci:
            m = sci
            argmax = i
    t.append(argmax)
    x = argmax
    for i in range(1,d)[::-1]:
        y = pre[i][x]
        t.append(y)
        x = y
    t = [i+1 for i in t[::-1]]
    v = score(t)
    i = 0
    while time.time() < 1.5+start:
        nt = [i for i in t]
        r = random.randrange(1,n+1)
        nt[i] = r
        nv = score(nt)
        if v < nv:
            t = [i for i in nt]
            v = nv
        i += 1
        i %= d
    for i in t:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 117272
data=input().rstrip().split()
n=int(data[0])
ans=[0 for i in range(n)]
m=int(data[1])

for i in range(m):
  data=input().rstrip().split()
  ans[int(data[0])-1]+=1
  ans[int(data[1])-1]+=1
for j in range(n):
	print(ans[j])


Measured memory_bytes: 3060
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

int n;
string s;
int a[MAXN];

int check() {
	for (int i=0; i<n; i++) {
		int pre = (i - 1);
		if (pre < 0) pre += n;
		int nxt = (i + 1) % n;
		if (a[i] == 1) {
//			if (a[0] == 1 && a[1] == 0) cout << a[nxt] << " "<< a[pre] << endl;
			if (s[i] == 'o' && a[nxt] != a[pre]) return 0;
			if (s[i] == 'x' && a[nxt] == a[pre]) return 0;
		}
		else {
			if (s[i] == 'o' && a[nxt] == a[pre]) return 0;
			if (s[i] == 'x' && a[nxt] != a[pre]) return 0;
		}
	}
	return 1;
}

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	cin >> n;
	cin >> s;
	
	for (int B=0; B<4; B++) {
		a[0] = B & 1;
		a[1] = (B >> 1) & 1;
//		cout << a[0] << " "<< a[1] << endl;
		for (int i=1; i<n; i++) {
			if (s[i] == 'o') {
				int nxt = (i + 1) % n;
				if (a[i] == 1) a[nxt] = a[i - 1];
				else a[nxt] = a[i - 1] ^ 1;
			}
			else {
				int nxt = (i + 1) % n;
				if (a[i] == 1) a[nxt] = a[i - 1] ^ 1;
				else a[nxt] = a[i - 1];
			}
		}
		if (check()) {
			for (int i=0; i<n; i++) cout << (a[i] ? 'S':'W');
			return 0;
		}
	}
	
	cout << -1;


}


Measured memory_bytes: 896
n = gets.chomp.to_i
list = gets.chomp.split(' ').map(&:to_i).sort
count = 0
n.times do |i|
  (i+1..(n-1)).each do |j|
    (j+1..(n-1)).each do |k|
      if list[i] != list[j] && list[j] != list[k] && list[i] != list[k] && list[i] + list[j] > list[k]
        count += 1
      end
    end
  end
end

print count

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


int a[102];

int main() {
    int n,x;
    cin >> n >> x;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    int ans = 0;
    for(int i=0;i<n;i++){
        if(a[i]>x)break;
        ans++;
        x-=a[i];
    }
    if(ans==0){
        cout << 0;
        return 0;
    }
    if(x>0&&ans==n)cout << ans-1;
    else cout << ans;
    return 0;
}


Measured memory_bytes: 256
def compute_divisors(x):
    # https://atcoder.jp/contests/abc106/submissions/3028544
    divisors = set()
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            divisors.add(i)
            divisors.add(x // i)
    return divisors

N = int(input())
c = 0

for i in range(1, N+1, 2):
    if len(compute_divisors(i)) == 8:
        c += 1
print(c)


Measured memory_bytes: 3060
keys = { 1 => [".", ",", "!", "?", " "],
         2 => ["a", "b", "c"],
         3 => ["d", "e", "f"],
         4 => ["g", "h", "i"],
         5 => ["j", "k", "l"],
         6 => ["m", "n", "o"],
         7 => ["p", "q", "r", "s"],
         8 => ["t", "u", "v"],
         9 => ["w", "x", "y", "z"]
       }

casenum = gets.to_i
casenum.times do
  s = gets.chomp.split(//).map &:to_i
  result = ""
  cur = nil
  index = 0
  s.each do |i|
    if i == 0
      result += keys[cur][index] unless cur.nil?
      cur = nil
      index = 0
      next

    else
      unless cur.nil?
        index += 1
        index = 0 if index == keys[cur].length
      end

      cur = i
    end
  end

  puts result
end

Measured memory_bytes: 6144
def main():
  ss = list(input())
  c = 0
  for i in range(len(ss)):
    if i % 2 == 0 and ss[i] == 'L':
      print('No')
      break
    elif i % 2 == 1 and ss[i] == 'R':
      print('No')
      break
    else:
      c += 1
  if c == len(ss):
    print('Yes')


if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    s = input()
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle += 1
    elif s == 'RE':
        re += 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

Measured memory_bytes: 9544
import Debug.Trace

main = do
    [n,p] <- map read . words <$> getLine :: IO [Int]
    let candMax =  ceiling $ (fromIntegral p) ** (1 / (fromIntegral n))
    print $ solve p n candMax

solve :: Int -> Int -> Int -> Int
solve p n i 
    | i == 1 = 1 
    | isAns = i
    | otherwise = solve p n (i-1)
    where  
        isAns = avoidOverFlow p n i n

avoidOverFlow :: Int -> Int -> Int -> Int -> Bool
avoidOverFlow p n i k
    | k == 0 = True
    | amari /= 0 = False
    | amari == 0 = avoidOverFlow shou n i (k-1)
    where 
        amari = p `mod` i
        shou = p `div` i

Measured memory_bytes: 508
import java.util.Scanner;

class Main {
    public static int solve(int a, int b) {
        return a * b;
    }
    public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int a = sn.nextInt();
        int b =  sn.nextInt();
        System.out.println(solve(a, b));
    }
}

Measured memory_bytes: 35780
#include<bits/stdc++.h>
#define F first
#define S second
#define INF (1e9)
#define N 5
using namespace std;

typedef pair<vector<string>,int> P;
typedef pair<int,int> P1;
typedef pair<P,P1> P2;

vector<string> s;
int n, sy, sx;

bool check(vector<string> grid){

  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      if(grid[i][j]=='#')return false;

  return true;
}

vector<string> infect(vector<string> grid){
  
  vector<string> res(n,string(n,'x'));
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      
      int cnt=0;
      
      for(int k=-1;k<=1;k++){
	for(int l=-1;l<=1;l++){
	  
	  if(k==0&&l==0)continue;
	  
	  int ni=i+k,nj=j+l;
	  	  
	  if(ni<0||nj<0||n<=ni||n<=nj)continue;
	  if(grid[ni][nj]!='.')cnt++;
	}
      }
      
      if(grid[i][j]=='@') res[i][j]='@';
      else if(grid[i][j]=='.'){
	if(cnt==3) res[i][j]='#';
	else res[i][j]='.';
      }else{
	if(cnt==2||cnt==3) res[i][j]='#';
	else res[i][j]='.';
      }
      
    }
  }
  
  return res;
}

int bfs(){
  
  map<vector<string>,int> memo;
  queue<P2> q;
  
  q.push(P2(P(s,0),P1(sy,sx)));
  memo[s]=0;
  
  while(!q.empty()){

    P2 t=q.front(); q.pop();
    
    vector<string> grid=t.F.F;
    
    int cost=t.F.S, y=t.S.F, x=t.S.S;
    
    if(check(grid))return cost;
    
    for(int i=-1;i<=1;i++){
      for(int j=-1;j<=1;j++){

	if(i==0&&j==0)continue;
	
	int ncost=cost+1, ny=y+i, nx=x+j;
	
	if(ny<0||nx<0||n<=ny||n<=nx)continue;
	if(grid[ny][nx]=='#')continue;
	
	vector<string> ngrid=grid;
	
	swap(ngrid[y][x],ngrid[ny][nx]);
	
	ngrid=infect(ngrid);
	
	if(memo.count(ngrid))continue;

	memo[ngrid]=ncost;
	q.push(P2(P(ngrid,ncost),P1(ny,nx)));
	
      }
    }
  }
  
  return INF;
}

int main(){
  
  while(1){
    
    cin>>n;
    if(!n)break;
    
    s.resize(n);
    
    for(int i=0;i<n;i++){
      cin>>s[i];
      
      for(int j=0;j<n;j++)
	if(s[i][j]=='@')sy=i,sx=j;
      
    }
    
    int ans=bfs();
    
    cout<<(ans==INF?-1:ans)<<endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 10652
// Akshit Awasthi
#include <bits/stdc++.h>
#define int long long
#define float long double
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define all(x) x.begin(), x.end()
#define deb(...) cerr << "[" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "]\n"
#define deb2(x, y) cerr << #x << " = " << x << "\t" << #y << " = " << y << endl
#define fastio                    \
    std::ios::sync_with_stdio(0); \
    std::cin.tie(NULL);           \
    std::cout.tie(NULL)
#define mod1 1000000007
#define mod2 998244353
#define mod mod1
#define MAX 200015
using namespace std;

template <class T>
istream& operator>>(istream& stream, vector<T>& v) {
    for (int i = 0; i < (int)v.size(); i++) stream >> v[i];
    return stream;
}
template <class T1, class T2>
istream& operator>>(istream& stream, pair<T1, T2>& p) {
    return stream >> p.first >> p.second;
}
template <class T>
ostream& operator<<(ostream& stream, const vector<T>& v) {
    for (int i = 0; i < (int)v.size(); i++) stream << v[i] << ' ';
    stream << '\n';
    return stream;
}
template <class T1, class T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& pair) {
    return stream << pair.first << ' ' << pair.second;
}
int pow(int a, int n) {
    if (n < 0) return 0;
    int ans = 1;
    while (n) {
        if (n & 1) ans = ans * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ans;
}
int __lcm(int a, int b) { return (a / __gcd(a, b)) * b; }
int fact(int n) { return n == 0 ? 1LL : n * fact(n - 1) % mod; }
int inverse(int x, int p = mod) { return pow(x, p - 2); }
int nck(int n, int k, int p = mod) {
    return fact(n) * inverse(fact(k), p) % p * inverse(fact(n - k)) % p;
}

void solve(void) {
    int n, k;
    cin >> n >> k;
    vector<int> arr(n);
    cin >> arr;
    int l = 1, r = 1e9;
    int ans = INT_MAX;
    while (l <= r) {
        int mid = ((l + r) / 2.0);
        int tempk = 0;
        for (int i = 0; i < n; i++) {
            tempk += (arr[i] - 0.01) / mid;
        }
        if (tempk <= k) {
            ans = min(ans, mid);
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    cout << ans;
}

int32_t main(void) {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
    fastio;
    // cout.setf(std::ios::unitbuf);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve();
    }
    return 0;
}

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

#define MAX_N 1000000
int dp[MAX_N], N, a[MAX_N];

int main() {
	cin >> N; int cnt = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (cnt == 0) { dp[cnt] = a[i]; cnt++; }
		else {
			if (dp[cnt - 1] < a[i]) {
				dp[cnt] = a[i];
				cnt++;
			}
			else {
				int squirrel = lower_bound(dp, dp + cnt, a[i]) - dp;
				dp[squirrel] = a[i];
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 5640
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String bus = scanner.next();
		
		if(bus.equals("AAA") || bus.equals("BBB")){
        	System.out.println("No");
        }else{
        	System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 35740
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  vector<int> a(N);
  rep(i, N) { cin >> a[i]; }
  vector<int> b(a);
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());

  if (N % 3 != 0) {
    cout << (b.size() == 1 && b[0] == 0 ? "Yes" : "No") << endl;
  } else {
    if (b.size() <= 3) {
      vector<int> cnt(b.size(), 0);
      rep(i, N) { cnt[lower_bound(b.begin(), b.end(), a[i]) - b.begin()]++; }
      int s = 0;
      rep(i, b.size()) {
        if (cnt[i] % (N / 3) != 0) {
          cout << "No" << endl;
          return 0;
        } else {
          rep(j, cnt[i] / (N / 3)) { s = s ^ b[i]; }
        }
      }
      cout << (s == 0 ? "Yes" : "No") << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4032
#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,a,b;cin>>n>>a>>b;
    int ca = 0;
    int cb = 0;
    string s;cin>>s;
    rep(i,n){


        if(s[i]=='a' && (ca + cb < a + b)){
          ++ca;
          cout<<"Yes"<<endl;

        }
        else if(s[i]=='b' && (ca + cb < a + b) && (cb < b)){
          ++cb;
          cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;        
    }
	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  string s;
  cin >> s;
  //if(x=='a'||x=='i'||x=='u'||x=='e'||x=='o')){cout << "vowel" << endl;}
  //elsse{cout << "consonant" << endl;}
  cout << s.substr(0,5) << ' ' << s.substr(6, 7) << ' ' << s.substr(14,5) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

s = ins()
t = ins()
print("Yes" if s == t[:-1] else "No")

Measured memory_bytes: 9060
import java.util.Random;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Random rand = new Random();

        String nickName = sc.nextLine();

        try {
            if(nickName.length() < 3 || nickName.length() > 20)
                throw new Exception("文字数が不正です。");
            if(!nickName.matches("^[A-Za-z]+$"))
                throw new Exception("文字が不正です。");
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
        int x = rand.nextInt(nickName.length() - 2);

        System.out.println(nickName.substring(x, x + 3));
    }
}

Measured memory_bytes: 35508
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<(n);i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<iostream>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>
using namespace std;
typedef long long ll;


int dp[101][4][4][4];
long l=1000000007;

int main(void){
    int n;
    cin>>n;
    dp[0][3][3][3]=1;

    rep(len, n){
        rep(i, 4){
            rep(j, 4){
                rep(k, 4){
                    if(dp[len][i][j][k]==0) continue;
                    rep(a, 4){
                        if(a==2&&i==1&&j==0) continue;
                        if(a==2&&i==0&&j==1) continue;
                        if(a==1&&i==2&&j==0) continue;
                        if(a==2&&i==1&&k==0) continue;
                        if(a==2&&j==1&&k==0) continue;
                        dp[len+1][a][i][j]+=dp[len][i][j][k];
                        dp[len+1][a][i][j]%=l;
                    }
                  
                }
            }
        }

    }
ll ans=0;
    rep(i, 4){
        rep(j, 4){
            rep(k, 4){
                ans+=dp[n][i][j][k];
                ans%=l;
            }
        }
    }

cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int F(int a, int b) {
  int x = 1;
  for (int i = 0; i < b; i++) {
    x = x * a;
  }
  return x;
}
int main() {
  int64_t N, K;
  cin >> N >> K;
  cout << K * F(K-1,N-1) << endl;
}


Measured memory_bytes: 256
ar = list(map(int,input().split(" ")))
br = [ar[0] * 8,ar[1] * 4,ar[2] * 2,ar[3]]
a = int(input())
ar[0] *= 4
ar[1] *= 2
del ar[3]
count = 0
if a >= 2:
    count += min(br) * (a // 2)
    if a % 2 == 1:
        count += min(ar)
else:
    count += min(ar)
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define MAXR	16
#define MAXN	256
#define MAXE	(MAXN<<1)
#define inf	(0x7fffffff)
typedef long long int ll;
ll d[2][MAXN][MAXN];

int N, M, R;
int r[MAXR];
int main(void)
{
  int i, j, k;
  for(i = 0;i < MAXN;++i)
    for(j = 0;j < MAXN;++j)
      d[0][i][j] = inf;
  scanf("%d%d%d", &N, &M, &R);
  for(i = 0;i < R;++i)
    scanf("%d", r+i);
  while(M--)
  {
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    d[0][A][B] = d[0][B][A] = C;
  }
  for(k = 1;k <= N;++k)
  {
    int ci = k&1; int op = ci ^ 1;
    for(i = 1;i <= N;++i)
      for(j = 1;j <= N;++j)
        d[ci][i][j] = min(d[op][i][j], d[op][i][k]+d[op][k][j]);
  }
  int ans = inf;
  sort(r, r+R);
  do
  {
    int t = 0;
    for(i = 1;i < R;++i)
      t += d[N&1][r[i-1]][r[i]];
    ans = min(ans, t);
  }while(next_permutation(r, r+R));
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1152