akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#define pll              pair<long,long>
#define pii              pair<int,int>
#define scn(a)           scanf("%d", &a)
#define scn2(a, b)       scanf("%d%d", &a, &b)
#define scn3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pairl            pair<ll , ll >
#define scnl(a)          scanf("%lld", &a)
#define scnl2(a, b)      scanf("%lld%lld", &a, &b)
#define scnl3(a, b, c)   scanf("%lld%lld%lld", &a, &b, &c)
#define scns(s)          scanf("%s",s)
#define prts(s)          printf("%s\n",s)
#define prt(a)           printf("%d\n", a)
#define prtl(a)          printf("%lld\n", a)
#define prs(a)           printf("%d ", a)
#define prt2(a, b)       printf("%d %d\n", a, b)
#define prt3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define prsl(a)          printf("%lld ", a)
#define prtl2(a, b)      printf("%lld %lld\n", a, b)
#define prtl3(a, b, c)   printf("%lld %lld %lld\n", a, b, c)
#define ptcs(a)          printf("Case %d: ", a)
#define pf               printf
#define sc               scanf
#define m_p              make_pair
#define vi               vector<int >
#define vil              vector<ll >
#define pb               push_back
#define mem(a, b)        memset((a), (b), sizeof(a))
#define lg2(n)           (31-__builtin_clz(n))
#define N                200005
#define inf              9999999
#define ll               long long
#define ull              unsigned long long
#define MIN              INT_MIN
#define MAX              INT_MAX
#define fast             ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
ll gcd(ll a, ll b){if(b==0) {return a;}return gcd(b, a % b);}
ll BigMod(ll B,ll P,ll M){     ll R=1; while(P>0)      {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
//___________________________________________________________________________________________________________________

vector<ll>v[N],v1;
map<string,ll>mp;
bool ok=true;
int main()
{
    ll n,m,k,c=0,x,y;
    string s;
    cin>>n>>m;
    ll a[n+1];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        v1.pb(abs(a[i]-m));
        m=a[i];
    }
    ll g=v1[0];
    for(int i=1;i<v1.size();i++)
    {
        g=gcd(g,v1[i]);
    }
    cout<<g<<endl;
    return 0;
}


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

int main() {
  int n,x;
  cin >> n >> x;
  int l[110];
  int sum;
  int counter;

  for(int i = 0; i < n; i++){
      cin >> l[i];
  }
  
  sum = 0;
  counter = 1;
  
  for(int i = 0; i < n; i++){
      sum = sum + l[i];
      if(sum > x){
            cout << counter << endl;
            return 0;
     }
      counter = counter + 1;
   }
  
  cout << counter << endl;
  
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Data.Bits
import Control.Monad
import Control.Monad.ST

swap :: (VUM.Unbox a) => (a -> Bool) -> VUM.MVector s a -> ST s Int
swap f vec = loopl 0 (VUM.length vec - 1)
  where
    loopl x y | x > y = return x
    loopl x y = do
      vx <- VUM.unsafeRead vec x
      if (f vx) then
        loopl (x+1) y
      else
        loopr x y vx
    loopr x y vx | x > y = return x
    loopr x y vx = do
      vy <- VUM.unsafeRead vec y
      if not (f vy) then
        loopr x (y-1) vx
      else do
        VUM.unsafeWrite vec x vy
        VUM.unsafeWrite vec y vx
        loopl (x+1) (y-1)

sums :: Int -> VU.Vector Int -> ST s (VUM.MVector s Int)
sums n as = do
  vec <- VUM.new $ (n * (n + 1)) `div` 2
  forM_ (zip [0..] [(x,y) | x <- [n-1,n-2..0], y <- [x+1..n]])
    $ \(i,(x,y)) ->
        VUM.unsafeWrite vec i (preSum VU.! y - preSum VU.! x)
  return vec
  where
    preSum = VU.scanl' (+) 0 as 
  

query :: Int -> Int -> VU.Vector Int -> Int
query n k as = runST $ do
  svec <- sums n as
  loop svec 39 0
  where
    loop _ (-1) acc = return acc
    loop svec !lev !acc = do
      t <- swap (`testBit` lev) svec
      if k <= t then
        loop (VUM.take t svec) (lev - 1) (acc `setBit` lev)
      else
        loop svec (lev - 1) acc

main = do
  [n,k] <- map read . words <$> getLine
  as <- VU.unfoldrN n (BS.readInt . BS.dropWhile (==' ')) <$> BS.getLine
  putStrLn $ show $ query n k as


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

using namespace std;

// Ï
int p;
int n1,n5,n10,n50,n100,n500;

// ¨ÂèÌ
int cntMaisu(int money){
	int cnt=0;
	while(money!=0){
		if(money>=500){
			cnt+=(money/500);
			money-=500*(money/500);
		}
		else if(money>=100){
			cnt+=(money/100);
			money-=100*(money/100);
		}
		else if(money>=50){
			cnt+=(money/50);
			money-=50*(money/50);
		}
		else if(money>=10){
			cnt+=(money/10);
			money-=10*(money/10);
		}
		else if(money>=5){
			cnt+=(money/5);
			money-=5*(money/5);
		}
		else if(money>=1){
			cnt+=(money);
			money-=(money);
		}
	}
	return cnt;
}
// ^¦çê½ÅÌÅ¬Ìx¥¢û
int calc(int money){
	int nn1=n1;
	int nn5=n5;
	int nn10=n10;
	int nn50=n50;
	int nn100=n100;
	int nn500=n500;

	int cnt=0;
	while(money!=0){
		if(money>=500&&nn500>=1){
			int t=min(money/500,nn500);
			cnt+=t;
			money-=t*500;
			nn500-=t;
		}
		else if(money>=100&&nn100>=1){
			int t=min(money/100,nn100);
			cnt+=t;
			money-=t*100;
			nn100-=t;
		}
		else if(money>=50&&nn50>=1){
			int t=min(money/50,nn50);
			cnt+=t;
			money-=t*50;
			nn50-=t;
		}
		else if(money>=10&&nn10>=1){
			int t=min(money/10,nn10);
			cnt+=t;
			money-=t*10;
			nn10-=t;
		}
		else if(money>=5&&nn5>=1){
			int t=min(money/5,nn5);
			cnt+=t;
			money-=t*5;
			nn5-=t;
		}
		else if(money>=1&&nn1>=1){
			int t=min(money,nn1);
			cnt+=t;
			money-=t;
			nn1-=t;
		}
		else
			return -1;
	}
	return cnt;
}

int main(){
	while(cin>>p>>n1>>n5>>n10>>n50>>n100>>n500&&!(p==0)){
		int minCost=100000000;
		// ¿å¤ÇÌàzÅ¥¤
		int ret=calc(p);
		if(ret!=-1)
			minCost=min(minCost,ret);
		// ã©ç©Ô¹é
		//for(int i = 5; i <= 1000000; i+=5){
		//	int p1=p-(p%i)+i;
		//	int r=calc(p1);
		//	if(r!=-1)
		for(int i = p; i <= p+1000; i++){
			int p1=p-(p%i)+i;
			int r=calc(p1);
			if(r!=-1)
				minCost=min(minCost,r+cntMaisu(p1-p));
		}
//		}
		cout<<minCost<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>

int main(void)
{
    int n=0,i,j;
    char s[200];
    scanf("%s",s);
    
    n = strlen(s);//文字列の長さ取得

    for(i=n-1;i>0;i--){
        if(i%2==0){//2で割って余り0・つまり偶数の時のみ同じ文字は繰り返されるためそれ以外は無視
            for(j=0;j<i/2;j++){
                if(s[j]!=s[(i/2)+j])//iを半分で割り、真ん中+1が違った場合break、を繰り返す
                    break;
            }
            if(j==i/2)//s[j]とs[(i/2)+j]が最後まで一緒だった場合も続けないのでbreak
                break;
        }
    }
    printf("%d\n",i);
    
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#define INF (1LL<<62)
using namespace std;

long long a, b, c, d;

int main() {
  cin >> a >> b >> c >> d;
  long long m = -INF;
  if (a * c > m) m = a * c;
  if (a * d > m) m = a * d;
  if (b * c > m) m = b * c;
  if (b * d > m) m = b * d;
  printf("%lld\n", m);
}

Measured memory_bytes: 3760
import math

n = int(input())
s = str(bin(n))[2:]
p = 0
if n >= 0:
    while 1:
        s = str(bin(n))[2:]
        ls = len(s)
        lsp = ls - p - 1
        if ls <= p:
            break
        if p % 2 == 0:
            p += 1
            continue
        if s[lsp] == '0':
            p += 1
            continue
        p += 1
        n += 2**p
else:
    n = abs(n)
    while 1:
        s = str(bin(n))[2:]
        ls = len(s)
        lsp = ls - p - 1
        if ls <= p:
            break
        if p % 2 == 1:
            p += 1
            continue
        if s[lsp] == '0':
            p += 1
            continue
        p += 1
        n += 2**p
print(str(bin(n))[2:])


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

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif  

    double n, k;
    cin >> n >> k;
    cout << ceil((n - 1)/ (k - 1)) << endl;
    return 0;
}


Measured memory_bytes: 3784
n, k = map(int, input().split())

a = [int(x)-1 for x in input().split()]

v = []
vc = [0]*n
b = 0
c = 0

while True:
    if vc[b]>0:
        stop = v.index(b)
        break
    v.append(b)
    vc[b] += 1
    b = a[b]
    c += 1



if k>stop:
    r = (k-stop)%(c-stop)
    print(v[stop+r]+1)
else:
    print(v[k]+1)


Measured memory_bytes: 32308
a[];main(c,l,r,p){for(;scanf(p="%d",&r)*r;printf("%d\n",c)){for(c=++r;c;)l=scanf(p,--c+a);for(;l<r&&!++c|a[p=l+r>>1]-*a;)a[p]<*a?r=p:(l=p+1);}}

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

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

  vector<int> R(n);
  for (int i = 0; i < n; i++) {
    cin >> R.at(i);
  }

  int minv = R.at(0);
  int maxv = R.at(1) - R.at(0);

  for (int i = 1; i < n; i++) {
    maxv = max(maxv, R.at(i) - minv);
    minv = min(minv, R.at(i));
  }

  cout << maxv << endl;
}


Measured memory_bytes: 3616
import numpy as np
import math
A, B, C, D = [int(i) for i in input().split()]

large = np.max([C, D])
small = np.min([C, D])

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

num_B_1 = B // C
num_B_2 = B // D
num_B_3 = B // lcm(large, small)

num_A_1 = (A-1) // C
num_A_2 = (A-1) // D
num_A_3 = (A-1) // lcm(large, small)

numB = num_B_1 + num_B_2 - num_B_3
numA = num_A_1 + num_A_2 - num_A_3

print((B-A+1) - (numB - numA))

Measured memory_bytes: 12436
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 310;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

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

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

char s[maxn][maxn];

int main(){
	read(n);
	REP(i,0,n-1)scanf("%s",s[i]);
	int ans=0;
	REP(x,0,n-1){
		bool ok=1;
		REP(i,0,n-1)REP(j,0,n-1)if(s[(i+x)%n][j%n]!=s[(j+x)%n][i%n])ok=0;
		if(ok)ans+=n;
	}
	iout(ans);
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>


int max(int a, int b);
int min(int a, int b);

int main(void){
  int q;
  scanf("%d",&q);

  double x1,y1,x2,y2,x3,y3,x4,y4;
  double x,y;//直線の交点
  double det;//行列式
  double k1,k2;
  int a,b,c,d;
  for(int i=0;i<q;i++){
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
    det=(x2-x1)*(y4-y3)-(y2-y1)*(x4-x3);
    if(det==0){//平行
      if(x1*y2-x2*y1!=x3*y4-x4*y3){
        printf("0\n");
        continue;
      }


      if(x2==x1){
        a=min(y1,y2);
        b=max(y1,y2);
        c=min(y3,y4);
        d=max(y3,y4);
      }
      else{
        a=min(x1,x2);
        b=max(x1,x2);
        c=min(x3,x4);
        d=max(x3,x4);
      }

      if(b<c || d<a){
        printf("0\n");
      }
      else{
        printf("1\n");
      }
      continue;
    }
    x=((x3-x4)*(x1*y2-x2*y1)+(x2-x1)*(x3*y4-x4*y3))/det;
    y=((y3-y4)*(x1*y2-x2*y1)+(y2-y1)*(x3*y4-x4*y3))/det;
    if(x1==x2){
      k1=(y-y1)*1.0/(y2-y1);
    }
    else{
      k1=(x-x1)*1.0/(x2-x1);
    }
    if(k1<0 || 1<k1){
      printf("0\n");
      continue;
    }

    if(x3==x4){
      k2=(y-y3)*1.0/(y4-y3);
    }
    else{
      k2=(x-x3)*1.0/(x4-x3);
    }
    if(k2<0 || 1<k2){
      printf("0\n");
      continue;
    }
    printf("1\n");
  }
  return 0;
}

int max(int a, int b) {
    if (a > b)
        return a;
    else
        return b;
}

int min(int a, int b) {
    if (a < b)
        return a;
    else
        return b;
}



Measured memory_bytes: 2112
// Problem : C - /\/\/\/
// Contest : AtCoder - AtCoder Beginner Contest 111
// URL : https://atcoder.jp/contests/abc111/tasks/arc103_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a) for (int i=0; i<(a); i++)
#define rep1(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define imax INT_MAX
#define imin INT_MIN
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	 
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n,ce=0,co=0,o,e;
	cin>>n;
	map<int,int> even,odd;
	loop(i,n)
	{
		int temp;
		cin>>temp;
		if(i%2==0)
		{
			even[temp]++;
			ce++;
		}
		else
		{
			odd[temp]++;
			co++;
		}
	}
	int mn1=imax,mn2=imax;
	trav(i,odd)
	{
		if(mn1>co-i.s)
		{
			o=i.f;
			mn1=co-i.s;
		}
	}
	trav(i,even)
	{
		if(mn2>ce-i.s)
		{
			e=i.f;
			mn2=ce-i.s;
		}
	}
		if(e!=o)
		cout<<mn1+mn2<<nl;
		else
		{
			int mnn1=100000,mnn2=100000;
			trav(i,odd)
			{
				if(mnn1>co-i.s&&i.f!=o)
					mnn1=abs(co-i.s);
				}
			trav(i,even)
			{
				if(mnn2>ce-i.s&&i.f!=e)
					mnn2=abs(ce-i.s);
				}
			//	cout<<mnn1<<" "<<" "<<mn2<<" "<<mnn2<<" "<<mn1<<nl;
			if(mnn2==100000&&mnn1==100000)
			cout<<n/2;
			else
			cout<<min(mnn2+mn1,mn2+mnn1);
		}
	
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 8296
#include <algorithm>
#include <bitset>
#include <complex>
#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 <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define endl "\n"

using namespace std;
using ll = long long;
using ld = long double;
using bnum = int64_t;
int n;
ll ans=0;
int main() {
    cin >> n;
    vector<ll> s(n);
    cin >> s[0];
    for(int i = 1;i<n;++i){
        cin >> s[i];
        if(s[i]>=s[i-1]){
            continue;
        }else{
            ans+=s[i-1] - s[i];
            s[i] = s[i-1];
        }
    }cout << ans << endl;
}


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<llll> vllll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair
#define clamp(v,lo,hi) min(max(v,lo),hi)
#define ABS(x) max((x),-(x))

template<typename T1, typename T2> inline void amin(T1 & a, T2 const & b) { if (a>b) a=b; }
template<typename T1, typename T2> inline void amax(T1 & a, T2 const & b) { if (a<b) a=b; }
template<typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template<typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
inline ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }

template <typename T>
int find_left(vector<T>& v, T elem) {
    return (int)(upper_bound(v.begin(), v.end(), elem) - v.begin()) - 1;
}
template <typename T>
int find_right(vector<T>& v, T elem) {
    return (int)(lower_bound(v.begin(), v.end(), elem) - v.begin());
}

const ll MOD=1000000007LL;

inline ll ADD(ll x, ll y) { return (x+y) % MOD; }
inline ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
inline ll MUL(ll x, ll y) { return x*y % MOD; }
inline ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
inline ll INV(ll y) { /*assert(y%MOD!=0);*/ return POW(y, MOD-2); }
inline ll DIV(ll x, ll y) { return MUL(x, INV(y)); }

ll f(ll N, ll k){
    ll cnt = 1 + k*(N+1) - k*(k+1)/2 - k*(k-1)/2;
    return cnt;
}

ll solve(int N, int K) {
    ll total = 0;
    for(int k=K; k<=N+1; ++k){
        (total += f(N, k)) %= MOD;
    }
    return total;
}

int main() {
    int N, K; cin >> N >> K;
    cout << solve(N,K) << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    int x, y, a, b, c;
    scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
    vector<pair<ll, int>> p(a + b + c);
    for (int i = 0; i < a; i++) scanf("%lld", &p[i].first), p[i].second = 0;
    for (int i = a; i < a + b; i++) scanf("%lld", &p[i].first), p[i].second = 1;
    for (int i = a + b; i < a + b + c; i++) scanf("%lld", &p[i].first), p[i].second = 2;
    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    int rcnt = 0, gcnt = 0;
    ll ans = 0;
    for (int i = 0; i < x + y; i++) {
        if (p[i].second == 0) rcnt++;
        else if (p[i].second == 1) gcnt++;
        ans += p[i].first;
    }
    if (rcnt > x) {
        ans = 0, rcnt = 0, gcnt = 0;
        for (auto e : p) {
            if (e.second == 0) {
                if (rcnt < x) ans += e.first, rcnt++;
            } else if (gcnt < y) {
                ans += e.first, gcnt++;
            } else break;
        }
    } else if (gcnt > y) {
        ans = 0, rcnt = 0, gcnt = 0;
        for (auto e : p) {
            if (e.second == 1) {
                if (gcnt < y) ans += e.first, gcnt++;
            } else if (rcnt < x) {
                ans += e.first, rcnt++;
            } else break;
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define p2 pair<lo,lo>
#define p3 pair<pair<lo,lo>,lo>
#define p4 pair<pair<lo,lo>,pair<lo,lo> >
#define st first
#define nd second
using namespace std;
typedef long long int lo;
const int N=500005,mod=1000000007;
lo a,b,c,d,e,f,g,h[N],arr[N];
string s;
vector<lo>v;
map<string,lo>mpi;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);
 //    freopen("out.txt","w",stdout);
    cin >> a;
    for(lo i=1;i<=a;i++){
    	cin >> s;
    	mpi[s]++;
    	b=max(b,mpi[s]);
    }
    for(map<string,lo>::iterator it=mpi.begin();it!=mpi.end();it++){
    	if(it->nd==b){
    		cout << it->st << endl;
    	}
    }
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
const int N=200005;
struct Gragh{
	static const int M=N*2;
	int cnt,y[M],nxt[M],fst[N];
	void add(int a,int b){
		y[++cnt]=b,nxt[cnt]=fst[a],fst[a]=cnt;
	}
}g;
int n,m,c[N],out[N][2],del[N];
char s[N];
int q[N],head,tail;
int main(){
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for (int i=1;i<=n;i++)
		if (s[i]=='A')
			c[i]=0;
		else
			c[i]=1;
	memset(out,0,sizeof out);
	for (int i=1;i<=m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		out[a][c[b]]++;
		out[b][c[a]]++;
		g.add(a,b);
		g.add(b,a);
	}
	memset(del,0,sizeof del);
	head=tail=0;
	for (int i=1;i<=n;i++)
		if (!out[i][0]||!out[i][1])
			q[++tail]=i,del[i]=1;
	while (head<tail){
		int x=q[++head];
		for (int i=g.fst[x];i;i=g.nxt[i]){
			int y=g.y[i];
			if (del[y])
				continue;
			out[y][c[x]]--;
			if (!out[y][c[x]])
				q[++tail]=y,del[y]=1;
		}
	}
	puts(tail!=n?"Yes":"No");
	return 0;
}

Measured memory_bytes: 8064
N = int(input())
S = input()
ans = 0
for i in range(1000):
    cur = str(i).zfill(3)
    cnt = 0
    for s in S:
        if cur[cnt] == s:
            cnt += 1
        if cnt == 3: 
            ans += 1
            break
print(ans)


Measured memory_bytes: 43132
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
 
#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")
 
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl '\n';
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; }
template <class T> inline T lcm(T a, T b) { return a * b / gcd(a, b); }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
    #define eprintf(...) 42
#endif

clock_t startTime;
double getCurrentTime() {
    return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const ll MOD = (ll)1e9 + 7, INF = (ll)1e18;;
ll add(ll x, ll y) {
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}
ll sub(ll x, ll y) {
    x -= y;
    if (x < 0) return x + MOD;
    return x;
}
ll mul(ll x, ll y) {
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(x, bin_pow(x, p - 1));
    return bin_pow(mul(x, x), p / 2);
}

const int N = 100100;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    startTime = clock();
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int n, ans = 0;
    cin >> n;
    
    for (int a = 1; a < n; ++a) {
        int b = n / a;
        if (a * b == n) --b;
        ans += b;
    }
    cout << ans << endl;
    
    return 0;
}


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

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

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

    int ans = 1;
    int th = p[0];
    for (int i = 1; i < n; ++i) {
        if (th >= p[i]) ++ans;
        th = min(th, p[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC
{
    class ABC
    {
        static void Main(string[] args)
        {
            int intInputVal = int.Parse(Console.ReadLine());
            //出力
            Console.WriteLine("ABC" + intInputVal);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll h,w,n,a[10005];
ll ans[105][105]; 
int main() {
 
slld(h);slld(w);
slld(n);
for(int i=1;i<=n;i++)
	slld(a[i]);
ll ind=1;
for(int i=1;i<=h;i++)
{
	if(i%2)
	{
		for(int j=1;j<=w;j++)
		{
			ans[i][j]=ind;
			a[ind]--;
			if(a[ind]==0)ind++;
		}
	}
	else
	{
		for(int j=w;j>=1;j--)
		{
			ans[i][j]=ind;
			a[ind]--;
			if(a[ind]==0)ind++;
		}
	}	
}
for(int i=1;i<=h;i++)
{
	for(int j=1;j<=w;j++)
	{
		pss("%lld ",ans[i][j]);
	}
	pss("\n");
}
	return 0;
           } 

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL n, k;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    LL Ans = (n / k) * (n / k) * (n / k);
    if(k % 2 == 0)
    {
        n += k / 2;
        Ans += (n / k) * (n / k) * (n / k);
    }
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 256
H,W,K = map(int,input().split())
C = [[int(i) for i in input()] for _ in range(H)]
ans = float("inf")

for i in range(1<<(H-1)):
    start = [0]
    end = []
    for j in range(H-1):
        if i & (1 << j):
            j += 1
            start.append(j)
            end.append(j)
    end.append(H)
    L = len(end)
    cnt = [0]*L
    dcnt = L-1
    fail = False
    for w in range(W):
        div = False
        idx = 0
        tmp = [0]*L
        for s,e in zip(start,end):
            for h in range(s,e): tmp[idx] += C[h][w]
            if tmp[idx] > K: 
                fail = True
                break
            if cnt[idx] + tmp[idx] > K:
                div = True
                cnt = tmp[:]
            else:
                cnt[idx] += tmp[idx]
            idx += 1
        if fail: break
        if div: dcnt += 1
    if fail: continue
    ans = min(dcnt,ans)

print(ans)

Measured memory_bytes: 46044
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

LL A, B, C, D;

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

    LL cd = lcm(C, D);

    LL bc = B / C;
    LL bd = B / D;
    LL bcd = B / cd;
    LL b = B - (bc + bd - bcd);

    LL ac = (A - 1) / C;
    LL ad = (A - 1) / D;
    LL acd = (A - 1) / cd;
    LL a = (A - 1) - (ac + ad - acd);

    LL ans = b - a;

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


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>
#define ll long long
using namespace std;

ll A[200010];
priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
bool cd[200010];

int main() {
	int N;
	ll D;
	cin >> N >> D;
	for(int i=0; i<N; ++i){
		cin >> A[i];
		pq.push(make_pair(A[i], i));
	}
	int cnt=0;
	ll ans=0;
	while(cnt<N-1){
		int now=pq.top().second;
		if(now>0){
			if(!cd[now]){
				cd[now]=1;
				ans += A[now]+A[now-1]+D;
				if(A[now]+D<A[now-1]){
					A[now-1]=A[now]+D;
					pq.push(make_pair(A[now-1], now-1));
				}
				++cnt;
			}
		}
		if(now<N-1){
			if(!cd[now+1]){
				cd[now+1]=1;
				ans += A[now]+A[now+1]+D;
				if(A[now]+D<A[now+1]){
					A[now+1]=A[now]+D;
					pq.push(make_pair(A[now+1], now+1));
				}
				++cnt;
			}
		}
		pq.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7408
#include <stdio.h>
#include <string.h>

int main(){
  int k,c=0;
  char S[20];
  scanf("%s",S);
  k=strlen(S);
  for(int i=0;i<k;i++)
    if(S[i]=='o') c++;
  if((15-k)+c>=8) printf("YES\n");
  else printf("NO\n");
  return 0;
}

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

int main(void){

  int debt,week,i;
  debt = 100000;

  cin >> week;

  for(i=0; i<week; i++){
    debt = debt * 1.05;
    if(debt % 1000 > 0){
      debt += 1000 - (debt % 1000);
    }
  }

  cout << debt << endl;
  return 0;

}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;

  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}


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

int main() {
    int k,n; cin>>k>>n;
    
    int m = 0;
    int sum = 0;
    int a[n];
    
        cin>>a[0];
        
    for(int i=1;i<n;++i){
        cin>>a[i];
        sum+=a[i]-a[i-1];
        m = max(m,a[i]-a[i-1]);
    }
    sum = sum + k-a[n-1]+a[0];
    
    m = max(m,k-a[n-1]+a[0]);
    sum = sum - m;

    cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	string s;
	int n, i, j, k, x, ss = 0, ans;
	cin >> n;
	map<string, int> pp;
	while (n--) {
		cin >> s >> x;
		ss += x;
		pp[s] = ss;
	}
	cin >> s;
	ans = ss - pp[s];
	cout << ans << "\n";

	return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


int n, k;
ll h[200005];
void solve() {
    cin >> n >> k;
    rep(i, n) cin >> h[i];

    sort(h, h + n, greater<>());

    ll ans = 0;
    rep(i, n) {
        if (i < k) continue;
        ans += h[i];
    }

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main() {

  int m, ans = 0, bad = 0;
  int popp;
  string n;
  cin >> n;
  for(int i = 0;i < n.size();i++){

    popp = n[i] - '0';
    ans += (popp != (i % 2));
    bad += (popp == (i % 2));
  }
  cout << min(ans, bad);
  return 0;
}


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

int main()
{
 int n;
 cin >> n;
 vector<int> p(n),q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  vector<int> a(n);
  rep(i,n) a[i]=i+1;
  map<vector<int>,int> mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(a.begin(),a.end()));
  int ans = abs(mp[p]-mp[q]);
  cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <set>
#include <cstring>
using namespace std;
 
int n,k;
set<int> dlike;
 
inline bool ok(int x)
{
	while(x>0)
	{
		if(dlike.count(x%10)) return 0;
		x/=10;
	}
	return 1;
}
 
int main()
{
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		int a;
		cin>>a;
		dlike.insert(a);
	}
	
	for(int i=n;i<100000;i++) if(ok(i)) {cout<<i;exit(0);}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;
 
int32_t main(){
    vaibhavv06;
	int n,W; cin>>n>>W;
    int w[n],v[n];
    int dp[W+1]={0};
    for(int i=0;i<n;i++) cin>>w[i]>>v[i];

    for(int i=0;i<n;i++){
        for(int j=W-w[i]; j>=0; j--){
            dp[j+w[i]] = max(dp[j+w[i]],dp[j]+v[i]);
        }
    }
    int ans=0;
    for(int i=0;i<=W;i++) ans= max(ans,dp[i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#

import sys
input=sys.stdin.readline

def main():
    H,W=map(int,input().split())
    print("".join(["#"]*(W+2)))
    for i in range(H):
        print("#",input().strip("\n"),"#",sep="")
    print("".join(["#"]*(W+2)))
    
if __name__=="__main__":
    main()


Measured memory_bytes: 62704
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

struct list {
	char c;
	struct list *front;
	struct list *back;
};

list *make_list(char c,list *f, list *b) {
	list* l = (list*)malloc(sizeof (list));
	l->c = c;
	l->front = f;
	l->back = b;
	return l;
}

int main() {
	int n;
	string b;
	cin >> n;
	for (int i = 0; i < n; i++) {
		list* train = (list*)malloc(sizeof (list));
		cin >> b;
		list** t;
		train->c = b[0];
		train->front = NULL;
		train->back = NULL;
		for (int j = 1; j < b.size(); j++) {
			if (b[j] == '-') {
			} else if (b[j] == '>') {
				if (train->back == NULL) {
					train->back = make_list(b[j+1], train, NULL);
				}
				train = train->back;
				j++;
			} else if (b[j] == '<') {
				if (train->front == NULL) {
					train->front = make_list(b[j+2], NULL, train);
				}
				train = train->front;
				j+=2;
			} 
		}
		while (train->front != NULL) {
			train = train->front;
		}
		while (train->back != NULL) {
			cout << train->c;
			train = train->back;
		}
		cout << train->c << endl;
	}
	return 0;
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int e,f,g;
  e=abs(a-b); 
  f=abs(c-b);
  g=abs(c-a);
  if(g<=d){
    cout<<"Yes"<<endl;
  }
  else if(f<=d&&e<=d){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
# 2019/02/09
# Minnano Procon 2019 - A

# Input
n, k = map(int,input().split())

# Calc
wn = int(n / 2 + 0.5)

if wn >= k:
    ans = "YES"
else:
    ans = "NO"

# Output
print(ans)

Measured memory_bytes: 2940
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		HashSet<Integer> hs = new HashSet<Integer>();
		for(int i = 0; i < n; i++){
		    hs.add(sc.nextInt());
		}
		
		// 計算
		int result = hs.size();
		
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 21716
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

h, w = MAP()
c = []
for i in range(10):
    c.append(LIST())
a = []
for i in range(h):
    a.append(LIST())

for i in range(10):
    for j in range(10):
        for k in range(10):
            c[j][k] = min(c[j][k], c[j][i]+c[i][k])

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] != -1:
            ans += c[a[i][j]][1]
print(ans)

Measured memory_bytes: 10688
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;

vector<pair<ll, ll> > prime_factorize(ll N) {
    vector<pair<ll, ll> > res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

ll C2(ll n) {
    if (n < 0) {
        return 0;
    }
    return n * (n - 1) / 2;
}

void Main()
{
    ll n;
    cin >> n;

    vector<ll> primeCnt(101);

    for (ll i = 2; i <= n; i++) {
        auto primes = prime_factorize(i);
        for(auto p: primes) {
            primeCnt[p.first] += p.second;
        }
    }

    // 指数がi以上の素数のかずd[i]
    vector<ll> d(101);
    rep(i, primeCnt.size()) {
        if (primeCnt[i] <= 0) {
            continue;
        }
        ll num = primeCnt[i];
        rep(i, num + 1) {
            d[i]++;
        }
    }

    ll res = d[74]; // 75
    res += C2(d[4]) * (d[2] - 2); // 5 x 5 x 3
    res += d[14] * (d[4] - 1);
    res += d[24] * (d[2] - 1);

    put(res);    
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=505;
const ll INF=1LL<<60;
ll rui[MAX];

void nor(ll &h1,ll &w1,ll &h2,ll &w2,ll level){
    if(h1>h2){
        h1=rui[level]-1-h1;
        h2=rui[level]-1-h2;
    }
    if(w1>w2){
        w1=rui[level]-1-w1;
        w2=rui[level]-1-w2;
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    rui[0]=1;
    for(int k=1;k<=30;k++) rui[k]=rui[k-1]*3;
    
    int Q;cin>>Q;
    while(Q--){
        ll h1,w1,h2,w2;cin>>h1>>w1>>h2>>w2;
        h1--;w1--;h2--;w2--;
        
        nor(h1,w1,h2,w2,30);
        
        ll ans=h2-h1+w2-w1;
        
        for(int t=30;t>=0;t--){
            ll ph1=h1/rui[t];
            ll pw1=w1/rui[t];
            ll ph2=h2/rui[t];
            ll pw2=w2/rui[t];
            
            if(ph1==ph2&&pw1==pw2) continue;
            
            if(ph1==ph2){
                if(ph1%3==1&&pw2-pw1!=1){
                    ll a1=h1-(ph1*rui[t]-1);
                    ll a2=(ph1+1)*rui[t]-h1;
                    ll b1=h2-(ph2*rui[t]-1);
                    ll b2=(ph2+1)*rui[t]-h2;
                    ans=w2-w1+min(a1+b1,a2+b2);
                    break;
                }
            }
            
            if(pw1==pw2){
                if(pw1%3==1&&ph2-ph1!=1){
                    ll a1=w1-(pw1*rui[t]-1);
                    ll a2=(pw1+1)*rui[t]-w1;
                    ll b1=w2-(pw2*rui[t]-1);
                    ll b2=(pw2+1)*rui[t]-w2;
                    ans=h2-h1+min(a1+b1,a2+b2);
                    break;
                }
            }
        }
        
        cout<<ans<<"\n";
    }
    
}


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


int main() {
  int n; 
  string s;
  cin >> n >> s;
  int ns = s.size();
  int cnt = 0;
  rep(i, 1000) {
    vector<int> pin = {i/100, (i/10)%10, i%10};
    int c = 0;
    rep(j, ns) if (s[j] == (pin[c] + '0')) {
      c++; 
      if (c == 3) { cnt++; break; }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int N,A[110]={};
int ans=0;
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      ans=max(abs(A[i]-A[j]),ans);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    TC = 1
    while True:
        N = int(input())
        if N == 0:
            break

        arr = [ [ 0 for _ in range(N) ] for _ in range(N) ]

        i = 0
        j = 0
        val = 1
        prevMove = "UR"

        while True:
            arr[i][j] = val
            val += 1

            if i == N - 1 and j == N - 1:
                break
            elif i == 0:
                if prevMove == "UR":
                    if j != N - 1:
                        j += 1
                        prevMove = "R"
                    else:
                        i += 1
                        prevMove = "D"
                else:
                    i += 1
                    j -= 1
                    prevMove = "DL"
            elif i == N - 1:
                if prevMove == "DL":
                    j += 1
                    prevMove = "R"
                else:
                    i -= 1
                    j += 1
                    prevMove = "UR"
            elif j == 0:
                if prevMove == "DL":
                    i += 1
                    prevMove = "D"
                else:
                    i -= 1
                    j += 1
                    prevMove = "UR"
            elif j == N - 1:
                if prevMove == "UR":
                    i += 1
                    prevMove = "D"
                else:
                    i += 1
                    j -= 1
                    prevMove = "DL"
            else:
                if prevMove == "DL":
                    i += 1
                    j -= 1
                else:
                    i -= 1
                    j += 1

        print("Case {}:".format(TC))
        TC += 1

        for i in range(N):
            for j in range(N):
                print("{:3d}".format(arr[i][j]), end='')
            print()


Measured memory_bytes: 5636
#include <iostream>
using namespace std;
int main(){
  long long int N, T, a;
  long long int sum = 0;
  cin >> N >> T;
  long long int t[N];
  for(int i  = 0; i < N; ++i){
    cin >> t[i];
  }
  for(int i = 0; i < N; ++i){
    if(t[i+1] - t[i] >= T){
      sum = sum + T;
    }
    if(t[i+1] - t[i] < T){
      sum = sum + t[i+1] - t[i];
    }
  }
cout << sum << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int i, n, x;
	fscanf(stdin, "%d", &n);
	for(i=1;i<=n;i++){
		x=i;
		if(x%3==0){
			printf(" %d", i);
			continue;
		}
		do{
			if(x%10==3){
				printf(" %d", i);
				break;
			}
			x/=10;
		}while(x);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2112
# coding: utf-8

# 14:35-14:48


def main():
    N, K = map(int, input().split())
    q = 10**9 + 7

    ans = 0
    for n in range(K, N+2):
        ans += n*(N-n+1) + 1
    
    return ans % q


print(main())


Measured memory_bytes: 9148