akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair
#define sz size
#define inf 1e9+5
 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,m;
    cin>>n>>m;
    priority_queue<ll> pq;
    ll a;
    for(ll i=0;i<n;i++){
        cin>>a;
        pq.push(a);

    }

    for(ll i=0;i<m;i++){
        ll temp=pq.top();
        pq.pop();
        pq.push(temp/2);
    }
    ll ans=0;
    while(!pq.empty()){
        ans+=(pq.top());
        pq.pop();
    }
    cout<<ans<<"\n";

    return 0;  
}

Measured memory_bytes: 1400
n, a, b=map(int, input().split())
S=list(input())
tuuka=a+b
gaijin=b
for s in S:
  if s=="c":
    print("No")
  elif s=="a":
    if tuuka>0:
      tuuka-=1
      print("Yes")
    else:
      print("No")
  elif s=="b":
    if tuuka>0 and gaijin>0:
      gaijin-=1
      tuuka-=1
      print("Yes")
    else:
      print("No")
      
    


Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

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

bool solve(ll A, ll B, ll C, ll D) {
  if (B > D) return false;

  ll x = max(A - C - 1, 0LL);
  ll t = x / B;
  ll a = A - t * B;
  if (a - B < 0) return false;

  if (B <= C) return true;

  ll g = gcd(B, D);
  return (B - g) % B + (A % g) <= C;
}

int main(void) {
  ll T;
  cin >> T;

  while (T-- > 0) {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << (solve(A, B, C, D) ? "Yes" : "No") << endl;
  }
}

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

int main() {
    string N;
    cin >> N;
    if(N[1] == N[2] && (N[0] == N[1] || N[3] == N[2])) cout << "Yes" << endl;
    else cout << "No" << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;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;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=600005;
const int mod=1e9+7;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
int pre[MAXN],inv[MAXN];
int C(int n,int m){return 1LL*pre[n]*inv[m]%mod*inv[n-m]%mod;}
int n,m,L,R;
int query(int p,int q,int lim)//>=p <q
{
	int fx=m,fy=n-m,ret=0;if(1LL*fx*p>lim)return 0;
	for(int i=0;i<=fy;i++)
	{
		int total=lim-i*q-fx*p;
		if(total<0)break;
		int num=1LL*C(total+n,n)*C(n,fx)%mod*C(n-fx,i)%mod;
		if(i&1)dl(ret,num);else ad(ret,num);
	}return ret;
}
int solve(int lim)
{
	int ans=0;
	for(int i=1;i<=lim;i++)ad(ans,query(i,i,lim)),dl(ans,query(i+1,i,lim));
	return (C(lim+n,n)-ans+mod)%mod;
}
int main()
{
	pre[0]=1;for(int i=1;i<MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod;
	inv[MAXN-1]=pow_mod(pre[MAXN-1],mod-2);
	for(int i=MAXN-2;i>=0;i--)inv[i]=1LL*inv[i+1]*(i+1)%mod;
	n=read();m=read();L=read();R=read();
	pr2((solve(R)-solve(L-1)+mod)%mod);
	return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a); '\n';
 
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	vector<char> s(n+2);
	rep(i, n) cin >> s[i];
	a -= 1;
	b -= 1;
	c -= 1;
	d -= 1;
	s[a] = 'A';
	s[b] = 'B';
	if (c < d) {
		while (true) {
			int tmpa = a;
			int tmpb = b;
			if (s[b + 2] == '.'&&b + 2 <= d) {
				b += 2;
				s[b] = 'B';
				s[b - 2] = '.';
			}
			if (s[b + 1] == '.'&&b + 1 <= d) {
				b += 1;
				s[b] = 'B';
				s[b - 1] = '.';
			}
			if (s[a + 2] == '.'&&a + 2 <= c) {
				a += 2;
				s[a] = 'A';
				s[a - 2] = '.';
			}
			if (s[a + 1] == '.'&&a + 1 <= c) {
				a += 1;
				s[a] = 'A';
				s[a - 1] = '.';
			}
			if (a == c && b == d) { cout << "Yes"; return 0; }
			if (a == tmpa && b == tmpb) { cout << "No"; return 0; }
		}
	}
	else{
		while (true) {
			int tmpa = a;
			int tmpb = b;
			if (s[a + 2] == '.'&&a + 2 <= c) {
				a += 2;
				s[a] = 'A';
				s[a - 2] = '.';
			}
			else if (s[a + 1] == '.'&&a + 1 <= c) {
				a += 1;
				s[a] = 'A';
				s[a - 1] = '.';
			}
			else if (s[b + 1] == '.'&&b + 1 <= d) {
				b += 1;
				s[b] = 'B';
				s[b - 1] = '.';
			}
			else if (s[b + 2] == '.'&&b + 2 <= d) {
				b += 2;
				s[b] = 'B';
				s[b - 2] = '.';
			}
			if (a == c && b == d) { cout << "Yes"; return 0; }
			if (a == tmpa && b == tmpb) { cout << "No"; return 0; }
		}
	}
	}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
int main(){
  int ap,bp,i,j,len,e=0;
  char data[3][100];

  while(1){
    for(i=0;i<3;i++){
      ap=0;
      bp=0;
   
      scanf("%s",data[i]);
      if(data[0][0]=='0'){
	e=1;
	break;
      }
      len=strlen(data[i]);
      for(j=1;j<len;j++){
        if(data[i][j]=='A') ap++;
        if(data[i][j]=='B') bp++;
      }
      if(ap>bp){
	ap++;
        printf("%d %d\n",ap,bp);
      }
      if(ap<bp){
	bp++;
        printf("%d %d\n",ap,bp);
      }
    }
    if(e==1) break;
  }
  return 0;
}    

    

Measured memory_bytes: 544
a,b,c,d=map(int,input())
s=[1,-1]
f=['+','-']
for i in range(2):
    for j in range(2):
        for k in range(2):
            if a+b*s[i]+c*s[j]+d*s[k]==7:
                    print(str(a)+f[i]+str(b)+f[j]+str(c)+f[k]+str(d)+'=7')
                    exit()

Measured memory_bytes: 3064
n = gets.chomp.to_i
a = gets.split.map(&:to_i)
def color(rate)
  if rate < 3200
    rate / 400
  else
    8
  end
end
h = Hash.new(0)
a.each do |r|
  h[color(r)] += 1
end
rr = 0
if h[8]
  rr = h[8]
  h.delete(8)
end
min = [h.size, 1].max
max = h.size + rr
puts "#{min} #{max}"


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

int main()
{
	int a; int b;
	cin >> a >> b;
	if (a <= 5) cout << 0 << endl;
	if (6 <= a && a <= 12) cout << b / 2 << endl;
	if (a > 12) cout << b << endl;
	return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
for i in range(n):
  ans = ""
  for j in range(i + 1, n):
    ixorj = i ^ j
    cnt = 1
    while ixorj >= 2:
      cnt += 1
      ixorj //= 2
    ans += str(cnt)
    if j != n-1:
      ans += " "
  print(ans)

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

using ll=long long;
int main(){
    ll N,M;
    cin>>N>>M;

    vector<ll> L(N),R(N);

    for(int i=0;i<N;i++) cin>>L[i]>>R[i],R[i]++;
    vector<int> inv;
    map<ll,int> mpX;
    {
        set<ll> s;
        for(auto& x:L) s.insert(x);
        for(auto& x:R) s.insert(x);
        int id=0;
        inv.resize(s.size());
        for(auto& x:s) mpX[x]=id++,inv[id-1]=x;
    }

    vector<int> sum(mpX.size());
    for(int i=0;i<N;i++){
        sum[mpX[R[i]]]--;
        sum[mpX[L[i]]]++;
    }
    for(int i=1;i<mpX.size();i++){
        sum[i]+=sum[i-1];
    }

    int turn=*max_element(sum.begin(),sum.end());

    if(turn%2==1){
        int pos=inv[sum.rend()-max_element(sum.rbegin(),sum.rend())-1];
        ll epos=1e9;
        for(int i=0;i<N;i++){
            if(L[i]<=pos && pos<R[i]){
                epos=min(epos,R[i]);
            }
        }
        ll res=(turn-1)*M+epos-1;
        cout<<res<<endl;
    }
    else{
        int pos=inv[max_element(sum.begin(),sum.end())-sum.begin()];
        ll epos=0;
        for(int i=0;i<N;i++){
            if(L[i]<=pos && pos<R[i]){
                epos=max(epos,L[i]);
            }
        }
        ll res=(turn-1)*M+M-epos;
        cout<<res<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 51048
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        int n = sc.nextInt();
        int dt, dx, dy, dif;
        // 初期値
        boolean can = true;
        int t = 0;
        int x = 0;
        int y = 0;

        for (int i = 0; i < n; i++) {
            // 入力値
            dt = sc.nextInt();
            dx = sc.nextInt();
            dy = sc.nextInt();
            dif = dt - t - Math.abs(dx - x) - Math.abs(dy - y);
            can = can & (dif >= 0 && dif % 2 == 0);
            t = dt;
            x = dx;
            y = dy;
        }

        // 出力
        if (can) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 89200
from functools import lru_cache


@lru_cache(None)
def f(x):
    if x == 0:
        return 0
    if x == 1:
        return D
    res = D*x
    for i in [2, 3, 5]:
        res = min(res, f(x//i)+x%i*D+coins[i], f(-(-x//i))+(i-x%i)*D+coins[i])
    return res


T = int(input())
for _ in range(T):
    N, A, B, C, D = map(int, input().split())
    coins = {2: A, 3: B, 5: C}
    print(f(N))
    f.cache_clear()


Measured memory_bytes: 11528
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

// http://wikiwiki.jp/cattail/?%CE%E0%BB%F7%C5%D9%A4%C8%B5%F7%CE%A5

// p=1
// ???????????????????????¢
double CalcManhattanDistance(int *vx, int *vy, int n)
{
	int i;
	double d = 0;
	for (i = 0; i < n; i++)
	{
		//printf("vx[i] - vy[i]=%d\n", (vx[i]-vy[i]));
		d += fabs(vx[i] - vy[i]);
	}
	return d;
}

// p=2
double CalcEuclideanDistance(int *vx, int *vy, int n)
{
	int i;
	double d = 0;
	for (i = 0; i < n; i++)
		d += pow(fabs(vx[i] - vy[i]), 2);
	return sqrt(d);
}
// p=3
double CalcMinkowskyDistance(int *vx, int *vy, int n)
{
	int i;
	double d = 0;
	for (i = 0; i < n; i++)
		d += pow(fabs(vx[i] - vy[i]), 3);
	return pow(d, 1.0/3.0);
}

double CalcChebyshevDistance(int *vx, int *vy, int n)
{
	int max = 0;
	int i;
	for (i = 0; i < n; i++)
	{
		if (max == 0)
			max = fabs(vx[i]-vy[i]);
		
		if (max < fabs(vx[i]-vy[i]))
			max = fabs(vx[i]-vy[i]);
	}
	return max;
}

int main()
{
	int n, i;
	int vx[100] = {0};
	int vy[100] = {0};
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++)
	{
		int x;
		scanf("%d", &x);
		vx[i] = x;
	}
	for (i = 0; i < n; i++)
	{
		int y;
		scanf("%d", &y);
		vy[i] = y;
	}
	
	printf("%f\n", CalcManhattanDistance(vx, vy, n));
	printf("%f\n", CalcEuclideanDistance(vx, vy, n));
	printf("%f\n", CalcMinkowskyDistance(vx, vy, n));
	printf("%f\n", CalcChebyshevDistance(vx, vy, n));
	
	return 0;
}

Measured memory_bytes: 696
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N;
    cin >> N;
    if (N == 1) {
        cout << "Hello World" << endl;
    }
    else {
        int A, B;
        cin >> A >> B;
        cout << A+ B << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string arr;
const int mod = 1e9+7, q =  1e5+5;
ll dp[q][150][2];

ll getsum(int ind, int n, int sum, bool flag, int d){
    if(ind>=n){return sum==0;}
    int limit=9;
    if(!flag) limit= arr[ind]-'0';
    //flag=true means earlier ther is some smaller digit used so we can take till 9 this time;
    if(dp[ind][sum][flag]!=-1) return dp[ind][sum][flag];
    
    ll res=0;
    for(int i=0;i<=limit;i++){
        if(flag || i<limit)
            res= (res + getsum(ind+1, n, (sum + i)%d, true,  d))%mod;

        else
            res= (res + getsum(ind+1, n, (sum + i)%d, false, d))%mod;
    }
    return dp[ind][sum][flag]= res;
}

int main(){
    // int t;cin>>t;
    // while(t--){
        // ll x, y; cin >> x >> y;
        string b; cin>>b;
        arr = b;
        int d; cin>>d;
        for(int i=0;i<b.size();i++)for(int j=0;j<150;j++)for(int k=0;k<2;k++) 
            dp[i][j][k]=-1;
        
        // for(int i=0;i<b.size();i++) arr[i]=b[i]-'0';
        ll right=getsum(0, b.size(), 0, 0, d);
        cout << (right - 1 + mod)%mod << endl;
    // }
}

Measured memory_bytes: 28152
#include<iostream>

using namespace std;

int main () {

    int n, x;
    int i, j, k;

    while (true) {

        cin >> n >> x;

        if (n == 0 && x == 0) {

            break;

        }

        int count = 0;

        for (i = 1; i <= n; i++) {

            for (j = i + 1; j <= n; j++) {

                for (k = j + 1; k <= n; k++) {

                    if (i + j + k == x) {

                        count += 1;

                    }

                }

            }

        }

        cout << count << endl;

    }

    return 0;

}

    

Measured memory_bytes: 3092
a, b = map(int, input().split())
s = input()
lst = list("1234567890")
for i in range(a + b + 1):
    if i < a:
        if s[i] not in lst:
            print("No")
            exit()
    elif i == a:
        if s[i] != "-":
            print("No")
            exit()
    elif b <= i:
        if s[i] not in lst:
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N, T;
  cin >> N >> T;
  vll t(N);
  for(int i = 0; i < N; i++){
    cin >> t.at(i);
  }
  ll sum = 0;
  for(int i = 0; i < N; i++){
    if(i == N-1) sum += T;
    else{
      sum += min(T, t.at(i+1) - t.at(i));
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    int i;
    int min=INF;
    ll sum=0;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        if(tmp%10!=0) min=MIN(min,tmp);
        sum+=tmp;
    }
    if(sum%10==0) {
        if(min==INF) {
            printf("0\n");
        }
        else {
            printf("%lld\n", sum-min);
        }
    }
    else {
        printf("%lld\n", sum);
    }


    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define loop(i,a,b)for(ll i=a;i<=b;i++)
#define loopr(i,a,b)for(ll i=b;i>=a;i--)
#define vll vector<ll> 
#define vvl vector<vll>
#define pii pair<ll,ll>
#define F first
#define S second
#define endl "\n"
#define M 1000000007
ll max(ll a,ll b){if (a>b) return a; else return b;}
 
/*ll po(ll x, ll y){
    if(y==0)
    return 1;
    if(y%2){
        return ((x)(po(x,y/2)%M)(po(x,y/2)%M) + M)%M;
    }
   return ((po(x,y/2)%M)*(po(x,y/2)%M) + M)%M;
}*/
 
/*void seive(bool prime[]){
    //bool prime[100002]; 
     
  
    for (ll p=2; p*p<=1000001; p++) 
    { 
        if (prime[p]) 
        { 
            for (ll i=p*p; i<=1000001; i+=p) 
                prime[i] = false; 
        } 
    }
}*/

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
    //cin>>t;
	while(t--){
	  ll h,w,m;
	  cin>>h>>w>>m;
	  unordered_map<ll,ll> row;
	  unordered_map<ll,ll> col;
	  ll mc=0,mr=0;
	  //unordered_map<ll,ll> mp;
	  unordered_map<ll,unordered_map<ll,ll>> mp;
	  ll p=0,q=0;
	  vector<pair<ll,ll>> pi(m);
	  fo(i,m){
	      ll r,c;
	      cin>>r>>c;
	      pi[i].first=r;
	      pi[i].second=c;
	      mp[r][c]=1;
	      row[r]++;
	      col[c]++;
	  }
	  fo(i,m){
	      ll r=pi[i].first;
	      ll c=pi[i].second;
	      //row[r];
	      //col[c];
	      if(row[r]>mr){
	          mr=row[r];
	          p=r;
	      }
	      else if(row[r]==mr && mp[r][q]==0)
	      p=r;
	      if(col[c]>mc){
	          mc=col[c];
	          q=c;
	      }
	      else if(c!=q && col[c]==mc && mp[p][c]==0)
	      q=c;
	  }
	//  cout<<p<<" "<<q<<endl;
	 // cout<<mr<<" "<<mc<<endl;
	  if(mp[p][q]==1)
	  cout<<mr+mc-1<<endl;
	  else
	  cout<<mr+mc<<endl;
	}
return 0;
}

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

int main()
{
  int b, r, g, c, s, t;

  while (cin >> b >> r >> g >> c >> s >> t, b + r + g + c + s + t){
    long res = 100;
    res += b * 15 + r * 15 + g * 7 + c * 2 + s * 3;
    res += (b * 5 + r * 3) * 16;
    res -= t * 3;
    cout << res << endl;
  }
} 

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 1003;

int n, cnt[MAXN];
ll ans = 1;
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();

    cin >> n;
    REP1 (i, n) {
        int cur = i;
        for (int j=2; j<=i; j++) {
            while (cur % j == 0) {
                cnt[j]++;
                cur /= j;
            }
        }
    }

    for (int i=2; i<=n; i++) {
        ans = ans * (cnt[i] + 1) % MOD;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int D;
	cin >> D;

	cout << "Christmas";

	for (int i = D; i < 25; i++)
	{
		cout << " Eve";
	}

	return 0;
}


Measured memory_bytes: 3556
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long Y = sc.nextLong();
		
		long max = 0;
		long num = 0;
		
		for(int i = 0; i < Y; i++) {
			max = (long)Math.pow(2, i) * X;
			if(max <= Y) {
				num = i + 1;
			} else {
				break;
			}
		}
		System.out.println(num);
	}
}


Measured memory_bytes: 22608
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
typedef long long ll;
int main(){
    fastio
    ll a , b ;
    cin >> a >> b ;
    vector<ll> common ;
    for(ll i = 1; i * i <= min(a, b); i++){
        if ( a % i == 0 ){
            if ( b % i == 0 ){
                common.push_back(i) ;
            }
            if ( a / i != i ){
                if ( b % (a / i) == 0 ) common.push_back(a / i) ;
            }
        }
    }
    sort(common.begin(),common.end());
    int n = (int) common.size() ;
    vector<bool> mark(n) ;
    for(int i = 1; i < n; i++){
        if ( !mark[i] )
            for(int j = i + 1; j < n; j++){
                if ( common[j] % common[i] == 0 ) mark[j] = true ;
            }
    }
    int ans = 0 ;
    for(int i = 0; i < n; i++){
        if ( !mark[i] ) ans++ ;
    }
    cout << ans << endl;
    return 0 ;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,c,ans=0,a[109];
    for(scanf("%d",&n),a[i=n]=109; i--;) scanf("%d",a+i);
    for(c=i=1; i<=n; ++i) a[i]==a[i-1]?++c:(ans+=(c>>1),c=1);
    printf("%d\n",ans),exit(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int s, t, n, m;
void chkmax(int &a, int b) {a = a > b ? a : b;}
void chkmin(int &a, int b) {a = a < b ? a : b;}
int read() {
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) {
		if(c == '-') f = -f;
		c = getchar();
	}
	while(isdigit(c)) {
		x = (x << 1) + (x << 3) + c - '0';
		c = getchar();
	}
	return x * f;
}
void write(int x) {
	char c[33] = {0}, tot = 0;
	if(x == 0) {puts("0"); return;}
	while(x) {c[++ tot] = x % 10 + '0'; x /= 10;}
	while(tot) {putchar(c[tot --]);}
	return ;
}
long long tmp;
string str;
void calc() {
	while(tmp) {
		tmp --; 
		str = (char)('a' + tmp % 26) + str;
		tmp /= 26;
	} 
	cout << str;
}
int main() {
	cin >> tmp;
	calc();
	return 0;
}


Measured memory_bytes: 3636
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前
sort()
sorted(reverse=true)
配列の初期化
配列名=[a]*n+[b]*m
Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions
import sys

s = stdin.readline().rstrip()
if s[-1] == 's':
    print(s+'es')
else:
    print(s+'s')


Measured memory_bytes: 72748
def devide(dev):
	count = 0
	while dev % 2 == 0:
		dev /= 2
		count += 1
	return count

n = int(input())
count_cal = []

for i in range(1, n+1):
	count_cal.append(devide(i))

MAX = count_cal[0]

for k in range(len(count_cal)):
	if MAX <= count_cal[k]:
		MAX = count_cal[k]
		ans = k

print(ans + 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 long long int gcd(long long int m,long long int n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	
}
int main(){
  
  string S,T;
  cin>>S>>T;
  bool unko=false;
  vector<string>date;
  
rep(i,S.size()-T.size()+1){
  bool flag=true;
  string mem=S;
  
for(ll j=i;j<i+T.size();j++){

if(S[j]!='?'&&S[j]!=T[j-i]){
  flag=false;
  break;
}
}
if(flag){
  for(ll j=i;j<i+T.size();j++){
    S[j]=T[j-i];
  }
  
  rep(j,S.size()){
    if(S[j]=='?'){
      S[j]='a';
       }
    }
    date.push_back(S);
    S=mem;
  }
}
  sort(all(date));
  
  if(date.size()==0){
cout<<"UNRESTORABLE"<<endl;
  }
  else{
    cout<<date[0]<<endl;
  }
}



Measured memory_bytes: 256
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
total = sum(a)
if total % 10 != 0:
    print(total)
else:
    a.sort()
    index = 0
    while index < n and a[index] % 10 == 0:
        index += 1
    if index == n:
        print(0)
    else:
        print(total - a[index])

Measured memory_bytes: 61992
H,W = map(int,input().split())
route = []
for i in range(1,H+1):
    line = input().split()
    line = [int(j) for j in line]
    if i%2 != 0:
        for j in range(1,W+1):
            route.append([i,j,line[j-1]])
    else:
        for j in range(W,0,-1):
            route.append([i,j,line[j-1]])
res = []
for i in range(H*W):
    if route[i][2] %2 != 0 and i != H*W -1:
        route[i][2] -=1
        route[i+1][2] +=1
        res.append([route[i][0],route[i][1],route[i+1][0],route[i+1][1]])
print(len(res))
for i in res:
    print(' '.join(map(str,i)))

Measured memory_bytes: 50472
<?php
$to_i = function($s){return (int)$s;};

list($w, $h, $x, $y, $r) = array_map($to_i, explode(" ", fgets(STDIN)));
if($x<$r || $y<$r || $x>$w-$r || $y>$h-$r) echo("No\n");
else echo("Yes\n");


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int H,W;
  cin >> H >> W;
  vector<string> v(H);
  for(int i = 0; i < H; i++){
    cin >> v.at(i);
  }

  vector<vector<int>> up(H, vector<int>(W,0));
  for(int j = 0; j < W; j++){
    for(int i = 0; i < H; i++){
      if(v.at(i).at(j) == '#'){
        up.at(i).at(j) = 0;
      } else { 
        up.at(i).at(j) = 1;
        if(i-1>=0){
          up.at(i).at(j) += up.at(i-1).at(j);
        }
      }
    }
  }


  vector<vector<int>> down(H, vector<int>(W,0));
  for(int j = 0; j < W; j++){
    for(int i = H-1; i >= 0; i--){
      if(v.at(i).at(j) == '#'){
        down.at(i).at(j) = 0;
      } else { 
        down.at(i).at(j) = 1;
        if(i+1 <= H-1){
          down.at(i).at(j) += down.at(i+1).at(j);
        }
      }
    }
  }

  vector<vector<int>> left(H, vector<int>(W,0));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(v.at(i).at(j) == '#'){
        left.at(i).at(j) = 0;
      } else { 
        left.at(i).at(j) = 1;
        if(j-1 >= 0){
          left.at(i).at(j) += left.at(i).at(j-1);
        }
      }
    }
  }
  vector<vector<int>> right(H, vector<int>(W,0));
  for(int i = 0; i < H; i++){
    for(int j = W-1; j >= 0; j--){
      if(v.at(i).at(j) == '#'){
        right.at(i).at(j) = 0;
      } else { 
        right.at(i).at(j) = 1;
        if(j+1 < W){
          right.at(i).at(j) += right.at(i).at(j+1);
        }
      }
    }
  }

  int max_val = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      int val = 0 ;
      val += right.at(i).at(j);
      val += left.at(i).at(j);
      val += up.at(i).at(j);
      val += down.at(i).at(j);
      val -= 3;

      if(val > max_val) max_val = val;
    }
  }
  cout << max_val << endl;


}


Measured memory_bytes: 67200
#include <stdio.h>

int main(void)
{
  int a, b, c, x;
  int ans=0;
  char arr[10];

  fgets(arr, sizeof(arr), stdin);
  sscanf(arr, "%d", &a);

  fgets(arr, sizeof(arr), stdin);
  sscanf(arr, "%d", &b);

  fgets(arr, sizeof(arr), stdin);
  sscanf(arr, "%d", &c);

  fgets(arr, sizeof(arr), stdin);
  sscanf(arr, "%d", &x);


  for (int i=0; i <= a; i++) {
    for (int j=0; j <= b; j++) {
      for (int r=0; r <= c; r++) {
        int test = 500*i + 100*j + 50*r;
        if (test == x) { ++ans;}
      }
    }
  }

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

  return 0;
}


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

int main()
{
	string s;
  	cin>>s;
  	if(s=="MON")
      cout<<"6"<<endl;
  else if (s=="TUE")
    cout<<"5"<<endl;
  else if (s=="WED")
    cout<<"4"<<endl;
  else if (s=="THU")
    cout<<"3"<<endl;
  else if(s=="FRI")
    cout<<"2"<<endl;
  else if (s=="SAT")
    cout<<"1"<<endl;
  else
    	cout<<"7"<<endl;
 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define maxH 250
int main(void){
	int A[maxH+1];
	int H,i;
	scanf("%d",&H);
	for(i=1;i<=H;i++)scanf("%d",&A[i]);
	for(i=1;i<=H;i++){
		printf("node %d: key = %d, ",i,A[i]);
		if(i!=1)printf("parent key = %d, ",A[i/2]);
		if(i*2<=H)printf("left key = %d, ",A[i*2]);
		if(i*2+1<=H)printf("right key = %d, ",A[i*2+1]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1804
import java.util.Arrays;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    long M = scanner.nextInt();
    long V = scanner.nextInt();
    int P = scanner.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) A[i] = scanner.nextInt();
    Arrays.sort(A);
    reverse(A);
    long[] cum = new long[N];
    for (int i = 1; i < N; i++) cum[i] = cum[i - 1] + A[i - 1];

    int count = P;
    for (int i = P; i < N; i++) {
      if (A[i] + M < A[P - 1]) break;
      long cap = M * (P - 1) + M * (N - i);
      cap += (i - P + 1) * (A[i] + M) - (cum[i] - cum[P - 1]);
      if (cap >= M * V) count++;
    }
    System.out.println(count);
  }

  private static void reverse(int[] a) {
    int i = 0;
    int j = a.length - 1;
    while (i < j) {
      int tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
      i++;
      j--;
    }
  }
}


Measured memory_bytes: 52048
import java.util.Scanner;

public class Main {

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

	    int n=gi();

        //System.out.println(Math.max(a+b, Math.max(a-b, a*b)));
        if (n<1000) {
        	System.out.print("ABC");
        }else {
        	System.out.print("ABD");
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35504
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int N,M;
	cin >> N >> M;
	priority_queue<int> que;
	for(int i = 0;i < N;i++) {
		int A;
		cin >> A;
		que.push(A);
	}
	for(int i = 0;i < M;i++) {
		int A = que.top();
		que.pop();
		A = A / 2;
		que.push(A);
	}
	int ret = 0;
	for(int i = 0;i < N;i++) {
		ret += que.top();
		que.pop();
	}
	cout << ret << endl;
}

Measured memory_bytes: 1400
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("no more input")
	}

	n, _ := strconv.Atoi(s.Text())
	return n
}

func findGoals(n int, links map[int][]int) []int {
	var r []int

	for i := 0; i < n; i++ {
		_, ok := links[i]
		if !ok {
			r = append(r, i)
		}
	}

	return r
}

func solve(n int, links, backLinks map[int][]int) int {
	goals := findGoals(n, links)

	stack := make([]int, len(goals))
	copy(stack, goals)

	memo := make([]int, n)
	for i := 0; i < n; i++ {
		memo[i] = -1
	}

	for len(stack) > 0 {
		stackSize := len(stack)
		i := stack[stackSize-1]

		if memo[i] != -1 {
			stack = stack[:stackSize-1]
			continue
		}

		max := -1
		for _, j := range backLinks[i] {
			if memo[j] == -1 {
				stack = append(stack, j)
			} else if memo[j] > max {
				max = memo[j]
			}
		}

		if len(stack) == stackSize {
			memo[i] = max + 1
			stack = stack[:stackSize-1]
		}
	}

	max := 0
	for _, i := range goals {
		if memo[i] > max {
			max = memo[i]
		}
	}

	return max
}

func main() {
	s := bufio.NewScanner(bufio.NewReader(os.Stdin))
	s.Split(bufio.ScanWords)

	n := nextInt(s)
	m := nextInt(s)

	links := make(map[int][]int)
	backLinks := make(map[int][]int)

	for i := 0; i < m; i++ {
		x := nextInt(s) - 1
		y := nextInt(s) - 1

		links[x] = append(links[x], y)
		backLinks[y] = append(backLinks[y], x)
	}

	fmt.Println(solve(n, links, backLinks))
}


Measured memory_bytes: 22400
// Written By NewbieChd
#include <cstdio>
using namespace std;

const int maxN = 2000003, mod = 1e9 + 7;
char s[maxN];

int main() {
    int n, i, ans = 1, tmp = 1;
    bool dir = 1;
    scanf("%d%s", &n, s + 1);
    if (s[1] != 'B') {
        printf("0\n");
        return 0;
    }
    for (i = 1; i <= n; ++i)
        ans = 1ll * ans * i % mod;
    n <<= 1;
    for (i = 2; i <= n; ++i) {
        if (s[i] == s[i - 1])
            dir ^= 1;
        if (dir)
            ++tmp;
        else
            ans = 1ll * ans * tmp % mod, --tmp;
    }
    printf("%d\n", tmp ? 0 : ans);
    return 0;
}


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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	string str;
	cin >> str;
	if(str[2] == str[3] && str[4] == str[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int main() {
	int N;  // N:桁数(1 <= N <= 3)
	int M;  // M:制約の数(0 <= M <= 5)
	int s[10]; // 何桁目か (1 <= s <= N)
	int c[10]; // c[i]: s[i]桁目の数字 (0 <= c <= 9)
	int num[10]; // 最小の数字
	for (int i = 0; i < 10; ++i) num[i] = -1;

	// Input
	std::cin >> N >> M;
	for (int i = 0; i < M; i++)
		for (int j = 0; j < 2; j++)
			if (j == 0) std::cin >> s[i];
			else std::cin >> c[i];

	// M == 0 制約がない
	if (M == 0) {
		if (N >= 2) std::cout << std::pow(10, N-1) << std::endl;
		else std::cout << 0 << std::endl;
		return 0;
	}

	// 制約条件を見ていく
	bool exist = true;
	for (int i = 0; i < M; ++i) {
		if (num[s[i]-1] == -1) {
			num[s[i]-1] = c[i];
		} else if (num[s[i]-1] != c[i]) {
			exist = false;
			break;
		}
		if (N >= 2 && num[0] == 0) {
			exist = false;
			break;
		}
	}
	if (!exist) {
		std::cout << -1 << std::endl;
		return 0;	
	}
	else {
		for (int i = 0; i < N; ++i)
            if (i == 0 && num[i] == -1) num[i] = 1;
			else num[i] = (num[i] == -1 ? 0 : num[i]);
	}
	int g_num = 0;
	for (int i = 0; i < N; ++i)
		g_num += (std::pow(10, N-i-1) * num[i]);
	std::cout << g_num << std::endl;
	return 0;
}



Measured memory_bytes: 256
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7

    L, R, d = map(int, input().split())
    ans = 0
    for i in range(L, R+1):
        if i % d == 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 72740
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int a, b;

int main() {
	cin >> a >> b;
	cout << (a + b) / 2 + (a + b)%2 << endl;
}


















Measured memory_bytes: 256
#include<stdio.h>

int main(){
  char str[3] = {};
  
  scanf("%s",str);
  if(str[0] == 'S' && str[1] == 'U'){
    printf("7");
  }else if(str[0] == 'M'){
    printf("6");
  }else if(str[0] == 'T' && str[1] == 'U'){
    printf("5");
  }else if(str[0] =='W'){
    printf("4");
  }else if(str[0] == 'T' && str[1] == 'H'){
    printf("3");
  }else if(str[0] == 'F'){
    printf("2");
  }else if(str[0] == 'S' && str[1] == 'A'){
    printf("1");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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;}


int const INF = 1001001001;


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

int n;
cin >> n;
vi a(n);
rep(i,n) cin >> a[i];

map<int,int> mp = {};
rep(i,n){
    mp[a[i] - 1]++;
    mp[a[i]]++;
    mp[a[i] + 1]++;
}

int ans = 0;

for(auto p : mp){
    ans = max(ans,p.second);
}
cout << ans << endl;

return 0;
}

Measured memory_bytes: 5120
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n,m = nm()

print(n*m)

Measured memory_bytes: 61704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int x, y; cin >> x >> y;
	int ans;
	ans = x + y/2;
	cout << ans << endl;
}


Measured memory_bytes: 256
// include
//#include <bits/stdc++.h> // last resort
#include <algorithm>     // sort, binary-search, etc.
#include <bitset>        // fixed-length bitset
#include <cmath>         // pow, log, etc.
#include <complex>       // complex number
#include <cstring>       // memset, memcpy
#include <deque>         //
#include <functional>    //
#include <iomanip>       // setprecision
#include <iostream>      // i/o
#include <iterator>      // operations for set
#include <map>           // map or dict
#include <numeric>       // iota, gcd, lcm
#include <queue>         //
#include <set>           //
#include <stack>         //
#include <string>        //
#include <unordered_map> //
#include <unordered_set> //
#include <utility>       // pair
#include <vector>        // variable-length array

// typedef and const
typedef long long ll;
const int DEFMOD = 1e9 + 7; // default modulus
const int INF = INT32_MAX;  // ~1e9
const ll LINF = INT64_MAX;  // ~1e18

//namespace
using namespace std;

// macros
// read and initialize
#define FILL(array, number) memset(array, number, sizeof(array))
#define RMI(array)             \
    for (auto &item : (array)) \
    cin >> item
// loop
#define FOREACH(item, array) for (auto &(item) : (array))
#define REP(index, time) for (int index = 0; index < (int)(time); ++index)
#define REPD(index, time) for (int index = time; 0 < index; --index)
#define SIZE(array) ((int)(array).size())
// write and presentation
#define COUTS(variable) cout << (variable) << " "
#define DUMP(variable) cout << #variable << ": " << (variable) << endl
#define ENDL cout << endl
#define WM(array)              \
    for (auto &item : (array)) \
    {                          \
        COUTS(item);           \
        ENDL;                  \
    }
// abbreviation
#define ALL(array) (array).begin(), (array).end()
#define M_ map<int, int>
#define MP make_pair
#define P_ pair<int, int>
#define PB(item) push_back(item)
#define PQ priority_queue<int>
#define PQG priority_queue<int, V, greater>
#define S_ set<int>
#define TO(condition, true, false) ((condition) ? (true) : (false))
#define V_ vector<int>

void func(std::string S, std::string T)
{
    int count = 0;
    REP(index, S.length())
    {
        if (S[index] != T[index])
            count++;
    }
    cout << count << endl;
}

int main()
{
    // cout << fixed << setprecision(5);

    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    func(S, T);
    return 0;
}


Measured memory_bytes: 4124
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args){

		solve_abc163_d();
	}
  
  	public static void solve_abc163_d(){

		FastScanner sc = new FastScanner(System.in);
		long mod = 1000000007;
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		long ans = 0;
		
		for(int i=k;i<=n+1;i++){
			//long tmpans = ((i * n) - (i * (i - 1)) + 1) % mod;
			long tmpans = solve_abc163_d_mod((((long)i * n)%mod - ((long)i * (long)(i - 1))%mod + 1), mod);
			ans = (ans + tmpans) % mod;
			//System.out.println(tmpans);
		}

		System.out.println(ans);

	}
	
	public static long solve_abc163_d_mod(long val, long m){
		  long res = val % m;
		  if (res < 0) res += m;
		  return res;
	}

}

Measured memory_bytes: 27148
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  long long a[N];
  int c0 = 0;
  int c2 = 0;
  int c4 = 0;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    if (a[i] % 4 == 0)
      ++c4;
    else if (a[i] % 2 == 0)
      ++c2;
    else
      ++c0;
  }

  if (N == 3 && c0 == 2 && c4 == 1) {
    cout << "Yes" << endl;
    return 0;
  }

  if (c2 == 0 && c0 - 1 > c4)
    cout << "No" << endl;
  else if (c2 != 0 && c0 > c4)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 1024