akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include <vector>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 2e5 + 5;

 
int vis[N];


int32_t  main() {

	IOS;

 
	int k;
	string s;

	cin >> k >> s;

	if (s.length() <= k) {
		cout << s << endl;
	}
	else {
		for (int i = 0; i < k; i++) {
			cout << s[i];
		}
		cout << "...";
	}


}

Measured memory_bytes: 3100
# 標準入力の読み込み（回数）
n=int(input())
# 標準入力の読み込み（数値列）
list_1=input().split()
list_2=list(range(len(list_1)))
for i in range(len(list_1)):
  list_1[i]=int(list_1[i])
# カウンタの定義
ctr = 0
# 判定プログラム
while True:
  for j in range(len(list_1)):
    list_2[j]=list_1[j]%2
    list_1[j]/=2
  s=sum(list_2)
  if(s!=0):
    break
  else:
    ctr+=1
print(ctr)

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

#define ll long long
int main()
{

    char ch;

    scanf("%c",&ch);


    int l=ch ;


    if(ch=='z'){
        cout<<"a"<<endl;
    }else{

       int x=l+1;
       char ch1=x;
        cout<<ch1<<endl;
    }





    return 0;
}


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

int main(){
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i=0; i<N; i++) cin >> a[i];
  int ans = 0;
  sort(a.begin(), a.end());
  for (int i=0; i<N; i++){
    if (a[i]>x) break;
    if (i != N-1){
      ans++;
      x -= a[i];
    }
    else {
      if (x == a[i]) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
  int N;
  int A;
  int r=0;

  cin >> N;
  cin >> A;
  if (A == 0) {
    if (N % 500 == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    r = N % 500;
    if (r <= A) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    int n;
    cin>>n;
    vector<int>mp(n);
    rep(i,n-1){
        int a;
        cin>>a;
        mp[--a]++;
    }
    rep(i,n)cout<<mp[i]<<endl;
    return 0;
}

Measured memory_bytes: 4052
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int main() {
	string S;
	cin >> S;
	bool ok = true;
	if (S.length() % 2 == 0) {
		string hi = "hi";
		for (int i = 0; i < S.length(); ++i) {
			if (hi[i % 2] != S[i]) {
				ok = false;
			}
		}
	}
	else {
		ok = false;
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}

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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int AB = abs(b - a);
  int BC = abs(c - b);
  int CA = abs(a - c);
  
  string ans = "No";
  if (CA <= d || (AB <= d && BC <= d)) ans = "Yes";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    for i in range(n):
        a[i] -= i + 1
    a.sort()
    t1 = 0
    t2 = 0
    for i in range(n):
        t1 += abs(a[i] - a[n//2])
        t2 += abs(a[i] - a[n//2 - 1])
    print(min(t1, t2))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 73840
N = gets.to_i
As = gets.split.map(&:to_i)
Bs = gets.split.map(&:to_i)

res, x = 0, 0
(0 .. N).each do |i|
  b = Bs[i] || 0
  c1 = [As[i], x].min
  c2 = [(As[i] - c1), b].min
  res += (c1 + c2)
  x = b - c2
end
puts res

Measured memory_bytes: 19356
#include <iostream>
#include<cstdio>
#include<sstream>
#include<string>
#include<cmath>
using namespace std;

int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m)){
        printf("%.lf\n",(1900*m+(n-m)*100)*pow(2,m));

    }
    return 0;
}


Measured memory_bytes: 256
// package com.company;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    static Scanner input = new Scanner(System.in);
    private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);

    private static void solve() {
        
        int n = input.nextInt();
        int m = input.nextInt();

        int[] a = arrayInput(n);
        int[] b = arrayInput(m);
        
        Map<Integer, Integer> map = new HashMap<>();
        
        for (int v : a) {
        map.put(v, 1); // the appear of element
        }
        for (int v : b) {
            if (map.containsKey(v)) {
                map.put(v, 2);   
            } else {
                map.put(v, 1);
            }
        }
        
        List<Integer> and = new ArrayList<>();
        List<Integer> or = new ArrayList<>(map.keySet());
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
        if (entry.getValue() == 2) {
            and.add(entry.getKey());
        }
        }
        Collections.sort(and);
        Collections.sort(or);
        
        out.println(and.size() + " " + or.size());
        for (int v : and) {
        out.println(v);
        }
        for (int v : or) {
        out.println(v);
        }
    }

    public static void main(String[] args) {
        solve();
        out.flush();
    }
    

    private static int[] arrayInput(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
        a[i] = input.nextInt();
        return a;
    }
}


Measured memory_bytes: 113336
#include<stdio.h>
#include<string.h>
int c,r,i,j,b[50][50]={0},w[50][50]={0},cb,cw;
char m[51][51];
void f(int (*p)[50],int y,int x,char k)
{
	int v[5]={0,1,0,-1,0},i;
	if(y>=0&&y<r&&x>=0&&x<c&&!p[y][x]&&m[y][x]!=k)
		for(p[y][x]=1,i=0;i<4;i++)
			f(p,y+v[i],x+v[i+1],k);
}

int main()
{
	for(;scanf("%d%d\n",&c,&r),r;)
	{
		memset(b,0,sizeof(b));
		memset(w,0,sizeof(w));
		for(i=0;i<r;i++)
			gets(m[i]);
		for(i=cb=cw=0;i<r;i++)
			for(j=0;j<c;j++)
			{
				if(m[i][j]=='B')
					cb++,f(b,i,j,'W');
				else if(m[i][j]=='W')
					cw++,f(w,i,j,'B');
			}
		for(cw*=-1,cb*=-1,i=0;i<r;i++)
			for(j=0;j<c;j++)
			{
				if(b[i][j]&&!w[i][j])
					cb++;
				else if(!b[i][j]&&w[i][j])
					cw++;
			}
		printf("%d %d\n",cb,cw);
	}
	return 0;
}

Measured memory_bytes: 864
from operator import mul
from functools import reduce

def comb(n, r):
    if n<r:
        return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

N,M=map(int,input().split())
# odd+odd
odd_odd = comb(M,2)
# even+even
even_even = comb(N,2)

print(odd_odd+even_even)

Measured memory_bytes: 3572
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll n,a[100010],i,ans[100010],k=0;
  scanf("%lld\n",&n);
  for(i=0;i<n;i++){
    scanf("%lld ",&a[i]);
  }
  for(i=1;i<n;i++){
    k+=a[i]-a[i-1];
    i++;
  }
  k+=a[0]-a[n-1];
  ans[0]=(a[0]-k)/2;
  for(i=1;i<n;i++){
    ans[i]=a[i-1]-ans[i-1];
  }
  for(i=0;i<n;i++){
    if(i==0){
      printf("%lld",ans[i]*2);
    }
    else{
      printf(" %lld",ans[i]*2);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <map>
#include <vector>

using ll = long long;

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

int main() {
    int N;
    ll V;
    std::cin >> N >> V;

    auto c = Vec<ll>(4, N, 0LL);
    for (auto& v : c) {
        for (auto& e : v) std::cin >> e;
    }

    std::map<ll, ll> cnt;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            ll sum = c[0][i] + c[1][j];
            if (!cnt.count(sum)) cnt[sum] = 0;
            ++cnt[sum];
        }
    }

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            ll sum = c[2][i] + c[3][j];
            if (cnt.count(V - sum)) ans += cnt[V - sum];
        }
    }

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



Measured memory_bytes: 65568
#include <stdio.h>

int main(void) {
	int n, i, len, ans[10];
	while (1) {
		scanf("%d", &n);
		if (n == -1) break;

		for (i = 0; i < 10; i++)
			ans[i] = 0;
		len = 0;
		do {
			ans[len] = n % 4;
			n /= 4;
			len++;
		} while (n != 0);
		for (i = len - 1; i >= 0; i--)
			printf("%d", ans[i]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 604
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt(), k = in.nextInt(), h[] = in.readIntArray(n), cost[] = new int[n];
            Arrays.fill(cost, (int) Math.pow(10, 9) + 5);
            cost[0] = 0;
            for (int i = 0; i < n; ++i)
                for (int j = i + 1; j <= i + k && j < n; ++j)
                    cost[j] = Math.min(cost[j], cost[i] + Math.abs(h[j] - h[i]));
            out.println(cost[n - 1]);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[(int) size];
            for (int i = 0; i < size; i++) array[i] = nextInt();
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 34016
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read(){
    int f=1,x=0;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return f*x;
} 
int POW(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=(ans*a)%c;
        a=(a*a)%c;
        b>>=1; 
    }
    return ans%c;
}
struct node{
    int x,y;
}; 
node s[1001000];
int cmp(node x,node y){
    return x.x>y.x;
}
int main(){
    std::ios::sync_with_stdio(false);
    int n=read(),m=read();
    for(int i=1;i<=2*n;i+=2){
        s[i].x=read();
        s[i+1].y=1;
        s[i+1].x=read();
    }
    int ans=0;
    sort(s+1,s+2*n+1,cmp);
    for(int i=1;i<=2*n;i++){
        if(s[i].y==1){
            m=m-s[i].x;
            ans++;
        }
        else{
            if(m%s[i].x==0){
                cout<<ans+m/s[i].x;
            }
            else cout<<ans+1+m/s[i].x;
            return 0;
        }
        if(m<=0){
            cout<<ans;
            return 0;
        }
    }
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7FFFFFFF
const double EPS = 1e-10;

int main (){
  int a,b;
 cin>>a>>b; 
  cout<<a*b-a-b+1<<endl;
}



Measured memory_bytes: 256
import sys
import numpy as np


def main():
    f = sys.stdin.buffer
    N, K = map(int, f.readline().split())
    H = np.array(list(map(int, f.readline().split())), dtype=np.int64)
    dp = np.ones(N, dtype=np.int64) * (2 ** 62)
    dp[0] = 0
    for i in range(0, N - 1):
        cost = np.abs(H[i] - H[i + 1 : i + K + 1])  # size K
        np.minimum(dp[i + 1 : i + K + 1], dp[i] + cost, out=dp[i + 1 : i + K + 1])
    print(dp[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
int n, a, b, c, d;
int main()
{
    cin >> a >> b;
    if (b % a == 0)
    {
        cout << a + b << endl;
    }
    else
    {
        cout << b - a << endl;
    }
    return 0;
}

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

int main()
{
    int N, M, a[50], b[50];
    cin >> N >> M;
    REP(i, M) cin >> a[i] >> b[i];

    int city[50][50] = {0};

    REP(i, M)
    {
        city[a[i] - 1][b[i] - 1]++;
        city[b[i] - 1][a[i] - 1]++;
    }

    int tcount;
    REP(i, N)
    {
        tcount = 0;
        REP(j, 50) tcount += city[i][j];
        cout << tcount << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  while(cin >> s){
    while(s.find("@")!=-1){
      int x=s.find("@");
      string buf;
      for(int i=0;i<s[x+1]-'0';i++) buf+=s[x+2];
      s.replace(x,3,buf);
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 1204
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
#include<vector>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)

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

int p[100000] = {};

void swap(int a,int b){
	int tmp;
	tmp = p[a];
	p[a] = p[b];
	p[b] = tmp;
}

int main() {

	int n, ans = 0;

	cin >> n;
	rep(i, 0, n) {
		cin >> p[i];
	}
	rep(i, 0, n) {
		int bef = 1, aft = 1;
		if (p[i] == i + 1) {
			if (i == 0)bef = INF;
			if (i == n - 1)aft = INF;
			for (int j = i - 1; j >= 0; j--) {
				if (p[j] == p[i]) {
					if (j != 0)bef++;
					else bef = INF;
				}
				else break;
			}
			for (int j = i + 1; j < n; j++) {
				if (p[j] == p[i]) {
					if (j != n - 1)aft++;
					else aft = INF;
				}
				else break;
			}
			if (bef >= aft && i!=n-1) {
				rep(j, 0, aft) {
					swap(i + aft - j, i + aft - j - 1);
					ans++;
				}
			}
			else {
				rep(j, 0, bef) {
					swap(i - bef + j, i - bef + j + 1);
					ans++;
				}
			}
		}
		
	}
	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 212345;
ll a[MAX_N];
ll b[MAX_N];

int main2() {
  int N = nextInt();
  REP(i, N) a[i] = nextInt();
  b[0] = 0;
  REP(i, N) b[i+1] = b[i] + a[i];
  map<ll, ll> count;
  REP(i, N+1) count[ b[i] ]++;

  ll ans = 0;
  for (auto it = count.begin(); it != count.end(); ++it) {
    ll c = it->second;
    ans += c * (c-1) / 2;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 15872
use std::collections::VecDeque;
use std::io::Read;
use std::iter::FromIterator;
use std::string::String;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut it = buf.split_whitespace();
    let s = it.next().unwrap();
    let q = it.next().unwrap().parse::<i64>().unwrap();
    let mut reversed = false;

    let mut deque = VecDeque::<char>::from_iter(s.chars());

    for _ in 0..q {
        let query = it.next().unwrap().parse::<i64>().unwrap();
        if query == 1 {
            reversed = !reversed;
        } else if query == 2 {
            let f = it.next().unwrap().parse::<i64>().unwrap();
            let c = it.next().unwrap().chars().next().unwrap();
            let push_front = if f == 1 { !reversed } else { reversed };
            if push_front {
                deque.push_front(c);
            } else {
                deque.push_back(c);
            }
        }
    }
    if reversed {

        let out = deque.into_iter().rev().collect::<String>();
        println!("{}", out);
    } else {
        let out = deque.into_iter().collect::<String>();
        println!("{}", out);
    }
}


Measured memory_bytes: 10492
//A.cpp
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int cnt = 0;
  for(int i = 0; i <= 500*A; i+=500){
    for(int j = 0; j <= 100*B; j+=100){
      for(int k = 0; k <= 50*C; k+=50){
        if(X-i-j-k==0) ++cnt;
      }
    }
  }
  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <random>
#include <utility>
#include <map>
#include <vector>
#include <queue>
#include <bitset>
#include <sstream>
#define REP(i,x) for(int i=0; i<(x); i++)
typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
    int w,b;
    cin>>w>>b;
    w--;
    b--;
    char m[100][100];
    REP(i, 100){
        REP(j, 100){
            m[i][j]='#';
        }
    }
    int lw=w/50,rw = w%50;
    REP(i, lw){
        REP(j, 50){
            m[i*2][j*2]='.';
        }
    }
    REP(i, rw){
        m[lw*2+2][i*2]='.';
    }
    for (int i=lw*2+4; i<100; i++) {
        REP(j, 100){
            m[i][j]='.';
        }
    }
    int lb=b/50,rb=b%50;
    REP(i, lb){
        REP(j, 50){
            m[lw*2+5+i*2][j*2]='#';
        }
    }
    REP(i, rb){
        m[lw*2+5+lb*2+2][i*2]='#';
    }
    cout << "100 100"<<endl;
    REP(i, 100){
        REP(j, 100){
            cout<<m[i][j];
        }
        cout<<endl;
    }
    
    return 0;
}



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

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define pb push_back
#define inf 1e+18L
#define MOD 1000000007

int nCk(int n, int k)
{
    int C[k+1];
    memset(C, 0, sizeof(C));
    C[0] = 1; // nC0 is 1
    rep(i,1,n+1)
    {
        for(int j=min(i,k); j>0; j--)
        {
            C[j] = C[j] + C[j-1];
        }
    }
    return C[k];
}

int main()
{
    FastIO
    int n, m;
    cin >> n >> m;
    cout << nCk(n,2) + nCk(m,2) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
ll int large=(ll int)1e13+7;
ll int mod=(ll int)1e9+7;
ll int const N=(ll int)1e6+10;

ll int mod_exp(ll int x,ll int n)
{
    ll int result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n=n/2;
    }
    return result;
}

ll int mod_inverse(ll int a)
{
    return mod_exp(a,mod-2);
}



int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll int T,i,j,ij;
T=1;
//cin>>T;
while(T--)
{
  ll int n,k;
  cin>>n>>k;
  ll int a[n];
  rep(i,0,n)
  cin>>a[i];
  sort(a,a+n);
  ll int ans=0;
  rep(i,0,k)
  ans+=a[i];
  cout<<ans;




}
return 0;
}
















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

# define ll long long
# define mod 1000000007
# define MAX 100005
# define PI 3.141592653589793238                                                                                  //shortcut keys

# define pb push_back
# define mp make_pair
# define all(x) x.begin(),x.end()
# define fr(i,a,b) for(int i=a;i<=b;i++)

# define decimal(k) fixed<<setprecision(k)
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------
using namespace std;

int main()
{
	ll a[2],b[2];
	fr(i,1,2)cin>>a[i];
	fr(i,1,2)cin>>b[i];
	ll ans=-1e18;
	fr(i,1,2){
		fr(j,1,2){
			ans=max(ans,a[i]*b[j]);
		}
	}
	cout<<ans<<'\n';
	
	return 0;
}



Measured memory_bytes: 3672
import qualified Data.ByteString.Char8 as BS

main = do
  s <- BS.getLine

  let n = BS.length s
      s1 = BS.take ((n-1) `div` 2) s
      s2 = BS.drop ((n-1) `div` 2 + 1) s

      checkPalindrome s i j | i >= j = True
                            | otherwise =
                              ((BS.index s i) == (BS.index s j))
                              && checkPalindrome s (i+1) (j-1)

  putStrLn $ if s1 == s2 && checkPalindrome s1 0 ((n-1) `div` 2 - 1)
             then "Yes"
             else "No"

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

#define INF 1145141919
using LL = long long int;
#define II pair<int, int>

using namespace std;

const int MAX_N = 200005;
const int MAX_M = 200005;

int N, M;
LL A[MAX_N], B[MAX_M];


int main()
{
  map<int, int> S;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    S[A[i]]++;
  }
  bool ansFlag = true;
  cin >> M;
  for(int i = 0; i < M; i++) {
    cin >> B[i];
    S[B[i]]--;
    if(S[B[i]] < 0) {
      ansFlag = false;
    }
  }

  if(ansFlag) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 12800
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
using namespace std;


 
/*
string fs(string str1, string str2)
{    if (str1.length() > str2.length())
        swap(str1, str2);
      string str = "";
    int n1 = str1.length(), n2 = str2.length();
    int diff = n2 - n1;
      int carry = 0;
      for (int i=n1-1; i>=0; i--)
    {
 
        int sum = ((str1[i]-'0') +
                   (str2[i+diff]-'0') +
                   carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }
      for (int i=n2-n1-1; i>=0; i--)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }
      if (carry)
        str.push_back(carry+'0');
      reverse(str.begin(), str.end());
 
    return str;
}*/
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
/*
ll gcdextended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; 
    int gcd = gcdextended(b%a, a, &x1, &y1); 
   
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}
 
 
///RELATIVE COPRIME
ll modinverse(ll a, ll m) 
{ 
    ll x, y; 
   ll g = gcdextended(a, m, &x, &y); 
    if (g != 1) 
return -1;
    else
    { 
        ll res = (x%m + m) % m; 
        return res;  
    } 
} 
  */
ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 
///M IS PRIME
ll modif(ll x,ll m){
return(powmod(x,m-2,m));
 
}
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second<y.second;}
bool f2(pll &x,pll &y){return x.first>y.first;}
bool f3(ll &x,ll &y){
    return x>y; 
    }

#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()


//include<bits/stdc++.h>


int main()
{ fastio;
//freopen("input.txt", "r", stdin); 
//freopen("output.txt", "w", stdout);
ll n,m;cin>>n>>m;
ll ans=0;
ll b[n];
ll s=0;
forl(i,0,n){cin>>b[i];s+=b[i];}
ll k=4*m;
ll x=s/k;
if(s%k!=0)x++;
forl(i,0,n){
    ll y=b[i];
    if(y>=x)ans++;
}
if(ans>=m){
    cout<<"Yes";
}
else cout<<"No";

return 0;
}




Measured memory_bytes: 3624
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int main() {
    string s;cin >> s;
    int mi = inf;
    rep(i, s.size()-2) {
        int k = stoi(s.substr(i,3));
        chmin(mi,abs(753-k));
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int n, l;
    int sum = 0;

    scanf("%d %d", &n, &l);

    for (int i = 1; i <= n; i++) {
        sum += l + i -1;
    }

    if (1 <= 1 - l && 1 - l <= n)
        printf("%d\n", sum);
    else if (1 > 1 - l)
        printf("%d\n", sum - l);
    else if (1 - l > n)
        printf("%d\n", sum - (l + n - 1));

    return 0;
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&!(1<<i);}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const int inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int rangesum(int lo, int hi, vi& pre) {
	if(lo==0)
		return pre[hi]%MOD;
	return (pre[hi]-pre[lo-1]+MOD)%MOD;
}
int32_t main(void)
{
	IOS;
	int n, k;
	cin>>n>>k;
	vi a(n);
	for(int i = 0; i < n; i++)
		cin>>a[i];
	int dp[2][k+1];
	vi pre(k+1, 0);
	for(int i = 0; i <= k; i++) {
		if(i <= a[0]) dp[0][i]=1;
		else dp[0][i]=0;
	}
	pre[0]=dp[0][0];
	for(int i = 1; i <= k; i++)
		pre[i]=(pre[i-1]+dp[0][i])%MOD;
	int cur=1;
	for(int i = 1; i < n; i++) {
		for(int j = 0; j <= k; j++)
			dp[cur][j]=0;
		for(int j = 0; j <= k; j++)
			dp[cur][j]=rangesum(max(0ll, j-a[i]), j, pre);
		pre[0]=dp[cur][0];
		for(int j = 1; j <= k; j++)
			pre[j]=(pre[j-1]+dp[cur][j])%MOD;
		cur^=1;
	}
	cout<<dp[cur^1][k]<<endl;
	time();
	return 0;
}

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

int main(void){
    int N, Abuf;
    cin >> N;
    vector<int> Boss(N, 0);
    for(int i=1; i<N; i++){
        cin >> Abuf;
        Boss[Abuf-1]++;
    }
    for(int i=0; i<N; i++){
        cout << Boss[i] << endl;
    }
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] num = new int[n];
        int cnt = 0;
        string[] str = Console.ReadLine().Split(' ');
        
        for(int i = 0; i < n; i++){
            num[i] = int.Parse(str[i]);
        }

        while(num[0] % 2 != 1){
            for(int i = 0; i < n; i++){
                if(num[i] % 2 == 0){
                    num[i] /= 2;
                }else{
                    Console.WriteLine(cnt);
                    return;
                }
            }
            cnt++;
        }

        Console.WriteLine(cnt);
    }
}



Measured memory_bytes: 13124
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef unsigned long long ll;
int N, n;

int main(){
    int h,w,k;
    cin >> h >> w >> k;
  vector<int> u(w,0);
  vector<int> b(h);
    vector<vector<int>> v(h, u);
  vector<vector<int>> ans = v;
    REP(i,h){
        string s;
       cin >> s;
        REP(j,w){
            if(s[j] == '#') v[i][j] = 1;
        }
        b[i] = accumulate(v[i].begin(), v[i].end(), 0);
    }
    int ind = 1;
  	int ii = 0;
  	while(b[ii] == 0) ++ii;
    for (int i = ii; i < h ; ++i){
        if(b[i] == 1) {
            REP(j,w) {
                ans[i][j] = ind;
            }
          if(b[i+1] != 0) ++ind;
        }
        else if(b[i] == 0){
            REP(j,w) {
                ans[i][j] = ans[i-1][j];
            }
          if(b[i+1] != 0) ++ind;
        }
        else if(b[i] > 1){
            REP(j,w){
                ans[i][j] = ind;
                if(v[i][j] == 1 && b[i] > 1) {++ind; --b[i];}
            }
          if(b[i + 1] != 0)++ind;
        }
    }
  for(int i = ii-1; i > -1; --i){
  	REP(j,w){
      ans[i][j] = ans[i+1][j];
    }
  }
  REP(i,h){
    REP(j,w){
      cout << ans[i][j] << " ";
    }
    cout << "\n";
  }
}

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

int main(void){
    long long l, r, min = 2020;
    cin >> l >> r;
    if(r-l >= 2018){
        cout << 0 << endl;
        return 0;
    }

    vector<long long> d(r-l+1);
    
    for(int i = 0; i < r-l+1; i++){
        d.at(i) = l+i;
        d.at(i) %= 2019;
    }
    
    rep(i, r-l+1){
        for(int j = i+1; j < r-l+1; j++){
            if(min > d.at(i)*d.at(j)%2019){
                min = d.at(i)*d.at(j)%2019;
            }
        }
    }
    
    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
N, Y = [int(_) for _ in input().split()]
Y = Y // 1000

for i in range(max(0, Y % 5), N + 1):
    for j in range(0, N + 1 - i):
        k = N - i - j
        if k < 0: continue
        # print(i, j, k, k * 10 + j * 5 + i)
        if k * 10 + j * 5 + i == Y:
            print(k, j, i)
            exit()
print(-1, -1, -1)

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

typedef long double lf;

int N;
lf X;
struct Line {
    int a, b, c;
    bool operator <(const Line &i) const {
        return (lf)-a/b*X-(lf)c/b + 1e-12 < (lf)-i.a/i.b*X-(lf)i.c/i.b || (abs((lf)-a/b*X-(lf)c/b - (lf)-i.a/i.b*X+(lf)i.c/i.b) < 1e-12 && (lf)-a/b < (lf)-i.a/i.b);
    }
};
vector<Line> line;

struct BIT {
    vector<int> tree;
    void init() {
        tree = vector<int>(4*N, 0);
    }
    void upd(int idx, int val, int l, int r, int n) {
        if(idx < l || r < idx) return;
        if(l == r) {
            tree[n] += val;
            return;
        }
        int m = (l + r)>>1;
        upd(idx, val, l, m, 2*n);
        upd(idx, val, m + 1, r, 2*n + 1);
        tree[n] = tree[2*n] + tree[2*n + 1];
    }
    int quer(int a, int b, int l, int r, int n) {
        if(b < l || r < a) return 0;
        if(a <= l && r <= b) return tree[n];
        int m = (l + r)>>1;
        int L = quer(a, b, l, m, 2*n);
        int R = quer(a, b, m + 1, r, 2*n + 1);
        return L + R;
    }
} bit;

struct Frac {
    int a, b;
    bool operator <(const Frac &i) const {
        return a * i.b < i.a * b;
    }
};
vector<Frac> F;
map<Frac, int> df;

lf solve() {
    F.clear();
    df.clear();
    for(int i = 0; i < N; i++) {
        F.push_back({ (((line[i].a < 0) ^ (line[i].b < 0))? 1 : -1) * abs(line[i].a), abs(line[i].b) });
    }
    sort(F.begin(), F.end());
    for(int i = 0; i < N; i++) df[ F[i] ] = i;

    lf s = -1e9, e = 1e9;
    for(int i = 0; i < 64; i++) {
        lf m = (s + e) / 2;
        X = m;

        sort(line.begin(), line.end());

        bit.init();

        int cnt = 0;
        for(int j = 0; j < line.size(); j++) {
            int t = df[ { (((line[j].a < 0) ^ (line[j].b < 0))? 1 : -1) * abs(line[j].a), abs(line[j].b) } ];
            cnt += bit.quer(0, t, 0, N - 1, 1);
            bit.upd(t, 1, 0, N - 1, 1);
        }

        if(cnt >= (N*(N - 1)/2 + 1)/2) e = m;
        else s = m;
    }

    return e;
}

int main() {
    scanf("%d", &N);
    line.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d %d %d", &line[i].a, &line[i].b, &line[i].c);
        line[i].c = -line[i].c;
    }

    lf x = solve();

    for(int i = 0; i < N; i++) {
        swap(line[i].a, line[i].b);
    }

    lf y = solve();

    cout<<fixed;
    cout.precision(20);
    cout << x << ' ' << y;
}


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

using namespace std;

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

	long long mini = 10000000000;
	for(long long i = 1; i * i <= n; ++i){
      if(n % i == 0){
        long long a = (long long)log10(i) + 1;
        long long b = (long long)log10(n / i) + 1;

        int tmp = max(a,b);

        //cout << a << "\n";
        //cout << b << "\n";

        if(mini > tmp) mini = tmp;
        else continue;
      }
      
	}

  cout << mini << "\n";

  return 0;
}

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

using namespace std;
#define ll long long
#define inf 998244353

ll fun(ll n,ll m)
{
    ll s=1;
    while(m)
    {
        if(m&1)
        {
            s=s*n%inf;
        }
        n=n*n%inf;
        m=m/2;
    }
    return s;
}

ll a[300005], f[300005], ma[300005];

int main()
{
    int n;
    memset(f,0,sizeof(f));
    memset(ma,0,sizeof(ma));
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        f[a[i]]++;
        ma[a[i]]++;
    }
    ll z=0;
    for(int i=0;i<n;i++)
    {
        if(f[a[i]]>=2)
        {
            z=z+f[a[i]]*(f[a[i]]-1)/2;
            f[a[i]]=0;
        }
    }
    for(int i=0;i<n;i++)
    {
        ll k=z-ma[a[i]]*(ma[a[i]]-1)/2+(ma[a[i]]-1)*(ma[a[i]]-2)/2;
        printf("%lld\n",k);
    }
    return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <string>

using namespace std;

typedef long long int ll;
const ll MOD = 1000000007;


int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    vector<ll> v(26, 0);
    ll sum = 1;
    for(int i=0;i<n;i++) {
        v[s[i] - 'a']++;
    }
    for(int i = 0; i<26;i++) {
        sum = (sum * (v[i] + 1)) % MOD;
    }
    cout << ((sum  + MOD - 1) % MOD )<< endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d>> e>> f;
    a*=100;
    b*=100;
    bool c1[f+1];
    bool c2[f+1];
    for(int i =0; i<=f; i++){
        c1[i] = false;
        c2[i] =false;
    }
    c1[0]=true;
    c2[0] = true;
    
    for(int i = 0; i<=f; i++){
        if(i+a<=f){
            c1[i+a]|=c1[i];
        }
        if(i+b<=f){
            c1[i+b]|=c1[i];
        }
        if(i+c<=f){
            c2[i+c]|=c2[i];
        }
        if(i+d<=f){
            c2[i+d]|=c2[i];
        }
    }
    int num, dem;
    num = 0;
    dem = 0;
    double best = -1.0;
    for(int i = 0; i<=f; i+=100){
        for(int j = 0; j<=f; j++){
            if(i+j>f){
                continue;
            }
            if(j>i/100*e){
                continue;
            }
            if(!c1[i]||!c2[j]){
                continue;
            }
            if((double)j/(double)(i+j) > best){
                best = (double)j/(double)(i+j);
                num = j;
                dem = i+j;
            }
        }
    }
    cout << dem << " " << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <tuple>
using namespace std;

int H, W, a, b;

int main() {
	cin >> H >> W >> a >> b;
	cout << (H - a)*(W - b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi   = vec<int>;
using vvi  = vec<vi>;
using vvvi = vec<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n; cin >> n;
  vector<pair<int,int>> a(n);
  int ai;
  rep(i,n) { cin >> ai; a[i] = {ai, i+1}; }
  sort(all(a));
  rep(i,n) cout << a[i].second << endl;
  return 0;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[45][405][405]={0};
int main(){
  ll n,ma,mb;
  cin>>n>>ma>>mb;
  for(int i=0;i<45;i++){
    for(int j=0;j<405;j++){
      for(int k=0;k<405;k++) dp[i][j][k]=17441744174417;
    }
  }
  dp[0][0][0]={0};
  for(int i=0;i<n;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    for(int j=0;j<405;j++){
      for(int k=0;k<405;k++){
        dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k]);
        if(j+a<405&&k+b<405) dp[i+1][j+a][k+b]=min(dp[i+1][j+a][k+b],dp[i][j][k]+c);
      }
    }
  }
  ll ans=17441744174417;
  for(int i=1;(i*ma)<405&&(i*mb)<405;i++) ans=min(ans,dp[n][i*ma][i*mb]);
  cout<<(ans==17441744174417?-1:ans)<<endl;
}


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

int main()
{
    int x,y;
    
    while(1){
        cin>>x>>y;
        if(x==0&&y==0)break;

        if(x>y){
            int temp = x;
            x=y;
            y=temp;
        }

        cout<<x<<" "<<y<<endl;

    }

    return 0;
}


Measured memory_bytes: 3060
import java.util.*;
public class Main {
    public static void main(String args []){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if((B-1)%(A-1)==0) System.out.println((B-1)/(A-1));
        else System.out.println((B-1)/(A-1)+1);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <regex>
#include <initializer_list>
#include <deque> 
#define DBL_MIN 0.000000000000001

#include <iostream>
using namespace std;


int main(void){
    long x,y;
    cin >> x >> y;
    int ax = abs(x);
    int ay = abs(y);
    int diff = max(ax,ay) - min(ax,ay);
    if(y == 0){
        if(x < 0){
            cout << abs(x) << endl;
        }else{
            cout << abs(x) + 1 << endl; 
        }
    }else if(0 <= x && 0 <= y){
        if(y >= x){
            cout << y - x << endl;
        }else{
            cout <<  x - y + 2 << endl;
        }
    }else if(x < 0 && y < 0){
        if(y >= x){
            cout << y - x << endl;
        }else{
            cout << abs(y) - abs(x) + 2 << endl;
        }
    } else if(x < 0 && 0 <= y){
        if(abs(y) >= abs(x)){
            cout << abs(y) - abs(x) + 1 << endl;
        }else{
            cout << abs(x) - abs(y) + 1  << endl;
        }
    }else if(0 <= x && y < 0){
        if(abs(x) > abs(y)){
            cout << abs(x) - abs(y) + 1 << endl;
        }else{
            cout << abs(y) - x + 1 << endl;
        }
    }
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> // Common file
#include<ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
ll t = 1, tt;
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (x*y)%hell;}
inline ll powMod(ll base,ll expo){
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base);
		expo>>=1;
	}
	return ans;
}
void solve(){
	ll n, k, res=0;
	cin>>n>>k;
	rep(i,k,n+2){
		ll maxi=(n*(n+1))/2-((n-i)*(n-i+1))/2, mini=(i*(i-1))/2;
		res=add(res,add(add(maxi,1),hell-mini%hell));
	}
	cout<<res;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3676