akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
n = int(input())
r = [int(input()) for _ in range(n)]

maxv = -2 * (10 ** 9)
minv = r[0]

for i in range(1, n):
    maxv = max(maxv, r[i] - minv)
    minv = min(minv, r[i])

print(maxv)



Measured memory_bytes: 13604
#include <iostream>
#include <math.h>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

int n, k;

int typeA (int x) { return x * 2; }
int typeB (int x) { return abs(k - x) * 2; }

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

    int ans = 0;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        ans += min(typeA(x), typeB(x));
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
	int n,k,length,i,T,t;
	int x[100000+10],a[100000+10];
    cin >> T;
    for(t=0;t<T;t++)
    {
        length=0;
        cin >> n;
	    cin >> k;
	    if (n<=k)
		    length = 0;
        for(i=0;i<n;i++)
		    cin >> x[i];
        for(i=0;i+1<n;i++)
		    a[i]=x[i+1]-x[i];
        sort(a,a+n-1);
	    for(i=0;i<n-k;i++)
		    length+=a[i];
	    cout << length << endl;
    }
	return 0;
}


Measured memory_bytes: 3804
#include<iostream>
#include<cctype>
#include<cstring>
using namespace std;

int main(){
    while(true){
        string s;
        cin >> s;
        if(s == "-"){
            break;
        }
        int n;
        cin >> n;
        for(int i = 0; i < n; i++){
            int x;
            cin >> x;
            s = s.substr(x, s.size()-x) + s.substr(0,x);
            //cout << s << endl;
        }
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n; pii ps[2333];
pii jf(pii g)
{
	int x=__gcd(g.fi,g.se);
	if(x) g.fi/=x, g.se/=x;
	if(g.fi<0) g.fi=-g.fi,g.se=-g.se;
	return g;
}
map<pii,int> cnt;
pii operator - (pii a,pii b)
{
	return pii(a.fi-b.fi,a.se-b.se);
}
const int MOD=998244353;
ll qp(ll a,ll b)
{
	ll x=1;
	while(b)
	{
		if(b&1) x=x*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return x;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d%d",&ps[i].first,&ps[i].second);
	sort(ps+1,ps+1+n);
	ll ans=qp(2,n)-n-1;
	for(int i=1;i<=n;++i)
	{
		cnt.clear();
		for(int j=i+1;j<=n;++j)
			++cnt[jf(ps[j]-ps[i])];
		for(auto g:cnt)
			ans-=qp(2,g.se)-1;
	}
	ans=(ans%MOD+MOD)%MOD;
	cout<<ans<<"\n";
}

Measured memory_bytes: 256
m,d=map(int, input().split())
ans=0
for j in range(m):
  for i in range(d):
    if ((i+1)//10)*((i+1)%10)==j+1:
      if ((i+1)//10)>=2 and ((i+1)%10)>=2:
        ans+=1

print(ans)

Measured memory_bytes: 3064
A,B,C,D = map(int,input().split())

def lcd(a,b):
    return (a*b)/fractions.gcd(a,b)

import fractions

two = B // C
three = B //D

g = int(lcd(C,D))
six = B // (g)

btwo = (A-1) // C
bthree = (A-1) //D
bsix = (A-1) // (g)

a = B - two - three  + six
b = (A-1) - btwo - bthree  + bsix



print(a - b)


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "YES" << endl;}
void no(){ cout << "NO" << endl;}

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

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

  ll n;
  cin >> n;

  ll ans = INF;


  for(ll i = 1; i * i <= n; i++){
    if(n % i == 0){
      string s = to_string(i);
      string t = to_string(n / i);
      ll tmp = max(s.size(), t.size());
      ans = min(ans,tmp);
    }
  }

  cout << ans <<endl;




  return 0;
}



Measured memory_bytes: 3652
#include <stdio.h>

int main(){

  int x,i;
  for(i = 1 ;; i++){

    scanf("%d",&x);

      if(x != 0){
	printf("Case %d: %d\n",i,x);
      }
      else{
	break;
      }
  }

 
  return 0; 
}




  // i++ == i = i + 1 == i += 1

  /*
  //パターン１
  int i;
  for(i = 0 ; i < 1000; i++){

    printf("Hello World\n");

  }
  
  //パターン２
  i = 0;
  while(i < 1000){
    printf("Hello World\n");
    i++;
  }

  //パターン３
  i = 0;
  while(1){

    if(i == 1000){
      break;
    }

    printf("Hello World\n");
    i++;

  }
  */

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  string SS="0"+S+"0";
  string T="";
  for(long i=1;i<SS.length();i++)T+=48+(SS[i]!=SS[i-1]);
  long ans=LONG_MAX,N=T.length();
  for(long i=0;i<N;i++)if(T[i]=='1')ans=min(ans,max(N-i-1,i));
  cout<<(ans!=LONG_MAX?ans:S.length());
}

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

typedef long long ll;

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

    ll t,a;
    t=T[0]; a=A[0];
    for(int i=1; i<N; i++){
        ll tx,ay;
        tx = t/T[i]; ay = a/A[i];
        if(t%T[i]!=0) tx++;
        if(a%A[i]!=0) ay++;

        ll n;
        n = max(tx,ay);
        t = n*T[i]; a = n*A[i];
    }
	
    cout << t+a << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
i = 0
while i < n:
    if a[i] % 2 == 0 and (a[i] % 3 != 0 and a[i] % 5 != 0):
        print("DENIED")
        break
    else:
        i += 1
if i == n:
    print("APPROVED")

Measured memory_bytes: 3060
import numpy as np
*a, = map(int,input().split())
a = np.array(a)
dp = [0]*3
count = 0
if a[0] == a[1] == a[2]:print(0);exit()
for i in range(3):
    if a[i] % 2 == 1:dp[i] = 1
if dp.count(1) == 2:
    for i in range(len(a)):
        if dp[i] == 1:a[i] += 1
    count += 1
    while not a[0] == a[1] == a[2]:
        a[np.argmin(a)] += 2
        count += 1
elif dp.count(0) == 2:
    for i in range(len(a)):
        if dp[i] == 0:a[i] += 1
    count += 1
    while not a[0] == a[1] == a[2]:
        a[np.argmin(a)] += 2
        count += 1
else:
    while not a[0] == a[1] == a[2]:
        a[np.argmin(a)] += 2
        count += 1
print(count)

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

const int maxn = 100000 + 10;
vector <int> son[maxn];
vector <int> son_v[maxn];
int fa[maxn], vv[maxn];

void dfs(int u, int fath)
{
    fa[u] = fath;
    int tn = son[u].size();
    for (int i = 0; i < tn; i++)
    {
        int v = son[u][i];
        if (v != fath)
        {
            if (son_v[u][i] % 2 == 0)
            {
                vv[v] = vv[u];
            }
            else
            {
                vv[v] = 3 - vv[u];
            }
            fa[v] = u;
            dfs(v, u);
        }
    }
}

void Add(int a, int b, int v)
{
    son[a].push_back(b);
    son[b].push_back(a);
    son_v[a].push_back(v);
    son_v[b].push_back(v);
}

int main()
{
    int n = 0;  cin >> n;
    for (int i = 1; i < n; i++)
    {
        int a = 0, b = 0, v = 0;    cin >> a >> b >> v;
        Add(a, b, v);
    }
    vv[1] = 1;
    dfs(1, 0);
    for (int i = 1; i <= n; i++)
    {
        cout << vv[i] % 2 << '\n';
    }
    getchar(); getchar();
    return 0;
}

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

int main(){
  
  int n;
  cin>>n;
  vector<int> a(n);
  double ans = 0.0;
  
  for(int i=0; i<n; i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  
  ans=(double)a[0];
  for(int i=1; i<n; i++){
    ans=(double)(ans+a[i])/2;
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)


func main() {
	var s []byte
	fmt.Scan(&s)


	ans := ""
	if string(s[len(s)-1]) == "s" {
		ans = "es"
	} else {
		ans = "s"
	}
	fmt.Println(string(s)+ans)



}



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

int func(int, int, int, int, int, int);
int N, W, V = 0 /*, memo[1000][1000]*/;
vector <vector <int>> w;
int ma = 1, mb, mc, md;

int main(void) {
	int max = 0, n;
	cin >> N >> W;
	w=vector <vector <int>>(N, vector<int>(2,0));
	cin >> w[0][0] >> w[0][1];

	for (int i = 1; i < N; i++) {
		cin >> w[i][0] >> w[i][1];
	}

	sort(w.begin(), w.end());
	
	/*for (int i = 0; i < N; i++) {
		cout<< w[i][0] <<"  "<< w[i][1]<<endl;
	}*/


	for (int a = N; a >= 0; a--) {
		for (int b = N - a; b >= 0; b--) {
			for (int c = N - a - b; c >= 0; c--) {
				int d = N - a - b - c;
				V = func(0, W, a, b, c, d);
				if (max < V) {
					max = V;
				}
			}
		}
	}

	cout << max << endl;

}
int func(int i, int j, int a, int b, int c, int d) {
	int res = 0;
	for (int i = N-1; i >=0; i--) {
		if ((w[0][0] == w[i][0]) && (a != 0)) {
			j -= w[i][0];
			if (j < 0)
				break;
			res += w[i][1];
			a -= 1;
		}
		else if ((w[0][0] + 1 == w[i][0]) && (b != 0)) {
			j -= w[i][0];
			if (j < 0)
				break;
			res += w[i][1];
			b -= 1;
		}
		else if ((w[0][0] + 2 == w[i][0]) && (c != 0)) {
			j -= w[i][0];
			if (j < 0)
				break;
			res += w[i][1];
			c -= 1;
		}
		else if ((w[0][0] + 3 == w[i][0]) && (d != 0)) {
			j -= w[i][0];
			if (j < 0)
				break;
			res += w[i][1];
			d -= 1;
		}
	}
	return res;
}

/*int func(int i, int j, int a, int b, int c, int d) {
	int res;

	if (a > ma || b > mb || c > mc || d > md)
		return 0;

	if (i == N||(a==0&&b==0&&c==0&&d==0))
		res = 0;

	else if (j < w[i][0])
		res = func(i+1,j,a,b,c,d);

	else {
		if ((w[i][0] == w[0][0])&& a != 0) {

			res = max(func(i + 1, j, a, b, c, d), func(i + 1, j - w[i][0], a-1, b, c, d) + w[i][1]);
		}
		else if ((w[i][0] == w[0][0] + 1)&& b != 0) {

			res = max(func(i + 1, j, a, b, c, d), func(i + 1, j - w[i][0], a, b-1, c, d) + w[i][1]);
		}
		else if ((w[i][0] == w[0][0] + 2)&& c != 0) {

			res = max(func(i + 1, j, a, b, c, d), func(i + 1, j - w[i][0], a, b, c-1, d) + w[i][1]);
		}
		else if ((w[1][0] == w[0][0] + 3)&& d != 0) {

			res = max(func(i + 1, j, a, b, c, d), func(i + 1, j - w[i][0], a, b, c, d-1) + w[i][1]);
		}
		else {
			res = func(i + 1, j, a, b, c, d);
		}
	}
	//return memo[i][j]=res;
	return res;
}*/

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

template<typename T>void chmax(T &a,T b){a=max(a,b);}
template<typename T>void chmin(T &a,T b){a=min(a,b);}
using namespace std;

void solve(){
	int n,a,b;
	cin>>n>>a>>b;
	int ans=a+b-n;
	if(ans<0)ans=0;
	cout<<min(a,b)<<" "<<ans<<endl;
}

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


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

int main(){
    int k, x;
    cin >> k >> x;
    for(int i = x-k+1; i <= x+k-1; i++) cout << i << " ";
    cout << endl;
    return 0;
}

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

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

  bool flag = false;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= M; j++) {
      if (i * (M - j) + (N - i) * j == K) flag = true;
    }
  }

  flag == true ? cout << "Yes" << endl : cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
using namespace std;
int main(){
    int N; cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N);
    for(int i = 1; i <= N-1; i++) cin >> B[i];
    ll ans = 0;

    A[1] = B[1];
    A[N] = B[N-1];

    for(int i = 2; i <= N-1; i++){
        A[i] = min(B[i-1],B[i]);
    }

    for(int i = 1; i <= N; i++) ans += A[i];

    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;
int main(){
 int a;
 int count = 0;
 cin >> a;
 while ( a !=0 ) {
  if (a % 10 == 2) {
   ++count;
  }
 a = a / 10;
}
 cout << count << endl;
 return 0;
}


Measured memory_bytes: 256
#pragma region Macros

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

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
ostream &operator<<(ostream &out, vector<T> const &v) {
    for (auto &&a : v) out << a << " ";
    out << endl;
    return out;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int N;
    cin >> N;
    vi a(N);
    REP(i, N) {
        cin >> a[i];
    }
    int b = 0;
    int count = 1;
    REP(i, N - 1) {
        if (a[i + 1] > a[i]) {
            if (b == -1) {
                count++;
                b = 0;
            } else {
                b = 1;
            }
        }
        if (a[i + 1] < a[i]) {
            if (b == 1) {
                count++;
                b = 0;
            } else {
                b = -1;
            }
        }
    }

    cout << count;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


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

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

using namespace std;

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

  int n, m;
  cin >> n >> m;

  bool memo[n][2] = {};

  REP(i, m) {
    int a, b;
    cin >> a >> b;

    if (a == 1) {
      memo[b - 1][0] = true;
    } else if (b == n) {
      memo[a - 1][1] = true;
    }
  }

  bool ans = any_of(&memo[0], &memo[0] + n, [](bool *temp) -> bool {
    return temp[0] && temp[1];
  });
  cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, a, cnt[100001] = {}, er = 0;

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a;
		cnt[a]++;
	}
	for (int i = 1; i <= 100000; i++)er += max(cnt[i] - 1, (ll)0);
	if (er % 2) {
		cout << n - er - 1 << endl;
	}
	else {
		cout << n - er << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
s = input()
lis = list(s)
ans = ""
s_rev = ""
s1 = ""
s1_rev = ""
s2 = ""
s2_rev =""
n = len(s)

def check(s,t):
    if s == t:
        return True
    else:
        return False

for i in range(n):
    s_rev+=lis[n-i-1]
for i in range(0,int((n-1)/2),1):
    s1+=lis[i]
    s1_rev+=lis[int((n-1)/2)-i-1]
for i in range(int((n+1)/2), n, 1):
    s2+=lis[i]
    s2_rev+=lis[int((n+1)/2)-i-1]

tf1 = check(s,s_rev)
tf2 = check(s1,s1_rev)
tf3 = check(s2,s2_rev)
if tf1 == True and tf2 == True and tf3 == True:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define N 1001
using namespace std;
vector<int> T[N];
int par[N];
map<string,int> M;
string mp[N];
int n,m;
int pos=0,used[N];

int cnt(int i){
  int sp=0;
  while(mp[i][sp]==' ')sp++;  
  return sp;
}

void mk_tree(){
  int idx=pos;
  int sp1=cnt(pos++);
  while(pos<n){
    int sp2=cnt(pos);
    if(sp1<sp2){
      T[idx].push_back(pos);
      par[pos]=idx;
      mk_tree();
    }
    else break;
  }
}

bool check(int pos,int target){
  if(pos==target) return 1;
  for(int i=0;i<T[pos].size();i++)
    if(check(T[pos][i],target))return 1;
  return 0;
}

int main(){
  while(1){
  cin>>n>>m;
  if(n==0&&m==0)break;
  
  M.clear();
  memset(used,0,sizeof(used));
  memset(par,0,sizeof(par));
  for(int i=0;i<N;i++)T[i].clear();

  n++;
  mp[0]="#######";
  M[mp[0]]=0;
  getline(cin,mp[0]);
  for(int i=1;i<n;i++){
    getline(cin,mp[i]);
    mp[i]=" "+mp[i];
    int j=0;
    while(mp[i][j]==' ')j++;
    M[mp[i].substr(j,mp[i].size()-j)] = i;
  }
  pos=0;
  mk_tree();  

  while(m--){
    string name1,str,name2,tmp;
    cin>>name1>>tmp>>tmp>>str>>tmp>>name2;
    name2=name2.substr(0,name2.size()-1);
    int ans=0;
    if(str=="child"||str=="parent"){
      if(str=="child")swap(name1,name2);
      int idx=M[name1],target=M[name2];
      for(int i=0;i<(int)T[idx].size();i++)if(T[idx][i]==target)ans=1;
    }
    if(str=="ancestor"||str=="descendant"){
      if(str=="descendant")swap(name1,name2);
      ans=check(M[name1],M[name2]);
    }
    if(str=="sibling") ans=par[M[name1]]==par[M[name2]];
    cout<<(ans?"True":"False")<<endl;
  
  }
  cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define pi 2*acos(-1)
#define max 1000005
int main()
{
    ll n,m,i,a;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>a;
        n-=a;
    }
    if(n>=0)
        cout<<n<<endl;
    else
        cout<<-1<<endl;
}


Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:35:24 2020

@author: Kanaru Sato
"""

a,b,c,k = list(map(int,input().split()))

if k <= a:
    print(k)
elif a<k and k<=a+b:
    print(a)
else:
    print(a-k+(a+b))


Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=55559;
const int MOD=1e9+7;
bool prime[N];

void init(){
    for(int i=2;i<=N-1;i++) prime[i]=true;
    for(int i=2;i<=N-1;i++){
        if(prime[i]){
            for(int j=i+i;j<=N-1;j+=i)  prime[j]=false;
        }
    }
    return ;
}

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

    init();
    vector<int> t;
    for(int i=1;i<=N-1;i++)
        if(prime[i])    t.pb(i);
//    cout << (int) t.size() <<endl;
    int n;
    cin >>n;
    int cnt=0;
    vector<int> ans;
    for(auto te:t){
        if(te%10==7){
            ans.pb(te);
        }
    }
    for(int i=1;i<=n;i++)   cout << ans[i]<<" ";

    return 0;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static long method(long c){
		long checker = 100;
		for (int i = 0; i < c; i++){
			//checker = (long) Math.floor(checker * (1 + 0.01));
			checker *= 1.01;
		}
		return checker;
	}

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long X = Long.parseLong(scan.nextLine());
		long year = 0;
		long head = 0;
		long tail = 3760;
		long center = 0;

		while (head <= tail){
			center = (head + tail) / 2;
			long checker = method(center);
			// = (long) Math.floor(100 * Math.pow((1 + 0.01), center));
			//System.out.println(checker);
			if (checker > X) {
				tail = center - 1;
			}else {
				head = center + 1;
			}
		}

		//System.out.println(head +" "+ center +" "+ tail);

		long[] arr = {head, center, tail};
		Arrays.sort(arr);

		if (X <= method(arr[0])){
			System.out.println(arr[0]);
		}else if (X <= method(arr[1])){
			System.out.println(arr[1]);
		}else if (X <= method(arr[2])){
			System.out.println(arr[2]);
		}
	}
}

Measured memory_bytes: 35796
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,L;
  cin >> N>> L;
vector<string> v(N);
  for(int i = 0;i < N ;i++){
    cin >> v[i];
  }
   sort(v.begin(),v.end());
  for(int i = 0;i< N;i++){
  cout << v[i];
  }
  cout << endl;
  
}

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

using namespace std;

int main()
{
  int n, k; cin >> n >>k;
  int a[n+1];
  memset(a, 0, sizeof(a));
  while(k--)
  {
  	int m; cin >> m;
  	while(m--)
  	{
  		int x; cin >> x;
  		a[x] = 1;
  	}
  }
  int ans = n;
  for(int i = 1; i<= n; i++)
  {
  	ans -= a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;


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

    int sum_max = 0;
    for(int trig = 0; trig < N; trig++){
        int sum = 0;
        for(int i = 0; i < N; i++){
            if(trig < i) sum += A[1][i];
            else if(trig == i) sum += A[0][i] + A[1][i];
            else sum += A[0][i];
        }
        sum_max = max(sum_max, sum);
    }
    cout << sum_max << endl;
}

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



int main() {
  string a,b,c;
  cin >> a >>b >> c;
  int ag=-1,bg=-1,cg=-1;
  char q='a';
  while(1){
    if(q=='a'){
      ag++;
      if(ag==a.size()){cout << 'A' << endl; return 0;}
      q=a[ag];
      continue;
    }
    if(q=='b'){
      bg++;
      if(bg==b.size()){cout << 'B' << endl; return 0;}
      q=b[bg];
      continue;
    }
    if(q=='c'){
      cg++;
      if(cg==c.size()){cout << 'C' << endl; return 0;}
      q=c[cg];
      continue;
    }

  }
}

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

int main(void) {
    string S;
    getline(cin, S);
    for (int i = 0; i < S.size(); i++) {
        char s = S[i];
        if (s >= 'a' && s <= 'z') printf("%c", s - 'a' + 'A');
        else if (s >= 'A' && s <= 'Z') printf("%c", s + 'a' - 'A');
        else printf("%c", s);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    
    static int cnt;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        shellSort(a, n);
    }
    
    static void insertionSort(int[] a, int n, int g){
        
        for(int i = g; i < n; i++){
            int v = a[i];
            int j = i-g;
            while(j >= 0 && a[j] > v){
                a[j+g] = a[j];
                j = j-g;
                cnt++;
            }
            a[j+g] = v;
        }
    }
    
    static void shellSort(int[] a, int n){
        
        cnt = 0;
        List<Integer> list = new ArrayList<>();
        list.add(1);
        int j = 0;
        while((list.get(j)*3 +1) < a.length){
            list.add(list.get(j)*3 +1);
            j++;
        }
        Collections.reverse(list);
        Integer[] g = list.toArray(new Integer[list.size()]);
        int m = g.length;
        for(int i = 0; i < m; i++){
            insertionSort(a, n, g[i]);
        }
        
        StringBuilder sb = new StringBuilder();
        sb.append(m).append(System.lineSeparator());
        for(int i = 0; i < m; i++){
            sb.append(g[i]).append(" ");
        }
        sb.deleteCharAt(sb.length()-1).append(System.lineSeparator());
        sb.append(cnt).append(System.lineSeparator());
        for(int i = 0; i < n; i++){
            sb.append(a[i]).append(System.lineSeparator());
        }
        
        System.out.print(sb);
    }
}


Measured memory_bytes: 180836
import math
import sys
from itertools import combinations 
import itertools

def main():
    h, w, n = list(map(int, input().split()))
    c = [input() for _ in range(h)]
    ans = 0
    black = 0
    for i in range(2 **h):
        for j in range(2 **w):
            black = 0
            for k in range(h):
                for l in range(w):
                    if ((i >>k) & 1) == 0 and ((j >> l) & 1) == 0:
                        if c[k][l] == "#":
                            black += 1
            if black == n:
                ans += 1
    print(ans)
    
main()

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

int main()
{
    i64 a;
    string b;
    cin >> a >> b;
    int bb = (b[0] - '0')*100+(b[2] - '0')*10+(b[3] - '0');

    i64 ans = a*bb/100LL;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
from math import degrees, atan2

def max_degree(a, b, x):
  full = a ** 2 * b
  half = full / 2
  if x == half:
    return 45
  elif x < half:
    e = (x * 2)/ (a * b)
    return degrees(atan2(b, e))
  else:
    e = ((full - x) * 2) / (a * a)
    return degrees(atan2(e, a))
    

a, b, x = map(int, input().split())
print(max_degree(a, b, x))

Measured memory_bytes: 3188
A = int(input())
B = int(input())
C = int(input())
S = int(input())
Ans = 0

for i in range(A+1):
    A500 = 500 * i
    for j in range(B+1):
        B100 = 100 * j
        for k in range(C+1):
            C50 = 50 * k
            if (A500+B100+C50) == S:
                Ans += 1
print(Ans)




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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, k;
int a[N], ans;
int d[N], mx[N];
bool u[N];
vector < int > g[N];
vector < int > gr[N];

void dfs (int v, int pr = 1) {
    mx[v] = d[v];
    for (auto to : g[v]) {
        if (to == pr) continue;
        d[to] = d[v] + 1;
        dfs (to, v);
        mx[v] = max(mx[v], mx[to]);
    }
    if (pr != 1 && mx[v] - d[v] >= k - 1) {
        mx[v] = 0;
        ++ ans;
    }
}
int main () {
    cin >> n >> k;
    For (i, 1, n) {
        cin >> a[i];
    }
    if (a[1] != 1) {
        a[1] = 1;
        ++ ans;
    }
    For (i, 1, n) {
        g[a[i]].pb(i);
    }
    dfs(1);
    cout << ans;
    return Accepted;
}

// Coded By OB

Measured memory_bytes: 44416
#include<stdio.h>
int solve(int,int);



int n,A[20];

int main(){
  int q,M,i;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}





int solve(int i,int m){
  if(m==0)return 1;
  if(i>=n)return 0;
  int res  =solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}

Measured memory_bytes: 2660
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

/***************/

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}

int gcd (int a, int b) {
    while (b > 0) {
        int t = a % b;
        a = b, b = t;
    }
    return a;
}

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

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << (k & 1 ? b - a : a - b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

map<char,ll> M;

int main(){
    ll N,C=1;cin>>N;
    string S;cin>>S;
    rep(i,N){
        M[S[i]]++;
    }
    for(auto P : M){
        if(P.second>0){
            C*=((P.second+1)%MOD);
            C%=MOD;
        }
    }
    cout << (C+MOD-1)%MOD << endl;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

signed main(){
    int n,m;
    cin>>n>>m;
    ll x[110000],y[110000],X[110000],Y[110000];
    for(int i=1;i<=n;i++) cin>>x[i];
    for(int i=1;i<=m;i++) cin>>y[i];

    for(int i=2;i<=n;i++) X[i-1]=x[i]-x[i-1];
    for(int i=2;i<=m;i++) Y[i-1]=y[i]-y[i-1];

    ll ans=0,sumX=0,sumY=0;
    for(int i=1;i<=n-1;i++){
        sumX+=X[i]*i*(n-i);
        sumX%=MOD;
    }
    for(int i=1;i<=m-1;i++){
        sumY+=Y[i]*i*(m-i);
        sumY%=MOD;
    }
    cout<<sumX*sumY%MOD<<endl;

}


Measured memory_bytes: 3584
S = input()
N = len(S)

ans = "Yes"

for x in range(N // 2):
    if S[x] != S[N-x-1]:
        ans = "No"

for x in range(0, (N-1)//2):
    if S[x] != S[(N-1)//2 - 1 - x]:
        ans = "No"

for x in range(0, (N-1)//2):
    if S[(N-1)//2 + 1 + x] != S[N-1-x]:
        ans = "No"

print(ans)

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

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "parade"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);

int main()
{
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    cout << n * (n + 1) / 2;
    return 0;
}


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

int pi[233333];

int main()
{
	int h,n; scanf("%d%d",&h,&n);
	for(int i=1; i<=h+10000; i++) pi[i]=200000000;
	for(int i=1; i<=n; i++)
	{
		int a,b; scanf("%d%d",&a,&b);
		for(int j=a; j<=h+10000; j++) pi[j]=min(pi[j],pi[j-a]+b);
	}
	int sum=200000000;
	for(int i=h; i<=h+10000; i++) sum=min(sum,pi[i]);
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <array>
#include <list>
#include <string>
#include <algorithm>
#include <queue>
#include <numeric>
#include <random>
#include <iomanip>
#include <chrono>

using namespace std;


int main() {

	int n;
	cin >> n;

	set<int> value;

	bool flag = false;
	for (int i = 0; i < n; i++)
	{
		int v;
		cin >> v;
		if (value.find(v) != value.end()) flag = true;
		value.insert(v);
	}

	if (flag) cout << "NO" << endl;
	else cout << "YES" << endl;

	return 0;
}


Measured memory_bytes: 9600
n,q=map(int,input().split())
hoge=input()
huga=[0]
for i in range(n-1):
  flag=0
  if(hoge[i]=="A" and hoge[i+1]=="C"):
    flag=1
  huga.append(huga[-1]+flag)

for i in range(q):
  a,b=map(int,input().split())
  print(huga[b-1]-huga[a-1])

Measured memory_bytes: 7688
import std.stdio, std.string, std.conv;

void main() {
    int n = readln.chomp.to!int;
    int[] p = readln.split.to!(int[]);
    int cnt;
    foreach (i, x; p) {
        if (x != i + 1) ++cnt;
    }
    writeln(cnt < 3 ? "YES" : "NO");
}

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

#define full_auto(x) for(auto it=x.begin();it!=x.end();it++)
#define rff freopen("input.txt","r",stdin)
#define de(x) cout<<#x<<"="<<x<<endl
#define pii pair<int,int>
#define PQ priority_queue
#define setp setprecision
#define el cout<<endl
#define ll long long
#define pb push_back
#define mp make_pair
#define ins insert
#define re return
#define se second
#define fi first
const int INF=(int)INFINITY;

vector <int> g[100003];
int n,ans;

int dfs(int x,int f){
//	de(x);
	int a=0,c=0;
	for (auto i:g[x]){
		if (i==f) continue;
		c++;
		a+=dfs(i,x);
	}
	ans+=max(c-1-a,0);
//	cout<<x<<":"<<a<<" "<<c<<endl;
//	if (max(c-1-a,0)) cout<<"ans+="<<max(c-1-a,0)<<endl;
//	el;
	re (bool)max(a,c-1);
}

int main(){
	int mx=0,mxn=0;
	int x,y;
	cin>>n;
	for (int i=1;i<n;i++){
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
		if (g[x].size()>mx){
			mx=g[x].size();
			mxn=x;
		}
		if (g[y].size()>mx){
			mx=g[y].size();
			mxn=y;
		}
	}
	dfs(mxn,-1);
	cout<<max(ans,1);
	re 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)


int main()
{
    double a;
	int  b;
	cin >> a >> b;

	int x, y;
	int ans;
	int p = ceil(25 * a / 2);
	ans = max(p, 10 * b);

	if (4 * b + 4 <= 5 * a || 5 * a + 5 <= 4 * b)
	{
		ans = -1;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3816
#!/usr/bin/env python3
import sys

YES = "POSSIBLE"  # type: str
NO = "IMPOSSIBLE"  # type: str

def solve(N: int, K: int, A: "List[int]"):
    if K in A:
        print(YES)
        return
    
    if max(A) < K:
        print(NO)
        return
    
    ## 互いに素のものが一つでもあれば1が作れるからなんでも作れる→互いにそのものがあるか判定
    import fractions
    from functools import reduce
    def gcd_list(numbers):
        return reduce(fractions.gcd, numbers)
    
    if gcd_list(A) == 1:
        print(YES)
    else:
        if K%gcd_list(A) == 0:
            print(YES)
        else:
            print(NO)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17196
#include <stdio.h>
#include <string.h>
#include <string>
#include <iostream>

int main(void)
{
	std::string s;
	std::cin >> s;
	auto N = s.size();
	int k[100000 + 1];
	
	memset(k, 0, sizeof(k));

	int i,r, l, j;
	int r_w, l_w, esp;
	int c = 0;
	r = l = i = 0;

	while (i != N) {

		r = l = 0;
		while (s[i + r] != 'L')	r++;
		(r_w = i + r - 1),(l_w = i + r);

		while (s[i + r + l] != 'R')
		{
			l++;
			if (i + r + l == N) break;
		}

		i = i + r + l;
		k[r_w] += r / 2;

		if (r % 2 == 1)k[r_w]++;
		k[l_w] += r - k[r_w];

		esp = k[l_w];

		k[l_w] += l / 2;
		if (l % 2 == 1) k[l_w]++;
		k[r_w] += l - k[l_w] + esp;

	}
	for (i = 0; i < N - 1; i++)	printf("%d ", k[i]);
	printf("%d\n", k[N - 1]);
	
	return 0;
}


Measured memory_bytes: 1024
import turtle
kame = turtle.Turtle()
kame.speed(0)
kame.left(90)
while True:
	x = map(int,raw_input().split(','))
	if x[0] == 0 and x[1] == 0:
		break
	else:
		kame.fd(x[0])
		kame.right(x[1])
		continue
print int(kame.xcor())
print int(kame.ycor())

Measured memory_bytes: 10716
def prim(n,M):
    d = [None]*n
    p = [None]*n
    searched = [0]*n
    
    for i in range(n):
        d[i] = float("inf")
        p[i] = -1
    
    d[0] = 0
    
    while True:
        minv = float("inf")
        u = -1
        for i in range(n):
            if minv > d[i] and not searched[i]:
                u = i
                minv = d[i]
        
        if u == -1:
            break
        searched[u] = 1
        for v in range(n):
            if (not searched[v]) and M[u][v] != -1:
                if d[v] > M[u][v]:
                    d[v] = M[u][v]
                    p[v] = u

    s = 0
    for i in range(n):
        if p[i] != -1:
            s += M[i][p[i]]
    return print(s)

n = int(input())
M = [list(map(int,input().split())) for _ in range(n)]
prim(n,M)


Measured memory_bytes: 5900
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	string S;
	cin >> S;
	S[3] = '8';
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;

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

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

    if(n%2 ==1){
        cout << 0 << endl;
        return 0;
    }
    ll st =1;
    ll count = 0;
    

    while(st<=n){
        st *=5;
        count++;
    }
    st /=5;
    count--;
    ll answer = 0;

    for(int i = 0;i<count; i++){
            ll st2 = 2*st;
            answer += n/st2;
            st /= 5;
        
    }
    
    cout << answer << endl;
}


Measured memory_bytes: 256
#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;
  cin >> n;

  vector<bool> z(n,false);

  rep(i,n){
    int a,b;
    cin >> a >> b;
    if(a==b) z[i] = true;
  }

  int c = 0;
  rep(i,n){
    if(z[i]) c++;
    else c = 0;
    if(c==3){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


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

typedef long long int ll;

int main () {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll d,t,s;
    cin >> d >> t >> s;
    
    ll tt = ceil((double)d/s);
    
    if (tt<=t) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
    
}


Measured memory_bytes: 3728
N,C = list(map(int,input().split()))

discomforts = [[0]*(N+1)]
for _ in range(C):
    row = [0]
    row.extend(list(map(int,input().split())))
    discomforts.append(row)
grid = [[0]*(N+1)]
for _ in range(N):
    row = [0]
    row.extend(list(map(int,input().split())))
    grid.append(row)

color_counts = [[0]*(C+1) for i in range(3)]

for i in range(1,N+1):
    for j in range(1,N+1):
        color_counts[(i+j)%3][grid[i][j]] += 1

ans = float('inf')
for c0 in range(1,C+1):
    for c1 in range(1,C+1):
        for c2 in range(1,C+1):
            if c0 != c1 and c1 != c2 and c2 != c0:
                total = 0
                for i in range(1,C+1):
                    total += discomforts[i][c0]*color_counts[0][i]
                    total += discomforts[i][c1]*color_counts[1][i]
                    total += discomforts[i][c2]*color_counts[2][i]
                ans = min(ans,total)
print(ans)

Measured memory_bytes: 46044
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main(void)
{
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int maxx = -50000, miny = 50000;

    for (int i = 0; i < n; i++)
    {
        int tempx;
        cin >> tempx;
        maxx = max(maxx, tempx);
    }

    for (int i = 0; i < m; i++)
    {
        int tempy;
        cin >> tempy;
        miny = min(miny, tempy);
    }

    bool flag = false;
    for (int i = maxx + 1; i <= miny; i++)
    {
        if (i > x && i <= y)
        {
            flag = true;
            cout << "No War" << endl;
            break;
        }
    }
    if (!flag)
        cout << "War" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    rep(i,3)rep(j,3){
        char c; cin>>c;
        if(i==j) cout<<c;
    }
    cout<<endl;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template<typename T> void print(const T & v);


int main() {
    ll N, K;
    cin >> N >> K;
    double ans = 0.0;
    for(ll i = 1; i <= N; i++){
        double p = 1.0;
        ll x = i;
        while(x < K){
            p /= 2.0;
            x *= 2;
        }
        ans += (p / N);
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
 
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
 
 
int main(){
  int m;
  cin>>m;
  while(m--){
    int g[5][5];
    for(int y=0;y<5;y++){
      for(int x=0;x<5;x++){
    cin>>g[y][x];
      }
    }
    int ans=0;
    for(int l=0;l<5;l++){
      for(int r=l;r<5;r++){
    for(int t=0;t<5;t++){
      for(int b=t;b<5;b++){
        int f=1;
        int c=0;
        for(int y=l;y<=r;y++){
          for(int x=t;x<=b;x++){
        f&=g[y][x];
        c++;
          }
        }
        if(f&&ans<c){
          ans=c;
        }
      }
    }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3088
N = int(input())
A = list(map(int,input().split()))
j = 1
n = 0
while n <= N-1:
    try:
        n = A.index(j,n)
        n += 1 
        j += 1   
    except ValueError:
        j = j-1
        if j == 0:
            print(-1)
        else:
            print(N-j)
        exit()
print(N-j+1)  

Measured memory_bytes: 77516