akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int N, M , X, Y; cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  rep(i, N) cin >> x[i];
  rep(i, M) cin >> y[i];
  sort(all(x));
  sort(all(y));

  bool ok = false;
  REP(z, X+1, Y){
    if(x[N-1] < z && z <= y[0]){
      ok = true;
      break;
    }
  }

  cout << (ok ? "No War" : "War") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
 
int main()
{
    ll s,c;
    cin >> s >> c;
    if(2*s >= c) cout << c / 2 << endl;
    else cout << s + (c-2*s)/4 << endl;
    return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn calc(a: i64, b: i64) -> i64 {
    if a % 4 == 0 && b % 4 == 3 || a > b{
        0
    }
    else if a % 4 == 0{
        b ^ calc(a, b-1)
    }
    else {
        a ^ calc(a + 1, b)
    }
}

fn main() {
    let v: Vec<i64> = read_vec();
    let a: i64 = v[0];
    let b: i64 = v[1];
    println!("{}", calc(a, b));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h> 
using namespace std;
//関数
const long INF=1000000000000000;
const long MOD=1000000007;
bool check=false;


int main(void){
    string s;
    cin>>s;
    
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    if(s=="Cloudy") cout<<"Rainy"<<endl;
    if(s=="Rainy") cout<<"Sunny"<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
    int a, b, c;
    double rag;
    long double h, s, l;
 
    cin >> a >> b >> c;

    rag = (double)c * M_PI / 180.0;    

    h = (double)b * sin(rag);           // 高さ
    s = (double)(a * h) * 0.5;          // 面積
    double L = (double)a - (double)b * cos(rag);
    l = sqrt(L * L + h * h) + a + b;    // 長さ
 
    cout << setprecision(16) << s << endl;
    cout << setprecision(16) << l << endl;
    cout << setprecision(16) << h << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
 
 
void solve(){
	int n, k;
	cin >> n >> k;
	int p[n];
	rep(i, n){
		cin >> p[i];
	}
	sort(p, p + n);
	int mx = 1e9;
	rep(i, n - k + 1){
		mx = min(mx, p[i + k - 1] - p[i]);
	}
	cout << mx;
}
 
 
 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
typedef pair<int,int> Bug;
#define a second
#define b first
vector<Bug> bug;

int solve(int l,int r){
	if(l+1==r)return l;
	int k=(l+r)/2;
	ll sumA=0;
	priority_queue<int> pq;
	for(auto x:bug){
		sumA+=x.a;
		pq.push(x.a);
		if(pq.size()>k){
			sumA-=pq.top();
			pq.pop();
		}
		if(pq.size()==k && sumA<=(ll)k*x.b){
			return solve(k,r);
		}
	}
	return solve(l,k);
}

int main(void){
	int N;
	cin>>N;
	bug.resize(N);
	rep(i,N)cin>>bug[i].a>>bug[i].b;
	sort(bug.begin(),bug.end(),greater<Bug>());
	cout<<solve(0,N+1)<<endl;
	return 0;
}

Measured memory_bytes: 27972
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1001

ll nCm[NUM][NUM];

int main(){

	ll N,K;
	scanf("%lld %lld",&N,&K);

	if(N < K){
		printf("0\n");
		return 0;
	}

	nCm[0][0] = 1;
	for(int n = 1; n <= N; n++){
		for(int m = 0; m <= K; m++){

			if(n == 0){

				nCm[n][m] = 1;

			}else{

				nCm[n][m] = nCm[n-1][m]+nCm[n-1][m-1];

			}
			nCm[n][m] %= MOD;
		}
	}

	printf("%lld\n",nCm[N-1][K-1]);

	return 0;
}




Measured memory_bytes: 10984
n,x=map(int,input().split())
X=list(map(int,input().split()))
def gcd(a,b):
    if b==0:
        return(a)
    else:
        return(gcd(b,a%b))

if n==1:
    print(abs(X[0]-x))
else:
    ans=abs(X[0]-x)
    for i in range(1, n):
        ans=gcd(ans,abs(X[i]-x))
    print(ans)

Measured memory_bytes: 14252
#include<iostream>
#include<stdio.h>
using namespace std;

void trace(int A[], int n) {
  int i;
  for(i=0; i<n; i++) {
    if (i>0) {
      printf(" ");
    }
    printf("%d", A[i]);
  }
  printf("\n");
}

int bubbleSort(int A[], int n) {
  int i = 0;
  int flag = 1;
  int count = 0;
  while (flag) {
    flag = 0;
    for (int j=n-1; j>=i+1; j--) {
      if (A[j] < A[j-1]) {
        swap(A[j], A[j-1]);
        count += 1;
        flag = 1;
      }
    }
    i += 1;
  }
  return count;
}

int main() {
  int n;
  int A[100];
  int c;

  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    scanf("%d", &A[i]);
  }
  c = bubbleSort(A, n);
  trace(A, n);
  printf("%d\n", c);
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;


int main(void){

    int N,K; cin>>N>>K;
    vector<ll> h(N);
    for (int i = 0; i < N; ++i) {
        cin>>h[i];
    }
    sort(h.begin(),h.end());

    ll mini = h[K-1]-h[0];
    for (int i = 0; i <= N - K; ++i) {
        mini = min(mini, h[i+K-1]-h[i]);
    }
    cout<<mini<<endl;
    return 0;
}

Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
#define eb emplace_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define mp make_pair
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 1e5 + 100;
const int LOG = 21;
const int mod = 998244353;
const int MX = 1e3 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;

template<class T1, class T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &rhs) {
    out << "( " << rhs.first << " , " << rhs.second << " )";
    return out;
}

vector<int> g[MAXN];

int dp[MAXN];

int cnt[32];

void dfs(int v, int p) {
    for (int to:g[v]) {
        if (to == p)
            continue;
        dfs(to, v);
    }

    memset(cnt, 0, sizeof cnt);
    for (int to:g[v]) {
        if (to == p)
            continue;
        for (int i = 0; i < 30; ++i) {
            if (dp[to] & (1 << i)) {
                cnt[i]++;
            }
        }
    }
    int last = 0;
    for (int i = 0; i < 30; ++i) {
        if (cnt[i] > 1)
            last = i + 1;
    }
    for (int i = last; i < 30; ++i) {
        if (cnt[i] == 0) {
            last = i;
            break;
        } else {

        }
    }
    int res = (1 << last);
    for (int i = last + 1; i < 30; ++i) {
        if (cnt[i] > 0) {
            res = res | (1 << i);
        }
    }
    dp[v] = res;
}

void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(1, -1);
    int res = 0;
    for (int i = 0; i < 30; ++i) {
        if (dp[1] & (1 << i))
            res = i;
    }
    cout << res << endl;

}

signed main() {
#ifdef zxc
    debug = 1;
    // freopen("../input.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;
    while (t--)
        solve();
    if (debug)
        cerr << endl << "time : " << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 11776
# include <stdio.h>
# include <algorithm>
int a[1000000];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i = 0; i < n; i++)
			scanf("%d",&a[i]);
	int q;
	int k = 0;
	scanf("%d",&q);
	for (int i = 0; i < q; i++)
	{
		int num;
		scanf("%d",&num);
		if( *std::lower_bound(a,a+n-1,num) ==num )	k++;
	}
	printf("%d\n",k);
 } 


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int a, p; cin >> a >> p;
    a = a * 3 + p;
    int ans = a / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
result = 0

def check(i, K):
    count = 0
    while (K > i):
        i *= 2
        count += 1
    return count

for i in range(1,N+1):
    count = check(i, K)
    dec = 1
    for j in range(count):
        dec /= 2.0
    result += dec

print(round(result/N, 12))

Measured memory_bytes: 3060
X, N = map(int, input().split())

try:
  p = set(map(int, input().split()))
  num = set(range(-100,201))
  mem = []

  ref = sorted(list(num - p))

  for item in ref:
    mem.append(abs(item - X))
  
  print(ref[mem.index(min(mem))])

except EOFError:
  print(X)

Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define f first
#define s second
#define mk make_pair
#define int long long

using namespace std;

const int N = 1e5 + 5;

int w[N], v[N];
int dp[105][N];

int32_t main()
{
    ios::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int n, W;
    cin >> n >> W;
    for(int i = 1;i <= n; ++i)
    {
        cin >> w[i] >> v[i];
    }
    for(int i = 1;i <= n; ++i)
    {
        for(int j = 1;j <= W; ++j)
        {
            if(j - w[i] < 0)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max(dp[i-1][j], dp[i-1][j - w[i]] + v[i]);
        }
    }
    int ans = 0;
    for(int i = 1;i <= n; ++i)
    {
        ans = max(ans, dp[i][W]);
    }
    cout << ans;
}

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> fact;
	for(int i=1; i*i<=m; i++){
		if(m%i == 0){
			fact.push_back(i);
			fact.push_back(m/i);
		}
	}
	int ans = 1;
	for(int i: fact){
		if(m/i >= n){
			ans = max(ans, i);
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int i;
bool check(vector<int>&T){
  for(i = 0; i < T.size(); i++){
    if(T[i]!=i+1)return 0;
  }
  return 1;
}

int main(){
  int n;
  vector<int> B;
  for(i = 1; i < 200; i++){
    B.push_back(i*(i+1)/2);
  }
  while(cin >> n, n){
    vector<int> T;
    int temp;
    int total=0;
    for(i = 0; i < n; i++){
      cin >> temp;
      total += temp;
      T.push_back(temp);
    }
    int ans = -1;
    if(binary_search(B.begin(),B.end(),total)){
      for(n = 0; n <=10000; n++){
	if(check(T)){
	  ans = n;
	  break;
	}else{
	  int a = T.size();
	  for( i = 0; i < a; i++){
	    T[i]--;
	  }
	    T.erase(remove(T.begin(),T.end(),0),T.end());
	    T.push_back(a);
	}
      }
    }
    cout << ans << endl;
  }


  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string s,t;
    cin>>s>>t;
    int ans =0;
    rep(i,s.size()){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if (s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

// constexpr int INF = 1e9;
constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  map<ll, ll> mpp, mpm;
  REP(i, N){
    cin >> A[i];
    mpp[i+A[i]]++;
    mpm[i-A[i]]++;
  }
  ll ans = 0;
  for(auto pr : mpp){
    ans += pr.second * mpm[pr.first];
  }
  for(auto pr : mpm){
    ans += pr.second * mpp[pr.first];
  }
  cout << ans/2 << endl;
  return 0;
}


Measured memory_bytes: 49408
let a = read_int ()
let b = read_int ()


(* 
1 + 2 = 3
1 + 3 = 4
2 + 3 = 5
 *)
let _ = match a + b with
  | 3 -> print_endline "3"
  | 4 -> print_endline "2"
  | _ -> print_endline "1"

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int H, W;
    cin >> H >> W;
    vector<string> field(H);
    VECCIN(field);

    REP(h, H) {
        REP(w, W) {
            if (field[h][w] == '#')continue;
            int bomb = 0;
            FOR(i, -1, 2) {
                if (h + i < 0 || h + i >= H)continue;
                FOR(j, -1, 2) {
                    if (w + j < 0 || w + j >= W)continue;
                    if (field[h + i][w + j] == '#')bomb++;
                }
            }
            field[h][w] = bomb + '0';
        }
    }

    REP(h, H) {
        cout << field[h] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
S = gets.chomp.to_s
T = gets.chomp.to_s

sl = S.length
st = T.length
ans = 1000

if S.include?(T)
  ans = 0
else
  (0..sl-st).each do |i|
    count = 0
    (0...st).each do |j|
      if S[j+i] != T[j]
        count += 1
      end
    end
    if count < ans
      ans = count
    end
  end
end

puts ans

Measured memory_bytes: 14292
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	vector<vector<int>> pf(20,vector<int>(n));
	for(int i=0;i<n;++i){
		int x;
		cin>>x;
		if(i){
			for(int j=0;j<20;++j) 
				pf[j][i]=pf[j][i-1];
		}
		for(int j=0;j<20;++j)
			if(x>>j&1) pf[j][i]++;
	}
	ll res=0;
	for(int i=0;i<n;++i){
		int l=0,r=i;
		while(l<=r){
			int m=(l+r)>>1;
			bool ok=true;
			for(int j=0;j<20;++j)
				if(pf[j][i]-(m?pf[j][m-1]:0)>1) ok=false;
			if(!ok) l=m+1;
			else r=m-1;
		}
		res+=i-l+1;
	}
	cout<<res<<'\n';
}




Measured memory_bytes: 19804
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;

ll N = 1e5 + 10;
vector<vector<ll>> adj(N);
vector<ll> visit(N);
vector<ll> length(N);
vector<ll> nodeDegree(N);

void dfs(ll i)
{
    visit[i] = 1;
    for (auto j = 0; j < adj[i].size(); j++)
    {
        nodeDegree[adj[i][j]]--;
        length[adj[i][j]] = max(length[i] + 1, length[adj[i][j]]);

        if (nodeDegree[adj[i][j]] == 0)
            dfs(adj[i][j]);
    }
}

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

    ll n, m, i, j, t1, t2, maxl = 0;
    cin >> n >> m;
    for (i = 0; i < m; i++)
    {
        cin >> t1 >> t2;
        adj[t1].pb(t2);
        nodeDegree[t2]++;
    }

    for (i = 1; i <= n; i++)
    {
        if (!visit[i] && nodeDegree[i] == 0)
            dfs(i);
    }

    for (i = 1; i <= n; i++)
    {
        maxl = max(maxl, length[i]);
    }

    cout << maxl << "\n";

    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};



int main()
{
	int n;
	cin >> n;
	vector<pair<string,int>> v,tmp;
	for(int i = 0; i < n; i++){
		int p; string s;
		cin >> s >> p;
		v.emplace_back(s,p);
	}
	tmp = v;

	for(int i = 0; i < n-1; i++){
		for(int j = n-1; j > i; j--){
			if(v[j-1].second < v[j].second){
				swap(v[j-1],v[j]);
			}
		}
	}

	for(int i = 0; i < n-1; i++){
		for(int j = n-1; j > i; j--){
			if(v[j-1].first > v[j].first){
				swap(v[j-1],v[j]);
			}
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(v[i] == tmp[j]) cout << j+1 << endl;
		}
	}

	return 0;
}


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

int main(){
	// sengen
	int d;
	// nyuryoku
	cin >> d;
	// keisan
	if(d == 25){
		cout << "Christmas" << endl;
	}else if(d == 24){
		cout << "Christmas Eve" << endl;
	}else if(d == 23){
		cout << "Christmas Eve Eve" << endl;
	}else{
		cout << "Christmas Eve Eve Eve" << endl;
	}
	// syutsuryoku
}

Measured memory_bytes: 3488
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

//modでの累乗(繰り返し二乗法)
ll modpow(ll x, ll y, ll m)
{
    if (y == 0)
        return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}

//modでの割り算
ll modinv(ll x, ll m) { return modpow(x, m - 2, m); }

//modでの安全な引き算
ll modsub(ll x, ll y, ll m){ return(x + m - y) % m; }

//乗算により二項係数を求める
ll binom(ll n, ll k, ll m)
{
    ll den = 1, num = 1;
    for (int i = 1; i <= k; ++i){
        den *= i;
        num *= (n + 1 - i);
        den %= m;
        num %= m;
    }
    return num * modinv(den,m);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, K;
    cin >> N >> K;
    vec2 f(N + 1, vec(K + 1, 0));
    rep(i, N + 1) f[i][0] = 1;
    rep1(i, N){
        ll a;
        cin >> a;
        rep1(j, K){
            f[i][j] = (f[i][j - 1] + f[i - 1][j]) % MOD;
            if(j -a - 1 >= 0) f[i][j] = modsub(f[i][j], f[i - 1][j - a - 1], MOD);
        }
    }

    print(f[N][K]);

    return 0;
}

Measured memory_bytes: 80256
n = int(input())

INF = 10**10
dp = [INF] * (n + 1)
dp[0] = 0
dp[1] = 1

num_list = [1]

for i in range(1, 9):
    n1 = 6**i
    n2 = 9**i
    if n1 <= n:
        num_list.append(n1)
    if n2 <= n:
        num_list.append(n2)

for i in range(0, n):
    for j in num_list:
        if i + j <= n:
            dp[i+j] = min(dp[i+j], dp[i] + 1)

print(dp[n])



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

int main() {
	string str; cin >> str;
  	int l = 0, r = str.length() - 1;
  	int cnt = 0;
  	for(; l < r; l++, r--) {
    	if(str[l] != str[r]) cnt++;
    }
  	cout << cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
using namespace std;
int main(){   
   int n;
   cin>>n;
   vector<int> p(n);
   int count=0;
   int x=100000000;
   for (int i = 0; i < n; i++)
   {
    int a;
    cin>>a;
    p[i]=a;
    int flag=0;
    if(x<a) flag=1;    
    if(flag==0) count++;
    x=min(x,a);
   }
   cout<<count;
   return 0;
}


Measured memory_bytes: 1024
s = list(input())
n = len(s)
ans = []
for i in range(2**(n-1)):
    a = 0
    b = 0
    for j in range(n):
        s[j] = int(s[j])
        b *=10
        if ((i>>j)&1):
            a = a+b+s[j]
            b = 0
        else:
            b+=s[j]
    a+=b
    ans.append(a)
print(sum(ans))

Measured memory_bytes: 3064
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if (b%a==0) {
      System.out.println(a+b);
    }else{
      System.out.println(b-a);
    }
  }
}


Measured memory_bytes: 21844
using System;
using System.Linq;

namespace aizu
{
    public class OnlineJudge
    {
        static void Main()
        {
            string input;
            while((input = Console.ReadLine()) != "END OF INPUT"){
                Console.WriteLine(string.Join("", input.Split().Select(p => p.Length).Select(p => p.ToString()).ToArray()));
            }
        }
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  ll n,m,x,y;
  cin>>n>>m>>x>>y;

  ll a[n+2],b[m+2];

  a[0]=x;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
  }

  b[0]=y;
  for(int i=1;i<=m;i++)
  {
    cin>>b[i];
  }

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

  if(a[n]<b[0])
    cout<<"No War\n";
  else
    cout<<"War\n";

}

int main()
{
    su;
    f();
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <math.h>
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int a[50][2], c[50][2];
	for(int i = 0;i<n;i++){
		cin >> a[i][0] >> a[i][1];
	}
	for(int i = 0;i<m;i++){
		cin >> c[i][0] >> c[i][1];
	}
	for(int i = 0;i<n;i++){
		long long int max = 500000000;
		int ans = -1;
		for(int j = 0;j<m;j++){
			if(abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]) < max){
				ans = j + 1;
				max = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

//Ford-Fulkerson(O(FE))
const int MAX_V=20010;
const int INF=10000;

struct edge{int to, cap, rev; };
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].pb(edge{to, cap, sz(G[to])});
    G[to].pb(edge{from, 0, sz(G[from])-1});
}

int dfs(int v, int t, int f){
    if(v==t) return f;
    used[v]=true;
    for(edge &e : G[v]){
        if(!used[e.to]&&e.cap>0){
            int d=dfs(e.to, t, min(f, e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

//sからtへの最大流
int max_flow(int s, int t){
    int flow=0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f=dfs(s,t,INF);
        if(f==0) return flow;
        flow+=f;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H,W;
    cin>>H>>W;
    rep(i,0,H){
        rep(j,0,W){
            char s;
            cin>>s;
            if(i==0||i==H-1||j==0||j==W-1) add_edge(i*W+j+H*W, 2*H*W, INF);
            if(s=='X'){
                add_edge(2*H*W+1, i*W+j, INF);
                add_edge(i*W+j, i*W+j+H*W, INF);
            }
            else add_edge(i*W+j, i*W+j+H*W, 1);
            if(i>=1){
                add_edge(i*W+j+H*W, (i-1)*W+j, INF);
                //add_edge((i-1)*H+j, i*H+j+H*W, INF);
            }
            if(i<H-1){
                add_edge(i*W+j+H*W, (i+1)*W+j, INF);
                //add_edge((i+1)*H+j, i*H+j+H*W, INF);
            }
            if(j>=1){
                add_edge(i*W+j+H*W, i*W+j-1, INF);
                //add_edge(i*H+j-1, i*H+j+H*W, INF);
            }
            if(j<W-1){
                add_edge(i*W+j+H*W, i*W+j+1, INF);
                //add_edge(i*H+j+1, i*H+j+H*W, INF);
            }
        }
    }
    int t=max_flow(2*H*W+1, 2*H*W);
    if(t>=INF) t=-1;
    cout <<t<<"\n";
}

Measured memory_bytes: 3200
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    string s; cin>>s;
    int a =s.size();
    for(int i=0;i<a;i++){
        if(s[0]=='B'){
            s.erase(s.begin()+0);
            i=-1;
            a-=1;
        }
        else if(s[i]=='B'){
             s.erase(s.begin()+i);
            s.erase(s.begin()+i-1);
            i=-1;
            a-=2;
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
#define PI 3.1415926535
using namespace std;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	string s;

	cin>>s;

	int size=s.size(), num[26]={}, ans;

	bool flag=false;

	rep(i, size){
		num[(int)(s[i]-'a')]++;
	}

	rep(i, 26){
		//cout<<num[i]<<endl;
		if(num[i]==0){
			flag=true; ans=i; break;
		}
	}
	if(flag){
		cout<<(char)('a'+ans)<<endl;
	} else{
		cout<<"None"<<endl;
	}
}



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

int main(){
  int n,m,a,b;
  cin>>n>>m;
  vector<int> ans(n);
  for (int i=0;i<m;i++){
    cin>>a>>b;
    ans.at(a-1)++;
    ans.at(b-1)++;
  }
  for (int i=0;i<n;i++){
    cout<<ans.at(i)<<endl;
  }
}

Measured memory_bytes: 256
//AtCoder Beginner Contest 175
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e2 + 5;
const double E = 1e-9;

//------------------------------------------------------------------------------
int n, l[N];
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*ifstream cin("input.txt");
	ofstream cout("output.txt");*/
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> l[i];
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			for (int k = j + 1; k < n; k++)
			{
				if (l[i] != l[j] && l[j] != l[k] && l[i] != l[k])
				{
					if (l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i])
						++ans;
				}
			}
		}
	}
	cout << ans;
	return 0;
}
//15-08-2020 17:41:13
//------------------------------------------------------------------------------

Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
namespace MCF {
	// required <string.h> <vector> <queue> <algorithm>
	#define MAXN 6100
	#define MAXM 21000000
	#define wint int
	#define cint int
	const wint wEPS = 0;
	const wint wINF = 1001001001;
	const cint cEPS = 0;
	const cint cINF = 1001001001;
	int n, m, ptr[MAXN], next[MAXM], zu[MAXM];
	wint capa[MAXM], tof;
	cint cost[MAXM], toc, d[MAXN], pot[MAXN];
	int vis[MAXN], pree[MAXN];
	void init(int _n) {
		n = _n; m = 0; memset(ptr, ~0, n * 4);
	}
	void ae(int u, int v, wint w, cint c) {
		next[m] = ptr[u]; ptr[u] = m; zu[m] = v; capa[m] = w; cost[m] = +c; ++m;
		next[m] = ptr[v]; ptr[v] = m; zu[m] = u; capa[m] = 0; cost[m] = -c; ++m;
	}
	bool solve(int src, int ink, wint flo = wINF) {
		int i, u, v;
		wint f;
		cint c, cc;
		memset(pot, 0, n * sizeof(cint));
		
		for (bool cont = 1; cont; ) {
			cont = 0;
			for (u = 0; u < n; ++u) for (i = ptr[u]; ~i; i = next[i]) if (capa[i] > wEPS) {
				if (pot[zu[i]] > pot[u] + cost[i] + cEPS) {
					pot[zu[i]] = pot[u] + cost[i]; cont = 1;
				}
			}
		}
		for (toc = 0, tof = 0; tof + wEPS < flo; ) {
			typedef pair<cint,int> node;
			priority_queue< node,vector<node>,greater<node> > q;
			for (u = 0; u < n; ++u) { d[u] = cINF; vis[u] = 0; }
			for (q.push(make_pair(d[src] = 0, src)); !q.empty(); ) {
				c = q.top().first; u = q.top().second; q.pop();
				if (vis[u]++) continue;
				for (i = ptr[u]; ~i; i = next[i]) if (capa[i] > wEPS) {
					cc = c + cost[i] + pot[u] - pot[v = zu[i]];
					if (d[v] > cc + cEPS) { q.push(make_pair(d[v] = cc, v)); pree[v] = i; }
				}
			}
			if (!vis[ink]) return 0;
			f = flo - tof;
			for (v = ink; v != src; v = zu[i ^ 1]) { i = pree[v]; f=min(f,capa[i]); }
			for (v = ink; v != src; v = zu[i ^ 1]) { i = pree[v]; capa[i] -= f; capa[i ^ 1] += f; }
			tof += f;
			toc += f * (d[ink] - pot[src] + pot[ink]);
			for (u = 0; u < n; ++u) pot[u] += d[u];
		}
		return 1;
	}
}
int x[3100];
int t[3100];
int p[3100];
pair<int,pair<int,int> > in[3100];
int ABS(int a){return max(a,-a);}
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	
	int s=2*a;
	int sl=2*a+1;
	int sr=2*a+2;
	int T=2*a+3;
	int U=T+1;
	int V=U+1;
	
	MCF::init(V+1);
//	MCF::ae(U,s,2,0);
//	MCF::ae(T,V,2,0);
	MCF::ae(s,T,2,0);
	MCF::ae(s,sl,1,0);
	MCF::ae(s,sr,1,0);
	int val=0;
	for(int i=0;i<a;i++){
		scanf("%d%d%d",x+i,t+i,p+i);
		in[i]=make_pair(t[i],make_pair(x[i],p[i]));
	}
	std::sort(in,in+a);
	for(int i=0;i<a;i++){
		t[i]=in[i].first;
		x[i]=in[i].second.first;
		p[i]=in[i].second.second;
	}
	for(int i=0;i<a;i++){
		if(ABS(x[i]-c)<=t[i]*b)MCF::ae(sl,2*i,1,0);
		if(ABS(x[i]-d)<=t[i]*b)MCF::ae(sr,2*i,1,0);
		MCF::ae(2*i+1,T,1,0);
/*		MCF::ae(U,i*2+1,1,0);
		MCF::ae(i*2,V,1,0);
		MCF::ae(i*2+1,i*2,1,p[i]);*/
		MCF::ae(i*2,i*2+1,1,-p[i]);
		val-=p[i];
	//	MCF::ae(2*i,2*i+1,1,-p[i]);
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			if(t[i]<t[j]&&(t[j]-t[i])*b>=ABS(x[i]-x[j])){
	//			printf("%d %d\n",i,j);
				MCF::ae(i*2+1,j*2,1,0);
			}
		}
	}
	MCF::solve(s,T,2+a);
	printf("%d\n",-MCF::toc);
}

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

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 3e5 + 5, H = (1 << 10), L = 1e5 + 5;
int value[N], weight[N], dp[H][L], sum_wt[H], sum_val[H];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> value[i] >> weight[i];
	}

	for (int i = weight[1]; i < L; i++) {
		dp[1][i] = value[1];
	}

	for (int i = 2; i <= min(H - 1, n); i++) {
		int p = i / 2;

		for (int j = L - 1; j >= 0; j--) {
			dp[i][j] = dp[p][j];
			if (j + weight[i] < L)
				dp[i][j + weight[i]] = max(dp[i][j + weight[i]], dp[i][j] + value[i]);
		}
		for (int j = 1; j < L; j++) {
			dp[i][j] = max(dp[i][j], dp[i][j - 1]);
		}
	}

	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int ver, cap;
		cin >> ver >> cap;

		vector<int> v;

		while (ver >= H) {
			v.push_back(ver);
			ver /= 2;
		}

		int ct = v.size();

		for (int j = 0; j < ct; j++) {
			sum_val[1 << j] = value[v[j]];
			sum_wt[1 << j] = weight[v[j]];
		}

		for (int j = 1; j < (1 << ct); j++) {
			sum_val[j] = sum_val[j & -j] + sum_val[j ^ (j & -j)];
			sum_wt[j] = sum_wt[j & -j] + sum_wt[j ^ (j & -j)];
		}

		int ans = 0;

		for (int j = 0; j < (1 << ct); j++) {
			if (sum_wt[j] <= cap) {
				ans = max(ans, sum_val[j] + dp[ver][cap - sum_wt[j]]);
			}
		}

		cout << ans << "\n";
	}

	return 0;
}

Measured memory_bytes: 405340
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll a,b,c,d,e,ans=1;
vector<ll> p[3];
bool dpx[100005],dpy[100005];
char s[100005];

int main(){
	cin>>s;
	cin>>a>>b;
	n=strlen(s);
	for(i=0;i<n;i++){
		if(s[i]=='F'){
			sum++;
		}else{
			p[num%2].pb(sum);
			if(num%2==0)a+=sum;
			if(num%2==1)b+=sum;
			sum=0;
			num++;
		}
	}
	p[num%2].pb(sum);
	if(num%2==0)a+=sum;
	if(num%2==1)b+=sum;
	sum=0;
	num++;
	dpx[p[0][0]]=true;
	for(i=1;i<p[0].size();i++){
		for(j=8000;j>=0;j--){
			if(dpx[j])dpx[j+p[0][i]]=true;
		}
	}
	dpy[0]=true;
	for(i=0;i<p[1].size();i++){
		for(j=8000;j>=0;j--){
			if(dpy[j])dpy[j+p[1][i]]=true;
		}
	}	
	if(dpx[a/2] && dpy[b/2] && a%2==0 && b%2==0 && a>=0 && b>=0){
		p("Yes");
	}else{
		p("No");
	}
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0LL;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define IT ::iterator
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);

int main()
{
    ll ac=0LL,tle=0LL,wa=0LL,re=0LL;
    ll ttt;
    cin >> ttt;
    while(ttt--)
	{
		string s;
		cin >> s;
		if(s=="AC")ac++;
		else if(s=="WA")wa++;
		else if(s=="TLE")tle++;
		else re++;
	}
	
	cout << "AC x " << ac << endl;;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re;
}


Measured memory_bytes: 3632
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n,k = map(int, input().split())
    h = list(map(int, input().split()))
    h.sort()
    if k == 0:
        print(sum(h))
    else:
        h = h[:-k]
        print(sum(h))


if __name__=="__main__":
    main()


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n);
	rep(i, n) cin >>a[i];
	
	bool ok=true;
	sort(all(a));
	if(n==1 && a[0] !=0) ok=false;
	else if(n>1 && n%2 && (a[0]!=0 || a[1]!=2)) ok=false;
	else if(n%2==0 && (a[1]!=1 || a[0]!=1)) ok=false;
	
	rep(i, n){
		if(i+2<n && a[i] +2 != a[i+2]) ok=false;
	}
	ll ans =1;
	rep(i, n/2) (ans *=2)%=MD;
	if(!ok) ans = 0;
	cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int K = stdIn.nextInt();
        long[] H = new long[N];
        for (int i = 0; i < N; i++) {
            H[i] = stdIn.nextLong();
        }
        stdIn.close();
        Arrays.sort(H);

        Long sum = (long)0;
        if (N < K) {
            System.out.println(0);
        } else if(K == 0) {
            for (int i = 0; i < N; i++) {
                sum += H[i];
            }
            System.out.println(sum);
        } else {
            for (int i = 0; i < K; i++) {
                H[N-1-i] = 0;
            }
            for (int i = 0; i < N; i++) {
                sum += H[i];
            }
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 90568
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b)   {return a>b?a:b;}
ll min(ll a,ll b)   {return a<b?a:b;}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("D:/Sublime/Rough/input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    //std::cout << std::fixed;
    //std::cout << std::setprecision(6);
    Fastio;
    int n;
    cin>>n;
    vector<pair<int,int>> v;
    fi(i,0,n)
    {
        int x,y;
        cin>>x>>y;
        v.pb({x,y});
    }
    ll mn = INT_MAX, mx = INT_MIN;
    for(auto i : v)
    {
        ll x = i.first, y = i.second;
        mn = min(mn, x+y);
        mx = max(mx,x+y);
    }
    ll dist = mx - mn;
    mn = INT_MAX, mx = INT_MIN;
    for(auto i : v)
    {
        ll x = i.first, y = i.second;
        mn = min(mn, x-y);
        mx = max(mx,x-y);
    }
    dist = max(dist,mx - mn);
    cout<<dist;
    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    
    return 0;
}

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

int main(){
    /*ある整数Nに対して各位の和をSとするとき、NがSで割り切れるとき
    Nをharshad数とする*/
    int N, S, x;
    cin >> N;
    x = N;
    S = 0;
    while(N > 0){
        S += N % 10;
        N = N / 10;
    }
    if(x % S == 0){
        cout << "Yes"<< endl;
    }
    else{
        cout << "No" << endl;
    }

}

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

int f(int n) {
  int ans = 1;
  for(int i = 0; i < n; i++) {
    ans *= i + 1;
  }
  return ans;
}

int main() {
  int N;
  cin >> N;
  int a = 0;
  int b = 0;
  vector<bool> keep1(N, false);
  vector<bool> keep2(N, false);
  for(int i = 0; i < N; i++) {
    int p;
    cin >> p;
    keep1.at(p - 1) = true;
    int count = 0;
    for(int j = 0; j < p - 1; j++) {
      if(!keep1.at(j)) {
        count++;
      }
    }
    a += count * f(N - i - 1);
  }
  for(int i = 0; i < N; i++) {
    int p;
    cin >> p;
    keep2.at(p - 1) = true;
    int count = 0;
    for(int j = 0; j < p - 1; j++) {
      if(!keep2.at(j)) {
        count++;
      }
    }
    b += count * f(N - i - 1);
  }
  if(a < b) {
    cout << b - a << endl;
  }
  else {
    cout << a - b << endl;
  }
}

Measured memory_bytes: 256
from collections import deque
import copy

H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

def bfs(x,y):
    check = copy.deepcopy(S)
    que = deque()
    que.append((x,y))
    check[y][x] = 0
    while que.__len__() != 0:
        x,y = que.popleft()
        tmp = check[y][x]
        for dx,dy in (1,0),(-1,0),(0,1),(0,-1):
            sx = x + dx
            sy = y + dy
            if -1 < sx < W and -1 < sy < H:
                if check[sy][sx] == '.':
                    check[sy][sx] = tmp + 1
                    que.append((sx,sy))
    return tmp

ans = 0
for x in range(W):
    for y in range(H):
        if S[y][x] == '.':
            ans = max(bfs(x,y),ans)

print(ans)

Measured memory_bytes: 9484
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
    vector<int> seq;
    int n, q, tmp, cnt;

    scanf("%d", &n);
    seq.reserve(n);
    for(int i=0; i<n; ++i) {
        scanf("%d", &tmp);
        seq.push_back(tmp);
    }

    scanf("%d", &q);
    cnt = 0;
    for(int i; i<q; ++i) {
        scanf("%d", &tmp);
        if(binary_search(seq.begin(), seq.end(), tmp))   ++cnt;
    }

    printf("%d\n", cnt);
}

Measured memory_bytes: 1268
n, m = gets.chomp.split(" ").map(&:to_i)
h_arr = gets.chomp.split(" ").map(&:to_i)
h_arr.unshift(-1)
hash = {}
1.upto(n) { |i|
    hash[i] = []
}
m.times.each {
    a, b = gets.chomp.split(" ").map(&:to_i)
    hash[a] << b
    hash[b] << a
}

arr = hash.filter { |k, v|
    v.filter { |vv|
        h_arr[k] <= h_arr[vv]
    }.count == 0
}
puts "#{arr.count}"


Measured memory_bytes: 33940
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

int main(){
	ll a, b; cin >> a >> b;
	cout << ((!(a % 3) || !(b % 3) || !((a + b) % 3)) ? "Possible" : "Impossible" )<< endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        String s = sc.next();
        int minDiff = Integer.MAX_VALUE;
        int n = 753;
        for (int i = 0; i < s.length() - 2; i++) {
            String tmp = s.substring(i, i + 3);
            int diff = Math.abs(n - Integer.parseInt(tmp));
            if (diff < minDiff) {
                minDiff = diff;
            }
        }
        System.out.println(minDiff);
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;

int main() {
  int n; cin >> n;
  deque<int> v;
  rep(i, n) {
    int a; cin >> a;
    if (i % 2 == (n % 2)) {
      v.push_back(a);
    } else {
      v.push_front(a);
    }
  } 
  for(int a : v) {
    cout << a << ' ';
  }
}


Measured memory_bytes: 2944
N = int(input())
LEN = len(str(N))
ans = 0
if LEN%2 == 0:
    for i in range(LEN//2):
        ans+=9*(10**(2*i))
else:
    for i in range(LEN//2):
        ans+=9*(10**(2*i))
    ans+=N-10**(LEN-1)+1
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>


int main(){
  
  int a, b, c, i, cnt;

  while(scanf("%d %d", &a, &b) != EOF){
    c=a+b;
    cnt=0;
    while(1){
      if(c==0) break;
      c/=10;
      cnt++;
    }
    printf("%d\n", cnt);
  }
  
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

int main(void){
  int h,w,diag,ans_diag,tmp;
  int i,j,ans_h,ans_w;
  while(1){
    scanf("%d %d",&h,&w);
    if(h==0 && w==0) break;
    diag=h*h+w*w;
    ans_diag=150*150*2;
    for(i=1;i<=150;i++){
      for(j=i+1;j<=150;j++){
        tmp=i*i+j*j;
        if(tmp==diag && i>h){
          ans_h=i;
          ans_w=j;
          goto loop;
        }
        if(tmp>diag && tmp<ans_diag){
          ans_diag=tmp;
          ans_h=i;
          ans_w=j;
        }
      }
    }
    loop:
    printf("%d %d\n",ans_h,ans_w);
  }
  return 0;
}

Measured memory_bytes: 600