akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <set>

using namespace std;

int main() {
	long long int n;
	cin >> n;
	vector<long long int> arr(n + 1);
	for (long long int i = 0; i < n; i++) {
		long long int x;
		cin >> x;
		arr[x] = i;
	}
	long long int ans = 0;
	set<long long int> indices = { arr[n] };
	for (long long int i = n - 1; i > 0; i--) {
		auto low = indices.lower_bound(arr[i]);
		long long int left1 = -1, left2 = -1;
		if (low != indices.begin()) {
			low--;
			left1 = *low;
			if (low != indices.begin()) {
				low--;
				left2 = *low;
			}
		}
		long long int right1 = n, right2 = n;
		auto high = indices.upper_bound(arr[i]);
		if (high != indices.end()) {
			right1 = *high;
			high++;
			if (high != indices.end()) {
				right2 = *high;
			}
		}
		//cout << left1 << left2 << right1 << right2 << endl;
		ans += i * (left1 - left2) * (right1 - arr[i]);
		ans += i * (arr[i] - left1) * (right2 - right1);
		indices.insert(arr[i]);
	}
	cout << ans << endl;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;


int H, W, N;
int ix, iy;
string S, T;

bool solve() {
    // left, right
    int left = 0, right = W;
    if (S[N - 1] == 'L') ++left;
    if (S[N - 1] == 'R') --right;
    for (int i = N - 2; i >= 0; --i) {
        if (T[i] == 'L') right = min(right + 1, W);
        else if (T[i] == 'R') left = max(0, left - 1);
        if (S[i] == 'L') left = left + 1;
        else if (S[i] == 'R') right = right - 1;
        if (left >= right) return false;
    }
    if (iy < left || iy >= right) return false;

    // up, down
    left = 0, right = H;
    if (S[N - 1] == 'U') ++left;
    if (S[N - 1] == 'D') --right;
    for (int i = N - 2; i >= 0; --i) {
        if (T[i] == 'U') right = min(right + 1, H);
        else if (T[i] == 'D') left = max(0, left - 1);
        if (S[i] == 'U') left = left + 1;
        else if (S[i] == 'D') right = right - 1;
        if (left >= right) return false;
    }
    if (ix < left || ix >= right) return false;

    return true;
}

int main() {
    while (cin >> H >> W >> N >> ix >> iy >> S >> T) {
        --ix, --iy;
        cout << (solve() ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 920
# Longest Common Subsequence problem: LCS
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/10/ALDS1_10_C

import sys
input = sys.stdin.readline
ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'


def get_LCS(x: str, y: str):
    lx = len(x)
    ly = len(y)
    dp = [[0] * (lx + 1) for _ in range(ly + 1)]  # 1-indexed

    for i in range(1, lx + 1):
        for j in range(1, ly + 1):
            if x[i - 1] == y[j - 1]:
                dp[j][i] = dp[j - 1][i - 1] + 1
            else:
                dp[j][i] = max(dp[j][i - 1], dp[j - 1][i])

    return dp[-1][-1]


def llcs(x, y):
    """solution author: bs5lNkJ"""
    pm = dict((zip(ascii_letters, [0] * 52)))
    for c in pm:
        for i, xc in enumerate(x):
            if c == xc:
                pm[c] |= (1 << i)

    V = (1 << len(x)) - 1

    for yc in y:
        V = ((V + (V & pm[yc])) | (V & ~pm[yc]))

    ans = bin(V)[-len(x):].count('0')

    return ans


n = int(input())

for _ in range(n):
    X = input().strip()
    Y = input().strip()
    print(llcs(X, Y))



Measured memory_bytes: 5636
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a>8||b>8){
      System.out.println(":(");
    }else{
      System.out.println("Yay!");
    }
  }
  

  
}

Measured memory_bytes: 23760
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}

int n;
vector<int> a,b;


bool chk1(int x)
{
	int ans=0;
	fo(i,n)
	{
		if(a[i]<=x)
			ans++;
	}
	if(n%2==0)
	{
		// cerr<<ans<<','<<n/2<<endl;
		if(ans==n/2)
		{
			int fans1=-INF,fans2=INF;
			fo(i,n)
			{
				if(a[i]<=x)
				{
					fans1=max(fans1,a[i]);
				}
				else
				{
					fans2=min(fans2,a[i]);
				}
			}
			// cerr<<"fans"<<fans1<<','<<fans2<<endl;
			return fans1+fans2<=x*2;
		}
	}
	return ans>=n/2+(n%2);
}

bool chk2(int x)
{
	int ans=0;
	fo(i,n)
	{
		if(b[i]>=x)
			ans++;
	}
	if(n%2==0)
	{
		if(ans==n/2)
		{
			int fans1=INF,fans2=-INF;
			fo(i,n)
			{
				if(b[i]>=x)
				{
					fans1=min(fans1,b[i]);
				}
				else
				{
					fans2=max(fans2,b[i]);
				}
			}
			return fans1+fans2>=x*2;
		}
	}
	return ans>=n/2+(n%2);
}

int f(int l,int r)
{
	if(r-l<=100)
	{
		int ans=0;
		for(int i=l;i<=r;i++)
		{
			if(i%2==0)
				ans++;
		}
		return ans;
	}
	if(l%2)
		l++;
	if(r%2)
		r--;
	int ans=r-l+1;
	ans=ans/2+1;
	return ans;
}

signed main()
{
	fio
	cin>>n;
	a.resize(n);
	b.resize(n);
	fo(i,n)
		cin>>a[i]>>b[i];
	fo(i,n)
	{
		a[i]*=2;
		b[i]*=2;
	}
	
	// cerr<<chk1(40)<<endl;
	// return 0;
	
	int lo=1,hi=2e9;
	while(lo<hi)
	{
		int mid=(lo+hi)/2;
		if(chk1(mid))
		{
			hi=mid;
		}
		else
		{
			lo=mid+1;
		}
	}
	int l=(lo+hi)/2;
	
	lo=1,hi=2e9;
	while(lo<hi)
	{
		int mid=(lo+hi)/2;
		if(chk2(mid))
		{
			lo=mid;
		}
		else
		{
			hi=mid-1;
		}
		if(lo+1==hi)
		{
			if(chk2(hi))
			{
				lo++;
			}
			else
			{
				hi--;
			}
		}
	}
	int r=(lo+hi)/2;
	
	// cerr<<l<<','<<r<<endl;
	
	int ans=r-l+1;
	
	if(n%2)
	{
		ans=f(l,r);
	}
	
	cout<<ans<<'\n';
	printclock;
}

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

const int MAXN = 100000;
int a[MAXN + 1];

int main() {
    //ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    if(n == 1) {
        cout << "1\n";
        return 0;
    }
    for(int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int asc = -1;
    int ans = 1;
    for(int i = 1; i < n; i++) {
        if(asc == 1 && a[i] >= a[i - 1] || asc == -1 && a[i] == a[i - 1])
            continue;
        if(asc == 0 && a[i] <= a[i - 1] || asc == -1 && a[i] == a[i - 1])
            continue;
        if(asc != -1) {
            ans++;
            i++;
        }
        if(i < n && a[i] > a[i - 1])
            asc = 1;
        else if(i < n && a[i] < a[i - 1])
            asc = 0;
        else
            asc = -1;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
#define _LIBCPP_DEBUG 0

#include <iostream>
#include <vector>

using namespace std;

int selectionSort(vector<int> A, int N)
{
    int minj;
    int count = 0;

    for (int i = 0; i < N-1; i++)
    {
        minj = i;
        for (int j = i; j < N; j++)
        {
            if (A.at(j) < A.at(minj))
            {
                minj = j;
            }
        }
        swap(A.at(i), A.at(minj));
        if (i != minj)
        {
            count++;
        }
    }

    for (int i = 0; i < N; i++)
    {
        if (i > 0)
        {
            cout << " ";
        }
        cout << A.at(i);
    }
    cout << "\n";
    cout << count << "\n";
}

int main() {
    int N, i;
    cin >> N;

    vector<int> vec(N);

    for (i = 0; i < N; i++)
    {
        cin >> vec.at(i);
    }

    selectionSort(vec, N);
}



Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	ll h, w;
	cin >> h >> w;
	
	if( h == 1 || w == 1 ) cout << 1 << endl;
	else cout << (h * w + 1) / 2 << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

/**
 *
 * @author C0117306
 */
public class Main {
    public static void main(String[] args) {
        ArrayList<Integer> arrayList = new ArrayList<Integer>();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k=sc.nextInt();
        int sum=0;
        for (int i = 0; i < n; i++) {
            arrayList.add(sc.nextInt());
        }
        for (int i = 0; i < k; i++) {
            sum=sum+Collections.max(arrayList);
            arrayList.remove(Collections.max(arrayList)); 
        }
        System.out.println(sum);
    }
    
}


Measured memory_bytes: 21844
N, K = map(int, input().split())
freq = [0] * (10**5 + 1)
for n in range(N):
    a, b = map(int, input().split())
    freq[a] += b
    
for i, f in enumerate(freq):
    K -= f
    if K <= 0:
        print(i)
        break


Measured memory_bytes: 5748
# AGC035A - XOR Circle
from functools import reduce
from operator import xor


def main():
    n = int(input())
    A = tuple(map(int, input().rstrip().split()))
    ans = reduce(xor, A)
    print("Yes" if ans == 0 else "No")


if __name__ == "__main__":
    main()

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

void print(int a[], int n){
    for(int i=0; i<n-1; i++){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
}

int main(){
    int n;
    cin >> n;
    int a[11];
    for(int i=0; i<n; i++){
        a[i] = i+1;
    }
    do {
        print(a, n);
    } while (next_permutation(a, a+n));
    return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,j,k,p;
	cin>>n;
	map<string,vector<int> > M;
	string s;
	map<int,int> M2;
	for(i=0;i<n;i++)
	{
		cin>>s;
		cin>>p;
		M2[p]=i+1;
		M[s].push_back(p);
	}
	map<string,vector<int> > ::iterator it;
	for(it=M.begin();it!=M.end();++it)
	{
	vector<int> temp = it->second;
	sort(temp.begin(),temp.end());
	n=temp.size();
	for(i=n-1;i>=0;i--)cout<<M2[temp[i]]<<endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7 ;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define vvv64 vector<vv32>
#define vvvv64 vector<vvv32>
 
ll exp(ll n, ll e)
{
    if (e==0)
        return 1;
    ll temp=exp((n*n)%MOD,e/2);
    return e%2==0 ? temp : (temp*n)%MOD;
}


void solve()
{
    int n,m;
    cin>>n>>m;
    vector<pair<int,string> > arr(m+1);
    v64 ac(n+1,0);
    int a=0,b=0;
    for (int i=1; i<=m; i++)
    {
        cin>>arr[i].fi>>arr[i].se;
        if (arr[i].se=="AC")
            ac[arr[i].fi]=1;
    }
    v64 ac1(n+1,0);
    for (int i=1; i<=m; i++)
    {
        if (arr[i].se=="WA" && ac1[arr[i].fi]==0 && ac[arr[i].fi]==1)
            b++;
        else
            ac1[arr[i].fi]=1;
    }
    for (int i=1; i<=n; i++)
        a+=ac[i];
    cout << a<<" "<<b<<endl;    
}
 
int main() {
    fast_cin();
    int t=1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 8064
import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def iif(n): return [int(input()) for _ in range(n)]
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    mod = 1000000007
    
    N, Q = mi()
    S = input()
    AC_cnt = [0] * len(S)
    cnt = 0
    for i in range(len(S)-1):
        if S[i] == "A" and S[i+1] == "C":
            cnt += 1
        AC_cnt[i+1] = cnt

    for i in range(Q):
        l, r = mi()
        print(AC_cnt[r-1] - AC_cnt[l-1])

    return

main()


Measured memory_bytes: 11792
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace _gnu_pbds;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i = a ; i < b ; i++)
#define stoink stack<ll>
#define quu queue<ll>
#define quee queue<pair<ll,ll>>
#define vec vector <ll>
#define vg vector<vector<ll> >
#define eg vector<pair<ll,ll>>
#define vgw vector<vector<pair<ll,ll> > >
#define pa pair<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define pre 0.00000000000000000001
#define inf 100000000000000000
#define mod (ll)(1e9+7)
#define endl '\n'
ll n;
ll arr[30][30];
vg dp(22,vec(1 << 22,-1));
ll func(ll ind,ll mask) {
    if(mask == (1 << n) - 1)
        return 1;
    if(dp[ind][mask] != -1)
        return dp[ind][mask];
    ll ans = 0;
    fr(i,0,n) {
        if(arr[ind][i] == 0 || (1 << i) & mask)
            continue;
        ans = (ans + func(ind + 1,mask | 1 << i)) % mod;
    }
    return dp[ind][mask] = ans;
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    cin >> n;
    fr(i,0,n) fr(j,0,n) cin >> arr[i][j];
    cout << func(0,0) << endl;
	return 0;
}

Measured memory_bytes: 756752
#include <stdio.h>
#include <string.h>
 
int main() {
 
  char str[1050] = {0};
  char ch[1050] = {0};
  char mei[30] = {0};
  char pl[1050]={0};
  int i,j,k,l,m,n,o,p;
 
  
  scanf("%s",str);
  scanf("%d",&n);
    
  for(i=0; i<7 ;i++) {
    ch[i] = str[i];
  }
 
  j=0;
  o=0;
  k=l=0;
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", mei);
    scanf("%d %d", &k, &l);
    // printf("mei= %s",mei);
   
     
    if(mei[2] =='p') {
      
      scanf("%s", pl);
 
      for(m=0;m<l-k+1;m++) {
 
    //  printf("str[%d]%c = pl[%d]%c\n",m+k,str[m+k] ,m,pl[m]);
    str[m+k] = pl[m];   
      }
    }
 
    else if(mei[2] == 'v') {
       
      for(m=0; m<strlen(str);m++) {
    ch[m] = str[m];
      }
       
      for(m=0;m<l-k+1;m++) {
    //  printf("str[%d]%c = ch[%d]%c\n",k+m,str[k+m],l-m,ch[l-m]);
    str[k+m] = ch[l-m];
      }
     
    }
 
    else if(mei[0] = 'p') {   
       
      for(m=k; m<=l;m++) {
    printf("%c" ,str[m]);
      }
      printf("\n");
    }
     
  }
 
    
  return 0;
 
}


Measured memory_bytes: 2092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	if(s=="SUN") cout<<7<<endl;
	if(s=="MON") cout<<6<<endl;
	if(s=="TUE") cout<<5<<endl;
	if(s=="WED") cout<<4<<endl;
	if(s=="THU") cout<<3<<endl;
	if(s=="FRI") cout<<2<<endl;
	if(s=="SAT") cout<<1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // cin, cout の高速化
#define MOD 1000000007
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)


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

    int N, T,A,ans;
    cin >> N;
    cin >> T;
    cin >> A;

    double min;
    min = 1e9;
    REP(i, N)
    {
        double x;
        cin >> x;
        x = std::abs(A-(T-x*0.006));
        if (min>x){
            min=x;
            ans=i;
        }

    }
    cout << (ans+1) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		int ans=s[0]-s[1]*2;
		Console.WriteLine("{0}",ans<0?0:ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

int main(){
    int n;
    int nums[105][105];
    while(cin >> n, n){
	int x = n / 2 + 1, y = n / 2;
	for(int i = 0;i < n;i++)for(int j = 0;j < n;j++)nums[i][j] = 0;
	for(int i = 1;i <= n * n;i++){
	    nums[x][y] = i;
	    x++;y++;
	    x%=n;y%=n;
	    if(nums[x][y]){
		x++;y+=n-1;
		x%=n;y%=n;
	    }
	}
	for(int i = 0;i < n;i++){
	    for(int j = 0;j < n;j++){
		printf("%4d",nums[i][j]);
	    }
	    cout << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 1208
#include<cstdio>
using namespace std;
int main(){
  int x,a,b;
  scanf("%d%d%d",&x,&a,&b);
  if(a>=b)
    printf("delicious\n");
  else if(a+x>=b)
    printf("safe\n");
  else
    printf("dangerous\n");
}

Measured memory_bytes: 128
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;


int main() {
    int N; cin >> N;
    double ans = 2 * (double)N * 3.14;
        cout<< ans << endl;
}

    


    








































































































































Measured memory_bytes: 3780
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
k = 100
x = inp()
for i in range(5000):
    temp = k + k * 0.01
    k = int(temp)
    if k >= x:
        break

print(i + 1)


Measured memory_bytes: 64100
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int ishard = 0;
  for(unsigned int i = 0; i < s.size() - 1; i++){
    if(s[i] == s[i+1]){
      ishard = 1;
    }
  }
  if(ishard == 0){
    cout << "Good";
  } else{
    cout << "Bad";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int N, L, T; 
	cin >> N >> L >> T; 
	int X[100010] = {}; 
	int W[100010] = {}; 
	int Aft[100010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> X[i] >> W[i]; 
		if(W[i] == 1){Aft[i] = (X[i] + T) % L;}
		else if(W[i] == 2){Aft[i] = (L + X[i] - (T % L)) % L;}
	}
	sort(Aft, Aft + N); 
	int F = 0; // 非負の座標にいる蟻の番号の最小値
	for(int i = 0; i < N; i++){
		int A = 0; 
		if(W[i] == 1){A = max(T + X[i], 0) / L ;
			F = (N + F - (A % N)) % N;}
		else if(W[i] == 2){A = max(T + L - X[i] - 1, 0) / L;
			F = (F + (A % N)) % N;}
	}
	for(int i = 0; i < F; i++){
		cout << Aft[N + i - F] << endl; 
	}
	for(int i = F; i < N; i++){
		cout << Aft[i - F] << endl; 
	}
}

Measured memory_bytes: 2304
import java.io.*;

public class Main {
    public static boolean checkPal (StringBuilder sb) {
        return sb.toString().contentEquals (sb.reverse());
    }

    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        String S = reader.readLine();
        StringBuilder sb = new StringBuilder (S);
        String str = S.substring (0, S.length() / 2);
        StringBuilder sbstr = new StringBuilder (str);
        System.out.println (checkPal (sb) && checkPal (sbstr) ? "Yes" : "No");
    }
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
	int A,N;
	cin >> N >> A;
	N=(N%500);
	if(N<=A){
	    cout << "Yes"  << endl;
	}else{
	    cout <<  "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b;
    while(1)
    {
        cin>>a>>b;
        if(a==0 && b==0) break;
        else
        {
                for(ll i=1; i<=a; i++)
            {
                  for(ll j=1; j<=b; j++)
                  {
                      if(i==1 || i==a || j==1 || j==b)
                        cout<<'#';
                      else
                        cout<<'.';
                  }
                  cout<<endl;
            }
            cout<<endl;
        }
    }
    return 0;
}



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

using namespace std;

// Function come here..

int main(int argc, char **argv)
{
    // Problem solution come here...
    int n;
    cin >> n;

    int count = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            if (i % 2 == 0)
            {
                if (j % 2 != 0)
                    count++;
            }
            else if (j % 2 == 0)
                count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int g,t,m500,m100,m50,m10,m5,m1,cnt=0;
  while(1){
    scanf("%d",&g);
    if(g==0){
      break;
    }
    t=1000-g;
    m500=t/500;
    cnt=cnt+m500;
    m500=t%500;
    m100=m500/100;
    cnt=cnt+m100;
    m100=m500%100;
    m50=m100/50;
    cnt=cnt+m50;
    m50=m100%50;
    m10=m50/10;
    cnt=cnt+m10;
    m10=m50%10;
    m5=m10/5;
    cnt=cnt+m5;
    m5=m10%5;
    m1=m5/1;
    cnt=cnt+m1;
    printf("%d\n",cnt);
    cnt=0;
  }
  return 0;
}

Measured memory_bytes: 600
def main():
    a, b = map(int, input().split())
    ans = 0
    for i in range(a, b + 1):
        tmp = str(i)
        if tmp[0] == tmp[4] and tmp[1] == tmp[3]:
            ans += 1
        else:
            pass
    print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;

#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define EPS 1e-9
#define X real()
#define Y imag()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using point = pair<double, double>;
using Vector = complex<double>;

int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	char c;
	cin >> c;
	cout << char(c + 1) << '\n';
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define modp(x, y) (((y) + (x) % (y)) % (y))
template<typename T> inline T gcd(T x, T y) { if(x < y) swap(x, y); T mod = x % y; if(mod == 0) return y; return gcd(y, mod); }
template<typename T> inline T lmc(T x, T y) { return x / gcd(x, y) * y; }

int N, M;
vector<int> edges[100000];
int color[100000];

int main(int argc, char* argv[])
{
	scanf("%d%d", &N, &M);
	for(int i = 0; i < M; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}

	stack<int> s;
	s.push(0);
	color[0] = 1;
	int count[2] = { 1, 0 };
	while(!s.empty())
	{
		int v = s.top();
		s.pop();
		for(int i = 0; i < (int)edges[v].size(); i++)
		{
			int next = edges[v][i];
			if(color[next] == 0)
			{
				color[next] = 3 - color[v];
				count[color[next] - 1]++;
				s.push(next);
			}
			else if(color[next] == color[v])
			{
				printf("%lld\n", (ll)N * (ll)(N - 1) / 2 - M);
				return 0;
			}
		}
	}
	printf("%lld\n", (ll)count[0] * (ll)count[1] - M);

	return 0;
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
#define int long long int 
#define pb push_back
using namespace std;
const int N =100005;
vector<int>v[N],v1[N],v2[N];
int parent[N];
int dp[N],dp2[N];
int ans[N];
map<int,int>mp[N];
void dfs(int s,int par,int mod)
{
    dp[s] = 1;
    parent[s] = par;
    int count=0;
    int flag=0;
    for(auto it:v[s])
    {
        if(it==par) continue;
        dfs(it,s,mod);
        dp[s] = ((dp[s]%mod*(dp[it]+1))%mod)%mod;
        v1[s].pb((dp[it]%mod+1LL%mod)%mod);
        v2[s].pb((dp[it]%mod+1LL%mod)%mod);
        mp[s][it] = count++;
        flag++;
    }
    if(flag){
    int mul = 1;
    int mul2 = 1;
    int n = v1[s].size();
   
    for(int i=0;i<n;i++)
    {
        
        v1[s][i] = ((mul%mod)*(v1[s][i]%mod))%mod;
        mul = v1[s][i];
        v2[s][n-i-1] = (mul2%mod*v2[s][n-i-1]%mod)%mod;
        mul2 = v2[s][n-i-1];
    }
  
  
    }

}

void dfs2(int s,int par,int mod)
{
    if(par==-1){
    dp2[s] = 0;
    ans[s] = dp[s];
    }
    else
    {
            dp2[s] = (dp2[parent[s]]%mod+1LL%mod)%mod;
            int idx = mp[parent[s]][s];
            int temp = 1;
          
          
            if(v1[parent[s]].size()>1){
            if(idx==0)
            {
                temp = (temp%mod*v2[parent[s]][idx+1]%mod)%mod;
                
            }
            else if(idx==v1[parent[s]].size()-1)
            {
                temp = (temp%mod*v1[parent[s]][idx-1]%mod)%mod;
                
            }
            else
            {
               
                temp = (temp*v1[parent[s]][idx-1]%mod)%mod;
                temp =(temp%mod*v2[parent[s]][idx+1]%mod)%mod;
               
            }
            }
            
            dp2[s] = (dp2[s]%mod*temp%mod)%mod;
            
        
        ans[s] = ((dp2[s]%mod+1LL%mod)%mod*dp[s]%mod)%mod;
        
    
     
    }
    for(auto it:v[s])
    {
        if(it==par) continue;
        dfs2(it,s,mod);
    }
    
}
int32_t main()
{
   
    
    int n,m;
    cin>>n>>m;

    for(int i=0;i<n-1;i++)
    {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }

   

    dfs(1,-1,m);
    // for(int i=1;i<=n;i++)
    // cout<<dp[i]<<" ";
    // cout<<"\n";


    dfs2(1,-1,m);

    // for(int i = 1;i<=n;i++)
    // cout<<dp2[i]<<" ";
    // cout<<"\n";

    for(int i=1;i<=n;i++)
    cout<<ans[i]<<"\n";
}


Measured memory_bytes: 41088
N, M = map(int, input().split())
X = list(map(int, input().split()))

X =  sorted(X)
d = []

if N >= M:
    print(0)
else:
    for i in range(M-1):
        d.append(X[i+1] - X[i])

    d = sorted(d)
    del d[len(d)-N+1:len(d)]
    S = sum(d)
    print(S)

Measured memory_bytes: 13960
#include <bits/stdc++.h>
// https://gcc.gnu.org/onlinedocs/gcc-4.6.2/libstdc++/api/a01040_source.html
using namespace std;
#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define pb push_back // 配列の最後にappendする
#define mp make_pair 
#define ALL(x) (x).begin(),(x).end()   // accumulateする場合、最初から最後までということか？
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

ll A,B,C,D,E,F,K,G,H,L,M,N,P,Q,R,W,X,Y,Z;
string S,T, U;
vector<ll> V;
int ans_s, ans_t;

// #define LOCAL
#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

int main(){

 cin >> S ;

REP(i,S.size())
 cout << "x";
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    long long ret = 0;
    int mx = 0;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        if (a > mx)
            mx = a;
        else
            ret += mx - a;
    }
    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 3628
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    AB = [list(map(int, input().split())) for _ in range(N)]
    CD = [list(map(int, input().split())) for _ in range(N)]

    reds = sorted(AB, key=lambda x: x[1], reverse=True)
    blues = sorted(CD, key=lambda x: x[0])
    cnt = 0

    for blue in blues:
        for red in reds:
            if red[0] < blue[0] and red[1] < blue[1]:
                red[1] = float("inf")
                cnt += 1
                break
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  string a;
  cin >> a;
  if (a[2] == a[3] and a[4] == a[5]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}
  /*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
  //配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
ll n ,L;
map<ll,bool> mp;
vector<string> s;
void dfs(ll len, ll le, ll ri){
	if(ri - le == 0){
		mp[L - len + 1] ^= 1;
		return;
	}
	if(ri - le == 1){
		if(len == s[le].length()) return;
		dfs(len + 1, le, ri);
		dfs(len + 1, le + 1, ri);
		return;
	}
	ll mi = le - 1, ma = ri, mid;
	while(ma - mi > 1){
		mid = (ma + mi) / 2;
		if(s[mid][len]=='0') mi = mid;
		else ma = mid;
	}
	dfs(len + 1, le, mi + 1);
	dfs(len + 1, ma, ri);
	return;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> L;
    s.resize(n);
    for(int i=0;i<n;i++){
    	cin >> s[i];
    }
    sort(be(s));
    dfs(0, 0, n);
    bool maki = false;
    map<ll,bool> g;
    for(auto& i:mp){
    	g[i.first&(-i.first)] ^= i.second;
    }
    for(auto& i:g){
    	if(i.second) maki = true;
    }
    cout << (maki?"Alice":"Bob") << endl;
    return 0;
}


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

using namespace std;
 
//#define int long long
using ll = long long;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define reps(i,n) for(ll i=0;i<=n;i++)

ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
 
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(){
    ios_base::sync_with_stdio(false);
    ll a,b,ans=0;
    cin >> a >> b;
    if(a==b){
        cout << a << endl;
        return 0;
    }

    if(b == a+1){
        ans = a^(a+1);
        cout << ans << endl;
        return 0;
    }

    if(a%2==0){
        if((b-a)%2==1){
            if((((b-a)/2))%2==0){
                cout << 1 << endl;
            }else{
                cout << 0 << endl;
            }
        }else{
            if((((b-a)/2))%2==0){
                cout << b << endl;
        }else{
            ans = 1^b;
            cout << ans << endl;
        }
        }
        }else{ //aが奇数のとき
            if(((b-a)/2)%2==0){
            ans = 0;
        }else{
            ans = 1;
        }
        if((b-a)%2==0){
            ans ^= a;
        }else{
            ans ^= a;
            ans ^= b;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>

int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	int a[M];
	int i, ret;
	ret = N;
	for(i = 0; i < M; i++){
		scanf("%d", &a[i]);
	}
	for(i = 0; i < M; i++){
		ret -= a[i];
		if(ret < 0){
			ret = -1;
			break;
		}
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 2184
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



int main() {	
	int d, g;
	cin >> d >> g;

	int m = 0;
	vector< vector<int> >v(d,vector<int>(2,0));
	rep(i,0,d) {
		cin >> v[i][0] >> v[i][1];
		m += v[i][0];
	}

	//dp[i][j]:100i点の問題まででj問解いた時の得点の最大値
	vector< vector<int> >dp(d+1,vector<int>(m+1,0));


	rep(i,0,d) {
		rep(j,0,m+1) {
			rep(k,0,v[i][0]+1) {
				if (j-k >= 0) {
					if (k != v[i][0]) {
						dp[i + 1][j] = max(max(dp[i][j - k] + k * (i + 1) * 100,dp[i][j]),dp[i+1][j]);
					}
					else {
						dp[i + 1][j] = max(max(dp[i][j - k] + k * (i + 1) * 100 + v[i][1], dp[i][j]),dp[i+1][j]);
					}
				}else{
					dp[i + 1][j] = max(dp[i][j],dp[i+1][j]);
				}
			}
		}
	}

	int ans = 1010;
	rep(j, 0, m + 1) {
		if (dp[d][j] >= g) { ans = j; break; }
	}

	cout << ans << endl;


	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int W, H, x, y, r;
	scanf("%d %d", &W, &H);
	scanf("%d %d %d", &x, &y, &r);
	if(0 <= (x-r) && (x+r) <= W && 0 <= (y-r) && (y+r) <= H) printf("Yes\n");
	else printf("No\n");
	return 0;
}


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

using namespace std;

typedef long long int ll;

const int MAXN = 100005;

int n;
ll ans;
ll a[MAXN], B[MAXN];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n + 1; ++i) 
	{
        scanf("%lld", &a[i]);
    }
    for (int i = 1; i <= n; ++i)
	{
        scanf("%lld", &B[i]);
        if (B[i] <= a[i])
            ans += B[i];
        else if (B[i] <= a[i] + a[i + 1]) 
		{
            ans += B[i];
            a[i + 1] -= (B[i] - a[i]);
        }
        else 
		{
            ans += (a[i] + a[i + 1]);
            a[i + 1] = 0;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1792
a, b, c = map(int, input().split())
if a == 7:
	if b == 5 and c == 5:
		print("YES")
	else:
		print("NO")
elif b == 7:
	if a == 5 and c == 5:
		print("YES")
	else:
		print("NO")
elif c == 7:
	if b == 5 and a == 5:
		print("YES")
	else:
		print("NO")


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define LSTAGE 1



int main()
{

    ll n;
    cin >> n;
    map<ll, int> v;
    for(ll i=  0; i < n; i++)
    {
        ll r;
        cin >> r;
        if(v.count(r)==0)
        {
            v[r] = 0;
            v[r]++;
        }
        else v[r]++;

    }
    map<ll, int> :: iterator it;
    ll area = 0;
    ll a= 0, b= 0;
    for(it = v.begin(); it!=v.end(); it++)
    {

//        cout << it->F<<endl;
        if(it->S >= 4)
        {
            area = max(area, it->F*it->F);
        }
        if(it->S>=2)
        {
            b = a;
            a = it->F;
            area = max(area, a*b);
        }
    }
    cout << area ;




    return 0;
}


Measured memory_bytes: 6528
def main():
    N = input_int()
    S = input()

    validitylist = [False] * N
    validitylist[0] = True

    for i in range(1, N):
        if S[i-1] != S[i]:
            validitylist[i] = True
    
    print(len([i for i in validitylist if i is True]))



def input_int():
    return int(input())


def input_int_tuple():
    return map(int, input().split())


def input_int_list():
    return list(map(int, input().split()))


main()


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

using namespace std;

int main(int argc, char *argv[])
{
    // input from txt （提出時にこの箇所は削除すること）
    //std::ifstream in("in.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int a[3];
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
    }
    sort(a, a+3);
    cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;

    return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,k,x,res=0;
  int food[1000010]={};

  cin >> n >> m;
  for(int i=0;i<n;i++){
    cin >> k;
    while(k--){
      cin >> x;
      food[x-1]++;
    }
  }
  for(int i=0;i<m;i++) if(food[i]==n) res++;
  cout << res << endl;
  return 0;
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,s,t) for(auto (i) = (s); (i) <= (t); ++(i))
#define repD(i,t,s) for(auto (i) = (t); (i) >= (s); --(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) ((a)^(b) & 1LL ^ 1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = 1e9 + 7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,a; cin>>n;
	ll s[100001] = {};
	rep(i,n){
		cin>>a;
		s[i + 1] = s[i] + a;
	}
	ll ans1 = 0, ans2 = 0,cur1 = 0,cur2 = 0,r1 = 1,r2 = -1;
	rep1(i,n){
		ll t = s[i] + cur1;
		if(r1 * t <= 0){
			ans1 += abs(r1 - t);
			cur1 += r1 - t;
		}
		r1 = -r1;
	}
	rep1(i,n){
		ll t = s[i] + cur2;
		if(r2 * t <= 0){
			ans2 += abs(r2 - t);
			cur2 += r2 - t;
		}
		r2 = -r2;
	}
	cout<<min(ans1,ans2)<<endl;
	
	return 0;
}





Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
set<int> s;
int main(){
	int n,a;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(s.find(a)==s.end()){
			s.insert(a);
		}
		else s.erase(a);
	}
	cout<<s.size()<<endl;
	return 0;
}


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

#ifdef LOCAL
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define dbgv(x) cerr << #x << " = " << x << endl
#define dbga(arr, len) {cerr << #arr << " = "; for (int _ = 0; _ < len; _++)\
cerr << arr[_] << " "; cerr << endl;}
#define dbgi(it) {cerr << #it << " = "; for (const auto& _ : it)\
cerr << _ << " "; cerr << endl;}
#else
#define dbg(...) (void)0
#define dbgv(x) (void)0
#define dbga(arr, len) (void)0
#define dbgi(it) (void)0
#endif

using ll = long long;
using dbl = long double;
using pii = pair<int, int>;

void solve() {
    ll n;
    scanf("%lld", &n);

    ll res = (ll)1e18;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i != 0) {
            continue;
        }
        ll j = n / i;
        res = min(res, i + j - 2);
    }

    printf("%lld\n", res);
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    solve();

    dbg("\n\ntime = %.3lf\n", (double)clock() / CLOCKS_PER_SEC);
}


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

#define SZ(v) ((int)(v).size())
using ll = long long;

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

	ll X;
	cin >> X;
	int nb_jours(0);
	ll cur(100);
	while (cur < X)
	{
		cur += cur/100;
		++nb_jours;
	}
	cout << nb_jours<<endl;
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    for(int i=n-1;i>=0;i--){
        if(i==0){
            cout<<A[i]<<endl;
            break;
        }
        cout<<A[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 3116