akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int k;
    string s;
    cin >> k >> s;
    
    if(s.size()<=k){
        cout << s << endl;
    }else{
        cout << s.substr(0,k) << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
#define yes {cout<<"Yes"<<endl; continue;};
#define no {cout<<"No"<<endl; continue;};

long long int GCD(long long int x, long long int y){
    if(x>y){
        long long int swap = x;
        x = y;
        y = swap;
    }
    while(true){
        if(y%x==0){
            return x;
        }else{
            long long int amari = y%x;
            y = x;
            x = amari;
        }
    }
}

int main() {
    int n;
    cin >> n;
    ll keep[n][4];
    rep(i,n){
        cin >> keep[i][0] >> keep[i][1] >> keep[i][2] >> keep[i][3];
    }
    rep(i,n){
        ll a,b,c,d;
        a = keep[i][0]; b = keep[i][1]; c = keep[i][2]; d = keep[i][3]; 
        if(d < b)no;
        if(b > a)no;
        a -= b;
        if(a<=c)a+=d;
        if(c>=b)yes;
        if(b==d){
            a -= (a/b)*b;
            if(c>=a){
                yes;
            }else{
                no;
            }
        }
        if(a<=c){
            ll x = (c-a) / (d-b);
            a += x * (d-b);
        }
        if(a<=c)a += d-b;
        if(a - c > b){
            ll x = (a-c) / b;
            if((a-c)%b==0){
                x--;
            } 
            a -= b * x;
        }
        a -= b; // ここでc>=a && a>c-b になっているはず
        //cout << a << ' ';
        if(a<0)no;
        ll x = GCD(b,d);
        if((c-a)>=x){
            ll count = (c-a)/x;
            a += count*x;
        }
        if(c>=a)a+=x;
        if(a>=b){
            cout << "Yes" << endl;
            continue;
        }else{
            cout << "No" << endl;
            continue;
        }
    }

    return 0;
}
 
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int way[20200];
int cnt[20200];
int main(){
    int n,x,y;
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<n;i++) {
        memset(way,0,sizeof way);
        for(int j=i+1;j<=n;j++){
            way[j]=j-i;
        }
        way[y]=min(way[y],abs(x-i)+1);
        for(int j=i+1;j<=n;j++) {
                if(j==y) continue;
                way[j]=min(way[j],abs(j-y)+1+abs(x-i));
        }
        for(int j=i+1;j<=n;j++){
            cnt[way[j]]++;
        }
    }
    for(int i=1;i<n;i++)
        printf("%d\n",cnt[i]);
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int main() {
  int a, b, ans = 0;
  cin >> a >> b;
  if((a >= 0 && b <= 0) || (a < 0 && b > 0)) {
    ans++;
  }else {
    if(a > b) ans += 2;
  }
  if(a == 0 && b == 0) ans = 0;
  if(a < 0) a = -a;
  if(b < 0) b = -b;
  ans += max(a, b) - min(a, b);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int a[n];
    rep(i,0,n)cin>>a[i];
    multiset<int> st;
    rep(i,0,n){
        auto itr=st.lower_bound(a[i]);
        if(itr==st.begin()){
            st.insert(a[i]);
            continue;
        }
        itr--;
        st.erase(itr);
        st.insert(a[i]);
    }
    cout<<st.size()<<endl;
}


Measured memory_bytes: 5376
N = int(input())
H = list(map(int, input().split()))
ans = 0
curr = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    curr += 1
  else:
    ans = max(ans, curr)
    curr = 0
else:
  ans = max(ans, curr)
  
print(ans)

Measured memory_bytes: 15148
#include <stdio.h>
int main(){
  int a[100],n,i,j;

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

  for(i=n-1;i>=0;i--){
    printf("%d",a[i]);
    if(i==0) printf("\n");
    else printf(" ");
  }

  return 0;
}

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


int main() {
	int N,ans=0;
	cin >> N;
	
	for (int i = 1; i <= N; i++)
	{
		if (i%2==1)
		{
			int tmp = i;
			int count = 0;
			for (int j = 1; j <= i; j++)
			{
				if (tmp%j==0)
				{
					count++;
				}
			}

			if (count==8)
			{
				ans++;
			}
		}
		
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int odd = 0,even = 0;
        for(int i=1;i<=n;i++){
            if(i%2==1)odd++;
            else even++;
        }

        System.out.println(odd*1.0/n);

    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25380
/*    Isn't it lovely, all alone?              */
/*    Heart made of glass, my mind of stone    */
/*    Tear me to pieces, skin to bone          */
/*    Hello, welcome home                      */

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
ll mod=1000000007;


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

ll t=1;
//cin>>t;
while(t--)
{

ll n;
cin>>n;

string p="abcdefghijklmnopqrstuvwxyz";
string ans="";

while(n>0)
{

if(n%26==0)
{
 n-=26;
 ans+='z';
 n/=26;
}
else
{
 ans+=p[(n%26)-1];
 n/=26;
}

}

reverse(ans.begin(),ans.end());
cout<<ans<<endl;

}
return 0;
}
















Measured memory_bytes: 3640
from fractions import gcd
from math import sqrt


def prime_factorize(n):
    result = []
    for i in range(2, int(sqrt(n)) + 1):
        if n % i != 0:
            continue
        t = 0
        while n % i == 0:
            n //= i
            t += 1
        result.append((i, t))
        if n == 1:
            break
    if n != 1:
        result.append((n, 1))
    return result


A, B = map(int, input().split())
print(len(prime_factorize(gcd(A, B))) + 1)


Measured memory_bytes: 5176
#coding: utf-8
abcd = list(input())
ans = 7
n = len(abcd) - 1
pm = ["+", "-"]
for i in range(2**n):
    tmp = abcd[:]
    for j in range(n):
        if (i >> j) & 1 == 1:
            tmp[j] += pm[0]
        else:
            tmp[j] += pm[1]
    v = eval("".join(tmp))
    if v == ans:
        print("".join(tmp)+"={}".format(ans))
        exit()
        

Measured memory_bytes: 3060
N = int(input())
M = 0
A = 0
R = 0
C = 0
H = 0

for i in range(N):
	S = input()
	if S[0] == "M":
		M += 1
	elif S[0] == "A":
		A += 1
	elif S[0] == "R":
		R += 1
	elif S[0] == "C":
		C += 1
	elif S[0] == "H":
		H += 1
	else:
		pass

print(M * A * (R + C + H) + (M + A) * (R * C + C * H + H * R) + R * C * H )

Measured memory_bytes: 3064
import java.util.*;

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

        int N = sc.nextInt();

        int[] A = new int[N];
        int[] B = new int[N];
        int[] C = new int[N];
        for (int i = 0; i < N; i++)
            A[i] = sc.nextInt();
        Arrays.sort(A);

        for (int i = 0; i < N; i++)
            B[i] = sc.nextInt();
        Arrays.sort(B);

        for (int i = 0; i < N; i++)
            C[i] = sc.nextInt();
        Arrays.sort(C);

        long[] up = new long[N];
        long[] dn = new long[N];

        Arrays.fill(up, -1);
        Arrays.fill(dn, -1);
        int j = N - 1;
        for (int i = N - 1; i >= 0; i--) {
            for (; j >= 0; j--) {
                if (A[j] < B[i]) {
                    up[i] = (long)(j + 1); // record how many a is less at B[i];
                    break;
                }
            }

            if (j < 0) break;
        }

        j = 0;
        for (int i = 0; i < N; i++) {
            for (; j < N; j++) {
                if (C[j] > B[i]) {
                    dn[i] = (long) N - j;
                    break;
                }
            }

            if (j > N) break;
        }

        long res = 0;

        for (int i = 0; i < N; i++) {
            if (up[i] > 0 && dn[i] > 0)
                res += up[i] * dn[i];
        }

        System.out.println(res);
    }




}


Measured memory_bytes: 95620
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<ll,ll>;


ll m=1000000007;

int main()
{
 ll a,b,c,d;
 cin>>a>>b>>c>>d;
 ll e,h;
 e=a*c;
 h=a*d;
 ll f,g;
 f=b*c;
 g=b*d;
 ll ans=e;
 ans=max(ans,h);
 ans=max(ans,f);
 ans=max(ans,g);
 cout<<ans<<endl;
}
 


 

 




Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a1(n),a2(n),s1(n+1),s2(n+1);
    s1[0]=0;
    s2[0]=0;
    rep(i,n){
        cin >> a1[i];
        s1[i+1] = s1[i] + a1[i];
    }   
    rep(i,n){
        cin >> a2[i];
        s2[i+1] = s2[i] + a2[i];
    }
    ll ans = 0;
    rep(i,n){
        ll tmp_ans = 0;
        tmp_ans += s1[i+1];
        tmp_ans += s2[n] - s2[i];
        ans = max(ans,tmp_ans);
    }
    cout << ans;
}

Measured memory_bytes: 256
/* Dynamic Programming implementation of LCS problem */
#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( string X, string Y, int m, int n )
{
   int L[m+1][n+1];

   /* Following steps build L[m+1][n+1] in bottom up fashion. Note
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++)
   {
     for (int j=0; j<=n; j++)
     {
       if (i == 0 || j == 0)
         L[i][j] = 0;
       else if (X[i-1] == Y[j-1])
         L[i][j] = L[i-1][j-1] + 1;
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]);
     }
   }

   // Following code is used to print LCS
   int index = L[m][n];

   // Create a character array to store the lcs string
   char lcs[index+1];
   lcs[index] = '\0'; // Set the terminating character

   // Start from the right-most-bottom-most corner and
   // one by one store characters in lcs[]
   int i = m, j = n;
   while (i > 0 && j > 0)
   {
      // If current character in X[] and Y are same, then
      // current character is part of LCS
      if (X[i-1] == Y[j-1])
      {
          lcs[index-1] = X[i-1]; // Put current character in result
          i--; j--; index--;     // reduce values of i, j and index
      }

      // If not same, then find the larger of two and
      // go in the direction of larger value
      else if (L[i-1][j] > L[i][j-1])
         i--;
      else
         j--;
   }

   // Print the lcs
   cout << lcs << endl;
}

/* Driver program to test above function */
int main()
{
    string s1,s2;
  cin >> s1 >> s2;
  int m = s1.size();
  int n = s2.size();
  lcs(s1, s2, m, n);
  return 0;
}


Measured memory_bytes: 35456
#include <iostream>
using namespace std;
typedef long long ll;
ll A,B,C;

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
using namespace std;
 
    
    
int main(){
  int k,a,b;
  cin>>k>>a>>b;
  if ((a%k==0)||(b%k==0)||(a/k)!=(b/k))
  {
    cout<<"OK"<<endl;
  }else{
    cout<<"NG"<<endl;
  }
  
    return 0;
}

Measured memory_bytes: 3132
fun main(args: Array<String>) {
    val (n, w) = readLine()!!.split(' ').map { it.toInt() }
    val inf = 1e9.toLong() + 1
    val dp = Array(n + 1) { LongArray(100001) { inf } }
    dp[0][0] = 0

    for (i in 0 until n) {
        val (wi, vi) = readLine()!!.split(' ').let { it[0].toLong() to it[1].toInt() }

        for (j in 0 until vi) {
            dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j])
        }
        for (j in vi..100000) {
            dp[i + 1][j] = Math.min(dp[i][j - vi] + wi, dp[i][j])
        }
    }

    println(dp[n].mapIndexed { i, l -> if (l <= w) i else -1 }.max())
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int UF_MAX = 200010;

class UF{
	int x[UF_MAX];
	
public:
	
	UF(){
		for(int i = 0 ; i < UF_MAX ; ++i) x[i] = -1;
	}
	
	void Union(int a , int b){
		int s = a;
		int t = b;
		while(x[s] > -1) s = x[s];
		while(x[t] > -1) t = x[t];
		if(s != t){
			if(x[s] < x[t]){
				x[s] += x[t];
				x[t] = s;
			} else {
				x[t] += x[s];
				x[s] = t;
			}
		}
		if(s != a) x[a] = s;
		if(t != b) x[b] = t;
	}
	
	bool Find(int a , int b){
		int s = a;
		int t = b;
		while(x[s] > -1) s = x[s];
		while(x[t] > -1) t = x[t];
		if(s != a) x[a] = s;
		if(t != b) x[b] = t;
		return s == t;
	}
	
	int Count(int a){
		int b = 0;
		for(int i = 0 ; i < a ; ++i) if(x[i] < 0) ++b;
		return b;
	}
} uf;


const int MC = 100010;
int N,M;
int K;
int a[MC],b[MC],w[MC];
int c[MC];
int s[MC];

int main(){
	cin >> N >> M >> K;
	repp(i,1,N+1){
		cin >> c[i];
	}
	repp(i,0,M){
		cin >> a[i] >> b[i] >> w[i];
		s[i] = i;
	}
	sort(s,s+M,[&](const int x , const int y){return w[x] < w[y];});
	LL ans = 0;
	int z = 0;
	repp(i,0,M){
		if(z==K-1) break;
		if(c[a[s[i]]] == 0 || c[b[s[i]]] == 0){
			if(c[a[s[i]]] != 0){
				if(uf.Find(c[a[s[i]]],K+b[s[i]])) continue;
				uf.Union(c[a[s[i]]],K+b[s[i]]);
			} else if(c[b[s[i]]] != 0){
				if(uf.Find(c[b[s[i]]],K+a[s[i]])) continue;
				uf.Union(c[b[s[i]]],K+a[s[i]]);
			} else {
				if(uf.Find(K+a[s[i]],K+b[s[i]])) continue;
				uf.Union(K+a[s[i]],K+b[s[i]]);
			}
			ans += w[s[i]];
			++z;
			continue;
		}
		if(uf.Find(c[a[s[i]]],c[b[s[i]]])) continue;
		uf.Union(c[a[s[i]]],c[b[s[i]]]);
		ans += w[s[i]];
		++z;
	}
	cout << (z<K-1?-1:ans) << endl;
	return 0;
}


Measured memory_bytes: 3072
import java.util.Scanner;

/**
 * @author yoshida3203
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
//		String str="ABCDE";
		Scanner sc=new Scanner(System.in);
		String str=sc.next();
		char[]word=str.toCharArray();

		int sum=0;
		int max=0;
		for(char a:word){
			if(a=='A'||a=='C'||a=='G'||a=='T'){
				sum++;
				max=Math.max(max, sum);
			}else{
				sum=0;
			}
		}
		System.out.println(max);



	}

}


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

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

    int sum = 0;
    for (int i = 1; i < N + 1; i++) {
        sum += B[A[i]];
        if (i != 1 && A[i] - A[i-1] == 1) sum += C[A[i-1]];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N,K,a=1;
    cin >> N >> K;
    for (int i=0;i<N;i++){
        if (a*2>a+K){
            a+=K;
        }else{
            a*=2;
        }
    }
    cout << a;
}

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

using namespace std;

bool judge(const string& str)
{
	int size = str.length();
	int C_idx = -1;
	int F_idx = -1;

	for (int i = 0; i < size; ++i)
	{
		if (str[i] == 'C')
		{
			C_idx = i;
			break;
		}

	}

	for (int i = size - 1; i >= 0; --i)
	{
		if (str[i] == 'F')
		{
			F_idx = i;
			break;
		}

	}
	if (C_idx == -1 || F_idx == -1)	return false;
	if (C_idx < F_idx)	return true;
	else	return false;
}

int main(int argc, char* argv[])
{
	string str;
	getline(cin, str);
	int res = judge(str);
	if (res)	cout << "Yes" << endl;
	else { cout << "No" << endl; }
	//cin.get();
	//cin.get();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  char tmp = S[0];
  int ans = 1;
  rep(i, N) {
    if(S[i] != tmp) {
      ans++;
      tmp = S[i];
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 512
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        String s = scan.next();
        int a = 0;
        int b = 0;
        int c = 4;
        a = Character.getNumericValue(s.charAt(0)) * 10 + Character.getNumericValue(s.charAt(1));
        b = Character.getNumericValue(s.charAt(2)) * 10 + Character.getNumericValue(s.charAt(3));
        if(1 <= a && a <= 12){
            if(1 <= b && b <= 12){
                c = 3;
            }else{
                c = 2;
            }
        }else if(1 <= b && b <= 12){
            if(1 <= a && a <= 12){
                c = 3;
            }else{
                c = 1;
            }
        }
        if(c == 1){
            System.out.println("YYMM");
        }else if(c == 2){
            System.out.println("MMYY");
        }else if(c == 3){
            System.out.println("AMBIGUOUS");
        }else{
            System.out.println("NA");
        }
    }
}

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

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();

        final Solver solver = new Solver();
        solver.solve(N, S);
    }
}

class Solver {
    public void solve(int N, String S) {
        int ans = 0;
        int cur = 'A';
        for (int i = 0; i < N; i++) {
            char c = S.charAt(i);
            if (cur == c) {
                cur++;
                if (cur > 'C') {
                    ans++;
                    cur = 'A';
                }
            }
            else {
                cur = (c == 'A') ? 'B' : 'A';
            }
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 23892
#!/usr/bin/env python3

L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(L[K-1])

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

int selection(vector<int>&a) {
	int mini;
	int cnt = 0;
	for (int i = 0; i<int(a.size()); i++) {
		mini = i;
		for (int j = i; j<int(a.size()); j++)
			if (a[j] < a[mini])
				mini = j;
		if (i != mini) {
			swap(a[i], a[mini]);
			cnt++;
		}	
	}
	return cnt;
}
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	int cnt = selection(a);
	rep(i, n)cout << a[i] << (i == n - 1 ? '\n' : ' ');
	cout << cnt << endl;;
	return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int arr[n];
    int i, j, sum1=0, sum2=0, mini=5050;

    for (i = 0; i < n; i++)
    {
        scanf("%d",&arr[i]);
    }
    for (j = 1; j<= n; j++)
    {
        for (i = 0; i < j; i++)
        {
            sum1=sum1+arr[i];
        }
        for (i = j; i < n; i++)
        {
            sum2=sum2+arr[i];
        }
        if(mini > abs(sum1-sum2))
        {
            mini = abs(sum1-sum2);
        }
        sum1= 0;
        sum2= 0;
    }
    printf("%d\n",mini);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int, int> P;
Int m, n, i, j, k, a, b, c, d;
Int gcd( Int a, Int b )
{
    if( a < b ) swap( a, b );
    if( b == 0 ) return a;
    return gcd( b, a % b );
}
main()
{
    cin >> a >> b >> c >> d;
    Int u = b - a + 1;
    u -= b / c - ( a - 1 ) / c;
    u -= b / d - ( a - 1 ) / d;
    Int lcm = c * d /  gcd( c, d );
    u += b / (lcm  ) - ( a - 1 ) / ( lcm );
    cout << u << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int a, b;
	cin >> a >> b;
	int ans = max(0, a - 2 * b);
	cout << ans;*/


	/*int n;
	cin >> n;
	vector<int>d(n);
	rep(i, n)cin >> d[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += d[i] * d[j];
		}
	}
	cout << ans;*/


	/*int n;
	string s;
	cin >> n >> s;
	s += " ";
	int ans = 0;
	rep(i, n) {
		if (s[i] != s[i + 1])ans++;
	}
	cout << ans;*/


	int n;
	cin >> n;
	vector<ll>l(n);
	rep(i, n)cin >> l[i];
	sort(all(l), greater<ll>());
	int i, j, k;
	ll ans = 0;
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			for (k = j + 1; k < n; k++) {
				if (l[i] >= l[j] + l[k])break;
				ans++;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        r: i64,
        g: i64,
        b: i64,
        n: i64,
    }

    let mut ans = 0;
    for i in 0..(n / r + 1) {
        let n = n - r * i;
        for j in 0..(n / g + 1) {
            let n = n - g * j;
            if n >= 0 && n % b == 0 {
                ans += 1;
            }
        }
    }

    println!("{}", ans);
}


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

int main() {
  string S;
  cin >> S;
  int total = 0;
  for(int i=0; i < (int)S.size(); i++) {
      if(S.at(i) == '+') {
          total += 1;
      }
      else{
          total -= 1;
      }
  }
  cout << total << endl;
}


Measured memory_bytes: 3580
n=int(input())
x=input()
t=int(x,2)
c=x.count('1')
a=t%-~c
b=0 if c<2 else t%~-c
for i in range(n):
  if int(x[i]):
    if c<2: print(0); continue
    else: t=(b-pow(2,n-i-1,c-1))%~-c
  else: t=(a+pow(2,n-i-1,c+1))%-~c
  z=1
  while t:
    d=bin(t).count('1')
    t%=d
    z+=1
  print(z)

Measured memory_bytes: 9416
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


ll getClBig(ll a, ll c){
  if(a%c == 0) return a;
  return a+c-a%c;
}

ll getClLow(ll a, ll c){
  if(a%c == 0) return a;
  return a-a%c;
}

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

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

    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll canAll = B-A+1;

    ll canC = (getClLow(B,C) - getClBig(A,C))/C + 1;
    ll canD = (getClLow(B,D) - getClBig(A,D))/D + 1;
    ll M = C*D/gcd(C,D);
    ll canM = (getClLow(B,M) - getClBig(A,M))/M + 1;

    cout << canAll - canC - canD + canM << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 1000010
#define ll long long
#define mod 1000000007
using namespace std;
int f[maxn], suf[maxn], fac[maxn], inv[maxn];
int calc(int a, int k)
{
	int ans = 1;
	while (k)
	{
		if (k % 2) ans = (ll)ans * a % mod;
		a = (ll)a *a % mod;
		k /= 2;
	}
	return ans;
}
int main()
{
	int n, h, d;
	cin >> n >> h >> d;
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = (ll)fac[i - 1] * i % mod;
	suf[h] = f[h] = fac[n - 1];
	for (int i = 0; i <= n; i++)
		inv[i] = calc(fac[i], mod - 2);
	int tmp = fac[n];
	for (int i = 1; i <= n - 1; i++)
		tmp = (tmp + fac[i]) % mod;
	for (int i = h - 1; i >= 1; i--)
	{
		f[i] = ((ll)suf[i + 1] - suf[min(i + d + 1, h)] + mod) % mod * tmp % mod;
		if (i + d >= h) f[i] = (f[i] + (ll)f[h] * tmp % mod) % mod;
		suf[i] = (suf[i + 1] + f[i]) % mod;
	}
	int res = 0;
	for (int i = 1; i <= d; i++)
		res = (res + (ll)n * f[i] % mod) % mod;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n;
int a[N], f[N];
int ans = 0;

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		ans += f[a[i]];
		f[a[i]]++;
	}	
	for(int i = 1; i <= n; i++)
	{
		ans -= f[a[i]] - 1;
		cout << ans << endl;
		ans += f[a[i]] - 1;
	}
	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int a, b;
  char c;
  cin >> a >> c >> b;
  if (c == '+')
    cout << a + b << endl;
  else
    cout << a - b << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		scan.useDelimiter("\\s");
		
		String W = scan.next();
		String H = scan.next();
		String x = scan.next();
		String y = scan.next();
		String r = scan.next();
		
		
		
		System.out.println(JudgeCircle(Integer.parseInt(W), Integer.parseInt(H), Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(r)));
	}
	
	public static String JudgeCircle(int W, int H, int x, int y, int r){
		if(x + r <= W && x - r >= 0 && y + r <= H && y - r >= 0){
			return "Yes";
		}else{
			return "No";
		}
	}
}

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

using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pf 				push_front
#define mp              make_pair
#define pii             pair<int,int>
#define MAX 			1000000
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
void c_p_c()
{
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
const int Max = 1e7;
int32_t main()
{
	//c_p_c();
	int n;
	cin >> n;
	int temp = floor(log10(n)) + 1;
	if (temp == 1)
		cout << n;
	else if (temp == 2)
		cout << "9";
	else if (temp == 3)
		cout << 9 + (n - 100 + 1);
	else if (temp == 4)
		cout << 9 + (900);
	else if (temp == 5)
		cout << 909 + (n - 10000 + 1);
	else if (temp == 6)
		cout << "90909";
}


Measured memory_bytes: 3912
def main():
    s = int(input())

    s1 = s // 100
    s2 = s - s1 * 100

    if s1 == 0:
        s1 = 13
    if s2 == 0:
        s2 = 13

    if s1 <= 12 and s2 <= 12:
        print('AMBIGUOUS')
    elif s1 <= 12 and s2 > 12:
        print('MMYY')
    elif s1 > 12 and s2 <= 12:
        print('YYMM')
    else:
        print('NA')

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
n,m=map(int,input().split())
l,r=[],[]

for i in range(m):
  ll,rr=map(int,input().split())
  l.append(ll)
  r.append(rr)
  
print(min(r) - max(l) + 1 if min(r)-max(l) >= 0 else 0)

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
int n, t;
int mx, mn = 1e9;
int f[100005];
int main()
{
	scanf("%d%d", &n, &t);
	for(int x, i = 1; i <= n; i++)
	{
		scanf("%d", &x);
		f[i] = max(x - mn, 0);
		mn = min(mn, x);
		mx = max(mx, f[i]);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		ans += (f[i] == mx);
	}
	printf("%d\n", ans);
	return 0;
}


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


int n,a[3400010] = {};
int main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		int A,b;
		cin >> A >> b;
		a[A + b]++;
	}
	for(int i = 0;i <= 3400000;i++){
		if(a[i] % 2) cout << i << " " << 0 << endl;
		a[i + 1] += a[i] / 2;
	}
	return 0;
}

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

using lint = int64_t;
#define bit(n) ((lint)1 << n);
const int INF = 1e9;
const lint LINF = 1e18;

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

class IoSetup {
    public:
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
        cerr << fixed << setprecision(12);
    }
} iosetup;

struct UnionFind {
    int n;
    vector<int> pars, sizes;

    UnionFind(int n): pars(n), sizes(n) {
        for (int i = 0; i < n; i++) {pars[i] = i; sizes[i] = 1;}
    }
    int root(int i) {
        if (pars[i] == i) return i;
        else return pars[i] = root(pars[i]);
    }
    bool is_same(int i, int j) {
        return root(i) == root(j);
    }
    void unite(int i, int j) {
        sizes[root(i)] += sizes[root(j)];
        pars[root(j)] = root(i);
    }
    int size(int i) {
        return sizes[root(i)];
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }

    int ans = n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i != j) {
                UnionFind uf(n);
                uf.unite(i, j);
                int p = x[i] - x[j], q = y[i] - y[j];
                for (int k = 0; k < n; k++) {
                    for (int l = 0; l < n; l++) {
                        if (k != l and p == x[k] - x[l] and q == y[k] - y[l]) {
                            uf.unite(k, l);
                        }
                    }
                }

                set<int> nd;
                for (int k = 0; k < n; k++) {
                    nd.insert(uf.root(k));
                }
                ans = min(ans, (int)nd.size());
            }
        }
    }

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<unordered_map>
#include<string>
#define LL long long
#define li i<<1
#define ri i<<1|1
using namespace std;
inline LL read()
{
    char c=getchar();LL x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
LL n,d,x,y,ans;
int main()
{
	n=read();
	d=read();
	while(n--){
		x=read();
		y=read();
		if(x*x+y*y<=d*d)
			++ans;
	}
	printf("%lld\n",ans);
	return 0;
}


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

li = [0]*n

for i in range(m):
    s, c = map(int, input().split())
    if li[s-1] != 0 and li[s-1] != c:
        print(-1)
        exit(0)
    if s==1 and c==0:
        if n>1:
            print(-1)
            exit(0)
    li[s-1]=c

if n>1 and li[0]==0:
    li[0]=1

for i in range(n):
    print(li[i], end="")

Measured memory_bytes: 3188
#include <iostream>

int main()
{
	int h, w;
	for (;;) {
		std::cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (int i=0; i!=h; ++i) {
			for (int j=0; j!=w; ++j) {
				std::cout << '#';
			}
			std::cout << '\n';
		}
		std::cout << '\n';
	}
}

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

typedef long long ll;
const int maxn = 2e5+10;
const int mod = 1e9+7;

int a[maxn];
ll sum[maxn];
int main(void){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		sum[i] = sum[i-1]+a[i];
		sum[i] %= mod;	
	}
	ll ans = 0;
	for(int i = 1; i < n; i++){
		ans += a[i]*(sum[n]-sum[i] + mod) % mod;
		ans %= mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5924
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main(){
    long long n,t,a;
    cin >> n >> t >> a;
    vector<int> h(n);
    long double tem;
    long long temp;
    a = a*1000;
    int num;
    int min = 5000000;
    int sum,ans;
    rep(i,n){
        cin >> h.at(i);
        temp = 1000*(t - 0.006*h.at(i));
        if( temp >= a) num = temp - a;
        else num = a - temp;
        if(num <= min){
            min = num;
            ans = i;
        }
    }
    cout << ans+1 << endl;
}


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

int N, M;
vector<int> G[1000000];
vector<int> e(1000000, -1);

int dfs(int s) {
    if (e[s] > 0) return e[s];
    int sum = 0;
    for (int i = 0; i < G[s].size(); i++) {
        sum = max(sum, dfs(G[s][i]) + 1);
    }
    return e[s] = sum;
}

int main() {
    cin >> N >> M;
    vector<bool> v(N, false);
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
        v[y] = true;
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (!v[i]) {
            ans = max(ans, dfs(i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 35456
(defun solve (n)
  (let ((tmp 0))
    (loop for i from 1 to n
          do (setq tmp (+ tmp i))
          when (<= n tmp)
          return (loop for j from 1 to i
                   unless (= (- tmp n) j)
                   collect j))))

(format t "~{~A~%~}" (solve (read)))

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

int main() {
 int A,B,C,X;
 cin >> A >>B >> C>>X;

 int count=0;

 
  for(int i=0;i<=A;i++){
    for(int j=0;j<=B;j++){
      for(int k=0;k<=C;k++){
        if(X==(500*i+100*j+50*k)){
          count++;
        }
      }
    }
  }

  cout << count <<endl;


}

Measured memory_bytes: 256
'use strict';

function main(arg) {
    arg = arg.split(" ").sort((a,b)=>a-b);
    let ans = 0;
    
    for(let i=0; i<arg.length-1; i++) {
        ans = ans + (arg[i+1] - arg[i]);
    }
    
    console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
    int n, p;
    string s;
    cin >> n >> p;
    cin >> s;
    long long ans = 0;
    if(p == 2 | p == 5) {
        for(int i = 0; i < n; i++) {
            if((s[i] - '0') % p == 0) {
                ans += (i + 1);
            }
        }
    } else {
        vector<int> cnt(p);
        cnt[0] = 1;
        long long tmp = 1;
        long long sum = 0;
        for(int i = n - 1; i >= 0; i--) {
            sum = ((s[i] - '0') * tmp + sum) % p;
            ans += cnt[sum];
            cnt[sum]++;
            tmp = tmp * 10 % p;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let a = get!([f64]);

    let res = a.iter().fold(0.0, |sum, &e| sum + 1.0/e);
    println!("{}", 1.0/res);
}


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


int main (){
    int N, K;
    string S;
    cin>>N>>K>>S;
    if(S.at(K-1)=='A'){
        S.at(K-1)='a';
    }
    if(S.at(K-1)=='B'){
        S.at(K-1)='b';
    }
    if(S.at(K-1)=='C'){
        S.at(K-1)='c';
    }
    cout<<S<<endl;
    
}

Measured memory_bytes: 256
import math
N,K = map(int,input().split())
ans = 0

if N >= K:
    ans += N-K+1 
    for i in range(1,K):
        ans += 1/(2 ** math.ceil(math.log2(K/i)))
else:
    for i in range(1,N+1):
        ans += 1/(2 ** math.ceil(math.log2(K/i)))

print(ans/N)

Measured memory_bytes: 3060
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;

int main()
{
  //"Don't regret anything you do, because in the end it makes you who you are."
  int a,b;
  cin >> a >> b;
  cout << a*b;
  return 0;
}

Measured memory_bytes: 3632
//solve1 : O(N)解法
//solve2 : O(N ^ 2)解法

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;
typedef pair<int, int> 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; }

string s;

//O(N)
string solve1(string s){
  int n = s.size();
  if(n % 2 == 1) return "No";
  for(int i = 0; i < n; i += 2){
    if(s.at(i) != 'h' || s.at(i + 1) != 'i')
      return "No";
  }
  return "Yes";
}

//O(N ^ 2)
string solve2(string s){
  int n = s.size();
  string comp = "hi";
  rep(i, n / 2){
    if(s == comp) return "Yes";
    comp += "hi";
  }
  return "No";
}

int main(){
  cin >> s;
  cout << solve1(s) << endl;
  //cout << solve2(s) << endl;
}


Measured memory_bytes: 256
from math import sqrt
A = []
for i in range(2,300000):
    if i%7==1 or i%7==6:
        k = 1
        for j in A:
            if j>sqrt(i):
                break
            elif i%j==0:
                k = 0
                break
        if k==1:
            A.append(i)
while True:
    n = int(input())
    if n==1:
        break
    a = n
    ans = []
    for b in A:
        if a%b==0:
            ans.append(b)
        if a<b:
            break
    print(str(n)+":",end=" ")
    print(*ans)


Measured memory_bytes: 6964
#include <stdio.h>

int main(void){
    char S[27];
    scanf("%s", S);
    
    int i=0, d[26];
    for(int j=0; j<26; j++){
        d[j] = 0;
    }

    while(S[i]!='\0'){
        int n = S[i] - 'a';
        d[n]++;
        if(d[n]>1){
            printf("no\n");
            return 0;
        }
        i++;
    }

    printf("yes\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)



int main (){
  string s;
  cin >> s;
  ll ans=0;
  int n=s.size();
  r(i,n){
    if(i!=n-1){
      r(j,n-i-1){
        ans+=(s[i]-'0')*pow(10,j)*pow(2,n-2-j);
      }
    }
    ans+=(s[i]-'0')*pow(10,n-i-1)*pow(2,i);
  }

  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        int r;
        int d = Math.DivRem(a, b, out r);
        double f = (double)a / b;
        Console.WriteLine(d + " " + r + " " + f.ToString("F10"));
    }
}


Measured memory_bytes: 17852