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

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [][] pass = new int[n][n];
			for(int i = 0; i < m;i++){
				int a = sc.nextInt() - 1;
				int b = sc.nextInt() - 1;
				pass[a][b]++;
				pass[b][a]++;
			}
			
			for(int i = 0; i < n;i++){
				int count = 0;
				for(int j = 0; j < n;j++){
					count += pass[i][j];
				}
				System.out.println(count);
			}
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 21844
s = input()
t = input()

end = []
flag = 1
for i in range(len(s)):
  if s[i] not in end:
    end.append(s[i])
    for j in range(len(t)):
      if s[i] == s[j]:
        if t[i] != t[j]:
          flag = 0
      else:
        if t[i] == t[j]:
          flag = 0

if flag == 0:
  print('No')
else:
  print('Yes')

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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = (y); x <= (z); x++)
#define REPP(x, y, z) for(int x = (y); x >= (z); x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn

//structure

//declaration

//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif

    string a;
    string b;

    cin >> a >> b;


        cout << b+a << '\n';

	return 0;
}


Measured memory_bytes: 256
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip("\n") for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst): print(*lst)
def OutV(lst): print(*lst, sep="\n")
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

## factorial library
## 

## begin library factorial here
## usage: fac = Factorial()
## usage: nCr = fac.comb(n, r)
## usage: nPr = fac.perm(n, r)
class Factorial:

    def __init__(self, N):
        self.fact = [0] * (N+1)
        self.fact_inv = [0] * (N+1)
        self.calc_factorial(N)
        self.calc_inv_factorial(N)

    def calc_factorial(self, N):
        self.fact[0] = 1
        for i in range(N):
            self.fact[i+1] = self.fact[i] * (i+1) % MOD

    def calc_inv_factorial(self, N):
        self.fact_inv[N] = pow(self.fact[N], MOD-2, MOD)
        for i in range(N, 0, -1):
            self.fact_inv[i-1] = self.fact_inv[i] * i % MOD

    def comb(self, n, r):
        if (n < 0 or r < 0 or n < r): return 0
        res = self.fact[n]
        res = res * self.fact_inv[r] % MOD
        res = res * self.fact_inv[n-r] % MOD
        return res

    def perm(self, n, r):
        if (n < 0 or r < 0 or n < r): return 0
        res = self.fact[n]
        res = res * self.fact_inv[r] % MOD
        return res

MOD = 998244353

N, A, B, K = iInM()

fac = Factorial(300000)

ans = 0
for a in range(N+1):
    if (K - A * a) % B == 0:
        b = (K - A * a) // B
        ans = (ans + fac.comb(N, a) * fac.comb(N, b)) % MOD
    else:
        continue

print(ans)

Measured memory_bytes: 87540
#include <bits/stdc++.h>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

class TaskB
{
public:
	ll a, y, x;
	void process()
	{
		cin >> x;
		a = 100;
		y = 0;

		while(true)
		{
			if(a>=x)
				break;
			a += a/100;
			y++;
		}

		cout << y << "\n";
	}
};


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


	TaskB solver;
	solver.process();

	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N;
    scan(N);
    int ans = 0;
    vector<vector<pair<int, int>>> a(N, vector<pair<int, int>>());
    rep(i, N) {
        int n;
        scan(n);
        rep(j, n) {
            int x, y;
            scan(x, y);
            a[i].emplace_back(x - 1, y);
        }
    }

    rep(bit, (1 << N)) {
        int cnt = 0;
        vector<int> human(N, -1);
        bool ok = true;
        rep(i, N) {
            if (bit & (1 << i)) {
                human[i] = 1;
            } else {
                human[i] = 0;
            }
        }
        rep(i, N) {
            if (bit & (1 << i)) {
                rep(j, (int)a[i].size()) {
                    int x = a[i][j].first;
                    int y = a[i][j].second;
                    if (human[x] != y) {
                        ok = false;
                        break;
                    }
                }
                cnt++;
            }
        }
        if (ok)
            chmax(ans, cnt);
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  ll n, d;
  cin >> n >> d;
  int ans = 0;
  while (n--) {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d) ans++;
  }
  cout << ans << '\n';
  return (0);
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	ll n;
	cin>>n;
	vector<ll> c(n);
	rep(i,n)cin>>c[i];

	sort(all(c));
	reverse(all(c));
	ll ans=0;
	rep(i,n){
		ans += (c[i]*(i+2))%mod;
		ans %= mod;
	}

	cout<<(ans*power(4,n-1))%mod<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			@SuppressWarnings("unchecked")
			List<Path>[] pathLists = new List[n];
			IntStream.range(0, n).forEach(i -> pathLists[i] = new ArrayList<>());
			IntStream.range(0, n - 1).forEach(i -> {
				int from = scanner.nextInt() - 1, to = scanner.nextInt() - 1;
				pathLists[from].add(new Path(from, to, 1));
				pathLists[to].add(new Path(to, from, 1));
			});
			// ノード1からの距離の配列
			int[] distances1 = dijkstra(pathLists, 0, n);
			// ノードnからの距離の配列
			int[] distancesn = dijkstra(pathLists, n - 1, n);
			// 黒と白に塗られたマスの数
			int black = 0, white = 0;
			for (int i = 0; i < n; i++) {
				if (distances1[i] <= distancesn[i]) {
					black++;
				} else {
					white++;
				}
			}
			System.out.println((black > white) ? "Fennec" : "Snuke");
		}
	}

	/**
	 * @param pathLists ノード間の連結パス一覧の配列
	 * @param src       開始ノード
	 * @param n         ノードの数
	 * @return 開始ノードからの距離の配列
	 */
	private static int[] dijkstra(List<Path>[] pathLists, int src, int n) {
		int[] distances = new int[n];
		Arrays.fill(distances, Integer.MAX_VALUE);
		// 最短距離が確定したかどうか
		boolean[] fixed = new boolean[n];
		Arrays.fill(fixed, false);
		// 出発地点までの距離を0とする
		distances[src] = 0;
		Queue<Path> queue = new PriorityQueue<>();
		queue.add(new Path(src, src, 0));
		while (!queue.isEmpty()) {
			int now = queue.poll().to;
			if (!fixed[now]) {
				fixed[now] = true;
				for (Path path : pathLists[now]) {
					if (!fixed[path.to] && distances[path.to] > distances[now] + path.cost) {
						distances[path.to] = distances[now] + path.cost;
						queue.add(new Path(path.to, path.to, distances[path.to]));
					}
				}
			}
		}
		return distances;
	}

	/**
	 * ノード間の一つのパスを表すクラス
	 */
	private static class Path implements Comparable<Path> {
		/** 開始ノード */
		@SuppressWarnings("unused")
		int from;
		/** 終了ノード */
		int to;
		/** 移動コスト */
		int cost;

		Path(int from, int to, int cost) {
			super();
			this.from = from;
			this.to = to;
			this.cost = cost;
		}

		@Override
		public int compareTo(Path path) {
			return Integer.compare(cost, path.cost);
		}
	}
}


Measured memory_bytes: 73740
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
 #define all(v) (v).begin(),(v).end()
 using ll = long long;
using Graph = vector<vector<int>>;
const int MAX = 510000;
const int MOD = 1000000007;
 const int NINE=1000000000;
 
 
int main(){
ll S;
  cin>>S;
ll x,y;
  x=1;
  y=S;
  if(S>NINE){
  if(S%NINE==0){
  ll t=S/NINE;
  t--;
    x=x+t;
    y=S-t*NINE;
  }
  else{
  ll t=S/NINE;
    x=x+t;
    y=S-t*NINE;
  }
  }
  cout<<0<<' '<<NINE<<' '<<1<<' '<<0<<' '<<x<<' '<<y;
}

Measured memory_bytes: 256
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

struct P {
    int a, b;
    int x, y;
    int opCmp(const ref P p) const {
        return b - p.b;
    }
}

void main() {
    int n, m, h, k;
    while (scanf("%d %d %d %d\n", &n, &m, &h, &k), n || m || h || k) {
        int[] ps;
        foreach (i; 0 .. n) {
            int p;
            scanf("%d\n", &p);
            ps ~= p;
        }
        P[] ss;
        foreach (i; 0 .. m) {
            int a, b;
            scanf("%d %d\n", &a, &b);
            a--; b--;
            ss ~= P(a, b);
        }
        ss = ss.sort.array;
        int[] xs = new int[n];
        foreach (i; 0 .. n) xs[i] = i;
        foreach (i; 0 .. m) {
            int x = ss[i].a,
                y = ss[i].a + 1;
            ss[i].x = xs[x];
            ss[i].y = xs[y];
            swap(xs[x], xs[y]);
        }
        int[] _ps = ps.dup;
        foreach (i; 0 .. n) {
            ps[xs[i]] = _ps[i];
        }
        int t = 0;
        foreach (i; 0 .. k) {
            t += ps[i];
        }
        int ans = t;
        foreach (i; 0 .. m) {
            int x = ss[i].x,
                y = ss[i].y;
            if (0 <= x && x < k) {
                if (0 <= y && y < k) continue;
                else ans = min(ans, t - ps[x] + ps[y]);
            } else if (0 <= y && y < k) {
                ans = min(ans, t - ps[y] + ps[x]);
            }
        }
        ans.writeln;
    }
}

Measured memory_bytes: 6448
object Main extends App {
	val scanner = new java.util.Scanner(System.in)
	val N = scanner.nextInt()
		
	val s = Array.fill(N)(scanner.next)

	val map = scala.collection.mutable.HashMap[String, Int]()

	for(i<-0 until N){
		val tp = s(i)
		map.put(tp, 1 + map.getOrElse(tp, 0))
	}

	val vmax = map.values.max
	val tmp = map.filter(z => z._2 == vmax).keys.toArray.sorted

	val pw = new java.io.PrintWriter(System.out)
	for (str <- tmp) {
      pw.println(str)
    }
    pw.flush()
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
object FastScanner {
	private val in: java.io.InputStream  = System.in
	private val buf = new Array[Byte](1024)
	private var ptr: Int = 0
	private var len: Int = 0

	@inline def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = {
		if(ptr >= len){
			ptr = 0
			len = in.read(buf)
			len > 0
		}else{
			true
		}
	}
	@inline def hasNext(): Boolean = {
		while(hasNextByte && !isPrintableChar(buf(ptr))) ptr+=1
		hasNextByte()
	} 
	@inline private def readByte(): Byte = {
		if(hasNextByte()){
			val res = buf(ptr)
			ptr += 1
			res
		}else{
			-1
		}
	}

	def next(): String = {
		if(!hasNext()) throw new java.io.EOFException("Console has reached end of input")
		val sb = new scala.collection.mutable.StringBuilder()
		var b  = readByte()
		while(isPrintableChar(b)){
			sb.append(b.toChar)
			b = readByte()
		}
		return sb.toString
	}

	def nextLong(): Long = {
		if(!hasNext()) throw new java.io.EOFException("Console has reached end of input")

		var n = 0L
		var minus = false
		var b: Int = readByte()
		if(b == '-'){
			minus = true
			b = readByte()
		}
		while(isPrintableChar(b)){
			if('0' <= b || b < '9'){
				n *= 10L
				n += (b - '0').toLong
			}
			else if(b == -1 || !isPrintableChar(b)){
				if(minus) return n
				else return -n
			}else{
				throw new java.io.EOFException("Not Number")
			}
			b = readByte()
		}
		if(minus) return -n
		else return n
	}
}

Measured memory_bytes: 81464
#include <cstdio>
#include <iostream>
using namespace std;
#define debug(...) //fprintf(stderr, __VA_ARGS__)
inline char nc()
{
	//return getchar();
	static char buf[100000], * l = buf, * r = buf;
	if(l == r) r = (l = buf) + fread(buf, 1, 100000, stdin);
	if(l == r) return EOF;
	return *l++;
}
template<class T> void readin(T & x)
{
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f;
}
const int mod = 1e9 + 7;
int n, k, a[605];
int dp[605][605], g[605], c[605][605];
void solve()
{
	g[0] = 1;
	for(int i = 1; i <= n; i++)
	{
		if(i & 1) g[i] = 0;
		else g[i] = 1ll * g[i - 2] * (i - 1) % mod;
	}
	debug("%d\n", g[n]);
	for(int i = 1; i <= n; i++)
	{
		for(int j = i; j <= n; j++)
		{
			c[i][j] = c[i][j - 1] + int(a[j] == 0);
		}
	}
	for(int len = 1; len <= n; len++)
	{
		for(int i = 1, j = len; j <= n; i++, j++)
		{
			int ok = true;
			for(int h = i; h <= j; h++)
			{
				if(a[h] && (a[h] < i || a[h] > j))
				{
					ok = false;
					break;
				}
			}
			if(ok == 0) continue;
			int x = c[i][j];
			dp[i][j] = g[x];
			for(int h = i + 1; h < j; h++)
			{
				int z = c[h + 1][j];
				dp[i][j] -= 1ll * dp[i][h] * g[z] % mod;
				dp[i][j] %= mod;
			}
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = i; j <= n; j++)
		{
			debug("%d ", dp[i][j]);
			int y = k - c[i][j];
			ans += 1ll * dp[i][j] * g[y] % mod;
			ans %= mod;
		}
		debug("\n");
	}
	ans = (ans + mod) % mod;
	cout << ans << endl;
}
int main()
{
	readin(n);
	readin(k);
	n <<= 1;
	for(int i = 1; i <= k; i++)
	{
		int x, y;
		readin(x);
		readin(y);
		a[x] = y;
		a[y] = x;
	}
	k = n - k * 2;
	solve();
	return 0;
}


Measured memory_bytes: 3072
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	long long N, P, Q; vector<long long> C;

	scanf("%lld", &N);
	scanf("%lld", &P);
	scanf("%lld", &Q);

	C = vector<long long>(N);

	long long zenbugaishoku = 0;

	for (int i = 0; i < N; i++)
	{
		scanf("%lld", &C[i]);

		zenbugaishoku += C[i];
	}
	
	vector<long long> A(N);

	for (int i = 0; i < N; i++)
	{
		A[i] = C[i] - (Q - i) * P;
	}

	sort(A.begin(), A.end());

	long long Answer = zenbugaishoku;

	long long sum = zenbugaishoku;

	for (int i = 0; i < N; i++)
	{
		sum -= A[i];

		sum += 2 * i * P;

		Answer = max(sum, Answer);
	}

	printf("%lld\n", Answer);

	return 0;
}

Measured memory_bytes: 10716
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let Ln = lines.shift().split(/\s/).map((v) => v - 0);
    let N = Ln[0], M = Ln[1], C = Ln[2];
    let Bn = lines.shift().split(/\s/).map((v) => v - 0);
    let ans = 0;
    for (let n = 0; n < N; n++) {
        let An = lines.shift().split(/\s/).map((v) => v - 0);
        let sum = Bn.reduce((ac, value, index) => ac + value * An[index], C);
        if (sum > 0) ans += 1;
    }
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long N, M;
    cin >> N >> M;
    vector<long long> A(N), B(N);
    for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
    vector<int> ind(N);
    for(int i = 0; i < N; i++) ind[i] = i;
    sort(ind.begin(), ind.end(), [&](int i, int j){
        return A[i] < A[j];
    });
    long long ans = 0;
    int i = 0;
    while(M > 0){
        if(M <= B[ind[i]]){
            ans += A[ind[i]] * M;
            M -= M;
        }
        else{
            M -= B[ind[i]];
            ans += A[ind[i]] * B[ind[i]];
        }
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5112
#include<stdio.h>
int main(void)
{
 int N,A,B;
 int taxi,train;
 int min=0;
 scanf("%d %d %d",&N,&A,&B);
 train=N*A;
 taxi=B;
 if(taxi<train)
  min=taxi;
 else
  min=train;
 printf("%d",min);
 return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#define ll long long
#define pb push_back
#define f first
#define s second
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
using namespace std;
const int N = 1e5 + 5;
 
 
int main() {
    fast;
    int n; cin >> n;
    int num = n / 1000;
    if(1000 * num != n)num++;
    cout << 1000 * num - n;
    return 0;
}

Measured memory_bytes: 3644
//This code was made by Chinese_zjc_
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
inline int rd(int &ddd)
{
	char tmp=getchar();
	int xxx=1;
	ddd=0;
	while(('0'>tmp||tmp>'9')&&tmp!='-'&&tmp!=EOF)
	{
		tmp=getchar();
	}
	if(tmp==EOF)
	{
		return EOF;
	}
	if(tmp=='-')
	{
		xxx=-1;
		tmp=getchar();
	}
	while('0'<=tmp&&tmp<='9')
	{
		ddd=(ddd<<3)+(ddd<<1)+(tmp^48);
		tmp=getchar();
	}
	return ddd*=xxx;
}
inline char rd(char &ddd)
{
	char tmp=getchar();
	while(tmp==' '||tmp=='\n')
	{
		tmp=getchar();
	}
	if(tmp==EOF)
	{
		return EOF;
	}
	return ddd=tmp;
}
inline int max(const int &A,const int &B)
{
	return A<B?B:A;
}
inline int min(const int &A,const int &B)
{
	return A<B?A:B;
}
int n,k;
signed main()
{
	rd(n);
	rd(k);
	for(int i=k-n+1;i<=k+n-1;++i)
	{
		printf("%lld ",i);
	}
	return 0;
}


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

int main(){
  ll A, B, C, flag = 1;
  string ans = "No";
  cin >> A >> B >> C;
  if(A == B && B != C) flag = 0;
  if(A == C && B != C) flag = 0;
  if(C == B && A != C) flag = 0;
  
  if(!flag){
    ans = "Yes";
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    long long distx,disty;
    for(long long i=(int)sqrt(n);i>=1;i--){
        if(n%i==0){
            distx=i;disty=n/i;
            break;
        }
    }
    //cout<<distx<<" "<<disty<<endl;
    cout<<distx-1+disty-1<<endl;
    return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

signed main()
{   
    gearup;
    string s; cin >> s;
    ll res = 0;
    rep(i,s.size()){
        if(s[i] == '+')res++;
        else res--;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1;  while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  /*#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("result.txt", "w", stdout);
  #endif*/
  int n;
  cin>>n;
  int a[n],b[n];
  forr(i,n)
    cin>>b[i];
  forr(i,n)
    a[i]= b[i];
  sort(a,a+n); 
  forr(i,n){
    if(b[i]==a[n-1])
        cout<<a[n-2]<<"\n";
    else
      cout<<a[n-1]<<"\n";
  }
return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

::std::int64_t gcd(::std::int64_t a, ::std::int64_t b) {
	while (b != 0) {
		::std::swap(a, b);
		b = b % a;
	}
	return a;
}

::std::vector<::std::int64_t> primes(::std::int64_t upper){
	::std::vector<::std::int64_t> res;
	for (::std::int64_t i = 2; i <= upper; ++i) {
		bool isPrime = true;
		for (auto x : res) {
			if (x * x > upper) break;
			if (i % x == 0) {
				isPrime = false;
				break;
			}
		}
		if (isPrime)
			res.push_back(i);
	}
	return res;
}



// return vector of prime factors of x
// O(sqrt x)
::std::vector<::std::pair<::std::int64_t, ::std::int32_t>> primeFactors(::std::int64_t x) {
	::std::vector<::std::pair<::std::int64_t, ::std::int32_t>> res;
	for (::std::int64_t i = 2; i*i <= x; ++i) {
		if (x % i == 0) {
			res.emplace_back(i, 1);
			x /= i;
			while (x % i == 0) x /= i, res.back().second++;
		}
	}
	if (x != 1) res.emplace_back(x, 1);
	return res;
}

bool isPrime(::std::int64_t x){
	if (x <= 1) return 0;
	for (::std::int64_t i = 2; i*i <= x; ++i) {
		if (x % i == 0) return false;
	}
	return true;
}

bool ok(int64 x, vector<int64>& v) {
	if (x == 1) return 0;
	REP(i, x-1) {
		int64 sum = 0;
		for (int64 j = i; j < v.size(); j += x-1) {
			sum += v[j];
		}
		if (sum % x) return false;
	}
	return (v[0] % x == 0);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	vector<int64> a(N+1);
	REP(i, N+1) cin >> a[N-i];
	int64 g = 0;
	REP(i, N+1) g = gcd(abs(a[i]), g);
	auto pf = primeFactors(g);
	vector<int64> res;
	REP(i, pf.size()) {
		if (ok(pf[i].fs, a))
			res.push_back(pf[i].fs);
	}
	auto ps = primes(N);
	REP(i, ps.size()) {
		if (ok(ps[i], a))
			res.push_back(ps[i]);
	}
	sort(all(res));
	res.erase(unique(all(res)), res.end());
	REP(i, res.size()) {
		cout << res[i] << endl;
	}
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 1;
		for (int i = 1; i <= N; i++) {
			ans = i * ans % ((long) Math.pow(10, 9) + 7);
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;
const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = false, flag = false;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
struct edge { ll to, cost; };

int main() {
	int ans = 0;
	string s;
	cin >> s;
	for (int i = 0;i < s.size()-1;i++) {
		if (s[i] != s[i + 1])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll h, w, K;
    cin >> h >> w >> K;
    K--;

    if(w == 1) {
        out(1);
        re0;
    }

    vvl dp(h+1, vl(w));  // dp[i+1][j] : i行j列を通過する場合の数の総数
    dp[0][0] = 1;
    rep(i, h) {  // i-1行を通過したとする
        rep(j, w) {  // j列にいるとする
            rep(b, 1<<(w-1)) {  // bのkビット目が1のときk列とk+1列を横線で繋ぐ
                vl v(w);  // v[k] : bのkビット目(v[k] = 1のときk列とk+1列を横線で繋ぐ)
                rep(k, w-1) {
                    if(b & 1<<k) {
                        v[k] = 1;
                    }
                }
                ll ok = true;  // 横線のつなぎ方がokならtrue
                rep(k, w-2) {
                    if(v[k] && v[k+1]) {  // 横線が端点を共有するときダメ
                        ok = false;
                    }
                }
                if(ok == false) {
                    continue;
                }
                // 以下横線のつなぎ方はルール的にok
                if(j >= 1 && v[j-1]) {  // j-1列目とj列目が横線でつながれているとき
                    dp[i+1][j-1] += dp[i][j];
                    dp[i+1][j-1] %= mod;
                }
                else if(j <= w-2 && v[j]) {  // j列目とj+1列目が横線でつながれているとき
                    dp[i+1][j+1] += dp[i][j];
                    dp[i+1][j+1] %= mod;
                }
                else {  // いずれも横線で繋がれていないとき
                    dp[i+1][j] += dp[i][j];
                    dp[i+1][j] %= mod;
                }
            }
        }
    }

    out(dp[h][K]);
    re0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		String S = sc.next();
		int count = 1;

		for(int i=0; i<S.length()-1; i++) {
			String a = S.substring(i,i+1);
			String b = S.substring(i+1,i+2);
			if(!a.equals(b)) {
				count++;
//				S = S.substring(0,i+1)+S.substring(i+2);
//				i--;
			}
		}
//		System.out.println(S.length());
		System.out.println(count);
	}
}


Measured memory_bytes: 39772
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>

typedef long long ll;

std::map<ll,int> G;
int n;

int main()
{
	scanf("%d",&n);
	ll sum=0,ans=0,x;
	G[sum]++;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		sum+=x;
		ans+=G[sum];
		G[sum]++;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 12800
import numpy as np

N, M, C = map(int, input().split())

B = np.array(list(map(int, input().split())))

cnt = 0

for i in range(N):
  A = np.array(list(map(int, input().split())))
  if np.dot(A, B) + C > 0:
    cnt += 1

print(cnt)

Measured memory_bytes: 12392
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	ss := strings.Split(s, "")

	literal := ""
	for i := 1; i <= len(ss); i++ {
		if i%2 == 1 {
			literal += ss[i-1]
		}
	}

	fmt.Println(literal)
}


Measured memory_bytes: 8320
def solve(lst):
    i = 1
    num_bricks = 0

    for num in lst:
        if num == i:
            num_bricks += 1
            i += 1
    
    if i == 1:
        return -1
    else:
        return len(lst) - num_bricks

N = input()
lst = list(map(int, input().strip().split(" ")))

print(solve(lst))

Measured memory_bytes: 24744
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ans[200000];
signed main(){
    int n;
    cin >> n;
    int now = 26;
    int keta = 1;
    while(n>now){
        n -= now;
        now *= 26;
        keta ++;
    }
    int cnt = 0;
    n--;
    while(n>0){
        ans[cnt] = n%26;
        n/= 26;
        cnt ++;
    }
    for(int i=keta-1;i>=0;i--){
        cout << (char)('a' + ans[i]);
    }
    cout << endl;
    



    return 0;
}

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

using namespace std;
using ll = long long;

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

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

#define DIVIDER 1000000007LL

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N, K;
  cin >> N >> K;
  
  // main procedure
  ll count = 0;
  
  for (ll i = K; i <= N+1; ++i) {
    ll max_r = i * (2*N - i + 2) / 2;
    ll min_r = i * i / 2;

    count = (count + (max_r - min_r + 1)) % DIVIDER;
  }

  // output
  WRITE_N(count);

  return 0;
}

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

int main()
{
    string s,t;
    int count, min = 10000;
    cin >> s >> t;
    for(int i = 0; i <= s.length()-t.length(); i++)
    {
        count = 0;
        for(int j = 0; j < t.length(); j++)
        {
            if(t[j] != s[i+j])
            {
                count++;
                //cout << t[j];
            }
        }
        if(count < min)
            min = count;
    }
    cout << min;
}


Measured memory_bytes: 3192
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(n, k) = in.readLine().split("\\s+").map(_.toLong)

    val remainder = n % k
    out.println(Math.min(remainder, k - remainder))

    out.flush()
  }
}


Measured memory_bytes: 25672
h,w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
moves = [0]
for y in range(h):
  for x in range(w-1):
    if a[y][x]%2:
      moves[0] += 1
      moves.append("{} {} {} {}".format(y+1,x+1,y+1,x+2))
      a[y][x] -= 1
      a[y][x+1] += 1
x = w-1
for y in range(h-1):
  if a[y][x]%2:
    moves[0] += 1
    moves.append("{} {} {} {}".format(y+1,x+1,y+2,x+1))
    a[y][x] -= 1
    a[y+1][x] += 1
for x in moves:
  print(x)


Measured memory_bytes: 16404
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#include <cstdint>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long a;
std::string s;

int main(){
    std::cin >> a >> s;
    //std::cout << a << '!' << s << std::endl;
    long c = (s[0] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
    //printf("%ld\n", c);
    printf("%ld\n", a * c / 100);
}


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

long long comb(long long n, long long k){
	long long ans = 1;
	if(k > n-k) k = n-k;
	long long p = (long long) pow(10,9) + 7;
	for(int i = 0; i < k; i++){
		ans *= n-i;
		ans = ans % p;
	}
	for(int i= 0; i < k; i++){
		ans = ans /(k-i);
	}
	return ans;
}
int main(){
	long long n,k;
	cin >> n >>k;
	long long ans = 0;
	for(long long i=k;i<=n+1;i++){
		long long min=0,max=0;
		min = (i * (i - 1)) /2;
		max = ((2*n -i +1) * i) /2;
		ans += max -min+1;
	}
	ans = ans % ((long long)pow(10,9)+7);
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAXX 1000005
#define ll signed long long int
using namespace std;
ll t , n, ans = 0, k= 0;
ll a, b;

signed main()
{
    FAST;
    cin >> a >> b;
    if(2*b >= a){
    	cout << 0 ;
    	return 0;
	}
	cout << a - 2*b;
}

Measured memory_bytes: 256
"use strict"

const main = (input) => {
    input = input.split(" ").map(number => Number(number));
    const min = input.reduce((a, b) => a < b ? a : b);
    const max = input.reduce((a, b) => a > b ? a : b);
    let answer = min + max;
    for (const number of input) {
        if (number !== min && number !== max) {
            const medium = number;
            answer = min + medium;
        }
    }
    console.log(answer);
};

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

Measured memory_bytes: 11468
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <tuple>
#include <vector>

// lib/quo.hpp
#ifndef QUO_H
#define QUO_H

/*
a == tools:quo(a, b) * b + tools::mod(a, b)
0 <= tools::mod(a, b) < std::abs(b)
*/

namespace tools {
  template <typename T>
  constexpr T quo(const T lhs, const T rhs) {
    return lhs > 0 ? lhs / rhs : rhs > 0 ? -((-lhs - 1 + rhs) / rhs) : (-lhs - 1 + -rhs) / -rhs;
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// lib/extgcd.hpp
#ifndef EXTGCD_HPP
#define EXTGCD_HPP


/*
usage:

std::tuple<int, int, int> result = tools::extgcd(4, 5);
int gcd = std::get<0>(result);
int x0 = std::get<1>(result);
int y0 = std::get<2>(result);
*/

namespace tools {
  template <typename T>
  std::tuple<T, T, T> extgcd(T prev_r, T r) {
    T prev_s = 1;
    T prev_t = 0;
    T s = 0;
    T t = 1;
    while (r != 0) {
      const T q = quo(prev_r, r);
      const T next_r = prev_r - q * r;
      prev_r = r;
      r = next_r;
      const T next_s = prev_s - q * s;
      prev_s = s;
      s = next_s;
      const T next_t = prev_t - q * t;
      prev_t = t;
      t = next_t;
    }
    return std::make_tuple(std::abs(prev_r), prev_s, prev_t);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);

  std::vector<i64> cumgcd1({0});
  cumgcd1.reserve(N + 1);
  for (auto it = A.begin(); it != A.end(); ++it) {
    cumgcd1.push_back(std::get<0>(tools::extgcd(cumgcd1.back(), *it)));
  }
  std::vector<i64> cumgcd2({0});
  cumgcd2.reserve(N + 1);
  for (auto it = A.rbegin(); it != A.rend(); ++it) {
    cumgcd2.push_back(std::get<0>(tools::extgcd(cumgcd2.back(), *it)));
  }
  std::reverse(cumgcd2.begin(), cumgcd2.end());

  i64 answer = 0;
  for (i64 i = 0; i < N; ++i) {
    answer = std::max(answer, std::get<0>(tools::extgcd(cumgcd1[i], cumgcd2[i + 1])));
  }

  std::cout << answer << std::endl;
  return 0;
}

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

int main(){
	int n;
	scanf("%d",&n);
	int arr[n+5];
	for(int i=0;i<n;i++){
		scanf("%d",&arr[i]);
	}
	
	int cnt=0;
	sort(arr,arr+n);
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(arr[i]+arr[j]>arr[k]&&
					arr[i]+arr[k]>arr[j]&&
					arr[k]+arr[j]>arr[i]){
						cnt++;
					}
				else break;
			}
		}
	}
	printf("%d\n",cnt);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;
    cin>>n;
    vector<ll> a(n+1),b(n);
    ll sum1=0;
    REP(i,n+1){
        cin>>a[i];
        sum1+=a[i];
    }

    REP(j,n){
        cin>>b[j];
    }

    REP(i,n){
        if(a[i]-b[i]>0){
            a[i]-=b[i];
        }else{
            if(a[i+1]-(b[i]-a[i])>0){
                a[i+1]-=b[i]-a[i];
                a[i]=0;
            }else{
                a[i]=0;
                a[i+1]=0;
            }
        }
    }
    ll sum2=0;
    REP(i,n+1){
        sum2+=a[i];
    }
    cout<<sum1-sum2;
    return 0;
}


Measured memory_bytes: 1792
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    h, n = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    print("Yes" if sum(a) >= h else "No")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 52292
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int>d(k);
  vector<int>snk(n);
  for(int i=0;i<n;i++){
    snk[i]=0;
  }
  for(int i=0;i<k;i++){
      cin>>d[i];
    vector<int>a(d[i]);
    for(int j=0;j<d[i];j++){
      cin>>a[j];
      snk[a[j]-1]++;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(snk[i]==0)
      ans++;
  }
  cout<<ans<<endl;
}

 
  

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> cnt(110,0);
    vector<int> ans;
    int n; 
    while(cin>>n){
        cnt[n]++;
    }
    int y=0;
    for(int i=1; i<=100; i++){
        y=max(y,cnt[i]); 
    }
    for(int i=1; i<=100; i++){
        if(cnt[i]==y) ans.emplace_back(i);
    }
    for(auto& a: ans){
        cout<<a<<endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int my(int x,int y){
  if(x<y)
    swap(x,y);
  while(y>0){
    int z=y;
    y=x%z;
    x=z;
  }
  return x;
}

int main(){
  int n;
  cin >> n;
  vector<int> mon(n);
  for(int i=0;i<n;i++)
    cin >> mon.at(i);
  int x=mon.at(0);
  for(int i=1;i<n;i++)
      x=my(mon.at(i),x);
  cout << x << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int X;
	scanf("%d", &X);
	
	int p, x, y;
	for (x = X; x > 1; x--) {
		for (p = 2; p * p <= x; p++) {
			if (x % p == 0) {
				y = x;
				while (y % p == 0) y = y / p;
				if (y == 1) break;
			}
		}
		if (p * p > x) continue;
		else break;		
	}
	
	printf("%d\n", x);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
    string s, y="yyyy", m="mm", d="dd";
    cin >> s;
    for(int i=0; i<4; ++i) y[i] = s[i];
    for(int i=0; i<2; ++i) m[i] = s[i+5];
    for(int i=0; i<2; ++i) d[i] = s[i+8];
    int iy= atoi(y.c_str()),
        im=atoi(m.c_str()),
        id=atoi(d.c_str());
    if(
        (iy>=2019) && (im>4)
       ) cout << "TBD" << endl;
    else cout << "Heisei" << endl;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS 
#include<stdio.h>
main() {
	int a, b, c, cnt;

	a = 0, b = 0, c = 0,cnt = 0;
	scanf("%d %d %d", &a, &b, &c);
	for (a; a<=b; a++) {
		if ((c%a)==0) cnt = cnt + 1;
	}
	printf("%d\n", cnt);

	return 0;
}


Measured memory_bytes: 2128
#include<stdio.h>
#include<math.h>

int main() {
	int n, T, A, i, min, ans, tp;
	if (scanf("%d%d%d", &n, &T, &A) == 0) return 1;
	T = (A - T) * 1000;
	min = 1000000000;
	ans = 0;
	for (i = 0; i < n; i++) {
		if (scanf("%d", &A) == 0) return 1;
		tp = abs(T + A * 6);
		if (tp < min) {
			min = tp;
			ans = i + 1;
		}
	}
	printf("%d", ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long H;
    cin >> H;
    long long n=0,ans=1;
    for(;H>1;n++){
        H/=2;
    }
    for(int i=0; i<n; i++){
        ans=(ans*2)+1;
    }
    cout << ans;
    return 0;
}


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

int main()
{
	int k;
	string s;
	cin >> k >> s;
	cout<<s.substr(0,min(k,(int)s.size()));
	if(k<s.size())
	{
		cout<<"...";
	}
	cout<<endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i, s, n) for(int i=(s); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'
using std::swap;

int a[100005];

int partition(int a[], int head, int r)
{
   const int x = a[--r];
   int i = head - 1;
   rep(j, r){
      if(a[j] <= x){
         ++i;
         swap( a[i], a[j] );
      }
   }
   ++i;
   swap( a[i], a[r] );
   return (i);
}

signed main()
{
   int N;
   scanf("%d", &N);
   rep(i, N)scanf("%d", a+i);

   int pibot = partition(a, 0, N);

   rep(i, N){
      printf( (i == pibot)? "[%d]" : "%d" , a[i]);
      putchar_unlocked( i + 1 < N ? ' ' : '\n' );
   }
}




Measured memory_bytes: 3564
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = Integer.parseInt(sc.next());
    int N = Integer.parseInt(sc.next());
    if(N == 0){
      System.out.println(X);
      return;
    }
    int p[] = new int[N];
    for(int i = 0; i<N;i++){
      p[i] = Integer.parseInt(sc.next());
    }
    boolean f = true;
    for(int j = 0;j<100;j++){
      int before = X - j;
      int after = X + j;
      for(int k =0;k<N;k++){
        if(before == p[k]){
          f = false;
        } 
      }
      if(f==true){
        System.out.println(X-j);
        return;
      }
      f = true;
      for(int k =0;k<N;k++){
        if(after == p[k]){
          f = false;
        } 
      }
      if(f==true){
        System.out.println(X+j);
        return;
      }
      f = true;
    }
  }
}

Measured memory_bytes: 35724
/* 
 * Project: AtCoder Beginners Contest 150 B - Count ABC
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/20
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <algorithm>
#include <numeric>
using namespace std;

int n;
char s[50];

void solve() {

    int cnt = 0;
    bool flag_a = false;
    bool flag_b = false;
    for (int i=0;i<n;i++) {
        if (flag_b) {
            if (s[i] == 'C')
                cnt++;
            flag_b = false;
        }
        if (flag_a) {
            if (s[i] == 'B')
                flag_b = true;
            flag_a = false;
        }
        flag_a = s[i] == 'A';
    }
    printf("%d\n", cnt);
}

int main() {

    scanf("%d", &n);
    scanf("%s", s);

    solve();

}

Measured memory_bytes: 3196