akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ini(N); ins(S);
  int r = 0 , b = 0;
  rep(i,N){
    if(S[i] == 'R') r++; else b++;
  }
  out(r > b ? "Yes" : "No");
}

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

#define ll long long int
#define absdiff(a,b) (a>b)?a-b:b-a
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"
const ll ll_MAX = 19223372036859;
const ll MOD = 1000000007;
ll fast_expo(ll x,ll p){if(p==0) return 1;
    else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} 
    else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  
    else return gcd(b%a,a); }

ll arr[3001];
ll dp[3001][3001];
ll n;

ll solve(ll i,ll j)
{
    if(i == j && n%2 == 1) return arr[i];
    else if(i == j && n%2 == 0) return -arr[i];
    if(dp[i][j] != ll_MAX) return dp[i][j];

    ll turn = (n-j+i)%2;
    if(turn == 1) return dp[i][j] = max(solve(i+1,j)+arr[i],solve(i,j-1)+arr[j]);
    else return dp[i][j] = min(solve(i+1,j)-arr[i],solve(i,j-1)-arr[j]);

}

int main()
{
    ll t_c; t_c = 1;
    // cin >> t_c;
    for(ll t_i=0; t_i<t_c; ++t_i){
        for(ll i=0; i<3001; ++i){
            for(ll j=0; j<3001; ++j)
                dp[i][j] = ll_MAX;
        }
        cin >> n;
        for(ll i=1; i<=n; ++i)
            cin >> arr[i];

        cout << solve(1,n);
    }   
    return 0;
}

Measured memory_bytes: 70784
#include<iostream>
using namespace std;
int main(){
	char B;
	cin>>B;
	switch(B){
		case 'A':cout<<'T';break;
		case 'C':cout<<'G';break;
		case 'G':cout<<'C';break;
		case 'T':cout<<'A';break;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = 0, z = 0;
		String s = sc.next();
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'A') {
				a = i;
				break;
			}
		}
		for (int j = a+1; j < s.length(); j++) {
			if (s.charAt(j) == 'Z') z = j;
		}
		System.out.println(z - a + 1);
	}

}

Measured memory_bytes: 26636
#include<bits/stdc++.h>
#define int long long
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); //freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);
#define maxn 100000
#define mod 1000000007

using namespace std;
int power(int a, int b, int m)
{
    int ans = 1;
    a %= m;
    while(b){
        if(b & 1) ans = (ans * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return ans;
}

int n, k, dp[maxn + 1];
vector <int> d[maxn + 1];

signed main()
{
    
    FLASH

    for(int i = 2; i <= maxn; i++)
        for(int j = i; j <= maxn; j += i) d[j].push_back(i);

    cin>>n>>k;

    dp[1] = 1;

    for(int i = 2; i <= k; i++){
        dp[i]= power(i, n, mod) + mod -  power(i - 1, n, mod);
        dp[i] %= mod;

        for(auto x: d[i]){
            dp[i] += mod - dp[i/x];
            dp[i] %= mod;
        }
    }

    for(int i = 2; i <= k; i++) dp[i] += dp[i - 1];

    int ans = 0, sm = 0;

    for(int i = 1; i <= k; i++){
        sm += dp[i];
        ans += i*dp[k/i];
        ans %= mod;
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 19724
END { load __FILE__ unless $stdin.eof? }

n = gets.to_i
a = gets.split.map!(&:to_i)

a_hist = a.tally
a_sum = a_hist.sum { |k, v| k * v }

q = gets.to_i
q.times do
  b, c = gets.split.map!(&:to_i)
  d = a_hist.delete(b) || 0

  if d > 0
    a_hist[c] ||= 0
    a_hist[c] += d
  end

  a_sum += (c - b) * d
  puts a_sum
end


Measured memory_bytes: 24944
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,x) for(i=1;i<=x;i++)
#define sp(a) fixed<<setprecision(a)
using namespace std;
using ll = long long int;
using lo = unsigned long long int;
typedef vector<ll> vi;
typedef vector<lo> vl;
typedef vector<ll> vi;
typedef pair<ll,ll> par;
ll n,sm = 0,k;
int main()
{
	cin>>n;
	while(n--){
		cin>>k,sm+=(k-1);
	}
	cout<<sm<<'\n';
	return 0;
}

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

typedef vector< string > mp;
typedef vector<bool > vi;

int main(){
    int H,W;
    cin >> H >> W;
    mp dp(H);
    vi row(H, false);
    vi col(W, false);
    for(int i = 0; i < H; i++){
        cin >> dp[i];
        for(int j=0; j < W; j++){
            if( dp[i][j] == '#'){
                row[i] = true;
                col[j] = true;
            }
        }
    }
    // cout <<'a';
    for(int i = 0; i < H; i++){
        if(row[i]){
            for(int j=0; j < W; j++){
                if(col[j]){
                    cout <<  dp[i][j];
                }
            }
            cout << endl;
        }
    }
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




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




void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


int main() {


  cout<<fixed<<setprecision(10);

  ll a,b,c; cin>>a>>b>>c;

  cout<<min(b/a, c)<<endl;


}

//


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
ll dp[1000010],sum[1000010],n,h,d,x,s;

ll modinv(ll a){
    ll b=mod,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b; swap(a,b);
        u-=t*v; swap(u,v);
        }
        u%=mod;
        if(u<0) u+=mod;
    return u;
}

int main(){
  cin >> n >> h >> d; s=1; dp[0]=1; sum[0]=1;
  for(ll i=1;i<=n;i++){
    s=s*i%mod; x=(x+s)%mod;
  }
  for(ll i=1;i<=h;i++){
    dp[i]=sum[i-1];
    if(i-d>0) dp[i]=(dp[i]-sum[i-d-1]+mod)%mod;
    dp[i]=dp[i]*x%mod;
    sum[i]=(sum[i-1]+dp[i])%mod;
  }
  cout << dp[h]*s%mod*modinv(x)%mod << endl;
}

Measured memory_bytes: 15872
p = 10**9+7
s = 0
s_sq = 0

N = int(input())
A = list(map(int, input().split()))

for i in range(N):
    s += A[i]
    s_sq += A[i]**2
    s %= p
    s_sq %= p

print((s**2 - s_sq) * pow(2, p-2, p) % p)

Measured memory_bytes: 94172
#include <iostream>
#include <algorithm>
#include<stdio.h>
using namespace std;

int main() {
    int a=0,b=0,H[100],W[100];
    while (1) {
        cin >> H[a] >> W[a];
        if (H[a] == 0 && W[a] == 0) break;
        a++;
        
    }
    
    while (b<a) {

        for (int i = 0; i < H[b]; i++) {
            for (int j = 0; j < W[b]; j++) {
                printf("#");
            }
        printf("\n");
        }
        b++;
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 3104
#写経
#https://atcoder.jp/contests/abc177/submissions/16326133
# Union Find 木
from sys import setrecursionlimit, stdin
 
def find(parent, i):
    #print("f:" + str(i))
    #print(parent)
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t
 
def unite(parent, i, j):
    i = find(parent, i)
    #print("i:" + str(i) )
    j = find(parent, j)
    #print("j:" + str(j))
    if i == j:
        return
    parent[j] += parent[i]
    parent[i] = j
    #print(parent)
 
readline = stdin.readline
setrecursionlimit(10 ** 6)

def resolve(): 
    N, M = map(int, readline().split())
    parent = [-1] * N
    for _ in range(M):
        A, B = map(lambda x: int(x) - 1, readline().split())
        unite(parent, A, B)
    print(-min(parent))

resolve()

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

int main() {
    int n, t_diff, xy_diff;
    cin >> n;
    int t[n+1], x[n+1], y[n+1];
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for(int i = 0; i < n; ++i) {
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    } 

    for(int i = 0; i < n; ++i) {
        t_diff = t[i+1] - t[i];
        xy_diff = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if(t_diff < xy_diff || t_diff%2 != xy_diff%2) {
            cout << "No" << "\n";
            return 0;
        }
    } 
    cout << "Yes" << "\n";
}


Measured memory_bytes: 1408
## (x+y)^2+(y+z)^2+(z+x)^2==2n
## 3この平方数の和
n=int(input())
dict={}
i,j,k=1,1,1
while (i+j)**2+(j+k)**2+(k+i)**2<=2*n:
    while (i+j)**2+(j+k)**2+(k+i)**2<=2*n:
        # print('\t',i,j,k)
        while (i+j)**2+(j+k)**2+(k+i)**2<=2*n:
            tmp=(i+j)**2+(j+k)**2+(k+i)**2
            tmp//=2
            if tmp not in dict:
                dict[tmp]=0
            dict[tmp]+=1
            # print(i,j,k)
            k+=1
        k=1
        j+=1
    j=1
    i+=1
# print(dict)
for i in range(1,n+1):
    if i in dict:
        print(dict[i])
    else:
        print(0)



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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;

const string YES = "Yes";
const string NO = "No";

void solve()
{
  ll a;
  scanf("%lld",&a);
  ll b;
  scanf("%lld",&b);
  ll c;
  scanf("%lld",&c);
  if (a+b==c||a+c==b||b+c==a) cout << YES << endl;
  else cout << NO << endl;
}

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


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

const vector<string> ans = {"AMBIGUOUS", "MMYY", "YYMM", "NA"};

string S;

bool shouldYY(string s) {
  return !((s[0] == '0' && s[1] != '0') || (s[0] == '1' && (s[1] <= '2')));
}

int main() {
  cin >> S;
  int x = shouldYY(S.substr(2, 2)) + (shouldYY(S.substr(0, 2)) << 1);

  cout << ans[x] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if ((Math.abs(a - b) <= d && Math.abs(b - c) <= d) || Math.abs(a - c) <= d) {
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}

	}

}

Measured memory_bytes: 21716
using System;
using System.Linq;

namespace _153_A
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var ha = Console.ReadLine()
                            .Split()
                            .Select(double.Parse)
                            .ToArray();
            Console.WriteLine(Math.Ceiling(ha[0] / ha[1]));
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    int h1,m1,s1,h2,m2,s2;
    int h,m,s;
    for(int i=0; i<3; i++) {
        cin>>h1>>m1>>s1>>h2>>m2>>s2;
        if(s2 < s1) {
            s = s2 - s1 + 60;
            m2--;
        } else {
            s = s2 - s1;
        }

        if(m2 < m1) {
            m = m2 - m1 + 60;
            h2--;
        } else {
            m = m2 - m1;
        }
        h = h2 - h1;
        printf("%d %d %d\n",h,m,s);
    }
    return 0;
}

Measured memory_bytes: 1144
import sys
import numpy as np


def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


n, k, *aaa = map(int, sys.stdin.buffer.read().split())
MOD = 10 ** 9 + 7
facts, invs = prepare(n, MOD)

dp = np.zeros(n + 1, dtype=np.int64)
dp[0] = facts[n]
for a in aaa:
    pat0 = facts[n] * invs[a] % MOD * invs[n - a] % MOD
    ndp = dp * pat0 % MOD
    for x in range(1, a + 1):
        pat = facts[n - x] * invs[a - x] % MOD * invs[n - a] % MOD * invs[x] % MOD
        ndp[x:] = (ndp[x:] + dp[:-x] * pat) % MOD
    dp = ndp
print(dp[n])


Measured memory_bytes: 12504
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(){
  int h,w;
  string map[50];

  cin >> h >> w;
  for (int i = 0; i < h; i++) cin >> map[i];

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

  queue<pair<int,int>> todo;
  todo.push(make_pair(0,0));

  vector<vector<int>> seen(h, vector<int>(w,-1));
  seen[0][0] = 0;

  while(!todo.empty()){
    pair<int,int> pos = todo.front();
    todo.pop();
    int x = pos.first;
    int y = pos.second;

    for(int i = 0; i < 4; i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
      if(map[nx][ny] == '#') continue;
      if(seen[nx][ny] == -1){
        todo.push(make_pair(nx,ny));
        seen[nx][ny] = seen[x][y] + 1;
      }
    }
  }

  // cout << seen[h-1][w-1] << endl;

  int count = 0;

  for(int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      if(map[i][j] == '.') count ++;
    }
  }
  if(seen[h-1][w-1] == -1) cout << -1 << endl;
  // 白のマスの数count　―　最短手数seen[h-1][w-1]　―　スタート地点1
  else cout << count - seen[h-1][w-1] - 1 << endl;
}

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

#define pb push_back
#define ff first
#define ss second

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

int n, mx;
string s;
map<string, int> mp;
vector<string> ans;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> s, mp[s]++, mx = max(mx, mp[s]);
	for (auto i : mp)
		if (i.ss == mx)
			ans.pb(i.ff);
	sort(ans.begin(), ans.end());
	for (auto i : ans)
		cout << i << endl;
	return 0;
}


Measured memory_bytes: 25584
N, M = map(int, input().split())
A = []
B = []
for n in range(N):
    tmp = list(map(int, input().split()))
    A.append(tmp)
for m in range(M):
    B.append(int(input()))

for n in range(N):
    combined = [x * y for (x, y) in zip(A[n], B)]
    print(sum(combined))


Measured memory_bytes: 6024
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
using namespace std;
const int N=3e5+100,mod=1e9+7;
ll vis[N];
int32_t main(){
    for (int i=2;i<N;i++){
        if (vis[i]) continue;
        for (int j=2*i;j<N;j+=i){
            vis[j]=1;
        }
    }
    ll n;
    cin >> n;
    for (int i=n;i<N;i++){
        if (!vis[i]){
            cout << i << endl;
            return 0;
        }
    }
}


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

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

string f(db x) {
	if(x <= 48) return "light fly";
	if(x <= 51) return "fly";
	if(x <= 54) return "bantam";
	if(x <= 57) return "feather";
	if(x <= 60) return "light";
	if(x <= 64) return "light welter";
	if(x <= 69) return "welter";
	if(x <= 75) return "light middle";
	if(x <= 81) return "middle";
	if(x <= 91) return "light heavy";
	return "heavy";
}

int main() {
	ios :: sync_with_stdio(0);

	for(db x; cin >> x; )
		cout << f(x) << '\n';

	return 0;
}

Measured memory_bytes: 3252
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define NUM 51

struct Info{
	Info(int arg_node_id,int arg_num){
		node_id = arg_node_id;
		num = arg_num;
	}
	bool operator<(const struct Info & arg) const{
		return num > arg.num;
	}

	int node_id,num;
};

int N;
int in_table[NUM],out_table[NUM],calc_out[NUM];
int edge_exist[NUM][NUM];
vector<int> G[NUM];

/*
 * TEST
 * TEST
 * TEST
 * TEST
 * TEST
 * TEST
 * TEST
 * TEST
 * TEST
 */

int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++)edge_exist[i][k] = 0;
	}

	int sum = 0,in_sum = 0;
	for(int i = 0; i <= N; i++){
		scanf("%d",&in_table[i]);
		sum += in_table[i];
		in_sum += i*in_table[i];
	}

	if(sum != N){
		printf("NO\n");
		return 0;
	}

	sum = 0;
	int out_sum = 0;
	for(int i = 0; i <= N; i++){
		scanf("%d",&out_table[i]);
		sum += out_table[i];
		out_sum += i*out_table[i];
	}

	if(sum != N){
		printf("NO\n");
		return 0;
	}

	if(in_sum != out_sum){
		printf("NO\n");
		return 0;
	}

	vector<Info> IN_NODE;
	int index = 0;

	for(int i = N; i >= 0; i--){
		for(int k = 0; k < in_table[i]; k++){
			IN_NODE.push_back(Info(index++,i));
		}
	}

	index = 0;

	for(int i = N; i >= 0; i--){
		for(int k = 0; k < out_table[i]; k++){
			calc_out[index++] = i;
		}
	}

	int count;

	for(int i = 0; i < N; i++){
		if(calc_out[i] == 0)continue;

		count = 0;
 		for(int k = 0; k < N; k++){
 			if(IN_NODE[k].num == 0)break;
 			count++;
 			IN_NODE[k].num--;
 			G[i].push_back(IN_NODE[k].node_id);
 			if(count == calc_out[i])break;
		}

 		if(count < calc_out[i]){
 			printf("NO\n");
 			return 0;
 		}

 		sort(IN_NODE.begin(),IN_NODE.end());
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < G[i].size(); k++){
			edge_exist[i][G[i][k]] = 1;
		}
	}

	printf("YES\n");

	for(int i = 0; i < N; i++){
		printf("%d",edge_exist[i][0]);
		for(int k = 1; k < N; k++){
			printf(" %d",edge_exist[i][k]);
		}
		printf("\n");
	}

	return 0;
}



Measured memory_bytes: 3272
man = input()
x = man.split()
k = int(x[0])
n = int(x[1])
dis = list(map(int, input().split()))
a = dis[0] + k
dis.append(a)

maxgap = 0
for i in range(n):
    gap = dis[i+1] - dis[i]
    maxgap = max(maxgap, gap)
print(k-maxgap)


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

int main() {
    //配列の宣言
    vector<int> vec(5);

    for (int i=0; i<5; i++) {
        cin >> vec.at(i);
    }

    int answer;
    //配列vecの中から0にあたる部分を探す
    for (int i=0; i<5; i++) {
        if (vec.at(i) == 0) {
            answer = i+1;
        }
    }
    cout << answer;
    return 0;
}

Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;



public class Main{
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 String A=sc.next();
	 String B=sc.next();
	 char[] a=A.toCharArray();
	 char[] b=B.toCharArray();
	 int count = 0;
	 if(a[0]==b[0]) {
		 count++;
	 }
	 if(a[1]==b[1]) {
		 count++;
	 }
	 if(a[2]==b[2]) {
		 count++;
	 }
	 System.out.println(count);
	 
	
	 

	 
	 
	 
	 
	 
	 
	
	 
	 
	 
 }
	


}




Measured memory_bytes: 24148
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<map>
using namespace std;


int main(){
  int d,g;
  cin >> d >> g;
  g /= 100;
  int p[d],c[d];
  for (int i=0;i<d;i++){
    cin >> p[i] >> c[i];
    c[i] /= 100;
  }
  int dp[1001]{};
  int m = 0;
  int mj = 0;
  for(int i=0;i<d;i++){
    for(int k=1000;k>0;k--){
      m = 0;
      for(int j=1;j<=p[i]&&k-j>=0;j++){
        mj = dp[k-j]+(i+1)*j;
        if (j == p[i]) mj += c[i];
        m = max(m,mj);
      }
      dp[k] = max(dp[k],m);
    }
  }

  for(int k=1;k<1001;k++){
    if(dp[k] >= g){
      cout << k << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{it.toLong()}

    var res = 0L

    for (t in a) {
        var s = t
        while (s % 2 == 0L) {
            res += 1L
            s /= 2L
        }
    }

    println(res)
}


Measured memory_bytes: 41420
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Integer n = sc.nextInt();
    Integer k = sc.nextInt();
    ArrayList<Integer> ps = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      ps.add(sc.nextInt());
    }
    Collections.sort(ps);
    Integer res = 0;
    for (int i=0;i<k;i++){
      res += ps.get(i);
    }

    System.out.println(res);
  }
}


Measured memory_bytes: 38848
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int n,m,x[100010],last=-1,ans,a[100010];
bool f[100010];
int main(){
	cin>>n>>m;
	for (int i=0;i<m;i++) cin>>x[i];
	sort(x,x+m);
	for (int i=0;i<m-1;i++) a[i]=x[i+1]-x[i];
	sort(a,a+m-1);reverse(a,a+m-1);
	for (int i=n-1;i<m;i++) ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

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

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

  bool me10 = n >= 10;

  int ans = 0;
  while (n > 0) {
    ans += n % 10;
    n /= 10;
  }

  if (me10 && ans == 1)
    ans = 10;

  cout << ans << endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        if (i % 2 != 0) {
            ll count = 0;
            for (ll j = 1; j <= N; j++) {
                if (i % j == 0){
                    count++;
                }
            }
            if (count == 8) {
                ans++;
            }
        }
    }

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


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

#define endl '\n'

long long const N = 1e6+1, M = 1000000007;

bool prime[N+1];
vector<long long> primes;
map<long long, int> findpos;
void sieve(){
    memset(prime, 1, sizeof prime);
    for (long long p=2; p*p<=N; p++){
        if (prime[p]){
            for (int i=p*p; i<=N; i+=p) prime[i] = 0;
        }
    }
    for (int p=2; p<=N; p++){
        if (prime[p]){
            findpos[p] = primes.size();
            primes.push_back(p);
        }
    }
    
}

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

    int n; cin >> n;
    int a[n], maxpos=0;;
    vector<int> e(800000, 0);
    vector<pair<int, int>> f[n];
    for (int i=0; i<n; i++){
        cin >> a[i];
        int x = a[i];
        for (int j=2; j*j <= x; j++){
            if (x % j == 0){
                int temp =0;
                while(x % j == 0){
                    temp++;
                    x /= j;
                }
                int pos = findpos[j];
                maxpos = max(maxpos, pos);
                f[i].push_back({pos, temp});
                e[pos] = max(e[pos], temp);
            }
        }
        if (x > 1){
            int pos = findpos[x];
            maxpos = max(maxpos, pos);
            f[i].push_back({pos, 1});
            e[pos] = max(e[pos], 1);
        }
    }
    long long ans = 0;
    for (int i=0; i<n; i++){
        for (int j=0; j<f[i].size(); j++){
            e[f[i][j].first] -= f[i][j].second;
        }
        long long temp = 1;
        for (int j=0; j<=maxpos; j++){
            for (int k=0; k<e[j]; k++) temp = (primes[j] * temp) % M;
        }
        ans = (ans + temp)%M;
        for (int j=0; j<f[i].size(); j++){
            e[f[i][j].first] += f[i][j].second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 10996
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(void)
{
    int X, Y;
    cin >> X >> Y;

    for (int i = 0; i <= X; ++i)
    {
        if (2*i + 4*(X-i) == Y) {
            cout << "Yes";
            return 0;
        }
    }
    
    cout << "No";

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define inf 1000000000
#define mod 1000000007
using namespace std;
using LL = long long;

int main(){
    string s;cin>>s;
    if(s[s.size()-1]!='A')s+='A';
    if(s[0]!='A')s.insert(s.begin(),'A');

    if(s=="AKIHABARA" || s=="AKIHBARA" || s=="AKIHABRA" || s=="AKIHBRA")cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

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

    int n;
    cin >> n;

    map<int, int> num;
    vector<int> A(n);
    rep(i, n){
        int a;
        cin >> a;
        ++num[a];
        A[i] = a;
    }

    int res = 0;
    rep(i, n){
        if(num[A[i]] % 2) {
            ++res;
            ++num[A[i]];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 5376
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

constexpr intmax_t mod = 1e9+7;

intmax_t modpow(intmax_t base, intmax_t iexp) {
  intmax_t res = 1;
  for (intmax_t dbl = base; iexp; iexp >>= 1) {
    if (iexp & 1) res = res * dbl % mod;
    dbl = dbl * dbl % mod;
  }
  return res;
}

int main() {
  char buf[131072];
  scanf("%s", buf);
  std::string z = buf;
  scanf("%s", buf);
  std::string o = buf;
  size_t n;
  scanf("%zu", &n);

  // size_t m = z.length();
  if (o.length() < n) {
    std::string t = z + std::string(o.rbegin(), o.rend());
    std::string u(t.rbegin(), t.rend());
    if (t != u) return puts("0"), 0;
    printf("%jd\n", modpow(26, (n-o.length()+1)/2));
    return 0;
  }

  std::string t0(o.rbegin(), o.rbegin()+n);
  std::string t = t0 + z + t0 + o;
  std::string u(t.rbegin(), t.rend());
  if (t != u) return puts("0"), 0;
  puts("1");
}



Measured memory_bytes: 3716
N,K=map(int,input().split())
X=[]
for i in range (N):
	A=list(map(int,input().split()))
	X.append(A)
Y=sorted(X, key=lambda x:x[0])
tmp=0
for i in range (len(Y)):
	M=Y[i][1]
	tmp+=int(M)
	if tmp>=K:
		print(Y[i][0])
		exit()

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

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
  int N, M, H, A, B;
  cin >> N >> M;
  vector<vector<int>> data(N+1);
  int cnt = 0;
  for (int i = 1; i <= N; i++){
    cin >> H;
    data[i].push_back(H);
  }
  for (int i = 0; i < M; i++){
    cin >> A >> B;
    data[A].push_back(data[B][0]);
    data[B].push_back(data[A][0]);
    }
  for (int i = 1; i < data.size(); i++){
     if (data[i].size() == 1) {
         cnt++;
         continue;
       }
      bool judge = true;
    for (int j = 1; j < data[i].size(); j++){
       if(data[i][0] <= data[i].at(j)){
       judge = false;
       break;
       }
    }
    if (judge) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 9280
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  ll x, y;
  cin >> x >> y;

  ll ans = 0;
  ll k = x;
  while(x <= k && k <= y) {
    ans++;
    k *= 2;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

vi v;

int main(){
	int n; scanf("%d", &n);
	REP(i, n){
		int a; scanf("%d", &a);
		v.EB(a);
	}
	sort(ALL(v));
	for(int &i : v) DEBUG("%d ", i); DEBUG("\n");
	ll ans = 0;
	REP(i, n){
		FOR(j, i+1, n){
			int p = v[j] - v[i], q = v[j] + v[i];
			int cnt = lower_bound(ALL(v), q) - lower_bound(ALL(v), p+1);
			ans += cnt;
			DEBUG("(%d, %d, _) : (%d, %d) = %d\n", v[i], v[j], p, q, cnt);
			if(p < v[i] && v[i] < q) ans--;
			if(p < v[j] && v[j] < q) ans--;
		}
	}
	printf("%lld\n", ans/3);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rc(s) return cout<<s,0
#define inf 200005
int n,i;
#define ll long long
ll a[inf],l,r,mid,mx;
int mmicegal(ll x)
{
	for(int i=1;i<=n;i++)x-=x%a[i];
	if(x<=2)return 1;
	return 0;
}
int mmareegal(ll x)
{
	for(int i=1;i<=n;i++)x-=x%a[i];
	if(x>=2)return 1;
	return 0;
}
int egal(ll x)
{
	for(int i=1;i<=n;i++)x-=x%a[i];
	if(x==2)return 1;
	return 0;
}
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i];
    l=0,r=1e15;
    while(l<=r)
	{
		mid=(l+r)/2;
		if(mmicegal(mid))l=mid+1;
		else r=mid-1;
	}
	if(!l)rc(-1);
	mx=l-1;
	l=0,r=mx;
    while(l<=r)
	{
		mid=(l+r)/2;
		if(mmareegal(mid))r=mid-1;
		else l=mid+1;
	}
	if(egal(r+1) && egal(mx))cout<<r+1<<" "<<mx<<endl;
	else cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = 2e9;
const int MAX_N = 1;
const ll INFL = 1e18L;

int main() {
  ll A, B, Q; cin >> A >> B >> Q;
  vi s(A), t(B);

  for (int i = 0; i < A; i++) cin >> s[i];
  for (int i = 0; i < B; i++) cin >> t[i];
  for (int i = 0; i < Q; i++) {
    ll a, ans = INFL;
    cin >> a;

    // s -> t
    auto npos = lb(s.begin(), s.end(), a);
    auto br = npos, bl = npos - 1;
    
    if (br != s.begin()) {
      npos = lb(t.begin(), t.end(), *bl);
      auto cr = npos, cl = npos - 1;

      if (cr != t.begin()) {
        ans = min(ans, abs(a - *bl) + abs(*bl - *cl));
      }
      if (cr != t.end()) {
        ans = min(ans, abs(a - *bl) + abs(*bl - *cr));
      }
    }
    if (br != s.end()) {
      npos = lb(t.begin(), t.end(), *br);
      auto cr = npos, cl = npos - 1;

      if (cr != t.begin()) {
        ans = min(ans, abs(a - *br) + abs(*br - *cl));
      }
      if (cr != t.end()) {
        ans = min(ans, abs(a - *br) + abs(*br - *cr));
      }
    }

    // t -> s
    npos = lb(t.begin(), t.end(), a);
    br = npos; bl = npos - 1;
    
    if (br != t.begin()) {
      npos = lb(s.begin(), s.end(), *bl);
      auto cr = npos, cl = npos - 1;

      if (cr != s.begin()) {
        ans = min(ans, abs(a - *bl) + abs(*bl - *cl));
      }
      if (cr != s.end()) {
        ans = min(ans, abs(a - *bl) + abs(*bl - *cr));
      }
    }
    if (br != t.end()) {
      npos = lb(s.begin(), s.end(), *br);
      auto cr = npos, cl = npos - 1;

      if (cr != s.begin()) {
        ans = min(ans, abs(a - *br) + abs(*br - *cl));
      }
      if (cr != s.end()) {
        ans = min(ans, abs(a - *br) + abs(*br - *cr));
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var HW = Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();
            if(HW[0]<2||HW[1] < 2)
            {
                Console.WriteLine(1);
                return;
            }
            Console.WriteLine((HW[0]*HW[1]+1)/2);
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>

using namespace std;

int main() {
	unsigned long long X;
	unsigned long long Y;
	cin >> X;
	cin >> Y;
	if (X%Y == 0) {
		cout << -1 << endl;
		return 0;
	}
	unsigned long long a = X;
	unsigned long long b = Y;
	unsigned long long tmp;
	unsigned long long r;

	if (a<b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	//bがXYの最大公約数 X/b Y/b は互いに素
	unsigned long long i = 2;
	Y = Y / b;
	while (Y%i==0){
		i++;
	}
	cout << X*i << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()
ans = float('inf')

for i in range(N - K + 1):
	cost = h[i + K - 1] - h[i]
	if cost < ans:
		ans = cost
		
print(ans)


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

int main(void) {
    int A,B,C;cin>>A>>B>>C;
    int cnt = 0;
    int coins = 0;
    while (true) {
        cnt++;
        coins += A;
        if (cnt % 7 == 0) coins += B;
        if (coins >= C) break;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

typedef long double ld;
const ld PI = acos(-1.0);
bool eq(ld a, ld b) { return abs(a - b) < EPS; }
typedef complex<ld> Point;
typedef vector<Point> Polygon;

ld dot(Point a, Point b)
{
	return real(conj(a)*b);
}


double dp[22][22][11111], dist[22][22][22];
int main()
{
	int n; ld r, th;
	cin >> n >> r >> th;
	vector<Point> ps;
	REP(i, n)
	{
		ld x, y; cin >> x >> y;
		ps.emplace_back(x, y);
	}
	REP(i, n)REP(j, n)REP(k, n)
	{
		Point pre = ps[i], now = ps[j], next = ps[k];
		Point v1 = now - pre, v2 = next - now;
		if (i == j || j == k || i == k)
		{
			dist[i][j][k] = INF;
		}
		else
		{
			ld lhs = dot(v1, v2), rhs = abs(v1)*abs(v2)*cos(th / 180.0 * PI);
			if (lhs - rhs > -EPS) dist[i][j][k] = abs(v2);
			else dist[i][j][k] = INF;
		}
	}
	REP(i, 22)REP(j, 22)REP(k, 11111) dp[i][j][k] = INF;
	dp[0][0][0] = 0;
	FOR(i, 1, n) dp[0][i][1] = abs(ps[i] - ps[0]);
	FOR(k, 1, 11111)REP(i, n)REP(j, n)
	{
		REP(l, n)
		{
			if (dist[i][j][l] == INF) continue;
			else chmin(dp[j][l][k + 1], dp[i][j][k] + dist[i][j][l]);
		}
	}
	int ans = 0;
	REP(i, 22)REP(j, 22)REP(k, 11111)
	{
		if (dp[i][j][k] <= r) chmax(ans, k);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換

int main() {
    int n;
    cin >> n;
    ll d[n];
    map<ll, int> md, mt;
    rep(i, n) {
        cin >> d[i];
        md[d[i]]++;
    }
    int m;
    cin >> m;
    ll t[m];
    rep(i, m) { 
        cin >> t[i];
        mt[t[i]]++;
         }
    
    
    if (n < m) {
        cout << "NO" << endl;
        return 0;
    }
    for(auto i : mt){
        if(md[i.first]<i.second){
            cout<<"NO"<<endl;
            return 0;
        }
    }


    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 31652
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string S;

LL ans = 0;

void solve(){
	//"A"、"BC"のみで構成される部分列を探し、
	//その中で、各Aについて
	//自分よりも後ろにある"BC"の数を加算
	int BC_counter = 0;
	for(int i=S.size()-1;i>=0;){
		if(S[i]=='C' && i-1>=0){
			if(S[i-1]=='B'){
				BC_counter++;
				i -= 2;
			}else{
				i--;
				BC_counter = 0;
			}
		}else if(S[i]=='A'){
			ans += (BC_counter);
			i--;
		}else{
			i--;
			BC_counter = 0;
		}
	}
}
 
int main(){
    cin >> S;
 
    solve();

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

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
bool com(string s, string t){
	FOR(i,t.length())if(s[i]!='?' && s[i]!=t[i]) return false;
	return true;
}

int main(){
	string s,t;
	cin >> s >> t;
	vi v;
	string ans,aux;
	for(int i=s.length()-t.length();i>=0;i--){
		if(com(s.substr(i,t.length()),t)) v.PB(i);
	}
	if(!v.empty()){
		for(auto i:v){
			aux=s;
			for(int j=i;j<i+t.length();j++)aux[j]=t[j-i];
			FOR(k,s.length())if(aux[k]=='?')aux[k]='a';
			ans=(ans.length()==0)?aux:min(aux,ans);
		}
		cout << ans;
	}
	else cout << "UNRESTORABLE";

	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(h[0] - h[1])
c1 = 0
c2 = 0
for i in range(2, n):
    c1 = abs(h[i] - h[i - 1])
    c2 = abs(h[i] - h[i - 2])
    dp[i] = min(c1 + dp[i - 1], c2 + dp[i - 2])
print(dp[-1])


Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1000000000+7;
static const double PI = 3.141592653589793;
vector<long long> vecmodfact(2,1);

long long modpow(long long x, long long n, long long mod = 0) {
  if (mod == 0) {
      long long res=1;
    while (n > 0) {
      if (n%2 == 1) {
        res = ( res*x );
      }
      x = (x*x);
      n /= 2;
    }
    return res;
  }

  long long res=1;
  while (n > 0) {
    if (n%2 == 1) {
      res = ( res*x ) % mod;
    }
    x = (x*x) % mod;
    n /= 2;
  }
  return res;
}

long long modinverse(long long x, long long mod) {
  // mod must be prime number.
  return modpow(x, mod-2, mod);
}

long long modfact(long long n, long long mod) {
  if (vecmodfact.size()-1 >= n) return vecmodfact.at(n);
  int i=vecmodfact.size();
  vecmodfact.resize(n+1);
  for (; i<=vecmodfact.size()-1; i++) {
    vecmodfact.at(i) = vecmodfact.at(i-1)*i % mod;
  }
  return vecmodfact.at(n);
}

long long modcomb(long long m, long long n, long long mod){
  if (m < n || n < 0) return 0;
  if (n == 0 || n == m) return 1;
  long long ans = modfact(m,mod) * modinverse(modfact(n,mod), mod) % mod;
  ans = ans * modinverse(modfact(m-n,mod), mod) % mod;
  return ans;
}



int main() {
  int a,b;
  cin >> a >> b;
  cout << a*b << endl;
}

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

int main()
{
    int a[4],b[4];
    while(~scanf("%d%d%d%d\n%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])) {
        int hi=0,bl=0;
        for(int i=0;i<4;++i) {
            if (a[i]==b[i]) { ++hi; continue; }
            for(int j=0;j<4;++j) {
                if (i == j) continue;
                if (a[i] == b[j]) ++bl;
            }
        }
        printf("%d %d\n", hi, bl);
    }

    return 0;
}

Measured memory_bytes: 1024
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
const ll mod = 1000000007;
#define int ll
int n, m, v, p, a[200002];
 
ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

bool check(int mid){
	if(p-1+n-mid+1>=v) return 1;
	int votes=0;
	for(int i=p; i<=mid-1; i++) votes+=a[mid]+m-a[i];
	votes+=(p-1+n-mid+1)*m;
	if(votes<m*v) return 0;
	return 1;
}
 
int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin>>n>>m>>v>>p;
	for(int i=1; i<=n; i++) cin>>a[i];
	sort(a+1, a+n+1, [](int a, int b){return (a>b);});
	//for(int i=1; i<=n; i++) cout<<a[i]<<" ";
	int l=p, r;
	for(int i=1; i<=n; i++) if(a[i]>=a[p]-m) r=i;
	r++;
	while(r-l>1){
		int mid=(l+r)/2;
		if(check(mid)) l=mid;
		else r=mid;
	}
	cout<<l;
}

Measured memory_bytes: 1024
#include <cstdio>  
using namespace std;  
int main() { 	
	int a,b,c,d,e; 	
	scanf("%d %d", &a, &b); 	
	if(a%10==9 || a/10==9){
		printf("Yes");
	}
	else{
		printf("No");
	}
	
} 

Measured memory_bytes: 128