akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define vi vector<ll>
#define all(v) v.begin(), v.end()

int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	ll count = 0;

	cin >> s;
	
	ll indA = LLONG_MAX, indZ = LLONG_MIN;

	rep(i, s.length())
	{	
		if (s[i] == 'A' && i < indA)
			indA = i;
		if (s[i] == 'Z' && i > indZ)
			indZ = i;
	}
	cout << abs(indA - indZ) + 1 << "\n";

	#ifdef LOCAL_DEFINE
		cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
	return 0;
}



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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    rep(i,n){
        rep(j,n){
            ll tmp=4*i+7*j;
            if(tmp==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

signed main(){
	int W, H, x, y;
	scanf("%lld%lld%lld%lld", &W, &H, &x, &y);
	printf("%lf %lld\n", (W * H) / 2.0, (int)(W == 2 * x && H == 2 * y));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    string s, t, u;
    int A, B;
    cin >> s >> t;
    cin >> A >> B;
    cin >> u;
    if(s == u){
        cout << A-1 <<" "<< B << endl;
    }else if(t == u){
        cout << A << " " << B-1 << endl;
    }
}

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

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void)
{
	int N;
	cin >> N;
	int ans = 0;
	set<int> st;
	Rep(i, N){
		int a;
		cin >> a;
		if(st.count(a)){
			st.erase(a);
		}else{
			st.insert(a);
		}
	}
	PrintLn(st.size());
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  long long Ta = 1;
  long long Ao = 1;
  for (int i=0; i<N; i++){
    long long T, A;
    cin >> T >> A;
    long long tmp = (long long)max((long double)ceil((long double)Ta/T),(long double)ceil((long double)Ao/A));
    Ta = tmp*T;
    Ao = tmp*A;
  }
  cout << Ta+Ao << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

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

int main(void)
{
    lli N;
    cin >> N;
    lli a[N];
    lli b[N + 1];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    fill(b, b + N + 1, 0);
    lli ans = 0;
    lli m = 1000000007;
    for (int i = 1; i <= N; i++)
    {
        b[i] = b[i - 1] + a[i - 1];
        b[i] %= m;
    }
    for (int i = 1; i < N; i++)
    {
        lli tmp = a[i - 1] * (b[N] + m - b[i]);
        tmp %= m;
        ans += tmp;
        ans %= m;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;
    cin>>n>>x;
    vector<int> l(n);
    rep(i,n) cin>>l[i];
    int ans=0;
    vector<int> d;
    d.push_back(0);
    rep(i,n){
      d.push_back(d.back()+l[i]);
    }
    rep(i,len(d)){
      if(d[i]<=x) ans++;
    }
    cout<<ans<<endl;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    ll ans = 0;
    for (int a0 = 0; a0 < 10; ++ a0) {
        for (int an = 0; an < 10; ++ an) {
            int countA = 0;
            for (int i = 1; i <= N; ++i) {
                int X = i, Y = i % 10;
                while (X / 10 != 0) X /= 10;
                if (X != a0 || Y != an) continue;
                countA++;
            }
            int countB = 0;
            for (int i = 1; i <= N; ++i) {
                int X = i, Y = i % 10;
                while (X / 10 != 0) X /= 10;
                if (Y != a0 || X != an) continue;
                countB++;
            }
            ans += (ll)countA * countB;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
typedef long long LL;
int mod=1e9+7;
int vis[1000005];
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int a[1005];
    int b[1005];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    sort(a,a+n);
    reverse(a,a+n);
    sort(b,b+m);
    reverse(b,b+m);
    a[n]=0;
    b[m]=0;
    LL ans=1;
    for(int i=0;i<n;i++){
        if(i!=0&&a[i]==a[i-1]){
            printf("0\n");
            return 0;
        }
        for(int j=0;j<=m;j++){
            if(j==m){
                ans*=j;
                ans%=mod;
                break;
            }
            if(b[j]==a[i]){
                break;
            }
            if(b[j]<a[i]){
                ans*=j;
                ans%=mod;
                break;
            }
        }
        vis[a[i]]=1;
    }
    for(int i=0;i<m;i++){
        if(i!=0&&b[i]==b[i-1]){
            printf("0\n");
            return 0;
        }
        for(int j=0;j<=n;j++){
            if(j==n){
                ans*=j;
                ans%=mod;
                break;
            }
            if(b[i]==a[j]){
                break;
            }
            if(b[i]>a[j]){
                ans*=j;
                ans%=mod;
                break;
            }
        }
        vis[b[i]]=1;
    }
    int i=0,j=0;
    for(int x=n*m;x>=1;x--){
        if(vis[x])
        continue;
        while(a[i]>x)i++;
        while(b[j]>x)j++;
        ans*=(i*j-(n*m-x));
        ans%=mod;
        if(ans<0){
            printf("0\n");
            return 0;
        }
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define nl cout<<'\n';
bool isPal(string s)
{
	int n=s.size();
	bool pal=true;
	int j=n-1;
	
	
		for(int i=0; i<n/2; i++)
		{
			if(s[i]==s[j])
			{
				j--;
				continue;
			}
			else
			{
				pal=false;
				break;
			}
			
		}
	
	
	
	return pal;
}

int main()
{

	string s;
	cin>>s;
	int n=s.size();
	int m=(n-1)/2;
	string s1=s.substr(0,m);
	int p=(n+3)/2;
	p--;
	string s2=s.substr(p,n-p+2);
	bool S=isPal(s);
	bool S1=isPal(s1);
	bool S2=isPal(s2);
	if(S2 && S1 && S)
		cout<<"Yes";
	else
		cout<<"No";
	



	return 0;
}

Measured memory_bytes: 256
h,w,k=gets.chomp.split.map(&:to_i)
dp=Array.new(h+1).map{Array.new(w)}

MOD = 1000000007

nn = [1,1,2,3,5,8,13,21,34]

dp[0][0] = 1
1.upto(w-1) do |i|
    dp[0][i] = 0
end

if w == 1
    puts 1
    exit
end

1.upto(h) do |i|
    0.upto(w-1) do |j|
        dp[i][j] = 0
        if(j==0)
            dp[i][j] += dp[i-1][j] * nn[w-1]
            dp[i][j] += dp[i-1][j+1] * nn[w-2]
        elsif(j==w-1)
            dp[i][j] += dp[i-1][j] * nn[w-1]
            dp[i][j] += dp[i-1][j-1] * nn[w-2]
        else
            n = nn[j-1]
            n *= nn[w-1-j]
            dp[i][j] += dp[i-1][j-1] * n

            n = nn[j]
            n *= nn[w-j-1]
            dp[i][j] += dp[i-1][j] * n

            n = nn[j]
            n *= nn[w-2-j]
            dp[i][j] += dp[i-1][j+1] * n
        end
        dp[i][j] = dp[i][j] % MOD
    end
end

#p dp
puts dp[h][k-1] % MOD


Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  while(A >= B) B *= 2, --K;
  while(B >= C) C *= 2, --K;
  cout << (K >= 0 ? "Yes" : "No") << endl;
}


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

bool is_prime(int n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else if (n % 2 == 0) {
        return false;
    }
    for (int i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0)
            return false;
    }
    return true;
}

int main() {
    int x;
    cin >> x;
    for (int i = x; i <= 1000003; i++) {
        if (is_prime(i)) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 3636
N=int(input())
A=list(map(int,input().split()))
sum_value = sum(A)
chiled_value = 1
top_value = 1
if(N==0 and A[0]==1):
    print(1)
    exit()
if(A[0]!=0):
    print(-1)
    exit()
for i in range(1,N):
    if(sum_value >= chiled_value*2):
        top_value += chiled_value*2
        chiled_value = chiled_value*2-A[i]
        sum_value=sum_value-A[i]
        if(A[i+1]>chiled_value*2):
            print(-1)
            exit()
    elif(sum_value < chiled_value*2):
        chiled_value=sum_value
        top_value += chiled_value
        sum_value=sum_value-A[i]
    if(A[i]>=2**i):
        print(-1)
        exit()
if((sum_value-A[N])!=0):
    print(-1)
    exit()
print(top_value+A[N])





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

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

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

	int x, y;
	while(cin >> x >> y && !(x == 0 && y == 0)){
		cnt = 0;
		if(x < y) swap(x, y);
		cout << gcd(x, y) << " ";
		cout << cnt << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
    int set=0;
    int max=10;
    vector<int> a(5);
    for(int i=0;i<5;i++){
        cin >> a[i];
        if(max>a[i]%10 && a[i]%10!=0){
            max=a[i]%10;
            set=i;
        }
    }

    int ans=0;
    for(int i=0;i<5;i++){
        if(i!=set && a[i]%10) a[i]=a[i]/10*10+10;
        ans+=a[i];
    }

    cout << ans << endl;
}

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

using namespace std;
int s[1000001];
int main() {
int m,n,c2,c3,c5,i,k=0;
for (c5=1;c5<=1000000;c5*=5) for (c3=1;c3*c5<=1000000;c3*=3) for (c2=1;c2*c3*c5<=1000000;c2*=2) s[c2*c3*c5]=1;
for (i=0;i<=1000000;i++) { k+=s[i]; s[i]=k; }
while(cin >> m) {
	if (m==0) break;
	cin >> n;
	cout << s[n]-s[m-1] << endl;
	}
return 0;
 }

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

double r[20],g[20],b[20];
int main(){
	int n,m;
	cin >> n >> m;
		
	for(int i = 0 ; i < n ; i++){
		cin >> r[i] >> g[i] >> b[i];
	}
	
	double ans = 0;
	for(int i = 0 ; i < (1<<n) ; i++){
		if(__builtin_popcount(i) == m){
			double get = 0;
			for(int j = 0 ; j < n ; j++){
				if(i >> j &1){
					for(int k = j+1 ; k < n ; k++){
						if(i>>k&1){
							get += (r[j]-r[k])*(r[j]-r[k]) + (g[j]-g[k])*(g[j]-g[k]) + (b[j]-b[k])*(b[j]-b[k]);
						}
					}
				}
			}
			ans = max(get,ans);
		}
	}
	printf("%.20f\n",ans);
}

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

using namespace std;

int a[101010];
unordered_map<int, int> cnt;

int main() {
	long long ans = 0;
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		if (i) a[i] += a[i - 1];
		a[i] %= m;
		if (a[i] % m == 0) ans += 1;
		ans += cnt[a[i]];
		cnt[a[i]] += 1;
	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3852
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Date implements Comparable<Date> {

    int y;
    int m;
    int d;
    final int[] date = { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

    Date( int y, int m, int d ) {
	this.y = y;
	this.m = m;
	this.d = d;
    }

    public int compareTo( Date date ) {
	if ( y != date.y ) {
	    return y - date.y;
	} else if( m != date.m ) {
	    return m - date.m;
	} else {
	    return d - date.d;
	}
    }

    boolean uruu( int y ) {
	if ( y % 400 == 0 ) {
	    return true;
	} else if( y % 100 == 0 ) {
	    return false;
	} else if ( y % 4 == 0 ) {
	    return true;
	} else {
	    return false;
	}
    }
    
    void increment() {
	d++;
	if ( d > date[ m ] ) {
	    if ( m != 2 || !uruu( y ) ){
		d = 1;
		m +=1;
	    } else if( m == 2 && d == 30 ) {
		m += 1;
		d = 1;
	    }
	} 
	if ( m == 13 ) {
	    y++;
	    m = 1;
	}
    }
    public String toString() {
	return String.format( "(%d, %d, %d)", y, m, d );
    }
}

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( true ) {

	    final int y1 = stdin.nextInt();
	    final int m1 = stdin.nextInt();
	    final int d1 = stdin.nextInt();
	    final int y2 = stdin.nextInt();
	    final int m2 = stdin.nextInt();
	    final int d2 = stdin.nextInt();

	    if ( y1 == -1 ) {
		break;
	    }

	    Date date1 = new Date( y1, m1, d1 );
	    Date date2 = new Date( y2, m2, d2 );
	    int count = 0;
	    while ( date1.compareTo( date2 ) < 0 ){
		date1.increment();
		//System.err.println( date1 );
		count++;
	    }
	    System.out.println( count );
	}	
    }
}

Measured memory_bytes: 20280
k,a,b=map(int,input().strip().split())
if b-a<=2:
    print(1+k)
else:
    d=b-a
    step=k-a+1
    if step%2==0:
        n=int(step/2)
        print(a+n*d)
    else:
        n=int(step/2)
        print(a+n*d+1)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  long result = 0;
  for (long ans = 1; ans <= (S.size() - 1) / 2; ans++) {
    string foo = S.substr(0, ans);
    string bar = S.substr(ans, ans);
    if (foo == bar) {
      result = ans;
    }
  }
  cout << result * 2 << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#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 all(x) (x).begin(),(x).end()
signed main(){
    int a,b;
    cin>>a>>b;
    if(a%b==0){
        cout<<"-1"<<endl;
        return 0;
    }
    cout<<a*(b-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():

    N, K = map(int, input().split())
    p = set()
    for _ in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for i in range(d):
            p.add(A[i])
    return N - len(p)

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9172
package main

import (
	"fmt"
)

func main() {
	var n int
	vehicle := make([]int, 5)
	fmt.Scan(&n)
	for i := range vehicle {
		fmt.Scan(&vehicle[i])
	}

	min := vehicle[0]
	for i := 1; i < 5; i++ {
		if min > vehicle[i] {
			min = vehicle[i]
		}
	}
	if n%min != 0 {
		fmt.Println(n/min + 5)
	} else {
		fmt.Println(n/min + 4)
	}
}


Measured memory_bytes: 512
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner sc=new Scanner(System.in);
	    int looplim=sc.nextInt();
	    boolean hua=false; 
	    int count=0;
	    for(int iter=0;iter<looplim;iter++)
	    {
	        int a=sc.nextInt();
	        int b=sc.nextInt();
	        if(a==b){count++;
	        if(count>=3) hua=true;}
	        else {count=0;}
	        
	    
	    }
	    if (hua)
	    System.out.println("Yes");
	    else
	    System.out.println("No");
	        
	}
}


Measured memory_bytes: 36116
#include <stdio.h>
#include <ctype.h>  // moji shori no library
 
int main(void)
{
  char ch;
  while(1)
    {
      // input
      scanf("%c",&ch);
      //evaluate convert output
      if(isupper(ch)!=0)
        {
          ch = tolower(ch);
          printf("%c",ch);
        }
      else if(islower(ch)!=0)
        {
          ch = toupper(ch);
          printf("%c",ch);
        }
      else
        {
          printf("%c",ch);
        }
      if (ch == '\n')break;
    }
  return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
#define ll long long
using namespace std;

int n,d;
int ans = 0;
int main()
{
    cin>>n>>d;
    for(int i=0; i<n; ++i){
        ll x,y;
        cin>>x>>y;
        if(sqrt(x*x+y*y)<=d){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let s: Vec<char> = buf.trim().chars().collect();
    let mut cnt = 0_usize;
    for i in 0..s.len() - 1 {
        if s[i] != s[i + 1] {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    data=[list(map(int,input().split())) for i in range(N)]
    data=sorted(data,key=lambda x: x[2], reverse=True)

    def height(X,Y,Cx,Cy,H):
        return max(H-abs(X-Cx)-abs(Y-Cy),0)
    def main():
        for i in range(101):
            for j in range(101):
                H = data[0][2] + abs(data[0][0] - i) + abs(data[0][1] - j)
                for k in range(1,N):
                    if height(data[k][0],data[k][1],i,j,H)!=data[k][2]:
                        break
                    elif k==N-1:
                        print(i,j,H)
                        return None

    main()

resolve()

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

using namespace std;


typedef long long int ll;
typedef vector<int>vi;
typedef deque<int> di;
#define f(i, a, b) for(int i = a; i <= b; i++)

int main () {

int a;
int b;
cin >> a >> b;
cout << a*b;


return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  string cp;
  int si=s.size();
  rep(i,si){
    if(s[i]=='?'){
      cp+='D';
    }
    else{
      cp+=s[i];
    }
  }
  cout<<cp<<'\n';
  return(0);
}


Measured memory_bytes: 3892
N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(i,i+M):
      for l in range(j,j+M):
        if A[k][l] != B[k-i][l-j]:
          break
        if A[k][l] == B[k-i][l-j] and k == i+M-1 and l == j+M-1:
          ans = 1
      else:
        continue
      break

if ans == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
   string s,t;
   cin>>s>>t;
   
   bool found=false;
   
   
   int n=s.size(),m=t.size();
   string ans(n,'z');
   
   if(m>n){
       cout<<"UNRESTORABLE";
       return 0;
   }
   for(int pos=0; pos<=n-m; pos++){
       string at(n,'a');
       bool works=true;
       for(int i=0; i<n && works; i++){
           if(i>=pos && i<pos+m){
               if(s[i]=='?' || s[i]==t[i-pos]){
                   at[i]=t[i-pos];
               }
               else{
                   works=false;
               }
           }
           else{
               if(s[i]=='?') at[i]='a';
               else at[i]=s[i];
           }
       }
       //cout<<pos<<" "<<at<<endl;
       if(works){
           found=true;
           ans=min(ans,at);
       }
   }
   if(found) cout<<ans;
   else cout<<"UNRESTORABLE";
   
    
    
    return 0;
    
}

Measured memory_bytes: 256
def solve():
    import sys
    input = sys.stdin.readline
    N,M,S = map(int,input().split())
    UVAB = [tuple(map(int,input().split())) for i in range(M)]
    CD = [tuple(map(int,input().split())) for i in range(N)]

    es = [[] for _ in range(N)]
    for u,v,a,b in UVAB:
        u,v = u-1,v-1
        es[u].append((v,a,b))
        es[v].append((u,a,b))

    INF = float('inf')
    times = [INF] * (2501 * N)
    start = min(2500,S)*N
    times[start] = 0
    hq = [start]
    ans = [-1] * N
    ans[0] = 0
    reached = 0
    import heapq
    heapq.heapify(hq)
    while hq:
        x = heapq.heappop(hq)
        t,v = divmod(x,N*2501)
        s,i = divmod(v,N)
        if ans[i] < 0:
            ans[i] = t
            reached += 1
            if reached == N-1: break
        for to,a,b in es[i]:
            if a > s: continue
            nv = (s-a)*N + to
            if times[nv] <= t + b: continue
            times[nv] = t + b
            heapq.heappush(hq, (t+b)*N*2501 + nv)
        ns = s
        nt = times[v]
        while ns <= 2500:
            ns += CD[i][0]
            nt += CD[i][1]
            nv = min(2500,ns)*N + i
            if times[nv] <= nt: break
            times[nv] = nt
            heapq.heappush(hq, nt*N*2501 + nv)
    print(*ans[1:], sep='\n')
solve()

Measured memory_bytes: 31884
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;

typedef long long ll;
const int N = 100005;

string str;
ll dp[N][13], pot[N];

ll back(int pos, int md){
	if(pos == str.size()) {
		return (md == 5);
	}
	ll &ans = dp[pos][md];
	if(ans != -1) return ans;
	if(str[pos] != '?') return ans = back(pos+1, (md + ((str[pos] - '0') * pot[pos])%13)%13)%mod;
	ans = 0;
	for (int i=0; i<10; i++){
		ans = (ans + back(pos+1, (md+(i*pot[pos])%13)%13))%mod;
	}
	return ans;
}

int main(){
	memset(dp, -1, sizeof dp);
	pot[0] = 1LL;
	for (int i=1; i<N; i++){
		pot[i] = (pot[i-1] * 10LL)%13;
	}
	cin >> str;
	reverse(str.begin(), str.end());
	cout << back(0, 0) << endl;
}


Measured memory_bytes: 19200
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll a;
ll sum=0;
ll tmp=infll;
for(int i=0;i<5;i++){
    cin>>a;
    ll cnt=0;
    for(int j=0;j<14;j++){
        cnt+=10;
    if(cnt>=a){
        chmin(tmp,a-(cnt-10));
        sum+=cnt;
        break;
    }
    }
}
cout<<sum-10+tmp<<endl;
}












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

int n, a;
vector<int> ans;

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a); a--;
        if(a <= i) ans.insert(ans.begin() + a, a+1);
        else return puts("-1")*0;
    }
    for(int it: ans) printf("%d\n", it);
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

bool U[105];
pll A[105];
pll B[105];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
    }
    REP(i, N) {
        cin >> B[i].first >> B[i].second;
    }
    sort(B, B + N, [](pll a, pll b) { return a.first < b.first; });
    ll ans = 0;
    REP(i, N) {
        pll b = B[i];
        ll index = -1;
        REP(j, N) {
            if (U[j])
                continue;
            if (A[j].first > b.first || A[j].second > b.second)
                continue;

            if (index < 0 || A[index].second < A[j].second)
                index = j;
        }

        if (index < 0)
            continue;
        U[index] = true;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using P=pair<int, int>;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io

    ll n, m, k;
    cin>>n>>m>>k;

    vector<ll> A(n), B(m);
    vector<ll> a, b;
    a.push_back(0);
    b.push_back(0);
    rep(i,n) {
        cin>>A[i];
        a.push_back(a[i] + A[i]);
    }
    rep(i,m) {
        cin>>B[i];
        b.push_back(b[i]+B[i]);
    }
    
    ll ans=0;
    int j=m;
    rep(i,n+1){
        if(a[i]>k) break;
        while(b[j] > k-a[i]) j--;
        ans=max(ans, (ll)(i+j));
    }

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11056
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<ll, ll>P;
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; }
void SAY(bool YES){cout<<(YES?"YES":"NO")<<endl;};
void Say(bool Yes){cout<<(Yes?"Yes":"No")<<endl;};

const ll MOD = 1000000007;

string replace(string s1, string s2, string s3){
    int pos = s1.find(s2);
    if(pos == string::npos){
        return s1;
    }
    s1.replace(pos, s2.size(), s3);
    return s1;
}

int main(){

    ll N;
    cin >> N;
    string s, t;
    cin >> s;
    t = s;
    for(;;){
        string tt = replace(t, "()", "");
        if(tt == t)break;
        t = tt;
    }
    for(ll i = 0; i < t.size(); i++){
        if(t[i] == ')')cout << "(";
    }
    cout << s;
    for(ll i = 0; i < t.size(); i++){
        if(t[i] == '(')cout << ")";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  ll n,k;
  cin >> n >> k;
  ll res = pow((n/k),3);
  if(k%2==0){
    if(n>=k/2){
      res += pow((n-k/2)/k+1,3);
    }
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    int A,B;
    cin >> A >> B;
    cout << (A+B)%24 << endl;
    return 0;
}


Measured memory_bytes: 384
//#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;

using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<ll, ll> pii;
typedef long double ld;
#define double long double
typedef pair<ld, ld> pld;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

typedef vector<ll> vi;
typedef vector<pii> vpii;
namespace IO {
    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> &a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> &a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> &a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define int ll

void solve() {
    int n;
    cin >> n;
    int n2 = n;
    int res = 0;
    for (int i = 2; i * i <= n2 && n > 0; ++i) {
        int cur = i;
        int d = 0;
        while (n % cur == 0) {
            ++d;
            n /= cur;
        }
        int cur2 = 1;
        while (d >= cur2) {
            ++res;
            d -= cur2;
            ++cur2;
        }
    }
    if (n > 1) ++res;
    put(res);
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;
    while (q--) solve();
}



Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <queue>
#include <map>
#include <numeric>
using namespace std;
typedef long long int ll;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<char> c(n);
	for(int i=0;i<n;i++){
		cin >> c[i];
	}
	sort(c.begin(),c.end());
	c.erase(unique(c.begin(),c.end()),c.end());
	if(c.size()==3){
		cout << "Three" << endl;
	}else{
		cout << "Four" << endl;
	}
}

Measured memory_bytes: 256
s=input()
t=input()
S={}
T={}
for i in range(len(s)):
    if s[i] in S.keys() and t[i] in T.keys():
        if S[s[i]]!=T[t[i]]:
            print("No")
            exit()
        else:
            S[s[i]]+=1
            T[t[i]]+=1
    elif s[i] not in S.keys() and t[i] not in T.keys():
        S[s[i]]=1
        T[t[i]]=1
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3692
def main():

    while True:

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

        if num[0] == 0 and num[1] == 0:
            break

        # 上の部分
        for i in range(num[1]):
            print('#', end='')
        print('')

        # 真ん中の部分
        for i in range(num[0]-2):
            print('#', end='')
            for j in range(num[1]-2):
                print('.', end='')
            print('#')

        # 下の部分
        for i in range(num[1]):
            print('#', end='')
        print('')

        print('')


if __name__ == "__main__":
    main()


Measured memory_bytes: 7008
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int sx = sc.nextInt();
    int sy = sc.nextInt();
    int tx = sc.nextInt();
    int ty = sc.nextInt();

    tx -= sx;
    ty -= sy;

    StringBuilder ans = new StringBuilder();

    ans.append("L");
    for (int i = 0; i < ty + 1; i++) {
      ans.append("U");
    }
    for (int i = 0; i < tx + 1; i++) {
      ans.append("R");
    }
    ans.append("D");

    for (int i = 0; i < tx; i++) {
      ans.append("L");
    }
    for (int i = 0; i < ty; i++) {
      ans.append("D");
    }

    for (int i = 0; i < tx; i++) {
      ans.append("R");
    }
    for (int i = 0; i < ty; i++) {
      ans.append("U");
    }

    ans.append("R");
    for (int i = 0; i < ty + 1; i++) {
      ans.append("D");
    }
    for (int i = 0; i < tx + 1; i++) {
      ans.append("L");
    }
    ans.append("U");

    os.println(ans.toString());
  }
}


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

int main(){
  int H,W,A,B;
  cin >> H >> W >> A >> B;

  int mat[H][W];
  for(int i=0; i<B; i++){
    for(int j=0; j<A; j++){
      mat[i][j] = 0;
    }
    for(int j=A; j<W; j++){
      mat[i][j] = 1;
    }
  }

  for(int i=B; i<H; i++){
    for(int j=0; j<A; j++){
      mat[i][j] = 1;
    }
    for(int j=A; j<W; j++){
      mat[i][j] = 0;
    }
  }

  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cout << mat[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>

using namespace std;

typedef pair<int,int>P;
const int MAX = 100;
P data[MAX];
int N,T,H,L;
int mon;

void solve(){
  int player = -1;

  while(1){
    player++;
    if(player == N) player = 0;
    if(data[player].first > 0){
      mon+=10;
      T++;
      data[player].first--;
      if(L < T) {
	cout << player+1 << endl;
	break;
      }
    }else if(data[player].second > 0){
      mon+=100;
      H++;
      data[player].second--;
    }else{
      cout << player+1 << endl;
      break;
    }

    if(mon >= 90){
      mon-=90;
      T-=mon/10;
      data[player].first+=mon/10;
      mon = 0;
      if(T < 0){
	cout << player+1 << endl;
	break;
      }
    }

  }
}

void input(){

  cin >> N >> T >> H >> L;

  for(int i = 0; i < N; i++)
    cin >> data[i].first >> data[i].second;  
}

int main(){
  input();
  solve();
  return 0;
}

Measured memory_bytes: 1160
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

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

		String str = sc.nextLine();
		String sl[] = str.split(" ");
		int n = Integer.parseInt(sl[0]);
		int k = Integer.parseInt(sl[1]);

		str = sc.nextLine();
		sl = str.split(" ");
		HashMap<Integer, Integer> m = new HashMap<>();
		for(int i = 0; i < n; i++)
		{
			int x = Integer.parseInt(sl[i]);
			m.put(x, m.containsKey(x) ? m.get(x) + 1 : 1);
		}

		ArrayList<Integer> list = new ArrayList<>(m.values());
		Collections.sort(list);
		int e = 0;
		int s = list.size();
		for(int i = 0; i < s - k; i++)
		{
			e += list.get(i);
		}
		System.out.println(e);
	}
}

Measured memory_bytes: 66512
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>

using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 
#define DEBUG_OUTPUT_ARRAY(XXX,ONE) for(int i=0;i<(ONE);i++){cout<<"DEBUG: i = "<<i<<" -> "<<XXX[i]<<endl;}
#define DEBUG_OUTPUT_ARRAY2(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<"<<< i = "<<i<<" >>>"<<endl;for(int j=0;j<(TWO);j++){cout<<"DEBUG: j = "<<j<<" -> "<<XXX[i][j]<<endl; } }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<i<<"  ";for(int j=0;j<(TWO);j++){cout<<XXX[i][j]<<" "; } cout<<endl;}

typedef pair<long long int,long long int> pll;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int N,K,a[105],res=INF;
int main() {
	cout << fixed << setprecision(18);
    cin>>N>>K;
    for(int i=0;i<N;i++){cin>>a[i];}
    for(int i=0;i<(1<<N-1);i++){
        long long int tmp=1,mymax=a[0],money=0;
        for(int j=0;j<N-1;j++){
            if(((1<<j)&i)==0){
                if(mymax>=a[j+1]){
                    money+=(-a[j+1]+mymax)+1;
                    mymax++;
                }
                tmp++;
            }else if(mymax<a[j+1]){
                tmp++;
            }
            mymax=max(mymax,a[j+1]);
        }
        if(tmp>=K){res=min(res,money);}
    }
    cout<<res<<endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, pair<int, int> > p;
 
#define MOD 1000000007

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

    string s;
    cin >> s;

    int a = 0;

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

    if(a % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main()
{
    //freopen("test.in","r",stdin);
    //freopen("test.ok","w",stdout);
    int64_t n,x=0,min;
    cin >> n;
    int64_t p[n];
    for (int i=0;i<n;i++)
        cin >> p[i];
    min=p[0];
    for (int i=0;i<n;i++)
        if (p[i]<=min) 
        {
            min=p[i];
            x++;
        }
    cout << x;
    
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int int64_t

signed main(){
	int n,m;cin>>n>>m;
	priority_queue<int,vector<int>,greater<>> q;
	rep(i,n){
		int c;cin>>c;
		q.push(c);
	}
	vector<pair<int,int>> r(m);
	rep(i,m){
		int b,c;
		cin>>b>>c;
		r[i]=make_pair(c,b);
	}
	sort(all(r),greater<>());
	rep(i,m){
		if(r[i].first>q.top()){
			rep(j,r[i].second){
				q.pop();
				q.push(r[i].first);
			}
		}
	}
	int ans=0;
	while(!q.empty()){
		ans+=q.top();
		q.pop();
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2676
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a<b)
	{
		printf("a < b\n");
	}
	else if(a>b)
	{
		printf("a > b\n");
	}
	else if(a==b)
	{
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2676
n = int(input())
s = list(input())
num = 0
k = -1
for i in range(1,n):
  if i + k >= n-1:
    break
  if s[-i] == 'R':
    j = k+1
    while True:
      if j +i == n:
        k = j
        break
      if s[j] == 'W':
        s[j] = 'R'
        s[-i] = 'W'
        k = j
        num += 1
        break
      j += 1
      
print(num)     
      

Measured memory_bytes: 10728
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		sc.close();
		long p = N % K;
		// System.out.println("p = " + p);
		// System.out.println("abs = " + Math.abs(p - K));
		// System.out.println(1000000000000000000L - 1);
		// 1000000000000000000 999999999999999999
		System.out.println(Math.min(p, Math.abs(p - K)));
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int main() 
{
	int H, A;
	cin >> H >> A;
	cout << (H + A - 1) / A << endl;
}


Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;



int main(){
  ios_base::sync_with_stdio(false);

  int n;

  cin >> n;

  if(n == 7 || n == 5 || n == 3){
    cout <<  "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}



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

using namespace std;

#define N 120000

int n,f[N];
vector<int> g[N];

void dfs(int u,int fa){
	for (int v:g[u])
		if (v!=fa){
			dfs(v,u);
			f[u]^=f[v];
		}
	++f[u];
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<n;++i){
		int x,y; scanf("%d%d",&x,&y);
		g[x].push_back(y); g[y].push_back(x);
	}
	dfs(1,0);
	puts(f[1]>1?"Alice":"Bob");
	
	return 0;
}
			

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int n;
const int maxn = 1e5 + 5;
int a[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    int s = 0;
    int cnt = 0;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        if(i > 1){
            if(a[i] != a[i - 1]){
                if(a[i] < a[i - 1]){
                    if(s == -1){
                        cnt++;
                        s = 0;
                    }else{
                        s = 1;
                    }
                }else{
                    if(s == 1){
                        cnt++;
                        s = 0;
                    }else{
                        s = -1;
                    }
                }
            }
        }
    }
    cout << cnt + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include<unordered_map>
#include<iostream>
#include<algorithm>
#include<utility>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define inf 0x7f7f7f
#define p(x) (x)*(x)
#define PI 3.14159265358979
using namespace std;

typedef vector<vector<int> > vtype;
typedef long long ll;
int *c = nullptr, *mid = nullptr, **a = nullptr;
int res = inf;

void func(int x, int n, int m, int k, int num);

int main()
{
	//ios::sync_with_stdio(false);
	int n = 0, m = 0, x = 0;
	bool istrue = false;
	cin >> n >> m >> x;
	c = new int[n+5]{0};
	a = new int*[n+5];
	mid = new int[m+5]{0};
	for(int i = 0; i <= n; ++i)
		a[i] = new int[m+5]{0};
	for(int i = 0; i < n; ++i){
		cin >> c[i];
		for(int j = 0; j < m; ++j)
			cin >> a[i][j];
	}
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < m; ++j)
			mid[j] += a[i][j];
	for(int i = 0; i < m && !istrue; ++i)
		if(mid[i] < x)
			istrue = true;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j)
			mid[j] = 0;
		func(i, n, m, x, c[i]);
	}
	if(istrue)
		cout << "-1" << endl;
	else
		cout << res << endl;
	for(int i = 0; i <= n; ++i)
		delete[] a[i];
	delete[] a;
	delete[] c;
	delete[] mid;
	mid = nullptr;
	a = nullptr;
	c = nullptr;
    return 0;
}

void func(int x, int n, int m, int k, int num)
{
	bool istrue = true;
	for(int i = 0; i < m; ++i){
		mid[i] += a[x][i];
		if(mid[i] < k)
			istrue = false;
	}
	if(!istrue){
		for(int i = x + 1; i < n; ++i)
			func(i, n, m, k, num+c[i]);
	}
	else
		res = min(res, num);
	for(int i = 0; i < m; ++i)
		mid[i] -= a[x][i];
}













Measured memory_bytes: 3572
#include <stdio.h>

int main(void){
	int n,t,a[100];
	while(1){
		scanf("%d",&n);
		if(n==0){
			return 0;
		}
		for(t=0;t<n;t++){
			scanf("%d",&a[t]);
		}
		if(n==1){
			printf("%d\n",a[0]);
		}
		else{
			printf("%d",a[0]);
			for(t=1;t<n-1;t++){
				if((a[t-1]+1!=a[t])&&(a[t]+1==a[t+1])){
					printf(" %d",a[t]);
				}
				if((a[t-1]+1!=a[t])&&(a[t]+1!=a[t+1])){
					printf(" %d",a[t]);
				}
				if((a[t-1]+1==a[t])&&(a[t]+1!=a[t+1])){
					printf("-%d",a[t]);
				}
			}
			if(a[n-2]+1==a[n-1]){
				printf("-%d\n",a[n-1]);
			}
			else{
				printf(" %d\n",a[n-1]);
			}
		}
	}
}
	

Measured memory_bytes: 600