akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n, m;
  cin >> n >> m;
  vector<pll> a(n);
  for(ll i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  sort(all(a));

  ll ans = 0;
  for(ll i = 0; i < n; i++){
    if(m <= a[i].second){
      ans += a[i].first * m;
      break;
    }else{
      ans += a[i].first * a[i].second;
      m -= a[i].second;
    }
    //cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

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


int main() {
    int N;
    string S, T;
    cin >> N >> S >> T;
    string ans = "";
    for (int i = 0;i < N; i++) {
        ans += S.at(i);
        ans += T.at(i);
    }
    cout << ans << endl;
}




Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < 50000; i++) {
        if (floor(i * 1.08 - i) == a && floor(i * 1.1 - i) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip() 
import bisect

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    A.sort()
    C.sort()

    ans = 0
    for b in B:
        a_r = bisect.bisect_left(A, b)
        c_l = bisect.bisect_right(C, b)
        ans += a_r * (N - c_l)

    print(ans)

if __name__ == '__main__':
    resolve()


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

int main(void){
    int sx,sy,tx,ty,dx,dy;
    cin>>sx>>sy>>tx>>ty;
    dx = tx-sx;
    dy = ty-sy;

    string ans = "";
    ans += string(dy,'U');
    ans += string(dx,'R');
    ans += string(dy,'D');
    ans += string(dx,'L');
    ans += 'L';
    ans += string(dy+1,'U');
    ans += string(dx+1,'R');
    ans += "DR";
    ans += string(dy+1,'D');
    ans += string(dx+1,'L');
    ans += 'U';
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    double res = 0;
    for(int i = 1; i <= N; i++) {
        int cnt = 0;
        int now = i;
        while(now < K) {
            now *= 2;
            cnt++;
        }
        res += (1 / (double)N) * (pow((1 / 2.0), (double)cnt));
    }
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

long long int gcd(long long int x, long long int y);

int main(int argc, char const *argv[]) {
    long long int x;
    long long int y;

    scanf("%lld", &x);
    scanf("%lld", &y);

    printf("%lld\n", gcd(x, y));

    return 0;
}

long long int gcd(long long int x, long long int y) {
    if (x < y) {
        long long int temp = x;
        x = y;
        y = temp;
    }

    long long int mod = 0;
    while (y > 0) {
        mod = x % y;
        x = y;
        y = mod;
    }
    return x;
}


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

int main()
{
    ll N;
    cin >> N;
    ll A[N];
    map<ll,ll> mp;
    for(ll i = 0; i < N; i++)
    {
        cin >> A[i];
        mp[A[i]]++;
    }

    ll count = 0;

    for(auto e:mp)
    {
        count += (e.second)*(e.second - 1)/2;
    }

    for(ll i = 0; i < N; i++)
    {
        ll tmpCount = count;
        tmpCount -= mp[A[i]]-1;
        cout << tmpCount << endl;
    }

    return 0;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
const int uchiha=1e3+5;
int arr[uchiha];
int main(){
int n,c1=0,c2=0;
cin>>n;
for(int i=0;i<n;i++){
    cin>>arr[i];
}
sort(arr,arr+n,greater<int>());
for(int i=0;i<n;i+=2){
    c1+=arr[i];
    c2+=arr[i+1];
}
cout<<abs(c1-c2);
}

Measured memory_bytes: 256
k,n = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
diff = []
(1...n).each do |i|
  diff << a[i] - a[i-1]
end
diff << (a[0] + (k - a[-1]))
sum = diff.inject(:+) - diff.max
puts sum

Measured memory_bytes: 17028
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
int main() {
	int k,n;
	cin>>k>>n;
	int arr[n];
	int check=0;
	ll sum=0;
	//int pos=0;
	for(int i=0;i<n;i++)
	{
	    cin>>arr[i];
	}
	check=arr[0]+(k-arr[n-1]);
	for(int i=1;i<n;i++)
	{
	    if((arr[i]-arr[i-1])>check)
	    check=(arr[i]-arr[i-1]);
	}
	cout<<k-check<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int n,m;
int ff[31];
int a;
int ans=0;
int main(){
	cin >> n >> m;
	for(int i=0;i<n;i++){
		int k;
		cin >> k;
		for(int j=0;j<k;j++){
			cin >> a;
			ff[a]++;
		}
	}
	for(int i=1;i<=m;i++){
		if(ff[i]==n) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, K;
    cin >> N >> K;
    cout << (N % K != 0 ? 1 : 0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e9;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll q,h,s,d,n;
    cin >> q >> h >> s >> d >> n;
    s = min({q*4,h*2,s});
    if (s*2 <= d){
        PRINT(n*s);
    }
    else{
        PRINT(n/2*d+n%2*s);
    }
}


Measured memory_bytes: 256
#import<iostream>
#import<vector>
using namespace std;main(){for(int n,m,d,i;cin>>n,i=n;){string s[20];vector<int>v[20],c(30);pair<int,string>a(1e9,"");for(;i--;)for(cin>>s[i]>>m;m--;++c[d],v[i].push_back(d))cin>>d;for(;++i<n;a=min(a,make_pair(m,s[i])))for(m=d=0;d<v[i].size();)m-=c[v[i][d++]]+~n;cout<<a.first<<' '<<a.second<<endl;}}

Measured memory_bytes: 0
require "prime"
n = gets.to_i

prime = Prime.each(55555).to_a

# 5個選んだ合計が合成数
# => 1の位の合計が 0,5 なら素数ではない = 合成数
# =>

puts prime.select{|num| num % 10 == 1}.take(n).join(" ")

Measured memory_bytes: 2680
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
int main(void){
     
    //変数：2点を「 x1, y1 と x2, y2 」と置く
    double x1, y1, x2, y2;
    
    //入力：2点を「 x1, y1 と x2, y2 」を入力
    cin >> x1 >> y1 >> x2 >> y2;
    
    //出力：三平方の定理で √ (x1-x2)^2 + (y1-y2)^2
   printf("%.8f\n", sqrt(pow(x1-x2, 2) + pow(y1-y2,2)));
    
}


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

using namespace std;

int main(){
	int n,m;
	while(cin >> n >> m && !(n == 0 && m == 0)){
		int taro[101];
		int hanako[101];

		int sumOfTaro=0;
		int sumOfHanako=0;
		for(int i = 0; i < n; i++){
			cin >> taro[i];
			sumOfTaro += taro[i];
		}
		for(int i = 0; i < m; i++){
			cin >> hanako[i];
			sumOfHanako += hanako[i];
		}
		bool b = false;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				if(sumOfTaro - taro[i] + hanako[j] == sumOfHanako - hanako[j] + taro[i]){
					cout << taro[i] << " " << hanako[j] << endl;
					b = true;
					break;
				}
			}
			if(b)
				break;
		}
		if(!b)
			cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  bool f[1001]={};
  f[1] = true;
  for(int i=2;i<=1000;i++){
    for(int j=2;pow(i,j)<=1000;j++){
      f[(int)pow(i,j)] = true;
    }
  }
  int n,ans = 1;
  cin >> n;
  for(int i=1;i<=n;i++){
    if(f[i])
      ans = max(ans,i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	int n;

	cin >> n;
	
	int cnt2 = 0;

	for (int i = 1; i <= n; i += 2) {
		int cnt = 0;

		for (int k = 1; k <= i; k++) {
			if (i%k == 0)cnt++;
		}
		//cout << "i->"<< i << "cnt->" << cnt << endl;
		if (cnt == 8)cnt2++;
	}

	cout << cnt2 << endl;


	return 0;
}

Measured memory_bytes: 256
from collections import Counter
N =int(input())
A = Counter(list(map(int,input().split())))
B = Counter(list(map(int,input().split())))
C = Counter(list(map(int,input().split())))
A_sort = sorted(A.items())
B_sort = sorted(B.items())
C_sort = sorted(C.items())

BtoC = []
ans = 0
start_j = 0
start_k = 0
sum_val = N
for j in range(len(B_sort)):
    for k in range(start_k , len(C_sort)):
        if B_sort[j][0] >= C_sort[k][0]:
            sum_val -= C_sort[k][1]
            start_k = k + 1
        else:
            BtoC.append([B_sort[j][0] , sum_val * B_sort[j][1]])
            break
#print(BtoC)
work = 0
for i in range(len(BtoC) - 2 , -1 , -1):
    BtoC[i][1] = BtoC[i+1][1] + BtoC[i][1]
    work = BtoC[i+1][1]
#print(BtoC)
for i in range(len(A_sort)):
    for j in range(start_j , len(BtoC)):
        if A_sort[i][0] >= BtoC[j][0]:
            start_j = j + 1
        else:
            ans += A_sort[i][1] * BtoC[j][1]
            break
print(ans)

Measured memory_bytes: 67320
#include <algorithm>
#include <iostream>

using namespace std;

constexpr static int MAXN = 1e6;
int64_t a[MAXN];

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

    int64_t mindiff = 1e18;
    for (int sgn : {-1, 1}) {
        int64_t sum = 0;
        int64_t diff = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
            if (sgn == -1 && sum >= 0) {
                diff += abs(sum + 1);
                sum = -1;
            }
            else if (sgn == 1 && sum <= 0) {
                diff += abs(sum - 1);
                sum = 1;
            }
            sgn *= -1;
        }
        mindiff = min(mindiff, diff);
    }
    cout << mindiff << endl;
}

Measured memory_bytes: 1024
N = int(input())
ans = [0 for i in range(N)]

for i in range(N-1):
  C, S, F = map(int, input().split())
  for j in range(0, i+1):
    if ans[j] < S:
      ans[j] += S - ans[j]
    elif ans[j]%F != 0:
      ans[j] += F - ans[j]%F
    ans[j] += C
    
for i in ans:
  print(i)



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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define PB push_back
#define MP make_pair
// #define F first
// #define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl


int main() {
    ll H;
    cin >> H;
    ll sum = 1;
    ll n = 1;
    while(H!=1) {
        H = H/2;
        sum += pow(2,n);
        n += 1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

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

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    int h,a;
    cin >> h >> a;
    if(h%a == 0){
        cout << h/a << endl;
        return 0;
    }else{
        cout << h/a+1 << endl;
    }
    return 0;
}


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

#define se second
#define fi first
#define mk(a,b) make_pair(a,b)

typedef long long ll;

int N;
string S;
map<pair<string,string>,ll> mp1[20],mp2[20];

int main()
{
    scanf("%d",&N);
    cin >> S;

    mp1[0][mk("","")] = 1;
    for(int i = 0; i < N; i++)
    {
        for(auto ite = mp1[i].begin(); ite != mp1[i].end(); ite++)
        {
            string S1 = (ite->fi).fi,S2 = (ite->fi).se;
            ll tmp = ite->se;
            mp1[i + 1][mk(S1 + S[i],S2)] += tmp;
            mp1[i + 1][mk(S1,S2 + S[i])] += tmp;
        }
    }
    reverse(S.begin(),S.end());
    mp2[0][mk("","")] = 1;
    for(int i = 0; i < N; i++)
    {
        for(auto ite = mp2[i].begin(); ite != mp2[i].end(); ite++)
        {
            string S1 = (ite->fi).fi,S2 = (ite->fi).se;
            ll tmp = ite->se;
            mp2[i + 1][mk(S1 + S[i],S2)] += tmp;
            mp2[i + 1][mk(S1,S2 + S[i])] += tmp;
        }
    }

    ll ans = 0;
    for(auto ite = mp1[N].begin(); ite != mp1[N].end(); ite++)
    {
        ans += (mp2[N][ite->fi]) * (ite->se);
    }

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


Measured memory_bytes: 136960
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
 int a, b;
 int result[1001];
 char op;
 int i = 0;
 while(scanf("%d %c %d", &a, &op, &b), op!='?')
 {
  switch(op)
  {
   case '+':
    result[i++] = a + b;
    break;
   case '-':
    result[i++] = a - b;
    break;
   case '*':
    result[i++] = a * b;
    break;
   case '/':
    result[i++] = a / b;
    break;
   default:
    break;
  }
 }
 for (int j = 0; j < i; j++)
 {
  cout << result[j] << endl;
 }
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int p[n];
	rep(i, n) cin >> p[i];
	
	int cnt = 0;
	rep(i, n - 2) {
		if ((p[i] > p[i + 1] and p[i + 1] > p[i + 2]) or (p[i] < p[i + 1] and p[i + 1] < p[i + 2])) cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int M = 998244353;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, s;
  cin >> n >> s;
  long dp[s+1] {};
  long res = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a <= s) for (int x = s; x; --x) {
      int y = x-a;
      if (y) {
        dp[x] += dp[y];
        dp[x] %= M;
      } else {
        dp[x] += i+1;
        dp[x] %= M;
        break;
      }
    }
    res += dp[s];
    res %= M;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>

int main(){
   std::string s;
   int K;
   std::cin >> s >> K;

   int count = 0;
   for(char ch='a'; ch<='z'; ++ch){
      std::set<std::string> sets;
      for(int i=0; i<s.size(); ++i){
	 if(s[i]==ch){
	    std::string tmp;
	    for(int j=0; j<K; ++j){
	       if(i+j>=(int)s.size()) break;
	       tmp += s[i+j];
	       sets.insert(tmp);
	    }
	 }
      }
      if(count+sets.size()<K){
	 count += sets.size();
      }else{
	 auto itr = sets.begin(); 
	 for(int j=0; j<K-count-1; ++j) ++itr;
	 std::cout << *itr << std::endl;
	 return 0;
      }
      
   }

   return -1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __ll128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}



void __sol(){
    ll a,b,n; cin >> a >> b >> n;
    ll x = min(b-1,n);
    cout <<(ll)((a*x)/b) - a*((ll)(x/b));
}


int main(){
    fastio
    ll tc=1; //cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

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

const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct edge1 { ll from, to, cost; };
double pai = 3.141592653589793;

int main() {
	ll n, a, b, x[100010];
	cin >> n >> a >> b;
	for (int i = 0;i < n;i++)cin >> x[i];
	ll l = 0, r = INF;
	while (r - l > 1) {
		ll mid = (l + r) / 2, sum = 0;
		for (int i = 0;i < n;i++) {
			if (x[i] - mid*b > 0) {
				if((x[i] - mid*b) % (a - b)!=0)sum += (x[i] - mid*b) / (a - b) + 1;
				else sum += (x[i] - mid*b) / (a - b);
			}
		}
		if (sum <= mid)r = mid;
		else l = mid;
	}
	cout << r << endl;
	}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
const ll MOD=1000000007;

int main(){
    int N;
    ll Z,W;
    cin >> N >> Z >> W;
    vector<ll> a(N);
    rep (i,N){
        cin >> a[i];
    }
    int ans;
    if (N>1){
        ans=max(abs(a[N-1]-W),abs(a[N-1]-a[N-2]));
    }
    else {
        ans=abs(a[0]-W);
    }
    cout << ans << endl;
}

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

int main(){
    int N,i,l,j,n,p,q,k,sum,asum;
    vector<int> vec;
    cin >> N;
    for(i=0; i < N; i++){
        cin >> l;
        vec.push_back(l);
    }    
    sort(vec.begin(), vec.end());

    asum = 0;
    for(i=vec.size()-1; i>-1; i--){
        n=vec[i];
        for(j=0; j<i; j++){
            p=vec[j];
            for(k=j+1; k<i; k++){
                q=vec[k];
                sum=p+q;
                if(sum > n && n != p && p != q && n != q){
                    asum += 1;
                }
            }
        }
        if(i==0){
            break;
        }
    }

    cout << asum << endl;

    /*
    for(i=0; i<vec.size(); i++){
        cout << vec[i] << " ";
    }
    */
}

Measured memory_bytes: 3176
import sys
a = 3
A = [list(map(int,input().split())) for c in range(a)]
N = int(input())
b = [int(input()) for c in range(N)]
#print(A)
#print(b)
C = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    for j in range(3):
        for k in range(N):
            if b[k] == A[i][j]:
                C[i][j] = 1

for i in range(3):
    if sum(C[i]) == 3:
        print("Yes")
        sys.exit(0)

for j in range(3):
    if C[0][j]+C[1][j]+C[2][j] == 3:
        print("Yes")
        sys.exit(0)

if C[0][0]+C[1][1]+C[2][2] == 3 or C[0][2]+C[1][1]+C[2][0] == 3:
    print("Yes")
    sys.exit(0)

print("No")


Measured memory_bytes: 9184
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define debug(x) std::cout << #x << ": " << x << '\n';
#define pb push_back
const int N = 1e3 + 10, LOG = 25;
char arr[N][N];
int col[N][2], row[N][2], swp[N];
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, m, a, b;
    std::cin >> n >> m >> a >> b;
    FOR(i, n) {
    	if (i < b) {
	    	row[i][0] = a;
	    	row[i][1] = m - a;
	    }
	    else {
	    	row[i][0] = m - a;
	    	row[i][1] = a;
	    }
    }
    FOR(i, m) {
    	if (i < a) {
    		// debug(i)
	    	col[i][0] = b;
	    	col[i][1] = n - b;
	    }
	    else {
	    	col[i][0] = n - b;
	    	col[i][1] = b;
	    }
    }
    bool swp = false;
    FOR(i, n) {
    	FOR(j, m) {
    		bool fl = false;
    		for (auto c : {0, 1}) {
	    		if (row[i][c] > 0 && col[j][c] > 0) {
	    			arr[i][j] = c + '0';
	    			row[i][c]--;
	    			col[j][c]--;
	    			fl = true;
	    			break;
	    		}
	    	}
	    	if (!fl && swp) {
	    		// swp = true;
	    		// debug(i << ' ' << j << ' ' << col[j][0] << ' ' << )
	    		std::cout << -1;
	    		return 0;
	    	}
    	}
    }
    FOR(i, n) {
    	FOR(j, m) {
    		std::cout << arr[i][j];
    	}
    	std::cout << '\n';
    }
}


Measured memory_bytes: 2304
import math
n = int(input())
c = [0]*(n-1)
s = [0]*(n-1)
f = [0]*(n-1)
for i in range(n-1):
  ci,si,fi = map(int,input().split())
  c[i] = ci
  s[i] = si
  f[i] = fi
for i in range(n-1):
  x = s[i]
  for j in range(i,n-2):
    x += c[j]
    x = max(s[j+1],math.ceil(x/f[j+1])*f[j+1])
  x += c[n-2]
  print(x)
print(0)

    
  
  
  
  

Measured memory_bytes: 42460
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n;
    string line[300];
    while (cin >> n && n) {
        for (int i = 0; i < n; i++) cin >> line[i];
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            ll cnt = 0, len = 0;
            for (int j = 0; j < n; j++) {
                if (line[i][j] == '1') len++;
                else len = 0;
                cnt = max(cnt, len);
            }
            ans = max(ans, cnt);
        }
        for (int j = 0; j < n; j++) {
            ll cnt = 0, len = 0;
            for (int i = 0; i < n; i++) {
                if (line[i][j] == '1') len++;
                else len = 0;
                cnt = max(cnt, len);
            }
            ans = max(ans, cnt);
        }
        for (int j = 0; j < n; j++) {
            ll cy = 0, cx = j;
            ll cnt = 0, len = 0;
            while (0 <= cy && cy < n && 0 <= cx && cx < n) {
                if (line[cy][cx] == '1') len++;
                else len = 0;
                cnt = max(cnt, len);
                cy++, cx--;
            }
            ans = max(ans, cnt);
        }
        for (int j = n - 1; j >= 0; j--) {
            ll cy = 0, cx = j;
            ll cnt = 0, len = 0;
            while (0 <= cy && cy < n && 0 <= cx && cx < n) {
                if (line[cy][cx] == '1') len++;
                else len = 0;
                cnt = max(cnt, len);
                cy++, cx++;
            }
            ans = max(ans, cnt);
        }
        for (int j = 0; j < n; j++) {
            ll cy = n - 1, cx = j;
            ll cnt = 0, len = 0;
            while (0 <= cy && cy < n && 0 <= cx && cx < n) {
                if (line[cy][cx] == '1') len++;
                else len = 0;
                cnt = max(cnt, len);
                cy--, cx--;
            }
            ans = max(ans, cnt);
        }
        for (int j = n - 1; j >= 0; j--) {
            ll cy = n - 1, cx = j;
            ll cnt = 0, len = 0;
            while (0 <= cy && cy < n && 0 <= cx && cx < n) {
                if (line[cy][cx] == '1') len++;
                else len = 0;
                cnt = max(cnt, len);
                cy--, cx++;
            }
            ans = max(ans, cnt);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3224
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>

using namespace std;

const int MAX = 1000;
struct Point{int x,y,z;};
vector<Point> V;


int sum,n,h;

void init(){
  V.clear();
  sum = n*n*n;
}

bool isCross(Point a, Point b){

  if(a.x == b.x && a.y == b.y && a.z == b.z) return false;

  if(a.x != -1 && b.x != -1)
    if(a.x != b.x) return false;
  
  if(a.y != -1 && b.y != -1)
    if(a.y != b.y) return false;

  if(a.z != -1 && b.z != -1)
    if(a.z != b.z) return false;

  return true;
}


void make(string s, int a, int b){

  Point p;
  p.x = p.y = p.z = -1;

  if(s == "xy"){
    p.x = a;
    p.y = b;
  }else if(s == "xz"){
    p.x = a;
    p.z = b;
  }else{
    p.y = a;
    p.z = b;
  }
  V.push_back(p);
}

int main(){
  while(cin >> n >> h && n+h){
    init();
    
    for(int i = 0; i < h; i++){
      string s;
      int a,b;
      cin >> s >> a >> b;
      make(s,a,b);
      sum -= n;
    }

    bool flg = false;
   
    for(int i = 0; i < V.size(); i++){
      vector<int> HIT;
      for(int j = i+1; j < V.size(); j++)
	if(isCross(V[i],V[j])){
	  sum++;
	  HIT.push_back(j);
	}

      for(int k = 0; k < HIT.size(); k++)
	for(int l = k+1; l < HIT.size(); l++)
	  if(isCross(V[HIT[k]],V[HIT[l]])) sum--;
	  


    }    
    cout << sum << endl;
  }	
  return 0;
}

Measured memory_bytes: 1240
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val H = Array.fill(N)(sc.nextInt())

    def solve(): Boolean = {
      var i = 0
      while (i < N - 1) {
        if (H(i+1) < H(i))
          if (H(i+1) + 1 >= H(i)) {
            H(i+1) += 1
          } else {
            return false
          }
        i += 1
      }
      true
    }

    println(if (solve()) "Yes" else "No")
  }

}

Measured memory_bytes: 52160
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

N, M = map(int, input().split())
adj = [[] for _ in range(N)]

def rec(v,visited,order):
    visited[v] = 0
    for u in adj[v]:
        if visited[u] < 0:
            rec(u,visited,order)
    order.append(v)

def main():
    xy = []
    for _ in range(M):
        x, y = map(int, input().split())
        xy.append((x-1,y-1))
        adj[x-1].append(y-1)
    
    # トポロジカルソート（dfsによって実装）
    visited = [-1] * N
    order = []
    for i in range(N):
        if visited[i] < 0:
            rec(i,visited,order)

    # 自分を始点とするパスの最長を保存
    dp = [0]*(N+1)
    for o in order:
        for u in adj[o]:
            dp[o] = max(dp[o],dp[u]+1)
    
    print(max(dp))

if __name__ == "__main__":
    main()

Measured memory_bytes: 75908
// https://atcoder.jp/contests/abc171/tasks/abc171_b

#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n' 

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

    int N, K;
    cin >> N >> K;

    int a[N];
    for(int i = 0; i < N; i++) cin >> a[i];

    sort(a, a+N);

    int sum = 0;
    for(int i = 0; i < K; i++) {
        sum += a[i];
    }

    cout << sum << endl;
}


Measured memory_bytes: 3632
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();
		if (a + b < 10) {
			System.out.println(a + b);
		}else {
			System.out.println("error");
		}
	}

}


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

int main(){
    int X, Y;
    cin >> X >> Y;
    int ans = 0;
    for (int i = 0; i < X + 1; i++){
        if(4 * i + 2 * (X - i) == Y)
            ans = 1;
    }
    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3540
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  double X;
  cin >> X;
  cout << (360 / gcd(X, 360LL)) << endl;
  return 0;
}

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


int main(){
	int n, m;
	cin >> n >> m;
	vector<int> L(m);
	vector<int> R(m);
	for (int i = 0; i < m; i++) {
		cin >> L[i] >> R[i];
	}
	int Lmax=0, Rmin=100000;
	if (m == 1) {
		cout <<R[0]-L[0]+1<< endl;
	}
	else {
		for (int i = 0; i < m; i++) {
			Lmax = max(Lmax, L[i]);
			Rmin = min(Rmin, R[i]);
		}
		if (Lmax > Rmin) {
			cout << 0 << endl;
		}
		else {
			cout << Rmin - Lmax + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char s[100001],s1[100001];
int main()
{
    cin>>s>>s1;
    if(strlen(s)!=strlen(s1)) puts("NO");
    else
	{
        reverse(s1,s1+strlen(s1));
        if(!strncmp(s,s1,strlen(s))) puts("YES");
        else puts("NO");
    }
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
if a >= 0 and b >= 0 and c <= 0 and d <= 0:
    print(max(a*d,b*c))
elif a <= 0 and b <= 0 and c >= 0 and d >= 0:
    print(max(a*d,b*c))
else:
    print(max(a*c,b*d))

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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int ans = 0;
        if(a == b && b == c) {
            ans = 1;
        } else if(a != b && b != c && a != c) {
            ans = 3;
        } else {
            ans = 2;
        }
        System.out.print(ans);
    }
}

Measured memory_bytes: 23380
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.clock", "r", stdin );

	const string mesg[] = { "alert" ,"warning" ,"safe" };
	const double range[] = { 0.0, 30.0, 90.0, 180.0 }; 
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	int i,j;
	for (i = 0; i < n; ++i){
		getline (cin, str );
		str = str.replace(str.find(':'), 1, " ");
		int hour, minute;

		stringstream ss(str);
		ss >> hour >> minute;
		double hour_arg = 30.*hour + minute/2.;
		double minute_arg = 6.*minute;
//		double diff_h = min (hour_arg, 360. - hour_arg);
//		double diff_m = min (minute_arg, 360. - minute_arg);
		double diff = fabs (hour_arg - minute_arg ); 
		diff = min (diff, 360. - diff ); 
//		cout << "hour_arg  : " << hour_arg << endl;
//		cout << "mintue_arg: " << minute_arg << endl;
//		cout << "diff:       " << diff << endl;

		if (diff >= 0.0 && diff < 30.0){
			cout << mesg[0] << endl;
		}else if (diff >= 30.0 && diff < 90.0){
			cout << mesg[1] << endl;
		}else{
			cout << mesg[2] << endl;
		} // end if
/*		
		for (j = 0; j < 3; ++j){
			if (diff >= range[j] && diff < range[j+1]){
				cout << mesg[j] << endl;
				break;
			} // end if
		} // end for
*/
	} // end loop
		
	return 0;
}

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

int main() {
  long long a,b,k; cin >> a >> b >> k;
  if(k <= a){
    cout << a-k << ' ' << b << endl;
  }
  else if(k > a && k <= a+b){
    cout << 0 << ' ' << a+b-k << endl;
  }
  else{
    cout << 0 << ' '  << 0 << endl;
  }
}

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

#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)

using ll = long long;
#define INF 1e9+3

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  REP(i, N){
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  int ans = 0;
  REP(i, N){
    FOR(j, i+1, N){
      FOR(k, j+1, N){
        if(L[k] < L[i]+L[j]){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include <string>
#include<cstdio>
#include<stack>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
using namespace std;
typedef long long ll;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}

//------------------変数-----------------------//
ll n, cou=1, kekka[4000], mae=1;
string a[60];
//-------------------関数----------------------//
int main() {
	cin >> n; ll aa = n;
	fill(kekka, kekka + 2000,1);
	REP(j, n) {
		ll kari = aa,z=aa;
		for (int i = 2; i <= kari; i++)
		{
			while (z%i == 0) {
				kekka[i]++; 
				z /= i;
			}
		}
		aa --;
	}
	REP(i, 2000) {
		mae *= kekka[i];
		mae %= mod;
	}cout << mae << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
bool comp(const pair<int,int>& a, const pair<int,int>& b){
  if(a.second == b.second){
    return a.first < b.first;
  }
  else return a.second < b.second;
}

int main(){
  int N ;
  cin >> N;
  vector<pair<int,int>> ABs(N);
  for(int i = 0; i < N; i++){
    pair<int,int> ab;
    cin >> ab.first >> ab.second;
    ABs.at(i) = ab;

  }
  sort(ABs.begin(), ABs.end(), comp);
  
  int task = 0;
  for(int i = 0; i < N; i++){
    task += ABs.at(i).first;
    if(task > ABs.at(i).second){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0; 
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long ll;
const ll mod = 1000000007;

ll powmod(ll x, ll y) {
    ll res = 1;
    for (ll i = 0; i < y; i++) {
        res = res * x % mod;
    }
    return res;
}
int main() {
    ll n;
    cin >> n;
    ll ans = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);
    ans %= mod;
    ans = (ans + mod) % mod;
    cout << ans << "\n";
}

Measured memory_bytes: 3580
import java.util.*;

class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] num = new int[10];
		while(scan.hasNextLong()){
			long l = scan.nextLong();
			for(int i = 0;i < num.length;i++){
				num[i] = 0;
			}
			for(int i = 0;i < 13;i++){
				num[(int)(l % 10)]++;
				l /= 10;
			}
			boolean hasAns = false;
			for(int i = 1;i <= 9;i++){
				num[i]++;
				if(num[i] <= 4 && dfs(num,1,false)){
					if(hasAns){
						System.out.print(" ");
					}
					System.out.print(String.valueOf(i));
					hasAns = true;
				}
				num[i]--;
			}
			if(!hasAns){
				System.out.print("0");
			}
			System.out.println("");
		}
	}
	static boolean dfs(int[] num,int i,boolean head){
		boolean res = true;
		for(int j = 0;j <= 9;j++){
			if(num[j] != 0){
				res = false;
			}
		}
		if(res){
			return true;
		}
		for(int j = i;j <= 9;j++){
			if(!head && num[j] >= 2){
				num[j] -= 2;
				res |= dfs(num,j,true);
				num[j] += 2;
			}
			if(num[j] >= 3){
				num[j] -= 3;
				res |= dfs(num,j,head);
				num[j] += 3;
			}
			if(j < 8 && num[j] > 0 && num[j + 1] > 0 && num[j + 2] > 0){
				num[j]--; num[j + 1]--; num[j + 2]--;
				res |= dfs(num,j,head);
				num[j]++; num[j + 1]++; num[j + 2]++;
			}
		}
		return res;
	}
}

Measured memory_bytes: 23568
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;
typedef deque<bool> db;
typedef deque<deque<bool> > ddb;

int main() {
  int n;
  cin >> n;
  int m = 10000;
  int mm = 0;
  vi tri(m, 0);
  rep (i, m) {
    tri[m] = i * (i+1) / 2;
    if (tri[m] >= n) {
      mm = i;
      break;
    }
  }
  set<int> si;
  int n_ = n;
  for (int i = mm; i >= 1; --i) {
    if (n_ >= i) {
      n_ -= i;
      si.insert(i);
    }
    if (n_ == 0) {
      break;
    }
  }
  for (auto i : si) {
    printf("%d\n", i);
  }

  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int x1, y1, x2, y2;
    
    int dx, dy;
    
    int x3, y3, x4, y4;
    
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    
    dx = x2 - x1;
    dy = y2 - y1;
    
    x3 = x2 - dy;
    y3 = y2 + dx;
    
    x4 = x3 - dx;
    y4 = y3 - dy;

    printf("%d %d %d %d\n", x3, y3, x4, y4);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int n;
int r,b;
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>s;
for (int i=0;i<s.size();++i)
if (s[i]=='R') ++r;
else ++b;
if (r>b) cout<<"Yes";
else cout<<"No";
	return 0;
}

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

#define DEBUG
#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif

int main() {
    int n, w, h;
    int x, y, z;
    cin >> n >> w >> h;

    int X[100005] = {};
    int Y[100005] = {};
    
    for (int i = 0; i < n; ++i) {
        cin >> x >> y >> z;
        X[max(0, x - z)] += 1;
        X[min(w, x + z)] -= 1;
        Y[max(0, y - z)] += 1;
        Y[min(h, y + z)] -= 1;
    }

    bool resx = true;
    int cnt = 0;
    for (int i = 0; i < w; ++i) {
        cnt += X[i];
        resx &= cnt > 0;
    }
    cnt = 0;
    bool resy = true;
    for (int i = 0; i < h; ++i) {
        cnt += Y[i];
        resy &= cnt > 0;
    }
    cout << (resx || resy ? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 3864
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  lint A[N];
  REP(i,N)cin>>A[i];
  lint s=0;
  REP(i,N)s+=A[i];
  set<lint> q;
  lint m=sqrt(s)+1;
  FOR(i,1,m){
    if(s%i!=0)continue;
    q.insert(i);
    q.insert(s/i);
  }
  for(auto itr=q.rbegin();itr!=q.rend();++itr){
    int c=*itr;
    // cerr<<c<<endl;
    int B[N];
    lint ss=0;
    REP(i,N){
      B[i]=A[i]%c;
      ss+=B[i];
    }
    sort(B,B+N);
    int temp=0;
    REP(i,N-ss/c)temp+=B[i];
    if(temp<=K){
      cout<<c<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
//
// Created by yuu on 2019-06-09.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;


int main(void){
    int N,K;
    cin>>N>>K;
    
    if(K==1){
        cout<<0<<endl;
        return 0;
    }
    
    cout<<(N-K)<<endl;


    return 0;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int N,M,i,ans,tmp;
string s;
map<string,int> cnt1,cnt2;
inline void solve(){
  IN(N);
  REP(i,N)IN(s),cnt1[s]++;
  IN(M);
  REP(i,M)IN(s),cnt2[s]++;
  for(map<string,int>::iterator it=cnt1.begin();it!=cnt1.end();it++){
    tmp=it->second-cnt2[it->first];
    chmax(ans,tmp);
  }
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int ans = 1000 * (x / 500);
        x %= 500;
        ans += 5 * (x / 5);
        System.out.println(ans);
    }

}

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

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

    if(a > b){
        cout << "a > b" << endl;
    }else if(a < b){
        cout << "a < b" << endl;
    }else{
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class t>
using table = vector<vector<t>>;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
  

int main() {
	int V, D;
	int aa = 1001;
	while (cin >> V >> D) {
		vector<int>fib(V+1);
		fib[0] = 1%aa;
		fib[1] = 2%aa;
		for (int i = 2; i <= V; ++i) {
			fib[i] = (fib[i - 1] + fib[i - 2])%aa;
		}
		vector<int>nums;
		for (int i = 1; i <= V; ++i) {
			nums.emplace_back(fib[i]);
		}
		sort(nums.begin(), nums.end());
		nums.erase(unique(nums.begin(), nums.end()), nums.end());
		int from = -10000;
		int ans = 0;
		for (int i = 0; i < nums.size(); ++i) {
			if (from + D <= nums[i]) {
				ans++;


			}
			from = nums[i];
		}
		cout << ans << endl;
	}
	return 0;
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

ll n;
vector<vector<long long>> v;
long long sum[70000] = {0};
long long dp[70000] = {0};

//sum[]に全ての集合毎の点数をセット
void sumset() {
    rep(i,1<<n){
        sum[i]=0;
        rep(j,n){
            for(int k = j + 1; k < n; ++k){
                if(((i >> j) & 1) && ((i >> k) & 1)) sum[i]+=v[j][k];
            }
        }
    }
}

long long solve(int now){
    if(dp[now] != -1) return dp[now];
    //  dp[S]=max(dp[S∖T]+sum[T]) TはSの部分集合
    long long ans = 0;
    // S⊃TなるTを全部列挙
//    for(int x = now; x > 0; --x) {
//        x &= now;
    for(int x = now; x > 0; --x &= now) {
        ans=max(ans, solve(now-x)+sum[x]);
    }
    return dp[now] = ans;
}

int main(){
    // 入力
    cin >> n;
    v.resize(n);
    for(int i = 0; i < n; ++i) {
    v[i].resize(n);
    for(int j = 0; j < n; ++j) cin >> v[i][j];
    }
    sumset();
// dp[]全てに-1を代入
    rep(i,1<<n) dp[i]=-1;
// dp[]の１要素のものに0を代入
    rep(i,n) dp[1<<i]=0;
    cout << solve((1 << n) - 1) << endl;
    return 0;
}

Measured memory_bytes: 4604