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

const int MAX = 1e6;
const int MOD = 1e9 + 7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
	int x, y;
	cin >> x >> y;
	if (x > y)swap(x, y);
	if ((2 * x - y) % 3 != 0) {
		cout << 0 << endl;
		return 0;
	}
	if ((-x + 2 * y) % 3 != 0) {
		cout << 0 << endl;
		return 0;
	}
	int xcnt = (2 * x - y) / 3;
	int ycnt = (-x + 2 * y) / 3;
	if (xcnt < 0 || ycnt < 0) {
		cout << 0 << endl;
		return 0;
	}
	COMinit();
	cout << COM(xcnt + ycnt, xcnt) << endl;
}

Measured memory_bytes: 23680
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        for (int n = N; n <= 999; n++) {
            int a = n / 100;
            int b = (n / 10) % 10;
            int c = n % 10;
            if (a == b && b == c) {
                System.out.println(n);
                return;
            }
        }
    }
}


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


ll num[sz];


int main()
{

  string a,b;
  ll i,j,k,p,d,m;

  cin>>a>>b;

  for(i=0;i<a.length();i++)
  {
      cout<<a[i];
      if(i<b.length())cout<<b[i];
  }

  cout<<endl;

  return 0;
}



Measured memory_bytes: 256
def getPaintCount(string, color):
	return len(string)-string.count(color)


N, M = map(int, input().split())
A = []
cnt = 0
for i in range(N):
	s = input().strip()
	if i==0:  #1行目は白
		cnt += getPaintCount(s, 'W')
	elif i==N-1:  #最終行は赤
		cnt += getPaintCount(s, 'R')
	else:
		A.append(s)  #N-2行のリスト

B = []  #白、青、赤の行数の組み合わせリスト
for w in range(0, N-1):  #白は0からN-3行の可能性
	for b in range(1, N-w):  #青は1からN-2行の可能性
		r = N-2-w-b
		if r>=0: B.append([w, b, N-2-w-b])
#print(B)
minmin = 2500
cnt2 = 0
for b in B:
	for i in range(len(A)):
		if i<b[0]:
			cnt2 += getPaintCount(A[i], 'W')
		elif b[0]<=i<b[0]+b[1]:
			cnt2 += getPaintCount(A[i], 'B')
		elif b[0]+b[1]<=i<b[0]+b[1]+b[2]:
			cnt2 += getPaintCount(A[i], 'R')
	if cnt2<minmin:
		minmin = cnt2
	cnt2 = 0

print(cnt+minmin)



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

int main()
{
  string a, b, c; cin >> a >> b >> c;
  cout << char(a[0] - 0x20) << char(b[0] - 0x20) << char(c[0] - 0x20) << endl;
  return 0;
}

Measured memory_bytes: 256
n, m, k = map(int, input().strip().split())
A = list(map(int, input().strip().split()))
B = list(map(int, input().strip().split()))
i=j=0

time=0
while j<m:
    time+=B[j]
    if time >k:
        time-=B[j]
        break
    j += 1
j-=1
rem=k-time
ans=j+1
cnt=ans
while True:
    while i<n and rem-A[i]>=0:
        rem-=A[i]
        i+=1
        cnt+=1
    ans=max(ans,cnt)
    
    rem+=B[j]
    j-=1
    cnt-=1
    if j<-1:
        break

print(ans)

Measured memory_bytes: 40956
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n; cin>>n;
    int acnt=0;
    bool valid=true;
    for(int i=0; i<n; i++){
        string s; cin>>s;
        if(s == "A") acnt++;
        else acnt--;

        if(acnt < 0) valid = false;
    }

    if(valid && acnt == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3160
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
namespace ConsoleApp15
{
    class Class373
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var B = A.Select(_ => Abs(_)).ToArray();
            if (A.Count(_ => _ < 0) % 2 == 0)
            {
                Console.WriteLine(B.Sum());
            }
            else
            {
                Console.WriteLine(B.Sum()-2*B.Min());
            }
        }
    }
}


Measured memory_bytes: 31324
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 1000000007
typedef long long ll;
#define all(v) (v).begin(),(v).end()
#define sz(x) int(x.size())
int main(){
	int n;
	string s;
	cin>>s;
	n=s.size();
	ll dp[n+1][13]={0};
	dp[0][0]=1;
	rep(i,n){
		int c;
		if(s[i]=='?'){
		c=-1;
		}else{
			c=s[i]-'0';
		}
		rep(k,10){
			if(c!=-1&&c!=k) continue;
				rep(j,13){
					
					dp[i+1][(j*10+k)%13]+=dp[i][j];
					dp[i+1][(j*10+k)%13]%=N;
				}
		}
		
	}
	cout<<dp[n][5]<<endl;
	return 0;
}

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

int main() {
  int n,m;
  cin>>n>>m;
  if(n==m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3612
//#pragma  GCC optimize("Ofast")

//#ifdef  DEBUG
//#define _GLIBCXX_DEBUG
//#endif

// -Ofast
// -O3
// -O2
// -fsanitize=address
// -fsanitize=undefined

// add_compile_options()

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <unordered_map>
#include <cmath>
#include <cassert>
#include <random>
using namespace std;
//using namesparsace __gnu_pbds;

mt19937 rnd;

int solve();

int main()
{
    srand(time(0));
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}

int max(int a, int b) {
    return a > b ? a : b;
}

const int maxN = 2e5 + 10;

int a[3];

int solve() {
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if ((a[0] == a[1] && a[1] != a[2]) || (a[1] == a[2] && a[0] != a[1])) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("Sunny"))System.out.println("Cloudy");
        else if (s.equals("Cloudy"))System.out.println("Rainy");
        else System.out.println("Sunny");
    }
}


Measured memory_bytes: 35584
N,M=map(int,input().split())
S=[]
K=[]
for i in range(M):
  s=list(map(int,input().split()))
  k=s[0]
  s.remove(s[0])
  K.append(k)
  S.append(s)
P=list(map(int,input().split()))
cnt=0
for i in range(2**N):
  d=[]
  for j in range(M):
    a=0
    for k in S[j]:
      a+=2**(k-1)
    if bin(a&i)[2:].count('1')%2==P[j]:
      d.append(1)
    else:
      d.append(0)
  if not 0 in d:
    cnt+=1
print(cnt)

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

using namespace std;


int main(){
    int N;
    cin>>N;
    int a[N+1], b[N+1], c[N+1];
    int dp[N+1][3];
    int maxPoints = 0;

    for(int i=1; i <= N; i++){
        cin>>a[i]>>b[i]>>c[i];
    }

    dp[1][0] = a[1];
    dp[1][1] = b[1];
    dp[1][2] = c[1];

    maxPoints = max(a[1], max(b[1], c[1]));

    for(int i=2; i <= N; i++){
        for(int j=0; j < 3; j++){
            if(j == 0){
                dp[i][j] = max(dp[i-1][1], dp[i-1][2]) + a[i];
            }
            else if(j == 1){
                dp[i][j] = max(dp[i-1][0], dp[i-1][2]) + b[i];
            }
            else if(j == 2){
                dp[i][j] = max(dp[i-1][0], dp[i-1][1]) + c[i];
            }
            maxPoints = max(maxPoints, dp[i][j]);
        }
    }
    cout<<maxPoints;
    return 0;
}


Measured memory_bytes: 5900
#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> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}

#define MAX 100001
#define WHITE 0
#define BLACK 1
vector<vector<pair<int, int> > > G(MAX);
vector<int> colorList(MAX, -1);

void dfs(int v, ll distance){
    colorList[v] = distance % 2;
    // cout << v + 1 << " " << colorList[v] << endl;
    for(int i = 0; i < G[v].size(); i++){
        int next = G[v][i].first;
        ll next_distance = distance + G[v][i].second;
        if(colorList[next] != -1)continue;
        dfs(next, next_distance);
    }
}

int main(void){
    int n;
    cin >> n;
    int m = n - 1;
    for(int i = 0; i < m; i++){
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        G[u].push_back(make_pair(v,w));
        G[v].push_back(make_pair(u,w));
    }
    dfs(0,0);
    for(int i = 0; i < n; i++){
        cout << colorList[i] << endl;
    }
}

Measured memory_bytes: 7680
# 入力の取得
n, y = map(int, input().split())

# 処理
xx = -1
yy = -1
zz = -1

for man in range(n+1):
    for gosen in range(n+1):
        sen = n - man - gosen
        if 0 <= sen and y == man*10000 + gosen*5000 + sen*1000:
            xx = man
            yy = gosen
            zz = sen
            break
    if xx != -1:
        break

print(str(xx) + " " + str(yy) + " " + str(zz))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL s,w;
    cin>>s>>w;
    PUTS(s <= w ? "unsafe" : "safe");
}

Measured memory_bytes: 3648
#include<cstdio>
typedef long long i64;
int n;
i64 a,b,c,d;
int main(){
	scanf("%d%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	n-=1;
	for(int x=0;x<=n;++x){
		int y=n-x;
		i64 l1=a+c*x,r1=a+d*x;
		i64 l2=b+c*y,r2=b+d*y;
		if(r1>=l2&&r2>=l1)return puts("YES"),0;
	}
	return puts("NO"),0;
}

Measured memory_bytes: 128
import itertools

n, m, q = map(int,input().split())

tr = [[0]*n for _ in range(n)]

for i in range(m):
    l, r = map((lambda x:int(x)-1), input().split())
    tr[l][r] += 1

for i in range(n):
    tr[i] = list(itertools.accumulate(tr[i]))

for i in range(q):
    p, q = map((lambda x:int(x)-1), input().split())
    ans = 0
    for j in tr[p:q+1]:
        ans += (j[q] - j[p-1]) if p>0 else j[q]

    print(ans)



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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> w(n);
    vector<ll> x(n, 0);
    REP(i, n)
    {
        cin >> w[i];
    }
    ll min_diff = INF;
    FOR(i, 1, n)
    {
        ll sum1 = accumulate(w.begin(), w.begin() + i, 0);
        ll sum2 = accumulate(w.begin() + i, w.end(), 0);
        ll diff = abs(sum1 - sum2);
        min_diff = min(min_diff, diff);
    }
    cout << min_diff << endl;
    return 0;
}


Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
//作者:中国江苏南京丁天行
using namespace std;
int q;
ll A,B;
ll calc(ll k){
    if((k+A)%2ll==0) return ((A+k)/2ll)*((A+k)/2ll+1ll);
    return ((A+k+1ll)/2ll)*((A+k+1ll)/2ll);
}
int main(){
    cin>>q;
    while(q--){
        cin>>A>>B;
        if(A>B)swap(A,B);
        ll l=A,r=orz;
        while(r-l>1){
            ll m=(l+r)/2ll;
            if(calc(m)<A*B)l=m;
            else r=m;
        }
        l=min(l,B-1ll);
        if(calc(A)>=A*B)l=A-1;
        cout<<l+A-1ll<<endl;
    }
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    L =  [int(s) for s in input().split()]
    most_long = 0
    other_longs = 0
    for l in L:
        if(l>most_long):
            other_longs += most_long
            most_long = l
        else:
            other_longs += l
    if(other_longs>most_long):
        print('Yes')
    else:
        print('No')



if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
const int MAX=1e5+5;
int main(int argc, char *argv[])
{
	double n,t,a;
	double h[MAX];
	cin>>n>>t>>a;
	int mins=1;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
		h[i]=fabs(t-h[i]*0.006-a);
		if(h[mins]>h[i])
			mins=i;
	}
	cout<<mins<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
typedef long long LL;
int main() {
	int k = 0, s = 0, ans = 0;
	std::cin >> k >> s;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
				if (s-(i+j)>=0 && s-(i+j)<=k) { ans++; }
		}
	}
	std::cout << ans << std::endl;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> as(n);
    for (int i = 0; i < n; i++) cin >> as[i];
    vector<int> dp(n);
    for (int i = n - 2; i >= 0; i--) {
        if (as[i + 1] <= as[i]) {
            dp[i] = dp[i + 1] + 1;
        } else {
            dp[i] = 0;
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  int N;
  cin >> N;
  if(N==7 || N==5 || N == 3) print("YES");
  else print("NO");
  
  

  return 0;
}


Measured memory_bytes: 256
n = int(input())
if n == 2:
    print(1)
    exit()
ans = []
divisors = []
for i in range(2,int(n**0.5)+1):
    #n-1の約数は全部
    if (n-1) % i == 0:
        ans.append(i)
        if i != (n-1) // i:
            ans.append((n-1)//i)
    #nの約数はやってみる
    if n % i == 0:
        divisors.append(i)
        if i != n // i:
            divisors.append(n//i)
for item in divisors:
    num = n
    while num%item == 0:
        num = num//item
    if num%item == 1:
        ans.append(item)
#print(divisors)
#print(ans)
print(len(ans)+2)#k=n,n-1がはいっていないので+2

'''
import math
n = int(input())
ans = []
divisors = []

for i in range(2,math.ceil(n**0.5)+1):
    num = n
    while num >= i:
        if num%i == 0:
            num //= i
        else:
            num -= i
    print(num)
    if num == 1:
        ans.append(i)
    if n % i == 0:
        divisors.append(i+1)
        if i != n // i:
            divisors.append(n//i+1)

print(ans)
print(divisors)
print(len(ans)+len(divisors))

#[2, 3, 4, 5, 10, 20, 157, 314, 628, 785, 1570, 3140, 3141]
'''

Measured memory_bytes: 3188
def round_up(i):
    if i % 10 == 0:
        return i
    return 10 - i % 10 + i


minutes = [int(input()) for i in range(5)]
m = [round_up(i) for i in minutes]
last = min((minutes[l] - 1) % 10 for l in range(5)) + 1

print(sum(m) + last - 10)


Measured memory_bytes: 38384
#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)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int v[100];
int main() {
  int n,K;
  while(cin>>n>>K) {
    inputs(v,n);
    ll ans = -(1LL << 50);
    REP(i,n) {
      for (int j=i; j<=n; j++) {
        if (i + (n-j) > K) continue;
        vector<int> have;
        REP(k,i) have.push_back(v[k]);
        for(int k=j; k<n; k++) have.push_back(v[k]);
        sort(ALL(have));

        ll sum = 0;
        FOR(it, have) sum += *it;
        REP(k, min((int)have.size(), K - (i + (n-j)))) {
          if (have[k] < 0) sum -= have[k];
          else break;
        }

        chmax(ans, sum);
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h[100005],dp[100005];
int main(){
	int n;
	cin>>n;
//	cout<<n;
	for(int i=0;i<n;i++) cin>>h[i];
	dp[0]=0;
	for(int i=1;i<n;i++){
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		if(i>1) dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
//		cout<<dp[i]<<" ";
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
struct Point{
    double x;
    double y;
};
//Point s,t,u;
void koch(int n,Point p1,Point p2){
    if(n==0)return;
    Point s,t,u;
    double dx=(p2.x-p1.x)/3;
    double dy=(p2.y-p1.y)/3;
    s.x=p1.x+dx;
    s.y=p1.y+dy;
    t.x=p2.x-dx;
    t.y=p2.y-dy;
    if(s.x<t.x)
    {
        if(s.y<t.y)
        {
            u.x=t.x-2*dx;
            u.y=t.y;
        }
        else if(s.y==t.y)
        {
            u.x=s.x+dx/2;
            u.y=s.y+(dx*sqrt(3))/2;
        }
        else{
            u.x=s.x+2*dx;
            u.y=s.y;
        }
    }
    else{
        if(s.y<t.y)
        {
            u.x=s.x+2*dx;
            u.y=s.y;
        }
        else if(s.y==t.y){
            u.x=s.x+dx/2;
            u.y=t.y+(dx*sqrt(3))/2;
        }
        else{
            u.x=t.x-2*dx;
            u.y=t.y;
        }
    }
    koch(n-1,p1,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,p2);
}
int main(){
    int n;
    cin>>n;
    Point p1,p2;
    p1.x=0;
    p1.y=0;
    p2.x=100;
    p2.y=0;
    printf("%.8f %.8f\n",p1.x,p1.y);
    koch(n,p1,p2);
    printf("%.8f %.8f\n",p2.x,p2.y);
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int s;
  cin>>s;
  vector<int> a(1000001);
  a[1]=s;
  for(int i=2;i<1000001;i++){
    if(a[i-1]%2==0){
      a[i]=a[i-1]/2;
    }
    if(a[i-1]%2==1){
      a[i]=a[i-1]*3+1;
    }
  }
  for(int i=2;i<1000001;i++){
    for(int j=0;j<i;j++){
      if(a[i]==a[j]){
        cout<<i<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 7192
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int L;
	cin >> L;

	L--;

	Int k = 1;
	vector<vector<Int>> ans;//from, to , 重み
	while (true) {
		if ((1LL<<k)-1<=L) {
			ans.push_back({ k,k + 1,0 });
			ans.push_back({ k,k + 1,1LL<<(k-1) });
			k++;
		}
		else {
			break;
		}
	}

	Int rest = L - ((1LL << (k-1)) - 1);//残り通り数
	for (Int i = 25; i >= 0; i--) {
		if (rest>=(1LL<<i)) {
			ans.push_back({ i + 1,k,L - (1LL << i) + 1 });
			rest -= (1LL << i);
			L -= (1LL << i);
		}
	}

	Int len = ans.size();
	cout << k << " " << len << "\n";
	for (Int i = 0; i < len; i++) {
		cout << ans[i][0]<<" "<<ans[i][1]<<" "<<ans[i][2] << "\n";
	}

}


Measured memory_bytes: 256
if __name__ == '__main__':
    k = input()
    k = int(k)
    ab = input()
    ab = ab.split()
    a = int(ab[0])
    b = int(ab[1])
    flag = False
    sum = k
    while k<=b:
        if a<=k and k<=b:
            flag = True
        k += sum
    if flag:
        print("OK")
    else:
        print("NG")


Measured memory_bytes: 9160
N = int(input()) - 1
rst = ''
for i in range(1, 10 ** 15):
    if N >= 26 ** i:
        N -= 26 ** i
        continue
    for j in range(i):
        rst += chr(ord('a') + N % 26)
        N //= 26
    print(rst[::-1])
    break

Measured memory_bytes: 9100
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim();
  var expressions = inputs.split('\n');
 
  for (var i = 0; i < expressions.length; i++) {
    if (expressions[i] === '0 ? 0') {
      break;
    }
    var expression = expressions[i].split(' ');
    var left = parseFloat(expression[0]);
    var right = parseFloat(expression[2]);
    var op = expression[1];
 
    if (op === '+') {
      console.log(left + right);
    } else if (op === '-') {
      console.log(left - right);
    } else if (op === '*') {
      console.log(left * right);
    } else if (op === '/') {
      console.log(Math.floor(left / right));
    }
  }
 
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 16068
/*
 * main.c
 *
 *  Created on: 2019/05/25
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int L[100001] = {0};
int R[100001] = {0};
int c[100001] = {0};
int main()
{
	int N = 0, M = 0, ans = 0, i = 0;
	int max_l = 0, min_r = 100001;
	scanf("%d %d", &N, &M);
	for(i = 1; i <= M; i++) {
		scanf("%d %d", &L[i], &R[i]);
		if(max_l < L[i]) {
			max_l = L[i];
		}
		if(R[i] < min_r) {
			min_r = R[i];
		}
	}
	if((min_r - max_l) < 0) {
		//
	} else {
		ans = (min_r - max_l) + 1;
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 896
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   // setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cassert> // assert
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  // abs, sin, cos, tan
#include <ctime> // clock

// __builtin_popcountll

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n; cin >> n;
  ll ans = 0;
  for(ll i = 105;i <= n;i += 2)
  {
    ll flag = 0;
    for(ll j = 1;j <= i;j++)
    {
      if(i % j == 0) flag++;
    }
    if(flag == 8) ans++;
  }
  cout << ans << endl;
  return;
}

//前処理
int main()
{
  int ti = clock();
  srand((unsigned)time(NULL));
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); //0埋め４桁
  Main();
  //cout << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl; // 実行時間計測
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#include <bitset>
#define LL long long

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a+b>=10)
    {
        cout << "error" << endl;
    }
    else
    {
        cout << a + b << endl;
    }
}

Measured memory_bytes: 256
import sys
import os
import math
from operator import itemgetter
 
N, H  = map(int,input().split())
katana = [0 for _ in range(N)]
 
for i in range(N):
    a,b = map(int,input().split())
    katana[i] = [a,b]
katana = sorted(katana,key=itemgetter(1),reverse=True)
maxA = 0
for i in range(N):
    maxA = max(maxA,katana[i][0])
 
cnt = 0
for k in katana:
    if H <= 0:
        print(cnt)
        sys.exit()
    if k[1] > maxA:
        H -= k[1]
        cnt += 1
cnt += math.ceil(H/maxA)
print(cnt)

Measured memory_bytes: 21912
N = int(input())
B = [int(i) for i in input().split()]

    
A = [0] * N
A[0] = B[0]
for i in range(1, N - 1):
    A[i] = min(B[i - 1], B[i])

A[N - 1] = B[N-2]

print(sum(A))

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1ll << 62)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  int n,m;
  cin >> n >> m;
  ll res = 0;
  REPD(i,(m/n)+1){
    if(!(m%i)){
      res = i;
      break;
    }
  }
  cout << res << endl;
  


  

  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main() {
	string O, E;
	cin >> O >> E;

	for (int i = 0; i < O.size(); i++) {
		cout << O[i];

		if (i < E.size())
			cout << E[i];
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<cmath>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int ans = a + b;
	if (ans < a - b)
		ans = a - b;
	if (ans < a*b)
		ans = a * b;

	cout << ans;
}

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

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() { 
    string S;
    cin >> S;

    if (S[S.size() - 1] == 's') {
        cout << S + "es" << "\n";
    } else {
        cout << S + "s" << "\n";
    }
    return 0;
}


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

int main()
{
    ll n;
    cin >> n;
    ll arr[5];
    for(ll i=0;i<5;i++)cin >> arr[i];
    ll ans = 0;
    ll mini = *min_element(arr,arr+5);

    cout << n/mini + (n%mini!=0) + 4 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,x;
    cin>>a>>b;
    x=a*b;
    if(x%2==0){
        cout<< "Even" <<endl;
    }
    else{
        cout<< "Odd" <<endl;
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
S = [input() for _ in range(H)]

X = [[0]*W for _ in range(H)]
Y = [[0]*W for _ in range(H)]

for h in range(H):
    cnt = 0
    l = 0
    for w in range(W):
        if S[h][w] == '.':
            cnt += 1
        else:
            for x in range(l, w):
                X[h][x] = cnt
            l = w+1
            cnt = 0
    for x in range(l, W):
        X[h][x] = cnt

for w in range(W):
    cnt = 0
    u = 0
    for h in range(H):
        if S[h][w] == '.':
            cnt += 1
        else:
            for y in range(u, h):
                Y[y][w] = cnt
            u = h+1
            cnt = 0
    for y in range(u, H):
        Y[y][w] = cnt

ans = 0
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            continue
        ans = max(ans, X[h][w] + Y[h][w] - 1)
print(ans)


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


int a,b,c,d,e;
int main(){

	while(cin >> a >> b >> c >> d >> e && a){
		int na,nb,nc;
		cin >> na >> nb >> nc;
		
		int ans = c * nc + na * a + nb * b;
		if( nc >= d){
			ans = e * nc + na * a + nb * b;
		}else{
			int s = d - nc;
			for(int i = 0 ; i <= min(na+nb,s) ; i++){
				int useB = i;
				int useA = 0;
				if( useB > nb ){
					useA = useB - nb;
					useB = nb;
				}
				ans = min(ans,d*e+(nb-useB)*b+(na-useA)*a);
			}
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);
int main(){
    string s;cin>>s;
    int ans =0;
    while(s.size()>1){
        if(s[0]==s.back()){
            s.erase(s.begin());
            s.pop_back();
        }
        else if(s[0]=='x'){
            ans++;
            s.erase(s.begin());
        }
        else if(s.back()=='x'){
            ans++;
            s.pop_back();
        }
        else {
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	string s; cin >> s;
	char x = 'a';
	vector<char> v(s.size());
	rep(i,s.size()){
		v[i] = s[i];
	}
	sort(all(v));
	rep(i,s.size()){
		if (x==v[i]){
			x++;
		}
	}
	if (x-'z' > 0){
		cout << "None" << endl;
	}else {
		cout << x << endl;
	}
	// cout << (x-'z' > 0 ? "None": x) << endl;
}

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

using pii = pair<int, int>;
using ll  = long long;
#define rep(i, j) for (int i = 0; i < (int)(j); i++)
#define repeat(i, j, k) for (int i = (j); i < (int)(k); i++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " : " << x << endl

template <class T>
bool set_min(T &a, const T &b) {
    return a > b ? a = b, true : false;
}
template <class T>
bool set_max(T &a, const T &b) {
    return a < b ? a = b, true : false;
}
// vector
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &a : v) is >> a;
    return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &t : v) os << "\t" << t;
    return os << endl;
}
// pair
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &v) {
    return os << "<" << v.first << ", " << v.second << ">";
}

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

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

    int N;
    cin >> N;
    vector<int> A(N - 1);
    cin >> A;
    vector<int> cnt(N);
    rep(i, A.size()) {
        cnt[A[i] - 1]++;
    }
    rep(i, N) {
        cout << cnt[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4756
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x;
    cin >> n >> x;
    int l[n];
    for(int i=0;i<n;i++)cin >> l[i];
    int ans=1;
    int count=0;
    for(int i=0;i<n;i++){
        count+=l[i];
        if(x<count)break;
        else ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve(ins):
    ins = ins.split("\n")
    h = list(map(int, ins[1].split(" ")))
    # costs = [abs(h1 - h2) for h1, h2 in zip(h, h[1:])]
    costs = [0, abs(h[0] - h[1])]
    for i in range(2, len(h)):
        costs.append(min(costs[i - 2] + abs(h[i] - h[i - 2]), costs[i - 1] + abs(h[i] - h[i - 1])))
    return costs[-1]


if __name__ == "__main__":
    print(solve("\n".join([input(), input()])))


Measured memory_bytes: 14952
#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];
    sort(A.begin(),A.end());
    bool count=true;
    for(int i=0;i<N-1;i++){
        if(A[i]==A[i+1]){
            count=false;

        }
    }
    if(count)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 1152
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    l, r, d = i_map()

    count = 0
    for i in range(l,r+1):
        if i % d == 0:
            count += 1

    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10516
#include <iostream>
#include <stdint.h>
#include <utility>
#include <limits.h>
#include <list>

struct Measurement{
  int64_t x;
  int64_t y;
  int64_t h;
};

using namespace std;

int main()
{
  int64_t N;
  cin >> N;

  list<struct Measurement> measurements;
  
  for (int64_t n=0; n<N; ++n) {
    int64_t x, y, h;
    cin >> x >> y >> h;
    struct Measurement measurement = {x,y,h};
    measurements.push_back(measurement);
  }

  if (measurements.front().h==0) {
    for (auto& m: measurements) {
      if (m.h!=0) {
	//cerr << "swapping" << endl;
	swap(measurements.front(), m);
	break;
      }
    } 
  }

  for (int64_t cx = 100; cx >= 0; --cx) {
    for (int64_t cy = 100; cy >= 0; --cy) {
      int64_t H = 0;
      bool flag = true;
      //cerr << "cx:" << cx << " cy:" << cy << endl;
      for (auto& m : measurements) {
	//cerr << m.x << ' ' << m.y << ' ' << m.h << endl;
	if (!flag)
	  break;
	if (H==0 && m.h > 0) {
	  H = m.h + abs(m.x - cx) + abs(m.y - cy);
	} else {
	  if (m.h != 0)
	    flag = (H == (m.h + abs(m.x - cx) + abs(m.y - cy)));
	  else // m.h==0
	    flag = (H <= (m.h + abs(m.x - cx) + abs(m.y - cy)));
	}
      }
      if (flag) {
	cout << cx << ' ' << cy << ' ' << H << endl;
	return 0;
      }
    }
  }
  
  cout << "Error"  << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1LL<<60)

int n,a,b;
vector<int> v;

int dp[2003][2];

int dfs(int used, int player){
    if(dp[used][player]!=-1)return dp[used][player];
    if(used==n)abort();
    int ret = abs(v[used-1]-v[n-1]);
    
    for(int k = n-1;k>used;k--){
        if(player==0)ret = max(dfs(k,!player),ret);
        else         ret = min(dfs(k,!player),ret);
    }
    
    return dp[used][player] = ret;
}

signed main(){
    cin>>n>>a>>b;
    n+=2;
    
    v.resize(n);
    v[0] = a;
    v[1] = b;
    rep(i,n-2)cin>>v[i+2];

    rep(i,2003)rep(k,2)dp[i][k] = -1;
    cout<<dfs(2,0)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iostream>
#include <set>
#include <deque>
#include <utility>
#include <numeric>
#include <map>
#include <math.h>
#define MAX 100000
#define inf (1LL << 62)
#define se second
#define fi first
#define pb push_back
#define m1 998244353
#define epi 1e-15d
#define NO "IMPOSSIBLE"
#define Ans(i, n) cout << "Case #" << i << ": " << n << endl;
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    int k,n;
    string s;
    cin >> k >> n >> s;
    s[n-1] ^= 32;
    cout << s;
}


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

ll a[maxn];
ll f[maxn];

inline ll read()
{
	ll x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

inline void writ(ll x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) writ(x/10);
	putchar(x%10+'0');
}
inline void write(ll x){writ(x);putchar('\n');}

int main()
{
	int t=0;
	int k=read();
	f[0]=1;
	for (int i=1;i<=20;++i) f[i]=9*f[i-1];
	for (int i=1;i<=9;++i) a[++t]=i;
	for (int i=1;i<=9;++i) a[++t]=i*10ll+9ll;
	for (int i=1;i<=19;++i) a[++t]=i*100ll+99ll;
	for (int i=2;i<=29;++i) a[++t]=i*1000ll+999ll;
	for (int i=3;i<=39;++i) a[++t]=i*10000ll+9999ll;
	for (int i=4;i<=49;++i) a[++t]=i*100000ll+99999ll;
	for (int i=5;i<=59;++i) a[++t]=i*1000000ll+999999ll;
	for (int i=6;i<=69;++i) a[++t]=i*10000000ll+9999999ll;
	for (int i=7;i<=79;++i) a[++t]=i*100000000ll+99999999ll;
	for (int i=8;i<=89;++i) a[++t]=i*1000000000ll+999999999ll;
	for (int i=9;i<=99;++i) a[++t]=i*10000000000ll+9999999999ll;
	for (int i=10;i<=99;++i) a[++t]=i*100000000000ll+99999999999ll;
	for (int i=10;i<=109;++i) a[++t]=i*1000000000000ll+999999999999ll;
	for (int i=11;i<=99;++i) a[++t]=i*10000000000000ll+9999999999999ll;
	for (int i=1;i<=k;++i) write(a[i]);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int d,w;
  int e[1001][1001],i,j;
  int l;
  int m,n;
  int xs,ys,xe,ye;
  int o,p,max;
  
  while(1){
  
    scanf("%d %d",&d,&w);

    if(d==0 && w==0){
      break;
    }

    for(i=0;i<d;i++){
      for(j=0;j<w;j++){
	scanf("%d",&e[i][j]);
      }
    }

    max=0;

    for(xe=2;xe<d;xe++){
      for(ye=2;ye<w;ye++){
	for(xs=0;xs<xe-1;xs++){
	  for(ys=0;ys<ye-1;ys++){

	    l=e[xs][ys];

	    for(j=ys;j<ye+1;j++){
	      if(e[xs][j]<l){
		l=e[xs][j];
	      }
	    }

	    for(i=xs;i<xe+1;i++){
	      if(e[i][ys]<l){
		l=e[i][ys];
	      }
	    }

	    for(j=ys;j<ye+1;j++){
	      if(e[xe][j]<l){
		l=e[xe][j];
	      }
	    }

	    for(i=xs;i<xe+1;i++){
	      if(e[i][ye]<l){
		l=e[i][ye];
	      }
	    }

	    n=0;
	    for(o=xs+1;o<xe;o++){
	      for(p=ys+1;p<ye;p++){

		m=l-e[o][p];
		n=n+m;
	
	      }
	    }

	    for(o=xs+1;o<xe;o++){
	      for(p=ys+1;p<ye;p++){
		if(e[o][p]>=l){
		  n=0;
		}
	      }
	    }

	    if(max<n){
	      max=n;
	    }
 
	  }
	}
      }
    }

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

  } 
  
  return 0;
}

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

using namespace std;

const int N = 2e5+7;
const int MOD = 1e9+7;
typedef pair<int, int> pii;

template <int _MOD> struct Mint
{
    int v = 0;
    Mint() {}
    Mint(int _v) : v((_v%_MOD+_MOD)%_MOD) {}
    Mint(long long _v) : v(static_cast<int>((_v%_MOD+_MOD)%_MOD)) {}
    Mint operator = (const int &_v) { return *this = Mint(_v); }
    Mint operator = (const long long &_v) { return *this = Mint(_v); }
    bool operator ! () const { return !this->v; }
    bool operator < (const Mint &b) const { return v < b.v; }
    bool operator > (const Mint &b) const { return v > b.v; }
    bool operator == (const Mint &b) const { return v == b.v; }
    bool operator != (const Mint &b) const { return v != b.v; }
    bool operator <= (const Mint &b) const { return v < b.v || v == b.v; }
    bool operator >= (const Mint &b) const { return v > b.v || v == b.v; }
    Mint operator + (const Mint &b) const { return Mint(v+b.v); }
    Mint operator - (const Mint &b) const { return Mint(v-b.v); }
    Mint operator * (const Mint &b) const { return Mint(1ll*v*b.v); }
    Mint operator / (const Mint &b) const { return Mint(b.inv()*v); }
    Mint& operator += (const Mint &b) { return *this = *this+b; }
    Mint& operator -= (const Mint &b) { return *this = *this-b; }
    Mint& operator *= (const Mint &b) { return *this = *this*b; }
    Mint& operator /= (const Mint &b) { return *this = *this/b; }
    Mint operator - () const { return Mint(-v); }
    Mint& operator ++ () { return *this += 1; }
    Mint& operator -- () { return *this -= 1; }
    Mint operator ++ (int) { Mint tmp = *this; *this += 1; return tmp; }
    Mint operator -- (int) { Mint tmp = *this; *this -= 1; return tmp; }
    Mint pow(int p) const {
        Mint res(1), x(*this);
        while (p) {
            if (p&1) res = res*x;
            x *= x;
            p >>= 1;
        }
        return res;
    }
    Mint inv() const { return pow(_MOD-2); }
    friend istream& operator >> (istream &is, Mint &mt) { return is >> mt.v; }
    friend ostream& operator << (ostream &os, const Mint &mt) { return os << mt.v; }
};
using mint = Mint<MOD>;

int n;
int a[N];

inline void solve()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort(a+1, a+n+1);
    reverse(a+1, a+n+1);
    mint res = 0, pow4 = 1;
    for (int i = 1; i < n; ++i) pow4 *= 4;
    for (int i = 1; i <= n; ++i)
        res += mint(i+1)*a[i];
    res *= pow4;
    cout << res << endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1024