akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi p(N);
  rep(i,N) {
    cin >> p[i];
  }
  int mi = INF;
  int ans = 0;
  rep(i,N) {
    if(p[i] < mi) {
      mi = p[i];
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

const int S = 2020;
int comb[S+10][S+10];
signed main() {
    int N, K; cin >> N >> K;
    for(int i=0; i<S; i++) {
        comb[i][0] = 1;
        for(int j=1; j<=i; j++) {
            (comb[i][j] += comb[i-1][j-1] + comb[i-1][j]) %= MOD;
        }
    }

    int n = N+K-1;
    int r = N;
    cout << comb[n][r] << endl;
    return 0;
}



Measured memory_bytes: 26084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();

        StringBuilder ans = new StringBuilder();

        for(int i=0; i<a.length; i++){
            ans.append(String.valueOf(a[i]));
            if(i <= b.length-1){
                ans.append(String.valueOf(b[i]));
            }
        }
        System.out.println(ans);
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
void setd(vector<long> &a,long n){
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a.begin(),a.end());
}
int main(){
  long n,ans=0;cin>>n;
  vector<long> a(n),b(n),c(n);
  setd(a, n);setd(b, n);setd(c, n);
  for(int i=0; i<n; i++){
    long anum=max(0L,min(n,(long)(lower_bound(a.begin(),a.end(),b[i])-a.begin())));
    long cnum=max(0L,min(n,(long)(c.end()-upper_bound(c.begin(),c.end(),b[i]))));
    ans+=anum*cnum;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5636
n, m = map(int, input().split())
ds = list(map(int, input().split()))
ds = sorted(ds)
dp = [100000] * (n+1)
dp[0] = 0

for i in range(n):
	for d in ds:
		if (i + d <= n):
			dp[i + d] = min(dp[i + d], dp[i] + 1)

print(dp[n])




Measured memory_bytes: 7256
l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',  'y', 'z'];print(l[l.index(input()) + 1])

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

 using namespace std;

 int main() {
   int N;
   cin >> N;
   vector<int> a(N);
   for (int i = 0; i < N; i++) cin >> a.at(i);

   int sum_min = 4000000;
   for (int i = -100; i <= 100; i++) {
     int sum = 0;
     for (int j = 0; j < N; j++) {
       sum += (a.at(j) - i) * (a.at(j) - i);
     }
     sum_min = min(sum_min, sum);
     if (sum_min == 0) break;
   }
   cout << sum_min << endl;
}


Measured memory_bytes: 256
#include <iostream>

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

using namespace std;



int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = n;
    rep(i,n-1) {
        if(s[i]==s[i+1]) --ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    int a,b;
    cin >> a >> b;
    if(a+b>=10) cout << "error" <<endl;
    else cout << a+b << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
  int a,b,i;
  scanf("%d%d",&a,&b);
  if(a<b)
    for(i=0;i<b;i++)
      printf("%d",a);
  else
    for(i=0;i<a;i++)
      printf("%d",b);
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
const int maxn = 200000 + 5;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n, A, B;
vector<int> G[maxn], T[maxn];

bool flag[maxn];
int fa[maxn][21], dep[maxn];

void dfs(int u, int f = 0) {
    fa[u][0] = f;
    dep[u] = dep[f] + 1;
    for(int i = 1; i <= 20; ++i) fa[u][i] = fa[fa[u][i-1]][i-1];
    for(int i = 0; i < int(G[u].size()); ++i) if(G[u][i] != f) { dfs(G[u][i], u); }
}
int lca(int u, int v) {
    if(dep[u] < dep[v]) swap(u, v);
    for(int i = 20; i >= 0; --i) 
        if(dep[fa[u][i]] >= dep[v]) u = fa[u][i];

    if(u == v) return u;
    for(int i = 20; i >= 0; --i) if(fa[u][i] ^ fa[v][i])
        u = fa[u][i], v = fa[v][i];
    return fa[u][0];
}
inline int dis(int u, int v) { return dep[u] + dep[v] - (dep[lca(u, v)] << 1); }

void Input() {
    n = read<int>();
    A = read<int>();
    B = read<int>();

    for(int i = 1; i < n; ++i) {
        static int x, y;
        x = read<int>();
        y = read<int>();
        T[x].pb(y), T[y].pb(x);
    }

    for(int i = 1; i < n; ++i) {
        static int x, y;
        x = read<int>();
        y = read<int>();
        G[x].pb(y), G[y].pb(x);
    }

    dfs(B, 0);

    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j < int(T[i].size()); ++j) {
            int v = T[i][j];
            if(dis(i, v) > 2) flag[i] = flag[v] = true;
        }
    }
}

int ans = 1;
void Dfs(int u, int fu = 0, int step = 1) {

    if(dep[u] == step) return;
    if(flag[u]) {
        puts("-1"); 
        exit(0);
    }

    chkmax(ans, dep[u]);
    for(int i = 0; i < int(T[u].size()); ++i) if(T[u][i] != fu) {
        if(dep[T[u][i]] > step) Dfs(T[u][i], u, step + 1);
    }
}

int main() {
#ifdef Wearry
    freopen("b.in", "r", stdin);
    freopen("b.out", "w", stdout);
#endif

    Input();
    Dfs(A, 0);
    printf("%d\n", (ans - 1) << 1);
    
    return 0;
}


Measured memory_bytes: 50940
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
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]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

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

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

const int M=1e6;
int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(auto &i:a) cin>>i;
	vi b(M);
	ll res=1;
	for(int i=1;i<n;i++){
		res+=Div(a[0],a[i]);
		ll g=gcd(a[0],a[i]);
		int x=a[i]/g;
		for(int j=2;j*j<=x;j++) if(x%j==0){
			int t=0;
			while(x%j==0){
				t++;
				x/=j;
			}
			b[j]=max(b[j],t);
		}
		if(x>1) b[x]=max(b[x],1);
	}
	for(int i=0;i<M;i++){
		for(int j=0;j<b[i];j++) (res*=i)%=mod;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;
 
int main(){
  ll n;
  cin>>n;
  string s;
  while(n>0){
    if(n%26==0){
      s+='z';
      n=(n-26)/26;
    }
    else{
      s+=char('a'+n%26-1);
      n/=26;
    }
  }
  reverse(s.begin(),s.end());
  cout<<s<<endl;
}

Measured memory_bytes: 3616
function main(input) {
  let [word, ...rest] = input
    .toLowerCase()
    .split(/\n/)
    .filter(v => !!v);
  rest.pop();
  const ans = rest
    .join(" ")
    .split(" ")
    .filter(w => w === word);
  console.log(ans.length);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 15440
#nn
from fractions import gcd 
n = int(input())
a = list(map(int, input().split()))
ans = 1
left = [0]
right = [0]

for i in range(n):
  left.append(gcd(left[-1], a[i]))
  right.append(gcd(right[-1], a[-(i+1)]))
right.reverse()

for i in range(n):
  ans = max(ans, gcd(left[i], right[i+1]))
print(ans)

Measured memory_bytes: 16148
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 998244353;

// ref: https://github.com/atcoder-live/library/blob/master/mint.cpp
struct mint
{
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD)
  {
  }
  mint operator-() const
  {
    return mint(-x);
  }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const
  {
    return mint(*this) += a;
  }
  mint operator-(const mint a) const
  {
    return mint(*this) -= a;
  }
  mint operator*(const mint a) const
  {
    return mint(*this) *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const
  {
    return pow(MOD - 2);
  }
  mint &operator/=(const mint a)
  {
    return *this *= a.inv();
  }
  mint operator/(const mint a) const
  {
    return mint(*this) /= a;
  }
};
istream &operator>>(istream &is, const mint &a)
{
  return is >> a.x;
}
ostream &operator<<(ostream &os, const mint &a)
{
  return os << a.x;
}

mint dp[3010][3010];

int main()
{
  long long N;
  scanf("%lld", &N);
  long long S;
  scanf("%lld", &S);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
  }

  dp[0][0] = 1;
  mint ans = 0;
  for (int i = 0; i < N; ++i)
  {
    for (int j = 0; j <= S; ++j)
    {
      dp[i + 1][j] += dp[i][j] * 2;
      if (j >= A[i])
        dp[i + 1][j] += dp[i][j - A[i]];
    }
  }
  cout << dp[N][S] << endl;

  return 0;
}


Measured memory_bytes: 74492
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll h, w;
    cin >> h >> w;
    ll ans = 0;
    if (w == 1 || h == 1)
    {
        cout << 1 << endl;
    }
    else if (w % 2 == 0)
    {
        cout << h * w / 2 << endl;
    }
    else
    {
        cout << h * (w - 1) / 2 + h / 2 + h % 2 << endl;
    }
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a[3];
    int ans = 2000;
    cin >> a[0] >> a[1] >> a[2];
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            if (i != j)
                for (int k = 0; k < 3; k++)
                    if (j != k && i != k)
                        ans = min(ans, abs(a[i] - a[j]) + abs(a[j] - a[k]));
    cout << ans << endl;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){

	int n,k;cin >> n >> k;
	vector<ll> v(n);
	REP(i,n)cin >> v[i];

	sort(ALL(v));

	ll ans = LLINF;
	REP(i,n-k+1){
		ans = min(ans, v[i+k-1] - v[i]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
import sys

N = int(input())
H = list(map(int, input().split()))

if N == 1:
    print("Yes")
    sys.exit()

for i in reversed(range(1, N)):
    if H[i-1] > H[i]:
        H[i-1] -= 1

    if H[i-1] > H[i]:
        print("No")
        sys.exit()

print("Yes")


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

int main(){
    int k,x;
    cin>>k>>x;
    string ans=(500*k>=x)?"Yes":"No";
    cout<<ans<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int w,h,n;
  cin >> w >> h >> n;
  int l=0,d=0,u=h,r=w; 
  rep(i,n){
    int x,y,a;
    cin >> x >> y >> a;
    if(a==1 && l<x) l=x;
    if(a==2 && r>x) r=x;
    if(a==3 && d<y) d=y;
    if(a==4 && u>y) u=y;
  }
  cout << (r-l<0||u-d<0 ? 0 :(r-l)*(u-d)) << endl;
  return 0;
} 

Measured memory_bytes: 3624
import sys
n,m = map(int,input().split())
d = [None]*n
for i in range(n):
    a,b = map(int,input().split())
    d[i] = [a,b]

d.sort(key=lambda x: x[0])

ryoukin = 0
cnt = 0
for lst in d:
    for i in range(lst[1]):
        ryoukin += lst[0]
        cnt += 1
        if cnt == m:
            print(ryoukin)
            sys.exit()

Measured memory_bytes: 57304
#include <iostream>
#include <cmath>
#include <math.h>
#include <algorithm>

int gcd(int a, int b, int c) {
	int m = std::min(a, b);
  	m = std::min(m, c);
  	for(int n = m ; n > 0 ; n--) {
      if(a % n == b % n && b % n == c % n && c % n == 0)
        return n;
    }
    return 1;
}

int main() {
  
  int k;
  std::cin >> k;
  long long sum = 0;
  for(int a = 1 ; a <= k ; a++) {
    for(int b = 1 ; b <= k ; b++) {
      for(int c = 1 ; c <= k ; c++) {
   	      sum += std::__gcd(a, std::__gcd(b, c));
      }
    }
  }
  std::cout << sum;
 
  return 0;
  
}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<long long> a(n);
  for(int i=0;i<n;i++)cin >> a.at(i);
  vector<long long> dp(n,20000000000);
  dp.at(0) = 0;
  for(int i=0;i<n;i++){
    for(int j=1;j<=k && i+j<n;j++){
      dp.at(i+j) = min(dp.at(i+j),dp.at(i)+abs(a.at(i)-a.at(i+j)));
    }
  }
  cout << dp.at(n-1) << endl;
}

Measured memory_bytes: 1792
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))
a = len([*filter(lambda x: x<=A,P)])
b = len([*filter(lambda x: A<x<=B,P)])
c = len([*filter(lambda x: B<x,P)])
print(min(a,b,c))

Measured memory_bytes: 9104
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll a,b;
    cin >> a >> b;
    if(a == 0 || b == 0 || (a < 0 && 0 < b)) {
        cout << "Zero" << endl;
        return 0;
    }
    if(a > 0 && b > 0) {
        cout << "Positive" << endl;
        return 0;
    }
    if(a < 0 && b < 0 && (b-a+1)%2 == 0) {
        cout << "Positive" << endl;
        return 0;
    }  
    if(a < 0 && b < 0 && (b-a+1)%2 != 0) {
        cout << "Negative" << endl;
        return 0;
    }  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    rep(i,k){
        if(b <= a){
            b *= 2;
        }
        else{
            if(c <= b){
                c *= 2;
            }
        }
    }
    if(a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3648
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int t, s, i;

    for(i = 0;i < 4;i++){
      t = sc.nextInt(); s = sc.nextInt();
      if(t == 1)out.println(6000 * s);
      else if(t == 2)out.println(4000 * s);
      else if(t == 3)out.println(3000 * s);
      else out.println(2000 * s);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

int32_t main()
{
  int n,k;
  cin>>n>>k;
  int v[n+1],w[n+1];
  v[0]=0;
  w[0]=0;
  for(int i=1;i<=n;i++)
  {
      cin>>w[i]>>v[i];
  }
int dp[n+1][k+1];
for(int i=0;i<=n;i++)
{
    for(int j=0;j<=k;j++)
    {
        if(i==0||j==0)
        {
        dp[i][j]=0;
        }
        else if(w[i]<=j)     
        {
            dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
        }
       else
        {
          dp[i][j]=dp[i-1][j];  
        }
        
        
    }
}

        cout<<dp[n][k];
}

 
    
  

Measured memory_bytes: 79104
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    n = int(input())
    a = []
    
    col = 1

    for _ in range(n):
        a.append(-int(input()))
    
    if n == 1:
        print(col)
        exit()

    b = [a[0]]
    m = 1

    for i in range(1,n):
        x = bisect_right(b,a[i])
        
        if x == m:
            col += 1
            b.append(a[i])
            m += 1
        else:
            b[x] = a[i]
        
    print(col)

    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

# vim: set foldmethod=marker:}}}


Measured memory_bytes: 117972
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N; cin >> N;
    vector<int> L(N);
    REP(i, 0, N) cin >> L[i];

    int ans = 0;
    REP(i, 0, N) {
        REP(j, i + 1, N) {
            REP(k, j + 1, N) {
                if (L[i] == L[j] || L[i] == L[k] || L[j] == L[k]) continue;
                if (L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[k] + L[j] > L[i]) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

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

        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int space = A - (B * 2);

        if (space >= 0) {
            System.out.println(space);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define F first
#define S second
#define ld long double
#define rep(i,n) for (int i =0;i < (n); ++i)
#define vi vector<ll>
#define all(v) (v).begin(),(v).end()
const int inf = 1e9 + 10;

void solve() {
	ll r; cin >> r;
	cout << 2 * M_PI*r;
}

int main() {

	FASTIO;

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(25);
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3760
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N,M=rl()
AB = []
for i in range(N):
    a,b=rl()
    AB.append([a,b])

AB.sort()

ans = 0
for a,b in AB:
    if M == 0:
        break
    if M > b:
        ans += a*b
        M -= b
    else:
        ans += a*M
        M -= M

print(ans)

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

int main(){
	int n;
  	cin>>n;
  	int i;
	int d[100][2];
  	for(i=0;i<n;i++){
    	cin>>d[i][0]>>d[i][1];
    }
  	for(i=0;i<n-2;i++){
    	if(d[i][0]==d[i][1]&&d[i+1][0]==d[i+1][1]&&d[i+2][0]==d[i+2][1]){
        	cout<<"Yes";
          	return 0;
        }
    }
  	cout<<"No";
}


Measured memory_bytes: 3072
#include<string>
#include<sstream>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<ios>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<type_traits>
#include<random>
#include<vector>
#include<map>

using namespace std;

string p_bit(int x,int p,int N)
{
	int keta = 1;
	for(int nn=1;pow(p,nn)<=x;nn++)
	{
		keta = nn + 1;
	}

	int seisububun[keta];
	int amari = x;
	for(int ii=0;ii<keta;ii++)
	{
		seisububun[keta-1-ii] = amari/pow(p,(keta-1-ii));
		int y = pow(p,(keta-1-ii));
		amari = amari%y;
	}
	string sss;
	for(int jj=0;jj<keta;jj++)
	{	
		string SS = to_string(seisububun[keta-1-jj]);
		sss =  sss + SS;
	}
	stringstream W;
	W << setfill('0') << right << setw(N) << sss; 
	return (W.str());
}

int count1(string r) {
  int count = 0;

  for (int i = 0; i < r.size(); i++)
    if (r[i] == '1') count++;

  return count;
}
int count2(string r) {
  int count = 0;

  for (int i = 0; i < r.size(); i++)
    if (r[i] == '2') count++;

  return count;
}
int count3(string r) {
  int count = 0;

  for (int i = 0; i < r.size(); i++)
    if (r[i] == '3') count++;

  return count;
}

int main()
{
	int N,A,B,C;
	cin >> N >> A >> B >> C;
	int l[N];
	for(int i=0;i<N;i++)
	{
		cin >> l[i];
	}

	int sum = 10000000;
	
	for(int i=0;i<pow(4,N);i++)
	{
		bool judge = 1;
		string s = p_bit(i,4,N);
		int la=0;
		int lb=0;
		int lc=0;
		for(int j=0;j<N;j++)
		{
			if(s[j]=='1')
			{
				la = la + l[j];
			}
			else if(s[j]=='2')
			{
				lb = lb + l[j];
			}
			else if(s[j]=='3')
			{
				lc = lc + l[j];
			}

		}
		int result = 0;
		int ka,kb,kc;
		if(count1(p_bit(i,4,N))==0){judge=0;}else{ka = count1(p_bit(i,4,N));}
		if(count2(p_bit(i,4,N))==0){judge=0;}else{kb = count2(p_bit(i,4,N));}
		if(count3(p_bit(i,4,N))==0){judge=0;}else{kc = count3(p_bit(i,4,N));}
		result = abs(A-la)+abs(B-lb)+abs(C-lc)+(ka-1+kb-1+kc-1)*10;

		if(sum>result && judge == 1)	
		{
			sum = result;
		}
		
	}
	cout << sum << endl;	
}




Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
//const long long int MOD = 1000003;
//const int MOD = 998244353;
const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	M = accumulate(v.begin(), v.end(), 0LL);
	long long int ans = M;
	for (auto i : v) {
		M -= i * 2;
		ans = min(ans, abs(M));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using ii = pair<int, int>;
 
void solve();
 
clock_t start_time;
double get_current_time() {
	return (double)(clock() - start_time) / CLOCKS_PER_SEC;
}
 
int main() {
	// freopen("input.txt", "r", stdin);
	// freopen();

	ios_base::sync_with_stdio(false);
	solve();
}
 
/* ========== actual code starts here ========== */
 
#define fi first
#define re return
#define se second
#define in insert
#define pb push_back
#define eb emplace_back
#define y1 y123123123123
#define all(x) x.begin(), x.end()
 
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repx(i, x, n) for (int i = x; i < (n); i++)
#define repd(i, n, d) for (int i = 0; i < (n); i += d)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepd(i, n, d) for (int i = (n) - 1; i >= 0; i -= d)
 
#ifdef artem
	#define debug(x) x
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define debug(x)
#endif

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	map<int, int> posa;
	for(int i = 0; i < n; i++) {
		cin >> a[ i ];
		posa[ a[ i ] ] = i;
	}
	vector<int> b = a;
	sort(all(b));
	map<int, int> posb;
	for(int i = 0; i < n; i++) {
		posb[ b[ i ] ] = i;
	}

	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(posa[ a[ i ] ] % 2 != posb[ a[ i ] ] % 2) {
			++ans;
		}
	}
	cout << (ans + 1) / 2 << endl;
}

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

bool is_connected(vector<vector<int>> const &graph, pair<int, int> const &e_rm) {
    queue<int> q;
    unordered_set<int> visited;
    q.push(0);
    while (!q.empty()) {
        int from = q.front();
        q.pop();
        if (visited.count(from)) continue;
        visited.insert(from);
        for (auto const &to: graph[from]) {
            bool ng = (from == e_rm.first && to == e_rm.second) || (from == e_rm.second && to == e_rm.first);
            if (!ng) {
                q.push(to);
            }
        }
    }
    bool result = visited.size() == graph.size();
    return result;
}

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

    vector<pair<int, int>> edges;
    vector<vector<int>> graph(N);

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        graph[a].push_back(b);
        graph[b].push_back(a);
        edges.emplace_back(a, b);
    }

    int cnt = 0;
    for (int e = 0; e < M; e++) {
        bool conn = is_connected(graph, edges[e]);
        if (!conn) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  char S[2*N][2*N];
  REP(i,N)REP(j,N)cin>>S[i][j];
  REP(i,N)REP(j,N)S[i+N][j]=S[i][j];
  REP(i,N)REP(j,N)S[i][j+N]=S[i][j];
  REP(i,N)REP(j,N)S[i+N][j+N]=S[i][j];
  lint ans=0;
  REP(B,N){
    bool f=true;
    REP(i,N)FOR(j,i,N){
      if(S[i][j+B]!=S[j][i+B])f=false;
    }
    ans+=f;
  }
  ans*=N;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

vector<int> primes;

int main(){ _;
  for(int i=6,j=2;i<300000;i+=j,j=(j==2?5:2)){
    for(int p:primes){
      if(p*p>i) break;
      if(i%p==0) goto np;
    }
    primes.push_back(i);
  np:;
  }
  int n;
  while(cin>>n,n!=1){
    cout<<n<<":";
    for(int p:primes){
      if(n%p==0)cout<<" "<<p;
      if(p>=n){break;}
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1368
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	mp::cpp_dec_float_100 a;
	mp::cpp_dec_float_100 b;
	cin>>a>>b;
	a*=b;
	//a=(cpp_int)a;
	string ans=a.str();
	rep(i,size(ans)){
		if(ans[i]=='.'){
			
			break;
		}else{
			cout<<ans[i];
		}
	}
	cout<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int x[n+1];
	for (int i=1;i<=n;i++)
	{
		cin>>x[i];
		
	}
	for (int i=1;i<=n;i++)
	{
		if (x[i]%2==1)
		{
			cout<<"first"<<endl;
			return 0;
		}
	}
	cout<<"second"<<endl;
	return 0;
}

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

int countABC(int count,string s)
{
  if(s.find("ABC")==::string::npos)
    return count;
  else{
    s = s.substr(s.find("ABC")+1);
    return countABC(++count,s);
  }
}

int main(){
  int n; string s;
  cin >> n >> s;
  int ans = countABC(0,s);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 123456

int primes[N*2+1];

int main(){
  int i,j,n,in;
  for(i=2;i<N+1;i++){
    if(!primes[i-1]){
      for(j=i*2;j<N*2+1;j+=i) primes[j-1]=-1;
    }
  }
  for(i=1;i<2*N+1;i++) primes[i]+=primes[i-1]+1;
  do{
    scanf("%d",&in);
    if(!in) break;
    printf("%d\n",primes[2*in-1]-primes[in-1]);
  }while(1);
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<LL> l_, r_;
  Solver(LL n) : n(n), l_(n), r_(n){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> l_[i] >> r_[i];
      r_[i]++;
    }
    LL maxl = *max_element(l_.begin(), l_.end());
    LL minr = *min_element(r_.begin(), r_.end());
    if (minr > maxl) {
      for (int i = 0; i < n; ++i) {
        if (r_[i] > maxl) r_[i] -= (minr - maxl);
      }
    }

    cout << calc(l_, r_) + 2 * max(minr - maxl, 0ll) << endl;
  }
  LL calc(vector<LL> l, vector<LL> r) {
    LL ret = 0;
    for (int i = 0; i < n; ++i) {
      ret = max(ret, r[i] - l[i]);
    }
    vector<LL> LR;
    for (int i = 0; i < n; ++i) {
      LR.push_back(l[i]);
      LR.push_back(r[i]);
    }
    sort(LR.begin(), LR.end());
    LR.erase(unique(LR.begin(), LR.end()), LR.end());
    for (int i = 0; i < n; ++i) {
      l[i] = distance(LR.begin(), lower_bound(LR.begin(), LR.end(), l[i]));
      r[i] = distance(LR.begin(), lower_bound(LR.begin(), LR.end(), r[i]));
    }
    LL maxlid = distance(l.begin(), max_element(l.begin(), l.end()));
    LL minrid = distance(r.begin(), min_element(r.begin(), r.end()));

    LL ll = l[minrid];
    LL lr = r[minrid];
    LL rl = l[maxlid];
    LL rr = r[maxlid];

    vector<LL> dp(LR.size());
    for (int i = ll; i <= lr; ++i) {
      dp[i] = rr;
    }

    for (int i = 0; i < n; ++i) {
      if (l[i] < r[minrid] && r[i] > l[maxlid]) {
        dp[l[i]] = min(dp[l[i]], r[i]);
      } else if (r[i] <= l[maxlid]) {
        ll = max(ll, l[i]);
        lr = min(lr, r[i]);
      } else {
        rl = max(rl, l[i]);
        rr = min(rr, r[i]);
      }
    }
    for (int i = r[minrid] - 1; i >= l[minrid]; --i) {
      dp[i] = min(dp[i], dp[i + 1]);
    }
    LL ret2 = 0;
    for (int i = l[minrid]; i < r[minrid]; ++i) {
      LL tll = ll;
      LL tlr = lr;
      LL trl = rl;
      LL trr = rr;
      tll = max(tll, (LL)i);
      trr = min(trr, dp[i + 1]);
      LL tmp = LR[trr] - LR[trl] + LR[tlr] - LR[tll];
      ret2 = max(ret2, tmp);
    }
    return max(ret, ret2);
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 6640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

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

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

int main() {
  int y, m, d;
  char c;
  
  cin >> y >> c >> m >> c >> d;
  
  if (m >= 5)
    cout << "TBD" <<endl;
  else
    cout << "Heisei" <<endl;
}

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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  string s;
  cin>>s;
  if(s=="RRR") drop(3);
  if(s=="SRR") drop(2);
  if(s=="RSR") drop(1);
  if(s=="RRS") drop(2);
  if(s=="RSS") drop(1);
  if(s=="SRS") drop(1);
  if(s=="SSR") drop(1);
  if(s=="SSS") drop(0);
  return 0;
}


Measured memory_bytes: 3652
### main

while true
  n = gets.strip.to_i
  break if n == 0

  gens = 7.times.map{0}

  n.times.each do
    age = gets.strip.to_i

    if age >= 60
      gens[6] += 1
    else
      gens[age / 10] += 1
    end
  end

  gens.each{|gn| puts gn}
end

Measured memory_bytes: 6104
n=input()
s=raw_input()
mod=10007
dp=[[0]*(1<<3) for _ in xrange(n+1)]
for i in xrange(n):
    if s[i]=="J":shift=2
    elif s[i]=="O":shift=1
    else:shift=0
    for j in xrange(8):
        if j&(1<<shift)!=0:
            if i==0:
                if j&(1<<2)!=0:
                    dp[i+1][j]=1
            else:
                for k in xrange(8):
                    if k&j!=0:
                        dp[i+1][j]+=dp[i][k]
                        dp[i+1][j]=dp[i+1][j]%mod
print(sum(dp[n])%mod)

Measured memory_bytes: 6540
N = int(input())
S = str(input())
n = 0
A = []
B = []
if N % 2 == 0:
  n = int(N / 2)
  for i in range(0, n):
    A.append(S[i])
    B.append(S[n+i])

if A == B and N % 2 == 0:
    print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,M;
  cin>>N>>M;
  ll n=min({N,M}),m=max({N,M});
  if(m==1){
    cout<<1<<endl;
  }else if(n==1){
    cout<<m-2<<endl;
  }else{
    cout<<(N-2)*(M-2)<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int main() {
    //数値を numbers　に代入
    int N;
    cin >>N;
    vector<int> numbers(N) ;
    for(int i=0;i<N;i++){
        numbers.at(i)=(i+1);
    }
    // 1からNまでのなかで、2で割れるものを探す
    int trial_num=0;
    for(int i=0;i>=0;i++){
        bool finished =  false;
        for(int j=0;j<N;j++){
            int b = (numbers.at(j) % 2);
            if(b==1){
            }
            else{
                numbers.at(j) = (numbers.at(j)/2);
                finished = true;
            }
        }
        
        if(finished){
            trial_num = trial_num + 1;
        }
        else{
            break;
        }
        
    }

    int answer = 1;
    for(int i=0;i<trial_num;i++){
        answer = 2 * answer;
    }
    cout << answer << endl;
}

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

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  int rest = 1;
  for (int i = 1; i < N; i++){
    if (S[i - 1] != S[i]){
      rest++;
    }
  }
  cout << rest << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

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

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

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;

int n, x;
deque <int> q;
int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n ; ++i){
        scanf("%d", &x);
        if(i % 2 == 0) q.push_front(x);
        else q.push_back(x);
    }
    if(n % 2 == 0){
        while(!q.empty()){
            printf("%d ", q.front());
            q.pop_front();
        }
    }
    else{
        while(!q.empty()){
            printf("%d ", q.back());
            q.pop_back();
        }

    }
    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll ZERO = 0;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N,K;
    cin >> N >> K;
    int ret = 0;
    while(N > 0) {
        N /= K;
        ret++;
    }
    cout << ret << endl;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string ns;
  getline(cin, ns);
  int a = 0, b = 1;
  for (auto c : ns) {
    int d = c - '0';
    int a_ = min(a + d, b + 10 - d);
    b = min(a + d + 1, b + 9 - d);
    a = a_;
  }
  cout << a << '\n';
}


Measured memory_bytes: 1948
import sys
from operator import itemgetter
input = sys.stdin.readline  # NOQA


def main():
    N, K = map(int, input().split())
    ab = [None] * N
    for i in range(N):
        ab[i] = tuple(map(int, input().split()))

    ab.sort(key=itemgetter(0))
    
    cnt = 0
    for a, b in ab:
        cnt += b
        if cnt >= K:
            ans = a
            break
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 18216
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
int main() {
	int x, y;
	cin >> x >> y;
	rep(i, 101) {
		rep(j, 101) {
			if (i + j == x && 2 * i + 4 * j == y) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3592
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;

const int N = 1e5 + 5;
const int M = N * 25;

int dis[N] ,n , m  , k , fir[N] , ne[M] , to[M] , C[M] , cnt;
bool vis[N];

void add(int x , int y , int z) {
	ne[++ cnt] = fir[x]; fir[x] = cnt; to[cnt] = y; C[cnt] = z;
}

struct NODE {
	int no , Dis;
	friend bool operator < (NODE xxx , NODE yyy) {
		return xxx.Dis > yyy.Dis;
	}
};

priority_queue<NODE>q;

#define Df(no , Dis) (NODE){no , Dis}
#define Foreachson(i , x) for(int i = fir[x];i;i = ne[i])

void dijkstra(void) {
	for(int i = 1;i <= 9;++ i) q.push(Df(i , i));
	while(!q.empty()) {
		while(!q.empty() && vis[q.top().no]) q.pop();
		if(q.empty()) break;
		NODE ind = q.top(); q.pop();
		vis[ind.no] = 1; dis[ind.no] = ind.Dis;
		Foreachson(i , ind.no) {
			int V = to[i];
			if(vis[V]) continue;
			q.push(Df(V , dis[ind.no] + C[i]));
		}
	}
	printf("%d\n" , dis[0]);
}

int main(void) {
	scanf("%d" , &n);
	for(int i = 1;i < n;++ i) {
		for(int j = 0;j <= 9;++ j) {
			add(i , (i * 10 + j) % n, j);
		}
	}
	dijkstra();
}

Measured memory_bytes: 23408
class Vector:
    def __init__(self):
        self.vec = []
    
    def push_back(self,x):
        self.vec.append(x)
    
    def random_access(self,p):
        return self.vec[p]

    def pop_back(self):
        self.vec.pop()

my_vec = Vector()

n = int(input())
for _ in range(n):
    args = input().split(' ')
    ope = args[0]
    if ope == '0':
        my_vec.push_back(int(args[1]))
    elif ope == '1':
        print(my_vec.random_access(int(args[1])))
    elif ope == '2':
        my_vec.pop_back()



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

int main(){
    string S;
    cin >> S;
    int64_t K;
    cin >> K;
    for(int i = 0;i < K;i++) {
        if(S.at(i) != '1') {
            cout << S.at(i) << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}

Measured memory_bytes: 256