akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  str s; cin >> s;
  map<char, ll> ans;
  for(ll i = 0;i < s.size();i++)
  {
    if(ans.count(s[i])) {fin("no") return;}
    else ans[s[i]];
  }
  fin("yes")
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _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 all(x) (x).begin(),(x).end()

const int mod=1e9+7;

int main(){
  int k;cin>>k;
  ll a[k];rep(i,k)cin>>a[i];
  ll max,min;
  max=min=2;
  rep(ri,k){
    int i=k-1-ri;
    if((min+a[i]-1)/a[i]*a[i]>max){
      cout<<-1<<endl;exit(0);
    }
    ll pM=max/a[i]*a[i];
    ll pm=(min+a[i]-1)/a[i]*a[i];
    if(pM==0){
      cout<<-1<<endl;exit(0);
    }
    max=pM+a[i]-1;
    min=pm;
  }
  if(max<2||min<2){
    cout<<-1<<endl;exit(0);
  }
  cout<<min<<" "<<max<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    ll ans = a[0] + b[n-1];
    for(ll i=0;i<n-1;++i){
        ll sum = a[0] + b[n-1];
        for(ll j=0;j<n-1;++j){
            if(i > j){
                sum += a[j+1];
            }else{
                sum += b[j];
            }
        }
        //cout<<sum<<endl;
        ans = max(ans, sum);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int count;
  cin>>count;
  int arr[count],t=1,c=0;
  for(long long int i=0;i<count;i++){
  	 cin>>arr[i];
  }
  for(long long int i=0;i<count;i++){
  	if(arr[i]!=t){
      c++;
    }
    if(arr[i]==t){
    	t++;
      continue;
    }
  }
  if(c==count)
    cout<<"-1";
  else cout<<c;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <math.h>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
#pragma GCC optimize ("-O3")
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
#define tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define ll long long int
ll max(ll a, ll b) {  return a > b ? a : b; }
ll gcd(ll a, ll b) { if (a == 0) return b; return b == 0 ? a : gcd(b, a % b);}
#define case(i) cout<<"Case #"<<i<<": ";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << '\n'; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
#define debug2(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
void err(istream_iterator<string> it, T a, Args... args) { cerr << "[ " << *it << " = " << a << " ]"; err(++it, args...);}
#define time__(d) for (auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second; debug2("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define pii pair <ll , ll >
#define pb push_back
#define PRECISION 10
const ll inf = 9223372036854775800;
const int MAXN = 100001;
const int LOGN = 22;
const int MAXBIT = 62;
const long double PI = 3.141592653589793;
const int DIGITSIZE = 18;
ll mod = 1e9 + 7;
ll MOD = 998244353;
int x4[] = {1, -1, 0, 0};
int y4[] = {0, 0, 1, -1};
int x8[] = {1, 1, 1, -1, -1, -1, 0, 0};
int y8[] = {1, 0, -1, 1, 0, -1, 1, -1};
bool takeTestCases = 0;
bool printCaseNo = 0;

void getac(int T) {
    int n;
    cin>>n;
    int arr[n];
    int xor1=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        xor1^=arr[i];
    }
    for(int i=0;i<n;i++){
        int val = (xor1 ^ arr[i]);
        cout<<val<<' ';
    }   
}
int  main()
{
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
//     freopen("error.txt", "w", stderr);
// #endif
    fastio;
    int t = 1;
    if (takeTestCases) cin >> t;
    int t_t = 1;
    while (t--) {
        if (printCaseNo)
        case (t_t);
        getac(t_t);
        t_t++;
    }
    cerr << "Total time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 4596
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
const LL MAXN=128;
const LL MAXM=100000+100;
const LL INF=0x3f3f3f3f;
LL dp[MAXM];
LL c[MAXN],v[MAXN];
LL n,w;
LL sum,ans;
 
int main(){
	memset(dp,INF,sizeof(dp));
	cin>>n>>w;
	for(LL i=1;i<=n;i++){
		cin>>c[i]>>v[i];
		sum+=v[i];
	}
	
	dp[0]=0; 
	for(LL i=1;i<=n;i++){
		for(LL j=sum;j>=v[i];j--){
			dp[j]=min(dp[j],dp[j-v[i]]+c[i]);
			if(dp[j]<=w) ans=max(ans,j);
		}
	} 
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
ls = tuple([] for i in range(N))
for _ in range(M):
    p, S = input().split()
    p = int(p)
    ls[p - 1].append(S)
    
cnt_crr = 0
cnt_pnt = 0

for e in ls:
    if "AC" in e:
        for _e in e:
            if _e == "AC":
                cnt_crr += 1
                break
            cnt_pnt += 1

print(cnt_crr, cnt_pnt)



Measured memory_bytes: 58784
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define maxn 100
#define mod 998244353
using namespace std;


string s, t;


int main() {
    for(int i=0;i<=300001;i++) s += '?';
    cin >> t;
    int l, r;
    l = s.size() - 1;
    r = t.size() + s.size();
    s += t;
    for(int i=0;i<=200000;i++) s += '?';
    int par = 0;
    int q;
    cin >> q;
    while(q--){
        int f;
        cin >> f;
        if(f == 1){
            par = 1 - par;

        }
        else{
            int tp;
            cin >> tp;
            char c;
            cin >> c;
            if(tp == 1){
                if(!par){
                    s[l] = c;
                    l--;
                }
                else{
                    s[r] = c;
                    r ++;
                }
            }
            else{
                if(par){
                    s[l] = c;
                    l--;
                }
                else{
                    s[r] = c;
                    r ++;
                }
            }
        }
    }
    string res  = "";
    for(auto x: s){
        if(x != '?') res += x;
    }
    if(par) reverse(res.begin(), res.end());
    cout << res << endl;


    return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    int n;
    cin>>n;
    vi h(n);rep(i,n)cin>>h[i];
    int min=0;
    rep(i,n-1){
        if(h[i]>h[i+1]){
            if(min!=0&&min>h[i+1]){cout<<"No";return 0;}
            min=h[i+1];
        }
        if(h[i]-h[i+1]>1){cout<<"No";return 0;}
    }
    cout<<"Yes";
}


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


int main() {
  bool ans = false;
  int N;
  cin >> N;
  
  vector<int> digits(4,0);
  
  
  digits.at(0) = (N / 1000); 
  digits.at(1) = (N / 100) % 10;
  digits.at(2) = (N / 10) % 10;
  digits.at(3) = (N % 10);
    
  if((digits.at(0) == digits.at(1)) && (digits.at(1) == digits.at(2))){
    ans = true;
  }
    
  if((digits.at(1) == digits.at(2)) && (digits.at(2) == digits.at(3))){
    ans = true;
  }
  

  
  if(ans){
    cout << "Yes" << endl;
  }else{
	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
def ERTS(N):
    table = [True]*(N+1)
    table[0], table[1] = False, False
    n = 2
    while n < N**0.5+1:
        if n:
            for i in range(n*2, N+1, n):
                table[i] = False
        n += 1
    return table

table = ERTS(10**5)
prime = []
for i in range(10**5+1):
    if table[i]:
        prime.append(i)

lst = []       
for p in prime:
    if table[(p+1)//2]:
        lst.append(p)

import bisect
Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    l = bisect.bisect_left(lst, L)
    r = bisect.bisect(lst, R)
    print(r - l)    

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

int main()
{
    int n, a, b;
    cin >> n;
    if (n == 1)
    {
        cout << "Hello World" << endl;
    }
    else
    {
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;

  if (A[A.size()-1] == B[0] && B[B.size()-1] == C[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int r;
    cin>>r;

    long double pi=3.1416,x;

    x=2*pi*r;

    cout<<setprecision(10)<<fixed;
    cout<<x<<endl;









    return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

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

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

   if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
      cout << 0 << endl;
      return 0;
   }

   if (a == b && b == c && c == a) {
      cout << -1 << endl;
      return 0;
   }

   int k = 0;
   while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
      int A = a, B = b, C = c;
      a = (B + C) / 2;
      b = (C + A) / 2;
      c = (A + B) / 2;
      k++;
   }
   cout << k << endl;

   return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0: return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y: return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)
        
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

n, m = map(int, input().split())
edge = []
for i in range(m):
    a, b = map(int, input().split())
    edge.append([a - 1, b - 1])

ans = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i == j: continue
        uf.unite(edge[j][0], edge[j][1])
    ans += (len(uf.roots()) != 1)
print(ans)
    
    

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int d[101010];
int cnt[101010];

ll pow(int a, int n)
{
    if(n == 0){
        return 0;
    }else{
        ll k = 1;
        for(int i = 0; i < n; i++){
            k *= a;
            k %= 998244353;
        }
        return k;
    }


}

int main()
{
    int n;
    cin >> n;
    int m = 0;
    for(int i = 0; i < n; i++){
        cin >> d[i];
        m = max(d[i],m);
    }

    for(int i = 0; i < n; i++){
        cnt[d[i]]++;
    }

    ll ans = 1;

    if(cnt[0] != 1 || d[0] != 0){
        cout << 0 << endl;
        return 0;
    }else{
        for(int i = 0; i < m; i++){
            if(cnt[i] == 0){
                cout << 0 << endl;
                return 0;
            }
        }
        for(int i = 1; i <= m; i++){
            ans *= (pow(cnt[i-1],cnt[i]));
            ans %= 998244353;
        }
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
const long long mod = 1000000007;
//const long long mod = 998244353;
int main() {
	int N, R;
	scanf("%d %d", &N, &R);
	printf("%d", R + 100 * maximum(10 - N, 0));
	return 0;
}

Measured memory_bytes: 128
import Control.Applicative
import qualified Data.Vector.Unboxed as V

main = do
  [_,capa] <- map (read :: String -> Int) . words <$> getLine
  goods <- map (map (read :: String -> Int) . words) . lines <$> getContents
  print $ V.maximum (resolve capa (V.enumFromStepN 0 0 (capa+1)) goods)

resolve capa capaV ([v,w]:xs)
  | xs == [] = koushin capaV [v,w] (capa-w)
  | otherwise = resolve capa (koushin capaV [v,w] (capa-w)) xs
  where
    koushin capaV [v,w] n
      | n == 0 && capaV V.! w <= v      = capaV V.// [( w , v)]
      | n == 0                          = capaV
      | oldValue == 0                   = next
      | capaV V.! (n+w) >= v + oldValue = next
      | otherwise = koushin (capaV V.// [( n + w , v + oldValue)]) [v,w] (n-1)
      where
        oldValue = capaV V.! n
        next     = koushin capaV [v,w] (n-1)

Measured memory_bytes: 8220
s=[]
for i in range(3):
  a1,a2,a3=list(map(int,input().split()))
  s.append(a1)
  s.append(a2)
  s.append(a3)
n=int(input())

t=[]
for i in range(n):
  b=int(input())
  for j in range(9):
    if b==s[j]:
      t.append(b)
      
def f(blist):
  for i in blist:
    if s[i] not in t:
      return False
  return True

p=[
[0,1,2],[3,4,5],[6,7,8],
  [0,3,6],
  [1,4,7],
  [2,5,8],
  [0,4,8],
  [2,4,6],
]
ans="No"
for i in p:
  if f(i):
    ans="Yes"
print(ans)
  

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){
    ll n;
    cin >> n;
    string s[n] = {};
    ll cnt = 0;
    ll a = 0,b = 0,both = 0;
    rep(i,0,n){
        cin >> s[i];
        rep(j,0,s[i].size()-1){
            if(s[i][j] == 'A' && s[i][j+1] == 'B') cnt++;
        }
        if(s[i][0] == 'B' && s[i][s[i].size()-1] == 'A') both++;
        else if(s[i][0] == 'B') b++;
        else if(s[i][s[i].size()-1] == 'A') a++;
    }
    
    if(min(a,b) > 0) cout << cnt + min(a,b) + both << endl;
    else if(a == 0 && b == 0) cout << cnt + max(0LL,both -1) << endl;
    else cout << cnt + both << endl;
     
    return 0;
}


Measured memory_bytes: 3912
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    ld x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(10) << sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) << endl;
}



Measured memory_bytes: 3292
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    bool res = false;
    for(int i = 0; i < 26; ++i){
        for(int j = 0; j < 15; ++j){
            if( 4 * i + 7 * j == n) res = true;
        }
    }
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



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

int main(void){
	int n,k,x,y,i,j;
	int a[101];

	for(i=0;i<101;i++){
		a[i]=0;
	}
	
	scanf("%d %d",&n,&k);
	
	for(j=0;j<k;j++){
		
		scanf("%d",&x);
		for(i=0;i<x;i++){
			scanf("%d",&y);
			a[y]=1;
		}
	}
	
	x=0;
	for(i=1;i<=n;i++)
	if(a[i]==0) x++;
	
	printf("%d\n",x);
	
	
	return 0;
}

Measured memory_bytes: 2152
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define up(a,b) (((a)%(b)==0)?((a)/(b)):((a)/(b))+1)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) (a>b)?(a>c)?a:c:(b>c)?b:c
#define min3(a,b,c) (a<b)?(a<c)?a:c:(b<c)?b:c
#define avg(a,b) ((a)+(b))/2
#define pb push_back
#define pob pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;

ll mymod(ll a, ll b)
{
	return (a%b + b)%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b, a%b);
}
bool prime[3001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=3000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=3000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[20];
void power()
{
	powe[0]=1;
	REP(i,1,20)
	{
		powe[i]=(powe[i-1]*10)%num;
        if(powe[i]<0)
        powe[i]+=num;
	}
}
struct node
{
	vll adj;
    ll dist;
};

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    ll r[a], g[b], C[c]; 
    REP(i,0,a)
    {
        cin>>r[i];
    }
    REP(i,0,b)
    {
        cin>>g[i];
    }
    REP(i,0,c)
    {
        cin>>C[i];
    }
    sort(r,r+a);
    sort(g,g+b);
    sort(C,C+c);
    ll p1 = a-1;
    ll p2 = b-1;
    ll p3 = c-1;
    ll sum=0;
    ll c1=0;
    ll c2=0;
    ll A,B,D;
    REP(i,0,x+y)
    {
        
        if(p1<a-x)
        {
            A=-1;
        }
        else
        {
            A=r[p1];
        }
        if(p2<b-y)
        {
            B=-1;
        }
        else
        {
            B=g[p2];
        }
        if(p3<0)
        {
            D=-1;
        }
        else
        {
            D=C[p3];
        }
        if(A>=B && A>=D)
        {
            sum+=A;
            p1--;
            continue;
        }
        else if(B>=D && B>=A)
        {
            sum+=g[p2];
            p2--;
        }
        else if(D>=A && D>=B)
        {
            sum+=C[p3];
            p3--;
            continue;
        }
    }
    cout<<sum<<endl;
	return 0;
}




Measured memory_bytes: 2560
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//  
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;

//#define __DBG__


void solve(void){
  
  int n;
  
  cin >> n;
  
  REP2(i,1,10){
    if(n%i==0){
      if(n/i<10){
        cout << "Yes" << endl;
        return;
      }
    }
  }
  
  cout << "No" << endl;

  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
int main()
{
    char a[6];
    scanf("%s",a);
    for(int i=0;i<2;i++)
    {
        if(a[i]=='9')
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define LOL ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<ll ,ll>
const int sz=1e4+100;
ll dp[sz][12];
string sol[sz][12];
ll n;
pii ara[12];
ll tk[]={0,2,5,5,4,5,6,3,7,6};
bool cmp(pii a,pii b)
{
    return a.s>b.s;
}
//string Max(string a, string b) {
//	if(a.size() == b.size()) {
//		return (a > b) ? a : b;
//	}
//	return (a.size() > b.size()) ? a : b;
//}
ll cholo(ll in,ll w)
{
       if(in>=n){
        if(w==0)  return 1ll;
        else return 0ll;
       }
       if(w==0)  return 1ll;
       ll p=0ll,q=0ll;
       string str1="",str2="";
       ll &ret=dp[w][in];
       if(~ret) return ret;
       if(w-ara[in].f>=0) p=cholo(in,w-ara[in].f);
       q=cholo(in+1,w);
       if(p==1) str1=string(1,'0'+ara[in].s)+sol[w-ara[in].f][in];
       if(q==1) str2=sol[w][in+1];
       if(str1.size() != str2.size())  sol[w][in]=(str1.size()>str2.size()) ? str1: str2;
       else  sol[w][in]=(str1[0]>str2[0]) ? str1 :str2;
       if(p==1 || q==1) ret=1ll;
       else ret=0ll;
       return ret;
}
int main()
{
    LOL
    ll a,b,c,i,j,k,q,p,x,y,sum,ct,ct1,m,l,r,x1,y1,mn,ans,h,sum1,in,z,mid,tot;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    cin>>tot>>n;
    memset(dp,-1ll,sizeof dp);
    for(i=0;i<n;i++){
        cin>>x;
        ara[i]=mk(tk[x],x);
    }
    sort(ara,ara+n,cmp);

    for(i=0;i<sz;i++)  for(j=0;j<12;j++) sol[i][j]="";
    ll last=cholo(0,tot);
    cout<<sol[tot][0]<<endl;

}



Measured memory_bytes: 75264
#include<stdio.h>

#define S 100

typedef struct COST{
	int cost;
	int nodenum;
}Cost;
 
int graph[S][S];
int n;
int cost[S];
Cost heap[S]; //minimum heap.
int N;  //number of elements in heap.

void setCost(Cost *dst, const Cost *src){
	dst->cost = src->cost;
	dst->nodenum = src->nodenum;
	return;
}
 
//e1->cost < e2->cost:-1
//e1->cost == e2->cost:0
//e1->cost > e2->cost:1
int cmpCost(Cost *e1, Cost *e2){
	return (e1->cost < e2->cost?-1:0) + (e1->cost > e2->cost?1:0);
}
 
void swapCost(Cost *e1, Cost *e2){
	int temp;
	temp = e1->cost; e1->cost = e2->cost; e2->cost = temp;
	temp = e1->nodenum; e1->nodenum = e2->nodenum; e2->nodenum = temp;
	return;
}
 
void up(int i){
	if( i <= 1 ){ return; }
	if( cmpCost(&heap[i], &heap[i/2]) == -1 ){
		swapCost(&heap[i], &heap[i/2]);
		up(i/2);
	}
	return;
}
 
void down(int i){
	int j;
	if( 2*i > N ){ return; }
	if( cmpCost(&heap[2*i], &heap[2*i+1]) == -1 ){
		j = 2*i;
	}else{
		j = 2*i+1;
	}
	if( cmpCost(&heap[i], &heap[j]) == 1 ){
		swapCost(&heap[i], &heap[j]);
		down(j);
	}
	return;
}
 
void delete(int i){
	if( i < 1 ){ return; }
	heap[i] = heap[N];
	N--;
	down(i);
	return;
}

int isInCost(int num){
	int i;
	for( i = 0; i < N; i++ ){
		if( heap[i].nodenum == num ){ return i; }
	}
	return -1;
}

void add(Cost *e){
	int re;
	if( (re = isInCost(e->nodenum)) >= 0 ){
		if( heap[re].cost < e->cost ){ return; }
		delete(re);
	}
	N++;
	setCost(&heap[N], e);
	up(N);
	return;
}
 
void init(){
	int i, j;
	for( i = 0; i < S; i++ ){
		cost[i] = -1;
		for( j = 0; j < S; j++ ){ graph[i][j] = -1; }
	}
}

void input(){
	int i, j;
	int u, k, v, c;
	scanf("%d", &n);
	for( i = 0; i < n; i++ ){
		scanf("%d %d", &u, &k);
		for( j = 0; j < k; j++ ){
			scanf("%d %d", &v, &c);
			graph[u][v] = c;
		}
	}
}

int getMinCost(int start){
	int i, j;
	Cost c, next;
	next.cost = 0;
	next.nodenum = start;
	add(&next);
	while( N > 0 ){
		setCost(&c, &heap[1]);
		delete(1);
		i = c.nodenum;
		for( j = 0; j < n; j++ ){
			if( graph[i][j] < 0 ){ continue; }
			next.cost = c.cost + graph[i][j];
			next.nodenum = j;
			if( cost[j] != -1 && cost[j] < next.cost ){ continue; }
			cost[j] = next.cost;
			add(&next);
		}
	}
	return 0;
}

void get(int s){
	cost[s] = 0;
	getMinCost(s);
}

void print(){
	int i;
	for( i = 0; i < n; i++ ){ printf("%d %d\n", i, cost[i]); }
	return;
}

int main(){
	init();
	input();
	get(0);
	print();
	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >>d;
  
  if(a > b){
    cout << b*c + (a-b)*d << endl;
  }
  else {
    cout << a*c << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    ll n, m, a, b;
    cin >> n >> m;
    vector<pair<ll, ll>> mp;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        mp.push_back(make_pair(a,b));
    }
    sort(mp.begin(), mp.end());
    ll ans = 0, index = 0;
    while(m){
        if(mp[index].second == 0){
            index++;
            continue;
        }
        m--;
        mp[index].second--;
        ans += mp[index].first;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2420
import sys
sys.setrecursionlimit(10 ** 7)
n = int(input())
edges = [[] for i in range(n)]
for i in range(n - 1):
    x, y = map(int, input().split())
    edges[x - 1].append(y - 1)
    edges[y - 1].append(x - 1)
def grundy_dfs(cur, prev):
    res = 0
    for next_ in edges[cur]:
        if next_ == prev:
            continue
        res ^= grundy_dfs(next_, cur) + 1
    return res
if grundy_dfs(0, -1) > 0:
    print("Alice")
else:
    print("Bob")

Measured memory_bytes: 114492
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
        int N,X;
        cin >> N >> X;
        vector<int> L(N),D(N+1);
 
        for(int i = 0; i  < N ;i++){
                cin >> L.at(i);
        }
        
        D.at(0) = 0;
        for(int i =1; i < N+1; i++){
                D.at(i) = D.at(i-1) + L.at(i-1); 
        }
        
        int count = 0;

        for(int i = 0; i < N+1; i++){
                
                if(D.at(i)>X){
                        break;
                }
                count ++;
        }
        cout << count ;
 
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		string s=sc.S;
		long ans=0;
		for(int i = 0;i<s.Length;i++) {
			if(s[i]!='9'){
				ans+=s[i]-'0'-1;
				if(i==0&&s.Substring(i+1,s.Length-1)==new string('9',s.Length-i-1)){ans+=(s.Length-i-1)*9+1;}
				else{ans+=Math.Max((s.Length-i-1)*9,i!=0?(s.Length-i)*9-(s[i]-'0'):0);}
				break;
			}
			else{ans+=9;}
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}


Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strnx = str.split(" ");
		int n = Integer.parseInt(strnx[0]);
		int x = Integer.parseInt(strnx[1]);
		str = input.readLine( );
		String[] list = str.split(" ");
		long[] a = new long[n];

		for(int i=0; i<n; i++){
			a[i] = Integer.parseInt(list[i]);
		}

		long count = 0;

		for(int i=0; i<n-1; i++){
			if(a[i]+a[i+1] > x){
				if(x-a[i]>=0 && a[i+1]>=x-a[i]){
					count = count -x+a[i]+a[i+1];
					a[i+1] = x-a[i];
				}else{
					count = count + a[i+1];
					a[i+1] = 0;
					while(a[i]>x){
						count = count+1;
						a[i] = a[i]-1;
					}
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 49676
import java.io.*;
class Program{
    boolean fact(int n){
        int count = 0;
        for(int i=1;i<=Math.sqrt(n);i++){
            if (n%i==0){
                if (i!=Math.sqrt(n)) count+=2;
                else{
                    if (Math.pow(Math.sqrt(n),2)==n) count+=1;
                    else count+=2;
                }
            }
        }
        if (count==8) return true;
        else return false;
    }
}
class Main{
    public static void main(String args[])throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        Program obj = new Program();
        boolean flag = false;int N = Integer.parseInt(in.readLine());
        if (N%4==0||N%7==0) flag = true;
        else{
            for(int i =4;i<N;i+=4){
                if ( (N-i)%7==0 ){
                    flag = true; break;
                }
            }
        }
        if (flag) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define RREP(i, n) for(int i=0; i>(int)(n); i--)
#define ALL(v) v.begin(), v.end()
#define INF 2e9
typedef long long ll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return 1;}return 0;}

using namespace std;

int dp[3333][3333];

int main(void){
	string s;
	string t;
	cin >> s;
	cin >> t;
	int s_l=s.length();
	int t_l=t.length();
	bool flag=true;
	REP(i, t_l){
		if(flag & (s[0]==t[i])){
			flag = false;
		}
		if(flag){
			dp[0][i] = 0;
		}else{
			dp[0][i] = 1;
		}
	}
        flag = true;
	REP(i, s_l){
		if(flag & (s[i]==t[0])){
			flag = false;
		}
		if(flag){
			dp[i][0] = 0;
		}else{
			dp[i][0] = 1;
		}
	}
	REP(i, s_l-1){
		REP(k, t_l-1){
			if(s[i+1]==t[k+1]){
				dp[i+1][k+1] = dp[i][k]+1;
			}else{
				dp[i+1][k+1] = max(dp[i][k+1], dp[i+1][k]);
			}
		}
	}
	int len = dp[s_l-1][t_l-1];
	string ans;
	while(len>0){
		if(s[s_l-1]==t[t_l-1]){
			ans = s[s_l-1]+ ans;
			s_l--;
			t_l--;
			len--;
		}else if((s_l-2>=0)and(dp[s_l-1][t_l-1]==dp[s_l-2][t_l-1])){
			s_l--;
		}else{
			t_l--;
		}
	}
	cout << ans << "\n";
	return 0;
}


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

using namespace std;
const int MAXN=5e5+7;
int n;
int a[MAXN];
string s;
void Input()
{
    cin>>s;
    n=s.size();
}
vector <int> pos;
void Output()
{
    s=" "+s;
    memset(a,-1,sizeof(a));
    for(int i=1;i<n;i++)
        if(s[i]=='>'&&s[i+1]=='<')
        pos.push_back(i+1);
    if(s[1]=='<')
    pos.push_back(1);
    if(s[n]=='>')
        pos.push_back(n+1);
    sort(pos.begin(),pos.end());
    for(int i=0;i<(int)pos.size();i++)
        a[pos[i]]=0;
    for(int i=1;i<=n+1;i++)
        if(a[i]==0)
    {
        int j=i;
        while(s[i]==s[j]&&j<=n)
        {
            a[j+1]=a[j]+1;
            j++;
        }
        j=i-1;
        while(s[i-1]==s[j]&&j>0)
        {
            a[j]=a[j+1]+1;
            j--;
        }
    }
    for(int i=1;i<n;i++)
        if(s[i]=='<'&&s[i+1]=='>')
        a[i+1]=max(a[i],a[i+2])+1;
    long long sum=0;
    for(int i=1;i<=n+1;i++)
    {
        sum+=a[i];
        cerr<<a[i]<<" ";
    }
    cout<<sum;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Output();
    return 0;
}


Measured memory_bytes: 3760
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;
int main() {
	int k, x; cin >> k >> x;
	for (int n = x - k+1; n < k + x; ++n) {
		cout << n;
		if (n != n + x - 1)cout<<" ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

void Hantei();
int n,i,k,x=0;
int three[10000];

int main(){
	scanf("%d",&n);
	Hantei();
	for(i=0;i<k;i++)printf(" %d",three[i]);
	printf("\n");
	
	return 0;
}

void Hantei(){
	for(x=1,i=1;i<=n;i++){
		if(((x%3)==0)||((x%10)==3)){
			three[k]=x;
			k++;
		}else if(x>=10){
			while(1){
				x=x/10;
				if((x==3)||(x%10)==3){
					three[k]=i;
					k++;
					break;
				}else if(x<10)break;
			}
		}
		x=i+1;
	}
	return;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 2097152;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif



int dp[21][N];
int arr[21][21];

signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    memset(dp, 0, sizeof(dp));
    int n; cin>>n;
    For(i, 0, n){
        For(j, 0, n){
            cin>>arr[i][j];
        }
    }
    int mx = pow(2, n);
    for(int i=0; i<n; i++){
        for(int j=0; j<mx; j++){
            int mask = j;
            int x = __builtin_popcountl(mask);
            if(x!=i+1)
                continue;            
            dp[i][j]=0;
            for(int k=0; k<n; k++){
                if(((1<<k)&j) && arr[i][k]){
                    if(i==0){
                        dp[i][j]=1;
                    }
                    else{
                        dp[i][j]+=dp[i-1][j^(1<<k)];
                    }
                }
            }
            dp[i][j]%=MOD;
        }
    }
    cout<<dp[n-1][mx-1];
    return 0;
}





Measured memory_bytes: 344320
#include "bits/stdc++.h"

using namespace std;

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

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);




int main() {
  vll power(401, vl(401));
  rep (i, 401) {
    power[0][i] = 1;
    rep1 (j, 400) {
      power[j][i] = power[j - 1][i] * i % MOD;
    }
  }
  vll sum(401, vl(402));
  rep (i, 401) {
    rep1(j, 401) {
      sum[i][j] = sum[i][j - 1] + power[i][j - 1];
      sum[i][j] %= MOD;
    }
  }
  int n, c;
  cin >> n >> c;
  vl a(n), b(n);
  rep (i, n) {
    cin >> a[i];
  }
  rep (i, n) {
    cin >> b[i];
  }
  vll dp(n + 1, vl(c + 1));
  dp[0][0] = 1;
  rep1(i, n) {
    rep (j, c + 1) {
      rep (k, j + 1) {
        dp[i][j] += dp[i - 1][k] * (sum[j - k][b[i - 1] + 1] - sum[j - k][a[i - 1]]) % MOD;
        dp[i][j] %= MOD;
      }
    }
  }
  while (dp[n][c] < 0) {
    dp[n][c] += MOD;
  }
  cout << dp[n][c] << endl;
}


Measured memory_bytes: 4224
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        s: Chars,
    }

    for i in 0..=s.len() {
        for j in i..=s.len() {
            if s[..i]
                .iter()
                .chain(&s[j..])
                .eq(&['k', 'e', 'y', 'e', 'n', 'c', 'e'])
            {
                println!("YES");
                return;
            }
        }
    }
    println!("NO");
}


Measured memory_bytes: 2156
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int n;
LL a[2222];
LL dp[2300][2300];

LL dfs(int l, int r) {
	l %= n, r %= n;
	if (dp[l][r] != -1)return dp[l][r];

	LL ans;
	int cnt = (r - l - 1 + n) % n;
	if (cnt == 0)ans = 0;
	else if (cnt & 1) {
		if (a[l] > a[r])ans = dfs((l - 1 + n) % n, r);
		else ans = dfs(l, (r + 1) % n);
	}
	else ans = max(dfs((l - 1 + n) % n, r) + a[l], dfs(l, (r + 1) % n) + a[r]);
	return dp[l][r] = ans;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	memset(dp, -1, sizeof(dp));
	LL ans = -2;
	for (int i = 0; i < n; i++)ans = max(ans, dfs((n + i - 1) % n, (n + i + 1) % n) + a[i]);
	cout << ans << endl;
}

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

typedef vector<int> vi;
typedef long long int ll;
#define clr(v, d)           memset(v, d, sizeof(v))
#define all(v)   (v.begin()),(v.end())
#define lp(i,n)     for(int i=0;i<n;i++)
#define sz(v)       v.size()
#define f           first
#define s           second
#define pb           push_back
#define MP           make_pair

ll m,n;
int arr[50];


int convert(ll num){
    int idx=0;
    while(num>0){
        arr[idx]=num%3;
        num=num/3;
        idx++;
    }
    return idx;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    string s;
    cin>>s;
    lp(i,s.length()){
        if((i+1)%2==1){
            if(s[i]=='R'||s[i]=='U'||s[i]=='D'){

            }
            else{
                cout<<"No";
                return 0;
            }
        }
        else{
            if(s[i]=='L'||s[i]=='U'||s[i]=='D'){

            }
            else{
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long


uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

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

int f(int n){
  int ans = 1;
  int tmp = 1024*1024; // 2^20
  LOOP(i,n/20){
    ans*=tmp;
    ans %= MOD;
  }LOOP(i,n%20){
    ans*=2;
    ans %= MOD;
  }
  return ans;
}

int g(int a, int b){
  int ans = 1;
  FOR(i,a,b+1){
    ans *= i;
    ans%=MOD;
  }
  return ans;
}

signed main(){
  int n;
  int a,b;
  int ans = 1;
  int ainv=1, binv = 1;
  cin >> n >> a >> b;
  LOOP1(i,a){
    ainv *= i;
    ainv %= MOD;
  }LOOP1(i,b){
    binv *= i;
    ainv %= MOD;
  }
  ans = f(n);
  // cerr << ans << endl;

  ainv = g(n-a+1, n)*modinv(g(1, a), MOD);
  binv = g(n-b+1, n)*modinv(g(1, b), MOD);
  ainv %= MOD;
  binv %= MOD;
  // cerr << g(1,a) << endl;
  // cerr << g(n-a+1, n) << " *" << ainv%MOD << ":" << binv%MOD << endl;
  ans = ans - (ainv + binv)-1;
  ans %= MOD;
  ans += MOD;
  ans %= MOD;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

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;
}

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

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int K;
  string S;
  cin>>K>>S;
  if(S.length()<=K){
    cout<<S<<endl;
  }else{
    cout<<S.substr(0,K)<<"..."<<endl;
  }
}


Measured memory_bytes: 3644
//	Author : amnptl 
//	   Godbless
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define NeedForSpeed() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD (1000000007); // 1e9+7
int main()
{
	NeedForSpeed();
	int a,b; cin>>a>>b;
	cout<<(a*b)<<endl;		
	return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
#define INF 100000000
using namespace std;


int main(){
	int N,M;
	int ans = 1;
	cin >> N >> M;
	vector<pair<int,int>> b;
	rep(i,0,M){
		int tmp1,tmp2;
		cin >> tmp1 >> tmp2;
		b.push_back(make_pair(tmp1,tmp2-1));
	}

	int high = INF;
	sort(b.begin(),b.end());
	rep(i,0,M){
		if(b[i].first <= high){ //一番aがちいさいとこの最大点の橋をこわした
			high = min(high,b[i].second);
		}else{
			ans++;
			high = b[i].second;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1400