akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std ; 
#define ll long long 
signed main()
{
	ll g[3],b[3],s[3],cnt=0,n; 
	cin >> n ; 
	cin >> g[1] >> s[1] >> b[1] ; 
	cin >> g[2] >> s[2] >> b[2] ; 
	ll p1 = 0 , p2 = 0 , p3 = 0 ; 
	p1 ^= ( g[1] >= g[2] ) ;
	p2 ^= ( s[1] >= s[2] ) ; 
	p3 ^= ( b[1] >= b[2] ) ;
	if ( p1 == 0 && p2 == 0 && p3 == 0 ) {
		for ( int i = 0 ; i <= n/g[1] ; i++ ) {
			for ( int j = 0 ; j <= (n-i*g[1])/s[1] ; j++ ) {
				int k = (n - i*g[1] - j*s[1])/b[1] ; 
				cnt= max(cnt,i*(g[2]-g[1])+j*(s[2]-s[1])+k*(b[2]-b[1])) ; 
			}
		}
		n += cnt ; 
	}
	else if ( p1 && p2 && p3 ) {
		for ( int i = 0 ; i <= n/g[2] ; i++ ) {
			for ( int j = 0 ; j <= (n-i*g[2])/s[2] ; j++ ) {
				int k = (n-i*g[2]-j*s[2])/b[2] ; 
				cnt = max(cnt,i*(g[1]-g[2])+j*(s[1]-s[2])+k*(b[1]-b[2])) ;
			}
		}
		n += cnt ; 
	}
	else if ( p1 && p2 )
	{	
		n += n/b[1]*(b[2]-b[1]) ; 
		for ( int i = 0 ; i <= n/g[2] ; i++ ) {
			int k = (n-i*g[2])/s[2] ; 
			cnt = max(cnt,i*(g[1]-g[2])+k*(s[1]-s[2])) ; 
		}
		n += cnt ; 
	}		
 	else if ( p2 && p3 ) {
 		n += n/g[1]*(g[2]-g[1]) ; 
 		for ( int i = 0 ; i <= n/s[2] ; i++ ) {
			int k = (n-i*s[2])/b[2] ; 
			cnt = max(cnt,i*(s[1]-s[2])+k*(b[1]-b[2])) ; 
		}
		n += cnt ; 
 	}
	else if ( p1 && p3 ) {
		n += n/s[1]*(s[2]-s[1]) ;
		for ( int i = 0 ; i <= n/g[2] ; i++ ) {
			int k = (n-i*g[2])/b[2] ; 
			cnt = max(cnt,i*(g[1]-g[2])+k*(b[1]-b[2])) ; 
		}
		n += cnt ;
	}
	else if ( p1 ) {
		for ( int i = 0 ; i <= n/s[1] ; i++ ) {
			int k = (n-i*s[1])/b[1] ; 
			cnt = max(cnt,i*(s[2]-s[1])+k*(b[2]-b[1])) ; 
		}
		n += cnt ;
		n += n/g[2]*(g[1]-g[2]) ;
	}
	else if ( p2 ) {
		for ( int i = 0 ; i <= n/g[1] ; i++ ) {
			int k = (n-i*g[1])/b[1] ; 
			cnt = max(cnt,i*(g[2]-g[1])+k*(b[2]-b[1])) ; 
		}
		n += cnt ; 
		n += n/s[2]*(s[1]-s[2]) ;
	}
	else if ( p3 ) {
		for ( int i = 0 ; i <= n/g[1] ; i++ ) {
			 int  k = (n-i*g[1])/s[1] ; 
			cnt = max(cnt,i*(g[2]-g[1])+k*(s[2]-s[1])) ; 
		}
		n += cnt ; 
		n += n/b[2]*(b[1]-b[2]) ;
	}
	cout << n ; 
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define N 6000 + 5
#define M 2000 + 5
#define rep(i, l, r) for(int i = l; i <= r; ++i)
int n, ans, Mod, dp[N][M];
int read(){
    char c; int x = 0, f = 1;
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int Inc(int a, int b){
    return (a += b) >= Mod ? a - Mod : a;
}
int Mul(int a, int b){
    return 1ll * a * b % Mod;
}
int main(){
    n = read(), Mod = read();
    dp[0][0] = 1;
    rep(i, 1, 3 * n) rep(j, 0, min(i / 2, n)){
        dp[i][j] = Inc(dp[i][j], dp[i - 1][j]);
        if(i >= 2 && j >= 1) dp[i][j] = Inc(dp[i][j], Mul(dp[i - 2][j - 1], i - 1));
        if(i >= 3 && j >= 1) dp[i][j] = Inc(dp[i][j], Mul(dp[i - 3][j - 1], Mul(i - 1, i - 2)));
    }
    rep(i, 0, n) ans = Inc(ans, dp[3 * n][i]);
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 46992
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<string.h>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<functional>
#include<algorithm>
#include<assert.h>
#include<numeric>
#include<limits.h>
using namespace std;
map<int,int>mp;
int main()
{
	mp[2]=1;
	mp[3]=2;
	mp[4]=3;
	mp[5]=4;
	mp[6]=5;
	mp[7]=6;
	mp[8]=7;
	mp[9]=8;
	mp[10]=9;
	mp[11]=10;
	mp[12]=11;
	mp[13]=12;
	mp[1]=13;
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==b)
	{
		printf("Draw\n");
		return 0;
	}
	if(mp[a]<mp[b])printf("Bob\n");else printf("Alice\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		rep(i,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,a,b;
	cin>>n>>m;
	Graph<ll> g(n);
	rep(i,m)cin>>a>>b,g.add(a-1,b-1,0);
	vb cntin(n,false);
	deque<int> d;
	d.push_back(0);
	d.push_back(get<0>(g.edge[0][0]));
	cntin[0]=cntin[d.back()]=true;
	bool lp=true;
	while(lp){
		lp=false;
		for(auto x:g.edge[d.back()]){
			if(!lp&&!cntin[get<0>(x)]){
				cntin[get<0>(x)]=true;
				d.push_back(get<0>(x));
				lp=true;
			}
		}
	}
	lp=true;
	while(lp){
		lp=false;
		for(auto x:g.edge[d.front()]){
			if(!lp&&!cntin[get<0>(x)]){
				cntin[get<0>(x)]=true;
				d.push_front(get<0>(x));
				lp=true;
			}
		}
	}
	cout<<d.size()<<endl<<d.front()+1;
	d.pop_front();
	while(!d.empty()){
		cout<<" "<<d.front()+1;
		d.pop_front();
	}
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin>>n;
    string s=to_string(n);
    int sum=0;
    FORE(x,s) {
        sum+=x-'0';
    }
    cout<<(n%sum==0?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
  int A,B,cnt=0;;

  scanf("%d",&A);
  scanf("%d",&B);

  for (int i = 0; i < 2; i++)
  {
    if(A>B)
    {
      cnt+=A;
      A--;
    }
    else
    {
      cnt+=B;
      B--;
    }
  }

  printf("%d\n",cnt);

  return 0;
}


Measured memory_bytes: 128
N = int(input())
W = [input() for i in range(N)]

vocab = {W[0]}
for i in range(1, N):
    if W[i] in vocab:
        print("No")
        exit()
    vocab.add(W[i])

    if W[i-1][-1] != W[i][0]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long n = sc.nextLong();

        // 与式を変形するとfloor(A(x%B)/B)
        // したがって、x = b - 1の時に与式は最大となる。
        long x = b - 1 <= n ? b - 1 : n;
        System.out.println(((a * (x % b)) - (a * (x % b) % b)) / b);
    }
}


Measured memory_bytes: 35756
# https://atcoder.jp/contests/agc011/tasks/agc011_a

n, c, k = map(int, input().split())

schedule = []
for _ in range(n):
    t = int(input())
    schedule.append(t)
schedule.sort()
# schedule.append(float('inf'))

def check(num, schedule, c, k):
    bus = 0
    start = schedule[0]
    p = 0
    i = 0
    while i < len(schedule):
        s = schedule[i]
        if s <= start + k:
            p += 1
            i += 1
            if p == c:
                bus += 1
                p = 0
                if i == len(schedule):
                    break
                start = schedule[i]
        else:
            start = schedule[i]
            bus += 1
            p = 1
            i += 1
    if p:
        bus += 1
    if bus <= num:
        return True
    return False

l = 0
r = 10 ** 10
ans = float('inf')
while l <= r:
    mid = (l + r) // 2
    if check(mid, schedule, c, k):
        r = mid - 1
        ans = min(ans, mid)
    else:
        l = mid + 1

print(ans)


Measured memory_bytes: 51160
#include<stdio.h>
int main(void){
  long int A,B;
  scanf("%ld %ld",&A,&B);
  long int i;
  long int j;
  if(A>=B){for(i=B;;i--){if(A%i==0&&B%i==0){break;}}
    printf("%ld",A*B/i);}
  if(B>A){for(j=A;;j--){if(A%j==0&&B%j==0){break;}}
    printf("%ld",A*B/j);} return 0;
}


Measured memory_bytes: 2148
"""
DFS
"""
# 再帰回数の上限を解除
import sys
sys.setrecursionlimit(10**7)


class Edge:
    def __init__(self, _to, _id):
        self.to = _to
        self.id = _id


def dfs(vertex, parent_color=-1, parent_vertex=-1):
    color = 1
    for g in graph[vertex]:
        u = g.to
        ei = g.id
        if u == parent_vertex:
            continue
        if color == parent_color:
            color += 1
        ans[ei] = color
        color += 1
        dfs(u, ans[ei], vertex)


N = int(input())
graph = [[] for _ in range(N)]
ans = [0 for _ in range(N-1)]
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(Edge(b, i))
    graph[b].append(Edge(a, i))

dfs(0)

# 最大次数が色数となる
mx = max([len(g) for g in graph])
print(mx)

for i in range(N-1):
    print(ans[i])



Measured memory_bytes: 97532
import bisect

q = int(input())

def pr(n):
    is_prime = [True]*(n+2)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,int((n+1)**0.5)+1):
        for j in range(2,i+1):
            if is_prime[i] == False:
                continue
            for k in range(2*i,n+1,i):
                is_prime[k] = False
                
    return is_prime
    
L = pr(10**5*2+2000)

li = []
for i in range(2,10**5 + 1):
    if L[i] and L[(i+1)//2]:
        li.append(i)

for i in range(q):
    l,r = map(int,input().split())
    l_ = bisect.bisect_left(li,l)
    r_ = bisect.bisect_right(li,r)
    print(r_ - l_)


Measured memory_bytes: 4980
// Created by ...
#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 vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int32_t main() {
    IOS;

        string s,t;cin>>s>>t;
        int n=s.size(),ans=0;
        rep(i,0,n-1)if(s[i]!=t[i])++ans;
        cout<<ans;
        



        cout<<'\n';
    return 0;
}

Measured memory_bytes: 3796
using System.Linq;
using System;
using System.IO;

class Program
{
  static void Main(string[] args)
  {
    string s = Console.ReadLine();
    var sorted = String.Join("", s.OrderBy(ch => ch));
    var ans = (sorted == "abc") ? "Yes" : "No";
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 13268
n = input()
if n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] == '7' or n[-1] == '9':
    print('hon')
elif n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8':
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9104
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    string s[2];
    cin >> s[0] >> s[1];
    vector<ll> dp(n);
    int start = 1;
    if (s[0].front() == s[1].front()) {
        dp[0] = 3;
    } else {
        dp[1] = 6;
        start = 2;
    }

    for (int i = start; i < n; ++i) {
        if (s[0][i] == s[1][i]) {
            if (s[0][i - 1] == s[1][i - 1]) {
                dp[i] = dp[i - 1] * 2;
            } else {
                dp[i] = dp[i - 1];
            }
        } else if (s[0][i] == s[0][i + 1]) {
            if (s[0][i - 1] == s[1][i - 1]) {
                dp[i] = dp[i - 1] * 2;
            } else {
                dp[i] = dp[i - 1] * 3;
            }
        } else
            dp[i] = dp[i - 1];
        dp[i] %= 1000000007LL;
    }

    cout << dp.back() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC168C()
{
	int A, B, H, M;
	cin >> A >> B >> H >> M;
	int MM = M + H * 60;

	double Pi = 3.14159265358979323846;

	double vh = 2.0 * Pi / (12 * 60);
	double vm = 2.0 * Pi / 60;

	double x1 = MM * vh;
	double x2 = MM * vm;
	double x = x2 - x1;
	double theta = cos(x2 - x1);
	double y = (double)A * A + (double)B * B - 2.0 * A * B * theta;
	cout << std::fixed << std::setprecision(30) << sqrt(y) << endl;
}
int main()
{
	ABC168C();
	return 0;
}



Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(ll i=0; i<n; i++)
#define all(v) v.begin(), v.end()
#define vec vector
typedef long long ll;
const int INF = 1001001001;

/*　<<stringで読み込んだ数列を一桁ずつint型へ変換>>
 
    string str;
    int N[桁数];
 
    cin >> str;
 
    for (int i = 0; i < 桁数; ++i) {
 
        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換
 
        //cout << N[i] << endl;  //確認のため表示
    }
*/
 


///////////////////////////////////////////////////////////////////////////


int main() {
    int K;
    cin >> K;
    string N;
    cin >> N;
    
    if(N.size() <= K){
        cout << N << endl;
    }

    else{
        N.erase(K, N.size()-K+1);
        cout << N << "..." << endl;
    }
}

Measured memory_bytes: 3628
@n = gets.to_i
@s = gets.chomp.chars.map {|e| e == ?o ? 0 : 1}

calc = ->(x, y) {
    a = Array.new(@n)
    a[0] = x
    a[-1] = y
    (@n-2).times {|i| a[i+1] = a[i] ^ @s[i] ^ a[i-1]}
    if a[-2] ^ @s[-2] ^ a[-3] == a[-1] && a[-1] ^ @s[-1] ^ a[-2] == a[0]
        puts a.map{|e| e == 0 ? ?S : ?W}.join
        exit
    end
}

calc.(0, 0)
calc.(0, 1)
calc.(1, 0)
calc.(1, 1)
p -1

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

using namespace std;
using i64 = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a = vector<int>(n + 1);
    vector<int> su = vector<int>(n + 1);
    vector<int> sv = vector<int>(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        su[i] = su[i - 1] + a[i];
        sv[i] = sv[i - 1] ^ a[i];
    }
    int s = 1, t = 1;
    i64 an = 0;
    while (t <= n)
    {
        if (su[t] - su[s - 1] == (sv[t] ^ sv[s - 1]))
        {
            t++;
            an += t - s;
            continue;
        }
        do
        {
            s++;
        } while (su[t] - su[s - 1] != (sv[t] ^ sv[s - 1]));
    }
    cout << an << "\n";
}

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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main() {
    int N;
    cin >> N;
    int tmp=N%10;
    if(tmp==2||tmp==4||tmp==5||tmp==7||tmp==9){
        cout <<"hon";
    }
    else if(tmp==3){
        cout <<"bon";
    }
    else cout <<"pon";

    return 0;
}


Measured memory_bytes: 3632
n = int(input())
wn = list(map(int, input().split() ) )




r = sum(wn)
l = 0
dis = r
index_ = 0
for i in range(len(wn)):
    r -= wn[i]
    l += wn[i]
    t = abs(r-l)
    if t < dis:
        dis = t
        index_ = i
#        print(l,r,dis)

print(dis)


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


using namespace std;
int main(){

 string a,b;
cin>>a>>b;

sort(a.begin(),a.end());

sort(b.begin(),b.end(),greater<>());

if(a<b) cout<<"Yes"<<endl;
else 
cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect

k,t=map(int,input().split())
a=list(map(int,input().split()))
x=max(a)
if k-x>=x-1:
    print(0)
else:
    print(2*x-1-k)

Measured memory_bytes: 77244
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main()
{
    int x, y;
    cin >> x >> y;

    int x1 = x;
    int x2 = -x;

    int y1 = y;
    int y2 = -y;

    int ans = 2e9;
    if (x1 <= y1)
        ans = min(ans, y1 - x1);
    if (x1 <= y2)
        ans = min(ans, y2 - x1 + 1);
    if (x2 <= y1)
        ans = min(ans, y1 - x2 + 1);
    if (x2 <= y2)
        ans = min(ans, y2 - x2 + 2);
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main() {
	
	int a, b;
	
	while( std::cin >>a >> b ) {
	
	if( a < b)
	std::cout << "a < b\n";
	
	else if ( a > b)
	std::cout << "a > b\n";
	
	else
	std::cout << "a == b\n";
	
	}
	return 0;
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

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

    ll k , n ; cin >> k >> n;

    ll a[n];

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

    ll ma = 0;
    ll prev = 0;
    for (ll i = 0; i < n; i++) {
        ma = max(ma, abs(prev - a[i]));
        prev = a[i];
    }

    ma = max(ma, k - a[n-1] + a[0]);

    ll ans = k - ma;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
N = int(input())
Ss = input()

ans = 0
for P in range(1000):
    Ds = str(P).zfill(3)
    pos = -1
    for D in Ds:
        pos = Ss.find(D, pos+1)
        if pos == -1:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 3060
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

slow = 1
fast = 1
counter = 0
for _ in range(K):
    slow = A[slow - 1]
    fast = A[A[fast-1]-1]
    counter += 1
    if slow == fast:
        break
# counter = m = lambda + k * myu
# m = lambda(開始地点) +(m - lambda)
# lambda進むとmyuの定数倍のmがlambdaから進んだ事になるのでそこがスタート地点
# get lambda
slow2 = slow
slow_start = 1
counter = 0
for _ in range(K):
    slow2 = A[slow2 - 1]
    slow_start = A[slow_start-1]
    counter += 1
    if slow2 == slow_start:
        break
lam = counter
slow3 = slow
counter = 0
for _ in range(K):
    slow3 = A[slow3 - 1]
    counter += 1
    if slow3 == slow:
        break
myu = counter

total = lam + (K-lam) % myu
length = 0
if total < K:
    length = total
else:
    length = K
current = 1
for _ in range(length):
    current = A[current-1]
print(current)

Measured memory_bytes: 92592
#include <iostream>

using namespace std;
int main()
{
    int N;
    cin >> N;

    for (int i = 1; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            if (N==i*j)
            {
                cout<<"Yes";

                return 0;
            }
            
        }
    }
    cout<<"No";
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

	ll k = (n+1)/2;
	cout << fixed << setprecision(10) << double(k)/n << endl;


}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>

#define max 9973219

using namespace std;

int main()
{
	int n, a[900], p=0;
	char prime[max+1];
	fill(prime, prime+(max+1), 1);
	
	prime[0] = prime[1] = 0;
	for(int i = 2; i <= max; i++){
		if(prime[i]){
			for(int j = 2*i; j <= max; j+=i){
				prime[j] = 0;
			}
		}
	}
	
	for(int i = 0; i+19 <= max; i+=30){
		if(prime[i+11] && prime[i+13] && prime[i+17] && prime[i+19]){
			a[p++] = i+19;
		}
	}
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		if(n < 19){
			cout << 13 << endl;
			continue;
		}
		if(max < n){
			cout << max << endl;
			continue;
		}
		
		for(int i = 1; i < p; i++){
			if(a[i] > n){
				n = i-1;
				break;
			}
		}
		
		cout << a[n] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 10000
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var xs = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var z = xs.Sum(x => x - 1);
        Console.WriteLine(z);
    }
}

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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(std::string S){
  if(S=="MON")
    std::cout << 6 << std::endl;
  else if(S=="TUE")
    std::cout << 5 << std::endl;
  else if(S=="WED")
    std::cout << 4 << std::endl;
  else if(S=="THU")
    std::cout << 3 << std::endl;
  else if(S=="FRI")
    std::cout << 2 << std::endl;
  else if(S=="SAT")
    std::cout << 1 << std::endl;
  else
    std::cout << 7 << std::endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {

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

		String str = sc.next();

		HashSet<Character> set = new HashSet<Character>();

		for(int i = 0; i < str.length(); i++){
			set.add(str.charAt(i));
		}

		System.out.println(set.size() == str.length() ? "yes" : "no");
	}
}

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

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

	vector<vector<int>> jobs(M); // i日目に選択出来る仕事
	
	
	rep(i,N){
		int a, b;
		cin >> a >> b;
		if(a > M) continue;
		jobs[M-a].push_back(b);
	}
	
	priority_queue<int> q;
	long ans = 0;
	
	for(int i = M-1; i >= 0; i--){
		for(int p : jobs[i]){
			q.push(p);
		}
		if(!q.empty()){
			ans += q.top();
			q.pop();
		}
	}
	
	
	cout << ans << endl;

}

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

int main() {
    int N;
    string S, left="", right="";
    cin >> N >> S;

    // 左端につけるべき"(" の数を数える
    int lcnt = 0, lcnt_max = 0;
    rep(i, S.size()) {
        if (S[i] == '(') lcnt--;
        if (S[i] == ')') lcnt++;
        lcnt_max = max(lcnt, lcnt_max);
    }
    rep(i, lcnt_max) left += "(";
    S = left + S;

    // 右端につけるべき")" の数を数える
    int rcnt = 0;
    rep(i, S.size()) {
        if (S[i] == '(') rcnt++;
        if (S[i] == ')') rcnt--;
    }
    rep(i, rcnt) right += ")";
    S = S + right;

    cout << S << endl;

    return 0;
}



Measured memory_bytes: 256
//
//  main.cpp
//  ABC
//
//  Created by Amarsanaa Davaasuren on 2019/08/31.
//  Copyright © 2019 Amarsanaa Davaasuren. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
using namespace std;



class UnionFind {
public:
    vector<int> Parent;
    UnionFind(int N){
        Parent = vector<int>(N,-1);
    }
    
    int root(int node){
        if (Parent[node] < 0){
            return node;
        }
        else{
            return Parent[node] = root(Parent[node]);
        }
    }
    
    int size(int node){
        return -root(node);
    }
    
    bool connect(int A, int B){
        int Aroot = root(A);
        int Broot = root(B);
        if (Aroot != Broot){
            if (size(Aroot) < size(Broot)) swap(Aroot,Broot);
            Parent[Aroot] += Parent[Broot];
            Parent[Broot] = Aroot;
            return true;
        }
        else{
            return false;
        }
    }
};




#define rep(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
using ll = long long;

template<typename T>
struct BIT{
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1){}
    void add(int i,int x=1){
        for(i++;i<=n;i += i&-i) d[i]+=x;
    }
    T sum(int i){
        T x = 0;
        for(i++;i;i -= i&-i) x += d[i];
    }
};





int main(){
    string s,t; cin >> s >> t;
    int ans = 0;
    rep(i,0,3){
        (s[i]==t[i]? ans++:ans);
    }
    cout << ans;
    
}

Measured memory_bytes: 256
import sys
d=0
for e in sys.stdin:
 c=list(map(int,e.split()))
 if len(c)>1:
  s,t=c;d=1
  if s>t:a+=s+t
  elif s<t:b+=s+t
  else:a+=s;b+=t
 else:
  if d:print(a,b)
  a=b=0


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
int n, d, maxi, mini;
vector<int> a;
int main(void){
	scanf("%d" , &n);
	a.push_back(-1);
	for(int i = 1 ; i <= n ; i++)
		scanf("%d" , &d) , a.push_back(d);
	maxi = INT_MIN;
	mini = INT_MAX;
	for(int i = 1 ; i <= n ; i++){
		maxi = max(maxi , a[i]);
		mini = min(mini , a[i]);
	}
	if(maxi == mini){
		if(maxi <= (n/2) || maxi == (n-1))
			printf("Yes");
		else
			printf("No");	
	}
	else if(maxi == mini + 1){
		int maxicnt = 0, minicnt = 0;
		for(int i = 1 ; i <= n ; i++){
			if(a[i] == mini)
				minicnt++;
			else if(a[i] == maxi)
				maxicnt++;	
		}
		int z = maxi - minicnt;
		if(1 <= z && z <= maxicnt/2)
			printf("Yes");
		else
			printf("No");			
	}	
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 892
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper

n = input()
print('Yes' if n.count('9') >= 1 else 'No')


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define ll          unsigned long long int

#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 
 
const long long INF = (long long) 1e11+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x*res);
    x=(x*x);    
    y=y/2;
  }
  
  return res%mod;
}
 
ll modinv(ll x){
  return power(x,hell-2);
}

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}

void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
    

void solve(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    
    double ang1=(h*30)+(m)*0.5;
    double ang2=m*6;
    
    double ang=(abs(ang1-ang2)*M_PI)/180.0;
    
    double p=sin(ang)*a;
    double bs=cos(ang)*a;
    
    b-=bs;
    
    double val=b*b+p*p;
    double hy=sqrt(val);
    cout<<fixed<<setprecision(15)<<hy;    
}

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;    
   
   while(test--)
   solve();
}


Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
 
 
int main(void){
  string S;
  cin >> S;
  sort(S.begin(), S.end());
  if(S[0] == S[1] && S[1] != S[2] && S[2] == S[3]) cout << "Yes";
  else cout << "No";
  
  return 0;
}

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

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    d = [0]*n
    d[0] = 1
    q = deque([0])
    p = [None]*n
    while q:
        x = q.popleft()
        nd = d[x]+1
        for y in v[x]:
            if not d[y]:
                d[y] = nd
                p[y] = x
                q.append(y)
    V = list(range(n))
    V.sort(key = lambda x:-d[x])
    t = [1]*n
    for x in V[:-1]:
        t[p[x]] += t[x]
    ans = 0
    p = pow(2,n-1,mod)
    for x in range(n):
        tx = t[x]
        if len(v[x]) < 2:
            continue
        s = p-1
        for y in v[x]:
            ty = t[y]
            if tx < ty:
                s -= pow(2,t[0]-tx,mod)-1
            else:
                s -= pow(2,ty,mod)-1
            s %= mod
        ans += s
        ans %= mod
    print(ans*pow(2,(mod-2)*n%(mod-1),mod)%mod)
    return

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


Measured memory_bytes: 66168
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        //string input= Console.ReadLine();
        int input =int.Parse(Console.ReadLine());
        Console.WriteLine(24*2-input);


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 11092
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
res = [0] * n
cnt = 0
for i,t in enumerate(s):
    if t == 'R': cnt = i
    else:
        ind = cnt + (i-cnt)%2 
        res[ind] += 1

for i,t in enumerate(s[::-1]):
    i = n-i-1
    if t == 'L': cnt = i
    else:
        ind = cnt - (cnt-i)%2
        res[ind] += 1
print(*res)

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B, C;
    cin >> A >> B >> C;
    A -= B;
    C -= A;
    cout << max(0LL, C) << endl;
    return 0;
}


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

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

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

#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

int sub(int a, int b) {
	return b == 0 ? a : add(a, MOD_BY - b);
}

int mul(int a, int b) {
	int r = 0;
	while (b > 0) {
		if (b & 1) r = add(r, a);
		a = add(a, a);
		b >>= 1;
	}
	return r;
}

int ruizyou(int a, int b) {
	int r = 1;
	while (b > 0) {
		if (b & 1) r = mul(r, a);
		a = mul(a, a);
		b >>= 1;
	}
	return r;
}

int inv(int a) {
	return ruizyou(a, MOD_BY - 2);
}

int waru(int a, int b) {
	return mul(a, inv(b));
}

int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int N, K;
int A[114514];

int nyan[114514];

int nCr(int n, int r) {
	int ans = 1, i;
	if (n < 0) return 0;
	if (r < 0 || n < r) return 0;
	for (i = 0; i < r; i++) {
		ans = mul(ans, n - i);
	}
	for (i = 1; i <= r; i++) {
		ans = waru(ans, i);
	}
	return ans;
}

int main(void) {
	int i;
	int answer = 0;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	qsort(A, N, sizeof(*A), cmp);
	for (i = 0; i < N; i++) {
		if (A[i] < 0) A[i] += MOD_BY;
	}
	if (K > 1) {
		for (i = 1; i < N; i++) {
			nyan[i] = nCr(i + 1 - 2, K - 2);
			if (nyan[i] > 0) break;
		}
		for (i++; i < N; i++) {
			nyan[i] = waru(mul(nyan[i - 1], i + 1 - 2), i + 1 - 2 - (K - 2));
		}
		for (i = 1; i < N; i++) {\
			nyan[i] = add(nyan[i - 1], nyan[i]);
		}
		for (i = K - 1; i < N; i++) {
			answer =
				add(
					answer,
					mul(
						sub(A[N - 1 - (i - (K - 1))], A[i - (K - 1)]),
						nyan[N - 1 - (i - (K - 1))]
					)
				);
		}
	}
	printf("%d\n", answer);
	return 0;
}

/*

       12345678
       ABCDEFGH
      ABCDEFGH
     ABCDEFGH
    ABCDEFGH
   ABCDEFGH
  ABCDEFGH
 ABCDEFGH
ABCDEFGH

  (3-1)*C + (4-1)*D + (5-1)*E + (6-1)*F + (7-1)*G + (8-1)*H
+ (4-2)*C + (5-2)*D + (6-2)*E + (7-2)*F + (8-2)*G
+ (5-3)*C + (6-3)*D + (7-3)*E + (8-3)*F
+ (6-4)*C + (7-4)*D + (8-4)*E
+ (7-5)*C + (8-5)*D
+ (8-6)*C

=   8*(H+G+F+E+D+C) + 7*(G+F+E+D+C) + 6*(F+E+D+C) + 5*(E+D+C) + 4*(D+C) + 3*C
  - 1*(C+D+E+F+G+H) - 2*(C+D+E+F+G) - 3*(C+D+E+F) - 4*(C+D+E) - 5*(C+D) - 6*C

*/


Measured memory_bytes: 1012
import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static StreamTokenizer in;
    static {
        try{
            in = new StreamTokenizer(new BufferedReader(new InputStreamReader(new BufferedInputStream(System.in))));
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public static int nextInt() throws IOException{ in.nextToken(); return (int)in.nval; }
    public static void main(String[] args) throws IOException{
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        int n=nextInt();
        int m=nextInt();
        int high[]=new int[n+1];
        int count[]=new int[n+1];
        for(int i=1;i<=n;i++)
            high[i]=nextInt();
        for(int i=0;i<m;i++){
            int p=nextInt();
            int q=nextInt();
            int x=high[p];
            int y=high[q];
            if(x==y){
                count[p]--;
                count[q]--;
            }else if(x<y)
                count[p]--;
            else count[q]--;
        }
        int ans=0;
        for(int i=1;i<=n;i++){
            if(count[i]==0)
                ans++;
        }
        System.out.println(ans);


    }
}


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

int N,M;
int D[100] = {0};

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < M; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        D[a]++;
        D[b]++;
    }
    for(int i = 1; i < N + 1; i++)
    {
        printf("%d\n",D[i]);
    }
    return 0;
}


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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S, T, U; bool check = true;	vector<ll> v;



int main() {
	//Code Line
	map<ll, ll> m, m1, m2;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		m[A[i]]++;
	}
	for (int i = 0; i <= n; i++) {
		m1[i] = (m[i] * (m[i] - 1)) / 2;
		m2[i] = ((m[i] - 1) * (m[i] - 2)) / 2;

	}
	for (int i = 0; i <= n; i++) {
		sum += m1[i];
	}

	for (int i = 0; i < n; i++) {
		cout << sum - (m1[A[i]] - m2[A[i]]) << endl;
	}



	return 0;
}


Measured memory_bytes: 44800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int d;
    cin >> d;
    int n = 25 - d;
    cout << "Christmas";
    while(n--)
        cout << " Eve";
    cout << endl;
}


Measured memory_bytes: 256
import math

N, D = map(int, input().split())
X = [[] for _ in range(N)]
for i in range(N):
	X[i] = list(map(int, input().split()))

cnt = 0
for i in range(N-1):
	for j in range(i+1, N):
		l = 0
		for x in range(D):
			l += (X[i][x] - X[j][x])**2
		if math.sqrt(l)-math.floor(math.sqrt(l)) == 0:
			cnt += 1

print(cnt)

Measured memory_bytes: 3064
n,m = map(int,input().split())
s = []
k = []
for i in range(m):
    s_in = list(map(int,input().split()))
    s.append(s_in[1:])
    k.append(s_in[0])
p = list(map(int,input().split()))
ans = 0
def bfs(switch):
    global ans
    if len(switch)==n:
        ok = 1 #全部の電球がつく
        for i in range(m):
            on_cnt=0
            for j in range(k[i]):
                if switch[s[i][j]-1]==1:
                    on_cnt+=1
            if on_cnt%2!=p[i]:
                ok = 0
        if ok:
            ans+=1
    else:
        bfs(switch+[0])
        bfs(switch+[1])
bfs([])
print(ans)

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

int main(){
    int n;
    long long int a, b;
    cin >> n >> a >> b;
    long long int xa, xb, ans = 0;
    for(int i=0;i<n;++i){
        if(i > 0)xa = xb;
        cin >> xb;
        if(i > 0){
            ans += min(a*(xb-xa), b);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;
int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int sum = 0;

	for (int i = 1; i <= n; i++)
	{
		int t = i;
		int w = 0;
		while (t>0) {
			int dig = t % 10;
			w += dig;
			t /= 10;
		}
		if (a <= w && w <= b) sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main (String[] args){
		int W,H,x,y,r;
		Scanner scan = new Scanner(System.in);
		W = Integer.parseInt(scan.next());
		H = Integer.parseInt(scan.next());
		x = Integer.parseInt(scan.next());
		y = Integer.parseInt(scan.next());
		r = Integer.parseInt(scan.next());
		
		if((x<r)||(y<r)){
			System.out.println("No");
		}else if((W>=x+r)&&(H>=y+r)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 25996
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}
// auto v = make_vec<int>(h, w);
// fill(v, 0);

signed main(){

  string s; cin >> s;
  int K; cin >> K;

  int n = s.size();
  auto dp = make_vec<int>(n+1, 10, 8, 2);
  dp[0][0][0][0] = 1;
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= 9; j++){
      for(int k = 0; k <= 9; k++){
        for(int l = 0; l < 5; l++){
          if(j == 0){
            dp[i+1][j][l][1] += dp[i][k][l][1];
            if(s[i]-'0' > 0){
              dp[i+1][j][l][1] += dp[i][k][l][0];
            }else{
              dp[i+1][j][l][0] += dp[i][k][l][0];
            }
          }
          else if(j >= s[i]-'0'){
            dp[i+1][j][l+1][1] += dp[i][k][l][1];
            if(j == s[i]-'0') dp[i+1][j][l+1][0] += dp[i][k][l][0];
          }else{
            dp[i+1][j][l+1][1] += dp[i][k][l][1] + dp[i][k][l][0];
          }
        }
      }
    }
  }
  int ans = dp[n][s[n-1]-'0'][K][0];
  for(int i = 0; i < 10; i++){
    ans += dp[n][i][K][1];
    //cout << dp[n][i][K][1] << endl;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
def main():
    n = int(input())
    hs = [int(e) for e in input().split()]
    moved = [False for _ in range(n)]

    for i in range(n - 1):
        h = hs[i]
        hn = hs[i + 1]
        if h - hn > 1:
            print("No")
            return

    i = 0
    while i < n:
        if i == n - 1:
            print("Yes")
            return
        h = hs[i]
        hn = hs[i + 1]
        if h <= hn:
            i += 1
            continue
        # h == hn + 1
        if moved[i]:
            print("No")
            return
        else:
            moved[i] = True
            hs[i] -= 1
            i -= 1


if __name__ == '__main__':
    main()



Measured memory_bytes: 64228
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <stack> //queueと類似
#include <queue> //要素を入れるデータ構造 push posh
#include <array> //member関数
#include <numeric> //accumulate等
#include <algorithm> //sort

using namespace std;

int main()
{
	const int Max = 100;
	array<int,Max> W;
	int r = 0;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> W[i];
		r += W[i];
	}
	
	int S1, S2;
	int answer = r;
	
	for (int T = 1; T < N; T++) {
		S1 = accumulate(W.begin(), W.begin()+T, 0);
		S2 = r - S1;
		if (abs(S1 - S2) < answer) {
			answer = abs(S1 - S2);
		}
	} 

	cout << answer; 
	return 0; 

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int32_t main(){_
   
   int a, b, m;   
   cin >> a >> b >> m;
   
   vector<int> r(a);   
   for (int i = 0; i < a; ++i)
   {
      cin >> r[i];
   }

   vector<int> M(b);
   for (int i = 0; i < b; ++i)
   {
      cin >> M[i];  
   }
      
   int ans = inf;
   for (int i = 0; i < m; ++i)
   {
      int x, y, cost;
      cin>>x>>y>>cost;
      --x, --y;
      smin(ans, r[x] + M[y] - cost);
   }

   sort(r.begin(), r.end());
   sort(M.begin(), M.end());

   smin(ans, r[0] + M[0]);

   cout<<ans;

   return 0;
}

Measured memory_bytes: 1792