akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <utility>
#include <queue>

using namespace std;
typedef long long signed int ll;

constexpr int inf = INT32_MAX / 2;

//template <class Tnode>
class djikstra {
private:
	ll* d = nullptr;
	map<int, map<int, ll>> p;
	int sz = 0;
public:
	void add_path(int from, int to, ll cost) {
		p[from][to] = cost;
	}
	void compute(int from,int nodes) {
		sz = nodes;
		if (d != nullptr) delete d;
		d = new ll[nodes];
		auto cmp = [this](int a, int b) {return d[a] > d[b]; };
		priority_queue <ll, vector<ll>, decltype(cmp)> q(cmp);
		for (int i = 0; i < nodes; i++) d[i] = INT64_MAX / 2;
		d[from] = 0;
		q.push(from);
		while (!q.empty()) {
			for (auto& e : p[q.top()]) {
				if (d[e.first] > d[q.top()] + e.second) {
					d[e.first] = d[q.top()] + e.second;
					q.push(e.first);
				}
			}
			q.pop();
		}
	}
	ll operator[](int node) {
		if (node >= sz) return INT64_MAX/2;
		return d[node];
	}
};

int main() {
	djikstra q;
	int v, e, r, s, t, d;
	cin >> v >> e >> r;
	for (int i = 0; i < e; i++) {
		cin >> s >> t >> d;
		q.add_path(s, t, d);
	}
	q.compute(r, v);
	for (int i = 0; i < v; i++) if (q[i] == INT64_MAX / 2) cout << "INF" << endl; else cout << q[i] << endl;
}


Measured memory_bytes: 43888
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    vector<int> dividables;
    for (int i = 1; i <= min(A, B); i++) {
        if (A % i == 0 && B % i == 0) dividables.push_back(i);
    }
    
    reverse(dividables.begin(), dividables.end());

    cout << dividables.at(K - 1) << endl;

    return 0;
}


Measured memory_bytes: 3580
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int N;
    cin >> N;

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

    for(int i=0;i<N;i++){
      if(A[i]%2==0){
        if(A[i]%3!=0 && A[i]%5!=0){
          cout << "DENIED" <<endl;
          return 0;
        }
      }
    }

    cout << "APPROVED" <<endl;

    
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<lint, int>;
using vec = vector<lint>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vec a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];

    sort(all(a), greater<lint>());
    sort(all(b), greater<lint>());
    sort(all(c), greater<lint>());

    vec d;
    rep(i, min(x, k)) rep(j, min(y, k)) {
        d.push_back(a[i] + b[j]);
    }
    sort(all(d), greater<lint>());

    vec e;
    rep(i, min(k, (int)d.size())) rep(j, min(z, k)) {
        e.push_back(d[i] + c[j]);
    }
    sort(all(e), greater<lint>());

    rep(i, k) {
        cout << e[i] << endl;
    }

    return 0;
}

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

signed main(){

  int n;
  cin>>n;
  if(n==1){
    cout<<1<<endl;
    cout<<1<<endl;
  }
  else if(n==2){
    cout<<2<<endl;
    cout<<0<<endl;
    cout<<11<<endl;
  }
  else{
    cout<<n-1<<endl;
    for(int i=0;i<n-1;++i){
      cout<<1;
      for(int j=0;j<i;++j)cout<<0;
      cout<<1<<endl;
    }
  }

}


Measured memory_bytes: 3104
//file_name:ABC67_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n,k;
    scanf("%d%d",&n,&k);
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);

    ll ans = 0;

    rep(i,k){
        ans += a[n-1-i];
    }

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



Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int a[(int)1e5+1]={0};
int main()
{
	int s=0;
	int n,i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		s+=abs(a[i-1]-a[i]);
	}
	s+=abs(a[i-1]-a[i]);
	for(i=1;i<=n;i++)
	{
		printf("%d\n",s-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]))+abs(a[i-1]-a[i+1]));
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int N,L;
    cin >> N >> L;
    vector<int>taste(N);
    int a=300;
    int b;
    int sum=0;
    rep(i,N){
        taste.at(i)=L+i;
        sum+=taste.at(i);
        if(a>abs(taste.at(i))){
            a=abs(taste.at(i));
            b=i;
        }
    }
    cout << sum-taste.at(b) << endl;
}

Measured memory_bytes: 256
import io
import sys
import math

def solve():
    A, B, H, M = list(map(int, input().split()))
    C_sq = A**2 + B**2 - 2*A*B*math.cos((H - 11/60 * M)*math.pi/6)
    C = math.sqrt(C_sq)
    print(C) 


if __name__ == "__main__":
    solve()

Measured memory_bytes: 62884
#include<cstdio>

#define REP(i,n)   for(int i=0;i<(n);++i)
#define MN 100000
int b[MN];

int main(){
    int n,min=1e9+7,d=0,cnt=0;
    scanf("%d%*d",&n);
    REP(i,n) scanf("%d",b+i);
    REP(i,n){
        int a=b[i];
        if(min>a) min = a;
        else if(d==a-min) ++cnt;
        else if(d<a-min){
            d = a - min;
            cnt = 1;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 512
// ------------------------------------
// Date:2018/ 3/13
// Problem:ABC 069 4-Adjacent c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int N;
  cin >> N;
  int a, four, two, other;
  four = two = other = 0;
  REP(i, N) {
    cin >> a;
    if (a % 4 == 0) four++;
    else if (a % 2 == 0) two++;
    else other++;
  }

  bool ok = true;
  if (two > 0) {
    if (other > four) ok = false;
  } else {
    if (other - 1 > four) ok = false;
  }

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



Measured memory_bytes: 256
def f(n):
    for i in range (1,n):
        n*=i
    return n
        
while True:
    n=int(input())
    if n==0:
        break
    else:
        a=str(f(n))
        s=0
        l=len(a)
        for i in range(l-1,-1,-1):
            if a[i]=='0':
                s+=1
            else:
                break
        print(s)


Measured memory_bytes: 5704
import sys
  
input()
minv = int(input())
maxv = -1000000000
  
for r in map(int,sys.stdin.readlines()):
  m = r-minv
  if maxv < m: 
    maxv = m
    if m < 0: minv = r
  elif m < 0: minv = r
  
print(maxv)


Measured memory_bytes: 19832
tmp = list(map(int,input().split()))
L = tmp[0] % 2019
R = tmp[1] % 2019
l = tmp[0]//2019
r = tmp[1]//2019
if l == r:
  if tmp[1] - tmp[0] > 673:
    print(0)
  else:
    num_list = []
    for i in range(tmp[0],tmp[1]+1,1):
      for k in range(i+1,tmp[1]+1,1):
        num_list.append((i*k) % 2019)
    print(min(num_list))
else:
  print(0)

Measured memory_bytes: 6788
#include<stdio.h>
int main(void)
{
	char a[100001];
	int i, co = 0;

	scanf("%s", a);
	
	for (i = 0; a[i] != '\0'; i++) {
		switch (a[i]) {
		case '0':
			if (a[i - 1] == '0') {
				a[i] = '1';
				co++;
			}
			break;
		case '1':
			if (a[i - 1] == '1') {
				a[i] = '0';
				co++;
			}
			break;
		}
	}
	printf("%d\n",co);
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [False] * N
B = [0] * N
cnt = 0
for i in range(M):
    p, S = input().split()
    if not A[int(p) - 1]:
        if S == 'AC':
            cnt += 1
            A[int(p) - 1] = True
        else:
            B[int(p) - 1] += 1
_cnt = 0
for i in range(N):
    if A[i]:
        _cnt += B[i]
print(cnt, _cnt)


Measured memory_bytes: 10452
def solve(n,m,ar):
    mod = int(1e9) + 7
    dp = [[0] * (m+2) for _ in range(n+2)]
    dp[1][1] = 1
    for i in range(1,n+1):
        for j in range(1,m+1):
            if ar[i][j] == "#": continue
            if i == 1 and j == 1: continue
            dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod

    print(dp[n][m])



if __name__ == '__main__':
    n,m = map(int,input().split())

    ar = [[-1] * (m+2) for i in range(n+2)]

    for i in range(1,n+1):
        temp = list(input())
        for j in range(1,m+1):
            ar[i][j] = temp[j-1]

    solve(n,m,ar)

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(c) ((int)((c).size()))
#define st first
#define nd second
#define pb push_back

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef long long ll;

void solve(){
    int n;
    cin>>n;
    if(n == 0){
        cout << "0\n";
        return;
    }
    ll acc = 1;
    string ans;
    while(n) {
        if(n&1) {
            n -= acc;
            ans += '1';
        } else ans += '0';
        n /= -2;
    }
    reverse(ALL(ans));
    cout<<ans<<'\n';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = LI()
for a in A:
    if a % 2 == 0 and a % 3 and a % 5:
        print('DENIED')
        break
else:
    print('APPROVED')

Measured memory_bytes: 39664
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const int MAX_V = 1100;
const int INF = 1001001001;
const ll LINF = 23456789123456789;
struct edge { ll to, cap, rev;};

vector<edge> G[MAX_V];
ll level[MAX_V]; // sからの距離
int iter[MAX_V]; // どこまで調べ終わったか

// fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(int from, int to, ll cap){
    G[from].push_back((edge){to, cap, (ll)G[to].size()});
    G[to].push_back((edge){from, 0, (ll)G[from].size() - 1});
}

// sからの最短距離をBFSで計算する
void bfs(int s){
    memset(level, -1, sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        rep(i,G[v].size()){
            edge &e = G[v][i];
            if(e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

// 増加パスをDFSで探す
ll dfs(int v, int t, ll f){
    if(v == t)return f;
    for(int &i = iter[v]; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(e.cap > 0 && level[v] < level[e.to]){
            ll d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// sからtへの最大流を求める
ll max_flow(int s, int t){
    ll flow = 0;
    for(;;){
        bfs(s);
        if(level[t] < 0)return flow;
        memset(iter, 0, sizeof(iter));
        int f;
        while((f = dfs(s, t, INF)) > 0){
            flow += f;
        }
    }
}

int main() {
    int n;
    cin >> n;
    int s_ = 0;
    int t_ = n+1;

    ll ans = 0;

    ll a[n+1] = {};
    srep(i,1,n+1){
        cin >> a[i];
        if(0 < a[i]){
            ans += a[i];
            add_edge(s_, i, 0);
            add_edge(i, t_, a[i]);
        }else{
            add_edge(s_, i, -a[i]);
            add_edge(i, t_, 0);
        }
    }

    srep(i,1,n+1){
        srep(j,i+1,n+1){
            if(j % i == 0){
                add_edge(i, j, LINF);
            }
        }
    }

    
    ll cut = max_flow(s_, t_);
    ans -= cut;
    

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


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

using namespace std;

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef complex<int64> point;
typedef vector<point> polygon;

int64 dot(point a, point b) { return real(conj(a) * b); }

int64 cross(point a, point b) { return imag(conj(a) * b); }

enum { OUT, ON, IN };
int contains(const polygon &P, const point &p)
{
	bool in = false;
	for (int i = 0, n = P.size(); i < n; ++i)
	{
		point a = P[i] - p, b = P[(i + 1) % n] - p;
		if (imag(a) > imag(b)) swap(a, b);
		if (imag(a) <= 0 && 0 < imag(b))
			if (cross(a, b) < 0) in = !in;
		if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
	}
	return in ? IN : OUT;
}


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

	int n; cin >> n;
	polygon v(n);
	for (int i = 0; i < n; ++i){
		int64 x, y; cin >> x >> y;
		v[i] = point(x, y);
	}

	int q; cin >> q;
	while (q--){
		int64 x, y; cin >> x >> y;
		point p(x, y);
		cout << contains(v, p) << endl;
	}

	return 0;
}

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

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    int sum = 0;
    for (int n : A) sum += n;

    if (sum >= H) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    char s;
    cin >> s;
    if(s=='z'){
        cout <<'a'<<endl;
    }
    else{
    s = s+1;
    cout <<s<<endl;
    }
    //cout << char(s+'1') <<endl;
}

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

using namespace std;

struct Parser{
    typedef long long LL;
    static const LL MOD = 1000000007;
    struct Result{
        int idx;
        LL val;
        Result(int i, LL v) : idx(i), val(v) {}
    };
    string s;
    Parser(string s_) {
        stringstream ss(s_);
        string t;
        while(ss >> t){
            s += t;
        }
    }
    inline void inc(int& k, char c) const {
        if(s[k] != c){
            printf("assert s[%d] = %c but %c\n", k, c, s[k]);
            exit(1);
        }
        k++;
    }
    inline bool is_term(char c) const {
        if(isdigit(c)) return true;
        return c == 'S';
    }
    int parse() const {
        return expr(0).val;
    }
    Result expr(int k) const {
        // printf("into expr(%d)\n", k);
        Result r = term(k);
        while(s[r.idx] == '>' && r.idx + 2 < s.size() && is_term(s[r.idx + 2])){
            inc(r.idx, '>');
            inc(r.idx, '>');
            // printf("expr(%d) call term(%d)\n", k, r.idx);
            Result t = term(r.idx);
            // printf("back expr(%d)\n", k);
            r.val = r.val >> min(60LL, t.val);
            r.idx = t.idx;
        }
        return r;
    }
    Result term(int k) const {
        // int fk = k;
        // printf("into term(%d)\n", k);
        if(s[k] == 'S'){
            inc(k, 'S');
            inc(k, '<');
            // printf("term(%d) call expr(%d)\n", fk, k);
            Result r = expr(k);
            // printf("back term(%d) (%d, %d)\n", fk);
            r.val = r.val * r.val % MOD;
            inc(r.idx, '>');
            return r;
        }else{
            LL num = 0;
            while(isdigit(s[k])){
                num = num * 10 + s[k++] - '0';
            }
            return Result(k, num);
        }
    }
};

int main(){
    string s;
    while(getline(cin, s) && s != "#"){
        cout << Parser(s).parse() << endl;
    }
    return 0;
}

Measured memory_bytes: 8840
N = int(input())
dic = {}
dic2 = {}
for i in range(N):
    s, p = input().split()
    dic[int(p)] = s
    dic2[int(p)] = i
dic = sorted(dic.items(), reverse=True)
for i,j in sorted(dic, key=lambda x:x[1]):
    print(dic2[i]+1)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

import static java.lang.StrictMath.floor;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = sc.nextInt();
        int d = sc.nextInt();

        int[][] arr = new int[n][d];

        for(int i=0; i<n; i++) {
            for(int j = 0; j<d; j++) {
                arr[i][j] = sc.nextInt();
            }
        }

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

            for(int j = i + 1; j < n; j++) {
                double dis = 0;
                for (int k = 0; k<d; k++) {
                    dis += (arr[i][k] - arr[j][k]) * (arr[i][k] - arr[j][k]);
                }
                dis = Math.sqrt(dis);
                double temp = floor(dis);
                if ( temp - dis == 0) {
                    res++;
                }

            }
        }
        System.out.println(res);
    }
}


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

int main()
{
  uint64_t a, b, k;
  cin >> a >> b >> k;
  for (auto i = 0; i < k; i++) {
    if (i % 2 == 0) {
      a /= 2;
      b += a;
    } else {
      b /= 2;
      a += b;
    }
  }
  cout << a << " " << b << endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>

int main()
{
	int a, b, c;
	int tempA, tempB, tempC;
	std::cin>> a >> b >> c;

	if (a < b){
		tempA = a;
		tempB = b;
		a = tempB;
		b = tempA;
	}
	if (b < c){
		tempB = b;
		tempC = c;
		b = tempC;
		c = tempB;
	}
	if (a < b){
		tempA = a;
		tempB = b;
		a = tempB;
		b = tempA;
	}
  std::cout << c << " " << b << " " << a << std::endl;
  return 0;
}

Measured memory_bytes: 3088
import java.io.*;

class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] strarr = str.split(" ");
        int num1 = Integer.parseInt(strarr[0]);
        int num2 = Integer.parseInt(strarr[1]);
        int num3 = Integer.parseInt(strarr[2]);
        
        if((num1 < num2) && (num2 < num3)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
    
}


Measured memory_bytes: 24248
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, i;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  for (int i = K; i < N ; i++) {
    if (vec.at(i) > vec.at(i-K)){
      cout << "Yes" << endl;
    }
    else if (vec.at(i) <= vec.at(i-K)) {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A[5];
    
    for(int i = 0; i < 5; i++){
        cin >> A[i];
    }
    int ans = 0;
    for(int i = 0; i < 5; i++){
        if(A[i] == 0){
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	cin>>n;
	vvi in(n,vi(4));
	rep(i,n)rep(j,4)cin>>in[i][j];
	vi x,y;
	rep(i,n)rep(j,4)if(j%2)y.pb(in[i][j]);
					else x.pb(in[i][j]);
	sort(all(x));sort(all(y));
	x.erase(unique(all(x)),x.end());
	y.erase(unique(all(y)),y.end());
	
	vvi tmp=in;
	rep(i,n)rep(j,4)if(j%2)tmp[i][j]=find(all(y),tmp[i][j])-y.begin();
					else tmp[i][j]=find(all(x),tmp[i][j])-x.begin();
	vvi field(x.size(),vi(y.size()));

	rep(i,n){
		field[tmp[i][0]][tmp[i][1]]++;
		field[tmp[i][2]][tmp[i][1]]--;
		field[tmp[i][0]][tmp[i][3]]--;
		field[tmp[i][2]][tmp[i][3]]++;
	}
	rep(i,x.size())loop(j,1,y.size())field[i][j]+=field[i][j-1];
	rep(j,y.size())loop(i,1,x.size())field[i][j]+=field[i-1][j];
	
	//loop(j,tmp[i][0],tmp[i][2])loop(k,tmp[i][1],tmp[i][3])

	ll out=0;
	rep(i,x.size())rep(j,y.size())if(field[i][j])
		out+=(ll)(x[i+1]-x[i])*(y[j+1]-y[j]);
	cout<<out<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
    int goukei=0;
   for (int i = 0; i < N; i++) {
    goukei += vec.at(i);}
  
  int SA=0, SB=0, s=0;
   for (int i = 0; i < N; i++) {
     SA += vec.at(i);
     SB = goukei - SA;
     if(SA > SB){
       int p = SA - SB;
        if(p < s)
          s = p;
       else
         break;
     }
     else
       s = SB - SA;
   }
  cout << s << endl;
}


Measured memory_bytes: 3640
while True:
    a,b,c=map(int,input().split())
    if a==-1 and b==-1 and c==-1 : break
    
    if a==-1 or b==-1 :
        print('F')
    
    elif a+b >= 80 :
        print('A')
    elif a+b >= 65 :
        print('B')
    elif a+b >= 50 :
        print('C')
    elif a+b >= 30 :
        if c >=50:
            print('C')
        else:
            print('D')
    else :
        print('F')


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

int main() {
  char b,ans;
  cin >> b;
  if(b=='A'){
    ans='T';
  }else if(b=='T'){
    ans='A';
  }else if(b=='C'){
    ans='G';
  }else if(b=='G'){
    ans='C';
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
d = dd(int)
for i in range(N):
  d[a[i]] += 1
ks = list(d.keys())
l = []
for k in ks:
  l.append(d[k])
l.sort(reverse = True)
res = 0
for _ in range(len(ks) - K): res += l.pop()
print(res)

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
namespace __gnu_pbds {
    typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
}
using namespace __gnu_pbds;

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}






int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("digits.in" , "r" , stdin);
//freopen("digits.out" , "w" , stdout);


     ll a,b,c,k;
     cin>>a>>b>>c>>k;
     ll ans=0;
     ans=min(a,k);
     k-=ans;
     if(k){
        ll how=min(k,b);
        k-=how;
     }
     if(k){
        ans-=min(k,c);
     }

     cout<<ans;






     return 0;

}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, a, b) for(int  i = a; i < b; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int N; 
bool used[100000+10];
vector<vector<int> > G;
map<pii,int> mp;
int K;

void bfs(int s){
    //for(int i = 0; i < N; i++) dist[i] = 1e9;
    K = 0;

    queue<pii> Q;
    Q.push({s,-1});
    used[s] = 1;
    //dist[s] = 0;

    while(!Q.empty()){
        int cnt = 1;
        pii v = Q.front(); Q.pop();
        //cout << "v " << v.first << endl;
        //used[v] = 1;
        for(auto nv: G[v.first]){
            if(used[nv] == 0){
                //dist[nv] = dist[v] + 1;
                if(cnt == v.second) cnt++;
                Q.push({nv, cnt});
                used[nv] = 1;
                mp[{v.first, nv}] = cnt;
                cnt++;
            }
        }
        K = max(K, cnt - 1);
    }
}

int main(){
    cin >> N;

    G.resize(N);
    vector<pii> P(N-1);
    rep(i, 0, N - 1){
        int a, b; cin >> a >> b; a--, b--;
        P[i] = {a,b};
        mp[{a,b}] = -1;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    bfs(0);
    cout << K << endl;
    rep(i, 0, N - 1) cout << mp[P[i]] << endl;

}

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

int main(){
    long long int n;
    cin>>n;
    long long int ans=10000000000000;
    for(long long int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            long long int j=n/i;
            ans=min(ans,j+i-2);
        }
        else int unko=0;
    }
    cout<<ans<<endl;
}

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

using lint = long long;


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= 9; ++i)
        for(int j = 9; j >= 1; --j)
            if (i*j == n) {
                cout << "Yes\n";
                exit(0);
            }
    cout << "No\n";
}

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

signed main(){
  string s;
  cin >> s;

  int pd[200000][2] = {};
  LOOP(i,s.length()){
    switch(s[i]){
      // case 'P':
      //   if(i!=0) pd[i][0] = pd[i-1][0];
      //   pd[i][0] = pd[i-1][0]++;
      //   pd[i][1] = -INF;
        break;

      case 'D':
        // if(i>0){
        //   pd[i][1] = max(pd[i-1][0]+1, pd[i-1][1]);
        // }
        // pd[i][0] = -INF;
        break;
      case '?':
        s[i] = 'D';
        if(i>0){
          pd[i][1] = max(pd[i-1][0]+1, pd[i-1][1]);
          pd[i][0] = max(pd[i-1][0]+1, pd[i-1][1]+1);
        }else{
          pd[i][1] = 0;
          pd[i][0] = 1;
        }
    }
    cerr << pd[i][0] << ":" << pd[i][1] << endl;
  }
  cout << s << endl;
}


Measured memory_bytes: 5280
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();
        int d = (int)a/b;
        int r = a%b;
        double f = (double)a/b;
        String str = String.format("%1$.6f", f);
        System.out.println(d + " " + r + " " + str);
    }
}


Measured memory_bytes: 26424
// ConsoleApplication5.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

int main()
{
	int a, b;
	std::cin >> a >> b;
	int c = 500 * a - b;
	if (c >= 0) { std::cout << "Yes" << std::endl; }
	else { std::cout << "No" << std::endl; }
	return 0;
}



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

long long dp[3002][3005];
long long a[100005];
long long w[100005];
long long v[100005];

int main()
{
    string s , t;

    cin >> s >> t;

    string ans;

    for(int i = 1 ; i<=s.size() ; i++)
    {
        for(int j = 1 ; j<=t.size() ; j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1;
                //ans = ans + s[i-1];
            }
            else
            {
                dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
            }
        }
    }


    for(int i = s.size() , j=t.size() ; i>=1 && j>=1 ; )
    {
            if(s[i-1]==t[j-1])
            {
                ans = ans + s[i-1];
                i--;
                j--;
            }
            else if(dp[i-1][j]>dp[i][j-1])
            {
                i--;
            }
            else
                j--;
    }

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

    cout << ans;
    return 0;
}


Measured memory_bytes: 71040
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int f=1;char ch = getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1;ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}

void solve(){
    int n;
    cin >> n;
    vector<pair<ll, ll> > v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i].F >> v[i].S;
    }
    sort(all(v));
    double len = 0;
    int cnt = 0;
    do{
        for(int i = 1; i < n; i++) {
            len += sqrt(pow(v[i].S - v[i - 1].S, 2) + pow(v[i].F - v[i - 1].F, 2)); 
        }
        cnt++;
    }while(next_permutation(all(v)));
    printf("%.9f", len / cnt);
}
 
int main(){
    //OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--)
    solve();
    return 0;
}

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

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

using namespace std;
using ll=long long;
const ll INF = 100000000;

int main() {
    ll n, tmp;
    cin >> n;
    tmp = n % 10;
    if (tmp == 2 || tmp == 4 || tmp == 5 || tmp == 7 || tmp == 9) {
        cout << "hon";
    } else if (tmp == 0 || tmp == 1 || tmp == 6 || tmp == 8) {
        cout << "pon";
    } else {
        cout << "bon";
    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int N = 50 + 5;

int n,m,q,a[N],b[N],c[N],d[N];
int ans,A[10];

void dfs(int x,int pre){
	if(x==n){
		int now=0;
		for(int i=0;i<q;i++) if(A[b[i]-1]-A[a[i]-1]==c[i]) now+=d[i];
		ans=max(ans,now);
	}else{
		for(int i=pre;i<=m;i++){
			A[x]=i;
			dfs(x+1,i);
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m>>q;
	for(int i=0;i<q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
	dfs(0,1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3624
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N, M, Q = map(int, input().split())
    A, B, C, D = [0] * Q, [0] * Q, [0] * Q, [0] * Q
    for i in range(Q):
        A[i], B[i], C[i], D[i] = map(int, input().split())

    ans = 0
    L = [i for i in range(1, M + 1)]
    LL = list(combinations_with_replacement(L,N))
    for i in LL:
        ls = i
        cnt = 0
        for j in range(Q):
            if ls[B[j] - 1] - ls[A[j] - 1] == C[j]:
                cnt += D[j]
        ans = max(ans, cnt)
    print(ans)


resolve()

Measured memory_bytes: 85204
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

typedef complex<double> P;
typedef vector<P> G;
const double EPS = 1e-10;
const double INF = 1e12;

struct L {
    P a, b, v;
    L(){}
    L(P _a, P _b) {a = _a, b = _b, v = b - a;}
    L(double _ax, double _ay, double _bx, double _by) {
        a = P(_ax, _ay), b = P(_bx, _by), v = b - a;
    }
};

double cross(P a, P b) {
    return imag(conj(a) * b);
}

double dot(P a, P b) {
    return real(conj(a) * b);
}

double areaG(G g) {
    int n = g.size();
    double ret;
    rep(i, n) {
        ret += cross(g[i], g[(i + 1) % n]);
    }
    return ret / 2;
}

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

    int n;
    cin >> n;
    G g;
    while (n--) {
        double x, y;
        cin >> x >> y;
        g.emplace_back(x, y);
    }

    printf("%.1f\n", areaG(g));
}

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

int main() {
  ios::sync_with_stdio(0);
  //int n; cin >> n;
  int a, b;
  cin >> a >> b;

  int add = 0;
  int now_empty = 1;
  while(now_empty < b) now_empty += (a - 1), add++;
  cout << add << endl;
  return 0;
}
/*
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(0);

  return 0;
}
 */

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll solve(ll n, ll x){
    if(n == 0)
    return 1;
    ll len = (ll)(pow(2, n + 2) + 0.1) - 3;
    ll p = (ll)(pow(2, n + 1) + 0.1) - 1;
    if(x == len)
    return p;
    if(x <= n)
    return 0;
    
    ll mid = len / 2;
    if(mid == x - 1)
    return 1LL + (ll)(pow(2, n) + 0.1) - 1;
    else if(mid < x - 1)
    return (ll)(pow(2, n) + 0.1) - 1 + 1LL + solve(n - 1, x - (2LL + (ll)(pow(2, n + 1) + 0.1) - 3LL));
    else
    return solve(n - 1, x - 1);
    
}
int main() {
    ll n, x;
    cin >> n >> x;
    cout << solve(n, x);
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;


int main(){
  int x,y;
  int t;
  while(cin >> x>> y,(x||y)){
    if(x>y){
      t=x;
      x=y;
      y=t;
    }
    cout << x <<" "<<y <<endl;
  }

  return 0;
}



Measured memory_bytes: 2988
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;




int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    cout << max(0, n - m + 1) << '\n';
    return 0;
}



Measured memory_bytes: 256
//Awwawa! Dis cold yis ratten buy tEMMIE!
#include <bits/stdc++.h>
#define ll long long
#define maxn 3005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll dp[maxn][maxn];
ll s[maxn][maxn];
int main() {
	int a, b, c, d;
	
	cin >> a >> b >> c >> d;
	for (int i = c; i >= a; i--)
		for (int j = d; j >= b; j--) {
			if (i == c && j == d) dp[i][j] = 1;
			else {
				dp[i][j] = 1ll * i * dp[i][j + 1] % mod;
				if (j == d)
					dp[i][j] = 1ll * j * dp[i + 1][j] % mod;
				else {
					dp[i][j] = (dp[i][j] + s[i + 1][j + 1] * j) % mod;
				}
				
			}
			s[i][j] = (s[i + 1][j] * (j - 1) + dp[i][j]) % mod;
		}
	cout << dp[a][b] << endl;
	return 0;
}


Measured memory_bytes: 144300
#include <iostream>
#include <string>

int main() {

	std::string str;
	std::string word ;
	int strLen;
	int wordLen;

	std::cin >> str;
	str += str;
	strLen = str.length();

	std::cin >> word;
	wordLen = word.length();
	

	for (size_t i = 0; i < strLen - wordLen; i++)
	{
		for (size_t j = 0; j < wordLen; j++)
		{
			if (!(str[i+j] == word[j]))
			{
				break;
			}
			if (j == wordLen - 1)
			{
				std::cout << "Yes\n";
				return 0;
			}
		}
	}
	std::cout << "No\n";

	return 0;
}


Measured memory_bytes: 3176
n = int(input())
a = []
b = []
for i in range(n):
  now = int(input())
  a.append(now)
  if now % 10 != 0:
    b.append(now)
if sum(a) % 10 != 0:
  print(sum(a))
elif len(b) != 0:
  print(sum(a)-min(b))
else:
  print(0)

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

int main(){
   
    int N;
    cin>>N;
    vector<int> S(N+1);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    S[N]=0;
    int cnt=0;
    bool flag=true;
    while(flag){
        flag=false;
    for(int i=0;i<N;i++){
        if(S[i]!=0){
            S[i]--;
            if(S[i+1]==0) cnt++;
            flag=true;
        }
    }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
/*input
20
>>>><>>><>><>>><<>>
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

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

#define ll long long
#define endl "\n"
#define all(c) c.begin(),c.end()
#define mod 1000000007
#define inf 1000000000000000001
#define F first
#define S second
#define dbg(x) cout << #x << " = " << x << '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll add(ll a,ll b)
{
    return (a%mod+b%mod)%mod;
}

ll sub(ll a,ll b)
{
    return (a%mod-b%mod+mod)%mod;
}

void solve()
{
    ll n,l,r;
    string s;
    cin>>n;
    cin>>s;
    ll dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    dp[1][1]=1;
    for(ll len=2;len<=n;len++)
    {
        ll pre[len]={0};
        pre[0]=0;
        for(ll i=1;i<=len-1;i++)
            pre[i]=add(pre[i-1],dp[len-1][i]);
        for(ll last=1;last<=n;last++)
        {
            if(s[len-2]=='<')
            {
                l=1;
                r=last-1;
            }
            else
            {
                l=last;
                r=len-1;
            }
            if(l<=r)
                dp[len][last]=add(dp[len][last],sub(pre[r],pre[l-1]));
        }
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
        ans=add(ans,dp[n][i]);
    cout<<ans;
}

int main() 
{
    off;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include<algorithm>
#define DIM 200005
#define x first
#define y second
using namespace std;
int n, m, i, u, nr, sol;
int h[DIM], ok[DIM], ind[DIM], ff[DIM];
pair<int, int> v[DIM];
int cmp(int a, int b){
    return v[a].x > v[b].x;
}
int cmp2(int a, int b){
    return v[a].y < v[b].y;
}
void upd(){
    int c = nr, p = c / 2;
    while(p > 0 && v[ h[c] ].y > v[ h[p] ].y){
        swap(h[p], h[c]);
        c = p;
        p = c / 2;
    }
}
void elim(){
    int p = 1, c = 2;
    while(c <= nr){
        if(c + 1 <= nr && v[ h[c + 1] ].y > v[ h[c] ].y){
            c++;
        }
        if(v[ h[c] ].y > v[ h[p] ].y){
            swap(h[p], h[c]);
            p = c;
            c = p + p;
        }
        else{
            break;
        }
    }
}
int main(){
    cin>> n >> m;
    for(i = 1; i <= n; i++){
        cin>> v[i].x >> v[i].y;
        ind[i] = i;
    }
    sort(ind + 1, ind + n + 1, cmp);
    u = 1;
    for(i = m; i >= 1; i--){
        while(v[ ind[u] ].x == i){
            h[++nr] = ind[u];
            upd();
            u++;
        }
        if(nr != 0){
            ff[i] = 1;
            ok[ h[1] ] = 1;
            swap(h[1], h[nr]);
            nr--;
            elim();
        }
    }
    nr = 1;
    for(i = 1; i <= m; i++){
        if(ff[i] == 1){
            ff[i] = 0;
            ff[nr] = 1;
            nr++;
        }
    }
    for(i = 1; i <= n; i++){
        ind[i] = i;
        sol += ok[i];
    }
    nr = 0;
    sort(ind + 1, ind + n + 1, cmp2);
    u = 1;
    for(i = 1; i <= m; i++){
        while(v[ ind[u] ].y == i){
            if(ok[ ind[u] ] == 0){
                nr++;
            }
            u++;
        }
        if(nr > 0 && ff[i] == 0){
            sol++;
            nr--;
        }
    }
    cout<< n - sol;
}


Measured memory_bytes: 4992
const input = require("fs").readFileSync("/dev/stdin", "utf8")
let cin = input.split(/ |\n/), cid = 0
const next = () => cin[cid++]
const nexts = (n) => cin.slice(cid, cid+=n).map(i=>parseInt(i))

const numbers = nexts(5)
console.log(numbers.indexOf(0) + 1)


Measured memory_bytes: 29636
from collections import Counter
N, M = (list)(map(int, input().split()))
A = (list)(map(int, input().split()))
A[0] %= M

for i in range(1, N):
    A[i] += A[i-1]
    A[i] %= M

ans = 0

C = Counter(A)
for num, val in C.items():
    if num == 0:
        ans += val
    if val >= 2:
        ans += val*(val-1)//2
print(ans)


Measured memory_bytes: 14636
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		int a=in.nextInt(),b=in.nextInt(),c=in.nextInt(),k=in.nextInt();
		int ans=0;
		if(a>=k)
		{
			System.out.println(k);
		}
		else 
		{
			if(a+b>=k)
			{
				System.out.println(a);
			}
			else
			{
				int x=a-k+a+b;
				System.out.println(x);
			}
		}
	}
}

Measured memory_bytes: 35780
//
//  main.cpp
//  ABC_168_D
//
//  Created by Joe Mori on 2020/05/30.
//  Copyright © 2020 Joe Mori. All rights reserved.
//

#include<bits/stdc++.h>

int main() {
    // insert code here...
    int N,M;
    std::cin>>N>>M;
    std::vector<std::vector<int> >Graph(N);
    for(int i=0;i<M;i++){
        int a,b;
        std::cin>>a>>b;
        a--;
        b--;
        Graph[a].push_back(b);
        Graph[b].push_back(a);
    }
    std::vector<int>dist(N,-1);
    std::queue<int>que;
    dist[0]=0;
    que.push(0);
    
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for(int nv:Graph[v]){
            if(dist[nv]>0)continue;
            dist[nv]=v+1;
            que.push(nv);
        }
        
    }
    std::cout<<"Yes"<<std::endl;
    for(int i=1;i<N;i++){
        std::cout<<dist[i]<<std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 10096