akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;
typedef unsigned long long ull;

ull PickLargestMinimumPiece(const ull _total_size, const ull _piece1_s, const ull _piece1_l, const ull _piece3_s, const ull _piece3_l){
	ull tmp = min(_piece1_s, _piece3_s);
	
	ull piece2 = _total_size - _piece1_s - _piece3_l;
	tmp = max(tmp, min(_piece1_s, piece2));

	piece2 = _total_size - _piece1_l - _piece3_s;
	tmp = max(tmp, min(_piece3_s, piece2));

	piece2 = _total_size - _piece1_l - _piece3_l;
	tmp = max(tmp, piece2);

	return tmp;
}

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

	int N;	//切れ込みの個数
	cin >> N;

	int *A = new int[N];	//各ピースの大きさを格納する配列
	ull total_size = 0;	//バームクーヘンの大きさ
	int i1_ini = 0;
	int A_max = 0;
	for(int i=0; i<N; i++){
		cin >> A[i];
		total_size += A[i];
		if (A[i] > A_max){
			A_max = A[i];
			i1_ini = i;
		}
	}
	ull one_third_size = total_size / 3;
	ull answer = 0;
	if (A_max > one_third_size){
		ull half_size = (total_size - A_max) / 2;
		ull tmp = 0;
		ull piece2 = 0;
		for (int i3 = i1_ini + 1; i3 < i1_ini + N - 1; i3++){
			piece2 = tmp;
			tmp += A[i3%N];
			if (tmp > half_size) break;
		}
		ull piece3 = total_size - A_max - tmp;
		answer = max(piece2, piece3);
		cout << answer << endl;
		delete[] A;
		return 0;
	}

	int i2 = i1_ini;
	ull piece1_s = 0;
	ull piece1_l = 0;
	for (; i2 < i1_ini + N - 2;){
		piece1_s = piece1_l;
		piece1_l += A[i2%N];
		i2++;
		if (piece1_l > one_third_size) break;
	}
	const int i1_fin = i2;

	int i3 = i1_ini + N;
	ull piece3_s = 0;
	ull piece3_l = 0;
	for (; i3 > i2 + 1;){
		piece3_s = piece3_l;
		i3--;
		piece3_l += A[i3%N];
		if (piece3_l > one_third_size) break;
	}
	i3++;

	/*ull tmp = 0;
	tmp = min(piece1_s, piece3_s);
	
	ull piece2 = 0;
	piece2 = total_size - piece1_s - piece3_l;
	tmp = max(tmp, min(piece1_s, piece2));

	piece2 = total_size - piece1_l - piece3_s;
	tmp = max(tmp, min(piece3_s, piece2));

	piece2 = total_size - piece1_l - piece3_l;
	tmp = max(tmp, piece2);

	answer = tmp;*/
	answer = PickLargestMinimumPiece(total_size, piece1_s, piece1_l, piece3_s, piece3_l);

	for (int i1 = i1_ini + 1; i1 < i1_fin; i1++){
		int A_tmp = A[(i1 - 1) % N];
		piece1_l -= A_tmp;
		if (piece1_l > one_third_size) piece1_s -= A_tmp;
		else{
			for (; i2 < i1 + N - 2;){
				piece1_s = piece1_l;
				piece1_l += A[i2%N];
				i2++;
				if (piece1_l > one_third_size) break;
			}
		}

		piece3_s += A_tmp;
		if (piece3_s <= one_third_size) piece3_l += A_tmp;
		else{
			for (; i3 < i1 + N - 1;){
				piece3_l = piece3_s;
				piece3_s -= A[i3%N];
				i3++;
				if (piece3_s <= one_third_size) break;
			}
		}

		/*tmp = min(piece1_s, piece3_s);

		piece2 = total_size - piece1_s - piece3_l;
		tmp = max(tmp, min(piece1_s, piece2));

		piece2 = total_size - piece1_l - piece3_s;
		tmp = max(tmp, min(piece3_s, piece2));

		piece2 = total_size - piece1_l - piece3_l;
		tmp = max(tmp, piece2);

		answer = max(answer, tmp);*/
		answer = max(answer, PickLargestMinimumPiece(total_size, piece1_s, piece1_l, piece3_s, piece3_l));
	}

	cout << answer << endl;

	delete[] A;

	return 0;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

//OJ freopen Template
void OJF(const char* inp, const char* out) {
	 freopen(inp, "r", stdin);
	 freopen(out, "w", stdout);
}

signed main()
{
	//OJF("*.inp", "*.out");
	fastio();
	int r; cin >> r;
	cout << r * r;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    cout << n*(n-1)/2+m*(m-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n;
    cin >> n;
    vll vec(n);
    REP(i, n) cin >> vec.at(i);
    sort(ALL(vec));
    cout << vec.at(vec.size()-1) - vec.at(0) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int i = 1;
        
        while(true){
            int line = Integer.parseInt(br.readLine());
            if(line == 0){
                break;
            }
            
            System.out.println("Case " + i + ": " + line);
            i++;
        }
    }
}

Measured memory_bytes: 31980
def main():
    s = input()
    K = int(input())
    r = set()
    for i in range(97, 97 + 26):
        for j, v in enumerate(s):
            if v == chr(i):
                for k in range(5):
                    r.add(s[j:j+k+1])
        if len(r) > 5:
            break
    l = list(r)
    l.sort()
    return l[K-1]
print(main())


Measured memory_bytes: 3060
import java.lang.IllegalArgumentException
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val op = sc.next()
    val b = sc.nextInt()
    println(answer050aAlt(a, op, b))
}

fun answer050aAlt(a: Int, op: String, b: Int): Int {
    return when (op) {
        "+" -> a + b
        "-" -> a - b
        else -> throw IllegalArgumentException()
    }
}

Measured memory_bytes: 29472
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;

int main() {
	int K, X;
	cin >> K >> X;
	if (K * 500 >= X) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll gcd (ll a,ll b){
    return b ? gcd(b,a%b) : a;
}
main(){
    int a;
    cin >> a;
    cout << 2 * a / gcd(2,a) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(){
    int n;
	cin>>n;
	if(n>81){
	cout<<"No";
	return 0;
}
 	for(int i=9;i>0;i--){
	if(n%i==0 && n/i<10){
	cout<<"Yes";
	return 0;
}
}
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let A = read::<i32>();
    let B = read::<i32>();
    let C = read::<i32>();

    if A == B {
        println!("{}", C);
    } else if B == C {
        println!("{}", A);
    } else {
        println!("{}", B);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

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


const int BIG_NUM = 1e8;

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

	vector<vector<int>> book(n, vector<int>(m + 1));

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m + 1; j++) {
			cin >> book[i][j];
		}
	}


	int ans = BIG_NUM;
	for (int b = 0; b < (1 << n); b++) {
		vector<int> a(m);
		int cost = 0;
		for (int i = 0; i < n; i++) {
			if (((b >> i) & 1) == 1) {
				for (int j = 0; j < m; j++) {
					a[j] += book[i][j + 1];
				}

				cost += book[i][0];

				
			}
			
			
		}
		


		bool canAchieve = true;
		for (int i = 0; i < m; i++) {
			if (a[i] < x) {
				canAchieve = false;
			}
		}


		
		if (!canAchieve) {
			continue;
		}

		

		ans = min(ans, cost);
	}

	if (ans == BIG_NUM) {
		ans = -1;
	}

	cout << ans << endl;


}

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

int main() {
  int n ,k ;
  string s;
  cin >> n >> k >> s;
  if( s.at(k-1) == 'A'){
    s.at(k-1) = 'a';
  }
  else if ( s.at(k-1) == 'B'){
    s.at(k-1) ='b';
  }
  else{
    s.at(k-1) = 'c';
  }
  cout << s ;
      
}

Measured memory_bytes: 256
using System;
class Program
{
  static void Main(string[] args)
  {
    // 入力値を取得
    string[] input = Console.ReadLine().Split(' ');
    int n = int.Parse(input[0]);
    int k = int.Parse(input[1]);
    int q = int.Parse(input[2]);
    
    // 初期値
    int[] points = new int[n];
    for (int i = 0; i < n; i++) {
      points[i] = k -q;
    }
    
    // ラウンド中のポイント設定
    for (int j = 0; j < q; j++) {
      int winner = int.Parse(Console.ReadLine()) - 1;
      points[winner]++;
    }
    
    // 出力
    for (int m = 0; m < n; m++) {
      Console.WriteLine(points[m] <= 0 ? "No" : "Yes");
    }
  }
}


Measured memory_bytes: 17600
N = int(input())
h = [int(i) for i in input().split()]

dp = [0] * N

for i in range(1, N):
    if i - 2 < 0:
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
    else:
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),
                    dp[i-2] + abs(h[i] - h[i-2]))

print(dp[-1])


Measured memory_bytes: 13980
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A,B,K;
  cin>>A>>B>>K;
  if(B-A+1<=2*K){
    FOR(i,A,B+1){
      cout<<i<<endl;
    }
    return 0;
  }
  FOR(i,A,A+K){
      cout<<i<<endl;
    }
  FOR(i,B-K+1,B+1){
      cout<<i<<endl;
    }

 
}
  





Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n,a,b;
	scanf("%d", &n);
	scanf("%d", &a);
	scanf("%d", &b);
	
	int i,j,k;
	int total_digit,total_number = 0;
	
	for(i=0; i<=n; i++){
		total_digit = 0;
		j = 10000;
		k = i;
		while(j>0){
			if(k/j > 0){
				total_digit = total_digit + k/j;
				k = k - k/j*j;
			}
			j = j/10;
		}
		if(total_digit>=a && total_digit<=b)
			total_number = total_number + i;
	}
	
	printf("%d", total_number);
	return 0;
}


Measured memory_bytes: 128
N = int(input())
H = list(map(int, input().split()))

dp = [0]

for i, x in enumerate(H):
  if i == 0:
    continue
  elif i == 1:
    dp.append( abs(H[i] - H[i-1]) )
  else:
    dp.append( min( dp[i-2] + abs(H[i] - H[i-2]) , dp[i-1] + abs(H[i] - H[i-1]) ) )

print(dp[-1])

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

int main() {
  int a[10];
  for(int i=0;i<10;i++){
    cin >> a[i];
  }

  sort(a, a+10);

  for(int i=9;i>6;i--){
    cout << a[i] << endl;
  }

  return 0;
}



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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int N;
    string s;
    cin >> N >> s;
    cout << (count(begin(s), end(s), 'R') > count(begin(s), end(s), 'B') ? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
map<P, bool> mp1, mp2;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, N;
    cin >> H >> W >> N;
    int a[100010], b[100010];
    rep(i, N) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        mp1[{a[i], b[i]}] = true;
    }
    int ans[10] = {};
    int checked = 0;
    rep(i, N) {
        rep(j, 3) {
            rep(k, 3) {
                int xx = a[i] + j - 1;
                int yy = b[i] + k - 1;
                if (xx <= 0 || xx >= H - 1) continue;
                if (yy <= 0 || yy >= W - 1) continue;
                if (mp2[{xx, yy}]) continue;
                mp2[{xx, yy}] = true;
                checked++;
                int cnt = 0;
                rep(s, 3) {
                    rep(t, 3) {
                        if (mp1[{xx + s - 1, yy + t - 1}]) cnt++;
                    }
                }
                //cout << xx << " " << yy << " " << cnt << endl;
                ans[cnt]++;
            }
        }
    }
    cout << (H - 2) * (W - 2) - checked << endl;
    rep(i, 9) {
        cout << ans[i + 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 214400
///
// File:  b.cpp
// Author: ymiyamoto
//
// Created on Sat Dec 23 21:43:58 2017
//

#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

int32_t main()
{
  int32_t N, A, B;
  cin >> N >> A >> B;

  int32_t num = 0;
  for (int32_t i = 1; i <= N; i++) {
    int32_t total = 0;
    string str = to_string(i);
    for (auto c : str) {
      total += c - '0';
    }
    if (A <= total && total <= B) {
      num += i;
    }
  }

  cout << num << endl;

  return 0;
}


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

void Main() {
  int n;
  cin >> n;
  long long a[n + 1], b[n];
  for (int i = 0; i < n + 1; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }

  long long ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i + 1] > b[i]) {
      ans += b[i];
      b[i] = 0;
    } else {
      ans += a[i + 1];
      b[i] -= a[i + 1];
    }
    ans += min(b[i], a[i]);
    a[i] = max(a[i] - b[i], (long long)0);
  }

  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

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

int main() {
  int N;
  string s;
  cin >> N >> s;

  int R_right = 0;
  int W_left = 0;
  for (int i = 0; i < N; i++) {
   if (s[i] == 'R') R_right++;
  }

  int b = 0;
  int min_ans = N;
  for (int i = 0; i < N + 1; i++) {
    min_ans = min(min_ans, max(R_right, W_left));
    if (i == N) continue;
    if (s[i] == 'R')
      R_right -= 1;
    else
      W_left += 1;
  }

  cout << min_ans << endl;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
int n,A[100001];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	A[1]--;
	for(int i=2;i<=n;i++){
		if(A[i]<A[i-1]){
			puts("No");
			return 0;
		}
		if(A[i]>A[i-1])A[i]--;
	}
	puts("Yes");
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
constexpr ll infl = 1ll<<60;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin>>n;
    cout << (n-1)/2 << endl;
    return 0;
}



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

using namespace std;

int main()
{
    int a, b, h, m, a0, b0;
    long double ang, ana, a1, d;
    cin >> a >> b >> h >> m;
    ang = (long double)(h + (long double)m / 60) * 30;
    a1 = (long double)m * 6;
    ana = fabs(ang - a1);
    a0 = a * a;
    b0 = b * b;
    d = (long double)(a0 + b0 - 2 * a * b * cos(ana / 57.2957795131));
    d = sqrt(d);
    printf("%0.12Lf\n", d);
}

Measured memory_bytes: 4152
n = int(input())
li = list(map(int,input().split()))
for i in range(n-1):
  if li[n-2-i] - li[n-1-i] == 1:
    li[n-2-i] = li[n-2-i] - 1
if li == sorted(li):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14396
n = int(input())
meals = list(map(int, input().split()))
suts = list(map(int, input().split()))
add_suts = list(map(int, input().split()))

total = 0
pre = None
for meal in meals:
    total += suts[meal-1]
    if pre is not None and pre + 1 == meal:
        total += add_suts[pre-1]
    pre = meal
print(total)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string S;
    cin >> N >> S;

    int64_t R=0, G=0, B=0;
    for (int i = 0; i < N; i++)
    {
        if(S.at(i) == 'R') R++;
        else if(S.at(i) == 'G') G++;
        else B++;
    }
    int64_t total = R*G*B;
    for (int i = 0; i < N; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            int k = 2*j - i;
            if(k >= N) continue;
            if(S.at(i) != S.at(j) && S.at(j) != S.at(k) && S.at(k) != S.at(i)) total--;
        }
        
    }
    cout << total << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define inf 6830885930
#define sc(a) scanf("%d",&a)
#define scc(a,b) scanf("%d %d",&a,&b)
#define sccc(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pff(a,b) printf("%d %d",a,b)
#define pfff(a,b,c) printf("%d %d %d",a,b,c)
#define pb(a) push_back(a)
#define em empty()
#define fr front()
#define cl clear()
#define sz size()
#define mp(a,b) make_pair(a,b)
#define fri(b) freopen(b,"r",stdin)
#define fro(b) freopen(b,"w",stdout)
/*
ID: uslusam1
TASK: test
LANG: C++
*/
 
 
using namespace std;

long long mod=(long long)1e9+7;

long long n,m;

char mat[1013][1013];
long long arr[1013][1013];
 
int main(){
	//fri(".in");
	//fro(".out");
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			char ch;
			cin>>ch;
			mat[i][j]=ch;
		}
	}
	for(int i=1;i<=n;i++){
		if(mat[i][1]=='.'){
			arr[i][1]=1;
		}
		else{
			break;
		}
	}
	for(int i=1;i<=m;i++){
		if(mat[1][i]=='.'){
			arr[1][i]=1;
		}
		else{
			break;
		}
	}
	for(int i=2;i<=n;i++){
		for(int j=2;j<=m;j++){
			if(mat[i][j]=='.'){
				arr[i][j]=arr[i-1][j]+arr[i][j-1];
				arr[i][j]%=mod;
			}
		}
	}
	cout<<arr[n][m]<<endl;
	
	
	return 0;
}


Measured memory_bytes: 9216
#include<iostream>
#include<vector>
using namespace std;
#define ll long long

//色々計算する用
int C[26],last2[26],T[365],Tans[365],V[365],Vorigin[365];
int S[365][26],last[365][26],last_sim[365][26];
int D,vmax,dadd_best,steps=0;

//リセット用の関数S
void R26(int A[26]){
    for(int i=0;i<26;++i)A[i]=0;
}

void R365(int A[365]){
    for(int i=0;i<365;++i)A[i]=0;
}

void R365_26(int A[365][26]){
    for(int i=0;i<365;++i)for(int j=0;j<26;++j)A[i][j]=0;
}

void copy26(int A[26],int B[26]){
    for(int i=0;i<26;++i)A[i]=B[i];
}

void copy365(int A[365],int B[365]){
    for(int i=0;i<365;++i)A[i]=B[i];
}

void copy365_26(int A[365][26],int B[365][26]){
    for(int i=0;i<365;++i)for(int j=0;j<26;++j)A[i][j]=B[i][j];
}

void greedy(){
    int dadd,i,j,k,l,i_calc,tbest,score,vbest;
    for(dadd=0;dadd<=26;++dadd){
        //リセット
        R26(last2);
        R365_26(last);

        for(i=0;i<D;++i){
            i_calc=min(i+dadd+1,D);
            for(j=0;j<26;++j){
                //得点の初期化
                if(i==0){
                    V[i]=0;
                }else{
                    V[i]=V[i-1];
                }
                
                //lastの初期化
                if(i==0)R26(last[i]);
                else copy26(last[i],last[i-1]);

                last[i][j]=i+1;
                V[i]+=S[i][j];

                for(k=0;k<26;++k)
                    for(l=i;l<i_calc;l++)V[i]-=C[k]*(l+1-last[i][k]);

                if(j==0||V[i]>=vmax){
                    vmax=V[i];
                    tbest=j;
                }
            }
            if(i==0)R26(last[i]);
            else copy26(last[i],last[i-1]);
            T[i]=tbest+1;
            last[i][tbest]=i+1;
        }

        //得点の再計算
        score=0;
        R26(last2);

        for(i=0;i<D;++i){
            score+=S[i][T[i]-1];
            last2[T[i]-1]=i+1;
            for(j=0;j<26;j++)score-=C[j]*(i+1-last2[j]);
        }

        if(dadd==0||(dadd!=0 && score>vbest)){
            dadd_best=dadd;
            vbest=score;
            copy365(Tans,T);
            copy365_26(last_sim,last);
        }
    }

    vmax=vbest;
    copy365(T,Tans);
    copy365_26(last,last_sim);
}

int main(){
    int i,j;
    cin>>D;
    for(i=0;i<26;++i)scanf("%d",&C[i]);
    for(i=0;i<D;++i)for(j=0;j<26;++j)scanf("%d",&S[i][j]);

    //初期解の生成    
    greedy();

    for(i=0;i<D;++i)printf("%d\n",T[i]);
    return 0;
}


Measured memory_bytes: 3368
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	int a;
	int b;
	int c;
	char input[15];
	
	fgets(input, sizeof(input), stdin);
	a = atoi(strtok(input, " "));
	b = atoi(strtok(NULL, " "));
	c = atoi(strtok(NULL, " "));
	
	if (a < b && b < c){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

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

bool is_palindrome(string s) {
  for(int i = 0; i < s.size() / 2; ++i) {
    if(s[i] != s[s.size() - i - 1]) {
      return false;
    }
  }
  return true;
}

int main() {
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for(int i = A; i <= B; ++i) {
    if(is_palindrome(to_string(i))) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

void we_r_done(){cout<<"NO"; exit(0);}

void debug(string mssg){cout<<mssg; exit(0);}


int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

        lli r,d,x;
        cin>>r>>d>>x;


    for(int i=1; i<=10; i++){
         x = r*x - d;
        printf("%lld\n",x);
    }

    return 0;
    ///return main();
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///priority_queue< int, vector< int >, greater< int > > minHeap;
///using bs = bitset<MX>; // how many distinct number can be form?


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

using namespace std;

int main(){
    int s;
    cin>>s;
    set<int> hoge;
    int ans=0;
    
    while(true){
        ans++;
        int before=hoge.size();
        hoge.insert(s);
        if(hoge.size()==before){
            cout<<ans<<endl;
            break;
        }
        
        if(s%2==0) s/=2;
        else s=3*s+1;
    }
    
    return 0;
}

Measured memory_bytes: 256
import itertools
import math

n = int(input())

xy = []

for _ in range(n):
    xy.append(tuple(map(int,input().split())))

ans = 0

per = itertools.permutations(range(n))

for p in per:
    x1,y1 = xy[p[0]]
    dif_tmp = 0
    for i in range(1,len(p)):
        x2,y2 = xy[p[i]]
        dif_tmp += ((x1-x2)**2 + (y1-y2)**2)**0.5
        x1,y1 = x2,y2

    ans += dif_tmp

ans /= math.factorial(n)
print(ans)

Measured memory_bytes: 41324
#include<stdio.h>
int main(){
  int a,b,c,i,j;

  j=0;

  scanf("%d%d%d",&a,&b,&c);

  for( i=a; i<=b; i++ ){

    if( c%i==0 ){
      j++;
    }

  }

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

  return 0;

}

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

using namespace std;
typedef long long ll;

int main() {
    int h,w;
    int mass[2000][2000];
    queue<int> wque[2000];
    queue<int> hque[2000];
    cin >> h >> w;
    for(int i=0;i<h;i++){
      string s;
      cin >> s;
      for(int j=0; j<w; j++){
        if(s[j]=='#'){
          wque[i].push(j);
          hque[j].push(i);
        }
      }
      wque[i].push(w);
    }
    for(int j=0; j<w;j++){
      hque[j].push(h);
    }

    int light[2001][2001];
    for(int i=0;i<h;i++){
      int start = -1;
      while(wque[i].size()){
        int end = wque[i].front();
        wque[i].pop();
        for(int j=start+1; j<end;j++){
          light[i][j]=end-start-1;
        }
        light[i][end]=0;
        start = end;
      }
    }
    int max = 0;
    for(int j=0;j<w;j++){
      int start = -1;
      while(hque[j].size()){
        int end = hque[j].front();
        hque[j].pop();
        for(int i=start+1; i<end;i++){
          light[i][j]+=end-start-1-1;
          if(light[i][j]>max)max =light[i][j];
        }
        light[end][j]=0;
        start = end;
      }
    }


    cout << max<<endl;

  return 0;
}


Measured memory_bytes: 51328
//
//  main.cpp
//  zoj2853
//
//  Created by cfhaiteeh on 14/03/2018.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define  LL long long

using namespace  std;
struct Matrix{
    LL  mat[4][4];
};
int n,m,k;
LL A,B,C,K;
Matrix MUL(Matrix a,Matrix b){
    Matrix c;
    memset(c.mat,0,sizeof(c.mat));
    for(int i=1;i<=3;i++){
        for(int j=1;j<=3;j++){
            for(int k=1;k<=3;k++){
                c.mat[i][j]=(c.mat[i][j]+a.mat[i][k]*b.mat[k][j]);
            }
        }
    }
    return c;
}
bool flag;
Matrix poww(Matrix a,LL k){
    Matrix ans;
    memset(ans.mat,0,sizeof(ans.mat));
    for(int i=1;i<=3;i++)ans.mat[i][i]=1;
    while(k!=0){
        if(k%2==1){
            ans=MUL(ans,a);
            LL p1=B*ans.mat[2][1]+C*ans.mat[3][1];
            LL p2=A*ans.mat[1][2]+C*ans.mat[3][2];
            LL cc=abs(p1-p2);
            if(cc>1000000000000000000LL){
                flag=0;
                return ans;
            }
        }
        a=MUL(a,a);
        k/=2;
    }
    return ans;
}
Matrix a;
LL ai[234];
double ci[234];
void init(){
    memset(a.mat,0,sizeof(a.mat));
    ai[1]=A;
    ai[2]=B;
    ai[3]=C;
    
 
}
double ans;
void play(){
    memset(a.mat,0,sizeof(a.mat));
    a.mat[2][1]=1;
    a.mat[3][1]=1;
    a.mat[1][2]=1;
    a.mat[3][2]=1;
    a.mat[1][3]=1;
    a.mat[2][3]=1;
    flag=1;
    Matrix c=poww(a,K);
    if(K==0){
        printf("%lld\n",A-B);
        return;
    }
    if(!flag){
        printf("Unfair\n");
    }
    else{   LL p1=B*c.mat[2][1]+C*c.mat[3][1];
        LL p2=A*c.mat[1][2]+C*c.mat[3][2];
      //  cout<<B<<" "<<C<<" "<<K<<endl;
       // cout<<p1<<" "<<p2<<endl;
        LL cc=(p1-p2);
        printf("%lld\n",cc);
        
    }
}
void pri(){
    //printf("%.0f\n",ans);
}
int main() {
    // insert code here...
  //  LL t=1000000000000000000
    while(scanf("%lld%lld%lld%lld",&A,&B,&C,&K)!=EOF){
        
        if(K%2==0)printf("%lld",A-B);
        else printf("%lld\n",B-A);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> prime;
void sieve(int n){
  vector<bool> is_prime(n, 1);
  prime.push_back(1);
  for (int i = 2; i <= n; i++) {
    if(is_prime[i] == false)continue;
    prime.push_back(i);
    for (int j = i; j <= n; j+=i) is_prime[j] = false;
  }
}

int main(int argc, char *argv[]){
  sieve((int)1e7 + 100);
  int n;
  while(std::cin >> n, n){
    int start = upper_bound(prime.begin(), prime.end(), n) -
      prime.begin();
    start--;
    // std::cout << "n:" << n << std::endl;
    // std::cout << "start:" << start << std::endl;
    // std::cout << "prime:" << prime[start] << std::endl;
    for (int i = start; i >= 0; i--) {
      int a = prime[i];
      if(prime[i - 1] == a - 2 &&
         prime[i - 2] == a - 6 &&
         prime[i - 3] == a - 8){
        std::cout << prime[i] << std::endl;
        break;
      }
    }
    //std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 6544
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

void solve()
{
    ll h = nxt(), w = nxt();

    vector <string> v(h);

    for(ll i=0; i<h; i++)
    {
        cin >> v[i];
    }

    vector <vector<ll>> dp(h, vector<ll> (w, (ll)1e15));

    for(ll i=0; i<h; i++)
    {
        for(ll j=0; j<w; j++)
        {
            if(!i && !j)
            {
                dp[i][j] = (v[i][j] == '#');
            }

            else
            {
                if(i)
                {
                    dp[i][j] = min(dp[i][j], dp[i-1][j] + (v[i-1][j] == '.' && v[i][j] == '#'));
                }

                if(j)
                {
                    dp[i][j] = min(dp[i][j], dp[i][j-1] + (v[i][j-1] == '.' && v[i][j] == '#'));
                }
            }
        }
    }

    cout << dp[h-1][w-1] << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define moder 1000000007
#define inf 10000000000000007
#define vsort(vec) sort(vec.begin(),vec.end())
#define vreverse(vec) reverse(vec.begin(),vec.end())
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

string s;
int a[100010], b[100010], c[100010], ta = 1;
int dp[100010][3];

signed main() {
	cin >> s;
	for (int i = 1; i <= s.size(); i++) {
		if (s[i - 1] == 'A') {
			a[i] = a[i - 1] + ta;
			b[i] = b[i - 1];
			c[i] = c[i - 1];
		}
		else if (s[i - 1] == 'B') {
			a[i] = a[i - 1];
			b[i] = b[i - 1] + a[i - 1];
			c[i] = c[i - 1];
		}
		else if (s[i - 1] == 'C') {
			a[i] = a[i - 1];
			b[i] = b[i - 1];
			c[i] = c[i - 1] + b[i - 1];
		}
		else {
			a[i] = a[i - 1] * 3 + ta;
			b[i] = b[i - 1] * 3 + a[i - 1];
			c[i] = c[i - 1] * 3 + b[i - 1];
			ta *= 3;
		}
		ta %= mod;
		a[i] %= mod;
		b[i] %= mod;
		c[i] %= mod;
	}
	cout << c[s.size()] << endl;
	ggr
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> x(n + 1);
    int memo;
    for (int i = 2; i <= n; i++)
    {
        memo = i;
        for (int j = 2; j <= memo; j++)
        {
            if (memo % j == 0)
            {
                memo /= j;
                x.at(j)++;
                j--;
            }
        }
    }
/*
    for(int i=1;i<=n;i++){
        cout<<i<<" "<<x.at(i)<<endl;
    }
*/
    ll ans = 1;
    for (int i = 1; i <= n; i++)
    {
        ans *= (x.at(i) + 1) % 1000000007;
        ans %= 1000000007;
    }
    cout << ans << endl;
}


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

int main() {
  ll rw=0;
  ll re=0;
  int n;string s;
  cin >>n>>s;
  rep(i,n) {
    if(s[i]=='E')re++;
    else rw++;
  }
  ll lw=0;
  ll le=0;
  ll ans=1e9;
  rep(i,n) {
    if(s[i]=='E') re--;
    else rw--;
    ans=min(ans,lw+re);
    if(s[i]=='E') le++;
    else lw++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) (x.size())
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define isOdd(n)    (n&1)
#define pow(n, m) (ll)powl(n, m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define clr(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE
#define MOD 1000000007
#define EPS 1e-7


typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<ll> vi;


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("test cases\\in.txt", "r", stdin);
    //freopen("test cases\\in.txt", "w", stdout);

    const int N  = 1e5 + 5;
    int n; cin >> n;
    ll a[n], sum = 0, f[N] = {};
    for(auto &i: a) cin >> i, sum += i, f[i]++;
    int q; cin >> q;
    while(q--){
        int b, c; cin >> b >> c;
        if(f[b]){
            sum += f[b]*c;
            sum -= f[b]*b;
            f[c] += f[b];
            f[b] = 0;
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 5204
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
//change null_type here for map/set
typedef tree<int,null_type,less<int>,rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;
typedef long long int  ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define F first
#define S second

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    x*=sgn; return ~c;
}
///START HERE
///indexed_set pbd;
//pbd.insert()
//auto x = pbd.find_by_order(2);
//int od=pbd.order_of_key(7)
///rope<int> rp;
//rp.push_back()
//RandomAccess like vector
//mutable_begin, mutable_end()

int main(){
    ///read()+printf
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //fast;
    ll n;
    cin>>n;
    ll ar[n],cnt[112345];
    mem(cnt,0);
    ll s=0;
    for(ll i=0;i<n;i++){
        cin>>ar[i];
        cnt[ar[i]]++;
        s+=ar[i];
    }
    ll q;
    cin>>q;
    while(q--){
        ll a,b;
        cin>>a>>b;
        s-=cnt[a]*a;
        s+=cnt[a]*b;
        cnt[b]+=cnt[a];
        cnt[a]=0;
            cout<<s<<endl;

    }



    return 0;
}


Measured memory_bytes: 5292
#!/usr/bin/env python3


M = 26


def conv_char(n, c):
    return chr(ord('A') + (ord(c) - ord('A') + n) % M)


def convert(n, s):
    return "".join(conv_char(n, c) for c in s)


def main():
    n = int(input())
    s = input()
    t = convert(n, s)
    print(t)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
function main(input) {
  const args = input.split(' ').map(n => parseInt(n, 10));
  
  const A = args[0];
  const B = args[1];
  const C = args[2];
  const D = args[3];
  
  if (Math.max(A, C) > Math.min(B,D)) {
    console.log(0);
  } else {
    console.log(Math.min(B, D) - Math.max(A, C));
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29544
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

const int P = 2019;

int main() {
    string S; cin >> S;

    vector<ll> mods(P, 0);
    ll ans = 0, cur = 0, coef = 1;

    mods[cur]++;
    REP(i, 0, S.size()) {
        cur = (cur + coef * (S[S.size() - i - 1] - '0') % P) % P;
        coef = coef * 10 % P;
        mods[cur]++;
    }

    REP(i, 0, P) {
        ans += mods[i] * (mods[i] - 1) / 2;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // input K X
        // X - K + 1 ～ X + K - 1 の値を連続して出力する。
        Scanner sc = new Scanner(System.in);
        int numK = sc.nextInt();
        int numX = sc.nextInt();
        int initNum = numX - numK + 1;
        String retStr = "" + initNum;
        for(int i = initNum + 1; i < numX + numK; i++){
            retStr = retStr + " " + i;
        }
        System.out.println(retStr);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define endl "\n"
#define fo for(int i=0;i<n;i++)
#define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define loopSolve int t; cin>>t; while(t--){solve();}
//INT_MAX         2,147,483,647                       <10^10
//U_INT_MAX       4,294,967,295                       <10^10
//LONG_LONG_MAX   9,223,372,036,854,775,807           <10^18
//U_LONG_LONG_MAX 18,446,744,073,709,551,615          <10^18
//ll power(int a, int b){
//    return (ll)(pow(a,b)+0.5);
//}

vector<int> gV(int n){
    vector<int> v(n);
    int input;
    fo { cin>>v[i];  }
    return v;
}

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}


void solve(){
    int l,r,d,ans=0;
    cin>>l>>r>>d;
    for(int i=l;i<=r;i++){
        if(i%d==0)
            ans++;
    }
    cout<<ans<<endl;

}


int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    //loopSolve;

	return 0;
}


Measured memory_bytes: 3616
def msm(s)
  seed = s
  Proc.new do
    sq = (seed*seed).to_s
    sq = "0" + sq until 8 <= sq.size
    seed = sq[2,4].to_i
  end
end

n = gets.to_i
n.times do |i|
  s = gets.to_i
  _msm = msm(s)
  puts "Case #{i+1}:"
  10.times { puts _msm.call }
end

Measured memory_bytes: 6096
// A.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	int c[3];
	cin >> c[0] >> c[1] >> c[2];
	sort(c, c + 3);
	cout << ((c[0] + c[1] == c[2]) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int (i)=1;(i)<(n);(i)++)
using namespace std;

int main() {
	long long N = 0;
	long long re = 0;
	cin >> N;
	rep(i, N+1) {
		re = re + i;
	}
	re = re - N;
	cout << re << endl;
	return 0;
}

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

int main(){
  int N;cin>>N;
  vector<string> S(N);
  for(int i=0;i<N;i++) cin>>S.at(i);
  int c0=0,c1=0,c2=0,c3=0;
  for(int j=0;j<N;j++){
    if(S.at(j)=="AC") c0++;
    else if(S.at(j)=="WA") c1++;
    else if(S.at(j)=="TLE") c2++;
    else c3++;
  }
  cout<<"AC x "<<c0<<endl;
  cout<<"WA x "<<c1<<endl;
  cout<<"TLE x "<<c2<<endl;
  cout<<"RE x "<<c3<<endl;
}

Measured memory_bytes: 6360
import sys

N=int(input())

if N==1:
    print("Yes")
    print(2)
    print(1,1)
    print(1,1)
    sys.exit()

#N<x*(x+1)/2
U=N #True
L=0 #False
flag=False

while U-L>1:
    x=(U+L)//2
    if N==x*(x+1)//2:
        print("Yes")
        flag=True
        break
    elif N<x*(x+1)//2:
        U=x
    else:
        L=x
        
if not flag: print("No")
else:
    print(x+1)
    
    data=[[0]*x for _ in range(x+1)]
    for i in range(x):
        data[0][i]=i+1
    head=x+1
    for i in range(1,x+1):
        for j in range(i):
            data[i][j]=data[j][i-1]
        for j in range(i,x):
            data[i][j]=head
            head+=1
            
    for i in range(x+1):
        print(x,end=' ')
        for d in data[i][:-1]:
            print(d,end=' ')
        print(data[i][-1])

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

int main(int argc, char const *argv[]) {
    long long x;
    cin >> x;

    int n_500 = x / 500;
    int n_5 = (x - n_500 * 500) / 5;
    int ans = n_500 * 1000 + n_5 * 5;

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


Measured memory_bytes: 3600
#include <algorithm>
#include <string>
#include <math.h>
#include <iostream>
using namespace std;

int main()
{
    int N;
    cin >> N;
    
    bool flag = false;
    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 50; j++) {
            int sum = i * 4 + j * 7;
            if (sum == N) {
                flag = true;
                break;
            }
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

# 集合Sと補集合を対応 → 空、全体を除くと完全に対応
# 和がsum(A)/2)以上での最小値

import numpy as np

N = int(input())
A = [int(x) for x in input().split()]

S = sum(A)

dp = np.zeros(S+1,dtype=np.bool)
dp[S] = 1
for a in A:
    dp[:-a] |= dp[a:]

answer = np.nonzero(dp[(S+1)//2:])[0][0] + (S+1)//2
print(answer)



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



signed main(){
    int n;
    cin >> n;
    double ans=0;
    double x;
    string s;
    for(int i=0;i<n;i++){
        cin >> x>>s;
        if(s=="JPY")ans+=x;
        else ans+= x*380000.0;
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mms(x) memset(x,0,sizeof(x))
#define mmc(x,y) memcpy(x,y,sizeof(y))
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;

const int N=100005;

int n,m,a,b,c,col[N];
VI e[N];
ll ans;
bool fl;

void dfs(int x){
	for(int v:e[x])
		if(!col[v])col[v]=3-col[x],dfs(v);else fl&=col[x]+col[v]==3;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;i++)scanf("%d%d",&u,&v),e[u].pb(v),e[v].pb(u); 
	for(int u=1;u<=n;u++)if(!col[u]){
		col[u]=1;
		if(!e[u].size())a++;else{
			fl=true;dfs(u);
			if(fl)b++;else c++;
		}
	}
	ans=(ll)a*(2*n-a)+(ll)b*b*2+(ll)c*c+(ll)b*c*2;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,m,l=0,r=inf;
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		l=max(l,x);
		r=min(r,y);
	}
	cout << max(ll(0),r-l+1);
	return 0;
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    d = {}
    for _ in range(n):
        a, b = input().split()
        d[a] = b
    tmp = [input().strip() for _ in range(int(input()))]
    ans = [d[a] if a in d.keys() else a for a in tmp]
    print("".join(ans))

Measured memory_bytes: 9404
k = 34
K = 1<<k
nu = lambda L: int("".join([bin(K+a)[-k:] for a in L[::-1]]), 2)
st = lambda n: bin(n)[2:] + "0"
li = lambda s: [int(a, 2) if len(a) else 0 for a in [s[-(i+1)*k-1:-i*k-1] for i in range(len(B)*2-1)]]

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [0] * 100001
for a in A:
    B[a] += 1
C = li(st(nu(B) ** 2))
ans = 0
for i in range(200001)[::-1]:
    a = min(M, C[i])
    M -= a
    ans += a * i
print(ans)

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

int main()
{
    //freopen("input.txt", "r", stdin);
    int n;
    cin>>n;
    int mina = 1000000;
    for(int i = 1; i<n; i++){
        int a = 0;
        int pow10 = 1;
        for(int j = 0; j<7; j++){
            a+=((i/pow10)%10);
            a+=(((n-i)/pow10)%10);
            pow10*=10;
        }
        mina = min(a, mina);
    }
    cout<<mina;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main() {
	
	int N, C, t = 0;

	cin >> N >> C;

	int *P = new int[C];

	for (int i = 0; i < C; i++) {
		cin >> P[i];
		t += P[i];
	}

	if (t / (N + 1) == 0 || t == N + 1)
		cout << "1\n";

	if (t > N + 1) {

		if (t % (N + 1))
			cout << t / (N + 1) + 1 << "\n";

		else
			cout <<  t / (N + 1) << "\n";

	}

	delete P;
	P = NULL;

	return 0;

}



Measured memory_bytes: 3104
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.LinkedHashMap

object Main extends App {
  Iterator.continually(readInt).takeWhile(_!=0).foreach { n =>
    val map = new LinkedHashMap[Long, Long]

    for(i<-1 to n) {
      val e = readLine.split(" ").map(_.toLong)
      if(!map.contains(e(0))) map += e(0) -> e(1)*e(2)
      else map(e(0)) += e(1)*e(2)
    }

    val filtered = map.filter( _._2 >= 1000000 )
    if(filtered.isEmpty) println("NA") else filtered.foreach( e => println(e._1))
  }
}

Measured memory_bytes: 45412