akhauriyash/Code-Regression huggingface dataset:
import std.stdio,std.string,std.conv;

int prime[1000000];

int main()
{
	prime[0] = prime[1] = 0;
	
	foreach(i;2..1000000)
	{
		prime[i] = 1;
	}
	foreach(i;2..1000000)
	{
		if(prime[i])
		{
			for(int j = i*2; j < 1000000 ;j += i)
			{
				prime[j] = 0;
			}
		}
	}

	int n;
	while(( n = readln.chomp.to!int) != 0)
	{
		int count = 0,ans = 0;
		foreach(i;0..1000000)
		{
			if(count == n) break;

			if(prime[i] == 1)
			{
				ans += i;
				count++;
			}
		}
		ans.writeln;
	}


	return 0;
}

Measured memory_bytes: 4952
D = int(input())
C = list(map(int, input().split()))
S = []
for _ in range(D):
    s_row = list(map(int, input().split()))
    S.append(s_row)

# Cを無視して最大値をとる
results = []
for d in range(D):
    s_row = S[d]
    max_value = max(s_row)
    max_index = s_row.index(max_value)
    results.append(max_index+1)

for result in results:
    print(result)


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

int main(){
    double pai=3.141592653589;
    int dice[6],tmp;
    char c[100];
    for(int i=0;i<6;i++){
        scanf("%d",&dice[i]);
    }
    scanf("%s",&c);
    for(int i=0;c[i];i++){
        if(c[i]=='S'){
            tmp=dice[4];
            dice[4]=dice[5];
            dice[5]=dice[1];
            dice[1]=dice[0];
            dice[0]=tmp;
        }else if(c[i]=='N'){
            tmp=dice[1];
            dice[1]=dice[5];
            dice[5]=dice[4];
            dice[4]=dice[0];
            dice[0]=tmp;
        }else if(c[i]=='W'){
            tmp=dice[2];
            dice[2]=dice[5];
            dice[5]=dice[3];
            dice[3]=dice[0];
            dice[0]=tmp;
        }else if(c[i]=='E'){
            tmp=dice[3];
            dice[3]=dice[5];
            dice[5]=dice[2];
            dice[2]=dice[0];
            dice[0]=tmp;
        }
    }
    printf("%d\n",dice[0]);
    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;
map<string,ll> m;
vector<string> v[200005];
int main()
{
    ll n;
    cin>>n;

    set<string> st;
    string s;
    rep(i,n)
    {
        cin>>s;
        st.insert(s);
        m[s]++;
    }
    ll t=st.size(),maxx=0;
    rep(i,t)
    {
        string ss=*st.begin();
        v[m[ss]].push_back(ss);
        maxx=max(maxx,m[ss]);
        st.erase(st.begin());
    }
    sort(v[maxx].begin(),v[maxx].end());
    rep(i,v[maxx].size()) cout<<v[maxx][i]<<"\n";
}


Measured memory_bytes: 40948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S;
    cin >> S;
    if (S[0] == S[1] && S[1] == S[2])
        cout << "Yes" << endl;
    else if (S[1] == S[2] && S[2] == S[3])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int[]b = new int[m];
		int[][]a = new int[n][m];
		
		for(int i=0; i<m; i++) {
			b[i] = sc.nextInt();
		}
		for(int i=0; i<n; i++) {
			for(int j=0; j<m; j++) {
				a[i][j] = sc.nextInt();		
			}
		}
		int cou = 0;
		for(int i=0; i<n; i++) {
			int al = 0;
			for(int j=0; j<m; j++) {
				al += a[i][j]*b[j];
			}
				if(al + c > 0) {
					cou++;
				}				
		}
		System.out.println(cou);
	}
}

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

#define m(a,b) memset(a,b,sizeof(a))
#define c(a) cout<<a<<endl;
#define rep(i,n) for(int i=1;i<=n;i++)
#define IO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long ll;
const int INF=1<<30;

int main(){
	IO;
	int a,b,c,ans=0;
	cin>>a>>b>>c;
	while(1){
		if (a&1||b&1||c&1){
			cout<<ans<<endl;
			break;
		}
		if (a==b&&b==c){
			cout<<"-1"<<endl;
			break;
		}
		ans++;
		int na=(b+c)>>1;
		int nb=(a+c)>>1;
		int nc=(a+b)>>1;
		a=na,b=nb,c=nc;
	}	
	return 0;
}

Measured memory_bytes: 256
# input
a, b, k = map(int, input().split())

# process
ra = a
rb = b
if a < k:
    ra = 0
    k -= a
else:
    ra = a - k
    k = 0

if b < k:
    rb = 0
else:
    rb = b - k 

# output
print(ra, rb)


Measured memory_bytes: 2940
s=input()
s1="KIH"
s2="B"
s3="R"
bl=False
for i in range(16):
    if i % 2 == 0:
        d1 = "A"
    else:
        d1=""
    if (i % 4)//2 == 1:
        d2 = "A"
    else:
        d2=""
    if (i % 8)//4 == 1:
        d3 = "A"
    else:
        d3=""
    if i//8 == 1:
        d4 = "A"
    else:
        d4=""
    if s == (d1+s1+d2+s2+d3+s3+d4):
        bl=True
if bl:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
using  namespace std;
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	if(m%n==0)
	{
		printf("%d\n",m/n);
	}
	else
	{
		int t=m/n+1;
		for(int i=t;i>=1;i--)
		{
			if(m%i==0)
			{
				printf("%d\n",i);
				break;
			}
		}
	}
	return 0;
}

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

int main() {
  int R, G, B, N;
  std::cin >> R >> G >> B >> N;

  int ans = 0;

  for (int r=0; r*R<=N; r++) {
    for (int g=0; r*R+g*G<=N; g++) {
      if ((N - (r*R+g*G)) % B == 0) {
        ans++;
      }
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b;
  c=b*2;
  d=a-c;
  if(d>=a||d<0){
    cout<<0<<endl;
  }
   else if(d<a){
     cout<<d<<endl;
 }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

bool is_ok(const vector<P> &ps) {
    int now = 0;
    for (P p: ps) {
        if (now + p.first < 0)
            return false;

        now += p.second;
    }
    return true;
}

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

    // (最小、全体の和)
    vector<P> posi, nega;
    int total = 0;
    rep(i, n) {
        string s;
        cin >> s;

        int min_ = 10000000, sum = 0;
        for (char c: s) {
            if (c == '(') sum++;
            else sum--;
            chmin(min_, sum);
        }

        if (0 < sum) posi.emplace_back(min_, sum);
        else nega.emplace_back(-sum + min_, -sum);

        total += sum;
    }

    sort(posi.rbegin(), posi.rend());
    sort(nega.rbegin(), nega.rend());

    if (total == 0 && is_ok(posi) && is_ok(nega)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 11224
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if(a+b>=m)return (a+b)-m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

int main()
{
    fastio;
    ll k;cin>>k;
    vector<ll> v;
    rep(i,1,10)v.pb(i);
    ll cnt=9;
    if(k<=cnt){
        cout<<k;
        return 0;
    }
    while(true)
    {
        int sz=v.size();
        vector<ll> vv;
        rep(i,0,sz)
        {
            ll cur=v[i]%10;
            if((cur-1)>=0 && (cur-1)<=9)
                vv.pb(cur-1+(v[i]*10)),cnt++;
            if(cnt==k){cout<<cur-1+(v[i]*10);return 0;}
            vv.pb(cur+(v[i]*10)),cnt++;
            if(cnt==k){cout<<cur+(v[i]*10);return 0;}
            if((cur+1)>=0 && (cur+1)<=9)
                vv.pb(cur+1+(v[i]*10)),cnt++;
            if(cnt==k){cout<<cur+1+(v[i]*10);return 0;}
        }
        v=vv;
    }
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

int main()
{
	pair<double ,int> runners[24];
	for (int i = 0; i < 24; ++i)
	{
		int a;
		double b;
		scanf("%d %lf", &a ,&b);
		runners[i] = make_pair(b, a);
	}
	for (int i = 0; i < 3; ++i)
	{
		sort(runners+i*8, runners+8+i*8);
		printf("%d %.2f\n", runners[0 + i*8].second, runners[0 + i*8].first);
		printf("%d %.2f\n", runners[1 + i*8].second, runners[1 + i*8].first);
		runners[0 + i*8].first = runners[1 + i*8].first = 1e10;
	}
	sort(runners, runners+24);
	printf("%d %.2f\n", runners[0].second, runners[0].first);
	printf("%d %.2f\n", runners[1].second, runners[1].first);

	return 0;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    long long x[n],y[n];
    pair<long long,long long> v[n];
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        v[i]=make_pair(x[i],y[i]);
    }
    sort(x,x+n);
    sort(y,y+n);

    vector<long long> ans;

    for(long long l=0;l<n;l++){
        for(long long r=l+1;r<n;r++){
            for(long long d=0;d<n;d++){
                for(long long u=d+1;u<n;u++){
                    int cnt=0;
                    for(auto i:v){
                        if(i.first>=x[l] && i.first<=x[r] && i.second>=y[d] && i.second<=y[u]){
                            cnt++;
                        }
                    }
                    long long s=(x[r]-x[l]) * (y[u]-y[d]);
                    if(cnt>=k) ans.push_back(s);
                }
            }
        }
    }

    sort(ans.begin(),ans.end());

    cout<<ans[0]<<endl;    


}

Measured memory_bytes: 18024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

int N, M;
int[][int] RS;
int[200000] IS;

void main()
{
    auto nm = readln.split.to!(int[]);
    N = nm[0];
    M = nm[1];

    foreach (_; 0..M) {
        auto ab = readln.split.to!(int[]);
        auto a = ab[0] - 1;
        auto b = ab[1] - 1;
        RS[a] ~= b;
        RS[b] ~= a;
    }

    IS[0] = 1;
    foreach (i; 0..N) {
        if (IS[i] == 1 && i in RS) {
            foreach (j; RS[i]) {
                if (IS[j] == 0) IS[j] = i == 0 ? 1 : 2;
            }
        }
    }

    writeln( IS[N-1] == 2 ? "POSSIBLE" : "IMPOSSIBLE" );
}

Measured memory_bytes: 39932
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var sum:Double = 0.0
    val a = readLine()!!.split(" ").map {
        val i = it.toInt()
        sum += i
        i
    }
    val ave:Long = Math.round(sum/n)

    var ans: Double = 0.0
    a.forEach {
        val i = it.toInt()
        ans += Math.pow(Math.abs(ave - i).toDouble(), 2.0)
    }

    println(ans.toInt())

}


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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '1')
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main (void){
  string s;
  int a = 0,k = 0;

  cin >> k >> s;

  a = s.size();
  if(a <= k){
    cout << s << endl;
  }else{
    for(int i = 0;i < k;i++){
      cout.put(s[i]);
    }
    cout << "...\n";
  }

  return 0;
}

Measured memory_bytes: 3628
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)
from decimal import *


def read():
    A, B = input().strip().split()
    return Decimal(A), Decimal(B)


def solve(A, B):
    x = A * B
    return x.quantize(Decimal("1."), rounding=ROUND_FLOOR)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9868
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20)
#define int long long
#define double long double
const int INF = 1e18, MOD = 2019;

struct UnionFind {
    vector<int> t;
    UnionFind(int size): t(size, -1) {}
    int root(int x) {return t[x] < 0 ? x : t[x] = root(t[x]);}
    int size(int x) {return -t[root(x)];}
    bool is_same(int x, int y) {return root(x) == root(y);}
    bool unite(int x, int y) {
        x = root(x), y = root(y);
        if(x != y) {
            if(t[y] < t[x]) swap(x, y);
            t[x] += t[y], t[y] = x;
        }
        return x != y;
    }
};

signed main() {
    INCANT;
    int n, a, b;
    cin>>n;
    int c[11111];
    queue<pair<int, int>> q;
    for (int i = 0; i < n - 1; i++) {
        cin>>a>>b;
        q.push(make_pair(a, b));
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin>>c[i];
        sum += c[i];
    }
    sort(c, c + n);
    reverse(c, c + n);
    cout<<sum - c[0]<<endl;
    int res[11111] = {}, now = 0, root = -1;
    UnionFind uf(11111);
    while (!q.empty()) {
        pair<int, int> p = q.front();
        q.pop();
        if (root == -1) root = p.first;
        if (uf.is_same(root, p.first) || uf.is_same(root, p.second)) {
            if (!res[p.first])  res[p.first]  = c[now], now++;
            if (!res[p.second]) res[p.second] = c[now], now++;
            uf.unite(root, p.first);
            uf.unite(root, p.second);
        } else {
            q.push(p);
        }
    }
    for (int i = 1; i <= n; i++) {
        cout<<res[i]<<' ';
    }
}

Measured memory_bytes: 768
#include <stdio.h>

int main()
{
  int n, A[100], res = 0;

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

  for (int i = 0; i <= n / 2; i++)
  {
    if (A[2 * i] % 2 == 1)
      res++;
  }

  printf("%d", res);

  return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>

int  main()
{
     int a,b;
      while(1)
      {
      scanf("%d %d",&a,&b);
       if( a==0 && b==0)
       {
           break;
       }
        for(int i=1; i<=a; i++)
        {
            for(int j=1; j<=b; j++)
            {
                if(i==1 || i==a || j==1 || j==b)
                {
                     printf("#");
                }
                else
                {
                    printf(".");
                }

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



Measured memory_bytes: 2056
#include<iostream>
using namespace std;
int n;
int dp[31];
int main(){
  dp[0]=1;
  dp[1]=1;
  dp[2]=2;
  for(int i=3;i<=30;i++){
    dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
  }
  while(cin>>n&&n){
    cout<<dp[n]/3650+(dp[n]%3650!=0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#![allow(unused_imports)]
#![allow(dead_code)]
use datastructure::*;
use grapth::*;
use input_scanner::*;
use math::*;
use string_algorithm::*;
use util::*;

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    let mut scan = Scanner::new();
    let x: char = scan.next();
    println!("{}", if x.is_ascii_uppercase() { "A" } else { "a" });
}

mod datastructure {}
mod grapth {}
mod math {}
mod string_algorithm {}
mod util {}
mod input_scanner {
    pub struct Scanner {
        bytes: Vec<u8>,
        begin: usize,
        end: usize,
    }

    impl Scanner {
        pub fn new() -> Self {
            use std::io::Read;
            let mut buffer: Vec<u8> = Vec::new();
            std::io::stdin().read_to_end(&mut buffer).unwrap();
            let end = (0..buffer.len())
                .find(|i| buffer[*i].is_ascii_whitespace())
                .unwrap_or(buffer.len());
            Scanner {
                bytes: buffer,
                begin: 0,
                end: end,
            }
        }
        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            let s: &str =
                unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
            let ret: T = s.parse::<T>().ok().expect("Parse error.");
            self.skip();
            ret
        }
        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
        pub fn next_word(&mut self) -> Vec<u8> {
            let r = Vec::from(&self.bytes[self.begin..self.end]);
            self.skip();
            r
        }
        fn skip(&mut self) {
            self.begin = (self.end..self.bytes.len())
                .find(|i| !self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
            self.end = (self.begin..self.bytes.len())
                .find(|i| self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
        }
    }
}


Measured memory_bytes: 2108
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException{
        String[] str;
        int n,x;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while((str = br.readLine().split(" ")) != null){
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);

            if(n==0&&x==0){
                break;
            }

            int count=0;
            for(int i=1;i< n;i++){
                for(int j = i + 1; j < n; j++){
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                }
            }
            System.out.println(count);
        }

        br.close();
    }
}

Measured memory_bytes: 24360
h, w = gets.split.map(&:to_i)
pixels = h.times.map { gets.chomp }

valid = true

h.times do |i|
  break unless valid

  w.times do |j|
    next if pixels[i][j] == "."

    l = !(j - 1 >= 0) || pixels[i][j - 1] == "."
    r = !(j + 1 < w) || pixels[i][j + 1] == "."
    u = !(i - 1 >= 0) || pixels[i - 1][j] == "."
    d = !(i + 1 < h) || pixels[i + 1][j] == "."

    if [l, r, u, d].all?(&:itself)
      valid = false
      break
    end
  end
end

puts valid ? "Yes" : "No"


Measured memory_bytes: 14276
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;


lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli a[110];

int main(void) {

	lli N,ans = 0;
	cin >> N;

	FOR(N)
		cin >> a[i];

	for (int i = 1; i < N; i++) {
		if (a[i - 1] == a[i]) {
			ans++;
			a[i] = 0;
		}
	}

	COUT(ans);

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		List<Integer> univW = new ArrayList<>();
		List<Integer> univK = new ArrayList<>();
		
		for(int i = 0; i < 10; i++) {
			univW.add(sc.nextInt());
		}
		
		for(int i = 0; i < 10; i++) {
			univK.add(sc.nextInt());
		}
		
		Collections.sort(univW);
		Collections.sort(univK);
		Collections.reverse(univW);
		Collections.reverse(univK);
		
		int sumW = 0, sumK = 0;
		
		for(int i = 0; i < 3; i++) {
			sumW+=univW.get(i);
			sumK+=univK.get(i);
		}
		
		System.out.println(sumW + " " + sumK);
	}
}

Measured memory_bytes: 25916
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
class A {
public:
	int x;
	int y;
	int z;
};
A a[100001];
int main() {
	// 오늘 할 것!  종만북 보기! 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	int x = 0;
	int y = 0;
	int z = 0;
	rep(i, n) {
		cin >> a[i].z >> a[i].x >> a[i].y;
		int dist = abs(a[i].x - x) + abs(a[i].y - y); 
		int time = a[i].z - z;
		if (dist > time || (time - dist) & 1) {
			cout << "No" << '\n'; return 0;
		}
		x = a[i].x; y = a[i].y; z = a[i].z;
	}
	
	cout << "Yes" << '\n';



}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#define M_PI 3.1415926535897932384626433832795

int main() {
	int a, b;
	cin >> a >> b;
	a -= 2 * b;
	if (a <= 0) {
		cout << 0;
	}
	else {
		cout << a;

	}
	return 0;
}

Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 1e6 + 111;
        
using namespace std;          

int n, p, a[maxn], dp[maxn];
string s;

void solve(){             
	int a, b, c;

	cin >> a >> b >> c;

	cout << c << " " << a << " " << b;
}                              
      
main(){
    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

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

int H, W, K, A[309][309], num;
int cnt[309];
char c[309][309];

void solve(int cl, int cr) {
	vector<int> P;
	for (int i = cl; i <= cr; i++) {
		for (int j = 1; j <= W; j++) {
			if (c[i][j] == '#') P.push_back(j);
		}
	}
	sort(P.begin(), P.end());

	for (int i = 0; i < P.size(); i++) {
		int v1 = 1, v2 = W;
		if (i >= 1) v1 = P[i - 1] + 1;
		if (i < (int)P.size() - 1) v2 = P[i];

		num++;
		for (int j = cl; j <= cr; j++) {
			for (int k = v1; k <= v2; k++) A[j][k] = num;
		}
	}
}

int main() {
	cin >> H >> W >> K;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> c[i][j];
			if (c[i][j] == '#') cnt[i]++;
		}
	}

	vector<int> vec;
	for (int i = 1; i <= H; i++) { if (cnt[i] >= 1) vec.push_back(i); }
	for (int i = 0; i < vec.size(); i++) {
		int v1 = 1, v2 = H;
		if (i >= 1) v1 = vec[i - 1] + 1;
		if (i < (int)vec.size() - 1) v2 = vec[i];

		solve(v1, v2);
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (j >= 2) cout << " "; cout << A[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
    string s,t; cin >> s >> t;
    int ss=s.size(),tt=t.size();
    bool can = false;
    if(1 <= ss && ss <= 10 && tt == ss+1){
        if(t.substr(0,ss) == s) can = true;
    }
    cout << (can ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3628
//2018.09.14 4.5min

#include <iostream>
using namespace std;

int main() {

    string s1,s2,s3;

    cin >> s1;
    cin >> s2;
    cin >> s3;

    char ans[3];

    ans[0] = s1[0];
    ans[1] = s2[1];
    ans[2] = s3[2];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>

using namespace std;

int n, m;
int dp[100043];
int nex[100043], ver[100043];
int tot, head[100043], indeg[100043];
int ans;

void Add_edge(int u, int v) {
  ++tot; nex[tot] = head[u]; ver[tot] = v; head[u] = tot; ++indeg[v];
}

void Topsort() {
  queue<int> q;
  for (int i = 1; i <= n; ++i) {
    if (indeg[i] == 0) {
      q.push(i);
    }
  }

  while (!q.empty()) {
    int u = q.front(); q.pop();
    ans = max(ans, dp[u]);
    for (int i = head[u]; i; i = nex[i]) {
      int v = ver[i];
      if (--indeg[v] == 0) {
        q.push(v);
        dp[v] = max(dp[v], dp[u] + 1);
      }
    }
  }
}

int main(int argc, char const *argv[]) {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    Add_edge(x, y);
  }

  Topsort();

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

  return 0;
}


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

using namespace std;

typedef long long ll;

const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] %= mod;
    }
    vector<int> suf(n);
    suf[n-1] = a[n-1];
    for(int i = n-2; i >= 0; i--)
        suf[i] = (suf[i+1] + a[i])%mod;

    ll ans = 0;
    for(int i = 0; i < n-1; i++) {
        ans = (ans + (a[i]*1LL*suf[i+1])%mod )%mod;
    }
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 4808
s = input()

s1 = list("AKIHABARA")
s2 = list(s)

while s1 and s2:
    if s1[-1] == s2[-1]:
        s1.pop()
        s2.pop()

    elif s1[-1] == "A":
        s1.pop()

    else:
        print("NO")
        exit()

if s1 and s1[-1] == "A":
    s1.pop()

if s1 or s2:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 9060
N = int(input())

A = list(map(int,input().split()))

num = 0

flag = True

while flag:

    flag = False

    for j in range(N-1):

        j = N-1-j

        if A[j] < A[j-1]:

            oaj = A[j]

            A[j] = A[j-1]
            A[j-1] = oaj

            flag = True

            num += 1

print (" ".join(map(str,A)))
print (num)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    string s;
    cin >> s;
    vector<vector<int>> dp(s.size()+1,vector<int>(2,0));
    rep2(i,1,s.size()+1) rep(j,2) {
        int n = s[i-1]-'0';
        if(j == 0) {
            chmax(dp[i][j],dp[i-1][j]+n);
        } else {
            if(n != 0) chmax(dp[i][j],dp[i-1][0]+n-1);
            if(i != 1) chmax(dp[i][j],dp[i-1][1]+9);
        }
    }
    cout << max(dp[s.size()][0],dp[s.size()][1]);
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    ll n,x,m;
    cin>>n>>x>>m;
    set<ll> s;
    ll a = x;
    s.insert(a);
    vector<ll> v;
    v.push_back(a);
    ll i=1;
    ll sum = a;

    while(true){
        if(i==n){
            cout<<sum<<endl;
            return 0;
        }
        a = ((a%m)*(a%m))%m;
        if(s.find(a)!=s.end()){break;}
        else{
            v.push_back(a);
            s.insert(a);
            sum+=a;
        }
        i++;
    }



    n-=v.size();
    ll ans = sum;
    int lpind = 0;
    ll nlp = 0;
    while(v[lpind]!=a){
        nlp+=v[lpind];
        lpind++;
    }
    ll looplen = v.size()-lpind;
    ans+=(n/looplen)*(sum-nlp);
    n%=looplen;
    for(int i=0;i<n;i++){
        ans+=v[i+lpind];
    }
    cout<<ans<<endl;






return 0;
}


Measured memory_bytes: 5948
#include<iostream>
using namespace std;
#define rep(i, a, b) for(int i=(a); i<(b); i++)
int main(){
  int r,D,x[11];
  cin>>r >> D>> x[0];
  
  rep(i,0,10){
    x[i+1]=r*x[i]-D;
    cout<<x[i+1]<<endl;
  }
  
}


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

int main(){
  int N; cin>>N;
  int d[110];
  for (int i=0;i<N;++i)cin>>d[i];
  
  int num[110]={0};
  for (int i=0;i<N;++i){
    ++num[d[i]];
  }
  int ans=0;
  for(int i=1;i<=100;++i){
    if (num[i]) ++ans;
  }
  
  cout<<ans<<endl;
}

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

using namespace std;

const int max_n = 200111, mod = 1000000007;

int mul(int x, int y) {
    return (1LL * x * y) % mod;
}

int power(int a, int b) {
    if (b == 0) {
        return 1 % mod;
    }
    if (b % 2 == 0) {
        return power(mul(a, a), b / 2);
    }
    return mul(a, power(a, b - 1));
}

int inv(int x) {
    return power(x, mod - 2);
}

const int max_f = 200111;

int f[max_f], rf[max_f];

void get_all_f() {
    f[0] = rf[0] = 1;
    for (int i = 1; i < max_f; ++i) {
        f[i] = mul(i, f[i - 1]);
    }
    rf[max_f - 1] = inv(f[max_f - 1]);
    for (int i = max_f - 2; i > 0; --i) {
        rf[i] = mul(i + 1, rf[i + 1]);
    }
}

int get_c(int n, int k) {
    if (n < k) {
        return 0;
    }
    return mul(f[n], mul(rf[k], rf[n - k]));
}

int b, w, p[2][max_n];
int r2 = inv(2), pw[max_n], rpw[max_n];

void solve(int b, int w, int p[]) {
    for (int i = w; i < b + w; ++i) {
        p[i] = mul(get_c(i - 1, w - 1), rpw[i]);
        p[i] += p[i - 1];
        p[i] %= mod;
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    get_all_f();
    pw[0] = 1;
    rpw[0] = 1;
    for (int i = 1; i < max_n; ++i) {
        pw[i] = mul(pw[i - 1], 2);
        rpw[i] = mul(rpw[i - 1], r2);
    }
    scanf("%d%d", &b, &w);
    solve(b, w, p[0]);
    solve(w, b, p[1]);
    for (int i = 1; i <= b + w; ++i) {
        int res = mul(1 + mod - p[0][i - 1] + mod - p[1][i - 1], r2);
        res += p[0][i - 1];
        res %= mod;
        printf("%d\n", res);
    }
    return 0;
}


Measured memory_bytes: 6528
line1 = input()
line2 = input()
line3 = input()
bingo = [0 for i in range(9)]
ans_bingo = [0 for i in range(9)]

bingo[0], bingo[1], bingo[2] = line1.split(" ")
bingo[3], bingo[4], bingo[5] = line2.split(" ")
bingo[6], bingo[7], bingo[8] = line3.split(" ")

n = input()
for i in range(int(n)):
    b = input()
    if b in bingo:
        index = bingo.index(b)
        ans_bingo[index] = "1"

if ans_bingo[0] == "1" and ans_bingo[1] == "1" and ans_bingo[2] == "1":
    print("Yes")
elif ans_bingo[3] == "1" and ans_bingo[4] == "1" and ans_bingo[5] == "1":
    print("Yes")
elif ans_bingo[6] == "1" and ans_bingo[7] == "1" and ans_bingo[8] == "1":
    print("Yes")
elif ans_bingo[0] == "1" and ans_bingo[3] == "1" and ans_bingo[6] == "1":
    print("Yes")
elif ans_bingo[1] == "1" and ans_bingo[4] == "1" and ans_bingo[7] == "1":
    print("Yes")
elif ans_bingo[2] == "1" and ans_bingo[5] == "1" and ans_bingo[8] == "1":
    print("Yes")
elif ans_bingo[0] == "1" and ans_bingo[4] == "1" and ans_bingo[8] == "1":
    print("Yes")
elif ans_bingo[2] == "1" and ans_bingo[4] == "1" and ans_bingo[6] == "1":
    print("Yes")
else:
    print("No")

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

int main() {
  int n,ij,ans=0;
  cin >> n;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      for(int k=1;k<=n;k++){
        ij = gcd(i,j);
        ans += gcd(ij,k);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


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

	ll c = min(a, b);
	ll d = max(a, b);

	ll x = d - (c + w);
	if (x <= 0)
	{


		println(0);
	}
	else
	{
		println(x);
	}
}


Measured memory_bytes: 3424
#include<stdio.h>
int a[100000]={};

int main()
{
  int n,t;
  int i;
  int maxdif=0;
  int min=1000000000;
  int ans=0;

  scanf("%d %d",&n,&t);

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

  for (i=0;i<n;i++) {
    if (min>a[i]) {
      min=a[i];
    }
    if (a[i]-min>maxdif) {
      maxdif=a[i]-min;
    }
  }

  min=1000000000;

  for (i=0;i<n;i++) {
    if (min>a[i]) {
      min=a[i];
    }
    if (a[i]-min==maxdif) {
      ans++;
    }
  }

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

  return 0;
}


Measured memory_bytes: 640
#include <cstdio>

/*
g(L, R) := \prod_{i=L}^{R} (1 + q^{A_i})
f(L, R) = [q^S] g(L, R)
\sum_{1<=L<=R<=N} f(L, R)
p[i] := \sum_{1<=L<=i} g(L, i)
p[i] = (p[i-1] + 1) * (1 + q^{A_i})
*/

constexpr unsigned mod = 998244353;

int n, s;
unsigned dp[3001];

int main(){
  scanf("%d%d", &n, &s);

  long long int ans = 0;
  for(int i = 0; i < n; i++){
    int a;
    scanf("%d", &a);
    dp[0]++;
    for(int j = s; j >= a; j--){
      dp[j] += dp[j - a];
      dp[j] -= mod * (dp[j] >= mod);
    }
    ans += dp[s];
  }
  printf("%d\n", (int) (ans % mod));
  return 0;
}


Measured memory_bytes: 128
unittest
{
	assert( [ "5", "0 5" ].parse.expand.solve == "1\n0 5" );				// 追加ケース
	assert( [ "5", "5 -5" ].parse.expand.solve == "2\n0 -5\n5 -5" );		// 追加ケース
	assert( [ "5", "-5 5" ].parse.expand.solve == "2\n0 5\n-5 5" );			// 追加ケース
	assert( [ "5", "1 4" ].parse.expand.solve == "1\n1 4" );				// 追加ケース
	assert( [ "5", "-8 2" ].parse.expand.solve == "2\n-5 0\n-8 2" );		// 追加ケース
	
//	assert( [ "11", "-1 2" ].parse.expand.solve == "3\n7 4\n2 10\n-1 2" );
	assert( [ "11", "-1 2" ].parse.expand.solve == "3\n11 0\n6 6\n-1 2" );
	assert( [ "4600", "52 149" ].parse.expand.solve == "-1" );
//	assert( [ "4", "9 9" ].parse.expand.solve == "5\n1 3\n4 2\n4 6\n6 8\n9 9" );
	assert( [ "4", "9 9" ].parse.expand.solve == "5\n-1 3\n-1 7\n1 9\n5 9\n9 9" );
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto k = input.front.to!( long );
	input.popFront;
	auto xy = input.front.split.to!( long[] );
	return tuple( k, xy[ 0 ], xy[ 1 ] );
}

auto solve( long k, long x, long y )
{
	// 計算しやすいように符号を+に統一
	auto sx = ( x < 0 ) ? -1L : 1L;
	auto sy = ( y < 0 ) ? -1L : 1L;
	x *= sx;
	y *= sy;
	auto w = ( y < x );
	if( w ) swap( x, y );
	
	// ゴールまでの距離を計算
	auto t = x + y;
	
	// どうやっても距離1までしか縮められないので無理
	if( k % 2 == 0 && t % 2 == 1 ) return "-1";
	
	// 最小打数と合計飛距離を計算
	auto n = ( t + k - 1 ) / k;
	if( n == 1 && t < k ) n++;				// 1打の飛距離よりゴールが近かったら必ず2打以上必要
	if( ( k * n ) % 2 != t % 2 ) n++;		// 飛距離とゴールまでの距離の偶奇を揃えるために追加で1打必要
	auto tt = k * n;
	
	// 各方向への飛距離を計算
	auto l = 0L;
	auto d = 0L;
	auto r = 0L;
	auto u = 0L;
	if( tt == t )
	{
		// 遠回りする必要がない場合は 下→右 コース
		l = 0L;
		d = y;
		r = x;
		u = 0L;
	}
	else
	{
		// 遠回りする必要がある場合は 左→下→右 コース
		l = ( tt - t ) / 2;
		d = y;
		r = tt - l - d;	
		u = 0L;
		
		// 折り返し地点をショートカットしてしまう打ち方になる場合は 左→下→右→上 コースで再計算
		auto e = ( l % k );
		if( e + d < k )
		{
			l -= e;
			d += e;
			r -= e;
			u += e;
		}
	}
	
	// 各打の座標を計算
	auto anss = new long[ 2 ][ n ];
	auto px = 0L;
	auto py = 0L;
	foreach( ref ans; anss )
	{
		auto ft = 0L;
		if( 0 < l )
		{
			// 左
			auto f = min( l, k - ft );
			px -= f;
			l -= f;
			ft += f;
		}
		if( l == 0 && 0 < d )
		{
			// 下
			auto f = min( d, k - ft );
			py += f;
			d -= f;
			ft += f;
		}
		if( l == 0 && d == 0 && 0 < r )
		{
			// 右
			auto f = min( r, k - ft );
			px += f;
			r -= f;
			ft += f;
		}
		if( l == 0 && d == 0 && r == 0 && 0 < u )
		{
			// 上
			auto f = min( u, k - ft );
			py -= f;
			u -= f;
			ft += f;
		}
		
		if( w ) ans = [ py * sx, px * sy ];
		else    ans = [ px * sx, py * sy ];
	}
	return format( "%s\n%s", anss.length, anss.map!( ( a ) => format( "%s %s", a[ 0 ], a[ 1 ] ) ).join( "\n" ) );
}


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


using namespace std;

typedef long long ll;


int main() {
	int x; 
	cin >> x;
	int sum = 0;
	int cnt = 0;
	while (sum < x) {
		cnt++;
		sum += cnt;
		
	}

	cout << cnt << endl;
}


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

int main(){
	ll n; cin>>n;
	int mx=0;
	for(int i=1; i<=sqrt(n); i++){
		if(n%i==0){
			string sa=to_string(i);
			string sb=to_string(n/i);
			int ka=sa.size();
			int kb=sb.size();
			mx=max(ka,kb);
		}
	}
	cout<<mx<<endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long ll;
ll arr[200001];
int main()
{

    ll n;
    cin>>n;
    for(int i=1;i<n;i++)
    {
        ll a;
        cin>>a;
        arr[a]++;
    }
   for(int i=1;i<=n;i++)
    cout<<arr[i]<<endl;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int x;
    cin >> x;

    if(x<1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}


Measured memory_bytes: 3516
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
  string a,b;
  while(cin >> a >> b){
    int ans = 0;
    for(int i = 0; i <= (int)a.size()*2; i++){
      int c = 0,t = 0;
      for(int j = 0; j < (int)b.size(); j++){
	//cout << (int)b.size() - i + j <<  " : " << j << endl;
	if((int)b.size() + j - i < 0 || (int)a.size() <= (int)b.size() + j - i)continue;
	if(a[(int)b.size() + j - i] == b[j]){
	  c++;
	}else{
	  t = max(t,c);
	  c = 0;
	}
      }
      ans = max(max(t,c),ans);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1208
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<string>
#include <cmath>

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    long long int a[3 * n];
    for(int i = 0; i < 3 * n; i++) {
        cin >> a[i];
    }

    long long int ans = 0;
    sort(a,a + 3 * n);
    for(int i = 0; i < n; i++) {
        ans += a[3 * n - 2 - i * 2];
    }

    cout << ans << endl;

}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
		float d,t,s;
		cin>>d>>t>>s;
		float t1 = double(d)/double(s);
		if(t1<=t){
			cout<<"Yes"<<endl;
		}
		else
		cout<<"No"<<endl;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

vector<pair<int, int>> ans;
void push_ans(int x, int y)
{
  ans.push_back(make_pair(x, y));
}

int main()
{
  int N;
  cin >> N;
  priority_queue<int> plus, none_plus;
  rep(i, N)
  {
    int A;
    cin >> A;
    if (A > 0)
      plus.push(A);
    else
      none_plus.push(A);
  }

  int M, P;
  if (plus.size() < 2)
  {
    if (plus.size() == 0)
    {
      M = none_plus.top();
      none_plus.pop();
    }
    else
    {
      M = plus.top();
      plus.pop();
    }
    while (none_plus.size())
    {
      int m = none_plus.top();
      push_ans(M, m);
      M -= m;
      none_plus.pop();
    }
  }
  else
  {
    int P = plus.top();
    plus.pop();
    if (none_plus.size() == 0)
    {
      vector<int> temp;
      while (plus.size())
      {
        temp.push_back(plus.top());
        plus.pop();
      }
      SORT(temp);
      M = temp[0];
      rep(i, temp.size() - 1)
      {
        push_ans(M, temp[i + 1]);
        M -= temp[i + 1];
      }
      push_ans(P, M);
      M = P - M;
    }
    else
    {
      M = none_plus.top();
      none_plus.pop();
      while (plus.size())
      {
        push_ans(M, plus.top());
        M -= plus.top();
        plus.pop();
      }
      none_plus.push(M);
      M = P;
      while (none_plus.size())
      {
        push_ans(M, none_plus.top());
        M -= none_plus.top();
        none_plus.pop();
      }
    }
  }

  cout << M << endl;
  rep(i, ans.size())
  {
    cout << ans[i].first << " " << ans[i].second << endl;
  }

  return 0;
}

Measured memory_bytes: 3444
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_a"
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func iabs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func solve(n int, heights []int) int {
	t := make([]int, n+1, n+1)
	for i := range t {
		t[i] = math.MaxInt64
	}

	t[0] = 0
	for i := 1; i < n; i++ {
		if v := t[i-1] + iabs(heights[i]-heights[i-1]); v < t[i] {
			t[i] = v
		}
		if 1 < i {
			if v := t[i-2] + iabs(heights[i]-heights[i-2]); v < t[i] {
				t[i] = v
			}
		}
	}

	return t[n-1]
}

func main() {
	sc := newScanner(os.Stdin)
	n := sc.Int()
	heights := sc.IntSlice(n)
	ans := solve(n, heights)
	fmt.Println(ans)
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    cout << a*b/2 << endl;
    return 0;
}


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

int main(){
    int N;
    int ans=0;

    cin >> N;

    if(N/100==7){
        ans++;
    }

    else if(N/10-(N/100)*10==7){
        ans++;
    }

    else if(N-(N/10)*10==7){
        ans++;
    }

    if(ans==0)
    cout << "No" << endl;

    else
    cout << "Yes" << endl;
    



    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if (a >= k) {
    printf("%lld %lld\n", a-k,b);
  }
  else if (b - k + a > 0) {
    printf("%lld %lld\n", 0, b- k + a);
  }
  else cout << 0 <<' '<<0<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int k = Integer.parseInt(sc.next());
      String s = sc.next();
      if (s.length() <= k) {
        System.out.println(s);
      } else {
        System.out.println(s.substring(0, k) + "...");
      }
    }
  }
}

Measured memory_bytes: 38532
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int l=s.size();
    bool ans=false;
    for(int i=0;i<l;i++){
        if(s==t)ans=true;
        else t=t[l-1]+t.substr(0,l-1);
    }
    if(ans==true)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256