akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <sstream>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

char aba[8][5];

int abac(int n,int i){
	if(n>4){
		aba[0][i]=' ';
		aba[1][i]='*';
		n-=5;
	}else{
		aba[0][i]='*';
		aba[1][i]=' ';
	}
	aba[2][i]='=';
	for(int j=3;j<8;j++){
		if(j-3==n)aba[j][i]=' ';
		else aba[j][i]='*';
	}
}

main(){
	char num[6];
	int flag=0;
	while(cin>>num){
		if(flag)cout<<endl;
		flag=1;
		int s=strlen(num);
		for(int i=0;i<5;i++){
			if(s-5+i<0)abac(0,i);
			else abac(num[s-5+i]-'0',i);
		}
		for(int i=0;i<8;i++){
			for(int j=0;j<5;j++){
				cout<<aba[i][j];
			}
			cout<<endl;
		}
	}
}

Measured memory_bytes: 844
n = int(input())
s = list(input())
ans = s.count('R')*s.count('G')*s.count('B')
for i in range(n):
    if s[i] == 'R':
        s[i] = 1
    elif s[i] == 'G':
        s[i] = 2
    elif s[i] == 'B':
        s[i] = 4

for i in range(n):
    for j in range(i+1,n):
        k = 2*j -i
        if k >= n:
            continue
        elif s[i]+s[j]+s[k] == 7:
            ans -= 1

print(ans)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
int parent[100001];
int a[100001];
int findparent(int x)
{
	if(parent[x]!=x)
		parent[x]=findparent(parent[x]);
	return parent[x];
}
void unionset(int a,int b)
{
	if((a=findparent(a))==(b=findparent(b)))
		return;
	parent[a]=b;
}
int  main()
{
	int n,m,i,sum=0,c,b;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
		parent[i]=i;
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<m;i++)
	{
		scanf("%d %d",&b,&c);
		unionset(a[b],a[c]);
	}
	for(i=1;i<=n;i++)
	{
		if(findparent(i)==findparent(a[i]))
			sum++;
		else 
			continue;
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))
S = [0]*N

S[0] = A[0]
for i in range(1,N):
    S[i] = S[i-1]+A[i]

X = [0]*N
Y = [0]*N

p = 0
# i番目とi+1番目の間で切る
for i in range(1,N-2):
    # p番目とp+1番目の間で切る
    while S[p] * 2 < S[i] and p < i-1:
        p += 1
    
    if p == 0:
        X[i] = p
    elif abs(S[i]-2*S[p]) < abs(S[i]-2*S[p-1]):
        X[i] = p
    else:
        X[i] = p-1
    
    # print('LEFT',i,p,X[i],abs(S[i]-2*S[X[i]]))

q = 2
# i番目とi+1番目の間で切る
for i in range(1,N-2):
    if q <= i:
        q = i+1
    # q番目とq+1番目の間で切る
    while (S[q]-S[i])*2 < S[N-1]-S[i] and q < N-2:
        q += 1
    
    if q == i+1:
        Y[i] = q
    elif abs((S[N-1]-S[q])-(S[q]-S[i])) < abs((S[N-1]-S[q-1])-(S[q-1]-S[i])):
        Y[i] = q
    else:
        Y[i] = q-1
    
    # print('RIGHT',i,q,Y[i],abs((S[N-1]-S[Y[i]])-(S[Y[i]]-S[i])))

# print(S)
# print(X)
# print(Y)

ans = 10**15
for i in range(1,N-2):
    cut = (S[X[i]],S[i]-S[X[i]],S[Y[i]]-S[i],S[N-1]-S[Y[i]])
    ans = min(ans,max(cut)-min(cut))
    # print(i,ans)

print(ans)


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

int main(){
    int n,s1= 0,s2 = 0,min = 0;
    int w[1000];
    cin >> n;
    for(int i = 1 ; i <= n ; i++) cin >> w[i];

    for(int t = 1; t <= n; t++){
        s1 = 0;
        s2 = 0;
        for(int j = 1; j <= t; j++){
            s1 += w[j];
            // cout << s1 << " s1" << endl;
        }
        for(int k = t+1; k <= n; k++){
            s2 += w[k];
            // cout << s2 << " s2" << endl;

        }
        if(t == 1){
            min = abs(s1 - s2);
            // cout << min << " t = 1" << endl;
        }else if(min > abs(s1 - s2)){
            min = abs(s1 - s2);
            // cout << min << endl;
        }
    }
    cout << min;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))
cnt = 0
for i in range(n):
    cnt += max(0, (b[i] - a[i] + 1) // 2)
if sum(b) - sum(a) >= cnt:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 4340
N=int(input())
x=y=t=0
flag=True
for i in range(N):
  ti, xi, yi = map(int, input().split())
  dist = abs(xi-x)+abs(yi-y)
  dt = ti-t
  x, y, t = xi, yi, ti
  if dist<=dt and dist%2==dt%2:
    continue
  else:
    flag=False
print("Yes") if flag else print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    int Max = k-a[n-1]+a[0];
    rep(i,n-1) {
        Max = max(Max, a[i+1]-a[i]);
    }
    cout << k-Max << endl;
    return 0;
}

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

// @author: pashka

const int MAX = 1000001;

const int MOD = 1000000007;

int mul(long a, int b){
    return (a * b) % MOD; 
}

int pw(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b /= 2;
    }
    return res;
}

int inv(int x) {
    return pw(x, MOD - 2);
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> p(MAX);
    for (int i = 2; i < MAX; i++) {
        if (p[i] == 0) {
            p[i] = i;
            for (int j = i + i; j < MAX; j += i) {
                p[j] = i;
            }
        }
    }

    vector<int> cnt(MAX);

    for (int x : a) {
        while (x > 1) {
            int pp = p[x];
            int pw = 0;
            while (p[x] == pp) {
                pw++;
                x /= pp;
            }
            cnt[pp] = max(cnt[pp], pw);
        }
    }
    
    int s = 1;
    for (int i = 2; i < MAX; i++) {
        s = mul(s, pw(i, cnt[i]));
    }
    
    int res = 0;
    for (int x : a) {
        res += mul(s, inv(x));
        res %= MOD;
    }
    cout << res;

    // https://kenkoooo.com/atcoder/#/table/pashka

    return 0;
}

Measured memory_bytes: 8064
#include <stdio.h>

int main(void)
{
    int ans = 0;
    int n, d[100];
    int i, j;

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

    for (i = 0; i < n - 1; i++)
        for (j = n - 1; j > i; j--)
            if(d[j] > d[j - 1])
            {
                int tmp = d[j - 1];
                d[j - 1] = d[j];
                d[j] = tmp;
            }

    for (i = 1; i < n; i++)
        if(d[i] != d[i - 1])
            ans++;

    printf("%d\n", ans + 1);

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

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

	ll all = pow(3,n);
	ll bad = 0;

	for (int i = 0; i < n; i++) {
		int g; cin >> g;
		if (g % 2 == 0) {
			bad++;
		}
	}
	ll bab = pow(2, bad);
	cout << all - bab << endl;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin >> n >> k;
  vector<int> a(n);
  vector<bool> b(k+1);
  for(int i=0;i<n;i++){
    cin >> a[i];
    b[a[i]]=true;
  }
  for(int i=0;i<=k;i++){
    for(int j=0;j<n;j++){
      if(i-a[j]>=0&&!b[i-a[j]]){
        b[i]=true;
      }
    }
  }
  if(b[k]){
    cout << "First" << endl;
  }
  else{
    cout << "Second" << endl;
  }
}

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

#define MAX 100

void initialize();
void push(int x);
int pop();
int isEmpty();
int isFull();

int top=0;
int s[MAX];

int main()
{
  int x,y,z,i=0;

  char c[MAX];
	
	while(scanf("%s",c)!=EOF){

	  

		if(c[0]=='-')
		{
	      
		y=pop();
		x=pop();
		z=x-y;
		push(z);
		}
		
		else if(c[0]=='+')
		{
	     
		y=pop();
		x=pop();
	        
		z=x+y;
		push(z);
		}
		
		else if(c[0]=='*')
		{
	       
		y=pop();
		x=pop();
		z=x*y;
		push(z);
		}
		
		else 
		{
		x=atoi(c);
			
		push(x);
		}
        
		 

	}

        x=pop();

	printf("%d\n",x);

	return 0;

}


void initialize()
{
	top=0;
}

void push(int x)
{

s[top]=x;
 top++;
}

int pop()
{
top--;
return s[top];
}

int isEmpty()
{
if(top==0)return 1;
else return 0;
}

int isFull()
{
if(top >= MAX-1 )return 1;
else return 0;
}



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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {
    
    int N,W;
    cin >> N >> W;
    int v[N+1],w[N+1];
    for(int i=1;i<=N;++i) cin >> v[i] >> w[i];
    int dp[N+1][W+1];
    rep(i,W+1) dp[0][i] = 0;
    for(int i=1;i<=N;++i) {
        for(int j=0;j<=W;++j) {
            if(w[i] > j) {
                dp[i][j] = dp[i-1][j];
                continue;
            }
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << endl;
}



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

int main() {

int n, k, c = 0, i;
int h[100000];

cin>>n>>k;
for(i = 0; i < n; i++){
    cin >> h[i];
}

for (i = 0; i < n; i++){
    if (h[i] >= k){
        c++;
    }
}

cout << c <<endl;
return 0;
}

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

using namespace std;

int n,s;
long long int a[10][1001][101];

long long int solver(int d,int sum,int p){
	if(a[d][sum][p] >= 0)return a[d][sum][p];

	if(d == n){
		if(sum == s){
			return a[d][sum][p] = 1;
		}else{
			return a[d][sum][p] = 0;
		}
	}

	long long int b = 0;
	for(int i = p;i <= 100;i++){
		b += solver(d+1,sum+i,i+1);
	}
	a[d][sum][p] = b;
	return b;
}
int main(){
	while(cin >>n >>s,n){
		fill_n(**a,10*1001*101,-1);
		cout << solver(0,0,0) << endl;
	}
	return 0;
}

Measured memory_bytes: 10948
#include<iostream>
#include <vector>

using namespace std;

int main()
{
	int n ;
	cin >> n ;
    double ans ;
  
    if(n%2 != 0)
       ans = ((double) (n/2)+1) /n ;
    else
      ans = ((double) n/2) /n ;

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


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

int main(){

    string s;
    cin >> s;

    string t;

    rep(i,s.size()){
        if(s[i]=='B'){
            if(t.size()>0){
                t.pop_back();
            }
        }else{
            t.push_back(s[i]);
        }
    }
    
    cout << t <<  endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

    int n, a[101] = {0}, k = 0, h, m = 0, i, j;

    scanf("%d", &n);

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

    for(i = k; i > 0; i--) {
        for(j = 0; j < n; j++) {
            if(a[j] >= i)
                m++;
        }
        if(m >= i) {
            h = i;
            break;
        }
        m = 0;
    }

    printf("%d\n", h);

    return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#define N 1001
int INFTY = (1<<21);

int n, M[N][N];
int color[N], d[N], f[N], tt;
int Q[N*2], head, tail;

void init(){
  head = tail = 1;
}

void enqueue(int x){
  Q[tail++] = x;
}

int empty(){
  return head == tail;
}

int dequeue(){
  int x = Q[head++];
  return x;
}

void bfs(int s){
  int i, u, v;
  init();
  enqueue(s);
  for ( i = 0; i < n; i++ )d[i] = INFTY;
  d[s] = 0;
  while(!empty()){
    u = dequeue();
    for ( v = 0; v < n; v++ ){
      if ( M[u][v] == 0 ) continue;
      if ( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }
  for ( i = 0; i < n; i++ ){
    printf("%d ",i+1);
      if(d[i]==INFTY){
          printf("%d\n",-1);
      }else{
           printf("%d\n",d[i]);
  }
  }
}

int main(){
  int  u, k, v, i, j;
  scanf("%d", &n);
  for ( i = 0; i <n; i++ ){
    for ( j = 0; j <n; j++ ) M[i][j] = 0;
  }
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }
  bfs(0);
  return 0;
}


Measured memory_bytes: 2112
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        h: [i64; n],
        e: [(usize, usize); m],
    }

    let mut a = vec![0; n];
    for i in 0..n {
        a[i] = h[i] - 1;
    }
    for i in 0..m {
        let (mut u, mut v) = e[i];
        u -= 1;
        v -= 1;
        a[u] = a[u].max(h[v]);
        a[v] = a[v].max(h[u]);
    }
    let mut ans = 0;
    for i in 0..n {
        if a[i] < h[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

int main(){
	int n,i,min,max,p,dis,ans= 1000000;
	cin >> n;
	int x[n];
	for(i = 0; i < n; i++){
		cin >> x[i];
	}
	sort(x, x+n);
	min = x[0];
	max = x[n-1];
	for(p = min; p <= max; p++){
		dis = 0;
		for(i = 0; i < n; i++){
			dis = dis + (x[i] - p)*(x[i] - p);
		}
		if(dis < ans){
			ans = dis;
		}
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 

const int MOD = 1000000007;

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

    vector<int> count(26);
    rep(i, N) {
        ++count[S[i]-'a'];
    }

    LL ans = 1;
    rep(i, 26) {
        ans = (ans * (count[i]+1)) % MOD;
    }

    ans = (ans + MOD -1) % MOD;    

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int d,t,s;
    cin>>d>>t>>s;
    float ans=1.0*d/s;
    int k=ceil(ans);
    if(k<=t) cout<<"Yes";
    else cout<<"No";    
    return 0;
}

Measured memory_bytes: 3596
import sys
input = sys.stdin.readline
sys.setrecursionlimit(300000)

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

root = [[] for _ in range(n+1)]
for i in range(n-1):
    a, b = map(int, input().split())
    root[a].append(b)
    root[b].append(a)
    
cnt = [0 for _ in range(n+1)]
for i in range(q):
    p, x = map(int, input().split())
    cnt[p] += x

def rec(node, parent):
    for i in root[node]:
        if i == parent:
            continue
        cnt[i] += cnt[node]
        rec(i, node)

rec(1, 1)
print(" ".join(map(str, cnt[1:])))

Measured memory_bytes: 232216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CS_AtCoder {
	class Program {
		static void Main(string[] args) {
			new Calc().Solve();
		}
	}
	public class Calc {
		Scan cin = new Scan();
		public void Solve() {
			var NK = cin.ReadLong(' ');
			var list = new List<Tuple<long, long>>();
			for (int i = 0; i < NK[0]; i++) {
				var aibi = cin.ReadLong(' ');
				list.Add(new Tuple<long, long>(aibi[0], aibi[1]));
			}
			list = list.OrderBy(_ => _.Item1).ToList();
			long sum = 0;
			foreach (var item in list) {
				sum += item.Item2;
				if (sum >= NK[1]) {
					item.Item1.WL();
					return;
				}
			}
			return;
		}
	}

	public class Scan {
		public Scan() { }
		public int ReadInt() => int.Parse(Console.ReadLine());
		public int[] ReadInt(char separator) => Console.ReadLine().Split(separator).Select(int.Parse).ToArray();
		public double ReadDouble() => double.Parse(Console.ReadLine());
		public double[] ReadDouble(char separator) => Console.ReadLine().Split(separator).Select(double.Parse).ToArray();
		public long ReadLong() => long.Parse(Console.ReadLine());
		public long[] ReadLong(char separator) => Console.ReadLine().Split(separator).Select(long.Parse).ToArray();
		public string ReadLine() => Console.ReadLine();
		public string[] ReadLine(char separator) => Console.ReadLine().Split(separator).ToArray();
	}
	public static class Utils {
		public static string Docking<T>(this IEnumerable<T> collection,Func<T,string> filter = null) {
			StringBuilder sb = new StringBuilder();
			foreach (var item in collection) {
				sb.Append(filter != null ? filter(item) : item.ToString());
			}
			return sb.ToString();
		}
		public static void WL(this object obj) => Console.WriteLine(obj);
		public static int IntParse(this string s) => int.Parse(s);
		public static int IntParse(this char c) => c - '0';
	}
}


Measured memory_bytes: 26288
#define ll long long
#define lld long double
#define cn(n)  ll n;cin >> n;
#define tes(t) ll t;cin>>t;while(t--) 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define al(v) v.begin(), v.end()
#define oset(X) tree<X, null_type, less<X>, rb_tree_tag, tree_order_statistics_node_update>
#define roset(X) tree<X, null_type, greater<X>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const long double PI = 3.141592653589793;
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <functional>
// using namespace __gnu_pbds;
using namespace std;
ll power(ll x, ll y, ll p){ll res = 1;x %= p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}
ll po(ll base, ll powerRaised){if (powerRaised != 0)return (base * po(base, powerRaised - 1));else return 1;}
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a, b);}
int main()
{
//   ios_base::sync_with_stdio(false);
//   cin.tie(NULL);
//   cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif //*
  // tes(t)
  // {
  // }
  lld a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(v==0 || v==w || w>v)
  cout<<"NO";
  else
  {
    lld rel=v-w;
    lld dist=abs(a-b);
    lld tt=dist/rel;
    if(tt<=t)
    cout<<"YES";
    else cout<<"NO";
  }
  
}


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

class rect {
public:
  int h, w;
  // 対角線の2乗
  int diagonal() {
    return h * h + w * w;
  }
};

// x > y なら1を返す
int rect_cmp(rect x, rect y) {
  if(x.diagonal() > y.diagonal()) return 1;
  else if(x.diagonal() == y.diagonal() && x.h > y.h) return 1;
  else return 0;
}

int main() {
  rect r;
  while(cin >> r.h >> r.w && r.h && r.w) {
    rect ans, cmp;
    ans.w = 150; ans.h = 150;
    for(cmp.h = 1; cmp.h < 150; ++cmp.h) {
      for(cmp.w = cmp.h + 1; cmp.w < 150; ++cmp.w) {
        if(rect_cmp(cmp, r) && rect_cmp(ans, cmp)) ans = cmp;
      }
    }
    cout << ans.h << ' ' << ans.w << endl;
  }
  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    ll num = 0;
    map<ll, ll> mp;
    rep(i, n)mp[a[i]]++;
    for(auto x : mp){
        num += (x.second-1)*x.second/2;
    }
    rep(i, n){
        cout << num - (mp[a[i]]-1)*mp[a[i]]/2 + (mp[a[i]]-2)*(mp[a[i]]-1)/2 << endl;
    }
}      

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

int b[100000];

int main(){
  int n;
  while(cin >>n , n){
    for (int i = 0; i < 100000; ++i){
      b[i] = 0;
    }
    for (int i = 0; i < n; ++i){
      cin >> b[i];
    }
    int i = 0;
    for (; i <= 10000; ++i){

      bool f = true;
      for (int k = 0; k < 100000 && b[k]; ++k){
	if (b[k] != k+1){
	  f =  false;
	  break;
	}
      }
      if ( f){
	break;
      }

      int t = 0;
      int j = 0;
      for (; j < 100000 && b[j]; ++j){
	--b[j];
	++t;
      }
      
      b[j] = t;
      for (int k = 0; k <= j; ++k){
	if (!b[k]){
	  for ( int l = k+1; l <= j; ++l){
	    if ( b[l] ){
	      b[k]=b[l];
	      b[l] = 0;
	      break;
	    }
	  }
	}
      }
      
    }
    if (i<=10000){
      cout << i << endl;
    } else {
      cout << -1 << endl;
    }
  }
}
	

Measured memory_bytes: 1548
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<string.h>
#include<typeinfo>
#define M 1046527
#define NIL (-1)
#define L 14
//#include <boost/multiprecision/cpp_int.hpp>

//namespace mp = boost::multiprecision;

using namespace std;


char H[M][L];

int getchar(char ch) {
	if (ch == 'A')return 1;
	else if (ch == 'C')return 2;
	else if (ch == 'G')return 3;
	else if (ch == 'T') return 4;
	else return 0;
}
long long getkey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++) {
		sum += p * (getchar(str[i]));
		p *= 5;
	}
	return sum;
}
int h1(int key) {
	return key % M;
}
int h2(int key) {
	return 1 + (key % (M - 1));
}

int find(char str[]) {
	long long key, i, h;
	key = getkey(str);
	for (i = 0; ; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0)return 1;
		else if (strlen(H[h]) == 0)return 0;
	}
	return 0;
}

int insert(char str[]) {
	long long key, i, h;
	key = getkey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main() {
	int i, n, h;
	char str[L],com[9];
	for (i = 0; i < M; i++) {
		H[i][0] = '\0';
	}
	scanf("%d", &n);
	for (i =0 ; i < n; i++) {
		scanf("%s %s", com, str);
		if (com[0] == 'i') {
			insert(str);
		}
		else {
			if (find(str)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}
	return 0;
}



Measured memory_bytes: 17456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,d;
    cin>>n>>d;
    ll x,y,count=0;
    while(n--){
        cin>>x>>y;
        if(x*x+y*y<=d*d){
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3572
n, m = map(int, input().split())
x = map(int, input().split())
y = map(int, input().split())
x = list(x)
y = list(y)
x.sort()
y.sort()
M = 10 ** 9 + 7
a = sum([(2 * k - n + 1) * x[k] for k in range(n)])
b = sum([(2 * k - m + 1) * y[k] for k in range(m)])
a %= M
b %= M
res = a * b % M
print(res)


Measured memory_bytes: 21824
h,w=map(int,input().split())
s=['#'*(w+2)]
s+=['#'+input()+'#' for _ in range(h)]
s.append('#'*(w+2))
h+=2
w+=2
p=[[1,0],[0,1],[-1,0],[0,-1]]
st=[]
cnt=0
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            cnt+=1
ans=0
n=[(1,1)]
route={n[0]:0}
count=0
while n:
    count+=1
    n2=[]
    for i in n:
        for j in p:
            np=(i[0]+j[0],i[1]+j[1])
            if s[np[0]][np[1]]=='.' and route.get(np,-1)==-1:
                n2.append(np)
                route[np]=count
    n=n2
if route.get((h-2,w-2),-1)>=0:
    print(cnt-route.get((h-2,w-2),-1)-1)
else:
    print(-1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    string s; cin >> s;
    int n = s.back() - '0';

    if (n == 3) {
        cout << "bon" << endl;
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
N = int(input())
A = [int(input()) for _ in range(N)]

mls = [-1 for _ in range(N+1)]
for i, a in enumerate(A, 1):
    mls[i] = max(mls[i-1], a)

mrs = [-1 for _ in range(N+1)]
for i, a in enumerate(A[::-1], 1):
    mrs[i] = max(mrs[i-1], a)
mrs = mrs[::-1]

for i in range(N):
    print(max(mls[i], mrs[i+1]))


Measured memory_bytes: 21520
D,N=map(int,input().split())
if N==100:
   a=100**D*N+100**D
   if D==0:
       print(101)
   if D==1 or D==2:
       print(a)     
else:
    a=100**D*N
    if D==0:
        print(N)
    if D==1 or D==2:
        print(a)

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

#define MOD 100000;

int main(){
	int x[101][101][2][2];
	int h,w,sum;
	while(true){
		memset(x,0,sizeof(x));
		for(int i=1;i<=100;i++){
			x[i][1][0][0]=1;
		}
		for(int i=1;i<=100;i++){
			x[1][i][1][0]=1;
		}
		cin>>h>>w;
		if(h==0 && w==0){
			break;
		}
		for(int i=2;i<=h;i++){
			for(int j=2;j<=w;j++){
				x[i][j][0][0]=(x[i-1][j][0][0]+x[i-1][j][0][1])%MOD;
				x[i][j][0][1]=x[i-1][j][1][0]%MOD;
				x[i][j][1][0]=(x[i][j-1][1][0]+x[i][j-1][1][1])%MOD;
				x[i][j][1][1]=x[i][j-1][0][0]%MOD;
			}
		}
		sum=(x[h][w][0][0]+x[h][w][0][1]+x[h][w][1][0]+x[h][w][1][1])%MOD;
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1328
#include<iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b != c 
	 || b == c && c != a
	 || c == a && a != b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


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

int main(void){
    int H,W;
    int h,w;
    cin>>H>>W>>h>>w;

    int ans;
    ans=H*W-h*W-w*(H-h);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int N, C;
    cin >> N >> C;

    int D[C][C];
    REP(i, C) {
        REP(j, C) {
            cin >> D[i][j];
        }
    }

    int cnt[3][C];
    REP(i, 3) REP(j, C) cnt[i][j] = 0;

    REP(i, N) {
        REP(j, N) {
            int c;
            cin >> c;
            ++cnt[(i+j)%3][c-1];
        }
    }

    int s[3][C];
    REP(c, 3) {
        REP(i, C) {
            s[c][i] = 0;
            REP(j, C) {
                s[c][i] += cnt[c][j] * D[j][i];
            }
        }
    }

    int ans = inf;
    REP(c0, C) {
        REP(c1, C) {
            if (c0 == c1) continue;
            REP(c2, C) {
                if(c1 == c2 || c0 == c2) continue;
                ans = min(ans, s[0][c0] + s[1][c1] + s[2][c2]);
            }
        }
    }
    
    cout << fixed << setprecision(20);
    cout << ans << endl;

}


Measured memory_bytes: 256
implicit none
integer(8) :: i,j,k,n
 
read(5,*) n

do i = 1,int(3*n/4)
  do j = int(3*n/4), 3500
       if (4*i*j-N*i-N*j/=0) then
          if (mod(N*i*j,4*i*j-N*i-N*j)==0 .and. (N*i*j)/(4*i*j-N*i-N*j)>0) then
            goto 100
             endif
          endif
enddo
enddo
 
100 write(6,"(i0,1x,i0,1x,i0)") i,j,(N*i*j)/(4*i*j-N*i-N*j)

end


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, a[2][110], sum1[110], sum2[110], cnt[110];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    rep(i, 0, 2) {
        rep(j, 0, n) {
            cin >> a[i][j];
        }
    }
    sum1[0] = a[0][0], sum2[n-1] = a[1][n-1];
    rep(i, 1, n) sum1[i] += sum1[i-1] + a[0][i];
    eper(i, n-2, 0) sum2[i] += sum2[i+1] + a[1][i];
    rep(i, 0, n) {
        cnt[i] = sum1[i] + sum2[i];
    }
    cout << *max_element(cnt, cnt+n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>
#include <set>

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n; cin >> n;
  char s[n];
  set<char> st;
  for(int i=0;i<n;i++){
    cin >> s[i];
    st.insert(s[i]);
  }
  if(st.size() == 3) cout << "Three" << endl;
  else cout << "Four" << endl;
}

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

def main():
    sx, sy, tx, ty = map(int, input().split())
    h = ty - sy
    w = tx - sx
    res  = "U" * h
    res += "R" * w
    res += "D" * h
    res += "L" * w
    res += "L"
    res += "U" * (h + 1)
    res += "R" * (w + 1)
    res += "D"
    res += "R"
    res += "D" * (h + 1)
    res += "L" * (w + 1)
    res += "U"
    print(res)

main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, m;
    std::string s;
    std::cin >> n >> m >> s;

    // (len, index)
    std::set<std::pair<int, int>> ss { { 0, n } };
    std::vector<int> len(n + 1, -1), to(n + 1, -1);
    len[n] = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '0') {
            if (ss.empty()) {
                std::cout << -1 << std::endl;
                return 0;
            }

            to[i] = ss.begin()->second;
            len[i] = len[to[i]] + 1;

            ss.emplace(len[i], i);
        }
        if (i + m <= n && s[i + m] == '0') {
            auto it = ss.lower_bound(std::make_pair(len[i + m], i + m));
            ss.erase(it);
        }
    }

    int v = 0;
    while (v < n) {
        std::cout << to[v] - v << " ";
        v = to[v];
    }
    std::cout << std::endl;

    return 0;
}


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

using namespace std;

class Point {
    public:
        double x, y;
        Point(double x = 0.0, double y = 0.0): x(x), y(y) {}

        Point operator + (Point p) { return Point(x + p.x, y + p.y); }
        Point operator - (Point p) { return Point(x - p.x, y - p.y); }
        Point operator * (double k) { return Point(x * k, y * k); }
        Point operator / (double k) { return Point(x / k, y / k); }

        double friend norm(Point p) { return p.x * p.x + p.y * p.y; }
        double friend abs(Point p) { return sqrt(norm(p)); }
};
typedef Point Vector;

double dot(Vector v1, Vector v2) {
    return v1.x * v2.x + v1.y * v2.y;
}

double cross(Vector v1, Vector v2) {
    return v1.x * v2.y - v1.y * v2.x;
}

int main(void) {
    int q, c, d;
    Point p0, p1, p2;
    cin >> p0.x >> p0.y;
    cin >> p1.x >> p1.y;
    cin >> q;

    for (int i = 0; i < q; i++) {
        cin >> p2.x >> p2.y;
        c = cross(p1 - p0, p2 - p0);
        d = dot(p1 - p0, p2 - p0);
        if (c > 0) cout << "COUNTER_CLOCKWISE\n";
        else if (c < 0) cout << "CLOCKWISE\n";
        else if (d < 0) cout << "ONLINE_BACK\n";
        else if (abs(p2 - p0) > abs(p1 - p0)) cout << "ONLINE_FRONT\n";
        else cout << "ON_SEGMENT\n";
    }

    return 0;
}


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

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;

    bool ok = true;
    for (size_t i = 0; i < s.size(); i++) {
        if (((i+1)%2 != 0 && s[i] == 'L') || ((i+1)%2 == 0 && s[i] == 'R')) ok = false;
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    
    ll n,k;
    cin>>n>>k;
    if(n%k==0) cout<<0<<endl;
    else cout<<1<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;
#define N 200010
namespace bit{
  ll dat[N];
  void init(){
      for(int i=0;i<N;i++){
          dat[i]=0;
      }
  }
  void add(ll i,ll x){
      for(;i<N;i+=i&-i){
          dat[i]+=x;
      }
  }
  ll sum(ll i){
      ll res=0;
      for(;i;i-=i&-i){
          res+=dat[i];
      }
      return res;
  }
};
ll n,m;
struct qry{
    ll l,r,id;
    bool operator<(const qry&key)const{
        if(this->r==key.r)return this->id<key.id;
        return this->r<key.r;
    }
};
ll ans[N];
int main(){
  cin>>n>>m;
  vector<qry> v;
  for(int i=0;i<n;i++){
      qry p;
      cin>>p.l>>p.r;
      p.id=0;
      v.push_back(p);
  }
  for(int d=1;d<=m;d++){
      ans[d]=n;
      for(int i=0;i<=m;i+=d){
          qry p;
          p.l=i,p.r=i+d-1;
          p.id=d;
          v.push_back(p);
      }
  }
  sort(v.begin(),v.end());
  bit::init();
  for(auto p:v){
      if(p.id==0){
          bit::add(p.l,+1);
      }
      else{
          ans[p.id]-=(bit::sum(p.r)-bit::sum(p.l));
      }
  }
  for(int d=1;d<=m;d++)cout<<ans[d]<<endl;
  return 0;
}



Measured memory_bytes: 51684
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int dp[13][100021] = {};
int main() {
	int n, x;
	cin >> n >> x;
	int minokasi = 1000000;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		sum = sum + a;
		minokasi = min(minokasi, a);
	}
	cout << n + (x - sum) / minokasi;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;


int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  ll t = 0;
  int ans = 0;
  rep(i, m) t += b[i];

  int j = m;
  rep(i, n + 1) {
    while (j >= 0 && t > k) {
      --j;
      t -= b[j];
    }

    if (t > k) continue;
    ans = max(ans, j + i);
    if (i == n) break;
    t += a[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 4808
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
    int a,b,sum,cnt;
    while(scanf("%d%d",&a,&b)!=EOF){
        sum=a+b;
        cnt=0;
        while(sum>0){
            cnt++;
            sum/=10;
        }
        cout << cnt << endl;
    }
    return 0;
}


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

int main(){
    int N; cin >> N;
    int Takoyaki[N]={};
    for(int i=0;i<N;i++){
        cin >> Takoyaki[i];
    }

    int RecoverHP=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            RecoverHP += Takoyaki[i]*Takoyaki[j];
        }
    }
    cout << RecoverHP << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=int_fast64_t;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,a,s=0;
    in>>n;
    bitset<4000001> bs;
    bs[0]=true;
    fr(i,n){
        in>>a;
        s+=a;
        bs|=bs<<a;
    }
    ++s;
    s>>=1;
    while(!bs[s]) ++s;
    cout<<s<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>

int main() {
		int antena[10000];
		for ( int i = 0; i < 5; i++ ) {
				scanf("%d", &antena[i]);
		}
		int k;
		scanf("%d", &k);
		for ( int i = 0; i < 4; i++ ) {
				for ( int j = i+1; j < 5; j++ ) {
						if ( antena[j] - antena[i] > k ) {
								printf(":(\n");
								return 0;
						}
				}
		}
		printf("Yay!\n");
		return 0;
}


Measured memory_bytes: 128
N = int(input())
S = []
for _ in range(N):
    S.append(input())
ac = S.count("AC")
wa = S.count("WA")
tle = S.count("TLE")
re = S.count("RE")

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

Measured memory_bytes: 16264
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
static const int MAX = 200000;

int main()
{
    int R[MAX], n;
    scanf("%d", &n);
    for(int i = 0; i<n; i++)
        scanf("%d", &R[i]);
    int maxv = -2000000000;
    int minv = R[0];

    for(int i = 1; i<n; i++)
    {
        maxv = max(maxv, R[i] -minv);
        minv = min(minv, R[i]);
    }
    cout << maxv << endl;

    return 0;
}



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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

int main(void)
{
  ll n; cin >> n;
  // ll x, y, z; cin >> x >> y >> z;
  // string s; cin >> s;
  vector<ll> a(n); REP(i, n) cin >> a[i];
  ll ans = 0;
  vector<ll> c(100100); REP(i, 100100) c[i] = 0;
  REP(i, n) {
    for(ll j = 0; j <= 2; j++) {
      c[a[i]+j]++;
    }
  }
  REP(i, 100010) {
    if(c[i] > ans) ans = c[i];
  }

    
  
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
//ll a[200007], b[200007];
//ll m[30][(2 * 100000)+7], M[200];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll i, j, k, l, test, r;
	ll n, m;
	cin >> n >> m;
	if (m >= n) cout << "unsafe";
	else cout << "safe";
}



Measured memory_bytes: 3612
N = int(input())
S = input()
max_found = 0
for i in range(1,N):
    found = 0
    s1 = S[:i]
    s2 = S[i:]
    for s in set(s1):
        if s in s2:
            found += 1
    if max_found < found:
        max_found = found
print(max_found)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define int long long
#define all(c) (c).begin(), (c).end()
#define cpresent(c,x) ((c).find(x) != (c).end()) // present in container?
#define vpresent(c,x) (find(all(c),x) != (c).end()) // present in vector?
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr), cout.tie(nullptr)
#define endl '\n'
using namespace std;

int a, b;

void solve(){   
    cin >> a >> b;
    int socket = 1;
    int cnt = 0;
    while(socket < b){
        socket += a - 1;
        cnt++;
    }
    cout << cnt << endl;
}

signed main(){
	fastio;
	// int t; cin >> t;
	// while(t--)
		solve();
	return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n, m;
  cin >> n >> m;
  vector<int> costs(m);
  vector<int> sets(m);
  for (int i = 0; i < m; i++) {
    cin >> costs[i];
    int num_edges;
    cin >> num_edges;
    for (int j = 0; j < num_edges; j++) {
      int e;
      cin >> e;
      e--;
      sets[i] |= 1 << e;
    }
  }

  vector<int> dp(1 << n, INT32_MAX);
  dp[0] = 0;
  for (int i = 0; i < 1 << n; i++) {
    if (dp[i] == INT32_MAX) continue;
    for (int j = 0; j < m; j++) {
      UpdateMin(dp[i | sets[j]], dp[i] + costs[j]);
    }
  }
  
  if (dp[(1 << n) - 1] == INT32_MAX) {
    cout << -1 << endl;
  } else {
    cout << dp[(1 << n) - 1] << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*
* 素因数分解
* @param [in] n   自然数
* @param [in] out 素因数分解した数が入る
*/
template<typename T>
void PrimeFactors(T n, std::map<T,T> &out)
{
	while (n % 2 == 0)
	{
		++out[2];
		n = n / 2;
	}

	for (T i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n%i == 0)
		{
			++out[i];
			n = n / i;
		}
	}

	if (n > 2)
		++out[n];
}
vector<int> to[20009];
vector<int> ans;
void dfs(int i,int j=-1){
    for(int v:to[i]){
        if(v==j)continue;
        ans[v]+=ans[i];
        dfs(v,i);
    }
}
int main(void){ 
    ll n,m;cin>>n>>m;
    ll a[n],b[n];
    rep(i,n){
        cin>>a[i];a[i]/=2;
        b[i]=a[i];
    }
    int k=0;
    while(b[0]%2==0){
        k++;
        b[0]/=2;
        //cout<<0<<" "<<k<<b[0]<<endl;
    }
    bool t=false;
    for(int i=1;i<n;i++){
        int w=0;
        while(b[i]%2==0){
        w++;
        b[i]/=2;
    }
    //cout<<i<<" "<<w<<endl;
    if(w!=k)t=true;
    }
    if(t){
        cout<<0<<endl;
        return 0;
    }
    ll lc=1;
    for(int i=0;i<n;i++){
        lc=lcm(lc,a[i]);
    }
    cout<<(m/lc+1)/2<<endl;
    
}



Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX_N 1000
ll N,V,ans=0;
ll a[MAX_N];
ll b[MAX_N];
ll c[MAX_N];
ll d[MAX_N];
unordered_map<ll,ll> t;

int main(){
  scanf("%lld %lld",&N,&V);
  for(int i=0;i<N;i++)scanf("%lld",&a[i]);
  for(int i=0;i<N;i++)scanf("%lld",&b[i]);
  for(int i=0;i<N;i++)scanf("%lld",&c[i]);
  for(int i=0;i<N;i++)scanf("%lld",&d[i]);
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      t[ a[i]+b[j] ]++;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      ans+=t[V-c[i]-d[j]];
  printf("%lld\n",ans);
  return 0;
}

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

int main(int argc, char const *argv[])
{
    ll h, w; cin >> h >> w;
    ll a = h*w;
  	if (h == 1 or w == 1){
          cout << 1 << endl;
          return 0;
      }
    else if (a%2 == 1)
    {
        a = (a+1)/2;
    }
    else {
        a /= 2;
    }
    cout << a << endl;

    return 0;
}


Measured memory_bytes: 256