akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    vector<ll> A(5);
    rep(i, 5) cin >> A[i];
    sort(A.begin(), A.end(), [](ll &a, ll &b) {
        return (10 - a % 10) % 10 < (10 - b % 10) % 10;
    });
    ll ans = 0;
    rep(i, 4) {
        ans += A[i] + (10 - A[i] % 10) % 10;
    }
    cout << ans + A.back() << endl;
    return 0;
}


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

#define ll long long
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MD 1000000007

char sep[2] = {' ', '\n'};

int main() {
  int i, j, k, n, m, l;

  ll a[110][110], b[110][110], c[110][110];
  cin >> n >> m >> l;
  rep(i, n) rep(j, m) cin >> a[i][j];
  rep(i, m) rep(j, l) cin >> b[i][j];
  rep(i, n) rep(j, l) {
    c[i][j] = 0;
    rep(k, m) c[i][j] += a[i][k] * b[k][j];
    cout << c[i][j] << sep[j == l - 1];
  }
  cout << flush;

  return 0;
}
  

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

int p, q, a, n;
double D;
typedef pair<int,int> P;

int dfs (int sum, int mul, int last, int count) {
    double d = (double)sum / mul;
    if (count > n) return 0;
    if (mul > a) return 0;
    if (d > D) return 0;
    if (d == D) return 1;


    int ret = 0;
    for (int i = last; i <= a / mul; i++) {
        ret += dfs(sum * i + mul, mul * i, i, count+1);
    }

    return ret;
}

int main ()
{
    while (cin >> q >> p >> a >> n, q + p + a + n) {
        D = (double)q / p;
        cout << dfs(0, 1, 1, 0) << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

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

const int INF = 1000000007;

ll factorial(ll n){
    if(n == 1){
        return 1;
    }
    return ( n * factorial(n-1) ) % INF;
}
int main(void){
    ll n, m;
    cin >> n >> m;
    if(abs(n-m) > 1){
        cout << "0" << endl;
        return 0;
    }
    ll sum = ((factorial(n) % INF ) * (factorial(m) % INF)) % INF;
    ll ans;
    if(n == m){
        ans = (sum*2) % INF;
    }else{
        ans = sum;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

vll dx = {1, 0, -1, 0};
vll dy = {0, 1, 0, -1};

//zaki_UnionFind
class UnionFind
{
    std::vector<int> data;
  public:
    UnionFind(int size) : data(size, -1) {}
    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
        if (data[y] < data[x])
                std::swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y)
    {
        return root(x) == root(y);
    }
    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x)
    {
        return -data[root(x)];
    }
};

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

    ll n, m;
    cin >> n >> m;
    UnionFind uf(2 * n);
    vll p(n);
    REP(i, n){
        cin >> p[i];
    }
    ll x, y;
    REP(i, m){
        cin >> x >> y;
        x--;
        y--;
        uf.unite(x, y);
    }
    ll res = 0;
    REP(i, n){
        if(uf.find(p[i] - 1, i)) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    static boolean check_num( int x ) {
    	if( ( x % 3 == 0 ) ) {
    		System.out.print( " " + x );
    		return true;
    	} else {
    		return false;
    	}
    }

    static boolean include3( int x, int i ) {
    	if ( ( x % 10 == 3 ) ) {
    		System.out.print( " " + i );
    		return true;
    	} else {
    		return false;
    	}
    }

    public static void main(String[] args) {

        int num = 0;

        Scanner sc= new Scanner( System.in );

        num = sc.nextInt();
        for ( int i = 1 ; i <= num ; i++ ) {
        	if ( check_num( i ) ) {
        		continue;
        	} else {
        		int x = i;
        		while ( x > 0 ) {
        			if ( include3( x , i ) ) {
        				break;
        			}
            		x /= 10;
        		}
        	}

        }
		System.out.print( "\n" );
        sc.close();
    }
}


Measured memory_bytes: 33084
N = gets.to_i
AB = N.times.map { gets.split.map(&:to_i) }.sort_by! { |ab| ab[1] }

t = 0
AB.each do |ab|
  t += ab[0]
  if t > ab[1]
    puts 'No'
    exit
  end
end

puts 'Yes'


Measured memory_bytes: 22520
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[101],b[101];
int main()
{
	int n,k,i,j,p,q;int ans=0;cin>>n>>k;
	for (i=1;i<=n;i++) cin>>a[i];
	for (i=1;i<=k && i<=n;i++)
	{
		for (j=0;j<=i;j++)
		{
			int l=j,r=i-j,cnt=0,res=0;
			for (p=1;p<=l;p++) b[++cnt]=a[p];
			for (p=n;p>n-i+j;p--) b[++cnt]=a[p];
			sort(b+1,b+cnt+1);
			for (p=1;p<=k-i && p<=cnt;p++) if (b[p]>=0) break;else b[p]=0;
			for (p=1;p<=cnt;p++) res+=b[p];
			ans=max(ans,res);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
from collections import deque

n=int(input())
E=[[]for _ in range(n)]
L=[]
for i in range(n-1):
   a,b=map(int,input().split())
   E[a-1].append(b-1)
   L.append(b-1)

que=deque([0])
ans=[0]*n
while que:
   s=que.popleft()
   color=1
   for ni in E[s]:
      if color==ans[s]:
         color+=1
      ans[ni]=color
      color+=1
      que.append(ni)
print(max(ans))
for ni in L:
   print(ans[ni])


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

using namespace std;
int main(){
  long x,y;
   cin >>x >> y;
  
  long res=10000000000;
  
  if(y-x>=0) res=min(res,y-x);
  if(-y-x>=0) res=min(res,(-y-x)+1);
  if(y+x>=0) res=min(res,(y+x)+1);
  if(-y+x>=0) res=min(res,(-y+x)+2);
  
  cout << res << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  char s[10], t[10];
  scanf("%s\n", s);
  scanf("%s", t);
  int ans = 0;
  for (size_t i = 0; i < 3; i++) {
    ans = (s[i] == t[i]) ? ans+1 : ans;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using in6 = int64_t;
using ind = double;
using vi = vector<in6>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<in6,in6>;
using psi = pair<string,in6>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 n;
  cin >> n;
  vi data(n-1);
  rep(i,n-1) cin >> data[i];
  vi ans(n,0);
  rep(i,n-1) {
    ans[data[i]-1]++;
  }
  rep(i,n) cout << ans[i] << "\n";
}


Measured memory_bytes: 6276
#include<iostream>
#include<string>
using namespace std;
int main() {
	int N;
	cin >> N;
	string W[101];
	bool ans = true;
	for (int i = 0; i < N; ++i) {
		cin >> W[i];
	}
	for (int i = 0; i < N-1; ++i) {
		if (W[i][W[i].size() - 1] != W[i + 1][0])
			ans = false;
		for (int j = i + 1; j < N; ++j) {
			if (W[i] == W[j])
				ans = false;
		}
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define lf long double
#define F first
#define S second
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <pair <ll,ll> >vii;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007

ll num(ll n)
{
    return log10(n)+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        if(num(i)%2==1)
            ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
N,M = [int(s) for s in input().split()]
p = [0] + [int(s) for s in input().split()]
par = []
counter = 0

for i in range(N+1):
    par.append(i)
    
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def same(x,y):
    return find(x) == find(y)

def union(x,y):
    x = find(x)
    y = find(y)
    if x != y:
        par[x] = y

for i in range(M):
    x,y = [int(s) for s in input().split()]
    union(x,y)
    
for i in range(1,N+1):
    if same(i,p[i]):
        counter += 1

print(counter)

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

void dfs(int idx, map<int, set<int>>& tree, const vector<int>& add, int add_sum, vector<int>& ans, vector<bool>& is_used)
{
    if(is_used[idx]) return;
    add_sum += add[idx];
    ans[idx] = add_sum;
    is_used[idx] = true;
    for(auto i : tree[idx])
    {
        if(is_used[i]) continue;
        dfs(i, tree, add, add_sum, ans, is_used);
    }
    add_sum -= add[idx];
    return;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, Q;
    cin >> N >> Q;
    vector<int> A(N-1), B(N-1);
    for(int i=0; i<N-1; i++)
    {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }
    vector<int> P(Q), X(Q);
    for(int i=0; i<Q; i++)
    {
        cin >> P[i] >> X[i];
        P[i]--;
    }

    map<int, set<int>> tree;
    for(int i=0; i<N-1; i++)
    {
        tree[A[i]].insert(B[i]);
        tree[B[i]].insert(A[i]);
    }
    vector<int> add(N, 0);
    for(int i=0; i<Q; i++)
    {
        add[P[i]] += X[i];
    }

    vector<int> ans(N);
    vector<bool> is_used(N, false);
    int add_sum = 0;
    dfs(0, tree, add, add_sum, ans, is_used);

    for(int i=0; i<N; i++)
    {
        cout << ans[i];
        if(i!=N-1) cout << ' ';
        else cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 67324
s=input()
a=int(s[:2])
b=int(s[2:])
if 1<=a<=12 and 1<=b<=12:
  print('AMBIGUOUS')
elif 1<=b<=12:
  print('YYMM')
elif 1<=a<=12:
  print('MMYY')
else:
  print('NA')


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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define str string
#define s_vec(data,name,vertical,horizontal) vector<vector<(data)>> (name)((vertical),vector<(data)>((horizontal)));


int main(){
    str a,b,c;
    cin>>a>>b>>c;
    
    cout<<a.at(0)<<b.at(0)<<c.at(0);



}

Measured memory_bytes: 256
n,k=map(int, input().split())
a=list(map(int, input().split()))
f=list(map(int, input().split()))

a.sort()
f.sort()
f.reverse()
x=0
for i in range(n):
    y=a[i]*f[i]
    x=max(x,y)

l=-1
r=x
z=0
while l+1<r:
    mid =(l+r)//2
    for i in range(n):
        if a[i]*f[i]<=mid:
            continue
        else:
            z+=-(-(a[i]*f[i]-mid)//f[i])
    if z<=k:
        r=mid
        z=0
    else:
        l=mid
        z=0
print(r)
    
    

    
    
    





Measured memory_bytes: 119500
#include<stdio.h>

int main()
{
    long long a,b,c,k;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
    if(k>a+b){
        c=k-a-b;
    }
    else if(k>a){
        c=0;
    }
    else if(k<=a){
        c=0;
        a=k;
    }
    printf("%lld", a-c);
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
#define ld long double
int main(){
    int64_t a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    int64_t dis = abs(a-b);
    if(v<=w){
        cout<<"NO"<<endl;
        return 0;
    }
    double time = double(dis)/abs(v-w);
    if(dis%abs(v-w)==0){
        if(dis/abs(v-w)<=t){
            cout<<"YES"<<endl;
        }   
        else{
            cout<<"NO"<<endl;
        }
        return 0;
    } 
    if(time<=t){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}   

Measured memory_bytes: 3596
#include<stdio.h>
#define MAX 10000
#define NIL -1

void setDepth(int,int);
int setHeight(int);
int getSibling(int);
void print(int);

typedef struct{
  int parent,left,right;
}Node;

Node T[MAX];
int n,D[MAX],H[MAX];

int main(){
  int v,l,r,root = 0;
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].parent = NIL;
  for(i=0;i<n;i++){
  scanf("%d %d %d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL)T[l].parent=v;
    if(r!=NIL)T[r].parent=v;
  }
  for(i=0;i<n;i++)if(T[i].parent==NIL)root=i;
  setDepth(root,0);
  setHeight(root);
  for(i=0;i<n;i++)print(i);
  return 0;
}

void setDepth(int u,int d){
  if(u==NIL)return;
  D[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL)h1=setHeight(T[u].left)+1;
  if(T[u].right!=NIL)h2=setHeight(T[u].right)+1;
  return H[u]=(h1>h2?h1:h2);
}

int getSibling(int u){
  if(T[u].parent==NIL)return NIL;
  if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL)
    return T[T[u].parent].left;
   if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL)
     return T[T[u].parent].right;
   return NIL;
}
void print(int u){
  int deg=0;
  
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  if(T[u].left!=NIL)deg++;
  if(T[u].right!=NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent==NIL){
    printf("root\n");
  }
  else if(T[u].left==NIL && T[u].right==NIL){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}

  



Measured memory_bytes: 2052
import java.awt.*

inline fun str() = readLine()!!
inline fun int() = str().toInt()
inline fun long() = str().toLong()

inline fun read(d:String = " ") = str().split(d)
inline fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
inline fun list() = list {toInt()}

inline fun <T> T.print() = this.also(::println)

fun main() {
	abc000X()
}

fun abc000X() {
	val (h1,m1,h2,m2,k) = list()

	val a = h1*60+m1
	val b = h2*60+m2

	println(b-a-k)
}


Measured memory_bytes: 36248
n=int(input())
mx=10**18
z=1

a=[int(i) for i in input().split()]
for i in a:
    if i==0:
        print(0)
        quit()

for i in a:
    z*=i
    if z>mx:    z=-1
    if z==-1:   break

if z>mx or z<0   : z=-1
print(z)



Measured memory_bytes: 21792
#左側にある連続した1の長さがKより小なら1以外の最初に現れる数、そうでないなら１を出力する
a=input()
k=int(input())
if int(a)<10:
    a=str(int(a)*11)
i=0
x=0
#左から順にみて、1ならKを1小さくし右に一つずれる、１以外があらわれるかｋが負になったら終了
while k>=0:
    if a[i]=='1':
        k-=1
        i+=1
        if k==0:
            x=1
            k=-1
    else: 
        k=-1
#微妙な調整のために、終了ステータスがｘの数を見ればわかるようになっている
#breakの代わりにK=-1で終了させている
print(a[i-x])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;



int main(){
    string a,b,c;
    cin >> a >> b >> c;
    if (a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int A, B, C;
  cin >> A >> B >> C;
  if(A%2 && B%2 && C%2) cout << min({A*B, B*C, C*A}) << endl;
  else cout << 0 << endl;

  return 0;
}


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

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buf;
    while(getline(ss, buf, sep)){
        v.push_back(buf);
    }
    return v;
}

int main(){
    int a, b; cin >> a >> b;
    cout << (b % a == 0 ? a + b : b - a) << endl;
}

Measured memory_bytes: 256
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var K = one[0];
  var X = one[1];
  myout((K * 500 >= X) ? "Yes" : "No");
}


Measured memory_bytes: 30980
S = input()
if S == "SUN":
    print(7)
elif S =="MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
elif S == "SAT":
    print(1)

Measured memory_bytes: 3060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, D, A = MAP()
XH = [LIST() for _ in range(N)]
XH.sort(key=lambda x:x[0])
X, H = zip(*XH)
right = [0]*N
for i, x in enumerate(X):
	right[i] = bisect(X, x+2*D)

damage = [0]*(N+1)
ans = 0
for i, (X, H) in enumerate(XH):
	if i != 0:
		damage[i] += damage[i-1]
	H -= damage[i]
	if H > 0:  # 追加攻撃が必要
		n = -(-H//A)
		ans += n
		d = A*n
		damage[i] += d
		damage[right[i]] -= d  # 範囲外の敵
print(ans)


Measured memory_bytes: 72772
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  cin >> n;
  int a = 100000;
  rep(i,n){
    a *= 1.05;
    if(a % 1000 != 0){
      a -= a%1000;
      a += 1000;
    }
    //cout << a << endl;
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 3016
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
int f[100][14];
int p[100][15];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n)
    {
        rep(j, 10)
        {
            cin >> f[i][j];
        }
    }
    rep(i, n)
    {
        rep(j, 11)
        {
            cin >> p[i][j];
        }
    }
    int ans = -(1 << 30);
    for (int b = 1; b < (1 << 10); b++)
    {
        int sum = 0;
        rep(i, n)
        {
            int count = 0;
            rep(j, 10)
            {
                if ((b >> j & 1) && f[i][j])
                    count++;
            }
            sum += p[i][count];
        }
        ans = max(ans, sum);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		double ans = 0;
		for(int i = 1; i <= N; i++) {
			int a = i;
			int h = 0;
			while(a < K) {
				h ++;
				a *= 2;
			}
			ans += (double)1/N/Math.pow(2,h);
		}
		System.out.println(ans);
	}

}


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

const int N = 200 * 1000 + 5;

int a[N];
int last[N];
int main() {
	int n;
	bool b = false;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i > 0 && a[i] > a[i - 1] + 1) {
			b = true;
		}
	}
	if (b || a[0] > 0) {
		cout << -1;
		return 0;
	}
	long long ans = 0;
	int x = 0;
	for (int i = 0; i < n; i++) {
		bool b = false;
		if (a[i] == 0) {
			x = i;
			b = true;
		}
		else if (a[i] == a[i - 1] + 1) {
			x = i;
			ans++;
			b = true;
		}
		if (!b)
			ans += a[i];
		//cout << i << " " << x << endl;
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, long long Z, long long W, std::vector<long long> a) {
    if (N >= 2) cout << max(abs(a[N - 2] - a[N - 1]), abs(a[N - 1] - W)) << endl; else cout << abs(a[N - 1] - W) << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long Z;
    scanf("%lld", &Z);
    long long W;
    scanf("%lld", &W);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &a[i]);
    }
    solve(N, Z, W, std::move(a));
    return 0;
}


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

#define REPI(i, n) for(int i = 0; i <= n; i++)
#define REPJ(j, n) for(int j = 0; j <= n; j++)

using ll = long long;
using namespace std;

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

    int k, s, ans = 0; cin >> k >> s;

    REPI(i, k)
        REPJ(j, k)
            if(i + j <= s & s - i - j <= k) ans++;
    cout << ans;
}


Measured memory_bytes: 256
def s():
 n=int(input())+1
 e=[input().split()for _  in[0]*~-n]
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for i in range(n):
  for r in range(n-i-1):
   c=r+i+1
   for j in range(r+1,c):
    x=m[r][j]+m[j][c]+p[r]*p[j]*p[c]
    if not 0<m[r][c]<=x:m[r][c]=x
 print(m[r][c])
if'__main__'==__name__:s()


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

using namespace std;
int n;
long long d;
map<pair<int, int>, int> v;
int main(){
    cin>>n>>d;
    int ans=0;
    for (int i=0; i<n; i++){
        long long x, y;
        cin>>x>>y;
        if (x*x+y*y<=d*d) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3640
N = gets.chomp.to_i
S = N.times.map{gets.chomp.to_s}

countac = 0
countwa = 0
counttle = 0
countre = 0

(0...N).each do |i|
  if S[i] == "AC"
    countac += 1
  elsif S[i] == "WA"
    countwa += 1
  elsif S[i] == "TLE"
    counttle += 1
  elsif S[i] == "RE"
    countre += 1
  end
end

puts "AC x #{countac}"
puts "WA x #{countwa}"
puts "TLE x #{counttle}"
puts "RE x #{countre}"

Measured memory_bytes: 21460
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
    int N,M;
    cin>>N>>M;
    vector<vector<int>> edges(N);
    REP(i,M)
    {
        int a,b;
        cin>>a>>b;
        a--;b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<int> route;
    set<int> use;
    int now = 0;
    route.push_back(now);
    use.insert(now);

    start:;
    for(auto next:edges[now])
    {
        if(use.find(next)==use.end())
        {
            now=next;
            route.push_back(now);
            use.insert(now);
            goto start;
        }
    }

    reverse(route.begin(),route.end());
    now=0;
    start2:;
    for(auto next:edges[now])
    {
        if(use.find(next)==use.end())
        {
            now=next;
            route.push_back(now);
            use.insert(now);
            goto start2;
        }
    }

    cout << route.size()<<endl;
    for(auto pos:route)
    {
        cout << pos + 1 << " ";
    }
    cout << endl;
   
    return 0;
}


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

int main() {
    #ifndef ONLINE_JUDGE
    freopen("D:/Sublime/Rough/input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    //std::cout << std::fixed;
    //std::cout << std::setprecision(6);
    Fastio;
    int x;
    cin>>x;
    if(x==0)
        cout<<1;
    else
        cout<<0;
    
    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    
    return 0;
}

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

int main(){
    string a,b,c;
    int x,y;
    cin >> a >>b;
    y =0;
    x = a.length();
    for(int i;i < x;i++){
        if(a.at(i)!=b.at(i)){
            y =1;
        }
    }
    if(y == 0){
        cout << "Yes" ;
    }else{
        cout <<"No";
    }

    
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll b=0,c=0,a,d=0,e,m,n,k,x,o=0,p,q,x1,y1,z,max1=0,s=0,ans,r,i1=-1;
    string t,u;

    cin>>n>>x;
    ll l;
    for(ll i=0;i<n;i++){
        cin>>l;
        o+=l;
        if(o>x){
            i1=i+1;
            b=1;
            break;
        }    
    }
    if(b==0)i1=n+1;
    cout<<i1<<endl;
    
}




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

int main(){
  
  int h,n;
  cin >>h >>n;
  vector<int> vec(n);
  int sum = 0;
  
  for(int i=0; i<n; i++){
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  
  if(sum >= h){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 640
def main():
    n, k, *xy = map(int, open(0).read().split())
    _x_ = sorted(xy[::2])
    ans = 4 * 10 ** 18
    for _x in _x_:
        for x_ in _x_[1:]:
            w = x_ - _x
            c = 0
            _h_ = []
            for x, y in zip(xy[::2], xy[1::2]):
                if _x <= x <= x_:
                    c += 1
                    _h_.append(y)

            if c >= k:
                _h_.sort()
                h = min(_h_[i + k - 1] - _h_[i] for i in range(c - k + 1))
                ans = min(ans, h * w)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9108
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e5+10;
int n,a[N],b[N],p[N],A[N],B[N],p1[N],p2[N];
bool vis[N];

int main(){
	n=read();
	For(i,1,n) a[i]=read(),A[i]=a[i],p1[i]=i;
	For(i,1,n) b[i]=read(),B[i]=b[i],p2[i]=i;
	sort(A+1,A+1+n),sort(B+1,B+1+n);
	For(i,1,n) if (!(A[i]<=B[i])) return puts("No"),0;
	For(i,1,n) if (A[i]<=B[i-1]) return puts("Yes"),0;
	sort(p1+1,p1+1+n,[](int x,int y){
		return a[x]<a[y];
	});
	sort(p2+1,p2+1+n,[](int x,int y){
		return b[x]<b[y];
	});
	For(i,1,n) p[p1[i]]=p2[i];
	for (int i=1;!vis[i];i=p[i]) vis[i]=1;
	For(i,1,n) if (!vis[i]) return puts("Yes"),0;
	puts("No");
}

Measured memory_bytes: 6340
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq

MOD = 1000000007

def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
    S, W = get_inputs(int)
    if W >= S:
        print("unsafe")
    else:
        print("safe")



if __name__ == '__main__':
    main()


Measured memory_bytes: 27136
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
map<ll,ll>mp;
map<ll,ll>mpp;
int main()
{
    ll n,k=0,i,j,l,sum=0,s;

    cin>>n;

     vector<ll>v;

    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){

            k=__gcd(i,j);

            v.push_back(k);

        }
    }

    for(i=0;i<v.size();i++){
        for(j=1;j<=n;j++){
            k=__gcd(j,v[i]);
            sum+=k;
        }
    }

    cout<<sum<<endl;

}


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

int main() {
	int N;
    cin >> N;
    int successCount = 0;
    for (int i =0 ;i < N; i++) {
        int D1, D2;
        cin >> D1 >> D2;
        if (D1 != D2) {
            successCount = 0;
            continue;
        }

        successCount++;

        if (successCount >= 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
N = int(input())
plan = [list(map(int, input().split())) for i in range(N)]

dp = [[0] * 3 for i in range(N)]
dp[0][0] = plan[0][0]
dp[0][1] = plan[0][1]
dp[0][2] = plan[0][2]



for i in range(len(plan)-1):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + plan[i+1][k])
print(max(dp[-1]))

Measured memory_bytes: 75096
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define int long long
#define puts(x) cout<<x<<endl
#define inf 243000000000000001
#define minf -243000000000000001
#define in(v) (v).begin(),(v).end()





int knapSack(int W, int wt[], int val[], int n) 
{ 
    int i, w; 
    int K[n + 1][W + 1]; 
  
    // Build table K[][] in bottom up manner 
    for (i = 0; i <= n; i++) { 
        for (w = 0; w <= W; w++) { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
                K[i][w] = max( 
                    val[i - 1] + K[i - 1][w - wt[i - 1]], 
                    K[i - 1][w]); 
            else
                K[i][w] = K[i - 1][w]; 
        } 
    } 
  
    return K[n][W]; 
} 
  


signed main(){
    int n,w;
    cin>>n>>w;
    int val[n+1];
    int wt[n+1];

    for( int i=0;i<n;i++ ){
        cin>>wt[i];
        cin>>val[i];
    }
    
    puts(knapSack(w,wt,val,n));
}


Measured memory_bytes: 82284
n = gets.to_i
a = gets.split.map(&:to_i).sort

n.times do |i|
  match = if n.odd?
            a[i] == (i + 1) / 2 * 2
          else
            a[i] == i / 2 * 2 + 1
          end
  unless match
    puts '0'
    exit
  end
end

puts 2 ** (n / 2) % (10 ** 9 + 7)


Measured memory_bytes: 9712
#include <iostream>

using namespace std;

int n;
string s;

int main(){

    string s1, s2;

    cin >> n >> s; 
    
    s1 = s.substr(0,n/2);
    s2 = s.substr(n/2,n);

    if(s1 == s2) cout << "Yes" << endl;
    else cout << "No" << endl;
  
  	return 0;
}

Measured memory_bytes: 256
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let (n,w) = {
        let line = get_input();
        let mut split = line.split_whitespace();
        let n:usize = split.next().unwrap().parse().unwrap();
        let w:usize = split.next().unwrap().parse().unwrap();
        (n,w)
    };
    let mut ws:Vec<usize> = Vec::new();
    let mut vs:Vec<i64> = Vec::new();

    for _ in 0..n {
        let line = get_input();
        let mut split = line.split_whitespace();
        ws.push(split.next().unwrap().parse().unwrap());
        vs.push(split.next().unwrap().parse().unwrap());
    }

    let mut dp = [[0; 100010]; 110];

    for i in 0..n {
        for j in 0..w+1 {
            dp[i + 1][j] = dp[i][j];
            if j >= ws[i] && dp[i][j - ws[i]] + vs[i] > dp[i][j] {
                dp[i + 1][j] = dp[i][j - ws[i]] + vs[i]
            }
        }
    }

    println!("{}", dp[n].iter().max().unwrap());
}

Measured memory_bytes: 91004
/*
 KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU LIKE!"
 -PICT,PUNE! :)
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 1000005
#define N 1000001
#define MAX2N 1*1000 + 10
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define forcj(p,n) for(ll j=p;j<(ll)n;j++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test ll t;cin>>t;for(ll testi=1;testi<=t;testi++)
#define djokovic  freopen("input00.txt", "r", stdin);freopen("output00.txt", "w", stdout);
ll gcd(ll a, ll b) {    if (b == 0) return a;    return gcd(b, a % b);}
ll lcm(ll a, ll b) {    return (a / gcd(a, b) * b);}
ll expo(ll x, ll y) {
    ll res = 1; x = x % mod; while (y > 0) {
        if (y & 1)res = (1ll * res * x) % mod;
        y = y >> 1; x = (1ll * x * x) % mod;
    } return res;
}
ll ncr(ll n, ll r) { ll res = 1; if (r > n - r)r = n - r; for (ll i = 0; i < r; i++) {  res *= n - i;  res /= i + 1; } return res;}
ll max(ll a, ll b) {return (a > b) ? a : b;}
bool prime(ll n) {ll i; for (i = 2; i <= sqrt(n); i++) {if (n % i == 0)return false;} return true;}
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b)
{   if (a.second == b.second)
        return a.first < b.first;
    return (a.second < b.second);
}
//https://www.youtube.com/watch?v=WTJSt4wP2ME

ll rr[] = {0, 1, 1, 1, 0, -1, -1, -1,};
ll cc[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll n, m, x, y, k, a[MAXN], p[MAXN];
void solve()
{
    cin >> n;
    ll sum = 0;
    forci(1, n + 1)
    {
        forcj(1, n + 1)
        {
            for (ll k = 1; k <= n; k++)
                sum += gcd(i, gcd(j, k));
        }
    }
    cout << sum;
}
signed main()
{
    bolt;
    //djokovic;
    solve();
}




Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
ll m=1000000007;
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%m;
p=(p*p)%m;
k>>=1;
}
return a;
}
using namespace std;
int main()
{
ll n;
cin>>n;
ll i,j,ans=0;
string s;
cin>>s;
for(i=0;i<n;i++)
{
if(s[i]==s[i+1])
{
while(s[i]==s[i+1])
i++;
ans++;
}
else
{
ans++;
}
}
cout<<ans;
}

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

bool is_A(string s){
	int size = s.size();
	if(size < 6) return false;
	if(s[0] != '>' || s[1] != '\'') return false;
	if(s[size - 1] != '~') return false;
	if(s[2] != '=') return false;
	int count = 0;
	int i = 2;
	while(s[i] == '='){ count++; i++; }
	if(s[i++] != '#') return false;
	for(int j = 0; j < count; j++, i++){
		if(s[i] != '=') return false;
	}
	if(i == size - 1) return true;
	else return false;
}

bool is_B(string s){
	int size = s.size();
	if(size < 6) return false;
	if(s[0] != '>' || s[1] != '^') return false;
	if(s[size - 1] != '~' || s[size - 2] != '~') return false;
	int i = 2;
	while(i < size - 2){
		if(s[i] != 'Q' || s[i+1] != '=') return false;
		i += 2;
	}
	return true;
}

int main(){
	string s;
	int n;
	cin >> n;
	getline(cin, s);
	for(int i = 0; i < n; i++){
		getline(cin, s);
		if(is_A(s)) cout << "A";
		else if(is_B(s)) cout << "B";
		else cout << "NA";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl
#define printV(v) for(int zxc=0;zxc<v.size()-1;zxc++){cout << v[zxc] << " ";} cout << v.back() << endl;

int main() {
    map<string, vector<int>> dic;
    string s;
    int page;
    while (cin >> s) {
        cin >> page;
        dic[s].push_back(page);
    }
    vector<pair<string, vector<int>>> dic_s;
    for (auto itr = dic.begin(); itr != dic.end(); itr++) {
        dic_s.push_back(make_pair(itr->first, itr->second));
    }
    sort(ALL(dic_s));
    REP(i, dic_s.size()) {
        vector<int> v = dic_s[i].second;
        cout << dic_s[i].first << endl;
        sort(ALL(v));
        printV(v);
    }
    return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;

signed main() {
  int n,m;cin>>n>>m;
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
  priority_queue<int> r;
  rep(i,n){
    pair<int,int> p;cin>>p.first>>p.second;
    q.push(p);
  }
  int ans = 0;
  
  repd(i,1,m+1){
    while(q.size() && q.top().first == i){
      r.push(q.top().second);
      q.pop();
    }
    if(r.size()){
      ans += r.top();r.pop();
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3568
N,K=[int(s) for s in input().split()]
S=list(input())
if S[K-1]=="A":
  S[K-1]="a"
elif S[K-1]=="B":
  S[K-1]="b"
else:
  S[K-1]="c"
print("".join([str(n) for n in S]))

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
int p[200][4]={0};
int main(){
int n,m,j,i,d,r,f,t,h;
cin>>n;
for(i=0;i<n;i++){
	for(j=0;j<3;j++)cin>>p[i][j];
}
for(i=0;i<3;i++){
	for(j=0;j<n;j++){
		f=0;
		if(p[j][i]!=0){
			for(h=j+1;h<n;h++){
				if(p[j][i]==p[h][i]){
					p[h][i]=0;
					f=1;
				}
			}
			if(f==1)p[j][i]=0;
		}
	}
}
for(i=0;i<n;i++){
	for(j=0;j<3;j++)p[i][3]+=p[i][j];
}
for(i=0;i<n;i++)cout<<p[i][3]<<endl;
return 0;
}
















	

Measured memory_bytes: 3096
import itertools
import numpy as np

N, M, Q = map(int, input().split())
G = [list(map(int, input().split())) for i in range(Q)]

A_cands = np.array(list(itertools.combinations_with_replacement(list(range(1, M+1)), N)))      

scores = np.zeros(len(A_cands), dtype=np.int64)

for i in range(Q):
    a, b, c, d = G[i]
    cond = A_cands[:, b - 1] - A_cands[:, a - 1] == c
    scores += cond * d
print(scores.max())

Measured memory_bytes: 46812
import java.util.Scanner;


public  class Main  {


	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int counter = 0;
		while(true) {
			if(counter>=C)break;
			if(A>B)break;
			
			B = B-A;
			counter++;
		}
		System.out.println(counter);
		
	}}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n = read::<i64>();   
    let ans:i64 = (1..n+1).fold(1,|x,y| (x * y)%  (1000000000 + 7));
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include<iostream>
using namespace std;
long long p[100005];
int main(){
  int n; cin >> n;
  for(int i=1;i<=n;i++) cin >> p[i];
  int cnt = 0;
  for(int i=1;i<=n;i++){
    if(p[i] == i){
      cnt++;
      swap(p[i],p[i+1]);
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1024
import sys

n=int(input())
wordList=[input()]
for _ in range(n-1):
    word =input()
    if word in wordList:
        print("No")
        sys.exit()
    elif wordList[-1][-1]!=word[0]:
        print("No")
        sys.exit()
    wordList.append(word)
print("Yes")


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

const long long MOD = 2;

void solve(long long N, std::vector<long long> A){
    bool flag = true;
    int count = 0;
    while (flag) {
        for (int i=0; i<N; i++) {
            if (A[i] % 2 != 0) flag = false;
            A[i] /= 2;
        }
        if (flag == true) count++;
    }
    cout << count << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005
 
int n;
 
int main()
{
    _FastIO;
    cin >> n;
    cout << pow(n , 3) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int x;
    double p;
    cin >> x >> p;
    cout << fixed << setprecision(7) << (x + 1) / 2 / p * 100.0 << endl;

    return 0;
}


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

# n=int(input())
# A=list(map(int,input().split()))
mod=1000000007
n,k=map(int,input().split())
n+=1
ans=0
l=0
r=0
for i in range(k):
    l+=i
posl=k-1
for i in range(n-k,n):
    r+=i
posr=n-k


while l!=r:
    ans+=r-l+1
    ans%=mod
    posl+=1
    l+=posl
    posr-=1
    r+=posr
print(ans+1)


Measured memory_bytes: 9200
#include <iostream>

using namespace std;

typedef long long ll;

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

    int n;
    cin >> n;

    int cnt[n];
    fill(cnt, cnt+n, false);

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        if (i - a >= 0 && i - a < n) {
            ans += cnt[i-a];
        }

        if (i + a < n) {
            cnt[i+a]++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4440