akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/

const int N=2e5+5;

int n;
int a[N];

namespace S1{
    int c[40];//在这一位上是右儿子的边数
    bool check(int k){
        int len=0;
        memset(c,0,sizeof(c));
        FOR(i,1,n){
            if(a[i]>len){
                FOR(j,len+1,a[i])++c[j];
                len=a[i];
            }else {
                int pos=a[i];
                while(c[pos]==k)--pos;
                if(pos==0)return 0;
                c[pos]++;
                FOR(j,pos+1,30)c[j]=0;//清空
                FOR(j,pos+1,a[i])c[j]++;
                len=a[i];
            }
        }
        return 1;
    }
}
int tot=0;

namespace S2{
    map<int,int> c;
    bool check(int k){
        int len=0;
        c.clear();
        FOR(i,1,n){
            if(a[i]>len){
            }else {
                int pos=a[i];
                if(k==1)return 0;
                while(tot<4e6&&pos&&c.count(pos)&&c[pos]==k-1)--pos,++tot;
                if(pos==0)return 0;
                c[pos]++;
                map<int,int>::iterator it=c.find(pos);
                ++it;
                c.erase(it,c.end());
            }
            len=a[i];
            //if(tot>=1e7)return 0;
            if(tot>=4e6)return 0;
        }
        return 1;
    }
}
int main(){
    scanf("%d",&n);
    FOR(i,1,n)scanf("%d",&a[i]);
    int l=1,r=n+1,mid;
    while(l<r&&tot<4e6)mid=(l+r)>>1,S2::check(mid)?r=mid:l=mid+1;
    if(tot>=4e6){
        FOR(i,1,n)a[i]=min(a[i],30);
        l=1,r=n+1;
        while(l<r)mid=(l+r)>>1,S1::check(mid)?r=mid:l=mid+1;
    }
    printf("%d\n",l);
    return 0;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

void solve(){
   int n;
   map<string,int>m;
   cin >> n;
   while(n--){
      string s;
      cin >> s;
      m[s] =1;
   }
   cout << sz(m);
}

int32_t main(){
   fast;
   int t = 1;
//   cin >> t;
   while(t--)  solve();   
}

Measured memory_bytes: 19288
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c=0;
    scanf("%d%d",&a,&b);
    while(c<1251){
        c++;
        int d=(int)c*0.08;
        int e=(int)c*0.1;
        if(a==d&&b==e) {
            printf("%d",c);
            break;
        }
        if(c==1250) {
            printf("-1");
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int a=scan.nextInt();
        int b=scan.nextInt();
        if(a%3==0||b%3==0||(a+b)%3==0){
            System.out.println("Possible");
        }
        else{
            System.out.println("Impossible");
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a, b;
    cin >> a >> b;
    rep(i, 1, 10000) {
        if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp

#include <iostream>
using namespace std;


int main(){	
	int min1 = 100,min2 = 100,sum1 = 0,sum2 = 0;
	int input;
	for(int i=0;i<4;i++){
		cin >> input;
		min1 = min(min1,input);
		sum1 += input;
	}
	for(int i=0;i<2;i++){
		cin >> input;
		min2 = min(min2,input);
		sum2 += input;
	}
	
	cout << (sum1 - min1) + (sum2 - min2)<< endl;
	
	return 0;
}

Measured memory_bytes: 3092
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll P,Q,R;
	cin >> P>>Q>>R;
	
	// 解法
	ll ans = P+Q+R;
	ans -= max(P, max(Q,R));
	
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
import Data.List
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine
readCsInt n = concat<$>replicateM n readLnInt

x ? (a,b) = if x then a else b
a~>(f,x) = [a] ++ (null x)?(f,x)

main = do
 [n] <- readLnInt
 inputs <- readLnInt
 putStr.unlines.map show $ solve n inputs

solve :: Int -> [Int] -> [Int]
solve n as = f n 1 (group(sort as))

f :: Int -> Int -> [[Int]] -> [Int]
f n t as@(ai:ajs)
 | t>n = []
 | t==head ai = [length ai] ++ f n (t+1) ajs'
 | otherwise = [0] ++ f n (t+1) as where
    ajs' = (null ajs)?([[0]],ajs)


Measured memory_bytes: 32280
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n, m;
    scan(n, m);
    auto ac = new bool[](n);
    auto wc = new int[](n);
    foreach (i ; 0 .. m) {
        int pi; string si;
        scan(pi, si);
        pi--;
        if (si == "AC") {
            ac[pi] = 1;
        }
        else {
            if (!ac[pi]) wc[pi]++;
        }
    }
    auto tot_ac = ac.sum();
    auto tot_wa = dotProduct(ac, wc);
    writefln("%d %d", tot_ac, tot_wa);
}
















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	int n;
	cin>>n;
	cout<<n*800-n/15*200;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

string a[101];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, l;
    cin >> n >> l;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a + n);
    for(int i = 0; i < n; i++){
        cout << a[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
# N = int(input())
# A = [int(x) for x in input().split()]
# from collections import defaultdict
# dd = defaultdict(lambda: 0)

R, G, B, N = [int(x) for x in input().split()]

cnt = 0

for r in range(1 + N // R):
    for g in range(1 + N // G):
        rest = N - (r * R + g * G)

        if rest >= 0 and rest % B == 0:
            cnt += 1
            # print("{}, {}".format(r,g))

print(cnt)


Measured memory_bytes: 40812
N, K = map(int, input().split())
h = [int(x) for x in input().split()]

dp = [float('inf')] * N
dp[0] = 0

for i in range(N-1):
    for j in range(i+1, i+K+1):
        if j >= N:
            break
        dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]))

print(dp[N-1])

Measured memory_bytes: 55008
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = Read();
            var moji = new List<string> { "3", "5", "7" };
            Action<string> dfs = null;

            var ans = 0;
            dfs = S =>
            {
                if (S != "" && long.Parse(S) > long.Parse(N)) return;

                if (S.Any(x => x == '3') && S.Any(x => x == '5') && S.Any(x => x == '7'))
                {
                    ans++;
                }

                foreach (var m in moji)
                {
                    dfs(S + m);
                }
            };

            dfs("");
            Println(ans);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 17360
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 	    make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod        1000000007
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll power(ll a , ll b,ll modi)
{
    ll res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % modi ;
        }
        b/=2 ;
        a = (a*a) % modi ;
    }
    return res ;
}
bool pali(vector<char>ch)
{
	for(int i=0;i<ch.size();i++)
	if(ch[i]!=ch[ch.size()-i-1])
	return false;
	return true;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
	//cin>>t;
	while(t--)
	{
	  string str;
	  cin>>str;
	  int n=str.length();
	  vector<char>ch1;
	  vector<char>ch2;
	  vector<char>ch3;
	  for(int i=0;i<n;i++)
	  ch3.pb(str[i]);
	  for(int i=0;i<(n-1)/2;i++)
	  ch1.pb(str[i]);
	  for(int i=(n+3)/2-1;i<n;i++)
	  ch2.pb(str[i]);
	  if(pali(ch1)&&pali(ch2)&&pali(ch3))
	  cout<<"Yes";
	  else
	  cout<<"No";
	}
return 0;
}

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

int main(){
    string s;
    cin>>s;
    if(s[0]!=s[1] && s[1]!=s[2] && s[2]!=s[3])cout<<"Good"<<endl;
    else cout<<"Bad"<<endl;

    return 0;

}

Measured memory_bytes: 256
k,s = map(int,input().split())
x=y=z=0
count = 0
for i in range(min(k,s)+1):
  for j in range(min(k,s)+1):
    z = s-x-y
    if 0 <= z <= k:
      count += 1
    y += 1
  y = 0
  x +=1
print(count)

Measured memory_bytes: 3060
#include<cstdio> 
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=3000+10,mo=1000000007;
int f[maxn][maxn],right[maxn],sum[maxn];
int i,j,k,l,r,t,n,m,ans,one,zero;
char get(){
    char ch=getchar();
    while (ch!='0'&&ch!='1') ch=getchar();
    return ch;
}
int main(){
    scanf("%d%d",&n,&m);
    fo(i,1,n) sum[i]=get()-'0';
    fo(i,1,n+1) sum[i]+=sum[i-1];
    fo(i,1,n+1) right[i]=i;
    fo(i,1,m){
        scanf("%d%d",&j,&k);
        right[j]=max(right[j],k);
    }
    fo(i,1,n) right[i]=max(right[i],right[i-1]);
    f[1][sum[right[1]]]=1;
    fo(i,1,n)
        fo(j,0,n)
            if (f[i][j]){
                l=right[i]+1;r=right[i+1];
                one=j;zero=right[i]-i+1-j;
                if (zero) (f[i+1][j+sum[r]-sum[l-1]]+=f[i][j])%=mo;
                if (one) (f[i+1][j-1+sum[r]-sum[l-1]]+=f[i][j])%=mo;
            }
    ans=f[n+1][0];
    (ans+=mo)%=mo;
    printf("%d\n",ans);
}

Measured memory_bytes: 33792
n=int(input())
hs=list(map(int,input().split()))

for i in range(1,n):
  if hs[i-1]==hs[i]:
    pass
  elif hs[i-1]-hs[i]>=1:
    print('No')
    exit()
  elif hs[i-1]-hs[i]<1:
      hs[i]-=1

print('Yes')

Measured memory_bytes: 14396
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 5e5 + 120;
 

int main(){FAST;
    int n ,res=0;
    cin >> n >> res;
        res = (res - n) * (res - n + 1) /2 - res;
        out(res);

}
 










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

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

    int x,ans = 0,i = 2;
    cin >> x;

    if(x == 1){
        cout << 1 << endl;
        return 0;
    }

    for(int i = 2; i < x; ++i){
        int j = 2;
        while(1){
            if(pow(i,j) > x) break;
            if(ans < pow(i,j)){
                ans = pow(i,j);
            }
            j++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
struct my_comp
{
	bool operator()(pair<ll,pll> p1, pair<ll,pll> p2)
	{
		if(p1.fi!=p2.fi)
		return p1.fi>p2.fi;
		return p1.se.fi<p2.se.fi;
	}
};
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);	
int main()
{
	string s;
	cin>>s;
	if(s[sz(s)-1]=='s')
	s+="es";
	else
	s+="s";
	cout<<s<<"\n";
	return 0;
}

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

const int N = 11000;
const int N2 = 110;
int cnt[N], dp[N2][N2][N2];
int n;

void dfs(int x, int y, int z){ 
	int sum = x * x + y * y + z * z + x * y + x * z + y * z;
	if (sum > 10000) return ;
	
	++cnt[sum];
	
	if (dp[x + 1][y][z] == -1) { 
		dp[x + 1][y][z] = 0;
		dfs(x + 1, y, z);
	} 
	if (dp[x][y + 1][z] == -1) { 
		dp[x][y + 1][z] = 0;
		dfs(x, y + 1, z);
	} 
	if (dp[x][y][z + 1] == -1) { 
		dp[x][y][z + 1] = 0;
		dfs(x, y, z + 1);
	} 
	
} 

int main(){
	scanf("%d", &n);
	
	memset(cnt, 0, sizeof cnt);
	memset(dp, -1, sizeof dp); 
	
	dfs(1, 1, 1);
	
	for (int i = 1; i <= n; ++i)
		printf("%d\n", cnt[i]);
	
	return 0;
}

Measured memory_bytes: 8968
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
#define fo(i,l,r,d) for(int i=(l);i<=(r);i+=(d))
using namespace std;
const int maxn=3e5+10;
int a[maxn],n;
int main(){
    scanf("%d",&n);
    rep(i,1,n){
        scanf("%d",&a[i]);
        if((i^a[i])&1) return puts("No"),0;
    }
    for(int i=1;i<=n;++i){
        if(a[i]==i) continue;
        int p;
        for(p=i;p<=n-2;p+=2)
            if(a[p+2]==p+2||a[p+1]!=p+1) break;
        int mx=0,mn=n+1;
        rep(j,i,p) mx=max(mx,a[j]),mn=min(mn,a[j]);
        if(mx!=p||mn!=i) return puts("No"),0;
        int f1=0,f2=0;
        fo(j,i,p,2)
            if(a[j]>f1) f1=a[j];
            else if(a[j]>f2) f2=a[j];
            else return puts("No"),0;
        i=p;
    }
    puts("Yes");
    return 0;
}
//DSYTXDY

Measured memory_bytes: 1536
#include<stdio.h>

int main()
{
    int a,n,sum=0,temp;
    scanf("%d", &a);
    temp = a;
    while(a!=0)
    {
        n=a%10;
        sum+=n;
        a=a/10;
    }
    if(temp%sum==0)
    {
        printf("Yes\n");
    }
    else
        printf("No\n");
    return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> D;
    rep(i, 5) {
        int d;
        cin >> d;
        D.push_back(d);
    }

    int ans = inf;
    do {
        int tmp = 0;
        rep(i, 5) {
            tmp += D[i];
            if (i == 4) break;
            while (! (tmp % 10 == 0)) {
                ++tmp;
            }
        }
        ans = min(ans, tmp);
    } while (next_permutation(all(D)));

    cout << ans << endl;

    return 0;
}

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

int main(){
	int n;
	cin >> n;
	map<int,int> r;
	for(int i = 0; i < n; i++){
		int k;
		cin >> k;
		r[k]++;
	}
	int ans = 0;
	while(!r.empty()){
		if(r.rbegin()->second == 0){
			r.erase(r.rbegin()->first);
			continue;
		}
		int f = r.rbegin()->first;
		r[f]--;
		int q = 1;
		while(q <= f) q *= 2;
		if(r.count(q-f) && r[q-f] > 0){
			r[q-f]--;
			ans++;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
  int N; long A; cin >> N; multiset<long> S;
  REP(i, N){ cin >> A; S.insert(A); }
  long L, R, a, b; vector<vector<long>> ans;
  REP(i, N-1){ 
    L=*S.begin(); R=*S.rbegin(); a=R-L; b=L-R;
    S.erase(S.find(L)); S.erase(S.find(R));
    if(S.size()){
      long l=*S.begin(), r=*S.rbegin(), m=max(abs(a-l), abs(a-r)), n=max(abs(b-l), abs(b-r));
      if(m>=n){ S.insert(a); ans.push_back({R, L}); }else{ S.insert(b); ans.push_back({L, R}); }
    }else{ cout << a << "\n"; ans.push_back({R, L}); }
  }
  REP(i, N-1){ cout << ans[i][0] << " " << ans[i][1] << "\n"; }
}

Measured memory_bytes: 11160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
inline int add(int a,int b){a+=b;return a>=mod?a-mod:a;}
inline int sub(int a,int b){a-=b;return a<0?a+mod:a;}
inline int mul(int a,int b){return 1ll*a*b%mod;}
inline int qpow(int a,int b){int ret=1;for(;b;b>>=1,a=mul(a,a))if(b&1)ret=mul(ret,a);return ret;}
/* math */
const int N = 1e7+5;
const int M = 5010;
int fac[N], ifac[N], inv[N];
inline void init(int n=1e7){
	fac[0]=ifac[0]=1;for(int i=1;i<=n;i++)fac[i]=mul(fac[i-1],i);
	ifac[n]=qpow(fac[n],mod-2);for(int i=n-1;i;--i)ifac[i]=mul(ifac[i+1],i+1);
	inv[1]=1;for(int i=2;i<=n;i++)inv[i]=mul(mod-mod/i,inv[mod%i]);
}
int g[M];
int n,a;

inline int binom(int a,int b){
	return mul(fac[a],mul(ifac[b],ifac[a-b]));
}

inline int solve(int a,int b,int c){
	return mul(fac[a+b+c],mul(a,inv[a+b]));
}
int ans=0;
int main()
{
	init();
	cin >> n >> a;
	for(int i=1;i<=a;i++){
		for(int j=1;j<=i;j++){
			int w=binom(i,j);if((i-j)&1)w=sub(0,w);
			int qwq=solve(j,n-a,max(0,a-i-1));
			ans=add(ans, mul(w,qwq));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 120820
def dis(p1,p2):
  return ((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)**0.5

n=int(input())
p=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  for j in range(i+1,n):
    ans+=dis(p[i],p[j])
print(ans*2/n)


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

int main(){
  string n;
  cin >> n;
  bool ok = false;
  rep(i,3){
    if(n[i]=='7') ok = true;
  }
  if(ok){
    puts("Yes");
  }else{
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 3632
# https://atcoder.jp/contests/keyence2019/tasks/keyence2019_b

s = gets.chomp
KEYENCE = 'keyence'

res = false
if s.include?("keyence")
  puts "YES"
  exit
end
0.upto(KEYENCE.size - 1) do |i|
  left = KEYENCE[0..i]
  idx = s.index(left)
  next if idx.nil?
  (idx + left.size + 1).upto(s.size - 1) do |j|
    res = true if s[0..idx + left.size] + s[j..-1] == "keyence"
    break if res
  end
  break if res
end

puts res ? "YES" : "NO"

Measured memory_bytes: 1788
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;
typedef ll Int;

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


// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
    return a * b / gcd(a, b);
}

ll count(ll a, ll b, ll div){
    return b / div - (a-1) / div;
}

int main(int argc, char**argv){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << (b - a + 1) - (count(a, b, c) + count(a, b, d) - count(a, b, lcm(c, d))) << endl;

    return 0;
}





















Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, y;
    cin >> n >> y;
    bool flag=false;

    for (int i = 0; i <= n; ++i)
    {
        for (int j = 0; j <= (n - i); ++j)
        {
            int k;
            k = n - i - j;
            if (y == 10000 * i + 5000 * j + 1000 * k)
            {
                cout << i << " " << j << " " << k << endl;
                flag = true;
                break;
            }
        }
        if (flag)
        {
            break;
        }
    }
    if (!flag)
    {
        cout << -1 << " "<< -1 << " " << -1 << endl;
    }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main implements Runnable {

    private void solve() throws IOException {

        int N = nextInt();
        int M = nextInt();

        int[] pref = new int[N+3];
        for(int m = 0; m < M; ++m) {
            int a = nextInt();
            int b = nextInt();
            int min = Math.min(a,b);
            int max = Math.max(a,b);
            pref[min]++;
            pref[max]--;
        }
        for(int i = 1; i <= N; ++i) {
            pref[i] += pref[i-1];
        }

        boolean even = true;
        int s = 0;
        for(int i = 1; i <= N; ++i) {
            s += pref[i];
            even &= (s % 2 == 0);
        }
        if(even) writer.println("YES");
        else writer.println("NO");
    }


    public static void main(String[] args) {
        new Main().run();
    }



    BufferedReader reader;
    //    BufferedReader reader2;
    StringTokenizer tokenizer;
    PrintWriter writer;
    //    BufferedWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//            reader = new BufferedReader(new FileReader("input.txt"));
            //            reader2 = new BufferedReader(new FileReader("1.in"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
//            writer = new     PrintWriter("output.txt");
//                                                    writer = new BufferedWriter(System.out);
            //                        writer = new BufferedWriter(new OutputStreamWriter(System.out));
            solve();
            reader.close();
            //            reader2.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    short nextShort() throws IOException {
        return Short.parseShort(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }

}

Measured memory_bytes: 41224
from itertools import permutations 
n = int(input())
p = list(map(int, input().split())) 
q = list(map(int, input().split()))
 
i = 0
for x in permutations(range(1, n+1)):
    i += 1
    if list(x) == p:
        a = i
    if list(x) == q:
        b = i

print(abs(a-b))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://arc066.contest.atcoder.jp/tasks/arc066_b>
問題文============================================================
正の整数 N が与えられます。
 2 つの整数 u,v(0≦u,v≦N) であって、ある非負整数 a,b が存在して、a xor b=u、a+b=v
 となるようなものが何通りあるかを求めてください。
 ここで、xor はビットごとの排他的論理和を表します。
 なお、答えは非常に大きくなることがあるので、10^9+7 で割った余りを求めてください。
 1≦N≦10^18
=================================================================

解説=============================================================
 解説を見た( http://kmjp.hatenablog.jp/entry/2017/01/11/1000 )
 
 制約の大きい数え上げは　桁dpやメモ化再帰の可能性が高い
 
 上からu,vの各桁の0,1を決めて行くメモ化再帰
 
 もいっこ
 OEISを用いる (http://piroz.hatenablog.com/entry/2016/12/19/005445 )
 
 testを実行して得られた数列を検索すると
 A007729 がそれらしい答えのものとわかる
 ここで、さらに調べるとこれは A002487 の部分和で表されることがわかる為、
 これをメモ化して行く
================================================================
*/
const ll MOD = 1e9+7;
ll N;
ll memo[64][5][5];
void init(){
    for(int i = 0; i < 64;i++)for(int j = 0; j < 5;j++)for(int k = 0; k < 5;k++) memo[i][j][k] = -1;
}
ll dfs(int d,int a,int b){
    if(d < 0) return 1;
    ll& ret = memo[d][a][b];
    if(ret != -1) return ret;
    ret = 0;
    
    if(N&(1LL<<d)){ // d 桁目が 1
        ret += dfs(d-1,1,min(2,b*2+1));
        ret += dfs(d-1,a,min(2,b*2));
    }else{
        ret += dfs(d-1,a,min(2,b*2));
        if(a && b) ret += dfs(d-1,a,min(2,b*2-1));
    }
    if(b){
        if(N&(1LL<<d)){
            ret += dfs(d-1,1,min(2,b*2-1));
        }else{
            ret += dfs(d-1,a,min(2,b*2-2));
        }
    }
    ret %= MOD;
    return ret;
}
ll solve_1(){
    init();
    cin >> N;
    return dfs(60,0,0);
}

void test(){
    set<pii> s;
    for(int n = 1; n < 20;n++){
        s.clear();
        for(int a = 0; a <= n; a++){
            for(int b = 0; a + b <= n; b++){
                s.insert(pii(a^b,a+b));
            }
        }
        cout << s.size() << endl;
    }
}

map<ll,ll> Memo;
ll f(ll n){
    ll& res = Memo[n];
    if(res != 0) return res;
    if(n <= 2) return res = n;
    res = f(n/2) + f((n-1)/2) + f((n+1)/2);
    res%=MOD;
    return res;
}
ll solve_2(){
    cin >> N;
    return f(N+1);
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
  // test();
  //  cout << solve_1() << endl;
    cout << solve_2() << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cstdlib>
#include <typeinfo>


using namespace std;

const int SUP = -1;

typedef pair<int, int> P;

const int MAX_H = 1000;
const int MAX_W = 1000;
char field[MAX_H][MAX_W + 1];
int d[MAX_H][MAX_W];
int H, W, N;
int sx, sy;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int bfs(){

  int time = 0;

  for (int i = 1; i <= N; i++) {

    for (int i = 0; i < H; i++)
      for (int j = 0; j < W; j++) d[i][j] = SUP;

      queue<P> que;

      que.push(P(sx, sy));
      d[sx][sy] = 0;


      while (que.size()){

        P p = que.front(); que.pop();

        if (field[p.first][p.second]-'0' == i) {
          time += d[p.first][p.second];
          sx = p.first;
          sy = p.second;
          break;
        }

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

          int nx = p.first + dx[i], ny = p.second + dy[i];

          if(0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] != 'X'&& d[nx][ny] == SUP){
            que.push(P(nx, ny));
            d[nx][ny] = d[p.first][p.second] + 1;
          }
        }
      }
  }
  return time;
}


int main(int argc, char const *argv[]) {
  cin >> H >> W >> N;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> field[i][j];
      if (field[i][j] == 'S'){
        sx = i;
        sy = j;
      }
    }
  }

  cout << bfs() << endl;
}

Measured memory_bytes: 7964
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define MOD2 998244353

using namespace std;
typedef long long int ll;

int main(void)
{
	fast;
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	int ct[4] = {0};
	for (int i = 0; i < 3; ++i)
	{
		int x, y; cin >> x >> y;
		++ct[x-1]; ++ct[y-1];
	}
	bool poss = 1;
	for (int i = 0; i < 4; ++i)
		if (!ct[i] or ct[i] == 3)
			poss = 0;
	if (poss) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 256
import queue

h,w=map(int,input().split())

ch,cw=map(int,input().split())
dh,dw=map(int,input().split())

ch-=1
cw-=1
dh-=1
dw-=1
#c->d

s=[input() for i in range(h)]

seen=[[0 for _ in range(w)] for _ in range(h)]
distance=[[10**7 for _ in range(w)] for _ in range(h)]

q=queue.Queue()#start point of each domain

distance[ch][cw]=0
seen[ch][cw]=1
q.put([ch,cw])


while (not q.empty()) and distance[dh][dw]==10**7:
  sth,stw=q.get()
  qi=queue.Queue()#BFS
  qi.put([sth,stw])
  wlis=[]
  while not qi.empty():
    ph,pw=qi.get()
    cntp=0
    for nearh,nearw in [[ph-1,pw],[ph+1,pw],[ph,pw-1],[ph,pw+1]]:
      if 0<=nearh<=h-1 and 0<=nearw<=w-1 and s[nearh][nearw]=="." and seen[nearh][nearw]!=1:
        qi.put([nearh,nearw])
        seen[nearh][nearw]=1
        distance[nearh][nearw]=distance[ph][pw]
      if 0<=nearh<=h-1 and 0<=nearw<=w-1 and s[nearh][nearw]=="#":
        cntp+=1
    if cntp!=0:
      wlis.append([ph,pw])
  for i,j in wlis:
    for warph,warpw in [[i-2,j-2],[i-2,j-1],[i-2,j],[i-2,j+1],[i-2,j+2],
                        [i-1,j-2],[i-1,j-1],[i-1,j],[i-1,j+1],[i-1,j+2],
                        [i,j-2],[i,j-1],[i,j+1],[i,j+2],
                        [i+1,j-2],[i+1,j-1],[i+1,j],[i+1,j+1],[i+1,j+2],
                        [i+2,j-2],[i+2,j-1],[i+2,j],[i+2,j+1],[i+2,j+2]]:
      if 0<=warph<=h-1 and 0<=warpw<=w-1 and s[warph][warpw]=="." and seen[warph][warpw]==0:
        q.put([warph,warpw])
        seen[warph][warpw]=2
        distance[warph][warpw]=distance[i][j]+1



if distance[dh][dw]==10**7:
  print(-1)
else:
  print(distance[dh][dw])


Measured memory_bytes: 119020
#include<bits/stdc++.h>
using namespace std;
int main(){
	list<int>l;
	int n; cin >> n;

	int temp;
	cin >> temp;
	l.push_back(temp);
	if(n%2 == 0)for(int i = 1; i < n; i++){
		cin >> temp;
		if(i%2 == 1)l.push_front(temp);
		if(i%2 == 0)l.push_back(temp);
	}
	if(n%2 == 1)for(int i = 1; i < n; i++){
		cin >> temp;
		if(i%2 == 1)l.push_back(temp);
		if(i%2 == 0)l.push_front(temp);
	}

	for(auto i = l.begin(); i != l.end(); i++)cout << *i << " ";
	cout << endl;
}

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

template <typename T>
using lim = numeric_limits<T>;

bool check[10];

bool valid(int x){
	string s = to_string(x);
	for (char c : s){
		if (check[c-'0']) return false;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	memset(check, 0, sizeof check);
	
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		int tt; cin >> tt;
		check[tt] = true;
	}

	while(!valid(n)) n++;

	cout << n << "\n";
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(),count=0;
		sc.close();
		Queue<Long> q = new ArrayDeque<>();
		for(long i=1;i<10;i++) q.add(i);
		while(true) {
			long temp = q.poll();
			count++;
			if(count==n) {
				System.out.println(temp);
				return ;
			}
			if(temp%10!=0) q.add(10*temp+temp%10-1);
			q.add(10*temp+temp%10);
			if(temp%10!=9) q.add(10*temp+temp%10+1);
		}
	}
}

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

using namespace std;
using ll = long long;

int a[25][25];
const int mod = 1e9 + 7;
int n;
ll dp[25][3000000];

int solve(int man, int mask){
    if (man == n){
        return 1;
    }
    if (dp[man][mask] != -1){
        return dp[man][mask];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++){
        if (!(mask & (1 << i)) && a[man][i]){
            ans += ll(solve(man + 1, mask | (1 << i)));
            ans %= mod;
        }
    }
    return dp[man][mask] = ans;
}

int main()
{
    memset(dp, -1, sizeof dp);
    cin >> n;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    cout << solve(0, 0);
    return 0;
}


Measured memory_bytes: 586240
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include <cstdint>
#define DEBUG
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long ll; using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define REP(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  int h,n;
  cin>>h>>n;
  int sum=0;
  REP(i,n){
    int a;
    cin>>a;
    sum+=a;
  }
  if(sum < h){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
long long int mod = 1000000007;
long long fast_exp(long long a,long long n,long long mod1)
    {
     
      if (n==0)return 1;
      else if (n==1)return a;
      if (n%2==0)return fast_exp((a*a)%mod1,n/2,mod1);
      else return (a*fast_exp((a*a)%mod1,n/2,mod1))%mod1;
    }
static bool is_power[1000001]={false};
void sieve()
{
    for (long long int c=2;c<=1000000;c++)
        if (is_power[c]==true)
            continue;
        else 
            for (long long int c1=c*c;c1<=1000000;c1=c1*c)
                is_power[c1]=true;
    return ;
}
   int gcd(int a,int b)
    {
        if (b<a)return gcd(b,a);
        else if (b%a==0)return a;
        else return gcd(b%a,a);
     
    }
int main()
{
    
    fast_io;
    int t;
    t=1;//cin >> t;
    for (;t>0;t--)
    {
       int k;
       cin >> k;
       long long res=0;
       for (int c=1;c<=k;c++)
        for (int c1=1;c1<=k;c1++)
            for (int c2=1;c2<=k;c2++)
                res+=gcd(gcd(c,c1),c2);

                cout << res << endl;


    }
    return 0;
}




Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(){
    int w,h,x,y,r,a,b,c,d;
    cin >> w >> h >> x >> y >> r;
    a = x - r;
    b = y + r;
    c = x + r;
    d = y - r;
    if(a >= 0 && b <= h && c <= w && d >= 0) {
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using SS = stringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + ( p ), ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

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

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

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

	string S;
	cin >> S;

	map< char, bool > exists;
	for_each( ALL( S ), [&]( const char c ){ exists[c] = true; } );

	cout << ( exists[ 'E' ] == exists[ 'W' ] && exists[ 'N' ] == exists[ 'S' ] ? "Yes" : "No" ) << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;
//abc179

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    ll a[n][2];
    rep(i,n){
        rep(j,2) cin>>a[i][j];
    }
    bool ok=0;
    rep(i,n-2){
        if(a[i][0]==a[i][1]&&a[i+1][0]==a[i+1][1]&&a[i+2][0]==a[i+2][1]) ok=1;

    }
    YN(ok);
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3636