akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	
	string s; cin >> s;
	int n = s.size();
	
	int tmp1 = 0;
	for (int i = 0; i < n; i++) {
		char c;
		if (i % 2 == 0) {
			c = '0';
		}
		else {
			c = '1';
		}

		if (s[i] != c) {
			tmp1++;
		}
	}


	int tmp2 = 0;
	for (int i = 0; i < n; i++) {
		char c;
		if (i % 2 == 0) {
			c = '1';
		}
		else {
			c = '0';
		}

		if (s[i] != c) {
			tmp2++;
		}
	}
	
	int ans = min(tmp1, tmp2);

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
#define mod 1000000007

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

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void solve(){
    string s;
    cin>>s;
    ll sm = 0;
    for(char& c:s){
        sm += (c - '0');
    }
    if(sm%9 == 0){
        cout<<"Yes\n";
        return;
    }
    cout<<"No\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    // pre();
    while (t--)
        solve();

    return 0;
}

Measured memory_bytes: 3732
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))

ans=0
MIN=10000000000000
for i in range(n):
  now=t-h[i]*0.006
  dif=abs(a-now)
  if dif<MIN:
    MIN=dif
    ans=i
print(ans+1)
 

Measured memory_bytes: 3060
hw = input('')
h = int(hw.split(' ')[0])
w = int(hw.split(' ')[1])
if h == 1:
  # h=1の場合、移動できない
  result = 1
elif w == 1:
  # w=1の場合、移動できない
  result = 1
else:
  if h%2 == 0:
    if w%2 == 0:
      # 縦偶数ｘ横偶数
      result = w // 2  * h 
    else:
      # 縦偶数ｘ横奇数
      result = (w//2 + 1) * h//2 + (w//2 * h//2)
  else:
    if w%2 == 0:
      # 縦奇数ｘ横偶数
      result = (w//2) * h
    else:
      # 縦奇数ｘ横奇数
      result = (w//2 + 1) * (h//2+1) + ( (w//2) * (h//2))
print(result)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
from fractions import gcd

n, m = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
fact2 = 0
tmp = a[0]
while tmp > 0 and tmp % 2 == 0:
    tmp //= 2
    fact2 += 1

for item in a:
    cnt = 0
    while item > 0 and item % 2 == 0:
        item //= 2
        cnt += 1
    if cnt != fact2:
        print("0")
        exit()

lcm = 1
for item in a:
    lcm = (item//2) * lcm // gcd(item//2, lcm)
print((m + lcm) // (2 * lcm))

Measured memory_bytes: 16272
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,a,b;cin>>x>>a>>b;
  int c=abs(x-a);
  int d=abs(x-b);
  string s;
  if(c>d) s="B";
  else s="A";
  cout<<s<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
import decimal 
import math
D=decimal.Decimal
def resolve():
    N,=pin()
    p=[tupin() for i in range(N)]
    ans=0
    for j in range(N):
        x,y=p[j]
        X,Y=D(x),D(y)
        for k in range(N):
            a,b=p[k]
            A,B=D(a),D(b)
            ans+=math.sqrt((X-A)**2+(Y-B)**2)
    print(float(ans/N))
#%%submit!
resolve()



Measured memory_bytes: 61292
#include<stdio.h>
#include<iostream>
#define re register
using namespace std;
int n,t;
int main(){
  int ans=2e9;int n,T;scanf("%d%d",&n,&T);
  for(re int i=1;i<=n;i++){
    int c,t;scanf("%d%d",&c,&t);
    if(t<=T)ans=min(ans,c);
  }
  if(ans==2e9)puts("TLE");
  else printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,x,y;
  cin >> n >> x >> y;
  cout << min(x,y) << " ";
  if(x+y<=n) {
    cout << 0 << endl;
  }
  else {
    cout << x+y-n << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s; cin >> s;

    size_t N = s.length();
    for (size_t i = 0; i < N; i += 2) {
        if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
            return cout << "No" << "\n", 0;
        }
    }

    for (size_t i = 1; i < N; i += 2) {
        if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
            return cout << "No" << "\n", 0;
        }
    }

    cout << "Yes" << "\n";

    return 0;
}


Measured memory_bytes: 256
mod = 10**9+7
N = int(input())
x = list(map(int, input().split()))
dp = [[0] for _ in range(N)]
dp[0] = 0
f = 1
fact = [1]*N
for i in range(1, N):
    dp[i] = dp[i-1]*i+f
    dp[i]%=mod
    f*=i
    f%=mod
fact[-1] = 1
for i in range(N-1)[::-1]:
    fact[i] = fact[i+1]*(i+1)
    fact[i]%=mod
ans = 0
for i in range(N-1):
    ans+=dp[i+1]*fact[i+1]*(x[i+1]-x[i])%mod
    ans%=mod
print(ans)







Measured memory_bytes: 73880
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; cin>>t; while(t--)
typedef long long int ll;
#define mxn 200001
vector<int>adj[mxn];
map<pair<int,int>,int>mp;
ll n;
int solve(int node,vector<bool>&vis){
    queue<int>q;
    q.push(node);
    int count=0;
    vis[node]=true;
    while(!q.empty()){
        int node=q.front();
        q.pop();
        for(auto it:adj[node]){
            if(!vis[it]){
                q.push(it);
                vis[it]=true;
            }
        }
        count++;
    }
    return count;
}
int main() {
    FIO;
    //test
    {
       ll i,m,l,r;
       cin>>n>>m;
       for(int i=0;i<m;i++){
           cin>>l>>r;
           if(l>r){
               swap(l,r);
           }
           if(mp[{l,r}]==0){
               adj[l].push_back(r);
               adj[r].push_back(l);
           }
           mp[{l,r}]++;
       }
       ll ans=0;
       vector<bool>res(n+1,false);
       for(i=1;i<=n;i++){
           if(!res[i]){
               ans=max(ans,(ll)solve(i,res));
           }
       }
       cout<<ans<<endl;
    }
	return 0;
}


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

#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'

int main()
{
	long long n;
	
	cin >> n;
	
	cout << (n+1)/2 << endl;
}




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

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

    for(int i = n; i < 1e9; ++i){
        bool f=true;
        int num = i;
        while(num > 0){
            for(int j = 0; j < k; ++j){
                if(num % 10 == a[j]) f = false;
            }
            if(!f) break;
            num /= 10;
        }
        if(f){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

int main(){
	string s;
	cin>>s;
	string front="asdfg",mid="asdfghj",back="asdfg";
	for(int i=0;i<5;i++){
		front[i]=s[i];
	}
	for(int i=6;i<13;i++){
		mid[i-6]=s[i];
	}
	for(int i=14;i<19;i++){
		back[i-14]=s[i];
	}
	cout<<front<<" "<<mid<<" "<<back;
	return 0;
}

Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll digitcal(ll x){
  ll n=0;
  while(x>0){
    x/=10;
    n++;
  }
  return n;
}

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

int main() {
  string s;
  s="ACL";
  int k;
  cin>>k;
  for(int i=0;i<k;i++){
    cout<<s;
  }
  cout<<endl;
  return 0;
}

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

int main(){
    int n, m, c;
    cin >> n >> m >> c;

    int b[30];
    for(int i = 0;i < m;i++) cin >> b[i];


    int ans = 0;
    int a;
    for(int i = 0;i < n;i++){
        int num = 0;
        for(int j = 0;j < m;j++){
            cin >> a;
            num += a*b[j];
        }
        if(num+c > 0){
            ans++;
        }
    }

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





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

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s, t;
    cin >> s >> t;
    string sp, tp;
    sp = s; tp = t;
    map<char, char> stot, ttos;
    for(int i = 0; i < (int)s.size(); ++i)
    {
        stot[s[i]] = t[i];
        ttos[t[i]] = s[i];
    }
    for(int i = 0; i < (int)s.size(); ++i)
    {
        sp[i] = stot[s[i]];
        tp[i] = ttos[t[i]];
    }
    if ((sp == t) && (tp == s)) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 1112
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( ll i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MAX = 1000000000000000;

ll ans;
ll H;
int N;
vector<pair<ll, ll> > v;
ll dp[10005];


int main(void) {
    scanf("%lld %d", &H, &N);
    rep(i, 0, N) {
        ll A, B;
        scanf("%lld %lld", &A, &B);
        v.pb(mp(A, B));
    }

    rep(i, 0, H+1) dp[i] = MAX;
    dp[0] = 0;

    rep(i, 1, H+1) {
        rep(j, 0, N) {
            ll a = v[j].first, b = v[j].second;
            if (a >= i) {
                dp[i] = min(dp[i], b);
            } else {
                dp[i] = min(dp[i], dp[i-a]+b);
            }

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

	return 0;
}


Measured memory_bytes: 384
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[100005];
int paper;
int ans;
int main() {
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=1;i<=len;i++) {
		if(!paper) {
			if(s[i]=='p') ans--;
			paper++;
			continue;
		}
		if(s[i]=='p') paper--;
		if(s[i]=='g') ans++,paper--;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c,d=0;
scanf("%d %d %d %d",&a,&b,&c,&d);

for(int i=0;i<100;i++){
    c=c-b;
    if(c<=0){
        printf("Yes\n");
        break;
    }
    a=a-d;
    if(a<=0){
        printf("No\n");
        break;
    }
    
}


return 0;

}

Measured memory_bytes: 1620
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int INF = 1e+12;
int n, W;
int w[100], v[100];
int dp[101][101][301];	//dp[i][j][k] = 商品i個見た. (今までにj個入れて)合計重さ = j * w[0] + kである. このときの, 価値max.

signed main() {
	int i, j, k;
	
	cin >> n >> W;
	for (i = 0; i < n; i++) cin >> w[i] >> v[i];
	
	for (i = 0; i <= n; i++) for (j = 0; j <= n; j++) for (k = 0; k <= 300; k++) dp[i][j][k] = -INF;
	dp[0][0][0] = 0;
	
	for (i = 0; i < n; i++) {
		for (j = 0; j <= i; j++) {
			for (k = 0; k <= 3 * i; k++) {
				dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
				dp[i + 1][j + 1][k + w[i] - w[0]] = max(dp[i + 1][j + 1][k + w[i] - w[0]], dp[i][j][k] + v[i]);
			}
		}
	}
	
	int ans = 0;
	for (j = 0; j <= n; j++) {
		for (k = 0; k <= 300; k++) {
			if (j * w[0] + k <= W) {
				ans = max(ans, dp[n][j][k]);
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 24192
pr=2:q
q=3:5:7:3#q
m#(a:b:x)=[n|n<-[a^2,a^2+2..b^2-2],gcd n m<2]++(m*b)#(b:x)

main=do
  n<-readLn::IO Int
  putStrLn.unwords.map show.take n.filter(\p->(p`mod`5)==1).dropWhile(<10)$pr

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

int main()
{
	int a, b, n, i, j, p, q=0, r;
	cin >> n;
	cin >> a;
	cin >> b;
	for(i = 1; i <= n; i++)
	{
		p = 0;
		r = i;
		while(1)
		{
			p += r%10;
			r = r/10;
			if(r < 10)
			{
				p += r;
				break;
			}
		}
		if((p >= a) && (p <= b))
		{
			q += i; 
		}
	}
	cout << q << endl;
	return 0;
} 

Measured memory_bytes: 256
L = int(input())
A = [int(input()) for _ in range(L)]

dp = [0] * (L + 1)
dp[0] = [0] * 5

for i in range(L):
  dp[i + 1] = [0] * 5
  dp[i + 1][0] = dp[i][0] + A[i]
  cost1 = A[i] % 2 if A[i] != 0 else 2
  dp[i + 1][1] = min([dp[i][0] + cost1, dp[i][1] + cost1])
  cost2 = (A[i] + 1) % 2
  dp[i + 1][2] = min([dp[i][0] + cost2, dp[i][1] + cost2, dp[i][2] + cost2])
  cost3 = A[i] % 2 if A[i] != 0 else 2
  dp[i + 1][3] = min([dp[i][0] + cost3, dp[i][1] + cost3, dp[i][2] + cost3, dp[i][3] + cost3])
  dp[i + 1][4] = min([dp[i][0] + A[i], dp[i][1] + A[i], dp[i][2] + A[i], dp[i][3] + A[i], dp[i][4] + A[i]])

print(min(dp[L]))

Measured memory_bytes: 68148
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
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;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

vi A(3);
rep(i,3) cin >> A[i];
sort(all(A));
int K;
cin >> K;

int ans = A[0]+A[1]+A[2]*pow(2,K);

cout << ans << endl;



return 0;
}

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

int main () {

    int H, W;
    cin >> H >> W;

    char a[H][W];

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

    bool h[H], w[W];
    fill(h, h + H, false); fill(w, w + W, false);

    for (int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if (a[i][j] == '#') {
                h[i] = true;
                break;
            }
        }
    }

    for (int i = 0; i < W; i++) {
        for (int j = 0; j < H; j++) {
            if (a[j][i] == '#') {
                w[i] = true;
                break;
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (h[i] && w[j]) {
                cout << a[i][j];
            }
        }
        if (h[i]) {
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

LL const mod = 1e9 + 7, MAXN = 1e6 + 5;
LL f[MAXN];

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n; cin >> n;
  f[0] = f[1] = 1;
  LL sum = 2;
  for (RI i = 2; i <= n; ++i) {
    f[i] = (sum - f[i-2] + mod) % mod;
    sum = (sum + f[i]) % mod;
  }
  (f[n] += 1ll * (n - 1) * f[n - 1] % mod) %= mod;
  for (RI i = 2; i <= n; ++i)
    (f[n] += 1ll * (n - i + 1) * f [n - i] % mod) %= mod;
  LL ans = f[n];
  for (RI i = 0; i < n - 1; ++i)
    (ans += 1ll * (n - 1) * (n - 1) % mod * f[i]) %= mod;
  cout << ans << endl;
  
  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 8448
N,K = map(int, input().split())
H = [int(input()) for i in range(N)]
H.sort()

hold = 0
ans = 10 ** 9 + 1
for i in range(K-1,N):
    hold = H[i] - H[i-(K-1)]
    ans = min(ans, hold)
print(ans)

Measured memory_bytes: 13280
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())
  
a,b,c,d=input2()
x=[a,b]
y=[c,d]
ans=a*c
for i in x:
	for j in y:
		if i*j > ans:
			ans=i*j
print(ans)

Measured memory_bytes: 9160
n = int(input())
num_list = list(map(int, input().split()))
num_list.sort(reverse=True)
ans = 0

for i in range(n-1):
  ans += num_list[i] / 2**(i+1)

ans += num_list[n-1] / 2**(n-1)
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        Map<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            map.put(A[i],map.getOrDefault(A[i],0)+1);
        }

        int ans = 0;
        for (int i = 0; i < N; i++) {
            int tmp = A[i];
            List<Pair> primes = new ArrayList<>();
            for (int p = 2; p*p <= tmp; p++) {
                if (tmp%p != 0) continue;

                Pair pair = new Pair(p);
                while (tmp%p == 0) {
                    pair.cnt++;
                    tmp /= p;
                }
                primes.add(pair);
            }
            if (tmp != 1) primes.add(new Pair(tmp,1));
            /*
            for (Pair x : primes) {
                System.out.println(x.p + " " + x.cnt);
            }
            */
            map.put(A[i],map.get(A[i])-1);
            boolean found = find(primes, map, 0, 1);
            if (!found) {
                ans++;
            }
            map.put(A[i],map.get(A[i])+1);
        }

        System.out.println(ans);
    }

    private static boolean find(List<Pair> primes, Map<Integer,Integer> map, int now, int div) {

        if (now == primes.size()) {
            return map.get(div) != null && map.get(div) > 0;
        }

        Pair a = primes.get(now);
        int tmp = 1;
        for (int i = 0; i <= a.cnt; i++) {
            if (find(primes, map, now+1, div*tmp)) {
                return true;
            }
            tmp *= a.p;
        }
        return false;
    }

    private static class Pair {
        final int p;
        int cnt;
        Pair(int p) {
            this.p = p;
            this.cnt = 0;
        }
        Pair(int p, int cnt) {
            this.p = p;
            this.cnt = cnt;
        }
    }
}



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

N,M = map(int, input().split())

def find(x):
    if parents[x] < 0:
        return x
    else:
        parents[x] = find(parents[x])
        return parents[x]

def union(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return

    if parents[x] > parents[y]:
        x,y = y, x

    parents[x] += parents[y]
    parents[y] = x 

def same(x,y):
    return find(x) == find(y)

edges = []
for i in range(M):
    a, b = map(int, input().split())
    edges.append((a-1,b-1))

ans = 0
for i in range(M):
    parents = [-1] * N
    for j in range(M):
        if i == j:
            continue
        s, e = edges[j]
        union(s, e)
    a, b = edges[i]
    if not same(a, b):
        ans += 1
print(ans)

Measured memory_bytes: 41072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	int ind;
	rep(i,n){
		cin>>a[i];
		if(a[i]==1){
			ind=i;
		}
	}
	ll ans=inf;
	rep(i,k){
		ll nk=k-1;
		ll ret1=max(0ll,ind-i);
		ll ret2=max(0ll,n-ind-k+i);
		//cout<<ret1<<' '<<ret2<<endl;
		chmin(ans,(ret1+nk-1)/nk+(ret2+nk-1)/nk+1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, k;
   cin >> n >> k;
   cout << (n % k ? 1 : 0) << endl;
   return 0;
}


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

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  int c=0, mn=10000;
  for(int i=0;i<=(s.length()-t.length());i++) {
    c=0;
   	for(int j=0;j<t.length();j++) {
      if(s[i+j]!=t[j])
        c++;
    }
    if(c < mn)
      mn = c;
  }
  cout << mn;
  return 0;
}

Measured memory_bytes: 3632
#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++)

#define ALL(v) v.begin(), v.end()




 


int main() {
  
  
  vector<int64_t> L;
  int64_t N;
  int64_t count2 = 0;

  cin >> N;
  int64_t t;
  REP(i,N){
    cin >> t;
    L.push_back(t);
  }
  
  sort(ALL(L));
  int64_t res = 0;
  REP(i,N){
    FOR(j,i+1,N){
      int k = lower_bound(ALL(L), L[i]+L[j]) - L.begin();

      res += max(k-(j+1),0);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": # "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

int main()
{
	map<int,int> data[2];
	rep(i,2)
		for(char buf[100];fgets(buf,100,stdin) && buf[0]!='\n';){
			int n;
			sscanf(buf,"%d,%*d",&n);
			data[i][n]++;
		}
	map<int,int> res;
	tr(data[0],i)
		if(data[1][i->first])
			res[i->first]=i->second+data[1][i->first];
	tr(res,i)
		cout<<i->first<<" "<<i->second<<endl;
	
	return 0;
}

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

int main() {
	int n,t;cin>>n>>t;
	int a[100000];for(int i=0;i<n;i++)cin>>a[i];
	int maxa,mina;
	vector<int> v;
	maxa=0;mina=a[0];
	for(int i=1;i<n;i++)
	{
		if(maxa<=a[i]-mina)
		{
			maxa=a[i]-mina;
			v.push_back(maxa);
		}
		if(mina>a[i])mina=a[i];
	}
	sort(v.begin(),v.end());
	int c=1;for(int i=v.size()-2;i>=0;i--)
	{
		if(v[i]==v[i+1])c++;
		else break;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 1276
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
       String s=sc.next();
 		String[] a=s.split("");
  		

    
 	if(a[2].equals(a[3])&&a[4].equals(a[5])){
    		System.out.println("Yes");
    	}else{
     		System.out.println("No");
   	 }

    	
    }
}


Measured memory_bytes: 23636
def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    P = [(1+p)/2 for p in P]
    p_sum = [sum(P[:K])]
    for i in range(K, N):
        p_sum.append(p_sum[-1] - P[i-K] + P[i])
    print(max(p_sum))

if __name__ == '__main__':
    main()

Measured memory_bytes: 25060
N, W = gets.chomp.split(" ").map(&:to_i)
k1 = []
k2 = []
k3 = []
k4 = []
w1, v1 = gets.chomp.split(" ").map(&:to_i)
k1 << v1
(N - 1).times do
  w, v = gets.chomp.split(" ").map(&:to_i)
  case w
    when w1
      k1 << v
    when w1 + 1
      k2 << v
    when w1 + 2
      k3 << v
    when w1 + 3
      k4 << v
  end
end
k1.sort_by!{|a| -a}
(k1.length - 1).times do |i|
  k1[i+1] += k1[i]
end
k2.sort_by!{|a| -a}
(k2.length - 1).times do |i|
  k2[i+1] += k2[i]
end
k3.sort_by!{|a| -a}
(k3.length - 1).times do |i|
  k3[i+1] += k3[i]
end
k4.sort_by!{|a| -a}
(k4.length - 1).times do |i|
  k4[i+1] += k4[i]
end

def take(ary, n)
  if n == 0 then
    return 0
  else
    return ary[n-1]
  end
end

sum = 0
(k1.length + 1).times do |i|
  (k2.length + 1).times do |j|
    (k3.length + 1).times do |k|
      (k4.length + 1).times do |l|
        if w1 * i + (w1 + 1) * j + (w1 + 2) * k + (w1 + 3) * l <= W then
          sum = [sum, take(k1, i) + take(k2, j) + take(k3, k) + take(k4, l)].max
        end
      end
    end
  end
end

puts sum

Measured memory_bytes: 1788
#include <iostream>
#include <string>

using namespace std;

int main(void){
    int sc[26]={0};
    int tc[26]={0};
    string s,t;
    char box;
    int flag=0;
    cin >> s;
    cin >> t;
    for(int i=0;i<s.length();i++){
        box = s.front();
        s.erase(s.begin());
        s.push_back(box);
        if(s == t){
            flag = 1;
            break;
        }
    }
    if(flag)printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main() {
  int n; cin >> n;
  while(n--) {
    string s1, s2; cin >> s1 >> s2;
      int m = max(s1.size(), s2.size());
      while(m != s1.size()) s1 = '0' + s1;
      while(m != s2.size()) s2 = '0' + s2;
      string ans;
      int c = 0;
      for(int i = m-1; i >= 0; i--) {
        int sum = s1[i]-'0' + s2[i]-'0' + c;
        c = sum/10;
        sum %= 10;
        ans += sum + '0';
      }
      if(c == 1) ans += '1';
      reverse(all(ans));
      if(ans.size() <= 80) cout << ans << endl;
      else cout << "overflow" << endl;
  }
}

Measured memory_bytes: 1212
//my vegetable has exploded. :(
#include<bits/stdc++.h>
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MM(x,y) memset(x,y,sizeof(x))
#define MCPY(a,b) memcpy(a,b,sizeof(b))
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define fi first
#define se second
using namespace std;
#define nl puts("")
#define int long long

inline int quickpow(int m,int n,int p){int b=1;while(n){if(n&1)b=b*m%p;n=n>>1;m=m*m%p;}return b;}
inline int getinv(int x,int p){return quickpow(x,p-2,p);}
inline int read(void){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){f=ch=='-'?-1:1;ch=getchar();}
    while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x * f;
}
const int MAXN = 4e5 + 10;
const int Mod = 998244353;
const int inv2 = getinv(2,Mod);
int inv[MAXN],fac[MAXN],n,m,Ans;
char A[MAXN],B[MAXN],C[MAXN],D[MAXN];
int a[MAXN],b[MAXN];
inline void init(void){
    inv[0]=inv[1]=fac[0]=1;
    rep(i,1,4e5) fac[i] = 1LL * fac[i-1] * i % Mod;
    inv[400000] = getinv(fac[400000],Mod);
    per(i,4e5-1,1) inv[i] = inv[i+1] * (i+1) % Mod;
}
///------------------head------------------
inline int Combine(int n,int m){return fac[n] * inv[m] % Mod * inv[n-m] % Mod;}
inline void calc(int n,int m,char *A,char *B,char *C,char *D){
    MM(a,0); MM(b,0);
    a[0] = b[m+1] = 1;
    int c1=0,c2=0,ret=0;
    rep(i,1,n) c2 += A[i] == '1';
    rep(i,1,m){
        if (D[i]=='1') ++c1;
        if (C[i]=='1') ++c1;
        a[i] = Combine(c1+c2,c1);
        if (c1) a[i] = (a[i] - Combine(c1+c2-1,c1-1) + Mod) % Mod;
    }
    c1 = 0,c2 = 0;
    rep(i,1,n) c2 += B[i] == '1';
    per(i,m,1){
        if (D[i]=='1') ++c1;
        if (C[i]=='1') ++c1;
        b[i] = Combine(c1+c2,c1);
        if (c1) b[i] = (b[i] - Combine(c1+c2-1,c1-1) + Mod) % Mod;
    }
    int t = 1;
    rep(i,0,m) {
        if (i > 0 && C[i] == '1' && D[i] == '1') t = t * inv2 % Mod;
        a[i] = a[i] * t % Mod;
        if (i <= m && C[i+1] == '0' && D[i+1] == '0') a[i] = 0;
    }
    rep(i,1,m) a[i]=(a[i-1]+a[i])%Mod;
    t=1;
    rep(i,1,m+1)
    {
        b[i] = b[i] * t % Mod;
        if (i <= m && C[i] == '1' && D[i] == '1') t = t * 2 % Mod;
        if (i > 1 && C[i-1] == '0' && D[i-1] == '0') b[i] = 0;
    }
    rep(i,1,m) ret = (ret + a[i-1] * b[i+1]) % Mod;
    Ans = (Ans + ret) % Mod;
}
signed main(signed argc, char *argv[])
{
    // freopen("a01.txt","r",stdin);
    // freopen("my.out","w",stdout);
    init();
    n=read();m=read();
    scanf("%s",A+1); scanf("%s",B+1); scanf("%s",C+1); scanf("%s",D+1);
    int ok=0;
    rep(i,1,n) ok|=(A[i]=='1')|(B[i]=='1');
    rep(i,1,m) ok|=(C[i]=='1')|(D[i]=='1');
    if (!ok) return puts("1"),0;
    calc(n,m,A,B,C,D); calc(m,n,C,D,A,B);
    printf("%lld\n",Ans % Mod);
    return 0;
}

/* Examples: */
/*

*/

/*

*/


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<long long>;
using ld = long double;

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  int n, x;
  cin >> n >> x;

  vi bi(n), li(n), ui(n);
  for (int i = 0; i < n; ++i) {
    cin >> bi[i] >> li[i] >> ui[i];
  }

  vector<ll> score_inc(n);
  vector<ll> score(n);
  for (int i = 0; i < n; ++i) {
    score[i] = (ll)ui[i] * (x - bi[i]);
    score_inc[i] = (ll)ui[i] * x - (ll)(ui[i] - li[i]) * bi[i];
  }
  vector<int> order(n);
  iota(ALL(order), 0);
  sort(ALL(order), [&](int lhs, int rhs) {
        return score_inc[lhs] > score_inc[rhs];
        //return score[lhs] > score[rhs];
      });

  debug(score_inc, order);

  auto CanWin = [&](ll tm) {
    const int num_taken = min<ll>(n, tm / x);
    ll tot_score = 0;
    vector<bool> is_taken(n);
    for (int i = 0; i < num_taken; ++i) {
      const int v = order[i];
      is_taken[v] = true;
      tot_score += score[v];
    }
    //if (tot_score >= 0) { return true; }
    ll next_taken = num_taken < n ? score_inc[order[num_taken]] : 0ll;
    debug(tm, tot_score, next_taken);

    int rem_tm = tm % x;
    ll best_diff = 0;
    for (int i = 0; i < n; ++i) {
      const ll start = (ll)li[i] * (-bi[i]);
      ll coef = (rem_tm >= bi[i]) ? ui[i] : li[i];
      ll best = coef * (rem_tm - bi[i]);
      debug(i, best, score_inc[i], next_taken);
      if (is_taken[i]) {
        best -= score_inc[i];
        best += next_taken;
      } else {
        tot_score += start;
      }
      maxi(best_diff, best - start);
    }
    debug(tot_score, best_diff);

    tot_score += best_diff;
    return tot_score >= 0;
  };

  ll min_x = -1, max_x = 1e12;

  while (max_x - min_x > 1) {
    auto mid_x = (min_x + max_x) / 2;
    if (CanWin(mid_x)) {
      max_x = mid_x;
    } else {
      min_x = mid_x;
    }
  }

  cout << max_x << "\n";
}



Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		int a,m1=0,m2=0;
		bool ans=true;
		for(int j=0;j<10;j++){
			cin >> a;
			if(m1<a) m1=a;
			else if(m2<a) m2=a;
			else ans=false;
			if(m1<m2) swap(m1,m2);
		}
		cout << (ans ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include"bits/stdc++.h"
#include<iostream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const ll inf = ll(1e18)+1;

int main() {
	string s, t, u;
	int a, b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if (s == u) {
		a--;
	}
	else {
		b--;
	}

	cout << a <<' '<< b << endl;
	return 0;
}

Measured memory_bytes: 3624
/*
"Won't stop untill I'm Phenomenal"
- Phenomenal, EMINEM
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    int x; cin>>x;
    cout<<(!x)<<endl;
    return 0;
}

Measured memory_bytes: 3584
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {
	public final static int maxn = 100005;
	public long[] a = new long[maxn];
	
	public void solve(InputReader in, PrintWriter out) {
		int n = in.nextInt(), k = in.nextInt();
		int i, j;
		long ans = 0;
		
		for (i=1; i<=n; ++i)
			a[i] = in.nextLong();
		
		if (a[1] > k) {
			ans += a[1] - k;
			a[1] = k;
		}
		for (i=2; i<=n; ++i) {
			//out.println(a[i]+a[i-1]);
			if (a[i]+a[i-1] > k) {
				ans += (a[i]+a[i-1]) - k;
				a[i] = k - a[i-1];
			}
		}
		// for (i=1; i<=n; ++i)
			// out.print(a[i] + " ");
		// out.println();
		
		out.println(ans);
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;
	
	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}
	
	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 41916
#include<stdio.h>
long long N, ans;
int ossu(long long a, long long b3, long long b5, long long b7){
	if(a>N){return;}
	if(b3+b5+b7==3){ans++;}
	ossu(a*10+3, 1, b5, b7);
	ossu(a*10+5, b3, 1, b7);
	ossu(a*10+7, b3, b5, 1);
}
int main(){
	scanf("%lld", &N);
	ossu(0, 0, 0, 0);
	printf("%lld\n", ans);
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.math.BigDecimal;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);
	int m = sc.nextInt();
	
	for(int k = 0; k < m; k++){
	    String str = sc.next();
	    BigDecimal def = new BigDecimal(str);
	    int y = sc.nextInt();
	    int n = sc.nextInt();
	    BigDecimal bdm = new BigDecimal(0);

	    for(int i = 0; i < n; i++){
		int s = sc.nextInt();
		str = sc.next();
		BigDecimal bd2 = new BigDecimal(str);
		str = sc.next();
		BigDecimal bd3 = new BigDecimal(str);
		BigDecimal bd = def;
		BigDecimal bd4 = new BigDecimal(0);
		if(s == 1){
		    for(int j = 0; j < y; j++){
			bd4 = bd.multiply(bd2);
			bd4 = bd4.setScale(0, BigDecimal.ROUND_DOWN);
			bd = bd4.add(bd);
			bd = bd.subtract(bd3);
		    }
		} else {
		    for(int j = 0; j < y; j++){
		        bd4 = bd4.add(bd2.multiply(bd));
			bd4 = bd4.setScale(0, BigDecimal.ROUND_DOWN);
			bd = bd.subtract(bd3);
		    }
		    bd = bd.add(bd4);
		}
		if(bdm.compareTo(bd) == -1){
		    bdm = bd;
		}
	    }
	    System.out.println(bdm.toString());
	}
    }

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

Measured memory_bytes: 13000
using System;

namespace AtC168
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int len = S.Length;
            string ans = "";
            if (K >= len) ans = S;
            else
            {
                ans = S.Substring(0,K);
                ans = ans + "...";
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27544
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
const ll INF = 1e18;

#define vll vector<ll>
#define rep(i, N) for (int i = 0; i < N; i++)

int main() {
    int N; ll T; cin >> N >> T;
    vll t(N); rep(i, N) cin >> t[i];
    t.push_back(INF);

    ll ans = 0;
    rep(i, N) ans += min(T, t[i + 1] - t[i]);

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

Measured memory_bytes: 4736
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        
        int second = scan.nextInt();
        int hour = second/3600;
        if (hour != 0 ) second = second % 3600;
        int minute = second/60;
        if (minute  != 0 ) second = second % 60;
        
        System.out.println(hour + ":" + minute + ":" + second);
    }
}



Measured memory_bytes: 26228
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main(void){
    while (true){
        int h, w;
        cin >> h >> w;
        if (h == 0 || w == 0) break;
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if (j == 0 || j == w - 1 || i == 0 || i == h - 1) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <limits.h>

int main(void){
	int x,y,z,x3,z3;
	int sum,max;

	while(scanf("%d",&z) && z){
		max = INT_MIN;
		z3 = z*z*z;

		for(x=1;(x3=x*x*x)<=z3;x++){
			for(y=1;(sum=x3+y*y*y)<=z3;y++){
				if(max < sum) max = sum;
			}
		}

		printf("%d\n",z3-max);
	}

	return 0;
}

Measured memory_bytes: 404
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cmath>
#include <iomanip>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {
	
	uint N;
	cin >> N;
	
	vector<int> x(N);
	vector<int> y(N);
	
	ull n2 = 1;
	for(uint i=0; i<N; i++) {
		cin >> x[i] >> y[i];
		n2 *= i + 1;
	}
	
	vector<uint> index(N);
	iota(index.begin(), index.end(), 0);
	
	vector<double> d(n2);
	uint j = 0;
	do {
		double dist = 0;
		for(uint i=1; i<N; i++) {
			dist += sqrt(pow(x[index[i]] - x[index[i-1]], 2) + pow(y[index[i]] - y[index[i-1]], 2));
		}
		d[j] = dist;
		j++;
	} while(next_permutation(index.begin(), index.end()));
	
	double ans = accumulate(d.begin(), d.end(), double(0)) / n2;
	
	cout << std::setprecision(7) << ans;
	return 0;
}


Measured memory_bytes: 512
// Problem : F - Division or Substraction
// Contest : AtCoder Beginner Contest 161
// URL : https://atcoder.jp/contests/abc161/tasks/abc161_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#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;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

bool simulate(ll n, ll i) {
	while (n % i == 0) n /= i;
	return n % i == 1;
}
set<ll> cnt;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	if (n == 2) { cout << 1 << endl; return 0; }
	for (ll i = 2; i * i <= n; i++) {
		if (simulate(n, i)) cnt.insert(i);
	}
	n--;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			cnt.insert(n / i);
		}
	}
	cnt.insert(n + 1);
	cout << sz(cnt) << endl;
	return 0;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >>a>>b;
    if(a==b) {cout << "Draw"; return 0;}
    if(a==1  ) {cout << "Alice"; return 0;} 
    if(b==1 ) {cout << "Bob"; return 0;}
    if(a>b) cout << "Alice";
    else cout << "Bob";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD_add(i,j) i=(i+j)%P
#define MOD_sub(i,j) i=(i-j+P)%P
#define	dp(i) DP[i-A]
#define int long long
using namespace std;
const int N = 100005;
int A, B, P, DP[N], ANS;
inline int tenPow(int x) {
	int cnt = 0;
	while (x > 0)
		x /= 10, cnt++;
	return pow(10, cnt-1);
}
inline void updateDP(int x) {
	int newVal = dp(x), t = x;
	while (t < B) {
		MOD_add(dp(t+(t==x)), newVal);
		t *= 10;
		MOD_sub(dp(min(tenPow(t), B)), newVal);
	}
}
signed main() {
	while (cin >> A >> B >> P, A | B | P) {
		memset(DP, 0, sizeof(DP)), DP[0] = 1, ANS = 0, B++;
		for (int i = A; i < B; i++) {
			if (i > A)
				MOD_add(dp(i),dp(i-1));
			updateDP(i);
			MOD_add(ANS, dp(i));
		}
		cout << ANS << endl;
	}
	return 0;
}

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

using namespace std;

#define fast_io ios::sync_with_stdio(false); cin.tie(NULL);

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

	if (a <= 8 && b <= 8)	
		cout << "Yay!";
	else
		cout << ":(";
	
	return 0;
}


Measured memory_bytes: 256