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

#define pb push_back
#define ff first
#define ss second

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

int a, b , c , d;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b >> c >> d;
	cout << a * b - c * b - d * a + c * d;
	return 0;
}


Measured memory_bytes: 384
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  const [N, D] = lines[0].split(" ").map(Number);
  console.log(Math.ceil(N / (2 * D + 1)));
});


Measured memory_bytes: 9548
#include<stdio.h>

int n,m;
int a=0,b=100000;
int main() {
    scanf("%d %d", &n, &m);
    int l,r;
    for(int i=0; i<m;i++) {
        scanf("%d %d", &l, &r);
        if (l > a) a = l;
        if (r < b) b = r;
    }

    printf("%d", b-a+1 > 0 ? b-a+1 : 0);
}


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

#if debug
#include "printer.hpp"
#define dump(a) cerr << #a << "(" << __LINE__ << ") = " << a << endl;
#else
#define dump(...)
#endif

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a, b) for (int i = (b)-1; i >= a; i--)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
const ll mod = 1000000007;

ll pow(ll x, ll y) {
  ll ret = 1, tmp = x;
  while (y) {
    if (y % 2) ret = ret * tmp % mod;
    tmp = tmp * tmp % mod;
    y /= 2;
  }
  return ret;
}

ll inverse(ll x) { return pow(x, mod - 2); }

int main() {
  ll h, w, n;
  cin >> h >> w >> n;
  if (h < w) h = w;
  cout << (n + h - 1) / h << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		//長方形の面積と周の長さ
		Scanner sc=new Scanner(System.in);
		int vertical=sc.nextInt();
		int cross=sc.nextInt();
		int menseki=vertical*cross;
		int gaisyu=(vertical+cross)*2;
		System.out.println(menseki+" "+gaisyu);
	}

}



Measured memory_bytes: 26172
#include <bits/stdc++.h>
 
using namespace std; 
 
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()
#define INF 1e9
 
typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	
 
 
int main(){
	
	
	int n;
	
	cin >> n;
	
	int ans = 1;
	
	f(i,2,40){
		f(j,2,30){
			int idx = pow(i,j);
			if(idx>n) break;
			ans = max(ans,idx);
		}
	}
	
	cout << ans << endl;
	

 
    return 0;
}


Measured memory_bytes: 512
x, y = map(int, input().split())

A, B = [0] * 206, [0] * 206
A[1] = 300000
A[2] = 200000
A[3] = 100000
B[1] = 300000
B[2] = 200000
B[3] = 100000

if x == 1 and y == 1:
    print(A[x] + B[y] + 400000)
else:
    print(A[x] + B[y])

Measured memory_bytes: 61896
import java.io.BufferedInputStream
import java.util.StringTokenizer

class FastScanner(){
    private val reader = BufferedInputStream(System.`in`).bufferedReader()
    private var st: StringTokenizer? = null
    fun next(): String {
        while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
        return st!!.nextToken()
    }
    fun hasNext(): Boolean {
        while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine() ?: return false)
        return true
    }
}

const val YES = "Yes"
const val NO = "No"

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> = Array<String>(size, init)
    fun iterateTokens(): Iterator<String> {
        val reader = BufferedInputStream(System.`in`).bufferedReader()
        return reader.use{ it.readText() }.splitToSequence(" ", "\n").iterator()
    }
    val tokens = iterateTokens()
    val N = tokens.next().toLong()
    val A = LongArray(N.toInt())
    val B = LongArray(N.toInt())
    for(i in 0 until N.toInt()){
        A[i] = tokens.next().toLong()
        B[i] = tokens.next().toLong()
    }
    solve(N, A, B)
}

fun solve(N: Long, A: LongArray, B: LongArray){
    val n = N.toInt()
    val ab = Array<Pair<Long, Long>>(n){
            A[it] to B[it]
        }.sortedBy{ it.second }
    var time = 0L
    for ( i in 0 until n){
        time += ab[i].first
        if (time > ab[i].second){
            println(NO)
            return
        }
    }
    println(YES)
    return
}



Measured memory_bytes: 133240
#include <cstdio>

int main()
{
	int a[100][100] = {0};
	int b[100][100] = {0};
	unsigned long int c[100][100] = {0};

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

	for (int i = 0; i < n; i++) { 
		for (int j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (int i = 0; i < m; i++) { 
		for (int j = 0; j < l; j++) {
			scanf("%d", &b[i][j]);
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++) {
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}


	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			printf("%ld", c[i][j]);
			if (j != l-1) printf(" ");
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> a(m);
  vector<bool> flag(m + 1, false);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    flag[a[i] - 1] = true;
  }
  int ans1 = 0, ans2 = 0;
  for (int i = x - 1; i <= n; i++) {
    if (flag[i]) {
      ans1++;
    }
  }

  for (int i = x - 1; i >= 0; i--) {
    if (flag[i]) {
      ans2++;
    }
  }

  cout << min(ans1, ans2) << endl;
}

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

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(){
    int a[3],count=1;
    cin >> a[0] >> a[1] >> a[2];
    qsort(a,3,sizeof(int),compare_int);
    for(int i=1;i<3;i++){
        if(a[i]!=a[i-1]){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  LL n, x, d;
  Solver2(LL n, LL x, LL d) : n(n), x(x), d(d){};

  void solve() {
    if (x == 0 && d == 0) {
      cout << 1 << endl;
      return;
    } else if (x == 0) {
      cout << (n - 1) * n / 2 + 1 << endl;
      return;
    } else if (d == 0) {
      cout << n + 1 << endl;
      return;
    }

    vector<LL> lb(n + 1), ub(n + 1), rlb(n + 1, LINF), rub(n + 1, -LINF);
    LL g = gcd(abs(x), abs(d));
    LL dx = d / g;
    LL dd = -x / g;
    if (dx < 0) dx = -dx, dd = -dd;
    DBG(dx, dd)
    for (int i = 1; i <= n; ++i) {
      lb[i] = lb[i - 1] + i - 1;
      ub[i] = ub[i - 1] + (n - i);
    }
    for (int i = n - 1; i >= 0; --i) {
      if (i + dx > n) continue;
      rlb[i] = min(lb[i + dx], rlb[i + dx]) - dd;
      rub[i] = max(ub[i + dx], rub[i + dx]) - dd;
    }
    DBG(ub, lb, rub, rlb)
    LL ans = 0;
    for (int i = 0; i <= n; ++i) {
      LL tmp = min(rub[i], ub[i]) - max(rlb[i], lb[i]) + 1;
      ans += ub[i] - lb[i] + 1 - max(0ll, tmp);
    }
    cout << ans << endl;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, x, d;
  std::cin >> n >> x >> d;

  Problem::Solver2 sol(n, x, d);
  sol.solve();
  return 0;
}


Measured memory_bytes: 6528
import java.io.PrintWriter;
import java.util.*;


public class Main{

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		double r=in.nextDouble();
		out.printf("%f %f",r*r*Math.PI,2*r*Math.PI);
		out.flush();
	}

}



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

using namespace std;

typedef pair<int, int> P;

const int INF = 1 << 29;

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

  vector<vector<P>> edge(n);
  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int v, c;
      cin >> v >> c;
      edge[u].push_back(P(c, v));
    }
  }

  vector<int> dist(n, INF);
  priority_queue<P, vector<P>, greater<P>> que;
  dist[0] = 0;
  que.push(P(0, 0));
  while (!que.empty()) {
    P p = que.top();
    que.pop();

    for (int i = 0; i < edge[p.second].size(); i++) {
      if (dist[edge[p.second][i].second] > p.first + edge[p.second][i].first) {
        dist[edge[p.second][i].second] = p.first + edge[p.second][i].first;
        que.push(
            P(p.first + edge[p.second][i].first, edge[p.second][i].second));
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << i << " " << dist[i] << "\n";
  }

  return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		if(N % 2 == 0) {
			System.out.println(N);
		}else {
			System.out.println(2*N);
		}
	}
}

Measured memory_bytes: 20948
n = int(input())
l = 0
r = 0
cntl = 0
cntr = 0
fl = 0
fr = 0
exl = 0
exr = 0
only_r = 0
only_l = 0
maxl = 0
maxr = 0
exlr = []
for i in range(n):
    s = input()
    templ = 0
    tempr = 0
    temp_exl = 0
    temp_exr = 0
    fl = 0
    fr = 0
    for i in s:
        if i == "(":
            tempr += 1
        elif i == ")":
            tempr -= 1
            if tempr < 0:
                tempr = 0
                templ += 1
                fl = 1
    temp_exl += templ
    if tempr > 0:
        temp_exr += tempr
        fr = 1
    if fl == 1 and fr == 0:
        only_l += temp_exl
    elif fr == 1 and fl == 0:
        only_r += temp_exr
    elif temp_exl + temp_exr > 0:
        exl += temp_exl
        exr += temp_exr
        exlr.append([temp_exl-temp_exr, temp_exl,temp_exr])
    # maxl = max(maxl,temp_exl)
    # maxr = max(maxr,temp_exr)
# print (exr,exl,only_r,only_l)
a = only_r
b = only_l
exlr.sort()
# exlr.sort(key=lambda x: x[1])

# print(exlr)
for i in range(len(exlr)):
    if exlr[i][1] <= a and exlr[i][0] <= 0:
        a -= exlr[i][0]
        exlr[i] = [0,0,0]
# print(exlr)
for i in exlr:
    a -= i[1]
    if a<0:
        print("No")
        exit()
    a += i[2]
if a-b == 0:
    print("Yes")
else:
    print("No")
# if exl+only_l == exr+only_r and exl-exr == only_r-only_l and only_l > 0 and only_r > 0:
#     print("Yes")
# elif exr+exl+only_l+only_r == 0:
#     print("Yes")
# else:
#     print("No")

    





Measured memory_bytes: 102200
#include <stdio.h>
#include <math.h>

typedef struct {
  double x;
  double y;
}point;

void kock(int, point, point);


int main() {
  point p1 = {0, 0}, p2 = {100, 0};
  int n;

  scanf("%d", &n);

  printf("%lf %lf\n", p1.x, p1.y);

  kock(n, p1, p2);

  printf("%lf %lf\n", p2.x, p2.y);

  return 0;
}



void kock(int n, point p1, point p2) {
  point s, t, u;
  double kaku;

  kaku = M_PI / 3;

  if (n == 0) return;

  s.x = (2 * p1.x + 1 * p2.x) / 3;
  s.y = (2 * p1.y + 1 * p2.y) / 3;
  t.x = (1 * p1.x + 2 * p2.x) / 3;
  t.y = (1 * p1.y + 2 * p2.y) / 3;
  u.x = (t.x - s.x) * cos(kaku) - (t.y - s.y) * sin(kaku) + s.x;
  u.y = (t.x - s.x) * sin(kaku) + (t.y - s.y) * cos(kaku) + s.y;

  kock(n-1, p1, s);
  printf("%lf %lf\n", s.x, s.y);

  kock(n-1, s, u);
  printf("%lf %lf\n", u.x, u.y);

  kock(n-1, u, t);
  printf("%lf %lf\n", t.x, t.y);

  kock(n-1, t, p2);
}



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

int main() {
	vector<int> v(3); int n; cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) { cin >> v[j]; v[j] = pow(v[j], 2); }
		sort(v.begin(), v.end());
		if (v[0] + v[1] == v[2]) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 3160
n = int(input())
l = [int(i) for i in input().split()]

def out(l):
    ll = bunkatu(l)
    
    res = 0
    
    for l in ll:
        
        #全て-1
        l2 = [i - 1 for i in l]
        
        #[]想定
        if not l2:
            continue
        
        if max(l2) > 0:
            res += 1 + out(l2)
        else:
            res += 1
        
    return res

def bunkatu(l):
    #0でリストを分ける
    s = 0 #start
    ll = []
    
    for k, v in enumerate(l) :
        #最初に0が渡されるかもしれないので0以下
        if v <= 0 :
            ll.append(l[s:k])
            s = k + 1
    #ループ最後
    else:
        if s != k + 1:
            ll.append(l[s:k + 1])
    return ll


print(out(l))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
inline void read(int &x){
    char c = getchar();
    int p = 1;
    x = 0;
    while(!isdigit(c)){
        if(c == '-')p = -1;
        c = getchar();
    }
    while(isdigit(c)){
        x = (x << 1) + (x << 3) + (c ^ '0');
        c = getchar();
    }
    x *= p;
}
int n, a[150];
int main(){
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    read(n);
    for(register int i = 1; i <= n; ++i){
        read(a[i]);
    }
    int tot = n + 1, cnt = 0;
    for(register int i = 1; i <= n; ++i){
        if(a[i] == a[i - 1]){
            cnt++;
            a[i] = tot++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		if(S.substring(2,3).equals(S.substring(3,4))&& S.substring(4,5).equals(S.substring(5,6))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
			
	
	}
}

Measured memory_bytes: 21844
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    scanner.nextInt()
    val m = scanner.nextInt()

    val ll = arrayListOf<Int>()
    val hl = arrayListOf<Int>()
    (1..m).forEach {
        ll.add(scanner.nextInt())
        hl.add(scanner.nextInt())
    }
    val lowMax = ll.max()!!
    val highMin = hl.min()!!
    if (lowMax > highMin)
        print(0)
    else
        print(highMin - lowMax + 1)
}


Measured memory_bytes: 77584
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	long long int n;
	cin >> n;
	if (n / 100 == n % 10) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,i,c=0,j,a;
  cin>>n;
  vector <pair <long long int,long long int > > v;
  for(i=0;i<n;i++)
  {
    cin>>a;
    v.push_back(make_pair(a,i+1));
  }
  sort(v.begin(),v.end());
  for(i=0;i<n;i++)
  {
    cout<<v[i].second<<" ";
  }
}


Measured memory_bytes: 2672
#include <stdio.h>
int main(){
    int a[6],temp;
    char c;
    for(int i=0;i<6;i++)scanf("%d",&a[i]);
    while(scanf("%c",&c)!=EOF){
        if(c=='E'){
            temp=a[0];
            a[0]=a[3];
            a[3]=a[5];
            a[5]=a[2];
            a[2]=temp;
        }
        if(c=='W'){
            temp=a[0];
            a[0]=a[2];
            a[2]=a[5];
            a[5]=a[3];
            a[3]=temp;
        }
        if(c=='N'){
            temp=a[0];
            a[0]=a[1];
            a[1]=a[5];
            a[5]=a[4];
            a[4]=temp;
        }
        if(c=='S'){
            temp=a[0];
            a[0]=a[4];
            a[4]=a[5];
            a[5]=a[1];
            a[1]=temp;
        }
    }
    printf("%d\n",a[0]);
}


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

int main() {
  int A, B, sum;
  cin >> A >> B;
  sum = max(A, B);
  if (A > B) {
    cout << A + (A-1) << endl;
  } else if (B > A) {
    cout << B + (B-1) << endl;
  } else {
    cout << 2*A << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List
import Data.Array

main = do
  li <- BS.getLine
  let [n,k] = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  li <- BS.getLine
  let as = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  let ans = compute n k as
  putStrLn $ unwords $ map show ans

{- いもす法、累積和、の方がまともな名前だ。
立ち上がりと立下りを一つの配列に累積し、それをなぞることで各ポイントの値を一気に取りだす
-}
compute :: Int -> Int -> [Int] -> [Int]
compute n k as = iterate (step n) as !! (min 41 k)

step :: Int -> [Int] -> [Int]
step n as = scanl1 (+) $ elems $ accumArray (+) 0 (1,n) imar
  where
    imar =
      [p
      | (i,a) <- zip [1..] as
      , p <- [(max 1 (i-a),1)] ++ [(j,-1) | let j = i+a+1, j <= n]
      ]

{- naive code : TLE
compute n k as = elems $ iterate (step n) (listArray (1,n) as) !! k
step n ar = accumArray (+) 0 (1,n) [ (j,1) | i <- [1..n], j <- [max 1 (i - ar ! i)..min n (i + ar ! i)] ]
-}


Measured memory_bytes: 150936
from itertools import accumulate
import bisect
n = int(input())
d = []
c = 0
co = 0
for i,j in zip(map(int,input().split()),map(int,input().split())):
  if i - j > 0:
    d.append(i-j)
  elif i - j < 0:
    c += i-j
    co += 1
d.sort(reverse=1)
if sum(d) + c < 0:
  print(-1)
elif c == 0:
  print(0)
else:
  d = list(accumulate(d))
  print(bisect.bisect_left(d,-c)+co+1)

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

/************* Using *************/
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using graph_t = vector<vector<ll>>;

/*********** Constants ***********/
const auto INF  = static_cast<int>(1e10);
const auto INFL = static_cast<ll>(1e18);
const auto MOD  = static_cast<ll>(1e9 + 7);
const auto NIL  = nullptr;

/*********** Variables ***********/
ll N;
vector<double> V;
double ANS;

/************* Utils *************/

/*********** Functions ***********/
bool init() {
    cin >> N;
    V.resize(N);
    for (auto &item : V) cin >> item;
    ANS = 0.0;
    return true;
}

void solve() {
    sort(V.begin(), V.end());
    ANS = V[0];
    for (ll i = 1; i < V.size(); i++) {
        ANS = (ANS + V[i]) / 2.0;
    }
}

void output() {
    cout << setprecision(10) <<ANS << endl;
}

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

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <queue>
#include <set>
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// long long comb(long long a, long long b){
//     long long MOD = 1000000007;
//     long long bunshi = 1;
//     long long bunbo = 1;
//     for (long long i = b; i > 0; --i)
//     {
//         bunshi = bunshi * (a - (b - i));
//         bunbo = bunbo * i;
//     }
//     return bunshi/bunbo;
// }
int main(){
    COMinit();
    long long N, K;
    long long MOD = 1000000007;
    std::cin >> N >> K;
    for (long long i = 1; i < K+1; ++i)
    {
        /* code */
        long long case_num;
        case_num = comb(K - 1, i - 1)*comb(N - K + 1, i);
        std::cout << case_num % MOD << "\n";
    }
    // std::cout << comb(3 ,2) << "\n";
}

Measured memory_bytes: 12160
#include <stdio.h>



 int main(){

   int i,j;
   int cards[4][13];
   char suit;
   int num;
   int n;



    scanf("%d",&n);

   for (i = 0;i<4;i++){
     for(j=1;j<=13;j++){
        cards[i][j]=0;
      }
   }


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

   scanf("%c %d\n",&suit,&num);


       if(suit == 'S')
          cards[0][num]=1;
       if(suit == 'H')
          cards[1][num]=1;
       if(suit == 'C')
          cards[2][num]=1;
       if(suit == 'D')
          cards[3][num]=1;

    }

    for(i = 0;i<4;i++){
      for(j = 1;j<=13;j++){
        if(cards[i][j]==1) continue;
          if(i==0)
          printf("S %d\n",j);
          if(i ==1)
          printf("H %d\n",j);
          if(i == 2)
          printf("C %d\n",j);
          if(i == 3)
          printf("D %d\n",j);

      }
    }










  //printf("\n");



return(0);
}

Measured memory_bytes: 600
#include<stdio.h>
 
int main(){
  int o,n,k,i,j;
  int key;
  int A[110];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(j=1;j<=n;j++)
    {  
          key = A[j];      
          i = j-1;
          while(i>0 && A[i]>key)
        {
          A[i+1]=A[i]; 
          i = i-1;
        }
          A[i+1] = key;
          for(k=1;k<=n;k++){
        if(k == n)printf("%d\n",A[k]);
        else printf("%d ",A[k]);
          }
    }
   
  return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
#define pll pair<ll,ll>
#define pii pair<int,int>
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
 
ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b) ;} 

template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}
 

 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 	char s;
 	cin>>s;
 	int a = int(s);
 	// cout<<a<<endl;
 	if(a>=65 and a<=90){
 		cout<<"A"<<endl;
 	}   
 	else{
 		cout<<"a"<<endl;
 	}
    return 0;
}

Measured memory_bytes: 3584
object Main extends App {

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt 
  val a = List.fill(n)(sc.nextInt) 
  val q = sc.nextInt 
  val m = List.fill(q)(sc.nextInt)
  
  def solve(i: Int, m: Int): Boolean = if(m == 0) true
    else if(i >= n) false
    else solve(i+1, m) || solve(i+1, m - a(i))
  
  val result = m.map(p => if(solve(0, p)) "yes" else "no")

  print(result.mkString(f"%n") + f"%n")

}



Measured memory_bytes: 45772
// AOJ 0625: Oranges
// 2017.12.16 bal4u@uu

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

#define INF 0x3030303030303030LL
int N, M, K;
int a[20001];
long long memo[20001];
char buf[30], *p;

int in()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

long long rec(int k)
{
	int i, lim;
	long long min, max, t, ans;

	if (k >= N) return 0;
	if (memo[k] < INF) return memo[k];
	ans = INF;
	min = max = a[k];
	lim = k + M; if (lim > N) lim = N;
	for (i = k; i < lim; i++) {
		if      (max < a[i]) max = a[i];
		else if (min > a[i]) min = a[i];
		t = rec(i+1) + K + (i-k+1) * (max-min);
		if (t < ans) ans = t;
	}
	return memo[k] = ans;
}

int main()
{
	int i;

	fgets(p=buf, 30, stdin);
	N = in(), p++, M = in(), p++, K = in();
	for (i = 0; i < N; i++) {
		fgets(p=buf, 15, stdin);
		a[i] = in();
	}
	memset(memo, 0x30, sizeof(memo));
	printf("%lld\n", rec(0));
	return 0;
}

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


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string op;
  int a,b;
  while(cin >> a >> op >> b){
    TSTART();
    int ans;
    if(op == "+")ans = a+b;
    else ans = a-b;
    cout << ans << endl;
    TSTOP();
  }
    return 0;
}



Measured memory_bytes: 256
n , l = map ( int , input ( ).split ( ) ) 
lst = [i + l - 1 for i in range ( 1 , n + 1 )]
ans=1000000 
sum1=sum(lst) 
for i in lst: 
	if abs(i)<abs(ans): 
		ans=i
print(sum1-ans)   

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split().Select(long.Parse).OrderByDescending(x => x).ToArray();
            for (int i = 1; i <= r[1]; i++)
            {
                var p = r[0] * i;
                if (p % r[1] == 0)
                {
                    Console.WriteLine(p);
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 13396
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define KDNGU ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first

using namespace std;

typedef long long LL;
typedef long double LD;

const int N = 1e5 + 9, M = 1e5 + 9, OO = 0x3f3f3f, MOD = 10000007;

int heights[N], ans[N];

int main(){
    KDNGU
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> heights[i];
    for (int i = 1; i < n; ++i){
        ans[i] = abs(heights[i - 1] - heights[i]) + ans[i - 1];
        if (i > 1)
            ans[i] = min(ans[i], abs(heights[i - 2] - heights[i]) + ans[i - 2]);
    }
    cout << ans[n - 1];
}
/*
    GOOD LUCK :*
*/


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

using namespace std;
int main() {
    int N, R;
    cin >> N >> R;
    if(N >= 10) {
        cout << R << endl;
    } else {
        cout << R + (100 * (10 - N)) << endl;
    }
}

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

int main()
{
    int n;
    long long s=0;
    cin>>n;
    int A[n],B[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
        A[i]=A[i]-(i+1);
    }
    sort(A,A+n);
    if(n%2==1){
        for(int i=0;i<n;i++){
            if(i<n/2){
                s=s-A[i];
            }else if(i>n/2){
                s=s+A[i];
            }
        }
        cout<<s;
        return 0;
    }else{
         for(int i=0;i<n;i++){
            if(i<n/2){
                s=s-A[i];
            }else{
                s=s+A[i];
            }
        }
        cout<<s;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long  int
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
ll knapSack(ll W, ll wt[], ll val[], ll n) 
{ 
    ll i, w; 
    ll K[n + 1][W + 1]; 
  
    // Build table K[][] in bottom up manner 
    for (i = 0; i <= n; i++) 
    { 
        for (w = 0; w <= W; w++)
         { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
                K[i][w] = max( 
                    val[i - 1] + K[i - 1][w - wt[i - 1]], 
                    K[i - 1][w]); 
            else
                K[i][w] = K[i - 1][w]; 
        } 
    } 
  
    return K[n][W]; 
} 
void solve()
{
       ll n,W;
       cin>>n>>W;
       ll wt[n],val[n],i,j;
       for(i=0;i<n;i++)
       {
       	  cin>>wt[i]>>val[i];
       }
       ll z=knapSack(W,wt,val,n);
      cout<<z;
}
int main()
{
    fast();
    {
      solve();
    }
    return 0;
}


Measured memory_bytes: 82416
def main():
    n = int(input())
    a = list(map(int, input().split()))

    if a.count(0) >= 1:
        print(0)
        return

    res = 1
    for x in a:
        res *= x
        if (res > 10 ** 18):
            print(-1)
            return
    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 21616
#include <stdio.h>

int s[100000],n;

int binarysearch(int s[],int key)
{
	int left = 0;
	int right = n;
	int mid;
	while(left < right)
	{
		mid = (left + right) / 2;
		if(s[mid] == key) return 1;
		else if(key < s[mid])
		{
			right = mid;
		}
		else
		{
			left = mid + 1;
		}
	}
	return 0;
}

int main()
{
	int i,q,key,cnt = 0;
	
	scanf("%d",&n);
	for(i = 0; i < n; i++) scanf("%d",s + i);
	
	scanf("%d",&q);
	for(i = 0; i < q; i++)
	{
		scanf("%d",&key);
		if(binarysearch(s,key)) cnt++;
	}
	
	printf("%d\n",cnt);
	
	return 0;
}

Measured memory_bytes: 980
import java.util.Scanner;

public class Main {

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

        int ans = -1;
        if (a == 1) {
            if (b == 2) {
                ans = 3;
            } else {
                ans = 2;
            }
        } else if (a == 2) {
            if (b == 1) {
                ans = 3;
            } else {
                ans = 1;
            }
        } else {
            if (b == 1) {
                ans = 2;
            } else {
                ans = 1;
            }
        }
        System.out.println(ans);

        sc.close();
    }

}


Measured memory_bytes: 21076
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        int a = in.ni()-1, b = in.ni()-1, c = in.ni()-1, d = in.ni()-1;
        char[] s = in.ns().toCharArray();
        boolean flag = true;
        if(c < d){
            for (int i = a; i < c; i++) if(s[i]=='#'&&s[i+1]=='#') flag = false;
            for (int i = b; i < d; i++) if(s[i]=='#'&&s[i+1]=='#') flag = false;
        }else{
            boolean flag2 = false;
            for (int i = a; i < c; i++)if(s[i]=='#'&&s[i+1]=='#') flag = false;
            for (int i = b; i < d; i++) if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.') flag2 = true;
            if(s[d-1]=='.'&&s[d]=='.'&&s[d+1]=='.') flag2 = true;
            flag = flag&&flag2;
        }
        out.println(flag?"Yes":"No");
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 26580
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (isPrimeNumber(sc.nextInt())) {
                count++;
            }
        }
        System.out.println(count);
    }

    private static boolean isPrimeNumber(int num) {
        double max = Math.sqrt(num);
        for (int i = 2; i <= max; i++) {
            if (num % i == 0) return false;
        }
        return true;
    }
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  vector<ll> v(4);
  REP(i, 4) cin >> v[i];
  sort(ALL(v));

  if(v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9) cout << "YES" << endl;
  else cout << "NO" << endl; 

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define min(p,q)((p)<(q)?(p):(q))
#define PI 3.14159265358979323

void nexp(int*a,int cnt){
	int l=cnt-1,r=cnt-1;
	int t;
	while(--l>=0&&a[l]>a[l+1]);
	if(l>=0){
		while(a[l]>a[r])r--;
		t=a[l];a[l]=a[r];a[r]=t;
	}
	for(l++,r=cnt-1;l<r;l++,r--)t=a[l],a[l]=a[r],a[r]=t;
}
int x[9],y[9];
int a[10];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",x+i,y+i);
	double ans=1e100;
	for(int i=1;i<=n;i++)a[i]=i;
	for(int iiii=0;iiii<40320;iiii++){
		double arg=0,tans=0;
		for(int i=0;i<=n;i++){
			double narg=atan2(y[a[i+1]]-y[a[i]],x[a[i+1]]-x[a[i]]);
			double temp=(narg-arg)/PI*180;
			while(temp<-180)temp+=360;
			while(temp>180)temp-=360;
			tans+=fabs(temp);
			arg=narg;
		}
		ans=min(ans,tans);
		nexp(a+1,n);
	}
	printf("%f\n",ans);
}


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

int main(){
	int a, b, c, d;
	int e[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
	scanf("%d%d%d%d", &a, &b, &c, &d);
	e[a]++;
	e[b]++;
	e[c]++;
	e[d]++;
	if(e[1] == 1 && e[9] == 1 && e[7] == 1 && e[4] == 1){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
A, B, C=map(int, input().split())
K=int(input())
K1=K
ans="No"
if A >= B:
    for i in range(K1):
        K=K-1
        B=B*2
        if B > A:
            break

K2=K
if K2==0 and C > B:
    ans="Yes"

for j in range(K2):
    K=K-1
    C=C*2
    if C > B:
        ans="Yes"
        break

print(ans)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int k,n; cin>>k>>n;
  vector<int> a(n),d(n);
  for(int i=0; i<n; ++i) cin>>a[i];
  int m=0;
  for(int i=0; i<n; ++i){
    if(i<n-1) d[i]=a[i+1]-a[i]; else d[i]=k-(a[i]-a[0]);
    m=max(m,d[i]);
  }
  cout<<k-m;
  return 0;
}
  

Measured memory_bytes: 4840
N = int(input())
def inpl(): return [int(i) for i in input().split()]
ctr = [0 for _ in range(10**5+2)]
a = inpl()
for i in a:
     ctr[i] += 1
subsum = ctr[0] + ctr[1] + ctr[2]
ans = subsum
for i in range(2,10**5+1):
    subsum = subsum - ctr[i-2] + ctr[i+1]
    ans = max(ans, subsum)
print(ans)

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  bool k = false;

    
  while(c || a >= 0){
    
  	c -= b;
  	if(c <= 0){
    	k = true;
  		break;
  	}
    
   	a -= d;
    if(a <= 0){
  		break;
  	}
  }
  
  
  
  if(k){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  
  return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;

namespace ProgrammingContest
{
    class HashMap<K, V> : Dictionary<K, V>
    {
        public V this[K key]
        {
            get
            {
                V v;
                return TryGetValue(key, out v) ? v : base[key] = default(V);
            }
            set { base[key] = value; }
        }
    }

    class Program
    {
        private int N;

        private long Mod = 1000000007;

        public void Solve()
        {
            N = int.Parse(Console.ReadLine());
            var hm = new HashMap<int, int>();

            for (int i = 2; i <= N; i++)
            {
                int cpi = i;
                for (int j = 2; j * j <= cpi; j++)
                {
                    while (cpi % j == 0)
                    {
                        //Console.WriteLine($"{cpi} {j}");
                        hm[j]++;
                        cpi /= j;
                    }
                }

                //Console.WriteLine($"{cpi} {i}");
                if (cpi > 1)
                {
                    hm[cpi]++;
                }
            }

            long ans = 1;
            foreach (KeyValuePair<int, int> keyValuePair in hm)
            {
                //Console.WriteLine($"{keyValuePair.Value} {keyValuePair.Key}");
                ans *= keyValuePair.Value + 1;
                ans %= Mod;
            }

            Console.WriteLine(ans);
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 13152
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll a,b,c;
    cin >> a >> b >> c;
    cout << max((ll)0,c-(a-b)) << endl;

    return 0;
}

Measured memory_bytes: 256
def resolve():
    N = int(input())
    NList = list(str(N))
    maxA = eval("+".join(NList))
    maxA = max(maxA, eval(
        "+".join(list(str(int(NList[0]) - 1) + "9" * (len(NList) - 1)))))
    print(maxA)


resolve()


Measured memory_bytes: 9036
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll m=1e9+7;
ll lev=0;
ll n,k;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%m;
p=(p*p)%m;
k>>=1;
}
return a;
}
using namespace std;
vector<ll> v[1000000+1];
ll vis[1000000+1]={0};
void dfs(ll u,ll p,ll lev)
{
    vis[u]=lev;
for(auto x: v[u])
{
if(x!=p)
{
dfs(x,u,lev+1);
}
}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	 ll n,k;
cin>>n>>k;
if(k<=n)
{
  ll  start=0,end=n;
  ll s=0,e=0;
ll z=n-k;
while(k--)
{
 s+=start;
 e+=end;	
	start++;
	end--;
}
ll ans=e-s+1;
ans%=m;
//cout<<z;
while(z--)
{
 s+=start;
 e+=end;
 ans+=(e-s+1);
 ans%=m;
	start++;
	end--;
}
cout<<(ans+1)%m;
}
else
cout<<1;
}
}


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

int main(){
    string n;
    cin >> n;
    for (int i=0; i < 3; ++i) {
        if (n[i] == '1') n[i] = '9';
        else n[i] = '1';
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 760
#include<stdio.h>
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i, j;
	int s[2003], t[2003];
	for (i = 0; i < n; i++)
		scanf("%d", &s[i]);
	for (i = 0; i < m; i++)
		scanf("%d", &t[i]);
	long long int p = 1000000007;
	long long int dp[2003][2003];
	for (i = 0; i < 2003; i++)
		for (j = 0; j < 2003; j++)
			dp[i][j] = 0;
	for (i = 0; i < 2003; i++)
		dp[i][0] = dp[0][i] = 1;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			if (s[i] == t[j])
			{
				dp[i + 1][j + 1] += dp[i][j];
				dp[i + 1][j + 1] %= p;
			}
			dp[i + 1][j + 1] += dp[i][j + 1] + dp[i + 1][j] - dp[i][j];
			dp[i + 1][j + 1] %= p;
			if (dp[i + 1][j + 1] < 0)
				dp[i + 1][j + 1] += p;
		}
	}
	printf("%lld\n", dp[n][m]);
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int cost[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};

template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

    int A, B;
    cin >> A >> B;
    if (B % A == 0)
        cout << A + B << endl;
    else
        cout << B - A << endl;

    /*
    int N, M;
    cin >> N >> M;
    vector<int> use(10, 0);
    while (M--)
    {
        int a;
        cin >> a;
        use[a] = 1;
    }
    vector<string> dp(N + 1);
    vector<int> dig(N + 1, -1);
    dp[0] = "";
    dig[0] = 0;
    for (int i = 0; i <= N; i++)
    {
        if (dig[i] == -1)
            continue;
        for (int j = 9; j >= 1; j--)
        {
            if (!use[j])
                continue;
            int next = i + cost[j];
            if (next > N)
                continue;
            if (dig[next] > dig[i] + 1)
                continue;
            if (dig[next] == -1 || dig[next] < dig[i] + 1)
            {
                dp[next] = dp[i] + (char)('0' + j);
                dig[next] = dp[next].size();
            }
            else
            {
                dp[next] = max(dp[next], dp[i] + (char)('0' + j));
            }
        }
    }
    cout << dp[N] << endl;
*/
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        int x = 0;
        int y = 0;

        if (n % a == 0) x = n/a*b;
        else x = (n/a+1)*b;

        if (n % c == 0) y = n/c*d;
        else y = (n/c+1)*d;

        if (x > y) System.out.println(y);
        else System.out.println(x);
    }
}


Measured memory_bytes: 26368
// http://hfuji.hatenablog.jp/entry/2015/12/09/175721

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

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

// ---------------------
#define INF 922337203685477580
typedef long long ll;
vector<int> par;
vector<int> rnk; // ??±???

void init(int n) {
  par = vector<int>(n);
  rnk = vector<int>(n);
  REP(i, n) {
    par[i] = i;
    rnk[i] = 0;
  }
}
int root(int key) {
  if (par[key] == key) return key;
  return root(par[key]);
}
int same(int a, int b) {
  return root(a) == root(b);
}
void unite(int a, int b) {
  int x = root(a);
  int y = root(b);
  if (x == y) return;

  if (rnk[x] < rnk[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

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

  init(n);

  REP(_, m) {
    int a, b;
    // cin >> a >> b;
    scanf("%d %d", &a, &b);
    unite(a, b);
  }
  int q;
  cin >> q;
  REP(_, q) {
    int a, b;
    // cin >> a >> b;
    scanf("%d %d", &a, &b);
    if (same(a, b)) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }

  return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  char g[H][W];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> g[i][j];
    }
  }
  
  int r[H], c[W];
  for (int i = 0; i < H; i++) r[i] = 0;
  for (int j = 0; j < W; j++) c[j] = 0;
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (g[i][j] == '#') { r[i] = 1; c[j] = 1; }
    }
  }
  
  for (int i = 0; i < H; i++) {
    if (r[i]) {
      for(int j = 0; j < W; j++) {
        if (c[j]) cout << g[i][j];
      }
      cout << endl;
    }
  }

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		List<Integer> list=new ArrayList<Integer>();
		//Long[] array = new Long[6];
		int n = sc.nextInt();
		int m = sc.nextInt();
		for(int i=0;m>i;i++) {
			int a = sc.nextInt();
			list.add(a);
		}
		List<Integer> list_sa=new ArrayList<Integer>();
		Collections.sort(list);
		for(int i=0;m-1>i;i++) {
			list_sa.add(list.get(i+1)-list.get(i));
		}
		Collections.sort(list_sa, Collections.reverseOrder());
		//System.out.println(list_sa);
		for(int i=0;n-1>i;i++) {
			if(list_sa.size()==0) {
				System.out.println(0);
				System.exit(0);
			}
			list_sa.remove(0);
		}
		int answer=0;
		for(int i=0;list_sa.size()>i;i++) {
			answer=answer+list_sa.get(i);
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 62136