akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace DPL1_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var L = new Dictionary<int, int>();
            L[0] = int.Parse(Console.ReadLine());
            int length = 1;
            for (int i = 0; i < n-1; i++)
            {
                var t = int.Parse(Console.ReadLine());
                if (L[length - 1] < t)
                {
                    L[length++] = t;
                }
                else
                {
                    L[L.TakeWhile(s => s.Value < t).Count()] = t;
                }

            }
            Console.WriteLine(length);
        }
    }
}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
				
		String s = sc.next();
		
		String a = s.substring(0,2);
		String b = s.substring(2,4);
		
		int t = Integer.parseInt(a);
		int r = Integer.parseInt(b);
		
		if(1<=t && t<=12) {
			if(1<=r && r<=12) {
				System.out.println("AMBIGUOUS");
			}
			if(r>12 || r==0) {
				System.out.println("MMYY");
			}
		}
		if((1<=r && r<=12 )&&( t > 12 || t == 0)) {
			System.out.println("YYMM");
		}
		if((r>12 || r == 0) && (t >12 || t ==0)) {
			System.out.println("NA");
		}
				
		}
}


Measured memory_bytes: 23764
#include <iostream>

int main() {
  int a, b, c, d;
  std::cin>>a>>b>>c>>d;
  bool isTAK=true;
  while(a>0 && c>0) {
    if(isTAK) c-=b;
    else a-=d;
    isTAK=!isTAK;
  }
  if(a<=0) std::cout<<"No";
  else std::cout<<"Yes";
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, h, w;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> h >> w;
  int ans = 0;
  FOR(i, 0, n){
    int _h, _w;
    cin >> _h >> _w;
    if(_h>=h && _w>=w) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

typedef long long int lli;

using namespace std;

int main() {

   lli N,K;
   cin >> N >> K;
   lli A[N];
   int city=0;
     int T[N],F[N],FF[N];
   for(int i=0;i<N;i++ ){
      cin >> city;
      A[i]=city-1;
     T[i]=0;
     F[i]=0;
     FF[i]=0;
   }

   int pos=0;
   int cc=0;
   int rem=0;
   for(long long int i=0;i<K;i++){
      
      if(pos==A[pos]){
      	break;
      }else{
        if(F[pos]==0){
        	F[pos]=1;
            FF[pos]=i;
        }else if(F[pos]==1){
            F[pos]=2;
            T[pos]=i-FF[pos];
        }else if(F[pos]==2 && cc==0){
        	rem=(K-i)%T[pos];
          	break;
        }
     }//fi
     //cout << i << " "<< pos << " " << T[pos] << " " << F[pos] << " " << FF[pos]<< endl; 
     pos=A[pos];
   }
   for(long long int i=0;i<rem;i++){
   		pos=A[pos];
   }
   cout << pos+1 << endl; 
}

Measured memory_bytes: 7540
s=int(input())
A=set()
A.add(s)
count=1
while count==len(A):
    if s%2==0:
        A.add(s/2)
        count+=1
        s=s/2
    else:
        A.add(3*s+1)
        count+=1
        s=3*s+1
print(count)

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

int main() {
  int N;
  cin >> N;
  string s, t;
  cin >> s >> t;
  
  int res = 10000000;
  for (int i = 0; i < N; i++){
    bool flag = false;
    for (int j = 0; j < N; j++){
      if (i + j >= N){
        res = min(i + N, res);
        break;
      }
      if (s[i + j] != t[j]) {
        flag = true;
        break;
      }
    }
    if (flag == false) res = min(i + N, res);
  }
  if (res == 10000000) res = N * 2;
  
  cout << res << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX / 2 + 2], R[MAX/2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ) {
    if ( L[i].value  <= R[j].value ) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  int mid;
  if ( left + 1 < right ) {
    mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ) {
    if ( A[j].value <= x.value ) {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if ( p < r ) {
    q = partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n - 1 );

  for ( i = 0; i < n; i++ ) {
    if ( A[i].suit != B[i].suit ) stable = 0;
  }

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

  return 0;
}


Measured memory_bytes: 4964
#include <cstdio>
#include <vector>
#include <algorithm>

#define PB push_back

using namespace std;

vector < int > v;
int n;

int main(){
    scanf("%d", &n);
    for(int i = 0;i<2*n;i++){
        int x;scanf("%d", &x);
        v.PB(x);
    }
    sort(v.begin(), v.end());
    int sol = 0;
    for(int i = 0;i<v.size();i += 2)
        sol += v[i];
    printf("%d\n", sol);
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    int n=s.length();
    int[][] a=new int[2][n];
    for(int i=0;i<n;i++){
      a[0][i]=i+(s.charAt(i)=='R'?1:-1);
    }
    for(int k=0;k<35;k++){
      for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
          a[m(i)][j]=a[i][a[i][j]];
        }
      }
    }
    int[] ans=new int[n];
    for(int i=0;i<n;i++){
      ans[a[0][i]]++;
    }
    for(int i=0;i<n-1;i++){
      System.out.print(ans[i]+" ");
    }
    System.out.println(ans[n-1]);
  }
  static int m(int i){
    return i==0?1:0;
  }
}

Measured memory_bytes: 41424
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    FOR(i, 0, n)
        cin >> a[i];
    sort(a.begin(), a.end());
    cout << a.back() - a.front() << endl;
    return 0;
}

Measured memory_bytes: 256
#d
n = int(input())
a = list(map(int, input().split()))
ans = [0]*len(a)
for i in range(len(a),0,-1):
    if sum(ans[i-1::i])%2 != a[i-1]:
        ans[i-1] = 1
print(sum(ans))
if sum(ans) > 0:
    ans_n = [str(i+1) for i, x in enumerate(ans)  if x==1]
    ans_n=" ".join(ans_n)
    print(ans_n)

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

typedef long long ll;
typedef long double ld;
const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll  INF = 1e18;
const ld  PI = acos((ld) -1);
template<class T> inline void array_input(T a[], size_t n){for(size_t i = 0; i < n; i++)cin >> a[i];}
/*
template<class T>
inline void array_init(T a[], T val){
    for(size_t i )
}
*/
long long binExp(long long a, long long b, long long mod){
    long long res = 1;
    while(b > 0){
        if(b % 2) res = res * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return res;
}

//#define FILE
int main(){
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // 0

    string s;
    cin >> s;

    int ans = 0, ma = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'R') ma++;
        else{
            ans = max(ma, ans);
            ma = 0;
        }
    }

    cout << max(ma, ans) << '\n';

    return 0;
}


Measured memory_bytes: 3624
def Get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def Get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def Get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def Get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
n=gets.to_i
a=gets.to_i

puts (n%500)<=a ? "Yes" : "No"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int a,b; cin >> a >> b;
    for(int i = 1; i <= 10000;++i){
        if(int(i*0.08) == a && int(i*0.1) == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int cans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


int main(){
    int N,A;
    cin >> N >> A;
    bool f = false;
    if(A - N%500 >= 0) f = true;
    cans(f);
    return 0;
}



Measured memory_bytes: 3636
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int num = Integer.parseInt(line);
        line = sc.nextLine();
        String[] lines = line.split(" ", 0);
        long[] array = new long[num];
        long ret = 0;
 
        for (int i = 0; i < num; i++) {
            array[i] = Long.parseLong(lines[i]);
        }
        
        long[] array2 = new long[num];
        long sum = 0;
        for (int i = 1; i < num; i++) {
            sum += array[i];
            if (sum >= 1000000007) {
                sum = sum % 1000000007;
            }
        }
        array2[0] = sum;
        for (int i = 1; i < num ; i++){
            array2[i] = array2[i - 1] - array[i];
            if (array2[i] < 0) {
                array2[i] += 1000000007;
            }
        }
        
        for (int i = 0; i < num; i++) {
            ret += (array[i] * array2[i]);
            if (ret >= 1000000007) {
                ret = ret % 1000000007;
            }
        }
 
        System.out.println(ret);
    }
 
}

Measured memory_bytes: 82964
#include <cstdio>
#include <algorithm>

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

using namespace std;

int main(){
	int q; scanf("%d",&q);
	while(q--){
		int c,a,n; scanf("%d%d%d",&c,&a,&n);
		int ans=0;
		for(int i=0;i<=min(min(c,a),n);i++){ // i: # of CAN teams
			int cc=c-i,aa=a-i;
			int j=min(cc/2,aa); // j: # of CCA teams
			ans=max(ans,i+j+(cc-2*j)/3);
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1028
'use strict'

const main = (INPUT) => {
  const a = INPUT.split('\n')[0].split(' ')
  if (a.every(v => v == a[0])) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;
int const MAX = 200005;
long long const INF = 100000000000000000;
struct edge
{
	int from; int to; long long value;
};

vector<edge> g[MAX];
long long pos[MAX];
int n, m;

bool possible(int s) {
	stack<int> S;
	S.push(s);
	pos[s] = 0;
	while (!S.empty()) {
		int now = S.top();
		S.pop();
		for (int i = 0; i < g[now].size(); i++) {
			int next = g[now][i].to;
			int dist = g[now][i].value;
			if (pos[next] == INF) {
				pos[next] = pos[now] + dist;
				S.push(next);
			}else{
				if (pos[next] - pos[now] != dist) {
					return false;
				}
			}
		}
	}
	return true;
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int f, t, v;
		cin >> f >> t >> v;
		g[f].push_back({ f,t,v });
		g[t].push_back({ t,f,-v });
	}
	for (int i = 1; i <= n; i++) {
		pos[i] = INF;
	}
	for (int i = 1; i <= n; i++) {
		if (pos[i] == INF) {
			if(!possible(i)){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define fore(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)

template <class T> bool mini(T& a, T b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, T b) { return a < b ? (a = b, 1) : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;

const int INF = (int)1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vvi a(n, vi(n));
    fore(i, 0, n) fore(j, 0, n) cin >> a[i][j];
    vi f(1 << n);
    f[0] = 1;
    fore(mask, 0, 1 << n) {
        int i = __builtin_popcount(mask);
        fore(j, 0, n) if (!(mask & (1 << j)) && a[i][j]) (f[mask | (1 << j)] += f[mask]) %= INF;
    }
    cout << f[(1 << n) - 1] << '\n';
    return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  string s;
  cin >> n>> s;
  if(n >= s.length())
    cout << s << endl;
  else {
    cout << s.substr(0, n) << "..." << endl;
  }
  return 0;
}

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

int main() {
	string str;
	int q;
	cin >> str >> q;
	for (int i = 0; i < q; i++) {
		string com;
		int a, b;
		cin >> com >> a >> b;
		if (com == "print")
			cout << str.substr(a, b - a + 1) << endl;
		if (com == "reverse")
			reverse(str.begin() + a, str.begin() + b + 1);
		if (com == "replace") {
			string p;
			cin >> p;
			str.replace(a, b - a + 1, p);
		}
	}
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;
using P = pair<int, int>;

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; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);


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

  int n; cin >> n;
  vector<string> ans;
  using P = pair<string, int>;
  queue<P> q;
  q.push(P("a", 1));

  while (!q.empty()) {
    P p = q.front(); q.pop();
    if (p.first.size() == n) {
      ans.push_back(p.first);
      continue;
    }
    for (int i = 0; i < p.second + 1; i++) {
      string s = p.first;
      s.push_back('a' + i);
      if (i < p.second) q.push(P(s, p.second));
      else q.push(P(s, p.second + 1));
    }
  }

  for (auto& s : ans) {
    cout << s << endl;
  }

  return 0;
}


Measured memory_bytes: 9852
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,a,b;
  cin>>x>>a>>b;
  int s,t;
  s=a-x;
  t=b-x;
  if(s<0)s=-s;
  if(t<0)t=-t;
  if(s>t)cout<<"B";
  else cout<<"A";
  
}


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

int main(){
    int N, K, C;
    std::cin >> N >> K >> C;
    std::string s;
    std::cin >> s;
    std::vector<int> work_day;
    int last_work = - C - 1;
    bool ok = false;
    for(int i = 0; i < N; ++i){
        if(s[i] == 'o' && i > last_work + C){
            work_day.push_back(i);
            last_work = i;
        }
        if((int)work_day.size() >= K){
            ok = true;
            break;
        }
    }
    if(!ok) return 0;
    std::vector<int> dp(N+1);
    dp[N] = 0;
    last_work = N + C;
    for(int i = N - 1; i >= 0; --i){
        if(s[i] == 'o' && i < last_work - C){
            dp[i] = dp[i+1] + 1;
            last_work = i;
        }else{
            dp[i] = dp[i+1];
        }
    }
    std::vector<int> ans;
    for(int i = 0; i < (int)work_day.size(); ++i){
        const int day = work_day[i];
        if(i + dp[day + 1] < K) ans.push_back(day);
    }
    for(const int day : ans){
        std::cout << day + 1 << "\n";
    }
}

Measured memory_bytes: 4216
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

#define BUF_SIZE 0x100

char buf0[BUF_SIZE];
char buf1[BUF_SIZE];

void read_line(char* buf, size_t size)
{
  fgets(buf, size, stdin);
  char* lf_addr = strchr(buf, '\n');
  if(lf_addr) {
    *lf_addr = '\0';
  }
}

bool match(const char* lstr, const char* sstr, int index)
{
  for(int i = 0; i < (int)strlen(sstr); i++) {
    if(lstr[i+index] == sstr[i] || lstr[i+index] == '?') {
      continue;
    } else {
      return false;
    }
  }
  return true;
}

void overwrite(char* lstr, const char* sstr, int index)
{
  strncpy(lstr+index, sstr, strlen(sstr));
}

void replace_question(char* lstr)
{
  for(size_t i = 0; i < strlen(lstr); i++) {
    if(lstr[i] == '?') {
      lstr[i] = 'a';
    }
  }
}

void convert(char* lstr, const char* sstr, int index)
{
  overwrite(lstr, sstr, index);
  replace_question(lstr);
}

int main()
{
  read_line(buf0, sizeof(buf0));
  read_line(buf1, sizeof(buf1));
  for(int i = (int)strlen(buf0) - (int)strlen(buf1); 0 <= i; i--) {
    if(match(buf0, buf1, i)) {
      convert(buf0, buf1, i);
      puts(buf0);
      return 0;
    } else {
      continue;
    }
  }
  puts("UNRESTORABLE");
  return 0;
}


Measured memory_bytes: 504
#!/usr/bin/ruby
require 'mathn'
h={};2.step(36){|i|h[i]=i.prime_division}
while(l=gets)!="0 0\n"
	l=l.split
	n=l[0].to_i;m=l[1].to_i(n)
	p h[n].map{|a,b|
		z=m;r=0
		while z>0 do r+=(z=z.div a) end
		r.div b
	}.min
end

Measured memory_bytes: 4004
#include<stdio.h>
#include<string.h>

int main(){
	int n;
	scanf("%d", &n);
	int price[n];
	for(int i=0; i<n; i++){
		scanf("%d", &price[i]);
	}
	
	int max=0, sum=0;
	for(int i=0; i<n; i++){
		sum+=price[i];
		if(max<price[i]) max=price[i];
	}
	printf("%d", sum-max/2);
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define MAX 200000
typedef long long l;

int L[MAX/2+2],R[MAX/2+2];

l merge(int A[], int n, int left, int mid, int right){
	int i,j,k;
	l count=0;
	
	int n1=mid-left;
	int n2=right-mid;
	
	for(i=0; i<n1; i++){
		L[i]=A[left+i];
	}
	
	for(i=0; i<n2; i++){
		R[i]=A[mid+i];
	}
	
	L[n1]=2000000000;
	R[n2]=2000000000;
	
	i=0;
	j=0;
	
	for(k=left; k<right; k++){
		if(L[i]<=R[j]){
			A[k]=L[i++];
		}
		else{
			A[k]=R[j++];
			count+=n1-i;
		}
	}
	return count;
}

l mergesort(int A[], int n, int left, int right){
	int mid;
	l v1,v2,v3;
	if(left+1<right){
		mid=(left+right)/2;
		v1 = mergesort(A, n, left, mid);
		v2 = mergesort(A, n, mid, right);
		v3 = merge(A, n, left, mid, right);
		return v1+v2+v3;
	}
	else{
		return 0;
	}
}

int main(void){
	int A[MAX],i,n;
	scanf("%d",&n);
	
	for(i=0; i<n; i++){
		scanf("%d",&A[i]);
	}
	
	l ans=mergesort(A, n, 0, n);
		printf("%lld\n", ans);
	
	return 0;
}




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

#ifdef LOCAL 
#include "/home/gokul/Codes/lib/prettyprint.hpp"
#else
#define debug(...) 2
#endif

const int M = 1e9 + 7;
vector<int> sub;
vector<vector<int>> g;

template <int MOD=1000000007>
struct Modular {
  int value;
  static const int MOD_value = MOD;

  Modular(long long v = 0) { value = v % MOD; if (value < 0) value += MOD;}
  Modular(long long a, long long b) : value(0){ *this += a; *this /= b;}

  Modular& operator+=(Modular const& b) {value += b.value; if (value >= MOD) value -= MOD; return *this;}
  Modular& operator-=(Modular const& b) {value -= b.value; if (value < 0) value += MOD;return *this;}
  Modular& operator*=(Modular const& b) {value = (long long)value * b.value % MOD;return *this;}

  friend Modular mexp(Modular a, long long e) {
    Modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
    return res;
  }
  friend Modular inverse(Modular a) { return mexp(a, MOD - 2); }

  Modular& operator/=(Modular const& b) { return *this *= inverse(b); }
  friend Modular operator+(Modular a, Modular const b) { return a += b; }
  friend Modular operator-(Modular a, Modular const b) { return a -= b; }
  friend Modular operator-(Modular const a) { return 0 - a; }
  friend Modular operator*(Modular a, Modular const b) { return a *= b; }
  friend Modular operator/(Modular a, Modular const b) { return a /= b; }
  friend std::ostream& operator<<(std::ostream& os, Modular const& a) {return os << a.value;}
  friend bool operator==(Modular const& a, Modular const& b) {return a.value == b.value;}
  friend bool operator!=(Modular const& a, Modular const& b) {return a.value != b.value;}
};

vector<Modular<>> fact, inv, ways;

int ncr(int n, int r) {
  return (fact[n] * inv[n-r] * inv[r]).value;
}

void dfs(int x, int par) {
  sub[x] = 0;
  for (auto to : g[x]) {
    if (to == par) continue;
    dfs(to, x);
    sub[x] += sub[to];
  }
  
  ways[x] = 1; 
  int cur = sub[x]; 
  for (auto to : g[x]) {
    if (to == par)  continue;
    ways[x] *= ncr(cur, sub[to]) * ways[to];
    cur -= sub[to];
  }
  sub[x]++;
}

void reroot(int x, int par) {
  int n = g.size() - 6;
  ways[x] = 1;

  for (auto to : g[x]) {
    ways[x] *= ncr(n, sub[to]) * ways[to];
    n -= sub[to];
  }

  n = g.size() - 5;
  for (auto to : g[x]) {
    if (to == par)  continue;
    int sz = sub[x];
    auto ans = ways[x];

    sub[x] = n - sub[to];  
    ways[x] *= inv[n-1];
    ways[x] *= fact[sub[x]-1];
    ways[x] *= fact[sub[to]];
    ways[x] /= ways[to];

    reroot(to, x);
    sub[x] = sz;
    ways[x] = ans;
  }
}

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n;
  cin >> n;

  g.resize(n + 5);
  sub.resize(n + 5);
  fact.resize(n + 5);
  inv.resize(n + 5);
  ways.resize(n + 5);

  fact[0] = 1, inv[0] = 1; 
  for (int i = 1;  i <= n; ++i) {
    fact[i] = i * fact[i-1];
    inv[i] = 1 / fact[i];
  }

  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;

    g[u].push_back(v);
    g[v].push_back(u);
  }

  dfs(1, 1);
  debug(ways);
  reroot(1, 1);

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

Measured memory_bytes: 17140
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

res = [A[0]]
for a in A[1:]:
    res.append(a)
    res.append(a)
print(sum(res[: N - 1]))


Measured memory_bytes: 130444
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAX 10000

long int S[MAX];

int linearSearch(int key, int n)
{
	int i;
	
	i = 0;
	S[n] = key;
	while (S[i] != key) {
		i++;
	}
	if (i == n) {
		return 1;
	}
	return 0;
}


int main()
{
	int n, q;
	long int T[MAX];
	int i, cnt;
	
	cnt = 0;
	
	scanf("%d",&n);
	for (i = 0; i < n; i++) {
		scanf("%ld",&S[i]);
	}
	
	scanf("%d",&q);
	for (i = 0; i < q; i++) {
		scanf("%ld",&T[i]);
	}
	
	for (i = 0; i < q; i++) {
		linearSearch(T[i], n);
		if (linearSearch(T[i], n) == 0) {
			cnt++;
		}
	}
	printf("%d\n",cnt);
return 0;
}


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

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

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

int n;
pii p[maxn >> 1];
int s[maxn];
int dp[maxn];

void work()
{
    cin >>n;
    for(int i = 0; i < n; i++)
    {
        int x, r;
        cin >>x >>r;
        p[i].fi = x - r;
        p[i].se = x + r;
        s[i << 1] = x - r;
        s[i << 1 | 1] = x + r;
    }

    sort(s, s + n * 2);
    int m = unique(s, s + n * 2) - s;
    sort(p, p + n, [](pii &lhs, pii &rhs){return lhs.se < rhs.se;});

    int t = 1;
    for(int i = 0; i < n; i++)
    {
        int l = p[i].fi, r = p[i].se;
        l = lower_bound(s, s + m, l) - s + 1;
        r = lower_bound(s, s + m, r) - s + 1;

        while(t <= r)
        {
            dp[t] = max(dp[t], dp[t - 1]);
            t++;
        }

        dp[r] = max(dp[r], dp[l] + 1);
    }

    int ans = 0;
    for(int i = 1; i <= m; i++) ans = max(ans, dp[i]);

    cout <<ans <<endl;
}


int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 2560
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    a.sort()
    c.sort()

    def bs(seq, target, key_):
        first = 0
        last = len(seq) - 1
        if key_ == '<=':
            while first + 1 < last:
                middle = (first + last) // 2
                if seq[middle] <= target:
                    first = middle
                else:
                    last = middle
            if seq[first] <= target < seq[last]:
                return first
            elif target < seq[first]:
                return
            else:
                return len(seq) - 1
        if key_ == '<':
            while first + 1 < last:
                middle = (first + last) // 2
                if seq[middle] < target:
                    first = middle
                else:
                    last = middle
            if seq[first] < target <= seq[last]:
                return first
            elif target <= seq[first]:
                return
            else:
                return len(seq) - 1
        if key_ == '>=':
            while first + 1 < last:
                middle = (first + last) // 2
                if seq[middle] < target:
                    first = middle
                else:
                    last = middle
            if seq[first] < target <= seq[last]:
                return last
            elif target <= seq[first]:
                return 0
            else:
                return
        if key_ == '>':
            while first + 1 < last:
                middle = (first + last) // 2
                if seq[middle] <= target:
                    first = middle
                else:
                    last = middle
            if seq[first] <= target < seq[last]:
                return last
            elif target < seq[first]:
                return 0
            else:
                return
    
    ans = 0
    for target in b:
        aindex = bs(a, target, '<')
        if aindex is None:
            continue
        cindex = bs(c, target, '>')
        if cindex is None:
            continue
        ans += (aindex + 1) * (len(c) - cindex)
    print(ans)

main()


Measured memory_bytes: 22516
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

int main(void) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int ans = std::min({a + b, a + c, b + c});
    printf("%d\n", ans);
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int nmax = max(a, max(b,c));
    int twos = 1;
    for(size_t i = 0; i < k; i++)
    {
        twos *= 2;
    }
    cout << twos * nmax + a + b + c - nmax << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		sc.close();
		StringBuilder ans = new StringBuilder();
		for (int i = 0; i < str.length(); i = i + 2) {
			ans.append(str.charAt(i));
		}
		System.out.println(ans);
	}
}

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

int main(void){
    int n ;
    cin >> n ;
    vector<pair<int,int>> a ;
    for (int i=0; i<n; i++){
        int x ;
        cin >> x ;
        pair<int,int> y ;
        y.first = x ;
        y.second = i ;
        a.push_back(y) ;
    }
    sort(a.begin(),a.end()) ;
    for (int i=0; i<n; i++){
        cout << a[i].second+1 << endl ;
    }
}

Measured memory_bytes: 1780
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define N 524288
int a[N],b[N],ch[N],out[N];
vector<int> par[N];
int dat[N*2+10];
int inf=1145141919;
priority_queue<int> q;
//[a,b)の最小値
int query(int a,int b,int k=0,int l=0,int r=N){
	if(r<=a || b<=l) return inf;
	if(a<=l && r<=b) return dat[k];
	int vl=query(a,b,k*2+1,l,(l+r)/2);
	int vr=query(a,b,k*2+2,(l+r)/2,r);
	return min(vl,vr);
}
void update(int k,int a){
	k+=N-1;
	dat[k]=a;
	while(k>0){
		k=(k-1)/2;
		dat[k]=min(dat[k*2+1],dat[k*2+2]);
	}
	return;
}
int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	rep(i,n){
		scanf("%d",&a[i]);a[i]--;
	}
	rep(i,n) b[a[i]]=i;
	//rep(i,n) cout<<b[i]<<endl;
	
	rep(i,N*2+10) dat[i]=inf;
	rep(i,n){
		int x=query(b[i],min(n,b[i]+k));
		if(x<inf) ch[b[-x]]++,par[b[i]].pb(b[-x]);
		update(b[i],-i);
	}
	
	rep(i,N*2+10) dat[i]=inf;
	for(int i=n-1;i>=0;i--){
		int x=query(max(0,b[i]-k+1),b[i]);
		if(x<inf) ch[b[i]]++,par[b[x]].pb(b[i]);
		update(b[i],i);
	}
	//rep(i,n) cout<<i<<' '<<par[i]<<' '<<ch[i]<<endl;
	
	rep(i,n){
		if(ch[i]==0) q.push(i);
	}
	rep(i,n){
		int p=q.top();q.pop();
		out[p]=n-i-1;
		rep(j,par[p].size()){
			ch[par[p][j]]--;
			if(ch[par[p][j]]<1) q.push(par[p][j]);
		}
	}
	
	rep(i,n) printf("%d\n",out[i]+1);
}


Measured memory_bytes: 44928
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	ll N, K;
	vector<ll> H(200005);
	ll sum = 0;

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
		sum += H[i];
	}
	sort(H.begin(), H.end(), std::greater<ll>());

	if (N <= K) {
		K = N;
	}
	for (int i = 0; i < K; i++) {
		sum -= H[i];
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1792
import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
 
N=II()
B=LI()

su = B[0]
for i in range(0,N-2):
    su+=min(B[i], B[i+1])
    
su+=B[N-2]


print(su)

Measured memory_bytes: 5048
#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 A,B,C,D;
  cin>>A>>B>>C>>D;
  
  string ans="Yes";
 
  while(true){
    C-=B;
    if(C<=0){
      ans="Yes";
      break;
    }
    A-=D;
     if(A<=0){
      ans="No";
      break;
    }
  } 
    cout<<ans<<endl;
    


}

Measured memory_bytes: 3588
#include <stdio.h>

int getLB(int a[],int k,int head,int tail){
    if(a[0]>=k)return 0;
    
    if(head>tail)return -1;
    
    int mid=(head+tail)/2;
    if(a[mid]<k)head=mid+1;
    else if(a[mid]>=k){
        if((mid-1>=0&&a[mid-1]<k)||mid==0)return mid;
        tail=mid-1;
    }
    
    return getLB(a,k,head,tail);
}
int getUB(int a[],int k,int head,int tail){
    if(a[0]>k)return 0;
    
    if(head>tail)return -1;
    
    int mid=(head+tail)/2;
    if(a[mid]<=k)head=mid+1;
    else if(a[mid]>k){
        if((mid-1>=0&&a[mid-1]<=k)||mid==0)return mid;
        tail=mid-1;
    }
    
    return getUB(a,k,head,tail);
}

int main(void){
    int i;
    
    int n;
    scanf("%d\n",&n);
    int a[n];
    for(i=0;i<n;i++)scanf("%d ",&a[i]);
    
    int q;
    scanf("%d\n",&q);
    
    int k,LB,UB;
    while(q--){
        scanf("%d\n",&k);
        LB=getLB(a,k,0,n-1);
        if(LB==-1){
            LB=n;
            UB=n;
        }else{
            UB=getUB(a,k,LB,n-1);
            if(UB==-1)UB=n;
        }
        printf("%d %d\n",LB,UB);
    }

    return 0;
}



Measured memory_bytes: 2192
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;

#define int ll
const int N = 1e6;
int nod[N + 2];

signed main(){

#ifndef ONLINE_JUDGE
	//freopen("in.txt" , "r" , stdin);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);

    for(int i = 1 ; i <= N ; i++)
        for(int j = i ; j <= N ; j += i)
            nod[j] += 1;
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1 ; i < n ; i++)
        ans += nod[i];
    cout << ans << '\n';

    return 0;

}



Measured memory_bytes: 11424
#include <iostream>
#include <vector>
#include <map>

using namespace std;

const long long int MOD=1e9+7;

int main() {
    int N;
    cin >> N;
    
    map<int, int> mp;
    for(int n=N; n>1; n--) {
        int tmp=n;
        int cur=2;
        while(tmp>=cur) {
            if(tmp%cur==0) {
                mp[cur]++;
                tmp /= cur;
                
                while(tmp%cur==0) {
                    mp[cur]++;
                    tmp /=cur;
                }
                cur++;
            } else {
                cur++;
            }
        }
    }
    

    long long int ans=1;
    for(auto i=mp.begin(); i!=mp.end(); i++) {
        ans *= (i->second + 1);
        ans %= MOD;
    }
    
    cout << ans << endl;



    return 0;
    
}

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

int main() {
  int N;
  int n=1;
  cin>>N;
  vector<int> vec(N);
  rep(i,N){
    cin>>vec.at(i);
  }
  rep(i,N){
    n=vec.at(n-1);
    if(n==2){
      cout<<i+1<<endl;
      break;
    }
    if(i==N-1){
      cout<<-1<<endl;
    }
  }
}

Measured memory_bytes: 640
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    const X = 101;
    const INF = int.max / 4;

    int[] T;
    int[] P;
    bool input() {
        int t; scanf("%d\n", &t);
        if (t == 0) return false;
        T = readln.chomp.split(" ").map!(to!int).array;
        int N; scanf("%d\n", &N);
        P = new int[X];
        P[] = INF;
        foreach (i; 0 .. N) {
            int D, M; scanf("%d %d\n", &D, &M);
            P[D] = min(P[D], M);
        }
        return true;
    }

    void solve() {
        auto dp = new int[][](X, T.length);
        foreach (i; 0 .. X) dp[i][] = INF;
        dp[1][0] = 0;
        foreach (i; 2 .. X) {
            dp[i][0] = min(dp[i][0], dp[i - 1][T.length - 1]);
            dp[i][0] = min(dp[i][0], dp[i - 1].reduce!min + 1);
            foreach (j; 1 .. T.length) {
                if (P[i] < T[j]) continue;
                dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
            }
        }
        /*
        foreach (i; 1 .. X) {
            writeln(dp[i].map!((a) => a == INF ? -1 : a));
        }
        */
        writeln(dp[X - 1].reduce!min);
    }

    while (input) solve;
}

Measured memory_bytes: 1264
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
 
    string s, ans;
    char chr[6];
    cin >> s;
    
    if (s[2] == s[3] && s[4] == s[5]) {
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout << ans;   
}


Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <math.h>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

double distance(double x1, double x2, double y1, double y2)
{
	double x = x1 - x2;
	double y = y1 - y2;
	return sqrt(x*x + y*y);
}

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::vector<std::pair<double, double>> pos;
	std::cin >> N;
	pos.resize(N);
	for (auto& xy : pos) {
		std::cin >> xy.first >> xy.second;
	}

	double sum = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			sum += distance(pos[i].first, pos[j].first, pos[i].second, pos[j].second);
		}
	}

	printf("%0.12f\n", sum / N * 2);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int cellNum = Integer.parseInt(sc.next());
		long[] cell = new long[cellNum];
		for (int i = 0; i < cellNum; i++) {
			long height = Long.parseLong(sc.next());
			cell[i] = height;
		}
		int moveMax = 0;
		for (int i = 0; i < cellNum; i++) {
			if (moveMax >= cell.length - i) {
				break;
			}
			int moveCount = 0;
			for (int j = i; j < cellNum; j++) {
				if (j < cellNum - 1 && cell[j] >= cell[j + 1]) {
					moveCount++;
				} else if (moveCount > moveMax) {
					moveMax = moveCount;
					break;
				} else {
					break;
				}
			}
		}
		System.out.println(moveMax);

	}

}


Measured memory_bytes: 46540
fun main(args: Array<String>) {
    val (W, H, x, y) = readLine()!!.split(" ").map { it.toDouble() }
    val mw: Double = W / 2
    val mh = H / 2
    val area = W*H
    println(area/2)
    if(x == mw && y == mh){
        println(1)
    }else{
        println(0)
    }
}

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

int main() {
  string S;
  cin >> S;

  int ans = abs(stoi(S.substr(0, 3)) - 753);
  for (int i = 1; i + 2 < S.size(); i++) ans = min(ans, abs(stoi(S.substr(i, 3)) - 753));
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const* argv[]) {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::string s;
    for (int i=0; i<3; i++) {
        std::cin >> s;
        std::cout << s[i];
    }
    return 0;
}


Measured memory_bytes: 256
num = int(input())
# 各行を入力しリストに格納
array = list(map(int, input().split()))
count = 0
for i in range (1,num-1,1):
  if array[i-1] < array[i] and array[i] <array[i+1] or array[i+1] < array[i] and array[i] <array[i-1]:
    count +=1
print(count)

Measured memory_bytes: 3060
k, n = gets.split.map(&:to_i)
houses = gets.split.map(&:to_i).sort
list = []
(0..n-1).each do |i|
  if i < n-1
    list << houses[i + 1] - houses[i]
  else
    list << k - houses[i] + houses[0]
  end
end
ans = k - list.max
puts ans


Measured memory_bytes: 21388