akhauriyash/Code-Regression huggingface dataset:
using System;

namespace CSsample
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());
            int e = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());
            if (e - a > k)
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine("Yay!");
            }
        }
    }
}



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

int main()
{
  int H,W;
  
  while(1)
  {
    cin >> H >> W;
    
    if(H==0||W==0)
      break;
    
    for(int i=0;i<W;i++)
    {
      cout << '#';
    }
    cout << endl;
    
    for(int b=0;b<(H-2);b++)
    {
    cout << '#';
    
    for(int a=0;a<(W-2);a++)
    {
      cout << '.';
    }
    cout << '#' << endl;
  }
    for(int i=0;i<W;i++)
    {
      cout << '#';
    }
    cout << endl;
    
    cout << endl;
  }
}


Measured memory_bytes: 3028
#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 ,k;
    cin >> n>> k;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    sort(a.begin(),a.end());
    int  sum = 0;
    rep(i,k){
        sum += a[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 	
 	int n; cin >> n;
 	for(int i = 1; i < 10; i++){
 		if(n%i == 0 && n/i <= 9){
 			cout << "Yes\n";
 			return 0;
 		}
 	}
 	cout << "No\n";
 
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
main(){
  int key,A[N],j,i,n,a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
   scanf("%d",&A[i]);
  }

  for(i=1;i<=n;i++){
    key = A[i];
    j=i-1;
     for(a=0;a<n-1;a++){
      printf("%d ",A[a]);
    }
     printf("%d\n",A[n-1]);
    while(j>=0 && A[j]>key){
      A[j+1] = A[j];
      j--;
      A[j+1] = key;
    }
  }
  return 0; 
}

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

int main() {
  int P, Q, R; 
  cin >> P >> Q >> R;
  
  int pq = P + Q;
  int pr = P + R;
  int qr = Q + R;

  int result = 0;
  if(pr < pq){
    if(pr < qr){
      result= pr;
    }
    else{
      result = qr;
    }
  }
  else{
    if(pq < qr){
      result = pq;
    }
    else{
      result = qr;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n, d = map(int,input().split())
x = []
for i in range(n):
    x.append([int(i) for i in input().split()])

ans = 0
for i in range(n): #iは1個目の点
    for j in range(i + 1, n): #jは２つ目の点
        tmp = 0
        for k in range(d): #dは次元
            tmp += pow(x[i][k] - x[j][k], 2)
        #print(tmp)
        if pow(tmp, 0.5) % 1 == 0:
            ans += 1
print(ans)


Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
int mod(ll a){
    int c=a%1000000007;
    if(c>=0)return c;
    else return c+1000000007;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

/////////////////////////////////




int main(){
    int n;cin>>n;
    while(n--){
        int a[10];for(int i=0;i<=9;i++)cin>>a[i];
        int b=0,c=a[0];int i=1;
        while(i<=9){
            if(c<a[i])c=a[i];
            else if(b<a[i])b=a[i];
            else break;
            i++;
        }
        i==10?cout<<"YES"<<endl:cout<<"NO"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3064
#include <cstdio>
int main()
{
	char s[5];
	scanf("%s", s);
	for (int i = 0; i < 3; i++) {
		if (s[i] == s[i + 1])
			return printf("Bad\n"), 0;
	}
	printf("Good\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  cin >> s >> t;
  
  vector <char> S(s.begin(), s.end());
  vector <char> T(t.begin(), t.end());
  
  int sum = 0;
  
  for(int i = 0; i < S.size(); i++){
    if(S[i] != T[i]){
      sum++;
    }
  }
  
  cout << sum;
  
}

Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 2e5+10;
LL num[maxn],sum[maxn];
const LL mod =1e9+7;
int main()
{
    LL n;
    cin >> n;
    for(int i = 1;i<=n;++i)
    {
        cin >> num[i];
        sum[i] = (sum[i-1]+num[i])%mod;
    }
    LL ans = 0;
    for(int i = 1;i<=n;++i)
    {
        ans = (ans+num[i]*(sum[n]-sum[i]+mod))%mod;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6768
#include <iostream>
using namespace std;
int l,r,d,x,ans;
int main() {
	
	cin>>l>>r>>d;
	
	ans=r/d;
	if(l==r&&l%d==0)
	{
		cout <<1;
		return 0;
	}
	if(l==r&&l%d!=0)
	{
		cout <<0;
		return 0;
	}
	if(l==d||l<d)
		x=0;
	else
		x=l/d;

	cout <<ans-x;
	
	return 0;
}

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

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < m; i++)
        cin >> b.at(i);
    int s, ac = 0;
    for (int i = 0; i < n; i++)
    {
        s = 0;
        for (int j = 0; j < m; j++)
        {
            cin >> a.at(i).at(j);
            s += a.at(i).at(j) * b.at(j);
        }
        if (s + c > 0)
            ac++;
    }
    cout << ac << endl;
}

Measured memory_bytes: 256
//#pragma region ALL(include define etc)
#include <iostream>   // swap(a, b)
#include <string>
#include <cmath>      // abs(絶対値) sin cos tan(角度 / 180.0 * 3.141592)
#include <vector>     // vec.push_back(a) vec.pop_back()
#include <algorithm>  // max(a, b) min(a, b) reverse() sort()
#include <functional> // sort(a, a + N, greater<型>());
#include <limits>
#include <math.h>
#include <iomanip>
#define int long long
//#define int unsigned long long
#define ll long long
#define double long double
using namespace std;
//#pragma endregion

signed main()
{
	// 10^18 = 1000000000000000000

	//int h1, h2, m1, m2, k;
	//int box, box1,box2;

	//int N;
	int n;
	//char n;
	//int a, b, c;
	//int m;
	int h, w, x;
	int k;
	int d;
	//int t;
	//string s;
	//string t;
	//int m1, m2;
	//int a, b, c, k;
	//int x, y;

	string s;
	//string s[100000];
	//string c[7];
	//int a[100000];
	//int b[200000];
	//int a[2000000] = { 0 };
	//int b[2000000] = { 0 };
	//int a[20000] = { 0 };
	//int b[20000] = { 0 };
	//vector<int>a(2000000);
	//vector<int>b(2000000);

	//int aaa = 0;
	//int bbb = 0;

	//int box[20000] = { 0 };
	char box[20000];
	int b[20000] = { 0 };
	//int box = 0;
	//int box[7][7] = { 0 };
	//int box2;
	//int p[1111];
	//int x[2000], y[2000];
	//int l[100];


	//long double aaa;

	int count = 0;
	//int k, d;
	//int a = 0;
	int all = 0;
	//double all;
	//double a, b;
	//double h, m;
	//int a[30000] = { 0 };
	//double c, d, e;

	//double mbox, hbox;
	//double box, box2;

	bool flag = true;
	//bool flag = false;

	//string str;

	//cin >> h1 >> m1 >> h2 >> m2 >> k;
	//cin >> n;
	//cin >> a >> b >> c;
	//cin >> s;
	//cin >> h >> w >> k;
	//cin >> n >> x >> t;

	getline(cin, s);

	count = s.length();

	for (int i = 0; i < count; i++)
	{
		all += s[i] - '0';
	}

	if (all % 9 == 0)
	{
		cout << "Yes\n";
	}
	else if (all % 9 != 0)
	{
		cout << "No\n";
	}
	/*count = n / x;
	if (n % x == 0)
	{
		all = t * count;
	}
	else if (n % x != 0)
	{
		all = t * (count + 1);
	}
	else
	{
		
	}*/


	//n = s.length();

	//sort(p, p + n);
	//n = n - 'Z';

	//box = n % 26;

	//for (int i = 0; i < k; i++)
	//{
	//	all += p[i];
	//}

	//all = n + (n * n) + (n * n * n);

	/*if (n > 0)
	{
		cout << "a\n";
	}
	else
	{
		cout << "A\n";
	}*/
	//n = t.length();

	/*cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tle << "\n";
	cout << "RE x " << re << "\n";*/

	//cout << x << "\n";
	//cout << all << "\n";
	//cout << box << "\n";
	//cout << a << b << c << "\n";

	/*if (flag == true)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}*/

	//cout << fixed << setprecision(111) << all;
	//return 0;
}


Measured memory_bytes: 3684
import java.util.Scanner;
 
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        
        int max = 0;
        for (int B = 1; B < 32; B++) {
        	for (int P = 2; P < 10; P++) {
        		int pow = (int)Math.pow(B, P);
        		if (pow <= X && pow > max) {
        			max = pow;
        		}
        	}
        }
        
        System.out.println(max);
    }
    
}

Measured memory_bytes: 21844
s=list(input())
n=len(s)
from collections import deque
q=deque([])

for i in range(n):
    if s[i]=='S':
        q.append('S')
    else:
        if q:
            if q[-1]=='T':
                q.append('T')
            else:
                q.pop()
        else:
            q.append('T')
print(len(q))

Measured memory_bytes: 61680
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }



int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	int a[n];
	int c = 0;
	forn(i, n){
		cin >> a[i];
		if(a[i] != i + 1)c++;
	}
	if(c == 2 || c == 0)puts("YES");
	else puts("NO");
	return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    vector< vector<ll> > dp(n, vector<ll>(2, 0));
    if (a[0] % 2 == 0)
    {
        dp[0][0] = 1;
        dp[0][1] = 2;
    }
    else
    {
        dp[0][0] = 2;
        dp[0][1] = 1;
    }
    for (int i = 0; i < n - 1; ++i)
    {
        if ((a[i + 1] % 2) == 0)
        {
            dp[i + 1][0] += dp[i][0] + dp[i][1] + dp[i][0] * 2;
            dp[i + 1][1] += dp[i][1] * 2;
        }
        else
        {
            dp[i + 1][0] += (dp[i][0] + dp[i][1]) * 2 + dp[i][0];
            dp[i + 1][1] += dp[i][1];
        }
    }
    cout << dp[n - 1][0];
    return 0;
}


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    map<string, int> ma;

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

    cout << ma.size() << endl;
    return 0;
}



Measured memory_bytes: 19200
S = input()
T = input()
dic = {}
for i,s in enumerate(S):
  if s not in dic:
    dic[s] = [i]
  else:
    dic[s].append(i)
#print(dic)
ind = -1
loop = 0
import bisect
for t in T:
  if t not in dic:
    ans = -1
    break
  if dic[t][-1]<=ind:
    loop += 1
    ind = dic[t][0]
  else:
    i = bisect.bisect_right(dic[t],ind)
    ind = dic[t][i]
  #print(ind)
#print(loop,ind)
else:
  ans = len(S)*loop+ind+1
          
print(ans)   

#print(*ans[1:], sep='\n')


Measured memory_bytes: 7600
def can_put(arr, point):
    for p in arr:
        if p[0] == point[0] or p[1] == point[1] or p[0]-p[1] == point[0]-point[1] or p[0]+p[1] == point[0]+point[1]:
            return False
    return True

K = int(input())
RC = [tuple(map(int,input().split())) for _ in range(K)]
def dfs(arr):
    if len(arr) == 8:
        se = set()
        for a in arr:
            se.add(a)
        for i in range(8):
            for j in range(8):
                if (i,j) in se:
                    print("Q", end="")
                else:
                    print(".", end="")
                if j == 7: print()
        exit()
    for i in range(8):
        for j in range(8):
            if can_put(arr, (i,j)):
                dfs(arr+[(i,j)])
dfs(RC)



Measured memory_bytes: 5624
import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
X = list(map(int,readline().split()))
Y = list(map(int,readline().split()))
DIV = 10 ** 9 + 7

# カウントする回数分X,Y軸ともに辺の長さを伸ばしていって巨大な長方形を作るイメージ
# X軸の、長さLの辺を3回数える場合、L * 2分X軸の辺の長さを伸ばす。
# X軸Y軸ともに各辺を数える回数が分かれば、巨大な長方形の面積はその積で求められる
# 
# X軸について、i番目の辺は、((i - 1) + 1) * (N - i)回数える
# 例：4番目の辺の場合
# ...X.. 
# Xより左から4通り（0も含むため） * Xより右から3通り(0も含むため)
# この回数分、辺の長さを掛けることを全ての辺に対して行った総和がX軸の辺の総量
# Y軸についても同じものを求めて、掛け合わせたものが答え

xsum = 0
for i in range(1, len(X)):
  # i番目の辺は、長さX[i] - X[i - 1]
  edge = X[i] - X[i - 1]
  # i番目の辺は((i - 1) + 1) * (N - i)回数える
  times = i * (N - i)
  xsum += ((edge % DIV) * (times % DIV)) % DIV
  xsum %= DIV

ysum = 0
for i in range(1, len(Y)):
  # i番目の辺は、長さY[i] - Y[i - 1]
  edge = Y[i] - Y[i - 1]
  # i番目の辺は((i - 1) + 1) * (M - i)回数える
  times = i * (M - i)
  ysum += ((edge % DIV) * (times % DIV)) % DIV
  ysum %= DIV

print((xsum * ysum) % DIV)

Measured memory_bytes: 24424
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

vector<vector<int>> d(10, vector<int>(10, 1000000));

void warshall_floyd(int n) {
    rep(k,n) rep(i,n) {
        rep(j,n) {
            d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
        }
    }
}

int main()
{
    int n, m; cin >> n >> m;
    char a[n][n], b[m][m];
    rep(i,n) rep(j,n) cin >> a[i][j];
    rep(i,m) rep(j,m) cin >> b[i][j];

    bool exist = false;
    for (int  ly= 0; ly < n; ly++) {
        for (int lx = 0; lx < n; lx++) {
            if (ly+m-1>= n || lx+m-1 >= n) continue;
            bool match = true;
            rep(y,m) {
                rep(x,m) {
                    if (a[ly+y][lx+x] != b[y][x])
                        match = false;
                }
            }
            if (match)
                exist = true;
        }

    }
    if (exist)
        cout << "Yes" << endl;
    else
        cout << "No"<< endl;
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
long long N, T, t[200010];
int main()
{
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		cin >> t[i];
	}
	long long an = T;
	for (int i = 0; i < N - 1; i++) {
		if (t[i + 1] - t[i] >= T) {
			an += T;
		}
		else {
			an += t[i + 1] - t[i];
		}
	}
	cout << an;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define umapi unordered_map<ll, ll>
#define umapc unordered_map<char, int>
#define endl "\n"
using namespace std;

/*
            ॐ
    || Jai Shree Ram ||  
 
 */


void solve()
{
    int n;
    cin>>n;

    unordered_map<string,int> mp;
    rep(i,n) {
        string s;
        cin>>s;

        mp[s]++;
    }

    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;

}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}




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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

int gcd(int a, int b){
  if(a == 0) return b;
  else return gcd(b%a, a);
}

int32_t main(){
  DESYNC;
  int n,k;
  cin >> n >> k;
  k = k+k+1;
  cout << (n+k-1)/k << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long 
#define ar array
#define f first
#define s  second
#define REP(i,n) for (int i=0;i<(n);i++)
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T>
using o_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; 

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);

  freopen("output1.txt","w",stdout);
#endif
}
const int mod=1000000007;
int power(int a,int b,int mod){
  a=a%mod;
  if(a==0){
    return 1;
  }
  int res=1;
  while(b){
    if(b&1){
      res=(res*a)%mod;
    }
    b>>=1;
    a=(a*a)%mod;
  }
  return res;
}

int  MMI(int p){
  return power(p,mod-2,mod);
}
int32_t main()
{
 c_p_c();
 
     string s;
     cin>>s;
     int ans=0;
     int len=0;
     int n=s.size();
     if(s[0]=='R')ans=1;
     for(int i=1;i<n;i++){
       if(s[i]=='R' && len==0){
        len++;
        ans=max(ans,len);
       }
      if(s[i]=='R' && s[i]==s[i-1]){
        len++;
        ans=max(ans,len);
      }
      else{
        len=0;
      }
     }
     cout<<ans<<"\n";

   
 
 
 return 0;  
 
}

Measured memory_bytes: 3584
import sys
list = input().split(" ")
N = int(list[0])
Y = int(list[1])

for yukichi in range(0,N+1):
    for ichiyo in range(0,N - yukichi + 1):
        hideyo = N - yukichi - ichiyo
        if 10000*yukichi + 5000*ichiyo + 1000*hideyo == Y:
            print(yukichi,ichiyo,hideyo)
            sys.exit()
 
print(-1,-1,-1)

Measured memory_bytes: 40556
/*\
 * ...
 * ......
 * In the name of ALLAH
 * ......
 * ...
 */

#include <bits/stdc++.h>

using namespace std;
#define Size(x) ((int)(x).size())
#define pb push_back
#define LD_OUT setprecision(12) << fixed
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int INF = 1e9 + 10;

int main()
{
	ios_base :: sync_with_stdio(false) ,cin.tie(0) , cout.tie(0);
	string s;cin>>s;
	int n = Size(s);
	for(int i=1;i<=n;++i){
		for(int d=0;d<26;++d){
			bool Fail = false;
			for(int j=0;j+i<=n;++j){
				bool f = false;
				for(int l=j;l<j+i;++l) if(s[l] - 'a' == d) f = true;
				if(!f) Fail = true;	
			}
			if(!Fail) return cout << i-1 << '\n' , 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int n, i, a, b, c;
 
    scanf("%d", &n);
    for (i = 0; i < n; ++i) {
        scanf("%d %d %d", &a, &b, &c);
        if ((a * a == b * b + c * c)
                || (b * b == c * c + a * a)
                || (c * c == a * a + b * b))
            printf("YES\n");
        else
            printf("NO\n");
    }
 
    return 0;
}

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    int n;
    in(n);
    int a[n + 2];
    ll sum = 0;
    a[0] = 0;
    a[n + 1] = 0;
    rep1(i, n + 1)
    {
        in(a[i]);
        sum += abs(a[i] - a[i - 1]);
    }

    rep1(i, n)
    {
        int tmp = sum;
        tmp = tmp + abs(a[i + 1] - a[i - 1]) - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]);
        out(tmp);
    }
}

Measured memory_bytes: 1664
# coding: utf-8

H, W = map(int, input().split(" "))

S = []
for i in range(H):
    tmp = input()
    S.append(list(tmp))


def eight_math_index(i, j, H, W):
    result = [(i-1, j-1), (i-1, j), (i-1, j+1),
              (i, j - 1), (i, j), (i, j + 1),
              (i + 1, j - 1), (i + 1, j), (i + 1, j + 1)]
    return list(filter(lambda x: (0 <= x[0] <= (H-1)) and (0 <= x[1] <= (W-1)), result))


for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            eight = eight_math_index(i, j, H, W)
            S[i][j] = 0
            for (k, l) in eight:
                if S[k][l] == "#":
                    S[i][j] += 1

for l in S:
    print("".join(list(map(str, l))))




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

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

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

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

int main(void){
	
	int N, i, count, flag;
	long *A;
	
	scanf("%d", &N);
	A = (long *)malloc(N * sizeof(*A));
	for( i = 0; i < N; i++ ){
		scanf("%ld", A + i);
		A = (long *)realloc(A, ( i + 2) * sizeof(*A) );
	}
	
	count = 0;
	flag = 0;
	while( 1 ){
		for( i = 0; i < N; i++ ){
			if( A[i] % 2 != 0 ) flag = 1;
		}
		if( flag == 1) break;
		for( i = 0; i < N; i++ ){
			A[i] /= 2;
		}
		count++;
	}
	printf("%d\n", count);
	free(A);
	
	return 0;
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}
const double PI=3.14159265358979323846;
template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int R;
  cin >> R;
  long double ans = 2 * R * PI;
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 3784
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<stdlib.h>
#include<iomanip>
#include<limits>
#include<queue>
#include<stack>
#include<math.h>
#include<array>

using namespace std;

#define rep(i, n) for( int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
//#define MAX_N 100
bool is_war( vector<int> x, vector<int> y){
	loop(Z, -100, 101){
		bool is_ok = true;
		rep(i, x.size()){
			if(x[i] >= Z){
				is_ok = false;
			}
		}
		rep(i, y.size()){
			if(y[i] < Z){
				is_ok = false;
			}
		}
		if(is_ok) return false;
	}
	return true;
}
int main(){
	int X, Y, N, M;
	cin >> N >> M >> X >> Y;
	vector<int> x(N + 1), y(M + 1);
	rep(i, N) cin >> x[i];
	rep(i, M) cin >> y[i];
	x[N] = X, y[M] = Y;
	if(is_war(x, y)){
		cout << "War" << endl;
	}else{
		cout << "No War" << endl;
	}
	return 0;
}

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

typedef unsigned uint;

bool is_exist_bin_search(uint v, std::vector<uint> s){
  uint min = 0, max = s.size();
  while(min < max){
    uint mid = (min + max) / 2;
    uint v_mid = s[mid];
    if(v_mid == v) return true;

    if(v_mid >= v) max = mid;
    else min = mid+1;
  }
  return false;
}

unsigned count(std::vector<uint> s, std::vector<uint> t){
  uint n = 0;
  for(uint i = 0; i < t.size(); i++){
    if(is_exist_bin_search(t[i],s)) n++;
  }
  return n;
}

int main(){
  //std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::vector<uint> s,t;

  {
    uint n;
    std::cin >> n;
    s.resize(n);
    for(uint i = 0; i < n; i++){
      std::cin >> s[i];
    }
  }

  {
    uint q;
    std::cin >> q;
    t.resize(q);
    for(uint i = 0; i < q; i++){
      std::cin >> t[i];
    }
  }

  std::cout << count(s,t) << '\n';
}

Measured memory_bytes: 2588
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++)
        a[i]=10;
    int s,c,check=0;
    for(int i=0;i<m;i++){
        cin>>s>>c;
        if(a[s-1]==10||a[s-1]==c)
            a[s-1]=c;
        else{
            a[s-1]=c;
            check=1;
        }
    }
    if(check==1||(a[0]==0&&n!=1))
        cout<<-1<<endl;
    else if(n==1&&(a[0]==10||a[0]==0))
        cout<<0<<endl;
    else{
        if(a[0]==10)
            a[0]=1;
        int ans=0;
        for(int i=0;i<n;i++)
            ans+=(a[i]%10)*pow(10,n-i-1);
        cout<<ans<<endl;
    }
    
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string s;
int x,y;

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

	cin >> s >> x >> y;

	vector<int> xo,yo;

	int flag_x[2][20005], flag_y[2][20005];
	memset(flag_x,0,sizeof(flag_x)); memset(flag_y, 0, sizeof(flag_y));
	flag_y[0][10000] = true;

	int cnt_t = 0;
	int len = 0;
	for (int i = 0;i < s.size();i++){
		if(s[i] == 'F') len++;
		else{
			if(cnt_t == 0){
				flag_x[0][10000+len] = true;
			}else if(cnt_t%2 == 1){
				yo.push_back(len);
			}else{
				xo.push_back(len);
			}
			len = 0;
			cnt_t++;
		}
	}
	if(cnt_t == 0){
		flag_x[0][10000+len] = true;
	}else if(cnt_t%2 == 1){
		yo.push_back(len);
	}else{
		xo.push_back(len);
	}

	int now = 0;

	for (int i = 0;i < xo.size();i++){
		memset(flag_x[(now+1)%2], 0, sizeof(flag_x[(now+1)%2]));
		for (int j = 0;j < 20000;j++){
			if(flag_x[now%2][j]){
				flag_x[(now+1)%2][j+xo[i]] = flag_x[(now+1)%2][j-xo[i]] = true;
			}
		}
		now++;
	}

	bool ans_x = flag_x[now%2][x+10000];

	now = 0;

	for (int i = 0;i < yo.size();i++){
		memset(flag_y[(now+1)%2], 0, sizeof(flag_y[(now+1)%2]));
		for (int j = 0;j < 20000;j++){
			if(flag_y[now%2][j]){
				flag_y[(now+1)%2][j+yo[i]] = flag_y[(now+1)%2][j-yo[i]] = true;
			}
		}
		now++;
	}

	bool ans_y = flag_y[now%2][y+10000];


	if(ans_x && ans_y) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()



template<const std::size_t N>
struct bfps: public std::bitset<N> {
  using size_type = std::size_t;
  size_type len;

  void recalc() {
    this->len = 0;
    for(i64 j = 5000; j --> 0;) {
      if((*this)[j]) {
        this->len = j + 1;
        return;
      }
    }
  }

  bfps() : std::bitset<N>() { this->len = 0; }
  //bfps(const std::uint_fast64_t x) : std::bitset<N>(x) { recalc(); }
  bfps(const std::bitset<N>& b) : std::bitset<N>(b) { recalc(); }
  size_type size() const { return this->len; }

  static std::pair<bfps, bfps> divmod(bfps a, const bfps& b) {
    assert(b.size() > 0);
    bfps d;
    for(i64 i = a.size() - b.size() + 1; i --> 0;) {
      if(a[i + b.size() - 1]) {
        a ^= (b << i);
        d ^= (bfps(1) << i);
      }
    }
    a.recalc();
    d.recalc();
    return std::pair<bfps, bfps>(d, a);
  }

  static bfps gcd(bfps a, bfps b) {
    while(b.any()) {
      auto dm = divmod(a, b);
      a = b;
      b = dm.second;
    }
    return a;
  }
};

using bits = bfps<5000>;

int main() {
  i64 N;
  cin >> N;
  bits X;
  cin >> X;
  X.recalc();

  vector<bits> A(N);
  rep(i,0,N) {
    cin >> A[i];
    A[i].recalc();
  }
  auto G = A[0];
  for(i64 i = 1; i < N; i++) {
    G = bits::gcd(G, A[i]);
  }
  i64 ans = 0;
  const i64 MOD = 998244353;
  if(X.size() - G.size() + 1 >= 0) {
    vector<i64> Bs(X.size() - G.size() + 1, 1);
    for(i64 i = 1; i < X.size() - G.size() + 1; i++) {
      Bs[i] = (Bs[i - 1] * 2) % MOD;
    } 
    bits now;
    for(i64 i = X.size() - G.size() + 1; i --> 0;) {
      if(X[i + G.size() - 1]) {
        ans = (ans + Bs[i]) % MOD;
      }
      if(now[i + G.size() - 1] != X[i + G.size() - 1]) {
        now ^= (G << i);
      }
    }
    bool OK = true;
    for(i64 i = 5000; i --> 0; ) {
      if(now[i] != X[i]) {
        if(now[i]) {
          OK = false;
        }
        break;
      }
    }
    if(OK) ans = (ans + 1) % MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>

char str_def[199999];
int S[59999];
int M,M_hf;
int N;
using namespace std;
priority_queue <int, vector<int>,greater<int> > oper[59999];
int cmp(const void *ka,const void *kb) {
	int a=*(int *)ka;
	int b=*(int *)kb;
	return a-b;
}
void add(int L,int R) {
	if(L==R) return;
	if(L>R) {
		oper[R].push(L);
	} else {
		oper[L].push(R);
	}
}
int mod26(int x) {
	while(x<0) x+=26;
	return x%26;
}
int eff[59999];
int main() {
	scanf("%s",str_def);
	while(str_def[M]!='\0') M++;
	M_hf=M/2;
	scanf("%d",&N);
	for(int i=0;i<N;i++) {
		int L,R;
		scanf("%d%d",&L,&R);
		L--;
		if(L>=M_hf+M%2) {
			add(M-R,M-L);
		} else if(R>=M_hf+M%2) {
			add(L,M-R);
		} else {
			add(L,R);
		}
	}
	//printf("%d\n",M_hf);
	for(int i=0;i<M_hf;i++) S[i]=mod26((int)str_def[M-1-i]-(int)str_def[i]);
	//for(int i=0;i<M_hf;i++) printf("%d\n",S[i]);
	for(int i=M_hf-1;i>0;i--) S[i]=mod26(S[i]-S[i-1]);
	//for(int i=0;i<M_hf;i++) printf("%d\n",S[i]);
	for(int i=0;i<M_hf;i++) {
		int req=mod26(S[i]+eff[i]);
		//printf("%d %d %d\n",i,S[i],eff[i]);
		if(oper[i].size()) {
			int top = oper[i].top();
			//printf("%d\n",top);
			eff[top]+=req;
			int recent = top;
			oper[i].pop();
			while(oper[i].size()) {
				top = oper[i].top();
				if(recent!=top) {
					add(recent,top);
					recent=top;
				}
				oper[i].pop();
			}
		} else {
			if(req) {
				printf("NO\n");
				return 0;
			}
		}
	}
	printf("YES\n");
	return 0;
}


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

typedef long long ll;

typedef pair<int,int>pii;
int main(){
    int H,W,D;
    map<int, pii> m;
    cin >> H >> W >> D;
    
    ll ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int tmp;
            cin >> tmp;
            tmp--;
            m[tmp] = make_pair(i,j);
        }
    }

    vector<int> v(H*W, 0);
    for(int i = 0; i < H*W; i++){
        if(i < D){
            v[i] = 0;
        } else { 
            v[i] = v[i-D] + abs(m[i].first - m[i-D].first) + abs(m[i].second - m[i-D].second);
        }
    }

    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int L,R;
        cin >> L >> R;
        L--; R--;
        cout <<  v[R] - v[L] << endl;
    }

}


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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef string str;
typedef vector<char> vc;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define all(a) a.begin(), a.end()

template <typename T>
T Sum(vector<T> n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (accumulate(n.begin() + a, n.end(), 0));
  }
  else
  {
    return (accumulate(n.begin() + a, n.begin() + b, 0));
  }
}
template <>
ld Sum(vector<ld> n, ll a, ll b)
{
  if (b == 0)
  {
    return (accumulate(n.begin() + a, n.end(), 0));
  }
  else
  {
    return (accumulate(n.begin() + a, n.begin() + b, 0));
  }
}

template <typename T>
void Sort(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b));
  }
}

template <typename T>
void Reve(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (reverse(n.begin() + a, n.end()));
  }
  else
  {
    return (reverse(n.begin() + a, n.begin() + b));
  }
}

template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}

template <typename T, typename U>
void V2(T &n, U &m)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i];
  }
}

template <typename T, typename U, typename W>
void V3(T &n, U &m, W &p)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i] >> p[i];
  }
}

void fYn(bool a)
{
  if (a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  exit(0);
}
//最大公約数
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
//最小公倍数
ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}
//複数個の最小公倍数
ll nlcm(vector<ll> numbers)
{
  ll res;
  res = numbers[0];
  for (ll i = 1; i < numbers.size(); i++)
  {
    res = lcm(res, numbers[i]);
  }
  return res;
}
//累乗(xのn乗%mod)
ll mod_pow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//大文字->小文字(+32)
//少数はなるべく整数に

void Main()
{
  ll n; cin >> n;
  fin(mod_pow(n, 3))
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {


    public void solve() throws IOException {
        int n = nextInt();
        int a[] = new int[n];
        int max = 0, min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
            max = Math.max(max, a[i]);
            min = Math.min(min, a[i]);
        }
        if(max - min > 1) {
            out.print("No");
            return;
        }else if(max - min == 0){
            if(max <= n / 2 || max == n - 1) out.print("Yes");
            else out.print("No");
            return;
        }else{
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                if(a[i] == min) cnt++;
            }
            if(cnt > min){
                out.print("No");
                return;
            }else{
                if(cnt + (max - cnt) * 2 > n){
                    out.print("No");
                }else out.print("Yes");
            }
        }
    }


    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Main().run();
    }

    void run() throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
//            br = new BufferedReader(new FileReader("queue.in"));
//            out = new PrintWriter(new File("queue.out"));
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

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

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

Measured memory_bytes: 34612
#include<stdio.h>

int main(){
  char N[4];
  int sum = 0;
  for(int i=0; i<4; i++){
    scanf("%c", &N[i]);
  }
  for(int j=0; j<4; j++){
    if(N[j] == '2')
     sum++;
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
def main():
    n, x = map(int, input().split())

    pb = [1]
    p = [1]
    for _ in range(n):
        pb.append(pb[-1] * 2 + 3)
        p.append(p[-1] * 2 + 1)

    ans = 0
    for _ in range(n):
        if x == 0:
            break
        if x >= pb[-2] + 2:
            x -= pb[-2] + 2
            ans += 1 + p[-2]
        else:
            x -= 1
        pb.pop(-1)
        p.pop(-1)

    if x >= 1:
        ans += 1

    print(ans)

main()

Measured memory_bytes: 8980
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,n;
    cin>>x>>n;
    int arr[n+5],ck[n+5],ans;
    vector<int>v(n);
    for(int i=0;i<n;++i){
        cin>>v[i];
        //ck[i]=arr[i];
    }
    /*for(int i=0;i<n;++i){
        ck[i]=(x-ck[i]);
        //cout<<ck[i];
    }
    int mn=INT_MAX,ans=INT_MAX;
    for(int i=0;i<n;++i){
        mn=min(mn,ck[i]);
    }
    for(int i=0;i<n;++i){
        if(ck[i]==mn){
            ans=min(arr[i],ans);
        }
    }*/
    int z=x,chk=x;
   // x-=1;
    if(n==0){
        cout<<chk;
    }
    else{
    while(1){
        auto it= find(v.begin(),v.end(),x);
        if(it!=v.end()){ x--;}
        auto it2= find(v.begin(),v.end(),z);
        if(it2!=v.end()) {z++;}
        if(it==v.end() || it2==v.end()){
                //z++;
                //x--;
                int p=z-chk;
                int n=chk-x;
                //cout<<z<<x;
            if(p<n){
                cout<<z;
            }
            else cout<<x;
            break;
        }
    }

}
}




Measured memory_bytes: 3608
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().replace(/\n/g, " ").split(" ");
var n = arr.shift() - 0;
var a = [];
for (var i = 0; i < 10000; i++) a[i] = false;
for (var i = 0; i < n; i++) {
    a[arr[i] - 0] = true;
    if (i + 1 < n) a[(arr[i] + arr[i + 1]) - 0] = true;
    if (i + 2 < n) a[(arr[i] + arr[i + 1] + arr[i + 2]) - 0] = true;
    if (i + 3 < n) a[(arr[i] + arr[i + 1] + arr[i + 2] + arr[i + 3]) - 0] = true;
}
for (var i = 0; i < 10000; i++) {
    if (a[i] == false) {
        console.log(i);
        break;
    }
}

Measured memory_bytes: 16964
#include <stdio.h>
 
using namespace std;
 
void output(int H[3][10]){
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
            printf(" %d",H[i][j]);
        }
        printf("\n");
    }
}
 
 
int main(){
    int H1[3][10],H2[3][10],H3[3][10],H4[3][10],n,h_num,f_num,r_num,div_num;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
            H1[i][j] = H2[i][j] = H3[i][j] = H4[i][j] = 0;
        }
    }
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%d %d %d %d",&h_num,&f_num,&r_num,&div_num);
        switch(h_num){
        case 1:
            H1[f_num-1][r_num-1] += div_num;
            break;
        case 2:
            H2[f_num-1][r_num-1] += div_num;
            break;
        case 3:
            H3[f_num-1][r_num-1] += div_num;
            break;
        case 4:
            H4[f_num-1][r_num-1] += div_num;
            break;
        }
    }
 
    output(H1);
    printf("####################\n");
    output(H2);
    printf("####################\n");
    output(H3);
    printf("####################\n");
    output(H4);
 
}


Measured memory_bytes: 2684
from math import sqrt, cos, radians
a, b, h, m = map(int, input().split())

def yogen(b, c, shi):
    return sqrt(b**2+c**2 - 2*b*c*cos(shi))

shi1 = radians(m / 60 * 360)
shi2 = radians((h * 60 + m)/(12*60)*360)

print(yogen(a, b, abs(shi1 - shi2)))


Measured memory_bytes: 62432
//package abc167.D

import java.io.*
import java.math.*
import java.util.*
import kotlin.math.*

var reader: BufferedReader = System.`in`.bufferedReader()
var writer: PrintWriter = PrintWriter(System.`out`)

fun next() = reader.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextStrings() = next().split(" ")
fun nextInts() = nextStrings().map { it.toInt() }
fun nextLongs() = nextStrings().map { it.toLong() }
fun nextDoubles() = nextStrings().map { it.toDouble() }

fun put(v: Any?) = writer.print(v)
fun puts() = writer.println()
fun puts(v: Any?) = writer.println(v)

var debug = false
fun dp(v: Any?) {
    if (debug) println(v)
}
fun dp() {
    if (debug) println()
}

fun test(case: Int, input: String, expected: String) {
    reader = input.trimIndent().reader().buffered()

    val stringWriter = StringWriter()
    writer = PrintWriter(stringWriter)

    solve()
    writer.flush()

    val actual = stringWriter.toString()

    println("[test $case]")
    if ("${expected}" == actual) {
        println("OK")
    } else {
        println("NG")
        println()
        println("expected: \"${expected}\"")
        println("actual:   \"${actual}\"")
    }
    println()
}

fun main(args: Array<String>) {
    if ((args.size == 1) && (args[0] == "test")) {
        testAll()
    } else {
        solve()
        writer.flush()
    }
}

///////////////////////////////////////////////////////////

fun testAll() {
    debug = true

    test(1,
    """
    4 5
    3 2 4 1
    """,
    "4")
    test(2,
    """
    6 727202214173249351
    6 5 2 5 3 2
    """,
    "2")
}

fun doSolve(): Int {
    val (N, K) = nextLongs()
    val towns = nextInts()

    if (K <= N) {
        var t = 1
        for (i in 0 until K) {
            t = towns[t-1]
        }
        return t
    }

    val visited = mutableMapOf<Int, Long>()
    var t = 1
    var first = 0L
    var second = 0L
    for (i in 0 until N) {
        if (visited.containsKey(t)) {
            first = visited[t]!!
            second = i
            break;
        }
        visited.put(t, i)
        t = towns[t-1]
    }

    val len = second - first
    val remain = (K - first) % len
    for (i in 0 until remain) {
        t = towns[t-1]
    }

    return t
}

fun solve() {
    put(doSolve())
}


Measured memory_bytes: 77272
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	ll x,y,cnt = 1;
	cin >> x >> y;
	
	while(1){
		x *= 2;
		if(y >= x) cnt++;
		else break;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int n, A[2000];
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;
}
int main(){
  int i,q,m;
  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;
}

Measured memory_bytes: 580
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

int A[3][3];
bool S[101];

void solve()
{
    REP0 (i, 3)
    {
        REP0 (j, 3)
        {
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    REP0 (i, N)
    {
        int b;
        cin >> b;
        S[b] = true;
    }

    REP0 (i, 3)
    {
        if (S[A[i][0]] and S[A[i][1]] and S[A[i][2]])
        {
            cout << "Yes" << endl;
            return;
        }
    }

    REP0 (i, 3)
    {
        if (S[A[0][i]] and S[A[1][i]] and S[A[2][i]])
        {
            cout << "Yes" << endl;
            return;
        }
    }

    if (S[A[0][0]] and S[A[1][1]] and S[A[2][2]])
    {
        cout << "Yes" << endl;
        return;
    }

    if (S[A[2][0]] and S[A[1][1]] and S[A[0][2]])
    {
        cout << "Yes" << endl;
        return;
    }

    cout << "No" << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
L, R = map(int, input().split())

z = 2019

if R-L>= 2019:
    print(0)
else:
    for l in range(L,R):
        for r in range(l+1, R+1):
            z = min(z, ((l % 2019) * (r % 2019)) % 2019)
    print(z)


Measured memory_bytes: 3060
a,b,c = map(int,input().split())
k = int(input())
cnt = 0
cnt2 = 0
ans = "No"
for i in range(k):
    if a < b:
        break
    else:
        b = b * 2
        cnt +=1
for i in range(k-cnt):
    if b < c:
        break
    else:
        c = c * 2
        cnt2 +=1
        
if a < b and b < c and cnt + cnt2 <=k:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61856
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<sstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
#define make_pair mkp;


int main(){
	ll n;
	cin>>n;
	ll ans=0;
	ll num=n/500;
	int b=n%500;
	int c=b/5;
	cout<<num*1000+c*5<<endl;

	return 0;
}

Measured memory_bytes: 256