akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
using namespace std;

int main() {
	int n;
	cin >> n;
	double t, a, h[n], res = 100000000.0;
	cin >> t >> a;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		h[i] = t - h[i] * 0.006;
		if (abs(h[i] - a) < res) {
			res = abs(h[i] - a);
			ans = i + 1;
		}
	}
	cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }

  int cnt = 0;

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      double dsum = 0;
      for (int k = 0; k < d; k++) {
        dsum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }

      const int di = sqrt(dsum);
      if (di * di == dsum) {
        ++cnt;
      }
    }
  }

  cout << cnt << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>

using namespace std;

string narabi = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
int convert(char c) {
	if (c >= 'a' && c <= 'z')return c - 'a';
	else return c - 'A' + 26;
}

int main() {
	int N;
	while (cin >> N, N != 0) {
		vector<int> rolling;
		for (int i = 0; i < N; i++) {
			int a;
			cin >> a;
			rolling.push_back(a);
		}

		string ans = "";
		string input;
		cin >> input;
		for (int i = 0; i < input.size(); i++) {
			ans += narabi[(convert(input[i]) - rolling[i % rolling.size()] + 52) % 52];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3160
from collections import deque 

n = int(input())

data = deque()

for i in range(n):
    command = input().split()
    
    if command[0] == "insert":
        data.appendleft(command[1])
    elif command[0] == "delete":
        # if command[1] in data:
        try:
            data.remove(command[1])
        except ValueError:
            pass
    elif command[0] == "deleteFirst":
        data.popleft()

    elif command[0] == "deleteLast":
        data.pop()

print(" ".join(data))



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

int main() {
  int n;
  cin >> n;
  string s,t,t1;
  cin >> s >> t;
  for (int i = n-1; i > -1; i--){
    t1 = s[i];
    t.insert(i, t1);
  }
  cout << t << endl;
}

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

int L[200];


int main(void) {
  int N;
  cin >> N;

  vector <int> L;
  for (int i = 0; i < 2*N; i++) {
	  int l;
	  cin >> l;
	  L.push_back(l);
  }

  sort(L.begin(), L.end());
  int ans = 0;
  for (int i = 0; i < N; i++) {
	  ans += L[i*2];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int ab[2001];

int main()
{
    int n;

    while (cin >> n) {
        int ans = 0;

        for (int i = 0; i < 2001; i++)
            ab[i] = 0;
        
        for (int a = 0; a <= 1000; a++)
            for (int b = 0; b <= 1000; b++)
                ab[a + b]++;
        
        for (int c = 0; c <= 1000; c++)
            for (int d = 0; d <= 1000; d++)
                if (n - c - d >= 0 && n - c - d <= 2000)
                    ans += ab[n - c - d];

        cout << ans << endl;
    }

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int s[n];
    int sum = 0;
    int p = 10000;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        sum += s[i];
        if(s[i] % 10 != 0){
            p = min(p,s[i]);
        }
    }
    if(sum % 10 == 0 && p != 10000){
        sum = sum - p;
    }
    else if (sum % 10 == 0 && p == 10000){
        sum = 0;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for A in range(a+1):
    for B in range(b+1):
        for C in range(c+1):
            if 500*A + 100*B + 50*C == x:
                cnt += 1
print(cnt)

Measured memory_bytes: 9184
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSkillUp solver = new CSkillUp();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSkillUp {
        int min = Integer.MAX_VALUE;
        int n;
        int m;
        int x;
        int[] c;
        int[][] book;
        int[] skill;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            n = in.nextInt();
            m = in.nextInt();
            x = in.nextInt();

            c = new int[n];
            book = new int[n][m];
            skill = new int[m];

            for (int i = 0; i < n; i++) {
                c[i] = in.nextInt();
                for (int j = 0; j < m; j++) {
                    book[i][j] = in.nextInt();
                }
            }

            dfs(-1, 0, skill);

            out.println(min == Integer.MAX_VALUE ? -1 : min);
        }

        public void dfs(int index, int cost, int[] skill) {
            index++;
            if (index == n) {
                // judge
                for (int i = 0; i < m; i++)
                    if (skill[i] < x) return;
                min = Math.min(min, cost);
                return;
            }

            dfs(index, cost, skill);
            for (int i = 0; i < m; i++) {
                skill[i] += book[index][i];
            }
            dfs(index, cost + c[index], skill);
            for (int i = 0; i < m; i++) {
                skill[i] -= book[index][i];
            }
        }

    }
}



Measured memory_bytes: 39056
using System;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int one = int.Parse(str[0]);
            int two = int.Parse(str[1]);
            int three = int.Parse(str[2]);
            int count = 0;
            for (int i = one; i <= two; i++)
            {
                if (three % i == 0)
                {
                    count++;
                }

            }
            Console.WriteLine(count);


        }
    }
}



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

int main() {
	ll n;
	cin>>n;
	vector<queue<ll>>a(1010);
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n-1;j++){
			ll x;
			cin>>x;
			x--;
			a[i].push(x);
		}
	}
	set<ll>ch;
	for(ll i=0;i<n;i++){
		ll nex=a[i].front();
		if(a[nex].front()==i){
			ch.insert(i);
			//cout << i<<endl;
		}
	}
	ll cnt=0;
	while(ch.size()!=0){
		cnt++;
		vector<ll>b;
		for(auto itr=ch.begin();itr!=ch.end();itr++){	
			a[*itr].pop();
			b.push_back(*itr);
		}
		ch.clear();
		while(b.size()!=0){
			ll now=b.back();
			b.pop_back();
			if(a[now].size()==0){
				continue;
			}
			ll nex=a[now].front();
			if(a[nex].front()==now){
				ch.insert(now);
				ch.insert(nex);
			}
		}
	}
	for(ll i=0;i<n;i++){
		if(a[i].size()!=0){
			cout << -1;
			return 0;
		}
	}
	cout <<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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


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

    int a, b; cin >> a >> b;
    int ans = 0;
    if(a > b) {
        ans += a;
        a--;
    } else {
        ans += b;
        b--;
    }
    ans += max(a, b);
    COUT(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdio>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<iomanip>
#include<list>
#include<set>
#include<utility>
using namespace std;

//repetition
//------------------------------------------

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
//#define INF (1 << 30)
#define pii pair<int, int>

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

static const int INF = 1000000010;
int d[510][510];
string s[510];

int main() {
  int n, a, num;
  cin >> n >> a;
  if(n>=500){
    num = n % 500;
  } else {
    num = n;
  }
  if(a - num >= 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
rist = input().split()
while int(rist[0])>0 and int(rist[2])>0:
  if int(rist[2])-int(rist[1])<=0:
    print("Yes")
    break
  else:
    rist[2] = int(rist[2])-int(rist[1])
 
  if int(rist[0])-int(rist[3])<=0:
    print("No")
    break
  else:
    rist[0] = int(rist[0])-int(rist[3])

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

int main() {
    int n,y;
    cin >> n >> y;
    for(int i=0;i<=n;i++)for(int j=0;j<=n;j++){
        int sum = i*10000+j*5000 +(n-i-j)*1000;
        if(i+j<=n&&sum == y){
            cout << i<<" "<<j<<" "<<n-i-j<<endl;
            return 0;
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
import bisect
n = int(input())
*L, = map(int, input().split())
L.sort()
cnt = 0
for i in range(n-2):
    a = L[i]
    for j in range(i+1, n-1):
        b = L[j]
        l = max(j+1, bisect.bisect_left(L, b-a))
        r = bisect.bisect_left(L, b+a)
        cnt += r-l
print(cnt)


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

using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b == 2 ? a : gcd(b, a % b);};
ll poww(ll a, ll b, ll md) {
   return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
const int MOD = 1e9+7;
const int SIZE = 1e5+10;
int main()
{
    //ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m,p,k;
    cin>>n>>m>>p>>k;
    //if(m>p){
        for(int i=0;i<k;i+=1){
            if(m<n || m==n){
               m = m*2;
               //cout<<m<<endl;
            }else if(p<m || p==m){
                p = p*2;
            }
        }
        //cout<<n<<m<<p<<endl;
        if(m>n && p>m) cout<<"Yes\n";
        else cout<<"No\n";
    //}










    return 0;
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














ll A, V, B, W, T;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> V >> B >> W >> T;
	if (A > B) swap(A, B);
	A += V * T;
	B += W * T;

	if (B <= A) cout << "YES" << endl;
	else cout << "NO" << endl;
}







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

int main() {
	int n,count=0;cin>>n;
  	vector<int> a(n);for(int i=0;i<n;i++) cin>>a[i];
  	for(int i=0;i<n-1;i++){
    	if(a[i]==a[i+1]){
        	count++;
          	i++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
  "strconv"
)

func main(){
  var A,B int
  fmt.Scan(&A, &B)
  result := 0
  for i:=A; i<=B; i++{
    s := strconv.Itoa(i)
    // fmt.Println(s)
    check := 1
    for j:=0; j<len(s); j++{
      // fmt.Println(j)
      if s[j] != s[len(s) - j-1]{
        check = 0
      }
    }
    if check == 1{
      result +=1
    }
  }
  fmt.Println(result)
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll H, W, N;
ll a[10010];
ll fld[110][110];

int main()
{
  std::cin >> H >> W >> N;
  rep( i, N )
    std::cin >> a[i];

  int curi = 0, curj = 0, cnt = 0, p = 1, all = 0;
  bool down = true;

  while( all < H*W )
  {
    fld[curi][curj] = p;

    ++cnt;
    ++all;

    //std::cout << i << ' ' << j << std::endl;

    if( cnt >= a[p-1] )
      ++p, cnt = 0;

    if( down )
    {
      if( curi < H-1 )
        ++curi;
      else
        ++curj, down ^= true;
    }
    else
    {
      if( curi > 0 )
        --curi;
      else
        ++curj, down ^= true;
    }
  }

  rep( i, H ) rep( j, W )
    std::cout << fld[i][j] << (j==W-1?'\n':' ');

  return 0;
}

Measured memory_bytes: 512
s = input()
t = input()
S = len(s)
T = len(t)
ans= ''
for i in range(S-T+1):
    c = 1
    for j in range(T):
        if s[i+j] == t[j] or s[i+j] == '?':
            continue
        else:
            c = 0
    if c :
        ans = s[0:i] + t + s[i+T:]
if ans:
    ans = ans.replace('?','a')
    print(ans)
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
using namespace std;
int T,t[100005],x[100005],y[100005];
int main()
{	
	cin>>T;
	int flag=true,a=0,b=0;
	for(int i=1;i<=T;i++)
	{
		cin>>t[i]>>x[i]>>y[i];
		if(((t[i]-t[i-1])-(abs(x[i]-a)+abs(y[i]-b)))%2!=0||((t[i]-t[i-1])-(abs(x[i]-a)+abs(y[i]-b))<0))
                flag=false;	
		a=x[i];b=y[i];
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int toplus(int);
int main(void) {
	int h[6];
	int i, j;
	int flg = 0;
	for (i = 0; i < 6; i++) {
		scanf("%d", &h[i]);
	}
	for (i = 0; i < 4; i++) {
		for (j = i + 1; j < 5; j++) {
			if (toplus(h[i]-h[j]) > h[5]) {
				flg = 1;
				break;
			}
		}
	}
	if (flg) {
		printf(":(\n");
	}
	else {
		printf("Yay!\n");
	}
	return 0;
}
int toplus(int x) {
	if (x < 0) {
		return -1 * x;
	}
	else {
		return x;
	}
}

Measured memory_bytes: 128
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

fn main() {
    input!{
        n: i64,
        m: i64,
    }

    if (n - m).abs() > 1 {
        println!("0");
        return;
    }
    let mut ans = 1;

    for i in 0..n {
        ans *= i + 1;
        ans %= 1_000_000_007;
    }
    for i in 0..m {
        ans *= i + 1;
        ans %= 1_000_000_007;
    }
    if n == m {
        ans *= 2;
        ans %= 1_000_000_007;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void){
	
	int a[20000],b[20000],i=0;
	char op[20000];
	for(i=0;i<20000;i++){
		scanf("%d %c %d",&a[i],&op[i],&b[i]);
		if(op[i] == '?'){
			break;
		}
		else if(op[i] == '+'){
		printf("%d\n",a[i]+b[i]);
		}
		else if(op[i] == '-'){
		printf("%d\n",a[i]-b[i]);
		}
		else if(op[i] == '*'){
		printf("%d\n",a[i]*b[i]);
		}
		else if(op[i] == '/'){
		printf("%d\n",a[i]/b[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;



signed main(){
    int m, n;
    cin >> m >> n;
    vector<int> d(m);
    rep(i, 0, m){
        int a;
        rep(j, 0, n){
            cin >> a;
            d[i] += a;
        }
    }
    sort(all(d));
    cout << d[m - 1] << endl;
}

Measured memory_bytes: 1216
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()
ans = INF
for x in set(s):  # xとの距離を調べる
	ans = min(ans, max([len(l) for l in s.split(x)]))

print(ans)


Measured memory_bytes: 5200
#include <math.h>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<stdio.h>
#include <iostream>
#include <vector>
#include <set>
//#include <string.h>
using namespace std;
using Graph = vector<vector<int>>;
queue<long>que;

int main(){
    int k;
    cin>>k;
    long ans=0;
    if(k<10)cout<<k<<endl;
    else{
        rep(i,9)que.push(i+1);
        int cnt=9;
        bool fin =false;
        
        while(fin==false){
        long num = que.front();
        que.pop();

        if(num%10==0){
            num = num*10;
            rep(i,2){
                long num1 = num+i;
                que.push(num1);
                cnt++;
                if(cnt == k){ans =num1;
                    fin = true;}
            }
        }
        else if(num%10<9){
            num = num*10+(num%10)-1;
            rep(i,3){
                long num1 = num+i;
                que.push(num1);
                cnt++;
                if(cnt == k){ans =num1;
                    fin = true;}
            }
        }
        else{
            num = num*10+(num%10)-1;
            rep(i,2){
                long num1 =num+i;
                que.push(num1);
                cnt++;
                if(cnt == k){ans =num1;
                    fin = true;}
            }
        }
        }
        
        cout << ans <<endl;
    }

}


Measured memory_bytes: 768
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

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

using namespace std;

int main(int argc, char* argv[]){
  long long int N, K;
  cin >> N >> K;
  long long int ans = 0;

  long long int low, high, tmp;
  for(long long int i = K; i <= N + 1; i++){
    low = (i - 1) * i / 2;
    high = i * (N - (i - 1) + N) / 2;
    tmp = high - low + 1;
    ans = (ans + tmp) % 1000000007;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll r;
    cin >> r;
    printf("%lld\n", 3 * r * r);
    return 0;
}


Measured memory_bytes: 256
# 拡張ユークリッド互除法
# ax + by = gcd(a,b)の最小整数解を返す
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


n = int(input())
A = list(map(int, input().split()))
C = [-1] * (n+1)
lr = 0
for i, a in enumerate(A):
    if C[a] == -1:
        C[a] = i
    else:
        lr = C[a] + n - i
        break


def combination(n, mod):
    lst = [1]
    for i in range(1, n+1):
        lst.append(lst[-1] * (n+1-i) % mod * modinv(i, mod) % mod)
    return lst


mod = 10**9+7
NC = combination(n+1, mod)
LRC = combination(lr, mod)
for i in range(1, n+2):
    print((NC[i] - (LRC[i-1] if i-1 <= lr else 0)) % mod)


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

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

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


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

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

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

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####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

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####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

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

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

N,K = IL()
S = N-K+1

for i in range(1,K+1):
  print(nCr(S,i)*nCr(K-1,i-1)%MOD)

Measured memory_bytes: 43376
#include<bits/stdc++.h>
#define pir pair<int,int>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
#define rsort(x,y) sort(x,y),reverse(x,y)
#define fr first
#define se second
using namespace std;
typedef long long ll;
const int Maxn=2100000;
const int inf=0x3f3f3f3f;

int n,ans;
char s[Maxn];

signed main() {
    // freopen("test.in","r",stdin);
    scanf("%d",&n);
    scanf("%s",s);
    int l=0,r=n-1;
    while(l<=r) {
        while(s[l]!='W'&&l<=r) l++;
        while(s[r]!='R'&&l<=r) r--;
        if(s[l]=='W'&&s[r]=='R'&&l<=r) ans++;
        l++,r--;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4020
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}

void solve() {
    int n,k;
    cin >> n >> k;
    int h[n];
    for(int i = 0;i < n;i++){
        cin >> h[i];
    }
    int c = 0;
    for(int i = 0;i < n;i++){
        if(k <= h[i]){
            c++;
        }
    }
    cout << c << endl;

}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define rep(i,n) for(i=0;i<n;i++)
#define PI 3.14159265358979323846264338327950L
int main(){
    int n;
    scanf("%d",&n);
    char s[n];
    scanf("%s",s);
    int i,cnt=0;
    rep(i,n-2){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') cnt++;
    }
    printf("%d",cnt);
    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n,ans=0;
    cin>>n;
    vector<ll> a(n+1),b(n);
    for (int i = 0; i < n+1; i++)
    {
        cin>>a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin>>b[i];
    }
    for (int i = 0; i < n; i++)
    {
        if(a[i]>=b[i])
        {
            ans+=b[i];
        }
        else
        {
            ans+=a[i];
            b[i]-=a[i];
            ans+=min(a[i+1],b[i]);
            a[i+1]-=min(a[i+1],b[i]);
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;



int n, a[300000];
signed main(){
  scanf("%lld", &n);
  rep(i,3*n)scanf("%lld", &a[i]);
  sort(a, a+3*n);
  int ans = 0, cnt = 0;
  drep(i,3*n-2,0){
    if(cnt == n)break;
    ans += a[i];
    i--;cnt++;
  }
  printf("%lld\n", ans);
	return 0;
}









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

using namespace std;

int my_max(int a, int b) {
    return a > b ? a : b;
}

int my_abs(int x) {
    return x < 0 ? -x : x;
}

unsigned long long dp[110][100010];

int main() {

    for(int i=0; i<110; i++) {
        for(int j=0; j<100010; j++) {
            dp[i][j] = UINT32_MAX;
        }
    }

    int n, w;
    int datas[100][2];
    cin >> n >> w;
    for(int i=0; i<n; i++) {
        cin >> datas[i][0] >> datas[i][1];
    }

    for(int i=0; i<=100010; i++) {
        if(datas[0][1]>=i) {
            dp[0][i] = datas[0][0];
        }
    }

    for(int i=0; i<110; i++) {
        dp[i][0] = 0;
    }

    for(int i=1; i<n; i++) {
        for(int j=0; j<=100010; j++) {
            if(j-datas[i][1]>=0) {
                dp[i][j] = min(dp[i-1][j], datas[i][0]+dp[i-1][j-datas[i][1]]);
            }
            else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    for(int i=100010-1; i>=0; i--) {
        if(dp[n-1][i] <= w) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 86144
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    a, b, x = map(int, input().split())
    print("YES" if a <= x <= a + b else "NO")
resolve()

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

int main() {
  long N,K,Q;
  cin>>N>>K>>Q;
  vector<int> a(Q);
  vector<long> ans(N,K-Q);
  for(int i=0;i<Q;i++){
    cin>>a.at(i);
  }
  for(int i=0;i<Q;i++){
    ans.at(a.at(i)-1)++;
  }
  for(int i=0;i<N;i++){
    if(ans.at(i)>0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}


Measured memory_bytes: 1792
n = STDIN.gets.to_i
S = STDIN.gets.split(' ').uniq.map {|i| i.to_i}
q = STDIN.gets.to_i
T = STDIN.gets.split(' ').map {|i| i.to_i}

found_count = 0
T.each do |t|
  left = 0
  right = S.length
  mid = 0
  while left < right
    mid = (left+right)/2
    # p "t: #{t}"
    # p "#{left} , #{right}"
    # p "S[mid] #{S[mid]}"
    if S[mid]==t
      found_count += 1
      break
    elsif S[mid] > t
      right = mid
    else
      left = mid + 1
    end
  end
#  p "#{t} #{S[mid]} [#{left},#{right}]"
end

print "#{found_count}\n"

Measured memory_bytes: 19928
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
int gcd(int x, int y)
{
    if(y==0)
        return x;
    return gcd(y, x%y);
}

 long long numbers[500005];

//int a[100005];

 int main(){

 long long n,k;
 cin>>n>>k;

 int done[n] = {0};

 while(k--)
 {
  int d,x;
   cin>>d;

   for(int i=0;i<d;i++){
        cin>>x;
     done[--x] = 1;
   }
 }

 int cnt=0;

 for(int i=0;i<n;i++){
    //    cout<<done[i]<<"  ";
    if(done[i] == 0){
        cnt++;
    }
 }

 cout<<cnt<<endl;

 return 0;
 }

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

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
/*
template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
 */
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e5 + 5;
const int INF = 2e9;

ll dp[MAXN][15];

int main() {
	//usaco("milkvisits");

#ifdef LOCAL
	setIn("in.txt");
	//setOut("out.txt");
#endif

	string s;
	cin >> s;

	if(s[0] == '?'){
		for(int i = 0; i < 10; i++){
			dp[0][i] = 1;
		}
	}
	else{
		dp[0][s[0] - '0'] = 1;
	}

	for(int i = 1; i < s.size(); i++){
		for(int j = 0; j < 13; j++){
			if(s[i] != '?'){
				int k = s[i] - '0';
				dp[i][(j * 10 + k) % 13] += dp[i - 1][j];
				dp[i][(j * 10 + k) % 13] %= MOD;
				continue;
			}
			for(int k = 0; k < 10; k++){
				dp[i][(j * 10 + k) % 13] += dp[i - 1][j];
				dp[i][(j * 10 + k) % 13] %= MOD;
			}
		}
	}

	cout << dp[s.size() - 1][5];
}

Measured memory_bytes: 12160
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>


int main(){
  int a,s=0,n,x;
  scanf("%d",&n);
  x=n;
  for (int i = 11; i >=0 ; i--) {
    a=pow(10,i);
    if(a<=n){
      s+=n/a;
      n-=(n/a)*a;
    }
  }
  if(x%s==0){
  printf("Yes");
}else{
  printf("No");
}
  return 0;

}


Measured memory_bytes: 128
//--------------------------------------------------
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2,popcnt,fma")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
//--------------------------------------------------
#include <bits/stdc++.h>
#include <chrono>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <stack>
#include <cstring>
//--------------------------------------------------
#define forn(i, n) for(int i = 0; i < n; i++)
#define forw(i, n) for(int i = n-1; i >= 0; --i)
#define forns(i, n, s) for(int i = s; i < n; i++)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
//----------------------------------------------------
using namespace std;
//----------------------------------------------------
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef vector<ll> lnum;
typedef complex<ld> comp;
//----------------------------------------------------
const ll mod = 1e9 + 7, mod2 = 998244353;
const ld eps = 1e-6;
const ll inf = 1e18;
const int base = 1e9;
const ld PI = 3.1415926;
//----------------------------------------------------
//#define endl '\n';
#ifdef MY_DEBUG
void deb(ld x) { cerr << x << endl; };
#else
void deb(ld x){};
#endif
//----------------------------------------------------
//----------------------------------------------------
int n, m;
//----------------------------------------------------
unsigned int bitcount(ull val) { return __builtin_popcount(val) + __builtin_popcount(val >> 32); }

void local() {
    freopen("test.in", "r", stdin);
}

void remote() {
}

void read() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> m;
}


int main() {
#ifdef MY_DEBUG
    local();
#else
    remote();
#endif
    read();

    cout << (n * (n-1)/2 + m*(m-1)/2) << endl;

}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

signed main () {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  vector<int> b(n+1);
  b[0] = 0;
  REP(i, n) {
    b[i+1] = (b[i] + a[i]) % m;
  }
  //REP(i, n) cout << b[i+1] << endl;
  unordered_map<int, int> c;
  REP(i, n+1) c[b[i]]++;
  int ans = 0;
  for(auto i = c.begin();i != c.end() ; ++i) ans += i->second * (i->second - 1) / 2;
  //  REP(i, n) if(!a[i]) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 5260
//AtCoder
//AGC013B Hamiltonish Path

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

const int MAXN=100000+10;
vector<int> edge[MAXN];
vector<int> path1,path2;
int vis[MAXN];
int n,m;

void dfs(int t)
{
	vis[t]=1;
	
	path1.push_back(t);
	
	for(int i=0;i<edge[t].size();++i)
		if(!vis[edge[t][i]])
		{
			dfs(edge[t][i]);
			return;
		}
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	cin>>n>>m;
	
	int x,y;
	for(int i=0;i<m;++i)
	{
		cin>>x>>y;
		
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	
	dfs(1);
	swap(path1,path2);
	dfs(1);
	
	cout<<int(path2.size()+path1.size()-1)<<endl;
	for(int i=int(path2.size()-1);i>0;--i)
		cout<<path2[i]<<' ';
	for(int i=0;i<path1.size();++i)
		cout<<path1[i]<<' ';
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 9976
using System;

namespace AtCoder.ABC._100
{
    class b
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var spl = line.Split(' ');
            var D = int.Parse(spl[0]);
            var N = int.Parse(spl[1]);
            Console.WriteLine(N != 100 ? Math.Pow(100, D) * N : Math.Pow(100, D) * (N + 1));
        }
    }
}


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

int main() {
	int N,i=0,tyu=0,X[200000]={},A[200000]={},b=0;
	bool flag=false;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>X[i];
		A[i]=X[i];
	}
	sort(A,A+N);
	tyu=A[N/2-1];
	for(int j=0;j<N;j++)
	{
		if(X[j]<=tyu)cout<<A[N/2]<<endl;
		else cout<<tyu<<endl;
	}
	}

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

int main()
{
    long long k,n,m,i;
    queue<long long>s;
    cin>>k;
    for(i=1;i<=9;i++)
        s.push(i);
    for(i=1;i<=k;i++)
    {
       n=s.front();
       s.pop();
       m=n%10;
       if(m!=0)
        s.push(10*n+m-1);
       s.push(10*n+m);
       if(m!=9)
        s.push(10*n+m+1);
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define sort(x) sort(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define f first
#define s second
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
int a[100005], n, m;

int main(){
	int i, j;
	cin >> n >> m;
	int ans = 0;
	int ou = 1;
	while(ou < m){
		ou--;
		ou += n;
		ans++;
	}
	cout << ans;
}


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

int main() {
  double a=0, b=0, c=0;
  int d=0;
  cin >> a >> b;
  c = (a+b)/2;
  d = (a+b)/2;
  if(c-d>0){
    d++;
  }
  cout << d << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
set<int> st;
set<int>::iterator it;
int main(){
	int n;
	cin>>n;
	while(n--){
		int a;
		cin>>a;
		it=st.find(a);
		if(it!=st.end()){
			st.erase(a);
		}else{
			st.insert(a);
		} 
	}
	int ans=0;
	for(int i=0;i<st.size();i++){
		ans++;
	} 
	cout<<ans<<endl;
}


Measured memory_bytes: 4864
from collections import deque
import itertools


def bfs():
    H, W = map(int, input().split())
    C = list(map(int, input().split()))
    D = list(map(int, input().split()))
    S = [list(input()) for _ in range(H)]

    tests = (0, 1), (1, 0), (-1, 0), (0, -1)
    # warps = itertools.product(range(-2, 3), range(-2, 3))

    start = (0, C[0] - 1, C[1] - 1)
    goal = (D[0] - 1, D[1] - 1)

    queue = deque()
    # (ワープ回数, x, y)
    queue.append(start)

    while queue:
        w_n, x, y = queue.popleft()

        # 通常移動
        for dx, dy in tests:
            nx = x + dx
            ny = y + dy

            if not (0 <= nx < H):
                continue

            if not (0 <= ny < W):
                continue

            if S[nx][ny] != "#":
                if S[nx][ny] != "." and w_n >= S[nx][ny]:
                    continue
                else:
                    S[nx][ny] = w_n
                    queue.appendleft((w_n, nx, ny))

        # warp
        for dx, dy in itertools.product(range(-2, 3), range(-2, 3)):
            nx = x + dx
            ny = y + dy

            if not (0 <= nx < H):
                continue

            if not (0 <= ny < W):
                continue

            if S[nx][ny] != "#":
                if S[nx][ny] != "." and w_n + 1 >= S[nx][ny]:
                    continue
                else:
                    S[nx][ny] = w_n + 1
                    queue.append((w_n + 1, nx, ny))

    if S[goal[0]][goal[1]] == ".":
        print(-1)
    else:
        print(S[goal[0]][goal[1]])


bfs()


Measured memory_bytes: 171128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll x, y;
 	cin >> x >> y;
 	set <ll> s;
 	s.insert(x);   
 	s.insert(y);
 	for (ll i = 1; i <= 3; i++) {
 		if (s.find(i) == s.end())
 			cout << i << endl;
 	}   
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

	for (unsigned int i = 0; i < S.length(); i++)
	{
		if (S[i] != T[i])
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
int main(void){

int sum , i;
char k[1000];

while(1){
scanf("%s",k);
if (k[0]=='0')break;
for (sum=0,i=0; k[i]!='\0'; i++) {
sum+=(k[i]-'0');
}
printf("%d\n",sum);
}
return 0;
}

Measured memory_bytes: 536