akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;

int main(){
  int m,n,x,y,num[30];
  vector<int> g[30];


  cin >> m >> n;
  for(int i=1;i<=m;i++)num[i] = 0;
  for(int i=0;i<n;i++){
    cin >> x >> y;
    g[x].push_back(y); num[y]++;
  }

  for(int i=0;i<m;i++){
    for(int j=1;j<=m;j++){
      if(num[j] == 0){
	num[j]--;
	cout << j << endl;
	for(int k=0;k<g[j].size();k++)num[g[j][k]]--;
	break;
      }
    }
  }
}

Measured memory_bytes: 1216
from math import ceil


def solve(string):
    b, a = map(int, string.split())
    h = 2 * ceil(max((a - 1) / 25, (b - 1) / 25)) + 1
    a -= 1
    b -= 1
    ans = []
    ans.append("{} {}".format(h, 100))
    for i in range(h):
        if i % 2 == 0:
            ans.append("." * 50 + "#" * 50)
        else:
            """
            if a > 0 and b > 0:
                ma = min(a, 25)
                mb = min(b, 25)
                ans.append("#." * ma + "##" * (25 - ma) + "#." * mb + "##" * (25 - mb))
                a -= ma
                b -= mb
            elif a == 0 and b > 0:
                mb = min(b, 25)
                ans.append("." * 50 + "#." * mb + "##" * (25 - mb))
                b -= mb
            elif a > 0 and b == 0:
                ma = min(a, 25)
                ans.append("#." * ma + "##" * (25 - ma) + "#" * 50)
                a -= ma
            """
            ma = min(a, 25)
            mb = min(b, 25)
            ans.append(".." * (25 - ma) + "#." * ma + "#." * mb + "##" * (25 - mb))
            a -= ma
            b -= mb
            a = max(a, 0)
            b = max(b, 0)
            # """
    return "\n".join(ans)


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (int)(n); ++i)
int main() {
  int n,num,s,a[101]={},p[7]={};
  cin >> n;
  rep(i,n){
      num=i;
      while(num%2==0){
          a[2]++;
          num/=2;
      }
      s=sqrt(num);
      for(int j=3;j<=s;j+=2){
          while(num%j==0){
              a[j]++;
              num/=j;
          }
      }
      if(num!=1){
          a[num]++;
      }
  }
  rep(i,n){
    if(a[i]>=4)
      p[0]++;
    else if(a[i]>=2)
      p[1]++;
    if(a[i]>=14)
      p[2]++;
    else if(a[i]>=4)
      p[3]++;
    if(a[i]>=24)
      p[4]++;
    else if(a[i]>=2)
      p[5]++;
    if(a[i]>=74)
      p[6]++;
  }
  int ans=0;
  ans+=p[0]*(p[0]-1)/2*p[1];
  ans+=p[0]*(p[0]-1)*(p[0]-2)/2;
  ans+=p[2]*p[3];
  ans+=p[2]*(p[2]-1);
  ans+=p[4]*p[5];
  ans+=p[4]*(p[4]-1);
  ans+=p[6];
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <vector>
# include <algorithm>
# include <string>
# include <set>
# include <map>
# include <bitset>
# include <queue>
# include <iomanip>
# include <string>

# define FILE
# define x first
# define y second
using namespace std;



int main()
{
    # ifdef FILEs
        freopen( "travel.in", "r", stdin );
        freopen( "travel.out", "w", stdout );
    # endif // FILE

    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif // FILE
    ios_base::sync_with_stdio( false );

    int n, a[3111], sum = 0;
    cin >> n;
    for ( int i = 1; i <= n; i ++ ){
        cin >> a[i];
    }
    sort( a+1, a + n + 1 );
    for( int i = 1; i <= n-2; i ++ ){
        for( int j = i+1; j <= n-1; j ++ ){
            int q = upper_bound( a+1, a+n+1, a[i]+a[j]-1 ) - a-1;
            sum += q - j;
        }
    }
    cout << sum;




    # ifdef FILEs
        cout << endl << "------------------------";
        cout << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s. |";
        cout << endl << "------------------------";
    # endif
    return 0;
}




Measured memory_bytes: 256
// ABC138-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

vector<vector<int>> node(210000,vector<int>(1,0));
vector<int> ct(210000,0);
vector<int> ans(210000,0);
vector<int> seen(210000,0);
void dfs(int x,int score){
    seen[x]=1;
    score+=ct[x];
    ans[x]=score;
    rep(i,node[x][0]){
        if(seen[node[x][i+1]]==1) continue;
        dfs(node[x][i+1],score);
    }
    return;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n,q;
    cin>>n>>q;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        node[a].push_back(b);
        node[a][0]+=1;
        node[b].push_back(a);
        node[b][0]+=1;
    }
    rep(i,q){
        int p,x;
        cin>>p>>x;
        ct[p]+=x;
    }
    dfs(1,0);
    rep(i,n) cout<<ans[i+1]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 26656
###<ABC.144>
###<A>ac(2)
##a,b = map(int,input().split())
##if a < 10 and b < 10:
##    print(a * b)
##else:
##    print(-1)

#<B>
n = int(input())
for i in range(1,10):
    for j in range(1,10):
        if i * j == n:
            print("Yes")
            exit()


print("No")


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

int main() {
	int n;
    cin >> n;
    vector<ll> sums(n), diffs(n);;
    for (int i = 0; i < n; ++i) {
        ll xi, yi;
        cin >> xi >> yi;
        sums[i] = xi + yi;
        diffs[i] = xi - yi;
    }
    sort(sums.begin(), sums.end());
    sort(diffs.begin(), diffs.end());
    ll ans = sums[n-1] - sums[0];
    ans = max(ans, diffs[n-1] - diffs[0]);
    
    cout << ans << endl;
}


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

const int MAX_N = 102;
int N;
vector<int> A;

void solve()
{
	vector<int> ans;
	while(!A.empty()){
		int n = -1;
		for(int i=0;i<(int)A.size();++i){
			if(A[i]==i+1){
				n = i;
			}
		}
		if(n==-1){
			cout << -1 << endl;
			return;
		}
		ans.push_back(n+1);
		A.erase(A.begin()+n);
	}
	reverse(ans.begin(), ans.end());
	for(int x : ans) cout << x << endl;
}

int main()
{
	cin >> N;
	A.resize(N);
	for(int i=0;i<N;++i) cin >> A[i];
	solve();
	return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
N = int(input())
a = list(map(int,input().split()))

ans = [[0]*W for i in range(H)]
now = 1
cnt = 0
for i in range(H):
    if i&1:
        for j in reversed(range(W)):
            if cnt == a[now-1]:
                now += 1
                cnt = 0
            ans[i][j] = now
            cnt += 1

    else:
        for j in range(W):
            if cnt == a[now-1]:
                now += 1
                cnt = 0
            ans[i][j] = now
            cnt += 1

for i in range(H):
    print(*ans[i])

Measured memory_bytes: 42608
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  int H, A;
  cin >> H >> A;
  if(H<A)
  {
    cout << 1 <<endl;
  }
  else
  {
    if(H%A==0)
    {
      cout << H/A << endl;
    }
    else
    {
      cout << H/A+1 <<endl;
    }
    
  }
  return 0;
}


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

using namespace std;
int A, B, C, D;
int main()
{
    cin>>A>>B>>C>>D;
    while(A>0 && C>0){
        C = C - B;
        if(C<=0){
            A = A;
        }
        else{
            A = A - D;
        }
        
    }
    
    
    if(A>0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }

    return 0;
}


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

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

    if(a>b){
        cout<<"a > b"<<endl;
    }else if(a==b){
        cout<<"a == b"<<endl;
    }else{
        cout<<"a < b"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll a,b,x;
 cin>>a>>b>>x;
 ans=b/x;
 if(a>0)ans-=(a-1)/x;
 if(a==0)ans++;
 pr(ans);
 return 0;}

Measured memory_bytes: 3608
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        a: i64, b: String
    }
    let bb = b.split('.').collect_vec();
    let (b1, b2) = (bb[0], bb[1]);
    let b1: i64 = b1.parse().unwrap();
    let b2: i64 = b2.parse().unwrap();
    let b = b1 * 100 + b2;
    let ans = a * b / 100;
    println!("{}", ans);
}


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

using namespace std;

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

	string b;
	cin >> b;

	if (b == "A") cout << "T";
	else if (b == "T") cout << "A";
	else if (b == "C") cout << "G";
	else if (b == "G") cout << "C";

	return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#include <math.h>

int main() {

	int N,M,X;
	int C[100010],A[15][15];
	long long ans = 100000000;
	cin >> N >> M >> X;
	

	for (int i = 0; i < N; i++) {
		cin >> C[i];
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}

	int keta;

	for (int i = 0; i < pow(2, N); i++) {
		int cost = 0;
		int skill[15] = { 0 };
		int is_OK = 1;

		for (keta = 0; keta < N; keta++) {
			if (i / int(pow(2, keta)) % 2 == 1) {
				for (int j = 0; j < M; j++) {
					skill[j] += A[keta][j];
				}
				cost += C[keta];
			}
		}

		for (int j = 0; j < M; j++) {
			if (skill[j] < X) {
				is_OK = 0;
			}
		}

		if (is_OK == 1 && cost < ans) {
			ans = cost;
		}

	}

	if (ans == 100000000) {
		ans = -1;
	}

	cout << ans << endl;

	cin >> N;

	return 0;


}

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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n,C;cin>>n>>C;

  int d[C][C]={};
  int c[n][n]={};

  rep(i, C){ rep(j, C){ cin>>d[i][j]; } }
  rep(i, n){ rep(j, n){ cin>>c[i][j]; c[i][j] -= 1;} }

  vector<vector<pii>> x(3);
  rep(r, 3){
    rep(newcolor, C){
      int tmp = 0;
      rep(i, n) rep(j, n){
        if ((i+j)%3!=r) continue;
        tmp += d[c[i][j]][newcolor];
      }
      x[r].pb(mp(tmp, newcolor));
    }
  }
  sort(all(x[0])); sort(all(x[1])); sort(all(x[2]));

  int res = INF;
  rep(i, 3){
    rep(j, 3){
      rep(k, 3){
        if (
            x[0][i].second==x[1][j].second or
            x[1][j].second==x[2][k].second or
            x[2][k].second==x[0][i].second
            )
          continue;
        chmin(res, x[0][i].first+x[1][j].first+x[2][k].first);
      }
    }
  }

  cout << res << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 2176
#include <stdio.h>

int main(){
	char S[3];
	scanf("%c%c%c",&S[0],&S[1],&S[2]);
	if (S[0] == S[1]&&S[1] == S[2]){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	int sum = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') sum++;
	}
	cout << sum << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    char s[n];
    for(int i = 0; i < n; i++){
            cin >> s[i];
    }
    bool flag = true;
    for(int i = 0; i < n; i++){
        if(s[i] == 'Y'){
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;


int main() {
    int N; cin>>N;
    vector<int> a(N+1);
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
    }
    a[N]=1e9+1;
    vector<bool> taller(N,false);
    for (int i = 0; i < N; ++i) {
        if(a[i]>=a[i+1]) taller[i]=true;
    }
    int ans=0,cnt=0;
    for (int i = 0; i < N; ++i) {
        if(taller[i]){
            cnt++;
        }else{
            ans=max(ans,cnt);
            cnt=0;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <cstdlib>
#include <typeinfo>

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

using namespace std;

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

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

void trace(int A[], int N) {
  for (int i = 0; i < N; ++i) {
    if (i > 0) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

string str_tolower(string s) {
  transform(s.begin(), s.end(), s.begin(),
            [](unsigned char c) { return tolower(c); });
  return s;
}

////////////////////////////////////////////////////////////

int n;
string a, b;

int main() {
  cin >> n;
  int taro = 0;
  int hanako = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b;
    if (a > b) {
      taro += 3;
    } else if (b > a) {
      hanako += 3;
    } else {
      taro += 1;
      hanako += 1;
    }
  }
  printf("%d %d\n", taro, hanako);
}



Measured memory_bytes: 3288
#include<stdio.h>

int main()
{
	int a[7] = { 1,3,5,7,8,10,12 };
	int b[4] = { 4,6,9,11 };
	int c[1] = { 2 };
	int x, y;
	int i;
	int z;
	int check1 = 0, check2 = -1;
	z = scanf("%d %d", &x, &y);


	for (i = 0; i < 7; i++)
	{
		//printf("a의값은 %d\n", a[i]);
		if (x == a[i])
		{
			check1 = 1;
			//printf("첫번째루프%d %d x의 값과 같습니다\n", x,a[i]);
			break;
		}
	}

	for (i = 0; i < 7; i++)
	{
		if (y == a[i])
		{
			check2 = 1;
			//printf("첫번째루프%d %d y의 값과 같습니다\n", y, a[i]);
			break;
		}
	}

	for (i = 0; i < 4; i++)
	{
		//printf("b의값은 %d\n", b[i]);
		if (x == b[i])
		{
			check1 = 2;
			//printf("두번째루프%d %d x의 값과 같습니다\n", x,b[i]);
			break;
		}
	}

	for (i = 0; i < 4; i++)
	{

		if (y == b[i])
		{
			check2 = 2;
			//printf("두번쨰루프%d %d y의 값과 같습니다\n", y, b[i]);
			break;
		}
	}
	if (x == c[0])
	{
		check1 = 3;
	}

	if (y == c[0])
	{
		check2 = 3;
	}
	if (check1 == check2)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}

	return 0;
}

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

int q;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> q;
	long long t = 0ll;
	for(int i=0; i<q; ++i){
		int p, n;
		char c;
		cin >> p >> c >> n;
		if(c == '(') t += n;
		else t -= n;
		if(t == 0ll) cout << "Yes\n";
		else cout << "No\n";
	}
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll n,m,q;
const ll MAX_Q=50;
vll a(MAX_Q),b(MAX_Q),c(MAX_Q),d(MAX_Q);


ll calc(vll v){
  ll res=0;
  REP(i,q){
    if(v[b[i]]-v[a[i]]==c[i])
      res+=d[i];
  }

  return res;
}


ll dfs(ll now, ll remind, vll v){
  if(remind==0)
    return calc(v);
  ll res=0;

  v[n-remind]=now;
  for(ll i=now; i<=m; i++)
    res=max(res,dfs(i,remind-1,v));

  return res;
}

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

  cin>>n>>m>>q;
  REP(i,q){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    a[i]--;
    b[i]--;
  }

  vll v(n);
  ll ans=dfs(1,n,v);
  cout<<ans<<endl;


}



Measured memory_bytes: 3620
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

A = [iln() for _ in range(3)]
N = iin()
b = [iin() for _ in range(N)]

B = [[False for _ in range(3)] for _ in range(3)]

for i in range(N):
    t = b[i]
    for j in range(3):
        for k in range(3):
            if A[j][k] == t:
                B[j][k] = True

for i in range(3):
    if B[i][0] and B[i][1] and B[i][2]:
        print('Yes')
        exit()
for i in range(3):
    if B[0][i] and B[1][i] and B[2][i]:
        print('Yes')
        exit()
if B[0][0] and B[1][1] and B[2][2]:
    print('Yes')
    exit()
if B[2][0] and B[1][1] and B[0][2]:
    print('Yes')
    exit()
print('No')


        

Measured memory_bytes: 5804
N = int(input())
x = [0]*N
y = [0]*N
h = [0]*N
for i in range(N):
  x[i],y[i],h[i]= [int(x) for x in input().split()]
H = 0
j = 0
while h[j]==0:
  j +=1
for cx in range(101):
  for cy in range(101):
    H = h[j]+abs(cx-x[j])+abs(cy-y[j])
    for n in range(N):
      res = max(H-abs(cx-x[n])-abs(cy-y[n]),0)
      if res==h[n]:
        if n==N-1:
          print(cx,cy,H)
          exit()
        continue
      else :
        break


Measured memory_bytes: 42608
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();

        int n;
        cin >> n;

        double ans = 0.0;
        for (int i = 0; i < n; ++i) {
            double val;
            string tapi;
            cin >> val >> tapi;
            if (tapi == "JPY") {
                ans += val;
            } else {
                ans += val * 380000.0;
            }
        }

        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;cin >> a >> b;
	vector<int> c = {4,6,9,11};
	if(a==2 || b==2){
		if(a==2 && b==2){
			cout << "Yes" << endl;
			return 0;
		}
		else{
			cout << "No" << endl;
			return 0;
		}
	}
	bool ansa=false,ansb=false;
	rep(i,4){
		if(c.at(i)==a) ansa=true;
		if(c.at(i)==b) ansb=true;
	}
	if((ansa && ansb) || (!ansa && !ansb)){
		cout << "Yes" << endl;
		return 0;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
s=input()
#print(s)
t=s[0]
c=[-1,1][s[0]=="R"]
d=[0]

for i in range(1,n):
    if t!=s[i]:
        d.append(c)
        c=0
    t=s[i]
    c+=[-1,1][s[i]=="R"]
d.append(c)
c=len(d)

#print(c,d)
if c>2:
    for i in range(1,k+1):
        if i*2>=c: break
        d[i*2]*=-1
#print(d)
"""
p=[-1,-1]
for i in range(1,c-1):
    tmp=(abs(d[i-1])+abs(d[i])+abs(d[i+1]))
    if tmp>p[0]:
        p[0]=tmp
        p[1]=i
i=p[1]
for j in range(k):
    if i+j*2>=c: break
    d[i+j*2]*=-1
"""
chk=0
ans=0
for i in d:
    if (i>0 and chk>0) or (i<0 and chk<0):
        chk+=i
    else:
        if chk!=0: ans+=abs(chk)-1
        chk=i

print(ans+(abs(chk)-1))


Measured memory_bytes: 45680
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
    
    int n;
    scanf("%d",&n);
    
    long long int c = 0;
    c = n/2 - (n%2==0);
    
    printf("%lld\n",c);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using i64 = long long;

std::vector<std::vector<int>> g;
std::vector<std::tuple<int, int, int>> edges;
std::vector<int> ret;
int k = 0;

void dfs(int v, int p, int c) {
    int j = c ? 0 : 1;
    for (int to : g[v]) {
        if (to == p) continue;
        dfs(to, v, j);
        auto it = std::lower_bound(edges.begin(), edges.end(), std::make_tuple(v > to ? to : v, v > to ? v : to, 0));
        ret[std::get<2>(*it)] = j++;
        if (j == c) j++;
    }
}

int main() {
    int n;
    std::cin >> n;
    g.resize(n);
    ret.resize(n - 1);
    for (int i = 1; i < n; i++) {
        int u, v;
        std::cin >> u >> v;
        --u; --v;
        g[u].push_back(v);
        g[v].push_back(u);
        if (u > v) std::swap(u, v);
        edges.emplace_back(u, v, i - 1);
    }

    std::sort(edges.begin(), edges.end());

    for (auto &v : g) k = std::max(k, (int)v.size());

    dfs(0, -1, -1);
    std::cout << k << std::endl;
    for (auto r : ret) std::cout << r + 1 << std::endl;

    return 0;
}


Measured memory_bytes: 9912
#include <bits/stdc++.h>
#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 long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;

    int ans = a[k-1];

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn = 16666;
int main(){
    int n;
    cin >> n;
    vector<long long> a(n), b(n);
    for(long long & v : a) cin >> v;
    for(long long & v : b) cin >> v;
    long long take = 0;
    for(int e = 0; e < n; e++){
        if(a[e] > b[e]){
            take += a[e] - b[e];
        } else {
            // take = 0;
        }
    }
    for(int e = 0; e < n; e++){
        if(a[e] < b[e]){
            long long take_max = ((b[e] - a[e]) / 2);
            long long take_now = min(take, take_max);
            a[e] += take_now * 2;
            take -= take_now;
        }
    }
    if(take == 0) printf("Yes\n");
    else printf("No\n");
    return 0;

}


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

using namespace std;
typedef long long ll;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k; cin >> k;
    for (int i = 1, x = 7; i <= k; i++) {
        if (x % k == 0) {
            return cout << i << endl, 0;
        }
        x *= 10; x += 7; x %= k;
    }
    cout << -1 << endl;
    return 0;
}


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

#define int long long

inline int in() { int t = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    do { t = t * 10 + ch - '0'; ch = getchar(); } while (ch >= '0' && ch <= '9');
    return t * f;
}

const int N = 1e5 + 5;

int n, m, v, p, a[N], nums[N], b[N], head[N];

signed main() {
    n = in(), m = in(), v = in(), p = in();
    for (int i = 1; i <= n; ++i) a[i] = in();
    std ::sort(a + 1, a + n + 1, std ::greater<int>());
    head[0] = 1;
    for (int i = 1; i <= n; ++i) {
        head[i] = head[i - 1];
        if (a[i] != a[head[i]]) head[i] = i;
        ++nums[head[i]];
    }
    int ans = head[p] - 1 + nums[head[p]], now = 0, nnum = nums[head[p]];
    for (int i = head[p] + nums[head[p]]; i <= n; ++i) {
        if (a[i] + m < a[p]) break;
        if (v <= n - nnum) ++ans;
        else {
            long long cur = m * (v - n + nnum) - now;
            cur = (cur + nnum - 1) / nnum;
            if (a[i] + m >= a[p] + cur) ++ans;
        }
        now += std ::min(m, a[p] - a[i]), ++nnum;
    }
    /*    for (int i = head[p] + nums[head[p]]; i <= n; ++i) {
            if (a[i] + m < a[p]) break;
            if (v <= n - nums[head[p]]) { ++ans; continue; }
            long long cur = m * (v - n + nums[head[p]]);
            cur = (cur + nums[head[p]] - 1) / nums[head[p]];
            if (a[i] + m >= a[p] + cur) ++ans;
        }*/
    std ::cout << ans << std ::endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <algorithm>
using int_t = long long int;
using std::cin;
using std::cout;
using std::endl;
int_t n, t;
struct P
{
    int_t cost, time;
} route[1002];
int main()
{
    cin >> n >> t;
    for (int_t i = 1; i <= n; i++)
        cin >> route[i].cost >> route[i].time;
    std::sort(route + 1, route + 1 + n, [](const P &a, const P &b) -> bool { return a.time < b.time; });
    int_t result = 99999;
    for (int_t i = 1; i <= n; i++)
    {
        if (route[i].time > t)
            break;
        result = std::min(result, route[i].cost);
    }
    if (result == 99999)
    {
        cout << "TLE";
    }
    else
        cout << result;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}

int main(){
  int n,k;
  cin>>n>>k;
  long double ans = 0.0;
  rep(i,n){
    long double tmp = 1.000;
    int hoge = i + 1;
    while(hoge < k){
      hoge *= 2;
      tmp /= 2.0;
    }
    ans += tmp;
  }
  ans /= n;
  cout<<fixed<<setprecision(10)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n: i64 = s.trim().parse().unwrap();
    for i in 1..50001 {
        if i * 108 / 100 == n {
            println!("{}", i);
            return;
        }
    }
    println!(":(");
}


Measured memory_bytes: 4352
A,B = input().split()
a = int(A)
b = int(B)
s = input()

ans = False
if "-" in s:
    if s.count("-") == 1:
        sa, sb = s.split("-")
        if len(sa) == a and len(sb) == b:
            for i in sa+sb:
                if not i.isdigit():
                    break
            else:   
                ans = True
if ans:
    print("Yes")
else:    
    print("No")

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N,A,B = inputIL()
ans = 0
for i in range(1,N+1):
  if A<= sum(int(x) for x in str(i))<=B:
    ans += i
print(ans)

Measured memory_bytes: 44140
capital=[[0,100] for i in range(26)]
small=list('abcdefghijklmnopqrstuvwxyz')
n=int(input())
for i in range(n):
  k=input()
  stack=[0]*26
  for j in range(len(k)):
    stack[small.index(k[j])]+=1
  for j in range(26):
    if stack[j]!=0:
      capital[j][0]+=1
      capital[j][1]=min(capital[j][1],stack[j])
ans=[]
for i in range(26):
  if capital[i][0]==n:
    for j in range(capital[i][1]):
      ans.append(small[i])
ans.sort()
print(''.join(ans))

Measured memory_bytes: 3064
cnt pat []  = 0
cnt pat str =
  let sub = take 3 str
      mtc = if pat == sub
            then 1
            else 0
  in
    mtc + (cnt pat $ drop 1 str)

ans [] = []
ans (l:ls) =
  let j = cnt "JOI" l
      i = cnt "IOI" l
  in
    [j,i] ++ (ans ls)

main = do
  c <- getContents
  let i = lines c
      o = ans i
  mapM_ print o

Measured memory_bytes: 5520
#include <iostream>
#include <string>
#include <vector>


using namespace std;

int main() {

    string S;
    cin >> S;

    reverse(S.begin(), S.end());

    string eraser = "eraser";
    string erase = "erase";
    string dreamer = "dreamer";
    string dream = "dream";

    reverse(eraser.begin(), eraser.end());
    reverse(erase.begin(), erase.end());
    reverse(dreamer.begin(), dreamer.end());
    reverse(dream.begin(), dream.end());

    do {

        int flg = false;

        if (S.substr(0, eraser.size()) == eraser) {
            flg = true;
            S = S.substr(eraser.size(), S.size() - eraser.size());
        }

        if (S.substr(0, erase.size()) == erase) {
            flg = true;
            S = S.substr(erase.size(), S.size() - erase.size());
        }

        if (S.substr(0, dreamer.size()) == dreamer) {
            flg = true;
            S = S.substr(dreamer.size(), S.size() - dreamer.size());
        }

        if (S.substr(0, dream.size()) == dream) {
            flg = true;
            S = S.substr(dream.size(), S.size() - dream.size());
        }


        // 全部見つからないとbreak
        if (flg != 0) continue;
        break;

    } while (true);


    if (S == "") {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;

    }
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
	int x=0,p=1;char c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//ruogu_alter
const int N=1e5+5;
int n,m,par[N],ex[N],ey[N],a=-1,b=-1;
vector<int>g[N];
//
int findset(int x){
	if(par[x]==x)return x;
	return par[x]=findset(par[x]);
}
bool unite(int x,int y){
	x=findset(x);y=findset(y);
	if(x>y)swap(x,y);
	int z=findset(a),w=findset(b);
	if(z>w)swap(z,w);
	if(x==z&&y==w)return true;
	par[x]=y;return false;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=getint();m=getint();
	rep(i,m){
		int x=getint()-1,y=getint()-1;
		g[x].push_back(y);
		g[y].push_back(x);
		ex[i]=x;ey[i]=y;
	}
	rep(i,n)if(g[i].size()&1)return !printf("No\n");
	rep(i,n)if(g[i].size()>5)return !printf("Yes\n");
	int cnt=0;
	rep(i,n)cnt+=(g[i].size()==4);
	if(cnt>=3)return !printf("Yes\n");
	if(cnt<=1)return !printf("No\n");
	rep(i,n)par[i]=i;
	cnt=0;
	rep(i,n)if(g[i].size()==4){
		if(a==-1)a=i;
		else b=i;
	}
	rep(i,m)if(unite(ex[i],ey[i])){
		++cnt;
	}
	if(cnt==2)printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
struct input_t{template<class T>operator T(){T t;std::cin>>t;return t;}}input;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint a=input;
    lint b=input;
    lint c=input;
    lint d=input;
    while(true){
        c-=b;
        if(c<=0){
            std::cout<<"Yes"<<'\n';
            return 0;
        }
        a-=d;
        if(a<=0){
            std::cout<<"No"<<'\n';
            return 0;
        }
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define Test ll t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define loopS(i,a,b,step) for(ll i=a;i<b;i+=step)
#define loopRS(i,a,b,step) for(ll i=a;i>=b;i-=step)
#define ull unsigned long long int
#define pll pair<ll,ll>
#define puu pair<ull, ull>
#define V vector
#define M map
#define UM unordered_map
#define mp(x,y) make_pair(x,y)
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define inf INT_MAX
#define S3(a,b,c) cin >> a >> b >> c
#define S2(a,b) cin >> a >> b
#define debug(x) cout << #x << " = " << x << endl;
using namespace std;

void input(ll n, ll arr[]) {
	rep(i, 0, n)cin >> arr[i];
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout.tie(NULL);
	ll n, w; S2(n, w);
	ll wt[n + 1], val[n + 1];
	rep(i, 0, n) {
		S2(wt[i], val[i]);
	}
	// rep(i,0,n)debug(wt[i]);
	ll dp[n + 1][w + 1];
	init(dp, 0);
	rep(i, 0, n + 1) {
		rep(j, 0, w + 1) {
			if (i == 0 || j == 0)dp[i][j] = 0;
			else if (wt[i - 1] <= j)
				// /Is the current items weight less
                //than or equal to running weight
				dp[i][j] = max(dp[i - 1][j], val[i - 1] + dp[i - 1][j - wt[i - 1]]);
			else {
				dp[i][j] = dp[i - 1][j];
			}
			// debug(dp[i][j]);
		}
	}
	
	cout << dp[n][w] << endl;
}


Measured memory_bytes: 79232
#include <iostream>
#include <string>
#include <vector>

int main(void) {
	// input
	int n;
	std::cin >> n;
	std::vector<std::string> s(n);
	for(int i = 0; i < n; ++i) std::cin >> s[i];

	std::vector<std::vector<int>> n_char(n);
	for(int i = 0; i < n; ++i) {
		n_char[i].resize(26);
		int len_s = s[i].size();
		for(int j = 0; j < len_s; ++j) n_char[i][s[i][j] - 'a'] += 1;
	}

	for(int k = 0; k < 26; ++k) {
		int n_char_min = 9999;
		for(int i = 0; i < n; ++i) n_char_min = (n_char[i][k] < n_char_min ? n_char[i][k] : n_char_min);
		for(int j = 0; j < n_char_min; ++j) std::cout << (char)('a' + k);
	}

	std::cout << std::endl;

	return 0;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;

int main()
{
    int N, ans = 100000+1;
    cin >> N;

    for (int i = 0; i <= N; i++) {
        int tmp = i, sum = 0;
        while (tmp) {
            sum += tmp % 6;
            tmp /= 6;
        }
        tmp = N - i;
        while (tmp) {
            sum += tmp % 9;
            tmp /= 9;
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdio>
using namespace std;


class DP{
public:
	double cost;
	int n, x;
	
	DP(){}
	DP(int xx, int nn, double cc){
		x=xx;n=nn;cost = cc;
	}
	
	bool operator< (const DP &opp) const {
		return cost>opp.cost;
	}
};
struct Edge{
	int to,dist;
};

double visit[40][260]={0};
main(){
	int N, M, p, a, b;
	int i,j;
	while(cin >> N >> M >> p >> a >> b, N){
		int t[12];
		vector<Edge> E[40];
		for(i=0;i<N;i++) cin >> t[i];
		for(i=0;i<p;i++){
			int x,y,z;
			cin >> x >> y >> z;
			E[x].push_back((Edge){y, z});
			E[y].push_back((Edge){x, z});
		}
		priority_queue<DP> dp;
		DP S;
		dp.push(DP(a, 0, 0));
		for(i=0;i<=M;i++)
			for(j=0;j<(1<<N);j++)
				visit[i][j] = 100000;
		while(!dp.empty()){
			S = dp.top();
			dp.pop();
			if(S.x == b) break;
			for(i=0;i<E[S.x].size();i++){
				Edge to = E[S.x][i];
				for(j=0;j<N;j++){
					if((S.n >> j) & 1) continue;
					DP T=S;
					T.x = to.to;
					T.cost += (double)to.dist / t[j];
					T.n |= 1 << j;
					if(visit[T.x][T.n] <= T.cost) continue;
					visit[T.x][T.n] = T.cost;
					dp.push(T);
				}
			}
		}
		if(S.x == b) cout << S.cost << endl;
		else cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 2796
#include <stdio.h>

int main(){
  int i,n,j,co,sum,ico;
  
  while(1){
    scanf("%d",&n);
    if(n==0) break;
    co=0;
    for(i=(n/2+1);i>=0;i--){
      for(j=i,sum=0,ico=0;j>0;j--){
	ico++;
	sum+=j;
        if(ico>=2 && sum==n){
	  co++;
	  break;
	}
	else if(sum>n) break;
      }
    }
    printf("%d\n",co);
  }
  
  return 0;
}

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

int main() {
  int N,M;
  int a,b;
  cin >> N >> M;
  vector<int> city(N);
  for (int i=0; i<M; i++){
    cin >> a >> b;
    for (int j=0; j<N; j++){
      if((j==a-1)||(j==b-1)){
        city.at(j)+=1;
      }
    }
  }
  for (int j=0; j<N; j++){
    cout << city.at(j) <<endl;
  }
}



Measured memory_bytes: 256
import bisect
n=int(input())
a=list(map(int,input().split()))
l=[0]
for i in range(n):
    l.append(l[-1]+a[i])
ans=10**20
for i in range(n-3):
    m=i+2
    f=bisect.bisect_left(l,l[m]//2)
    if f==m:
        f-=1
    f-=1
    if abs(l[m]-2*l[f])>abs(l[m]-2*l[f+1]):
        z=[l[m]-l[f+1],l[f+1]]
    else:
        z=[l[m]-l[f],l[f]]
    b=bisect.bisect_left(l,(l[-1]+l[m])//2)
    if b==n+1:
        b-=1
    if b==n:
        b-=1
    b-=1
    if abs((l[-1]-l[b])-(l[b]-l[m]))>abs((l[-1]-l[b+1])-(l[b+1]-l[m])):
        z.append(l[-1]-l[b+1])
        z.append(l[b+1]-l[m])
    else:
        z.append(l[-1]-l[b])
        z.append(l[b]-l[m])
    ans=min(ans,max(z)-min(z))
    #print(z)
print(ans)
                 


Measured memory_bytes: 25784
# -*- coding: utf-8 -*-

k,n = map(int, input().split())
a=list(map(int, input().split()))

d=[]
for i in range(n-1):
    d.append(a[i+1]-a[i])
d.append(a[0]+k-a[n-1])

print(k-max(d))


Measured memory_bytes: 26444
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        int[] nt = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int res;
        try
        {

            res = Enumerable.Repeat(0, nt[0]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).Where(x => x[1] <= nt[1]).Min(x => x[0]);
        Console.WriteLine(res);
        }
        catch
        {
            Console.WriteLine("TLE");
            
        }
    }
}

Measured memory_bytes: 13524
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int c[100005];
int asc(const void *a, const void *b)
{
    return c[*(int *)b] - c[*(int *)a];
}
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int a[100005], b[100005];
    for (i = 0; i < n; i++)
        scanf("%d %d", &a[i], &b[i]);
    for (i = 0; i < n; i++)
        c[i] = a[i] + b[i];
    int d[100005];
    for (i = 0; i < n; i++)
        d[i] = i;
    qsort(d, n, sizeof(int), asc);
    double ans = 0;
    for (i = 0; i < n; i++)
        if (i % 2 == 0)
            ans += a[d[i]];
        else
            ans -= b[d[i]];
    printf("%.0lf\n", round(ans));
    return 0;
}

Measured memory_bytes: 2172