akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
import pprint


def solve(N: int, M: int, Q: int, L: "List[int]", R: "List[int]", p: "List[int]", q: "List[int]"):
    mem = [[0] * N for i in range(N)]
    mem2 = [[0] * N for i in range(N)]
    for i in range(M):
        mem[L[i] - 1][R[i] - 1] += 1
    for h in range(N):
        for w in range(N):
            sum = mem[h][w]
            if h == 0 and w > 0:
                sum += mem2[h][w-1]
            elif w == 0 and h > 0:
                sum += mem2[h-1][w]
            elif h > 0 and w > 0:
                sum += mem2[h][w-1] + mem2[h-1][w] - mem2[h-1][w-1]
            mem2[h][w] = sum
    for i in range(Q):
        pc = p[i]-1
        qc = q[i]-1
        low = mem2[pc-1][qc] + mem2[qc][pc-1] - \
            mem2[pc-1][pc-1] if pc > 0 else 0
        sum = mem2[qc][qc] - low
        print(sum)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]"
    R = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]"
    q = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        p[i] = int(next(tokens))
        q[i] = int(next(tokens))
    solve(N, M, Q, L, R, p, q)


if __name__ == '__main__':
    main()


Measured memory_bytes: 30204
# https://atcoder.jp/contests/abc141/tasks/abc141_b
s = input()
sr = s[::2].replace("R", "").replace("U", "").replace("D", "")
sl = s[1::2].replace("L", "").replace("U", "").replace("D", "")
if sr or sl:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>
#include<map>

#define all(c) (c).begin(),(c).end()

using namespace std;

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

  map<char, char>mp;
  mp['A']='T';
  mp['C']='G';
  mp['G']='C';
  mp['T']='A';

  for(int i=0;i<t.size();i++)t[i]=mp[t[i]];

  cout << t << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main( void )
{
  int n,x,y,z;
  cin >> n;
  for( int i=0; i<n; i++ ){
    cin >> x >> y >> z;
    if( cin.eof() ) break;
    if( x > y ) swap( x, y );
    if( x > z ) swap( x, z );
    if( y > z ) swap( y, z );
    if( x*x + y*y == z*z ) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, T;
    cin >> n >> T;
    int c[n], t[n];
    for (int i = 0; i < n; ++i)
        cin >> c[i] >> t[i];
    int cost(-1);
    for (int i = 0; i < n; ++i)
    {
        if ((cost < 0 || c[i] < cost) && t[i] <= T)
        {
            cost = c[i];
        }
    }
    if (cost > 0)
        cout << cost << endl;
    else
    {
        cout << "TLE" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

ll power(ll a,ll b) {
    ll res = 1;
    while(b) {
        if(b&1) res=(res*a);
        b>>=1;
        a=(a*a);
    }
    return res;
}

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

    ll n,x;
    cin>>n;
    ll f,l,ans=0;
    map<ll,ll> m;
    ifr(i,1,n+1) {
        x = i;
        l = x%10;
        if(l==0) continue;
        while(x) {
            if(x/10==0) f=x;
            x/=10;
        }
        ans+=2*m[(f*10+l)];
        // cout<<i<<" "<<2*m[(f*10+l)]<<endl;
        if(f==l) m[f]++,ans++;
        m[(l*10+f)]++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

ll n, m, k;

int main()
{
  //  freopen("test.in","r",stdin);

    scanf("%lld%lld", &n, &m);
    k = max(0LL, (m - 2 * n) / 4);

    n += k;
    m -= 2 * k;

    printf("%lld", min(n, m / 2));





    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int n,m,x,y,memo = 0;
    cin >> n >> m;
    
    rep(i,0,m){
        cin >> x >> y;
        
        memo =  min(min(x,y),min(n-x+1,n-y+1));
        
        if(memo % 3) cout << memo % 3 << endl;
        else cout << 3 << endl;
    }
    return 0;
}


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

N, K = map(int, input().split())
tree = [[] for i in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

ans = K
visit = [False]*(N+1)
visit[1] = True
queue = tree[1][:]
for i in range(len(queue)):
    ans *= K-1-i
    ans %= 1000000007
    visit[queue[i]] = True


while len(queue) > 0:
    nextqueue = []
    for now in queue:
        nexttemp = []
        for next in tree[now]:
            if not visit[next]:
                nexttemp.append(next)
                visit[next] = True
        nextqueue.extend(nexttemp)
        for i in range(len(nexttemp)):
            ans *= K-2-i
            ans %= 1000000007
    queue = nextqueue[:]

print(ans)


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

#define ll long long int
ll ar[1000000];


int main()
{
	cin.sync_with_stdio(0);
    cin.tie(0);
	
	int n;
	cin>>n;
	int ar[n];
	for(int i=0;i<n;i++)
	{
		cin>>ar[i];
	}

	int dp[n+1];
	memset(dp,0,sizeof dp);

	dp[1]=abs(ar[1]-ar[0]);
	for(int i=2;i<n;i++)
	{
		
		dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
	}
	
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#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 <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

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

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
 
  int X, Y; cin >> X >> Y;
  for (int x = 0; x <= 1000; x++) {
    for (int y = 0; y <= 1000; y++) {
      if (2 * x + 4 * y == Y and x + y == X) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}


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

int main(){
	int n, temp, pre;
	vector<int> c(1, 0);
	vector<int> a(300000, 0);
	vector<int> p(300000, -1);
	a[0] = 1;
	cin >> n;
	for(int i = 1;i<=n;i++){
		cin >> temp;
		if(pre == temp) a[i] = a[i-1];
		else if(p[temp] == -1){
			a[i] = a[i-1];
			p[temp] = i;
		}
		else{
			a[i] = (a[i-1] + a[p[temp]]) % 1000000007;
			p[temp] = i;
		}
		pre = temp;
	}
	cout << a[n] << endl;
	return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I,m=0;
		int[][] a=new int[n][];
		int[] h=new int[n];
		StringBuilder sb=new StringBuilder();
		for(int i = 0;i<n;i++) {
			a[i]=sc.Ia;
			if(a[i][0]==1){m++;}
		}
		int[][] z=new int[m][];
		for(int i=0,j=0;i<n;i++) {
			if(a[i][0]==1){z[j]=new int[]{a[i][1],i};j++;}
		}
		Array.Sort(z,(u,v)=>u[0]-v[0]);
		for(int i=0;i<m;i++){h[z[i][1]]=i+1;}
		Bit bit=new Bit(m+1);
		Bit bit2=new Bit(m+1);
		int[] b=new int[m+1];
		long p=0;
		for(int i=0,j=0;i<n;i++) {
			if(a[i][0]==1){
				p+=a[i][2];
				b[h[i]]=a[i][1];
				bit.Ud(h[i],(long)1e9+a[i][1]);
				bit2.Ud(h[i],1);
				j++;
			}
			else{
				int lb=-1,ub=m,mid=0;
				while(ub-lb>1){
					mid=(ub+lb)/2;
					if(bit2.Get(mid)>=((j+1)>>1)){ub=mid;}
					else{lb=mid;}
				}
				sb.Append(b[ub]+" "+(Math.Abs((1e9+b[ub])*(j-(j>>1)-1)-bit.Get(ub-1))+Math.Abs((1e9+b[ub])*(j>>1)-(bit.Get(m)-bit.Get(ub)))+p)+"\n");
			}
		}
		Console.Write(sb);
	}
}
public class Bit{
	private int n;
	private long[] bit;
	public Bit(int n){
		this.n=n;
		bit=new long[n+1];
	}
	public void Ud(int a,long p){while(a<=n){bit[a]+=p;a+=a&-a;}}
	public long Get(int n){
		long a=0;
		while(n>0){a+=bit[n];n-=n&-n;}
		return a;
	}
	public long Get2(int m,int n){
		long a=0,b=0;
		while(n>m){a+=bit[n];n-=n&-n;}
		if(n==m){return a;}
		while(n!=m){b+=bit[m];m-=m&-m;}
		return a-b;
	}
	public void Clear(){bit=new long[n+1];}
}

public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public string Sz{get{return Console.ReadLine();}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2(int b){return Array.ConvertAll((((b&1)!=0?"0 ":"")+Console.ReadLine()+((b&2)!=0?" 0":"")).Split(),int.Parse);}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public string[] Sa2{get{return ("# "+Console.ReadLine()).Split();}}
}


Measured memory_bytes: 46332
def main():

    n, q = map(int, input().split())
    s = input()

    cumsum = [0]*n
    for i in range(n-1):
        if s[i:i+2] == 'AC':
            cumsum[i+1] = cumsum[i] + 1
        else:
            cumsum[i+1] = cumsum[i]

    res = [None]*q

    for i in range(q):

        l, r = map(int, input().split())
        res[i] = cumsum[r-1] - cumsum[l-1]

    for i in range(q):
        print(res[i])


main()


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

int main(void){
   
   int A,B,C; //A:max B:now C
   cin >> A >> B >> C; 
   
   int sa = A - B;
   
   C -= sa;
   if(C < 0) C = 0;
   
   cout << C <<endl;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll s[100000];
    ll sum = 0;
    for(int i = 0; i < 100000; i++){
        sum += i;
        s[i] = sum;
    }
    while(true){
        ll b;
        cin >> b;
        if(b == 0) break;
        for(int i = 100000; i > 0; i--){
            if(b - s[i] >= 0 && (b - s[i]) % i == 0){
                cout << (b - s[i]) / i + 1 << " " << i << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, std::string S)
{
    int left = 0;
    int right = 0;
    stack<char> s;
    int pairs=0;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == ')')
        {
            right++;
            if (!s.empty())
            {
                s.pop();
                pairs++;
            }
        }
        if (S[i] == '(')
        {
            left++;
            s.push('(');
        }
    }

    for (int i = 0; i < right - pairs; i++)
    {
        cout << "(";
    }
    cout << S;
    for (int i = 0; i < left - pairs; i++)
    {
        cout << ")";
    }
    cout << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


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

class Process{
	string name;
	int t;
public:
	Process(string n, int i) : name(n), t(i){}
	Process() : name(""), t(0){}
	int execute(int j){return t -= j;};
	string get_name(){return name;};
	int get_time(){return t;};
};
int main(){
	int n, j;
	cin >> n >> j;
	Process queue[n];
	string name;
	int t;
	for (int i = 0; i < n; i ++){
		cin >> name >> t;
		queue[i] = Process(name, t);
	}
	int i = 0, last = 0, nt= 0, s = n, temp = 0;
	while (s > 0){
		nt += j;
		temp = queue[i].execute(j);
		if (temp <= 0){
			nt += temp;
			cout << queue[i].get_name() << " " << nt << "\n";
			s -= 1;
			i = (i + 1) % n;
		}else{
			queue[last] = queue[i];
			i = (i + 1) % n;
			last = (last + 1) % n;
		}
	}
}


Measured memory_bytes: 6256
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A"

// header file section
#include <iostream>
#include <cstdio>
#include <cfloat>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <numeric>
#include <algorithm>
//#include "../../segment_tree/segment_tree.hpp"
//#include "../../data_type/min_monoid.hpp"

#ifndef SEGMENT_TREE_HPP
#define SEGMENT_TREE_HPP

#include <vector>
#include <functional>
#include <iterator>

//===
template<class Monoid>
struct SegmentTree {
    using T = typename Monoid::value_type;

    std::vector<T> tree;

    SegmentTree() = default;
    explicit SegmentTree(int n)
        :tree(n << 1, Monoid::identity()) {};

    template<class InputIterator>
    SegmentTree(InputIterator first, InputIterator last) {
        tree.assign(distance(first, last) << 1, Monoid::identity());

        int i;
        i = size();
        for (InputIterator itr = first; itr != last; itr++) {
            tree[i++] = *itr;
        }

        for (i = size() - 1; i > 0; i--) {
            tree[i] = Monoid::operation(tree[(i << 1)], tree[(i << 1) | 1]);
        }
    };

    inline int size() {
        return tree.size() >> 1;
    };

    inline T operator[] (int k) {
        return tree[k + size()];
    };

    void update(int k, const T dat) {
        k += size();
        tree[k] = dat;
        
        while(k > 1) {
            k >>= 1;
            tree[k] = Monoid::operation(tree[(k << 1)], tree[(k << 1) | 1]);
        }
    };

    // [l, r)
    T fold(int l, int r) {
        l += size(); //points leaf
        r += size();

        T lv = Monoid::identity();
        T rv = Monoid::identity();
        while (l < r) {
            if (l & 1) lv = Monoid::operation(lv, tree[l++]);
            if (r & 1) rv = Monoid::operation(tree[--r], rv);
            l >>= 1;
            r >>= 1;
        }

        return Monoid::operation(lv, rv);
    };
};
//===

#endif

#ifndef MIN_MONOID_HPP
#define MIN_MONOID_HPP

#include <numeric>
#include <algorithm>

template<class T>
struct MinMonoid {
    using value_type = T;
    inline static T identity() {
        return std::numeric_limits<T>::max();
    };
    inline static T operation(const T a, const T b) {
        return std::min(a, b);
    };
};

#endif


using namespace std;
using llong = long long;

llong n, q;
llong com, x, y;

int main() {
    cin >> n >> q;

    vector<llong> v(n, (1ll << 31) - 1);
    SegmentTree<MinMonoid<llong>> seg(v.begin(), v.end());

    for (int i = 0; i < q; i++) {
        cin >> com >> x >> y;

        if (com == 0) {
            seg.update(x, y);
        }
        else {
            cout << seg.fold(x, y + 1) << '\n';
        }
    }

    return 0;
};




Measured memory_bytes: 5200
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <cstring>
//#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI acos(-1.0)
typedef long long ll;
typedef unsigned long long ull;
#define gcd __gcd
const int INF=0x3f3f3f3f;
const ll LINF=1000000000000000000;
//priority_queue<int, vector<int>, greater<int> >p;
#define N 200005
ll n,m,l,x,y,k,sum,g,mid,h,v;
//ll d[4][2]={1,0,-1,0,0,1,0,-1};
ll a[N],b[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i],b[a[i]]=i;
    x=k=1;
    for(int i=2;i<=n;i++)
    {
        if(b[i]>b[i-1])k++;
        else {x=max(x,k);k=1;}
    }
    x=max(x,k);
    cout<<n-x<<endl;
    return 0;
}



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

a = [int(x) for x in input().split()]

print(' '.join([str(x) for x in a]))
 
for i in range(1, n):
    
    v = a[i]
    j = i - 1
    
    while j >= 0 and a[j] > v:
        a[j + 1] = a[j]
        
        j -= 1
    
    a[j + 1] = v
    
    print(' '.join([str(x) for x in a]))
        



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

int main()
{
    int a, b;
    cin >> a >> b;

    if (a == 1) {
        a += 13;
    }
    if (b == 1) {
        b += 13;
    }

    if (a < b) {
        cout << "Bob" << endl;
    } else if (a > b) {
        cout << "Alice" << endl;
    } else {
        cout << "Draw" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())

Map = [['.' for i in range(w+2)]]
for i in range(h):
    tmp = ['.'] + list(input())+['.']
    Map.append(tmp)
Map.append(['.' for i in range(w+2)])

Cnt = [[0 for j in range(w)] for i in range(h)]

for i in range(1,h+1):
    for j in range(1,w+1):
        cnt = 0
        if Map[i][j]=='#':
            Cnt[i-1][j-1] = '#'
            continue
        for ij in range(i-1,i+2):
            for ji in range(j-1,j+2):
                if ij == i and ji==j:
                    continue
                if Map[ij][ji]=='#':
                    cnt+=1
        Cnt[i-1][j-1] =cnt
for i in range(len(Cnt)):
    ans = map(str,Cnt[i])
    print(''.join(ans))

Measured memory_bytes: 3064
fn main() {
    let (a, b, c, k): (i64, i64, i64, i64) = readln();
    let answer = if k % 2 == 0 { a - b } else { b - a };
    println!("{}", answer);
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = sc.next().split("");
        int count = 1;
        for (int i = 1; i < n; i++) {
            if (s[i].equals(s[i - 1])) {
                continue;
            }
            count++;
        }
        System.out.println(count);
    }

}



Measured memory_bytes: 35692
def main():
    N = int(input())
    d = []
    for _ in range(N):
        d.append(int(input()))

    d = sorted(d, reverse = True)
    X = 1
    for i in range(N-1):
        if d[i] > d[i+1]: X +=1 

    print(X)  # 段数

if __name__ == "__main__":
    main()

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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;


int N, M;
map< int, vector< int > > g[1000000];
vector< int > add[100000];
int v[100000];

int main() {
  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b, --c;
    g[c][a].push_back(b);
    g[c][b].push_back(a);
    add[a].push_back(c);
    add[b].push_back(c);
  }
  queue< int > que;
  que.emplace(0);
  memset(v, -1, sizeof(v));
  v[0] = 0;
  set< pair< int, int > > eval;
  function< void(int, int, int) > dfs = [&](int c_idx, int idx, int cur) {
    if(eval.count({c_idx, idx})) return;
    eval.emplace(c_idx, idx);
    for(auto &to : g[c_idx][idx]) {
      dfs(c_idx, to, cur);
      if(v[to] == -1) {
        v[to] = cur;
        que.emplace(to);
      }
    }
  };
  while(que.size()) {
    int p = que.front();
    que.pop();
    for(auto &luz : add[p]) dfs(luz, p, v[p] + 1);
  }
  cout << v[N - 1] << endl;
}

Measured memory_bytes: 116096
#include <stdio.h>
#include <stdlib.h>

void swap(long *x,long *y){
    long z;
    z=*x;
    *x=*y;
    *y=z;
}

int max(long a,long b){
    if(a>b)return a;
    else return b;
}

void pushdown(long* a,int n){
    int i=1;
    while(1){
        if(a[i]>=max(a[2*i],a[2*i+1]))break;
        if(a[2*i]>a[2*i+1]){
            swap(&a[i],&a[2*i]);
            i*=2;
        }else{
            swap(&a[i],&a[2*i+1]);
            i=2*i+1;
        }
        if(i*2>n)break;
    }
}

void add_num(long*a,int i){
    while(i>1){
        if(a[i]<=a[i/2])break;
        swap(&a[i],&a[i/2]);
        i/=2;
    }
}

int main(void){
    int N,M,tmp;
    scanf("%d%d",&N,&M);
    long a[100001];
    for(int i=0;i<100001;i++)a[i]=0;
    for(int i=1;i<N+1;i++){
        scanf("%ld",&a[i]);
        add_num(a,i);
    }
    for(int i=0;i<M;i++){
        a[1]=a[1]/2;
        pushdown(a,N);
    }
    long count=0;
    for(int i=1;i<N+1;i++){
        count+=a[i];
    }
    printf("%ld\n",count);
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    ll k;
    cin >> k;
    ll tmp = 7;
    ll ans = 1;
    set<ll> rec;
    while(tmp < k){
        tmp *= 10;
        tmp += 7;
        ans++;
    }
    rec.insert(tmp);

    do{
        ll div = tmp/k;
        ll mod = tmp%k;
        if(mod == 0) break;
        while(mod < k){
            mod *= 10;
            mod += 7;
            ans++;
        }
        if(rec.find(mod) != rec.end()){
            ans = -1;
            break;
        }
        rec.insert(mod);
        tmp = mod;
    } while(true);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 45764
#include<bits/stdc++.h>
using namespace std;
//#define int long long
//#define deb(x) cout << #x << " = "<< x << "\n";

const int maxn = 1000000;
int n, a[maxn+1], b[maxn+1];

signed main() {
//	freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	cin >> n;
	int maxi = 0;
	for(int i = 0; i < n; i++) {
		cin >> b[i];
		a[b[i]]++;
	}
	bool pairwise_coprime = true;
	for(int i = 2; i <= maxn; i++) {
		int cnt = 0;
		for(int j = i; j <= maxn; j += i) { 
			cnt += a[j];
			if(cnt >= 2) {
				pairwise_coprime = false;
				break;	
			}
		}
		if(!pairwise_coprime) break;
	}
	
	if(pairwise_coprime) {
		cout << "pairwise coprime";
		return 0;
	}
	
	int g = 0;
	for(int i = 0; i < n; i++) {
		g = __gcd(g, b[i]);
		if(g == 1) break;
	}
	if(g == 1) {
		cout << "setwise coprime";
	} else {
		cout << "not coprime";
	}
}


Measured memory_bytes: 11476
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<cstring>
#include<list>
using namespace std;
typedef vector<int>VI;
typedef vector<VI>VVI;
typedef vector<string>VS;
typedef pair<int,int>PII;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define PB push_back
#define EACH(i,c) for(typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

struct data{
    int l,r;
    data(int a,int b):l(a),r(b){}
    data(){}
};

int N,M;
int p,q,r;
int x[5001],y[5001];

int solve(){
    vector<data>L;
    L.push_back(data(1,N));
    x[M]=p-1,y[M]=q;
    REP(i,M+1){
        vector<data>a,b,c;
        int sum=0;
        int pos;
        for(int j=0;j<L.size();j++){
            data d=L[j];
            if(x[i]==0)break;
            if(sum+(d.r-d.l+1)<=x[i]){
                a.push_back(d);
                sum+=(d.r-d.l+1);
                pos=j+1;
                if(sum==x[i])break;
            }
            else{
                a.push_back(data(d.l,x[i]+d.l-1-sum));
                //cout<<"**** "<<d.l<<" "<<x[i]+d.l-1-sum<<endl<<endl;
                L[j]=data(x[i]+d.l-sum,d.r);
                pos=j;
                break;
            }
        }
        sum=x[i];
        for(int j=pos;j<L.size();j++){
            data d=L[j];
            if(x[i]==y[i])break;
            if(sum+(d.r-d.l+1)<=y[i]){
                b.push_back(d);
                sum+=(d.r-d.l+1);
                pos=j+1;
                if(sum==y[i])break;
            }
            else{
                b.push_back(data(d.l,y[i]+d.l-1-sum));
                L[j]=data(y[i]-sum+d.l,d.r);
                pos=j;
                break;
            }
        }
        L.erase(L.begin(),L.begin()+pos);
        if(i==M){
            L=b;
            break;
        }
        L.insert(L.end(),b.begin(),b.end());
        L.insert(L.end(),a.begin(),a.end());
        //cout<<endl;EACH(it,L)cout<<it->l<<" "<<it->r<<endl;
    }
    //cout<<endl;EACH(it,L)cout<<it->l<<" "<<it->r<<endl;
    int cnt=0;
    EACH(it,L){
        int l=it->l,u=it->r;
        if(l>r)continue;
        if(u<=r)cnt+=u-l+1;
        else{
            cnt+=r-l+1;
        }
    }
    return cnt;
}







int main(){
    while(cin>>N,N){
        cin>>M;
        cin>>p>>q>>r;
        REP(i,M)cin>>x[i]>>y[i];
        cout<<solve()<<endl;
    }
    return 0;
}

Measured memory_bytes: 1464
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    N = int(input())
    S = input()

    ans = S[1:].count("E")
    A = []
    A.append(ans)

    for i in range(1, N):
        if S[i - 1] == "W":
            ans += 1
        if S[i] == "E":
            ans -= 1
        A.append(ans)

    print(min(A))



main()


Measured memory_bytes: 17176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k%2==0)cout<<a-b<<endl;
    else cout<<b-a<<endl;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define END(x) cout << x << endl; exit(0);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, minimum, maximum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    vl a(3);
    REP(i, 0, 3) {
        cin >> a[i];
    }
    sort(ALL(a), greater<>());
    MSG(a[0] * 10 + a[1] + a[2])
}


Measured memory_bytes: 256
d[9999],W,N,w,c,j,a;main(t){for(;scanf("%d%d",&W,&N),W;printf("Case %d:\n%d\n%d\n",t++,d[a],a))for(bzero(d,W*5);N--;)for(j=W+scanf("%d,%d",&c,&w);j-->w;a=d[j]-d[W]?a:j)d[j]=fmax(d[j],d[j-w]+c);}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int deg[5];
vector<int> nei[10];
int main(){
	for(int i=0;i<3;i++){
		int x,y;
		cin>>x>>y;
		x--,y--;
		deg[x]++;
		deg[y]++;
	}
	int x=0,y=0;
	for(int i=0;i<4;i++){
		if(deg[i]==1) x++;
		if(deg[i]==2) y++;
	}
	if(x==2&&y==2) cout<<"YES"; else cout<<"NO";
}

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

int main(){
	int dp[4001];
	string a,b;
	while(cin>>a>>b){
		int ans=0;
		memset(dp,0,sizeof(dp));
		for(int i=0;i<a.size();i++){
			for(int j=b.size()-1;j>=0;j--){
				if(a[i]==b[j]){
					ans=max(ans,dp[j+1]=dp[j]+1);
				}
				dp[j]=0;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
# coding: utf-8
# Your code here!

arr = list(map(int, input()))
num = 0

if (arr.count(9) == len(arr)) or (arr[0] != 9 and arr.count(9) == len(arr) - 1):
    num = sum(arr)
else:
    num = arr[0] - 1 + (len(arr) - 1) * 9
print(num)

Measured memory_bytes: 3060
n, m, p = [ int(v) for v in input().split() ]
node_list = []
node_list_2 = []
for i in range(m):
    a, b, c = [ int(v) for v in input().split() ]
    node_list.append((a-1,b-1,p-c))
    node_list_2.append((b-1,a-1,p-c))


def b_f(node_list,n,t):
    distance_list = [ 10**15 for i in range(n) ]
    distance_list[t] = 0

    for i in range(n):
        new_distanece_list = distance_list
        for j in node_list:
            a, b, c = j
            if distance_list[a] != 10**15:
                if new_distanece_list[b] > distance_list[a] + c:
                    new_distanece_list[b] = distance_list[a] + c
        distance_list = new_distanece_list

        if i == n-2:
            distance_list_n_minus_1 = [i for i in distance_list]
        elif i == n-1:
            distance_list_n = [i for i in distance_list]

    if distance_list_n_minus_1 == distance_list_n:
        negative_cycle = 0
    else:
        negative_cycle = 1

    return distance_list_n_minus_1, negative_cycle


point_list_s = b_f(node_list,n,0)[0]
point_list_g = b_f(node_list_2,n,n-1)[0]
point_list = [ True for i in range(n) ]

for i in range(n):
    if point_list_s[i] == 10**15 or point_list_g[i] == 10**15:
        point_list[i] = False

node_list_3 = [ i for i in node_list if point_list[i[0]] == True and point_list[i[1]] == True ]
ans = b_f(node_list_3,n,0)

if ans[1] == 0:
    print(-min(0,ans[0][-1]))
else:
    print(-1)

Measured memory_bytes: 49240
S = input()

S_int = [int(S[i]) for i in range(len(S))]

count = 0
for i in range(len(S)-1):
    if S_int[i] == S_int[i+1]:
        count += 1
        S_int[i+1] += 1
        S_int[i+1] %= 2

print(count)

Measured memory_bytes: 3956
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
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 (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int s,w; cin >> s>>w;
    if (w>=s) {
        ct("unsafe");
    } else {
        ct("safe");
    }
}


Measured memory_bytes: 3644
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>

using namespace std;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;


class R
{
public:

	int iD;
	string S;
	int P;

	R()
	{
		cin >> S >> P;
	}

	bool operator<(const R & a)const
	{
		if (S == a.S)
		{
			return P > a.P;
		}
		return S < a.S;
	}

};


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

	vector<R> rList(N);
	for (int i = 0; i < N; ++i)
	{
		rList[i].iD = i + 1;
	}
	
	sort(rList.begin(), rList.end());
	
	for (auto & r : rList)
	{
		cout << r.iD << endl;
	}

	return 0;
}

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

int main()
{
  int n;
  cin>>n;

  int x=1;  //組み合わせみつかったらxを0にする。

  for(int s=0;s<26;s++){
    for(int t=0;t<15;t++){
      if(4*s+7*t==n){
        x=0;
      }
    }
  }

  if(x==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

typedef long long int lli;

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

int main(){
  lli a1, m1, a2, m2, a3, m3;
  
  while(cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3, a1|m1|a2|m2|a3|m3){
    
    lli x, y, z;
    x = a1 % m1;
    y = a2 % m2;
    z = a3 % m3;
    
    lli X = 1, Y = 1, Z = 1;
    while(x != 1) x = x*a1 % m1, X++;
    while(y != 1) y = y*a2 % m2, Y++;
    while(z != 1) z = z*a3 % m3, Z++;
    
    cout << lcm(X, lcm(Y, Z)) << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
from itertools import product

n = input()
m = []
for i in range(3, len(n)+1):
    m += [int(''.join(j)) for j in product(['3','5','7'], repeat=i) if len(set(j)) == 3]

ans = 0
for i in m:
    if i <= int(n):
        ans += 1

print(ans)

Measured memory_bytes: 4340
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
B=[]
C=[]
for i,a in enumerate(A):
  B.append(i+a)
  C.append(i-a)
  
b = Counter(B)
c = Counter(C)
ans=0
for d in b.items():
  ans+=d[1]*c[d[0]]
print(ans)
 
  

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

int main() {
 int N , x;
  cin >> N;
  x = 0;
  for(int i;i < N;i++){
   int A ;
    cin >> A;
    if(A % 2 != 0){
    continue;
    }
    else{
    if(A % 3 != 0 && A % 5 != 0){
    x = 1;
     }
    }
  }
  if (x == 1) cout << "DENIED"<< endl;
  else{cout << "APPROVED" << endl;}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
int main()
{
    int n;
    bool a[110] = {false};
    a[0] = true;
    for (int i = 0; i <= 100; i++)
    {
        if (a[i])
        {
            a[i + 4] = true;
            a[i + 7] = true;
        }
    }
    cin >> n;
    if (a[n])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static int cnt;
  public static void dfs(int u,int[] v,
  List<Integer>[] l)
  {
      v[u]=1;
      cnt++;
      for(int child:l[u])
      {
        if(v[child]==0)       
        dfs(child,v,l);
      }     
  }
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    List<Integer>[] l=new ArrayList[n];
    for(int i=0;i<n;i++)
    l[i]=new ArrayList<>();
    for(int i=0;i<m;i++)
    {
      int x=sc.nextInt();
      int y=sc.nextInt();
      x--;
      y--;
     // if(!l[x].contains(y))
      l[x].add(y);
     // if(!l[y].contains(x))
      l[y].add(x);
    }
    int max=0;
    int v[]=new int[n];
    for(int i=n-1;i>=0;i--)
    {
      if(v[i]==0)
      {
      cnt=0;
      dfs(i,v,l);
      max=Math.max(max,cnt);
      }
    }
    System.out.println(max);
  }
}
    

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s = "pphbhhphph";

	ll n; cin >> n;
	cout << s[n%10] << "on" << endl;
}



Measured memory_bytes: 3648
#include<stdio.h>

int main(){
	int cnt;
	int i;
	int x[10000],y[10000];
	while(1){
		scanf("%d %d",&x[cnt],&y[cnt]);
		if(x[cnt]==0&&y[cnt]==0)break;
		cnt++;
	}
	
	int tmp;
	for(i=0;i<cnt;i++){
		if(x[i]>y[i]){
		tmp=x[i];
		x[i]=y[i];
		y[i]=tmp;
		}
		printf("%d %d\n",x[i],y[i]);
	}
	return 0;
}

Measured memory_bytes: 2644
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 ANS = 0;

	cin >> N;

	
	for (SINT32 i = 0; i < N; i++) {
		for (SINT32 j = 0; j < N; j++) {
			if ((N - i*4 - j*7) == 0) {
				cout << "Yes";
				return 0;

			}
		
		}
	}

	cout << "No";
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  

ll gcd(ll x, ll y){
  if(x%y==0) return y;
  return gcd(y, x%y); 
}

int main(){
  ll a, b;  cin >> a >> b;
  ll ans=0;



    ll x = gcd(a, b);
    vector<ll> obj;
    //obj.push_back(x);
    for(ll i=2; i*i<=x; i++)
      if(x%i==0){ 
        while(x%i==0) x/=i;
        obj.push_back(i);
        // obj.push_back(i);
        // if(i*i != x) obj.push_back(x/i);
      }
    if(x!=1) obj.push_back(1);
    ans = obj.size();
    // sort(obj.begin(), obj.end());
    // vector<bool> isPrime(x+1, true);
    // isPrime[0] = false;
    // for(auto p: obj){
    //   //cout << p << endl;
    //   if(p==1) continue;
    //   if(!isPrime[p]) continue;
    //   for(ll j=2*p; j<=x; j+=p)  isPrime[j] = false;
    // }

    // for(auto x: obj) 
    //   if(isPrime[x]) ans += 1; 
  
  cout << ans+1 << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        String s = sc.next();
        int win = 0;
        int left = 15 - s.length();
        sc.close();

        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'o') {
                win++;
            }
        }

        if ((win + left) > 7) {
            // 出力
            System.out.println("YES");
        } else {
            // 出力
            System.out.println("NO");
        }

    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }
 
int main() {
    init();
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;

    return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, d;
    while(cin >> n >> d, n+d){
        vector<int> sum(n, 0), v[n], ind(n, 0);
        for(int i = 0; i < n; i++){
            int m;  cin >> m;
            while(m-- > 0){
                int x;  cin >> x;
                v[i].push_back(x);
                sum[i] += x;
            }
            reverse(v[i].begin(), v[i].end());
        }
        bool update = true;
        while(update){
            update = false;
            for(int i = 0; i < n; i++){
                if(sum[i] == 0) continue;
                int ma = 0, mi = 1<<30;
                for(int j = 0; j < n; j++){
                    if(i == j)  ma=max(ma,sum[i]-v[i][ind[i]]), mi=min(mi,sum[i]-v[i][ind[i]]);
                    else        ma=max(ma,sum[j]), mi=min(mi,sum[j]);
                }
                if(ma-mi <= d){
                    update = true;
                    sum[i] -= v[i][ind[i]++];
                    break;
                }
            }
        }
        cout << (*max_element(sum.begin(),sum.end()) == 0 ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 3168