akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
  char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
  vector<char*> v({token});
  while(token = strtok(NULL,", ")) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main() {
    IOS;
    string s;
    cin>>s;
    if(s.back()=='s') {
    	s+="es";
    	cout<<s;
    }else{
    	s+='s';
    	cout<<s;
    }
    return 0;   
} 

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

int main(){
  string S;
  cin>>S;
  vector<int> count(26,0);
  for(int i=0;i<S.size();i++){
    count.at(S.at(i)-'a')++;
  }
  bool flag=true;
  for(int i=0;i<26;i++){
    if(count.at(i)>1){
      flag=false;
    }
  }
  if(flag){
    cout<<"yes"<<endl;
  }else{
    cout<<"no"<<endl;
  }
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    double sum = 0.0;
    for (int i = 0; i < n; i++) {
        double A;
        cin >> A;
        sum += 1.0 / A;
    }

    cout << fixed << setprecision(10) << 1.0 / sum << "\n";
    return 0;
}

Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

def cmb(n, r, p):
    global fact, factinv
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p


def main():
    N, K = [int(x) for x in input().split()]
    MOD = 10 ** 9 + 7

    a = min(N - 1, K)

    global fact, factinv, inv
    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
        factinv.append((factinv[-1] * inv[-1]) % MOD)

    ans = 1
    for i in range(1, a + 1):
        ans += cmb(N, i, MOD) * cmb(N - 1, N - i - 1, MOD) % MOD

    print(ans % MOD)


if __name__ == '__main__':
    main()


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

int main(){
    int N;
    cin >> N;
    int odd = 0;
    int even = 0;
    rep(i,N){
        int A;
        cin >> A;
        if (A % 2 == 0) even++;
        else odd++;
    }
    if (odd % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int n, a, b; cin >> n >> a >> b;
    vector<int> p(n); rep(i, n) cin >> p[i];
    int x, y, z; x = y = z = 0;
    rep(i, n) {
        if(p[i]<=a) x++;
        else if(p[i]<=b) y++;
        else z++;
    }
    cout << min(x, min(y, z));
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll N;
ll C[200050];
ll before[200050];
ll dp[200050];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> C[i];
    for(int i = 1; i <= 200000; i++) before[i] = -1;
    dp[0] = 1;
    for(ll i = 1; i <= N; i++) {
        ll now = C[i];
        dp[i] = dp[i - 1];
        if(before[now] != -1 && before[now] < i - 1) {
            dp[i] += dp[before[now]];
            dp[i] %= mod;
        }
        before[now] = i;
    }
    cout << dp[N] << endl;
    return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];
ll M[100005];

struct Combination {
    Combination(ll n) {
        mNumTbl.resize(n + 1);
        mInverseNumTbl.resize(n + 1);
        mNumTbl[0] = 1;
        mInverseNumTbl[0] = 1;
        FOR(i, n + 1, 1) {
            mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
        }
        FOR(i, n + 1, 1) {
            mInverseNumTbl[i] = modpow(mNumTbl[i]);
        }
    }

    ll get(ll n, ll r) {
        if (n < r || n < 0)
            return 0;
        return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) % MOD;
    }

    ll modpow(ll n) {
        ll s = 1, p = n;
        for (ll i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD) {
            if (((MOD - 2) & (1 << i)) == 0)
                continue;
            s *= p;
            s %= MOD;
        }
        return s;
    }

    vector<ll> mInverseNumTbl;
    vector<ll> mNumTbl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    memset(M, 0, sizeof(M));
    REP(i, N + 1) {
        cin >> A[i];
        M[A[i]]++;
    }

    Combination cmb(N + 5);

    ll p = INF, s = INF;
    REP(i, N + 1) {
        if (M[A[i]] == 1)
            continue;
        p = std::min(i, p);
        s = std::min(N - i, s);
    }

    REP(i, N + 1) {
        ll n = i + 1;
        ll ans = cmb.get(N + 1, n);
        ans -= cmb.get(p + s, n - 1);
        cout << (ans + MOD) % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
a1, a2, a3, a4 = map(int,input().split())
b1, b2, b3, b4 = map(int,input().split())

S = a1 + a2 + a3 + a4
T = b1 + b2 + b3 + b4
print(max(S,T))



Measured memory_bytes: 5592
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstring>
#define R register
#define EN std::puts("")
#define LL long long
inline LL read(){
	LL x=0,y=1;
	char c=std::getchar();
	while(c<'0'||c>'9'){if(c=='-') y=0;c=std::getchar();}
	while(c>='0'&&c<='9'){x=x*10+(c^48);c=std::getchar();}
	return y?x:-x;
}
//a:abs大负数->abs小负数->小正数->大正数
//b:大正数->小正数->abs小负数->abs大负数 
int n,fir;
LL k;
LL a[200006],b[200006];
inline int finda(int i,LL ans){
	R int l=1,r=n,mid,ret=0;
	while(l<=r){
		mid=(l+r)>>1;
		if(a[mid]*a[i]<ans) ret=mid,l=mid+1;
		else r=mid-1;
	}
	return ret>=i?(ret-1):ret;
}
inline int findb(int i,LL ans){
	R int l=1,r=n,mid,ret=0;
	while(l<=r){
		mid=(l+r)>>1;
		if(b[mid]*a[i]<ans) ret=mid,l=mid+1;
		else r=mid-1;
	}
	return (ret+i>n)?(ret-1):ret;
}
inline int check(LL ans){
	LL nowk=0;
	for(R int i=1;i<fir;i++)//负数 
		nowk+=findb(i,ans);
	for(R int i=fir;i<=n;i++)
		nowk+=finda(i,ans);
	nowk/=2;
	return nowk>=k;
}
inline int cmp(int x,int y){
	return x<y;
}
int main(){
	n=read();k=read();
	for(R int i=1;i<=n;i++) a[i]=read(); 
	std::sort(a+1,a+1+n,cmp);
	fir=n+1;
	for(R int i=1;i<=n;i++)
		if(a[i]>=0){fir=i;break;}
	for(R int i=1;i<=n;i++) b[n-i+1]=a[i];
	R LL l=-1e18,r=1e18,mid,ans;
	while(l<=r){
		mid=(l+r)/2;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	std::printf("%lld",ans-1);
	return 0;
}


Measured memory_bytes: 3328
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
        a:[i64;n],
    }
    let mut ans = 0;
    for i in 1..n - 1 {
        let mut left = min(a[i - 1], a[i + 1]);
        let mut right = max(a[i - 1], a[i + 1]);
        if (left..right).contains(&a[i]) {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
int n,h[20];
scanf("%d",&n);
int ans=0;
int max=0;
for(int i=0;i<n;i++)
{
scanf("%d",&h[i]);
if(max<h[i]){max=h[i];}
if(h[i]>=max){ans++;}
}
printf("%d\n",ans);
}

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

namespace ABC133
{
    class Program
    {
        static void Main(string[] args)
        {
            string Str = Console.ReadLine().Trim();
            string[] StrArr = Str.Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
            int[] IntArr = StrArr.Select(int.Parse).ToArray();
            int n = IntArr[0];
            int d = IntArr[1];
            int[][] x = new int[n][];

            for (int i = 0; i < n; i++)
            {
                Str = Console.ReadLine().Trim();
                StrArr = Str.Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
                x[i] = StrArr.Select(int.Parse).ToArray();
            }
            double distance = 0;
            int cnt = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    distance = 0;
                    if (i <= j)
                    {
                        break;
                    }
                    //Console.WriteLine(i.ToString() + "," + j.ToString());
                    for (int di = 0; di < d; di++)
                    {
                        distance += Math.Pow(x[i][di] - x[j][di], 2);
                    }
                    distance = Math.Sqrt(distance);
                    if (distance - Math.Floor(distance) == 0)
                    {
                        cnt++;
                    }
                    //Console.WriteLine("dis:"+distance);
                }

            }
            Console.WriteLine(cnt);
            //Console.Read();

        }
    }
}


Measured memory_bytes: 13396
from collections import defaultdict
import os, sys
if os.environ.get("USER") == "hoge":
    def debug(*args): print(*args, file=sys.stderr)
else:
    def debug(*args): pass
def debug(*args): pass
N=int(input())
A=[int(i) for i in input().split()]
dd=defaultdict(int)
for a in A:
    dd[a]+=1
#print(dd)
B=sorted(A,reverse=True)
ans=0
for x in B:
    debug(A)
    #print(x)
    if dd.get(x,-1)==0:
        continue
    s=len(bin(x))-3
    if x==1<<s:
        t=dd.get(x,-1)
        if t!=-1:
            ans+=t//2
            dd[x]-=(t//2)*2
            #print(ans)
            #print(dd)
    else:
        s+=1
        #print((1<<s)-x)
        t=dd.get((1<<s)-x,-1)
        if t>=1:
            ans+=1
            dd[x]-=1
            dd[(1<<s)-x]-=1
            #print(ans)
            #print(dd)
print(ans)


Measured memory_bytes: 112468
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int size=s.size();
    int count=0;
    char now;
    for (int i=0;i<size;i++) {
        if (i==0) {
            now=s[i];
        } else {
            if (s[i]!=now) {
                now=s[i];
                count++;
            }
        }
    }
    cout<<count<<endl;
}


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

long long int gcd(long long int m, long long int n){
    if(n == 0){
        return m;
    }

    return gcd(n, m % n);
}

long long int lcm(long long int m, long long int n){
   long long int tmp = gcd(m, n);
   return (m / tmp * n);
}

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

    /*
    long long int prime;
    cin >> prime;
    */

    long long int ans = 1LL;
    for(int i = 0; i < n /*- 1*/; i++){
        long long int tmp;
        cin >> tmp;
        /*
        if(i == 0){
            ans = lcm(prime,tmp);
        }
        else{
            ans = lcm(ans, tmp);
        }
        */
       ans = lcm(ans, tmp);
    }
   
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# coding=utf_8

def btlcmp(taro, hanako):
    if taro > hanako :
        return 0
    elif taro == hanako :
        return 1

    return 2

res = [[3,0],[1,1],[0,3]]

taro_p = 0
hanako_p = 0

btltime = int(input())

for i in range(btltime):
    s = input().split()
    resi = btlcmp(s[0], s[1])
    taro_p += res[resi][0]
    hanako_p += res[resi][1]

print(str(taro_p) +" "+ str(hanako_p))


Measured memory_bytes: 5608
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,q;
  cin>>n>>q;
  vector<vector<long long> > v(n+5);
  rep(i,q){
    int tmp,t,x;
    cin>>tmp;
    if(tmp==0){
      cin>>t>>x;
      v[t].push_back(x);
    }
    else if(tmp==1){
      cin>>t;
      if(v[t].size()==0){
        cout<<'\n';
        continue;
      }
      rep(j,(int)v[t].size()-1){
        cout<<v[t][j]<<' ';
      }
      cout<<v[t][v[t].size()-1]<<'\n';
    }
    else{
      cin>>t;
      v[t].clear();
    }
  }
  return(0);
}


Measured memory_bytes: 8968
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int d = int.Parse(input[0]);
            int N = int.Parse(input[1]);
            
            if(N == 100)N = 101;
            Console.WriteLine(Math.Pow(100, d) * N);
            
            // 文字列の入力
            //string s = Console.ReadLine();
            //出力
            //Console.WriteLine((a + b + c) + " " + s);

            //int a = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            /*string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            if (a <= 7 && b <= 7 && a >= 1 && b >= 1)
            {
                Console.WriteLine("Yay!");
            }
            else
            {
                Console.WriteLine(":(");
            }*/
            // 文字列の入力
            //string s = Console.ReadLine();
            //出力
            //Console.WriteLine((a + b + c) + " " + s);
        }


    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    string s ;
    string ans[] = {"Yes", "No"};
    int flag = 0;
    cin>>s;
    for (int i = 0; i < s.length(); i++){
        if (i % 2 == 0){
            if (s[i] == 'L'){
                flag = 1;
            }
        }else{
            if (s[i] == 'R'){
                flag = 1;
            }
        }
    }
    cout<<ans[flag]<<endl;
}

Measured memory_bytes: 256
N = int(input())

X = []
Y = []
for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
 
sum = 0
for i in range(N):
    for j in range(N):
        x = (X[i] - X[j])**2
        y = (Y[i] - Y[j])**2
        sum += (x + y)**(1/2)

print(sum/N)

Measured memory_bytes: 3188
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;

int main(){
	char a,b,c,d;
	int A,B,C,D;
	scanf("%c%c%c%c",&a,&b,&c,&d);
	A=a-48;
	B=b-48;
	C=c-48;
	D=d-48;
	if(A+B+C+D==7) printf("%c+%c+%c+%c=7\n",a,b,c,d);
	else if(A-B+C+D==7) printf("%c-%c+%c+%c=7\n",a,b,c,d);
	else if(A+B-C+D==7) printf("%c+%c-%c+%c=7\n",a,b,c,d);
	else if(A+B+C-D==7) printf("%c+%c+%c-%c=7\n",a,b,c,d);
	else if(A-B-C+D==7) printf("%c-%c-%c+%c=7\n",a,b,c,d);
	else if(A-B+C-D==7) printf("%c-%c+%c-%c=7\n",a,b,c,d);
	else if(A+B-C-D==7) printf("%c+%c-%c-%c=7\n",a,b,c,d);
	else if(A-B-C-D==7) printf("%c-%c-%c-%c=7\n",a,b,c,d);
}


Measured memory_bytes: 256
while True:
	try: c1, c2, c3 = list(map(int,input().split()))
	except: break
	safe = 20 - (c1 + c2)
	deck = [i for i in range(1,11) if i <= safe and i != c1 and i != c2 and i != c3]
	print(["YES","NO"][len(deck) / 7 <= 0.5])


Measured memory_bytes: 5612
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define PB push_back
#define MP make_pair
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define INF (1<<28)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main() {
    ll n, a[200005], num[200005] = {};
    ll ans = 0;
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        num[a[i]]++;
    }
    for (ll i = 1; i <= n; i++) {
        if (num[i] % 2 == 0) {
            ans += (num[i] / 2) * (num[i] - 1);
        }
        else {
            ans += num[i] * ((num[i] - 1) / 2);
        }
    }
    for (ll i = 0; i < n; i++) {
        cout << ans - (num[a[i]] - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 5760
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a=[[0],[0],[0]]
n = int(input())
for i in range(n):
    A,B,C = map(int,input().split())
    a[0].append(A)
    a[1].append(B)
    a[2].append(C)
dp = []
for j in range(n+1):
    dp.append([0,0,0])

dp[1][0] = a[0][1]
dp[1][1] = a[1][1]
dp[1][2] = a[2][1]
for i in range(2,n+1):
    for j in range(3):
        x = dp[i-1][(j+1)%3]+a[j][i]
        y = dp[i-1][(j+2)%3]+a[j][i]
        dp[i][j] = max(x,y)
print(max(dp[n][0],dp[n][1],dp[n][2]))


Measured memory_bytes: 34644
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i=0;i<t;i++)
#define ll long long int
#define ld long double
#define umpl unordered_map<ll,ll> 
#define vl vector<ll>
#define vld vector<ld>
#define vvl vector<vl>
#define pb push_back
#define pll pair<ll,ll>
#define inf 1e18
#define pcout(x,p) cout<<fixed<<setprecision(p)<<x
#define all(a) a.begin(),a.end()
#define endl "\n"
const ll mod=1e9+7;
inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}
inline ll ceil(ll a,ll b){return (a%b==0)?(a/b):(a/b+1);}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    for(auto v : V) os << v <<"  ";
    return os;
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") ";
    return os<<"}";
}
struct comp { 
    template<class T1,class T2,class T3,class T4>
    bool operator()(const pair<T1,T2> &p1,const pair<T3,T4> &p2){
        return p1.first<p2.first;
    }
};


int main(){
	fio;	
	ll n;cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++){
			if(i*j>=n)break;
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
long long k,ans;
inline int read()
{
	int num=0,flag=1;
	char c=getchar();
	for (;c<'0'||c>'9';c=getchar())
	if (c=='-') flag=-1;
	for (;c>='0'&&c<='9';c=getchar())
	num=(num<<3)+(num<<1)+c-48;
	return num*flag;
}
int main()
{
	a=read();
	b=read();
	c=read();
	scanf("%lld",&k);
	if (k%2==1) ans=b-a;
	else ans=a-b;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    cities = [list(map(int, input().split())) for _ in range(N)]
    distances = [distance(cities[i], cities[j]) for i in range(N) for j in range(N)]
    total_distances = sum(distances)
    print((total_distances) / N)


def distance(a, b):
    return ((b[0] - a[0]) ** 2 + (b[1] - a[1]) ** 2) ** 0.5


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;

int main(){
  int n;cin >> n;
  int sum1 = 0;
  int a[n]; for(int i = 0;i<n;i++) {
    cin >> a[i];
    sum1 += a[i];
  }
  int sum2 = 0;int s = 1e4;
  for(int i = 0;i<n-1;i++){
    sum2 += a[i];
    sum1 -= a[i];
    s = min(s,abs(sum2 -sum1));
  }
  cout << s << endl;
}

Measured memory_bytes: 256
X,N = map(int,input().split())
P = list(map(int,input().split()))+[float("inf")]
P.sort()
k = 0
ans = 1000
for i in range(-100,102):
    if i == P[k]:
        k += 1
        continue
    if abs(i - X) < abs(ans - X):
        ans = i
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    
    int N, x, a[100], imos[101], ans;
    int i, j;
    
    cin >> N >> x;
    for (i = 0; i < N; i++) {
        cin >> a[i];
    }
    
    sort(a, a + N, [](int a, int b) -> int { return a < b; });
    
    imos[0] = 0;
    for (i = 0; i < N; i++) {
        imos[i+1] = imos[i] + a[i];
    }
    
    for (i = 0; i <= N; i++) {
        if (x >= imos[i]) {
            ans = i;
        } else {
            break;
        }
    }
    if (ans == N) {
        if (imos[N] != x) ans--;
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
ll MOD=998244353;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll rec(ll N,ll X){
    if(N==0)return 1;
    if(X==1)return 0;
    ll len = (1LL<<(N+1))-3;
    ll num = (1LL<<N)-1;
    if(X<=len+1){
        return rec(N-1,X-1);
    }else if(X==len+2){
        return 1+num;
    }else if(X<=(len+1)*2){
        return num+1+rec(N-1,X-2-len);
    }else{
        return (num+1)*2-1;
    }

}

int main(){
    ll N,X;
    cin>>N>>X;
    ll res = rec(N,X);
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstdio>
using namespace std;

int main() {
    // get input
//    int n;
    //ちゃんと問題文を読む
    int a, b;
//    cin >> n ;
    cin >> a >> b;

    int c = a * b;


//    string output;
//
//    // check whether the procust is divisible by 2 or not
//    if (n % 2 == 1){
//        output = "odd";
//    }
//    else{
//        output = "even";
//    }
//    // output
//    cout << output

    //スッキリ一行でまとめるの良き
    if (c % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;

}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
#include<unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

template <typename T1, typename T2> pair<T1,T2> operator+(pair<T1,T2> p1, pair<T1,T2> p2)
{
  return make_pair(p1.first+p2.first, p1.second+p2.second);
}
template <typename T1, typename T2> pair<T1,T2> operator+=(pair<T1,T2>& p1, pair<T1,T2> p2)
{
  p1.first += p2.first; p1.second += p2.second; return p1;
}

template <typename T1, typename T2> pair<T1,T2> operator-(pair<T1,T2> p1, pair<T1,T2> p2)
{
  return make_pair(p1.first-p2.first, p1.second-p2.second);
}
template <typename T1, typename T2> pair<T1,T2> operator-=(pair<T1,T2>& p1, pair<T1,T2> p2)
{
  p1.first -= p2.first; p1.second -= p2.second; return p1;
}

int main(void){
	lli h, w, n; cin >> h >> w >> n;
	vector<pair<int, int>> b(n);
	rep(i, n) cin >> b[i].fir >> b[i].sec;
	
	lli ans[10];
	rep(i, 10) ans[i] = 0;
	
	sort(b.begin(), b.end());
	
	auto itr = b.begin();
	auto jtr = itr;
	while(itr != b.end()){
		bool ff[5][5];
		rep(i, 5) rep(j, 5) ff[i][j] = false;
		
		pair<int, int> p = *itr;
		auto ori = p - mp(2, 2);

		rep(i, 5){
			auto a_s = lower_bound(b.begin(), b.end()	, mp(ori.fir + i, -IINF));
			auto a_e = lower_bound(b.begin(), b.end()	, mp(ori.fir + i + 1, -IINF));
			auto b_s = lower_bound(a_s		, a_e		, mp(ori.fir + i, ori.sec));
			auto b_e = lower_bound(a_s		, a_e		, mp(ori.fir + i, ori.sec + 5));
			while(b_s != b_e){
				ff[(*b_s).fir - ori.fir][(*b_s).sec - ori.sec] = true;
				b_s++;
			}
		}

		rep(i, 3) rep(j, 3){
			int c = 0;
			if(ori.fir + i <= 0 || ori.sec + j <= 0 || ori.fir + i + 2 > h || ori.sec + j + 2 > w) continue;
			bool f = true;
			rep(ii, 3){
				rep(jj, 3){
					if(ff[i+ii][j+jj] && (i+ii <= 1 || (i+ii == 2 && j+jj <= 1))){
						f = false;
						break;
					}
					if(ff[i+ii][j+jj]) c++;
				}
				if(f == false) break;
			}
			if(f == false) continue;
			ans[c]++;
		}
		
		itr++;
	}
	
	
	lli sum = 0;
	rep(i, 9) sum += ans[i+1];
	ans[0] = (h-2)*(w-2) - sum;
	
	rep(i, 10) cout << ans[i] << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int K, N;
  rd(N);
  rd(K);
  if(K==1){
    wt_L(0);
    wt_L('\n');
  }
  else{
    wt_L(N-K);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190902-1

// --- original code ---
// {
//   int N, K;
//   rd(N, K);
//   wt(if[K==1,0,N-K]);
// }


Measured memory_bytes: 256
n, k = [int(_) for _ in input().split()]
ans = 0
for i in range(0, min(k, n+1)):
    if (2 * i) % k == 0:
        if i == 0:
            m = n // k
            ans += m + 3*m*(m-1) + m*(m-1)*(m-2)
        else:
            m = ((n-i) // k) + 1
            ans += m + 3*m*(m-1) + m*(m-1)*(m-2)
print(ans)

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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(), v.end()
#define fori(i, j, k) for (int i = (j); i < (int)(k); i++)
#define forb(i, j, k) for (int i = (j); i >= (int)k; i--)
#define lchild(ind) 2 * ind + 1
#define rchild(ind) 2 * ind + 2
#define bug(val) cout << "# " << val << endl;
#define bugs(val) cout << '_' << val;
#define bugl(val) cout << "## " << val << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
typedef pair<ll, pll> plp;
typedef pair<pll, int> ppi;
typedef pair<pll, ll> ppl;
typedef pair<pll, pll> ppp;
typedef vector<int> vi;
typedef vector<ll> vll;

const int maxn = 1e5 + 1;
const ll inf = 2e18, mod = 1e9 + 7;

ll w, h, ans = inf, s[3];

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

	cin >> w >> h;

	if (!(w % 3) || !(h % 3))
		ans = 0;
	fori (i, 1, w)
	{
		s[0] = i * h;
		s[1] = ((w - i) * (h / 2));
		s[2] = ((w - i) * ((h + 1) / 2));
		ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
	}
	fori (i, 1, h)
	{
		s[0] = i * w;
		s[1] = ((h - i) * (w / 2));
		s[2] = ((h - i) * ((w + 1) / 2));
		ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
	}
	if (h % 3)
		ans = min(ans, w);
	if (w % 3)
		ans = min(ans, h);

	cout << ans << endl;
}

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

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

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

  int sum = 0;

  for (int i = 0; i < n; i++) {
    while (1) {
      if (a[i] % 2 == 0) {
        sum++;
        a[i] /= 2;
      } else
        break;
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
n, a = map(int, input().split())
X = list(map(int, input().split()))

# editorial 参照 -> 3 dimentional DP
# 制約1: x1-xjのカード, 制約2: k枚選択, 制約3: 点数合計A*k
sum_X = sum(X)
DP = [[[0 for _ in range(sum_X+1)] for _ in range(n+1)] for _ in range(n+1)]


for j in range(n+1):
    for k in range(n+1):
        for s in range(sum_X+1):
            if (j==0) and (k==0) and (s==0):
                DP[j][k][s] = 1
            elif (j >= 1) and (s < X[j-1]):
                DP[j][k][s] = DP[j-1][k][s]
            elif (j >= 1) and (k >= 1) and (s >= X[j-1]):
                DP[j][k][s] = DP[j-1][k][s] + DP[j-1][k-1][s-X[j-1]]
            else:
                DP[j][k][s] = 0

ans  = 0
for k in range(1, n+1):
    if a*k > sum_X:
        pass
    else:
        ans += DP[n][k][a*k]

print(ans)

Measured memory_bytes: 95836
import sys
n, m = map(int, input().split())
r = 10**9 + 7

if 1 < abs(n - m):
    print(0)
    sys.exit()
elif abs(n - m) == 1:
    ans = 1
else:
    ans = 2
    
for i in range(2, n + 1):
    ans *= i
    ans %= r

for i in range(2, m + 1):
    ans *= i
    ans %= r

print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"os"
)

func run() int {
	var n int
	fmt.Scanf("%d\n", &n)
	var s string
	fmt.Scanf("%s", &s)

	for _, c := range s {
		fmt.Print(string(((byte(c)-65)+byte(n))%26 + 65))
	}

	return 0
}

func main() {
	os.Exit(run())
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> ii;

const int len = 5005;
const ll inf = 1e15;
ii arr[len];
ll dp[len];

bool comp(ii a, ii b){
    return (a.fi+a.se > b.fi+b.se);
}

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d %d", &arr[i].fi, &arr[i].se);

    sort(arr, arr+n, comp);

    for (int i = 1; i <= n; i++)
        dp[i] = inf;

    for (int i = n-1; i >= 0; i--)
        for (int j = n; j >= 1; j--)
            if (dp[j-1] <= arr[i].fi)
                dp[j] = min(dp[j], dp[j-1]+arr[i].se);

    int ans = 0;
    for (int i = 0; i <= n; i++)
        if (dp[i] < inf)
            ans = i;

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


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

using namespace std;
using ll = long long;

vector<int> is_prime;

const int N = 1e5 + 10;

int solve(int x) {
	for (int i = 2; i < N; ++i) {
		if (!is_prime[i]) continue;
		if (i >= x) return i;
		if (1ll * i * i > N) continue;
		for (int j = i * i; j < N; j += i) {
			is_prime[j] = false;
		}
	}
	cout << "Not found" << endl;
	exit(1);
}

int main() {
	int x;
	cin >> x;
	is_prime.resize(N, true);
	cout << solve(x) << "\n";
	return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

template <typename T>
bool Setmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  in(int, D);
  vector<int> c(26);
  rep(i, 26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  rep(i, D) rep(j, 26) cin >> s[i][j];

  int sat = 0;
  vector<int> last(26);
  rep(i, D) {
    int d = i + 1;
    int maxi = numeric_limits<int>::min();
    int chosen;
    rep(j, 26) {
      int change = s[i][j];
      rep(k, 26) {
        int last_day = k == j ? d : last[k];
        change -= c[k] * (d - last_day);
      }
      // HACK
      change += (d - last[j]) * c[j] * 6;
      if (Setmax(maxi, change)) {
        chosen = j;
      }
    }
    last[chosen] = d;
    sat += maxi;
    dbg(sat, maxi, chosen);
#if DEBUG
    rep(i, 26) {
      if (i) cerr << " ";
      cerr << last[i];
    }
    cerr << endl;
#endif
    out(chosen + 1);
  }
  dbg(max(1000000 + sat, 0));
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

template <long long mod>
struct modular {
    long long value;
    modular(long long x = 0) {
        value = x % mod;
        if (value < 0) value += mod;
    }
    modular& operator+=(modular other) {
        if ((value += other.value) >= mod) value -= mod;
        return *this;
    }
    modular& operator-=(modular other) {
        if ((value -= other.value) < 0) value += mod;
        return *this;
    }
    modular& operator*=(modular other) {
        value = value * other.value % mod;
        return *this;
    }
    modular& operator/=(modular other) {
        long long a = 0, b = 1, c = other.value, m = mod;
        while (c != 0) {
            long long t = m / c;
            m -= t * c;
            swap(c, m);
            a -= t * b;
            swap(a, b);
        }
        a %= mod;
        if (a < 0) a += mod;
        value = value * a % mod;
        return *this;
    }
    modular operator-() { return modular(-value); }
    modular operator+(modular rhs) { return modular(*this) += rhs; }
    modular operator-(modular rhs) { return modular(*this) -= rhs; }
    modular operator*(modular rhs) { return modular(*this) *= rhs; }
    modular operator/(modular rhs) { return modular(*this) /= rhs; }
    bool operator==(modular rhs) { return value == rhs.value; }
    bool operator!=(modular rhs) { return value != rhs.value; }
    bool operator<(modular rhs) { return value < rhs.value; }
};
template <long long mod>
string to_string(modular<mod> x) {
    return to_string(x.value);
}
template <long long mod>
ostream& operator<<(ostream& stream, modular<mod> x) {
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream << x.value;
}
template <long long mod>
istream& operator>>(istream& stream, modular<mod>& x) {
    stream >> x.value;
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream;
};
const long long mod = 998244353LL;
using mint = modular<mod>;

inline mint pw(mint a, long long n) {
    mint res = 1;
    while (n > 0) {
        if (n & 1) {
            res *= a;
        }
        a *= a;
        n >>= 1;
    }
    return res;
}
vector<mint> fact, finv;
inline void cinit(int n) {
    fact.resize(n, 1);
    finv.resize(n, 1);
    for (int i = 2; i < n; i++) {
        fact[i] = fact[i - 1] * i;
    }
    finv[n - 1] /= fact[n - 1];
    for (int i = n - 2; i >= 2; i--) {
        finv[i] = finv[i + 1] * (i + 1);
    }
}
inline mint C(int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fact[n] * finv[k] * finv[n - k];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    cinit(2000000);
    mint ans = 0;
    for (int a = m % 2; a <= min(n, m); a += 2) {
        int cnt = (3 * m - a) / 2;
        mint res = C(cnt + n - 1, n - 1);
        res -= C(cnt - m + n - 1, n - 1) * a;
        res -= C(cnt - (m + 1) + n - 1, n - 1) * (n - a);
        res *= C(n, a);
        ans += res;
    }
    cout << ans << '\n';
    return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	std::string s;
	std::cin >> s;
	for (auto &i : s) i -= '0';
	int n = s.size();
	static int dp[1000002][2];
	for (auto &i : dp) for (auto &j : i) j = 1000000000;
	dp[0][0] = 0;
	dp[0][1] = 1;
	for (int i = 0; i < n; i++) {
		// down->down
		dp[i + 1][0] = std::min(dp[i + 1][0], dp[i][0] + s[i]);
		dp[i + 1][1] = std::min(dp[i + 1][1], dp[i][0] + s[i] + 1);
		dp[i + 1][0] = std::min(dp[i + 1][0], dp[i][1] + (10 - s[i]));
		dp[i + 1][1] = std::min(dp[i + 1][1], dp[i][1] + (10 - s[i] - 1));
	}
	int res = dp[n][0];
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 9220
a_start, a_end, b_start, b_end = map(int, input().split())

if a_start < b_start:
    f_start, f_end = a_start, a_end
    s_start, s_end = b_start, b_end
else:
    f_start, f_end = b_start, b_end
    s_start, s_end = a_start, a_end

overlap_time = 0
if f_end <= s_start:
    overlap_time = 0
elif s_start < f_end and s_end < f_end:
    overlap_time = s_end - s_start
else:
    overlap_time = f_end - s_start

print(overlap_time)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
int main() {
  string S,T;
  cin >> S >> T;
  int ans = 2000000000,t;
  int i,j;
  for(i=0;i<=S.length()-T.length();i++) {
    t = 0;
    for(j=0;j<T.length();j++) {
      if(S[i+j] != T[j])t++;
    }
    ans = min(ans,t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define ll long long
#define re return
#define mp map<int,int>
using namespace std;
ll a[100005],b[100005],sum[100005],cnt,ans;
bool cmp(int x,int y){
	return x>y;
}
int main() {
	int n;
	cin>>n;
	rep(i,1,n)cin>>a[i];
	rep(i,1,n){
		cin>>b[i];
		if(a[i]>b[i]) sum[i]=a[i]-b[i];
		else if(a[i]<b[i]) cnt+=b[i]-a[i],ans++;
	}
	sort(sum+1,sum+1+n,cmp);
	rep(i,1,n){
		if(cnt>0) cnt-=sum[i],ans++;
	}
	if(cnt>0)cout<<-1;
	else cout<<ans;
	re 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int main ()
{
	int a,b,x;
	scanf("%d%d%d",&a,&b,&x);
	if (x >= a && x <= a+b) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
  ll x;
  cin >> x;
  ll n,m;
  n=x/500;
  m=(x-n*500)/5;
  cout << fixed <<setprecision(0);
  cout << n*1000+m*5 <<endl;
  
      
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

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

int main(){
	string s;
	cin >> s;
	
	vector<int> c(26, 0);
	for(int i = 0; i < s.size(); ++i){
		c[s[i] - 'a']++;
	}
	
	for(int i = 0; i < 26; ++i){
		if(c[i] == 0){
			char ans = (char)i + 'a';
			cout << ans << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	
	return 0;
}



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

int main() {
  string s; cin >> s;
  
  map<string,ll>m;
  m["SAT"]=1;
  m["FRI"]=2;
  m["THU"]=3;
  m["WED"]=4;
  m["TUE"]=5;
  m["MON"]=6;
  m["SUN"]=7;
  
  cout << m[s] << endl;
  return 0;
}

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

int myABS( int a, int b )
{
	return ( a < b ? b - a : a - b );
}

int main()
{
	int A1, A2, A3;
	std::cin >> A1 >> A2 >> A3;

	std::vector<int> v;

	// A1 -> A2 -> A3
	v.emplace_back( myABS( A1, A2 ) + myABS( A2, A3 ) );

	// A1 -> A3 -> A2
	v.emplace_back( myABS( A1, A3 ) + myABS( A2, A3 ) );

	// A2 -> A1 -> A3
	v.emplace_back( myABS( A1, A2 ) + myABS( A1, A3 ) );

	// A2 -> A3 -> A1
	v.emplace_back( myABS( A2, A3 ) + myABS( A1, A3 ) );

	// A3 -> A1 -> A2
	v.emplace_back( myABS( A1, A3 ) + myABS( A1, A2 ) );

	// A3 -> A2 -> A1
	v.emplace_back( myABS( A2, A3 ) + myABS( A1, A2 ) );

	// 昇順ソート
	std::sort( v.begin(), v.end(), []( int a, int b ) {
			return( a < b );
		} );

	std::cout << v[0] << std::endl;	//	最小値を出力

	return ( 0 );
}


Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long n,a[3005],dp[3005][3005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i],dp[i][i]=a[i];
	for(int i=n-1;i>=1;i--)
		for(int j=i+1;j<=n;j++)
			dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
	cout<<dp[1][n];
	return 0;
}

Measured memory_bytes: 70016
n,*a=map(int,open(0).read().split())
b=[0]*n
for i in range(1,n+1)[::-1]:
  if not sum(b[i-1::i])%2==a[i-1]:
    b[i-1]=1
print(sum(b))
print(*[i+1 for i,b_i in enumerate(b) if b_i==1])


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

signed main(signed argc, char* argv[]) {
    int n;
    string s,t;
    cin>>n>>s>>t;
    rep(i,n){
        cout<<s[i]<<t[i];
    }
    cout<<endl;
}


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;

ll n;

void Main() {
  cin >> n;
  vll l(n);

  REP(i, n) {
    cin >> l[i];
  }

  RSORT(l);

  // COUTA(i, l);

  ll ng_count = 0;
  REP(i, n) {
    FOR(j, i + 1, n - 1) {
      FOR(k, j + 1, n - 1) {
        if (l[i] >= l[j] + l[k]) {
          ng_count += (n - k);
          // cout << i << " " << j << " " << k << endl;
          break;
        }
      }
    }
  }

  ll nc3 = n * (n - 1) * (n - 2) / 6;
  COUT(nc3 - ng_count);
  // COUT(nc3);
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


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

// dp[i][j] is the probability of getting j heads with the first i coins
double dp[3000][3000];
double p[3000];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	memset(dp, 0, sizeof(dp));

	for(int i = 1; i <= n; i++)
		cin >> p[i];
	dp[0][0] = 1.0;

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

	double ans = 0.0;
	for(int i = (n/2+1); i <= n; i++) {
		ans += dp[n][i];
	}

	cout << fixed << setprecision(10) << ans << "\n";
}

Measured memory_bytes: 70784