akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  int n;
  cin>>n;
  int a[n],b[n];
  vector<pair<int,int>> vec; 
  REP(i,n){
    cin>>a[i]>>b[i];
    vec.push_back(make_pair(a[i], b[i]));
  }
  sort(ALL(vec));
  int ans = (vec[n-1].first - vec[0].first + 1) + vec[n-1].second + vec[0].first - 1;
  cout<<ans<<endl;
  return 0; 
}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int n,m;cin>>n>>m;
  int c[30];
  for(int i=1;i<=m;i++)cin>>c[i];

  static int dp[50010];
  for(int t=0;t<=50000;t++)dp[t]=100000;
  dp[0]=0;

  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      if(i>=c[j]) dp[i]=min(dp[i],dp[i-c[j]]+1);
    }
  }

  cout<<dp[n]<<endl;
  return 0;
}



Measured memory_bytes: 3520
#include<stdio.h>

int main(){

 int x,y;

 while(1){ 

   scanf("%d %d",&x,&y);

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

     break;

 }
 
   

  if(x < y){

    printf("%d %d\n",x,y);

   }else{

    printf("%d %d\n",y,x);

   }

  }

return 0;

}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N = 100005;
int a[N];

#define T pii
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
int A[N];
ll sm[N];
int main(){
	int n, m, v, p;
	sd(n); sd(m); sd(v); sd(p);
	for(int i = 1; i <= n; i++){
		sd(a[i]);
		A[i] = a[i];
	}

	sort(A + 1, A + n + 1);
	for(int i = 1; i <= n; i++) sm[i] = sm[i - 1] + A[i];
	int num = 0;
	for(int i = 1; i <= n; i++){
		int t = upper_bound(A + 1, A + n + 1, a[i] + m) - A;
		int up = n + 1 - t;
		if(up >= p){
			continue;
		}
		
		t = n - p + 2;
		int V = v - p;
		if(V <= 0 || a[i] >= A[t - 1]){
			num++;
			continue;
		}

		int thresh = a[i] + m;

		int pos = upper_bound(A + 1, A + n + 1, a[i]) - A;

		ll rem = max(0LL, sm[t - 1] - sm[pos - 1]);
		int cnt = max(0, t - pos);
		V -= pos - 2;
		if(V <= 0){
			num++;
			continue;
		}

		if(thresh * 1ll * cnt - rem >= V * (ll) m) num++;
	}
	printf("%lld\n", num);
}

Measured memory_bytes: 1792
use std::io::Read;
use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let k: usize = iterator.next().unwrap().parse().unwrap();

    let mut queue: VecDeque<usize> = VecDeque::new();
    for i in 1..10 {
        queue.push_back(i)
    }

    let mut ans: usize = 0;
    for _ in 0..k {
        ans = queue.pop_front().unwrap();

        let last = ans % 10;
        if last != 0 {
            queue.push_back(ans * 10 + last - 1);
        }
        queue.push_back(ans * 10 + last);
        if last != 9 {
            queue.push_back(ans * 10 + last + 1);
        }
    }

    return ans.to_string()
}


Measured memory_bytes: 6396
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
	int key;
	Node *prev, *next;
};

Node *nil;//番兵

Node* listSearch(int key) {
	Node *cur = nil->next;
	while (cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}

void init() {
	nil = (Node *)malloc(sizeof(Node));//mallocは指定したサイズのメモリを動的に確保する標準ライブラリ
	nil->prev = nil;
	nil->next = nil;
}

void printList() {
	Node *cur = nil->next;
	int isf = 0;
	while (1) {
		if (cur == nil) break;//curが番兵と一致するまで処理し続ける
		if (isf++ > 0)printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t) {
	if (t == nil)return;//tが番兵の場合は処理しない
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);//freeは必要のなくなったメモリを解放する標準ライブラリ
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void insert(int key) {//リストを連結する
	Node* x = (Node*)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main() {
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for (i = 0; i < n; i++) {
		scanf("%s%d", com, &key);//cinよりscanfの方が高速
		if (com[0] == 'i') { insert(key); np++; size++; }
		else if (com[0] == 'd') {
			if (strlen(com) > 6) {
				if (com[6] == 'F')deleteFirst();
				else if (com[6] == 'L') deleteLast();
			}
			else {
				deleteKey(key);
				nd++;
			}
			size--;//削除したから大きさを-1している
		}
	}

	printList();

	return 0;
}



Measured memory_bytes: 33852
#pragma GCC optimize("O3")

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rep2(i,a,n) for(ll i=a;i<(n);++i)
#define repr(i,n) for(ll i=n;i>=0; --i)
#define repr2(i,a,n) for(ll i=n;i>=a; --i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define VEC(v) vector<v >

#define INT(...) int __VA_ARGS__;IN(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;IN(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;IN(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;IN(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;IN(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;IN(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;IN(__VA_ARGS__)

int scan(){ return getchar(); }
void scan(int& a){ cin>>a; }
void scan(long long& a){ cin>>a; }
void scan(char &a){cin>>a;}
void scan(double &a){ cin>>a; }
void scan(long double& a){ cin>>a; }
void scan(char a[]){ scanf("%s", a); }
void scan(string& a){ cin >> a; }
template<class T> void scan(vector<T>&);
template<class T, size_t size> void scan(array<T, size>&);
template<class T, class L> void scan(pair<T, L>&);
template<class T, size_t size> void scan(T(&)[size]);
template<class T> void scan(vector<T>& a){ for(auto& i : a) scan(i); }
template<class T> void scan(deque<T>& a){ for(auto& i : a) scan(i); }
template<class T, size_t size> void scan(array<T, size>& a){ for(auto& i : a) scan(i); }
template<class T, class L> void scan(pair<T, L>& p){ scan(p.first); scan(p.second); }
template<class T, size_t size> void scan(T (&a)[size]){ for(auto& i : a) scan(i); }
template<class T> void scan(T& a){ cin >> a; }

void IN(){}
template <class Head, class... Tail> void IN(Head& head, Tail&... tail){ scan(head); IN(tail...); }

int in() {int x;cin>>x;return x;}
ll llin() {unsigned long long x;cin>>x;return x;}

#define ios cin.tie(NULL), ios_base::sync_with_stdio(false)
#define cfs(n) cout<<fixed<<setprecision((n))
#define endl '\n'
#define ret return 0

constexpr ll mod=998244353;
constexpr ll mod2=10e9+7;
const double PI = 3.1415926535897932384626433832795028841971; //acos(-1)

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
// endmacro

int main(){
  ios; cfs(15);
  STR(a,b);

  const int SIZE = a.size();
  int cnt = 0;
  for(int i=0; i<SIZE; ++i) 
  {
    if(a[i] != b[i])
      ++cnt;
  }
  cout << cnt << endl;
  ret;
}

Measured memory_bytes: 3788
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    cin >> n;
    int sum = 0;
    int mx=-1;
    rep(i,n){
        int x;
        cin >> x;
        sum += x;
        mx = max(mx,x);
    }
    cout << sum-mx/2 << endl;
}

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

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

    int n;
    cin >> n;
    vector<long long> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    vector<long long> B(n, 0);
    B[0] = A[0];
    for(int i = 1; i < n; i++){
        B[i] = B[i - 1] + A[i];
    }

    long long mi = 1e18;
    for(int i = 0; i < n; i++){
        mi = min(mi, abs(B[n - 1] - 2 * B[i]));
    }

    cout << mi << endl;

    return 0;
}

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

typedef long long ll;
#define f(i,n) for(int i=0;i<n;i++)
ll n,d;
bool chd(ll x,ll y)
{
    ll x_sq=x*x;
    ll y_sq=y*y;
    if((x_sq+y_sq)<=(d*d)) return true;
    else return false;
}

int main()
{
    ll count=0;
    cin>>n>>d;
    while(n--)
    {
        ll x,y;
        cin>>x>>y;
        if(chd(x,y)) count++;
    }
    cout<<count;
}

Measured memory_bytes: 3616
import queue
def main():
    n, m = map(int, input().split())
    G = [[] for _ in range(n+1)]
    par = [None]*(n+1)
    cnt = [0]*(n+1)
    for _ in range(n-1+m):
        a, b = map(int, input().split())
        G[a].append(b)
        cnt[b] += 1
    p = -1
    for i in range(1, n+1):
        if cnt[i] == 0:
            p = i
            break
    par[p] = 0
    q = queue.Queue()
    q.put(p)
    t = [0]*(n+1)
    while not q.empty():
        x = q.get()
        for v in G[x]:
            t[v] += 1
            if t[v] == cnt[v]:
                q.put(v)
            par[v] = x
    for ans in par[1:]:
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 22864
#include <iostream>

using namespace std;

int main(){
    int N, flg;
    cin >> N;
    int D1[N] = {0};
    int D2[N] = {0};

    for (int i = 0; i < N; i++){
        cin >> D1[i] >> D2[i];
    }

    flg = 0;
    for (int i = 0; i < N - 1; i++){
        if (D1[i] == D2[i]){
            if ((D1[i+1] == D2[i+1]) && (D1[i+2] == D2[i+2])){
                cout << "Yes" << endl;
                flg++;
                break;
            }
        }
    }

    if(flg != 1){
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3616
package main

import (
	"fmt"
	"sort"
)

// Ary ...
type Ary []int

func (a Ary) Len() int {
	return len(a)
}

func (a Ary) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (a Ary) Less(i, j int) bool {
	return a[i] < a[j]
}

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	// fmt.Printf("a = %d, b = %d, c = %d\n", a, b, c)

	var ary Ary
	ary = append(ary, a)
	ary = append(ary, b)
	ary = append(ary, c)

	sort.Sort(ary)
	// fmt.Printf("sorted ary = %v\n", ary)

	var tmp, types int
	for _, a := range ary {
		if tmp != a {
			types++
		}
		tmp = a
	}
	fmt.Println(types)
}


Measured memory_bytes: 512
n = int(input())
lst = [int(x) for x in input().split()]

num = sum(lst)//n
sum1 = 0
sum2 = 0

for i in lst:
  sum1 += (i-num)**2
  sum2 += (i-num-1)**2
  
if sum1 < sum2:
  print(sum1)
else:
  print(sum2)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 200005

int cnt;
bool vis[N];
vector<int>G[N];

void dfs(int u){
   vis[u]=1,cnt++;
   for(int v:G[u]){
      if(!vis[v]) dfs(v);
   }
}

int main ()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n,m;cin>>n>>m;
   for(int i=1;i<=m;i++){
      int u,v;cin>>u>>v;
      G[u].pb(v);
      G[v].pb(u);
   }
   int ans=0;
   for(int i=1;i<=n;i++){
      if(!vis[i]){
         cnt=0,dfs(i);
         ans=max(ans,cnt);
      }
   }
   cout<<ans<<"\n";
   return 0;
}



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

int main() {
  string s, t; cin >> s >> t;
  
  bool found = false;
  string ans;
  
  for (int i = s.size() - t.size(); i >= 0; i--) {
    if (s[i] == t[0] || s[i] == '?') {
      found = true; 
      ans = s; 
      ans[i] = t[0];
      for (int j = 1; j < t.size(); j++) {
        if (ans[i + j] == '?') {
          ans[i + j] = t[j];
        } else {  
          if (ans[i + j] != t[j]) {
            found = false;
            break;
          }
        }
      }
      if (found) break;
    }
  }
  
  for (int i = 0; i < ans.size(); i++) if (ans[i] == '?') ans[i] = 'a';
  
  if (found) cout << ans << endl;
  else cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
X, K, D = map(int, input().split())

# 移動できる距離の max は KD

if abs(X) >= K*D:
    ans = abs(X) - K*D
else:
    if (K - X//D)%2 == 0:
        ans = X%D
    else:
        ans = X%D - D
    ans = abs(ans)

print(ans)

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

int main(void)
{
  int A, B, i;
  char S[11], T[11], U[11];
  
  scanf("%s %s", S, T);
  scanf("%d %d", &A, &B);
  scanf("%s", U);
  
  for (i = 0; i < 11; i++)
  {
    if (S[i] != U[i])
    {
      B = B - 1;
      break;
    }
    if (T[i] != U[i])
    {
      A = A - 1;
      break;
    }
  }
  
  printf("%d %d\n", A, B);
  return 0;
}

Measured memory_bytes: 128
n,x = gets.split.map(&:to_i)

a = gets.split.map(&:to_i)
b = a.dup

(n-1).times do |nn|
  # p nn
  if b[nn] + b[nn+1] > x
    b[nn+1] = x - b[nn]
    if b[nn+1] < 0
      b[nn] += b[nn+1]
      b[nn+1] = 0
    end
  end
end
p a.inject(:+) - b.inject(:+)

Measured memory_bytes: 9348
import sys
import numpy as np
import numba
from numba import jit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main(n, a):
  cnt = 0
  for i, j in enumerate(a):
    if i+1 == a[j-1]:
      cnt+=1
  return cnt//2

n = int(readline())
a = np.array(readline().split(), np.int64)
print(main(n,a))

Measured memory_bytes: 97832
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N;
    cin >> N;
    if (N < 1000) {
        cout << "ABC" << endl;
    } else {
        cout << "ABD" << endl;
    }
}


Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)
ans=[-1]*n
ans[0]=0
print('Yes')
d=deque([0])
while d:
  now=d.pop()
  for x in l[now]:
    if ans[x]<0:
      ans[x]=now
      d.appendleft(x)
for i in range(1,n):
  print(ans[i]+1)

Measured memory_bytes: 34072
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a[n];
	for (int i = 0 ; i < n ; i++) cin >> a[i];
	sort(a, a + n);
	cout << a[n - 1] - a[0];
}


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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); ++i)
    if (s[i] == '2') ans++;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int N, K;
    scanf("%d%d", &N, &K);
    int arr[N];
    for(int i=0;i<N;i++){
        scanf("%d", &arr[i]);
    }

    for(int j=0;j<N-K;j++){
        if(arr[j]<arr[j+K]){
            printf("Yes\n");
      } else {
            printf("No\n");
        }
    }

    return 0;
}

Measured memory_bytes: 3940
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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


Measured memory_bytes: 3576
use std::io;

fn main() {
  let mut buf = String::new();
  io::stdin().read_line(&mut buf).unwrap();
  let s: Vec<&str> = buf.split_whitespace().collect();
  let x: u32 = s[0].parse().unwrap();
  let y: u32 = s[1].parse().unwrap();
  let z: u32 = s[2].parse().unwrap();
  println!("{}", (x - z) / (y + z));
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
int main() {
	int n, ans = 100000;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		int cnt = 0;
		while (a % 2 == 0) {
			a /= 2;
			cnt++;
		}
		if (cnt < ans)ans = cnt;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//                          VIVEK UPADHYAY
//                         MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                         TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl ;
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 1e5+ 10 ;
const int MAX = 1e7 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;
int x[] = {1,1,1,-1,-1,-1,0,0};
int y[] = {0,1,-1,0,-1,1,1,-1};
int main() {
    int N ;
    cin >> N ;
    int A , B ;
    cin >> A >> B ;
    if(N==1) cout<<"Hello World\n" ;
    else cout<<A+B<<endl;
    return  0 ;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    static List<Long> list = new ArrayList<>();
    static List<Long> out = new ArrayList<>();
    
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long K = sc.nextLong();

        dfs(list);

        Collections.sort(out);
        
        System.out.println(out.get((int) (K-1)));
        

    }
    
    static void dfs(List<Long> list){
        //終了条件
        if(list.size()==10){
            //終了時に実施する処理はこちら
            return;
        }
        else{
        //再帰呼び出し処理 
            long from = ((list.size()==0) ? 1 : Math.max((list.get(list.size()-1)-1),0));
            long to = ((list.size()==0) ? 9 : Math.min((list.get(list.size()-1)+1),9));

            for(long i=from;i<=to;i++){
                list.add(i);
                String st="";
                for(long j=0;j<=list.size()-1;j++){
                    st = st + Long.toString(list.get((int) j));    
                }
                long k = Long.parseLong(st);
                out.add(k);
                dfs(list);
                list.remove(list.size()-1);
            }
        }
    }    
}





Measured memory_bytes: 141188
fun main(args: Array<String>) {
    val s = readLine()!!
    val array = LongArray(s.length + 1)
    for (i in 0 .. s.lastIndex) {
        if (s[i] == '<') {
            array[i + 1] = Math.max(array[i] + 1, array[i + 1])
        }
    }
    // array.forEachIndexed { i, v ->
    //     if (i < s.length) {
    //         print("$v ${s[i]} ")
    //     } else {
    //         println("$v")
    //     }
    // }

    for (i in s.lastIndex downTo 0) {
        if (s[i] == '>') {
            array[i] = Math.max(array[i], array[i + 1] + 1)
        }
    }
    // array.forEachIndexed { i, v ->
    //     if (i < s.length) {
    //         print("$v ${s[i]} ")
    //     } else {
    //         println("$v")
    //     }
    // }
    println(array.sum())
}



Measured memory_bytes: 41892
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int ans;
int main()
{
	string a;
	cin>>a;
	int k=a.length();
	for(int i=0;i<k;i++)
	{
		if(a[i]=='C'&&ans==0)
		ans=1;
		if(a[i]=='F'&&ans==1)
		ans=2;
	}
	if(ans==2)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    v_string s(3); 
    string ans("ABC");

    irep(i, 3) {
        cin >> s[i];
    }
    int start = 0;
    while(1) {
        if(s[start].empty()) { 
            cout << ans[start] << endl;
            return 0;
        } 
        char top = s[start][0];
        s[start] = s[start].substr(1);
        if(top == 'a') { 
           start = 0;
        } else if(top == 'b') {
           start = 1;
        } else {
           start = 2;
        }
    }

    return 0;
}
/** atcoder **/


Measured memory_bytes: 256
/*
    ASEEN AAN 
            PINDAN AALE JATT!!!
                                */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1000000007;   
lli INF=1e17;
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,q,z,x,y,k,m;
const double pi1=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
//lli tot=0;
vector<lli> pf(string s) {
    int n = (int)s.length();
    vector<lli> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//map<ll,lli> dp;
//set<lli> s[100005];
lli dp[100005];
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>k;
    lli a[n+1];
    for(int i=1;i<=n;i++)
    cin>>a[i];
    mem1(dp,1e17);
    dp[1]=0;
    for(lli i=2;i<=n;i++)
    {
        for(int j=1;j<min(i,k+1);j++)
        {
            dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
        }
    }
    cout<<dp[n];
}

Measured memory_bytes: 1792
n,m = map(int, input().split())
nums = {}
flg = False
for i in range(m):
    key,val = input().split()
    if (key in nums.keys() and val != nums[key]) or (n > 1 and key == "1" and val == "0"):
        flg = True
        break
    else:
        nums[key] = val

if flg:
    print(-1)
else:
    output = ""
    for i in range(1, n + 1):
        if i == 1 and n > 1:
            nums.setdefault(str(i), "1")
        else: 
            nums.setdefault(str(i), "0")
        output = output + nums.get(str(i))
    print(output)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


template<class Type>
Type solve(Type res = Type()){
    int A,B; cin >> A >> B;
    if(A*B%2 == 0) return "No";
    else return "Yes";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    //test();
    //solve<ll>();
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}



Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long array[];
		array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = Long.parseLong(sc.next());
		}

		BigInteger sum = BigInteger.ZERO;
		BigInteger tate = BigInteger.ZERO;
		BigInteger yoko = BigInteger.ZERO;
		for (int i = 0; i < n - 1; i++) {
			tate = tate.add(BigInteger.valueOf(array[i]));
			yoko = BigInteger.valueOf(array[i + 1]);
			sum = sum.add(tate.multiply(yoko));
		}

		sum = sum.remainder(BigInteger.valueOf(1000000007));

		System.out.println(sum);

	}
}


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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	int n;
	cin >> n;
	vector<pair<int, int>> V(n);
	for (int i = 0; i < n; ++i)
		cin >> V[i].s >> V[i].f;
	sort(V.rbegin(), V.rend());
	int time = V[0].f;
	for (int i = 0; i < n; ++i)
	{
		time = min(time, V[i].f);
		time -= V[i].s;
		if (time < 0)
		{
			cout << "No";
			return;
		}
	}
	cout << "Yes";
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

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



int main(){
    int A,B;
    cin>>A>>B;
    int res=0;
    for(int i=A;i<=B;i++){
        string num=to_string(i);
        string num1=num;
        reverse(num.begin(),num.end());
        if(num1==num)res+=1;
    }
    printf("%d",res);
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	char b;
	cin >> b;
	if (b == 'A') cout << "T" << endl;
	if (b == 'T') cout << "A" << endl;
	if (b == 'C') cout << "G" << endl;
	if (b == 'G') cout << "C" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }

    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
    }
}

class Program
{
    static int Gcd(int a, int b)
    {
        if (a < b){ return Gcd(b, a); }
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    public static void Main()
    {
        int n = int.Parse(ReadLine());
        var a = ReadIntArray();

        int x = a[0];
        for (int i = 1; i < n; i++)
        {
            x = Gcd(x, a[i]);
        }

        WriteLine(x);
    }
}


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

int main() {
    int n;
    cin >> n;
    string ans = "No";
    rep(i, 10)rep(j, 10) {
        if (i * j == n) ans = "Yes";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll N,Q,x,i;scanf("%lld%lld",&N,&Q);
  ll a[N+1];a[N] = -1;
  for(i=0;i<N;i++) scanf("%lld",&a[i]);
  ll l,r,sum,ans;
  for(i=0;i<Q;i++){
    scanf("%lld",&x);
    l = 0;r = 0;sum = 0;ans = 0;
    while(r <= N){
      if(sum <= x){
        ans += r-l;
        sum += a[r];r++;
      } else {
        sum -= a[l];l++;
      }
    }
    printf("%lld\n",ans);
  }
}


Measured memory_bytes: 3976
N = int(input())
A = list(map(int, input().split()))
A.sort()

def isOk(n):
    now = sum(A[:n + 1])
    for a in A[n + 1:]:
        if a <= now * 2:
            now += a
        else:
            return False
    return True

ok = N - 1
ng = -1

while ok - ng > 1:
    mid = (ok + ng) // 2

    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(N - (ng + 1))

Measured memory_bytes: 14304
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	ll int data[200001];
	int n;
	cin >> n;
	REP(i,n) cin >> data[i];
	ll int prev = 999999999;
	ll int ans = -999999999;
	REP(i,n-1){
		if(prev<data[i]) continue;
		FOR(j,i+1,n){
			ans = max(ans,data[j]-data[i]);
		}
		prev = data[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2724
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define sz(a) int((a).size())
//use brackets before operations if taking MOD
//use map only when necessary
//give long long to arrays and variables properly
int mul(int a, int b,int mod = MOD) {
	return int(a * 1ll * b % mod);
}
int norm(int a,int mod = MOD) {
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
	//a = (a%mod+mod)%mod;
	return a;
}
int powmod(int x,int y,int mod = MOD){
	int res = 1;
	while(y>0)
	{
		if(y&1)
			res = mul(res,x,mod);
		x = mul(x,x,mod);
		y=y>>1;
	}
	return res;
}
int inv(int a,int mod = MOD) {
	return powmod(a, mod - 2);
}

int main() {



	int n,d; cin>>n>>d;
	int v[n][d];
	for(int i = 0;i<n;i++)
	{
		for(int j = 0;j<d;j++)
		{
			cin>>v[i][j];
		}
	}
	int ans = 0;
	for(int i = 0;i<n;i++)
	{
		for(int j = i+1;j<n;j++)
		{
			ll res = 0;
			for(int k = 0;k<d;k++)
			{
				res += (v[i][k] - v[j][k])*(v[i][k] - v[j][k]);
			}
			long long sq = sqrt((long double)res);
			if( (sq*sq) == res)
			{
				ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}

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

int main() {
  int a,b;
  cin >> a >>b;
  if(a%3==0 || b%3==0 || (a+b)%3==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  
  
  
}

Measured memory_bytes: 3628
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

alias Dist = Tuple!(int, "n", int, "d");

Dist[][100_001] DS;
int[100_001] NS;
bool[100_001] BS;

void main()
{
    int N, M, L, R, D;
    readf("%d %d", &N, &M);
    foreach (i; 1..M+1) {
        readf(" %d %d %d", &L, &R, &D);
        DS[L] ~= Dist(R, D);
        DS[R] ~= Dist(L, -D);
    }

    bool check(int i, int org, int d) {
        if (!BS[i]) {
            BS[i] = true;
            NS[i] = NS[org] + d;
        } else if (NS[i] != NS[org] + d) return false;

        while (!DS[i].empty) {
            auto head = DS[i][0];
            DS[i] = DS[i][1..$];
            if (head.n != org && !check(head.n, i, head.d)) return false;
        }
        return true;
    }

    for (int start = 1; start <= N; ++start) {
        if (BS[start]) continue;
        if (!DS[start].empty && !check(start, 0, 0)) {
            writeln("No");
            return;
        }
    }
    writeln("Yes");
}

Measured memory_bytes: 26108
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	string s; cin >> s;
	int maxx = 0;
	int x = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I')x++;
		else if (s[i] == 'D')x--;
		maxx = max(maxx, x);
	}
	cout << maxx << endl;
	char c; cin >> c;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    int i,m,f,r;
    char cGrade;
    for (i=0;i<50;i++){
        cin >> m >> f >>r;
        if (m==-1 && f==-1 && r==-1){
            break;
        }
        
        if (m==-1 || f==-1){
            cGrade='F';
        }else{
            if (m+f>=80){
                cGrade='A';
            }else{
                if (m+f>=65){
                    cGrade='B';
                }else{
                    if (m+f>=50){
                        cGrade='C';
                    }else{
                        if (m+f>=30){
                            if (r>=50){
                                cGrade='C';
                            }else{
                                cGrade='D';
                            }
                            
                        }else{
                            cGrade='F';
                        }
                    }
                }
            }
        }
        cout << cGrade << endl;
    }
}


Measured memory_bytes: 3084
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long LL;
int main()
{
    LL x;
    LL cnt =0;
    LL m = 100;
    scanf("%lld",&x);
    while(m<x)
    {
        cnt++;
        m+=m*0.01;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3764
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//stdout<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll N,K;
    cin >>N>>K;
    ll ans=0;
    //-----------------------------------
    for(ll i=K;i<=N+1;i++){
        ans+= (i*(N*2-i+1)/2 - (i-1)*i/2 +1)%mod;
        ans%=mod;
    }


    cout << ans <<endl;


    return (0);
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  vi x(3), y(3);
  rep (i, 3) cin >> x[i] >> y[i];

  double t = 0;
  vector<double> a(3);
  rep (i, 3) {
    int x1 = x[i], x2 = x[(i + 1) % 3], y1 = y[i], y2 = y[(i + 1) % 3];
    x2 -= x1; y2 -= y1;
    double dist = sqrt(x2 * x2 + y2 * y2);
    chmax(t, dist);
    a[i] = dist;
  }

  double s = abs((x[1] - x[0]) * (y[2] - y[0]) - (x[2] - x[0]) * (y[1] - y[0])) / 2.0;
  double r = 2 * s / (a[0] + a[1] + a[2]);

  double ans = t / (2 + t / r);
  Sp(ans);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n, sum;
	cin >> n;
	int t[105];
	for(int i = 1; i <= n; i++)
	{
		cin >> t[i];
	}
	int m;
	cin >> m;
	int p[105], x[105];
	for(int i = 1; i <= m; i++)
	{
		cin >> p[i] >> x[i];
	}
	for(int i = 1; i <= m ; i++)
	{
		sum = 0;
		for(int j = 1; j <= n; j++)
		{
			if(j == p[i])
			{
				sum += x[i];
				continue;
			}
			else
			sum += t[j];
		}
		cout << sum << endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using Graph = vector<vector<ll>>;

int main(){
  int n;cin>>n;
  map<int,int> mp;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    int a;cin >> a;
    sum += a;
    mp[a]++;
  }
  int q;cin>>q;
  for (int i = 0; i < q; i++) {
    int b,c;cin>>b>>c;
    int diff = c - b;
    int num = mp[b];
    mp[c] += mp[b];
    mp[b] = 0;
    sum += num*diff;
    cout << sum << endl;
  }

}

Measured memory_bytes: 8064
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int i,n,c=0,temp=10000000;
    cin>>n;
    int a;
    for(i=0;i<n;i++)
    {
        cin>>a;
        if(a<=temp)
        {
            c++;
            temp = a;
        }
    }
    cout<<c<<endl;

}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func floatSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	x, y := iScan(), iScan()
	ans := 0
	f := make([]int, x+1)
	f[0] = 1
	inv := make([]int, x+1)
	inv[0] = 1
	for i := 1; i < x+1; i++ {
		f[i] = f[i-1] * i % mod
		inv[i] = modinv(f[i], mod)
	}
	for i := 0; i*2 <= x; i++ {
		j := x - i*2
		if i+j*2 == y {
			ans += f[i+j] * inv[i] % mod * inv[j] % mod
			ans %= mod
		}
	}
	fmt.Println(ans)
}
func modinv(a, m int) int {
	b, u, v := m, 1, 0
	for {
		t := a / b
		a -= t * b
		u -= t * v
		a, b, u, v = b, a, v, u
		if b == 0 {
			break
		}
	}
	u %= m
	if u < 0 {
		u += m
	}
	return u
}


Measured memory_bytes: 17972