akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n,m, ans = 0,lmax,rmin;
	string s;
	bool flag = true;

	cin >> n >> m;

	lmax = 0;
	rmin = n;

	vector<pair<ll, ll>> a(m);

	forll(i, 0, m)
		cin >> a[i].first >> a[i].second;

	forll(i, 0, m)
	{
		if (lmax < a[i].first-1)
			lmax = a[i].first-1;
		if (rmin > a[i].second - 1)
			rmin = a[i].second - 1;
	}

	forll(i, 0, n)
	{
		if (i >= lmax && i <= rmin)
			ans++;
	}

	cout << ans;

}


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

int main(){

    int n;

    cin >> n;

    vector<string> w(n);

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

        cin >> w[i];

    }

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

        if(w[i-1][w[i-1].length() - 1] != w[i][0]){

            cout << "No" << endl;
            return 0;

        }

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

            if(w[i] == w[j]){

                cout << "No" << endl;
                return 0;

            }

        }

    }

    cout << "Yes" << endl;

    return 0;

}

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

int main(void){
    int n, m;
    cin >> n >> m;
    int l[m], r[m];
    int MAXl = 0, MINr = 10000000;
    for(int i = 0; i < m; i++){
        cin >> l[i] >> r[i];
        MAXl = max(l[i], MAXl);
        MINr = min(r[i], MINr);
    }
    int ans = MINr - MAXl + 1;
    if(ans < 0)
        ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int n,mi=10000000,ma=-10000000;
    long long sum=0;
    cin >> n;
    int i,b;
    for(i=0;i<n;i++){
        cin >> b;
        mi=min(mi,b);
        ma=max(ma,b);
        sum+=b;
    }
    cout << mi << " " << ma << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int a, b, c; cin >> a >> b >> c;
	if (b - a == c - b)cout << "YES" << "\n";
	else cout << "NO" << "\n";

	return 0;
}

Measured memory_bytes: 256
import numpy as np
import queue
H, W = map(int, input().split())
S = [input() for _ in range(H)]
reach = [[False] * W for i in range(H)]
step = np.ones((H, W)) * (-1)
m = 0
q = queue.Queue()

for sh in range(H):
    for sw in range(W):
        if False and S[sh][sw] == '#':
            pass
        elif ((sh - 1 >= 0 and S[sh -1][sw] != '#') and  (sh + 1 < H and S[sh +1][sw] != '#')) and ((sw - 1 >= 0 and S[sh][sw-1] != '#') and  (sw + 1 < W and S[sh][sw + 1] != '#')):
            pass
        else:
            reach = [[False] * W for i in range(H)]
            step = np.ones((H, W)) * (-1)
            q.put((sw, sh, 0))
            while not q.empty():
                x, y, s = q.get()
                if x < 0 or W <= x or y < 0 or H <= y:
                    pass
                elif reach[y][x]:
                    pass
                elif S[y][x] == '#':
                    pass
                else:
                    reach[y][x] = True
                    step[y, x] = min(s, step[y, x]) if step[y, x] != -1 else s

                    q.put((x+1, y, s+1))
                    q.put((x-1, y, s+1))
                    q.put((x, y-1, s+1))
                    q.put((x, y+1, s+1))

            m = max(m, np.max(step))

print(int(m))


Measured memory_bytes: 14172
#include <iostream>
#define LL long long
using namespace std;

LL x;

int main(){
    cin >> x;

    LL res=2*(x/11);
    x-=11*(x/11);
    if (x>0) res++;
    if (x>6) res++;
    cout << res << "\n";
    return 0;
}


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

#define dbl double
#define pb push_back
#define SQ(x) (x)*(x)
#define ll long long
#define ull unsigned long long
#define vc vector
#define F first
#define S second
#define in ll
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(x) x.begin(), x.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt...) (0)

using namespace std;

ll c[100][100];

int n, p;
int a[2] = {0, 0};

int main() {
    c[0][0] = 1;
    for (int i = 1; i < 100; i++) {
        c[i][0] = 1;
        for (int j = 1; j < i; j++) {
            c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
        }
        c[i][i] = 1;
    }

    cin >> n >> p;
    loop(i, n) {
        int e;
        cin >> e;
        a[e % 2]++;
    }

    ll ans = 0;
    for (int i = p; i <= a[1]; i += 2) {
        ans += c[a[1]][i];
    }

    ans *= (1ll << (a[0]));
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,c,d,e,f,g,h;
cin>>a;

long long sum=0;
for(long long i=1;i<=a;i++)
{
if(i%3==0||i%5==0)
continue;
else
    sum+=i;


}


cout<<sum;
}



Measured memory_bytes: 3624
N = int(input())
S = input()

cur = None

pat = 0
for c in range(N):
    if S[c] == cur:
        continue
    elif cur != None:
        cur = S[c]
        pat += 1
    elif c == N-1:
        pat += 1
    elif S[c] != cur:
        cur = S[c]
        pat += 1
print(pat)

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

int main(){
  constexpr int TBC= INT_MAX;
  constexpr int Vmax_1= 1000;
  int N,W;
  cin >> N >> W;
  const int Vmax_N= N* Vmax_1;

  vector<pair<int, int>> data(N);
  int buf_w, buf_v;
  for(int i=0; i<N; i++){
    cin >> buf_w >> buf_v;
    data.at(i)= make_pair(buf_w, buf_v);
  }

  vector<int> dp(Vmax_N+ 1, TBC);
  dp.at(0)= 0;
  for(auto [weight, value]:data){
    for(int v=Vmax_N; v>= value; v--){
      if(dp.at(v- value) != TBC && dp.at(v- value)+ weight <= W){
        dp.at(v)= min(dp.at(v), dp.at(v- value)+ weight);
      }
    }
  }

  int ans= 0;
  for(int v=Vmax_N; v>=0; v--){
    if(dp.at(v) <= W){
      ans= v;
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3764
#include <iostream>

using namespace std;

int main()
{
    int x[]={2,3,4,5,6,7,8,9,10,11,12,13,1};
    int i=0;
    int m,n,o,p;
    cin>>m>>n;
    for (i=0;i<13;i++){
        if (x[i]==m)
            o=i;}
    for (int j=0;j<13;j++){
        if (x[j]==n)
            p=j;}
    if (o>p)
        cout<<"Alice";
    else if (o==p)
        cout<<"Draw";
    else if (p>o)
        cout<<"Bob";
    return 0;
}


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

int main(){
    int n, cnt, z;
    vector<int> v;
    scanf("%d", &n);

    for (int i = 0; i < n; i++){
        scanf("%d", &z);
        z--;
        v.push_back(z);
    } 

    int now = 0;
    for (int i = 0; i <= n; i++){
        if (now == 1){
            printf("%d\n" ,i);
            break;
        }

        if (i == n){
            printf("-1\n");
            break;
        }
        now = v.at(now);
    }

    return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;

const int V_MAX=100000;
const int E_MAX=100000;

struct edge{
	int from;
	int to;
	bool operator<( const edge& right ) const {
        return from == right.from ? to < right.to : from < right.from;
    }
};

vector<int> G[V_MAX];
bool used_v[V_MAX]={};
//bool used_e[E_MAX][E_MAX]={};
vector<int> pre(V_MAX,INT_MAX);
vector<int> low(V_MAX,INT_MAX);
vector<edge> result;
int order;

void dfs(int s,int p){
	if(used_v[s]==true){return;}
	used_v[s]=true;
	pre[s]=order;
	low[s]=order;
	order++;
	for (int i=0;i<G[s].size();i++){
		//used_e[s][G[s][i]]=true;
		if(!used_v[G[s][i]]){
			dfs(G[s][i],s);
			low[s]=min(low[s],low[G[s][i]]);
		}else if(G[s][i]!=p){
			low[s]=min(low[s],pre[G[s][i]]);
		}
	}
	if(!(s==0 && p==0) && low[s]>pre[p]){
		edge e;
		e.from=min(s,p);
		e.to=max(s,p);
		result.push_back(e); 
	}
}

int main(){
	int V,E,s,t;
	cin>> V >> E;
	for (int i=0;i<E;i++){
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	
	order=0;
	dfs(0,0);
	
	sort(result.begin(),result.end());
	for(int i=0;i<result.size();i++){
		cout << result[i].from << " " << result[i].to << endl;
	}
	/*
	for(int i=0;i<V;i++){
		cout << pre[i] << " ";
	}
	cout << endl;
	
	for(int i=0;i<V;i++){
		cout << low[i] << " ";
	}
	*/
	return 0;
}

Measured memory_bytes: 5752
# デバッグ用
GBN_DEBUG = False
GBN_DEBUG = True
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)

#本体ここから

#S = input()
#N = int(input())
#S, T = input().split()
N, K = map(int, input().split())
#W = [input() for _ in range(N)]
l = list(map(int, input().split()))

l.sort(reverse=1)
ans = 0
for i in range(K):
    ans += l[i]

print(ans)


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

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


Measured memory_bytes: 256
d = int(input())
c = list(map(int,input().split()))
up = []
for _ in range(d):
  up.append(list(map(int,input().split())))
ans = [[-1] for _ in range(26)]
for i in range(d):
  ans[i%26].append(i)
#ans[0].append(0)
#ans[16].append(1)
#ans[12].append(2)
#ans[13].append(3)
#ans[12].append(4)

for al in range(26):
  ans[al].append(d)
#print(ans)
import bisect
from random import random
from random import randrange
scr = 0
for al in range(26):
  now = ans[al]
  l = len(now)
  for j in range(1,l):
    scr -= c[al] * (now[j]-now[j-1]-1) * (now[j]-now[j-1]) // 2
    #print(c[al] * (now[j]-now[j-1]-1) * (now[j]-now[j-1]) // 2)
  for j in range(1,l-1):
    scr += up[now[j]][al]
    #print(up[now[j]][al])
  #print('$')
#print(scr)
task = [i%26 for i in range(d)]
#print(task)
for _ in range(10**5):
  day = randrange(d)
  pre = task[day]
  pst = randrange(26)
  if pre == pst:
    continue
  bpre = bisect.bisect_left(ans[pre],day)
  bpst = bisect.bisect_left(ans[pst],day)
  bpre1 = ans[pre][bpre-1]
  bpre2 = ans[pre][bpre+1]
  bpst1 = ans[pst][bpst-1]
  bpst2 = ans[pst][bpst]
  #print(day,ans[pre][bpre],ans[pst][bpst])
  #print(day)
  #print(bpre1,day,bpre2,'#',pre)
  #print(bpst1,day,bpst2,'#',pst)
  tmp = 0
  tmp -= c[pre] * (day-bpre1) * (bpre2-day)
  #print(c[pre] * (day-bpre1) * (bpre2-day))
  tmp += c[pst] * (day-bpst1) * (bpst2-day)
  #print(c[pst] * (day-bpst1) * (bpst2-day))
  tmp -= up[day][pre]
  #print(up[day][pre])
  tmp += up[day][pst]
  #print(up[day][pst])
  #print(tmp)
  if tmp > 0:
    #print(ans[pre])
    #print(ans[pst])
    ans[pre].remove(day)
    bisect.insort(ans[pst],day)
    #print(ans[pre])
    #print(ans[pst])
    task[day] = pst
    scr += tmp
    #print(scr)
  #print('%')
#for x in ans:
  #print(x)
for x in task:
  print(x+1)

Measured memory_bytes: 83304
#include <vector>

/*
 * @title 全方位木DP
 * @docs docs/graph/re-rooting.md
 */

template<typename M>
std::vector<typename M::T> re_rooting(const std::vector<std::vector<int>> &adj,
                                      const std::vector<std::vector<typename M::E>> &cost) {
    using T = typename M::T;
    int n = adj.size();
    std::vector<std::vector<T>> dp(n);
    {
        static auto dfs = [&](auto &&self, int cur, int par) -> T {
            dp[cur].resize(adj[cur].size());
            T cum = M::id();
            for (int i = 0; i < adj[cur].size(); i++) {
                if (adj[cur][i] == par) { continue; }
                dp[cur][i] = M::op_TE(self(self, adj[cur][i], cur), cost[cur][i]);
                cum = M::op_TT(cum, dp[cur][i]);
            }
            return cum;
        };
        dfs(dfs, 0, -1);
    }
    std::vector<T> ret(n);
    {
        static auto dfs = [&](auto &&self, int cur, int par, T drop) -> void {
            int m = adj[cur].size();
            std::vector<T> l_cum(m + 1), r_cum(m + 1);
            l_cum[0] = r_cum[m] = M::id();
            for (int i = 0; i < m; i++) {
                if (adj[cur][i] == par) { dp[cur][i] = M::op_TE(drop, cost[cur][i]); }
                l_cum[i + 1] = M::op_TT(l_cum[i], dp[cur][i]);
            }
            for (int i = m - 1; i >= 0; i--) { r_cum[i] = M::op_TT(dp[cur][i], r_cum[i + 1]); }
            for (int i = 0; i < m; i++) {
                if (adj[cur][i] == par) { continue; }
                self(self, adj[cur][i], cur, M::op_TT(l_cum[i], r_cum[i + 1]));
            }
            ret[cur] = l_cum[m];
        };
        dfs(dfs, 0, -1, M::id());
    }
    return ret;
}

struct diameter_rr {
    using T = int;
    using E = int;
    static T id() { return 0; }
    static T op_TT(const T &a, const T &b) { return std::max(a, b); }
    static T op_TE(const T &a, const E &b) { return a + b; }
};

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> adj(n, vector<int>()), cost(n, vector<int>());
    for (int i = 0; i < n - 1; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        adj[s].push_back(t), adj[t].push_back(s);
        cost[s].push_back(w), cost[t].push_back(w);
    }
    vector<int> cands = re_rooting<diameter_rr>(adj, cost);
    int ans = 0;
    for (int i = 0; i < n; i++) { ans = max(ans, cands[i]); }
    cout << ans << endl;
}


Measured memory_bytes: 35220
l=list(input())
a=int(l[0])
b=int(l[1])
c=int(l[2])
d=int(l[3])
x=y=z=2
for i in range(2):
  for j in range(2):
    for k in range(2):
      if i==1:
        _b=-b
      else:
        _b=b
      if j==1:
        _c=-c
      else:
        _c=c
      if k==1:
        _d=-d
      else:
        _d=d
      if sum([a,_b,_c,_d])==7:
        x=i
        y=j
        z=k
if x==1:
  x='-'
else:
  x='+'
if y==1:
  y='-'
else:
  y='+'
if z==1:
  z='-'
else:
  z='+'
print(str(a)+x+str(b)+y+str(c)+z+str(d)+'=7')

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

import sys
import copy
import math

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~

A, B = map(int, input().split())

S = A - 1
T = B - 1

print((S + T - 1) // S)


Measured memory_bytes: 3444
H, W = map(int, input().split())
T = [","*W + ",,"]  + ["," + input() + "," for _ in range(H)] + [","*W + ",,"]
ans = ""
d = [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]
for i in range(1, H+1):
    for j in range(1, W+1):
        if T[i][j] == "#":
            ans += "#"
        else:
            ans += str(sum(T[i+x][j+y] == "#" for x, y in d))
    ans += "\n"
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=200;
int h,w;
int f[maxn][maxn],flag[maxn][maxn];
int main()
{
	cin>>h>>w;
	for (int i=1;i<=h;i++)
		for (int j=1;j<=w;j++)
		{
			char k;cin>>k;
			if (k=='#') flag[i][j]=1;
		}
	memset(f,0x3f,sizeof(f));
	if (flag[1][1]) f[1][1]=1;else f[1][1]=0;
	for (int i=1;i<=h;i++)
		for (int j=1;j<=w;j++)
			f[i+1][j]=min(f[i+1][j],f[i][j]+(!flag[i][j] && flag[i+1][j])),
			f[i][j+1]=min(f[i][j+1],f[i][j]+(!flag[i][j] && flag[i][j+1]));
	cout<<f[h][w]<<endl;
	return 0;
}


Measured memory_bytes: 512
import copy
S = list(input())
s = copy.copy(S)
ans = 1
i = 0
while True:
    if i >= len(s):
        break
    if s[i] == "x":
        del s[i]
        i -= 1
    i += 1

def main(s):
    for i in range(int((len(s)) / 2)):
        if s[i] != s[len(s) - 1 - i]:
            print(-1)
            return 0
    cnt = 0
    num = [-1]
    for i in range(len(S)):
        if S[i] != "x":
            num.append(i)
    num.append(len(S))
    i = 0
    s = copy.copy(S)
    cnt = 0
    #print(num)
    if len(num) % 2 == 0:
        i = int(len(num) / 2)
        for j in range(i, len(num) - 1):
            #print(i, j, j + 1, len(num) - j - 1, len(num) - j - 2)
            cnt += abs(abs(num[j] - num[j + 1]) - abs(num[len(num) - j - 1] - num[len(num) - j - 2]))
            #print(abs(num[j] - num[j + 1]), i, j)
            #print(abs(num[len(num) - j - 1] - num[len(num) - j - 2]))
    else:
        i = int(len(num) / 2)
        for j in range(i, len(num) - 1):
            #print(i, j, j + 1, len(num) - j - 1, len(num) - j - 2)
            cnt += abs(abs(num[j] - num[j + 1]) - abs(num[len(num) - j - 1] - num[len(num) - j - 2]))
            #print(abs(num[j] - num[j + 1]), i, j)
            #print(abs(num[len(num) - j - 1] - num[len(num) - j - 2]))
    print(cnt)
    return 0
        
            
main(s)


Measured memory_bytes: 9892
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);

char itoc(int i)
{
    if (i < 26)
        return i + 'a';
    if (i < 26 * 2)
        return i - 26 + 'A';
    return i - 26 * 2 + '0';
}

int ctoi(int c)
{
    if ('a' <= c && c <= 'z')
        return c - 'a';
    if ('A' <= c && c <= 'Z')
        return c - 'A' + 26;
    return c - '0' + 26 * 2;
}

int qry(string s)
{
    cout << "? " << s << endl;
    int ans;
    cin >> ans;
    return ans;
}

const int N = 128;
int n;
const int m = 62;

bool issub(string s)
{
    return (qry(s) == n - s.size());
}

int q[m];

string rec(int l, int r)
{
    if (l == r)
    {
        string s = "";
        for (int i = 0; i < q[l]; ++i)
            s += itoc(l);
        return s;
    }
    int m = (l + r) / 2;
    string a = rec(l, m);
    string b = rec(m + 1, r);
    string s = "";
    while (!a.empty() && !b.empty())
    {
        if (issub(s + a[0] + b))
        {
            s += a[0];
            a.erase(a.begin());
        }
        else
        {
            s += b[0];
            b.erase(b.begin());
        }
    }
    s += a;
    s += b;
    return s;
}

void solv()
{
    for (int i = 0; i < m; ++i)
    {
        string s = "";
        for (int j = 0; j < N; ++j)
            s += itoc(i);
        q[i] = N - qry(s);
    }
    for (int i = 0; i < m; ++i)
        n += q[i];
    string ans = rec(0, m - 1);
    assert(qry(ans) == 0);
    cout << "! " << ans << endl;
}

int main()
{
    #ifdef SOMETHING
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


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

int main() {
  int N; cin >> N;
  bool flag = false;
  for(int i=0;i<N/7+1;i++){
    if(flag =( (N - i*7)%4==0 )) break;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s[100002];
    int a[100002];
    string s1;
    int x,n,q,head,tail,tot=0;
    head=0; tail=0;
    cin>>n>>q;
    for (int i=0; i<n; i++){
    	cin>>s1>>a[i];
    	s[i]=s1;
    	tail++;
	}
	while (head!=tail){
		  if (a[head]>q){
		  	 tot+=q;
		     x=a[head]-q;
		     s1=s[head];
			 head++;
			 if (head>n) head=0;
			 a[tail]=x;	
			 s[tail]=s1;
			 tail++;
			 if (tail>n) tail=0; 
		  }
		  else{
		  	 cout<<s[head]<<' '<<a[head]+tot<<endl;
		  	 tot+=a[head];
		  	 head++;
		  	 if (head>n) head=0;
		  }
	}
    return 0;
} 


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int a[110],b[10],c[10];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=1;i<=n;i++)
		cin>>c[i];
	for(int i=1;i<=n;i++)
		a[i]=i;
	int x1,y1,t=0,flag=1,flag1=1; 
	do{
		t++;flag=1,flag1=1;
		for(int i=1;i<=n;i++)
			if(a[i]!=c[i]){
				flag=0;
				break;
			}
		if(flag)
			x1=t;
		for(int i=1;i<=n;i++)
			if(a[i]!=b[i]){
				flag1=0;
				break;
			}
		if(flag1)
			y1=t;
	}while(next_permutation(a+1,a+n+1)); 
	cout<<abs(x1-y1);
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define inf 1000000000000000001
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
#define Set(N,p) N=((N)|((1LL)<<(p)))
#define Reset(N,p) N=((N)&(~((1LL)<<(p))))
#define Check(N,p) (!(((N)&((1LL)<<(p)))==(0)))
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define OUT(x) for(auto a:x) cout << a << " "; cout << endl;
#define OK cout << "@===================ok===================@" <<endl;
#define WTF cout <<"< "<<lo<<" | "<< hi <<" >" << endl;

using namespace std;

int f[4];
int main()
{
	int x,y;
	cin >> x >> y;
	f[x]=1;
	f[y]=1;
	for(int i=1;i<=3;i++){
		if(f[i]==0) cout <<i << endl;
	}
}


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

template<class T,class F>
struct disjoint_sparse_table{
  int n;
  int log_n;
  int sz;
  vector<vector<T>> table;
  F f;
  disjoint_sparse_table(F& f):f(f){}
  disjoint_sparse_table(vector<T> const& v,F& f):f(f){
    build(v);
  }
  void build(vector<T> const& v){
    sz = v.size();
    n = 1;
    log_n = 0;
    while(n<v.size()){n<<=1;log_n++;}
    table.emplace_back(v);
    table.resize(log_n+1);
    build_left(0,n/2,1);
    build_right(n/2,n,1);
  }
  void build_left(int l,int r,int k){
    if(k>=log_n)return;
    if(r>sz)return;
    vector<T> v;
    v.reserve(r-l);
    v.emplace_back(table[0][r-1]);
    for(int i=r-2;i>=l;--i){
      v.emplace_back(f(v.back(),table[0][i]));
    }
    reverse(v.begin(),v.end());
    table[k].insert(end(table[k]),v.begin(),v.end());
    build_left(l,(l+r)/2,k+1);
    build_right((l+r)/2,r,k+1);
  }
  void build_right(int l,int r,int k){
    if(k>=log_n)return;
    if(l>sz)return;
    vector<T> v;
    v.reserve(min(r,sz)-l);
    v.emplace_back(table[0][l]);
    for(int i=l+1;i<r&&i<sz;++i){
      v.emplace_back(f(v.back(),table[0][i]));
    }
    table[k].insert(end(table[k]),begin(v),end(v));
    build_left(l,(l+r)/2,k+1);
    build_right((l+r)/2,r,k+1);
  }
  int msb(int c){
    int ret = 0;
    if (c >> 16)
      c >>= 16, ret += 16;
    if (c >> 8)
      c >>= 8, ret += 8;
    if (c >> 4)
      c >>= 4, ret += 4;
    if (c >> 2)
      c >>= 2, ret += 2;
    return ret + (c >> 1);
  }
  T fold(int l,int r){
    int k = log_n-msb(l^r);
    if(k==log_n)k=0;
    return f(table[k][l],table[k][r]);
  }
  void dump(){
    for(auto v:table){
      for(auto x:v)cout<<x<<" ";
      cout<<endl;
    }
  }
};

signed main(){

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;

  auto gcd = [](int a,int b){
    while(1){
      if(b==0)return a;
      a%=b;
      swap(a,b);
    }
  };

  disjoint_sparse_table<int,decltype(gcd)> dst(a,gcd);
  int ans = 1;
  for(int i=1;i<n-1;++i){
    ans = max(ans, gcd(dst.fold(0,i-1),dst.fold(i+1,n-1)) );
  }
  ans = max(ans,dst.fold(1,n-1));
  ans = max(ans,dst.fold(0,n-2));
  cout<< ans <<endl;

}

Measured memory_bytes: 8068
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007

int main(){
    int w,a,b;
    cin >> w >> a >> b;
    if(b>=(a+w)) cout << b-a-w << endl;
    else if(a>=b+w) cout << a-b-w << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())

a1 = ''
b1 = ''

for i in range(b):
    a1 = a1 + str(a)
for i in range(a):
    b1 = b1 + str(b)

if a1 < b1:
    print(a1)
else:
    print(b1)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int counter = 0;
        for (int i=0; i<N; i++) {
            int temp = sc.nextInt();
            if (temp >= M) counter++;
        }
        System.out.println(counter);
    }
}


Measured memory_bytes: 49880
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int n;cin>>n;
    string s;
    if(n==0){
        cout<<n<<endl;
        return 0;
    }
    int k=-2;
    while(n!=0){
        if(n%k==0){
            s+='0';
            k*=-2;
        }else {
            s+='1';
            n-=(k/-2);k*=-2;
        }
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}

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

A.sort()
A.append(A[0]+K)
dif = 0
for i in range(1, N+1):
  dif = max(dif, A[i] - A[i-1])
  #print(dif)
print(K-dif)


Measured memory_bytes: 26100
#include<bits/stdc++.h>
#define FastIO1 ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define si(n) scanf("%d",&n)
#define sl(n) scanf_s("%lld",&n)
#define nsl(n) scanf_s("%lld\n",&n)
#define nsi(n) scanf("%d\n",&n)
#define repz(i,a,n) for(int i=a;i<n;i++)
#define repo(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for (int i=n;i>=a;i--)
#define stlfor(it,stl) for(auto &it:stl)
#define pb push_back
#define mp make_pair
namespace FastIO {
	const int SIZE = 1 << 16;
	char buf[SIZE], obuf[SIZE], str[60];
	int bi = SIZE, bn = SIZE, opt;
	int read(char* s) {
		while (bn) {
			for (; bi < bn && buf[bi] <= ' '; bi++);
			if (bi < bn) break;
			bn = fread(buf, 1, SIZE, stdin);
			bi = 0;
		}
		int sn = 0;
		while (bn) {
			for (; bi < bn && buf[bi] > ' '; bi++) s[sn++] = buf[bi];
			if (bi < bn) break;
			bn = fread(buf, 1, SIZE, stdin);
			bi = 0;
		}
		s[sn] = 0;
		return sn;
	}
	template<typename T>
	bool read(T& x) {
		int n = read(str), bf;
		if (!n) return 0;
		int i = 0; if (str[i] == '-') bf = -1, i++; else bf = 1;
		for (x = 0; i < n; i++) x = x * 10 + str[i] - '0';
		if (bf < 0) x = -x;
		return 1;
	}
};
using namespace FastIO;
using namespace std;
typedef long long ll;
typedef long double db;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll a, ll b,ll mod) { ll ans = 1; while (b) { if (b & 1) ans = (ans * a)%mod ; b >>= 1; a = (a * a)%mod; }return ans; }
ll qmul(ll a, ll b, ll mod) { ll ans = 0; while (b > 0) { if (b & 1)ans = (ans + a) % mod; b >>= 1; a = (a + a) % mod; }return ans; }
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
string hack = { "NB" };
int hack1 = 0;
int hack2 = hack1 + 666;

void NB() {
	string s;
	string t1="erase", t2="eraser", t3="dreamer", t4="dream",t5="dreameraser",t6="dreamerase";
	bool flag = 1;
	cin >> s;
		int n =(int)s.size();
		for (int i = 0; i < n; i++) {
			if (s.substr(i, 11) == t5) {
				i += 10;
			}
			else if (s.substr(i, 10) == t6) {
				i += 9;;
			}
			else if (s.substr(i, 7) == t3) {
				i += 6;
			}
			else if (s.substr(i, 5) == t4) {
				i += 4;
			}
			else if (s.substr(i, 6) == t2) {
				i += 5;
			}
			else if (s.substr(i, 5) == t1) {
				i += 4;
			}
			else {
				flag = 0;
				break;

			}
		}
			if (flag)puts("YES");
			else puts("NO");
	
}
int main(){
	FastIO1
		NB();
	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl;
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
#define FOR(i, n) for(ll i = 0; i < n; i++)
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);    
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<bool> a(n, false);
    while(k--){
        ll snk;
        cin >> snk;
        while(snk--){
            ll s;
            cin >> s;
            a[s-1] = true;
        }
    }
    ll count = 0;
    for(auto i : a) if(i == false) ++count;
    cout << count << "\n";
}

Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 101;

int a[MAXN];

int main()
{
    int n;
    while(cin >> n && n)
    {
        REP(n) cin >> a[i];
        int ans = 0;

        for(int j = n - 1; j > 0;j--)REP(j)
        {
            if(a[i] > a[i+1]){ swap(a[i], a[i+1]);ans++; }

        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

  for (;;) {
    int curr, next;
    int res;
    int n;

    scanf("%d", &n);
    if (n == 0) break ;

    curr = 0; next = 3;
    res = 0;
    for (i = 0; i < n; ++i) {
      char cmd[4];

      scanf(" %s", cmd);
      if (strcmp(cmd, "lu") == 0) {
	curr = curr | 2;
      }
      if (strcmp(cmd, "ru") == 0) {
	curr = curr | 1;
      }
      if (strcmp(cmd, "ld") == 0) {
	curr = curr & ~2;
      }
      if (strcmp(cmd, "rd") == 0) {
	curr = curr & ~1;
      }
      
      if (curr == next) {
	++res;
	next = (next == 0 ? 3 : 0);
      }
    }
    printf("%d\n", res);
  }


  return (EXIT_SUCCESS);
}

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

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



  const int maxN = 100005;
int main(){
  int n;
  cin >> n;


  bool are[maxN];
  rep(i,maxN) are[i]=true;

  for(int i=2;i<maxN;i++){
    //cout << i << are[i] << endl;
    if(are[i]==false)continue;
    if(i>= n && are[i]==true){
      cout << i << endl;
      break;
    }
    if(are[i]==true){
      //cout << i << endl;
      for(int j=i+i; j<maxN; j+=i)are[j]=false;
    }
  }
  return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,d,cmp,cmpp,m,h,w,xx[ohara],yy[ohara],x,y,sum[4002][4002],pos,k;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
char c;
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n>>k;
      rep(i,n){
        cin>>yy[i]>>xx[i]>>c;
        if(c=='W')yy[i]+=k;
        xx[i]++;yy[i]++;
        xx[i]=(xx[i]+2*k)%(2*k);
        yy[i]=(yy[i]+2*k)%(2*k);
        sum[yy[i]][xx[i]]++;
        sum[yy[i]+2*k][xx[i]]++;
        sum[yy[i]+2*k][xx[i]+2*k]++;
        sum[yy[i]][xx[i]+2*k]++;
      }
      rep(i,4001){
        rep(j,4001){
          if(i==0)continue;
          sum[i][j]+=sum[i-1][j];
        }
      }
      rep(i,4001){
        rep(j,4001){
          if(i==0)continue;
          sum[j][i]+=sum[j][i-1];
        }
      }
      rep(i,2*k+1){
        rep(j,2*k+1){
         cnt=sum[i+k][j+k]+sum[i][j]-sum[i][j+k]-sum[i+k][j];
         cnt+=sum[i+k+k][j+k+k]+sum[i+k][j+k]-sum[i+k][j+k+k]-sum[i+k+k][j+k];
         ans=max(ans,cnt);
        }
      }
      Cout(ans);
     

       
return 0;
}


Measured memory_bytes: 131328
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

        vector<ll> p(a), q(b), r(c);
        REP(i, a) cin >> p[i];
        REP(i, b) cin >> q[i];
        REP(i, c) cin >> r[i];

        sort(p.begin(), p.end());
        sort(q.begin(), q.end());
        sort(r.begin(), r.end(), greater<ll>());

        for (int i = 0, j = a - x, k = b - y; i < c; i++) {
                if (j == a && k == b || r[i] < p[j] && r[i] < q[k]) break;
                
                // (j < a || k < b) && (r[i] >= p[j] || r[i] >= q[k])
                if (k == b) {
                        if (r[i] <= p[j]) break;
                        p[j] = r[i];
                        j++;
                        continue;
                }

                if (j == a) {
                        if (r[i] <= q[k]) break;
                        q[k] = r[i];
                        k++;
                        continue;
                }

                if (r[i] - p[j] > r[i] - q[k]) {
                        p[j] = r[i];
                        j++;
                } else {
                        q[k] = r[i];
                        k++;
                }
        }

        ll sum = 0;
        FOR(i, a-x, a) sum += p[i];
        FOR(i, b-y, b) sum += q[i];

        cout << sum << endl;

        return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, T;
    cin >> n >> T;
    int ans = INF;
    rep(i, 0, n){
        int c, t;
        cin >> c >> t;
        if(t <= T){
            ans = min(ans, c);
        }
    }
    if(ans == INF) cout << "TLE" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC081C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] A = new int[200000];
            var target = Console.ReadLine().Split(' ');
            int N = int.Parse(target[0]);
            int K = int.Parse(target[1]);
            Dictionary<int, int> a = new Dictionary<int, int>(); 
            target = Console.ReadLine().Split(' ');
            for(int i=0;i<N;i++){
                int tmp = int.Parse(target[i]);
                if(a.ContainsKey(tmp)){
                   a[tmp]++; 
                } else {
                    a.Add(tmp, 1);
                }
            }
//            Console.WriteLine(a.Count);
//            var list = new List<KeyValuePair<int, int>>(a);
            List<int> list = a.Values.ToList();
            list.Sort();
            int count = 0;
            for(int i=0;i<list.Count-K;i++){
                count += list[i];
            }
            Console.WriteLine(count);
//            for(int i=0;i<list.Count;i++){
//                Console.WriteLine(list[i].Value);
//            }
        }
    }
}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> v;
  for(int i = 0; i < n; i++){
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(v.begin(), v.end());
  int ans = 0;
  for(int i = 0; i < k; i++){
    ans += v[n-1-i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int N; cin >> N;
		if (N == 0) break;
		vector<int> L(N), b(N);
		for (int i = 0; i < N; i++) {
			int M; cin >> M >> L[i];
			while (M--) {
				int S, E; cin >> S >> E;
				S -= 6; E -= 6;
				for (int j = S; j < E; j++)
					b[i] |= (1 << j);
			}
		}
		vector<ll> dp(1 << 16);
		for (int i = 0; i < N; i++) {
			for (int S = (1 << 16) - 1; S >= 0; S--) {
				if (S & b[i]) continue;
				int _S = S | b[i];
				dp[_S] = max(dp[_S], dp[S] + L[i]);
			}
		}
		cout << dp[(1 << 16) - 1] << endl;
	}
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

ll dp[101][10001];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,W;
	cin>>n>>W;
	vl v(n),w(n);
	rep(i,n)cin>>v[i]>>w[i];
	rep(i,n){
		rep(j,min(10001,W+1)){
			if(j<w[i])dp[i+1][j]=dp[i][j];
			else dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
		}
	}
	cout<<dp[n][W]<<endl;
}


Measured memory_bytes: 11032
#include <iostream>

using namespace std;
using ll = long long;

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

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

  bool ans = false;
  rep(i, n.length()) {
    if (n[i] == '7') ans = true;
  }

  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


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

int main(){
  int N,W;
  cin >> N >> W;
  int v[100],w[1000];
  for(int i=0;i<N;i++){
    cin >> v[i] >> w[i];
  }
  int DP[N+1][W+1];

  for(int j=0;j<=W;j++){
    DP[0][j] = 0;
  }

  for(int i=1;i<=N;i++){
    for(int j=0;j<=W;j++){
      if(j<w[i-1]){
        DP[i][j] = DP[i-1][j];
      }
      else{
        if(DP[i-1][j]>DP[i-1][j-w[i-1]]+v[i-1]){
          DP[i][j] = DP[i-1][j];
        }
        else{
          DP[i][j] = DP[i-1][j-w[i-1]]+v[i-1];
        }
      }
    }
  }
  cout << DP[N][W] << endl;
  return 0;
}



Measured memory_bytes: 7012
import math

k = int(input())

ans = 0
res = 0


for i in range(1,k+1):
    for j in range(1,k+1):
        tmp = math.gcd(j,i)
        for k in range(1,k+1):
            res = math.gcd(k,tmp)
            ans += res

print(ans)  

Measured memory_bytes: 9128
n = int(input())
p = input().split(" ")

ans = 0

for i in range(1,n-1):
    if (int(p[i-1]) < int(p[i]) and int(p[i]) < int(p[i+1])) or(int(p[i-1]) > int(p[i]) and int(p[i]) > int(p[i+1])):
        ans += 1
    else:
        ans += 0

print(ans)

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

int a[105];
int dp[105][100005];

#define MOD 1000000007

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

    for(int i = 0; i <= k; ++i){
        if(i)
            dp[0][i] = dp[0][i-1];
        if(i <= a[0])
            dp[0][i]++;
    }

    for(int i = 1; i < n; ++i){
        dp[i][0] = 1;
        for(int j = 1; j <= k; ++j){
            dp[i][j] = dp[i][j - 1];
            dp[i][j] += (dp[i - 1][j] - (j - a[i] - 1 >= 0 ? dp[i - 1][j - a[i] - 1] : 0) + MOD) % MOD;
            dp[i][j] %= MOD;
        }
    }

    cout << (dp[n - 1][k] - dp[n - 1][k - 1] + MOD) % MOD << "\n";
    return 0;
}

/*
3 4
3 2 4
*/


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

int main() {
	vector<int>x;
	int N = 0;
	int num = 0;
	int price = 0;
	int small = 0;
	int index = 0;
	cin >> N;
	cin >> num;
	
	for (int i = 0; i < N; i++) {
		cin >> price;
		x.push_back(price);
	}
	price = 0;
	for (int i = 0; i < num; i++) {
		small = x[0];
		for (int j = 0; j < x.size(); j++) {
			if (small > x[j]) {
				small = x[j];
				index = j;
			}
		}
		price += small;
		small = 0;
		x.erase(x.begin() + index, x.begin() + index + 1);
		index = 0;
	}

	cout << price;
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> ht;
    
    rep(i,n)
    {
        ll l;
        cin>>l;
        ht.push_back(l);
    }
    sort(ht.begin(),ht.end(),greater<ll>());
    if(n<=k)
    {
        cout<<0<<endl;
        return 0;
    }
    rep(i,k)
    {
        ht[i]=0;
    }
    ll total=0;
    rep(i,n)
    {
        total+=ht[i];
    }
    cout<<total<<endl;
    
}

Measured memory_bytes: 2420
#include<stdio.h>
int main(){
    int N,A,B;
    scanf("%d",&N);
    scanf("%d %d",&A,&B);
    int Anew,Bnew;
    for(int i=1;i<N;i++){
        scanf("%d %d",&Anew,&Bnew);
        if(Bnew<B){
            A=Anew;
            B=Bnew;
        }
    }
    printf("%d",A+B);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=500001;
typedef long long ll;
map<ll,ll> cnt;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    ll pref=0;
    ll ans=0;
    cnt[0]++;
    for(int i=1; i<=n; ++i){
        ll a;
        cin>>a;
        pref+=a;
        ans+=cnt[pref];
        cnt[pref]++;
    }
    cout<<ans;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int x,y,z,ans=0,m;
    cin>>x>>y>>z;
    long long cnt=0;
    for(int i=1;i<=x;i++)
    {
        stringstream ss;
        string s;
        m=i;
        ss<<i;
        ss>>s;
        for(int i=0;i<SZ(s);i++)
        {
            int k=s[i]-'0';
            ans+=k;
        }
        if(ans>=y&&ans<=z)
        {
           cnt+=m;
        }
        ans=0;
    }
    cout<<cnt<<NL;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<21);

int main()
{
  int n;
  vector<pair<int,int>> adj[MAX];

  cin >> n;
  for (int i = 0; i < n; ++i)
  {
    int u, k;
    cin >> u >> k;
    for (int j = 0; j < k; ++j)
    {
      int v, c;
      cin >> v >> c;
      adj[u].emplace_back(v, c);
    }
  }

  priority_queue<pair<int,int>> PQ;
  int d[MAX];
  bool visited[MAX];
  for (int i = 0; i < n; ++i)
  {
    d[i] = INFTY;
    visited[i] = false;
  }
  d[0] = 0;
  PQ.emplace(0,0);

  while (!PQ.empty())
  {
    pair<int,int> f = PQ.top(); PQ.pop();
    int u = f.second;
    visited[u] = true;
    if (d[u] < f.first * (-1)) continue;

    for (int i = 0; i < adj[u].size(); ++i)
    {
      int v = adj[u][i].first;
      if (visited[v]) continue;
      if (d[v] > d[u] + adj[u][i].second)
      {
        d[v] = d[u] + adj[u][i].second;
        PQ.emplace(d[v] * (-1), v);
      }
    }
  }

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

  return 0;
}



Measured memory_bytes: 7960
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;

ll _lcm(ll a, ll b){
    return (a*b)/__gcd(a, b);
}

void nope(){
    cout << 0;
    exit(0);
}

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    ll n, m;
    cin >> n >> m;
    vector<ll> v(n);
    for(auto &i : v) cin >> i, i/=2;

    ll lcm = 1;
    for(auto i : v){
        lcm = _lcm(lcm, i);
        if(lcm > m || lcm/i % 2 == 0) nope();
    }

    cout << m/lcm - m/(lcm*2);
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 4356
dim = input().split()
m = int(dim[0])
n = int(dim[1])
matrix = [input().split() for i in range(m)]
vector = [int(input()) for i in range(n)]
for i in range(m):
    result = 0
    for j in range(n):
        result += int(matrix[i][j]) * vector[j]
    print(result)



Measured memory_bytes: 6248