akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using P = pair<int,int>;

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const double lam = 0.000001;

int main()
{
    int X; cin >> X;
    double an = 0, bn = 0;
    int K = 0;
    double theta = M_PI/2;
    while(true){
        /*
        double an_1 = an*cos(M_PI*X/180) - bn*sin(M_PI*X/180) + an;
        double bn_1 = an*sin(M_PI*X/180) + bn*cos(M_PI*X/180) + bn;
        */
        theta += M_PI*X/180;
        double an_1 = cos(theta) + an;
        double bn_1 = sin(theta) + bn;
        K += 1;
        if(abs(an_1)<lam && abs(bn_1)<lam){
            break;
        }else{
            an = an_1;
            bn = bn_1;
        }
    }
    cout << K << endl;
}

Measured memory_bytes: 3996
import java.util.*
import kotlin.*

import java.io.InputStream
import java.lang.NumberFormatException
import java.lang.StringBuilder


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = FastScanner()
        val s = sc.next()
        println(s.count { it == '+' } - s.count { it == '-' })
    }
}


class FastScanner {
    companion object {
        val input: InputStream = System.`in`
        val buffer = ByteArray(1024) { 0 }
        fun isPrintableChar(c: Int): Boolean = c in 33..126
    }

    var ptr = 0
    var buflen = 0
    private fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = input.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }

    private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b)
            b = readByte()
        }
        return sb.toString()
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextDouble(): Double = next().toDouble()
}


Measured memory_bytes: 31400
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    cout<<n*(n-1)/2<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

void insertSort(int a[],int n);

int main()
{
	int n;
	cin>>n;
	int a[1010];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int k=0;k<n-1;k++)cout<<a[k]<<' ';
	cout<<a[n-1]<<endl;
	insertSort(a,n);
	return 0;
}

void insertSort(int a[],int n)
{
	for(int i=1;i<n;i++){
		int v = a[i];
		int j=i-1;
		while(j>=0&&v<a[j]){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		for(int k=0;k<n-1;k++){
			cout<<a[k]<<' ';
		}
		cout<<a[n-1]<<endl;
	}
}


Measured memory_bytes: 3096
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll d;
  while (std::cin >> d) {
    ll ans = 0;
    for (ll x = d; x < 600; x += d) {
      ans += d * x * x;
    }
    std::cout << ans << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3056
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
// clang-format on

int N;
void dfs(string s, char mx) {
  if (s.length() == N) {
    printf("%s\n", s.c_str());
  } else {
    for (char c = 'a'; c <= mx; c++) {
      dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx));
    }
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  dfs("", 'a');

  return 0;
}


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

int main() {
	int n;cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]--;
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(a[a[i]]==i)ans++;
	}
	ans/=2;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;


#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search  >
#define lower(arr,n,fixed) lower_bound(arr,arr+n,fixed)-arr  //Lower value search  >=
#define FOR(i,a,n) for(int i=a; i<(int)n; i++)
#define FORI(i,a,n) for(int i=a; i>=(int)n; i--)
#define pii pair<int,int>
#define vpii vector<pii>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define all(a) a.begin(), a.end()
#define MEMSET(p,i) memset(p,i,sizeof(p))

typedef long long LL;

LL memo[100010];
LL v[100010];
int n;

LL dp(int i)
{
	if(i >= n)
		return 1e9;

	if(i == n-1)
		memo[i] = 0;

	if(memo[i] != -1)
		return memo[i];

	LL &dpm = memo[i];
	dpm = 0;
	dpm += min(abs(v[i]-v[i+1])+dp(i+1), abs(v[i]-v[i+2])+dp(i+2));
	return dpm;
}

int main(void)
{
	fastIO();

	cin >> n;

	MEMSET(v,0);
	FOR(i,0,n)
		cin >> v[i];
	
	MEMSET(memo,-1);

	cout << dp(0) << endl;
}

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

int main () {
  int N;
  cin >> N;
  
  if(N % 2 == 0) {
  	cout << N / 2 << "\n"; 
  } else {
   	cout << N / 2 + 1 << "\n"; 
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/* #include <atcoder/all> */
#include <iostream>
using namespace std;
/* using namespace atcoder; */
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 998244353;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    ll x;
    cin >> x;
    /* vector<vector<bool>> memo(7, vector<bool>(x+1, false)); */
    vector<bool> memo(x+1, false);
    memo[0] = true;
    REP(i, x+1) {
        if (!memo[i]) continue;
        REP(j, 6) {
            int nowval = 100 + j;
            if (i + nowval <= x) {
                memo[i+nowval] = true;
            }
        }
    }
    if (memo[x]) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}


int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 3632
#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>

const long INF = (1l << 30);
const long LINF = (1l << 60);

typedef std::pair<long, long> P;

long n;
long x[100005], l[100005];
P rob[100005];

int main(){
    scanf("%ld", &n);
    for(int i = 0; i < n; i++){
        scanf("%ld%ld", x+i, l+i);
        rob[i].first = x[i] - l[i];
        rob[i].second = x[i] + l[i];
    }
    std::sort(rob, rob+n);
    long ans = 0;
    long minr = rob[0].second;
    for(int i = 0; i < n; i++){
        if(minr <= rob[i].first){
            ans++;
            minr = rob[i].second;
        }else{
            minr = std::min(minr, rob[i].second);
        }
    }
    printf("%ld\n", ans+1);
}


Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*

*/

ll x,ans;

int main(void){
	cin>>x;
	reg(i,1,1e9){
		if(i*(i+1)/2>=x){
			ans=i;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
if len(S) % 2 == 1:
    l = len(S) - 1
else:
    l =len(S) - 2
while l > 0:
    if S[: (l // 2)] == S[(l // 2): 2 * (l // 2)]:
        print(l)
        break
    else:
        l -= 2


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

const int maxN = 2005, INF = 1e9;

struct Node
{
	int x, y, v;
	Node(int X = 0, int Y = 0, int Z = 0) { x = X; y = Y; v = Z; }
};

int n, ans, mx;
int A[maxN * 3 + 1];
int f[maxN + 1][maxN + 1], g[maxN + 1];

inline void chkmx(int a, int b, int v)
{
	f[a][b] = f[b][a] = max(f[a][b], v);
	g[a] = max(g[a], f[a][b]);
	g[b] = max(g[b], f[b][a]);
	mx = max(mx, f[a][b]);
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= 3 * n; i++) scanf("%d", &A[i]);

	if(n == 1) return puts(A[1] == A[2] && A[2] == A[3] ? "1" : "0"), 0;

	for(int i = 0; i <= n; i++)
	{
		g[i] = -INF;
		for(int j = 0; j <= n; j++)
			f[i][j] = -INF;
	}

	if(3 * n >= 5)
	{
		for(int i = 1; i <= 5; i++)
			for(int j = i + 1; j <= 5; j++)
			{
				int lst = 0;
				bool flag = true;
				for(int k = 1; k <= 5; k++)
					if(k != i && k != j)
					{
						if(lst && A[k] != lst) flag = false;
						lst = A[k];
					}
				if(flag) chkmx(A[i], A[j], 1);
				else chkmx(A[i], A[j], 0);
			}
	}

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			mx = max(mx, f[i][j]);

	for(int i = 6; i < 3 * n; i += 3)
	{
		int a = A[i], b = A[i + 1], c = A[i + 2];
		
		if(a == b && b == c) { ans ++; continue; }
		
		vector<Node> res; 
		
		res.push_back( Node(a, b, max(mx, f[c][c] + 1)) );
		res.push_back( Node(a, c, max(mx, f[b][b] + 1)) );
		res.push_back( Node(b, c, max(mx, f[a][a] + 1)) );

		for(int j = 1; j <= n; j++)
		{
			if(b == c) res.push_back( Node(a, j, max(g[j], f[j][c] + 1)) );
			else res.push_back( Node(a, j, g[j]) );
			if(a == c) res.push_back( Node(b, j, max(g[j], f[j][a] + 1)) );
			else res.push_back( Node(b, j, g[j]) );
			if(a == b) res.push_back( Node(c, j, max(g[j], f[j][b] + 1)) );
			else res.push_back( Node(c, j, g[j]) );
		}

		for(int i = 0; i < res.size(); i++)
			chkmx(res[i].x, res[i].y, res[i].v);
	}

	int res = -INF;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
		{
			int t = f[i][j];
			if(i == j && j == A[3 * n]) t ++;
			res = max(res, t);
		}
	
	printf("%d\n", res + ans);
	return 0;
}


Measured memory_bytes: 19596
#include <iostream>
#include <math.h>
using namespace std;
long long gcd(long long a,long long b){
	if(!b)return a;
	return gcd(b,a%b);
}
int main(){
	long long a,b,g,t,ans=1,tt;
	cin>>a>>b;
	g=gcd(a,b);
	t=g;int ss=sqrt(t);
	for(int i=2;i<=ss;i++){
		if(!(g%i)){
			while(!(g%i))g/=i;
			ans++;
		}
	}
	if(g!=1)ans++;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

// 素数判定
bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

int main(){
  ll X; cin>>X;

  for(ll i = X; i<=MAX; i++){
    if(is_prime(i)){
      cout<<i<<endl;
      return 0;
    }
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c;
  int d=0;
  cin>>a;
  int i;
  for(i=0;i<a;i++){
    cin>>b>>c;
    d+=c-b+1;
  }
  cout<<d<<endl;
}

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

int main(){
    int h, w, sc = 0;
    cin >> h >> w;
    char C[60][60];
    int D[60][60];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> C[i][j];
            if(C[i][j] == '#'){
                sc++;
            }
            D[i][j] = 1e9; 
        }
    }
    D[0][0] = 0;
    int dx[4] = {0, 0, -1, 1};
    int dy[4] = {-1, 1, 0, 0};
    queue<pair<int, int>> q;
    q.push(make_pair(0, 0));  
    while(!(q.empty())){
        pair<int, int> tmp = q.front();
        q.pop();
        for(int i = 0; i < 4; i++){
            int nx, ny;
            nx = tmp.first + dx[i];
            ny = tmp.second + dy[i];
            if(nx < 0 or ny < 0 or nx >= h or ny >= w or C[nx][ny] == '#'){
                continue;
            }
            if(D[tmp.first][tmp.second] + 1 < D[nx][ny]){
                D[nx][ny] = D[tmp.first][tmp.second] + 1;
                q.push(make_pair(nx, ny));
            }
        }
    }
    if(D[h - 1][w - 1] == 1e9) cout << -1 << endl;
    else{
        cout << h * w - D[h - 1][w - 1] - 1 - sc << endl;
    }

    return 0;
}

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

int main(){
  
  string a;
  cin >> a;
  
  if( a >= "A" && a < "a" ){
    
    cout << "A" << endl;
    
  }
  
  else {
    
    cout << "a" << endl;
    
  }
  
}
    
    


Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int a, b;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    if (a < b) {
        cout << "0\n";
    }
    else {
        cout << "10\n";
    }
    //system("pause");
    return 0;
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, M, P, ans=0, tmp=0;
vector<vector<pair<ll,ll>>> G;

vector<ll> to[2505];
vector<ll> rto[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];
bool ok[2505];
 
void dfs(int v) {
    if (reachableFrom1[v]) return;
    reachableFrom1[v] = true;
    for (int u : to[v]) {
        dfs(u);
    }
}

void rdfs(int v) {
    if (reachableToN[v]) return;
    reachableToN[v] = true;
    for (int u : rto[v]) {
        rdfs(u);
    }
}
 
signed main() {
    cin >> N >> M >> P;
    G.resize(N);
    for(int i=0;i<M;i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        c -= P;
        c = -c;
        G[a].push_back(make_pair(b,c));
        to[a].push_back(b);
        rto[b].push_back(a);
    }
    dfs(0);
    rdfs(N-1);
    for(int i=0;i<N;i++) {
        ok[i] = reachableFrom1[i]&reachableToN[i];
    }
    { // bellman-ford
        vector<int> d(N,INF);
        d[0] = 0;
        bool upd = true;
        int step = 0;
        while (upd) {
            upd = false;
            for(int a=0;a<N;a++) {
                for(int j=0;j<G[a].size();j++) {
                    ll b = G[a][j].first;
                    ll c = G[a][j].second;
                    if (!ok[a]) continue;
                    if (!ok[b]) continue;
                    int newD = d[a]+c;
                    if (newD < d[b]) {
                        upd = true;
                        d[b] = newD;
                    }
                }
            }
            step++;
            if (step > N) {
                puts("-1");
                return 0;
            }
        }
        ans = max(-d[N-1], 0LL);
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

// when range [l, r), has property notP~P, want first P.
// when return r, means not found.
template <typename T>
T bs_first(T l, T r, function<bool (T)> f) {
    assert(l < r);
    T mid;
    while (l != r) {
        mid = l + (r-l)/2;
        if (f(mid)) {
            r = mid;
        }else {
            l = mid + 1;
        }
    }
    return r;
}

const int N = 1024; 
int cnt[N][N];
int a[N<<1][N<<1];
int b[N<<1][N<<1];

void solve() {
    int n, D;
    cin >> n >> D;
    for (int _ = 0; _ < n; _++) {
        int x,y;
        cin >> x >> y;
        x%=D;
        y%=D;
        cnt[x][y]++;
    }
    n = 0;
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < D; j++) {
            int k = 0;
            while (k*k < cnt[i][j]) {
                k++;
            }
            n = max(n,k);
        }
    }
    int z = (n-1)*n;
    int p = (n-1)*(n-1);
    int Z = 0;
    int P = 0;
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < D; j++) {
            if (cnt[i][j] > z) {
                Z++;
                int x=i+1, y=j+1;
                a[x][y] = a[x][y+D] = a[x+D][y] = a[x+D][y+D] = 1;
            } else if (cnt[i][j] > p) {
                P++;
                int x=i+1, y=j+1;
                b[x][y] = b[x][y+D] = b[x+D][y] = b[x+D][y+D] = 1;
            }
        }
    }
    const int LIM = D<<1; 
    for (int i = 1; i <= LIM; i++) {
        for (int j = 1; j <= LIM; j++) {
            a[i][j] += a[i-1][j] + a[i][j-1] - a[i-1][j-1];
            b[i][j] += b[i-1][j] + b[i][j-1] - b[i-1][j-1];
        }
    }
    auto sum = [&](int i, int j, int d){
        return a[i+d][j+d] - a[i][j+d] - a[i+d][j] + a[i][j];
    };
    auto sum_b = [&](int i, int j, int d){
        return b[i+d][j+d] - b[i][j+d] - b[i+d][j] + b[i][j];
    };
    auto cover = [&](int i, int j, int d){
        return P - sum_b(i+d,j+d,D-d);
    };

    if (D == 1) {
        cout << (n-1); return;
    }

    int res = D;
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < D; j++) {
            int tmp = bs_first<int>(1, D, [&](int d){
                    return sum(i,j,d) >= Z;
                    });
            int cov = bs_first<int>(1, D, [&](int d){
                    return cover(i,j,d) >= P;
                    });
            tmp = max(tmp, cov);
            res = min(res, tmp);
        }
    }
    res += (n-1)*D - 1;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 37120
// AB BAHUT HO GAYA . NEXT LEVEL PAR JAO 
// HAVE FAITH AND BEILEVE IN YOURSELF 
#include<bits/stdc++.h>
using namespace std;
#define lli long long int 
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define loopb(i,a,b) for (lli i=a;i>=b;i--)
#define pb push_back
#define mod 1000000007
#define fast() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define gcd(a,b) (__gcd((a),(b)))
#define lcm(a,b)(((a)*(b))/gcd((a),(b)))
#define ma 1e18
#define bc __builtin_popcountll
#define vi vector<lli>
#define pr pair<lli,lli>
#define vp vector<pr>
#define F  first
#define S   second
#define lld long double
int main()
{fast();
lli n,a,b,c,d;
cin>>n;
a=0;
b=0;
c=0;
d=0;
string s;
loop(i,0,n)
{cin>>s;
if(s=="AC")
{a++;
}
if(s=="WA")
{b++;
}
if(s=="TLE")
{c++;
}
if(s=="RE")
{d++;
}
}
cout<<"AC x "<<a<<"\n";
cout<<"WA x "<<b<<"\n";
cout<<"TLE x "<<c<<"\n";
cout<<"RE x "<<d<<"\n";
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

int main(){
    char moji[10] = {};
    scanf("%s", &moji);
    if((moji[0] != moji[1])&&(moji[1]!=moji[2])&&(moji[2]!=moji[0])){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

int max(int a, int b){
    if(a > b){
        return a;
    }else{
        return b;
    }
}

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


int changeTheChar(char c){

  if(c=='I'){
    return 1;
  }else if(c=='V'){
    return 5;
  }else if(c=='X'){
    return 10;
  }else if(c=='L'){
    return 50;
  }else if(c=='C'){
    return 100;
  }else if(c=='D'){
    return 500;
  }else if(c=='M'){
    return 1000;
  }

  

  return 0;

}

int main()
{
  string str;
  while(cin >> str){

    vector<int> roman(str.size(), 0);
    // ????????????
    for(int i=0;i<str.size();i++){
      roman[i] = changeTheChar(str[i]);
    }

    for(int i=0;i<roman.size();i++){
      // cout << roman[i] << " ";
    }

    int res = 0;
    while(roman.size()>0){
      int maxI=0;
      int maxIndex;
      // ?????§???????´¢
      for(int i=roman.size()-1;i>=0;i--){
	if(maxI <= roman[i]){
	  maxI = roman[i];
	  maxIndex = i;
	}
      }
      // cout << maxIndex << endl;
      // cout << maxI << endl;

      if(maxIndex!=0){
	res += roman[maxIndex] - roman[maxIndex-1];
	roman.erase(roman.begin());
	roman.erase(roman.begin());
      }else{
	res += roman[maxIndex];
	roman.erase(roman.begin());
      }

      // cout << res << endl;
    }

    cout << res << endl;


  }




  return 0;
}

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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b >> c >> x;
	if (a * b > c * x) {
		cout << a * b;
	}
	else {
		cout << c * x;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    ll n;
    cin >> n;
    ll ans[40];
    REP(i, 40)ans[i] = -1;
    ll idx = 0;
    while(true){
        if(!(n % 2)){
            n = n / (-2);
            ans[idx] = 0;
        }else{
            n = (n - 1) / (-2);
            ans[idx] = 1;
        }
        if(!n){
            ans[0] = 0;
            break;
        }
        if(n == 1){
            ans[++idx] = 1;
            break;
        }

        idx++;
    }
    RREP(i, 40){
        if(ans[i] != -1)cout<<ans[i];
    }
    print("");
}

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

int main()
{
  int n;
  scanf("%d",&n);
  static int a[200000];
  for(int i=0;i<2*n-1;i++){
    scanf("%d",a+i);
  }
  int L=1,R=2*n;
  while(L+1<R){
    int d=(L+R)/2;
    int x=0,y=0;
    while(x<=n-2&&!(a[n-1-x]<d&&a[n-2-x]<d)&&!(a[n-1+x]<d&&a[n+x]<d)){\
      x++;
    }
    while(y<=n-2&&!(a[n-1-y]>=d&&a[n-2-y]>=d)&&!(a[n-1+y]>=d&&a[n+y]>=d)){\
      y++;
    }
    if(y<x||(y==x&&((a[n-1]>=d&&n%2==1)||(a[n-1]<d&&n%2==0)))){
      L=d;
    }
    else{
      R=d;
    }
  }
  printf("%d\n",L);
  return 0;
}


Measured memory_bytes: 896
def main():
    NMC = list(map(int, input().split()))
    N, M, C = NMC[0], NMC[1], NMC[2]
    B = list(map(int, input().split()))
    A = [input() for i in range(N)]
    ans = 0
    sum = 0
    cnt = 0
    for j in range(len(A)):
        sample = list(map(int, A[j].split()))
        for k in range(len(sample)):
            sum += sample[k]*B[k]
        sum = sum + C
        cnt += 1
        if sum > 0:
            ans += 1
        sum = 0
    print(ans)
main()


Measured memory_bytes: 3064
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]
ans = [[] for i in range(n)]
for i in range(n):
    for j in range(m):
        ans[i].append(abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]))
for i in range(n):
    print(ans[i].index(min(ans[i]))+1)

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

int main() {
  int n;
  cin >> n;
  int a[n+1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int run = a[1];
  int count = 1;
  
  while (run != 2 && count < n) {
    run = a[run];
    count++;
  }
  if (run == 2) cout << count << endl;
  else cout << "-1" << endl;
  return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int n;
  cin >> n;
  vi primes;
  for (int i = 2; i <= n; i++) {
    bool flag = true;
    for (int j = 2; j < i; j++) {
      if (i % j == 0) {
        flag = false;
        break;
      }
    }
    if (flag) {
      primes.push_back(i);
    }
  }
  int m = primes.size();
  vi num(m);
  for (int i = 2; i <= n; i++) {
    int x = i;
    rep (j, m) {
      while (x % primes[j] == 0) {
        num[j]++;
        x /= primes[j];
      }
    }
  }
  vii a = {
    {24, 2}, {4, 4, 2}, {14, 4}, {74}
  };
  ll ans = 0;
  rep (i, a.size()) {
    ll temp = 1;
    rep (j, a[i].size()) {
      int x = 0;
      rep (k, m) {
        if (num[k] >= a[i][j]) {
          x++;
        }
      }
      x -= j;
      temp *= max(x, 0);
    }
    if (i == 1) temp /= 2;
    ans += temp;
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 384
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define limit 1000000000000000000 //1e18
#define mod 1000000007 //1e9+7
#define llu long long unsigned
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,n)    for(ll i=0; i<n; i++)
#define rep1(i,a,b)    for(ll i=a; i<b; i++)
#define repV(i,n)    for(ll i=0; i<v.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  i,j,n,k,opt=0;
    string s,t;
    cin >>n>>s;
    ll lft=0,ryt=n-1;
    while(lft<ryt)
    {
        if(s[lft]=='W'&&s[ryt]=='R')
        {
            swap(s[lft],s[ryt]);opt++;
        }
        else if(s[lft]=='W'&&s[ryt]=='W')
        {
            ryt--;
        }
        else if(s[lft]=='R'&&s[ryt]=='R')
        {
            lft++;
        }
        else{
            lft++;ryt--;//R-W
        }
    }
    cout <<opt<< endl;
    return 0;
}


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

using namespace std;
#define ll long long
#define f first
#define s second
int main() {
    //freopen("sample-8.in", "r", stdin);
    //freopen("output8.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll r,d,x;
    cin>>r>>d>>x;
    for(int i=0;i<10;i++){
        x=r*x-d;
        cout<<x<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

score = 0
prev = -1
for ai in a:
    score += b[ai - 1]
    if prev + 1 == ai:
        score += c[prev - 1]

    prev = ai

print(score)

Measured memory_bytes: 38480
#include<stdio.h>
 
int main(void){
  char b[11];
  int i,c=0,n=0,x=0;
  
  scanf("%s",b);
  
  for(i=0;i<11;i++){
    if(b[i]=='A'||b[i]=='C'||b[i]=='G'||b[i]=='T'){
      c++;
      n=1;
    }
    else if(n==1){
      if(x<c){
      x=c;
      c=0;
      }
    }
  }
  
  printf("%d\n",x);
   
  return 0;
}

Measured memory_bytes: 128
N, Q = map(int, input().split())
S = input()

numAC = [0]
for i in range(1, N):
  numAC.append(numAC[-1] + int(S[i-1:i+1] == 'AC'))

for _ in range(Q):
  l, r = map(int, input().split())
  print(numAC[r-1] - numAC[l-1])

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

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

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


int dfs(int yi, int xi, vvi& used, vector<string>& m){

  stack<pii> st;
  st.push(pii(yi,xi));

  int size = 0;
  set<char> flag;
  while(st.size()){
    int y = st.top().first;
    int x = st.top().second;
    st.pop();
    if(used[y][x] == 1) continue;
    used[y][x] = 1; size ++;
    
    for(int i=0; i<4; i++){
      int ny = y + dy[i];
      int nx = x + dx[i];

      if(ny >= h || ny < 0 || nx >= w || nx < 0){ // ?£????
	continue;
      }
      else if(m[ny][nx] == 'B' || m[ny][nx] == 'W'){ // ???
	flag.insert(m[ny][nx]);
	continue;
      }
      else if( used[ny][nx] == 1 ){ // ??¢?´¢??????
	continue;
      }
      else if(m[ny][nx] == '.'){ // ?????????
	st.push(pii(ny,nx));
      }
    }
  }
  if( flag.size() == 2 || flag.size() == 0) return 0;
  if( *flag.begin() == 'W') return size*(-1);
  return size;

}


int main(){

  while(1){
    cin >> w >> h;
    if(!w and !h) break;

    vector<string> m(h);
    for(int j=0; j<h; j++)
      cin >> m[j];

    
    int bl=0,wh=0;
    vvi used(h,vector<int>(w,0));
    for(int j=0; j<h; j++){
      for(int i=0; i<w; i++){
	if( m[j][i] == '.' and used[j][i] == 0 ){
	  int x = dfs(j,i,used,m);
	  if(x > 0){
	    bl += x;
	  }
	  if(x < 0){
	    wh -= x;
	  }
	}
      }
    }
    cout << bl << " " << wh << endl;
  }
  
}

Measured memory_bytes: 1280
#import time

def main():
    N, M = map(int, input().split())
    Hs = [0]+list(map(int, input().split()))
    As = [list(map(int, input().split())) for _ in range(M)]

    edge = [{0} for _ in range(N+1)]
    for i in range(M):
        j, k = As[i]
        edge[j].add(Hs[k])
        edge[k].add(Hs[j]) 
    
    tru = [True] * (N+1)
    #s = {0,1}
    #print(edge)   
    for i, s in enumerate(edge):
        if len(s)==1:
            if 0 in s: continue
        ma = int(max(s))
        if ma >= Hs[i]:
            tru[i] = False
    
    ans = tru.count(True)-1

    return ans

if __name__ == '__main__':
    #start = time.time()
    print(main())
    #elapsed_time = time.time() - start
    #print("経過時間:{}".format(elapsed_time * 1000) + "[msec]")

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

using namespace std;

const int MOD = 1e9 + 7;

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	
	long long res = 0;
	
	for (int i = k; i <= n + 1; i++) {
		long long least = 1LL * i * (i - 1) / 2LL;
		long long most = 1LL * (n + 1) * n / 2LL - 1LL * (n + 1 - i) * (n - i) / 2LL;
		
		res = (res + (most - least + 1)) % MOD;
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 3836
#include <iostream>

using namespace std;

int main() 
{
    
    int a, b, c, i, ans;
    cin >> a >> b >> c;
ans = 0; //initialise
    
 for( i=a; i<=b; i++)
 {
      if(c % i == 0)
     
     ans++;
 }
    
    cout << ans <<endl;
}


Measured memory_bytes: 3116
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int count=0,i,j;
		while(sc.hasNext()){
			String str=sc.next();
			char ch[]=str.toCharArray();
			for(i=0;i<ch.length/2;i++){
				if(ch[i]!=ch[ch.length-i-1]) break;
			}
			if(i==ch.length/2) count++;
		}
		System.out.println(count);
	}
}

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

int main(){
  int A,B; cin>>A>>B;
  string S; cin>>S;
  string ans="Yes";
  for(int i=0; i<A+B+1; i++){
    if(i==A&&S[i]!='-')ans="No";
    if(i!=A&&S[i]=='-')ans="No";
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {

    int N, X, Y;
    cin >> N >> X >> Y;
    
    int ans[N];
    for (int i = 0; i < N; i++) {
      ans[i] = 0;
    }
    
    for (int i = 1; i <= N-1; i++) {
      for (int j = i+1; j <= N; j++) {
        ans[min(j-i,abs(X-i)+1+abs(Y-j))]++;
      }
    }
    
    for (int i = 1; i <= N-1; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <iostream>
#include <cmath>
#define ll long long
#define EPS 1e-5
#define FOR(i,x,y) for(int i = x; i <= y; ++i)
#define rFOR(i,x,y) for(int i = x; i >= y; --i)
#define MS(x,y) memset(x,y,sizeof x)
using namespace std;

char a[400000];
int nxt[300000][30];
int dp[300000];


int main()
{
    MS(dp,0);
    scanf("%s",a + 1);
    int len = strlen(a + 1);
    for(int i = 0; i < 26; ++i) nxt[len + 1][i] = -1;
    for(int i = len; i >= 0; i--)
    {
        for(int j = 0; j < 26; ++j)
        {
            if(a[i] == 'a' + j)
                nxt[i][j] = i;
            else nxt[i][j] = nxt[i + 1][j];
        }
    }
    //string ans;
    dp[len + 1] = 1;
    for(int i = len; i >= 1; --i)
    {
        dp[i] = 1e9;
        for(int j = 0; j < 26; ++j)
        {
            if(nxt[i][j] == -1) dp[i] = 1;
            else dp[i] = min(dp[i],dp[nxt[i][j] + 1] + 1);
        }
    }

    int now = 1;
    while(now != -1)
    {
        for(int i = 0; i < 26; ++i)
        {
            if(nxt[now][i] == -1)
            {
                printf("%c\n",'a' + i);
                now = -1;
                break;
            }
            else if(dp[now] == dp[nxt[now][i] + 1] + 1)
            {
                printf("%c",'a' + i);
                now = nxt[now][i] + 1;
                break;
            }
        }
    }
    //printf("\n");
}


Measured memory_bytes: 27136
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int, int>pii;
int ans[1000000];
int main()
{
	int num;
	scanf("%d", &num);
	vector<pii>v;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		v.push_back(make_pair(z, i + 1));
		ans[z] = i + 1;
	}
	sort(v.begin(), v.end());
	int pt = 1;
	for (int i = 0; i < v.size(); i++)
	{
		for (int j = 0; j < v[i].second - 1; j++)
		{
			for (;;)
			{
				if (ans[pt] == 0)
				{
					if (pt >= v[i].first)goto l01;
					ans[pt] = v[i].second;
					pt++;
					break;
				}
				pt++;
			}
		}
	}
	reverse(v.begin(), v.end());
	pt = num * num;
	for (int i = 0; i < v.size(); i++)
	{
		for (int j = 0; j < num - v[i].second; j++)
		{
			for (;;)
			{
				if (ans[pt] == 0)
				{
					if (pt <= v[i].first)goto l01;
					ans[pt] = v[i].second;
					pt--;
					break;
				}
				pt--;
			}
		}
	}
	printf("Yes\n");
	for (int i = 0; i < num*num; i++)printf("%d ", ans[i + 1]); printf("\n");
	if (false)
	{
	l01:;
		printf("No\n");
	}
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define ll long long
#define endl \'n'
using namespace std;
const ll mod = (ll)10e9+7;
const int INF = 0x3f3f3f3f;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int m=0;
    string str;
    cin >> str;
    str = ' ' + str;
    int n = str.length();
    for(int i=1; i<=n-2; i++)
    {
        if(str[i]==str[i+1])
        {
            cout << i << " " << i+1;
            return 0;
        }
        else if(str[i]==str[i+2])
        {
            cout << i << " " << i+2;
            return 0;
        }
    }
    cout << "-1 -1";
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
const int mx=2e6+5;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,m;cin >> n >> m;
	vector <int> a(n);
	int sum=0;
	rep(i,m){
		cin >> a[i];
		sum+=a[i];
	}
	if(sum>n)cout<<-1<<endl;
	else cout<<n-sum << endl;;
}
	


Measured memory_bytes: 7176
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    vector<int> v;
    int mini = 1e9;
    rep(i,n){
        int a;
        cin >> a;
        v.push_back(a);
    }
    int ite = mini;
    rep(i,ite){
        int tmpmin = mini;
        rep(j,n){
            if(v[j] != mini){
                v[j] %= mini;
            }
            if (v[j] != 0){
                tmpmin = min(tmpmin,v[j]);
            }
       }
       if(tmpmin == mini)break;
       mini = tmpmin;
    }
    P(mini);
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 892
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef tuple<ll, ll, ll> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    double a, b, x; cin >> a >> b >> x;
    if(x < a*a*b / 2.0){
        double y = 2.0 * x / a / b;
        cout << fixed << setprecision(20) << 180.0 / pi * atan(b/y) << endstr;
    }
    else{
        double rem = a*a*b - x;
        double y = 2.0*rem / a / a;
        cout << fixed << setprecision(20) << 180.0 / pi * atan(y/a) << endstr;
    }
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
const int N=2e3+20,MOD=1e9+7;
int c[N][N],n,k,red,blue,ans;
int main()
{
	c[0][0]=1;
	for(int n=1;n<N;n++)
	{
		for(int r=0;r<=n;r++)
		{
			if(r==0 or r==n) c[n][r]=1;
			else c[n][r]=c[n-1][r-1]+c[n-1][r];
			c[n][r]%=MOD;
		}
	}

	cin>>n>>k;

	blue=k,red=n-k;
	for(int k=1;k<=blue;k++)
	{
		ans=(1ll*c[red+1][k]*c[blue-1][k-1])%MOD;
		printf("%d\n",ans);
	}
}

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

int main()
{
	int a[5],i,j,k;

	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
	for(i=0; i<5; i++)
	{
		for(j=i+1; j<5; j++)
		{
			if((a[j]-a[i])>k)
			{
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;

	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ka=[list(map(int,input().split())) for _ in range(n)]

flg = [0] * (m+1)
for i in range(n):
  for j in range(1,ka[i][0]+1):
    food = ka[i][j]
    flg[food] += 1

result = 0
for i in range(m+1):
  if flg[i] == n:
    result += 1
print(result)

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
#define in std::cin
#define ou std::cout
int main() {
    int N;
    in >> N;
    int t = N%2 == 0? 0:1;
    ou << N/2 + t << std::endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
  
int main() {
  int N,K;
  cin >> N >> K;
  int x = 1;
  
  rep(i,N){
    if (x < K) {
      x *= 2;
    }else x += K;
  }
  cout << x;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    uint64_t n=1,x = 0;
    int k;
    cin>>k;
    queue< uint64_t> q;
    
    set <uint64_t> s;
    for(int i=1;i<10;i++){
        s.insert(i);
    }
    uint64_t i;
    for(i=0;i<k;i++){
        x = *s.begin();
        if(x >= 4000000000) break;
        int lst =x%10;
        if(lst != 0){
            s.insert((x*10 + (lst -1)));
        }
        s.insert((x*10 + (lst)));
        if(lst != 9){
            s.insert((x*10 + (lst + 1)));
        }
        s.erase(s.begin());
    }
    k--;
    // cout<<"ho gya\n";
    while(k-->0)
        s.erase(s.begin());
    
    // cout<<"nhi gya\n";
    cout<<x;
    return 0;
}

Measured memory_bytes: 9216