akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

typedef unsigned long long int ulint;
typedef long long int lint;


ulint binary_search(ulint lower, ulint higher, bool (*func)(ulint)) {
  if (higher - lower == 1) {
    if ((*func)(lower)) {
      return lower;
    } else {
      return higher;
    }
  }
  
  ulint mid = (lower + higher) / 2;
  // cout << "lmh= " << lower << ", "  << mid << ", "  << higher << endl; 
  
  if ((*func)(mid)) {
    return binary_search(lower, mid, func);
  } else {
    return binary_search(mid, higher, func);
  }
}

// global
ulint N, K;

vector<ulint> A;
vector<ulint> F;


bool can_solve(ulint val) {
  ulint k_need = 0;
  for (int i = 0; i < N; ++i) {
    if (A[i] * F[i] > val) {
      ulint cost = (A[i] * F[i] - val - 1) / F[i] + 1;
      k_need += cost; 
    }
  }
  return (k_need <= K);
}

int main(){
  cin >> N >> K;
    
  for (ulint i = 0; i < N; ++i) {
    ulint a;
    cin >> a;
    A.push_back(a);
  }
  for (ulint i = 0; i < N; ++i) {
    ulint a;
    cin >> a;
    F.push_back(a);
  }
  
  // cout << F[0] << " " << F[1] << " " << F[2] << " " << endl;

  sort(A.begin(), A.end());
  sort(F.begin(), F.end(), greater<ulint>());

  // cout << F[0] << " " << F[1] << " " << F[2] << " " << endl;
  
  ulint val = binary_search(0, A[N-1] * F[0], can_solve);

  cout << val << endl;
}


Measured memory_bytes: 4848
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}

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

int main() {
    string s;
    cin >> s;
    if(s == "SUN") cout << 7 << endl;
    else if(s == "MON") cout << 6 << endl;
    else if(s == "TUE") cout << 5 << endl;
    else if(s == "WED") cout << 4 << endl;
    else if(s == "THU") cout << 3 << endl;
    else if(s == "FRI") cout << 2 << endl;
    else if(s == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

bool IsValid(const ll N, const ll M, const ll V, const ll P,
	     const vector<ll> &A, int i) {
  if (A[P - 1] <= A[i] + M) {
    ll sum = 0;
    for (int j = P - 1; j < i; ++j) {
      sum += (A[i] + M) - A[j];
    }
    int X = P - 1;
    int Y = N - 1 - i;
    if (M * (V - (X + Y + 1)) <= sum) {
      return true;
    } else {
      return false;
    }
  } else {
    return false;
  }
}

int main() {
  ll N, M, V, P;
  cin >> N >> M >> V >> P;
  
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());

  if (IsValid(N, M, V, P, A, N - 1)) {
    cout << N << endl;
    return 0;
  }

  int p = 0;
  int q = N - 1;

  while (p + 1 < q) {
    int m = (p + q) / 2;
    if (IsValid(N, M, V, P, A, m)) {
      p = m;
    } else {
      q = m;
    }
  }

  cout << p + 1 << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define aint(v) v.begin(), v.end()
using P = pair<int, int>;
constexpr int mod = 1000000007;

class mint {
public:
    int x;
    constexpr mint(long long x=0) : x((x % mod + mod) % mod) {}
    constexpr mint operator-() const { 
      return mint(-x);
    }
    constexpr mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(int t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    constexpr mint inv() const {
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& a){
        os << a.x;
        return os;
    }
};

signed main() {

    int n, k;
    cin >> n >> k;
    
    mint ans = 0;
    REP(i, k, n+2){
        mint mn(i*(i-1)/2);
        mint mx(i*(2*n-i+1)/2);
        ans += mx - mn + 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define Q 1000000007

// ll white, black;
// vector<vector<char>> c(h, vector<char>(w));
// ll ans = 0;
// vector<ll> a(N);
// const int M = 2;
// void dfs(vector<int> &A) {
//     // 終端条件 --- 10 重ループまで回したら処理して打ち切り
    

//     if(A.size() == h+w){
//       // rep(i, A.size()) cout << A[i];
//       // cout << " ";
//       vector<vector<char>> tmp(h, vector<char>(w));
//       rep(i, h){
//         rep(j, w) tmp[i][j] = c[i][j];
//       }
//       ll cnt = black;
//       for(ll i = 0; i < h; i++){
//         if(A[i] == 1){
//           // cout << i << " ";
//           rep(j, w){
//             if(tmp[i][j] == '#'){
//               tmp[i][j] = 'r';
//               cnt--;
//             }
//           }
//         }
//       }
//       for(ll i = h; i < h+w; i++){
//         if(A[i] == 1){
//           // cout << i << " ";
//           rep(j, h){
//             if(tmp[j][i-h] == '#'){
//               tmp[j][i-h] = 'r';
//               cnt--;
//             }
//           }
//         }
//       }

//       // cout << cnt << endl;
//       if(cnt == k) ans++;
      
//       return;
//     }

//     for (int v = 0; v < M; ++v) {
//         A.push_back(v);
//         dfs(A);
//         A.pop_back(); // これが結構ポイント
//     }
// }

int main(){
  
  ll n,x,t;
  cin >> n >> x >> t;
  if(n%x == 0) cout << n/x * t << endl;
  else  cout << (n/x + 1) * t << endl;
  


  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int ans = 0;
    rep(i, n) {
        if (s[i] == 'R') {
            int index = i + 1;
            if (index < n) {
                if (s[index] == 'R') {
                    ans++;
                }
            }
        }
        if (s[i] == 'L') {
            int index = i - 1;
            if (index >= 0) {
                if (s[index] == 'L') {
                    ans++;
                }
            }
        }
    }
    rep(i, k) {
        ans += 2;
        if (ans >= n - 1) {
            ans = n - 1;
            break;
        }
    }

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

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 512
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  h, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  w, _ := strconv.Atoi(sc.Text())

  sq := make([][]bool, h + 1)
  var mem [2001][2001][2]int

  for i := 0; i < h; i++ {
    sq[i] = make([]bool, w + 1)
    sq[i][w] = true
    sc.Scan()
    s := sc.Text()
    for j := 0; j < w; j++ {
      if s[j] == '#' {
        sq[i][j] = true
      }
    }
  }

  sq[h] = make([]bool, w + 1)
  for i := 0; i < w; i++ {
    sq[h][i] = true
  }


  for i := 0; i < h; i++ {
    base := 0
    for base < w {
      j := base
      for !sq[i][j] {
        j++
      }
      for k := base; k < j; k++ {
        mem[i][k][0] = j - base
      }
      base = j + 1
    }
  }

  for i := 0; i < w; i++ {
    base := 0
    for base < h {
      j := base
      for !sq[j][i] {
        j++
      }
      for k := base; k < j; k++ {
        mem[k][i][1] = j - base
      }
      base = j + 1
    }
  }

  max := 0
  for i := 0; i < h; i++ {
    for j := 0; j < w; j++ {
      if mem[i][j][0] + mem[i][j][1] > max {
        max = mem[i][j][0] + mem[i][j][1]
      }
    }
  }

  fmt.Println(max - 1)

}


Measured memory_bytes: 73088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
bool compare(pair<string,int> p1, pair<string,int> p2)
{
	if(p1.first!=p2.first)
	{
		return p1.first<p2.first;
	}
	return p2.second<p1.second;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<pair<string,int>> a;
	map<pair<string,int>,int> M;
	for(int i=0;i<n;i++)
	{
		string x;int y;
		cin >> x >> y;
		a.push_back(make_pair(x,y));
		M[make_pair(x,y)]=i+1;
	}
	sort(a.begin(),a.end(),compare);
	for(int i=0;i<n;i++)
	{
		cout << M[a[i]] << endl;
	}
	
	return 0;
}

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

#define int long long
string S;
int const M = 101;
int dp[M][5][2], K, D, N;
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> S; cin >> K;
    N = S.size();
    dp[N][K][0] = dp[N][K][1] = 1;
    for(int i = N - 1; i >= 0; i--){
        for(int k = K; k >= 0; k--, D = S[i] - '0'){
            for(int d = 1; d >= 0; d--){
                for(int j = (d) ? D : 9; j >= 0; j--){
                    dp[i][k][d] += dp[i + 1][min(4ll,k + (j > 0))][d & (j == D)];
                }
            }
        }
    }
    cout << dp[0][0][1] << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative

countDivision :: Integer -> [Integer] -> Integer
countDivision count a
  | all even a = countDivision (count+1) (map (\n -> n `quot` 2) a)
  | otherwise = count

main :: IO ()
main = do
  getLine
  a <- (map read . words) <$> getLine
  putStrLn $ show $ countDivision 0 a


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

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

  vector<int> v;
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    sum += i;
    v.push_back(i);

    if (sum >= n) {
      int x = sum - n;
      for (int i = 0; i < v.size(); ++i)
        if (v[i] != x)
          cout << v[i] << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 384
import math

n = int(input())

s0 = 2
t0 = a0 = 1
for i in range(n):
    t, a = map(int, input().split())

    m = max((t0 + t - 1) // t,
            (a0 + a - 1) // a)
    # m = max(math.ceil(t0 / t),
    #         math.ceil(a0 / a))

    t0, a0 = t * m, a * m
    s0 = t0 + a0
    # print(s0, t0, a0, m)

print(s0)


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  string s;
  cin >> n >> s;
  
  int ans = 0;
  for(int i = 2; i < n; i++){
    if(s[i - 2] == 'A' && s[i - 1] == 'B' && s[i] == 'C') ans++;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt(), b= scan.nextInt(),c=scan.nextInt();
		int []array=new int[a];
		for(int i=0;i<c;i++) {
			array[scan.nextInt()-1]++;
		}

		for(int i=0;i<a;i++) {
			if(b+array[i]-c>0) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}


	}
}

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


int main() {
  ll n ; 
  #ifndef TEST
  cin >> n ;
  #else
  n = 13 ;
  #endif

  cout << ( ( n - 1 ) * n / 2 ) << endl ; 
 
  return 0 ; 
}


Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b,x;
  cin >> a >> b >> x;

  cout << (a<=x && a+b>=x ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;

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;
}

struct UnionFind{
    int num;
    vector<int> par,rank;
    UnionFind(int n):num(n),par(n),rank(n,1){
        iota(par.begin(),par.end(),0);
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    bool merge(int x, int y){
        x=root(x),y=root(y);
        if (x==y) return false;
        if (rank[x]<rank[y]) swap(x,y);
        par[y]=x;
        rank[x]+=rank[y];
        --num;
        return true;
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    int size(int x){
        return rank[root(x)];
    }
    int count(){
        return num;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,K; cin >> N >> M >> K;
    UnionFind uf(N);
    vector<int> direct(N,0),block(N,0);
    rep(i,M){
        int A,B; cin >> A >> B;
        uf.merge(--A,--B);
        ++direct[A],++direct[B];
    }
    rep(i,K){
        int C,D; cin >> C >> D; --C,--D;
        if (uf.same(C,D)) ++block[C],++block[D];
    }
    rep(i,N) cout << uf.size(i)-direct[i]-block[i]-1 << (i!=N-1?' ':'\n');
}

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

int partition(int A[],int p,int r){
    int x = A[r];
    int i = p;
    int temp;
    for(int j = p; j<r ; j++){
        if(A[j] <= x){
            temp = A[j];
            A[j] = A[i];
            A[i] = temp;
            i++;
        }
    }
    temp = A[i];
    A[i] = A[r];
    A[r] = temp;
    return i;
}

int main(){
    int n,r;
    cin >> n;
    int A[n];
    for(int i=0; i<n; i++) cin >> A[i];

    r = partition(A,0,n-1);

    for(int i=0; i<n; i++){
        if(i == r){
            cout << "[" << A[i] << "]";
        }else{
            cout << A[i];
        }
        if(i != n-1) cout << " ";
    }
    cout << endl;
    
}


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

int main() {
    char c;
    cin >> c;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long  ll;

const int MAX_N = 110;
ll dp[MAX_N][21];
int d[MAX_N];

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

    for (int i = 0; i < N; ++i)
        cin >> d[i];

    dp[0][d[0]] = 1;
    for (int i = 0; i < N - 1; ++i) {
        for (int sum = 0; sum <= 20; ++sum) {
            if (sum + d[i + 1] <= 20)
                dp[i + 1][sum + d[i + 1]] += dp[i][sum];
            if (sum - d[i + 1] >= 0)
                dp[i + 1][sum - d[i + 1]] += dp[i][sum];
        }
    }

    cout << dp[N - 2][d[N - 1]] << endl;

    return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
int n, r, Q; vector<int> a(50), b(50), c(50), d(50); long ans;
void DFS(vector<int> A){
  int l=A.size();
  if(l==r){ 
    long now=0;
    for(int i=0; i<Q; i++){ if(A[b[i]]-A[a[i]]==c[i]){ now+=d[i]; } }
    ans=max(ans, now); return;
  }
  for(A.push_back((l)?A.back():0); A.back()<n; A.back()++){ DFS(A); }
}
int main(){
int N, M; cin >> N >> M >> Q; n=M; r=N;
for(int i=0; i<Q; i++){ cin >> a[i] >> b[i] >> c[i] >> d[i]; a[i]--; b[i]--;  }
DFS({});
cout << ans << "\n";
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        Integer s = sc.nextInt();
        Integer preI = s / 100;
        Integer endI = s % 100;
        boolean isPrePossibleM = 1 <= preI && preI <=12;
        boolean isEndPossibleM = 1 <= endI && endI <=12;
        if (isPrePossibleM) {
            if (isEndPossibleM) {
                System.out.println("AMBIGUOUS");
            } else {
                System.out.println("MMYY");
            }
        } else {
            if (isEndPossibleM) {
                System.out.println("YYMM");
            } else {
                System.out.println("NA");
            }
        }
    }
}

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

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))


using namespace std;


typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 
typedef long double LD;


int A, B, C, D, E, F;
int res1, res2;

int main(){
	cin>>A>>B>>C>>D>>E>>F;
	if(C<D) swap(C,D);
	ii ratio = ii(0, 1);
	res1 = 100*A;
	res2 = 0;
	for(int x=0; 100*x*A<=F ; ++x) for(int y=0; y*B<=F-100*x*A;++y){
		int wt = x*A + y*B;
		int upper = min(E*wt, F - 100*wt);
		int ms = 0;
		for(int z=0;z*C<=upper;++z){
			int w = (upper-z*C)/D;
			ms = max(ms, w*D + z*C);
		}
		if(ratio.first * wt < ratio.second * ms){
			ratio = ii(ms, wt);
			res1 = ms + wt*100;
			res2 = ms;
		}
	}
	cout<<res1<<' '<<res2;
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long int64;
typedef pair<int64, int64> pll;

const int INF = 0x3f3f3f3f;

const int MAX_N = 200000;


int A[MAX_N+1];
int tmp[MAX_N+1];

int solve(int64 N,int64 K){
	int v = 1;
	while(K){
		if(K&1)	v = A[v];

		K /= 2;
		for (int i = 1; i <= N; ++i)
			tmp[i] = A[A[i]];
		for (int i = 1; i <= N; ++i)
			A[i] = tmp[i];
	}
	return v;
}

int main(){
	int64 N,K;	scanf("%lld%lld",&N,&K);
	for (int i = 1; i <= N; ++i)	scanf("%d",A+i);
	int ans = solve(N,K);
	printf("%d\n",ans);
}



Measured memory_bytes: 4788
#include <iostream>
#include <vector>

using namespace std;

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

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

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == i + 1) {
			ans++;
			swap(a[i], a[i + 1]);
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

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

int main(){
	int n; cin >> n;
	vector<int> h(n);
	forn(i, n){
		cin >> h[i];
	}
	int cont = 0;
	for(int i=n-1;i>=0;i--){
		int flag = 0;
		for(int j=0;j<i;j++){
			if(h[j] > h[i]){
				flag = 1;
				break;
			}
		}
		if(!flag) cont++;
	}
	cout << cont << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

LL H,W;

LL get_ans(LL H, LL W){
    LL a,b=W/2; LL res=(1LL<<60);
    for (a=1; a<H; a++){

        res=min(res,max({abs(a*W-(H-a)*b),abs(a*W-(H-a)*(W-b)),abs((H-a)*b-(H-a)*(W-b))}));
    }
    return res;
}

int main(){
    cin >> H >> W;

    LL res=(1LL<<60);
    if (H%3==0 || W%3==0) res=0;
    if (H>2) res=min(res,W);
    if (W>2) res=min(res,H);
    res=min(res,get_ans(H,W));
    res=min(res,get_ans(W,H));
    cout << res << "\n";



    return 0;
}


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

int main(){
  string S,T,S_min="";
  cin >>S>>T;
  string S_ans=S;
  int flag;
  bool OK=false;
  
  for(int i=0; i<S.size()-T.size()+1; i++){
    flag=0;
    for(int j=0; j<T.size();j++){
      if(S[i+j]=='?')flag+=1;
      else if(S[i+j]==T[j])flag+=1;
    }
    
    if(flag==T.size()){
      OK=true;
    
      for(int k=0;k<S.size();k++){
        if(S[k]=='?')S_ans[k]='a'; 
      }
	 
      for(int j=0;j<T.size();j++) S_ans[i+j]=T[j];
      
      if(S_min=="")S_min=S_ans;
      else S_min=min(S_min,S_ans);
 
    }
  }
  
  if(OK==false)S_min="UNRESTORABLE";
  cout<< S_min<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define scan(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define scan1(a,n) for(int i=0;i<n;i++){  int z; cin>>z; a.pb(z);}
#define print(a) for(int i=0;i<a.size();i++){    cout<<a[i]<<" " ;}
#define for1(i,n) for(int i=0;i<n;i++)
#define pi 6.28318530717958623200
int main() 
{
    int r;
    cin>>r;
    cout << std::fixed;
    cout << std::setprecision(20);
	cout<<(double)pi*r<<endl;
 	return 0;
} 

Measured memory_bytes: 3736
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
#define int ll

ll n;
vector<pair<ll, ll> > g[500000];
ll ans[500000];

void run(int v, ll d)
{
    if (ans[v] != -1)
    {
        return;
    }
    ans[v] = d;
    for (int i = 0; i < g[v].size(); i++)
    {
        int u = g[v][i].first;
        run(u, g[v][i].second + d);
    }
}

signed main()
{
    fill(ans, ans + 500000, -1);
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
    }
    run(1, 0);
    for (int j = 1; j <= n; j++)
    {
        cout << ans[j] % 2 << "\n";
    }
}


Measured memory_bytes: 22784
S = input()
Q = int(input())
query = [list(input().split()) for _ in range(Q)]
revflag = 0
before = ""
after = ""

for i in query:
    if i[0] == '1':
        revflag = 1 - revflag
    else:
        if (revflag == 0 and i[1] == '1') or (revflag == 1 and i[1] == '2'):
            before += i[2]
        else:
            after += i[2]

if revflag == 0:
    print(before[::-1]+S+after)
else:
    print(after[::-1]+S[::-1]+before)

Measured memory_bytes: 30964
#include<bits/stdc++.h>
using namespace std;
const int N = 1000000+ 10;
int arr[N];
const double eps = 1e-10;
char s[N], x[N], ans[N];
int cnt1[30], cnt2[30];
pair<int, int> p[N];
int cmp(char a, char b)
{
    return a>b;

}
int main()
{
    int n;
    long long m;
    scanf("%d%lld", &n, &m);
    for(int i = 0; i<n; i++)
    {
        scanf("%d%d", &p[i].first, &p[i].second);
    }
    sort(p, p+n);
    for(int i = 0; i<n; i++)
        if(m>p[i].second)
            m -= p[i].second;
        else
        {
            cout<<p[i].first<<endl;
            break;
        }
    return 0;
}


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

from collections import defaultdict
M = 200001
N = int(input())
F = []
X = [[] for _ in range(M)] #上向きのy座標, 下向きのy座標
Y = [[] for _ in range(M)]

S1 = defaultdict(list) #x+yが一致
S2 = defaultdict(list)
T1 = defaultdict(list)
T2 = defaultdict(list)

for _ in range(N):
    x, y, c = input().split()
    x = int(x)
    y = int(y)
    if c == 'U':
        c = 0
        S1[x + y].append((x - y, c))
        T1[x - y].append((x + y, c))
    elif c == 'R':
        c = 1
        S1[x + y].append((x - y, c))
        T2[x - y].append((x + y, c))
    elif c == 'D':
        c = 2
        S2[x + y].append((x - y, c))
        T2[x - y].append((x + y, c))
    else:
        c = 3
        S2[x + y].append((x - y, c))
        T1[x - y].append((x + y, c))
    if c % 2 == 0:
        X[x].append((y, c))
    else:
        Y[y].append((x, c))

res = 10**18

for i in range(M):
    X[i].sort()
    tmp = None
    for j in range(len(X[i])):
        y, c = X[i][j]
        if c == 0:
            tmp = y
        if c == 2:
            if tmp is not None:
                res = min(res, (y - tmp) * 5)

for i in range(M):
    Y[i].sort()
    tmp = None
    for j in range(len(Y[i])):
        x, c = Y[i][j]
        if c == 1:
            tmp = x
        if c == 3:
            if tmp is not None:
                res = min(res, (x - tmp) * 5)

for k, v in S1.items():
    v.sort()
    tmp = None
    for j in range(len(v)):
        z, c = v[j]
        if c == 1:
            tmp = z
        if c == 0:
            if tmp is not None:
                res = min(res, (z - tmp) * 5)

for k, v in S2.items():
    v.sort()
    tmp = None
    for j in range(len(v)):
        z, c = v[j]
        if c == 2:
            tmp = z
        if c == 3:
            if tmp is not None:
                res = min(res, (z - tmp) * 5)

for k, v in T1.items():
    v.sort()
    tmp = None
    for j in range(len(v)):
        z, c = v[j]
        if c == 0:
            tmp = z
        if c == 3:
            if tmp is not None:
                res = min(res, (z - tmp) * 5)

for k, v in T2.items():
    v.sort()
    tmp = None
    for j in range(len(v)):
        z, c = v[j]
        if c == 1:
            tmp = z
        if c == 2:
            if tmp is not None:
                res = min(res, (z - tmp) * 5)

print(res if res != 10**18 else 'SAFE')

Measured memory_bytes: 190648
N,K,C=map(int,input().split())
S=input()
l=[None]*N
c=0
t=0
while c<K:
    if S[t]=="o":
        l[t]=c
        c+=1
        t+=C+1
    else:
        t+=1
t=N-1
a=[]
while c:
    if S[t]=="o":
        c-=1
        if c==l[t]:
            a.append(t+1)
        t-=C+1
    else:
        t-=1
print(*a[::-1],sep="\n")

Measured memory_bytes: 23852
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n,m = LI()
    if n >= m//2:
        return m//2
    r = n
    m -= 2*n
    r += m//4

    return r

print(main())


Measured memory_bytes: 7704
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m,h;
           
        while(true){
            String c = sc.next();
            if(c.equals("-"))
                break;
               
            m = sc.nextInt();
            for(int i=0;i<m;i++){
                h = sc.nextInt();
                String head=c.substring(0,h);
                String tail=c.substring(h);
                c=tail + head;
            }
            System.out.println(c);
        }
    }
}


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

int main() {

  int N;
  cin >> N;

  vector<pair<string, int>> SP(N);
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    int P;
    cin >> P;
    P = 100 - P;
    if (P < 10) {
      SP[i].first = S + "00" + to_string(P);
    } else if(P < 100) {
      SP[i].first = S + "0" + to_string(P);
    } else {
      SP[i].first = S + to_string(P);
    }
    SP[i].second = i + 1;
  }

  sort(SP.begin(), SP.end());

  for (int i = 0; i < N; i++) {
    cout << SP[i].second << endl;
  }

}

Measured memory_bytes: 256
/* 
 * Author: pawanmsr
 */

// #include <iostream>
// #include <iomanip>
// #include <string>
// #include <vector>
// #include <algorithm>
// #include <queue>
// #include <deque>
// #include <bitset>
// #include <iterator>
// #include <list>
// #include <stack>
// #include <map>
// #include <set>
// #include <functional>
// #include <numeric>
// #include <utility>
// #include <limits>
// #include <fstream>
// #include <cstring>

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

// Macro //
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>

// Global //
string s;

// Functions //


// Main //
int main(int argc, char const *argv[])
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    
    /* code */
    cin >> s;
    if (s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;

int main() {
    ll x, y;
    cin >> x >> y;

    int cnt = 0;
    while(x <= y){
        x *= 2;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 888
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (!n) return 0;
    int is[10];
    fill(is, is+10, 0);
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      is[x]++;
    }
    for (int i = 0; i <= 9; i++) {
      if (is[i])
        for (int j = 0; j < is[i]; j++)
          cout << '*';
      else
        cout << '-';
      cout << endl;
    }
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	int n,count=0;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	while(1){
		for(int i = 0; i < n; i++){
			if(a[i]%2!=0){
				cout <<count <<endl;
				return 0;
			}
			a[i] = a[i]/2;
			if(a[i]==0){
				cout << count <<endl;
				return 0;
			}
		}
		count++;
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC161C
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = RLong;
            long K = RLong;

            long cand1 = N % K;
            long cand2 = (K - cand1) % K;

            long ans = Math.Min(cand1, cand2);
            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 27764
using System;
class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            string[] data = Console.ReadLine().Split(' ');
            int n = int.Parse(data[0]);
            int m = int.Parse(data[1]);
            if (n == 0 && m == 0) break;

            int count = 0;
            for (int i = 1,icount = n-2; i <= icount; i++)
            {
                for (int j = i + 1,jcount = n-1; j <= jcount; j++)
                {
                    for (int k = j + 1; k <= n; k++)
                    {
                        if (i + j + k == m)
                        {
                            count++;
                        }
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  cin >> n >> k;
  vl h(n);
  rep(i, n) cin >> h[i];
  sort(all(h));
  ll ans = 1e9;
  rep(i, n - k + 1) {
    ll d = h[i + k - 1] - h[i];
    ans = min(ans, d);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void)
{
  int H, W;
  cin >> H >> W;
  while (!(0 == H && 0 == W)) {
    REP(i, H) {
      REP(j, W) {
        cout << '#';
      }
      cout << '\n';
    }
    cout << '\n';
    cin >> H >> W;
  }
}



Measured memory_bytes: 3036
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>

using namespace std;
typedef long long ll ;
int main(){
  ll n;
  ll m;
  cin >> m;
  cin >> n;
  vector<int> tmp(n);
  for(int i=0;i<n;i++){
    cin >> tmp[i];
  }
  for(int i=m;1;i++){
    int buf = i;
    bool flag=true;
    while(buf){
      for(int j=0;j<n;j++){
        if(buf%10==tmp[j])flag=false;
      }
      buf/=10;
    }
    if(flag){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {

  double Pi = 3.1415926535897;
  double r;
  cin >> r;
  
  double ans1 = Pi * r * r;
  double ans2 = 2 * Pi * r;
  
  cout << fixed << setprecision(5);
  cout << ans1 << " " << ans2 << endl;
}


Measured memory_bytes: 3264
import sys

sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque


'''
dp[i][j]...(0,0)からスタートして(i,j)に到達する経路のなかでの最大の価値
dp[i][j]=max(dp[i][j-1],dp[i-1][j]) + v[i][j]


dp[i][j][k] ... (0,0)からスタートして(i,j)に到達する経路のなかでi行目ですでにk(以下)個選んでいるときの最大の価値

遷移は、i,jのvを拾うときと拾わないときのmax
dp[i][j][k] = max(dp[i][j-1][k-1]+V[i,j], dp[i][j-1][k]
                  ) #k個のままのほうが価値が高いかk-1から拾ったほうが価値が高いか

上からの遷移 # 拾うか拾わないかでこうかな
dp[i][j][0]=max(dp[i][j-1][0],max_k(dp[i-1][j]))
dp[i][j][1]=max(dp[i][j-1][0],max_k(dp[i-1][j][k])+V[i][j])
'''

R, C, K = ints()
RCV = read_tuple(K)
V = [[0] * C for _ in ra(R)]
for r, c, v in RCV:
    V[r - 1][c - 1] = v

# dp = [[[0] * 4 for _ in ra(C)] for _ in ra(R)]
dp0 = [[0] * C for _ in ra(R)]
dp1 = [[0] * C for _ in ra(R)]
dp2 = [[0] * C for _ in ra(R)]
dp3 = [[0] * C for _ in ra(R)]

# dp[0][0][0] = 0
dp1[0][0] = V[0][0]
dp2[0][0] = V[0][0]
dp3[0][0] = V[0][0]

for j in ra(1, C):
    dp1[0][j] = max(dp1[0][j - 1], dp0[0][j - 1] + V[0][j])
    dp2[0][j] = max(dp2[0][j - 1], dp1[0][j - 1] + V[0][j])
    dp3[0][j] = max(dp3[0][j - 1], dp2[0][j - 1] + V[0][j])

for i in ra(1, R):
    dp0[i][0] = dp1[i - 1][0]
    dp1[i][0] = dp0[i][0] + V[i][0]
    # dp2[i][0] = dp0[i][0] + V[i][0]
    # dp3[i][0] = dp0[i][0] + V[i][0]


for i in ra(1, R):
    for j in ra(1, C):
        ma = max(dp0[i - 1][j],
                 dp1[i - 1][j],
                 dp2[i - 1][j],
                 dp3[i - 1][j])

        dp0[i][j] = max(dp0[i][j - 1],  # 左
                        ma)  # 上

        dp1[i][j] = max(dp0[i][j - 1] + V[i][j],  # 左から来て拾う
                        dp1[i][j - 1],  # 拾わないほうが大きい場合もある
                        ma + V[i][j])  # 上から来て拾う

        dp2[i][j] = max(dp1[i][j - 1] + V[i][j], dp2[i][j - 1])
        dp3[i][j] = max(dp2[i][j - 1] + V[i][j], dp3[i][j - 1])


print(max(dp0[R - 1][C - 1],
          dp1[R - 1][C - 1],
          dp2[R - 1][C - 1],
          dp3[R - 1][C - 1],
          ))

# print(*values, sep='\n')
# print(*dp, sep='\n')

# dp2 = [[-1] * C for _ in ra(R)]
# for i in ra(R):
#     for j in ra(C):
#         dp2[i][j] = max(dp[i][j])
# print(*dp2, sep='\n')


Measured memory_bytes: 458796
N = parse(Int,readline())

if N%10 == 2 || N%10 ==4 || N%10==5 || N%10==7||N%10==9
        println("hon")
elseif N%10 == 0 || N%10==1 || N%10==6||N%10==8
        println("pon")
else
        println("bon")
end


Measured memory_bytes: 152136
#include<stdio.h>

int main(){
  int x,a,b,hoge,foo;
  scanf("%d %d %d",&x,&a,&b);
  if(x>a){
    hoge=x-a;
  }else{
    hoge=a-x;
  }
  if(x>b){
    foo=x-b;
  }else{
    foo=b-x;
  }
  if(hoge<foo){
    printf("A\n");
  }else if(foo<hoge){
    printf("B\n");
  }
  return(0);
}


Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

using namespace std;
using ll=long long;

void solve(){
  int num;
  cin >> num;
  vector<int> ar(num);
  for(int i=0;i<num;i++)
    cin >> ar[i];
  vector<int> dp(num);
  dp[0]=0;
  dp[1]=abs(ar[1]-ar[0]);
  for(int i=2;i<num;i++)
    dp[i]=min(dp[i-2]+abs(ar[i]-ar[i-2]),dp[i-1]+abs(ar[i]-ar[i-1]));
  cout << dp[num-1] << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 1024
var s1,s2:ansistring;
c:array['a'..'z']of 0..1;
f:array['a'..'z']of 'a'..'z';
i:longint;
begin 
	readln(s1);
	readln(s2);
	fillchar(c,sizeof(c),0);
	for i:=1 to length(s1) do
	begin 
		if c[s1[i]]=0 then 
		begin 
			f[s1[i]]:=s2[i];
			c[s1[i]]:=1;
		end
		else if s2[i]<>f[s1[i]] then begin write('No');halt;end;
	end;
	fillchar(c,sizeof(c),0);
	for i:=1 to length(s1) do
	begin 
		if c[s2[i]]=0 then 
		begin 
			f[s2[i]]:=s1[i];
			c[s2[i]]:=1;
		end
		else if s1[i]<>f[s2[i]] then begin write('No');halt;end;
	end;
	write('Yes');
end.


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

int main(){
	int h, w;
	string s[26][26];
	cin >> h >> w;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			cin >> s[i][j];
		}
	}
	for(int i = 0;i < h;i++){
		char c = 'A';
		for(int j = 0;j < w;j++){
			if(s[i][j] == "snuke"){
				cout << c << i+1 << endl;
			}
			c++;
		}
	}
	return 0;
}

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

int main()
{
    int n, x, y;
    cin >> n >> x >> y;
    int ara[n+1];
    memset(ara,0,sizeof(ara));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            ara[min(j-i,abs(x-i) + 1 + abs(j-y))]++;
        }
    }
    for (int i = 1; i < n; i++) {
        cout << ara[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0642



#include<iostream>
 using namespace std; //標準名前空間を使用


    int main(){

    int sugorokunomasu[110] ;
    int N ;
    int saidairenzokusuucount = 0 ; // 1の最大連続数カウント
    int saidairenzokusuucountmax = 0 ; // 1の最大連続数の最大値

    cin >> N ;


            for (int i = 1 ; i <= N ; i = i + 1 ){
             cin >> sugorokunomasu[i] ; //すごろくのマスの読み込み

                    if(sugorokunomasu[i] == 1){ // すごろくのマスに1が出てきた場合

                        saidairenzokusuucount =  saidairenzokusuucount + 1 ; //そうでなければ、1の最大連続数カウントに1を+


                        // 1の最大連続数の最大値を更新されているかの判定
                        if(saidairenzokusuucount > saidairenzokusuucountmax) 
                        { 
                        saidairenzokusuucountmax = saidairenzokusuucount ; //更新されていれば、1の最大連続数の最大値を更新
                        }else{
                        //最大値を更新しない場合は何もしない
                        }
                        


                    }else{ //すごろくのマスに0が出てきた場合

                        // 1の最大連続数の最大値を更新されているかの判定
                        if(saidairenzokusuucount > saidairenzokusuucountmax) 
                        { 
                        saidairenzokusuucountmax = saidairenzokusuucount ; //更新されていれば、1の最大連続数の最大値を更新
                        saidairenzokusuucount = 0 ; //1の最大連続数カウントをフラッシュして0に
                        }else{
                        //最大値を更新しない場合は何もしない
                        saidairenzokusuucount = 0 ; //1の最大連続数カウントをフラッシュして0に
                        }

                    
                    
                    }

                


            }


    cout << saidairenzokusuucountmax + 1 << endl ;

    /* デバッグ用
    cout << sugorokunomasu[1] ;
    cout << sugorokunomasu[2] ;
    cout << sugorokunomasu[3] ;
    cout << sugorokunomasu[4] ;
    cout << sugorokunomasu[5] ;
    */

    }       






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

int main() {
    map<int,int> m;
    int n,k;
    cin >> n>>k;
    ll sum=0;
    rep(i,k){
        int l;
        cin >> l;
        sum += l;
    }
    cout << (sum>=n? "Yes":"No") << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
 
    int n = sc.nextInt();
    int m = sc.nextInt();
    int k = sc.nextInt();


    System.out.println((n - m +1) * (n - k + 1));

 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 22356