akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    
    freopen("output.txt", "w", stdout);
    #endif

    ll n,i;
    cin>>n;
    ll arr[n];
    ll ans=0;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        if(i%2==0 && arr[i]%2!=0)
        {
            ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3576
<?php
	for($dataset_cnt = 0; 5 > $dataset_cnt; $dataset_cnt++)
	{
		$input_cnt = trim(fgets(STDIN));
		
		if(0 == $input_cnt)
		{
			break;
		}
		
		$pointa = 0;
		$pointb = 0;
		
		for($loop_cnt = 0; $input_cnt > $loop_cnt; $loop_cnt++)
		{
			$input_data = split(" ", trim(fgets(STDIN)));
			if($input_data[0] > $input_data[1])
			{
				$pointa += $input_data[0] + $input_data[1];
			}
			else if($input_data[0] < $input_data[1])
			{
				$pointb += $input_data[0] + $input_data[1];
			}
			else
			{
				$pointa += $input_data[0];
				$pointb += $input_data[1];
			}
		}
		echo $pointa . " " . $pointb . "\n";
	}
?>


Measured memory_bytes: 9264
#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 rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    map<string, int> mp;
    rep(i, N){
        string s;
        cin >> s;
        if(mp.count(s)) mp[s]++;
        else mp[s] = 1;
    }
    int M;
    cin >> M;
    rep(i, M){
        string s;
        cin >> s;
        if(mp.count(s)) mp[s]--;
        else mp[s] = -1;
    }
    int ans = 0;
    for(auto &e: mp){
        ans = max(ans, e.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for ( auto blockTime = make_pair(chrono::high_resolution_clock::now(), true);blockTime.second;\
debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define li long long int
#define ld long double
#define eb push_back
#define pb pop_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define size(a) a.size()
#define rev(a) reverse(a.begin(),a.end())
#define len(a) a.length()
#define f first
#define s second
#define sort(a) sort(a.begin(),a.end())
#define vli vector<li>
#define vvli vector<vli >
#define pli pair<li,li>
#define vpli vector<pli>
#define inp(t) li t;cin>>t; while(t--)
using namespace std;
const li mod = 1e9+7;
#define MAXN 1000005 

li power(li a, li b) { a%=mod; li ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}

bool isprime(li n)
{
  if (n == 1)
    return false;
  int i = 2;
  while (i*i <= n){
      if (n % i == 0)return false;
      i += 1;
  }
  return true;
}

li lcm(li a,li b)
{
    return ((a*b)/__gcd(a,b));
}

void solve()
{
  li x,y,z;
  cin>>x>>y>>z;

  li k;
  cin>>k;

  int count = 0;
  while(y<=x)
   {
    y*=2;
    count++;
   }
  while(z<=y)
    {
      z*=2;
      count++;
    }

  if(count>k)
    cout<<"No\n";
  else
    cout<<"Yes\n";

}

int main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    solve();
    return 0;
}

Measured memory_bytes: 3644
#ABC091C
n=int(input())
red=[]
blue=[]
for i in range(n):
    red.append(tuple(map(int,input().split())))
for j in range(n):
    blue.append(tuple(map(int,input().split())))
blue.sort(key=lambda x:x[0])
red.sort(key=lambda x:x[0])
ans=0
for i in range(n):
    ymax=-1
    maxidx=-1
    for j in range(len(red)):
        if red[j][0]>=blue[i][0]:break
        if ymax< red[j][1] <blue[i][1]:
            ymax=red[j][1]
            maxidx=j
    if maxidx==-1:continue
    else:
        red.pop(maxidx)
        ans+=1
print(ans)

Measured memory_bytes: 3064
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

n = inp[0]
p n**3

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
int main() {
	int vec=0;
	int n;
	int a=0;
	int b=0;
	int game_a, game_b;
	std::vector<int>veca, vecb;
	while (1) {
		std::cin >> n;
		if (n == 0)break;
		else {
			for (int i = 0; i < n; ++i) {
				std::cin >> game_a>>game_b;
				if (game_a == game_b) { a += game_a; b += game_b; }
				else if (game_a > game_b)a += game_a + game_b;
				else b += game_a + game_b;
			}
			veca.push_back(a); vecb.push_back(b); a = 0; b = 0;
		}
	}
	for (int i = 0; i < veca.size(); ++i) {
		std::cout << veca[i] <<" "<<vecb[i]<< std::endl;
	}
	return 0;
}

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

int main(void) {
  int n, m;
  bool flag = false, go = false;
  cin >> n >> m;
  int fr[m], to[m], cou[m] = {-1}, ds[m] = {-1};
  for (int i = 0; i < m; i++) {
    cin >> fr[i] >> to[i];
    if (fr[i] == 1) {
      cou[i] = to[i];
    }
    if (to[i] == n) {
      ds[i] = fr[i];
    }
  }
  int fg;
  sort(cou, cou + m);
  sort(ds, ds + m);
  for (int i = m - 1; i > 0; i--) {
    //  cout << cou[i] << " " << ds[i] << endl;
    if (cou[i] <= 0) {

      break;
    }

    if (binary_search(ds, ds + m, cou[i]) == true) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }

  cout << "IMPOSSIBLE" << endl;

  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s[10];scanf("%s",s);
  int l=strlen(s);
  for(int i=0;i<l-1;i++){
    if (s[i]=='A'&&s[i+1]=='C'){
      puts("Yes");return 0;
    }
  }
  puts("No");
}

Measured memory_bytes: 256
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;

void solve(){
    int n , k ;
    cin >> n >> k ;
    vector<int> a(n) ;
    for(int i = 0 ; i < n ; i++){
    	cin >> a[i] ;
    }
    vector<int> ans ;
    for(int i = 0 ; i < n-k ; i++){
    	int cur = a[i] ;
    	int nxt = a[i+k] ;
    	ans.pb((int)nxt>cur) ;
    }
    for(int i : ans){
    	cout << (i ? "Yes" : "No") ;
    	cout << endl ;
    }
}

int32_t main(){
    FAST_IO ;
    int t = 1 ;
//  cin >> t ;
    while(t--){
        solve() ;
    }
}


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

using namespace std;

class fenwick {
	vector<int> t;
	
	public:
		fenwick(int n) {
			t.resize(n + 1);
		}

		void add(int p, int d) {
			for(; p < (int)t.size(); p += p & -p) {
				t[p] += d;
			}
		}

		int query(int p) {
			int ret = 0;

			for(; p; p -= p & -p) {
				ret += t[p];
			}

			return ret;
		}
};

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

	int n, m;
	cin >> n >> m;

	vector<pair<int, int> > v;
	v.resize(n);

	for(int i = 0; i < n; ++i) {
		cin >> v[i].first >> v[i].second;
	}

	sort(v.begin(), v.end(), [&] (pair<int, int> x, pair<int, int> y) {
		return x.second - x.first < y.second - y.first;
	});
	
	fenwick fenwick(m + 2);

	for(auto& p : v) {
		fenwick.add(p.first, 1);
		fenwick.add(p.second + 1, -1);
	}
	
	int tot = 0;

	vector<int> ans;

	ans.resize(m);

	for(int i = m; i >= 1; --i) {
		while(!v.empty() && v.back().second - v.back().first + 1 >= i) {
			++tot;

			fenwick.add(v.back().first, -1);
			fenwick.add(v.back().second + 1, 1);

			v.pop_back();
		}

		ans[i - 1] = tot;

		for(int j = 0; j <= m; j += i) {
			ans[i - 1] += fenwick.query(j);
		}
	}

	for(auto x : ans) {
		cout << x << '\n';
	}

	return 0;

}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = RSt();
            int xCnt = s.Length - s.Replace("x", "").Length;
            Console.WriteLine(xCnt < 8 ? "YES" : "NO");
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll p[100100],q[100100],r[100100];

vector<ll> v;

int main(void){
	int x,y,z,a,b,c,i;
	ll ans = 0ll;
	cin >> x >> y >> a >> b >> c;
	for(i=0; i<a; ++i){
		cin >> p[i];
	}
	for(i=0; i<b; ++i){
		cin >> q[i];
	}
	for(i=0; i<c; ++i){
		cin >> r[i];
		v.push_back(r[i]);
	}
	sort(p,p+a,greater<ll>());
	sort(q,q+b,greater<ll>());
	for(i=0; i<x; ++i){
		v.push_back(p[i]);
	}
	for(i=0; i<y; ++i){
		v.push_back(q[i]);
	}
	sort(v.begin(),v.end(),greater<ll>());
	for(i=0; i<x+y; ++i){
		ans += v[i];
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    vector<int> piza = {a,b};
    vector<int> count = {x,y};
    int ans = 0;
    if(c*2 > a+b){
        ans = a*x + b*y;
    }
    else{
        ans += min(x,y) * c * 2;
        int z,zz;
        if(x >= y){
            z = 0;
            zz = 1;
        }
        else{
            z = 1;
            zz = 0;
        }
        ans += min(piza.at(z)*(count.at(z)-count.at(zz)) , c*2*(count.at(z)-count.at(zz)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)

signed main(){
  while(1){
    int n,m;
    cin>>n>>m;
    if(n==0&&m==0) break;
    int a[200],b[200];
    lp(i,n) cin>>a[i];
    lp(i,m) cin>>b[i];
    int asum=0,bsum=0;
    lp(i,n){
      asum+=a[i];
    }
    lp(i,m){
      bsum+=b[i];
    }
    int ansa,ansb,anssum=INF;
    lp(i,n){
      lp(j,m){
	if(asum+b[j]-a[i]==bsum+a[i]-b[j]){
	  if(anssum>a[i]+b[j]){
	    ansa=a[i];
	    ansb=b[j];
	    anssum=a[i]+b[j];
	  }
	}
      }
    }
    if(anssum==INF){
      cout<<-1<<endl;
    }
    else{
      cout<<ansa<<" "<<ansb<<endl;
    }
  }
  return 0;
}





Measured memory_bytes: 3092
n = int(input())
from collections import defaultdict as dd

hsh = dd(int)

for i in range(n):
  s = list(input())
  s = ''.join(sorted(s))
  hsh[s] += 1

x = 0
for i in hsh.keys():
  x += (hsh[i]*(hsh[i]-1))//2

print(x)

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

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


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

// nCrの計算
const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using mint = ModInt<mod>;

int main() {
  // 前処理
  COMinit();

  ll N,M; cin >> N >> M;

  vector<mint> prod(M+1,1);

  for(ll i = 1; i <= M; i+=1){
    prod[i] = prod[i-1] * (mint)i;
  }


  mint mPn = prod[M] * prod[M-N].inv();
  mint ans = 1;
  ans *= mPn;
  ans *= mPn;
  
  mint minus = 0;
  for(ll K = 1; K <= N; K++){
    mint tmp = 1;

    ll nCk = COM(N,K);
    tmp *= (mint)nCk;

    mint mPk = prod[M] * prod[M-K].inv();
    tmp *= mPk;

    mint mkPnk = prod[M-K] * prod[M-N].inv();
    tmp *= mkPnk;
    tmp *= mkPnk;

    if(K%2==0){
      ans += tmp;
    } else { 
      ans -= tmp;
    }
  }
  cout << ans << endl;
}





Measured memory_bytes: 17176
n,m,q = map(int, input().split())
lr=[list(map(int,input().split())) for i in range(m)]
pq=[list(map(int,input().split())) for i in range(q)]
arr = [[0 for _ in range(n)] for _ in range(n)]
for l,r in lr:
    arr[l-1][r-1]+=1
rui = [[0 for _ in range(n)] for _ in range(n)]

rui[0][0] = arr[0][0]

for i in range(1,n):
    rui[i][0] = rui[i-1][0] + arr[i][0]
for j in range(1,n):
    rui[0][j] = rui[0][j-1] + arr[0][j]

for i in range(1,n):
    for j in range(1,n):
        rui[i][j] = rui[i-1][j] + rui[i][j-1] - rui[i-1][j-1] + arr[i][j]

for p,q in pq:
    p-=1
    q-=1
    cnt = rui[q][q]
    if p!=0:
        cnt-=rui[p-1][q]
        cnt-=rui[q][p-1]
        cnt+=rui[p-1][p-1]

    print(cnt)

Measured memory_bytes: 128320
//https://atcoder.jp/contests/abc074/tasks/arc083_b
//D - Restoring Road Network
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}

template< typename T >
void warshall_floyd(vector<vector<T>>& d) //nは頂点数
{
  const int n = d.size();
	for(int i = 0; i < n; i++) // 経由する頂点
		for(int j = 0; j < n; j++) // 開始頂点
			for(int k = 0; k < n; k++) // 終端
        if(d[j][i] != LINF && d[i][k] != LINF) //負辺がない場合は不要
				  d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main() {
  ll N; cin>>N;
  vector<vector<ll>> ann(N,vector<ll>(N));
  REP(i,N){
    REP(j,N){
      cin>>ann[i][j];
    }
  }

  auto g=ann;
  warshall_floyd(g);
  ll ans=0;
  REP(i,N){
    REP(j,N){
      if(ann[i][j]!=g[i][j]){
        ans=-1;
        break;
      }
    }
  }
  if(ans<0) {
    cout<<ans<<endl;
    return 0;
  }

  const int n = g.size();
	for(int i = 0; i < n; i++) // 経由する頂点
		for(int j = 0; j < n; j++) // 開始頂点
			for(int k = 0; k < n; k++) // 終端
				  if (g[j][k] == g[j][i] + g[i][k]){
            if (i!=j&&i!=k) ann[j][k]=0;
          }

  REP(i,N)REP(j,N){
    ans += ann[i][j];
  }
  cout<<ans/2<<endl;

  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

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


Measured memory_bytes: 256
//To all well wishers,I own this code
#include <bits/stdc++.h>
using namespace std;
#define int                     long long   
#define double                  long double
#define endl                    "\n"
#define pb                      push_back
#define PI                      3.1415926535897932384626433832795l
#define F                       first
#define S                       second
#define mp                      make_pair
#define f(i,n)                  for(int i=0;i<n;i++)
#define fastio                  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)                  (v).begin(),(v).end()
#define rall(v)                 (v).rbegin(),(v).rend()
#define gcd(a,b)                __gcd((a),(b))
#define fill(a,value)           memset(a,value,sizeof(a));
#define minn(v)                 *min_element(v.begin(), v.end());
#define maxx(v)                 *max_element(v.begin(), v.end());
#define print(x)                cout<<(x)<<endl;
#define sum(v)+x                accumulate(v.begin(), v.end(),x);
#define debug(x)                cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int>           pii;
typedef vector<int>             vi;

signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    string s,t;
    cin>>s>>t;
    map<char,vector<int>>m;
    int n=s.size();
    int freq[26]={0};
    for(int i=0;i<n;i++)
    {
        freq[s[i]-'a']=1;
        m[s[i]].pb(i);
    }
    bool flag=true;
    for(int i=0;i<(int)t.size();i++)
    {
        if(freq[t[i]-'a']==0)
        {
            flag=false;
        }
    }
    if(!flag)
    {
        print(-1)
    }
    else
    {
        int prev=-1;
        int ans=1;
        for(int i=0;i<(int)t.size();i++)
        {
            auto lower = lower_bound(m[t[i]].begin(), m[t[i]].end(), prev);
            if(lower==m[t[i]].end())
            {
                ans++;
                lower=m[t[i]].begin();
            }
            prev=*lower+1;
        }
        int x=(ans-1)*s.length();
        x+=prev;
        print(x)
        
    }
    
    
    return 0;
}




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

int dp[2][333][333],ans,n,m;
int mod=1000000007;

signed main(){
  cin>>n>>m;
  dp[0][1][1]=1;
  for(int i=0;i<m;i++){
    for(int j=0;j<=n;j++){
      for(int k=0;k<=n;k++){
        dp[(i+1)%2][j+1][k]+=dp[i%2][j][k]*(n-j);
        dp[(i+1)%2][j][j]+=dp[i%2][j][k]*k;
        dp[(i+1)%2][j][k]+=dp[i%2][j][k]*(j-k);

        dp[(i+1)%2][j+1][k]%=mod;
        dp[(i+1)%2][j][j]%=mod;
        dp[(i+1)%2][j][k]%=mod;
      }
    }
    r(k,333)r(j,333)dp[i%2][k][j]=0;
  }
  cout<<dp[m%2][n][n]<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef long int li;

#define printArray(x,n) for(int i=0;i<n;i++) cout<<x[i]<<" "; cout<<endl;
#define DEBUG(x) cout<<">>> "<<#x<<" : "<<x<<endl;

int main(int argc, char const *argv[]){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    string a[n],tmp;
    int b[n];
    cin>>a[0]>>b[0];
    for(int i=1;i<n;i++){
        cin>>a[i]>>b[i];
        b[i] += b[i-1];
    }
    cin>>tmp;
    for(int i=0;i<n;i++){
        if(tmp == a[i]){
            cout<<b[n-1] - b[i];
            break;
        }
    }
    return 0;
}


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

# define f first
# define s second
using namespace std;

const int N = 1e5 + 100;
const int B = 20;

int n, q, timer, len;
int depth[N], dist[N];
int edges[N][2], LCA[N][B+2];
int tin[N], tout[N], fth[N][2];
vector < pair< int, int > > gr[N];
vector < int > sdst[N], scnt[N], dst(N,0), cnt(N,0);

void dfs( int v, int p )
{
    tin[v] = ++timer;
    depth[v] = depth[p] + 1;

    LCA[v][0] = p;
    for( int i = 1; i < B; i ++ )
        LCA[v][i] = LCA[ LCA[v][i-1] ] [i-1];

    for( auto ed: gr[v] ){
        if( ed.f == p ) continue;
        dist[ ed.f ] = dist[ v ] + edges[ ed.s ][ 1 ];
        fth[ed.f][0] = v;
        fth[ed.f][1] = ed.s;
        dfs( ed.f, v );
    }
    tout[v] = ++timer;
}
bool upper( int v, int u )
{
    return  ( tin[v] < tin[u] && tout[u] < tout[v] );
}
int lca( int v, int u )
{
    if( upper( v, u ) )return v;
    if( upper( u, v ) )return u;

    for( int i = B-1; i >= 0; i -- )
        if( !upper( LCA[v][i], u ) ) v = LCA[v][i];
    //cout << "lca :" << v << ' ' << u << ' ' << LCA[v][0] << endl;
    return LCA[v][0];
}
void spec_ver( int v, int p )
{
    if( depth[v] % len == 1 ){
        sdst[v] = dst;
        scnt[v] = cnt;
    }
    for( auto ed: gr[v] ){
        if( ed.f == p ) continue;
        dst[ edges[ed.s][0] ] += edges[ed.s][1];
        cnt[ edges[ed.s][0] ] ++;
        spec_ver( ed.f, v );
        dst[ edges[ed.s][0] ] -= edges[ed.s][1];
        cnt[ edges[ed.s][0] ] --;
    }
}
int get( int v, int x, int y )
{
    if( sdst[v].size() )
        return y * scnt[v][x] - sdst[v][x];
    int ret = 0;
    if( edges[ fth[v][1] ][0] == x )
        ret = y - edges[ fth[v][1] ][1];
    return ret + get( fth[v][0], x, y );
}
int main()
{
    ios_base::sync_with_stdio( false );

    cin >> n >> q;
    for( int i = 1; i < n; i ++ ){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        edges[i][0] = c; edges[i][1] = d;
        gr[a].push_back( make_pair( b, i ) );
        gr[b].push_back( make_pair( a, i ) );
    }
    tin[0] = 0;
    tout[0] = 2*N;
    len = sqrt( n )+1;
    dfs( 1, 0 );
    spec_ver( 1, 0 );
    /*
    for( int i = 1; i <= n;i  ++ ){
        cout << i << ' ' << depth[i] << ' ' << tin[i] << ' ' << tout[i] << endl;
    }
    */
    while ( q-- ){
        int x, y, v, u;
        cin >> x >> y >> v >> u;
        int _lca = lca( v, u );
        int D = dist[v] + dist[u] - 2*dist[ _lca ];
        //cout << v << ' ' << u << ' ' <<  _lca << endl;
        int g1 = get( v, x, y );
        int g2 = get( u, x, y );
        int g3 = get( _lca, x, y );
        D = D + g1 + g2 - 2*g3;
        cout << D << endl;
    }
    return 0;
}
/*
15 100
1 2 1 10
1 3 1 10
1 4 1 10
2 5 1 10
2 6 1 10
3 7 1 10
3 8 1 10
3 9 1 10
4 10 1 10
4 11 1 10
8 12 1 10
8 13 1 10
8 14 1 10
9 15 1 10

*/


Measured memory_bytes: 274048
import java.util.*;
import java.io.*;
import java.lang.*;

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

        String a = sc.next();
        String b = sc.next();

        int n = a.length();
        int ans = 0;

        for (int i = 0; i<n; i++){
            if (a.charAt(i) != b.charAt(i)){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 41408
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define ipair pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int arr[1000001],cnt[1000001];

int32_t main()
{
  int n;
  cin>>n;
  cout<<(int)(n*n);
}


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

#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int K, A, B;
  cin >> K >> A >> B;

  if (B - A <= 1)
    out(K+1);
  else {
    long long k = K-(A-1), ans = A;
    ans += (B-A) * (k/2);
    if (k % 2 == 1)
      ++ans;
    out(ans);
  }

  return 0;
}


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

int main()
{
	for(int n;cin>>n && n;){
		int prev=0,res=0;
		int l=0,r=0;
		while(n--){
			string s; cin>>s;
			if(s=="lu") l=1;
			if(s=="ru") r=1;
			if(s=="ld") l=0;
			if(s=="rd") r=0;
			if(l==r && l!=prev)
				prev=l,res++;
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 1208
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    ll a, b; cin >> a >>b;
    ll m; cin >> m;
    vector<ll> A(a+1);
    vector<ll> B(b+1);
    rep(i, a) cin >> A.at(i+1);
    rep(i, b) cin >> B.at(i+1);

    vector<ll> x(m), y(m), c(m);
    rep(i, m) cin >> x.at(i) >> y.at(i) >> c.at(i);

    ll ans = 1000000;
    rep(i, m){
        ans = min(ans, A.at(x.at(i))+B.at(y.at(i))-c.at(i));
    }

    ll tmp = 1000000;
    rep(i, a) tmp = min(tmp, A.at(i+1)); 
    ll tmp2 = 1000000;
    rep(i, b) tmp2 = min(tmp2, B.at(i+1)); 

    ans = min(ans, tmp+tmp2);
    if(ans<0) ans = 0;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define ll long long

signed main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	cout << (min_element(a.begin(), a.end()) - a.begin() + 1) << endl;
	return 0;
}


Measured memory_bytes: 3100
X, N = map(int,input().split())
if N != 0:
  p = list(map(int, input().split()))
  for i in range(2*X):
    if X-i in p and X+i in p:
      continue
    elif X-i not in p:
      print(X-i)
      break
    elif X+i not in p and X-i in p:
      print(X+i)
      break
else:
  print(X)

Measured memory_bytes: 9108
/*

    author : s@if

*/

#include<bits/stdc++.h>
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

	cin>>m>>n;
  
  if(m<n)
    cout<<0<<endl;
  else
    cout<<10<<endl;

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;

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

ll lcm(ll a,ll b){
    if(a==0||b==0){
        return 0;
    }
    return a*b/gcd(a,b);
}

int main(){
    ll a,b;
    cin >> a>>b;
    ll ans=lcm(a,b);
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define fill(x,v) memset(x, v, sizeof(x))
#define PI (ld)acos(-1)
#define endl '\n'
#define dbg(x) cout<<#x<<"="<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<endl; 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define IO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
const ld eps=(ld)1e-9;
const ll inf=(ll)1e18;
const ll mod=(ll)1e9+7;
int n, w, a[102][2];
ll d[102][100001];
ll f(int i, int j){
	if(i==0){
		return 0;
	}
	if(d[i][j]!=-1){
		return d[i][j];
	}
	ll ans=INT_MIN;
	if(j-a[i][0]>=0){
		ans=max(ans,a[i][1]+f(i-1,j-a[i][0]));
	}
	ans=max(ans,f(i-1,j));
	return d[i][j]=ans;
}


void solve(){
	cin>>n>>w;
	fill(d,-1);
	for (int i = 1; i <=n; ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			cin>>a[i][j];
		}
	}
	cout<<f(n,w);
}

int main(){fio;
int test=1;
// cin>>test;
while(test--){
	solve();
	cout<<endl;
}
return 0;
}

Measured memory_bytes: 80000
import numpy as np
n = int(input())
X = []; U = []
for i in range(n):
    x,u = input().split()
    X.append(float(x)); U.append(1 if u == 'JPY' else 3.8e5)
X = np.array(X); U = np.array(U)
print(np.dot(X,U))

Measured memory_bytes: 12600
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef vector<int> vi;

#define PB push_back
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define all(a) a.begin(),a.end()

int P[1001];

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

	int N, M;
	
	while (cin >> N >> M, N || M) {
		rep1(i, N) cin >> P[i];

		vi A;

		A.PB(0);

		rep(i, N + 1) rep(j, N + 1) if (P[i] + P[j] <= M) A.PB(P[i] + P[j]);

		sort(all(A));

		int ma = 0;

		rep(i, A.size()) {
			int tmp;

			int pos = upper_bound(all(A), M - A[i]) - A.begin();

			if (pos == A.size()) {
				tmp = A.back();
			} else if (pos - 1 == -1) {
				tmp = 0;
			} else {
				tmp = A[pos - 1];
			}

			if (A[i] + tmp <= M) {
				ma = max(ma, A[i] + tmp);
			}
		}

		cout << ma << endl;
	}
}

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

int main(){
    int sum, asi;
    cin >> sum >> asi;

    bool isOk = false;
    for(int i = 0; i <= sum; i++){
            if(2*i + 4*(sum - i) == asi){
                isOk = true;
            }
    }

    string ans = isOk ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
N = int(input())
A = list(map(int,input().split()))
cnt = [0] * (10**5+1)
for i in range(N):
  if A[i] == 0:
    cnt[A[i]] += 1
    cnt[A[i]+1] += 1
  elif A[i] == 10**5:
    cnt[A[i]-1] += 1
    cnt[A[i]] += 1
  else:
    cnt[A[i]-1] += 1
    cnt[A[i]] += 1
    cnt[A[i]+1] += 1
print(max(cnt))



Measured memory_bytes: 13964
N = int(input())
s = input()
R = s.count('R')
G = s.count('G')
B = s.count('B')

count = R*G*B
cnt = 0
for i in range(len(s)):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            count -= 1
print(count)

Measured memory_bytes: 9192
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;

using namespace std;
int N;
int L;
int P;
const int MAX_N = 100000;
const int MAX_W = 100000;


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

void solve() {
	vector<int> a(3);

	int  b, c;
	cin >> a[0] >> a[1] >> a[2];

	int a1 = abs(a[0] - a[1]) + abs(a[0] - a[2]);
	int a2 = abs(a[1] - a[0]) + abs(a[1] - a[2]);
	int a3 = abs(a[2] - a[0]) + abs(a[2] - a[1]);

	ce(min({ a1,a2,a3 }));

	
}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,n;

    scanf("%d%d%d",&n,&b,&c);
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        int x=i,digit=0;
        while(x!=0)
        {
            digit+=(x%10);
            x/=10;
        }
        if(digit>=b && digit<=c)
            sum+=i;
    }
    cout<<sum<<endl;

    return 0;
}


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

int main(){
  int n, c[4];
  while((cin >> n), n){
    if(n%1111==0){
      cout << "NA\n";
      continue;
    }
    int num = 0;
    while(n!=6174){
      for(int i=0; i<4; i++){
	c[i] = n%10;
	n/=10;
      }
      sort(c,c+4);
      int p=0, q=0;
      for(int i=0; i<4; i++){
	p*=10; q*=10;
	p+=c[i]; q+=c[3-i];
      }
      n = q-p;
      num++;
    }
    cout << num << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
    int k; cin >> k;
    cout << v[k-1] << endl;
}


Measured memory_bytes: 256
n = int(input())
a_li=[int(input()) for i in range(n)]

a_sorted = sorted(a_li, reverse=True)
max_a = a_sorted[0]
second = a_sorted[1]
for i in range(n):
    if a_li[i] == max_a:
        print(second)
    else :
        print(max_a)


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

int main(){
ll N, Ans = 0;cin >> N;
vector<ll> A(N);
vector<ll> a(N);

rep(i, 0, N){
    
    cin >> A[i];

    a[i] = A[i];

}

rep(i, 0, N - 1){

    if(a[i + 1] - a[i] < 0)a[i + 1] = a[i];

}

rep(i, 0, N){

    Ans += a[i] - A[i];

}

cout << Ans;

}

Measured memory_bytes: 6408
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] g = buildGraph(sc, n, m);
        boolean ans = false;
        for(int a : g[0]){
            for(int b : g[a]){
                if(b == n - 1) ans = true;
            }
        }

        if(ans) System.out.println("POSSIBLE");
        else System.out.println("IMPOSSIBLE");
        sc.close();
    }

    public static int[][] buildGraph(Scanner sc, int n, int m){
        int[][] graph = new int[n][];
        int[][] edges = new int[m][2];
        int[] deg = new int[n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() -1;
            int b = sc.nextInt() -1;
            edges[i][0] = a;
            edges[i][1] = b;
            deg[a]++;
            deg[b]++;
        }
        for (int i = 0; i < n; i++) {
            graph[i] = new int[deg[i]];
        }
        for (int i = 0; i < m; i++) {
            int a = edges[i][0];
            int b = edges[i][1];
            graph[a][--deg[a]] = b;
            graph[b][--deg[b]] = a;
        }

        return graph;
    }

}


Measured memory_bytes: 113812
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;


int main() {

    int N;
    cin >> N;
    cout << (N + 2 - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
count = 0
ans = 0

for i in range(n-1):
  if h[i] >= h[i + 1]:
    count += 1
  else:
    if ans < count:
      ans = count
    count = 0

ans = max(ans, count)
print(ans)  

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


using namespace std;

using ll   = long long;
using ii   = pair < int , int >;
using i3   = pair < int , ii >;
using li   = pair < ll , int >;
using lii  = pair <  ll,  ii >;
using vi   = vector < int >;
using vl   = vector < ll >;
using vli  = vector < li >;
using vii  = vector < ii >;
using vi3  = vector < i3 >;
using vlii = vector < lii >;

const int N = 2e5 + 5;
const ll INF = 1e17;
const double eps = 1e-12 , PI = acos(-1);

int n , m;

vi adj[N];

int start = 0;

vector < vi > ans;
int p[N];
bool vis[N];

void getCyc(int u){
    vi tmp;

    while( true ){
            tmp.push_back(u);
            if(u == start)break;
            u = p[u];
    }

    reverse(tmp.begin() , tmp.end());
    ans.push_back(tmp);
}

void bfs(int u){
    memset(vis , 0 , sizeof vis);

    queue < int > q;
    p[u] = u;
    vis[u] = 1;
    q.push(u);

    while( !q.empty() ){
            u = q.front();
            q.pop();

            for(int v : adj[u]){
                    if(v == start){
                            getCyc(u);
                            return;
                    }
            }

            for(int v : adj[u]){
                    if(vis[v])continue;
                    vis[v] = 1;
                    p[v] = u;
                    q.push(v);
            }
    }
}

void solve(int cs){
    scanf("%d %d" , &n , &m);

    for(int i = 0 ; i < m ; i ++){
            int u , v;
            scanf("%d %d" , &u , &v);
            adj[u].push_back(v);
    }

    for(int i = 1 ; i <= n ; i ++){
            start = i;
            bfs(i);
    }

    int sz = ans.size();
    if(sz == 0){
            printf("-1\n");
            return;
    }

    int mn = 10000 , dx = 0;
    for(int i = 0 ; i < sz ; i ++){
            if(ans[i].size() < mn){
                    mn = ans[i].size();
                    dx = i;
            }
    }

    printf("%d\n" , ans[dx].size());
    for(int A : ans[dx]){
            printf("%d\n" , A);
    }
}

main(){
    int t = 1;

    for(int cs = 1 ; t -- ; cs ++){
        solve(cs);
    }

    return 0;
}



Measured memory_bytes: 9088
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a.at(i);
  int mi = 1000000010;
  int ma = 0;
  rep(i,n) mi = min(mi,a.at(i));
  rep(i,n) ma = max(ma,a.at(i));
  cout << ma - mi << endl;
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
		using namespace std;
		#define sz(x) (int)(x).size()
		#define int long long int
		#define loop(i,a,b) for(int i=a;i<b;i++)
		#define scan(arr,n) for (int i = 0; i < n; ++i) cin >> arr[i]
		#define vi vector<int>
		#define si set<int>
		#define pii pair <int, int>
		#define sii set<pii>
		#define vii vector<pii>
		#define mii map <int, int>
		#define pb push_back
		#define all(aa) aa.begin(), aa.end()
		#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
		//Constants
		const int mod = 1000000007; /* 1e9 + 7*/
		const int MAXN = 1000005; /*1e6 +5 */
		 
		int spf[1000009]; // stores the smallest prime factor of a number
		 vector<vi> graph;
		// vi count1;
		 
		 int gcdExtended(int a, int b, int *x, int *y); 
		 
		 int count1(int x,int y,int z);
		 //int n;
		void sieve()
		{
			spf[1] = 1;
			for (int i=2; i<MAXN; i++)
				spf[i] = i;
			for (int i=4; i<MAXN; i+=2)
				spf[i] = 2;
		 
			for (int i=3; i*i<MAXN; i++)
				if (spf[i] == i)
				{
					for (int j=i*i; j<MAXN; j+=i)
						if (spf[j]==j)
							spf[j] = i;
				}
		}
		
		void print(vi v)
		{
			for(auto x:v)
			cout<<x<<" ";
			cout<<endl;
		}
		 
		/* Iterative Function to calculate (x^y)%p 	 in O(log y) */
		int power(int x,  int y, int p)
		{
			int res = 1;     // Initialize result
			x = x % p; // Update x if it is more than or
						// equal to p 
			if (x == 0) return 0; // In case x is divisible by p;     
			while (y > 0)
			{
				// If y is odd, multiply x with result
				if (y & 1)
					res = (res*x) % p;     
				// y must be even now
				y = y>>1; // y = y/2
				x = (x*x) % p;
			}
			return res;
		}
		
		 
		void solve()
		{
			string s,t;
			cin>>s>>t;
			int n=sz(t);
			int ans=INT_MAX;
			if(sz(s)==sz(t))
			{
				int cnt=0;
				loop(j,0,sz(s))
				{
					if(s[j]!=t[j])
					cnt++;
				}
				cout<<cnt<<endl;
				return ;
				
			}
			loop(i,0,sz(s)-n)
			{
				string str=s.substr(i,n);
				//cout<<str<<endl;
				int cnt=0;
				loop(j,0,sz(str))
				{
					if(str[j]!=t[j])
					cnt++;
				}
				ans=min(ans,cnt);
			}
			cout<<ans<<endl;
			
		}

		 
		int32_t main()
		{
			faster;
			int t=1;
			//cin>>t;
			while(t--) solve();		 
			return 0;
		}


Measured memory_bytes: 3644
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main() {
  string S;
  cin >> S;
  int N = S.size();
  ll ans = 0;
  for(int i = 0; i < 1 << (N - 1); i++) {
    ll now = S[0] - '0';
    ll sum = 0;
    for(int j = 0; j < N - 1; j++) {
      if (i >> j & 1) {
        sum += now;
        now = S[j + 1] - '0';
      } else {
        now *= 10;
        now += S[j + 1] - '0';
      }
    }
    ans += sum + now;
  }
  cout << ans << endl;
  return 0;
}

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

vector<int> adj[100001];
int vis[100001];
int dp[100001];

#define pb push_back

void dfs(int node)
{
	vis[node] = 1;
	dp[node] = 0;
	
	for(int child : adj[node])
	{
		if(vis[child] == 0)
			dfs(child);
			
		dp[node] = max(dp[node], dp[child] + 1);
	}
}

int main() {
	// your code goes here
	
	int n, m;
	cin >> n >> m;
	
	while(m--)
	{
		int x,y;
		cin >> x >> y;
		adj[x].pb(y);
	}
	
	for(int i = 1; i <= n; i++)
	{
		if(vis[i] == 0)
			dfs(i);
	}
	int ans =0;
	for(int i = 1; i <= n; i++)
	{
		ans = max(ans, dp[i]);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12412
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String a = sc.next();
    String b = sc.next();
    String c = sc.next();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      if (!((a.charAt(i) == b.charAt(i)) && (b.charAt(i) == c.charAt(i)))) {
        if ((a.charAt(i) != b.charAt(i)) && (b.charAt(i) != c.charAt(i)) && (c.charAt(i) != a.charAt(i))) {
          ans += 2;
        } else {
          ans++;
        }
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 35660
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    ll a, b, n;
    cin >> a >> b >> n;
    if ( n >= b - 1 ) {
        cout << a * ( b - 1 ) / b - a * ( ( b - 1 ) / b ) << endl;
    }
    else {
        cout << a * n / b - a * ( n / b ) << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#import itertools,math
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,k=map(int,input().split())
print(n-k+1)
for i in range(2,k+1):
  if i > n-k+1:
    print(0)
  else:
    print(cmb(n-k+1,i)*(cmb(k-1,i-1))%(10**9+7))

Measured memory_bytes: 3944