akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>
#include<queue>
#include<cmath>

using namespace std;

typedef long long int64;

int main(void){
    int64 N,M,K;
    cin>>N>>M>>K;
    vector<int64> A(N+1);
    vector<int64> B(M+1);

    for (int64 i = 1; i <= N; i++)
    {
        cin>>A[i];
    }
    for (int64 i = 1; i <= M; i++)
    {
        cin>>B[i];
    }

    int64 time=0;
    int64 books=0;
    int64 a_tmp=0,b_tmp=0;
    int64 ans=0;
    
    for (int64 i = 1; i <= N && time<K; i++)
    {
        if(time+A[i]>K) break;
        time+=A[i];
        a_tmp=i;
        // cout<<"read A"<<i<<endl;
    }
    for (int64 i = 1; i <= M && time<K; i++)
    {
        if(time+B[i]>K) break;
        time+=B[i];
        b_tmp=i;
        // cout<<"read B"<<i<<endl;
    }
    // a_tmp=(a_tmp==0?0:a_tmp+1);
    // b_tmp=(b_tmp==0?0:b_tmp+1);
    books=a_tmp+b_tmp;
    ans=books;
    // cout<<books<<"books"<<endl;
    b_tmp+=1;

    for (int64 i = a_tmp; i >=1; i--)
    {
        time-=A[i];
        books--;
        // cout<<"no read A"<<i<<endl;
        for(;b_tmp<=M&&K>time;b_tmp++){
            if(time+B[b_tmp]>K) break;
            time+=B[b_tmp];
            books++;
            // cout<<"read B"<<b_tmp<<endl;
        }
        ans=max(ans,books);
        // cout<<books<<"books"<<endl;
    }
    
    cout<<ans<<endl;

    
    return 0;
}

Measured memory_bytes: 6356
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int x = scan.nextInt();
        long[] a = new long[N];
        long[] n = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextLong();
            n[i] = a[i];
        }
        for (int i = 0; i < N; i++) {
            if (i == 0) {
                if (x < n[i]) {
                    n[i] = x;
                }
                continue;
            }
            if (x < n[i-1] + n[i]) {
                n[i] = n[i] - (n[i]+n[i-1] - x);
            }
        }
        long answer = 0;
        for (int i = 0; i < N; i++) {
            answer += a[i] - n[i];
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 61956
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vl>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

vl burger, patty;

ll dfs(ll &X, int L) {
  ll ret = 0;

  // bun
  --X;
  if (X == 0) return ret;

  // level L-1 burger
  if (X < burger[L-1]) return ret + dfs(X, L-1);
  X -= burger[L-1];
  ret += patty[L-1];
  if (X == 0) return ret;

  // patty
  --X;
  ++ret;
  if (X == 0) return ret;

  // level L-1 burger
  if (X < burger[L-1]) return ret + dfs(X, L-1);
  X -= burger[L-1];
  ret += patty[L-1];
  return ret;  // left only buns
}

void solve() {
  int N; ll X; cin >> N >> X;

  burger.assign(N+1, 1);
  patty.assign(N+1, 1);
  rep(i,N) {
    burger[i+1] = burger[i]*2 + 3;
    patty[i+1] = patty[i]*2 + 1;
  }

  cout << dfs(X, N) << endl;
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
import sys
import functools

def minmaxsum(*t):
    (x,y,z),e=t
    if x > e:
        x=e
    if y < e:
        y = e
    z += e
    return (x,y,z)

input()
m,x,s = functools.reduce(minmaxsum,map(int,input().split()),(1000000,-1000000,0\
))
print(m,x,s)

Measured memory_bytes: 8868
n, m = gets.chomp.split(" ").map(&:to_i)
ans = [] # P, Y, 入力順, x
x = Array.new(n+1, 0)

m.times do |i|
    input = gets.chomp.split(" ").map(&:to_i)
    input << i
    ans << input
end

ans.sort_by!{|v| v[1]}

m.times do |i|
    x[ans[i][0]] += 1
    ans[i] << x[ans[i][0]]
end

ans.sort_by!{|v| v[2]}

ans.each do |res|
    printf("%06d%06d", res[0], res[3])
    puts ""
end

Measured memory_bytes: 31920
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
    string S;
    cin>>S;
    long long ans=0;
    long long numA=0;
    for(int i=1;i<S.size();i++){
        if(S[i-1]=='B'&&S[i]=='C'){
            S[i-1]='D';
            S.erase(S.begin()+i);
        }
    }
    for(int i=0;i<S.size();i++){
        if(S[i]=='A') numA++;
        else if(S[i]=='D') ans+=numA;
        else numA=0;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > > 
#define pii pair<int,int> 
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define SZ(x) ((int)x.size())
using namespace std;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
const int BufferSize=1<<16;
char buffer[BufferSize],*Bufferhead,*Buffertail;
bool Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T>inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){rev|=c=='-';c=Getchar();if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	if(c=='.'){
		c=Getchar();double t=0.1;
		while(c>='0'&&c<='9') x=x+(c-'0')*t,c=Getchar(),t=t/10;
	}
	x=rev?-x:x;
	return 1;
}
template<class T1,class T2> inline bool read(T1 &x,T2 &y){return read(x)&read(y);}
template<class T1,class T2,class T3> inline bool read(T1 &x,T2 &y,T3 &z){return read(x)&read(y)&read(z);}
template<class T1,class T2,class T3,class T4> inline bool read(T1 &x,T2 &y,T3 &z,T4 &w){return read(x)&read(y)&read(z)&read(w);}
inline bool reads(char *x){
	char c=Getchar();
	while(c<33||c>126){c=Getchar();if(Terminal)return 0;}
	while(c>=33&&c<=126) (*x++)=c,c=Getchar();
	*x=0;return 1;
}
template<class T>inline void print(T x,const char c='\n'){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[20];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------head---------------------------------------------

const int inf=0x3f3f3f3f;
const int N=200005,M=100005,mod=1e9+7;
template<class T,class S> inline void ch(T &x,const S y){x=(x+y)%mod;}
inline int exp(int x,int y,const int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,st,a[N];

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	read(n);
	for(int i=1;i<=n;i++)
		read(a[i]);
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	st=n;
	for(int i=1;i<=n;i++)
		if(a[i]<i){
			st=i-1;
			break;
		}
	bool up=1,right=1;
	up=(a[st]-st-1)&1;
	for(int i=st+1;i<=n;i++)
		if(a[i]==st) right^=1;
	dprintf("%d %d\n",up,right);
	if(!up||!right) puts("First"); else puts("Second");
	return 0;
}

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

int main(){
  rep(i,3) cin >> A[i];
  
  int a[3] = {0,1,2};
  
  int cost = 9999999;
  rep(i,3){
    int b[3];
    rep(j,3) b[j] = (a[j] + i) % 3;
    
    int tmp_cost = abs( A[b[0]] - A[b[1]] ) + abs( A[b[1]] - A[b[2]] ); 
    if(tmp_cost < cost) cost = tmp_cost;
  }
  cout << cost <<endl;
  return 0; 
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> vec(k);
    fill(vec.begin(), vec.end(), n / k);
    n %= k;
    int pos = 0;
    while (n--) {
        ++vec[pos++];
        pos %= k;
    }
    sort(vec.begin(), vec.end());
    cout << vec.back() - vec.front() << '\n';
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

fn main() {
    let input = readv::<u32>();
    let num = input[0] * 100 + input[1] * 10 + input[2];
    if num % 4 == 0 {
        print!("YES");
    } else {
        print!("NO");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define PP pair<P,P>
using namespace std;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

#define P pair<ll, ll>

// 出力は.xで！！！！
/*
ll ni(ll a){
    if(a==0) return 1;
    else if(a%2==0) return ((ni(a/2)%MOD)*(ni(a/2)%MOD)%MOD);
    else return ((ni(a-1)%MOD)*2%MOD);
}
*/
int main(){
  int n; cin >> n;
  map<P,P> p;
  ll zero=0;

  rep(i,n){
    ll a,b; cin >> a >> b;
    ll g=gcd(a,b);
    if(a==0 && b==0){
      zero++;
      continue;
    }
    a/=g;
    b/=g;
    if(a==0){
      p[P(0,1)].first++;
      continue;
    }
    if(b==0){
      p[P(0,1)].second++;
      continue;
    }
    if(a>0 && b>0) p[P(a,b)].first++;
    if(a<0 && b<0) p[P(-a,-b)].first++;
    if(a>0 && b<0) p[P(-b,a)].second++;
    if(a<0 && b>0) p[P(b,-a)].second++;
  }

  mint ans=1;

  for(auto m : p){
      int f=m.second.first;
      int s=m.second.second;
      mint tmp=1;
      tmp+=mint(2).pow(f)-1;
      tmp+=mint(2).pow(s)-1;
      ans*=tmp;
  }

  cout << (ans+zero-1).x << endl;
return 0;
}


Measured memory_bytes: 19116
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String s = sc.next();
      int count = 0;
      int max = 0;
      for(int i = 0;i < n;i++){
      	if(s.substring(i,i+1).equals("I")){
        	count++;
          	max = Math.max(max,count);
        }else{
        	count--;
            max = Math.max(max,count);
        }
      }
      System.out.println(max);
    }
}


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

int main() {
  int n;
  cin >> n;
  int r=0,l=1e9+1;
  rep(i,n){
     int a; cin >> a;
     r=max(a,r), l=min(a,l);
  }
  cout << r-l << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
    string s;
    int q;
    cin>>s>>q;
    int x=0;
    int c=1;
    int d=2;
    stack<char>fro;
    queue<char>bac;
    while(q--)
    {
        int a,b;
        cin>>a;
        if(a==1)
        {
            x++;
            c=3-c;
            d=3-d;
        }
        else
        {
            cin>>b;
            char ch;
            cin>>ch;
            if(b==c)
            {
                fro.push(ch);
            }
            else
            {
                bac.push(ch);
            }
        }
    }
    
    string l="";
    while(!fro.empty())
    {
        l+=fro.top();
        fro.pop();
    }
    
    string r="";
    while(!bac.empty())
    {
        r+=bac.front();
        bac.pop();
    }
    
    s=l+s;
    s=s+r;
    if(x%2==1)
    {
        reverse(s.begin(),s.end());
    }
    cout<<s<<"\n";
    
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int main() {
  ll h,w; cin >>h >>w;
  ll res = 0;
  if (h==1 || w==1) res = 1;
  else if (h%2==0 || w%2==0) res = h*w/2;
  else{
    res = h*w/2 + 1;
  }
  cout <<res <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int r,c;
	int i,j;

	while (1) {
		scanf("%d%d",&r,&c);
		if (r == 0 && c == 0) {
			break;
		}
		for (i = 0;i != r;++i) {
			for (j = 0;j != c;++j) {
				printf((i + j)%2 == 0 ? "#" : ".");
			}
			printf("\n");
		}
		printf("\n");
	}	
	return 0;
}

Measured memory_bytes: 588
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC152A - AC or WA

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        String ans = (n == m) ? "Yes" : "No";

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

int dp[100005];

vector< vector<int> > g;

int solve(int o) {
    int ret = dp[o];
    if (ret < 0) {
        if (g[o].empty()) {
            ret = 0;
        } else {
            int tmp = 0;
            for (int n: g[o]) {
                tmp = max(tmp, solve(n));
            }
            ret = tmp+1;
        }
        dp[o] = ret;
    }
    return ret;
}


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

    int N, M;
    cin >> N >> M;

    g.resize(N);
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        g[x].push_back(y);
    }

    rep(i, N) dp[i] = -1;
    rep(i, N) solve(i);

    int ans = 0;
    rep(i, N) ans = max(ans, dp[i]);

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
/*int main(){
    double n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    cout<<min((ceil(n/a)*b),(ceil(n/c)*d))<<endl;
}
*/
int main(){
    int n, ans = 0, temp = 0;
    cin>>n;
    vector<int> v(n);
    for(int i = 0;i < n;i++){
        cin>>v[i];
        if(v[i]==1){
            temp++;
        }else{
            if(ans<temp){
                ans=temp;
            }
            temp = 0;
        }
    }
    if(ans<temp){
        ans=temp;
    }
    cout<<ans+1<<endl;
}


Measured memory_bytes: 3136
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#define pb push_back
#define mp make_pair
#define p1 first
#define p2 second
using namespace std;

const int N = 200005;
int n , a[N], mi, ma;

int main()
{
    //freopen("a.inp","r",stdin);
    cin >> n; mi = ma = 0;
    for(int i=1; i<=n; ++i) {
        scanf("%d",a+i);
        if (a[i] > a[ma]) mi = ma, ma = i; else
        if (a[i] > a[mi]) mi = i;
    }
    for(int i=1; i<=n; ++i) if (i != ma)
        printf("%d\n",a[ma]); else printf("%d\n",a[mi]);
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
        string s;
        cin >> s;
        if ((s.length() % 2 == 0)  ^ (s[0] == s[s.length()-1]))
                cout << "Second" << endl;
        else
                cout << "First" << endl;
        return 0;
}


Measured memory_bytes: 512
import sys
input=sys.stdin.readline
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
  l[i].sort()

ans=[]
l.sort()
B1=[];R1=[]
for i in range(n):
  B1.append(max(l[i]))
  R1.append(min(l[i]))
ans.append((max(B1)-min(B1))*(max(R1)-min(R1)))

Bleft=[]
Bright=[]
Rleft=[]
Rright=[]

M=B1[0];m=B1[0]
Bleft.append([m,M])
for i in range(1,n):
  M=max(M,B1[i])
  m=min(m,B1[i])
  Bleft.append([m,M])

B1.reverse()
M=B1[0];m=B1[0]
Bright.append([m,M])
for i in range(1,n):
  M=max(M,B1[i])
  m=min(m,B1[i])
  Bright.append([m,M])

M=R1[0];m=R1[0]
Rleft.append([m,M])
for i in range(1,n):
  M=max(M,R1[i])
  m=min(m,R1[i])
  Rleft.append([m,M])

R1.reverse()
M=R1[0];m=R1[0]
Rright.append([m,M])
for i in range(1,n):
  M=max(M,R1[i])
  m=min(m,R1[i])
  Rright.append([m,M])

for i in range(n-1):
  M1=max(Bleft[i][1],Rright[n-2-i][1])
  m1=min(Bleft[i][0],Rright[n-2-i][0])
  M2=max(Rleft[i][1],Bright[n-2-i][1])
  m2=min(Rleft[i][0],Bright[n-2-i][0])
  ans.append((M1-m1)*(M2-m2))

print(min(ans))

Measured memory_bytes: 140904
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int f(int n) {
  int res = 0;
  while(n > 0) {
    res += n % 10;
    n /= 10;
  }
  return res;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  rep(i,1,n+1) {
    int k = f(i);
    if (a <= k && k <= b) ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(ll i = 1; i <= (ll)c; i++)
#define ll long long
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;
const int inf = 1000000000; // 10^9

int main(){
    double r, pi;
    cin >> r;

    pi = 3.1415926535;
    cout << r * 2 * pi << endl;

    return 0;
}

Measured memory_bytes: 3792
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	r := a(n)
	fmt.Println(r)
}

func a(n int) string {
	for i := 1; i <= 9; i++ {
		for j := 1; j <= 9; j++ {
			if s := i * j; n == s {
				return "Yes"
			}
		}

	}
	return "No"
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

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

int main()
{
  cout << fixed << setprecision(10);
  int N,M;
  cin >> N >> M;
  cout << (N-1)*(M-1) << endl;
  return 0;
}


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

class Shape {
public:
    int H, W;
    Shape(int H, int W) {
        this->H = H;
        this->W = W;
    }
};

int main(void) {
    int H, W;
    vector<Shape> shapeList;

    while(true) {
        cin >> H >> W;

        if(H == 0 && W == 0) break;
        shapeList.push_back(Shape(H, W));
    }

    for(int i=0; i < shapeList.size(); i++) {
        for(int j=0; j < shapeList[i].H; j++) {
            for(int k=0; k < shapeList[i].W; k++) {
                if((j + k) % 2 == 0)
                    cout << "#";
                else
                    cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>


int head=0;
int tail=0;
int const MAX=10000005;
struct obj{
    char name[100];
    int number;
};
obj Q[MAX];

void enque(obj x){
    Q[tail]=x;
    if(tail<MAX){tail++;}else{tail=0;}
}

obj deque(){
    if(head<MAX){head++;}else{head=0;}
    return Q[head-1];
}



int main()
{
    int n,q,i,time=0;
    obj input,temp;
    scanf("%d %d",&n,&q);
    for(i=0;i<n;i++){
        scanf("%s",input.name);
        scanf("%d",&input.number);
        enque(input);
    }
    while(head!=tail){
        temp=deque();
        if (temp.number>q){
            temp.number-=q;
            enque(temp);
            time+=q;
        }else{
            time+=temp.number;
            printf("%s %d\n", temp.name, time );
        }
    }
}


Measured memory_bytes: 21792
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
	int a[100000],N,two=0,four=0;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>a[i];
		if(a[i]%2==0){
			a[i]/=2;
			two++;
			if(a[i]%2==0){
				four++;
			}
		}
	}
	int none=N-two;
	if(N%2==0){
		if(none<=four){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else{
		if(none-1<=four){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	

	/*
	if(N%2==0){
		if(N/2<=four+two/2){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else{
		if((N-1)/2<=four+(two-1)){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
*/
	
}

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

int n, m, p;
bool d[200001];

int main()
{
	scanf("%d %d %d", &n, &m, &p);
	rep(i, m){
		int _d;
		scanf("%d", &_d);
		d[_d] = d[_d + n] = true;
	}
	
	priority_queue<int, vector<int>, greater<int> > minq;
	priority_queue<int> maxq;
	
	rep(i, n){
		if (!d[i]) continue;
		minq.push(i);
		maxq.push(i);
	}
	
	int res = 1 << 30;
	rep(i, n){
		if (p < i) p += n;
		
		//puts("_");
		int left, right;
		while (true) {
			left = minq.top();
			if (left < i) minq.pop();
			else break;
		}
		while (true) {
			right = maxq.top();
			if (right < i) maxq.pop();
			else break;
		}
		
		//printf("%d %d\n", left, right);
		
		if (p <= left) res = min(res, right - p);
		else if (right <= p) res = min(res, p - left);
		else {
			int vl = (p - left) + (right - left);
			int vr = (right - p) + (right - left);
			res = min(res, min(vl, vr));
		}
		if (d[i + n]){
			minq.push(i + n);
			maxq.push(i + n);
		}
	}
	
	printf("%d\n", res * 100);
}

Measured memory_bytes: 1576
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 10000100
//#define NIL -1

int main() {
    LL a;
    LL b;
    LL x;
    LL ans;
    cin >> a >> b >> x;
    if(a==0){
        ans=b/x+1;
    }else{
        ans=b/x-(a-1)/x;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
N, K = map(int, input().split())
A = [int(x) for x in input().split()]


def solve(N, K, A):
    A.sort()
    res = 0
    MOD = 10**9 + 7
    fact_table = [1] * (N + 1)
    inv_fact_table = [1] * (N + 1)
    for i in range(1, N + 1):
        fact_table[i] = fact_table[i - 1] * i % MOD

    def inverse(n):
        if n == 1:
            return 1
        q = MOD // n
        r = MOD % n
        return (MOD - q * inverse(r) % MOD) % MOD

    inv_fact_table[N] = inverse(fact_table[N])
    for i in range(N - 1, 0, -1):
        inv_fact_table[i] = inv_fact_table[i + 1] * (i + 1) % MOD

    def comb(n, k):
        return fact_table[n] * inv_fact_table[n - k] % MOD * inv_fact_table[k] % MOD

    s = [1, -1]
    for m in range(2):
        for i in range(K - 1, N):
            res = (res + s[m] * A[i] * comb(i, K - 1)) % MOD
        A = sorted(A, reverse=True)
    return (res + MOD) % MOD


print(solve(N, K, A))


Measured memory_bytes: 16472
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string S, ans = "";
  cin >> S;
  for (int i=0; i<S.size(); i++) {
    for (int j=S.size()-i; j>=0; j--) {
      string sub = S.substr(i, j); // 部分文字列を全探索
      bool OK = true;
      for (int k=0; k<j; k++) {
        if (sub[k]!='A'&&sub[k]!='C'&&sub[k]!='G'&&sub[k]!='T') {
          OK = false;
          break;
        }
      }
      if (OK&&sub.size()>ans.size()) ans = sub;
    }
  }
  cout << ans.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N,M,K;
  cin>>N>>M>>K;
  for(ll i=0;i<=N;i++){
    for(ll j=0;j<=M;j++){
      if(i*M+j*N-2*i*j==K){cout<<"Yes"<<endl;return 0;}
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <time.h>
using namespace std;

int main()
{
    int N;
    //cin>>N;
    scanf("%d", &N);
    //vector<vector<bool>> A(N, vector<bool>(N));
    static bool A[2048][2048];
    for (int i=1; i<N; i++)
    {
        //string t;
        //cin>>t;
        for (int j=0; j<i; j++)
        {
            char c;
            scanf(" %c", &c);
            A[i][j] = c!='0';
            A[j][i] = !A[i][j];
        }
    }

    //vector<vector<bool>> L(N, vector<bool>(N));
    //vector<vector<bool>> R(N, vector<bool>(N));
    static bool L[2048][2048];
    static bool R[2048][2048];
    for (int i=0; i<N; i++)
        L[i][i] = R[i][i] = true;

    /*
    for (int d=1; d<N; d++)
        for (int i=0; i<N; i++)
        {
            if (i+d<N)
                for (int j=i+1; j<N; j++)
                    if (A[i][j] && L[j][i+d] && R[j][i+1])
                        L[i][i+d] = true;

            if (0<=i-d)
                for (int j=0; j<i; j++)
                    if (A[i][j] && L[j][i-1] && R[j][i-d])
                        R[i][i-d] = true;
        }

    int ans = 0;
    for (int i=0; i<N; i++)
        if (L[i][N-1] && R[i][0])
            ans += 1;
    */


    for (int d=1; d<N; d++)
        for (int i=0; i<N; i++)
        {
            if (i+d<N)
            {
                auto &l = L[i+d];
                auto &r = R[i+1];
                auto &a = A[i];
                bool b = false;
                for (int j=i+1; j<=i+d; j++)
                    b |= a[j] & l[j] & r[j];
                L[i+d][i] = b;
            }

            if (0<=i-d)
            {
                auto &l = L[i-1];
                auto &r = R[i-d];
                auto &a = A[i];
                bool b = false;
                for (int j=i-d; j<i; j++)
                    b |= a[j] & l[j] & r[j];
                R[i-d][i] = b;
            }
        }

    int ans = 0;
    for (int i=0; i<N; i++)
        if (L[N-1][i] && R[0][i])
            ans += 1;

    cout<<ans<<endl;

    cerr<<(double)clock()/CLOCKS_PER_SEC<<endl;
}


Measured memory_bytes: 12544
l = list(map(int, input().split()))
s = ''
s += 'U'*(l[3]-l[1])
s += 'R'*(l[2]-l[0])
s += 'D'*(l[3]-l[1])
s += 'L'*(l[2]-l[0])
s += 'L'
s += 'U'*(l[3]-l[1]+1)
s += 'R'*(l[2]-l[0]+1)
s += 'D'
s += 'R'
s += 'D'*(l[3]-l[1]+1)
s += 'L'*(l[2]-l[0]+1)
s += 'U'
print(s)


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

int main(void) {

	int A, B, C, X;
	int calc = 0;
	int count = 0;

	cin >> A >> B >> C >> X;

	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				calc = 500 * i + 100 * j + 50 * k;
				if (calc == X) count++;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <utility>
#include <numeric>
 
using namespace std;

int main() {
  	int N;
  	cin >> N;
  	vector<int> H(N);
  	for (int i = 0; i < N; i++) {
      	cin >> H[i];
    }
  	
  	int ans = 0;
  	int cnt = 0;
  	for(int i = 0; i < N; i++) {
      	if (i == N - 1) {
          	ans = max(ans, cnt);
          	break;
        }
      	if (H[i+1] > H[i]) {
          ans = max(ans, cnt);
          cnt = 0;
          continue;
        }
      	++cnt;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int R;
  cin >> R;
  string ans;
  if(R < 1200){
    ans = "ABC";
  } else if (R < 2800){
    ans = "ARC";
  } else {
    ans = "AGC";
  }

  cout << ans << endl;

}

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

int main()
{
	int A, B;
	cin >> A >> B;
	if(A == 1 && B ==2){
		printf("3");
	} else if(A == 1 && B ==3){
		printf("2");
	} else if(A == 2 && B ==1){
		printf("3");
	} else if(A == 2 && B ==3){
		printf("1");
	} else if(A == 3 && B ==1){
		printf("2");
	} else if(A == 3 && B ==2){
		printf("1");
	} else {
		abort();
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define MAX 2100000
#define INF 1001000000

int main(){
  ll K;
  cin>>K;
  vector<ll> a(50,49);
  for(int i=0;i<50;i++){
    a.at(i)+=K/50-K%50;
  }
  for(int i=0;i<K%50;i++){
    a.at(i)+=51;
  }

  cout<<50<<endl;
  for(int i=0;i<50;i++){
    cout<<a.at(i)<<" ";
  }
  cout<<endl;
}


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

namespace AthleteProgramming
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            for(int i = 0; i < n; i++)
            {
                int[] array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                Sort(ref array);
                CheckRightTriangle(array);
            }
        }

        static void CheckRightTriangle(int[] array)
        {
            if (array[0] * array[0] == array[1] * array[1] + array[2] * array[2])
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }

        static void Sort(ref int[] array)
        {
            for(int i = array.Length-1; i >= 0; i--)
            {
                for(int j = 0; j < i; j++)
                {
                    if (array[j] < array[j + 1])
                    {
                        Swap(ref array[j], ref array[j + 1]);
                    }
                }
            }
        }

        static void Swap(ref int a, ref int b)
        {
            int tmp = a;
            a = b;
            b = tmp;
        }

    }
}

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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

int main () {
	//std::ios::sync_with_stdio(false);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	int n, a, b;
	cin >> n >> a >> b;
	if (abs(a - b) % 2 == 1) {
	 	cout << "Borys" << endl;
	} else {
	 	cout << "Alice" << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a;
	while(a--){
		cin>>b;
		if(b%2==0){
			if(b%3!=0&&b%5!=0){
				cout<<"DENIED"<<endl;
				return 0;
			}
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}

Measured memory_bytes: 256
from numpy import*
n,a=open(0)
n=int(n)
a=int64(a.split())
dp=zeros((n+1,n+1),'i8')
for k in range(1,n+1):
    i=arange(n-k+1)
    j=i+k
    dp[i,j]=amin(vstack((dp[i+1,j]-a[i],dp[i,j-1]-a[j-1])),0)if(n-k)%2else amax(vstack((dp[i+1,j]+a[i],dp[i,j-1]+a[j-1])),0)
print(dp[0,n])

Measured memory_bytes: 84556
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <climits>
#include <random>
#include<algorithm>

#define int_max 2147483647;

//AGC 30

void Problem_A(void)
{
    int a ,b ;
    std::cin>>a>>b;
    if(b%a == 0)
    {
        std::cout<<a+b;
    }
    else
    {
        std::cout<<b - a;
    }
}

void Problem_B(void)
{
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<int> > mat (n,std::vector<int>(m+1));
    for(int i = 0; i < n ; i ++)
    {
        std::cin>> mat[i][0];
        for (int j = 1; j <= int(mat[i][0]); j++)
        {
            std::cin>>mat[i][j];
        }
    }

    std::vector<int> manage_vec(m);
    for(int i = 0; i < m; i ++)
    {
        manage_vec[i] = 0;
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j <= int(mat[i][0]); j++)
        {
            manage_vec[mat[i][j]-1] = manage_vec[mat[i][j]-1] + 1;
        }
    }
    int check = 0;
    for (int i = 0; i < m; i++)
    {
        if(manage_vec[i] == n)
        {
            check = check + 1;
        }
    }

        std::cout<<check;
    
    return;
}
int main(int argc, char const *argv[])
{
    Problem_B();
    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace abc143
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_abc143C();
        }

        public static void solve_abc143C()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string s = Console.ReadLine();

            char prev = s[0];
            int cnt = 1;
            for (int i = 0; i < n; i++)
            {
                if (s[i] != prev)
                {
                    cnt++;
                }

                prev = s[i];
            }

            Console.WriteLine(cnt);
        }


        public static void solve_abc143B()
        {
            int n = Convert.ToInt32(Console.ReadLine());

            int[] d = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = i + 1; j < n ; j++)
                {
                    sum += d[i] * d[j];
                }
            }

            Console.WriteLine(sum);
        }

        public static void solve_abc143A()
        {
            int[] ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int a = ab[0];
            int b = ab[1];

            Console.WriteLine(a > 2 * b ? a - 2 * b : 0);
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const int INF = 2000000000;
    ll N,M,K;
    ll A[100010],B,C,X;
    bool F=true;
    ll ans=0;
    string S;
    priority_queue<ll,vector<ll>,greater<ll>> Q,W;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    EREP(i,N){
        if(i%5!=0&&i%3!=0){
            ans+=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3644
#![allow(dead_code)]

use std::io;
fn main() {
    solve_b();
}

fn solve_b() {
    loop {
        let mut line = String::new();
        io::stdin().read_line(&mut line).unwrap();
        let line: Vec<_> = line.trim()
            .split(' ')
            .map(|s| s.parse::<u32>().unwrap())
            .collect();

        let n = line[0];
        let x = line[1];

        if n == 0 && x == 0 {
            break;
        } else {
            let mut count = 0;
            for i in 1..(n as usize - 1) {
                for j in (i + 1)..(n as usize) {
                    for k in (j + 1)..(n as usize + 1) {
                        if i + j + k == x as usize {
                            count += 1;
                        }
                    }
                }
            }
            println!("{}", count);
        }
    }
}



Measured memory_bytes: 5024
#include <iostream>
#define MOD 1000000007

using namespace std;

typedef long long int ll;

ll mysum(ll start,ll end){
  ll sum = 0;
    for(ll i=start;i<=end;i++){
      sum = sum + i;
    }
    return sum;
}

int main(void){
  int N,K;
  cin >> N >> K;
  ll ans = 0;
  //i個えらぶとき
  ll pre = mysum(N-K+1,N);
  ll aft = mysum(0,K-1);
  for(int i=K;i<=N+1;i++){
    ll num = 0;
    num = pre - aft + 1;
    ans = (ans + num)%MOD;
    pre = pre + N - i;
    aft = aft + i;
  }
  cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int64_t ans = 10000000000000000;
  int64_t sum = 0;
  int64_t cnt = 0;
  //+-+-のパターン
  for(int i=0; i<N; i++){
    sum += vec.at(i);
    if(i %2 == 0){
      if(sum > 0){
        continue;
      }
      else{
        cnt += abs(sum)+1;
        sum = 1;
      }
    }
    else{
      if(sum < 0){
        continue;
      }
      else{
        cnt += sum+1;
        sum = -1;
      }
    }
  }
  ans = min(ans,cnt);
  cnt = 0;
  sum = 0;
  //-+-+のパターン
  for(int i=0; i<N; i++){
    sum += vec.at(i);
    if(i %2 != 0){
      if(sum > 0){
        continue;
      }
      else{
        cnt += abs(sum)+1;
        sum = 1;
      }
    }
    else{
      if(sum < 0){
        continue;
      }
      else{
        cnt += sum+1;
        sum = -1;
      }
    }
  }
  ans = min(ans,cnt);
  cout << ans << endl;
}

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

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

int main()
{
    int a, b; cin >> a >> b;
    if (a <= b) loop(b) cout << a;
    else loop(a) cout << b;
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int i,j,v,N,n;
  int A[100];

  scanf("%d",&N);
  for(i = 0; i < N; i++) {
    scanf("%d",&A[i]);
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  
  printf("\n");
    
  for(i = 1; i <= N-1; i++) {
    v = A[i];
    j = i -1;
    
    while(j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
     
    for(n = 0; n < N; n++) {
      if(n) printf(" ");
      printf("%d",A[n]);
    }
    printf("\n");
      
  }

  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n,k; cin >> n >> k;
  int ans = INF;
  REP(bit, 1<<n) {
    int num = 1;
    REP(i, n) {
      if (bit >> i & 1) num*=2;
      else num+=k;
    }
    ans = min(ans, num);
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define int long long 
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=200005;
const int MOD=1000000007;
const int INF =1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int N,A[MAXN],B[MAXN];

void solve1(){
	int s1 = 0, s2 = INF;
	while (s2-s1> 1){
		int m = (s1+s2)/2;
		int cnt = 0;
		FOR(i,1,N){
			if (m < A[i]) cnt++;
		}
		if (cnt > N/2) s1 = m;
		else s2 = m;
	}
	int e1 = 0, e2 = INF;
	while (e2-e1>1) {
		int m = (e1+e2)/2;
		int cnt = 0;
		FOR(i,1,N){
			if (m > B[i]) cnt++;
		}
		if (cnt > N/2) e2 = m;
		else e1=m;
	}
	int ans = e1-s2+1;
	cout<<ans;
	exit(0);
}
void solve2(){
	int s1 = 0, s2 = INF;
	while (s2-s1> 1){
		int m = (s1+s2)/2;
		int cnt = 0;
		FOR(i,1,N){
			if (m < A[i]) cnt++;
		}
		if (cnt > N/2) s1 = m;
		else s2 = m;
	}
	int e1 = 0, e2 = INF;
	while (e2-e1>1) {
		int m = (e1+e2)/2;
		int cnt = 0;
		FOR(i,1,N){
			if (m > B[i]) cnt++;
		}
		if (cnt > N/2-1) e2 = m;
		else e1=m;
	}
	//db(s2), db(e1);
	int s3 = 0, s4 = INF;
	while (s4-s3> 1){
		int m = (s3+s4)/2;
		int cnt = 0;
		FOR(i,1,N){
			if (m < A[i]) cnt++;
		}
		if (cnt > N/2-1) s3 = m;
		else s4 = m;
	}
	int e3 = 0, e4 = INF;
	while (e4-e3>1) {
		int m = (e3+e4)/2;
		int cnt = 0;
		FOR(i,1,N){
			if (m > B[i]) cnt++;
		}
		if (cnt > N/2) e4 = m;
		else e3=m;
	}
	//db(s4), db(e3);
	int ss = s2 + s4;
	int ee = e1 + e3;
	cout<<ee-ss+1;
	exit(0);
}
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	FOR(i,1,N) cin>>A[i]>>B[i];
	if (N%2==1) solve1();
	else solve2();	
}


Measured memory_bytes: 6744
n, m = map(int, input().split())
s = input()

dp = [float('inf')] * (n + 1)
dp[0] = 0

N = n + 1
N0 = 2 ** (N - 1).bit_length()
data = [float('inf')] * (2 * N0)

# a_k の値を x に更新
def update(k, x):
    k += N0 - 1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = min(data[2 * k + 1], data[2 * k + 2])

# [a_l, a_(l+1), ..., a_(r-1)]の最小値を求める
def query(l, r):
    L = l + N0
    R = r + N0
    s = float('inf')
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R - 1])

        if L & 1:
            s = min(s, data[L - 1])
            L += 1
        L >>= 1
        R >>= 1
    return s

update(0, 0)
for i in range(1, n + 1):
    if s[i] == '1':
        continue

    dp[i] = query(max(0, i - m), i) + 1
    update(i, dp[i])

if dp[-1] == float('inf'):
    print(-1)
else:
    cur = n
    target = dp[n] - 1
    arr = [n]

    while cur > 0:
        for i in range(max(0, cur - m), cur):
            if dp[i] == target:
                cur = i
                target -= 1
                arr.append(i)
                break

    arr = arr[::-1]
    ans = []
    for i in range(len(arr) - 1):
        ans.append(arr[i+1] - arr[i])

    for _ans in ans:
        print(_ans)


Measured memory_bytes: 65464