akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    string S, T;
    cin >> S >> T;
    int idx = -1;
    for(int i = 0; i < S.length(); i++) {
        int j = 0;
        while(j < T.length() && (S[i + j] == T[j] || S[i + j] == '?'))
            j++;
        if(j == T.length())
            idx = i;
    }
    if(idx < 0) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    string ans = S.substr(0, idx) + T + S.substr(idx + T.length());
    for(int i = 0; i < ans.length(); i++) {
        if(ans[i] == '?')
            ans[i] = 'a';
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string ans = "No";
            if (N % 10 == 9)
            {
                ans = "Yes";
            }

            if (N - 90 >= 0)
            {
                ans = "Yes";
            }
            Console.WriteLine(ans);
            Console.ReadLine();

        }
    }
}


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

int main(){
int a,b;
cin>>a>>b;
if(b<a)
a--;
cout<<a;
system("pause");
return 0;
}

Measured memory_bytes: 504
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

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

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N;
int board[1010][1010];

signed main() {
    scanf("%lld", &N);
    rep(i,0,N) {
        int sx, sy, tx, ty;
        scanf("%lld%lld%lld%lld", &sx, &sy, &tx, &ty);
        board[sx][sy]++;
        board[sx][ty]--;
        board[tx][sy]--;
        board[tx][ty]++;
    }

    rep(i,0,1010) rep(j,1,1010) board[i][j] += board[i][j-1];
    rep(j,0,1010) rep(i,1,1010) board[i][j] += board[i-1][j];
    
    int ans = 0;
    rep(i,0,1010) rep(j,0,1010) {
        chmax(ans, board[i][j]);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 11200
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
int n;
cin >> n;
int a[n+2];
int b[n+1];
long long int d=0;
a[0]=0;a[n+1]=0;
for(int i=1;i<=n;i++) {
  cin >>a[i];
}
for(int i=0;i<=n;i++){
  b[i]=abs(a[i]-a[i+1]);
  d+=b[i];
  }
  for(int i=1;i<=n;i++){
      long long int ans=d;
      ans-=(b[i-1]+b[i]);
      ans+=abs(a[i+1]-a[i-1]);
      cout <<ans <<endl;
  }
}


Measured memory_bytes: 2048
n=int(input())
p=[]
for _ in range(n):
  a,b=map(int,input().split())
  p.append([a-b,a+b])
#print(p)
p.sort(key=lambda x:x[1])
#print(p)
ans=0
cur=(10**9)*-1
for i in range(n):
  if cur<=p[i][0]:
    #print("i:%d残す,cur:%d,p[i][1]:%d,p[i][0]:%d" % (i,cur,p[i][1],p[i][0]))
    ans+=1
    cur=p[i][1]
print(ans)
  

Measured memory_bytes: 25540
n = int(input())
s = list(input())

w_cnt = [0] * n
e_cnt = [0] * n
for i, ss in enumerate(s):
    if i != 0:
        w_cnt[i] = w_cnt[i-1]
        e_cnt[i] = e_cnt[i-1]
    if ss == 'W':
        w_cnt[i] += 1
    else:
        e_cnt[i] += 1

ans = n
for i in range(n):
    left = i - 1
    right = i + 1
    left_w = 0
    right_e = 0
    if left >= 0:
        left_w = w_cnt[i-1]
    if right_e <= n - 1:
        right_e = e_cnt[-1] - e_cnt[i]
    ans = min(ans, left_w + right_e)
print(ans)


Measured memory_bytes: 19832
N,M=map(int, input().split())
arr=[]
for i in range(N):
    a,b=map(int,input().split())
    arr.append([a,b])

def getKey(item):
    return item[0]

arr.sort(key=getKey)

ans=0
for i in range(N):
    if M==0:
        break
    a,b=arr[i]
    if M >= b:
        ans=ans+(b*a)
        M = M - b
    else:
        ans=ans+(M*a)
        M=0

print(ans)


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    
    int ans = 0;
    for (int i = 0; i < n; i++){
        int h;
        cin >> h;

        if (h >= k)
            ans += 1;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
import sys
from itertools import product

D, G = [int(i) for i in input().strip().split(' ')]
ps = []
cs = []
alls = []
vs = []
counter = 0
for line in sys.stdin:
    counter += 100
    p, c =[int(i) for i in line.strip().split(' ')]
    ps.append(p)
    cs.append(c)
    all = p * counter + c
    alls.append(all)
    vs.append(float(all)/p)

candidates = []
for x in  product([False, True], repeat=D):
    score = 0
    cnum = 0
    for count, bit in enumerate(x):
        if bit:
            score += alls[count]
            cnum += ps[count]
    if score >= G:
        candidates.append(cnum)
        continue
    for count, bit in enumerate(x[::-1]):
        if not bit:
            for xxx in range(ps[D-count-1]):
                score += (D-count) * 100
                cnum += 1
                if score >= G:
                    candidates.append(cnum)
                    break
print(min(candidates))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<vector>
using namespace std;
 
int main() {
  int b=0,count=0;
	string a;
cin>>a;
  b=a.size();
  for(int i=0;i<a.size()/2;i++){
    if(a.at(i)==a.at(b-i-1)){
    }
    else{
      count++;
    }
  }
  cout<<count;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  vecll x(n), y(n), h(n);
  rep(i,n){
    cin >> x[i] >> y[i] >> h[i];
  }

  rep(cx,101){
    rep(cy,101){
      bool ok=true;
      ll ansh = -1;
      rep(i,n){
        if(h[i]>0) {
          ansh = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
          break;
        }
      }
      rep(i,n){
        ll height = max(ansh - abs(x[i]-cx) - abs(y[i]-cy), 0ll);
        if(h[i]!=height) {
          ok = false;
        }
      }
      if(ok){
        prt3(cx, cy, ansh);
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3644
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

ll kai(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x;
  if(y&1){
    return (x*kai(x,y-1))%MOD;
  }else{
    ll t = kai(x,y/2);
    return (t*t)%MOD;
  }
}

ll comb(ll a,ll b,vector<ll> &p){
  if(a == 0)return 1;
  if(b == 0)return 1;
  ll ans = p[a+b];
  ans = (ans*kai(p[a],MOD-2))%MOD;
  ans = (ans*kai(p[b],MOD-2))%MOD;
  return ans;
}

ll mind(int x,vector<int> &v){
  int ok = v.size()-1,ng = -1;
  while(ok - ng > 1){
    int next = (ok+ng)/2;
    if(v[next] > x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}

ll maxd(int x,vector<int> &v){
  int ok = 0,ng = v.size();
  while(ng - ok > 1){
    int next = (ok+ng)/2;
    if(v[next] < x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}


int main(){
  int N;
  cin >> N;
  vector<ll> L(N);
  rep(i,N)cin >> L[i];
  ll ans = 0;
  sort(L.begin(),L.end());
  for(int i = 0;i <= N-3;i++){
    for(int j = i+1;j <= N-2;j++){
      for(int k = j+1;k <= N-1;k++){
        ll a = L[i],b = L[j],c = L[k];
        if(a != b && b != c){
          if(a < b + c && b < a + c && c < a + b)ans++;
        }else{
          continue;
        }
      }
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3656
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long LL;
int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
int read() {
	int s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}
void put(int x) {
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int main() {
	int a = read(), b = read(), c = read();
	put(_min(b / a, c));
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();

        // 0からiまでの最大公約数
        int[] leftCache = new int[n];
        leftCache[0] = a[0];
        for (int i = 1; i < n; i++) {
            leftCache[i] = gcd(leftCache[i - 1], a[i]);
//            System.out.println(leftCache[i]);
        }

        // iからn-1までの最大公約数
        int[] rightCache = new int[n];
        rightCache[n - 1] = a[n - 1];
        for (int i = n - 2; i >= 0; i--) {
            rightCache[i] = gcd(rightCache[i + 1], a[i]);
//            System.out.println(rightCache[i]);
        }

        int ans = rightCache[1]; // 左端を除いた場合
        for (int i = 0; i < n - 2; i++) {
            int candidate = gcd(leftCache[i], rightCache[i + 2]);
            if (candidate > ans) {
                ans = candidate;
            }
        }
        // 右端を除いた場合
        if (leftCache[n - 2] > ans) {
            ans = leftCache[n - 2];
        }
        System.out.println(ans);
    }

    static int gcd(int a, int b) {
//        if (a == 0 || b == 0) {
//            return 1;
//        }
        if (a > b) {
            if (a % b == 0) {
                return b;
            } else {
                return gcd(b, a % b);
            }
        } else {
            if (b % a == 0) {
                return a;
            } else {
                return gcd(a, b % a);
            }
        }
    }
}


Measured memory_bytes: 50336
s=str(input())
p=str(input())
S=list(s)
x=0
for i in range(len(s)):
    if p in s:
        print('Yes')
        x=1
        break
    S.append(S[0])
    S.pop(0)
    s=''.join(S)
if x==0:
    print('No')


Measured memory_bytes: 5560
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

int n;
ll a[200009], b[200009];

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

    cin >> n;
    rep(i, n) cin >> a[i] >> b[i];

    sort(a, a + n);
    sort(b, b + n);

    if(n & 1) {
        cout << b[n >> 1] - a[n >> 1] + 1 << endl;
        return 0;
    }

    cout << ((b[n / 2 - 1] + b[n / 2]) - (a[n / 2 - 1] + a[n / 2])) + 1 << endl;

    return 0;
}

Measured memory_bytes: 6784
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M);
	for (int i = 0; i < M; i++) {
		cin >> A.at(i);
	}
	int sum=0;
	int a = -1;
	for (int i= 0; i < M; i++) {
		sum += A.at(i);
	}
	if (N - sum >= 0) {
		cout << N - sum << endl;
	}
	else {
		cout << a << endl;
	}
}

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

#ifndef ONLINE_JUDGE
#define debarr(a,x,y)cerr<<#a<<":";for(int i=x;i<=y;i++)cerr<<a[i]<<" ";cerr<<endl;
#define deb(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S, class T>ostream &operator<<(ostream &os, const pair<S, T> &p) {return os << "(" << p.first << "," << p.second << ")";}
template<class T>ostream &operator<<(ostream &os, const vector<T> &p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>ostream &operator<<(ostream &os, const set<T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>ostream &operator<<(ostream &os, const multiset<T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class S, class T>ostream &operator<<(ostream &os, const map<S, T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>void dbs(string str, T t) {cerr << str << ":" << t << "\n";}
template<class T, class...S>void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << ":" << t << ","; dbs(str.substr(idx + 1), s...);}
#else
#define deb(...){}
#endif
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

#define int              long long
#define ll               long long
#define ld               long double
#define fi               first
#define se               second
#define mp               make_pair
#define pb               push_back
#define sz(x)            (int)x.size()
#define all(x)           x.begin(),x.end()
#define ini(x,y)         memset(x,y,sizeof(x))
#define rep(i,n)         for(int i=0;i<n;i++)
#define fr(i,a,b)          for(int i=a;i<=b;i++)
#define fb(i,a,b)        for(int i=a;i>=b;i--)
#define tr(a,x)          for(auto& a:x)
typedef pair<int, int>   pii;
typedef vector<int>      vi;
typedef vector<pii>      vii;
typedef map<int, int>    mii;
typedef set<int>         si;
const ll inf = 1e18;
const int N = 2e5 + 10;

void solve(int tc)
{
	int n;
	cin >> n;
	mii m;
	si s;
	for (int i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			s.insert(i);
			while (n % i == 0)
			{
				m[i]++;
				n /= i;
			}
		}
	}
	if (n > 1)
	{
		s.insert(n);
		m[n]++;
	}
	int ans = 0;
	for (auto u : s)
	{
		int x = m[u];
		int ss = 0;
		while (((ss + 1) * (ss + 2) / 2) <= x) ss++;
		ans += ss;

	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;

	fr(i, 1, t) solve(t);

	return 0;
}

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

int main(){

  int n,a[10],b,c;

  cin >> n;

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

    sort(a,a+3);

    if(a[2]*a[2]==a[0]*a[0]+a[1]*a[1]) cout << "YES" << endl;
    else cout << "NO" <<endl;

  }
} 

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="SUN") cout<<7;
	else if(s=="MON") cout<<6;
	else if(s=="TUE") cout<<5;
	else if(s=="WED") cout<<4;
	else if(s=="THU") cout<<3;
	else if(s=="FRI") cout<<2;
	else if(s=="SAT") cout<<1;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  string t(1, s[0]);
  for (int i = 1; i < n; ++i) {
    if (s[i] != 'C' || t[t.size() - 1] != 'B') t += s[i];
    else t[t.size() - 1] = 'x';
  }
  ll res = 0, ca = 0;
  for (int i = 0; i < t.size(); ++i) {
    if (t[i] == 'A') ++ca;
    else if (t[i] == 'x') {
      res += ca;
    } else {
      ca = 0;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)

using namespace std;

void solve(string S, string T) {
  int s = S.length();
  int t = T.length();
  int ans(t);
  REP(i, s - t + 1) {
    int diff(0);
    REP(j, t)
      if (S[i + j] != T[j])
	diff++;
    ans = min(ans, diff);
  }
  cout << ans << endl;
}

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

  string S, T;
  cin >> S >> T;

  solve(S, T);

  return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll gcd(ll a, ll b) {
    while ( b != 0 ) {
        ll t = b;
        b = a % b;
        a = t;
    }
    return a;
}

ll solve() {
    ll N, m = 1;
    cin >> N;
    vector<ll> T(N);

    for ( int i = 0; i < N; i++ ) {
        cin >> T[i];
        if ( i == 0 ) {
            m = T[i];
        } else {
            ll d = gcd(m, T[i]);
            m = m / d * T[i];
        }
    }
    return m;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  long long a[100000],T,ans[100000],stop;
  int j,k,d[100000],x[100000],Q,i,N,s;
  //in
  scanf("%d %lld %d",&N,&T,&Q);  
  for(i=0;i<N;i++){
  scanf("%lld %d",&a[i],&d[i]);
  }
  for(i=0;i<Q;i++){
    scanf("%d",&x[i]);
    x[i]--;
  }
  //in end
  for(i=0;i<Q;i++){
    s=0;
    if(d[x[i]]==1){
      for(j=x[i];j<N;j++){
	if(d[j]==2){
	  stop=(a[j]+a[j-1])/2;
	  //printf("stop %d\n",stop);
	  if(a[x[i]]+T>stop){
	  ans[i]=stop;
	  s=1;
	  break;
	  }
	}
      }
      if(s==0)ans[i]=a[x[i]]+T;
    }

    if(d[x[i]]==2){
      for(j=x[i];j>=0;j--){
	if(d[j]==1){
	  stop=(a[j]+a[j+1])/2;
	  //printf("st %d\n",stop);//
	  if(a[x[i]]-T<stop){
	  ans[i]=stop;
	  s=1;
	  break;
	  }
	}
      }
      if(s==0)ans[i]=a[x[i]]-T;
    }
  }

  for(i=0;i<Q;i++){
    printf("%lld\n",ans[i]);
  }
  return 0;
}
 

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

int main(void) {
    int a[5],k;
    for(int i=0;i<5;i++) {
        cin >> a[i];
    }
    cin >> k;

    if((a[4]-a[0]) > k) {
        cout << ":(\n";
    } else {
        cout << "Yay!\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_MOD			1000000007								// 除数(10の9乗+7)
#define D_ARRAY_MAX		2000									// 最大配列数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Array[D_ARRAY_MAX];								// 配列
static int siACnt;												// 配列数
static int siK;													// K

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, j;
	char lc1Buf[1024];

	// 配列数・K - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siACnt, &siK);

	// 配列 - 取得
	for (i = 0; i < siACnt; i++) {
		fscanf(szpFpI, "%d", &si1Array[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 個数 - 取得
	int liCnt = 0;
	for (i = 0; i < siACnt; i++) {
		for (j = 0; j < siACnt; j++) {
			if (si1Array[i] > si1Array[j]) {
				if (i < j) {
					liCnt = ((long long)liCnt + (long long)siK * (long long)(siK + 1) / 2) % D_MOD;
				}
				else {
					liCnt = ((long long)liCnt + (long long)(siK - 1) * (long long)siK / 2) % D_MOD;
				}
			}
		}
	}

	return liCnt;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// １行出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define LL long long
using namespace std;
inline int read( )
{
  int sum=0;char c=getchar( );bool f=0;
  while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );}
  while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( );}
  if(f) return -sum;
  return sum;
}
const int N=200005;
int n,K,a[N],c[N];
struct ex{LL v;int ps;}d[N];
inline bool operator < (const ex &a,const ex &b) {return a.v==b.v?a.ps<b.ps:a.v<b.v;}
inline void add(int x) {for(int i=x;i<=n;i+=i&-i) c[i]++;}
inline int ask(int x) {int i,r=0;for(i=x;i;i-=i&-i) r+=c[i];return r;}
int main( )
{
  int i,j,cnt=0;LL s=0,ans=0;
  n=read( );K=read( );
  for(i=1;i<=n;i++) a[i]=read( )-K;
  for(i=1;i<=n;i++) s+=a[i],d[++cnt]=(ex){s,i+1};
  d[++cnt]=(ex){0,1};
  sort(d+1,d+cnt+1);n++;
  for(i=1;i<=cnt;i++) j=d[i].ps,ans+=ask(j-1),add(j);
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

//最大公約数,最小公倍数
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main(void){
    ll n, m;
    cin >> n >> m;

    string s, t;
    cin >> s >> t;

    ll l = lcm(n, m);
    ll a = l / n;
    ll b = l / m;

    ll l2 = lcm(a, b);


    for(int i = 0; i < l / l2; i++){
        if(s[i * l2 / a] != t[i * l2 / b]){
            cout << "-1" << endl;
            return 0;
        }
    }

    cout << l << endl;
    return 0;

}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}



int main() {
	int a,b;
	cin >> a >> b;
  
  ll ans = 0;
  
  REP(i,b-a){
	ans += (i  +1);
  }
  ans -= b;
	cout << ans << endl;
	return 0;
}


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

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

    int N;
    cin >> N;

    vector<int> vi(N);
    rep(i, N) { cin >> vi[i]; }

    for (auto num : vi) {
        if (num % 2 == 0) {
            if (num % 3 != 0 && num % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7,maxn=5005;
ll dp[maxn][maxn],f[maxn],tmp[maxn];
int sz[maxn];
vector<int>g[maxn];
void dfs(int u,int pre)
{
    dp[u][1]=1;
    sz[u]=1;
    for(auto v:g[u])
        if(v!=pre)
        {
            dfs(v,u);
            //sz[u]+=sz[v];
            for(int i=0;i<=sz[u];++i)
            {
                tmp[i]=dp[u][i];
                dp[u][i]=0;
            }
            for(int i=0;i<=sz[u];++i)
                for(int j=0;j<=sz[v];++j)
                    dp[u][i+j]=(dp[u][i+j]+tmp[i]*dp[v][j])%mod;
            sz[u]+=sz[v];
        }
    for(int i=0;i<=sz[u];i+=2)
        dp[u][0]=(dp[u][0]+mod-dp[u][i]*f[i]%mod)%mod;
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;++i)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    f[0]=1;
    for(int i=2;i<=n;++i) f[i]=f[i-2]*(i-1)%mod;
    dfs(1,0);
    printf("%d\n",(int)(mod-dp[1][0]));
    return 0;
}


Measured memory_bytes: 195200
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    string ans="APPROVED";
    
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a%2==0){
            bool ok=false;
            if(a%3==0) ok=true;
            if(a%5==0) ok=true;
            if(!ok) ans="DENIED";
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
#define fi first
#define se second
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    Int n;
    cin >> n;
    string s;
    cin >> s;
    if (n % 2 == 1) {
        dump("No");
        return 0;
    }
    for (Int i = 0; i < n / 2; i++) {
        if (s[i] != s[n / 2 + i]) {
            dump("No");
            return 0;
        }
    }
    dump("Yes");
    return 0;
}

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

int N;
string S, T;

int main() {
    cin >> N >> S >> T;

    int cnt = 0;
    for (int i = 1; i <= N; i++) {
        bool f = true;
        for (int j = 0; j < i; j++) {
            if (S[N-i+j] != T[j]) {
                f = false;
                break;
            }
        }
        if (f) cnt = max(cnt, i);
    }

    cout << 2*N-cnt << endl;

  
    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  
  if ((N % 10) == 3)
  {
    cout << "bon" << endl;
  }
  else if ((N % 10) == 0 || (N % 10) == 1 || (N % 10) == 6 || (N % 10) == 8)
  {
    cout << "pon" << endl;
  }
  else
  {
    cout << "hon" << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
 
using namespace std;

const int INF = 1e9;
int N;
bool passed[100010];

template <typename T1, typename T2>
void dfs(const T1& list, T2& d, int depth, int r){
	if (passed[r]) return;

	d[r] = depth;
	passed[r] = true;
	for (int i = 0; i < list[r].size(); i++){
		dfs(list, d, depth+1, list[r][i]);
	}
}

int main(){
	cin >> N;
	vector<vector<int>> list(N+1);
	for (int i = 0; i < N-1; i++){
		int a, b;
		cin >> a >> b;
		list[a].push_back(b);
		list[b].push_back(a);
	}

	for (int i = 0; i <= N; i++) passed[i] = false;
	passed[1] = true;
	vector<int> d1(N+1, INF);
	d1[1] = 0;
	for (int i = 0; i < list[1].size(); i++){
		dfs(list, d1, 1, list[1][i]);
	}

	for (int i = 0; i <= N; i++) passed[i] = false;
	passed[N] = true;
	vector<int> dN(N+1, INF);
	dN[N] = 0;
	for (int i = 0; i < list[N].size(); i++){
		dfs(list, dN, 1, list[N][i]);
	}

	int black = 0, white = 0;
	for (int i = 1; i <= N; i++){
		if (d1[i] <= dN[i]) black++;
		if (d1[i] > dN[i]) white++;
	}

	if (black > white) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;

	return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
int main() {
  ll a,b;cin>>a>>b;
  ll ans=lcm(a,b);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int n = 0;
  int i;

  for(i=0; i<S.length(); i++)
    if(S[i] == '+')
      n++;
    else if(S[i] == '-')
      n--;
    else{
      cout << "error!!" << endl;
      exit(1); 
    }

  cout << n << endl;
  
  return 0;
}


Measured memory_bytes: 256
{-
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168
?????????: Kannondou
??°?????£?????¨??????:???1??\???10???????????????????£???°???????????°??£???
-}
import Control.Applicative
import Control.Monad

main = do
 n <- fmap read getLine
 when (n>0) $ do
  print $ (f n + 3649) `div` 3650
  main

f :: Integer -> Integer
f 0 = 1
f 1 = f 0
f 2 = f 0 + f 1
f 15 = 5768
f 18 = 35890
f 19 = 66012
f 20 = 121415
f n = f (n-1) + f (n-2) + f (n-3)

Measured memory_bytes: 4088
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t n,k;
  cin >> n >> k;
  if(n>=k){
    int64_t y=n/k;
    n-=y*k;
  }
  cout << min(n,k-n) << endl;
}  


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	a := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scanf("%d", &a[i])
	}
	answer := calcHangOut(n, m, a)
	fmt.Println(answer)
}

func calcHangOut(n, m int, a []int) int {
	hangOutDays := n
	for i := 0; i < m; i++ {
		hangOutDays -= a[i]
	}
	if hangOutDays < 0 {
		return -1
	} else {
		return hangOutDays
	}
}


Measured memory_bytes: 2516
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int i=1;
		while(true){
        	String x=br.readLine();
        	if(x.equals("0")) break;
        	sb.append("Case "+i+": "+x+"\n");
        	if(i%100==0){
        		System.out.print(sb.toString());
        		sb.setLength(0);
        	}
    		i++;
        }
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 25000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1);
const ll mod=1e9+7;
int main()
{
	int n,m;
	cin>>n>>m;
	if(n>m)
	{
		cout<<"safe"<<endl;
	}
	else
	{
		cout<<"unsafe"<<endl;
	} 
	return 0;
}


Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int total = 0;
  if (a + b > 2*c) {
    if (x > y) {
      total += y*2*c;
      if (a >= 2*c) {
        total += (x-y)*2*c;
      }
      else {
        total += (x-y)*a;
      }
    }
    else if (x == y) {
      total += y*2*c;
    }
    else {
      total += x*2*c;
      if (b >= 2*c) {
        total += (y-x)*2*c;
      }
      else {
        total += (y-x)*b;
      }
    }
  }
  else if (a + b == 2*c) {
    if (x > y) {
      total += y*2*c;
      total += (x-y)*a;
    }
    else if (x == y) {
      total += y*2*c;
    }
    else {
      total += x*2*c;
      total += (y-x)*b;
    }
  }
  else {
    total += x*a + y*b;
  }
  cout << total << endl;
}
      
      


Measured memory_bytes: 3596
#include <iostream>
#include <string>

int main() {
  int a, b;
  std::cin >> a >> b;

  std::string cmp = "==";
  if (a > b) {
    cmp = ">";
  } else if (a < b) {
    cmp = "<";
  }

  std::cout << "a " << cmp << " b" << std::endl;
}


Measured memory_bytes: 3156
using System;

namespace ABC054_D___Mixing_Experiment
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            var N = read[0];
            var Ma = read[1];
            var Mb = read[2];

            var Mmax = N * 10 + 1;

            var costs = new int[Mmax,Mmax];
            for(int i = 0 ; i < Mmax ; i++) for(int j = 0 ; j < Mmax ; j++) costs[i,j] = int.MaxValue;
            costs[0,0] = 0;
            
            for(int i = 0 ; i < N ; i++)
            {
                read = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
                var a = read[0];
                var b = read[1];
                var c = read[2];
                
                for(int j = Mmax - 1 ; j >= 0 ; j--)
                {
                    for(int k = Mmax - 1 ; k >= 0 ; k--)
                    {
                        if(costs[j,k] != int.MaxValue) costs[j+a,k+b] = Math.Min(costs[j+a,k+b],costs[j,k] + c);
                    }
                }
            }

            var result = int.MaxValue;
            decimal ratio = (decimal)Ma / (decimal)Mb;

            for(int i = 1 ; i < Mmax ; i++) for(int j = 1 ; j < Mmax ; j++) if((decimal)i/(decimal)j == ratio) result = Math.Min(result,costs[i,j]);

            if(result == int.MaxValue) result = -1;

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13140
a,b,k = map(int,input().split())
if a >= k:
    if a-k < 0:
        print(0,b)
    else:
        print(a-k,b)
else:
    if b-(k-a)>0:
        print(0,b-(k-a))
    else:
        print(0,0)

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

int f(int n){
    if(n % 2 == 0){
        return n/2 * 11;
    }else{
        return f(n-1) + 6;
    }
}

signed main() {
    int x; cin >> x;
    int n = (x/11) * 2;
    while(f(n) < x) n++;
    cout << n << endl;
}

Measured memory_bytes: 256
D = dict()
N = int(input())
for i in range(N):
    s = input()
    if s in D.keys():
        D[s] += 1
    else:
        D[s] = 1
M = int(input())
for i in range(M):
    t = input()
    if t in D.keys():
        D[t] -= 1
ans = 0
for v in D.values():
    ans = max(ans,v)
print(ans)


Measured memory_bytes: 3060
import bisect

N, T = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]

"""
a_x = 1 and b_x is t_i = 2*(t_i +2) 
n 店舗回るのに 2^nはかかる
30店舗以上は回れない
"""

a0 = []
nab = []
for a, b in AB:
    if a == 0:
        a0.append(b)
    else:
        nab.append(((b + 1) / a, a, b))
a0.sort()

nab.sort()

a0sum = []  # key: n of visit, value : cost
_sum = 0
for b in a0:
    _sum += 1 + b
    a0sum.append(_sum)

INF = 1 << 32
dp = [0] + [INF] * 29
for index, (_, a, b) in enumerate(nab):
    # print(a, b)
    ndp = [0] + [INF] * 29
    for count in range(1, 29):
        ndp[count] = min(dp[count],
                         dp[count - 1] + 1 + (dp[count - 1] + 1) * a + b)
    dp = ndp

ans = 0
# print(a0sum)
# print(nab)
# print(dp)
for count, t in enumerate(dp):
    if t > T:
        continue
    v = bisect.bisect_right(a0sum, T - t)
    ans = max(ans, v + count)
print(ans)


Measured memory_bytes: 107352
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int A[n];
    REP(i,n) cin >> A[i];
    int cnt = 0;
    FOR(i,1,n-1){
        if( (A[i] - A[i-1]) * (A[i] - A[i+ 1]) < 0) cnt ++;
    }
    cout << cnt << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int m = sc.nextInt();
    long keta = 0;
    long s = 0;
    for(int i = 0; i < m; i++) {
      long d = sc.nextLong();
      long c = sc.nextLong();
      keta += c;
      s += (d * c);
    }
    long ans = keta - 1 + (s - 1) / 9;
    System.out.println(ans);
  }
}


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

int main() {
    int n;
    cin >> n;
    int d[n];
    for(int i = 0; i < n; i++) cin >> d[i];
    int ma = 0;
    for(int i = 0; i < n; i++) {
        ma = max(ma, 10 * (i - 1) + d[i - 1]);
        if(10 * i > ma) {
            cout << "no" << endl;
            return 0;
        }
    }

    ma = 0;
    for(int i = n - 1; i >= 0; i--) {
        ma = max(ma, 10 * (n - i - 1) + d[i]);
        // cout << ma << " " << 10 * (n - i - 1) << endl;
        if(10 * (n - i) > ma) {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
}


Measured memory_bytes: 4268
import math

N = int(input())
greater = 0
min_greater = 10**10

a = round(math.sqrt(N)) + 1

for i in range(1, a):
	if  N % i == 0:
		greater = max(N / i, i)
	if greater < min_greater:
		min_greater = greater

ans = int(math.log10(min_greater) + 1)

print(ans)



Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	double h[6]={165.0,170.0,175.0,180.0,185.0,1e9};
	int n;
	cin>>n;
	vector<int>out(6);
	while(n--){
		double a;
		cin>>a;
		rep(i,6)if(a<h[i]){out[i]++;break;}
	}
	rep(i,6){
		cout<<i+1<<":";
		rep(j,out[i])cout<<"*";
		cout<<endl;
	}	
}

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

int main()
{
  string s, t;
  cin >> s;
  cin >> t;
  int a = 0;
  for (int i = 0;  i < 3; ++i)
  {
    if (s[i] == t[i]) ++a;
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline

def main():
    n = int(read())
    se = set()
    for i in range(n):
        a = int(read())
        se.add(a)
    print(len(se))
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=2000000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}

class Edge{
public:
	long long from;
	long long to;
	long long w;
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long N,X;
	cin>>N>>X;
	long long l;
	long long now=0;
	long long ans=0;
	for(int i=0;i<N;i++){
		if(now<=X)ans++;
		cin>>l;
		now+=l;
	}
	if(now<=X)ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int c,mx;
string s;
int main()
{
	int i;
	cin>>s;
	for(i=0;i<3;i++)
	{
		if(s[i]=='R')
		{
			c++;
		}
		else
		{
			c=0;
		}
		mx=max(mx,c);
	}
	cout<<mx<<endl;
	return 0;
} 

Measured memory_bytes: 3624
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 2005
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define ff first
#define ss second

int n,k,m;
int a[maxn];
pii b[maxn];

inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int bel[maxn],cnt[maxn];
bool vis[maxn];

int main(){
	n=read(),k=read(),m=read();
	for (int i=1;i<=n;i++) a[i]=read(),b[i]=mp(a[i],i);
	sort(b+1,b+n+1); int ans=1e9;
	for (int l=1,r=1;l<=n;l=r){
		int id=1,num=0;
		memset(cnt,0,sizeof(int)*(n+1));
		for (int i=1;i<=n;i++){
			if (vis[i]) cnt[id++]=num,num=0;
			else ++num,bel[i]=id;
		}
		cnt[id++]=num,num=0;
		int pps=0,mn=1e9,mx=0;
		for (int i=l;i<=n;i++){
			int v=b[i].ff,pos=bel[b[i].ss];
			if (cnt[pos]>=k){
				--cnt[pos],++pps,mn=min(mn,v),mx=max(mx,v);
				if (pps==m) break;
			}
		}
		if (pps==m) ans=min(ans,mx-mn);
		for (;r<=n&&b[r].ff==b[l].ff;++r) vis[b[r].ss]=1;
	}
	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 < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x)
#define CMIN(m, x)  m = min(m,x)
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;

int cnt = 0;
void dfs(int i,vector<vector<int>> &g, vector<vector<int>> &ans){
    if(ans[i][0] == 0){
        cnt++; 
        ans[i][0] = cnt;
        REP(j,g[i].size()){
            dfs(g[i][j] - 1,g,ans);  
        }
        cnt++;

        ans[i][1] = cnt;
    }
}
int main(){
    int n;
    cin >> n;
    int u,k;
    vector<vector<int>> g(n);
    vector<vector<int>> ans(n,vector<int>(2,0));
    REP(i,n){
        cin >> u >> k;
        g[u - 1] = vector<int>(k);
        REP(j,k)
            cin >> g[u - 1][j];
    }
    REP(i,n)
        dfs(i,g,ans);
    REP(i,n){
        printf("%d %d %d\n",i + 1, ans[i][0],ans[i][1]);
    }

    return 0;
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
ll xor0_x(ll x){
	ll ans=0,loop,bits;
	if(x%4==1 || x%4==2)ans=1;
	FOR(i,1,43){
		loop = (1LL<<(i+1));
		bits = (x%loop)-loop/2ll+1ll;
		if(bits>0 && (bits&1ll))bits=1ll;
		else bits = 0ll;
		ans += (bits<<(i));
	}
	return ans;
}
int main(){
	ll a,b;
	cin >> a >> b;
	cout << (xor0_x(a-1)^xor0_x(b)) << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int h1,m1,h2,m2,k;

    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int ans = 60*h2 + m2 - 60*h1 - m1;

    cout << ans - k << endl;


    return 0;
}

Measured memory_bytes: 3632
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import product

    s = input()
    l = len(s) - 1
    ans = 0

    for bit in product(range(2), repeat=l):
        score = 0
        cur = ""
        for i, b in enumerate(bit):
            cur += s[i]
            if b:
                score += int(cur)
                cur = ""
        cur += s[-1]
        score += int(cur)
        ans += score

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68016
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static  ll INF = 1e9;
using namespace std;

signed main(){
	ll n,x;
	cin>>n>>x;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	sort(a.begin(),a.end());
	ll sum=0,ans=0;
	for(int i=0;i<n;++i){
		sum+=a[i];
		if(sum<=x)++ans;
	}
	if(x>sum)--ans;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256