akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
using static Func;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; }
	static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var ps = MakeArray(N, i => { var x = Strs; return new Tuple<string, int, int>(x[0], int.Parse(x[1]), i + 1); });
		Array.Sort(ps, (x, y) => { var c = x.Item1.CompareTo(y.Item1); return c == 0 ? y.Item2.CompareTo(x.Item2) : c; });
		foreach (var t in ps) WriteLine(t.Item3);
	}
}
static class Func { }


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

int search (int i, int j, vector<string> s) {
    int cnt = 0;
    for (int x=-1; x<=1; x++) {
        for (int y=-1; y<=1; y++) {
            if (i+x < 0 || j+y < 0) continue;
            if (i+x >= s.size() || j+y >= s[i].size()) continue;
            if (x == 0 && y == 0) continue;
            if (s[i+x][j+y] == '#') cnt++;
        }
    }
    return cnt;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i=0; i<h; i++) cin >> s[i];
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (s[i][j] == '#') {
                cout << "#";
                continue;
            }
            cout << search(i, j, s);
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;
 
using namespace std;

int f(int x, int y) {

	int r = y % x;
	if (r == 0) return x;

	return f(r, x);
}

int main() {

	int x, y;
	cin >> x >> y;

	cout << f(y, x) << endl;
}



Measured memory_bytes: 3104
import java.util.Scanner;

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

            long mod = (long) (1e9 + 7);

            long countAll = 1;
            for (int i = 0; i < N; i++) {
                countAll *= 10;
                countAll %= mod;
            }

            long count9 = 1;
            for (int i = 0; i < N; i++) {
                count9 *= 9;
                count9 %= mod;
            }

            long count8 = 1;
            for (int i = 0; i < N; i++) {
                count8 *= 8;
                count8 %= mod;
            }

            long res = countAll;
            res += -count9 + mod;
            res %= mod;
            res += -count9 + mod;
            res %= mod;
            res += count8;
            res %= mod;

            System.out.println(res);
        }
    }
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

i64 P;
const int maxn = 6100;
i64 fact[maxn], tcaf[maxn], d2[maxn];

i64 deg(i64 x, i64 d) {
    if (d < 0) d += P - 1;
    i64 y = 1;
    while (d) {
        if (d & 1) (y *= x) %= P;
        (x *= x) %= P;
        d /= 2;
    }
    return y;
}

i64 cnk(int n, int k) {
    return fact[n] * tcaf[k] % P * tcaf[n - k] % P;
}

i64 rec(int lft, int z, int a) {
    if (z == 0) {
        i64 ans = tcaf[a] % P * d2[a] % P * rec(lft, 1, 0);
        if (lft) (ans += rec(lft - 3, 0, a + 1) * cnk(lft, 3)) %= P;
        return ans;
    }
    i64 ans = tcaf[a];
    if (a + 1 <= lft - 2) (ans += cnk(lft, 2) * rec(lft - 2, 1, a + 1)) %= P;
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n >> P;
    fact[0] = 1;
    for1(i, 3 * n) fact[i] = i * fact[i - 1] % P;
    forn(i, 3 * n + 1) tcaf[i] = deg(fact[i], -1);
    d2[0] = 1;
    forn(i, 3 * n) d2[i + 1] = d2[i] * 2 % P;

    cout << rec(3 * n, 0, 0) << '\n';

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


Measured memory_bytes: 512
#include<stdio.h>

int main()
{
    int i=0 ;
    int cmp=0 ;
    int alp[26] = {0} ;

    char str[1200] = {0} ;
    char mem=0 ;

    while ( scanf("%s",str) != EOF ){

        for (i=0 ;i<1200 ;i++){

            if (str[i] == '\0') break ;

            if (str[i] >= 'A' && str[i] <='Z'){
                cmp=str[i] - 'A' ;
                alp[cmp]++ ;

            } else if (str[i] >= 'a' && str[i] <= 'z'){
                cmp=str[i] - 'a' ;
                alp[cmp]++ ;

            }

            cmp=0 ;

        }
    }

    for (i=0 ;i<26 ;i++){

        mem=i + 'a' ;
        printf("%c : %d\n",mem ,alp[i]) ;

    }

    return 0;
}

Measured memory_bytes: 540
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll d[310][310];

int main(){
  ll h,w,k;
  cin>>h>>w>>k;
  clr(d,-1);
  vector<string> vs;
  rep(y,0,h){
    string s;
    cin>>s;
    vs.pb(s);
  }
  ll c = 0;
  rep(y,0,h){
    rep(x,0,w){
      if(vs[y][x]=='#'){
        d[y][x] = c;
        c++;
      }
    }
  }
  rep(x,0,w){
    rep(y,1,h){
      if(d[y-1][x]!=-1&&d[y][x]==-1){
        d[y][x] = d[y-1][x];
      }
    }
    per(y,0,h-1){
      if(d[y+1][x]!=-1&&d[y][x]==-1){
        d[y][x] = d[y+1][x];
      }
    }
  }
  rep(x,1,w){
    rep(y,0,h){
      if(d[y][x-1]!=-1&&d[y][x]==-1){
        d[y][x] = d[y][x-1];
      }
    }
  }
  per(x,0,w-1){
    rep(y,0,h){
      if(d[y][x+1]!=-1&&d[y][x]==-1){
        d[y][x] = d[y][x+1];
      }
    }
  }
  rep(y,0,h){
    rep(x,0,w){
      cout << d[y][x]+1;
      if(x!=w-1)cout << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
using namespace std;
int main (){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if (A+B>C+D){
        cout << "Left";
    }else if(A+B<C+D){
        cout << "Right";
    }else{
        cout << "Balanced";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;
typedef long long ll;

int main() {
    int a;
    cin >> a;
    int ans = a + a * a + a * a * a;
    cout << ans << endl;
}

Measured memory_bytes: 3592
from collections import deque
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
A = [input().rstrip() for _ in range(H)]
dist = [[-1] * W for _ in range(H)]
queue = deque()
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            dist[i][j] = 0
            queue.append((i, j))
while queue:
    i, j = queue.popleft()
    for di, dj in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        ni, nj = i+di, j+dj
        if 0 <= ni < H and 0 <= nj < W and dist[ni][nj] == -1:
            dist[ni][nj] = dist[i][j] + 1
            queue.append((ni, nj))
print(max(max(row) for row in dist))

Measured memory_bytes: 85980
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;





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

for(int i=1;i<=100000;i++){


    int a = int(double(i) * 0.08);
    int b = int(double(i) * 0.1);

    if(a == A and b == B) {
        cout<<i<<endl;
        return 0;
    }





}

cout<<-1<<endl;
return 0;



}

Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MAX = 10**18
MIN = -10**18
MOD = 998244353

n,y = map(int,input().split())

for i in range(n+1):
    for j in range(n+1):
        d = y - i*10000 - j*5000
        cnt = n-i-j
        if cnt>= 0 and cnt*1000 == d:
            print(i,j,cnt)
            sys.exit() 
print("-1 -1 -1")

Measured memory_bytes: 3316
n=input()
pon = [0, 1, 6, 8]
hon = [2, 4, 5, 7, 9]
if int(n[len(n)-1]) in pon:
  print('pon')
elif int(n[len(n)-1]) in hon:
  print('hon')
else:
  print('bon')


Measured memory_bytes: 9000
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int INF=INT_MAX;
int n;
int l[10];
int A,B,C;
int temp;
void sort3(int &a,int &b,int &c){
  if(c<a){
    if(c<b){
      if(a<b){
	temp=a;a=c;c=b;b=temp;
      }
      else{
	temp=a;a=c;c=temp;
      }
    }
    else{
      temp=a;a=b;b=c;c=temp;
    }
  }
  else{
    if(a<b){
      if(c<b){
	temp=b;b=c;c=temp;
      }
    }
    else{
      temp=a;a=b;b=temp;
    }
  }
}

int res=INF;
void rec(int i,int a,int b,int c,int amp,int bmp,int cmp){
  if(i==n){
    if(a!=0&&b!=0&&c!=0){
      sort3(a,b,c);
      res=min(res,abs(A-a)+abs(B-b)+abs(C-c)+10*(amp+bmp+cmp));
    }
    return ;
  }
  rec(i+1,a+l[i],b,c,amp+1,bmp,cmp);
  rec(i+1,a,b+l[i],c,amp,bmp+1,cmp);
  rec(i+1,a,b,c+l[i],amp,bmp,cmp+1);
  rec(i+1,a,b,c,amp,bmp,cmp);
}
    
int main(){
  cin>>n;
  cin>>A>>B>>C;
  sort3(A,B,C);
  rep(i,n){
    cin>>l[i];
  }
  rec(0,0,0,0,-1,-1,-1);
  prin(res);

  

  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=defaultdict(lambda:0)
# dp[i]:足場iに到達するための最小コスト。はじめカエルは足場1にいるのでdp[1]=0
dp[1]=0
dp[2]=abs(h[0]-h[1])
for i in range(3,n+1):      
      dp[i]=min([dp[i-j]+abs(h[i-1]-h[i-j-1]) for j in range(1,min(k+1,i))])
print(dp[n])


Measured memory_bytes: 63328
#include <stdio.h>

int main(){
    char str[15];
    char str2[15];
    scanf("%s", str);
    
    for(int i=0, j=0;str[i]!='\0';i++){
        if(str[i] == '0'){
            str2[j] = '0';
            ++j;
            str2[j] = '\0';
        } else if(str[i] == '1'){
            str2[j] = '1';
            ++j;
            str2[j] = '\0';
        } else {
            if(j>0){
                str2[--j] = '\0';
            }
        }
    }
    printf("%s", str2);
    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll K,X,Y;
int dbg;
int main() {
	cin>>K>>X>>Y;
	ll rx=1,ry=1;
	if(X<0)X*=-1,rx=-1;
	if(Y<0)Y*=-1,ry=-1;
	ll dist=X+Y;
	if(dist==K) {
		printf("1\n%lld %lld",X*rx,Y*ry);
	} else if(dist==0) {
		printf("2\n%lld 0\n0 0",K*rx);
	} else {
		if(K%2==0 && dist%2) {
			puts("-1");
			return 0;
		}
		vector<pii> ans;
		while(X||Y) {
			dist=X+Y;
			ans.push_back({X,Y});
			if(dist%K==0) {
				ll t=min(X,K);
				X-=t, Y-=K-t;
			} else if(dist>K) {
				ll m=dist/K, x, y;
				if((X-Y+(m+1)*K)%2==1) m++;
				x=(X-Y+(m+1)*K)/2;
				y=-x+m*K;
				if(x<0||y<0) {
					x=(X-Y+(m-1)*K)/2;
					y=-x+m*K;
				}
				X=x,Y=y;
			} else {
				ll m=1,x,y;
				if((X-Y+(m+1)*K)%2==1) {
					x=X+K;
					y=Y;
				} else {
					x=(X-Y+(m+1)*K)/2;
					y=-x+m*K;
					if(x<0||y<0) {
						x=(X-Y+(m-1)*K)/2;
						y=-x+m*K;
					}
				}
				X=x,Y=y;
			} 
			//if(dbg++>=100) break;
			//printf("%lld %lld\n",X,Y);
			//y=-x+mK, y-Y+K=x-X, y=x-X+Y-K=-x+mK, 2x=X-Y+(m+1)K
			//y=-x+mK, y-Y-K=x-X, y=x-X+Y+K=-x+mK, 2x=X-Y+(m-1)K
		}
		reverse(all(ans));
		printf("%d\n",sz(ans));
		for(auto& it:ans) printf("%lld %lld\n",it.fi*rx,it.se*ry);
	}
	return 0;
}

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

public class Main {

	private int getMinCost(int n, int[] p) {
		int[][] m = new int[n+1][n+1];
		for (int s = 0; s < n; s++) {
			for (int i = 1, j = s + 2; j <= n; i++, j++) {
				m[i][j] = Integer.MAX_VALUE;
				for (int k = i; k < j; k++) {
					m[i][j] = Math.min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
				}
			}
		}
		return m[1][n];
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int[] p = new int[n+1];
		for (int i = 0, j = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(reader.readLine());
			int n1 = Integer.parseInt(st.nextToken());
			int n2 = Integer.parseInt(st.nextToken());
			if (i == 0) {
				p[j++] = n1;
			}
			p[j++] = n2;
		}
		reader.close();
		System.out.println(getMinCost(n, p));
	}	

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


Measured memory_bytes: 24560
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;
// typedef long long int 
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
// typedef pair<ll,ll> pll;
const int modi = 1e9+7;

void solve(){
	int n,m;
	cin >> n >> m;
	string s;
	cin >> s;
	int dp[n+1]; // number of jumps to reach i
	memset(dp,0,sizeof(dp));
	set<int> last_reach;
	last_reach.insert(n);
	for(int i =n-1;i>=0;i--){
		// cout << i << endl;/
		if(s[i]=='1')
			dp[i] = modi;
		else{
			if(i+m<*last_reach.begin()){
				dp[i] = modi;
				continue;
			}
			int to = *--last_reach.upper_bound(i+m);
			// cout << " to " << to << endl;
			if(to>i+m)
				dp[i] = modi;
			else{
				if(dp[to]==modi)dp[i] = modi;
				else{
					dp[i] = 1 + dp[to];
					last_reach.insert(i);
				}
			}
		}
	}
	if(dp[0]!=modi){
		int jumps = dp[0];
		// cout << jumps << endl;
		// int i =1;
		int last = 0;
		vector<int> places;
		for(int i =1;i<=n;i++){
			if(dp[i]==jumps-1){
				places.pb(i-last);
				last = i;
				jumps--;
			}
		}

		for(auto e:places){
			cout << e << " ";
		}
		cout << endl;
	}	
	else{
		cout << -1 << endl;
	}
 }
int main(){
	fast;
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif

	// int t;cin >> t;while(t--)
		solve();
}


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

#define reps(i,j,n) for(int i = (j) ; i < (int)(n) ; ++i)    
#define rep(i,n) reps(i,0,n)  
#define each(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)  
  
#define all(v) (v).begin(), (v).end()  
#define pb(x) push_back(x)  
#define sz(x) (int)((x).size())  
#define UNQ(s) {sort(ALL(s));(s).erase(unique(ALL(s)),(s).end());}   
#define fr first  
#define sc second  
  
typedef pair< int , int > Pi;  
typedef pair< int , Pi > Pii;

  
typedef long long int64;  
const int INF = 1 << 30;  
  
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is>>a.first>>a.second; }  
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os<<a.first<<" "<<a.second; }  
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ rep(i,sz(vc)) is >> vc[i]; return is;}  
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ rep(i,sz(vc)) os << vc[i] << endl; return os; }  

int main(){
  int n;
  vector< vector< int > > vc( 5, vector< int >(5));

  int dp[6][4][4][4][4];
  int temp[] = { 0, 60, 70, 80};


  cin >> n;
  while(n--){
    cin >> vc;

    fill_n( ****dp, 6 * 4 * 4 * 4 * 4, -1);
    dp[0][0][0][0][0] = 0;

    for(int i = 0; i < 5; i++){
      for(int j = 0; j < 4; j++){
        for(int k = 0; k < 4; k++){
          for(int l = 0; l < 4; l++){
            for(int m = 0; m < 4; m++){
              if(dp[i][j][k][l][m] == -1) continue; /* 一番下足してないかも >< */

              for(int o = 0; o < 4; o++){
                for(int p = 0; p < 4; p++){
                  for(int q = 0; q < 4; q++){
                    for(int r = 0; r < 4; r++){
                      int cost = 0;

                      if(vc[i][0] != 0) cost += temp[(vc[i][0] - 1 + j + o) % 4];
                      if(vc[i][1] != 0) cost += temp[(vc[i][1] - 1 + j + k + o + p) % 4];
                      if(vc[i][2] != 0) cost += temp[(vc[i][2] - 1 + k + l + p + q) % 4];
                      if(vc[i][3] != 0) cost += temp[(vc[i][3] - 1 + l + m + q + r) % 4];
                      if(vc[i][4] != 0) cost += temp[(vc[i][4] - 1 + m + r) % 4];

                      dp[i + 1][o][p][q][r] = max( dp[i + 1][o][p][q][r], dp[i][j][k][l][m] + cost);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    cout << dp[5][0][0][0][0] << endl;
  }
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
const ll mod=1e9+7;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0',ch=getchar();}
    return x*f;
}
int n,a[N],cnt[N];
int main()
{
	n=read();
	for(int i=1; i<=n; i++){
		a[i]=read();
		cnt[a[i]]++;
	}
	ll ans=0;
	for(int i=1; i<=n; i++) if(cnt[i]) ans+=1ll*cnt[i]*(cnt[i]-1)/2;
	for(int i=1; i<=n; i++) printf("%lld\n",ans-1ll*(cnt[a[i]]-1));
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;


Node treeMinimum(Node x){
while(x->left != NIL) x = x->left;
  return x;
}


Node treeSuccessor(Node x){
Node y;

if(x->right != NIL)return treeMinimum(x->right);
y = x->parent;

while((y != NIL)&& (x == y->right)){
  x = y;
  y = y->parent;
}
return y;

}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
    return u;
  }
  if(k<u->key){
    return treeSearch(u->left,k);
  }
  else {
    return treeSearch(u->right,k);
  }
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->right==NIL || z->left==NIL){
    y = z;
   }
  else y=treeSuccessor(z);

    if(y->left != NIL)x = y->left;
    else x = y->right;

    if(x != NIL)x->parent = y->parent;
    if(y->parent == root)root = x;
    else if(y == y->parent->left)y->parent->left = x;
    else y->parent->right = x;

    if(y!=z) z->key = y->key;
    free(y);

}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;

  if(y == NIL){
    root = z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else{
      y->right = z;
    }
  }
}

void inorder(Node u){
  if(u == NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
  if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,m,a[101];
	cin>>n>>m;
	ll cnt=0;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		cnt+=a[i];
	}
	ll sum=0;
	for(ll i=0;i<n;i++){
		if(a[i]*4*m>=cnt){
			sum++;
		}
	}
	if(sum>=m){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int ans = Math.min( b/a, c);
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String c = sc.next();
      if(c.equals("a")||c.equals("e")||c.equals("i")||c.equals("u")||c.equals("o"))
        System.out.println("vowel");
      else System.out.println("consonant");
    }
}

Measured memory_bytes: 21716
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      if(x == 7||x == 5||x == 3)System.out.println("YES");
      else System.out.println("NO");
      sc.close();
    }
}


Measured memory_bytes: 22608
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if a==b:
    print("YES")
    exit()
d=abs(a-b)
if w>=v:
    print("NO")
    exit()
if d/(v-w)<=t:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 61640
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_D
// Recursion / Divide and Conquer - The Number of Inversions

#define SUBMIT

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <limits>
#include <numeric>
#include <set>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_N = 200000;
int A[MAX_N];

ui64 merge(int left, int mid, int right) {
    ui64 inv_count = 0;
    auto n1 = mid - left;
    auto n2 = right - mid;
    int L[n1 + 1], R[n2 + 1];
    for (int i = 0; i < n1; ++i) L[i] = A[left + i];
    for (int i = 0; i < n2; ++i) R[i] = A[mid + i];
    L[n1] = R[n2] = INT_MAX;

    auto i = 0, j = 0;
    for (int k = left; k < right; ++k) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
            inv_count += n1 - i;
        }
    }

    return inv_count;
}

ui64 merge_sort(int left, int right) {
    ui64 inv_count = 0;
    if (left + 1 < right) {
        auto mid = (left + right) / 2;
        auto c1 = merge_sort(left, mid);
        auto c2 = merge_sort(mid, right);
        auto c3 = merge(left, mid, right);
        inv_count += c1 + c2 + c3;
    }

    return inv_count;
}


int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> A[i];

    auto inv_count = merge_sort(0, n);
    cout << inv_count << endl;
    return 0;
}


Measured memory_bytes: 4640
orders = []
5.times { orders << gets.chomp.to_i }

def far_from_decimal(x)
  m = x % 10
  (10 - m) % 10
end
orders.sort! { |x, y| far_from_decimal(x) <=> far_from_decimal(y) }

total = orders.reduce(0) do |total, x|
  total + x + far_from_decimal(x)
end

puts(total - far_from_decimal(orders.last))


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

#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define AI(a,size,n) array<int,size> a;REP(i,n){assert(0<scanf("%d",&a[i]));}

int main(){
  INT(n);
  vector<int> ans(n + 1, -1); ans[1] = 0;
  map<int, vector<pair<int, int>>> gr;
  REP(n - 1){
    INT(u); INT(v); INT(w);
    gr[u].EB(v, w); gr[v].EB(u, w);
  }
  queue<int> q; q.push(1);
  while(!q.empty()){
    int u = q.front(); q.pop();
    for(auto p: gr[u]){
      int v, w; v = p.first; w = p.second;
      if (ans[v] < 0){
        ans[v] = (ans[u] + w) % 2;
        q.push(v);
      }
    }
  }
  REP(i, 1, n + 1){
    printf("%d\n", ans[i]);
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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


int main( int argc, char *argv[] ) {
	int n, m;
	cin >> n >> m;
	vector<ii> res(m);
	vector<vector<int>> pref;
	for ( int i = 0 ; i < m ; i++ ){
		int p, y;
		cin >> p >> y;
		pref.push_back({p, y, i});
	}
	sort(pref.begin(), pref.end());
	int ra = 1;
	for ( int i = 0 ; i < pref.size() ; i++ ){
		if ( i > 0 && pref[i-1][0] != pref[i][0] )
			ra = 1;
		res[pref[i][2]] = ii(pref[i][0], ra++);
	}
	for ( auto c : res ) {
		printf("%06d%06d\n", c.first, c.second);
	}
	return 0;
}


Measured memory_bytes: 8368
import sys

def solve():
      input = sys.stdin.readline
      N, K = map(int, input().split())
      L = [[int(i) for i in input().split()] for _ in range(K)]
      L.sort()
      mod = 998244353
      D = [0] * (N + 1)
      D[0] = 1
      D[1] = -1
      for i in range(N):
            if i > 0:
                  D[i] += D[i-1]
                  D[i] %= mod
            for l, r in L:
                  if i + l <= N:
                        D[i + l] += D[i]
                        D[i + l] %= mod
                  if i + r + 1 <= N:
                        D[i + r + 1] -= D[i]
                        D[i + r + 1] = (mod + D[i + r + 1]) % mod
      print(D[N-1])

      return 0

if __name__ == "__main__":
      solve() 

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

using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

#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

const int MOD = 1000000007;

string A; 
ll co[26], ans;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> A;
	for (char a: A) co[a-'a'] ++;
	ll N = A.length();
	ans = 1+N*(N+1)/2;
	F0R(i,26) ans -= co[i]*(co[i]+1)/2;
	cout << ans;
}

// read!
// ll vs. int!

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

int main() {
    int a, b, x ,y, z, ans=-1;
    cin >> a >> b;
    if(a%2==0) x=a*12.5;
    else x=a*12.5+1;
    if((a+1)%2==0) y=(a+1)*12.5;
    else y=(a+1)*12.5+1;
    bool flag=false;

    for(int i=x; i<y; i++) {
        z=i*0.1;
        if(z==b) {
            flag=true;
            ans=i;
            break;
        }
    }
    if(flag) cout << ans;
    else cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <functional>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(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--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    int N, C;
    cin >> N >> C;
    int D[C][C], c[N][N];

    rep(i, 0, C) rep(j, 0, C) cin >> D[i][j];
    rep(i, 0, N) rep(j, 0, N) cin >> c[i][j], c[i][j]--;

    int cost[3][C];
    memset(cost, 0, sizeof(cost));
    rep(ci, 0, C) rep(i, 0, N) rep(j, 0, N) {
        cost[(i + j) % 3][ci] += D[c[i][j]][ci];
    }

    int rsl = 1 << 30;
    rep(i, 0, C) {
        rep(j, 0, C) {
            if(i == j) continue;
            rep(k, 0, C) {
                if(i == k or j == k) continue;
                int tmp = 0;
                tmp += cost[0][i];
                tmp += cost[1][j];
                tmp += cost[2][k];
                rsl = min(rsl, tmp);
            }
        }
    }

    cout << rsl << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(int (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(int (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

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

int main()
{
    ll a,b,c,d,e,ans;
    cin >> a >> b >> c >> d;
    e = lcm(c, d);
    ans = (b - a + 1) - ((b / c + b / d) - ((a - 1) / c + (a - 1) / d) - (b / e - (a - 1) / e));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

const int INF=1001001001;

int main() {
  int N,X,Y;
  cin>>N>>X>>Y;
  X--;Y--;
  map<int,int>k;

  for(int i=0;i<N;i++){
    vector<int>dist(N,INF);
    queue<int>q;

    auto push=[&](int v,int d){
      if(dist[v]!=INF){return;}
      dist[v]=d;
      q.push(v);
    };
    push(i,0);
    while(!q.empty()){
      int v=q.front();q.pop();
      int d=dist[v];
      if(v-1>=0){push(v-1,d+1);}
      if(v+1<N){push(v+1,d+1);}
      if(v==X){push(Y,d+1);}//迂回は＋１より先に来るから更新されない
      if(v==Y){push(X,d+1);}
    }
    for(int i=0;i<N;i++){
      k[dist[i]]++;
    }
  }
  for(int i=1;i<N;i++){
    cout<<k[i]/2<<endl;
  }
  return 0;
}

Measured memory_bytes: 3700
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>

using namespace std;

void solve(int N, vector<int> A) {
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int a = A[i];
    while (true) {
      if (a % 2 == 0) {
        ans += 1;
        a /= 2;
      } else {
        break;
      }
    }
  }
  printf("%d\n", ans);
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  solve(N, A);
  return 0;
}

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

string s;

signed main()
{
    cin >> s;

    int cnt_a = 0;
    int cnt_b = 0;
    REP(i, 3){
        if (s[i] == 'A') cnt_a++;
        if (s[i] == 'B') cnt_b++;
    }

    if (cnt_a == 3 || cnt_b == 3) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

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

using namespace std;

#define ll long long
#define M 1000005
#define ii pair<ll, ll>
#define fi first
#define se second

ll n, a[1000000], b[1000000], ans;

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> n;
    for (int i = 1; i <= n + 1; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    for (int i = 1; i <= n; i++){
        if (b[i] > a[i]){
            ans += a[i];
            b[i] -= a[i];
            a[i] = 0;
        }
        else{
            ans += b[i];
            a[i] -= b[i];
            b[i] = 0;
        }
        if (b[i] > a[i + 1]){
            ans += a[i + 1];
            b[i] -= a[i + 1];
            a[i + 1] = 0;
        }
        else{
            ans += b[i];
            a[i + 1] -= b[i];
            b[i] = 0;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5120
#include<stdio.h>

int main()
{
	int a,c,d;
	int b[100000];
	scanf("%d",&a);
	for(c=0;c<a;c++)
	{
		scanf("%d",&b[c]);
	}
	for(c=0;c<a;c++)
	{
		if(b[c]%2==1)//奇数判定
		{
			d++;
		}
	}
	if(d%2==0)
	{
		printf("YES");
	}
	else{
		printf("NO");
	}
}

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

int max1(vector<int> vec){
  sort(vec.begin(),vec.end());
  return vec.at(vec.size()-1);
}
int max2(vector<int> vec){
  sort(vec.begin(),vec.end());
  return vec.at(vec.size()-2);
}

int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v.at(i);
  }
  int a=max1(v),b=max2(v);
  if(a==b){
    for(int i=0;i<n;i++){
      cout<<a<<endl;
    }
  }
  else{
    for(int i=0;i<n;i++){
      if(v.at(i)==a){
        cout<<b<<endl;
      }
      else 
        cout<<a<<endl;
    }
  }
}


Measured memory_bytes: 3184
#include<iostream>
#include<cstdlib>

using namespace std;

string str;

void change(int a,int b){
  int diff = abs(a-b);
  for(int i = 0; i < diff; i++){
    if(str[a-1] == 'z') str[a-1] = 'a';
    else str[a-1]++;
    if(str[b-1] == 'z') str[b-1] = 'a';
    else str[b-1]++;
  }
  swap(str[a-1],str[b-1]);
}

int main(){
  int in;
  while(cin >> in && in){
    cin >> str;
    int a[in],b[in];
    for(int i = 0; i < in; i++) cin >> a[i] >> b[i];
    for(int i = in-1; i >= 0; i--) change(a[i],b[i]);
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void){
	
	int x;
	
	scanf("%d",&x);
	
	if(x<=100){
	
	 if(x>=1){
	
	x = x*x*x;

	printf("%d\n",x);
	
	 }
	}
	
	return 0;
	
}


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


vector<int> prime_table(int a){
    //aまでの素数のテーブルを作成
    //main側ではa+1のvectorを作成しておく
    vector<int>X(a+1);
    int flag=0;
    X[0]=0,X[1]=0;
    for(int i=2;i<=a;i++){
        for(int j=2;j<=sqrt(i);j++){
            if(i%j==0){
                flag++;
            }
        }
        if(flag==0) X[i]=1;
        flag=0;
    }
    return X;
}
int main(){
    int Q;
    cin>>Q;
    vector<int>l(Q);
    vector<int>r(Q);
    vector<int>X(100001);
    X=prime_table(100000);
    int count=0;
    rep(i,Q){
        cin>>l[i]>>r[i];
        }

    vector<int>sum(100001,0);
    int sum2 = 0;
    for(int i=1;i<=100000;i+=2){
        if(X[i]==1&&X[(i+1)/2]==1){
            sum2+=1;
        }
        sum.at(i)=sum2;
        //cout<<i<<" "<<sum[i]<<endl;
    }
    
    rep(i,Q){
        cout<<sum[r[i]]-sum[l[i]-2]<<endl;
    }
    
    


    return 0;
}


Measured memory_bytes: 2168
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    string  s;
    cin >> s;
    int ans = 0;
    rep(i,0,sz(s)-1)if(s[i] != s[i+1])ans++;
    P(ans);
    return  0;
}


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

int main(){
    int n;
    cin>>n;
    int i=1;
    while(1){
        if(n*i%360==0)break;
        i++;
    }
    cout<<i<<endl;
}

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

int a,b;

int main(){
    cin>>a>>b;
    if(a==1)a+=13;
    if(b==1)b+=13;
    if(a>b)cout<<"Alice"<<endl;
    else if(a<b)cout<<"Bob"<<endl;
    else cout<<"Draw"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	vs s(3);
	cin >> s;
	YN(s[0][s[0].length() - 1] == s[1][0] && s[1][s[1].length() - 1] == s[2][0]);

	return 0;
}

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

using namespace std;

int main() {
  vector<int> T(5);
  for (int i = 0; i < 5; i++) cin >> T[i];
  sort(T.begin(), T.end());

  int answer = numeric_limits<int>::max();
  do {
    int time = 0;
    for (int i = 0; i < 5; i++) {
      time += T[i];
      if (i < 4) {
        time = (time + 9) / 10 * 10;
      }
    }
    answer = min(answer, time);
  } while (next_permutation(T.begin(), T.end()));
  cout << answer;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define db "knapsack"
#define fi first
#define se second
#define endl '\n'
const int INF = 1e9 + 1;
const int maxN = 1e5 + 2;
const int mod = 1e9 + 7;
typedef long long ll;
typedef int Array[maxN];
typedef ll LLArray[maxN];
typedef pair<int, int> PII;
typedef PII PIIArray[maxN];

void docfile()
{
    if (ifstream("FORM.inp"))
    {
        freopen("FORM.inp", "r", stdin);
        freopen("FORM.out", "w", stdout);
    }
    else if (ifstream(db".inp"))
    {
        freopen(db".inp", "r", stdin);
        freopen(db".out", "w", stdout);
    }
}

//-----------------------------------------------------------------------------
int n;

void solve()
{
    if(n <= 9) cout << n;
    else if(n <= 99) cout << 9;
    else if(n <= 999) cout << n - 90;
    else if(n <= 9999) cout << 909;
    else if(n <= 99999) cout << n - 9090;
    else if(n == 100000) cout << 90909;
}

void input()
{
    cin >> n;
    solve();
}

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

    input();
}


//-----------------------------------------------------------------------------
/*
template <typename T>
void write (T a)
{
    if (a < 0)
    {
        putchar ('-');
        write (-a);
        return;
    }
    if (a < 10)
    {
        putchar ('0' + a);
        return;
    }
    write (a / 10);
    putchar ((char)('0' + (a % 10)));
}

void read(long long& x)
{
    x = 0;
    int f = 1;
    char ch = getchar();
    while (!isdigit(ch))
        f = ch == '-' ? - f : f, ch = getchar();
    while (isdigit(ch))
        x = x * 10 + ch - '0', ch = getchar();
    x *= f;
}
*/




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

int h,w;

int d[50][50];
bool g[50][50][4];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		cin >> w >> h;
		if(w==0&&h==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				d[i][j]=1e9;
				for(int k=0;k<4;k++){
					g[i][j][k]=0;
				}
			}
		}
		for(int i=0;i<h-1;i++){
			for(int j=0;j<w-1;j++){
				int ww; cin >> ww;
				if(ww){
					g[i][j][2]=g[i][j+1][3]=1;
				}
			}
			for(int j=0;j<w;j++){
				int ww; cin >> ww;
				if(ww){
					g[i][j][0]=g[i+1][j][1]=1;
				}
			}
		}
		for(int j=0;j<w-1;j++){
			int ww; cin >> ww;
			if(ww){
				g[h-1][j][2]=g[h-1][j+1][3]=1;
			}
		}
		d[0][0]=0;
		queue<pair<int,int>> q; q.push(make_pair(0,0));
		while(q.size()){
			auto p=q.front(); q.pop();
			int x=p.first,y=p.second;
			for(int i=0;i<4;i++){
				if(g[x][y][i])continue;
				int nx=x+dx[i],ny=y+dy[i];
				if(0<=nx&&nx<h&&0<=ny&&ny<w){
					if(d[nx][ny]>d[x][y]+1){
						d[nx][ny]=d[x][y]+1;
						q.push(make_pair(nx,ny));
					}
				}
			}
		}
		if(d[h-1][w-1]>=1e9){
			printf("0\n");
		}else{
			printf("%d\n",d[h-1][w-1]+1);
		}
	}
}


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

int main() {
	
	int N, red, blue;
	char s[105];

	cin >> N >> s;
	red = blue = 0;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'R')
			red++;
		else
			blue++;
	}
	if (red > blue)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256