akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  bool is_ok = false;
  for (int i = 0; i <= N; i += 7)
  {
    if ((N - i) % 4 == 0)
      is_ok = true;
  }

  if (is_ok)
  {
    printYes();
  }
  else
  {
    printNo();
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N, M;
	cin >> N >> M;

	vector<int> coord(M, 0);

	for (int i = 0; i < M; i++)
	{
		cin >> coord[i];
	}

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

	int accum = 0;
	vector<int> diff;

	for (int i = 0; i < M - 1; i++)
	{
		accum += (coord[i + 1] - coord[i]);
		diff.push_back(coord[i + 1] - coord[i]);
	}

	sort(diff.begin(), diff.end(), [](const int& l, const int& r)
	{
		return l > r;
	});

	for (int i = 0; i < min(N - 1, (int)diff.size()); i++)
	{
		accum -= diff[i];
	}

	cout << accum;

	return 0;
}


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

ll ans[100000];
int main() {
	ll n;
	cin>>n;
	for(ll i=1;i<=100;i++){
		for(ll j=1;j<=100;j++){
			for(ll k=1;k<=100;k++){
				ll cnt=i*i+j*j+k*k+i*j+j*k+k*i;
				ans[cnt]++;
			}
		}
	}
	for(ll i=1;i<=n;i++){
		cout <<ans[i]<<endl;
	}
	// your code goes here
	return 0;
}

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

#define pii pair<int,int>
#define pll pair<lld,lld>
#define pb push_back
#define next nextt
#define left leftt
#define right rightt
#define lld long long
#define Inf 2100000100
#define mod 1000000007
#define Linf 1000000000000000000LL
#define get gett

using namespace std;

int N,K,ans;

int gcd(int x,int y){
	return x ? gcd(y%x,x) : y;
}

int main(){
	int tmp,big;
	scanf("%d %d %d",&N,&K,&tmp);
	big = tmp;
	for(int i=1; i<N; i++){
		int x;
		scanf("%d",&x);
		tmp = gcd(tmp,x);
		big = max(big,x);
	}
	if(N == 1){
		if(K == tmp) ans = 1;
	}else{
		if(K%tmp == 0 && K <= big) ans = 1;
	}
	if(ans == 1) puts("POSSIBLE");
	else puts("IMPOSSIBLE");

	return 0;
}


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

char g[100][100];

int main() {
    int A, B; cin >> A >> B;
    rep(i, 100){
        rep(j, 100){
            if(i < 50){
                g[i][j] = '.';
            } else {
                g[i][j] = '#';
            }
        }
    }

    int cnta = 0;
    int cntb = 0;

    bool ch = false;
    for (int i = 0; i < 50; i+=2){
        for (int j = 0; j < 100; j+=2){
            if(cntb == B-1){
                ch = true;
                break;
            }
            g[i][j] = '#';
            cntb++;
        }
        if(ch)break;
    }

    ch = false;
    for (int i = 51; i < 100; i+=2){
        for (int j = 0; j < 100; j+=2){
            if(cnta == A-1){
                ch = true;
                break;
            }
            g[i][j] = '.';
            cnta++;
        }
        if(ch)break;
    }

    cout << 100 << " " << 100 << endl;
    rep(i, 100){
        rep(j, 100){
            cout << g[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 

int arr[3][3];
bool vis[3][3]={0};

int main()
{
    fastio();
    int n,k; cin>>n>>k; int arr[k]; for(int i=0;i<k;++i) cin>>arr[i];
    sort(arr,arr+k);
    int distance=n-arr[k-1]+arr[0];
    for(int i=1;i<k;++i)
    {
        if(arr[i]-arr[i-1]>=distance) distance=arr[i]-arr[i-1];
    }
    cout<<n-distance;
    return 0;
}

Measured memory_bytes: 1024
while n = gets
  n.to_i.times{
    xa,ya,ra,xb,yb,rb = gets.split.map(&:to_f)
    dist = ((xa-xb)**2+(ya-yb)**2)**0.5
    if dist > ra+rb then
      puts 0
    elsif rb < ra and dist < ra-rb
      puts 2
    elsif ra < rb and dist < rb-ra
      puts -2
    else
      puts 1
    end
  }
end

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

#define SUQARE_SIZE  100000

int block[SUQARE_SIZE];
int blockSize;

void updateTable(int arr[],int index,int val)
{
    // 更新
    arr[index] += val;
    // block内の合計値を更新する
    int blockNumber = index / blockSize;
    int startIndex = blockNumber * blockSize;
    int addValue = arr[startIndex];
    // ブロック内の最大値を更新する
    for (int i = startIndex + 1;i < startIndex + blockSize;++i) {
        addValue += arr[i];
    }
    block[blockNumber] = addValue;
}

int query(int arr[],int l, int r)
{
    int addValue = 0;
    // 左端
    while (l < r && l % blockSize != 0 && l != 0)
    {
        addValue += arr[l];
        l++;
    }
    // blockに該当する部分
    while ((l + blockSize) <= r)
    {
        addValue += block[l / blockSize];
        l += blockSize;
    }
    // 右端
    while (l <= r)
    {
        addValue += arr[l];
        l++;
    }
    return addValue;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,q,x,y,c;
    cin >> n >> q;
    int nums[n];
    for(int i = 0;i < n;++i){
        nums[i] = 0;
        block[i] = 0;
    }
    // block size
    blockSize = sqrt(n);
    
    for(int i = 0;i < q;++i){
        cin >> c >> x >> y;
        x--;        // 1から!
        switch(c){
                // add(i,x): aiにxを加算する。
            case 0:
                updateTable(nums,x,y);
                break;
                // getSum(s,t): as,as+1,...,atの合計値を出力する。
            case 1:
                --y; // 1から!
                cout << query(nums,x,y) << endl;
                break;
        }
    }
}



Measured memory_bytes: 3964
#include<iostream>

using namespace std;

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

  int five = 0, seven = 0;
  five = (a == 5) + (b == 5) + (c == 5);
  seven = (a == 7) + (b == 7) + (c == 7);
  cout << (five == 2 && seven ==1 ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
m = 10^9 + 7 :: Int

modpow :: Int -> Int -> Int
modpow a n
    | n == 1 = a `mod` m
    | otherwise = (if n `mod` 2 == 1
                  then a * modpow (a `mod` m)  (n-1)
                  else modpow (a*a `mod` m) (n `div` 2)) `mod` m

fact :: Int -> Int -> Int
fact x y
    | x == y = y
    | otherwise = x * fact (x - 1) y `mod` m

nCr :: Int -> Int -> Int
nCr n r = ((fact n (n-r+1)) * modpow (fact r 1) (m - 2) ) `mod` m

main :: IO()
main = do
  [n,a,b] <- map read . words <$> getLine
  print $ ((modpow 2 n) - 1 - nCr n a - nCr n b) `mod` m

Measured memory_bytes: 8204
#include <iostream>

using namespace std;

int main()
{
    char s[11];
    int N,K;
    char flag;
    int i;
    scanf("%d", &N);
    fflush(stdin);
    scanf("%s", s);
    fflush(stdin);
    scanf("%d", &K);
    flag = s[K - 1];
    for(i = 0; i < N; i++)
    {
        if(s[i] != flag)
        {
            s[i] = '*';
        }
    }
    printf("%s\n", s);
    return 0;
}


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

struct Edge{
    int to, id;
};

vector<vector<Edge> > g;
vector<int> ans;

void dfs(int v, int p = -1, int pc = -1){
    int color = 1;
    rep(i,g[v].size()){
        int u = g[v][i].to, ei = g[v][i].id;
        if(u == p) continue;
        if(color == pc) color++;
        ans[ei] = color;
        color++;
        dfs(u, v, ans[ei]);
    }
}

int main(){
    int n;
    cin >> n;
    g.resize(n);
    ans = vector<int>(n-1);
    int a, b;
    rep(i,n-1){
        cin >> a >> b;
        a--; b--;
        g[a].push_back((Edge){b, i});
        g[b].push_back((Edge){a, i});
    }

    dfs(0);
    int dig = 0;
    rep(i,n){
        dig = max(dig, int(g[i].size()));
    }
    cout << dig << endl;
    rep(i,n-1){
        cout << ans[i] << endl;
    }  
}

Measured memory_bytes: 8320
# coding: utf-8
# Your code here!
input_line = input().split()
N = int(input_line[0])
M = int(input_line[1])
count = 0
line = input().split()
for i in range(M):
    count+=int(line[i])
    
if N - count <= -1:
    print(-1)
    
    
else:
    print(N - count)

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

int main() {
    string s, ans = "";
    cin >> s;

    for (int i = 0; i < 4; i++)
    {
        ans += s[i];
    }
    if (ans == "YAKI")
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
  
int cd(long long n) 
{ 
    int count = 0; 
    while (n != 0) { 
        n = n / 10; 
        ++count; 
    } 
    return count; 
} 
  
int main(void) 
{ 
    long long n;
    cin>>n;
	int c=0,i; 
    for(i=1;i<=n;i++)
    {
    	if(cd(i)%2==1)
    	{
    		c++;
		}
	}
	cout<<c;
    return 0; 
} 
  

Measured memory_bytes: 256
import sys
from collections import deque

# input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


def main():
    BLACK = '#'
    WHITE = '.'
    H, W = map(int, input().split())
    graph = [None] * H
    # w_score = [[0 for i in range(W)] for i in range(H)]
    # h_score = [[0 for i in range(W)] for i in range(H)]
    options = [(-1, 0), (0, 1), (1, 0), (0, -1)]
    visited = [[False for i in range(W)] for i in range(H)]
    initial = []

    for i in range(H):
        graph[i] = list(input())

        for j in range(W):
            if graph[i][j] == BLACK:
                initial.append((i, j))
                visited[i][j] = True

    # print(visited)
    # print(graph)

    q = deque()
    q.append(initial)
    ans = 0
    while len(q) != 0:
        n = q.popleft()
        # print(ans, n)

        items = set()
        for p in n:
            for d in options:
                i = p[0] + d[0]
                j = p[1] + d[1]

                if i >= 0 and i < H and j >= 0 and j < W and not visited[i][j] and graph[i][j] == WHITE:
                    visited[i][j] = True
                    graph[i][j] = BLACK
                    items.add((i, j))
                # else:
                #     print(i, j)

        if len(items) > 0:
            ans += 1
            q.append(items)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 139176
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
string s;
int k;
int INFi=1000000000;
ll INFl=1000000000000000;

struct UnionFind{
    vector<int> par;//初期化
    vector<int> rank;//高さ
    UnionFind(int n=0):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);//経路圧縮
    }
    void unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry) return;
        if(rank[rx]<rank[ry]) rank[rx]=ry;
        else rank[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
struct edge{int from,to,cost;};
vector<edge> es(100); //辺の集合
vector<int> d(100,INFi);//最短距離
int V,E;//頂点数、辺数

int main(){
    string s;cin>>s;
    int a[10];
    int b=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0'){
            a[b]=0;
            b++;
        }
        else if(s[i]=='1'){
            a[b]=1;
            b++;
        }
        else if(s[i]=='B'&&b!=0) b--;
    }
    for(int i=0;i<b;i++) cout<<a[i];
    cout<<endl;
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug_x(x) cout<< #x <<"---> : "<<x<<endl;
#define debug_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#define _rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
//std::mt19937 mrand(random_device{}());
//int rnd(int x) { return mrand() % x ; }
const ll mod=1e7;
ll ksm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

/***********************/

int main(){
    ssd;
    int n,k;cin>>n>>k;
    vector<string> s(n);
    for(auto &it : s) cin>>it;
    sort(all(s));
    for(auto it : s) cout<<it;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <stdio.h>

using namespace std;

int main(void)
{

	int val,count = 0;
	while (cin >> val)
	{
		for (int a = 0; a < 10; a++)
		{
			for (int b = 0; b < 10; b++)
			{
				for (int c = 0; c < 10; c++)
				{
					for (int d = 0; d < 10; d++)
					{
						if (a + b + c + d == val)count++;

					}

				}


			}


		}

		printf("%d\n", count);
		count = 0;

	}

}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  vector<int> h(n);
  rep(i,n){
    cin>>h[i];
  }
  vector<int> dp(n);
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  fori(i,2,n){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),
              dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[n-1]<<endl;
  return 0;
}


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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    if(n==0){
        cout << n << endl;
        return 0;
    }
    else if(n==1){
        cout << 1 << endl;
        return 0;
    }
    else if(n==-1){
        cout << 11 << endl;
        return 0;
    }
    vector<int> ans(1e4, 0);
    int cnt=0;
    while(1){
        if(n%2==0){
            if(n==-2){
                ans[cnt++]=0;
                ans[cnt++]=1;
                break;
            }
            else{
                ans[cnt++]=0;
                n=n/(-2);
            }
        }
        else{
            if(n==-1){
                ans[cnt++]=1;
                ans[cnt++]=1;
                break;
            }
            ans[cnt++]=1;
            if(n<0) n=n/(-2)+1;
            else n=n/(-2);
            //cout << n << endl;
        }
        //cout << n << endl;
    }

    for(int i=cnt-1; i>=0; i--){
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
void printVector(vector < pair <lli,lli> > v){
    for(int i =0;i<v.size();i++)cout << v[i].first << " " << v[i].second << endl;
    cout << endl;
}
int main(){
    
    lli n,m;
    cin >> n >> m;

    vector < pair <lli,lli> > v(n+1);
    for(int i =1;i<=n;i++){
        lli x,y;
        cin >> x >> y;
        v[i].first = x;
        v[i].second = y;
    }
    //printVector(v);
    vector < vector <lli> > dp(n+1, vector <lli> (m+1));
    for(int i =0;i<=n;i++)dp[i][0]=0;
    for(int j = 0;j<=m;j++)dp[0][j] = 0;
//    for(int i =1;i<=n;i++){
//        for(int j =1;j<=m;j++){
//
//                cout << dp[i][j] << " ";
//        }
//        cout << endl;
//    }
    for(int i =1;i<=n;i++){
        for(int j =1;j<=m;j++){
                dp[i][j] = dp[i-1][j];
            if(v[i].first<=j)
                dp[i][j] = max(dp[i][j],dp[i-1][j-v[i].first]+v[i].second);
                //cout << dp[i-1][j-v[i].first]+v[i].second << endl;
                //cout << i -1 << " " << j-v[i].first << endl;
        }
    }
//    for(int i =1;i<=n;i++){
//        for(int j =1;j<=m;j++){
//
//                cout << dp[i][j] << " ";
//        }
//        cout << endl;
//    }
    cout << dp[n][m]<<endl;
}


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

using I = long long;
const I M = 1e9+7;

vector<I> factorial(auto n) {
  vector<I> f(n, 1);
  for(auto i=1; i<n; ++i) f[i] = f[i-1] * i % M;
  return f;
}

I power(I m, I n) {
  if(!n) return 1;
  return (n & 1) ? (power(m, n - 1) * m % M) : power(m * m % M, n >> 1);
}
I inverse(I n) {
  return power(n, M - 2);
}
I combination(I n, I r, auto& f) {
  if(!n) return 1;
  if(n < r) return 0;
  return (f[n] * inverse(f[n - r]) % M) * inverse(f[r]) % M;
}

I solve(auto N) {
  if(N==2) return 1;
  if(N==3) return 4;
  auto f = factorial(1e6+1);
  I res = 0;
  I last = 0;
  for(auto K=(N+1)/2; K<N; ++K) {
    auto cnt = combination(K-1, N-1-K, f);
    cnt *= f[K] * f[N-1-K] % M;
    cnt %= M;
    res += K * (cnt - last) % M;
    res = (res + M) % M;
    last = cnt;
  }
  return res;
}

int main() {
  int N;
  cin >> N;
  cout << solve(N) << endl;
}


Measured memory_bytes: 8064
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
int main() {
	int N,Da,Db,count=0;
	bool flag = false;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> Da >> Db;
		if (Da == Db) {
			count++;

		}else
		{
			count = 0;
		}
		if (count == 3) {
			flag = true;
			break;
		}
	}
	cout << (flag ? "Yes" : "No");


	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int A, B, X; cin >> A >> B >> X;

    if (A <= X && X <= A + B) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    a,b,c = map(int,input().split())
    if a + b >= c:
        print('Yes')
    else:
        print('No')
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38636
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SMI(): return input().split()
def SLI(): return list(input())

def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')

# from math import ceil, floor, log2
from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    K = II()

    q = deque([(1, 1)])
    used = [0 for _ in range(K)]
    while len(q) > 0:
        # print(q)
        v, cost = q.popleft()
        if v == 0:
            print(cost)
            return

        if used[v]:
            continue
        used[v] = 1

        q.appendleft(((v*10) % K, cost))
        q.append(((v+1) % K, cost+1))



if __name__ == '__main__':
    solve()


Measured memory_bytes: 14440
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int32_t main(){
    fastio;
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> a(n);
    frr(i,n) cin >> v[i];
    a[0] = v[0];
    int x = -1;
    for(int i=1;i<n;i++){
        a[0] += v[i] * x;
        x = -x;
    }
    for(int i=1;i<n;i++){
        a[i] = 2*(v[i-1] - a[i-1]/2);
    }
    for(int k : a){
        cout << k << " ";
    }
    cout << endl;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n, k, q);
  vector<int> v(n);
  rep(i, q) {
    in(int, a);
    ++v[a - 1];
  }
  rep(i, n) {
    out(k - (q - v[i]) > 0 ? "Yes" : "No");
  }
}


Measured memory_bytes: 1024
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>

 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define LLIandI pair<long long int , int>
#define ll long long

ll int r,D,x;
int main(void){
    scanf("%lld %lld %lld",&r,&D,&x);
    ll int ans=0;
    rep(i,10){
        printf("%lld\n",r*x-D);
        x=r*x-D;
    }
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	s := readi()
	w := readi()

	if w >= s {
		fmt.Println("unsafe")
		return
	}

	fmt.Println("safe")
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

// 最大公約数
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

// 最小公倍数
func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func comb(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7

	COMB_MAX = 510000
)

var (
	readString func() string
)

var (
	fac  = [COMB_MAX]int{}
	finv = [COMB_MAX]int{}
	inv  = [COMB_MAX]int{}
)

func init() {
	readString = newReadString(os.Stdin)
}

func combInit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < COMB_MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 1760
#include<bits/stdc++.h>
#include<cmath>
#include<math.h>
using namespace std;
int main () {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double s = (double)M;
  s /= 30;
  s *= M_PI;
  double k = (double)H * 60 + M;
  k /= 60;
  k /= 6;
  k *= M_PI;
  k -= s;
  double a = (double)A * A;
  double b = (double)B * B;
  double c = (double)2 * A * B;
  c *= cos(k);
  double ans = a + b - c;
  cout << setprecision(20) << sqrt(ans) << endl;
}

Measured memory_bytes: 4192
N, A, B, C, D = map(int, input().split())
S = input()

A, B, C, D = A - 1, B - 1, C - 1, D - 1
if (A < C < B < D) or (A < B < C < D):
    if '##' in S[A: C + 1]:
        print('No')
        exit()

    if '##' in S[B: D + 1]:
        print('No')
        exit()
    print('Yes')


if A < B < D < C:
    if '##' in S[A: C + 1]:
        print('No')
        exit()

    if '##' in S[B: D + 1]:
        print('No')
        exit()

    if '...' in S[B - 1: D + 2]:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5+10;
vector<int> ordem;
vector<int> g[MAX];
int ingrau[MAX], dp[MAX], n, m, ans;
bool marc[MAX];
void Ordenar(int v)
{
	ordem.push_back(v); marc[v] = 1;
	int grau = g[v].size();
	for(int i=0;i<grau;i++)
	{
		int prox = g[v][i];
		ingrau[prox]--;
		if(!ingrau[prox]) Ordenar(prox); 
	}
	return;
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int a,b; scanf("%d %d",&a,&b);
		g[a].push_back(b);
		ingrau[b]++;
	}
	for(int i=1;i<=n;i++) if(ingrau[i] == 0 && !marc[i]){ Ordenar(i); }
	for(int i=n-1;i>=0;i--)
	{
		int cur = ordem[i];
		int grau = g[cur].size();
		for(int i=0;i<grau;i++)
		{
			int prox = g[cur][i];
			dp[cur] = max(dp[prox]+1,dp[cur]);
		}
		ans = max(dp[cur],ans);
	}
	printf("%d",ans);
}

Measured memory_bytes: 11768
#include <stdio.h>

int main(void)
{
  int a, b, c;

  scanf("%d %d %d",&a,&b,&c);

  if(a<c){
    if(c<b){
      printf("Yes");
    }
    else{
      printf("No");
    }
  }
  else{
    if(b<c){
      printf("Yes");
    }
    else{
      printf("No");
    }
  }

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

vector<vector<int>> dis;
vector<vector<char>> used;
queue<P> q1;

int main(){
	int n,m,p;
	int i,j,k;
	int a,b,c;
	int x,y;
	string sa;
	cin>>n>>m>>p;
	cin>>a>>b>>x>>y;
	a--,b--,x--,y--;
	dis.assign(n,vector<int>(m,INF));
	used.assign(n,vector<char>(m,0));
	for(i=0;i<n;i++){
		cin>>sa;
		for(j=0;j<m;j++){
			if(sa[j]=='@')dis[i][j]=-1;
		}
	}
	q1.push(make_pair(a,b));
	dis[a][b]=0;
	for(i=0;!q1.empty();i++){
		j=q1.size();
		while(j--){
			a=q1.front().first,b=q1.front().second,q1.pop();
			if(dis[a][b]!=i || used[a][b])continue;
			used[a][b]=true;
			for(k=a+1;k<n && k<=a+p;k++){
				if(dis[k][b]<=i)break;
				dis[k][b]=i+1;
				q1.push(make_pair(k,b));
			}
			for(k=a-1;k>=0 && k>=a-p;k--){
				if(dis[k][b]<=i)break;
				dis[k][b]=i+1;
				q1.push(make_pair(k,b));
			}
			
			for(k=b+1;k<m && k<=b+p;k++){
				if(dis[a][k]<=i)break;
				dis[a][k]=i+1;
				q1.push(make_pair(a,k));
			}
			for(k=b-1;k>=0 && k>=b-p;k--){
				if(dis[a][k]<=i)break;
				dis[a][k]=i+1;
				q1.push(make_pair(a,k));
			}
		}
	}
	if(dis[x][y]==INF)dis[x][y]=-1;
	cout<<dis[x][y]<<endl;
}

Measured memory_bytes: 11120
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

class Edge {
public:
  Edge(int v_, int a_, int b_): v(v_), a(a_), b(b_) {}
  int v;
  int a;
  int b;
};

const int kMaxS = 2500;
const ll kInf = 1e18;

int main() {
  int N, M, S;
  cin >> N >> M >> S;
  S = min(kMaxS, S);
  vector<vector<Edge> > g(N);
  for (int i = 0; i < M; ++i) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    --u; --v;
    g[u].push_back(Edge(v, a, b));
    g[v].push_back(Edge(u, a, b));
  }
  vector<int> C(N);
  vector<int> D(N);
  for (int i = 0; i < N; ++i) {
    cin >> C[i] >> D[i];
  }

  vector<vector<ll> > dist(N, vector<ll>(kMaxS + 1, kInf));
  priority_queue<vector<ll> > q;  // {-t, u, s}
  dist[0][S] = 0;
  q.push({-0, 0, S});

  while (not q.empty()) {
    vector<ll> token = q.top();
    q.pop();
    ll t = -token[0];
    int u = token[1];
    int s = token[2];
    for (auto e : g[u]) {
      if (s < e.a) continue;
      int ns = s - e.a;
      ll nt = t + e.b;
      if (dist[e.v][ns] > nt) {
	dist[e.v][ns] = nt;
	q.push({-nt, e.v, ns});
      }
    }
    // self-loop
    int ns = min(kMaxS, s + C[u]);
    ll nt = t + D[u];
    if (dist[u][ns] > nt) {
      dist[u][ns] = nt;
      q.push({-nt, u, ns});
    }
  }

  for (int u = 1; u < N; ++u) {
    ll mn = kInf;
    for (int s = 0; s <= kMaxS; ++s) {
      mn = min(mn, dist[u][s]);
    }
    cout << mn << endl;
  }
  
  return 0;
}


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

int main(){
int n;
while(cin>>n){
int ans(0);
for(int i=0;i<=9;i++){
	for(int j=0;j<=9;j++){
		for(int k=0;k<=9;k++){
			for(int l=0;l<=9;l++){
				if(i+j+k+l==n)ans++;
			}
		}
	}
}
cout<<ans<<endl;
}

return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    bool dp[102][10002];
    int s[101];
    int N;cin>>N;
    for(int j=0; j<=10000;j++){
      dp[0][j]=false;
    }
    dp[0][0]=true;

    for(int i=0; i<N;i++) cin>>s[i];

    for(int i=0; i<N;i++){
      for(int j=0; j<=10000;j++){
        if(j-s[i]>=0){
          if(dp[i][j-s[i]]||dp[i][j]) dp[i+1][j]=true;
        }else{
          if(dp[i][j]) dp[i+1][j]=true;
        }
      }
    }

    for(int j=10000; j>=0;j--){
      if(j%10!=0 && dp[N][j]){
        cout<<j<<endl; return 0;
      }
    }

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


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

int main(){
  int K,A,B,C;
  int ans =0;

  cin >> A >> B >> C >> K;
  for(int i=0;i<A;++i){
    if(K == 0) break;
    ans += 1;
    K -= 1;
  }

  for(int i=0;i<B;++i){
    if(K == 0) break;
    K -= 1;
  }

  for(int i=0;i<C;++i){
    if(K == 0) break;
    ans -= 1;
    K -= 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3592
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<llint> vllint;
typedef vector<vllint> vvllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int n, m;
	cin >> n >> m;
	vint a(m);
	vvint b(n, vint(m));
	vint ans(n, 0);
	rep(i, n) {
		rep(j, m) {
			cin >> b[i][j];
		}
	}
	rep(i, m)cin >> a[i];
	rep(i, n) {
		rep(j, m) {
			ans[i] += b[i][j] * a[j];
		}
	}
	rep(i, n)cout << ans[i] << endl;
	return 0;
}


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

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

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

using namespace std;

int main() {
	int Q, A, B, C, D;
	scanf("%d", &Q);
	while (Q--) {
		scanf("%d%d%d%d", &A, &B, &C, &D);
		int len = (max(A, B) - 1) / (min(A, B) + 1) + 1;
		int l = 0, r = A + B;
		while (l < r) {
			int mid = l + r >> 1;
			int cb = mid / (len + 1), ca = mid - cb;
			ca = A - ca, cb = B - cb;
			if (cb <= 1ll * ca * len) l = mid + 1;
			else r = mid;
		}
		int cb = l / (len + 1), ca = l - cb;
		ca = A - ca, cb = B - cb;
		int bg = l + 1 - (len - (cb - ca * len));
		for (int i = C; i <= D; ++i)
			if (i <= l) putchar("AB"[(i - 1) % (len + 1) == len]);
			else putchar("BA"[(i - bg) % (len + 1) == len]);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<ll>A(N);
  vector<ll>sum(N+1);
  REP(i,N)cin>>A[i];
  vector<vector<ll>> dp(N+1,vector<ll>(N+1,0));

  REP(i,N)sum[i+1]=sum[i]+A[i];

  REP(i,N)dp[i][i]=A[i];

  FOR(w,2,N+1){
    REP(l,N){
      int r=l+w;
      if(r>N)break;
      dp[l][r]=INFLL;
      FOR(m,l+1,r){
        dp[l][r]=min(dp[l][r],dp[l][m]+dp[m][r]+sum[r]-sum[l]);
      }
    }
  }

  cout<<dp[0][N]<<endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
using graph = vector<vector<int>>;
int main(){
    int x[6];
    for(int i=0; i<5; ++i){cin >> x[i];}
    for(int i=0; i<5; ++i){
        if(x[i]==0){
            cout << i+1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3588
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>


using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
ll A[2][100005] = {};
ll B[2][100005] = {};
ll C[200005] = {};
bool f, ff;
string S;
set <long long>sll;
pl bufpl;
vector <long long>vl[3];
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}



ll minn, maxx;
double ansa;



int main() {


	cin >> S;
	S[3] = '8';

	cout << S << endl;

	return 0;

}


Measured memory_bytes: 764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

int main(int argc, char* argv[]){
	string S;
	string T;

	cin >> S;
	cin >> T;

	const char *s = S.c_str();
	const char *t = T.c_str();

	int len = strlen(s);
	if(strncmp(s, t, len)==0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;

}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

static const char iwi[] = {'i','w','(',')'};

int FastPow(int x,int power){
  int res = 1;
  while(power){
    if(power & 1) res *= x;
    x *= x;
    power >>= 1;
  }
  return res;
}

bool isClear(char buf[12]){
  if(strlen(buf) % 2 != 0
     && (buf[strlen(buf) / 2] == '('
	 || buf[strlen(buf) / 2] == ')')) return false;
  for(int i=0,j=strlen(buf)-1;i<strlen(buf)/2;i++,j--){
    if(buf[i] == '(' && buf[j] != ')') return false;
    else if(buf[i] == ')' && buf[j] != '(') return false;
    else if(buf[i] == 'i' && buf[j] != 'i') return false;
    else if(buf[i] == 'w' && buf[j] != 'w') return false;
  }
  return true;
}

int CountFlag(int S){
  int res = 0;
  while(S){
    if(S & 1) res++;
    S >>= 1;
  }
  return res;
}

int main(){
  char buf[12];
  while(~scanf("%s",buf)){
    int upper = FastPow(4,strlen(buf));

    int min_modify_count = INF;
    for(int S=0;S<=upper;S++){
      int tmp_S = S;
      char tmp_buf[12];
      
      int modify_count = 0;
      memset(tmp_buf,'\0',sizeof(tmp_buf));
      strcpy(tmp_buf,buf);

      for(int i=0;i<strlen(tmp_buf);i++){
	if(buf[i] != iwi[tmp_S % 4]) modify_count++;
	tmp_buf[i] = iwi[tmp_S % 4];
	tmp_S /= 4;
      }

      if(!isClear(tmp_buf)) continue;

      min_modify_count = min(modify_count,min_modify_count);
    }
    printf("%d\n",min_modify_count);
  }
}

Measured memory_bytes: 1148
l,r=map(int,input().split())
if r-l>=2019: print(0)
else:
    ans=2018
    mod_l=l%2019
    mod_r=r%2019
    for i in range(min(mod_l,mod_r),max(mod_l,mod_r)+1):
        for j in range(i+1,max(mod_l,mod_r)+1):
            mod=(i*j)%2019
            if mod<ans: ans=mod
    print(ans)

Measured memory_bytes: 41964
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            int a = line[0], b = line[1], c = line[2];

            var ret = b / a;

            if (ret > c) ret = c;

            Console.WriteLine(ret);
        }
    }
}


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

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int f = 0, s = 0;
	int a, b, c; cin >> a >> b >> c;
	if(a == 5) ++f;
	if(b == 5) ++f;
	if(c == 5) ++f;
	if(a == 7) ++s;
	if(b == 7) ++s;
	if(c == 7) ++s;
	cout << (f == 2 && s == 1 ? "YES" : "NO") << '\n'; 
	return 0;
}

Measured memory_bytes: 3648