akhauriyash/Code-Regression huggingface dataset:
/** 	Author: Apoorva Mittal  **/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define nl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pair<int, int>>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repD(i, a, b) for (int i = a; i >= b; i--)
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define init(i, k) memset(i, k, sizeof i)
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define inp(a) rep(i, 0, a.size()) cin >> a[i];
#define out(a)                               \
    cout << #a << ": "<<endl;                      \
    rep(i, 0, a.size()) cout << a[i] << " "; \
    cout << endl;
#define out2d(a)                \
    cout << #a << ": " << endl; \
    rep(i, 0, a.size())         \
    {                           \
        rep(j, 0, a[0].size())  \
                cout            \
            << a[i][j] << " ";  \
        cout << endl;           \
    }
#define flush fflush(stdout);
#define lb lower_bound
#define ub upper_bound
#define maxe *max_element
#define mine *min_element
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define pqueue priority_queue
#define precise(x) cout << fixed << showpoint << setprecision(x);
#define setbit(x) __builtin_popcountll(x)
#define gcd(a, b) __gcd(a, b)
#define deb(x) cout << #x << " " << x << endl;
#define Y "YES"
#define N "NO"
const int mod = 1e9 + 7;
// ====== Useful functions begin ======
inline int add(int a, int b) { return ((a % mod) + (b % mod)) % mod; }
inline int sub(int a, int b) { return ((a % mod) - (b % mod) + mod) % mod; }
inline int mul(int a, int b) { return ((a % mod) * (b % mod)) % mod; }
// ====== Useful functions end ======
const int inf = 1e18;
const int maxn = 1e3 + 5;

//--------------------------------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------

void solve()
{
    int n; cin>>n;
    int w;cin>>w;
    vvi arr(n+1,vi(2));
    rep(i,1,n+1)
    {
        rep(j,0,2)
        cin>>arr[i][j];
    }
    vvi dp(n+1,vi(w+1,0));

    rep(i,1,n+1)
    {
        rep(j,1,w+1)
        {
            if(arr[i][0] <= j)
            {
                dp[i][j] = max(arr[i][1] + dp[i-1][j-arr[i][0]] , dp[i-1][j]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    // out2d(dp)
    cout<<dp[n][w]<<endl;

    
}
signed main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    speed;
    int t = 1;
    // cin >> t;

    for (int tt = 1; tt <= t; tt++)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
    }
}

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

const int INF = 1e9;

template <typename T>
struct BellmanFord {
  struct Edge {
    int from, to;
    T cost;
  };
  int n;
  vector<T> dist;
  vector<int> hasPath;
  vector<Edge> es;
  BellmanFord(int n_, T INF = 1e9)
    : n(n_), dist(n_, INF + INF), hasPath(n_, 0) {}

  void addEdge(int u, int v, T w) { es.push_back({u, v, w}); }
  bool build(int s) {
    dist[s] = 0;
    hasPath[s] = 1;
    for (int i = 0; i < n; ++i) {
      for (auto&& e : es) {
        if (dist[e.to] > dist[e.from] + e.cost) {
          dist[e.to] = dist[e.from] + e.cost;
          hasPath[e.to] |= hasPath[e.from];
          if (i == n - 1 && hasPath[e.to]) return false;
        }
      }
    }
    return true;
  }
};

int main() {
  int n, m, p;
  cin >> n >> m >> p;
  vector<int> a(m), b(m), c(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i], a[i]--, b[i]--;
  }
  BellmanFord<int> bf1(n), bf2(n);
  for (int i = 0; i < m; i++) {
    bf1.addEdge(a[i], b[i], 1);
    bf2.addEdge(b[i], a[i], 1);
  }
  bf1.build(0);
  bf2.build(n - 1);
  vector<bool> need(n, false);
  for (int i = 0; i < n; i++) {
    need[i] = (bf1.dist[i] < INF && bf2.dist[i] < INF);
  }
  BellmanFord<int> g(n);
  for (int i = 0; i < m; i++) {
    if (!need[a[i]] || !need[b[i]]) continue;
    g.addEdge(a[i], b[i], p - c[i]);
  }
  bool ok = g.build(0);
  if (ok) {
    cout << max(0, -g.dist[n - 1]) << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 768
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) throws Exception {
        String s = sc.next();
        boolean[] bs = {
            s.matches(".*keyence"),
            s.matches("k.*eyence"),
            s.matches("ke.*yence"),
            s.matches("key.*ence"),
            s.matches("keye.*nce"),
            s.matches("keyen.*ce"),
            s.matches("keyenc.*e"),
            s.matches("keyence.*")
        };
        
        for(int i = 0; i < 8; ++i) {
            if(bs[i]) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}


Measured memory_bytes: 21972
//#include <ext/pb_ds/assoc_container.hpp> 
    // #include <ext/pb_ds/tree_policy.hpp> 
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    #include <cstring>
    #include <vector>
    #include <deque>
    #include <queue>
    #include <set>
    #include <map>
    #include <valarray>
    #include <iterator>
    #include <functional>
    #include <limits>
    #include <algorithm>
    #include <numeric>
    #include <cmath>
    #include <cassert>
    #include <unordered_map>
    #include <unordered_set>
    #include <stack>
    using namespace std;
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define trace(x) cerr << #x << ": " << x << " " << endl;
     
    typedef int64_t ll;
     
    #define endl '\n'
    #define int ll
    ll mod=1e9+7;
    ll mod1=1e9+5;
     
    ll power(ll a,ll b)
    {
        if(b==0) return 1;
        else if(b%2==0)
            return power((((a%mod)*(a%mod))%mod),b/2)%mod;
        else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
    }
     
    // using namespace __gnu_pbds;
    // #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
    //find_by_order(k)  returns iterator to kth element starting from 0;
    //order_of_key(k) returns count of elements strictly smaller than k;
    //erase,insert same as normal set
  
    int32_t main()
    {
        IOS

        
       int a,b;
       cin>>a>>b;
       cout<<(a+b-1)/b;


    }       

Measured memory_bytes: 256
M=10**9+7
x,y=map(int,input().split())
ans=0
if (x+y)%3==0:
  a=(2*y-x)//3
  b=(2*x-y)//3
  if a>=0 and b>=0:
    f1,f2=1,1
    for i in range(a+1,a+b+1):
      f1*=i
      f1%=M
    for i in range(1,b+1):
      f2*=i
      f2%=M
    ans=f1*pow(f2,M-2,M)

print(ans%M)

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

typedef long long ll;
typedef pair<int,int> P;
const ll MOD = 1000000007;

#define fr first
#define sc second

int main(){
	ll n,k;
	ll a[2002];
	cin >> n >> k;
	for(int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	
	ll b=0;
	ll c=0;
	for(int i = 0 ; i < n ; i ++){
		for(int j = i+1 ; j < n ; j ++){
			if(a[i] > a[j])b ++;
			if(a[i] != a[j])c ++;
		}
	}
	//cout << b << " " << c << endl;
	ll ret = c*k;
	ret %= MOD;
	ret *= k-1;
	ret %= MOD;
	ret *= 500000004;
	ret %= MOD;
	ret += b*k;
	ret %= MOD;
	cout << ret << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int hg = sc.nextInt();
		int wg = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		sc = null;
		System.out.println((hg-h)*(wg-w));
	}
}


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

int main(){
    //input
    int a,b;
    cin >> a >> b;
        
    int sum = 0;
    for(int i=0;i<b-a;i++){
        sum+=i;
    }
    cout << sum - a << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> //ABC 168_a
#define ll long long
using namespace std;
int n,ans;
int main(){
	cin>>n;
	ans=n%10;
	if(ans==2||ans==4||ans==5||ans==7||ans==9)
		cout<<"hon";
	else if(ans==0||ans==1||ans==6||ans==8)
		cout<<"pon";
	else if(ans==3)
		cout<<"bon";
	return 0;
}

Measured memory_bytes: 3636
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;


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

	double x, t;
	cin >> x >> t;
	
	cout << x/t << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B,C;
    cin >> A >> B >> C;
    if(A == B && A != C) cout << "Yes" << endl;
    else if(A == C && A != B) cout << "Yes" << endl;
    else if(B == C && A != B) cout << "Yes" << endl;
    else  cout << "No" << endl;
}


Measured memory_bytes: 256
def skip_num(num_digits:list, compare_digit):
    compare_upper_digit = num_digits[compare_digit]
    compare_lower_digit = num_digits[compare_digit + 1]
    if compare_upper_digit > compare_lower_digit:
        num_digits[compare_digit + 1] = compare_lower_digit + 1
        if compare_digit + 2 > len(num_digits):
            num_digits[compare_digit + 2:] = [0] * (len(num_digits) - compare_digit - 2)
    else: # compare_upper_digit < compare_lower_digit
        num_digits[compare_digit] = compare_upper_digit + 1
        num_digits[compare_digit + 1:] = [0] * (len(num_digits) - compare_digit - 1)
    
    return int("".join([str(i) for i in num_digits]))

K = int(input())

lunlun_count = 0
num = 0
while True:
    num += 1
    if num < 10:
        lunlun_count += 1
    else:
        num_digits = list(map(int, str(num)))
        is_lunlun = True
        for i in range(len(num_digits) - 1):
            if abs(num_digits[i] - num_digits[i + 1]) > 1:
                is_lunlun = False
                num = skip_num(num_digits, i) - 1
                break
            
        if is_lunlun:
            lunlun_count += 1
    if lunlun_count >= K:
        break

print(num)


Measured memory_bytes: 9156
# import sys; input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	D, T, S = getlist()
	if S * T >= D:
		print("Yes")
	else:
		print("No")


if __name__ == '__main__':
	main()

Measured memory_bytes: 64680
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

void solve(){
	int x,y;
	cin>>x>>y;

	if(4*x<y || y<2*x || y%2!=0){
		cout<<"No\n";
		return ;
	}
	cout<<"Yes\n";
	return ;
}

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

    #ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		
	int t=1;

	while(t--){
		solve();
	}
    return 0;
}

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

int main(){
  typedef std::pair<long, long> pair;
  std::vector<pair> drink;

  int n, m;
  std::cin >> n >> m;
  long tmp_a, tmp_b;
  for(int i = 0; i < n; i++){
    std::cin >> tmp_a >> tmp_b;
    drink.push_back(std::make_pair(tmp_a, tmp_b));
  }
  std::sort(drink.begin(), drink.end());

  long sum = 0, cnt = 0;
  int k = 0;
  long x, y;
  while(cnt < m){
    x = drink[k].first;
    y = drink[k].second;
    if(cnt + y <= m){
      sum += x*y;
      cnt += y;
    }
    else {
      sum += (m - cnt)*x;
      cnt += y;
    }
    k++;
  }

  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 2420
#include <stdio.h>
 
int main(void){
    int n;
    scanf("%d",&n);
    
    if(n%2 == 0) printf("%lf",(double)1/(double)2);
    if(n%2 == 1) printf("%lf",(double)(n/2+1)/(double)n);
  
    return 0;
}

Measured memory_bytes: 128
n = int(input())
if n % 10 == 2 \
    or n % 10 == 4 \
    or n % 10 == 5 \
    or n % 10 == 7 \
    or n % 10 == 9: 
      print('hon')
elif n % 10 == 0 \
    or n % 10 == 1 \
    or n % 10 == 6 \
    or n % 10 == 8:
      print('pon')
else:
  print('bon')

Measured memory_bytes: 9124
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<template<class...> class ContT, class ValueT, size_t Dim>
struct vec_type
{
    using type = ContT<typename vec_type<ContT, ValueT, Dim-1>::type>;
};

template<template<class...> class ContT, class ValueT>
struct vec_type<ContT, ValueT, 0>
{
    using type = ValueT;
};

template<class ValueT, size_t Dim = 1>
using vec_t = typename vec_type<std::vector, ValueT, Dim>::type;


template<class ValueT, size_t Dim, class = typename std::enable_if<Dim == 0>::type>
auto make_vec(ValueT value = ValueT()) -> ValueT
{
    return value;
}

template<class ValueT, size_t Dim, class... Rest>
auto make_vec(size_t size0, Rest... rest)
{
    auto vec = make_vec<ValueT, Dim-1>(rest...);
    return std::vector(size0, vec);
}

int diffabs(int l, int r)
{
    if (l < r) return r-l;
    else return l-r;    
}


///////////////////////////////////////////////////

int main()
{
    int N, K;
    cin >> N >> K;
    vi A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    vi imos(N+1, 0);
    for (int k = 0; k < K; k++)
    {
        fill(begin(imos), end(imos), 0);
        for (int i = 0; i < N; i++)
        {
            int l = max(0, i - A[i]);
            int r = min(N + 1, i + A[i] + 1);
            ++imos[l];
            --imos[r];
        }

        int N_count = 0;
        for (int i = 0; i < N; i++)
        {
            A[i] = imos[i] + ((i > 0) ? A[i-1] : 0);
            if (A[i] == N) ++N_count;
        }
        if (N_count == N) break;
    }

    for (int a : A)
    {
        cout << a << " " <<  endl; 
    }
       
}

Measured memory_bytes: 4844
//#define local
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
#ifdef local
#include "debug.cpp"
#else
#define debug(...)
#endif
const ll mod = 1e9 + 7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    ll n; cin >> n;
    vec<ll> a(n); 
    ll sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
        sum %= mod;
    }
    ll res = 0;
    rep(i,n-1){
        sum = (sum + mod - a[i])%mod;
        res += (a[i] * sum)%mod;
        res %= mod;
    }
    cout << res << endl;
}

Measured memory_bytes: 4780
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String S = br.readLine();
        String T = br.readLine();
        int ans=0;

        for (int i=0; i<S.length(); i++) {
            if (S.charAt(i)!=T.charAt(i)) {
                ans++;
            }
        }
        System.out.println(ans);

    }

}

Measured memory_bytes: 36328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define double long double
#define rep(i, n) for (int i = 0; i < n; i++)
#include <math.h> /* M_PI */
#define INF 2147483647

int main()
{
    int N;
    cin >> N;
    vector<ll> f(N + 1);
    for (int i = 1; i < N + 1; i++)
    {
        for (int j = 1; j <= N / i; j++)
        {
            f[i * j] += 1;
        }
    }
    ll ans = 0;
    for (int i = 1; i < N + 1; i++)
    {
        ans += i * f[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 81396
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int s;
  ci(s);
  ve<int> a;
  a.pb(s);
  int i = 1;
  wh(true){
    if(a.at(i - 1) % 2 == 0){
      a.pb(a.at(i - 1) / 2);
    }
    else{
      a.pb(a.at(i - 1) * 3 + 1);
    }
    rep(j, i){
      if(a.at(j) == a.at(i)){
        co(i + 1);
        rt;
      }
    }
    i++;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using std::cin;
using std::cout;
using std::string;
int length(string c)
{
	int i=0;
	while(c[i]!=0)
		i+=1;
	return i;
}
int main()
{
	int len,temp=0,i,j;
	string str,ans;
	cin>>str;
	len=length(str);
	for(i=0;i<len;i++)
	{
		if('0'==str[i]){
			ans.push_back('0');
			temp++;
		}
		else if('1'==str[i]){
			ans.push_back('1');
			temp++;
		}
		else if('B'==str[i]){
			if(0==temp)
			continue;
		else
			ans.pop_back();
			temp--;
			}
	}
	cout<<ans;
	return 0;
		
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N,Q; cin >> N >> Q;
    ll from = 0;
    while(Q--){
        ll com,k; cin >> com >> k;
        if(com == 1){
            from = (from + k)%N;
        }else{
            ll out = (from + k)%N;
            if(out == 0) out = N;
            cout << out << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3204
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int main(){
	int e;
	int x,y,z;
	int m;
	int z3,y2,doe;
	while(cin>>e,e){
		x=y=z=0;
		m=1000000000;

		for(z=0;z*z*z<=e;z++){
			z3=z*z*z;
			for(y=0;y*y<=e-z3;y++){
				doe=e-z3;
				y2=y*y;
				doe-=y2;
				if(m>doe+z+y)
					m=doe+z+y;
			}
		}
		

		cout<<m<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

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

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

int main() {
  int a, b;
  while(cin >> a >> b) {
    cout << gcd(a, b) << " " << lcm(a, b) << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int n;
	int *p;
	scanf("%d", &n);
	p = (int *)malloc(sizeof(int) * n);
	for (int k=0; k<n; k++){
		scanf("%d", &p[k]);
	}
	int x = 0;
	int now_min = 0;
	for(int i=0; i<n; i++){
		if(i == 0){
			now_min = p[i];
			x++;
		}
		else{
			if(p[i] <= now_min){
				x++;
				now_min = p[i];
			}
		}
	}
	printf("%d\n", x);
	return 0;
}


Measured memory_bytes: 896
import collections
N = int(input())
A = list(map(int, input().split()))

l = []
r = []
al = []
for i, x in enumerate(A):
  if i % 2 == 0:
    l.append(x)
  else:
    r.append(x)
  al.append(x)

c = collections.Counter(l)
d = collections.Counter(r)
e = collections.Counter(al)

if len(e.keys()) <= 1:
  print(N//2)
  exit()
else:
  mx = -1
  ans = 0
  ck = max(c.items(), key=lambda x:x[1])[0]
  cmx = max(c.items(), key=lambda x:x[1])[1]

  dk = max(d.items(), key=lambda x:x[1])[0]
  dmx = max(d.items(), key=lambda x:x[1])[1]

  if ck == dk:
    if cmx > dmx:
      ans += N//2 - cmx
      ans += N//2 - d.most_common(2)[1][1]
    elif cmx < dmx:
      ans += N//2 - dmx
      ans += N//2 - c.most_common(2)[1][1]
    else:
      if c.most_common(2)[1][1] >= d.most_common(2)[1][1]:
        ans += N//2 - dmx
        ans += N//2 - c.most_common(2)[1][1]
      else:
        ans += N//2 - cmx
        ans += N//2 - d.most_common(2)[1][1]
  else:
      ans += N//2 - cmx
      ans += N//2 - dmx

print(ans)


Measured memory_bytes: 29144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define plint pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
#define SIZE 3
int main(){
    int n;
    bool is_bingo = false;
    vector<vector<int>> a(3,vector<int>(3));
    REP(i,SIZE) cin >> a[0][i];
    REP(i,SIZE) cin >> a[1][i];
    REP(i,SIZE) cin >> a[2][i];
    cin >> n;
    vector<int> b(n);
    REP(i,n) cin >> b[i];

    REP(i,n){
        REP(j,SIZE){
            REP(k,SIZE){
                if(a[k][j]==b[i]) a[k][j] = 0;
            }
        }
    }
    // yoko
    REP(i,SIZE){
        if(a[i][0]==0 && a[i][1]==0 && a[i][2]==0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    // tate
    REP(i,SIZE){
        if(a[0][i]==0 && a[1][i]==0 && a[2][i]==0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    // naname
    if(a[0][0]==0 && a[1][1]==0 && a[2][2]==0){
            cout << "Yes" << endl;
            return 0;        
    }
    if(a[0][2]==0 && a[1][1]==0 && a[2][0]==0){
            cout << "Yes" << endl;
            return 0;        
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>

int main(){
int a,b;
int d;
int i;

scanf("%d %d",&a,&b);
if(b<10)
	d=a*10+b;
else if(b<100)
	d=a*100+b;
else d=a*1000+b;

//printf("a=%d\n",a);
//printf("b=%d\n",b);
//printf("d=%d",d);
i=(int)sqrt(d)*sqrt(d);

if(i==d){
	printf("Yes");}
else{
	printf("No");}

return 0;
}

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

int ans = 0;
void rec(vector<int>& S, int i, vector<vector<int>>& s, vector<int>& p){
	int n = S.size();
	int temp;
	if(i == n){
		/////
		//for(int j=0; j<S.size(); j++){
		//	cout << S[j] << " ";
		//}
		//cout << endl;
		for(int j=0; j<p.size(); j++){
			temp = 0;
			for(int k=0; k<s[j].size(); k++){
				temp += S[s[j][k]-1];	
			}
			temp = temp%2;
			if(temp != p[j]){
				return;
			}
		}
		ans++;
		return;
	}
	rec(S, i+1, s, p);
	S[i] = 1;
	rec(S, i+1, s, p);
	S[i] = 0;
}
void makeCombination(vector<int>& S, int n, vector<vector<int>>& s, vector<int>& p){
	for(int i=0; i<S.size(); i++){
		S[i] = 0;
	}
	rec(S, 0, s, p);
}



int main(){
	int n, m, k, in;
	cin >> n >> m;
	vector<int> S(n);
	vector<vector<int>> s(m);
	vector<int> p(m);
	for(int i=0; i<m; i++){
		cin >> k;
		for(int j=0; j<k; j++){
			cin >> in;
			s[i].push_back(in);	
		}
	}
	for(int i=0; i<m; i++){
		cin >> p[i];
	}
	makeCombination(S, n, s, p);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int N;
    scanf("%d",&N);
    int last=N%10;
    if(last==2 || last==4 || last==5 || last==7 || last==9)
        printf("hon");
    else if(last==0 || last==1 || last==6 || last==8)
        printf("pon");
    else
        printf("bon");


    return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std ;
#define int long long
#define pb push_back
#define mp make_pair
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define sorta(v) stable_sort(v.begin(),v.end())
#define sortd(v) stable_sort(v.begin(),v.end(),greater <> ())
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define I(a) insert(a)
#define F first
#define S second
const int N=1e9+7;

int power(int x, int y){ 
    int res = 1; 
    while (y > 0){
        if (y & 1) 
            res = ((res) * (x));
        res %= N; 
        y = y >> 1; 
        x = ((x) * (x)); 
    }
    return res; 
}

int powmod(int a,int b,int n){
    int x=1, y=a; 
    while (b > 0) {
        if (b%2 == 1) {
            x = (x*y) % n;
        }
        y = (y*y) % n; 
        b /= 2;
    
    }
    return x % n;
}

int32_t main(){
    fastIO
    int t=1;
    //cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector <int> v(n+1),dp(n+1,0);
        for(int i=1;i<=n;i++)
            cin>>v[i];
        dp[2]=dp[1]+abs(v[2]-v[1]);
        for(int i=2;i<=n;i++){
            dp[i]=dp[i-1]+abs(v[i]-v[i-1]);
            for(int j=1;j<=k;j++){
                if(i-j>=1)
                    dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
            }
        }
        cout<<dp[n]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = sc.next();
        if (n % 2 != 0) {
            System.out.print("No");
        } else {
            String hstr = str.substring(0, n/2);
            if (str.equals(hstr+hstr)) {
                System.out.print("Yes");
            } else {
                System.out.print("No");
            }
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;
typedef vector<ll> vll;
// ll gcd(ll a, ll b){if (b==0){return a;}return gcd(b, a%b);}
// for (ll i=0;i<n;i++) {
// sort(.begin(),.end());
int main(){
  ll n,ans=0,sum=0;
  cin>>n;
  vll a(n);
  for (ll i=0;i<n;i++) {
    cin>>a[i];
    sum+=a[i];
  }
  sort(a.begin(),a.end());
  if (n==2) {
    cout<<a[1]-a[0]<<endl;
    cout<<a[1]<<' '<<a[0]<<endl;
    return 0;
  }
  else {
    if (a[n-1]<0) {
      cout<<2*a[n-1]-sum<<endl;
      for (ll i=1;i<n-1;i++) {
        cout<<a[n-1]<<' '<<a[i]<<endl;
        a[n-1]-=a[i];
      }
      cout<<a[n-1]<<' '<<a[0]<<endl;
    }
    else if (a[0]>0) {
      cout<<sum-2*a[0]<<endl;
      for (ll i=1;i<n-1;i++) {
        cout<<a[0]<<' '<<a[i]<<endl;
        a[0]-=a[i];
      }
      cout<<a[n-1]<<' '<<a[0]<<endl;
    }
    else {
      for (ll i=1;i<n-1;i++) {
        if (a[i]<0) {
          ans-=a[i];
        }
        else {
          ans+=a[i];
        }
      }
      ans+=a[n-1]-a[0];
      cout<<ans<<endl;
      for (ll i=1;i<n-1;i++) {
        if (a[i]<0) {
          cout<<a[n-1]<<' '<<a[i]<<endl;
          a[n-1]-=a[i];
        }
        else {
          cout<<a[0]<<' '<<a[i]<<endl;
          a[0]-=a[i];
        }
      }
      cout<<a[n-1]<<' '<<a[0]<<endl;
    }
  }
}

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

int main() {
	int bg[4] = { 0 };
	int d1;
	char d2;
	char b[3];
	while (cin >> d1 >> d2 >> b) {
		switch (b[0]) {
		case 'A':
			if (b[1]) {
				++bg[2];
			}
			else {
				++bg[0];
			}
			break;
		case 'B':
			++bg[1];
			break;
		case 'O':
			++bg[3];
			break;
		default:
			break;
		}
	}
	for (int i = 0; i < 4; ++i) {
		cout << bg[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
import java.util.*;
import java.io.*;

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String s = br.readLine();	//１行目の文字を読み取る
        String p = br.readLine();	//２行目の文字を読み取る
        sb.append(s);				//sbに加えることにより文字の最後と最初を繋げた
        sb.append(s);
        if(sb.indexOf(p) != -1){
        	//指定文字列が対象文字列中の何番目に出現するかをindexOfで調べ
        	//対象文字列がなかった場合には-1が出るので!=条件にした
        	System.out.println("Yes");
        	//-1以外だったらYesが出力される
        }else{
        	System.out.println("No");
        	//-1だったらNoが出力される
        }
     }
}

Measured memory_bytes: 17048
n = int(input())
s = str(input())

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            i_pos = s.find(str(i))

            if i_pos == -1:
                continue

            j_pos = s.find(str(j), i_pos+1)

            if j_pos == -1:
                continue

            k_pos = s.find(str(k), j_pos+1)

            if k_pos == -1:
                continue

            ans += 1

print(ans)

Measured memory_bytes: 3064
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[4];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) System.out.println("YES");
		else System.out.println("NO");
	}
}

Measured memory_bytes: 23124
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var N int
	fmt.Scan(&N)
	sc.Split(bufio.ScanWords)
	a := make([]int, N)
	abs := make([]int, N)
	for i := 0; i < N; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	var mc int
	z := false
	for i := 0; i < N; i++ {
		if a[i] < 0 {
			mc++
			abs[i] = a[i] * -1
			continue
		}
		if a[i] == 0 {
			z = true
		}
		abs[i] = a[i]
	}

	var r int
	if mc%2 == 0 || z {
		for i := 0; i < N; i++ {
			r += abs[i]
		}
	} else {
		min := math.MaxInt64
		for i := 0; i < N; i++ {
			r += abs[i]
			min = Min(min, abs[i])
		}
		r -= min * 2
	}
	fmt.Println(r)

}
func Min(a, b int) int {
	if b < a {
		return b
	}
	return a
}


Measured memory_bytes: 3840
n,m = map(int, input().split())

a = 1
b = 10**5

for _ in range(m):
    l,r = map(int, input().split())
    if l > a:
        a = l

    if r < b:
        b = r

if a <= b:
    print(b-a+1)

else:
    print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
const int N=200005;

ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }

bool ch(int num, set <int> st) {
    while(num>0) {
        int dig=num%10;
        if(st.find(dig)!=st.end()) return 0;
        num/=10;
    }
    return 1;
}



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
    cout<<fixed<<setprecision(15);
    
    string s;
    cin>>s;
    int len=s.length();

    vector <char> q;

    for(int i=0;i<s.length();i++) {
        if(s[i]=='B') {
            if(!q.empty()) {
                q.pop_back();
            }
        }
        else {
            q.push_back(s[i]);
        }
    }

    

    for(int i=0;i<q.size();i++) {
        cout<<q[i];
    }


    return 0;
}


Measured memory_bytes: 256
/*input
5
abcab
*/

#include <bits/stdc++.h>

using namespace std;

const int MOD = 1e9 + 7;

int add(int a, int b) {
  int r = a + b;
  if (r >= MOD) r -= MOD;
  return r;
}

int mul(int a, int b) {
  return int((long long)a * b % MOD);
}

int sub(int a, int b) {
  int r = MOD + a - b;
  if (r >= MOD) r -= MOD;
  return r;
}

int cnt[32];

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

  int n;
  scanf("%d\n", &n);

  char s[100005];
  scanf("%s", s);

  for (int i = 0; i < n; ++i)
  {
    cnt[s[i]-'a']++;
  }

  int ans = 1;
  for (int i = 0; i < 26; ++i)
  {
    ans = mul(ans, cnt[i] + 1);
  }

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

  return 0;
} 

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n,a[SIZE] = {};
  ll ans = 0;

  scanf("%d",&n);

  for(int i=0;i<n;i++) scanf("%d",a+i);

  for(int i=0;i<n;i++){
    if(i>0){
      ans += min(a[i-1],a[i]);
      a[i] -= min(a[i-1],a[i]);
    }
    
    ans += a[i]/2;
    a[i]%=2;
  }
    
  printf("%lld\n",ans); 
  
  return 0;
}


Measured memory_bytes: 640
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
l2=sorted(l,key=lambda x:x[1])
d=dict()
for p,y in l2:
    if not p in d.keys():
        d[p]=dict()
    d[p][y]=len(d[p])+1
for p,y in l:
    print('{}'.format(p).zfill(6)+'{}'.format(d[p][y]).zfill(6))


Measured memory_bytes: 65416
from collections import deque, Counter
import sys
H, W = map(int, input().split())
count = 0
grid = ['s' for h in range(H)]
for h in range(H):
    grid[h] = list(input())
    tmp_count = Counter(grid[h])['#']
    if tmp_count == W:
        print(-1)
        sys.exit()
    count += tmp_count

deq = deque([(0, 0)])
visited = [[-1 for w in range(W)] for h in range(H)]
visited[0][0] = 0
route = 0
while deq:
    for _ in range(len(deq)):
        h, w = deq.popleft()
        #print(h, w)
        if (h, w) == (H - 1, W - 1):
            print(H * W - visited[h][w] - 1 - count)
            sys.exit()
        for j, k in ([-1, 0], [0, -1], [0, 1], [1, 0]):
            new_h, new_w = h + j, w + k
            if 0 <= new_h <= H - 1 and 0 <= new_w <= W - 1:
                if grid[new_h][new_w] != '#' and visited[new_h][new_w] == -1:
                    visited[new_h][new_w] = visited[h][w] + 1
                    deq.append((new_h, new_w))
print(-1)




Measured memory_bytes: 3436
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>


using namespace std;

long long A,B;

int main()
{
  cin >> A >> B;
  
  if(A==B)
  {
    cout << A;
  }
  else if(A%2==0)
  {
    if((B-A-1)%4==0)
    {
      cout << ((B-1)^B);
    }
    else if((B-A-1)%4==1)
    {
      cout << ((B-2)^(B-1)^B);
    }
    else if((B-A-1)%4==2)
    {
      cout <<((B-3)^(B-2)^(B-1)^B);
    }
    else
    {
      cout <<B;
    }
  }
  else
  {
    if((B-A-1)%4==0)
    {
      cout << (A^B);
    }
    else if((B-A-1)%4==1)
    {
      cout << (A^(B-1)^B);
    }
    else if((B-A-1)%4==2)
    {
      cout <<(A^(B-2)^(B-1)^B);
    }
    else
    {
      cout <<A;
    }
  }
  

}

Measured memory_bytes: 256
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


void func(LL &A, LL &B) {
	if (A % 2 == 1) {
		A--;
	}
	LL n = LL(A / 2);
	A -= n;
	B += n;
}	


int main() {
	LL A, B, K;
	cin >> A >> B >> K;

	REP(i, K) {
		if (i % 2 == 0) {
			func(A, B);
		} else {
			func(B, A);
		}
	}

	cout << A << " " << B << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().strip().split()))
q = int(input())
M = list(map(int, input().strip().split()))

d = []
for x in range(1 << n):
    b = '{:0{}b}'.format(x, n)
    d.append(sum(a[i] for i in range(n) if b[i] == '1'))

for m in M:
    print('yes' if m in d else 'no')

Measured memory_bytes: 44760
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
#include <functional>
#include <string.h>

#define LOP(N) for(int i=0; i<N; i++)
#define LOOP(i, N) for(int i=0; i<N; i++)
#define LOOP_s(i, start, end) for(int i=start; i<end; i++)

using namespace std;


int main() {
    int H, W;
    cin >> H >> W;
    int grid[50][50];
    char tmp;
    LOOP(r, H) {
        LOOP(c, W) {
            cin >> tmp;
            grid[r][c] = tmp;
        }
    }
    
    int rs, re, cs, ce, count;
    LOOP(r, H) {
        rs = r-1 < 0 ? 0 : r-1;
        re = r+1 >= H ? H-1: r+1;
        LOOP(c, W) {
            if (grid[r][c] == '#') {
                cout << '#';
                continue;
            }
            
            cs = c-1 < 0 ? 0 : c-1;
            ce = c+1 >= W ? W-1: c+1;
            // cout << r << c << rs << re << cs << ce << endl;
            count = 0;
            LOOP_s(rsub, rs, re+1) {
                LOOP_s(csub, cs, ce+1) {
                    if (grid[rsub][csub] == '#') ++count;
                }
            }
            cout << count;
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
struct RC {
    int r, c;
};

int dp[101][101];
int main()
{
    int N;
    cin >> N;
    vector<RC> rc(N);
    rep(i, N) {
        int r, c;
        cin >> r >> c;
        rc[i] = {r, c};
    }

    vector<vector<int>> dp(N, vector<int>(N, 1e9));
    rep(i, N) dp[i][i] = 0;

    repd(w, 1, N) {
        rep(i, N - w) {
            int j = i + w;
            repd(k, i, j) {
                chmin(dp[i][j], dp[i][k] + dp[k + 1][j] + rc[i].r * rc[k].c * rc[j].c);
            }
        }
    }

    cout << dp[0][N - 1] << endl;
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
using namespace std;
 int main(){
 	int n,m;
 	cin>>n;
 	int t[n];;
 	int s[n];;
 	for(int a=0;a<n;a++)
 	{
 		cin>>t[a];
 		s[a]=t[a];
	 }
	cin>>m;
	int p[m]={0};
	int x[m]={0};
	int sum[m]={0};
	for(int a=0;a<m;a++){
		cin>>p[a]>>x[a];
	}
	for(int z=0;z<m;z++){
	
	for(int j=0;j<n;j++){
		if(p[z]==(j+1)){
			t[j]=x[z];
		}
		sum[z]+=t[j];
		t[j]=s[j];
	}
}
for(int z=0;z<m;z++){
	printf("%d \n",sum[z]);
}

return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <bitset>
#include <set>
 
#define square(x) (x * x)
#define cube(x) (x * x * x)
#define is_square(x) square((long long)sqrt(x)) == x
 
using namespace std;
 
const int MAXN = 100005;
 
int n,ans;
long long x;
long long a[MAXN];
long long val[MAXN];
 
map<long long,int> cnt;
 
int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1;i <= n;i++)
	{
		cin >> x;
		for (long long j = 2;cube(j) <= x;j++)
			while (x % cube(j) == 0)
				x /= cube(j);
		cnt[a[i] = x]++;
		val[i] = 1;
		for (long long j = 2;cube(j) <= x;j++)
			if (x % j == 0)
			{
				if (x % square(j) == 0)
					val[i] *= j;
				else
					val[i] *= square(j);
				while (x % j == 0)
					x /= j;
			}
		if (is_square(x))
			val[i] *= (long long)sqrt(x);
		else 
			val[i] *= square(x);
	}
	if (cnt[1])
	{
		cnt[1] = 0;
		ans++;
	}
	for (int i = 1;i <= n;i++)
	{
		ans += max(cnt[a[i]],cnt[val[i]]);
		cnt[a[i]] = cnt[val[i]] = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 14336
ary = []
count = Hash.new(0)
while tmp = gets
  break if tmp.to_i == 0
  ary << tmp.to_i
end

ary.each do |ary_i|
  count[ary_i] += 1
end

max = count.map(&:last).max
# p count.select{|_,v| v == max }
count.select{|_,v| v==max}.sort_by{|k,_| k }.each do |k,_|
  puts k
end


Measured memory_bytes: 6868
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
int main() {
  int n;
  string s;
  cin >> n >> s;
  long long r, g, b;
  r = g = b = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      r++;
    } else if (s[i] == 'G') {
      g++;
    } else {
      b++;
    }
  }
  long long ans = r * g * b;
  int a = 0;
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      int k = 2 * j - i;
      /*
      if (k >= n) {
        cout << k << endl;
      }
      */
      if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i] && k < n) {
        //&&k < n
        a++;
      }
    }
  }
  cout << ans - a << endl;
  return 0;
}

// g++ lo.cpp
// ./a.exe
// g++ -o つくりたいふぁいるめい　もとのふぁいる.cpp
// https://atcoder.jp/contests/abc162/submissions/11913717

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

typedef long long LL;

int k,a,b;
LL ans;

int main()
{
	scanf("%d%d%d",&k,&a,&b);
	if (k<=a) {printf("%d\n",k+1);return 0;}
	k-=a-1;ans=a;
	if (b-a>2)
	{
		ans+=(LL)(b-a)*(k/2);
		k%=2;
	}
	ans+=k;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
l.sort(reverse=True)
s=l[0]
n-=2
for i in range(1,n):
	if n>1:
		s+=l[i]*2
		n-=2
	elif n==1:
		s+=l[i]
		n-=1
	else:
		break
print(s)

Measured memory_bytes: 94280
N=int(input())
L=[]
M=""
while N!=0:
  M=int((-1)*(N%(-2)))
  if N<0:
    N=int((N-1)/(-2))
  else:
    N=int(N/(-2))
  L.insert(0,str(M))
if len(L)==0:
  L=["0"]
print("".join(L))


Measured memory_bytes: 3060
using System;
class Program {
  static void Main(string[] args) {
    Program pg = new Program();
    int[] nums = pg.Ret_frm_str(Console.ReadLine().Split(' '));
    int a_b = nums[0] * nums[1];
    for (int cnt = 1; cnt < 4; cnt++) {
      if (a_b * cnt % 2 == 1) {
        Console.WriteLine("Yes");
        break;
      } else {
        if (cnt == 3) {
          Console.WriteLine("No");
        }
      }
    }
  }
  
  private int[] Ret_frm_str (string[] str) {
    return new int[] { int.Parse(str[0]), int.Parse(str[1]) };
  } 
}

Measured memory_bytes: 13140
#include <map>
#include <list>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int a,b,c;
int main()
{
	fast; 
	cin>>a>>b>>c;
	if (a>c || a+b<c)
	   cout<<"NO"<<endl;
	else
	   cout<<"YES";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,i;
    int m,ans=0;
    int count=0;
    string s;
    std::cin >>s ;
    n=s.size();
    for (i=0;i<n;i++){
        if(i%2==0&&s[i]=='0')count++;
        if(i%2==1&&s[i]=='1')count++;
        }
    ans = min(count,n-count);
    std::cout << ans << std::endl;
    //else std::cout << 2*max(a,b)-1 << std::endl;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  N = readInts()[0]
  A = readInts()
  B = readInts()

  ans = 0
  carry = 0
  B.append(0)
  for i, b in enumerate(B):
    n = min(A[i], carry)
    restA = A[i] - n
    m = min(restA, b)
    ans += n + m
    carry = b - m
  print(ans)

if __name__ == "__main__":
  main()


Measured memory_bytes: 19156
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

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

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

typedef long long ll;

const ll MOD = 1e9 + 7;

class ACircle {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int r;
	    in >> r;
	    out << r * r << "\n";
	}
};


signed main() {
	ACircle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#import sys
#input=sys.stdin.readline
N,W=map(int,input().split())
w,v=[0]*N,[0]*N

for i in range(N):
    w[i],v[i]=map(int,input().split())
V=sum(v)
dp=[[float('inf')]*(V+1) for i in range(N+1)] #初期化はfor より *の方が早い

dp[0][0]=0
for i in range(N):
    for j in range(V+1):
        if j-v[i]>=0:
            dp[i+1][j]=dp[i][j-v[i]]+w[i]
        dp[i+1][j]=min(dp[i][j],dp[i+1][j])

for j in range(V+1):
    if dp[N][j]<=W:
        res=j
print(res)
# stdinなし

Measured memory_bytes: 312016
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  long K;cin>>K;
  int p;char q='1';
  for(int i=0;i<s.size();i++){
    if(s.at(i)!='1'){
      p=i;
      q=s.at(i);
      break;
    }
  }
  
  if(p+1>K)cout<<1<<endl;
  else cout<<q<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=20005;
ll n;
vip a;

int main(){
	cin>>n;
	a=vip(n);
	for(int i=0;i<n;i++){
		ll x,y,z;
		cin>>x>>y>>z;
		a[i]={x+y,{x,z}};
	}
	sort(a.begin(),a.end());
	vl dp(M);
	ll res=0;
	for(int i=0;i<n;i++){
		P p=a[i].second;
		ll x=a[i].first,y=p.first,z=p.second;
		for(int j=x-y;j>=0;j--) dp[j+y]=max(dp[j+y],dp[j]+z);
	}
	for(int i=0;i<M;i++) res=max(res,dp[i]);
	cout<<res<<endl;
}

Measured memory_bytes: 384