akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int main(){
    int a,b;
    cin>>a>>b;
    cout<<(double)a/b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    cin >> s;

    if (c < d)
    {
        for (int i = a; i < c; i++)
        {
            if (s[i] == '#' && s[i + 1] == '#')
            {
                Yes(0);
                return 0;
            }
        }
        for (int i = b; i < d; i++)
        {
            if (s[i] == '#' && s[i + 1] == '#')
            {
                Yes(0);
                return 0;
            }
        }
        Yes(1);
        return 0;
    }
    else
    {
        for (int i = a; i < c; i++)
        {
            if (s[i] == '#' && s[i + 1] == '#')
            {
                Yes(0);
                return 0;
            }
        }
        bool flag = false;

        for (int i = b; i <= d; i++)
        {
            if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.')
            {
                flag = true;
                break;
            }
            if (s[i] == '#' && s[i + 1] == '#')
            {
                break;
            }
        }
        if (flag)
        {
            Yes(1);
        }
        else
        {
            Yes(0);
        }
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    string s; cin >> s;
    deque<char> que;
    rep(i, s.size()) que.push_back(s[i]);

    int q; cin >> q;
    bool mae = true;
    rep(i, q) {
        int t; cin >> t;
        if (t==1) {
            mae = !mae;
        } else {
            int f; cin >> f;
            char c; cin >> c;
            if ((mae && f==1) || (!mae && f==2)) {
                que.push_front(c);
            } else {
                que.push_back(c);
            }
        }
    }

    while (que.size()) {
        if (mae) {
            char x = que.front();
            que.pop_front();
            cout << x;
        } else {
            char x = que.back();
            que.pop_back();
            cout << x;
        }
    }
    cout << endl;
}

Measured memory_bytes: 976
def gcd(a, b)
  a, b = b, a % b while b > 0
  a
end

def lcm(a, b)
  (a * b / gcd(a, b)).to_i
end

while line = gets
  a, b = line.split.map(&:to_i)
  puts "#{gcd(a, b)} #{lcm(a, b)}"
end

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

int N, M, Q;
int a[50], b[50], c[50], d[50];
int A[10];
int max = 0;

void solve() {
    int ans = 0;
    for (int i = 0; i < Q; ++i) {
        if ((A[b[i]] - A[a[i]]) == c[i]) {     
            ans += d[i];
        }
    }

    max = std::max(max, ans);
}

void dfs(int n, int cur) {
    if (n == N) {
        solve();
        return;
    }

    if (cur > M) { 
        return;
    }

    A[n] = cur;
    dfs(n + 1, cur);

    dfs(n, cur + 1);
}

int main() {
    std::cin >> N >> M >> Q;
    for (int i = 0; i < Q; ++i) {
        std::cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i];
        --b[i];
    }
    
    dfs(0, 1);
    std::cout << max << std::endl;

    return 0;
}


Measured memory_bytes: 3588
#include <iostream> 
#include <cstring>
#include <algorithm> 
#include <cmath> 
#include <cstdio> 
#define size 500050
using namespace std;
int a[size];
int main()
{
	int n,ans=0;
	string s;
	cin>>s;
	for(int i=0; i<s.length(); i++) {
		if(s[i]==s[i+1]) {
			cout<<"Bad"<<endl;
			return 0;
		}
	}
	cout<<"Good"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
  int n, k;
  unordered_map<int, int> mp;
  cin >> n >> k;
  REP(i, n) {
    int work;
    cin >> work;
    mp[work]++;
  }
  vector<pair<int, int>> v;
  for (auto e : mp)
    v.push_back(make_pair(e.second, e.first));
  sort(v.begin(), v.end(), greater<pair<int, int>>());
  int t = 0;
  REP (i, v.size()) {
    if (i == k) break;
    t += v[i].first;
  }
  cout << n - t << endl;
}


Measured memory_bytes: 11592
#include <stdio.h>

int main(void)
{
	unsigned short i, d;
	long long sum;
	while( scanf("%d", &d) != EOF){
		sum = 0;
		for(i=1; i<600/d; i++){
			sum += (i*d)*(i*d) * d;
		}
		printf("%lld\n", sum);
	}
	return 0;
}

Measured memory_bytes: 596
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : September 19, 2020 6:01 PM
 *    Problem Name  : A - Plural Form
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc179/tasks/abc179_a
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;

    int len = s.length();
    if(s[len-1] == 's') cout << s << "es" << endl;
    else cout << s << "s" << endl;

    return 0 ;
}


Measured memory_bytes: 3644
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long int            ll;
typedef long double              ld;
#define Faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi                 acos(-1);
#define test        int t; cin>>t; while(t--)
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//cin.getline(array,size);
int main()
{
    string a;
    cin>>a;
    if(a[0]=='R'&&a[1]=='R'&&a[2]=='R')
        cout<<"3"<<endl;
    else if((a[0]=='R'&&a[1]=='R')||(a[1]=='R'&&a[2]=='R'))
        cout<<"2"<<endl;
    else if(a[0]=='R'||a[1]=='R'||a[2]=='R')
        cout<<"1"<<endl;
    else
        cout<<"0"<<endl;
}


Measured memory_bytes: 3584
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

s = STR()
pre = ''
strt = 0
ans = 0
for i in range(1, len(s) + 1):
    if pre == s[strt:i]:
        continue
    pre = s[strt:i]
    strt = i
    ans += 1
print(ans)

Measured memory_bytes: 62552
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    while(A >= B) {B *= 2; K--;}
    while(B >= C) {C *= 2; K--;}
    if(K < 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 3660
#include <iostream>

using namespace std;

int main()
{
	int n;
	int now;
	int cnt;
	int a[100000];
	bool ap[100000];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		a[i]--;
		ap[i]=false;
	}
	now = a[0];
	ap[0] = true;
	cnt++;
	while(ap[now]!=true)
	{
		if(now==1)
		{
			cout<<cnt<<endl;
			return 0;
		}
		ap[now] = true;
		now = a[now];
		cnt++;
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <strstream>
#include <string>
#include <deque>
#include <vector>
typedef unsigned int UINT;
using namespace std;

int main(void) {
    int ans = 0;
    string S;
    cin >> S;
    for (char s : S) {
        if (s == '+')
            ans++;
        else
            ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mod 1000000007

int modInverse(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
int main()
{
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	ll r[a],g[b],cl[c];
	for(int i=0;i<a;i++)
		cin>>r[i];
	for(int i=0;i<b;i++)
		cin>>g[i];
	for(int i=0;i<c;i++)
		cin>>cl[i];
	sort(r,r+a);
	sort(g,g+b);
	sort(cl,cl+c);
	ll z[3000002];
	ll s=0,t=0;
	ll cnt=0;
		for(int i=a-1;cnt<x;i--)
		{
			z[t]=r[i];
			t++;
			cnt++;
			//cout<<1<<" ";
		}
		cnt=0;
		//cout<<endl;
		for(int i=b-1;cnt<y;i--)
		{
			z[t]=g[i];
			t++;
			cnt++;
			//cout<<1<<" ";
		}////cout<<endl;
		for(int i=c-1;i>=0;i--)
		{
			z[t]=cl[i];
			t++;
			//cout<<1<<" ";
		}//cout<<endl;
		ll to=x+y;
		sort(z,z+t);
		for(int i=t-1;to>0;i--)
		{			//cout<<1<<" ";


			s+=z[i];
			to--;
		}
		cout<<s<<endl;
	
	
}

Measured memory_bytes: 6656
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

string s;
bool f = 1;

void iscat(int &i){
    if (s[i] != 'm') return;
    i++;
    iscat(i);
    if (s[i] != 'e' || !f) {
        f = 0;
        return;
    }
    i++;
    iscat(i);
    if (s[i] != 'w' || !f) {
        f = 0;
        return;
    }
    i++;
}

int main() {
    cin >> s;
    int i = 0;

    iscat(i);

    if (f && i == s.length()) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;


    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<class Z> map<Z, int> factorize(Z n) {
  map<Z, int> res;
  for (Z i = 2; i * i <= n; ++i) while (n % i == 0) ++res[i], n /= i;
  if (n != 1) ++res[n];
  return res;
}

lint tmod(lint a, lint p) { return (a %= p) < 0 ? a + p : a; }
lint mod_pow(lint a, lint n, lint p) {
  assert(n >= 0);
  a = tmod(a, p);
  lint res = 1;
  while (n) {
    if (n & 1) (res *= a) %= p;
    (a *= a) %= p;
    n >>= 1;
  }
  return res;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int p, t; cin >> p >> t;
// BEGIN CUT HERE
  auto mp = factorize(p - 1);
  auto mod_ord = [&](lint x) -> lint {
    if (mod_pow(x, p - 1, p) != 1) return -1;
    lint res = p - 1;
    for (const auto& e : mp) {
      for (int i = 0; i < e.second; ++i) {
        if (mod_pow(x, res / e.first, p) == 1) {
          res /= e.first;
        } else break;
      }
    }
    return res;
  };
// END CUT HERE
  while (t--) {
    int n; cin >> n;
    V<lint> g(n);
    lint d = p - 1;
    for (auto&& e : g) {
      cin >> e;
      d = __gcd(d, (p - 1) / mod_ord(e));
    }
    lint a; cin >> a;
    cout << !((p - 1) / mod_ord(a) % d) << '\n';
  }
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#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;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[4] = {1,0,-1,0};
constexpr ll ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll a = sqrt(n-1)/1;
    int cnt = 0;
    rep(i,1,a+1){
        if ((n-1)%i == 0) cnt++;
    }
    cnt *= 2;
    if (a*a == n-1) cnt--;
    a = sqrt(n)/1;
    rep(i,2,a+1){
        if (n%i != 0) continue;
        ll s = i,t = n/i,m = n;
        while(m%s == 0){
            m /= s;
        }
        if (m%s == 1) cnt++;
        m = n;
        while(m%t == 0){
            m /= t;
        }
        if (m%t == 1 && s != t) cnt++;
    }
    PRINT(cnt);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int ll;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x = a*b, y = c*d;
    if(x > y){
        cout << x;
    } else {
        cout << y;
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#define INF 1e6
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,m,a,b,c;
	cin>>n>>m;
	int edge[n][n];
	int dist[n][n];
	rep(i,n)rep(j,n)dist[i][j]=edge[i][j]=INF;
	rep(i,m){
		cin>>a>>b>>c;
		a--;b--;
		edge[a][b]=edge[b][a]=dist[a][b]=dist[b][a]=c;
	}
	rep(k,n){
		rep(i,n){
			rep(j,n){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	int ans=0;
	int flg[n][n];
	rep(i,n)fill(flg[i],flg[i]+n,true);
	rep(i,n){
		rep(j,n){
			if(i==j)continue;
			if(edge[i][j]!=dist[i][j]&&flg[i][j]&&edge[i][j]!=INF){
				ans++;
				flg[i][j]=flg[j][i]=false;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;


int main(){
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1 ; i <= n ; ++i){
        int sz = log10(i) + 1;
        ans += (sz & 1);
    }

    cout << ans << "\n";
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long

int max(int aa, int bb);

int main(void) {
    int a_len,b_len,itr,itrA,itrB,dp[3005][3005],tmp,piv_x,piv_y,piv_ans=0,ans_len;
    char a_str[3005],b_str[3005], ans[3005];
    scanf("%s %s",a_str,b_str);
    //配列の長さを取得
    a_len = strlen(a_str);
    b_len = strlen(b_str);
    //初期化
    for(itr = 0;itr <= a_len; itr++){
        dp[itr][0] = 0;
    }
    for(itr = 0;itr <= b_len; itr++){
        dp[0][itr] = 0;
    }
    /*
    dpの計算
    三通りあるので、それらの最大値を取る
    */
    for(itrA = 1;itrA <= a_len; itrA++){
        for(itrB = 1;itrB <= b_len; itrB++){
            dp[itrA][itrB] = max(dp[itrA][itrB-1],dp[itrA-1][itrB]);
            if(a_str[itrA-1]==b_str[itrB-1]){
                tmp = dp[itrA-1][itrB-1] + 1;
                dp[itrA][itrB] = max(dp[itrA][itrB],tmp);
            }
        }
    }
    //右下から探索を始める
    piv_x = a_len;
    piv_y = b_len;
    
    while(piv_x != 0 && piv_y != 0){
        if(dp[piv_x][piv_y] == dp[piv_x-1][piv_y]){
            piv_x--;
        }
        else if(dp[piv_x][piv_y] == dp[piv_x][piv_y-1]){
            piv_y--;
        }
        else{
            //左上なのでansに追加
            ans[piv_ans] = a_str[piv_x-1];
            piv_ans++;
            piv_y--;
        }
    }
    ans_len = strlen(ans);
    //反転しながら出力
    for(itr = ans_len-1;itr >= 0; itr--){
        printf("%c",ans[itr]);
    }
    printf("\n");
    
    return 0;
}
//maxを計算する関数
int max(int aa, int bb) {
    if (aa > bb)
        return aa;
    else
        return bb;
}

Measured memory_bytes: 35456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt();
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			if (a >= b) {
				System.out.println("delicious");
			} else if (x + a >= b) {
				System.out.println("safe");
			} else {
				System.out.println("dangerous");
			}
		}
	}
}


Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

ll N = 100001;
ll K = 100001;
ll mod = 1000000007;

vector<ll> fac(N), finv(N), inv(N);

void Cinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < N;i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

long long com(ll n,ll k){
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
    Cinit();
    cin >> N >> K;
    vector<ll> A(N);
    for (int i = 0; i < N;i++)
        cin >> A[i];

    sort(A.begin(), A.end());
    ll ans = 0;

    for (int i = 0; i < N;i++){
        if(i >= K - 1)
        ans += A[i] * com(i, K - 1)  % mod;
        if(N - 1 - i >= K - 1)
        ans -= A[i] * com(N - i - 1, K - 1) % mod;
        ans %= mod;
    }
    if(ans < 0)
        ans -= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define dbg(x) cout << #x"=" << x << endl; 
const int MAX_N = 550;
LL n,K;
LL A[MAX_N];
LL B[MAX_N];

bool check(int F){
    LL sum = 0;
    for(int i = 1; i <= n; ++i) {
        B[i] = A[i]%F;
        sum += B[i];
    }
    sort(B+1, B+1+n);
    LL k = sum/F;
    LL ans = 0;
    for(int i = 1; i <= n-k; ++i) ans += B[i];
    return ans <= K;
}

int main(){ 
   // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> K;
    LL sum = 0;
    for(int i = 1; i <= n; ++i){
        cin >> A[i];
        sum += A[i];
    }
    int ans = 1;
    for(int i = 1; i <= sum/i; ++i){
        if(sum%i == 0){
            if(check(sum/i)){
                ans = sum/i;
                break;
            } else if(check(i)){
                ans = max(ans, i);
            }
        }
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  
  bool flag1 = true, flag2 = true;

  for(int i = 0; i < S.length()/2; i++){
    if(S[i] != S[S.length()-i-1]){
      flag1 = false;
    }
  }

  if(flag1){
    for(int i=0 ; i<S.length()/4; i++){
      if(S[i] != S[S.length()/2 - i -1]){
        flag2 = false;
      }
      if(S[S.length()/2 + 1 +i] != S[S.length() - i-1]){
        flag2 = false;
      }
    }
  }

  
  if(flag2 && flag1){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll N,M;
    cin >> N >> M;
    // M の 約数を列挙する
    vector<ll> d;
    for(ll i=1;i*i<=M;i++){
        if(M%i==0){
            d.push_back(i);
            d.push_back(M/i);
        }
    }
    ll ans = 1;
    for(auto x:d){
        if( M>= x*N){
            ans = max(ans,x);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	int A, B, ans=0;

	cin >> A >> B;
	if( A == 1 ) A = 100;
	if( B == 1 ) B = 100;

	if( A > B ){
		cout << "Alice" << endl;
	}else if( A < B ){
		cout << "Bob" << endl;
	}else{
		cout << "Draw" << endl;
	}

	return 0;
}


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

using namespace std;

const int N = 2e5 + 10;

int n;
int a[N];
long long res = 0;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a + 1, a + 1 + n);
    int cnt = n - 2;
    res += a[n];
    for (int i = n - 1; i >= 1; i--) {
        if (!cnt) break;
        res += a[i];
        cnt--;
        if (!cnt) break;
        res += a[i];
        cnt--;
        if (!cnt) break;
    }
    cout << res;
}


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

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

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    string N; cin >> N;
    int ans=0;
    for(int i=0;i<N.size();i++){
        int tmp = N[i]-'0';
        ans+=tmp;
    }
    if(ans%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3708
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int main() {
	string S;
	cin >> S;
	stack<int> st;
	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
		if (st.empty() || st.top() == S[i]) {
			st.push(S[i]);
		}
		else {
			st.pop();
			ans += 2;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 768
mod = 1000000007

N,M = list(map(int,input().split()))
a = [int(input()) for i in range(M)]

dp = [0]*(N+2)
dp[0] = 1

for i in a:
  dp[i] = -1

for i in range(N+1):
  if dp[i] == -1:
    continue
  if i+1 <= N:
     if dp[i+1] != -1:
      dp[i+1] += dp[i]%mod
  if i+2 <= N:
    if dp[i+2] != -1:
      dp[i+2] += dp[i]%mod

print(dp[N]%mod)

Measured memory_bytes: 50008
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[100005][3];
int main()
{
	ll n,i,j;
	cin >> n;
	ll a[n],b[n],c[n];
	for(i=0;i<n;i++)
		cin >> a[i] >> b[i] >> c[i];
		
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n;
    cin >> n;
    vector<ll> l(n);
    REP(i, n){ cin >> l.at(i); }
    ll ans = 0;
    REP(i, n){
        for(ll j = i + 1; j < n; ++j){
            for(ll k = j + 1; k < n; ++k){
                if(l.at(i) == l.at(j) || l.at(i) == l.at(k) || l.at(j) == l.at(k)){
                    continue;
                }
                array<ll, 3> a = {l.at(i), l.at(j), l.at(k)};
                sort(ALL(a));
                if(a.at(2) < a.at(0) + a.at(1)){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    int64_t size = S.size();
    int64_t siro_count = 0;
    int64_t kuro_count = 0;
    for (int64_t i=0; i<size; i++) {
        if (i % 2 == 0) {
            if (S[i] == '0') {
                siro_count += 1;
            } else {
                kuro_count += 1;
            }
        } else {
            if (S[i] == '0') {
                kuro_count += 1;
            } else {
                siro_count += 1;
            }
        }
    }

    cout << min(siro_count, kuro_count) << endl;
    return 0;
}

Measured memory_bytes: 3728
// Aizu Vol-2 0226: Hit and Blow
// 2017.8.6

#include <stdio.h>

int f[10];

int main()
{
	char r[5], a[5];
	int h, b, i;

	while (1) {
		scanf("%s%s", r, a);
		if (r[0] == '0' && !r[1]) break;
		for (h = i = 0; i < 4; i++) {
			if (r[i] == a[i]) h++, r[i] = a[i] = 0;
		}
		for (i = 0; i < 10; i++) f[i] = 0;
		for (i = 0; i < 4; i++) if (r[i]) f[r[i] & 0xf]++;
		for (b = i = 0; i < 4; i++) if (a[i] && f[a[i] & 0xf]) b++;
		printf("%d %d\n", h, b);
	}
	return 0;
}

Measured memory_bytes: 540
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str_input = scan.nextLine();
    int ans = 0;
    int amari = 1;

    var str = str_input.split(" ");
    var L = Integer.parseInt(str[0]);
    var R = Integer.parseInt(str[1]);
    var d = Integer.parseInt(str[2]);

    for (var i = L; i <= R; i++) {
      amari = i % d;
      if ( amari == 0 ) {
        ans++;
      }
    }

    System.out.println(ans);
    scan.close();
  }
}

Measured memory_bytes: 35552
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    int ans = 700;
    string s;
    cin >> s;
    for (int i = 0; i < 3; ++i)
        if (s[i] == 'o') ans += 100;
    cout << ans << endl;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define ull unsigned long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define nl cout<<'\n'
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pll pair<long long,long long>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define sll set<long long>
#define all(v) (v).begin(),(v).end()
#define Unique(x)           (x).erase(unique(all(x)), x.end())
#define v_present(vec,x)  (find(all(vec),x)!=(vec).end())
#define present(myset,x)    ((myset).find(x)!=(myset).end())
#define Cprint(c)  for(auto i:(c)) { cout<<i<<" "; } nl
#define trace2(x,y) cout<<x<<" "<<y<<endl;
#define trace3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define trace4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<endl;
ll mod = 1e9+7;
const int MAX = 1e5+5;
using namespace std;
ll dp[105][100005];

int main()
{
    FAST_IO;
    ll n,W;
    cin>>n>>W;
    ll w[n+1]; ll v[n+1];
    for(int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
    }

    for(int i=0;i<=n;i++){
        for(int wt=0;wt<=W;wt++){
            if(i==0 || wt==0) {
                dp[i][wt] = 0;
                continue;
            }
            if(w[i]<=wt){
                dp[i][wt] = max(dp[i-1][wt],v[i]+dp[i-1][wt-w[i]]);
            }
            else
                dp[i][wt]=dp[i-1][wt];
        }
    }
    cout<<dp[n][W];


    return 0;

}


Measured memory_bytes: 80256
n,T=map(int,input().split())
l=[]
for i in range(n):
    l.append(list(map(int,input().split())))
c=[]
t=[]
for i in range(n):
    c.append(l[i][0])
    t.append(l[i][1])

c_n=[]
t_n=[]
for i in range(n):
    if t[i]<=T:
        c_n.append(c[i])
        t_n.append(t[i])

if len(c_n)==0:
    print("TLE")
else:
    for i in range(len(c_n)):
        if c_n[i]==min(c_n):
            print(c_n[i])
            break




Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1e9+7;
using namespace std;

int main(){
    int h, w, d; cin >> h >> w >> d;
    vector<int> x(h*w+1), y(h*w+1), ct(h*w+1);
    REP(i, h){
        REP(j, w){
            int a; cin >> a;
            x[a] = i; y[a] = j;
        }
    }
    
    for(int i = d+1; i <= h*w; ++i)
            ct[i] = ct[i-d] + abs(x[i]-x[i-d]) + abs(y[i]-y[i-d]);
    
    int q; cin >> q;
    REP(i, q){
        int l, r; cin >> l >> r;
        cout << ct[r] - ct[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
#include <cstdio>

int N;
double p[2999];
double dp[3000][3000];

int main(){

    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%lf", &p[i]);
    }

    for(int i = 0; i <= N; i++){
        dp[0][i] = 0.0;
    }
    dp[0][0] = 1.0;

    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= N; j++){
            if(j == 0){
                dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]);
            }
            else{
                dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]) + dp[i - 1][j - 1] * p[i - 1];
            }
        }
    }

    double ans = 0.0;

    for(int i = 0; i <= N; i++){
        if(2 * i > N){
            ans += dp[N][i];
        }
    }

    printf("%.10lf\n", ans);

    return 0;
}

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

using namespace std;
const string filename = "PARITY";

int n;
int a[1000001];

int main(int argc, char** argv)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	//freopen( (filename + ".inp").c_str(), "r", stdin);
	//freopen( (filename + ".out").c_str(), "w", stdout);

	cin >> n;                    
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	cout << ((accumulate(a + 1, a + 1 + n, 0LL) % 2) ? "NO" : "YES");
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int ma = K + A[0] - A[N - 1];
  for (int i = 0; i < N - 1; i++) {
    ma = max(ma, A[i + 1] - A[i]);
  }
  cout << K - ma << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
void marmot0814() {
    int n; cin >> n;
    vector<int> arr(n);
    for (auto &v : arr)
        cin >> v;
    vector<int> dp(n, INF);
    dp[0] = 0;
    dp[1] = abs(arr[0] - arr[1]);
    for (int i = 2 ; i < n ; i++)
        dp[i] = min(dp[i - 1] + abs(arr[i - 1] - arr[i]), dp[i - 2] + abs(arr[i - 2] - arr[i]));
    cout << dp[n - 1] << '\n';
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1, kase = 0; // cin >> t;
    while (t--) {
        // cout << "Case #" << ++kase << ":";
        marmot0814();
    }
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	int N; cin >> N;

	int P = 1;
	for (int i = 0; i < N; i++) {
		P *= (i+1);
	}
	vector<int> X(N,0);
	vector<int> Y(N,0);
	for (int i = 0; i < N; i++) {
		cin >> X[i];
		cin >> Y[i];
	}

	vector<vector<double>> distance(N,vector<double>(N,0.0));

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i != j) {
				double d = sqrt(pow((X[i]-X[j]),2) + pow((Y[i]-Y[j]),2));
				distance[i][j] = d;
				distance[j][i] = d;
			}
		}
	}

	vector<int> idx(N,0);
	for (int i = 0; i < N; i++) {
		idx[i] = i;
	}

	double ans = 0.0;

	do {
		double sum = 0.0;	
		for (int i = 0; i < N-1; i++) {
			sum += distance[idx[i]][idx[i+1]];
		}
		ans += sum;
	}while (next_permutation(idx.begin(), idx.end()));
	cout << setprecision(10) <<  ans / P << endl;
	return 0;

}


Measured memory_bytes: 3796
# AtCoder Beginner Contest 121
# https://atcoder.jp/contests/abc121
import sys
#import numpy as np

s2nn = lambda s: map(int, s.split(' '))
ss2nn = lambda ss: map(int, ss)
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    H, W = i2nn()
    h, w = i2nn()
    n = (H - h) * (W - w)
    print(n)

main()


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	int flag = 0,cnt = 0;
	REP(i, n-1) {
		if (flag == 1) {
			if (v[i] > v[i + 1]) {
				cnt++;
				flag = 0;
			}
		}else if (flag == -1) {
			if (v[i] < v[i + 1]) {
				cnt++;
				flag = 0;
			}
		}
		else {
			if (v[i] < v[i + 1])flag = 1;
			else if (v[i] > v[i + 1])flag = -1;
		}
	}
	cout << cnt+1 << endl;
	return 0;
}


Measured memory_bytes: 640
use std::vec::Vec;
use std::cmp::*;

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

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

fn main() {
    let x: usize = read();
    let mut ans = 1;
    for i in 2..x+1 {
      let mut tmp = i * i;
      if tmp > x { break; }
      while tmp <= x {
        tmp *= i;
      }
      tmp /= i;

      ans = max(tmp, ans);
    }
    println!("{}", ans);
}


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

const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
    // エラトステネスのふるい
    // エラトステネスのふるい
    int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i])
            continue;
        for (int j = i * 2; j < MAX; j += i)
            is_prime[j] = 0;
    }

    // 2017-like 数かどうか
    vector<int> a(MAX, 0);
    for (int i = 0; i < MAX; i++) {
        if (i % 2 == 0)
            continue;
        if (is_prime[i] && is_prime[(i + 1) / 2])
            a[i] = 1;
    }

    //累積和
    vector<int> s(MAX + 1, 0);
    for (int i = 0; i < MAX; i++)
        s[i + 1] = s[i] + a[i];

    int Q;
    cin >> Q;
    for (int q = 0; q < Q; q++) {
        int l, r;
        cin >> l >> r;

        cout << s[r + 1] - s[l] << endl;
    }
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-8;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// dp: 人iがj回目まででk回休憩する確率
// iがj回休憩して優勝する確率は (iがj回休憩する確率) * Π(j!=iがm回目まででpj回以上休憩する確率)
// pjは算数で求められる 累積和とっとくと楽そう
// t,vが0の場合に注意

int n, m, l, t[111], v[111];
double p[111], dp[111][55][55], r[111][55];

signed main() {
	cin >> n >> m >> l;
	rep(i,n) cin >> p[i] >> t[i] >> v[i];
	rep(i,n) p[i] /= 100;
	rep(i,n) {
		dp[i][0][0] = 1;
		rep(j,m) rept(k,j) {
			dp[i][j+1][k+1] += dp[i][j][k] * p[i];
			dp[i][j+1][k] += dp[i][j][k] * (1. - p[i]);
		}
		repr(j,m) r[i][j] = r[i][j+1] + dp[i][m][j];
	}
	rep(i,n) {
		double res = 0;
		rept(j,m) {
			if (v[i]==0) break;
			double ti = 1.*l/v[i] + 1.*j*t[i], pl = dp[i][m][j];
			rep(k,n) if (i!=k) {
				if (v[k]==0) continue; // 勝ち確
				if (t[k]==0) {
					if (deq(ti,1.*l/v[k]) || ti+eps>1.*l/v[k]) pl = 0;
					continue;
				}
				if (ti<1.*l/v[k]) continue; // kが休憩0でもiの方が速い場合
				int pj = ceil((ti-1.*l/v[k])/t[k]);
				if (deq((ti-1.*l/v[k])/t[k],pj)) pj++;
				if (pj>m) {
					pl = 0; // kが毎回休憩してもj回休憩したiより速い場合
					break;
				}
				else pl *= r[k][pj];
			}
			res += pl;
		}
		printf("%.14lf\n",res);
	}
}


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int lim = 3 * n / 2;
    if (k > 2 * n - lim) {
        cout << -1 << endl;
        return 0;
    }
    int l = 0, r = (3 * n - 1) / 2, cnt = 2 * n;
    while (l < r) {
        cout << l + k << " " << r + k << " " << (cnt++) + k << "\n";
        l += 2;
        --r;
    }
    l = 1;
    r = 2 * n - 1;
    while (l < n) {
        cout << l + k << " " << r + k << " " << (cnt++) + k << "\n";
        l += 2;
        --r;
    }
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
int dp[5001][5001];

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    for (int i = 0; i < 5001; i++)
        for (int j = 0; j < 5001; j++)
            dp[i][j] = 0;

    int l = 0;
    for (int i = 0; i < S.size()-1; i++) {
        for (int j = i+1; j < S.size(); j++) {
            if (S[i] == S[j] && j-dp[i][j] != i && i-dp[i][j] != j) {
                int m = max(dp[i][j] + 1, dp[i + 1][j + 1]);
                dp[i + 1][j + 1] = m;
                if (m > l) l = m;
            }
        }
    }

    cout << l << endl;
}

Measured memory_bytes: 98048
#include <iostream>
using namespace std;
#define int long long
signed main() {
  int x;
  cin>>x;
  int y1 = (x/500);
  int y2 = (x%500)/5;
  //cout<<y1<<" "<<y2<<"\n";
  cout<<(y1*1000 + y2*5)<<"\n";
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N;
ll A[101010];
ll X[101010];

int main() {
  cin >> N;
  ll sum = 0;
  ll sum_a_odd = 0;
  rep(i, 0, N) {
    cin >> A[i];
    sum += A[i];
    if (i % 2 == 1) {
      sum_a_odd += A[i];
    }
  }
  X[0] = sum - 2 * sum_a_odd;

  rep(i, 0, N - 1) {
    int idx = (2 * i) % N;
    int idx1 = (2 * i + 1) % N;
    int idx2 = (2 * i + 2) % N;
    X[idx2] = X[idx] - 2 * (A[idx] - A[idx1]);
  }

  rep(i, 0, N) {
    cout << X[i];
    if (i != N - 1) {
      cout << " ";
    }
  }
}


Measured memory_bytes: 2944
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if(a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if(a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end


 
int main(){
  int a,b; scanf("%d%d",&a,&b);
  rep(i,b-a+1,b+a)printf("%d ",i);
  return 0;
}

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

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

    int dish;
    int ans = 0;
    int last_rest = 0;
    for (int i = 0; i < 5; ++i) {
        cin >> dish;
        int dish_round_up = ((dish + 9) / 10) * 10;
        ans += dish_round_up;
        last_rest = max(last_rest, dish_round_up - dish);
    }
    cout << ans - last_rest << endl;
    return 0;
}


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

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

    int num = 1;
    int ans = 0;
    while(num <= n)
    {
        num = num * k;
        ans++;
    }

    cout << ans <<"\n";

    return 0;    

}


Measured memory_bytes: 256
N,T=map(int,input().split())
CT=[list(map(int, input().split())) for i in range(N)]
min_cost=10000
for i in CT:
    if i[1]>T:
        continue
    else:
        min_cost=min(min_cost,i[0])
if min_cost==10000:
    print("TLE")
else:
    print(min_cost)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N, Q;
int top = 0;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> Q;
    rep(_, 0, Q) {
        int t, k; cin >> t >> k;

        if (t == 0) {
            int ans = (top + k - 1) % N;
            printf("%d\n", ans + 1);
        } else {
            top = (top + k) % N;
        }
    }
}



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

int main() {
  int n, r, k, i;
  cin >> n;
  r = 0;
  k = 1;
  i = 1;
  while(i <= n) {
    k = k * 10;
    for(; i <= min(n, k-1); ++i)
      r++;
    k = k * 10;
    for(; i <= min(n, k-1); ++i);
  }
  cout << r << '\n';
  return 0;
}

Measured memory_bytes: 256