akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();
        int d = sc.nextInt();

        int ans = 0;
        for(int i=l;i<=r;i++) {
            if(i%d==0) {
                ans++;
            }
        }


        System.out.println(ans);
    }
}


Measured memory_bytes: 35656
#include<bits/stdc++.h>
using namespace std;	
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		int cur = 7%n;
		map<int,int>mp;
		int ans =1;
		while(1){
			if(cur==0){
				break;
			}
			if(mp.count(cur)){
				ans= -1;break;
			}
			mp[cur]++;
			// trace(cur);
			cur*=10;
			cur+=7;
			cur%=n;
			ans++;
		}
		cout<<ans;

	}
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> ret;
  for (int i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      ret.push_back(i);
      if (i * i != m) ret.push_back(m / i);
    }
  }
  sort(ret.begin(), ret.end());
  int ans = 1;
  for(int i=0; i<ret.size(); i++){
    if(m/ret[i]>=n) ans = max(ans, ret[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++) // for文のマクロを定義
using namespace std;

int main() {
    double N, M;
    cin >> N >> M;
    vector<int> A(N);
    double sum = 0;
    rep(i, N) {
        cin >> A.at(i);
        sum += A.at(i);
    }
    int count = 0;
    double x = (sum / (4 * M));
    rep(i, N) {
        if (A.at(i) >= x) {
            count ++;
        }
    }
    if (count >= M) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
int []n=new int[2];
        n[0] = sc.nextInt();
n[1] = sc.nextInt();
int k = sc.nextInt();
for(int i=0;i<k;i++){
n[i%2]=n[i%2]/2;
n[(i+1)%2]+=n[i%2];
}
System.out.println(n[0]+" "+n[1]);
    }
}

Measured memory_bytes: 23380
import java.util.*;

public class Main {
	static int mod = 1_000_000_007;
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        if((x + y) % 3 != 0) {
        	System.out.println(0);
        	return;
        }
        int n = (2 * y - x) / 3;
        int m = y - 2 * n;
        if(n < 0 || m < 0) {
        	System.out.println(0);
            return;
        }
        System.out.println(comb(n+m, m) % mod);
    }

    private static long comb(int a, int b) {
    	long fA = factorial(a, a-b+1);
    	long fB = factorial(b, 1);
    	long invert = modPow(fB, mod - 2);
    	return fA * invert % mod;
    }

    private static long modPow(long a, long b) {
    	if(b == 1)
    		return a;
    	if(b == 0)
    		return 1;
    	long res = modPow(a, b / 2) % mod;
    	if(b % 2 == 1)
    		return (res * res % mod) * a % mod;
    	return (res * res % mod);
    }

    private static long factorial(int n, int start) {
    	long res = 1L;
    	for(long i = start; i <= n; i++)
    		res = res * i % mod;
    	return res % mod;
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, k, h;
  in(n);
  vector<ll> b(n), c(n);
  rep(i, n)
    in(b[i]);
  k = 0;
  rep(i, n)
    k += b[i];
  c[0] = k;
  a = 1;
  while(a < n){
    c[0] -= 2 * b[a];
    a += 2;
  }
  b.pb(b[0]);
  rep2(i, 1, n){
    c[i] = 2 * b[i - 1] - c[i - 1];
  }
  rep(i, n){
    out(c[i]);
    hina;
  }
  memi;
}

Measured memory_bytes: 2928
#include <iostream>
#include <stdio.h>
#define MAX 10001
using namespace std;

int root[MAX];
int high[MAX];

int find(int x)
{
    if (x == root[x])
    {
        return x;
    }
    else
    {
        return(root[x] = find(root[x]));
    }
}

void unit(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;

    if (high[x] < high[y])
    {
        root[x] = y;
    }
    else
    {
        root[y] = x;
        if (high[x] == high[y])
        {
            high[x]++;
        }
    }
}

bool same(int x, int y)
{
    return find(x) == find(y);
}

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

    for (int i = 0; i < n; i++)
    {
        root[i] = i;
        high[i] = 0;
    }

    int query;
    scanf("%d", &query);

    int command, x, y;
    for (int i = 0; i < query; i++)
    {
        scanf("%d %d %d", &command, &x, &y);
        if (0 == command)
        {
            unit(x, y);
        }
        else
        {
            if (same(x, y))
            {
                printf("%d\n", 1);
            }
            else
            {
                printf("%d\n", 0);
            }
        }

    }


    return 0;
}



Measured memory_bytes: 3280
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

ll n;
string a;
vector<string> ans;
string c = "abcdefghijklm";

int main(void) {
    ll n;
    cin >> n;
    ll a[n], sum[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a+n);
    for(ll i = 0; i < n; i++){
        if(i==0) sum[i] = a[i];
        else sum[i] = sum[i-1]+a[i];
    }
    sort(sum, sum+n, greater<ll>());
    sort(a, a+n, greater<ll>());
    ll ans = 1;
    for(ll i = 1; i < n; i++){
       // cout << sum[i] << endl;
        if(sum[i]*2>=a[i-1]) ans++;
        else break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define dot cout<< setprecision(20)<<endl;
#define vsor(x) sort(x.begin(),x.end());
#define vrev(x) reverse(x.begin(),x.end());
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define bit(b,n) for(int b=0;b<(1<<(ll)(n));b++)

using namespace std;

int main(){
int a;cin>>a;
cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int N=5005;
long long dp[N][N];
struct P{
    long long h;
    long long p;
}a[N];
bool cmp(P a,P b){
   return a.h+a.p<b.h+b.p;
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i].h>>a[i].p;
    }
    sort(a+1,a+n+1,cmp);
    memset(dp,0x3f,sizeof(dp));
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        dp[i][0]=0;
        for(int j=1;j<=i;j++){
          dp[i][j]=dp[i-1][j];
          if(dp[i-1][j-1]<=a[i].h)
          {
              dp[i][j]=min(dp[i-1][j-1]+a[i].p,dp[i][j]);
          }
        }
    }
    int ans=0;
    long long inf=1e12;
    for(int i=5000;i>=0;i--){
        if(dp[n][i]<=inf){
            ans=i;
            break;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 196096
#include<cstdio>
#include<utility>
#include<algorithm>


using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int v[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &v[i]);
    }
    int mn = 0;
    int even[100000], odd[100000];
    fill(even, even + 100000, 0);
    fill(odd, odd + 100000, 0);
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            even[v[i]-1]++;
        }else{
            odd[v[i]-1]++;
        }
    }
    // for(int i = 0; i < 3; i++){
    //     printf("even = %d odd = %d\n", even[i], odd[i]);
    // }
    
    pair<int, int> max_even, max_odd, submax_even, submax_odd;
    max_even.first = 0;
    max_odd.first = 0;
    submax_even.first = 0;
    submax_odd.first = 0;
    max_even.second = 0;
    max_odd.second = 0;
    submax_even.second = 0;
    submax_odd.second = 0;
    for(int i = 0; i < 100000; i++){
        if(submax_even.first < even[i]){
            if (max_even.first < even[i]) {
                submax_even.first = max_even.first;
                submax_even.second = max_even.second;
                max_even.first = even[i];
                max_even.second = i;
            }else{
                submax_even.first = even[i];
                submax_even.second = i;
            }
        }
        if(submax_odd.first < odd[i]){
            if (max_odd.first < odd[i]) {
                submax_odd.first = max_odd.first;
                submax_odd.second = max_odd.second;
                max_odd.first = odd[i];
                max_odd.second = i;
            }else{
                submax_odd.first = odd[i];
                submax_odd.second = i;
            }
        }
    }
    // printf("%d %d\n", max_odd.first, max_odd.second);
    // printf("%d %d\n", max_even.first, max_even.second);
    // printf("%d %d\n", submax_odd.first, submax_odd.second);
    // printf("%d %d\n", submax_even.first, submax_even.second);
    int ans = 0;
    if (max_odd.second != max_even.second) {
        ans =  n - max_even.first - max_odd.first;
    }else{
        if (submax_odd.first < submax_even.first) {
            ans = n - max_odd.first - submax_even.first;
        }else{
            ans = n - submax_odd.first - max_even.first;
        }
        
    }
    
    printf("%d\n", ans);

}

Measured memory_bytes: 1280
import math
a, b, k = list(map(int, input().split(' ')))
if k > a*a*b / 2:
    p = 2*b - 2*k / (a*a)
    q = (p**2 +a**2) ** 0.5
    limit = p
else:
    p = 2*k/(a*b)
    q = (p**2 +b**2) ** 0.5
    limit = b

left = 0.0
right = 90.0
while right > left + 1e-12:
    r = (left + right) / 2.0
    if q * math.sin(math.radians(r)) < limit:
        left = r
    else:
        right = r

print(r)

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

int main()
{
    int a, b, c;
    string s;

    cin >> a >> b;

    if (a % 2 == 1 && b % 2 == 1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys


sys.setrecursionlimit(1000000)


MAX_N = 100001

memo = [-1] * MAX_N


def f(n):
    # 残り金額が0なら引き出す必要がないので0(再帰の終端条件)
    if n == 0:
        return 0
    # すでに探索済みならメモを参照する
    if memo[n] != -1:
        return memo[n]

    res = sys.maxsize

    pow9 = 1
    while pow9 <= N:
        if n - pow9 < 0:
            break
        res = min(res, f(n-pow9)+1)
        pow9 *= 9


    pow6 = 1
    while pow6 <= N:
        if n - pow6 < 0:
            break
        res = min(res, f(n-pow6)+1)
        pow6 *= 6

    # メモ
    memo[n] = res

    return res


if __name__ == '__main__':
    N = int(input())

    print(f(N))



Measured memory_bytes: 89668
uses crt;
var dp:array[0..100,0..100000] of int64;
    v,w:array[0..100] of int64;
    i,j,n,vmax:longint;
function max(a,b:int64):int64;
begin
    if a>b then exit(a) else exit(b);
end;
begin
    clrscr;
    readln(n,vmax);
    for i := 1 to n do readln(w[i],v[i]);
    for i := 0 to n do dp[0,i]:=0;
    for j := 0 to vmax do dp[i,0]:=0;
    for i:=1 to n do 
      for j := 1 to vmax do if j<w[i] then dp[i,j]:=max(dp[i,j],dp[i-1,j]) 
        else dp[i,j]:=max(dp[i-1,j],dp[i-1,j-w[i]]+v[i]);
    writeln(dp[n,vmax]);
    readln;
end.

Measured memory_bytes: 78336
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn calc(depth: usize, cnt: usize, cnts: &Vec<usize>, memo: &mut Vec<Vec<i64>>) -> i64 {
    let n = cnts.len() - 1;
    if cnt == 75 {
        return 1;
    }
    if depth == n + 1 || cnt > 75 {
        return 0;
    }
    if memo[cnt][depth] != -1 {
        return memo[cnt][depth];
    }
    let mut ret = 0;
    for i in 0..(cnts[depth] + 1) {
        let ncnt = cnt * (i + 1);
        ret += calc(depth + 1, ncnt, cnts, memo);
    }
    memo[cnt][depth] = ret;
    return ret;
}

fn main() {
    let n = read::<usize>();
    let mut cnts = vec![0; n + 1];
    for i in 1..(n + 1) {
        let mut v = i;
        for j in 2..(i + 1) {
            while v % j == 0 {
                cnts[j] += 1;
                v /= j;
            }
        }
    }
    let mut memo = vec![vec![-1; n + 1]; 100];
    let ans = calc(0, 1, &cnts, &mut memo);
    println!("{}", ans);
}


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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000

typedef long long ll;
typedef pair<ll,ll> P;

int main()
{	
	int n;cin >> n;
	set<char> s;
	REP(i,n)
	{
		char tmp;cin >> tmp;
		s.insert(tmp);
	}
	
	if(s.size() == 3)
	{
		cout << "Three" << endl;
	}
	else
	{
		cout << "Four" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
/*		Author : Kaustubh Gangwar
		||S||A||M||R||A||T||
*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ld long double
#define pb push_back
#define gcd __gcd
#define vii vector<int>
#define vll vector<long long>
#define all(x) x.begin(),x.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
typedef long long  ll;
typedef pair<int,int> pii;

ll bpow(ll a, ll b) {
	a=a; ll res = 1;
    while(b){
        if (b & 1)
        res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int32_t main()
{	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	ll test=1;
	//cin>>test;
	while(test--)
	{//	ll l,r; cin>>l>>r;
		ll n; cin>>n;
		ll ans=0;
		ll a[n];
		f(i,0,n)
		{	cin>>a[i];
			if(!(i%2) && a[i]%2)
			ans++;
		}
		
		cout<<ans;
		
	}
return 0;
}


Measured memory_bytes: 3608
import java.lang.Math.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map { it.toInt() }

    val dp = IntArray(n)
    dp[1] = abs(h[0] - h[1])

    for (i in 2 until n) {
        dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2])
    }
    println(dp.last())
}

Measured memory_bytes: 48592
import math                                                         
a,b,h,m=map(int,input().split())                                    
hs=h*(360/12)+m*(30/60)                                             
ms=m*(360/60)                                                       
print(math.sqrt(a**2+b**2-2*a*b*math.cos(((hs-ms)/360)*2*math.pi)))                                                   

Measured memory_bytes: 9508
#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(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int N;
int X[212345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", X + i);
	
	vector<int> v(N);
	REP(i, N) v[i] = X[i];
	sort(ALL(v));
	
	REP(i, N) {
		int ans;
		if (X[i] <= v[N / 2 - 1]) ans = v[N / 2];
		else ans = v[N / 2 - 1];
		printf("%d\n", ans);
	}
	
	return 0;
}


Measured memory_bytes: 3712
s = input()

for bit in range(1<<3):
    ans=int(s[0])
    f=s[0]
    
    for j in range(3):
        if bit & (1<<j):
            ans+=int(s[j+1])
            f+="+"
        else:
            ans-=int(s[j+1])
            f+="-"
        
        f+=s[j+1]
    
    if ans == 7:
        print(f + "=7")
        exit()

Measured memory_bytes: 3060
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class CompetitiveProgrammingProgram
{
    static long Gcd(long a, long b)
    {
        long[] v = new long[] { a, b };
        while (v[1] != 0) { v = new long[] { v[1], v[0] % v[1] }; }
        return v[0];
    }
    static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }
    class Node<T>
    {
        private int m_height;
        private Node<T> m_parent;
        public T Item { get; private set; }
        public Node(T item)
        {
            m_height = 0;
            m_parent = this;
            Item = item;
        }
        public Node<T> Find()
        {
            if (m_parent == this) { return this; }

            Node<T> parent = m_parent.Find();
            m_parent = parent;
            return parent;
        }
        public static void Unite(Node<T> a, Node<T> b)
        {
            Node<T> p = a.Find();
            Node<T> q = b.Find();
            if (p.m_height < q.m_height)
            {
                p.m_parent = q;
                q.m_height = Math.Max(p.m_height + 1, q.m_height);
            }
            else
            {
                q.m_parent = p;
                p.m_height = Math.Max(q.m_height + 1, p.m_height);
            }
        }
    }
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        long D = long.Parse(input[1]);
        long[,] pos = new long[N, 2];
        for (int i = 0; i < N; i++)
        {
            input = Console.ReadLine().Split(' ');
            pos[i, 0] = long.Parse(input[0]);
            pos[i, 1] = long.Parse(input[1]);
        }
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            if (pos[i, 0] * pos[i, 0] + pos[i, 1] * pos[i, 1] <= D * D)
                ans++;
        }
        Console.WriteLine(ans.ToString());
    }
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> lucas(N+1);
    lucas.at(0) = 2;
    lucas.at(1) = 1;
    for(int i = 2; i < N + 1;i++) 
      lucas.at(i) = lucas.at(i-1) + lucas.at(i-2);
    cout << lucas.at(N) << endl;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  IN(N,K);
  N -= (N/K)*K;
  OUT(min(N,K-N));

  return 0;
}


Measured memory_bytes: 256
///IDA*
#include<stdio.h>
#include<string.h>
#include<math.h>
int Map[4][4];
int max1,min1;
int start_x,start_y;
int flag;
int c[4][2]= {0,1,-1,0,1,0,0,-1};///右（0），上（1），下（2），左（3）；

int HMD()///曼哈顿距离；
{
    int i,j,num=0;
    for(i=0; i<3; i++)
        for(j=0; j<3; j++)
            if(Map[i][j]==0)
                continue;
            else
                num+=fabs((Map[i][j]-1)/3-i)+fabs((Map[i][j]-1)%3-j);
    return num;
}

void start_xyz()///0的起始位置；
{
    int i,j;
    for(i=0; i<3; i++)
        for(j=0; j<3; j++)
            if(Map[i][j]==0)
            {
                start_x=i;
                start_y=j;
                return ;
            }
}

void swap(int *a,int *b)///交换函数;
{
    int t;
    t=*a;
    *a=*b;
    *b=t;
}

void dfs(int x,int y,int s,int last_step)
{
    if(flag)
        return ;
    if(s==max1)///当结果等于当前假定最优解；
    {
        int l=HMD();
        if(l==0)///与目标状态相同；
        {
            min1=s;///记录结果；
            flag=1;
        }
        return ;
    }
    for(int i=0; i<4; i++)
    {
        if(last_step+i==3&&s>0)///和上次方向不能相反；
            continue;
        int dx=x+c[i][0];
        int dy=y+c[i][1];
        if(dx<0||dy<0||dx>=3||dy>=3)///是否越界；
            continue;
        swap(&Map[dx][dy],&Map[x][y]);///先交换0和要交换数的值；
        if(HMD()+s<=max1&&!flag)///IDA*剪枝。核心：当前曼哈顿距离+当前深度<=假定最优解；
        {
            dfs(dx,dy,s+1,i);
            if(flag)
                return ;
        }
        swap(&Map[dx][dy],&Map[x][y]);///回溯；
    }
}
int main()
{
    char a[10];
    int i,j;
    for(i=0;i<3;i++)
        for(j=0;j<3;j++)
            scanf("%d",&Map[i][j]);
    start_xyz();///找到0的起始位置；
    max1=HMD();///初始假定最优解；
    flag=0;
    while(!flag)
    {
        dfs(start_x,start_y,0,0);
        if(!flag)
            max1++;///增加假定最优解；
    }
    printf("%d\n",min1);
    return 0;
}





Measured memory_bytes: 2756
#include<bits/stdc++.h>
using namespace std;
int main(){
  string n;
  cin >> n;
  int sum;
  int size=n.size();
  for(int i=0;i<size;i++){
    sum+=n.at(i)-'0';
  }
  if(sum%9==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
   

    ll ans = 1;
    vector <ll> v(100001,0);
    ll cnt_zero = 0;
    ll n;
    cin >> n;
    for (ll i=0;i<n;i++){
        ll a;
        cin >> a;
        if(a == 0){
            cnt_zero++;
            v[a]++;
        }else{
            ans *= v[a-1];
            v[a-1]--;
            v[a]++;
            ans %= mop;
        }
    }
    if(cnt_zero == 1){
        cout << (ans * 3) % mop << endl;
    }else if(cnt_zero == 2 or cnt_zero == 3){
        cout << (ans * 6) % mop << endl;
    }else{
        cout << 0 << endl;
    }
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> p(n);
    REP(i, 0, n) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    cout << max(0, p[n / 2] - p[n / 2 - 1]) << endl;
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

int read() {
	char ch;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar());
	int x=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

const int N=2e5+5;

int n,m,a[N];

bool chk(int p) {
	p<<=1;
	fo(i,p+1,n) if (a[i]+a[n-(i-p)+1]<m) return 0;
	return 1;
}

int main() {
	n=read()<<1;m=read();
	fo(i,1,n) a[i]=read();
	sort(a+1,a+n+1);
	int l=0,r=n>>1,p=0;
	while (l<=r) {
		int mid=l+r>>1;
		if (chk(mid)) p=mid,r=mid-1;
		else l=mid+1;
	}
	int ans=0;p<<=1;
	fo(i,1,p) ans=max(ans,a[i]+a[p-i+1]);
	fo(i,p+1,n) ans=max(ans,a[i]+a[n-(i-p)+1]-m);
	printf("%d\n",ans);
	return 0;
}

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

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define endl '\n'
#define eps  1e-9
const double pi=acos(-1);

const int mod=1e9+7;
//_______________________

int h[22];

int32_t main()
{ 
  io;
  
  
  int cnt=0,n;
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>h[i];

  for(int i=1;i<=n;i++)
  {
    bool ok=true;
    for(int j=0;j<i;j++)
    {
      if(h[j]>h[i])
        ok=false;
    }
    if(ok)
      cnt++;
  }

  cout<<cnt;
  
 return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	string s;

	while (cin >> s)
	{
		string t;
		for (int i = 0; i < s.length(); i++)
		{
			if (s.at(i) == '@')
			{
				int m = s.at(i + 1) - '0';
				for (int j = 0; j < m; j++)
				{
					t += s.substr(i + 2, 1);
				}
				i += 2;
			}
			else
			{
				t += s.substr(i, 1);
			}
		}

		cout << t << endl;
	}
}



Measured memory_bytes: 3100
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
   int a,b,n;
   cin>>a>>b;
   n=a+b;
if(n%2==0){
    cout<<n/2<<endl;
}
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
}



Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

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

    int p = 0;
    int q = (int) s.size() - 1;

    int ans = 0;
    while (q - p >= 0) {
        if (s[p] == s[q]) {
            p++;
            q--;
        } else {
            if (s[p] == 'x') {
                ans++;
                p++;
            } else if (s[q] == 'x') {
                ans++;
                q--;
            } else {
                ans = -1;
                break;
            }
        }
    }

    cout << ans << endl;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  11121
  114

  1211121121
  41121121
  621121
  9121

  55
  10

  3111112
  51112
  514
  }*/

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

  vi a;
  int cnt = 1;
  char cur = s[0];
  rep(i, 1, n){
    if(cur == s[i]){
      cnt++;
    }else{
      a.emplace_back(cnt);
      cnt = 1;
    }
    cur = s[i];
  }
  if(cnt) a.emplace_back(cnt);

  int len = 2*k+1, ans;
  if(sz(a) <= len){
    int sum = 0;
    for(int i : a) sum += i;
    ans = sum - 1;
  }else{
    vi s(sz(a)+1), s2(sz(a)+1);
    rep(i, 0, sz(a)) s[i+1] = s[i] + a[i];
    rep(i, 0, sz(a)) s2[i+1] = s2[i] + a[i]-1;

    ans = 0;
    rep(i, 0, sz(a)-len+1){
      int tmp = s[i+len]-s[i]-1 + s2[sz(a)]-s2[i+len] + s2[i];
//      cout << i << ":" << tmp << endl;
      chmax(ans, tmp);
    }
  }

  cout << ans << endl;

//  rep(i, 0, sz(a)) cout << a[i] << " ";
//  cout << endl;

  return 0;
}



Measured memory_bytes: 2932
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
ll fact[upperlimit];
ll invfact[upperlimit];
ll ncr(int n,int r){
	ll ans=fact[n];
	ans*=invfact[n-r];ans%=mod;
	ans*=invfact[r];ans%=mod;
	return ans;
}
ll npr(int n,int r){
	ll ans=fact[n];
	ans*=invfact[n-r];ans%=mod;
 	return ans;
}
int main() {
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	fact[0]=1;invfact[0]=1;
	for(int i = 1; i < upperlimit; i++){
		fact[i]=fact[i-1];fact[i]*=i;fact[i]%=mod;
		invfact[i]=powmod(fact[i],mod-2,mod);
	}
	int n,m;
	sd(n);sd(m);
	ll ans=0;
	for(int i = 0; i <= n; i++){
		ll calc=npr(m-i,n-i);
		calc*=calc;calc%=mod;
		calc*=ncr(n,i);calc%=mod;
		calc*=npr(m,i);calc%=mod;
		if(i&1) ans+=mod-calc;
		else ans+=calc;
		ans%=mod;
	}
	plld(ans);
	return 0;
}

Measured memory_bytes: 19436
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20191024
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split();
            int[] d = new int[n];
            int[] d2 = new int[n * (n - 1)];
            int ans = 0;

            for(int i = 0; i < n; i++)
            {
                d[i] = int.Parse(s[i]);
            }

            int k = 0;
            for (int i = 0; i < d.Length; i++)
            {
                for(int j = 0; j < d.Length; j++)
                {
                    if (i != j)
                    {
                        d2[k] = d[i] * d[j];
                        k++;
                    }
                }
            }

            for(int i =0; i<d2.Length;i++)
            {
                ans += d2[i];
            }

            Console.WriteLine(ans / 2);

        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin>>n;
    map<ll,int> m;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        m[a]++;
    }
    vector<ll> v;
    for(auto p : m){
        if(p.second>=4){
            v.push_back(p.first);
            v.push_back(p.first);
        }else if(p.second>=2) v.push_back(p.first);
    }
    sort(v.rbegin(),v.rend());
    if((int)v.size()<2) cout<<0<<endl;
    else cout<<v[0]*v[1]<<endl;
}

Measured memory_bytes: 9868
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>

#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e7;
const int maxn = 3e5 + 5;
ll mod = 1e9 + 7;

string s, t;
set<string> ans;
int n, k;
int main()
{
	cin >> s;
	scanf("%d",&k);
	n = s.length();
	
	for (int i = 0; i < n; i++)
	{
		for (int j = i; j < i + k && j < n; j++)
		{
			t = s.substr(i, j - i + 1);
			ans.insert(t);
		}
	}

	set<string>::iterator it = ans.begin();
	while(--k) ++it;
	cout << *it;
}

Measured memory_bytes: 1664
N,S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353

dp = [[0]*3005 for _ in range(3005)]
dp[0][0] = 1
for i in range(0,N):
    for s in range(0,S+1):
        if s-A[i] >= 0:
            dp[i+1][s] = dp[i][s]*2 + dp[i][s-A[i]]
        else:
            dp[i+1][s] = dp[i][s]*2
        dp[i+1][s] %= mod

print(dp[N][S])

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

void unique_count(vector<int> &a, vector<vector<int>> &b) {
	// erase(b.begin(), b.end());
	for (int i=0; i<a.size(); i++)
		if ((i>0)&&(a.at(i)==a.at(i-1)))
			b.back().at(1)++;
		else
			b.push_back({a.at(i), 1});
	return;
}

int	main() {
	int N;
	cin >>N;
	vector<int> A(N, 0);
	for (int i=0; i<N; i++)
		cin >>A.at(i);
	sort(A.begin(), A.end());
	vector<vector<int>> b;
	unique_count(A, b);
	int P=0;
	int S=pow(2, 30);
	while(S>1) {
		int L=0;
		int R=b.size()-1;
		while(L<=R) {
			if (0==b.at(L).at(1))
				L++;
			else if (0==b.at(R).at(1))
				R--;
			else {
				int LL=b.at(L).at(0);
				int RR=b.at(R).at(0);
				if (S==LL+RR) {
					if (L==R) {
						if (2<=b.at(L).at(1)) {
							P++;
							b.at(L).at(1) -=2;
						} else {
							L++;
							R--;
						}
					} else {
						P++;
						b.at(L).at(1)--;
						b.at(R).at(1)--;
					}
				} else if (S<LL+RR)
					R--;
				else
					L++;
			}
		}
		S /=2;
	}
	cout <<P <<endl;
	return 0;
}



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

using namespace std;

int main(){

    int i,n,x,im=0;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>x;
        if(x%2==0){
            if(x%3!=0&&x%5!=0) im=1;
        }
    }

    if(im==1) printf("DENIED\n");
    else printf("APPROVED\n");


    return 0;
}


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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

typedef long long int           ll;
typedef unsigned long long int  ull;
typedef long double             ld;

typedef pair<int, int>          pii;
typedef pair<ll,ll>             pll;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<pii>             vpii;
typedef vector<pll>             vpll;

#define test(t)		        int t; cin >> t; while(t--)
#define f(i, a, b)	        for(int (i) = (a); (i) < (b); ++(i))
#define all(a)		        (a).begin(), (a).end()
#define endl 		        "\n"
#define deb(x)		        cout << #x << ": " << x << endl;
#define deb2(x,y)	        cout << #x << ": " << x << " ~ " <<  #y << ": " << y << endl;
#define deba(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define debap(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n.first << "-" << n.second << " "; cout << "]" << endl;
#define fast 		        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
    int x;
    cin >> x;
    cout << !x << endl;
}

int main()
{
    fast;
    // test(t)
        solve();
    return 0;
}

Measured memory_bytes: 3636
# https://tjkendev.github.io/procon-library/python/range_query/bit.html
# Binary Indexed Tree (Fenwick Tree)
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
        self.el = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)


def main():
    from string import ascii_lowercase
    import sys
    input = sys.stdin.readline

    n = int(input())
    s = [ascii_lowercase.index(c) for c in input().rstrip()]
    q = int(input())

    bits = [BIT(n) for _ in range(26)]
    for base1, ord in enumerate(s, 1):
        bits[ord].add(base1, +1)

    ret = []
    for _ in range(q):
        it = iter(input().split())
        if next(it) == '1':
            # 変更
            base1 = int(next(it))

            prev_ord = s[base1 - 1]
            next_ord = ascii_lowercase.index(next(it))

            bits[prev_ord].add(base1, -1)
            bits[next_ord].add(base1, +1)

            s[base1 - 1] = next_ord

        else:
            # 返答
            start, end = map(int, it)
            res = sum(
                bits[ord].get(start - 1, end) > 0
                for ord in range(26)
            )

            ret.append(res)

    print(*ret, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 249500
using System;
using System.Linq;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var sp = Console.ReadLine().Split(' ');
            var n = int.Parse(sp[0]);
            var m = int.Parse(sp[1]);
            var h = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var abAry = new int[m][];
            for (int c = 0; c < m; c++)
            {
                abAry[c] = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            }

            var fromA = abAry.ToLookup(ab => ab[0]);
            var fromB = abAry.ToLookup(ab => ab[1]);

            int cnt = 0;
            for (int c = 0; c < n; c++)
            {
                int max = 0;
                foreach(var ab in fromA[c+1])
                {
                    max = Math.Max(max, h[ab[1] - 1]);
                }
                foreach(var ab in fromB[c+1])
                {
                    max = Math.Max(max, h[ab[0] - 1]);
                }
                if (max < h[c])
                {
                    cnt++;
                }
            }

            Console.WriteLine(cnt);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 69064
package main

import "fmt"

func main() {
	var k, x int
	fmt.Scan(&k, &x)
	for i := x - (k - 1); i < x; i++ {
		fmt.Println(i)
	}
	for i := x; i < x+k; i++ {
		fmt.Println(i)
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <cstring>
#include <numeric>
#include <stack>
#include <iomanip>
#include <chrono>
using namespace std;

#define inf 200000000000000
#define mod 1000000007
#define eps 1e-7
#define PI 3.1415926535897932385

#define sd(mark) scanf("%d",&mark)
#define ss(mark) scanf("%s",mark)
#define sl(mark) scanf("%lld",&mark)
#define clr(mark) memset(mark,0,sizeof(mark))
#define setinf(mark) memset(mark,0x3f,sizeof(mark))

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()

#define int ll

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

#ifndef KaalaNamak
#define endl '\n'
#define trace(...)
#define start_routine() 
#define end_routine()
#endif

int power(int x, int y) { 
    int res = 1;      
    x = x % mod; 
    while (y > 0) { 
        if((y & 1)==1) res = (res * x) % mod; 
        y = y >> 1;  
        x = (x * x) % mod;  
    } 
    return res; 
} 

signed main() {
    start_routine();
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);
    cout<<fixed<<setprecision(10);
    int t=1;
    // cin>>t;
    #ifdef KaalaNamak
        t=4;
    #endif
    while(t--){
        int n;
        cin>>n;
        int res;
        res= power(10,n)+power(8,n) - 2*power(9,n) + mod+mod;
        cout<<res%mod<<"\n";

    }
    end_routine();

} 

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
//=============================
void input()
{
    cin>>K;

}
//=============================
void func(){}
//=============================
void solve()
{
    int ev,od;
    od = (K+1)/2;
    ev = K/2;
    cout<<ev*od<<endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	long[] a = new long[n];
      	long b = 0;
      	long b2 = 0;
      	long sum = 0;
      	long sum2 = 0;
      	for(int i=0; i<n; i++){
        	a[i] = sc.nextLong() - (i+1);
        }
      	Arrays.sort(a);
      	if(n%2==0){
        	b = (a[n/2] + a[n/2-1])/2;
          	b2 = b + 1;
          	for(int i=0; i<n; i++){
            	sum += Math.abs(a[i]-b);
              	sum2 += Math.abs(a[i]-b2);
            }
          	sum = Math.min(sum, sum2);
        }
      	else{
        	b = a[(n+1)/2 - 1];
          	for(int i=0; i<n; i++){
            	sum += Math.abs(a[i]-b);
            }
        }
      	System.out.println(sum);
    }
}


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


using ll = long long;
const int MaxN = 3000+10;
const int Mod = 998244353;
int N, S;
int A[MaxN];
int C[MaxN];


void solve()
{
    ll ans = 0;
    for (int k = 1; k <= N; k++) {
        C[0] = (C[0] + 1) % Mod;
        for (int i = S; i >= A[k]; i--)
            C[i] = (C[i] + C[i - A[k]]) % Mod;
        ans = (ans + C[S]) % Mod;
    }
    cout << ans << endl;
}


int main()
{
    cin >> N >> S;
    for (int i = 1; i <= N; i++) cin >> A[i];
    solve();
    return 0;
}


Measured memory_bytes: 256
while True:
    try:
        L = [int(x) for x in list(input())]
    except:
        break

    T =[]
    while len(L) > 1:
        for i in range(len(L)-1):
            T.append( (L[i] + L[i+1])%10 )
        L = T[:]
        T = []
    print(L[0])



Measured memory_bytes: 5600
import scala.io.StdIn.{readInt,readLine}

object Main {
  def toBinaryString(d:Double,cnt:Int,s:String):String = {
    if(d==0D) "0"
    else if(cnt>4) "NA"
    else {
      val d2 = d*2D
      if(d2 == 1D) s+"1"
      else if(d2>1D) toBinaryString(d2-1D,cnt+1,s+"1")
      else toBinaryString(d2,cnt+1,s+"0")
    }
  }

  def main(args:Array[String]) = {
    Iterator.continually(readLine).takeWhile(_.trim.toDouble >= 0.0 ).foreach { s =>
      val d = s.trim.toDouble
      val d1 = d.toInt.toBinaryString
      val d2 = d-d.toInt
      val d2tob = toBinaryString(d2,0,"")

      if(d2tob=="NA") println("NA")
      else if(d2tob.length>4) println("NA")
      else if(d1.length>8) {
        println("NA")
      } else {
        println(("0"*(8-d1.length))+d1+"."+d2tob+("0"*(4-d2tob.length)))
      }
    }
  }
}

Measured memory_bytes: 45888
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i, n) FOR(i,0,n)
#define INF 1e12
const int MOD = 1000000007;
typedef pair<ll,ll> P;

int main(void){
    int N,M,ans=0;
    cin >> N >> M;
    FOR(i,1,N) ans += i;
    FOR(i,1,M) ans += i;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
  	
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		
		for(int i=0;i<S.length();i++){
			System.out.print("x");
		}
		
		System.out.println();
		
	}
}

Measured memory_bytes: 23124