akhauriyash/Code-Regression huggingface dataset:
//check check
#include<iostream>
#include<vector>
#include<algorithm>
#include<fstream>
#include<queue>
#include<cstring>

#define ll long long
#define pb(x) push_back(x)

using namespace std;

const int NMAX = 2005;
const ll MOD = 1e9+7;

ll v[NMAX],dp[NMAX],freq[NMAX];

int main()
{
    ll N,K,i,j;

    cin>>N>>K;

    for(i = 1 ; i <= N ; ++i)
        cin>>v[i];

    for(i = N ; i  ; --i)
    {
        freq[v[i]]++;
        ll sum = 0;
        for(j = 1 ; j < v[i] ; ++j)
            sum = (sum + freq[j])%MOD;
        dp[i] = sum;
    }

    ll rez = 0;
    for(i = 1 ; i <= N ; ++i)
    {
        ll sum = 0;
        for(j = 1 ; j < v[i] ; ++j)
            sum = (sum + freq[j])%MOD;
        ll prod = (K*(K-1)/2)%MOD;
        rez = (rez + ((dp[i]*K)%MOD + (prod*sum)%MOD)%MOD)%MOD;
    }
    rez %= MOD;
    cout<<rez;

    return 0;

}


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

int main(){
  long n,k,i,j,bf=0,af=0,div=1000000007;
  cin>>n>>k;
  int a[n];
  for(i=0;i<n;i++) cin>>a[i];

  for(i=0;i<n;i++){
    for(j=0;j<i;j++){
      if(a[i]>a[j]) bf++;
    }
    for(j=i+1;j<n;j++){
      if(a[i]>a[j]) af++;
    }
  }
  if(k%2){
    af=af*k%div;
    af=af*((k+1)/2);
    bf=bf*k%div;
    bf=bf*((k-1)/2);
  }
  else{
    af=af*(k+1)%div;
    af=af*(k/2);
    bf=bf*(k-1)%div;
    bf=bf*(k/2);
  }
  af=af%div;
  bf=bf%div;
  af+=bf;
  cout<<af%div<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a <= b) {
            System.out.println(a);

        } else {
            System.out.println(a - 1);
        }

    }
}

Measured memory_bytes: 22740
from collections import defaultdict
N = int(input())
D = [int(x) for x in input().split()]
M = int(input())
T = [int(x) for x in input().split()]

cnt = defaultdict(int)
for d in D:
  cnt[d] += 1
for t in T:
  cnt[t] -= 1

answer = 'YES' if min(cnt.values()) >= 0 else 'NO'
print(answer)

Measured memory_bytes: 41572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		String s = sc.next();

		if(3200 <= a) System.out.println(s);
		else System.out.println("red");

		sc.close();
	}
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int w,a,b;
	cin>>w>>a>>b;
	if(a<b&&b>(a+w))
	{
		cout<<abs(b-(a+w));
		}
		else if(a>b){
			cout<<abs(a-(b+w));
		}
		else if(a<=b<=(a+w)){
			cout<<"0";
			
		}
		return 0;
	
}

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

#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pii pair<ll, ll>
#define piii pair<ll, pair<ll, ll>>
#define debug(x) cout<<#x<<" = "<<x<<endl

using namespace std;
const int N = 100005;
ll t, n, m, k, q, a, b, x, y, ans, arr[N];
bool vis[N], valid;
ll mod = 998244353;
string s;

int main() {
    io;
    t = 1;
//    cin >> t;
    while (t--) {
        n = 5;
        for (int i = 1; i <= n; ++i) {
            cin >> arr[i];
            if (!arr[i])
                ans = i;
        }
        cout << ans << endl;
    }
    return 0;
}
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);


Measured memory_bytes: 3644
import math
X, N = map(int, input().split())
P = list(map(int, input().split()))
ans_1 = X
ans_2 = X
while True:
    if ans_1 not in P:
        print(ans_1)
        exit()
    ans_1 -= 1

    if ans_2 not in P:
        print(ans_2)
        exit()
    ans_2 += 1

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
int n,m,q;
int x,y,xx,yy;
char a[2005][2005];
int l1[2005][2005],l2[2005][2005];
int pt[2005][2005];
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)
		scanf("%s",a[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			pt[i][j]=pt[i][j-1]+pt[i-1][j]-pt[i-1][j-1]+a[i][j]-'0';
			int cnt1=0,cnt2=0;
			if(a[i][j]=='1')
			{
				if(a[i-1][j]=='1') cnt1++;
				if(a[i][j-1]=='1') cnt2++;
			}
			l1[i][j] = l1[i][j-1] + l1[i-1][j] - l1[i-1][j-1] + cnt1;
			l2[i][j] = l2[i][j-1] + l2[i-1][j] - l2[i-1][j-1] + cnt2;
		}
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d%d%d",&x,&y,&xx,&yy);
		int potn,edgen1,edgen2;
		potn = pt[xx][yy] - pt[xx][y-1] - pt[x-1][yy] + pt[x-1][y-1];
		edgen1 = l1 [xx][yy] - l1[xx][y-1] - l1[x][yy] + l1[x][y-1];
		edgen2 = l2[xx][yy] - l2[xx][y] - l2[x-1][yy] + l2[x-1][y];
		printf("%d\n",potn-edgen1-edgen2);
	}
}

Measured memory_bytes: 52864
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long mod = 1000000007;

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

	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if ((e - a) > k) {
		cout << ":(" << "\n";
	}
	else {
		cout << "Yay!" << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

ans = [None] * N

x = 0
for i, ai in enumerate(A):
    if i % 2 == 0:
        x += ai
    else:
        x -= ai

ans[0] = x

for i, ai in enumerate(A[:-1]):
    x = 2 * ai - ans[i]
    ans[i+1] = x

ans = [str(i) for i in ans]
print(" ".join(ans))

Measured memory_bytes: 18504
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, s;
    cin >> n >> k >> s;
    for(int i = 0; i < k; i++) {
        cout << s << ' ';
    }
    for(int i = k; i < n; i++) {
        if(s <= 2) {
            cout << s + 1 << " ";
        } else {
            cout << s - 1 << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 1280
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MOD = 1e9+7;

ll dp[44][1<<18];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, X, Y, Z;
    cin >> N >> X >> Y >> Z;
    ll ans = 1;
    for (int i = 0; i < N; i++) {
        ans *= 10;
        ans %= MOD;
    }
    int ng = 0;
    ng |= 1<<Z;
    ng |= 1<<(Y+Z);
    ng |= 1<<(X+Y+Z);
    int mask = 1<<18; mask--;
    dp[0][1] = 1;
    for (int n = 0; n < N; n++) for (int state = 0; state < mask; state++) {
        for (int i = 1; i <= 10; i++) {
            int ns = ((state<<i)&mask)+1;
            if ((ns&ng) == ng) continue;
            dp[n+1][ns] += dp[n][state];
            dp[n+1][ns] %= MOD;
        }
    }
    for (int i = 0; i < mask; i++) {
        ans -= dp[N][i];
        ans %= MOD;
    }
    cout << (ans+MOD)%MOD << endl;
    return 0;
}


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

int main() {

    string S;
    cin >> S;
    if(S == "SUN"){
        cout << 7;
    }else if(S == "MON"){
        cout << 6;
    }else if(S == "TUE"){
        cout << 5;
    }else if(S == "WED"){
        cout << 4;
    }else if(S == "THU"){
        cout << 3;
    }else if(S == "FRI"){
        cout << 2;
    }else{
        cout << 1;
    }
    return 0;
}

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

#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

bool Compare(pair<ll,ll> p, pair<ll,ll> q){ return p.fi > q.fi; }

int main(){
    ll n, m; cin >> n >> m;
    ll a[n]; rep(i,0,n) cin >> a[i];
    vector<pair<ll, ll>> p;
    rep(i,0,m){
        ll b, c;
        cin >> b >> c;
        p.pb(mp(c,b));
    }
    sort(all(p), Compare);
    sort(a, a+n);

    ll idx1 = 0, idx2 = 0;
    while(1){
      	//cout << p[idx2].fi << " " << p[idx2].se << endl;
        rep(i,0,p[idx2].se) if(a[idx1] < p[idx2].fi) a[idx1++] = p[idx2].fi;
        else break;
      	idx2++;
        if(idx1 == n || idx2 == m) break;
    }

    ll ans = 0;
    rep(i,0,n){
      	//cout << a[i] << endl;
      	ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3316
n = int(input())
A = [list(map(int,input().split())) for _ in range(n)]
X = [0,0,0]
for i in range(n):
    if A[i][2]>0:
        X = A[i]
        break


for x in range(101):
    for y in range(101):
        h = X[2] + abs(x-X[0]) + abs(y-X[1])
        flag = 1
        for i in range(n):
            if A[i][2] != max(h - abs(x-A[i][0]) - abs(y-A[i][1]),0):
                flag = 0
        if flag == 1:
            print(x,y,h)

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

int main(void){
	int i,v,d,ans;
	int fib[1012];

	while(cin>>v>>d){
		for(i=fib[0]=2,fib[1]=3;i<v;fib[i]=(fib[i-1]+fib[i-2])%1001,i++);
		sort(fib,fib+v);
		for(i=ans=1;i<v;i++) if(fib[i] - fib[i-1] >= d) ans++;
		cout<<ans<<endl;
	}

	return 0;
}

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

using namespace std;

const int INF = 100000000;

int n;
vector<int> data;

void solve(int n, int p){
  if(n == 0){
    cout << data[0];
    for(int i=1;i<data.size();i++){
      cout << ' ' << data[i];
    }
    cout << endl;
    return;
  }
  for(int i=min(n, p);i>0;i--){
    data.push_back(i);
    solve(n-i, i);
    data.pop_back();
  }
}

main(){
  while(cin >> n && n){
    solve(n, INF);
  }
  return 0;
}

Measured memory_bytes: 0
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A = list(map(int, readline().split()))
    A.sort()

    print(A[2] - A[0])

    return


if __name__ == '__main__':
    main()


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

int main() {
  int map[101];
  for (int i = 0; i <= 6; i++) {
    int low = pow(2, i); int high = pow(2, i+1);
    for (int j = low; j < min(high, 101); j++) {
      map[j] = low;
    }
  }
  int n;
  cin >> n;
  cout << map[n];
  
  return 0;
}


Measured memory_bytes: 256
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, m, n) for (int i = m; i < n; i++)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

struct Card {
    char symbol;
    int value;
};

void BubbleSort(vector<Card> &c, int N){
    bool flag = true;
    while(flag){
        flag = false;
        repr(i, N - 2){
            if(c.at(i + 1).value < c.at(i).value){
                swap(c.at(i + 1), c.at(i));
                flag = true;
            }
        }
    }
}

void SelectionSort(vector<Card> &c, int N){
    int min;
    rep(i, N - 1){
        min = i;
        rep2(j, i, N){
            if(c.at(j).value < c.at(min).value){
                min = j;
            }
        }

        if(i != min){
            swap(c.at(i), c.at(min));
        }
    }
}

void printout(vector<Card> c, int N){
    rep(i, N){
        if(i > 0){
            cout << " ";
        }
        cout << c.at(i).symbol << c.at(i).value;
    }
    cout << endl;
}

int main()
{
    bool flag = true;
    int N;
    cin >> N;
    vector<Card> c1(N),c2(N);

    rep(i, N){
        cin >> c1.at(i).symbol >> c1.at(i).value;
    }
    c2 = c1;

    BubbleSort(c1,N);
    SelectionSort(c2,N);

    printout(c1, N);
    cout << "Stable" << endl;
    printout(c2, N);

    rep(i, N){
        if(c1.at(i).symbol != c2.at(i).symbol){
            flag = false;
        }
    }

    if(flag){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;

inline int updiv(int a,int b){ return (a + b - 1) / b; }
 
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    int a, b;
    cin >> a >> b;

    if(b % a == 0){
        cout << a + b << '\n';
    }else{
        cout << b - a << '\n';
    }

    return (0);
}

Measured memory_bytes: 3660
'use strict'
const gcd = (m, n) => {
  if (n === 0) {
    return m
  } else {
    return gcd(n, m % n)
  }
}
function main(input) {
  input = input.split('\n').map(v => v.split(' ').map(v => ~~v))
  const n = input[0][0]
  const m = input[1].sort((a, b) => a - b)
  const sa = [0]
  let ans = m[0]
  for (let i = 1; i < n; i++) {
    ans = gcd(ans, m[i])
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 28704
// ABC 085

// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  input.splice(0,1); //先頭削除

  // 重複を削除したリスト
  var arr = input.filter(function (x, i, self) {
    return self.indexOf(x) === i;
  });

  console.log(arr.length-1) //要素数の入力分マイナス１をする
}

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


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

using namespace std;

typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long double ld;

const int inf = 1e9;
const ll inf64 = 1e18;

struct RMQ {
    vector<int> a; // [0, n)
    int n, LOG;
    vector<int> _log;
    vector<vector<pii>> rmq;

    RMQ(const vector<int>& aa) {
        a = aa;
        n = (int) a.size();
        LOG = 0;
        while ((1 << LOG) <= n) LOG++;
        _log.resize(n + 1);
        for (int i = 2; i <= n; i++) {
            _log[i] = _log[i - 1] + 1;
            if ((1 << _log[i]) > i) _log[i]--;
        }
        rmq.resize(LOG, vector<pii>(n));
        for (int i = 0; i < n; i++) {
            rmq[0][i] = {a[i], i};
        }
        for (int j = 1; j < LOG; j++) {
            for (int i = 0; i + (1 << j) <= n; i++) {
                rmq[j][i] = min(rmq[j - 1][i], rmq[j - 1][i + (1 << (j - 1))]);
            }
        }
    }

    pii get_min(int l, int r) const {
        int lg = _log[r - l + 1];
        return min(rmq[lg][l], rmq[lg][r - (1 << lg) + 1]);
    }
};

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    vector<int> p(n);

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

    vector<int> pr(n), sf(n);

    for (int i = 0; i < n; i++) {
        pr[i] = 1;
        if (i > 0 && p[i] > p[i - 1]) {
            pr[i] = pr[i - 1] + 1;
        }
    }

    for (int i = n - 1; i >= 0; i--) {
        sf[i] = 1;
        if (i + 1 < n && p[i] < p[i + 1]) {
            sf[i] = sf[i + 1] + 1;
        }
    }

    int any = 0;
    set<pii> qq;

    RMQ mn(p);

    vector<int> pp(n);
    for (int i = 0; i < n; i++) {
        pp[i] = -p[i];
    }

    RMQ mx(pp);

    for (int i = k - 1; i < n; i++) {
        if (pr[i] >= k) {
            any = 1;
//            cout << "? " << i << "\n";
            continue;
        }
        int ql, qr;
        {
            int bl = i - pr[i];
            int br = i;
            int bm;
            while (br - bl > 1) {
                bm = (bl + br) / 2;
                if (bm == i || -mx.get_min(i - k + 1, bm).first < p[bm + 1]) {
                    br = bm;
                } else {
                    bl = bm;
                }
            }
            qr = br;
        }
        {
            int bl = i - k + 1;
            int br = i - k + 1 + sf[i - k + 1];
            int bm;
            while (br - bl > 1) {
                bm = (bl + br) / 2;
                if (bm == i - k + 1 || mn.get_min(bm, i).first > p[bm - 1]) {
                    bl = bm;
                } else {
                    br = bm;
                }
            }
            ql = bl;
        }
//        cout << i << " : " << ql << " .. " << qr << "\n";
        if (ql < qr) {
            qq.insert({ql, qr});
        }
    }

    cout << any + (int) qq.size() << "\n";

    return 0;
}


Measured memory_bytes: 72164
N = int(input())
Primes = [True for i in range(55556)]
for i in range(2, 55556):
    if Primes[i] == True:
        num = i * 2
        while num <= 55555:
            Primes[num] = False
            num += i

count, Ans = 0, []
for i in range(2, 55556):
    if Primes[i] == True and i % 5 == 1:
        Ans.append(i)
        count += 1
    if count == N:
        break

print(" ".join(map(str, Ans)))

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

const int MAX = 1000;

int N;
double T, A, H[MAX];

double abs(double d) {
  if (d >= 0) return d;
  else return -d;
}

int main() {

  cin >> N >> T >> A;
  for (int i = 0; i < N; i++)
    cin >> H[i];

  int ans = 0;
  double diff = 100000;
  for (int i = 0; i < N; i++) {
    double r = abs(A - (T - 0.006*H[i]));
    if (r < diff) {
      ans = i+1;
      diff = r;
    }
  }

  cout << ans << endl;

}

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

bool dp[100010];
int a[101];

void solve()
{
  int n, k; cin >> n >> k;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  
  for (int i = 0; i <= k; i++)
  {
    for (int j = 0; j < n; j++)
    {
      if (i - a[j] >= 0)
      {
        if (dp[i - a[j]] == false)
        {
          dp[i] = true;
          break;
        }
      }
      else break;
    }
  }
  
  if (dp[k]) cout << "First";
  else cout << "Second";
  cout << endl;
}

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

Measured memory_bytes: 384
// template
#include <bits/stdc++.h>
using namespace std;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i)
typedef long long int ll;
#define SIZE(x) ((int)(x).size())
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
typedef pair<long long, long long> LP;
#define out cout
#define in cin

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    in >> n;
    if (int(n / 10) == 9 or n % 10 == 9){
        out << "Yes" << endl;
    }
    else{
        out << "No" << endl;
    }
}


Measured memory_bytes: 256
import scala.io.StdIn._

object Helpers {
  def readIntLine = readLine.split(" ").map(_.toInt)
  def readInts(n: Int) = Array.fill(n)(readInt)

  def splitDigits(i: Int): Seq[Int] = i.toString.map(_.asDigit)

  def log[A](x: A): A = {println(x); x}

  implicit class IntImplicits(val i: Int) {
    def isEven = i % 2 == 0
    def isOdd = !isEven

    def ** (exp: Int): Int = scala.math.pow(i, exp).intValue
  }

  implicit class LongImplicits(val i: Long) {
    def isEven = i % 2 == 0
    def isOdd = !isEven

    def ** (exp: Long): Long = scala.math.pow(i, exp).longValue
  }

  def mycomb[T](n: Int, l: List[T]): List[List[T]] =
    n match {
      case 0 => List(List())
      case _ => for(el <- l;
                sl <- mycomb(n-1, l dropWhile { _ != el } ))
                yield el :: sl
  }
  
  def comb[T](n: Int, l: List[T]): List[List[T]] = mycomb(n, l.distinct)
}

object Main extends App {
  import Helpers._

  val n = readInt
  val ss = Array.fill(n)(readLine)

  println(ss.distinct.length)
}



Measured memory_bytes: 74376
N,K = gets.split.map(&:to_i)
$ns = (0..N).map{ {} }
$es = []
(N-1).times{
  a,b = gets.split.map(&:to_i)
  $ns[a][b] = $ns[b][a] = 1
  $es << [a,b]
}

def cnt(f,n,k)
  return 0 if k < 0
  return 1 if k == 0
  a = 1
  $ns[n].keys.select{ |m| m != f }.each{ |m| a += cnt(n,m,k-1) }
  # 1 + $ns[n].keys.select{ |m| m != f }.reduce(0){ |a,m| a + cnt(n,m,k-1) }
  a
end


if K%2 == 0
  p N - (1..N).map{ |n|
    ms = $ns[n].keys
    ms.map{ |m| cnt(n,m,K/2-1) }.reduce(0,:+) + 1
  }.max
else
  p N - $es.map{ |a,b|
    cnt(a,b,K/2) + cnt(b,a,K/2)
  }.max
end


Measured memory_bytes: 5756
n,m=map(int,input().split())
par=[-1 for _ in range(n)]
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)

    if x != y:
        x,y=y,x
    else:
        return
    par[x]+=par[y]

    par[y] = x
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    unite(a,b)

ans=0
for i in par:
    if i<0:
        ans+=1
print(ans-1)

Measured memory_bytes: 10780
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll K;
int A[MAX_N];

void solve() {
	cin >> N >> K;
	rep(i, 0, N) {
		cin >> A[i];
	}
	ll res = 0;
	rep(i, 0, N) {
		rep(j, i + 1, N) {
			if(A[i] > A[j]) res++;
		}
	}
	MUL(res, K);
	rep(i, 0, N) {
		ll tmp = 0;
		rep(j, 0, N) {
			if(A[i] > A[j]) tmp++;
		}
		MUL(tmp, (K * (K - 1) / 2) % mod);
		ADD(res, tmp);
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
from math import factorial
from sys import exit, stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
p_n = factorial(N)
p_m = factorial(M)
NUM = 10**9+7
if abs(N-M)==0:
    ans = 2*p_n*p_m
elif abs(N-M)==1:
    ans = p_n*p_m
else:
    ans = 0
print(ans%NUM)

Measured memory_bytes: 5312
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

	int num[100001];
	memset(num, 0, sizeof(num));
	for (auto i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b;
		++num[a];
		++num[b];
	}

	auto result = "YES";
	for (auto i = 1; i <= N; ++i)
	{
		if (num[i] % 2 != 0)
		{
			result = "NO";
			break;
		}
	}
	cout << result << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>

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

int main() {
  vector<int> a(10000), b(10000);

  rep(i,10000) cin >> a[i] >> b[i];

  rep(i,10000){
    if(a[i] == 0 && b[i] == 0) return 0;
    if(a[i] > b[i]) cout << b[i] << " " << a[i] << endl;
    else cout << a[i] << " " << b[i] << endl;
  }
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll A,B;
int K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B>>K;
	FOR(i,K) {
		if(i%2==0) {
			B+=A/2;
			A/=2;
		}
		else {
			A+=B/2;
			B/=2;
		}
	}
	cout<<A<<" "<<B<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

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

  string A;
  cin >> A;
  int n[4];
  rep (i, 0, 4) {
    n[i] = A[i] - '0';
  }
 
  int x[] = {1, -1};
  int op[3];
  int num;
  string ans;
  rep(i, 0, 2) {
    op[0] = x[i];
    rep(j, 0, 2) {
      op[1] = x[j];
      rep(k, 0, 2) {
        op[2] = x[k];
        num = n[0] + n[1] * op[0] + n[2] * op[1] + n[3] * op[2];
        if (num == 7) {
          cout << n[0];
          if (op[0] < 0)
            cout << '-';
          else
            cout << '+';
          cout << n[1];
          if (op[1] < 0)
            cout << '-';
          else
            cout << '+';
          cout << n[2];
          if (op[2] < 0)
            cout << '-';
          else
            cout << '+';
          cout << n[3] << "=7" << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  vector<int> mods(s.size());
  mods[s.size() - 1] = s.back() - '0';
  int p = 10;
  for (int i = s.size() - 2; i >= 0; i--) {
    int d = s[i] - '0';
    mods[i] = (p * d + mods[i + 1]) % 2019;
    p = p * 10 % 2019;
  }

  vector<int> cnts(2019, 0);
  cnts[0]++;
  for (int i = 0; i < mods.size(); i++) {
    cnts[mods[i]]++;
  }

  long long ans = 0;
  for (auto c : cnts) {
    ans += c * (c - 1) / 2;
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 4328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int N = in.nextInt(), A = in.nextInt();
			int[] xn = in.nextIntArray(N);
			int X = A;
			for (int i = 0; i < N; i++) {
				X = Math.max(X, xn[i]);
			}

			long[][][] dp = new long[N+1][N+1][N*X+1];
			dp[0][0][0] = 1;

			for (int i = 1; i <= N; i++) {
				for (int j = 0; j <= N; j++) {
					for (int k = 0; k <= N*X; k++) {
						int prevJ = j - 1;
						int prevK = k - xn[i-1];

						if (prevJ < 0 || prevK < 0) {
							dp[i][j][k] = dp[i-1][j][k];
						} else {
							dp[i][j][k] = dp[i-1][j][k] + dp[i-1][prevJ][prevK];
						}
					}
				}
			}

			long ans = 0;
			for (int k = 1; k <= N; k++) {
				ans += dp[N][k][k*A];
			}
			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			Console.WriteLine(Math.Min(vs[0] * vs[1], vs[2]));
		}
	}
}


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

double AB(double num){
	if(num<0)num*=(-1);
	return num;
}

int main(){
	int n,h,m;
	double hh,mm,d;
	for(cin>>n;n>0;n--){
		scanf("%d:%d",&h,&m);
		
		
		mm=360.0*(double)m/60.0;
		hh=360.0*((double)h*60.0+(double)m)/720.0;
		d=AB(hh-mm);
		if(d>180)d=360-d;
		if(d<30)printf("alert\n");
		else if(d>=90)printf("safe\n");
		else printf("warning\n");
	}
	
	return 0;
}


Measured memory_bytes: 1200
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = long.Parse(line[0]);
        var b = long.Parse(line[1]);
        var n = long.Parse(line[2]);
        getAns(a, b, n);

    }
    static void getAns(long a, long b, long n)
    {
        long x;
        if (n >= b - 1) x = b - 1;
        else x = n;
        var ans = a * (x % b) / b;
        Console.WriteLine(ans);
    }
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

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

const int dy[2][7] = {
	{  1,  0, -1, -1, -1,  0,  0},
	{  1,  1,  0, -1,  0,  1,  0}
};

inline int cnv(int x) { return x + 150; }
inline bool in_range(int x, int mn, int mx) { return mn <= x && x < mx; }

int sx, sy, gx, gy, n, lx, ly;
bool board[300][300];

struct State {
	int x, y, t, ignore;
	bool operator > (const State& a) const { return ignore > a.ignore; }
};

int dst[300][300][7];

int djk() {
	memset(dst, -1, sizeof(dst));
	
	priority_queue< State, vector< State >, greater< State > > que;
	que.push(State{sx, sy, 0, 0});
	
	dst[cnv(sy)][cnv(sx)][0] = 0;
	
	while (!que.empty()) {
		State s = que.top(); que.pop();
		
		int x = s.x, y = s.y, t = s.t, ignore = s.ignore;
		
		if (dst[cnv(y)][cnv(x)][t] < ignore) continue;
		
		if (x == gx && y == gy) return ignore;
		
		int d = ((int)abs(x * y * t)) % 6;
		int nt = (t + 1) % 6;
		
		for_(dd,0,7) {
			int nx = x + dx[dd], ny = y + dy[abs(x) & 1][dd];
			
			bool flag = false;
			
			if (!in_range(nx, -lx, lx + 1) || !in_range(ny, -ly, ly + 1)) flag = true;
			
			if (!flag && board[cnv(ny)][cnv(nx)]) flag = true;
			
			int add = (d == dd) ? 0 : 1;
			
			if (d == dd && flag) {
				nx = x;
				ny = y;
				flag = false;
				add = 1;
			}
			
			if (!flag) {
				int& nx_dst = dst[cnv(ny)][cnv(nx)][nt];
				
				if (nx_dst == -1 || nx_dst > ignore + add) {
					nx_dst = ignore + add;
					que.push(State{nx, ny, nt, ignore + add});
				}
			}
		}
	}
	
	return -1;
}

int main() {
	cin >> sx >> sy >> gx >> gy;
	cin >> n;
	
	memset(board, 0, sizeof(board));
	
	for_(i,0,n) {
		int x, y;
		cin >> x >> y;
		board[cnv(y)][cnv(x)] = 1;
	}
	
	cin >> lx >> ly;
	
	cout << djk() << endl;
}

Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int k;
    cin>>k;
    int cur=0;
    for(int i=1;i<=k;i++){
        cur=cur*10+7;
        cur%=k;
        if(cur==0){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3652
n = input()
n = int(n[-1])

if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
  print("hon")
elif n == 0 or n == 1 or n == 6 or n == 8:
  print("pon")
else:
  print("bon")

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

import static java.lang.Integer.parseInt;

/**
 * Sum of 4 Integers
 */
public class Main {

	static int N = 4;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);

			int[][] dp = new int[N + 1][n + 1];
			dp[0][0] = 1;

			for (int i = 1; i <= N; i++) {
				for (int j = 0; j <= 9; j++) {
					for (int k = j; k <= n; k++) {
						dp[i][k] += dp[i - 1][k - j];
					}
				}
			}

			System.out.println(dp[N][n]);
		}
	}
}


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

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

    return dividend / divisor;
}

int main(){
    int n,m;
    cin>>n>>m;
    long long ans=0;
    if(n==1&&m==1)cout<<ans<<endl;
    else{
        ans+=combination(n,2);
        ans+=combination(m,2);
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(m);
  REP(i,n) cin >> a[i];
  REP(i,m) cin >> b[i];
  bool flag1 = false;

  REP(i,n-m+1) {
    REP(j,n-m+1) {
      bool flag2 = true;
      REP(k,m){
        string s = a[i+k].substr(j,m);
        if(b[k] != s) flag2 = false;
      }
      if(flag2) flag1 = true;
    }
  }
  YesorNo(flag1);
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    String line = scanner.next();
    int n = line.length();
    long sum = 0;
    for(int i=0;i<n;i++){
      int digit = Integer.parseInt(line.substring(i,i+1));
      int j = n - i - 1; // number of operators in the right side
      if(j > 0)
      	sum += digit * pow(2,n-2) * (pow(5,j) - 1) / 4;
      sum += digit * pow(2,i) * pow(10,j);
    }
    System.out.println(sum);
  }
  
  private static long pow(int a, int n){
    if(n == 0){
      return 1;
    }else{
      int half = n / 2;
      int b = n & 1;
      long halfpower = pow(a, half);
      if(b == 0){
        return halfpower * halfpower;
      }else{
        return halfpower * halfpower * a;
      }
    }
  }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl);
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%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);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    string s;
    cin >> s;
    s += s.back();
    int n = s.size();
    vector<string> ss;

    string prev = "";
    prev += s[0];
    ss.emplace_back(prev);

    for(int i = 1; i < n; ++i){
        string now = "";
        now += s[i];
        int j = 0;
        while(prev == now){
            ++j;
            now += s[i+j];
        }
        i += j;
        ss.emplace_back(now);
        // eee(ss);
        prev = now;
    }

    ppp(ss.size()-1);




    return 0;
}


Measured memory_bytes: 10996
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)



int main(){
    string s;
    int res;
    cin >> s;
    res = count(s.cbegin(), s.cend(), '1');
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
x = int(input())

if 1800 <= x <= 1999:
    print(1)
elif 1600 <= x <= 1799:
    print(2)
elif 1400 <= x <= 1599:
    print(3)
elif 1200 <= x <= 1399:
    print(4)
elif 1000 <= x <= 1199:
    print(5)
elif 800 <= x <= 999:
    print(6)
elif 600 <= x <= 799:
    print(7)
elif 400 <= x <= 599:
    print(8)

Measured memory_bytes: 9184
# 入力される配列の長さ
 array_length = gets.to_i

# #入力される配列
 array_value = gets.chomp.split(" ")

array_value_for_bubble = array_value.clone
array_value_for_selection = array_value.clone


# puts array_value_for_bubble.object_id
# puts array_value_for_selection.object_id
#stable or not judgement function
def stableOrNotJudgement(before_array, after_array, array_length)
    #0でstable 1でnot stable
    result_flag = 0
    
    0.upto(array_length - 2) do |i|
        array_val_i = after_array[i]
        array_val_i_plus_1 = after_array[i + 1]
        
        if array_val_i.split("")[1].to_i == array_val_i_plus_1.split("")[1].to_i
            result_flag = before_array.index(array_val_i) > before_array.index(array_val_i_plus_1) ? 1 : 0
            
        end
        
        break if result_flag == 1
    end
    
    result = result_flag == 1 ? "Not stable" : "Stable"
    result_flag = 0
    return result
    
    
end

# bubble sort function
def BubbleSort(bubble_input_array, bubble_input_array_length)
    for i in 0..(bubble_input_array_length - 1)
        (bubble_input_array_length - 1).downto(i + 1) do |j|
            # インデックスが小さい方の値が小さい場合には値を交換
            if bubble_input_array[j].split("")[1].to_i < bubble_input_array[j - 1].split("")[1].to_i
                bubble_input_array[j], bubble_input_array[j - 1] = bubble_input_array[j - 1], bubble_input_array[j]
                
            end
        end
    end
end

BubbleSort(array_value_for_bubble, array_length)
puts array_value_for_bubble.join(" ")
puts stableOrNotJudgement(array_value, array_value_for_bubble, array_length)

#selection sort function
def SelectionSort(selection_input_array, array_length)
    for i in 0..(array_length - 1)
    minj = i
        for j in i..(array_length - 1)
            if selection_input_array[j].split("")[1].to_i < selection_input_array[minj].split("")[1].to_i
                minj = j
            end
            
        end
        selection_input_array[i],selection_input_array[minj] = selection_input_array[minj],selection_input_array[i] 
    end
    
end



SelectionSort(array_value_for_selection, array_length)
puts array_value_for_selection.join(" ")
puts stableOrNotJudgement(array_value, array_value_for_selection, array_length)


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 9223372036854775807

ull GCD (ull c,ull d){
    if(c<d)
        swap(c, d);
    ull r = c % d;
    if(r ==0)
        return d;
    else
        return GCD(d, r);
}

int main(void)
{
    ull a, b, c, d;
    cin >> a >> b >> c >> d;

    //c,dのGCDを使って最小公倍数を求める
    ull cd = c / GCD(c, d) * d;
    //bまでのcとdの割れる数の個数
    ull b_c = b / c;
    ull b_d = b / d;
    ull b_cd = b / cd;

    //a-1までのcとdの割れる数の個数
    ull a_c = (a-1) / c;
    ull a_d = (a-1) / d;
    ull a_cd = (a-1) / cd;

    //a以上の数の中の割り切れる数合計を求めた
    ull t_ans = (b_c + b_d - b_cd) - (a_c + a_d - a_cd);
    //a〜b間の個数
    ull dis = b - a + 1;

    cout << dis - t_ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string S, T; int chain;
int main() {
	while (true) {
		getline(cin, S);
		S += ' ';
		T = "";
		if (S == "END OF INPUT ") { break; }
		for (int i = 0; i < S.size(); i++) {
			if (S[i] != ' ') { chain++; }
			else { T += to_string(chain); chain = 0; }
		}
		cout << T << endl;
	}
}

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

using namespace std;
int main(){
	int x, n;
	cin >> x >> n;

	int arr[n];
	int i,j,k;

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


	for(i = x, j = x; i <= 101, j >= -1; i++, j--){
		int temp_i = 0, temp_j = 0;
		for(k = 0; k < n; k++){
			if(arr[k] == i)
				temp_i = 1;
			if(arr[k] == j)
				temp_j = 1;
		}

		if(temp_i == 0 && temp_j == 1){
			cout << i;
			break;
		}
		else if(temp_i == 1 && temp_j == 0){
			cout << j;
			break;
		}
		else if(temp_i == 0 && temp_j == 0){
			if(i < j)
				cout << i;
			else
				cout << j;

			break;
		}

	}
}


Measured memory_bytes: 3636
s=input()
l=len(s)

i=0
while i<l:
  if i%2!=0:
    if s[i]=='R':
      print('No')
      exit()
  else:
    if s[i]=='L':
      print('No')
      exit()
      
    
  i=i+1        
print('Yes')


Measured memory_bytes: 3064