akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int[] ia = readNums();
		int a = ia[0];
		int b = ia[1];
		String line = readLine();
		if (line.length() != a + b + 1) {
			pln("No");
			return;
		}
		for (int i = 0; i < a; i++) {
			if (line.charAt(i) < '0' || '9' < line.charAt(i)) {
				pln("No");
				return;
			}
		}
		if (line.charAt(a) != '-') {
			pln("No");
			return;
		}
		for (int i = a + 1; i < a + 1 + b; i++) {
			if (line.charAt(i) < '0' || '9' < line.charAt(i)) {
				pln("No");
				return;
			}
		}
		pln("Yes");
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int N;
int V[20], C[20];

bool state[20];

int search(int itr)
{
    if (itr == N) {
        int X, Y;
        X = 0;
        Y = 0;
        REP(i, N) {
            if (state[i]) {
                X += V[i];
                Y += C[i];
            }
        }
        return X - Y;
    }
    else {
        state[itr] = true;
        int c1 = search(itr + 1);
        state[itr] = false;
        int c2 = search(itr + 1);
        return max(c1, c2);
    }

}

int main(int argc, char **argv)
{
    cin >> N;
    REP(i, N) cin >> V[i];
    REP(i, N) cin >> C[i];

    REP(i, N) state[i] = false;
    cout << search(0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
/*
int dfs(int foo, int timer)
{
    //foo is node number
    if (finds[foo].first != -1)
        return timer;
    finds[foo].first = ++timer;
    int result = timer;
    if (data[foo].size() != 0)
    {
        rep(i, data[foo].size())
        {
            result = dfs(data[foo][i], result);
        }
    }
    finds[foo].second = ++result;
    return result;
}
*/

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b;
    rep(i, m)
    {
        int temp;
        cin >> temp;
        b.push_back(temp);
    }
    int count = 0;
    rep(i, n)
    {
        int sum = 0;
        rep(j, m)
        {
            int temp;
            cin >> temp;
            sum += temp * b[j];
        }
        sum += c;
        if(sum>0)
            count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int x = 0;
        int l = 0;
        int r = 0;
        for (int i = 0 ; i < n ; i++) {
            if (s[i] == '(') {
                l++;
            }
            if (s[i] == ')') {
                r++;
            }
            x = Math.min(x, l - r);
        }
        int d = l - r;
        for (int i = 0 ; i < -1 * x ; i++) {
            System.out.print("(");
        }
        System.out.print(s);
        for (int i = 0 ; i < d - x ; i++) {
            System.out.print(")");
        }
        System.out.println("");

    }

}

Measured memory_bytes: 21972
i = input().split()
i_int = [int(n) for n in i]
a = input().split()
A = [int(m) for m in a]
N = i_int[0]
M = i_int[1]

th = sum(A)/(4 * M)

##print(threshhold)

c = 0
for val in A:
    if val >= th:
    ##print(val)
        c += 1

if c >= M:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  cout<<A.at(N-1)-A.at(0)<<endl;
}


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

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
    double r = Double.parseDouble(buf.readLine());
    double pi = 3.141592653589;
    System.out.printf("%.6f %.6f\n", pi*r*r, 2*pi*r);
  }
}

Measured memory_bytes: 24868
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    ll a; cin>>a;
    ll len = 1, d = 26;
    for(; a>d;){
        a -= d;
        len++;
        d *= 26;
    }
    vec<ll> o;
    a--;
    for(; len; a/=26, len--) o.pb(a%26);
    reverse(o.begin(), o.end());
    for(ll i : o) cout<<(char)('a'+i);
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>
#include <queue>
#include <utility>
#define INF 0x3FFFFFFF

using namespace std;


int main(void){
	int n, h, w, i, j, k, dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0}, s[11][20][20], d[11][11], a, b, dp[11][1 << 10], min;
	pair<int,int> l[11];
	queue<pair<int,int> > que;
	char field[20][21];
	while(1){
		scanf("%d%d%*c",&w,&h);
		if(w == 0 && h == 0) break;
		n = 1;
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				field[i][j] = getchar();
				if(field[i][j] == '*') l[n].first = j,l[n++].second = i, field[i][j] = '.';
				else if(field[i][j] == 'o') l[0].first = j, l[0].second = i, field[i][j] = '.';
			}
			getchar();
		}
		memset(s,-1,sizeof(s));
		for(i = 0;i < n;i++){
			que.push(l[i]);
			s[i][que.front().second][que.front().first] = 0;
			while(que.size()){
				a = que.front().first, b = que.front().second;
				for(j = 0;j < 4;j++){
					if(a + dx[j] >= 0 && a + dx[j] < w && b + dy[j] >= 0 && b + dy[j] < h && field[b + dy[j]][a + dx[j]] == '.' && s[i][b + dy[j]][a + dx[j]] == -1){
						que.push(pair<int,int>(a + dx[j],b + dy[j]));
						s[i][b + dy[j]][a + dx[j]] = s[i][b][a] + 1;
					}
				}
				que.pop();
			}
		}
		for(i = 0;i < n;i++){
			for(j = 1;j < n;j++){
				d[i][j] = s[i][l[j].second][l[j].first];
				if(i != 0){
					d[j][i] = s[i][l[j].second][l[j].first];
				}
			}
		}
		for(i = 0;i < n;i++){
			for(j = 1;j < n;j++) if(d[i][j] == -1) break;
			if(j != n) break;
		}
		if(i != n){
			printf("-1\n");
			continue;
		}
		for(i = 0;i < 1 << (n - 1);i++)
			for(j = 0;j < n;j++) dp[j][i] = INF;
		dp[0][0] = 0;
		for(i = 0;i < 1 << (n - 1);i++){
			for(j = 0;j < n;j++){
				for(k = 1;k < n;k++){
					if(~i & (1 << (k - 1)) && dp[k][i | (1 << (k - 1))] > dp[j][i] + d[j][k])
						dp[k][i | (1 << (k - 1))] = dp[j][i] + d[j][k];
				}
			}
		}
		min = INF;
		for(i = 0;i < n;i++)
			if(min > dp[i][(1 << (n - 1)) - 1]) min = dp[i][(1 << (n - 1)) - 1];
		printf("%d\n",min >= INF - 0x2000000 ? -1 : min);
	}
	return 0;
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int answer=1, X=0;
  for(int i=0; i+1<N; i++) {
    X=vec.at(i+1)-vec.at(i);
    if(X>0) {
      answer+=1;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);
  static int N;

  public static void main(String[] args) {
    N = sc.nextInt();
    int[] A = new int[N];
    int[] B = new int[N];
    int[] C = new int[N];
    int[] D = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
      B[i] = sc.nextInt();
    }
    for (int i = 0; i < N; i++) {
      C[i] = sc.nextInt();
      D[i] = sc.nextInt();
    }
    BiMatching bm = new BiMatching(N, N);
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (A[i] < C[j] && B[i] < D[j]) {
          bm.addEdge(i, j);
        }
      }
    }
    System.out.println(bm.matching());
  }

  static class BiMatching {
    ArrayList<ArrayList<Integer>> left = new ArrayList<>();
    ArrayList<ArrayList<Integer>> right = new ArrayList<>();
    int[] l2r, r2l;

    BiMatching(int n, int m) {
      l2r = new int[n];
      r2l = new int[m];
      Arrays.fill(l2r, -1);
      Arrays.fill(r2l, -1);
      for (int i = 0; i < n; ++i) {
        left.add(new ArrayList<>());
      }
      for (int i = 0; i < m; ++i) {
        right.add(new ArrayList<>());
      }
    }

    void addEdge(int ln, int rn) {
      left.get(ln).add(rn);
      right.get(rn).add(ln);
    }

    int matching() {
      int res = 0;
      for (int i = 0; i < left.size(); ++i) {
        if (l2r[i] != -1) continue;
        boolean[] visited = new boolean[right.size()];
        for (int j = 0; j < left.get(i).size(); ++j) {
          if (dfs(left.get(i).get(j), visited)) {
            l2r[i] = left.get(i).get(j);
            r2l[left.get(i).get(j)] = i;
            ++res;
            break;
          }
        }
      }
      return res;
    }

    boolean dfs(int rn, boolean[] visited) {
      int l = r2l[rn];
      if (l == -1) {
        return true;
      }
      visited[rn] = true;
      for (int i = 0; i < left.get(l).size(); ++i) {
        int r = left.get(l).get(i);
        if (visited[r]) continue;
        if (dfs(r, visited)) {
          r2l[r] = l;
          l2r[l] = r;
          return true;
        }
      }
      return false;
    }
  }
}


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);
const long long MOD = 1000000007;

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll a;
    ll p[200010];
    string s;

    cin >> a;

    cout << a + a*a + a*a*a << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
using namespace std;
long long n,ans,sum[26];
char a[200005];
int main()
{
	scanf("%s",a+1);n=strlen(a+1);
	ans=n*(n+1)/2;
	for(int i=1;i<=n;++i) sum[a[i]-'a']++;
	for(int i=0;i!=26;++i) ans-=sum[i]*(sum[i]+1)/2;
	printf("%lld",ans+1);
	return 0;
}

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

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

    int k;
    string s;
    cin >> k;
    cin >> s;

    if(s.size() <= k){
         cout << s;
    }

    else if(s.size() != k){
        s = s.substr(0, k);
        cout << s << "...";
    }



    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		String[] str_a = new String[n];
		String[] str_b = new String[m];
		String[][] a = new String[n][n];
		String[][] b = new String[m][m];
		int i = 0;
		int j = 0;
		for(i = 0; i < n; i++) {
			str_a[i] = scan.next();
		}
		for(i = 0; i < m; i++) {
			str_b[i] = scan.next();
		}
		String message = "No";
		for(i = 0; i < n; i++) {
			for(j = 0; j < n; j++) {
				a[i][j] = str_a[i].charAt(j) + "";
			}
		}
		for(i = 0; i < m; i++) {
			for(j = 0; j < m; j++) {
				b[i][j] = str_b[i].charAt(j) + "";
			}
		}
		a:for(i = 0; i + m <= n; i++) {
			for(j = 0; j + m <= n; j++) {
				b:for(int k = 0; k < m; k++) {
					for(int l = 0; l < m; l++) {
						if(a[i + k][j + l].equals(b[k][l])) {
						} else {
							break b;
						}
						if((k == m -1) && (l == m - 1)) {
							message = "Yes";
							break a;
						}
					}
				}
			}
		}
		System.out.println(message);
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
L x,y,s,ans=-99999;
L tax(L it,L per){
    double res=(((double)it/100.0)*(per))+(double)it;
    L res2=res;
    return res2;
}
void solve(){
    ans=-99999;
    L it1=s,dt1,dt2,it2;
    while(tax(it1,x)>s)it1--;
    while(1){
        dt1=tax(it1,x);
        dt2=s-dt1;
        it2=s-it1;
        while(it2){
            L txd=tax(it2,x);
            if(txd==dt2){
                L tmp1=tax(it1,y),tmp2=tax(it2,y);
                if(tmp1+tmp2>ans){
                    ans=tmp1+tmp2;
                }
            }
            else if(txd<dt2)break;
            it2--;
        }
        it1--;
        if(it1==0)break;
    }
}
int main()
{
    while(scanf("%lld%lld%lld",&x,&y,&s)&& x||y||s){
        solve();
        cout<<ans<<"\n";
    }


    return 0;
}



Measured memory_bytes: 3152
pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}

fn z_algorithm(a: &[usize]) -> Vec<usize> {
    let n = a.len();
    let mut z = vec![0; n];
    z[0] = n;
    let mut i = 1;
    let mut len = 0;
    while i < n {
        while i + len < n && a[len] == a[i + len] {
            len += 1;
        }
        z[i] = len;
        if len == 0 {
            i += 1;
            continue;
        }
        let mut j = 1;
        while j + z[j] < len {
            z[i + j] = z[j];
            j += 1;
        }
        i += j;
        len -= j;
    }
    z
}

fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    let n: usize = rd.get();
    let s: String = rd.get();
    let s = s
        .chars()
        .map(|c| c as usize - 'a' as usize)
        .collect::<Vec<_>>();
    let mut ans = 0;
    for i in 0..n {
        let z = z_algorithm(&s[i..n]);
        for j in (i + 1)..n {
            ans = std::cmp::max(ans, std::cmp::min(j - i, z[j - i]));
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2240
#include<iostream>
using namespace std;
 
int main(){
  int a,b,c,d,n; cin>>n;
  a=n%10; b=(n%100-a)/10; c=(n%1000-b*10-a)/100; d=(n-c*100-b*10-a)/1000;
  if(a==b && b==c )
    cout << "Yes" <<endl;
  else if(b==c && c==d )
    cout << "Yes" <<endl;
  else
    cout<< "No" <<endl;
  return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc054/tasks/abc054_a
a, b = map(int, input().split())

if a == 1:
    a = 14
if b == 1:
    b = 14

if a < b:
    print("Bob")
elif b < a:
    print("Alice")
else:
    print("Draw")


Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
#include<vector>
#include<math.h>
#include<algorithm>

using namespace std;

int main()
{
	long long int m, n;
	long long int mod = 1000000007;
	cin >> m >> n;
	long long int power = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			power = power * m % mod;
		}
		m = m * m % mod;
		n = n >> 1;
	}

	cout << power << endl;
	return 0;
}

Measured memory_bytes: 1156
s = list(map(str, input()))

import math
if len(s)%2 == 0:
    c = math.floor(len(s)/2)
    l = s[0:c]
    r = list(reversed(s[c:len(s)]))
elif len(s)%2 == 1:
    c = math.floor((len(s))/2)
    l = s[0:c]
    r = list(reversed(s[c+1:len(s)]))
    
count = 0
for i in range(len(l)):
    if l[i] != r[i]:
        count += 1
    else:
        continue
        
print(count)

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

int main() {
  int N, d[100000], count=0;
  cin >> N;
  for(int i=0; i<N; ++i) cin >> d[i];
  sort(d, d+N);
  cout << d[N/2]-d[N/2-1] << endl;
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 998244353;

std::vector<std::vector<LL>>comb;
void make_comb(LL size)
{
	comb.resize(size + 1);
	rep(i, comb.size())
	{
		comb[i].resize(size + 1);
		comb[i][0] = 1;
		comb[i][i] = 1;
	}
	for (LL k = 1; k < comb.size(); ++k) for (LL j = 1; j < k; ++j) comb[k][j] = (comb[k - 1][j - 1] + comb[k - 1][j]) % mod;
}

int main()
{
	LL K, N;
	in >> K >> N;

	std::vector<LL>pows(K + 1);
	pows[0] = 1;
	for (LL i = 1; i <= K; ++i) pows[i] = (pows[i - 1] * 2) % mod;
	make_comb(N + K);
	for (LL i = 2; i <= 2 * K; ++i)
	{
		LL p = 0, ans = 0;
		for (LL j = 1; j <= K; ++j)
		{
			if (i - j < j) break;
			if (i - j <= K) ++p;
		}
		if (i % 2 == 0)
		{
			for (LL j = p - 1; j <= 2 * (p - 1); ++j)
			{
				if (j + 1 >= K) break;
				if (N - (2 * (p - 1) - j) >= 0)
				{
					LL num1 = (pows[2 * (p - 1) - j] * comb[p - 1][j - (p - 1)]) % mod;
					LL num2 = comb[(N - (2 * (p - 1) - j)) + (K - (j + 1) - 1)][K - (j + 1) - 1];
					(ans += (num1 * num2) % mod) %= mod;
				}
				if ((N - 1) - (2 * (p - 1) - j) >= 0)
				{
					LL num3 = (pows[2 * (p - 1) - j] * comb[p - 1][j - (p - 1)]) % mod;
					LL num4 = comb[((N - 1) - (2 * (p - 1) - j)) + (K - (j + 1) - 1)][K - (j + 1) - 1];
					(ans += (num3 * num4) % mod) %= mod;
				}
			}
		}
		else
		{
			for (LL j = p; j <= 2 * p; ++j)
			{
				if (j >= K || N - (2 * p - j) < 0) continue;
				LL num1 = (pows[2 * p - j] * comb[p][j - p]) % mod;
				LL num2 = comb[(N - (2 * p - j)) + (K - j - 1)][K - j - 1];
				(ans += (num1 * num2) % mod) %= mod;
			}
		}
		out << ans << std::endl;
	}
}


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

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N,vector<int>(M));
  for(int i = 0; i < N; i++){
    cin >> C[i];
    for(int j = 0; j < M; j++){
      cin >> A[i][j];
    }
  }
  int money = -1;
  bool can = false;
  for(int bit = 0; bit < (1<<N); bit++){
    vector<int> USL(M);
    int minUSL = -1;
    int cost = 0;
    for(int i = 0; i < N; i++){
      if(bit & (1<<i)){
        for(int j = 0; j < M; j++){
          USL[j] += A[i][j];
        }
        cost += C[i];
      }
    }
    for(int j = 0; j < M; j++){
      if(minUSL == -1 || minUSL > USL[j]){
        minUSL = USL[j];
      }
    }
    if(minUSL >= X){
      if(money > cost || money == -1){
        money = cost;
        can = true;
      }
    }
  }
  if(can){
    cout << money << endl;
  }else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<char> S(N);
    for (int i=0; i<N; i++) cin >> S[i];

    bool f1 = (S[0] == '1') ? true : false;
    bool e1 = (S[N-1] == '1') ? true : false;


    vector<int> Sg;
    if (!f1) Sg.emplace_back(0);
    char last_num = f1 ? '1' : '0';
    int cnt = 0;
    for (int i=0; i<N; i++) {
        if (last_num == S[i]) {
            cnt += 1;
        } else {
            Sg.emplace_back(cnt);
            cnt = 1;
        }
        if (i == N-1) Sg.emplace_back(cnt);
        last_num = S[i];
    }
    if (!e1) Sg.emplace_back(0);

    // 処理していく
    int res = 0;
    
    if (Sg.size() <= 2*K+1) {
        res = accumulate(Sg.begin(), Sg.end(), 0);
    } else {
        for (int i=2*K+1; i<=Sg.size(); i+=2) {
            res = max(res, accumulate(Sg.begin()+i-(2*K+1), Sg.begin()+i, 0));
        }
    }

    cout << res << endl;

    return 0;

}

Measured memory_bytes: 1020
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

long long Lcm(long long a,long long b){
	return (((a)*(b)))/__gcd(a,b);
}

int main(){
	
	ll a,b;
	cin>>a>>b;


	cout<<Lcm(a,b)<<endl;	


	
	
	return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {
	private static final int MOD = 1_000_000_007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();

		System.out.println(3 * r * r);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	private static long gcd(long m, long n) {
		long temp;
		while (m % n != 0) {
			temp = n;
			n = m % n;
			m = temp;
		}
		return n;
	}

	private static long lcm(long m, long n) {
		return m / gcd(m, n) * n;
	}

	private static int add(int a, int b) {
		return (a + b) % MOD;
	}

	private static int sub(int a, int b) {
		return (a - b % MOD) % MOD;
	}

	private static int mul(int a, int b) {
		return ((a % MOD) * (b % MOD)) % MOD;
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public char nextChar() throws IOException {
			return (char) skip();
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

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

int dp[30009][5][1000] = {0};

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans;
    dp[0][0][0] = 1;
    rep(i,N) {
        int s = S[i] - '0';
        rep(i2,4)rep(i3,1000){
            dp[i+1][i2][i3] |= dp[i][i2][i3];
            dp[i+1][i2+1][i3*10+s] |= dp[i][i2][i3];
        }
    }
    rep(i,1000) ans+=dp[N][3][i];
    cout << ans << endl;
}

Measured memory_bytes: 586240
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)*}
    };
}

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

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

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

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

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

fn main() {
    input! {
        n: usize,
    }
    if n / 10 == 9 || n % 10 == 9 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
H, W = map(int, input().split())

a = [input() for i in range(H)]

a = [i for i in zip(*a)]
a = [i for i in a if "#" in i]

a = [i for i in zip(*a)]
a = [i for i in a if "#" in i]

for i in a:
    print("".join(i))

Measured memory_bytes: 3188
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


const int N = 50;
ll d[N + 1][N + 1];

void solve()
{
    int n;
    scanf("%d", &n);
    vector<int> a(n), b(n);
    int i,j;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    for (i = 0; i < n; i++) {
        scanf("%d", &b[i]);
    }

    ll ans = 0;
    int p;
    for(p=0; p<100; p++) {
        for (i = 0; i <= N; i++) {
            for (j = 0; j <= N; j++) {
                if (i == j) d[i][j] = 0;
                else        d[i][j] = LINF2;
            }
        }

        for (i = 1; i <= N; i++) {
            for (j = 1; j <= i; j++) {
                int k = i % j;
                ll disttmp = ((ll)1 << j);
                if (ans & ((ll)1 << j)) disttmp = 0;
                d[k][i] = MIN(d[k][i], disttmp);
            }
        }

        for (int k = 0; k < N+1; ++k)
            for (int i = 0; i < N+1; ++i)
                for (int j = 0; j < N+1; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

        ll max = 0;
        for (i = 0; i < n; i++) {
            //printf("%lld\n", d[b[i]][a[i]]);
            max = MAX(max, d[b[i]][a[i]]);
        }
        if (max == 0) {
            break;
        }
        for (i = N; i >= 0; i--) {
            if (max & ((ll)1 << i)) {
                ans = ans | ((ll)1 << i);
                break;
            }
        }
    }
    if (p == 100) {
        printf("-1\n");
    }
    else {
        printf("%lld\n", ans);
    }
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 256
from heapq import heapify, heappush, heappop
import sys
input = sys.stdin.readline

def solve():
    N, Q = map(int, input().split())
    events = []
    for i in range(N):
        S, T, X = map(int, input().split())
        events.append((S-X-0.5, 1, X))
        events.append((T-X-0.5, 0, X))
    for i in range(Q):
        D = int(input())
        events.append((D, 2, i))

    events.sort()

    anss = [-1] * Q
    PQ = []
    isClosed = dict()
    for tm, tp, x in events:
        if tp == 0:
            isClosed[x] = 0
        elif tp == 1:
            isClosed[x] = 1
            heappush(PQ, x)
        else:
            while PQ:
                if isClosed[PQ[0]] == 1:
                    anss[x] = PQ[0]
                    break
                heappop(PQ)

    print('\n'.join(map(str, anss)))


solve()


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;

  if ((a == b || b == c || c ==a) && !(a == b && b == c)){
    cout << "Yes"  << endl;
  }else{
   cout << "No" << endl;
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int C[9];
int INV[200];
int main()
{
    int A[9], B, N;
    rep(i, 200)INV[i] = -1;
    rep(i, 9){
        cin >> A[i];
        INV[A[i]] = i;
    }
    cin >> N;
    rep(i, N){
        
        cin >> B;
        if (INV[B] != -1)
            C[INV[B]] = 1;
    }
    if (C[0] + C[1] + C[2] == 3||
        C[3] + C[4] + C[5] == 3||
        C[6] + C[7] + C[8] == 3||
        C[0] + C[3] + C[6] == 3||
        C[1] + C[4] + C[7] == 3||
        C[2] + C[5] + C[8] == 3||
        C[0] + C[4] + C[8] == 3||
        C[2] + C[4] + C[6] == 3){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if((a==b && a!=c) || (b==c && b!=a) || (c==a && c!=b)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Thu Mar 26 22:17:55 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import defaultdict
from itertools import combinations

n = ni()
s = nsn(n)
d = defaultdict(int)
for i in range(n):
    d[s[i][0]] += 1

m = [0] * 5
for i, v in enumerate("MARCH"):
    m[i] = d[v]

ans = 0
for p in combinations(range(5), 3):
    i, j, k = p
    ans += m[i] * m[j] * m[k]

print(ans)

Measured memory_bytes: 10112
<?php
$N = intval(trim(fgets(STDIN)));
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
$B = array_map("intval", explode(" ", trim(fgets(STDIN))));
 
//座圧する・本質的ではないが、計算量がかなり際どいのでDPの長さを50から36に落とせるメリットは大きい
list($_, $fuku, $atsu) =$r= atsu(array_merge($A, $B));
foreach($A as $i => $a)$A[$i] = $atsu[$a]+1;
foreach($B as $i => $b)$B[$i] = $atsu[$b]+1;
$MAX = max($atsu)+1;
 
$dp = array_fill(0, 1<<$N, array_fill(0,51,PHP_INT_MAX));
$dp[0][0] = 0;//どの数字も選んでいない状態の最大の数字は0としてよい
for($bit = 0, $NN = 1<<$N; $bit < $NN; ++$bit){
    $consumed = countBits($bit);
    $ords = [];
    $iter = $consumed;
    for($i = 0; $i < $N; ++$i)
        if(!($bit & (1<<$i)))
            $ords[$i] = $iter++;//使われていないカードの元の位置と現在位置の組を作成
    for($s = 0; $s <= $MAX; ++$s){
        if($dp[$bit][$s] == PHP_INT_MAX)continue;
        foreach($ords as $origPosition => $currentPosition){
            $newNumber = ($origPosition - $consumed) & 1 ? $B[$origPosition] : $A[$origPosition];
            if($newNumber >= $s){//広義単調増加であればよい
                $newBits = $bit | (1<<$origPosition);
                chmin($dp[$newBits][$newNumber], $dp[$bit][$s] + abs($currentPosition - $consumed));
            }
        }
    }
}
$min = min($dp[(1<<$N)-1]);
if($min == PHP_INT_MAX){
    echo -1;
}else{
    echo $min;
}
 
/**
 * ちょっと早くBitを数える -- 18回ループするより速い。
 **/
function countBits($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}
 
/**
 * 座圧対象の配列を渡すと以下の値を返す
 * ・圧縮された配列
 * ・復元用のMap
 * ・圧縮用のMap
 **/
function atsu($array){
    $a = array_flip($array);
    $fuku = array_flip($a);
    sort($fuku);
    $atsu = array_flip($fuku);
    foreach($array as $i => $val)$array[$i] = $atsu[$val];
    return [$array, $fuku, $atsu];
}
 
function chmax(&$a, $b){
    if($a < $b){
        $a = $b;
        return true;
    }
    return false;
}
function chmin(&$a, $b){
    if($a > $b){
        $a = $b;
        return true;
    }
    return false;
}

Measured memory_bytes: 690680
// https://atcoder.jp/contests/abc161/tasks/abc161_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K;
    cin >> K;
    queue<int> q;
    FOR(i, 1, 10) q.push(i);
    int cnt = 0;
    while (!q.empty()) {
        int t = q.front();
        q.pop();
        cnt++;
        if (cnt >= K) {
            cout << t << endl;
            return 0;
        }
        FOR(i, t % 10 - 1, t % 10 + 2) {
            if (i >= 0 && i <= 9) {
                q.push(t * 10 + i);
            }
        }
    }

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
using namespace std;
int main()
{
	string s;

	cin >> s;

	int n = s.length();
	int count = 0;


	map<char, int> mymap;
	map<char, int> finalmap;
	map<char, bool> flagmap;
	for (int i=0;i<s.length();++i)
	{
		char c = s[i];
		int dist;
		if (mymap[c] == 0 && flagmap[c] == false)
		{
			flagmap[c] = true;
			dist = i - mymap[c];
		}
		else
		{
			dist = i - mymap[c]-1;
		}
		
		if (dist > finalmap[c])
		{
			finalmap[c] = dist;
		}
		mymap[c] = i;
	}

	for (auto& elem : mymap)
	{
		//cout << elem.second << endl;
		int dist = s.length() - 1 - elem.second;
		//cout << dist << endl;
		if (dist > finalmap[elem.first])
		{
			finalmap[elem.first] = dist;
		}
	}

	int m = INT_MAX/2;
	for (auto& elem : finalmap)
	{
		m = min(m, elem.second);
	}
	

	cout << m << endl;


}

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

typedef vector<int> vi;
typedef vector<vi> vvi;

int main()
{
	while (1)
	{
		string s; cin >> s;
		if (s[0] == '0') return 0;
		
		vvi cnt(s.length(), vi(11, 0));
		cnt[0][s[0] - '0']++;

		rep(i, 1, s.length())
		{
			int n = s[i] - '0';
			if (i % 2 == 1) n = (n * (-1) + 11) % 11;

			rep(j, 0, 11)
			{
				int nn = (j + n) % 11;
				cnt[i][nn] += cnt[i-1][j];
			}

			if(n != 0) cnt[i][n]++;
		}

		int ans = 0;
		//rep(i, 0, s.length()) ans += cnt[i][0];
		rep(i, 1, s.length())
		{
			int n = s[i] - '0';
			if (i % 2 == 1) n = (n * (-1) + 11) % 11;
			int to = (11 - n) % 11;
			ans += cnt[i - 1][to];

			//printf("(%d, %d)\n", i, cnt[i - 1][to]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 9860
#include <cstdio>
#include <algorithm>
#include <cctype>
#include <cstring>
using namespace std;
typedef long long i64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e3+5;
int k, n, a[N][N];
int main()
{
    k = read(), n = min(k, 500), k -= n;
    for(int i = 1, j = 0; i <= n; ++i)
    {   
        int u = ++j, v = k>0?++j:j; --k;
        for(int x = 1, y = i; x <= n; ++x, y = y%n+1)
            a[x][y] = x&1?u:v;
    }
    printf("%d\n", n);
    for(int i = 1; i <= n; ++i, puts(""))
        for(int j = 1; j <= n; ++j)
            printf("%d ", a[i][j]);
    return 0;
}

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

int main()
{
    int n, x;

    cin >> n;

    for(int i = 1; i <= n; i++) {
        if(!(i%3)){
            cout << ' ' << i;
        }else {
            x = i;
            while(x) {
                if(x%10==3) {
                    cout << ' ' << i;
                    break;
                }
                x /= 10;    // 31-39 --> x%10==3
            }
        }
    }
    cout << endl;

    return 0;

}


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

int main()
{
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	int n,l,r,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&l,&r);
		ans+=(r-l+1);
	}
	printf("%d\n",ans);
	return 0;
}

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

const int mod = 1'000'000'007;

int main(){
    int n, x;
    cin >> n >> x;
    int dis = 0;
    int count = 0;
    vector<int> l(n);
    for(int i = 0; i < n; i++){
        cin >> l.at(i);
    }
    for(int i = 0; i < n; i++){
        dis += l.at(i);
        if(dis <= x) count++;
    }
    cout << count + 1 << endl;
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    int x = 1;
    for (int i = 0; i < n; i++) x *= 100;

    int ans = 0;
    int count = 1;
    while (count <= m) {
        ans += x;
        if ((ans/x) % 100 == 0) continue;
        count++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <climits>
#include <tuple>
#include <queue>
#include <cassert>
#include <set>
//#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define el '\n'
 

 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	ll a;
	cin >> a;
	cout << (1000 - a % 1000) % 1000<<el;


    return 0;
}

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

int main()
{
	int n, boss;
	cin >> n;

	vector<int> count(n+1, 0);

	for(int i=2; i<=n; i++)
	{
		cin >> boss;
		++count[boss];
	}

	for(int i=1; i<=n; i++)
		cout<<count[i]<<endl;

	return 0;
}

Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=100005;
const ll inf=(1e15);
int n,k;
ll h[maxn][4],dp[maxn][4];
int main()
{
    //ios_base::sync_with_stdio(0),cin.tie(0);
    while(cin>>n)
    {
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=3;j++) cin>>h[i][j];
        }
        for(int i=1;i<=3;i++) dp[1][i]=h[1][i];
        for(int i=2;i<=n;i++)
        {

            dp[i][3]=h[i][3]+max(dp[i-1][1],dp[i-1][2]);
            dp[i][2]=h[i][2]+max(dp[i-1][1],dp[i-1][3]);
            dp[i][1]=h[i][1]+max(dp[i-1][3],dp[i-1][2]);

        }
        ll maxnum=0;
        for(int i=1;i<=3;i++) maxnum=max(maxnum,dp[n][i]);
        cout<<maxnum<<"\n";
    }
}


Measured memory_bytes: 6528
'use strict';
(function(stdin) {
  var inputs  = stdin.toString().trim().split('\n');
  var sorts = inputs
  .map(Number)          // ??°??????
  .sort(function(a,b){  // ????????????????????????
    return b-a;
  })
  .slice(0,3)                //????????????3????????????
  .join('\n');                  //????????§??????




console.log(sorts);
  
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

//-------------------------------------------------------//

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

int main() {
	ll k, sum = 0;
	cin >> k;
	
	for(int a = 1; a <= k; a++) {
		for(int b = 1; b <= k; b++) {
			for(int c = 1; c <= k; c++) sum += gcd(gcd(a,b),c);
		}
	}
	
	cout << sum << endl;
  
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
    ll n;
    vector<ll> abcde;
    cin >> n;
    for (int i = 0; i < 5; ++i) {
        ll val;
        cin >> val;
        abcde.emplace_back(val);
    }
    ll sval = abcde[0], min_val;
    sort(abcde.begin(), abcde.end());
    min_val = abcde[0];

    ll ans = 0;
    ans += (n + (min_val - 1)) / min_val;
    ans += 4;

    cout << ans << endl;

    return 0;
}

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

#define int long long
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; }

signed main(){
	int a, b;
	cin >> a >> b;
	cout << (a+b) % 24 << endl;

	return 0;
}


Measured memory_bytes: 3576
N = int(input())
A = list(map(int, input().split()))
MOD = 1000000007
cnt = [0,0,0] # 現在割り当てられている人数
ans = 1 # 現時点での組み合わせ
for a in A:
    idx = []
    for i in range(3):
        if cnt[i] == a: # 割り当て可能
            idx.append(i)
    if len(idx)==0: # 割り当て不能
        print(0)
        exit()
    cnt[idx[0]]+=1 # 任意の色で良いので、一番番号が若い色とする
    ans *= len(idx) # 割り当て可能な人数をかける
    ans %= MOD
print (ans)

Measured memory_bytes: 20776
N=int(input())
X=list(map(int,input().split()))
m=10**9+7
Y=[i*2+1 for i in range(N)]
r=1
j=0
a=0
for i in range(N-1):
    if X[i]<Y[j]:
        r=r*(i-a+1)%m
        a+=1
        j-=1
    j+=1
for i in range(N-a):
    r=r*(i+1)%m
print(r)

Measured memory_bytes: 14588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    long int ans=0;
    for(long int i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
        ans++;
    }
    cout<<ans<<endl;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

struct UF{
	vector<int> p;
	UF() {}
	UF(int n) : p(n, -1) {}
	int find(int a){ return p[a] < 0 ? a : p[a] = find(p[a]); }
	bool unite(int a, int b) {
		a = find(a); b = find(b);
		if(a == b) return false;
		if(-p[a] < -p[b]) swap(a, b);
		p[a] += p[b]; p[b] = a;
		return true;
	}
	bool root(int a){ return p[a] < 0; }
	bool same(int a, int b){ return find(a) == find(b); }
	int size(int a){ return -p[find(a)]; }
};

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	
	UF ufa(n);
	rep(i, m){
		int a,b;
		cin >>a >>b;
		ufa.unite(a-1, b-1);
	}
	int ans = 0;
	rep(i, n) ans = max(ans, ufa.size(i));
	cout <<ans <<"\n";
	return 0;
}



Measured memory_bytes: 3956
use v5.18;
use warnings;
use List::Util qw( min );
sub read_line { chomp(my $str = <STDIN>); $str }
sub splited_read_line { split / /, read_line }

my $n = read_line;
my $s = read_line;
my @splited_s = split //, $s;

sub char_nums {
  my $chars = shift;
  my %counter;
  for my $c (@$chars) {
    $counter{$c}++;
  }
  \%counter;
}

my ($right, $left) = (
  +{
    chars    => [],
    east_num => 0,
    west_num => 0,
  },
  do {
    my $chars = [ @splited_s[1 .. $n - 1] ];
    my $char_nums = char_nums $chars;
    +{
      chars    => $chars,
      east_num => $char_nums->{E} // 0,
      west_num => $char_nums->{W} // 0,
    };
  },
);

my $min_change_num = $n;
for my $leader_index (0 .. $n - 1) {
  my $right_change_num = $right->{west_num};
  my $left_change_num  = $left->{east_num};
  $min_change_num = min( $min_change_num, $right_change_num + $left_change_num );

  my $char = $splited_s[$leader_index];
  push @{ $right->{chars} }, $char;
  $right->{east_num}++ if $char eq 'E';
  $right->{west_num}++ if $char eq 'W';

  my $shift_char = shift @{ $left->{chars} } // '';
  $left->{east_num}-- if $shift_char eq 'E';
  $left->{west_num}-- if $shift_char eq 'W';
}
say $min_change_num;


Measured memory_bytes: 62880