akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll MOD = 1e9+7;
const ll N = 1e7+10;
ll f[N], rf[N];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(int i = 1; i < N; i++) f[i] = (f[i - 1] * i) % MOD;
    rf[N - 1] = inv(f[N - 1]);
    for(int i = N-2; i >= 0; i--) rf[i] = (rf[i + 1] * (i + 1)) % MOD;
}
ll C(int n, int k) {
    if(k < 0 || n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!^(-1)
    ll c = rf[k]; // = k!^(-1)
    ll bc = (b * c) % MOD;
    return (a * bc) % MOD;
}
ll p(int n, int k) {
    if (k < 0 || n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n - k]; // = (n-k)!^(-1)
    return (a * b) % MOD;
}
ll H(int n, int k) {
    if (n == 0 && k == 0) return 1;
    return C(n + k - 1, k);
}
ll mod_pow(ll x, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n & 1)
        {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

int main()
{
    init();
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();
    int m = k + n;
    vector<ll> tf(m+1, 0);
    vector<ll> ts(m+1, 0);
    tf[0] = 1;
    ts[0] = 1;
    for(int i = 0; i < m; i++)
    {
        tf[i+1] = tf[i] * 25 % MOD;
        ts[i+1] = ts[i] * 26 % MOD;
    }
    ll ans = 0;
    for(int i = 0; i <= m; i++)
    {
        if(k-i < 0) break;
        ll tmp = (C(m-i-1, n-1) * tf[k-i]) % MOD;
        tmp = (tmp * ts[i]) % MOD;
        ans = (ans+tmp) % MOD;
    }
    cout << (ans+MOD) % MOD << endl;
}


Measured memory_bytes: 191800
import java.util.Scanner;

public class Main {

	void run() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			for (int i=0;i<m;i++) {
				n -= sc.nextInt();
			}
			
			System.out.println(n < 0 ? -1 : n);
		}
	}

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

}


Measured memory_bytes: 46148
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#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,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}



int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    vector<int> r(n);
    REP(i,n){
        cin >> l[i] >> r[i];
    }
    int res = 0;
    REP(i,n){
        res += r[i]-l[i]+1;
    }
    put(res);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sc(v) v.size()
#define eb push_back
#define pb pop_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define TC() int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define mk make_pair
#define fi first
#define se second
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

int main()
{
	int r;
	cin>>r;
	cout<<(3*r*r)<<"\n";
    return 0;
}


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

const int INF = 100000000;

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(2, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 2; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'0'] = i;
    }
    return res;
}

int main(){
    //input
    string P,Q;
    cin >> P >> Q;

    //calc
    vector<vector<int> > nextP = calcNext(P);
    vector<vector<int> > nextQ = calcNext(Q);
    int n=P.length(), m=Q.length();
    vector<vector<int> > dp(n+1,vector<int>(m+1,INF));
    int i,j,k;
    for(i=n; i>=0; i--){
        for(j=m; j>=0; j--){
            for(k=0; k<=1; k++){
                if(nextP[i][k]>=n && nextQ[j][k]>=m){
                    dp[i][j]=1;
                }else if(nextP[i][k]>=n){
                    dp[i][j]=min(dp[i][j],dp[n][nextQ[j][k]+1]+1);
                }else if(nextQ[j][k]>=m){
                    dp[i][j]=min(dp[i][j],dp[nextP[i][k]+1][m]+1);
                }else{
                    dp[i][j]=min(dp[i][j],dp[nextP[i][k]+1][nextQ[j][k]+1]+1);
                }
            }
        }
    }

    //output
    int nowi=0, nowj=0;
    while(dp[nowi][nowj]>1){
        for(k=0; k<=1; k++){
            if(nextP[nowi][k]+1>n&&nextQ[nowj][k]+1>m){
                cout << k;
                nowi = n;
                nowj = m;
                break;
            }else if(nextP[nowi][k]+1>n){
                if(dp[nowi][nowj]==dp[n][nextQ[nowj][k]+1]+1){
                    cout << k;
                    nowi = n;
                    nowj = nextQ[nowj][k]+1;
                    break;
                }
            }else if(nextQ[nowj][k]+1>m){
                if(dp[nowi][nowj]==dp[nextP[nowi][k]+1][m]+1){
                    cout << k;
                    nowi = nextP[nowi][k]+1;
                    nowj = m;
                    break;
                }
            }else if(dp[nowi][nowj]==dp[nextP[nowi][k]+1][nextQ[nowj][k]+1]+1){
                cout << k;
                nowi = nextP[nowi][k]+1;
                nowj = nextQ[nowj][k]+1;
                break;
            }
        }
    }
    for(k=0; k<=1; k++){
        if(nextP[nowi][k]>=n && nextQ[nowj][k]>=m){
            cout << k << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 65896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<ll> x(101,0 );
  for (ll i = a; i < b;i++){
    x[i]++;
  }
  for (ll i = c; i < d;i++){
    x[i]++;
  }
  ll ans = 0;
  rep(i,101){
    if(x[i]==2){
      ans++;
    }
  }
  print(ans);
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    s,p,r = map(int, input().split())
    t = input().rstrip()
    hasi = []

    res = 0
    for i in range(n):
        if t[i]=='r':
            a = r
            b = 'p'
        if t[i]=='s':
            a = s
            b = 'r'
        if t[i]=='p':
            a = p
            b = 's'
        if i<k:
            res += a
            hasi.append(b)
        else:
            if t[i]==t[i-k] and b in hasi[i-k]:
                hasi.append('x')
                continue
            else:
                res += a
                hasi.append(b)
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 53488
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
#define mm 1000000007
LL pp(LL x,LL nn)
{
	LL res=1;
	while(nn>0)
	{
		if(nn&1)
		res=(res*x)%mm;
		x=(x*x)%mm;
		nn/=2;
	}
	return res;
}
LL n,a[100005],s,flap;

int main()
{
	while(cin>>n)
	{
		flap=0;
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
		}
		sort(a,a+n);
		if(n%2!=0)
		{
			if(a[0]==0)
			flap=1;
			if(a[0]!=0)
			flap=0;
			for(int i=1;i<n;i++)
			{
				if(i%2==0&&a[i]==i||i%2!=0&&(a[i]-1)==i)
				flap=1;
				else
				{
					flap=0;
					break;
				}
			}
		}
		else
		{
			for(int i=0;i<n;i++)
			{
				if(i%2==0&&(a[i]-1)==i||i%2!=0&&a[i]==i)
				flap=1;
				else
				{
					flap=0;
					break;
				}
			}
		}
		s=n/2;
		//cout<<s<<' ';
		if(flap==1)
		cout<<pp(2,s)<<endl;
		else
		cout<<0<<endl;
	}
	return 0;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
int main(){
  ll k,a,b;
  cin>>k>>a>>b;
  for(ll i=a;i<=b;i++){
    if(i%k==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX=10000;
static const int INFTY=(1<<20);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n;
vector<pair<int,int> >adj[MAX];

void dijkstra(){
  priority_queue<pair<int,int> > PQ;
  int d[MAX],color[MAX];
  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  PQ.push(make_pair(0,0));
  color[0]=GRAY;

  while(!PQ.empty()){
    pair<int,int>f=PQ.top();
    PQ.pop();
    int u=f.second;
    color[u]=BLACK;

    if(d[u]<f.first*(-1)) continue;

    for(int j=0;j<adj[u].size();j++){
      int v=adj[u][j].first;
      if(color[v]==BLACK) continue;
      if(d[v]>d[u]+adj[u][j].second){
        d[v]=d[u]+adj[u][j].second;
        PQ.push(make_pair(d[v]*(-1),v));
        color[v]=GRAY;
      }
    }
  }

  for(int i=0;i<n;i++){
    cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
  }
}

int main(){
  int k,c,u,v;
  cin>>n;

  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      adj[u].push_back(make_pair(v,c));
    }
  }
  
  dijkstra();

  return 0;
}



Measured memory_bytes: 7988
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    std::sort(a.begin(), a.end());
    if(a[n - 1] == a[n -2]){
        for(int i = 0; i < n; i++){
            cout << a[n-1] << endl;
        }
    }else{
        for(int i = 0; i < n; i++){
            if(b[i] == a[n-1]){
                cout << a[n-2] << endl;
            }else{
                cout << a[n-1] << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  string c;
  cin>>c;
  vector<char>vec(c.size());
  for(int i=0;i<c.size();i++){
    vec.at(i)=c.at(i);
  }
  if(a>0){
  for(int i=0;i<vec.size();i++){
    for(ll j=0;j<a;j++){
      if(vec.at(i)=='Z')vec.at(i)='A';
    else vec.at(i)+=1;
    }
  }
  }
  
  for(int i=0;i<vec.size();i++){
    cout<<vec.at(i);
  }
  return 0;
}
     


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

int main (){
  int A,B,C,X;
  cin >> A >> B >> C >>X;
  //int n = x/50;
  
  int cnt =0;
  for(int i =0;i<=A;i++){
   for(int j=0;j<=B;j++){
     for(int k=0;k<=C;k++){
       if(500*i+100*j+50*k ==X)cnt++;
     }
   }
  }
  
  cout <<cnt<<endl;
  
}



Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define f(i,x,n) for(ll i=x;i<n;i++)
using namespace std;
  char a[1000][1000];
  ll dp[1000][1000];
  ll comp(int n, int m){
  	if(dp[n][m]!=-1) return dp[n][m];
  	if(n<0 || m<0) return 0;
  	dp[n][m]=0;
  	if(n>0) if(a[n-1][m]=='.') dp[n][m]+=comp(n-1,m);
  	if(m>0) if(a[n][m-1]=='.') dp[n][m]+=comp(n,m-1);
  	return (dp[n][m] %mod);
  }
int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m; cin>>n>>m;
    f(i,0,n) f(j,0,m) cin>>a[i][j];
     memset(dp,-1,sizeof(dp));
    dp[0][0]=1;
    ll ans=comp(n-1,m-1);
    cout<<ans;
		

	
	
	
	
	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 = 1e9;
const LL LLINF = 1e16;

int main(){
    int n, k;
    cin >> n >> k;
    double ans = 0;
    rep1(i, n+1){
        LL tmp = i, ct = 1;
        while(tmp < k){ tmp*=2; ct*=2;}
        ans += 1./ct;
    }
    ans /= 1.*n;
    cout << decimal << ans << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define mod 1000000007

int main() {
  ll n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a[i];
  vll cnt(60);
  rep(i,n)rep(j,60) if(a[i]>>j&1LL) cnt[j]++;
  ll ans = 0LL;
  rep(i,60) {
    ll tmp = cnt[i]*(n-cnt[i]);
    rep(j,i) {
      tmp *= 2LL;
      tmp %= mod;
    }
    ans += tmp;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

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


int main()
{
	int X, A, B;
	cin >> X >> A >> B;
	if (B - A > X) {
		cout << "dangerous" << endl;
	}else if(B<=A){
		cout << "delicious" << endl;
	}
	else {
		cout << "safe" << endl;

	}
    return 0;
}

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

using namespace std;

long long euclid(long long m, long long n){
  if(n==0){
    return m;
  }
  return euclid(n, m%n);
}

long long Gcd(long long m, long long n){
  if(m>n){
    return euclid(m,n);
  }else{
    return euclid(n,m);
  }
}

long long Lcm(long long m, long long n){
  return m*n/Gcd(m,n);
}


int main(){
  long long input_data;

  long long m,n;
  int i;

  cin >> m >> n;

  cout << Lcm(m,n) << endl;


  return 0;
}


Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
def do():
    a,b=STRM()
    if (a=='H' and b=='H') or (a=='D' and b=='D'):
        print('H')
    else:
        print('D')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include <cstdio>

using namespace std;

int p[100000];
int par[100000];

int find(int x) {
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    
    if (par[x] == y) return;
    
    par[x] = y;
}

int main() {
    int n, m, ans = 0, i;
    
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &p[i]);
        p[i]--;
    }
    
    for (i = 0; i < n; i++) par[i] = i;
    
    for (i = 0; i < m; i++) {
        int x, y;
        
        scanf("%d %d", &x, &y);
        
        x--;
        y--;
        
        unite(x, y);
    }
    
    for (i = 0; i < n; i++) {
        if (find(i) == find(p[i])) ans++;
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;
#define sd(n) scanf("%d", &n)
#define sdd(n, m) scanf("%d%d", &n, &m)
#define sddd(n, m, k) scanf("%d%d%d", &n, &m, &k)
#define pd(n) printf("%d\n", n)
#define pc(n) printf("%c", n)
#define pdd(n, m) printf("%d %d\n", n, m)
#define pddd(n, m, z) printf("%d %d %d\n", n, m, z)
#define pld(n) printf("%lld\n", n)
#define pldd(n, m) printf("%lld %lld\n", n, m)
#define plddd(n, m, z) printf("%lld %lld %lld\n", n, m, z)
#define sld(n) scanf("%lld", &n)
#define sldd(n, m) scanf("%lld%lld", &n, &m)
#define slddd(n, m, k) scanf("%lld%lld%lld", &n, &m, &k)
#define sf(n) scanf("%lf", &n)
#define sc(n) scanf("%c", &n)
#define sff(n, m) scanf("%lf%lf", &n, &m)
#define sfff(n, m, k) scanf("%lf%lf%lf", &n, &m, &k)
#define ss(str) scanf("%s", str)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = a; i >= n; i--)
#define mem(a, n) memset(a, n, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ce i == n ? '\n' : ' '
#define mod(x) ((x) % MOD)
#define gcd(a, b) __gcd(a, b)
#define lowbit(x) (x & -x)
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
inline int read()
{
	int ret = 0, sgn = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9')
	{
		if (ch == '-')
			sgn = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		ret = ret * 10 + ch - '0';
		ch = getchar();
	}
	return ret * sgn;
}
inline void Out(int a) //ê?3?ía1ò
{
	if (a > 9)
		Out(a / 10);
	putchar(a % 10 + '0');
}

ll gcd(ll a, ll b)
{
	return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
///快速幂m^k%mod
ll qpow(ll x, ll n, ll mod)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = x * x % mod, n >>= 1;
	}
	return res;
}

ll n, k;

int main()
{
	sldd(n, k);
	ll ans = INF;
	ll res;
	if (n > k)
		n %= k;
	while (1)
	{
		res = abs(n - k);
		if (res > ans)
			break;
		ans = min(ans, res);
		n = res;
	}
	pld(ans);
	return 0;
}


Measured memory_bytes: 256
a = int(input().rstrip())
b = int(input().rstrip())
c = int(input().rstrip())
x = int(input().rstrip())

counter = 0

for i in range(0, a + 1):
    sum_a = i * 500
    if sum_a > x:
        continue
    for j in range(0, b + 1):
        sum_b = j * 100
        sum_ab = sum_a + sum_b
        if sum_ab > x:
            continue
        for k in range(0, c + 1):
            sum_c = k * 50
            sum_abc = sum_ab + sum_c
            if sum_abc > x:
                continue
            elif sum_abc == x:
                counter += 1

print(counter)


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int a[2];
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='Z'){a[0]=i;}
    }
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            a[1]=i;
            break;
        }
    }
    cout << a[0]-a[1]+1 << endl;


    return 0;
}

Measured memory_bytes: 720
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
INF = float('inf')
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

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

        if x == y:
            return

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

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = inpl()
uf = UnionFind(N)
for i in range(M):
    a,b = inpl()
    uf.union(a-1,b-1)

print(uf.group_count() - 1)

Measured memory_bytes: 76360
S = input()
if S[0] == "A":
    count = 0
    S2 = S[2:-1]
    for i in S2:
        if i == "C":
            count += 1
    if count == 1:
        S3 = S[1:].replace("C","")
        if S3.islower():
            print("AC")
            exit()
print("WA")

Measured memory_bytes: 3060
using System;

class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            if (S.Length == N)
            {
                if (N % 2 == 1)
                {
                    //奇数のときは繰り返しはない？？？
                    Console.WriteLine("No");
                }
                else
                {
                    var fronthalf = S.Substring(0, N / 2);
                    var rearhalf = S.Substring(N / 2, N / 2);

                    if (fronthalf == rearhalf)
                    {
                        Console.WriteLine("Yes");
                    }
                    else
                    {
                        Console.WriteLine("No");
                    }
                }
            }

  
        }
    }

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)

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

  priority_queue< double, vector<double>, greater<double> > q;
  rep(i, n) {
    double x;
    cin >> x;
    q.push(x);
  }
  
  while (q.size() > 1) {
    double v1 = q.top();
    q.pop();
    double v2 = q.top();
    q.pop();
    double v = (v1 + v2) / 2.0;
    q.push(v);
  }
  
  double ans = q.top();
  cout << ans << endl;
}


Measured memory_bytes: 256
N, X, D = map(int, input().split())
if D == 0:
    r = N*(X!=0)+1
else:
    d=dict()
    for k in range(N+1):
        M = (k*X)%D
        F = (k*X)//D + ((k-1)*k)//2 #(1..k-1)
        L = (k*X)//D + (2*N-k-1)*k//2# (N-k..N-1)
        if M not in d:
            d[M] = list()
        d[M].append((F,-1))
        d[M].append((L,1))
    r = 0
    for m in d:
        fc=f=0
        for x in sorted(d[m]):
            r+=(x[0]-f+1)*(fc<2)*(x[1]>0)
            fc-=x[1]
            f=(fc==1)*x[0]*(x[1]<0)+f*(x[1]>0 or fc!=1)
print(r)


Measured memory_bytes: 91480
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[][] dice = new int[N][2];
    for(int i = 0; i < N; i++){
      dice[i][0] = scan.nextInt();
      dice[i][1] = scan.nextInt();
    }
    
    int count = 0;
    String judge = "No";
    for(int[] roll: dice){
      if(roll[0] != roll[1]){
        count = 0;
      } else {
        count += 1;
      }
      
      if(count == 3){
        judge = "Yes";
        break;
      }
    }
    
    System.out.println(judge);	
  }
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main() {
int n,k;
cin>>n>>k;
int p[n];
rep(i,n){
    cin>>p[i];
}
sort(p,p+n);
int ans=0;
rep(i,k){
ans+=p[i];
}
cout<<ans<<endl;
    return 0;
}


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

int main (){
  string a,b;
  cin>>a>>b;
  
  if(a=="H"){
    if(b=="H"){
      cout<<"H"<<endl;
    }
    if(b=="D"){
      cout<<"D"<<endl;
    }
  }
  if(a=="D"){
    if(b=="H"){
      cout<<"D"<<endl;
    }
    if(b=="D"){
      cout<<"H"<<endl;
    }
  }
}

Measured memory_bytes: 256
def main():
    X = int(input())
    for A in range(-119, 119):
        flag = False
        for B in range(-119, 119):
            if A**5 - B**5 == X:
                print(A, B)
                flag = True
                break
        if flag:
            break
if __name__ == '__main__':
    main()

Measured memory_bytes: 63720
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    if ( a==b && b == c){
        cout << "No" << endl;
        return 0;
    }
    else if(a==b || b==c || c == a){
        cout << "Yes" << endl;
        return 0;
    }
    else {
        cout << "No" << endl;
        return 0;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

struct fast_combination {
    fast_combination(int n, int mod_) :fac(n+1, 0), finv(n+1, 0), inv(n+1, 0), mod_(mod_) {
        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_;
        }
    }

    int64_t operator()(int n, int k) {
        if (n > fac.size()-1) return -1;
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n-k] % mod_) % mod_;
    }

    int64_t multichoose(int n, int k) {
        return this->operator ()(n+k-1, k);
    }

    std::vector<int64_t> fac, finv, inv;
    int mod_;
};

int main(int argc, char **argv) {
    i64 s;
    cin >> s;

    fast_combination comb(s, mod);
    i64 ans=0;
    for (i64 l = 1; l<s; ++l) {
        i64 remain = s - l*3;
        if (remain < 0) break;

        ans += comb(remain+l-1, remain);
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#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 FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;
const int maxn = 1e5+5;
int dist[maxn][3]; VI G[maxn]; 

void bfs(const int s, const int n)
{
    FOR(i,1,n+1) FOR(j,0,3)
        dist[i][j] = inf;
    queue<PII> Q; Q.push(PII(s,0)); dist[s][0] = 0;
    while (Q.size()) {
        const int u = Q.front().first; 
        const int i = Q.front().second;
        Q.pop();
        FOR_ALL(v,G[u]) {
            const int d = dist[u][i]+1;
            const int j = (i+1)%3;
            if (d < dist[*v][j]) {
                dist[*v][j] = d;
                Q.push(PII(*v,j));
            }
        }
    }
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,m;
    while (cin >> n >> m) {
        FOR(i,1,n+1)
            G[i].clear();
        FOR(i,0,m) {
            int u,v; cin >> u >> v;
            G[u].push_back(v);
        }
        int s,t; cin >> s >> t;
        bfs(s,n);
        cout << (dist[t][0] < inf ? dist[t][0]/3 : -1) << endl;            
    }
    return 0;
}


Measured memory_bytes: 6912
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

S = get_int

i = 1
cur = S
set = Set.new
set.add(cur)
loop do
  i += 1
  ax = cur % 2 == 0 ? (cur / 2) : (3 * cur + 1)
  break if set.include?(ax)
  set.add(ax)
  cur = ax
end

puts i


Measured memory_bytes: 14372
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    int p = 0, q = 0, r = 0;
    for (int i = 0; i < n; ++i) {
        int k;
        scanf("%d",&k);
        if(k%4 == 0){
            p++;
        }else if(k%2 == 0){
            q++;
        }else r++;
    }
    if(q == 0){
        cout << (r <= p+1 ? "Yes" : "No") << "\n";
    }else {
        cout << (r <= p ? "Yes" : "No") << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

public class Program
{
    public static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());

        double total = 0.0d;

        for (int i = 0; i < N; i++)
        {
            string[] line = Console.ReadLine().Split(' ');

            double value = double.Parse(line[0]);
            bool isYen = (line[1] == "JPY");

            total += isYen ? value : (value * 380000.0d);
        }

        Console.WriteLine(total);
        Console.ReadLine();
    }
}

Measured memory_bytes: 11220
// qdd on Aug 04, 2019

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

using ll = long long;

const ll P = 1e9;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll S;
    cin >> S;
    ll x = (P - (S % P)) % P;
    ll y = (S + x) / P;
    cout << 0 << ' ' << 0 << ' ' << P << ' ' << 1 << ' ' << x << ' ' << y << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cctype>
#include <cassert>
using namespace std;
typedef function<int(int[3])> node_t;
int sub[3]={2,1,0};
int mul[3][3]={{0,0,0},{0,1,1},{0,1,2}};
int add[3][3]={{0,1,2},{1,1,2},{2,2,2}};
string S;
int cur=0;
char readchar()
{
    assert(cur < S.size());
    char ret = S[cur];
    cur += 1;
    return ret;
}
node_t parse()
{
    char c=readchar();
    if(isdigit(c))
        return [ =](int[3]){return c-'0'; };
    if(isalpha(c))
        return [ =](int a[3]){return a[c-'P']; };
    node_t left=parse();
    if(c=='-')
        return [ =](int a[3]){return sub[left(a)]; };
    assert(c=='(');
    char op = readchar();
    node_t right = parse();
    ++cur;
    if(op=='*')
        return [ =](int a[3]){return mul[left(a)][right(a)]; };
    return [ =](int a[3]){return add[left(a)][right(a)]; };
}
int solve()
{
    cur = 0;
    auto tree = parse();
    int count = 0;
    for(int p:{0,1,2})
        for(int q:{0,1,2})
            for(int r:{0,1,2})
            {
                int a[] = {p, q, r};
                if(tree(a) == 2)
                    count++;
            }
    return count;
}

int main()
{
    cin >> S;
    while(S!=".")
    {
        cout << solve() << endl;
        cin >> S;
    } 
    return 0;
}



Measured memory_bytes: 3008
#include <stdio.h>

int main()
{
   int w,h,x,y,r;
   scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
   if(w-r>=x&&r<=x&&h-r>=y&&r<=y){
   	printf("Yes\n");
   }else{
   	printf("No\n");
    }
}


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

int main() {
  int a,b,c,d,ans;
  cin >> a >> b >> c >> d;
  ans = 0;

  if (a > b) {
    ans += b;
  } else {
    ans += a;
  }

  if (c > d) {
    ans += d;
  } else {
    ans += c;
  }


  cout << ans << endl;

}

Measured memory_bytes: 256
import itertools


N, A, B, C = map(int,input().split())
L = [int(input()) for _ in range(N)]
ans = 10**9

for pattern in itertools.product(range(4), repeat=N):
    if not {1, 2, 3} <= set(pattern):
        continue

    trees = [0] * 3
    synthesis_cost = -30
    for num, length in zip(pattern, L):
        if num == 0:
            continue
        trees[num-1] += length
        synthesis_cost += 10

    fix_cost = 0
    for tree_length, target_length in zip(trees, [A, B, C]):
        fix_cost += abs(target_length - tree_length)

    total_cost = synthesis_cost + fix_cost
    ans = min(ans, total_cost)

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN=2010;
const int MOD=1e9+7;
int n,k;
long long fac[MAXN*MAXN],inv[MAXN*MAXN],f[MAXN][MAXN];
long long C(long long x,long long y)
{
	return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
long long qpow(long long x,long long y)
{
	long long tmp=1;
	for(;y;y>>=1,x=x*x%MOD)if(y&1)tmp=tmp*x%MOD;
	return tmp;
}
int main()
{
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	scanf("%d%d",&n,&k);
	if(k==1)
	{
		printf("1");
		return 0;
	}
	fac[0]=1;
	for(int i=1;i<=n*k;i++)fac[i]=fac[i-1]*i%MOD;
	inv[n*k]=qpow(fac[n*k],MOD-2);
	for(int i=n*k;i>=1;i--)inv[i-1]=inv[i]*i%MOD;
	f[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++)
		{
			f[i][j]=f[i-1][j];
			if(!j)continue;
			f[i][j]=(f[i][j]+f[i][j-1]*(n-j+1)%MOD*C(n-i+(n-j+1)*(k-1)-1,k-2))%MOD;
		}
	printf("%lld\n",f[n][n]);
	return 0;
}


Measured memory_bytes: 93056
while True:
    try:
        a = input().split()
        stack = []
        for inp in a:
            if inp == "+":
                x = stack.pop()
                y = stack.pop()
                stack.append(x+y)
            elif inp == "-":
                x = stack.pop()
                y = stack.pop()
                stack.append(y-x)
            elif inp == "*":
                x = stack.pop()
                y = stack.pop()
                stack.append(x*y)
            elif inp == "/":
                x = stack.pop()
                y = stack.pop()
                stack.append(y/x)
            else:
                stack.append(float(inp))

        print(*stack)
    except:
        break



Measured memory_bytes: 5572
from statistics import mean, median,variance,stdev
# S = input()
n = int(input())
# N, K = map(int, input().split())
a = list(map(int, input().split()))
# LR = [list(map(int, input().split())) for _ in range(M)]

ans = 0

s = sum(a)
N = len(a)
mean = s / N

for i in range(N):
    if abs(a[ans] - mean) > abs((a[i]-mean)):
        ans = i

print(ans)

Measured memory_bytes: 6092
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;

int main(){
    int n,m; cin >> n >> m;
    vector<int> count(n,0);
    int a;
    rep(i,m*2) {
        cin >> a;
        count[a-1]++;
    }

    rep(i,n) cout << count[i] << endl;
    return 0;


}




Measured memory_bytes: 256
import math
a,b,h,m=map(int,input().split())
theta=abs(h*math.pi/6+m*math.pi/360-m*math.pi/30)
if theta>math.pi:
  theta=2*math.pi-theta
ans=math.sqrt(a*a+b*b-2*a*b*math.cos(theta))
print(ans)

Measured memory_bytes: 9500
INF = 25*10**9
import bisect
a,b,q = map(int,input().split())
s = []
t = []
x = []
for i in range(a):
    s.append(int(input()))
for i in range(b):
    t.append(int(input()))
for i in range(q):
    x.append(int(input()))
s.append(INF)
s.insert(0,-INF)
t.append(INF)
t.insert(0,-INF)    
for i in range(q):
    a1 = bisect.bisect_left(s,x[i])
    b1 = bisect.bisect_left(t,x[i])
    c1 = max(s[a1],t[b1])-x[i]
    c2 = x[i]-min(s[a1-1],t[b1-1])
    c3 = 2 * s[a1]-x[i]-t[b1-1]
    c4 = 2 * t[b1]-x[i]-s[a1-1]
    c5 = s[a1]+x[i]-2*t[b1-1]
    c6 = t[b1]+x[i]-2*s[a1-1]
    print(min(c1,c2,c3,c4,c5,c6))

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    string s;
    cin >> s;

    if (n%2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    for (int i=0; i<n/2; i++) {
        if (s[i] != s[i+n/2]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;


    return 0;
}


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

int main(void){
  int N, M;
  int D[10000], P[10000]; 
  int Porg[10000];
  while(cin >> N >> M, N | M){
    for(int i=0; i < N; i++){
      int d, p; cin >> d >> p;
      D[i] = d; P[i] = p; Porg[i] = p;
    }
    int maxp_ind = 0;
    int cnt = 0;
    while(M > 0 && cnt <  N){
      maxp_ind = max_element(P, P+N) - P;
      P[maxp_ind] = 0;
      if(D[maxp_ind] <= M){
        M -= D[maxp_ind];
        D[maxp_ind] = 0;
      }else{
        D[maxp_ind] -= M;
        M = 0;
      }
      cnt++;
    }
    int ans = 0;
    for(int i=0; i < N; i++){
      ans += D[i] * Porg[i];
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1272
N, K = map(int, input().split())
V = [0] + list(map(int, input().split())) + [0]

maxv = 0
for l in range(min(K, N) + 1):
    for r in range(min(K, N) - l + 1):
        gets = V[:l + 1] + V[-1 - r:]
        gets.sort()
        d = K - l - r
        #print("il={},ir={},d={},gets={}".format(il,ir,d,gets))
        for i in range(d):
            if len(gets) <= 0:
                break
            v = min(gets)
            if v >= 0:
                break
            #print("remove={}".format(v))
            gets.remove(v)
        maxv = max(maxv, sum(gets))
        #print("sum(gets)={}".format(sum(gets)))

print(maxv)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//
        int A, B, C;
        cin >> A >> B >> C;

        cout << max({A,B,C})-min({A,B,C}) << endl;
        

        return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		// 楽曲数を取得
		int songCount = scanner.nextInt();

		// 楽曲リストを取得
		List<Object[]> songList = new ArrayList<Object[]>();
		while (songCount > 0) {
			songList.add(new Object[] {scanner.next(), scanner.nextInt()});
			songCount--;
		}

		// 寝落ちしたタイミングの曲名を取得(該当曲の再生時間は含まない)
		String neotiSong = scanner.next();

		scanner.close();

		// 寝落ち後の再生時間を取得
		boolean neotiFlg = false;
		int sleepTime = 0;
		while (songCount < songList.size()) {
			if (neotiFlg) {
				sleepTime += (int) songList.get(songCount)[1];
				songCount ++;
				continue;
			}
			if (neotiSong.equals(songList.get(songCount)[0])) {
				neotiFlg = true;
				songCount ++;
				continue;
			}
			songCount ++;
		}

		// 寝落ち後の再生時間を出力
		System.out.println(sleepTime);
	}

}

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

int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	rep(i,N) cin >> L[i];

  sort(all(L));
	int ans = 0;
	rep(a,N)rep(b,a)rep(c,b){
		bool c1 = L[a] < L[b] + L[c];
		bool c2 = L[b] < L[c] + L[a];
		bool c3 = L[c] < L[a] + L[b];
		if(c1&&c2&&c3){
			ans += (b-c);
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N,K = map(int, input().split())
MOD_BY = 7 +10**9

#末尾の数字の和は
#20000100000
#となる。明らかに10**100は超えない。
#頭の数は何個足し合わせたかで決まる
#違いが出るのは末尾の数

#https://drken1215.hatenablog.com/entry/2020/04/20/003900

#最小値から最大値まで連続した数を作れる

ans = 0

for i in range(K,N+2):
    comb_min = (0+i-1)*i//2 #sum(all_num[0:i])
    comb_max = (N+N-i+1)*i//2 #sum(all_num_inv[0:i])
    #print(i,comb_min,comb_max)
    comb_num = comb_max - comb_min + 1
    ans += comb_num
    ans %= MOD_BY
    
print(ans)

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

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 1000000007
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int l;
    cin >> l;
    ll sta = l*l*l;
    cout << fixed;
    double pom = (1.0 * sta) / 27.0;
    cout << setprecision(7) <<  pom << endl;
    return 0;
}


Measured memory_bytes: 256
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    double r ; cin >> r;
    double ans = 2.0 * r * (22.0/7.0);
    printf("%3f", ans);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3804
#include <algorithm>
#include <iostream>
#include <vector>
#include <string> 

typedef long long ll;
using namespace std;
const ll m = 1e9 + 7;

int main() {
	ll x, k, d; cin >> x >> k >> d;
	x = abs(x);
	ll temp = min(k, x / d);
	k -= temp;
	x -= temp * d;

	if (k & 1) {
		cout << d - x << endl;
	}
	else {
		cout << x << endl;
	}
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll INF = (1 << 30);
const ll inf = (1LL << 50LL);
const int  maxn = 1e6 + 5;
int n, k;
int arr[maxn];
int dp[maxn];
int rek(int at){
    if(at == n - 1){
        return 0;
    }
    if(dp[at] != -1){
        return dp[at];
    }
    int ret = INF;
    for(int i = 1; i <= k; i ++){
        if(i + at < n){
            ret = min(ret, rek(i + at) + abs(arr[at] - arr[i + at]));
        }
    }
    return dp[at] = ret;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
//    ifstream cin("in.txt");
    cin >> n >> k;
    for(int i = 0; i  <n; i ++){
        cin >> arr[i];
        dp[i] = -1;
    }
    
    cout << rek(0) << endl;
    return 0;
}


Measured memory_bytes: 9472
q, h, s, two = map(int, input().split())
n = int(input())
one = min(q * 4, h * 2, s)

if n % 2 == 0:
	print(min(two * (n // 2), one * n))
else:
	print(min(two * (n // 2) + one, one * n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e5 +7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L



int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    bool turn = true;
    while (A > 0 && C > 0) {
        if (turn) {
            C -= B;
        }
        else {
            A -= D;
        }
        turn ^= 1;
    }
    if (A <= 0) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }

    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n,x;
	cin>>n>>x;
	int m[100]={0};
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>m[i];
		sum+=m[i];
	}
	x-=sum;
	int res=0;
	for(int i=0;i<n;i++){
		int y=x/m[i];
		if(y>res){
			res=y;
		}
	}
	cout<<n+res<<endl;
}

Measured memory_bytes: 256