akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll INF = 1LL<<61;

long long pairs(ll n, ll k, vector<ll> a) {
  sort(a.begin(), a.end());

  long long left = -INF, right = INF;

  while(right > left + 1) {
    long long x = (left + right) / 2;
    long long s = 0, t = 0;

    for(int i=0;i<n;i++) {
      if(a[i] > 0) {
	ll l2 = -1, r2 = n;
	while(r2 > l2 + 1) {
	  ll m = (l2 + r2) / 2;
	  if(a[i] * a[m] <= x) l2 = m;
	  else r2 = m;
	}
	s += r2;
      }
      else if (a[i] < 0) {
	ll l2 = -1, r2 = n;
	while(r2 > l2 + 1) {
	  ll m = (l2 + r2) / 2;
	  if(a[i] * a[m] <= x) {
	    r2 = m;
	  } else l2 = m;
	}
	s += n - r2;
      }
      else if (x >= 0) s+= n;
      if(a[i] * a[i] <= x) ++ t;
    }
    long long num = (s-t) / 2;
    if(num >= k) right = x;
    else left = x;
  }

  return right;
}
int main() {
  ll n, k;
  cin >> n;
  cin >> k;
  vector<long long> a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  cout << pairs(n, k, a);
}

Measured memory_bytes: 6380
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int c[8] = {1,2,1,2,1,4,1,4};
int main(void){
  int p[8];
  while(cin>>p[0]){
    FOR(i,1,8) cin>>p[i];
    int sum = -1;
    int ans = 0;
    int pnum;
    REP(i,8){
      int tmp = 0;
      REP(k,8){
        tmp += min(c[(k+i)%8],p[k]);
      }
      if(tmp>sum){
        ans = i;
        sum = tmp;
        pnum = 0;
        REP(k,8){
          pnum += pow(10,7-k) * c[(k+i)%8];
        }
      }else if(tmp==sum){
        int ptmp=0;
        REP(k,8){
          ptmp += pow(10,7-k) * c[(k+i)%8];
        }
        if(ptmp<pnum){
          pnum = ptmp;
          ans = i;
          sum = tmp;
        }
      }
    }
    bool f=false;
    REP(i,8){
      if(f){
        cout<<" ";
      }else{
        f = true;
      }
      cout<<c[(i+ans)%8];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long s = sc.nextLong(), c = sc.nextLong();
		
		if(s<=c/2){
			System.out.println(s + (c-2*s)/4);
		}
		else{
			System.out.println(c/2);
		}
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <cstdlib>
using namespace std;
char op[4];
int a[5], k = 1;
void dfs(int now) {
    if(now == 7 && k == 4) {
        for(int i = 1; i <= 3; i ++) 
            cout << a[i] << op[i];
        cout << a[4] << "=7\n";
        exit(0);
    }
    if(k > 3) return;
    op[k++] = '+';
    dfs(now+a[k]);
    k --;
    op[k++] = '-';
    dfs(now-a[k]);
    k --;
}

int main() {
    char s;
    for(int i = 1; i <= 4; i++) {
        s = getchar();
        a[i] = s - 48;
    }
    dfs(a[1]);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
H = [0] + H
dp = [0] * (N+1)
for i in range(2,N+1):
    if i-2>=1:
        dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))
    else:
        dp[i] = dp[i] + abs(H[i]-H[i-1])
res = dp[N]
print(res)

Measured memory_bytes: 85756
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int k = fs.nextInt();
		
		int[] okachiArr = new int[n];
		
		for(int i = 0; i < k; i++) {
			int numOfSunuke = fs.nextInt();
			for(int j = 0; j < numOfSunuke; j++) {
				int sunuke = fs.nextInt();
				okachiArr[sunuke-1] = 1;
			}
		}
		
		int ans = 0;
		for(int i = 0; i < n; i++) {
			if(okachiArr[i] == 0) {
				ans++;
			}
		}
		
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 33500
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  string s;
  cin >> s;
  int res = 1e9;
  for (int i = 0; i < 26; i++) {
    char c = 'a' + i;
    int tmp = 0;
    int cnt = 0;
    for (int j = 0; j < (int)s.size(); j++) {
      if (s[j] == c) {
        chmax(tmp, cnt);
        cnt = 0;
      } else {
        cnt++;
      }
    }
    chmax(tmp, cnt);
    chmin(res, tmp);
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = str(input())

if K == 1:
	S = S[K-1].lower() + S[K:N]
elif K == N:
	S = S[0:N-1] + S[N-1].lower()
else:
	S = S[0:K-1] + S[K-1].lower() + S[K:N]

print(S)

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

#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    int N; cin >> N;
    vector<int> A(N); cin >> A; 

    int ans = 0;
    for(;;) {
        bool done = true;
        for (auto& a : A) {
            if (a%2 == 0) {
                a /= 2;
            } else {
                done = false;
                break;
            }
        }
        if (done) ans++;
        else break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    s=input()
    s_len=len(s)
    c_s=Counter(s)
    if c_s['o']+(15-s_len)>=8:
        print("YES")
    else:print("NO")

if __name__=='__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

signed main() {
    int m,n;
    cin>>n>>m;
    int odda=n, oddb=1, evena=n/2, evenb=n/2+2;
    rep(i, m) {
        if(i%2==0) {
            cout<<odda<<' '<<oddb<<endl;
            odda--; oddb++; 
        } else {
            cout<<evena<<' '<<evenb<<endl;
            evena--; evenb++;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF =1e9;
const ll LINF=1e18;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//setprecision(15)有効数字15桁
//-std=c++14
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;}
ll r1,c1,r2,c2;
const ll M = pow(10, 9) + 7;

vector<ll> fac(20000001);  //n!(mod M)
vector<ll> ifac(20000001); //k!^{M-2} (mod M)
ll mpow(ll x, ll n)
{ //x^n(mod M)
    ll ans = 1;
    while (n != 0)
    {
        if (n & 1)
            ans = ans * x % M;
        x = x * x % M;
        n = n >> 1;
    }
    return ans;
}
//conbination
ll comb(ll a, ll b)
{ //aCb(mod M)
    if (a == 0 && b == 0)
        return 1;
    if (a < b || a < 0)
        return 0;
    ll tmp = ifac[a - b] * ifac[b] % M;
    return tmp * fac[a] % M;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> r1>>c1>>r2>>c2;
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i <= 2000000; i++)
    {
        fac[i + 1] = fac[i] * (i + 1) % M;              // n!(mod M)
        ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M)
    }
    ll ans=0;
    for(int i=c1;i<=c2;i++){
        ans+=comb(r2+i+1,r2)-comb(r1-1+i+1,r1-1);
        ans+=MOD;
        ans%=MOD;
    }
    cout<<ans<<"\n";
}
//http://drken1215.hatenablog.com/entry/2020/02/09/225000


Measured memory_bytes: 312704
#include <bits/stdc++.h>
#define int long long 
#define ld long double
using namespace std;
const int mod = 998244353;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int val = n / 500;
    int rem = (n % 500) / 5;
    int ans = val * 1000 + rem * 5;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a>>b;
    if (a>b) swap(a,b);
    if (a==1){
        if (b==2){
            cout<<3;
        }
        else cout<<2;
    }
    else cout<<1;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void) {
	char A[11], B[11], C[11];
	int a, b;
	scanf("%s", A);
	scanf("%s", B);
	scanf("%s", C);
	a = strlen(A);
	b = strlen(B);
	if ((A[a - 1] == B[0]) && (B[b - 1] == C[0])) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(int, N);
    vector<i64> a(N);
    read(a);

    map<i64, i64> cnt;
    rep(j, 0, N) { cnt[j - a[j]] += 1; }

    i64 ans = 0;
    rep(i, 0, N) {
        if (cnt.count(a[i] + i)) {
            ans += cnt[a[i] + i];
        }
        cnt[i - a[i]] -= 1;
    }

    print(ans);

    return 0;
}


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

int main()
{
	long long int n,a[100000],i,dp[100000];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(i=2;i<n;i++)
	{
		dp[i]=min((dp[i-2]+abs(a[i]-a[i-2])),(dp[i-1]+abs(a[i]-a[i-1])));
	}
	cout<<dp[n-1];
	return 0;
}

	


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MOD			1000000007
#define FOR(i,l,r)	for(int i=l;i<=r;i++)
#define REP(i,n)	for(int i=1;i<=n;i++)
#define REP0(i,n)	for(int i=0;i<n;i++)
#define PB			push_back
#define MP			make_pair
#define PII			pair<int,int>
#define VI			vector<int>
#define ALL(x)		(x).begin(),(x).end()
#define MAKE1(a)	int a;
#define MAKE2(a,b)	int a,b;
#define MAKE3(a,b,c) int a,b,c;
#define MAKE4(a,b,c,d) int a,b,c,d;
#define DR1(a)		MAKE1(a);cin>>a;
#define DR2(a,b)	MAKE2(a,b);cin>>a>>b;
#define DR3(a,b,c)	MAKE3(a,b,c);cin>>a>>b>>c;
#define DR4(a,b,c,d) MAKE4(a,b,c,d);cin>>a>>b>>c>>d;
#define int long long
int n,a[100005],b[100005],ans=0;
signed main(){
	cin>>n;
	for(int i=1;i<=n+1;i++)	cin>>a[i];
	for(int i=1;i<=n;i++)	cin>>b[i];
	for(int i=1;i<=n+1;i++){
		if(b[i]>=a[i]){
			ans+=min(a[i]+a[i+1],b[i]);
			b[i]=max(0ll,b[i]-a[i]);
			a[i]=0;
			a[i+1]=max(0ll,a[i+1]-b[i]);
		}
		else{
			ans+=b[i];
			a[i]-=b[i];
			b[i]=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
int main()
{
    int k;
    cin>>k;
    ll n=7;
    int f=0;
    for(int i=1; i<=1000005&&f==0; i++)
    {
        if(n%k==0)
        {
            cout<<i<<endl;
            f=1;
        }
        else
        {
            n=n*10+7;
            n%=k;
        }
    }
    if(f==0)
        cout<<"-1"<<endl;
}


Measured memory_bytes: 3588
import copy

n = int(input())

lis = []
for _ in range(n):
    lis.append(int(input()))
    
slis = sorted(copy.deepcopy(lis), reverse=True)
    
m = max(lis)
s = sorted(slis, reverse=True)
s.remove(m)
sm = max(s)


for i in range(n):
    if lis[i] != m:
        print(m)
    else:
        print(sm)


Measured memory_bytes: 16140
while True:    
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    
    for i in range(h):
        if i == 0 or i == h-1:
            for j in range(w):
                print("#", end="")
            print()
        else:
            print("#", end="")
            for j in range(w-2):
                print(".", end="")
            print("#")
    print()


Measured memory_bytes: 7000
# AOJ 0296: A Fat Wallet
# Python3 2018.6.23 bal4u

a = (1, 5, 10, 50, 100, 500)
c = list(map(int, input().split()))
s = 0
for i in range(6): s += a[i]*c[i]
print(1 if s >= 1000 else 0)


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main()
{
    int k, n;
    string s;
    cin >> k >> s;
    n = s.size();
    combination c(n+k);
    mint ans = 0;
    for (int i = 0; i<=k; ++i){
        mint now = mint(26).pow(k-i);
        now *= mint(25).pow(i);
        now *= c(i+n-1, n-1);
        ans += now;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35560
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
bool eq(VEC<int>a, VEC<int>b){
  REP(i,0,a.size()){
    if(a[i]!=b[i])return 0;
  }
  return 1;
}

int main() {
  int N;
  cin>>N;
  VEC<int>c(N);
  VEC<int>P(N),Q(N);
  REP(i,0,N)cin>>P[i];
  REP(i,0,N)cin>>Q[i];
  REP(i,0,N)c[i]=i+1;
  int a,b;
  int i = 1;
  do{
    if(eq(c, P))a=i;
    if(eq(c, Q))b=i;
    i++;
  }while(next_permutation(ALL(c)));
  cout<<abs(a-b)<<endl;

  return 0;
}


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

int main() {
  int N,M,count,m=0;
  cin>>N;
  vector<string> s(N);
  vector<string> t(M);
  for(int i=0;i<N;i++){
    cin>>s.at(i);
  }
  cin>>M;
  for(int i=0;i<M;i++){
    cin>>t.at(i);
  }

  for(int i=0;i<N;i++){
    count=0;
    for(int j=0;j<N;j++){
      if(s.at(i)==s.at(j)){
        count++;
      }
    }
      	for(int k=0;k<M;k++){
          if(s.at(i)==t.at(k)){
        		count--;
          }
        }
    
    m=max(m,count);
  }
  cout<<m<<endl;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int N;
  cin >> N;
  if(N<=999){
    cout << "ABC" <<endl;
  }
  else{
    cout << "ABD" << endl;
  }
}      
     

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

//fixed << setprecision(8)

using namespace std;

#define ll long long
#define vec vector
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n,buf=0;
	double ans=0;
	string s;

	cin >> n;

	vector<pair<double, string>> a(n);

	forll(i, 0, n)
		cin >> a[i].first >> a[i].second;

	forll(i, 0, n)
	{
		if (a[i].second == "JPY")
			ans += a[i].first;
		else
			ans += a[i].first * 380000;
	}

	cout << fixed << setprecision(6) << ans;
}

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => (::std::cmp::min($x, min!($($z),*)));
}
#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => (::std::cmp::max($x, max!($($z),*)));
}

fn main() {
    input! {
        _n: i64,
        s: chars,
    }
    let d: i32 = s.iter().map(|c| match *c {
        'R' => 1,
        'B' => -1,
        _ => unreachable!()
    }).sum();
    let ans = if d > 0 { "Yes" } else { "No" };
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  ll n, a, b, r;
  cin >> n >> a >> b;
  r = (n / (a + b)) * a;
  r += min(n % (a + b), a);
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 256
import itertools
n=int(input())
x=[list(map(int,input().split())) for i in range(n)]
a=[]
for i in range(n):
    a.append(i)

p=list(itertools.permutations(a,n))

aa=1
for j in range(1,n+1):
  aa*=j

len=0
for j in range(aa):
  for i in range(n-1):
    len+=((x[p[j][i]][0]-x[p[j][i+1]][0])**2+(x[p[j][i]][1]-x[p[j][i+1]][1])**2)**(1/2)
b=len/aa
print(b)


Measured memory_bytes: 45424
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
  // 整数の入力
  string S,T;
  cin >> S >> T;
  ll min_not_matches = numeric_limits<ll>::max();
  for(int i = 0;i + T.length() - 1< S.length();i++){
    ll not_matches = 0;
    for(int j = 0; j < T.length();j++){
      if (S[i+j] != T[j]){
        not_matches++;
      }
    }
    min_not_matches = min(min_not_matches,not_matches);
  }
  cout << min_not_matches << endl;
 return 0;
}

Measured memory_bytes: 3556
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CFiveTransportations solver = new CFiveTransportations();
        solver.solve(1, in, out);
        out.close();
    }

    static class CFiveTransportations {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long min = Long.MAX_VALUE;
            for (int i = 0; i < 5; i++) min = Math.min(min, in.nextLong());
            out.println((long) Math.ceil((double) n / min) + 4);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

//GCD and LCM
llt gcd(llt x, llt y)
{
  if(y == 0) return x;
  return gcd(y, x%y);
}
llt lcm(llt x, llt y)
{
  return (x / gcd(x, y)) * y;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

int main()
{
  int x, t;
  cin>>x>>t;
  cout<<(x-t>=0?(x-t):0)<<endl;
}


Measured memory_bytes: 14080
def main():
    import heapq
    n=int(input())
    a=list(map(int,input().split()))
    h=a[:n]
    dp1=[sum(h)]
    heapq.heapify(h)
    for i in range(n):
        j=heapq.heappop(h)
        if a[n+i]>j:
            dp1.append(dp1[-1]+a[n+i]-j)
            heapq.heappush(h,a[n+i])
        else:
            dp1.append(dp1[-1])
            heapq.heappush(h,j)
    h=[-i for i in a[2*n:]]
    dp2=[sum(h)]
    heapq.heapify(h)
    for i in range(n):
        j=heapq.heappop(h)
        if -a[2*n-i-1]>j:
            dp2.append(dp2[-1]-a[2*n-i-1]-j)
            heapq.heappush(h,-a[2*n-i-1])
        else:
            dp2.append(dp2[-1])
            heapq.heappush(h,j)
    dp2=dp2[::-1]
    print(max([dp1[i]+dp2[i] for i in range(n+1)]))
main()

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int c=0;
    map<char,bool> vis;
    for (int i=0;i<4;i++)
    {
        if (vis[s[i]]==false)
            {
                c++;
                vis[s[i]]=true;
            }
    }
    if (c==2)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

int n, k;
int niz[100002];
long long DP[100002];

int main() {
    cin >> n >> k;
    for (int i=0; i<n; i++) cin >> niz[i];
    DP[0] = 0;
    DP[1] = abs(niz[0]-niz[1]);

    for (int i=2; i<n; i++) {
        DP[i] = 1000000000;
        for (int j=1; j <= k; j++) {
            if (j > i) continue;
            DP[i] = min(DP[i], DP[i-j] + abs(niz[i]-niz[i-j]));
        }
    }

    cout << DP[n-1];
    return 0;
}


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

// #define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vin(v,n) copy_n(istream_iterator<int>(cin),n,back_inserter(v));
#define all(v) v.begin(),v.end()
#define INF 2000000000
#define MOD 1000000007
#define ll long long 
#define vi vector<int>
#define ii pair<int,int>
#define si set<int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define f1(i,a,b) for(int i = a;i<b;i++)
#define f2(i,a,b) for(int i = a;i<=b;i++)

using namespace std;

int32_t main() 
{
	IOS;
	int n;
	cin >> n;
	vi v;
	vin(v,n);
	vi dp(n+1, 0);
	dp[0] = 0;
	dp[1] = abs(v[1]-v[0]);
	f1(i,2,n)
		dp[i] = min(dp[i-1]+abs(v[i]-v[i-1]), dp[i-2]+abs(v[i]-v[i-2]));
	
	cout << dp[n-1];

}


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

using namespace std;

int main()
{
    string w;
    cin>>w;
    int C[256] = {};
    for (char c: w)
        C[c]++;
    string answer = "Yes";
    for (int c: C)
        if (c%2!=0)
            answer = "No";
    cout<<answer<<endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    int N;
    cin >> N;
    vl A(N);
    REP(i,N)cin >> A[i];
    vl ans(N);

    ll e1 = 0 , e2 = 0;
    ll i;
    for(i=0;;i+=2){
        if(i>N)break;
        e1 += A[i];
    }

    for(i;;i+=2){
        if(i%N==0)break;
        e2 += A[i%N];
    }

    ans[0] = e1-e2;
    // ans[N-1] = A[i]*2-ans[0];
    for(int i=N-1;i>0;i--){
        ans[i] = A[i]*2-ans[(i+1)%N];
    }

    REP(i,N-1) cout << ans[i] << " ";

    cout << ans[N-1] << endl;


}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string answer;
  answer = "APPROVED";
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  for (int i=0; i < N; i++) {
    if (vec.at(i)%2 == 0) {
      if (vec.at(i) %3 != 0){
        if (vec.at(i) %5 != 0){
          answer = "DENIED";
          break;
        }
        else {
          answer = "APPROVED";
        }
      }
      else{
        answer = "APPROVED";
      }
      
    }
  }
  
  cout << answer << endl;
}

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

int main() {
  int n;
  cin >> n;

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

  for ( int i = 0; i < n; i++ ) {
    if ( i ) cout << " ";
    cout << a[i];
  }
  cout << endl;

  for ( int i = 1; i < n; i++ ) {
    int v = a[i];
    int j = i-1;
    while ( j >= 0 && a[j] > v ) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    for ( int i = 0; i < n; i++ ) {
      if ( i ) cout << " ";
      cout << a[i];
    }
    cout << endl;
  }

  
    
  return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  vl a(3*N);
  rep(i, 3*N) cin >> a[i];

  priority_queue<ll, vl, greater<ll>> que1;
  vl fromL(N + 1, 0);
  rep(i, N){
    fromL[0] += a[i];
    que1.push(a[i]);
  }

  rep2(i, 1, N + 1){
    que1.push(a[N - 1 +  i]);
    fromL[i] = fromL[i - 1] + a[N - 1 + i] - que1.top();
    que1.pop();
  }

  priority_queue<ll> que2;
  vl fromR(N + 1, 0);
  rep(i, N){
    fromR[0] += a[3*N - 1 - i];
    que2.push(a[3*N - 1 - i]);
  }

  rep2(i, 1, N + 1){
    que2.push(a[2*N - i]);
    fromR[i] = fromR[i - 1] + a[2*N - i] - que2.top();
    que2.pop();
  }

  ll ans = (ll)(-pow(10, 17));

  rep(i, N + 1){
    ans = max(ans, fromL[i] - fromR[N - i]);
    // cout << fromL[i] << ' ' << fromR[N - i] << endl;
  }

  cout << ans << endl;
  
  return 0;
}


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


int W, H, x, y, r;

int main(void) {
  cin >> W >> H >> x >> y >> r;

  if(r <= x && x <= W - r && r <= y && y <= H - r) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
int main(){
    // Your code here

    int a,b,c,d,i,j,ans;
    cin >> a >>b >>c>>d;
    
    if(a>c){
        i=a;
    }else{
        i=c;
    }
    
    if(b<d){
        j=b;
    }else{
        j=d;
    }
    
    ans = j-i;
    
    if(ans<0){
        cout << 0 <<endl;
    }else{
        cout << ans <<endl;
    }
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n,two[31],ans=0,cnt;
    vector<int> a,b;
    two[0]=1;
    for(int i=1;i<31;i++){
        two[i]=two[i-1]*2;
    }
    scanf("%d",&n);
    a.resize(n);
    b.resize(n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&b[i]);
    }
    for(int i=30;i>=1;i--){
        cnt=0;
        for(int j=0;j<n;j++){
            a[j]%=two[i];
            b[j]%=two[i];
        }
        sort(a.begin(),a.end());
        sort(b.begin(),b.end());
        for(int k=0;k<n;k++){
            decltype(b)::iterator it1 = std::lower_bound(b.begin(), b.end(), two[i-1]-a[k]);
            decltype(b)::iterator it2 = std::lower_bound(b.begin(), b.end(), 2*two[i-1]-a[k]);
            decltype(b)::iterator it3 = std::lower_bound(b.begin(), b.end(), 3*two[i-1]-a[k]);
            cnt+=it2-it1+b.end()-it3;
        }
        if(cnt%2){
            ans+=two[i-1];
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 1792
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=sc.nextInt();
		if(n%500<=a) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");

		}
		}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> t(n);
  int i;
  for(i=0;i<n;i++){
    cin >> t.at(i);
  }
  int m;
  cin >> m;
  vector<pair<int,int>> px(m);
  for(i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    px.at(i)=make_pair(a,b);
  }
  for(i=0;i<m;i++){
    int sum=0;
    int re=t.at(px.at(i).first-1);
    t.at(px.at(i).first-1)=px.at(i).second;
    for(int j=0;j<n;j++){
      sum+=t.at(j);
    }
    t.at(px.at(i).first-1)=re;
    cout << sum << endl;
  }
}

Measured memory_bytes: 256
N, M = map(int, input().split())

sorted_inputs = {}
ans = [None]*M

for i in range(M):
    P, Y = map(int, input().split())
    if sorted_inputs.get(P) is None:
        sorted_inputs[P] = [(Y, i)]
    else:
        sorted_inputs[P].append((Y, i))

for pref, l in sorted_inputs.items():
    l.sort() # Yでソートされる
    for j, (Y, i) in enumerate(l):
        first = str(pref).rjust(6, '0')
        latter = str(j+1).rjust(6, '0')
        ans[i] = first + latter

for item in ans:
    print(item)

Measured memory_bytes: 42924
n = int(raw_input())

ining = 0
out = 0
score = 0
fst = sec = thr = 0, 0, 0
while ining < n:
  val = raw_input()

  if val == 'HIT':
    if thr == 1:
      score += 1
      thr = 0

    thr = sec
    sec = fst
    fst = 1

  if val == 'HOMERUN':
    if thr == 1:
      score += 1
    if sec == 1:
      score += 1
    if fst == 1:
      score += 1
    score += 1
    fst = sec = thr = 0, 0, 0

  if val == 'OUT':
    out += 1
    if out == 3:
      print score
      score = 0
      out = 0
      fst = sec = thr = 0
      ining += 1


Measured memory_bytes: 4668
N=int(input())
a=[int(input()) for i in range(N)]
b=sorted(a)
d={}
for i in range(N):
  d[b[i]]=i
for i in range(N):
  a[i]=d[a[i]]
ans=0
for i in range(N):
  if i%2==0 and a[i]%2==1:
    ans+=1
print(ans)

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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

int inp[10];

int main() {
	for(int i=0;i<5;i++) {
		cin >> inp[i];
	}
	for(int i=0;i<5;i++) {
		if(inp[i] == 0) {
			cout << i+1 << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3564
/**
 *    This code has been written by YueGuang, feel free to ask me question. Blog: http://www.yx.telstudy.xyz
 *    created:
 */
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
using namespace std;
typedef long long ll;
string s[110];
map<string, int> mp;

int mx;
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) cin >> s[i], mp[s[i]]++;
    int m;
    scanf("%d", &m);string t;
    for(int i = 0; i < m; i++) cin >> t, mp[t]--;
    for(int i = 0; i < n; i++){
        mx = max(mx, mp[s[i]]);
    }
    cout << mx << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define frr(j,i,n) for(int i=j;i<=n;++i)
using namespace std;
void solve() 
{
	int k;
    cin>>k;
    frr(1,i,k)  cout<<"ACL";

}
int main() 
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}



Measured memory_bytes: 3532
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
LL a[maxn];
int main(){
	int n,x,a,sum=0;
	cin>>n>>x;
	int flag=n+1;
	for(int i=1;i<=n;i++){
		cin>>a;
		sum+=a;
		if(sum>x&&flag==n+1){
			flag=i;
		}
	}
	cout<<flag;
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(pow(10,5)+1,0);
  ll s=0;
  rep(i,n) {
    int k;
    cin >> k;
    s+=k;
    a[k]++;
  }
  ll q;
  cin >> q;
  vector<ll> b(q),c(q);
  vector<ll> res(q);
  rep(i,q) {
    cin >> b[i] >> c[i];
    s = s - a[b[i]]*b[i] + a[b[i]]*c[i];
    res[i]=s;
    a[c[i]]+=a[b[i]];
    a[b[i]]=0;
  }
  rep(i,q) cout << res[i] << endl;
  return 0;
}


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

int main(void){
    int n, t;
    cin >> n >> t;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];\
    
    vector<vector<int>> dp1(n, vector<int>(t, 0)), dp2(n, vector<int>(t, 0));
    rep(i, n) {
        for (int j = t-(a[i]+1); j >= 0; j--) {
            dp1[i][j+a[i]] = max(dp1[i][j+a[i]], dp1[i][j]+b[i]);
            //if (i < n-1)
            //    dp1[i+1][j+a[i]] = dp1[i][j+a[i]];
        }
        if (i < n-1)
            for (int j = 0; j < t; j++)
                dp1[i+1][j] = dp1[i][j];
    }
    
    for (int i = n-1; i >= 0; i--) {
        for (int j = t-(a[i]+1); j >= 0; j--) {
            dp2[i][j+a[i]] = max(dp2[i][j+a[i]], dp2[i][j]+b[i]);
            //if (i != 0)
            //    dp2[i-1][j+a[i]] = dp2[i][j+a[i]];
        }
        if (i != 0)
            for (int j = 0; j < t; j++)
                dp2[i-1][j] = dp2[i][j];
    }
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t; j++) {
            if (i != 0 && i != n-1)
                ans = max(ans, b[i]+dp1[i-1][j]+dp2[i+1][t-1-j]);
            else if (i == 0)
                ans = max(ans, b[i]+dp2[i+1][t-1-j]);
            else
                ans = max(ans, b[i]+dp1[i-1][j]);
        }
    }
    /*
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t; j++)
            cout << dp1[i][j] << " ";
        cout << endl;
    }
    */
    
    cout << ans << endl;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
string word[4] = {"dream", "dreamer", "erase", "eraser"};
int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    for (int i = 0; i < 4; i++) {
        reverse(word[i].begin(), word[i].end());
    }
    int N = s.size();
    bool check = true;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 4; j++) {
            int n = word[j].size();
            if (s.substr(i, n) == word[j]) {
                i += n - 1;
                break;
            }
            if (j == 3) {
                check = false;
            }
        }
        if (!check) {
            break;
        }
    }
    cout << (check ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int N=3e5+5;

ll d,t,s;

int main()
{
    ios::sync_with_stdio(false);
    cin>>d>>t>>s;
    if(t*s>=d)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    int H,W,N;
    cin >> H >> W >> N;
    cout << (N + max(H,W) - 1) / max(H,W) << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())

zenbu = N*M
naka = max(N-2,0)*max(M-2,0)
kado = [4,2,1][[N,M].count(1)]
hen = N*M-naka-kado

if N==M==1:
    print(1)
elif N==1 or M==1:
    print(hen)
else:
    print(naka)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a,b,c,d;
	a=s[0]-'0';
	b=s[1]-'0';
	c=s[2]-'0';
	d=s[3]-'0';
	if(a+b+c+d==7)cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<'='<<7<<endl;
	else if(a+b+c-d==7)cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<'='<<7<<endl;
	else if(a+b-c+d==7)cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<'='<<7<<endl;
	else if(a+b-c-d==7)cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<'='<<7<<endl;
	else if(a-b+c+d==7)cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<'='<<7<<endl;
	else if(a-b+c-d==7)cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<'='<<7<<endl;
	else if(a-b-c+d==7)cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<'='<<7<<endl;
	else if(a-b-c-d==7)cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<'='<<7<<endl;
	return 0;
}


Measured memory_bytes: 256