akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <bits/stdc++.h>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;

int main()
{
    string S;
    cin >> S;
	if(S=="ABC"){
        cout <<"ARC" <<endl;
    }else{
        cout <<"ABC" <<endl;
    }
}

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

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int l = k - a[n - 1] + a[0];
    for (int i = 0; i < n - 1; i++) {
        l = max(l, a[i + 1] - a[i]);
    }

    cout << k - l << endl;
}

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

int main() {
	int a,b;
	cin >> a >> b;
	for (int price=1; price <= 1000; price++) {
		int taxa = price * 0.08;
		int taxb = price * 0.1;
		if (taxa == a && taxb == b) {
			cout << price << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c,count=0;
	scanf("%d %d %d",&a,&b,&c);
	int i;
	for(i=a;i<=b;i++){
	if(c%i ==0)
	count++;
	}
	printf("%d\n",count);
}



Measured memory_bytes: 2140
import java.util.Scanner;

public class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n=scanner.nextInt();
		long t[]=new long[n];
		long a[]=new long[n];
		for(int i=0;i<n;i++) {
			t[i]=scanner.nextInt();
			a[i]=scanner.nextInt();
		}
		for(int i=1;i<n;i++) {
			long p=calc(t[i-1],a[i-1],t,a,i);
			t[i]*=p;
			a[i]*=p;
		}
		System.out.println(t[n-1]+a[n-1]);
	}

	private static long calc(long brd_t, long brd_a, long[] t, long[] a, int i) {
		long res=Math.max(brd_t/t[i], brd_a/a[i]);
		while(t[i]*res<brd_t||a[i]*res<brd_a) {
			res++;
		}
		return res;
	}
}

Measured memory_bytes: 24532
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n = int(input())
    C = input()
    C_cunt = Counter(C)
    cunt_r = C_cunt['R']
    ans = 0
    for i in range(cunt_r):
        if C[i] == 'W':
            ans += 1
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 73816
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
  string a,b;cin >> a>> b;
  int m = b.size();
  int ab = stoi(a)* pow(10, m)+ stoi(b);
  //cout << ab << endl;
  bool ans = false;
  for(int i = 0; i < ab; ++i){
    if(i*i == ab){ans = true;break;    }
  }
  string s="No";
  if(ans)s = "Yes";
  cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
const ll MAX = 2e5+3;
const ll INF = 1e9;
ll dp[MAX];
 
 
int main()
{
    ll n,k;
    cin>>n>>k;
    ll ht[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>ht[i];
      dp[i]=INF;
      
    }
    if(n<k)
    {
        cout<<abs(ht[n]-ht[1]);
        return 0;
    }
    dp[0]=dp[1]=0;
    for(int i=2;i<=k+1 && i<=n;i++)
    {
        dp[i]=abs(ht[i]-ht[1]);
    }
    for(int i=k+2;i<=n;i++)
    {
        for(int j=i-k;j<=i-1;j++)
            dp[i]=min(dp[i],dp[j]+abs(ht[i]-ht[j]));    
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
<?php
list($a) = ints();
list($b) = ints();
list($c) = ints();
list($x) = ints();
$cnt = 0;
for ($i = 0; $i <= $a; $i++) {
    for ($j = 0; $j <= $b; $j++) {
        if ($i * 500 + $j * 100 > $x) continue;
        $rest = $x - $i * 500 - $j * 100;
        if ($rest % 50 === 0 && $rest / 50 <= $c) $cnt++;
    }
}
echo $cnt;;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4604
from collections import deque
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
d = deque([A[0]])
#tmp = [A[0]]
for i in range(1,N,1):
  #print(i)
  #print(tmp)
  ans += d.popleft()
  d.extend([A[i],A[i]])
print(ans)

Measured memory_bytes: 32436
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


ll n;

void solve()
{
    cin >> n;
        vector <char> v;
        while (n>0) {
            if (n%26==0) {
                v.pb(26+96); n/=26;n--;
            }
            else {
                v.pb(n%26 + 96); n/=26;
            }
        }
        for (int i=v.size()-1; i>=0; i--) cout << v[i];
        //sout(n);nout(' ');
    

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3656
n = int(input())
plcs = [list(map(int,input().split())) for _ in range(n)]
A = [0, 0, 0]
for i in range(n):
    A = [plcs[i][j] - A[j] for j in range(3)]
    if A[0] >= abs(A[1]) + abs(A[2]) and plcs[i][0] % 2 == (abs(plcs[i][1]) + abs(plcs[i][2])) % 2:
        continue
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 27280
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
using namespace std;


int main(void) {
	int r,g,b,n,ans,tmp,num=0;
	cin>>r>>g>>b>>n;

	for (int ir = 0; ir <= n; ir++) {
		for (int ig = 0; ig <= n; ig++) {
			tmp=ir*r+ig*g;
			if((n-tmp)%b==0&&(n-tmp)/b>=0&&(n-tmp)/b<=n)num++;
		}
	}

	cout<<num<<"\n";

	return 0;
}


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

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

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    rep(i,N+1) cin >> A[i];

    vector<ll> B(N);
    rep(i,N) cin >> B[i];

    ll ans = 0;
    rep(i,N)
    {
        if( A[i] + A[i+1] > B[i] )
        {
            if( A[i] > B[i] ) ans += B[i];
            else
            {
                ans += B[i];
                B[i] -= A[i];
                A[i+1] -= B[i];
            }
        }
        else
        {
            ans += A[i] + A[i+1];
            A[i+1] = 0;
        }
    }
    cout << ans << endl;
}


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

int main() {

  int a, b;
  cin >> a >> b;
  
  if ( a * b % 2 == 0 ) {
    cout << "Even" << endl;
  }
  
  else {
    cout << "Odd" << endl;
  }
  
}

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

using namespace std;

const int N = 900;

vector <int> f[3];

int g[N][N], cost[N][N];
const int bits = 30;
// 😂 😂
int main() {
  int n, c; cin >> n >> c;

 for(int i = 1; i <= c; ++i) {
    for(int j = 1; j <= c; j++) {
      cin >> cost[i][j];
    }
  }

  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) {
      cin >> g[i][j];
      f[(i + j) % 3].push_back(g[i][j]);
    }
  }
  
  int ans = 1e9;
  vector < pair <int, int> > colors[3];
  for(int i = 0; i < 3; i++) {
    int p = 2000000, col = -1;
    for(int cc = 1; cc <= c; cc++) {
      int sum = 0;
      for(int temp: f[i]) {
        sum += cost[temp][cc];
      }
      colors[i].push_back(make_pair(cc, sum));
    }
  }
  for(int i = 0; i < colors[0].size(); i++) {
    for(int j = 0; j < colors[1].size(); j++) {
      for(int k = 0; k < colors[2].size(); k++) {
        auto a = colors[0][i];
        auto b = colors[1][j];
        auto c = colors[2][k];
        if(a.first != b.first && a.first != c.first && b.first != c.first) {
          ans = min(ans, a.second + b.second + c.second);
        }
      }
    }
  }
  cout << ans << endl;
}

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

typedef pair<int, int> P;
set<P> mtt[16][16];
int gx, gy, p, dp[16][16];

int main(){
    int n;
    for(scanf("%d", &n);n--;){
        scanf("%d%d%d", &gx, &gy, &p);
        for(int x = 0; x < 16; x++){
            for(int y = 0; y < 16; y++){
                mtt[x][y].clear();
                dp[x][y] = 0;
            }
        }
        for(int x = 0; x < p; x++){
            int x1, y1, x2, y2;
            scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
            mtt[x1][y1].insert(P(x2, y2));
            mtt[x2][y2].insert(P(x1, y1));
        }
        for(int x = 0; x <= gx; x++){
            for(int y = 0; y <= gy; y++){
                dp[x][y] = 0;
                if(x == 0 && y == 0) dp[x][y] = 1;
                else if(x == 0){
                    if(mtt[x][y].find(P(x, y-1)) == mtt[x][y].end()) dp[x][y] += dp[x][y-1];
                }else if(y == 0){
                    if(mtt[x][y].find(P(x-1, y)) == mtt[x][y].end()) dp[x][y] += dp[x-1][y];
                }else{
                    if(mtt[x][y].find(P(x, y-1)) == mtt[x][y].end()) dp[x][y] += dp[x][y-1];
                    if(mtt[x][y].find(P(x-1, y)) == mtt[x][y].end()) dp[x][y] += dp[x-1][y];
                }
            }
        }
        if(dp[gx][gy]) printf("%d\n", dp[gx][gy]);
        else puts("Miserable Hokusai!");
    }
    return 0;
}

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

const long long MAXprime=250000LL;
bool bp[MAXprime];
vector<long long> p;
void boolprime()
{
	for (long long i = 0; i < MAXprime; ++i) bp[i]=1;
	bp[0]=0, bp[1]=0;
	for (long long i = 2; i*i < MAXprime; ++i)
	{
		if(bp[i])
		{
			p.push_back(i);
			for (long long j = 2; i*j < MAXprime; ++j) bp[i*j]=0;
		}
	}
	for (long long i = p.at(p.size()-1)+1; i < MAXprime; ++i) if(bp[i]) p.push_back(i);
}

int main(int argc, char const *argv[])
{
	boolprime();
	int n;
	cin>>n;
	int i=n;
	for (auto v:p)
	{
		if (v%5LL==1LL)
		{
			if (i==n)
			{
				cout<<v;
			}
			else
			{
				cout<<" "<<v;
			}
			--i;
		}
		if (i==0)
		{
			break;
		}
	}
	return 0;
}


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

int		main(void)
{
	int a, b, c, d, e, k;

	cin >> a >> b >> c >> d >> e >> k;
	int R = max({e-d, e-c, d-c, e-b, d-b, c-b, e-a, d-a, c-a, b-a});

	if (R > k)
		cout << ":(" << endl;
	else
		cout << "Yay!" << endl;
}


Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>str;
    if(str[0]=='R'||str[1]=='R'||str[2]=='R') sum=1;
    if(str[0]=='R'&&str[1]=='R'||str[2]=='R'&&str[1]=='R') sum=2;
    if(str[0]=='R'&&str[1]=='R'&&str[2]=='R') sum=3;
    cout<<sum<<endl;

    return 0;
}


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

bool isAcgt(char s)
{
    if (s == 'A' || s == 'T' || s == 'G' || s == 'C')
    {
        return true;
    }
    else
    {
        return false;
    }
}

int main()
{
    string s;
    cin >> s;

    int max = -1, num = 0;

    int p = 0;

    while (p < s.size())
    {
        if (isAcgt(s[p]))
        {
            num += 1;
            if (p == s.size() - 1)
            {
                if (max < num)
                {
                    max = num;
                }
            }
        }
        else
        {
            if (max < num)
            {
                max = num;
            }
            num = 0;
        }
        p++;
    }
    cout << max << endl;
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int a,b,n;
	cin >> a>>b>>n;
	int x = min(b - 1, n);
	print(floor(a*x / b) - a * floor(x / b));
}

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

vector<int> G[100005],tp;
int ind[100005],pa[100005];

int main(){
    ios_base::sync_with_stdio(0);
    int n,m; cin>>n>>m;
    for(int i=1;i<n+m;++i){
        int u,v; cin>>u>>v;
        G[u].push_back(v);
        ++ind[v];
    }
    queue<int> q;
    for(int i=1;i<=n;++i)if(ind[i]==0)q.push(i);
    while(q.size()){
        int now=q.front(); q.pop();
        tp.push_back(now);
        for(int i:G[now])--ind[i];
        for(int i:G[now])if(ind[i]==0){
            q.push(i);
            pa[i]=now;
        }
    }
    for(int i=1;i<=n;++i)cout<<pa[i]<<'\n';
}


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

int main(){
int a,b,c,d,e,f;
cin>>a>>b>>c>>d>>e;
if(a>=b){
if(b>=c){
f=c;
}
if(b<=c){
f=b;
}
}
else{
if(a<=c){
f=a;
}
if(a>=c){
f=c;
}
}

if(d<=e){
cout<<f+d-50<<'\n';
}

if(d>e){
cout<<f+e-50<<'\n';
}

return 0;
}

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

int main(){
    using namespace std;
    unsigned long H, W, A, B;
    cin >> H >> W >> A >> B;
    unsigned long BW = B * W, AH = A * H;
    long x = W - 2 * A, y = H - 2 * B;
    long g = BW - AH;
    long a{0}, b{0};
    if([&]{
        for(a = 0; a < H; ++a)for(b = 0; b < W; ++b)if(a * x - b * y == g)return false;
        return true;
    }())return 0 & puts("No");
    vector<unsigned long> r(H);
    priority_queue<pair<unsigned long, unsigned long>> pq;
    for(unsigned long i = 0; i < H; ++i)r[i] = i < a ? W - A : A;
    for(unsigned long i = 0; i < W; ++i)pq.emplace(i < b ? H - B : B, i);
    for(unsigned long i = 0; i < H; ++i){
        vector<unsigned long> v(W);
        vector<pair<unsigned long, unsigned long>> hoge;
        for(unsigned long j = 0; j < r[i]; ++j){
            auto t = pq.top();
            pq.pop();
            v[t.second] = 1;
            hoge.push_back(move(t));
            --hoge.back().first;
        }
        for(const auto& j : hoge)pq.push(j);
        copy(v.begin(), v.end(), ostream_iterator<unsigned long>(cout));
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

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

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using ll = long long;
using namespace std;
int main() {
  	string s;
    cin >> s;
  	if (s[0] == s[1] ||
        s[1] == s[2] ||
        s[2] == s[3]) {
      	cout << "Bad" << endl;
    } else {
      	cout << "Good" << endl;
    }
  
  	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		scn.nextLine();
		char[] str = scn.nextLine().toCharArray();
		int[] black = new int[N+1];
		int ans = N;
		for(int i = 0;i < N ;i++) {
			black[i+1] = black[i]+(str[i]=='#'?1:0);
		}
		for(int i = 0;i <= N;i++) {
			ans = Math.min(ans,black[i] + ((N-i) - (black[N]-black[i])));
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 28496
import heapq
if __name__ == "__main__":
  n, m = list(map(int, input().split()))
  A = list(map(int, input().split()))
  A_inv = [-a for a in A]
  heapq.heapify(A_inv)
  for i in range(m):
    max_inv = heapq.heappop(A_inv)
    heapq.heappush(A_inv, -(-max_inv//2))
  print(-sum(A_inv))

Measured memory_bytes: 14184
n, m, k = map(int, input().split())
MOD = 998244353

frac = [1]*(n+1)
inv = [1]*(n+1)
for i in range(1,n+1):
  frac[i] = i*frac[i-1]%MOD
  
inv[n] = pow(frac[n], MOD-2, MOD)
for i in range(n-1, 0, -1):
  inv[i] = inv[i+1]*(i+1)%MOD
  
def nCr(n,r):
  res = frac[n]*inv[n-r]%MOD
  res = res*inv[r]%MOD
  return res
  
ans  = 0
for i in range(k+1):
  num_pair_block = i + 1
  num_seg = n-i
  ans += m*pow(m-1, num_seg-1, MOD)*nCr(n-1, i)%MOD
  ans %= MOD
  
print(ans)

Measured memory_bytes: 24644
#include <bits/stdc++.h>
using namespace std;
// clang-format off

using LL = long long;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
 
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
// clang-format on

void solve(long long N, long long K) {
  // solver code

  LL ans = N % K;

  ans = min(ans, abs(ans - K));

  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  solve(N, K);
  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vpi = vector<pii>;

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

    int n;
    cin >> n;
    vpi a(n);
    for (pii &x : a) cin >> x.first >> x.second;
    int cur = 0;
    string ans = "No\n";
    for (int i = 0; i < n; i++) {
        if (a[i].first == a[i].second) cur++;
        else cur = 0;
        if (cur >= 3) {
            ans = "Yes\n";
            break;
        }
    }
    cout << ans;

	return 0;
}

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

ll return_gcd(ll a, ll b){
    if(b == 0) return a;
    return return_gcd(b, a%b);
}

ll return_lcm(ll a, ll b){
    ll gcd = return_gcd(a, b);
    return a / gcd * b;
}

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

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

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

}

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

int main(){
  int N;
  int64_t A,B;
  cin >> N >> A >> B;
  int64_t X,pre,dist;
  cin >> pre;
  int64_t ans=0;
  for(int i=1;i<N;i++){
    cin >> X;
    dist=X-pre;
    ans+=min(dist*A,B);
    pre=X;
  }
  cout << ans << endl;
  return 0;
}


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


int main(){
	int n;
	cin >> n;
	long long a=1,b=1;
	for(int i = 0 ; i < n ; i++){
		long long x,y;
		cin >> x >> y;
		long long r = max( (a+x-1) / x, (b+y-1) / y);
		a = r * x;
		b = r * y;
	}
	cout << a+b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast_cin() ios_base::sync_with_stdio(false)
using namespace std;
const int N = 1e5+7;

int main(){
    fast_cin();
    int mx = 0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    string s1 = "";
    for(int i = 0; i<s.size(); i++)
    {
        s1+=s[i];
        string temp = "";
        int c = 0;
        for(int j=i+1; j<s.size();j++)
            temp+=s[j];
        sort(s1.begin(),s1.end());
        sort(temp.begin(),temp.end());
        set<char>ss,ss1;
        string piz = "";
        string piz2="";
        for(auto it:s1)ss.insert(it);
        for(auto it:temp)ss1.insert(it);
        for(auto it:ss)piz+=it;
        for(auto it:ss1)piz2+=it;
        for(int i=0;i<piz.size();i++)
            for(int j = 0; j<piz2.size();j++)
                if(piz[i]==piz2[j])
                    c++;
        mx = max(mx,c);
    }
    cout << mx;
    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>M;
    cout<<(N + M - 1) / M<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define NOT_FOUND -1

int i, j, n, S[100000000], q, T[100000000], N, key, num;
int linearSearch();
int main()
{
  int counter = 0;
  
  scanf("%d", &n); // S???????´???°
  for(i = 0; i < n; i++) scanf("%d", &S[i]);
  scanf("%d", &q);
  for(i = 0; i < q; i++) scanf("%d", &T[i]);
  
  for(i = 0; i < n; i++)
    {
      num = 0;
      for(j = 0; j < i; j++)
	if(S[j] == S[i]) num++;
      if(num == 0)
	{key = S[i];
	  if(linearSearch() != NOT_FOUND) counter++;
	}
    }
  printf("%d\n", counter);
  
  return 0;
}

int linearSearch()
{
  j = 0;
  T[n] = key;
  while(T[j] != key)
    {
      j++;
    }
  if(j == n) return NOT_FOUND;
  return j;
}

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

int main() {
	int x[5];
	int i = 0;
	for (i = 0; i < 5; i++) {
		cin >> x[i];
		if (x[i] == 0)
			break;
	}
	cout << i + 1 << endl;
	return 0;
}

Measured memory_bytes: 3620
def bs(v):
    nc = 0
    m = len(v)
    while m > 0:
        j=0 
        while j < m-1:
            if v[j] > v[j+1]:
                x = v[j+1]
                v[j+1] = v[j]
                v[j] = x
                nc += 1
            j += 1
        m -= 1
    return(nc)

while True:
    n = int(input())
    if n==0:
        break
    v = []    
    for _ in range(n):
        x = int(input())
        v.append(x)

    print(bs(v))

Measured memory_bytes: 7728
N, A, B = map(int, input().split())
X = list(map(int, input().split()))
X2 = [x*A for x in X]
ans = 0
a = X2[0]
for i in X2[1:]:
    b = i - a
    if b > B:
        ans += B
    else:
        ans += b
    a = i
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};
typedef pair<int,int> P;

P func(int x){
  int a,b;
  b = x % 10;
  while(x > 9){
    x /= 10;
  }
  return {x,b};
}
int main(){
  int n; cin >> n;
  map<P,int> mp;
  for(int i = 1; i <= n; i++){
    mp[func(i)]++;
  }
  
  ll ans = 0;
  for(auto m:mp){
    //printf("{%d,%d} = %d \n",m.first.first,m.first.second,m.second);
    P tmp = {m.first.second,m.first.first};
    auto itr = mp.find(tmp);
    if(itr != mp.end()){
      ans += m.second * itr->second;
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

int main () {
    int y,m,d;
    char i,j;
    cin >> y >> i >> m >> j >> d;
    
    if (m >= 5){
        cout << "TBD" << endl;
    }

    else {
        cout << "Heisei" << endl;
    }

}

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

int main()
{
    int n, m;

    cin >> n;

    if (n % 1000 == 0)
    {
        cout << "0\n";
    }
    else
    {
        m = (n / 1000) + 1;
        m *= 1000;
        cout << m - n << "\n";
    }
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  
  vector<int>a(N);

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

  sort(a.begin(),a.end());
  
  int A=0;
  int B=0;
   for(int i=0;i<N;i++){
     if(i%2==0){
       A+=a.at(i);
     }
     else{
       B+=a.at(i);
     }
   }
  

cout<<abs(A-B)<<endl;
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split(" ");

    var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);

    var c = a + b;
    if(c >= 24) {
        c = c - 24;
    }
    console.log(c);
}

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

Measured memory_bytes: 7372
// Nurbakyt Madibek
// Look at my code! IT'S AWESOME

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <unordered_set>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) (int)((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;
typedef pair < int, ull > pu;
typedef pair < ll, ll > pl;

const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const double eps = 1e-9;

const int MAX_N = (int)1e5 + 5;
const int mod = (int)1e9 + 7;

int n;
vector < int > g[MAX_N];

int dfs(int v, int pr = -1) {
    int res = 0;
    for (auto to : g[v]) {
        if (to == pr)
            continue;
        int val = dfs(to, v) + 1;
        res ^= val;
    }
    return res;
}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    cin >> n;
    for (int i = 1, u, v; i < n; i++) {
        cin >> u >> v;
        g[u].pb(v), g[v].pb(u);
    }
    if (dfs(1) > 0)
        cout << "Alice\n";
    else
        cout << "Bob\n";
    return 0;
}


Measured memory_bytes: 10368
#include <stdio.h>

int main()
{
    int a,b,c,tm,tm2,tm3;
    scanf("%d%d%d",&a,&b,&c);
    tm=a+b;
    tm2=b+c;
    tm3=a+c;
    if(tm==c || tm2==a || tm3==b)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

int main(){
  int N,L;
  cin>>N>>L;
  vector<string> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  sort(p.begin(),p.end());
  string T="";
  for(int i=0;i<N;i++){
    T+=p[i];
  }
  cout<<T<<endl;
}

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

int main() {
    int N,K; cin >> N >> K;
    set<int> ans;
    for(int i=0; i<K; i++){
        int d; cin >> d;
        for(int j=0; j<d; j++){
            int A; cin >> A;
            ans.insert(A);
        }
    }
    cout << N-ans.size() << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include <iostream>
#include <string>
 
using namespace std;
 
int N;
 
void dfs(string s, char mx){
 if(s.length() == N){
 	printf("%s\n", s.c_str());
 } else {
 for(char c='a';c<=mx;c++){
 dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx));
 }
 }
 }
 
 int main(void){
 cin >> N;
 dfs("", 'a');
return 0;
 }

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

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n = sz(s);
  int m = sz(t);
  int ans = INT_MAX;
  for (int i = 0; i + m - 1 < n; i++) {
    int j = i + m - 1;
    int cnt = 0;
    for (int k = i; k <= j; k++) {
      if (s[k] != t[k - i]) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << '\n';
  /*
  int n = sz(s);
  int m = sz(t);
  vector <vi> dp(n, vi(m, -1));
  const int INF = 1e9;
  function <int(int,int)> rec = [&] (int i, int j) -> int {
    if (j == m) return 0;
    if (i == n) return INF;
    if (dp[i][j] != -1) return dp[i][j];
    int ret = 0;
    if (s[i] == t[j]) ret = rec(i + 1, j + 1);
    ret = min(ret, rec(i + 1, j));
    ret = min(ret, 1 + rec(i + 1, j + 1));
    return dp[i][j] = ret;
  };
  cout << rec(0, 0) << '\n';
  */
  return (0);
}


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

int main() {
  
  
  int n, k;
  cin >> n >> k;
  //n = スヌケくんの数 k = お菓子の種類
  //d = その種類のお菓子を持っている人数
  
  vector<int> vec(n);
  
  for(int i = 0; i < n; i++){
    vec.at(i) = 0;
  }
  
  for(int i = 0; i < k; i++){
    int d;
    cin >> d;
    for(int j = 0; j < d; j++){
      int a;
      cin >> a;
      int b = a - 1;
      vec.at(b) = vec.at(b) + 1;
    }
  }
  
  int total = 0;
  
  for(int i = 0; i < n; i++){
    if(vec.at(i) == 0){
      total = total + 1;
    }
  }
  
  cout << total << endl;

  
  
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define all(x) (x.begin(),x.end())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define endl "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define sz(a) (int)a.size()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define Q(x) for(int i=0;i<x;i++)
#define show(x) for(auto i:x)cout<<i<<" ";cout<<endl;

using namespace std;
const ll mod = 1e9 + 7;

int main() {

	int n;
	cin >> n;
	vi a(n);
	Q(n)cin >> a[i];
	int temp = a[0];
	rep(i, 1, n) {
		temp = __gcd(a[i], temp);
	}
	if (temp != 1) {
		cout << "not coprime";
		return 0;
	}
	set<int>divisors;
	rep(i, 0, n) {
		int x = a[i];
		if (x % 2 == 0) {
			if (divisors.find(2) != divisors.end()) {
				cout << "setwise coprime";
				return 0;
			}
		}
		while (x % 2 == 0) {

			divisors.insert(2);
			x /= 2;
		}
		for (int j = 3; j * j <= x; j += 2) {
			if (x % j == 0) {
				if (divisors.find(j) != divisors.end()) {
					cout << "setwise coprime";
					return 0;
				}
			}
			while (x % j == 0) {
				divisors.insert(j);
				x /= j;
			}
		}
		if (x > 1) {
			if (divisors.find(x) != divisors.end()) {
				cout << "setwise coprime";
				return 0;
			}
			divisors.insert(x);
		}
	}
	cout << "pairwise coprime";
	return 0;
}


Measured memory_bytes: 7292
x = gets.chomp
y = x.split("\s")
a = y[0]
b = y[1]

if a == "H"
    if b == "H"
        ans = "H"
    else
        ans = "D"
    end
else
    if b == "H"
        ans = "D"
    else
        ans = "H"
    end
end
print(ans, "\n")


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

int main() {
  int N,K,i,j;
  double p=0;
  cin >> N >> K;
  for(i=0; i<min(N,K); i++) {
    int x=0;
    for(j=i+1; j<K; j*=2)
      x++;
    p += ((double)1/pow(2,x));
  }
  p /= N;
  cout << setprecision(12);
  if(N<K)
    cout << p;
  else
    cout << p+(N-K)*((double)1/N);
  cout << endl;
}

Measured memory_bytes: 512
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    pii tmp;

    rep(i,0,N) {
        int A, B; cin >> A >> B;
        chmax(tmp, make_pair(A, B));
    }
    cout << tmp.first + tmp.second << endl;
    return 0;
}

Measured memory_bytes: 256
/** @Date    : 2017-08-26 20:15:51
  * @FileName: B.cpp
  * @Platform: Windows
  * @Author  : Lweleth (SoungEarlf@gmail.com)
  * @Link    : https://github.com/
  * @Version : $Id$
  */
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 2e5+20;
const double eps = 1e-8;

char s[N];

LL cnt[28];
int main()
{
	while(~scanf("%s", s))
	{
		MMF(cnt);
		int x = strlen(s);
		LL ans = 0;
		for(int i = 0; i < x; i++)
			cnt[s[i] - 'a']++;
		for(int j = 0; j < 26; j++)
			ans += (x - cnt[j]) * cnt[j];
        printf("%lld\n", ans / 2 + 1);
	}
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int main()
{
	ll n;
	cin >> n;
	ll a = 1;
	int i = 0;
	for (i = 0; a < n; i++)
	{
		a *= 3;
	}
	cout << i << endl;
	return 0;
}

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

typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int n;
int main(){
    cin>>n;
    vector<int>a(n+1);
    vector<int>b(n);
    rep(i,n+1)cin>>a.at(i);
    rep(i,n)cin>>b.at(i);
    ll ans=0;
    rep(i,n){
        if(b.at(i)>a.at(i)){
        ans+=a.at(i);
        b.at(i)-=a.at(i);
        a.at(i)=0;
        if(b.at(i)>=a.at(i+1)){
            ans+=a.at(i+1);
            a.at(i+1)=0;
            b.at(i)-=a.at(i+1);
        }
        else{
            ans+=b.at(i);
            a.at(i+1)-=b.at(i);
        }
        }
        else{
            ans+=b.at(i);
            a.at(i)-=b.at(i);
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 1152
import java.util.Scanner;



public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int p = sc.nextInt();
			if(n+m+p==0) break;
			
			int sum = 0;
			int win = 0;
			boolean winer = true;
			for(int i=1;i<=n;i++) {
				int bet = sc.nextInt();
				if(i==m) {
					if(bet==0) {
						winer = false;
					}
					else
						win = bet;
				}
				sum += bet*100;
			}
			if(!winer)
				System.out.println(0);
			else {
				sum = sum*(100-p)/100;
				System.out.println(sum/win);
			}
		}
	}
}


Measured memory_bytes: 37316
A = str(input())
B =int(A[:2])
C =int(A[2:4])


if B >=1 and B<=12:
    B_mm = True
else:
    B_mm = False

if C >=1 and C<=12:
    C_mm = True
else:
    C_mm = False

if B >=0 and B<=99:
    B_yy = True
else:
    B_yy = False

if C >=0 and C<=99:
    C_yy = True
else:
    C_yy = False

if B_yy == True and C_mm == True and B_mm ==True and C_yy ==True:
    print('AMBIGUOUS')
elif B_yy == True and C_mm == True:
    print('YYMM')
elif C_yy == True and B_mm == True:
    print('MMYY')
else:
    print('NA')




Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    string N;
    cin >> N;
    for (char n : N) {
        if (n == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

// can be applied to string type
#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T>
void Debug(const T &val) { cerr << val << End; }
template<typename T, typename... Args>
void Debug(const T &val, Args... args) {
    cerr << val << ' ';
	Debug(std::forward<Args>(args)...);
}

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

// can be applied to string type
#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
// array sorters
#define Sart(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])));
#define SartR(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])), std::greater<__typeof(a[0])>())

#define pb push_back
#define mp make_pair
#define a first
#define b second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    long k;
	int t;

	cin >> k >> t;

	priority_queue<pair<int, int> > pq;
	pair<int, int> p, pp;
	int ans = 0;
	int a, prev = -1;

	int i;

	rep(i, t) {
		cin >> a;

		pq.push(mp(a, i));
	}

	while (!pq.empty()) {
		p = pq.top();

		pq.pop();

		if (prev == p.b) {
			if (pq.empty()) {
				ans += p.a;

				break;
			}

			pp = pq.top();
			
			pq.pop();

			pp.a--;
			if (0 < pp.a) pq.push(pp);
		    
			p.a--;
			if (0 < p.a) pq.push(p);
		} else {
			p.a--;

			prev = p.b;

			if (0 < p.a) pq.push(p);
		}
	}
    
	Out(ans);
	
	return 0;
}


Measured memory_bytes: 384
<?php
fscanf(STDIN, "%d %d", $monster_count, $critical);
if($monster_count<=$critical){
  echo 0;
  exit;
}
$monster_s = fgets(STDIN);
$exploded_monster_s = explode(' ', trim($monster_s));
sort($exploded_monster_s);
$nokori = array_splice($exploded_monster_s, 0, $monster_count-$critical);
echo (int)array_sum($nokori);

Measured memory_bytes: 31392
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

int main()
{
	int n, m, a, b;
	vector<int> e[100010];
	cin >> n >> m;
	rep(i, m)
	{
		cin >> a >> b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	int p[200010], done[100010]={};
	int l=100000, r=100001;
	p[l]=a, p[r]=b;
	done[a]=1, done[b]=1;
	int mul=0, mur=0;
	int tmp;
	while(mul+mur<2)
	{
		if(mul==0)
		{
			tmp=p[l];
			int cnt=0;
			rep(j, e[tmp].size())
			{
				if(done[e[tmp][j]]==0)
				{
					done[e[tmp][j]]=1;
					l--;
					p[l]=e[tmp][j];
					break;
				}
				cnt++;
			}
			if(cnt==e[tmp].size()) mul=1;
		}
		if(mur==0)
		{
			tmp=p[r];
			int cnt=0;
			rep(j, e[tmp].size())
			{
				if(done[e[tmp][j]]==0)
				{
					done[e[tmp][j]]=1;
					r++;
					p[r]=e[tmp][j];
					break;
				}
				cnt++;
			}
			if(cnt==e[tmp].size()) mur=1;
		}
	}
	cout << (r-l+1) << endl;
	cout << p[l];
	for(int j=l+1; j<=r; j++) cout << ' ' << p[j];
	cout << endl;
	return 0;
}

Measured memory_bytes: 7040
#include <stdio.h>

int main (void){
  long long N,power=1;
  int i;

  scanf("%lld",&N);
  for(i=2;i<=N;i++){
    power=power*i;
    power %= 1000000007;
  }

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

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long

using namespace std;

const int N=3010,mod=998244353;
int n,x,f[N][N<<1],fac[N],inv[N],ans;

inline void upd(int &x,int y){x+=y; x-=x>=mod?mod:0;}

void init(int n){
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	rep (i,2,n) fac[i]=(ll)fac[i-1]*i%mod,inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod;
	rep (i,2,n) inv[i]=(ll)inv[i]*inv[i-1]%mod;
}
int C(int n,int m){return (ll)fac[n]*inv[m]%mod*inv[n-m]%mod;}

int main(){
	ios::sync_with_stdio(0);
	cin>>n>>x; init(n);
	f[0][0]=1;
	rep (i,1,n) rep (j,1,x){
		upd(f[i][j],f[i-1][j-1]);
		if (j>1) upd(f[i][j],f[i-1][j-2]);
	}
	rep (i,0,n){
		int res=0;
		rep (j,0,x-2) upd(res,f[i][j]);
		rep (j,0,i)
			if (i-j<=j&&x-1-2*(i-j)>=0) upd(res,f[j-(i-j)][x-1-2*(i-j)]);
			else if (i-j>j&&j*2==x-1) upd(res,1);
		upd(ans,(ll)C(n,i)*res%mod);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	vector <int> data(110);
	vector <bool> atoz(26);
	for (int i = 0; i < 26; i++)
	{
		atoz[i] = false;
	}
	for (int i = 0 ; i<s.size();i++)
	{
		atoz[(s[i] - 'a')] = true;
	}
	
	for (int i = 0; i < 26; i++)
	{
		if (atoz[i] == false)
		{
			cout << (char)(i + 'a') << endl;
			return 0;
		}
	}

	cout << "None" << endl;
	
	
	return 0;

	


}

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

typedef long long ll;

int main() {
    int N, M, a, b;
    cin >> N >> M;
    vector<vector<bool>> e(N, vector<bool>(N, false));
    rep(i, M) {
        cin >> a >> b;
        e[a - 1][b - 1] = true;
        e[b - 1][a - 1] = true;
    }
    vector<int> p(N - 1);
    rep(i, N - 1) p[i] = i + 1;
    int ans = 0;
    do {
        bool f = e[0][p[0]];
        rep(i, N - 2) {
            f &= e[p[i]][p[i + 1]];
        }
        if (f) ans++;
    } while (next_permutation(p.begin(), p.end()));
    cout << ans << "\n";
}

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

int main() {
    string s; cin >> s;
    int l[4];
    for (int i = 0; i < 4; i++) {
        l[i] = s[i] - '0';
    }
    for (int bit = 0; bit < (1<<3); bit++) {
        int sum = l[0];
        string t; t += s[0];
        for (int i = 0; i < 3; i++) {
            if (bit & (1<<i)) {
                sum += l[i+1];
                t += '+';
            }
            else {
                sum -= l[i+1];
                t += '-';
            }
            t += s[i+1];
        }
        if (sum == 7) {
            t += "=7";
            cout << t << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 768
n,m,x = map(int,input().split())
c = list(list(map(int,input().split())) for _ in range(n))
ans = 10**7
for i in range(1<<n):
    mokuhyo = [0]*m
    cost = 0
    for j in range(n):
        if i>>j&1:
            for r in range(m):
                mokuhyo[r] += c[j][r+1]
            cost += c[j][0]
    if all(k>=x for k in mokuhyo):
        ans = min(ans, cost)
print("-1" if ans == 10**7 else ans)        

Measured memory_bytes: 9100