akhauriyash/Code-Regression huggingface dataset:
n, x, y = list(map(int, input().split()))
d = [0] * n
flag = False
if y == n:
    flag = True
for i in range(1, n):
    for j in range(i + 1, n + 1):
        dist = min([abs(x - i) + 1 + abs(j - y), j - i])
        if dist <= n - 1:
            d[dist] += 1
# for i in range(1, n):
#     memo_i = []
#     for j in range(1, n):
#         if i <= x and j >= y:
#             dist = (x - i) + 1 + (j - y)
#             if dist <= n - 1:
#                 d[dist] += 1
#         elif i <= x:
#             dist = min([j - i, (x - i + 1 + (y - j))])
#             if dist <= n - 1:
#                 d[dist] += 1
#         elif j >= y:
#             dist = min([j - i, (j - y + 1 + (i - x))])
#             if dist <= n - 1:
#                 d[dist] += 1
#         else:
#             dist = min([j - 1, (y - j) + 1 + (i - x)])
#             if dist <= n - 1:
#                 d[dist] += 1
# if flag:
#     for i in range(1, n):
#         dist = min([abs(x - i) + 1, n - i])
#         if dist <= n - 1:
#             d[dist] += 1
for i in range(1, n):
    print(d[i])


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	int n;
	cin >> n;
	
	ll a[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];

	ll h = a[0], acc = 0;

	for (int i = 1; i < n; i++) {
		if (a[i] >= h)
			h = a[i];

		else
			acc += h - a[i];
	}

	cout << acc;

	return 0;
}

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

public class Program{
    public static void Main(){
      //N人、K種類
      string[] NandK = Console.ReadLine().Split(' ');
      int person = int.Parse(NandK[0]);
      int okashi = int.Parse(NandK[1]);
      
      int i = okashi;
      int tricked = person;
      int oyatsuNum = 0;
      int tmpOyatsu = 0;
      
      List<string> list = new List<string>();
      while(i > 0)
      {
        //お菓子を持っている人数
      	oyatsuNum = int.Parse(Console.ReadLine());
        
        //おやつを持っているひと
        string[] oyatsuHolder = Console.ReadLine().Split(' ');
        foreach(string str in oyatsuHolder)
        {
        	list.Add(str);
        }

        i --;
      }
        

		tmpOyatsu = list.Distinct().Count();
      tricked = person - tmpOyatsu;
          Console.WriteLine(tricked);

      
      
    }
}







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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define LOCAL
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound
#define lowbit(x) x&(-x)
#define testbit(x,i) x&(1<<i)

inline void checkmin(int &x,int y){x=min(x,y);}
inline void checkmax(int &x,int y){x=max(x,y);}

int S,W;

int main() 
{
	#ifndef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>S>>W;
    if(W>=S) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    /* end code */
	return 0;
}

Measured memory_bytes: 3652
//標準関数をすべてインクルードする。
#include <bits/stdc++.h>
using namespace std;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    int h, n;
    cin >> h >> n;
    //2次元vector
    //vector<vector<要素の型>> 変数名(縦の要素数, vector<要素の型>(横の要素数));
    vector<int> A(n, 0);
    for (int i = 0; i < n; ++i)
		cin >> A[i];

    sort(A.begin(), A.end());

    for (auto i : A){
        h -= i;
    }

    if (h <= 0) cout << "Yes" << endl;
    if (h > 0) cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}
ll a[3005];
ll cum[3005];
ll n;
ll dp[3005][3005];

ll sum(ll l,ll r)
{
	return cum[r]-cum[l-1];
}

ll solve(ll l,ll r)
{
	if(dp[l][r]!=-1)
	{
			return dp[l][r];
	}
	if(l>r)
	{
		return 0;
	}
	dp[l][r]=max(a[l]+sum(l+1,r)-solve(l+1,r),a[r]+sum(l,r-1)-solve(l,r-1));
	return dp[l][r];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i,ans;
	cin>>n;
	cin>>a[0];
	cum[0]=a[0];
	for(i=1;i<n;i++)
	{
		cin>>a[i];
		cum[i]=cum[i-1]+a[i];
	}    
	memset(dp,-1,sizeof(dp));
	ans=solve(0,n-1);
	ans=2*ans-cum[n-1];
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 74300
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <sstream>

using namespace std;

int main() {
    char a,b;

    cin >> a >> b;

    if(a == b){
        cout << "H" << endl;
    }
    else{
        cout << 'D' << endl;
    }
    
    return 0;
}




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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b;
  cin >> a >> b;
  vector<int> va{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1};

  int pt_a, pt_b;
  for (int i = 0; i < va.size(); ++i) {
    if (a == va[i]) {
      pt_a = i;
    }

    if (b == va[i]) {
      pt_b = i;
    }
  }

  if (pt_a == pt_b) {
    cout << "Draw" << '\n';
  } else if (pt_a < pt_b) {
    cout << "Bob" << '\n';
  } else {
    cout << "Alice" << '\n';
  }

  return 0;
}

Measured memory_bytes: 3624
n,x = map(int, input().split())
l =list(map(int, input().split()))
d = 0
for i in range(n + 1):
  if i < n:
    if d <= x:
      a = i
      d = d + l[i]
  else:
    if d <= x:
      a = i
 
print(a+1)
  

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

int main() {
  int N; string S; cin >> N >> S;
  int size = S.size();
  for (int i = 0; i < size; i++) {
    S[i] += N;
    if (S[i] > 'Z') S[i] -= 26;
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=n;i>=0;i--){
		int sq=int(sqrt(i));
		if(sq*sq==i){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
R,G,B,N=(int(i) for i in input().split())
import math
answer=0
for r in range(0,math.floor(N/R)+1):
    for g in range(math.floor(N/G)+1):
        sss=R*r+G*g
        if sss>N:
            break
        if (N-sss)%B==0:
            answer+=1
print(answer)
 



Measured memory_bytes: 3060
def main():

    s = input()
    ng, np = 0, 0
    count = 0
    for c in s:
        if c == "g":
            if np + 1 <= ng:
                 count += 1
                 np += 1
            else:
                ng += 1
        else:
            if np + 1 <= ng:
                np += 1
            else:
                ng += 1
                count -= 1
    return count

if __name__ == '__main__':
    print(main())

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

using namespace std;
#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 lb lower_bound
#define ub upper_bound
#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), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

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;
vector < int > g[N];
int d[N];

void dfs (int v, int pr = 0) {
	for (auto to : g[v]) if (pr != to) {
		d[to] = d[v] + 1;
		dfs(to, v);
	}
	
}

int main () {
	SpeedForce;
	cin >> n;
	for (int i = 1, l, r; i < n; ++i) {
		cin >> l >> r;
		g[l].pb(r);
		g[r].pb(l);
	}

	d[1] = 0;
	dfs(1);
	int mx = 1;
	for (int i = 1; i <= n; i ++) {
		if (d[i] > d[mx]) mx = i;
	}
	d[mx] = 0;
	dfs(mx);
	for (int i = 1; i <= n; i ++) {
		if (d[i] > d[mx]) mx = i;
	}
	cout << (d[mx] % 3 == 1 ? "Second\n" : "First\n");
   	return Accepted;
}

// B...a

Measured memory_bytes: 31104
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll x=0,j=100;
	while(cin>>a)
	{
	    x+=a*j;
	    j/=10;
	}
	if(x%4==0)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
var p=require("fs").readFileSync("/dev/stdin","utf8");
p = p.split("\n").map(a=>+a);
console.log(main());
function main(){
  var N = "No";
  var n = p[0];
  var a = {};
  for(var i = 1; i <= n; i++){
    if((p[i] ^ i) & 1)return N;
    var u = p[i], v = i;a[u] = 1;
    while(i < u){
      i++;
      if(p[i] !== i)return N;
      i++;
      if((p[i] ^ i) & 1)return N;
      if(u < p[i]){u = p[i]; a[u] = 1;}
      else if(v === p[i]){
        do{
          v += 2;
        }while(a[v])
      }
      else return N;
    }
  }
  return "Yes";
}

Measured memory_bytes: 51164
s = input()
slist = []
for i in range(len(s)):
    slist.append(s[i])

def isKaibun(s): #s is list
    s2 = s[:]
    s2.reverse()
    if s == s2:
        return 1
    return 0

if isKaibun(slist) and isKaibun(slist[:(len(slist)-1)//2]) and isKaibun(slist[(len(slist)+3)//2 -  1:]):
    print('Yes')
    exit()
print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a;
  b=a/100;
  c=a-100*b;
  if(0<b && b<13 && 0<c && c<13)
    cout<<"AMBIGUOUS"<<endl;
  else if(b<13 && b!=0)
    cout<<"MMYY"<<endl;
  else if(c<13 && c!=00)
    cout<<"YYMM"<<endl;
  else
    cout<<"NA"<<endl;
}

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

using namespace std;

int main(){
    string S, T;
    int A, B;
    string U;
    
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if (U == S){
        A--;
    }
    else{
        B--;
    }
    cout << A << " " << B << endl;
    
    return 0;
}


Measured memory_bytes: 256
//--------------------------------------------------------------------------------
// Code By:
//					######                  #               ######
//					##   #                  #               #
//					#####      ##       #####      ##       #   ###
//					##   #              #   #               #   # #
//					##    #	            #####               ##### #
//---------------------------------------------------------------------------------

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

                             /* ----------------------------- START of Template ---------------*/
#define ll long long int
#define FOR(x,to) for(x=0;x<(to);x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<long long int> >
#define vll vector<long long int>
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SZ(X) ((int)(X).size())
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second

void getZarr(string str, vll &Z)
{
    ll n = str.length();
    ll L, R, k;
    L = R = 0;
    for (ll i = 1; i < n; ++i)
    {
        if (i > R)
        {
            L = R = i;
            while (R<n && str[R-L] == str[R])
                R++;
            Z[i] = R-L;
            R--;
        }
        else
        {
            k = i-L;
            if (Z[k] < R-i+1)
                Z[i] = Z[k];
            else
            {
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                Z[i] = R-L;
                R--;
   } } }}
vector<ll>isprime;
void seive(ll size){
	isprime.resize(size+1,1);
	ll i,j;
	isprime[0]=0;
	isprime[1]=0;
	for(i=2;i*i<=size;i++){
		if(isprime[i]){
			for(j=2;j*i<=size;j++)isprime[i*j]=0;
		}
	}
}
ll power(ll x,unsigned ll y, ll m){
	if(y==0)return 1;
	ll p=power(x,y/2,m);
	p=(p*p)%m;
	if(y%2!=0)p=(p*x)%m;
	return p;
}
ll modinverse(ll a,ll m){
	return power(a,m-2,m);
}


                       /* ----------------------          End Of Template --------------------------------*/

ll findans(){
	ll n,ans=0,i;
	cin>>n;
	vll v(n);
	for(i=0;i<n;i++){
		cin>>v[i];
		if(i%2==0&&v[i]%2!=0)ans++;
	}
	cout<<ans<<endl;
	return 0;



}

int main(){
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll t,i;
	//cin>>t;
  t=1;
	for(i=0;i<t;i++){
		findans();
	}
return 0;
}






Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main() {
  long N; cin >> N;
  vector<long> box(1, 0), num = {3, 5, 7};
  int count = 0;
  bool judge = false;
  for(int i = 0; ; i++) {
    long x = box.at(i);
    for(int j = 0; j < 3; j++) {
      long y = x * 10 + num.at(j);
      if(y > N) {
        judge = true;
        break;
      }
      string s = to_string(y);
      if(s.find("3") != string::npos && s.find("5") != string::npos && s.find("7") != string::npos) count++;
      box.push_back(y);
    }
    if(judge) break;
  }
  cout << count << endl;
}

Measured memory_bytes: 640
#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<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}



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

     int n;
  cin >> n;
  bool b =false;
  for(int i=0;i<=n/4 ;i++){
    for(int j=0;j<=n/7 ; j++){
      if(4*i+7*j==n){b=true; break;}
    }
    if(b==true)break;
  }
  if(b==true)cout<<"Yes"<<endl;
  else cout <<"No"<<endl;






}


Measured memory_bytes: 3660
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

bool equal3( char &a, char &b, char &c )
{
	return a == b && b == c;
}

int idx[][3] = {
	0, 1, 2,
	3, 4, 5,
	6, 7, 8,
	0, 3, 6,
	1, 4, 7,
	2, 5, 8,
	0, 4, 8,
	2, 4, 6
};

void printRes( string buffer )
{
	for ( int i = 0; i < sizeof( idx ) / sizeof( idx[0] ); i++ )
	{
		if ( buffer[ idx[i][0] ] != 's' && equal3( buffer[ idx[i][0] ], buffer[ idx[i][1] ], buffer[ idx[i][2] ] ) )
		{
			cout << ( buffer[ idx[i][0] ] == 'o' ? 'o' : 'x' ) << endl;;
			return;
		}
	}

	cout << 'd' << endl;
	return;
}

int main()
{
	string buffer;

	while ( cin >> buffer )
	{
		printRes( buffer );
	}		

	return 0;
}

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


int main() {
    int N; cin >> N;
    vector<pair<int,int>> v(N,pair<int,int>(0,0));
    rep(i,N){
        cin >> v.at(i).first;
        v.at(i).second=i;
    }
    sort(v.begin(),v.end());

    for(int j=0;j<N;j++){
        cout << v.at(j).second+1 << " ";
    }
    cout << endl;

}

Measured memory_bytes: 1664
#include<stdio.h>
int main(void)
{
	int n;
	int x,y;
	scanf("%d",&n);
	x=n/10;
	y=n%10;
	if(x==9||y==9){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int n, x;
    cin >> n >> x;
    vector<Int> p(n), c(n);
    for (Int i = 0; i < n; i++) {
        cin >> p[i] >> c[i];
    }
    Int res = INF;
    for (Int bit = 0; bit < (1<<n); bit++) {
        Int s = 0;
        Int cnt = 0;
        for (Int i = 0; i < n; i++) {
            if (bit & (1<<i)) {
                s += c[i];
                s += 100 * (i + 1) * p[i];
                cnt += p[i];
            }
        }
        vector<Int> b;
        for (Int i = 0; i < n; i++) {
            if (bit & (1<<i)) continue;
            for (Int j = 0; j < p[i]; j++) {
                b.push_back(100 * (i + 1));
            }
        }
        sort(all(b), greater<Int>());
        if (s >= x) {
            res = min(cnt, res);
            continue;
        }
        for (Int i = 0; i < (Int)b.size(); i++) {
            s += b[i];
            cnt++;
            if (s >= x) {
                res = min(res, cnt);
                break;
            }
        }
    }
    print(res);
}

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


Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	int x,a,b,c,ans=0;
	scanf("%d%d%d%d",&a,&b,&c,&x);
	for (register int i=0;i<=a;++i) {
		for (register int j=0;j<=b;++j) {
			for (register int k=0;k<=c;++k) {
				if (500*i+100*j+50*k==x) {
					++ans;
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = [None for i in range(N)]
for i in range(N):
  A[i] = input()
A = Counter(A)
keyA = list(A.keys())
valuesA = list(A.values())
most = max(valuesA)

ans = [None for _ in range(N)]
for i in range(len(valuesA)):
  if valuesA[i] == most:
    ans[i] = keyA[i]
ans = [a for a in ans if type(a) == str]
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Measured memory_bytes: 37312
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

int BE(int b,int e){
    if(e==0){
        return 1;
    }else{
        int sum = BE(b,e/2);
        if(e%2==0){
            return (sum*sum)%MOD;
        }else{
            return (((sum*sum)%MOD)*b)%MOD;
        }
    }
}

int factional[214514]={};
int fact(int x){
    return factional[x];
}
void fact_init(){
    factional[0]=1;
    factional[1]=1;
    for(int i=2;i<=214514;i++){
        factional[i]=(factional[i-1]*i)%MOD;
    }
}


int comb(int n,int r){
    return (((fact(n)*BE(fact(r),MOD-2))%MOD)*BE(fact(n-r),MOD-2))%MOD;
}


signed main(){
    fact_init();
    int N,M;
    int Ans=1;
    cin >> N >> M;
    int r=2;
    while(M>1){
        int pM=M;
        for(int i=r;i<=100000;i++){
            if(M%i==0){
                int e=0;
                while(1){
                    if(M%i==0){
                        e++;
                        M/=i;
                    }else{
                        break;
                    }
                }
                //cout << i << " " << e << endl;
                Ans=(Ans*comb(N+e-1,e))%MOD;
                break;
            }
        }
        if(pM==M){
            Ans=(Ans*N)%MOD;
            break;
        }
    }
    cout << Ans%MOD << endl;
    return 0;
}   


Measured memory_bytes: 1920
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, H = LI()
    ab = []
    for i, _ in enumerate(range(N)):
        _ab = LI()
        ab.append((_ab[0], _ab[1], i))
    a_max, b_max, a_max_i = sorted(ab, key=lambda x:x[0])[-1]
    ab = sorted(ab, key=lambda x:x[1])[::-1]
    cnt = 0
    i = 0

    while i < N and H > 0:
        a, b, ken_i = ab[i]
        if b < a_max:
            break
        H -= b
        cnt += 1
        i += 1

    if H > 0:
        cnt += (math.ceil(H / a_max))

    print(cnt)
    
main()



Measured memory_bytes: 25348
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 998244353 
#define pb push_back
#define mb make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main(){
	IOS;
	int n; cin >> n;
	int inp[n]; for(int i=0;i<n;i++) cin >> inp[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(inp[1]-inp[0]);
	for(int i=2 ; i<n;i++){
		dp[i] = min(dp[i-1]+abs(inp[i]-inp[i-1]),dp[i-2]+abs(inp[i]-inp[i-2]));
		// cout << dp[i] << " ";
	}
	cout << dp[n-1] << endl;

	return 0;
}




Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int sunukeCount = sc.nextInt();
		int okashiCount = sc.nextInt();
		int itazuraCount = 0;
		boolean[] itazuraFlag = new boolean [sunukeCount];
		for (int i = 0; i < sunukeCount; i++) {
				itazuraFlag[i] = true;
		}

		for (int i = 0; i < okashiCount; i++) {
			int dCount = sc.nextInt();
			for (int j = 0; j < dCount; j++) {
				int tmp = sc.nextInt();
				tmp--;
				itazuraFlag[tmp] = false;
			}
		}

		for (int i = 0; i < sunukeCount; i++) {
			if (itazuraFlag[i] == true) {
				itazuraCount++;
			}
		}

		System.out.print(itazuraCount);

	return;

	}
}


Measured memory_bytes: 37168
#include <stdio.h>
#include <stdbool.h>
#define MAX 36

struct Card{
    char suit;
    int value;
};

struct Card a[MAX],b[MAX];
int N;

void BubbleSort();
void SelectionSort();
int isStable();

int main(){
int i;

scanf("%d",&N);

for(i=0;i<N;i++){
    scanf(" %c%d ",&a[i].suit,&a[i].value);
    b[i].suit=a[i].suit;
    b[i].value=a[i].value;
}

BubbleSort();

for(i=0;i<N;i++){
    if(i==N-1) printf("%c%d\n",a[i].suit,a[i].value);
    else printf("%c%d ",a[i].suit,a[i].value);
}
printf("Stable\n");

SelectionSort();

for(i=0;i<N;i++){
    if(i==N-1) printf("%c%d\n",b[i].suit,b[i].value);
    else printf("%c%d ",b[i].suit,b[i].value);
}
if(isStable()) printf("Stable\n");
else printf("Not stable\n");

return 0;
}


void BubbleSort(){
int i,j;
struct Card tmp;

for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
        if(a[j].value<a[j-1].value){
            tmp=a[j];
            a[j]=a[j-1];
            a[j-1]=tmp;
            }
        }
    }
}

void SelectionSort(){
    int i,minj,j;
    struct Card tmp;

    for(i=0;i<N;i++){
        minj=i;
        for(j=i;j<N;j++){
            if(b[j].value<b[minj].value) minj=j;
        }
        tmp=b[i];
        b[i]=b[minj];
        b[minj]=tmp;
    }
}

int isStable(){
    int i;

    for(i=0;i<N;i++){
        if(a[i].suit!=b[i].suit) return 0;
    }
    return 1;
}



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

int main(void){
    char s[200001]; 
    int start = 0, last = 0;

    scanf("%s", s);

    for(int i = 0; i < strlen(s); i++){
        if(s[i] == 'A'){
            start = i;
            break;
        }
    }
    for(int i = strlen(s) - 1; i >= 0; i--){
        if(s[i] == 'Z'){
            last = i;
            break;
        }
    }  

    printf("%d\n", last - start + 1);

    return 0;

} 


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;


int main() {
  int k , s ;
  cin >> k >> s ;
  int ans = 0;
  
  rep(i,k+1){
    rep(j,k+1){
      int z = s - i - j  ;
      if(0 <= z && z<=k)
      ans++;
    }
  }
  
  cout << ans <<endl;
}


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

using namespace std;

int main() {
    string a;
    int k[3];
    cin>>a;
    for(int i=0;i<3;++i) k[i]=a[i]-'a'+1;
    sort(k,k+3);
    for(int i=1;i<=3;++i) {
        if(k[i-1]!=i)
            puts("No"),exit(0);
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
#define mod 200003
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll f(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=f(a,b/2,p);
		return t*t%p;
	}
	return a*(f(a,b-1,p))%p;
} 
//cout << fixed << setprecision(桁数);
//__builtin_popcount()
signed main(){
	ll n,m; cin>>n>>m;
	vl dx={0,1,0,-1};
	vl dy={1,0,-1,0};
	vector<vector<char>> g(n,vector<char>(m));
	rep(i,0,n)rep(j,0,m)cin>>g[i][j];
	ll ans=0;
	rep(i,0,n){
		rep(j,0,m){
			if(g[i][j]=='#')continue;
			vector<vector<bool>> seen(n,vector<bool>(m,0));
			seen[i][j]=1;
			queue<pl> q;
			q.push(make_pair(i,j));
			vvl vec(n,vl(m,0));
			vec[i][j]=0;
			while(!q.empty()){
				pl p=q.front(); q.pop();
				ll a,b; tie(a,b)=p;
				rep(k,0,4){					
					if(0<=a+dx[k] && 0<=b+dy[k] && a+dx[k]<n && b+dy[k]<m){
						if(seen[a+dx[k]][b+dy[k]])continue;
						seen[a+dx[k]][b+dy[k]]=1;
						if(g[a+dx[k]][b+dy[k]]=='#')continue;
						q.push(make_pair(a+dx[k],b+dy[k]));
						vec[a+dx[k]][b+dy[k]]=vec[a][b]+1;
					}
				}
			}
			rep(s,0,n){
				rep(t,0,m){
					if(g[s][t]=='#')continue;
					chmax(ans,vec[s][t]);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3640
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1] or p[i - 1] > p[i] > p[i + 1]:
        cnt += 1

print(cnt)


Measured memory_bytes: 2940
import sys
input=sys.stdin.readline
n=int(input())
l=[int(input()) for i in range(n)]
li=[0 for i in range(n+1)]
for i,j in enumerate(l):
    li[j]=i
ans=n-1
i=1
ms=1
while i<n:
    if li[i]<li[i+1]:
        ms+=1
        i+=1
    else:
        ans=min(ans,n-ms)
        ms=1
        i+=1
print(min(ans,n-ms))

Measured memory_bytes: 18968
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[] ans = new boolean[n];
		for(int i=0;i<n;i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			if(a*a+b*b==c*c || b*b+c*c==a*a || c*c+a*a==b*b){
				ans[i]=true;
			}else{
				ans[i]=false;
			}
		}
		
		for(int i=0;i<n;i++){
			if(ans[i]==true){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}

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

int main(){
	int A, B;
	cin >> A >> B;
  	int count = 0;
  	for(int i = A; i <= B; i++) {
    	if(i/10000 == i%10 && i%10000/1000 == i%100/10)
          count++;
    }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a,b,c;
    for(int i=0;i<n;i++){
        cin >> a>> b>> c ;
        
        if(a>b)swap(a, b);
        if(b>c)swap(b, c);
        if(a>b)swap(a, b);
        if(a*a+b*b==c*c){
            cout <<"YES" << endl;
        }
        else cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
#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;
    ll stc = 0, mny = 1000;
    cin >> n;
    vector<ll> a(n);
    for (ll& i : a) cin >> i;
    for (int i = 0; i < n-1; ++i) {
        if (stc == 0){
            if(a[i] < a[i + 1]) stc = mny / a[i], mny %= a[i];
        }
        else{
            if (a[i] > a[i + 1]) mny += stc * a[i], stc = 0;
        }
    }
    mny += stc * a[n - 1];
    cout << mny << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};

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

signed main(void) {
	ll a, b;
	cin >> a >> b;

	ll gc = gcd(a, b);
	ll cur = gc;
	int cou = 1;

	rep(i, 2, sqrt(gc) + 1) {

		if (cur % i == 0)
			cou++;

		while (cur % i == 0)
			cur /= i;
			
	}

	if (cur != 1)
		cou++;

	cout << cou << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    if(a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3])cout<<"Yes"<<endl;
    else if(a[0]==a[1]&&a[1]==a[2])cout<<"Yes"<<endl;
    else if(a[1]==a[2]&&a[2]==a[3])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <utility>
#include <cmath>
#include <string>
#include <bitset>
#include <queue>
#include <cstdio>
#include <cstring>
#include <deque>
#include <unordered_map>
#include <climits>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <ctime>
#include <cstdint>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define fa(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>b;--i)
#define setp pair<pair<int,int>,int>
#define setl pair<int,int>
#define M_PI 3.14159265358979323846

using namespace std;

LL gcd(LL a, LL b) { return a % b ? gcd(b, a % b) : b; }
LL lcm(LL a, LL b) { return (a * b) / gcd(a, b); }
pair <int, int> vu[8] = { {0,1}, {1,0} , {1,-1},{0,-1},{-1,0},{-1,1},{0,1}, {1,0} }; // EWSN

const int max_v = 1e5 + 7;
const int INF = 1e7 + 7;

int a, b, c, d,k;
int m;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);	
	ci(a >> b >> c >> d>>k);
	if (a <= c)
	{
		m = 60 * (c - a);
		if (b <= d) m += d - b;
		else m -= b - d;
	}
	else
	{
		c += 24;
		m = 60 * (c - a);
		if (b <= d) m += d - b;
		else m -= b - d;
	}

	co(m - k);
	return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>

using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_buck(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second


int main(){
	int k,s;
	cin>>k>>s;
	int ans=0,temp1,temp2;
	rep(i,k+1){
		if(s-i>k){
			temp1= s-i-2*k;
			temp1= 1-temp1;
			ans += max(0,temp1);
		}else{
			temp2= s-i+1;
			ans += max(0,temp2);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl;
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 N,M;
int a[50],b[50];
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
bool used[401][401];
vector<int> V[60][60];
int cnt = 0,ans = 0,num = 0;

void dfs(int X,int cnt){
    if(used[X][cnt] == true) return;
    used[X][cnt] = true;
  	num++;
    REP(i,V[cnt][X].size()){
        dfs(V[cnt][X][i],cnt);
    }
}

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    cin >> N >> M;
    REP(i,M) cin >> a[i] >> b[i];
    REP(i,M){
        REP(j,M){
            if(i == j) continue;
            V[i][a[j]].pb(b[j]);
            V[i][b[j]].pb(a[j]);
        }
    }
    REP(i,M){
        dfs(1,i);
      		//cout << num << ' ' << N << endl;
        if(num != N) ans++;
        num = 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << a[0] << b[1] << c[2] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int K;
    cin >> K;
    string S;
    cin >> S;
    if(S.size()<=K){
        cout << S << endl;
        return 0;
    }
    list<char> B;
    rep(i,S.size()){
        B.push_back(S[i]);
    }
    rep(i,S.size()-K){
        B.pop_back();
    }
    rep(i,3){
        B.push_back('.');
    }
    stl_rep(i,B){
        cout << *(i);
    }
    cout << endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int sum[200005],cnt[200005];
int main(){
    int N,C; cin >> N >> C;
    vector<int> s(N),t(N),c(N);
    rep(i,N) cin >> s[i] >> t[i] >> c[i];
    for(int i = 1; i <= C; i++){
        rep(j,200005) cnt[j] = 0;
        rep(j,N){
            if(c[j] == i){
                cnt[2*s[j]-1]++; cnt[2*t[j]]--;
            }
        }
        FOR(j,1,200005) cnt[j] += cnt[j-1];
        rep(j,200005){
            if(cnt[j] > 0) sum[j]++;
        }
    }
    int ans = 0;
    rep(i,200005){
        ans = max(sum[i], ans); 
    }
    cout << ans << endl;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    vector<int> b(n);
    for(int i=0;i<n;i++){
        b.at(a.at(i)-1)=i+1;
    }
    for(int i=0;i<n;i++){
        cout<<b.at(i)<<" ";
    }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, T;
vi V;
void input() {
  cin >> N >> T;
  V.resize(N);
  rep(i, 0, N - 1) { cin >> V[i]; }
}
void solve() {
  int now = -1;
  int cnt = 0;
  int prv = -INF;
  for (auto x : V) {
    if (prv + T > x) {
      cnt += T - (prv + T - x);
    } else {
      cnt += T;
    }
    prv = x;
  }
  cout << cnt << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 1792
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    inf=10**16
    aa=[II() for _ in range(n)]

    dpl=[inf]*(n+1)
    dpl[0]=0
    s=0
    for i in range(n):
        a=aa[i]
        s+=a
        dpl[i+1]=s
        if a==0:dpl[i+1]=min(dpl[i+1],dpl[i]+2)
        else:dpl[i+1]=min(dpl[i+1],dpl[i]+a%2)
    #print(dpl)

    dpr=[inf]*(n+1)
    dpr[n]=0
    s=0
    for i in range(n-1,-1,-1):
        a=aa[i]
        s+=a
        dpr[i]=s
        if a==0:dpr[i]=min(dpr[i],dpr[i+1]+2)
        else:dpr[i]=min(dpr[i],dpr[i+1]+a%2)
    #print(dpr)

    even=[0]
    for a in aa:
        if a%2:even.append(even[-1])
        else:even.append(even[-1]+1)
    #print(even)

    mn=inf
    ans=inf
    for i in range(n+1):
        mn=min(mn,dpl[i]-even[i])
        cur=mn+dpr[i]+even[i]
        ans=min(ans,cur)
    #print(aa)
    print(ans)

main()

Measured memory_bytes: 37352
#include <stdio.h>

int main(void) {

    int n, a, b;

    scanf("%d", &n);

    int c = 0;

    for (int i = 0; i < n; i++) {
        scanf("%d %d", &a, &b);
        if (a == b)
            c++;
            
        if (c >= 3)
            break;   

        if (a != b)
            c = 0;
    }

    if (c >= 3)
        printf("Yes\n");

    if (c < 3)
        printf("No\n");

    return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
long long v[110], nr;
int main()
{
    int n;
    cin >> n;
    if (n == 2)
        cout << -1 << '\n';
    else
    {
        for (int i = 1; i <= n; i++)
        {
            nr=1;
            for (int j = 1; j <= n; j++)
                if (i != j)
                    v[nr]=j, nr++;
            rotate(v+1, v+nr+1-i, v+nr);
            for (int j=1; j<nr; j++)
                cout << v[j] << ' ';
            cout << '\n';
        }
    }
    return 0;
}


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

typedef long long ll;

long long gcd(long long a, long long b) {

   	if(a < b) {
       swap(a, b);
   	}

	long long r = a % b;
	while(r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

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

    int N;

    cin >> N;

    vector<ll> A(N);

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

    vector<ll> L(N);
    vector<ll> R(N);

    L[0] = A[0];
    R[N - 1] = A[N - 1];

    for(int i = 1; i < N; i++) {
        L[i] = gcd(L[i - 1], A[i]);
        R[N - 1 - i] = gcd(R[N - i], A[N - 1 - i]);
    }

    ll max = R[1];

    for(int i = 1; i < N - 1; i++) {
        ll x = gcd(L[i - 1], R[i + 1]);
        if(x > max) {
            max = x;
        }
    }

    if(L[N - 2] > max) {
        max = L[N - 2];
    }

    cout << max << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;

int main() {
    long long N, K, mi, ma;
    cin >> N >> K;
    long long sum = 0;;
    for(long long i=K; i<=N+1; i++) {
        mi = (0+(i-1))*i/2;
        ma = (N-i+1+N)*i/2;
        sum += ma - mi + 1;
        sum %= mod;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3644
import math
K = int(input())
sumi = 0
for i in range(1,K+1):
    sumi += i
sumk = 0
for i in range(1,K+1):
    for k in range(1, K+1):
        if not i == k:
            sumk += math.gcd(i, k)
sumk *= 3
sumj = 0
for i in range(1, K+1):
    for k in range(i+1, K+1):
        for j in range(k+1, K+1):
            sumj += math.gcd(math.gcd(i, k),j)
sumj *= 6

print(sumi+sumk+sumj)

Measured memory_bytes: 9144
class KochCurve
  def solve(n)
    ans = koch(Point.new(0.0, 0.0), Point.new(100.0, 0.0), n)
  end

  def koch(pl, pr, n)
    if n== 0
      [pl, pr]
    else
      p1 = Point.new(
        (2 * pl.x + pr.x) / 3,
        (2 * pl.y + pr.y) / 3
      )
      p2 = Point.new(
        (pl.x + 2 * pr.x) / 3,
        (pl.y + 2 * pr.y) / 3
      )
      p3 = Point.new(
        (pl.x + pr.x) / 2 - Math.sqrt(3) * (pr.y - pl.y) / 6,
        (pl.y + pr.y) / 2 + Math.sqrt(3) * (pr.x - pl.x) / 6
      )

      a1 = koch(pl, p1, n - 1)
      a2 = koch(p1, p3, n - 1)
      a3 = koch(p3, p2, n - 1)
      a4 = koch(p2, pr, n - 1)

      a1.pop
      a2.pop
      a3.pop
      a1 + a2 + a3 + a4
    end
  end
end

class Point
  attr_accessor :x, :y
  def initialize(x, y)
    @x = x
    @y = y
  end
  def to_s
    "#{@x} #{@y}"
  end
end

kc = KochCurve.new
ans = kc.solve(gets.to_i)
ans.each{ | a | puts "#{a}" }



Measured memory_bytes: 7156
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;
void solve()
{
  char ch;
  cin>>ch;
  if(ch>=97 && ch<=122)
  cout<<'a';
  else
  cout<<'A';
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3644