akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N;
	long[][] memo;
	long MOD = 1000000007;

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		// 0: 0と9を双方含む
		// 1: 0のみ含む
		// 2: 9のみ含む
		// 3: 0と9を双方含まない
		memo = new long[N][4];

		// 初期化
		memo[0][0] = 0;
		memo[0][1] = 1;
		memo[0][2] = 1;
		memo[0][3] = 8;
	}

	void calc() {
		for (int i = 1; i < N; ++i) {
			memo[i][0] = (memo[i - 1][0] * 10 + memo[i - 1][1] + memo[i - 1][2]) % MOD;
			memo[i][1] = (memo[i - 1][1] * 9 + memo[i - 1][3]) % MOD;
			memo[i][2] = (memo[i - 1][2] * 9 + memo[i - 1][3]) % MOD;
			memo[i][3] = (memo[i - 1][3] * 8) % MOD;
		}
	}

	void showResult() {
		System.out.println(memo[N - 1][0]);
	}
}

Measured memory_bytes: 93220
#include <iostream>
using namespace std;
typedef long long ll;
 
int h, w, k;
ll memoa[101][8];
 
ll row(int n){
    if(n <= 0){
        return 1;
    }
    if(n == 1){
        return 2;
    }
    return row(n - 2) + row(n - 1);
}
 
ll count(int t, int l){
    if(t == 0){
        if(l == 0){
            return 1;
        }
        else{
            return 0;
        }
    }
    if(l < 0 || l >= w){
        return 0;
    }
    if(memoa[t][l] != 0){
        return memoa[t][l];
    }
    return memoa[t][l] = (count(t - 1, l - 1) * row(l - 2) * row(w - l - 2) + count(t - 1, l) * row(l - 1) * row(w - l - 2) + count(t - 1, l + 1) * row(l - 1) * row(w - l - 3)) % 1000000007;
}
 
int main()
{
    cin >> h >> w >> k;
    for(int i = 0; i <= h; i++){
        for(int j = 0; j < w; j++){
            memoa[i][j] = 0;
        }
    }
    cout << count(h, k - 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
map<pair<int,int>,int> cnt;
int par[200005][2];
int find(int x,int i)
{
	if (par[x][i]!=x)
	par[x][i]=find(par[x][i],i);
	return par[x][i];
}
void Union(int x,int y,int i)
{
	x=find(x,i);
	y=find(y,i);
	if (x!=y)
	par[x][i]=y;
}
int main()
{
	int n,k,l;
	scanf("%d%d%d",&n,&k,&l);
	for (int i=1;i<=n;i++)
	{
		par[i][0]=i;
		par[i][1]=i;
	}
	while (k--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		Union(a,b,0);
	}
	while (l--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		Union(a,b,1);
	}
	for (int i=1;i<=n;i++)
	cnt[{find(i,0),find(i,1)}]++;
	for (int i=1;i<=n;i++)
	printf("%d ",cnt[{find(i,0),find(i,1)}]);
}

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

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

    int n;
    cin >> n;
    long long tmp;
    long long sum = 0;
    map<long long, int> a;
    a[0] = 1;
    for (int i = 0; i < n; ++i) {
        cin >> tmp;
        sum += tmp;
        a[sum]++;
    }

    long long res = 0;
    for (auto &e : a) {
        res += (long long) (e.second - 1) * e.second / 2;
    }

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;
int main()
{
  ll A, B, C, K; cin >> A >> B >> C >> K;
  if (A >= K) {
  	cout << K << endl;
  } else  if (A + B >= K) {
  	cout << A << endl;
  } else  {
  	cout << 2 * A - K + B<< endl;
  }
}

Measured memory_bytes: 3596
A = []
ans = 0

def merge(left, mid, right):
	global A
	global ans
	n1 = mid - left
	n2 = right - mid
	l = []
	r = []
	for i in range(n1):
		l += [A[left + i]]
	for i in range(n2):
		r += [A[mid + i]]
	l += [10**18]
	r += [10**18]
	i = 0
	j = 0
	ans += right - left
	for k in range(left, right):
		if l[i] <= r[j]:
			A[k] = l[i]
			i += 1
		else:
			A[k] = r[j]
			j += 1


def Msort(left, right):
	if left + 1 < right:
		mid = int((left + right)/2)
		Msort(left, mid)
		Msort(mid,right)
		merge(left,mid,right)

def main():
	global ans
	global A
	n = int(input())
	A = list(map(int,input().split()))
	Msort(0,n)
	print(" ".join(list(map(str,A))))
	print(ans)

main()


Measured memory_bytes: 66784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(all(a), greater<ll>());
  ll ans = 0;
  rep(i, n - 2) rep2(j, i + 1, n - 1) {
    ll l = j, r = n;
    while(l + 1 < r) {
      ll x = (l + r) / 2;
      if(a[x] > a[i] - a[j])
        l = x;
      else
        r = x;
    }
    ans += l - j;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  while(cin >> N && N){
    vector<int> v1(N);
    vector<int> v2(N);
    REP(i, N) cin >> v1[i];
    REP(i, N) cin >> v2[i];
    sort(v1.begin(), v1.end());
    reverse(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    bool NA = true;
    for(int i = 0; i < N - 1; i++){
      int cnt = lower_bound(v2.begin(), v2.end(), v1[i]) - v2.begin();
      cnt = v2.size() - cnt;
      if((i + 1) - cnt > (i + 1) / 2){
        cout << (i + 1) << endl;
        NA = false;
        break;
      }
    }
    if(NA) cout << "NA" << endl;
  }
  return 0;
}

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

int main() {
    string x, y;
    cin >> x >> y;
    y[y.length() - 1] = 0;
    for (int i = 0; i < y.length(); i++) {
        if (y[i] == x[i]) {
            if (i == y.length() - 1){
                cout << "Yes";
            }else {
                continue;  
            }
        } else {
            cout << "No";
            break;
        }
    }
    
}

Measured memory_bytes: 3556
import java.util.*;

public class Main {
    static int[] colors;
    static ArrayList<Path>[] graph;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		graph = new ArrayList[n + 1];
		for (int i = 1; i <= n; i++) {
		    graph[i] = new ArrayList<Path>();
		}
		for (int i = 0; i < n - 1; i++) {
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int length = sc.nextInt();
		    graph[a].add(new Path(b, length));
		    graph[b].add(new Path(a, length));
		}
		colors = new int[n + 1];
		Arrays.fill(colors, -1);
		search(1, 0);
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= n; i++) {
		    System.out.println(colors[i]);
		}
		
	}
	
	static void search(int idx, int color) {
	    if (colors[idx] != -1) {
	        return;
	    }
	    colors[idx] = color;
	    for (Path x : graph[idx]) {
	        int next;
	        if (x.length % 2 == 0) {
	            next = color;
	        } else {
	            next = (1 + color) % 2;
	        }
	        search(x.to, next);
	    }
	}
	
	static class Path {
	    int to;
	    int length;
	    
	    public Path (int to, int length) {
	        this.to = to;
	        this.length = length;
	    }
	}
}


Measured memory_bytes: 115652
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <iostream>
using namespace std;
using ll = long long int;

const int MAXB = 100010;
ll A, B, P, dp[MAXB + 10], base[15];

ll add_dp(ll ub, ll digit, ll isOp) {
  // [lb, ub]
  if(isOp) ub--;
  ll lb = base[digit];

  if(lb > ub) return 0;
  if(B < lb or ub < A) return 0;
  ll mi = max(A, lb), ma = min(B, ub);
  ll idxMi = mi - A + 1, idxMa = ma - A + 1;

  // fprintf(stderr, "lb = %lld, ub = %lld, digit = %lld, mi = %lld, ma = %lld\n", lb, ub, digit, mi, ma);
  return (dp[idxMa] - dp[idxMi - 1] + P) % P;
}

ll solve() {
  fill(dp, dp + MAXB, 0);

  ll width = B - A + 1;
  for(int i=0; i<width; i++) {
    dp[i+1] = 1;
    ll num = A + i;
    string s = to_string(num);
    ll ub = 0;

    for(size_t k=0; k<s.length(); k++) {
      ub = ub * 10 + (s[k] - '0');
      (dp[i+1] += add_dp(ub, k+1, k+1 == s.length())) %= P;
    }

    (dp[i+1] += dp[i]) %= P;
  }
  return dp[width];
}

int main() {
  base[1] = 1;
  for(int i=2; i<15; i++) {
    base[i] = base[i-1] * 10;
  }
  
  while(cin >> A >> B >> P, A) {
    cout << solve() << endl;
  }
  return 0;
}



Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define ll long long 
#define inf 1000000007
using namespace std;
void make_fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int main(){
    make_fast();
	    int a;
	    cin>>a;
	    cout<<a+(a*a)+(a*a*a)<<endl;
}
	   


Measured memory_bytes: 3644
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n;
	cin>>n;
	vector<ll> v(n*2);
	ll sum = 0;
	rep(i, n){
		ll a, b;
		cin>>a>>b;
		sum += a;
		sum %= 86400;
		v[i] = sum;
		v[i+n] = sum+86400;
		sum += b;
	}
	sort(all(v));
	v.pb(1e17);
	ll res = 1;
	ll l = 0, r = 0;
	while(r<n*2){
		while(v[r]-v[l]<=10800) r++;
		chmax(res, r-l);
		l++;
	}
	cout<<res<<endl;
	return 0;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

// d: 現在のケタ数
// val: 現在の値
// all: ここに格納していく (参照型にしておく)
void rec(int d, long long val, vector<long long> &all) {
    // 格納
    all.push_back(val);

    // 10 桁だったらそれ以上やらずに打ち切り
    if (d == 10) return;

    // 次の桁へ進む処理
    for (int j = -1; j <= 1; ++j) {
        int add = (val % 10) + j;
        if (add >= 0 && add<= 9) rec(d+1, val*10+add, all);
    }
}

int main() {
    int K;
    cin >> K;
    vector<long long> all;
    for (int v = 1; v < 10; ++v) rec(1, v, all);

    // 小さい順に並び替える
    sort(all.begin(), all.end());

    // K 番目
    cout << all[K-1] << endl;
}

Measured memory_bytes: 5372
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , bytes ) => { read_value ! ( $ next , String ) . into_bytes ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
#[allow(dead_code)]
pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer)
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) } ; }

#[allow(dead_code)]
fn main() {
    input!{
        n: usize,
        a: [u64; n],
    }
    for v in a {
        if v % 2 != 0 {
            println!("first");
            return;
        }
    }
    println!("second");
}

Measured memory_bytes: 4352
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    let cost = [1000, 2
,
5
,
5
,
4
,
5
,
6
,
3
,
7
,
                6];
    input! {
        n: usize,
        a: [usize],
    }
    let mut can = vec![false; 10];
    for a in a { can[a] = true; }
    let mut dp = vec![vec![-INF; n + 1]; 11];
    const INF: i64 = 1 << 50;
    dp[0][0] = 0;
    for i in 0..10 {
        for j in 0..n + 1 {
            dp[i + 1][j] = dp[i][j];
        }
        if !can[i] { continue; }
        if cost[i] <= n + 1 {
            for j in 0..n + 1 - cost[i] {
                dp[i + 1][j + cost[i]] =
                    max(dp[i + 1][j + cost[i]], 1 + dp[i + 1][j]);
            }
        }
    }
    assert!(dp[10][n] > 0);
    let mut ans = vec![];
    let mut rem = dp[10][n];
    let mut cur = n;
    for i in (0..10).rev() {
        if !can[i] { continue; }
        while cur >= cost[i] && rem == dp[i + 1][cur - cost[i]] + 1 {
            rem -= 1;
            cur -= cost[i];
            ans.push(i);
        }
    }
    for a in ans {
        puts!("{}", a);
    }
    puts!("\n");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cout<<x<<endl;
#define pb push_back
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;
const ll infll=1e15;


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x,y;
    cin>>x>>y;

    int sum=0;
    int ara[5]={0,300000,200000,100000};


    if(x>=1 && x<=3)
        sum+=ara[x];

    if(y>=1 && y<=3)
        sum+=ara[y];

    if(x==1 && y==1)
        sum+=400000;

    cout<<sum<<"\n";


    return 0;
}


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

const ll MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int cnt[10][10];
int main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		string s=to_string(i);
		cnt[s[0]-'0'][s.back()-'0']++;
	}
	ll ans=0;
	rep(i,10)rep(j,10){
		ans+=cnt[i][j]*(ll)cnt[j][i];
	}
	cout<<ans<<endl;
}

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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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;
}

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

bool is_prime(int x)
{
    if (x <= 1)
    {
        return false;
    }
    for (int i = 2; i * i <= x; i++)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
}

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

    int ans = 0;
    rep(i, n)
    {
        int a;
        cin >> a;
        for (int j = 0; j < d; j += a)
        {
            ans++;
        }
    }
    cout << ans + x << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	k := nextInt()
	plist := make([]int, n)
	for i := 0; i < n; i++ {
		plist[i] = nextInt()
	}
	sort.Sort(sort.IntSlice(plist))

	sum := 0
	for i := 0; i < k; i++ {
		sum += plist[i]
	}

	fmt.Println(sum)
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
N, Y = map(int, input().split())
Y //= 1000
n_10, n_5, n_1 = -1, -1, -1

r_1 = Y % 5
for i in range(r_1, N+1, 5):
    tmp_1 = i
    tmp_10 = int((Y + 4*tmp_1 - 5*N) // 5)
    tmp_5 = N - tmp_10 - tmp_1
    if tmp_10 >= 0 and tmp_5 >= 0 and (10*tmp_10 + 5*tmp_5 + tmp_1) == Y:
        n_10, n_5, n_1 = tmp_10, tmp_5, tmp_1
        print(n_10, n_5, n_1)
        break
else:
    print(n_10, n_5, n_1)


Measured memory_bytes: 3064
/*  -*- coding: utf-8 -*-
 *
 * 2718.cc: Vector Field
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 3000;

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef map<int,int> mii;

/* global variables */

int xs[MAX_N], ys[MAX_N], cxs[MAX_N], cys[MAX_N], xis[MAX_N], yis[MAX_N];
char cs[MAX_N];
mii xmap, ymap;
bool used[MAX_N];
vpii xvs[MAX_N], yvs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d %d %c", &xs[i], &ys[i], &cs[i]);
    cxs[i] = xs[i], cys[i] = ys[i];
    //printf("(%d,%d)[%c]\n", xs[i], ys[i], cs[i]);
  }

  sort(cxs, cxs + n);
  int xn = unique(cxs, cxs + n) - cxs;
  for (int i = 0; i < xn; i++) xmap[cxs[i]] = i;
  sort(cys, cys + n);
  int yn = unique(cys, cys + n) - cys;
  for (int i = 0; i < yn; i++) ymap[cys[i]] = i;

  for (int i = 0; i < n; i++) {
    xis[i] = xmap[xs[i]], yis[i] = ymap[ys[i]];
    xvs[yis[i]].push_back(pii(xis[i], i));
    yvs[xis[i]].push_back(pii(yis[i], i));
  }

  for (int i = 0; i < yn; i++) sort(xvs[i].begin(), xvs[i].end());
  for (int i = 0; i < xn; i++) sort(yvs[i].begin(), yvs[i].end());

  int maxd = 0;
  for (int st = 0; st < n; st++) {
    memset(used, false, sizeof(used));
    int d = 0;

    for (int i = st; i >= 0;) {
      used[i] = true, d++;
      int xi = xis[i], yi = yis[i];
      char c = cs[i];

      if (c == '>') {
	vpii &xv = xvs[yi];
	int k =
	  lower_bound(xv.begin(), xv.end(), pii(xi, i)) - xv.begin() + 1;
	while (k < xv.size() && used[xv[k].second]) k++;
	i = (k < xv.size()) ? xv[k].second : -1;
      }
      else if (c == '<') {
	vpii &xv = xvs[yi];
	int k =
	  lower_bound(xv.begin(), xv.end(), pii(xi, i)) - xv.begin() - 1;
	while (k >= 0 && used[xv[k].second]) k--;
	i = (k >= 0) ? xv[k].second : -1;
      }
      else if (c == 'v') {
	vpii &yv = yvs[xi];
	int k =
	  lower_bound(yv.begin(), yv.end(), pii(yi, i)) - yv.begin() + 1;
	while (k < yv.size() && used[yv[k].second]) k++;
	i = (k < yv.size()) ? yv[k].second : -1;
      }
      else {
	vpii &yv = yvs[xi];
	int k =
	  lower_bound(yv.begin(), yv.end(), pii(yi, i)) - yv.begin() - 1;
	while (k >= 0 && used[yv[k].second]) k--;
	i = (k >= 0) ? yv[k].second : -1;
      }
    }

    if (maxd < d) maxd = d;
    //printf("st=%d, d=%d\n", st, d);
  }

  printf("%d\n", maxd);
  return 0;
}

Measured memory_bytes: 3692
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {

  trait Monoid[A]{
    def op(a1: A, a2: A): A
    def zero: A
  }

  type Per = List[Int]
  type Rot = Dice => Dice

  object DiceRoll extends Monoid[Rot]{

    def op(rot1: Rot, rot2: Rot): Rot = (dice: Dice) => rot2(rot1(dice))
    def zero: Rot = (dice: Dice)=>dice

    val north = List(2,6,3,4,1,5).map(_ - 1)
    val east = List(4,2,1,6,5,3).map(_ - 1)
    val ccw = List(1,4,2,5,3,6).map(_ - 1)

    def rot(perm: Per): Rot = (dice: Dice) => Dice(perm.map(dice.pip))

    def axial(f: Rot): List[Rot] = List(zero,f,op(f,f),op(op(f,f),f))

    def enumerateTop(f: Rot = zero, n: Int = 6): List[Rot] = {
      if(n<=0)List[Rot]()
      else if(n%2==0) f :: enumerateTop(op(f,rot(north)),n-1)
      else f :: enumerateTop(op(f,rot(east)),n-1)
    }

    def enumerate: List[Rot] = enumerateTop().flatMap( e => axial(rot(ccw)).map(op(e,_)))
  }

  case class Dice(pip: List[Int]){
    lazy val all: List[Dice] = DiceRoll.enumerate.map(_(Dice(pip)))
    def ===(that: Dice): Boolean = pip == that.pip
    def ==(that: Dice): Boolean = all.exists(_ === that)
  }

  def main(args: Array[String]): Unit = {
    val Array(n,_*) = readLine.split(" ").map(_.toInt)
    val dices = for(i <- 1 to n) yield Dice(readLine.split(" ").map(_.toInt).toList)

    val res = for{
      i <- 0 until n
      j <- 0 until n
      if i<j
    } yield dices(i) == dices(j)

    println( if(res.fold(false)(_ | _)) "No" else "Yes")
  }
}

Measured memory_bytes: 51048
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    int idx = n, reach = n;
    vector<int> res(0);
    while (idx > 0) {
        int r = min(idx, m);
        while (s[idx - r] == '1' && idx - r < reach) {
            r--;
        }

        if (idx - r == reach) {
            break;
        }

        reach = idx - min(idx, m);
        idx -= r;
        res.push_back(r);
    }

    if (idx == 0) {
        cout << res[res.size() - 1];
        for (int i = res.size() - 2; i >= 0; i--) {
            cout << " " << res[i];
        }
        cout << endl;
    } else {
        cout << "-1" << endl;
    }
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
queue<char>que;
int main(){
	string s;
	int ans=0;
	cin>>s;
	for(int i=0;i<s.size();i++)que.push(s[i]);
	for(int i=0;i<s.size();i++){
		(que.front()=='+')?ans++:ans--;
		que.pop();
	}cout<<ans<<'\n';
	return 0;
}

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

class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split(' ');
		string[] str2 = Console.ReadLine().Split(' ');

		int H = int.Parse(str[0]);
		int W = int.Parse(str[1]);
		int h = int.Parse(str2[0]);
		int w = int.Parse(str2[1]);

		Console.WriteLine((H - h) * (W - w));
	}
}

Measured memory_bytes: 11092
h, w, d = map(int, input().split())

# aij to (i, j)
a = {}
for i in range(h):
    ai = list(map(int, input().split()))
    for j in range(w):
        a[ai[j]] = (i + 1, j + 1)

q = int(input())

mana = [0 for i in range(h * w + 1)]
for i in range(1, h * w + 1):
    if i + d > h * w:
        break

    y, x = a[i]
    ny, nx = a[i + d]
    mana[i + d] = mana[i] + abs(y - ny) + abs(x - nx)

for i in range(q):
    l, r = map(int, input().split())
    print(mana[r] - mana[l])



Measured memory_bytes: 24472
#include <iostream>
#include<cstdio>
using namespace std;
typedef long long ll; 
ll x[300000],y[300000];

int main(){
    ll n,d,sum=0;
    scanf("%lld%lld",&n,&d);
    for(ll i=1;i<=n;i++){
    	scanf("%lld%lld",&x[i],&y[i]);
    	if(x[i]*x[i]+y[i]*y[i]<=d*d){
    		sum++;
    	}
    }
    printf("%lld",sum);
    /*while(t--){
    	ll n;
    	scanf("%lld",&n);
    	
    
    }*/

    
    return 0;
}

Measured memory_bytes: 6952
n = int(input())
a = list(map(int, input().split()))

ans, count = 0, 0
for i in range(n):
    ans += abs(a[i])
    if a[i] < 0:
        count += 1
a = list(abs(i) for i in a)
if count%2 != 0:
    ans -= 2*min(a)
print(ans)
    


Measured memory_bytes: 20140
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

N,K,C = inputIL()
S = inputS()

L = []

i = 0
c = 0
while i<N:
  if c == K:
    break
  if S[i]=="o":
    L.append(i)
    c += 1
    i += C+1
  else:
    i += 1

R = []

i = N-1
c = 0
while i>=0:
  if c == K:
    break
  if S[i]=="o":
    R.append(i)
    c += 1
    i -= C+1
  else:
    i -= 1

for l,r in zip(L,R[::-1]):
  if l == r:
    print(l+1)


Measured memory_bytes: 102108
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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 (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b,c;cin>>a>>b>>c;
    vector<ll> v={a,b,c};
    sort(all(v));
    cout << (v[0] == v[1] ? v[2] : v[0]) << ednl;
}


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

int main(void) {
    string str, cmd, rep;
    int q, s, e;

    cin >> str >> q;
    for (int i = 0; i < q; i++) {
        cin >> cmd >> s >> e;
        int interval = e - s + 1;

        if (cmd == "print") {
            cout << str.substr(s, interval) << endl;
        } else if (cmd == "reverse") {
            string original = str.substr(s, interval);
            int size = original.size();
            for (int i = 0; i < size; i++) {
                str[s + i] = original[size - i - 1];
            }
        } else if (cmd == "replace") {
            cin >> rep;
            str.replace(s, interval , rep);
        }
    }

    return 0;
} 

Measured memory_bytes: 1220
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int MOD;

Int dp[330][330];//upper_bound, cnt
Int memo[330][330];

// insert add nums to from nums.
Int calc(Int from, Int add){
    Int &res = memo[from][add];
    if(res != -1)return res;
    if(from == 0 || add == 0)return res = 1;
    return res = (calc(from-1, add) + calc(from, add-1) * (from + 1)) % MOD;
}

int main(){
    Int n, k, m;
    for(int i = 0;i < 330;i++)for(int j = 0;j < 330;j++)memo[i][j] = -1;
    cin >> n >> k >> m;
    MOD = m;
    dp[0][0] = 1;
    for(int i = 1;i <= k;i++){
        for(int j = 0;j <= n;j++){
            //insert l is,
            for(int l = 0;l <= j;l++){
                (dp[i][j] += dp[i-1][l] * calc(l, j-l)) %= MOD;
            }
//            cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    cout << dp[k][n] << endl;
    return 0;
}

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

int main() {
 string s;
 cin >> s;
 int count = 0;
 for(char i:s){
    if (i == 'o') count += 1;
 }
 if ((15-s.size())+count >= 8) cout << "YES"<< endl;
 else cout << "NO" << endl;
}
  

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

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

	ll N, M;  cin >> N >> M;

	ll n = N, m = M;
	ll cnt = 0;
	if (n * 2 <= m) {
		cnt += n;
		m -= 2 * n;
	}
	else {
		cnt += m / 2;
		m -= 2 * cnt;
	}

	if (m > 3) cnt += m / 4;

	cout << cnt << endl;
	return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


#define ALICE "Alice"
#define BORYS "Borys"
#define DRAW "Draw"

const char* solve(int n, int a, int b) {
    int d = b-a-1;
    if (d == 0) return BORYS;
    return (d % 2)? ALICE : BORYS;
}

int main() {
    int n,a,b; cin >>n>>a>>b;
    cout << solve(n,a,b) << endl;
    return 0;
}


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

void Sum(int data[3],int K){
    
    data[2] *= 2;
    
    if(K == 1){
        int sum = 0;
        for(int i=0;i<3;i++) sum += data[i];
        cout << sum << endl;
    }
    else{
        Sum(data,K-1);
    }
}

int main(void){
    
    int data[3];
    int K;
    
    for(int i=0;i<3;i++) cin >> data[i];
    cin >> K;
    sort(data,data+3);
    
    Sum(data,K); 
    
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    try (Scanner scanner = new Scanner(System.in)) {
      while (true) {
        final int n, x;
        n = scanner.nextInt();
        x = scanner.nextInt();
        if (n == 0 && x == 0) {
          break;
        }
        int count = 0;
        for (int i = 1; i <= n - 2; i++) {
          if (i > x) {
            break;
          } else  if (i + 2 * n - 1 < x) {
            continue;
          }
          for (int j = i + 1; j <= n - 1; j++) {
            if (i + j > x) {
              break;
            } else if (i + j + n < x) {
              continue;
            }
            for (int k = j + 1; k <= n; k++) {
              if (i + j + k == x) {
                count++;
                break;
              }
            }
          }
        }
        System.out.println(count);
      }
    }

  }
}

Measured memory_bytes: 26960
program main
implicit none
integer :: a, b, k
integer :: i, j

read(*,*) a, b, k

j = 0
do i = b, 1, -1
   if(mod(a,i) == 0 .and. mod(b,i) == 0 ) then
      j = j + 1
   end if
   if(j == k) then
      write(*,'(i0)') i
      stop
   end if
end do

end program main


Measured memory_bytes: 256
import math
n = int(input())
p = math.floor(math.log10(n))
ans = (n // (10**p)) * (10**p) - 1
if (n + 1) % (10**p) == 0:
    ans += 10**p
list_ans = list(str(ans))
count = 0
for i in list_ans:
    count += int(i)
print(count)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

/* -- template -- */
//__builtin_popcount
int main() {
    int x[5]; rep(i, 5) cin >> x[i];
    rep(i, 5) {
        if(x[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll ball, color; cin >> ball >> color;
  ll ans = (color * pow(color-1, ball-1));
  
  cout << ans  << endl; 
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> h(N+1);
	for(int i = 1; i <= N; i++) {
		cin >> h[i];
	}

	vector<int> c(N+1, 0);

	c[0] = -1;
	c[1] = 0;

	for(int i = 2; i <= N; i++) {
		if(i > 2) {
			c[i] = min(c[i-2] + abs(h[i] - h[i-2]), c[i-1] + abs(h[i] - h[i-1]));
		} else {
			c[i] = c[i-1] + abs(h[i] - h[i-1]);
		}
	}
	
	cout << c[N] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

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

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    cin >> a;
    vector<int> dp(k + 1);
    rep(i, k + 1) rep(j, n) if (0 <= i - a[j]) dp[i] |= dp[i - a[j]] ^ 1;
    cout << (dp[k] ? "First" : "Second") << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin >> a >> b >> c;
  if (a+b>=c)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int q = sc.nextInt();

		int[][] a = new int[n + 1][n + 1];
		for (int i = 0; i < m; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			a[l][r]++;
		}
		for (int i = 0; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				a[i][j] += a[i][j - 1];
			}
		}

		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= n; j++) {
				a[i][j] += a[i - 1][j];
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int answer = a[y][y];
			if (x > 0) {
				answer += -a[y][x - 1] - a[x - 1][y] + a[x - 1][x - 1];
			}
			sb.append(answer);
			sb.append("\n");
		}
		System.out.print(sb.toString());
	}
}


Measured memory_bytes: 154556
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())

def q(i): #i, i+1,...
    res = ["?"] + list(map(str,range(i,i+n)))
    print(*res)
    sys.stdout.flush()
    I = input()
    return I

c0 = q(1)

ok = 1
ng = n+1
while(abs(ok-ng) > 1):
    mid = (ok + ng)//2
    c = q(mid)
    if c0 == c: ok = mid
    else: ng = mid


ans = [-1]*(2*n+1)
ans[ok] = c0[0]
ans[ng+n-1] = "B" if c0 == "Red" else "R"

L = list(range(2*n+1))

g1 = L[ng:ng+n-1]
g2 = L[1:ok] + L[ng+n:]

#print(ok,ng,ans)
#print(g1,g2)


for i in g1:
    res = ["?"] + g2[:] + [i]
    print(*res)    
    sys.stdout.flush()
    c = input()
    ans[i] = c[0]

for i in g2:
    res = ["?"] + g1[:] + [i]
    print(*res)    
    sys.stdout.flush()
    c = input()
    ans[i] = c[0]


L = "".join(ans[1:])
a = ["!"] + [L]
print(*a)
sys.stdout.flush()



Measured memory_bytes: 3532