akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    long long int  N, W;
    if (scanf("%lld%lld", &N, &W) < 2) return 0;

    // 重さ 4通り グループ分け
    vector<long long int> a, b, c, d;

    long long int w, v;

    if (scanf("%lld%lld", &w, &v) < 2) return 0;
    long long int w0 = w;

    for (int i = 1; i <= N; i++)
    {
        if (w == w0) a.push_back(v);

        else if (w == w0 + 1) b.push_back(v);

        else if (w == w0 + 2) c.push_back(v);

        else d.push_back(v);

        if (i != N) if (scanf("%lld%lld", &w, &v) < 2) return 0;
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    sort(d.begin(), d.end());

    // 価値 降順
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    reverse(c.begin(), c.end());
    reverse(d.begin(), d.end());

    // 価値 降順 累積和
    for (int i = 1; i < (signed)a.size(); i++) a[i] += a[i - 1];
    for (int i = 1; i < (signed)b.size(); i++) b[i] += b[i - 1];
    for (int i = 1; i < (signed)c.size(); i++) c[i] += c[i - 1];
    for (int i = 1; i < (signed)d.size(); i++) d[i] += d[i - 1];

    long long int ans = 0LL;
    for (int i = 0; i <= (signed)a.size(); i++)
    {
        for (int j = 0; j <= (signed)b.size(); j++)
        {
            for (int k = 0; k <= (signed)c.size(); k++)
            {
                // グループ A B C 重さ 合計
                long long int
                    wag = i * w0 + j * (w0 + 1) + k * (w0 + 2);

                // 制限超過
                if (wag > W) continue;

                // グループ D 数
                // グループ A B C 重さ 合計 から 算出
                long long int l = (W - wag) / (w0 + 3);

                if ((int)d.size() < l) l = d.size();

                long long int s = 0LL;

                if (i != 0LL) s += a[i - 1];

                if (j != 0LL) s += b[j - 1];

                if (k != 0LL) s += c[k - 1];

                if (l != 0LL) s += d[l - 1];

                if (s > ans) ans = s;
            }
        }
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include <math.h>
using namespace std;
 
int main(){
 
  int n=1;
  long H,ans;
  
  cin >> H;
 
  while(1){
    
    if(H<pow(2,n))break;
    
    n++;
    
  }
  
  ans = pow(2,n)-1;
  cout << ans;
 
  return 0;
  
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var k, a, b int
  fmt.Scan(&k)
  fmt.Scan(&a, &b)

  for a <= b {
    if a%k == 0 {
      fmt.Println("OK")
      return
    }
    a++
  }
  fmt.Println("NG")
}


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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

typedef long long ll;
using namespace std;

int main() {
  string a;
  int ans = 0;
  
  rep(i,0,3){
    scanf("%c", &a[i]);
    if(a[i] == '1') ans++;
  }

  printf("%d\n", ans);

  return 0;
}

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

m = min(lis)
lis.remove(min(lis))
m_2 = min(lis)
lis.remove(min(lis))
v = (m + m_2) / 2   

for i in range(0, N - 2):
    v = (v + min(lis)) / 2
    lis.remove(min(lis))

print(v)
    

Measured memory_bytes: 3060
def main():
    N = int(input())
    A = list(map(int, input().split()))
    prev = 0
    ans = 0
    for a in A:
        if a == prev:
            ans += 1
            prev = 0
        else:
            prev = a
    print(ans)


if __name__ == "__main__":
    main()


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


using namespace std;

typedef long long ll;
const int MAXN = 2e5 + 5;
int a[MAXN];
int main()
{
  
int rl = 0;
int n;
cin >> n;
for(int i = 1 ; i <= n ; i++)
  cin >> a[i];

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

   if(!rl)
      cout << -1;
  else 
     cout << n - rl;


}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        for(int i=0; i<=x; i++) {
            int num = 2*i + 4*(x-i);
            if(y == num) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");

    }


}

Measured memory_bytes: 35796
import bisect
def main():
 
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
 
    # print(L)
    ans = 0
    for i in range(N-2):
        for j in range(i+2, N):
            a = L[i]
            c = L[j]
            k = bisect.bisect_left(L, c-a+1)
            if k <= i:
                ans += j-i-1
            else:
                ans += j-k
    return ans
 
if __name__ == '__main__':
    print(main())

Measured memory_bytes: 42204
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;

const int MAX = 999999;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int x, y;
  cin >> x >> y;
  int a = (2 * x - y) / 3, b = (2 * y - x) / 3;
  if (a < 0 || b < 0 || (2 * x - y) % 3 != 0 || (2 * y - x) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  COMinit();

  cout << COM(a + b, a) % MOD << endl;
  return 0;
}

Measured memory_bytes: 23680
#include <iostream>

#define ll long long

using namespace std;

ll a[50];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	for(int i = 0; i < 50; i++)
		a[i] = i;
	
	ll k;
	cin >> k;
	
	int n = 50;
	ll complete_operations = k/n;
	
	for(int i = 0; i < 50; i++)
		a[i] += complete_operations;
	
	int rem = k % n;

	for(int i = 0; i < 50 && rem > 0; i++)
	{
		a[i] += n +1;
		
		for(int j = 0; j < 50; j++)
			a[j]--;
				
		rem--;
	}		
	
	cout << n << '\n';
	for(int i = 0; i < n; i++)
		cout << a[i] << ' ';
	cout << '\n';
	
	return 0;
}

Measured memory_bytes: 256
# ソートしたやつの小さい方から2つを決めてもうひとつはにぶたん
# 3, 5としたときに残りの一つは5, 6, 7みたいになる
# このにぶたんなんか実装がめっっっちゃむずくない？サンプル1が通らんのだが
# やったけどTLEなるな

import bisect

n = int(input())
arr = sorted(list(map(int, input().split())))


def lower_bound(arr, x):
    l, r = 0, len(arr)
    while l < r:
        mid = (l + r) // 2
        if arr[mid] < x:
            l = mid + 1
        else:
            r = mid
    return l


ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        idx_l = lower_bound(arr, arr[i] + arr[j]) - 1
        # print(
        #     "arr[{}]+arr[{}]={}より小さくなるはじめてのインデックス {}".format(
        #         i, j, arr[i] + arr[j], idx_l
        #     )
        # )
        # print("idx_l = {}, arr[{}]={}".format(idx_l, idx_l, arr[idx_l]))
        # print("範囲 {}".format(arr[j + 1 : idx_l + 1]))
        ans += len(arr[j + 1 : idx_l + 1])
print(ans)


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

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

int main()
{
	unsigned long long a, b, c; cin >> a >> b >> c;
	if (c <= a + b) {
		cout << "No\n";
		return 0;
	}

	unsigned long long v = c - a - b;
	v *= v;

	cout << (v > 4 * a * b ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD (long long)(1e9 + 7)
using namespace std;

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const {
    return ModInt(*this) += p;
  }
  ModInt operator-(const ModInt &p) const {
    return ModInt(*this) -= p;
  }
  ModInt operator*(const ModInt &p) const {
    return ModInt(*this) *= p;
  }
  ModInt operator/(const ModInt &p) const {
    return ModInt(*this) /= p;
  }
  bool operator==(const ModInt &p) const {
    return x == p.x;
  }
  bool operator!=(const ModInt &p) const {
    return x != p.x;
  }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt ans(1), mul(x);
    while(n) {
      if(n & 1) ans *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ans;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};

long long n;
vector<long long> cnt, edges[200005], par;
vector<bool> ch;

ModInt<MOD> solve();
long long rec(long long now);

int main() {
  cin >> n;
  for(int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }

  cout << solve() << endl;
  return 0;
}

ModInt<MOD> solve() {
  ModInt<MOD> res, two = 2;
  cnt.assign(n, 0);
  ch.assign(n, 0);
  par.assign(n, -1);
  ch[0] = 1;
  rec(0);
  for(int i = 0; i < n; ++i) {
    ModInt<MOD> now = 0;
    long long sum = 0;
    for(auto nowp : edges[i])
      if(par[i] != nowp) {
        sum += cnt[nowp];
        now += two.pow(cnt[nowp]) - 1;
      }
    if(par[i] != -1) now += two.pow(n - sum - 1) - 1;
    res += two.pow(n - 1) - 1 - now;
  }
  return res / two.pow(n);
}

long long rec(long long now) {
  long long res = 0;
  for(auto nextp : edges[now]) {
    if(!ch[nextp]) {
      ch[nextp] = 1;
      par[nextp] = now;
      res += rec(nextp);
    }
  }
  return cnt[now] = res + 1;
}

Measured memory_bytes: 21888
n=int(input())
Y=[list(map(int,input().split())) for i in range(n)]
range=[]
ans,end=0,-1*(10**9+1)
for X in Y:
  range.append([X[0]-X[1],X[0]+X[1]])
range.sort(key=lambda X: X[1])

for R in range:
  if end <= R[0]:
    ans += 1
    end=R[1]
  else:
    continue
print(ans)

Measured memory_bytes: 42792
keta1=0
for i in range(1,12+1):
  print('?',10**(i-1),flush=True)
  ans=input()
  if ans=='Y':
    keta1=i
if keta1!=12:
  keta=keta1
else:
  keta=12
  for i in range(10,0,-1):
    print('?',2*10**(i-1),flush=True)
    ans=input()
    if ans=='Y':
      keta=i
l=10**(keta-1)-1
r=10**keta
while r-l!=1:
  mid=(l+r)//2
  print('?',mid*10,flush=True)
  ans=input()
  if ans=='Y':
    r=mid
  else:
    l=mid
print('!',r,flush=True)

Measured memory_bytes: 9012
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
// ll MOD = 1000000007;
//
// ll mod(long long val) {
//     long long res = val % MOD;
//     if (res < 0) res += MOD;
//     return res;
// }
//
// ll modinv(ll a) {
//     ll b = MOD, u = 1, v = 0;
//     while (b) {
//         ll t = a / b;
//         a -= t * b; swap(a, b);
//         u -= t * v; swap(u, v);
//     }
//     u %= MOD;
//     if (u < 0) u += MOD;
//     return u;
// }
//
// const int MAX = -1;
// ll fac[MAX], finv[MAX], inv[MAX];
// void com_init() {  // initialize nCk table with O(N)
//     fac[0] = fac[1] = 1;
//     finv[0] = finv[1] = 1;
//     inv[1] = 1;
//     for (int i = 2; i < MAX; i++){
//         fac[i] = fac[i - 1] * i % MOD;
//         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
//         finv[i] = finv[i - 1] * inv[i] % MOD;
//     }
// }
// ll com(int n, int k){  // nCk
//     if (n < k) return 0;
//     if (n < 0 || k < 0) return 0;
//     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
// }

const int MAX_N = 505;
int N, M, Q, L, R;
int arr[MAX_N][MAX_N];

void dump() {
    cout << "---" << endl;
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            if (i == j) cout << "*";
            else cout << " ";
            cout << arr[i][j];
            cout << "\t";
        }
        cout << endl;
    }
}

int main() {
    memset(arr, 0, sizeof(arr));
    cin >> N >> M >> Q;
    for (int i = 0; i < M; ++i) {
        cin >> L >> R; --L; --R;
        ++arr[L][R];
    }
    for (int i = 0; i < MAX_N; ++i) {
        for (int j = 0; j + 1 < MAX_N; ++j) {
            arr[i][j + 1] += arr[i][j];
        }
    }
    // dump();
    for (int j = 0; j < MAX_N; ++j) {
        for (int i = MAX_N - 1; i - 1 >= 0; --i) {
            arr[i - 1][j] += arr[i][j];
        }
    }
    // dump();
    for (int i = 0; i < Q; ++i) {
        cin >> L >> R; --L; --R;
        cout << arr[L][R] << endl;
    }
    return 0;
}


Measured memory_bytes: 1920
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

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

    String s = sc.nextLine();

    for (char c : s.toCharArray()) {
        if (Character.isUpperCase(c)) {
            pw.print(Character.toLowerCase(c));
        } else {
            pw.print(Character.toUpperCase(c));
        }
    }
    pw.println();
    pw.flush();
    sc.close();
  }
}


Measured memory_bytes: 26120
#include<bits/stdc++.h>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;

ll fast(ll n,ll k)
{
    ll res = 1;
    n%=MOD;
    while(k>0)
    {
        if ((k&1) == 1)
            res = (res * n)%MOD;
        k = k>>1;
        n = (n * n)%MOD;
    }
    return res;
}

ll mod_div(ll n)
{
    return fast(n,MOD-2);
}

ll combo(ll n, ll r)
{
    if (0 <= r && r <= n)
    {
        r = min(n - r,r);
        ll a = 1, b = 1;
        foi(1,r+1)
        {
            b = ((b%MOD) * (i%MOD))%MOD;
            a = ((a%MOD)*(n%MOD))%MOD;
            n -= 1;
        }
        return (a%MOD * mod_div(b)%MOD)%MOD;
    }
    else
        return 0;
}

int main()
{
    f_io;
    ll s;
    cin >> s;
    ll n = s/3;
    ll ans = 0;
    foi(1,n+1)
    {
        ll rem = s - 3*i;
        ans = (combo(rem+i-1,i-1)+ ans)%MOD; 
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define BUF 1e5
#define INF 1 << 30
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
constexpr ll mod = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> A >> S;
    if (A >= 3200) {
        cout << S << endl;
    } else {
        cout << "red" << endl;
    }
}

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

using namespace std;

int main( )
{
	int n;	
	cin>>n;
	
	vector<double> x(n), y(n);	
	double num;
	for( int i=0; i<n; i++ ) {
		cin>>num;
		x.at( i ) = num;
	}
	for( int i=0; i<n; i++ ) {
		cin>>num;
		y.at( i ) = num;
	}
	double Dxy, Dxy2, Dxy3, Dmax;
	Dxy = Dxy2 = Dxy3 = Dmax = 0;
	for( int i=0; i<n; i++ ) {
		num = fabs(  x.at( i ) - y.at( i ) );
		Dxy += num;
		Dxy2 += pow( num, 2 );
		Dxy3 += pow( num, 3 );
		Dmax = max( Dmax, num );
	}
	
	cout.setf( ios::fixed );
	cout<<Dxy<<endl;
	cout<<sqrt( Dxy2 )<<endl;
	cout<<cbrt( Dxy3 )<<endl;
	cout<<Dmax<<endl;
	
	return 0;
}

Measured memory_bytes: 1316
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long int ll;

int main()
{
    ll N, K;
    cin >> N >> K;

    if (N % 2 == 0)
    {
        if (N / 2 < K)
            cout << "NO" << endl;
        else
        {
            cout << "YES" << endl;
        }
    }
    else
    {
        if (N / 2 < K - 1)
            cout << "NO" << endl;
        else
        {
            cout << "YES" << endl;
        }
    }
}

Measured memory_bytes: 256
//Code by ASIM FOIZE AIMON
//CSE'19;CUET
//avoid copy paste//Hit the frined button
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise cout.precision(10); cout << fixed;
#define endl "\n"
#define int int64_t
#define ll long long
#define yes printf("YES\n")
#define no printf("NO\n")
int32_t main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/input.txt", "r", stdin);
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/output.txt", "w", stdout);
    #endif*/
    int a[100001],b,c=0,d=0,e,f,m,n,p,y,z,t,i,j,k;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<n-2;i++)
    {
        for(j=i+1;j<n-1;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k])
                    c++;
            }
        }
    }
    cout<<c<<endl;
}



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

int main()
{
    int A, B;
    cin >> A >> B;
    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;
    return 0;
}

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

int main()
{
  int N;
  cin >> N;
  int K;
  cin >> K;
  vector<int> xvec(N);
  for (auto &x : xvec)
  {
    cin >> x;
  }
  int sum = 0;
  for (int i = 0; i < N; i++)
  {
    sum += 2 * min(abs(xvec[i] - 0), abs(xvec[i] - K));
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

class Main {
    public static void main(String[] args) throws IOException {
        try (PrintWriter writer = new PrintWriter(System.out); InputReader reader = new InputReader(System.in)) {
            String input = reader.readLine();

            char[] inputChars = input.toCharArray();
            int length = inputChars.length;
            long ans = inputChars[0] - '0' + 9 * (length - 1);
            for (int i = 1; i < length; i++) {
                if (inputChars[i] != '9') {
                    writer.println(ans - 1L);
                    writer.flush();
                    return;
                }
            }

            writer.println(ans);
            writer.flush();
        }
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readLine().split(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readLine().split(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    @Override
    public void close() throws IOException {
        this.br.close();
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <tgmath.h>
#define MOD 1000000007
using namespace std;
#define INT_MAX 2147000000
#define LONG_MAX 9223372036854775806

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

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    cout << min(A,B) << " " << max(0,-N+A+B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

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

double calcs(double x1,double x2,double x3,double y1,double y2,double y3){
	double a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	double b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
	double c=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
	double s=(a+b+c)/2.0;
	return sqrt(s*(s-a)*(s-b)*(s-c));
}


int main(){
	double tx,ty,nx,ny,ix,iy,s=0.0;
	char c;
	cin>>tx>>c>>ty>>nx>>c>>ny;
	while(cin>>ix>>c>>iy){
		s+=calcs(tx,nx,ix,ty,ny,iy);
		nx=ix;
		ny=iy;
	}
	printf("%.15lf\n",s);
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
int solve(vector<int> arr,int n)
{
	vector<int> dp(n+1);
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		int option1=abs(arr[i]-arr[i-1])+dp[i-1];
		int option2=(i==2)?inf:abs(arr[i]-arr[i-2])+dp[i-2];
		dp[i]=min(option1,option2);
	}
	return dp[n];
		
}

int main()
{ 
	int n;
	cin>>n;
	vector<int> arr(n+1);
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
	}
	cout<<solve(arr,n);
}


Measured memory_bytes: 4268
#! /bin/ruby

n = gets.chomp.to_i
targets = gets.chomp.split(" ").map(&:to_i)

ans = []
n.times do |i|
  (n-i).downto(1) do |m|
    index = targets.index(m)
    if !index
      next
    end
    if targets[index] == index + 1
      ans << targets.delete_at(index)
      break
    end
  end
end
if ans.length == n
  ans.reverse.each {|a| puts a }
else
  puts -1
end


Measured memory_bytes: 1788
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
k = ni()

res = 1

for _ in range(n):
    res = min(res+k, 2*res)
    
print(res)

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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


Measured memory_bytes: 3296
#include "bits/stdc++.h"

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

ll n;

int number[3] = { 7, 5, 3 };

int dfs(ll s) {
	if (s > n) {
		return 0;
	}
	int a = 0, b = 0, c = 0;
	int i = 1;
	while (s / i > 0) {
		ll num = s / i;
		if (num % 10 == 7) a++;
		if (num % 10 == 5) b++;
		if (num % 10 == 3) c++;
		i *= 10;
	}
	ll ret;
	if (a < 1 || b < 1 || c < 1) {
		ret = 0;
	}
	else {
		ret = 1;
	}
	for (int i = 0; i < 3; i++) {
		ret += dfs(s * 10 + number[i]);
	}
	return ret;
}

int main() {
	cin >> n;
	cout << dfs(0) << en;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
mistakelist = []
for i in range (len(p)):
  if p[i] == i+1:
    continue
  else:
    mistakelist.append(i+1)
if len(mistakelist) ==0:
  print ("YES")
elif len(mistakelist) == 2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
N, K = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
minvalue = None
for i in range(0, N-K+1):
	j = i+K-1
	if i == j:
		k = abs(X[i])
	elif X[i]*X[j]>=0:
		k = max(abs(X[i]), abs(X[j]))
	else:
		k = min(abs(X[i])*2+X[j], abs(X[i])+X[j]*2)
	if minvalue is None:
		minvalue = k
	else:
		minvalue = min(minvalue, k)
print(minvalue)
	


Measured memory_bytes: 14224
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e17;
#define int long long


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	FORR(i, 1, 9) {
		FORR(j, 1, 9) {
			if (i*j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        char[] s = sc.next().toCharArray(), t = sc.next().toCharArray();
        int ans = 0;
        for (int i = 0; i < s.length; i++)
            if (s[i] != t[i]) ans++;
        out.println(ans);
        out.flush();
        out.close();
    }

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

        public int[] nextIntArray(int n) throws IOException {
            int[] ans = new int[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextInt();
            return ans;
        }
    }
}


Measured memory_bytes: 37816
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,c;
    cin>>s;
    int ans=1000000000;
    f(i,0,s.size()-1){
        c[0]=s[i];
        c[1]=s[i+1];
        c[2]=s[i+2];
        int k=stoi(c);
        ans=min(abs(k-753),ans);
    }
     cout<<ans;
}   
    
    
     

     
   





Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
  
  long long N,K;
  cin >> N >> K;

  long long ans = 0;
  vector<long long> S(N+1,0);
  S[N] = N;
  for(int i = N;i > 0;i--) {
    S[i-1] = S[i]+i-1;
  }

  reverse(S.begin(),S.end());

  for(long long i = K;i <= N+1;i++) {
    ans += S[i-1]-i*(i-1)/2+1;
    ans %= MOD;
  } 
  
  cout << ans << endl;



}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll n; cin>>n;
  vector<ll> a(n);
  rep(i, n) cin>>a.at(i);
  ll cnt=0; ll ans=0;
  vector<ll> b;
  rep(i, n-1) {
    if(a.at(i)>=a.at(i+1)) cnt++;
    else {
      cnt=0;
    }
    ans=max(cnt, ans);
  }
  cout << ans << endl;
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

typedef std::complex<double> P2;
using std::norm;
using std::real;
using std::conj;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2376299#1
P2 projection(P2 p1, P2 p2, P2 p) {
   P2 t = p2 - p1;
   return p1+(t)/norm(t)*real((p-p1)*conj(t));
}
P2 refrection(P2 p1, P2 p2, P2 p) {
   P2 t = p2 - p1;
   return p1+conj((p-p1)/t)*t;
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long x1, y1, x2, y2; scan(x1, y1, x2, y2);
      long q; scan(q);
      for(long i = 0; i < q; ++i) {
         long x, y; scan(x, y);
         auto res = refrection(P2(x1,y1), P2(x2, y2), P2(x,y));
         printf("%.20lf %.20lf\n", res.real(), res.imag());
      }
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int INF = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  int check = 1;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == s[i + 1]) {
      check++;
    } else {
      if (check % 2 != 0) {
        cout << "No" << endl;
        return 0;
      }
      check = 1;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}


int main(){
	vector<int> a;
	int q;
	cin >> q;
	rep(i,q){
		int qi;
		cin >> qi;
		if (qi == 0) {
			int n;
			cin >> n;
			a.push_back(n);
		}
		else if (qi == 1){
			int n;
			cin >> n;
			cout << a[n] << endl;
		}
		else {
			a.pop_back();
		}
	}
	return 0;
}




Measured memory_bytes: 3860
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n, m, k := scanInt(), scanInt(), scanInt()
	A := scanInts(n)
	B := scanInts(m)

	a, b := []int{0}, []int{0}

	for i, ele := range A {
		a = append(a, ele+a[i])
	}
	for i, ele := range B {
		b = append(b, ele+b[i])
	}

	ans, j := 0, m
	for i := 0; i < n+1; i++ {
		if a[i] > k {
			break
		}
		for b[j]+a[i] > k {
			j--
		}
		if ans < i+j {
			ans = i + j
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 14128
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int[] A = new int[ N];
		ArrayList<Integer> a = new ArrayList<Integer>();
		boolean can = true;
		for(int i = 0;i < N;i++) {
			A[i] = scn.nextInt();
			if(A[i] > i+1)can = false;
		}

		if(can) {
			for(int i = 0;i < N;i++) {
				a.add(A[i]-1,A[i]);
			}
			for(int i = 0;i < N;i++) {
				System.out.println(a.get(i));
			}
		}else {
			System.out.println(-1);
		}
	}
}


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

#define sz(x) (int)((x).size())
#define xx first
#define yy second

#define MAT vector<vector<int>> 

const int N = 51;
const ll mod = 1e9 + 7;

ll add(ll x, ll y) {
    return ((x + y) % mod + mod) % mod;
}
ll mul(ll x, ll y) {
    return (x * y) % mod;
}

int n;

MAT matmul(MAT a, MAT b) {
    MAT c = MAT(n, vector<int>(n));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            for (int k = 0; k < n; k++)
                c[i][j] = add(c[i][j], mul(a[i][k], b[k][j]));
    return c;
}
MAT matpow(MAT a, ll p) {
    MAT b = MAT(n, vector<int>(n));
    for (int i = 0; i < n; i++)
        b[i][i] = 1;
    while (p) {
        if (p & 1)
            b = matmul(b, a);
        a = matmul(a, a);
        p >>= 1;
    }
    return b;
}

void solve() {
    cin >> n;
    ll k; cin >> k;
    MAT g(n, vector<int>(n));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> g[i][j];
    ll ans = 0;
    MAT gK = matpow(g, k);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            ans = add(ans, gK[i][j]);
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 3720
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll x;
    cin >> x;
    ll est = 100;
    ll i = 1, ans = 0;
    while(true) {
        est *= 1.01;
        if(est > x - 1) {
            ans = i;
            break;
        }
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(10)]
for k in range(10):
  for i in range(10):
    for j in range(10):
      d[i][j] = min(d[i][j], d[i][k] + d[k][j])
res = 0
for _ in range(H):
  a = list(map(int, input().split()))
  for x in a:
    if x != -1: res += d[x][1]
print(res)

Measured memory_bytes: 40556
/***
*	??????????????????
****/

#include <iostream>
#include <vector>
using namespace std;

int main(void)		//???????????¢??°
{
	int n;
	cin >> n;
	
	vector <int> str;
	str.resize(n);
	
	for(int i =0; i < n ;  i++){	//????????\???
		cin >> str[i] ;
	}
//	int k = n-1;
	
	int cnter = 0;
	for( int i=0 ; i < n-1 ; ++i ){
		
		for(int j = 1 ; j< (n-i); j++){
			if( str[j] < str[j-1]){//????????????????´???¨??????
				int temp = str[j];
				str[j]     = str[j-1];
				str[j-1]   = temp;
				cnter ++;
			}
		}
	}
//	k=j;
	
//----------------------------------	???????????????
	for(int i =0; i<n ; i++){
		cout << str[i] ;
		if(i != (n-1)){
			cout << " ";
		}
	}
	cout << endl;
	
	cout << cnter << endl;
	
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int nxt = 1, ans = 0;
  rep(i,n) {
    if (nxt == a[i]) {
      ++nxt;
    } else {
      ++ans;
    }
  }
  if (ans == n) ans = -1;
  cout << ans << endl;
  return 0;
}

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

int	main(void)
{
  char word;
  cin >> word;
  
  if ((word == 'a') || (word == 'i') ||( word == 'u') || (word == 'e') || (word == 'o')) 
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
  return (0);
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

H,W,N=map(int,input().split())
B=[set() for i in range(H+1)]
for i in range(N):
    x,y=map(int,input().split())
    B[x].add(y)

NOW=1

for i in range(2,H+1):
    for j in B[i]:
        if j<=NOW:
            print(i-1)
            sys.exit()

    if not (NOW+1 in B[i]):
        NOW+=1

print(H)

Measured memory_bytes: 55512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    string s;
    cin>>s;
    for (char a : s){
        if(a=='9'){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";

    return 0;
}


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

int     main() {
        int A, B, C, D;
        cin >>A >>B >>C >>D;
        for (;;) {
                C -=B;
                if (C<=0) {
                        cout <<"Yes" <<endl;
                        break;
                }
                A -=D;
                if (A<=0) {
                        cout <<"No" <<endl;
                        break;
                }
        }
        return 0;
}

Measured memory_bytes: 3636
object Main {

  val amari = 1000000007

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N, A, B, C = sc.nextInt()
    val L = Array.fill(N)(sc.nextInt())
    println(calc(L, Nil ,Nil, Nil))

    def calc(array: Array[Int], l1: List[Int], l2: List[Int], l3: List[Int]): Int = {
      if (array.isEmpty) {
        if (l1.isEmpty || l2.isEmpty || l3.isEmpty) {
          Int.MaxValue
        } else {
          Math.abs(l1.sum - A) + Math.abs(l2.sum - B) + Math.abs(l3.sum - C) + (l1.length + l2.length + l3.length - 3) * 10
        }
      } else {
        val h = array.head
        val t = array.tail
        Seq(
          calc(t, l1, l2, l3),
          calc(t, h :: l1, l2, l3),
          calc(t, l1, h :: l2, l3),
          calc(t, l1, l2, h :: l3)
        ).min
      }
    }
  }
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int t[512][512];

int main2() {
  CLR(t, 0);

  int N = nextInt();
  int M = nextInt();
  int Q = nextInt();
  REP(i, M) {
    int L = nextInt();
    int R = nextInt();
    t[L][R]++;
  }
  for (int l = 1; l <= N; l++) {
    for (int r = 1; r <= N; r++) {
      t[l][r] += t[l][r-1];
    }
  }
  REP(qqq, Q) {
    int p = nextInt();
    int q = nextInt();
    int ans = 0;
    for (int i = p; i <= q; i++) {
      ans += t[i][q] - t[i][i-1];
    }
    printf("%d\n", ans);
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 1920
#include <tuple>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> union_tree;

int root(int leave)
{
	int tmp = leave;
	if (leave == union_tree[leave])
	{
		return leave;
	}
	union_tree[tmp] = root(union_tree[tmp]);
	return union_tree[tmp];
}

int is_same_set(int a, int b)
{
	return root(a) == root(b) ? 1 : 0;
}

void unite(int a, int b)
{
	union_tree[root(a)] = root(b);
}

int main()
{
	int n;
	cin >> n;
	vector<tuple<int, int, int>> bridges;
	for (int i = 0; i < n; i++)
	{

		for (int j = 0; j < n; j++)
		{
			int cost;
			cin >> cost;
			if (cost == -1)
			{
				continue;
			}
			else
			{
				bridges.push_back(make_tuple(cost, i, j));
			}
		}
		union_tree.push_back(i);
	}
	sort(bridges.begin(), bridges.end());
	int index(0),cost(0);
	for (int i = 0; i < n - 1; i++)
	{
		while (is_same_set(get<1>(bridges[index]), get<2>(bridges[index])))
		{
			index++;
		}
		cost += get<0>(bridges[index]);
		unite(get<1>(bridges[index]), get<2>(bridges[index]));
	}
	cout << cost << endl;
	return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>


using namespace std;

int main() {
  int n,m,a,sum;
  sum=0;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>a;
    sum+=a;
  }
  int ans = n-sum;
  if(ans <0)
  cout<<-1<<endl;
  else
    cout<<ans<<endl;
  

  return 0;
}

Measured memory_bytes: 3580
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if ((s.charAt(0)==s.charAt(1)&&s.charAt(1)==s.charAt(2))||(s.charAt(1)==s.charAt(2)&&s.charAt(2)==s.charAt(3)))System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35560
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int a[200000],b[200000];
int main(){
	int n,m;cin>>n>>m;
	ll s1=0,s2=0;
	rep(i,n){
		cin>>a[i];
		s1+=a[i];
	}
	rep(i,m){
		cin>>b[i];
		s2+=b[i];
	}
	cout<<s1*s2<<endl;
}


Measured memory_bytes: 3908