akhauriyash/Code-Regression huggingface dataset:
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

map<string, int> M;

int main() {
  string word, long_word, freq_word;
  int cnt = 0, length = 0;
  while (cin >> word) {
    if (M.count(word))
      M[word]++;
    else
      M[word] = 1;
    if (M[word] > cnt) {
      cnt = M[word];
      freq_word = word;
    }
    if (word.length() > length) {
      length = word.length();
      long_word = word;
    }
  }
  cout << freq_word << ' ' << long_word << endl;
}



Measured memory_bytes: 3012
# coding: utf-8
N = int(input())
list = input().split(" ")

num_list = []

for num in list:
    num_list.append(int(num))

count = 0
end_flg = 0
while True:
    for i in range(len(num_list)):
        if num_list[i] % 2 == 1:
            end_flg = 1
        else:
            num_list[i] = int(num_list[i]/2)
    if end_flg == 1:
        break
    count += 1

print(count)

Measured memory_bytes: 3064
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

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


	int n, K;
	cin >> n >> K;

	vector<ll> A, B;
	rep(i, n) {
		int a;
		cin >> a;

		if (a >= 0) A.pb(a);
		else B.pb(-a);
	}
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());
	sort(B.begin(), B.end());
	reverse(B.begin(), B.end());

	int N = A.size();
	int M = B.size();

	ll kari = 1;
	int ikeru = 1;
	int p = 0, q = 0;

	if (K % 2) {
		if (N == 0) {
			ikeru = 0;
		}
		else {
			kari = A[0];
			p = 1;
		}
	}

	while (ikeru && p + q < K) {
		if (p + 2 > N && q + 2 > M) {
			ikeru = 0;
			break;
		}
		if (p + 2 > N) {
			kari = kari * B[q] % mod * B[q + 1] % mod;
			q += 2;
		}
		else if (q + 2 > M) {
			kari = kari * A[p] % mod * A[p + 1] % mod;
			p += 2;
		}
		else {
			ll tmp1 = A[p] * (ll)A[p + 1];
			ll tmp2 = B[q] * (ll)B[q + 1];
			if (tmp1 > tmp2) {
				kari = kari * A[p] % mod * A[p + 1] % mod;
				p += 2;
			}
			else {
				kari = kari * B[q] % mod * B[q + 1] % mod;
				q += 2;
			}
		}
	}

	if (p + q == K && ikeru) {
		co(kari);
		return 0;
	}

	reverse(A.begin(), A.end());
	reverse(B.begin(), B.end());

	p = 0;
	q = 0;
	kari = 1;
	while (p + q < K) {
		if (p == N) {
			kari = kari * B[q] % mod;
			q += 1;
		}
		else if (q == M) {
			kari = kari * A[p] % mod;
			p += 1;
		}
		else {
			if (A[p] < B[q]) {
				kari = kari * A[p] % mod;
				p += 1;
			}
			else {
				kari = kari * B[q] % mod;
				q += 1;
			}
		}
	}
	co((mod - kari) % mod);


	Would you please return 0;
}

Measured memory_bytes: 5508
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int main(){
    int n,k,a,ans=0;
    in(n);in(k);
    for(int i=1;i<=n;i++){
    	in(a);if(a>=k)ans++;
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
const int INF = 1001001001;
int a[12][12];

void test_case(){
	int n , m , x; cin >> n >> m >> x;
	vector<int> c(n);
	for(int i = 0 ; i < n ; i++){
		cin >> c[i];
		for(int j = 0 ; j < m ; j++){
			cin >> a[i][j];
		}
	}
	int ans = INF;
	for(int s = 0 ; s < (1<<n) ; s++){
		int cost = 0;
		vector<int> d(m);
		for(int i = 0 ; i < n ; i++){
			if(s>>i & 1){
				cost+=c[i];
				for(int j = 0 ; j < m ; j++)
					d[j] += a[i][j];
			}
		}
		bool ok = true;
		for(int j = 0 ; j < m ; j++)
			if(d[j] < x)
				ok = false;
		if(ok)
			ans = min(ans,cost);
	}
	if(ans == INF)
		cout<<"-1\n";
	else
		cout<<ans<<"\n";
				
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    int x,y,t;
    int f=0;
    int arr[10001];
    cin>>a>>b;
    for(int i=1;i<=11000;i++)
    {
        x=floor(0.08*i);
        y=floor(0.1*i);
        if(x==a&&y==b)
        {
            t=i;
            f=1;
            break;
        }
    }
if(f)
cout<<t<<endl;
else
    cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;



int main(){
int x; cin>>x;
ll sum=0;
ll i=0;
while(sum<x){
  i++;
  sum+=i;
}
cout<<i<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long arr[100000][3] = {0};
int main()
{
    long long n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            int a;
            cin>>a;
            arr[i][j] = a;
        }
    }
    long long dp[100000][3];
    memset(dp,0,sizeof dp);

    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];

    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
            {
                dp[i][j] = arr[i][j] + max(dp[i-1][1],dp[i-1][2]);
            }

            if(j==1)
            {
                dp[i][j] = arr[i][j] + max(dp[i-1][0],dp[i-1][2]);   
            }

            if(j==2)
            {
                dp[i][j] = arr[i][j] + max(dp[i-1][0],dp[i-1][1]);
            }
        }
    }   
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;

    return 0;
}

Measured memory_bytes: 7820
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int n = sc.nextInt();
    int a = 0;
    String ans = "No";
    for(int i=0; i<n; ++i)
      a += sc.nextInt();
    if(h <= a) ans = "Yes";
    System.out.println(ans);
  }
}

Measured memory_bytes: 47612
#include<stdio.h>
int main(void)
{
	int l,a,b,c,d,s,j;
	scanf("%d",&l);
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	if(a%c==0){
	
		s= a / c;
	}
	else{
		s= a / c + 1;
	}
	if(b%d==0){
		j= b / d;
	}
	else{
		j= b / d + 1;
	}
	if(s<j){
		printf("%d\n",l-j);
	}
	else{
		printf("%d\n",l-s);
	}
	return 0;
}
	


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    const double pi = acos(-1);
    double angm = (m / 60.0) * 2 * pi;
    double angh = (h / 12.0) * 2 * pi + (m / 60.0) * 2 * pi / 12;
    double xh = a * cos(angh), yh = a * sin(angh);
    double xm = b * cos(angm), ym = b * sin(angm);
    double dx = xh - xm, dy = yh - ym;
    double ans = dx * dx + dy * dy;
    ans = sqrt(ans);
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4100
import java.util.Scanner;
import java.lang.Math;

class Main{
	public static void main(String[] arg){
	
		
		
		
		Scanner sc = new Scanner(System.in);
		double a,b,c,co,radian,radians;
		a=sc.nextDouble();
		b=sc.nextDouble();
		co=sc.nextDouble();
		radian=Math.toRadians(co);
		radians=Math.cos(radian);
		
		c= b*b+a*a-2*b*a*radians;
		c=Math.sqrt(c);
		double p =(a+b+c)/2;
		
		double S=Math.sqrt(p*(p-a)*(p-b)*(p-c));
		double H=2*S/a;
		double L=a+b+c;
		System.out.printf("%.8f\n",S);
		System.out.printf("%.8f\n",L);
		System.out.printf("%.8f\n",H);
		
		}
}



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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    // ??
    reverse(S.begin(), S.end());
    for(int i=0; i<4; i++)
       reverse(divide[i].begin(), divide[i].end());
    
    bool can = true;

    for(int i=0; i < S.size();){
        bool can2 = false;
        for(int j=0; j<4; j++){
            string d = divide[j];
            if(S.substr(i, d.size()) == d){
                can2 = true;
                i += d.size();
            }
        }
        if(!can2){
            can = false;
            break;
        }
    }
    if(can){
        cout << "YES" <<endl;
    }else{
        cout << "NO" << endl;
    }
}


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

struct Edge {
    int from, to, d;
};

int main() {
    int n;
    cin >> n;
    vector<Edge> es[n + 1];
    for (int i = 1; i < n; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        es[u].push_back(Edge {0, v, w});
        es[v].push_back(Edge {0, u, w});
    }

    queue<Edge> que;
    int color[n + 1];
    fill(color, color + n + 1, -1);
    color[0] = 0;
    que.push(Edge {0, 1, 0});

    while (!que.empty()) {
        auto e = que.front();
        que.pop();
        if (color[e.to] >= 0)
            continue;
        color[e.to] = (e.d + color[e.from]) % 2;
        for (auto v: es[e.to]) {
            que.push(Edge {e.to, v.to, v.d});
        }
    }

    for (int i = 1; i <= n; i++) {
        cout << color[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 7296
def calc_sum_digit(N):
    sum_digit = 0
    while N > 0:
        sum_digit += N%10
        N = N//10
    return sum_digit


if __name__ == '__main__':
    N, A, B = map(int, input().split())

    answer = 0
    for i in range(1, N+1):
        sum_digit = calc_sum_digit(i)
        if A <= sum_digit <= B:
            answer += i

    print(answer)

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

int main(){
  int a,b,c;
  string s,h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  queue<int> q;
  while(1){
    cin>>a;
    if(a==0)break;
    while(q.size()!=0)q.pop();
    for(int i=0;i<a;i++){
      cin>>b;
      q.push(b);
    }
    cin>>s;
    for(int i=0;i<s.size();i++){
      if('a'<=s[i]&&s[i]<='z')c=s[i]-'a';
      else if('A'<=s[i]&&s[i]<='Z')c=s[i]-'A'+26;
      //cout<<c<<" ";///////////
      c-=q.front();
      //cout<<c<<endl;///////////
      if(c<0)c=h.size()+c;
      q.push(q.front());q.pop();
      cout<<h[c];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3144
n=int(input())

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

s = 0
mini = 10000000000000
count = 0
for i in t:
    if i < 0:
        count += 1
    s += abs(i)
    mini = min(mini, abs(i))
if count%2 == 0:
    print(s)
else:
    print(s-mini*2)

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

int main() {
	int A,B,C;
  	cin >> A >> B >> C;
  
  	int max = A;
  	if(B > max) max = B;
  	if(C > max) max = C;
  
  	int others = A + B + C - max;
  
  	if(others == max) {
    	cout << "Yes" << endl;
    }else {
    	cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#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(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int mi = -1, ma = -1;
    int n;
    cin >> n;
    vector<int> v;
    rep(i, n){
        int a;
        cin >> a;
        int index = lower_bound(ALL(v), a) - v.begin() - 1;
        //cout << index << endl;
        if(index == -1){
            v.insert(v.begin(), a);
        }
        else{
            v[index] = a;
        }
    }
    //print(v);
    print(v.size());
    
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define N 4444

using namespace std;

char ch[N];
int len;
int rn[N],bn[N],gn[N];
int main(){
	long long res=0;
	ios_base::sync_with_stdio(false);
	cin >> len >> ch;
	for (int i=0; i<len; i++){
		rn[i]=rn[i-1];
		gn[i]=gn[i-1];
		bn[i]=bn[i-1];
		if (ch[i]=='R')rn[i]++;
		if (ch[i]=='G')gn[i]++;
		if (ch[i]=='B')bn[i]++;
	}
	for (int i=0 ;i<len; i++){
		if (ch[i]=='R'){
			res+=bn[i]*gn[i];
		}
		if (ch[i]=='G'){
			res+=bn[i]*rn[i];
		}
		if (ch[i]=='B'){
			res+=gn[i]*rn[i];
		}
	}
	for (int i=0; i<len; i++){
		for (int j=i+1; j<len ; j++){
			int k=2*j-i;
			if (k<len){
				if(ch[i]!=ch[j] && ch[j]!=ch[k] && ch[i]!=ch[k]){
					//cout<<i<<"-"<<j<<"-"<<k<<endl;
					res--;
				}
			}
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 3656
def binary(n):
    return bin(n)[2:]

def pow_w_mod(a, x, mod):  # a^x mod n
    x = [int(b) for b in binary(x)]
    y = a
    for i in range(1, len(x)):
        y = (y**2) % mod
        if x[i] == 1:
            y = (y * a) % mod
    return y
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def combination(n, r, mod=10**9 + 7):
    r = min(r, n - r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i + 1, mod) % mod
    return res

n, m = map(int, input().split())
#a = combination(n+m, 2, mod=10**9 + 7)

if n < 2:
    b = 0 
else:
    b = combination(n, 2, mod=10**9 + 7)

if m < 2:
    c = 0
else:
    c = combination(m, 2, mod=10**9 + 7)
print(b+c)

Measured memory_bytes: 3064
n, k = gets.to_s.split.map{|e|e.to_i}
a = [0] + gets.to_s.split.map{|e|e.to_i}
 
t = Array.new(n+1){ -1 } 
used = Array.new(n+1){ false }
 
s = 1
t[1] = 0
i = 0
used[1] = true
loop do
  
  s = a[s]
  
  i +=1
  if i == k
    puts s
    exit
  end
  
  used[s] ? break : used[s] = true
  
  t[s] = i
end

dist = t[s]
cycle = i - dist

if dist >= k
  puts s
else
  idx = (k - dist) % cycle + dist
  puts t.index(idx)
end

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

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

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

	vector<int> count(n,0);
	int num=0;

	for (int i = 0; i < n-1; i++)
	{
		if(h[i]<h[i+1])
		{
			num++;
			continue;
		}
		count[num]++;
	}
	cout<<*max_element(count.begin(),count.end())<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void) {
    int a, b, d, r;
    double f;
    
    scanf("%d %d", &a, &b);
    
    d = a / b;
    r = a % b;
    f = (double)a / b;
    
    printf("%d %d %f\n", d, r, f);
    
    return 0;
} 


Measured memory_bytes: 2040
def main():
    N, M = map(int, input().split())
    if N > M:
        N, M = M, N

    if M == 1:
        print(1)
    elif N == 1:
        print(M-2)
    elif N == 2:
        print(0)
    else:
        print((N-2) * (M-2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61744
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
	

int32_t main() {
	boost;
	int n;
	cin >> n;
	int ans  = 0;
	for(int i = 1,x;i <=n;i++) {
		cin >> x;
		if(i % 2 && x % 2)
			ans++;
	}
	cout << ans <<endl;
}



Measured memory_bytes: 3604
def check():
    N,M = map(int, input().split())
    A = [input() for _ in range(N)]
    B = [input() for _ in range(M)]
    
    for i in range(N-M+1):
        for j in range(N-M+1):
            flag = True
            for k in range(M):
                if A[i+k][j:j+M] != B[k]:
                    flag = False
            if flag:
                return 'Yes'
    return 'No'
print(check())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::string s; cin >> s;
	int tmp = 0;
	for(int i = 0; i < s.size(); i++) tmp += s[i] - '0';
	
	if(std::stoi(s) % tmp) printf("No\n");
	else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main(void){

    int a, b;
    cin >> a >> b;

    cout << (a == b ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

void solve(long long N) 
{
  long max = 0;
  for (long long i = 1; i <= std::sqrt(N); i++)
  {
    if(N%i == 0)
    {
      max = i + N/i;
    }
  }
  std::cout << max-2 << std::endl;
  
}

int main(void) 
{
  long long N;
  std::cin >> N;
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
	int s,a,b,c,d,ans=1;
	scanf("%d",&s);
	a=s/1000;
	b=(s-1000*a)/100;
	c=(s-1000*a-100*b)/10;
	d=(s-1000*a-100*b-10*c);
	if(a==b&&b==c) ans=0;
	if(b==c&&c==d) ans = 0;
	if(ans == 0) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

    long long a = 1;
    for (int i = 0; i < n; i++) {
        a *= 10;
        a %= 1000000007;
    }
    long long b = 1;
    for (int i = 0; i < n; i++) {
        b *= 9;
        b %= 1000000007;
    }
    long long c = 1;
    for (int i = 0; i < n; i++) {
        c *= 8;
        c %= 1000000007;
    }
    long long result = (a + c) % 1000000007 - (b * 2) % 1000000007 + 1000000007;

    cout << result % 1000000007 << endl;
    return 0;
}

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

const int MAX_N = (int)(500 + 5);
const int MAX_C = (int)(30 + 5);

int n, c;
int diff[MAX_C][MAX_C];
int color[MAX_N][MAX_N];

map<int, int> zero;
map<int, int> one;
map<int, int> two;

int ans = MAX_N * MAX_N * 1000 + 5;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &c);

  for (int i = 1; i <= c; ++i) for (int j = 1; j <= c; ++j) {
    scanf("%d", &(diff[i][j]));
  }

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

  for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) {
    int group = (i + j) % 3;
    if (group == 0) {
      zero[color[i][j]] += 1;
    }
    else if (group == 1) {
      one[color[i][j]] += 1;
    }
    else {
      two[color[i][j]] += 1;
    }
  }


  for (int col0 = 1; col0 <= c; ++col0) for (int col1 = 1; col1 <= c; ++col1) {
    if (col0 != col1) {
      for (int col2 = 1; col2 <= c; ++col2) {
        if (col0 != col2 && col1 != col2) {
          int cost0 = 0;
          int cost1 = 0;
          int cost2 = 0;

          for (auto itr = zero.begin(); itr != zero.end(); ++itr) {
            cost0 += itr->second * diff[itr->first][col0];
          }

          for (auto itr = one.begin(); itr != one.end(); ++itr) {
            cost1 += itr->second * diff[itr->first][col1];
          }

          for (auto itr = two.begin(); itr != two.end(); ++itr) {
            cost2 += itr->second * diff[itr->first][col2];
          }

          ans = min(ans, cost0 + cost1 + cost2);
        }
      }
    }
  }

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

	return 0;
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int k = Integer.parseInt(str[0]);
    int n = Integer.parseInt(str[1]);
    int[] a = new int[n];
    int diff = 0;
    int sum = 0;
    int max = 0;
    str = in.readLine().split(" ");
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(str[i]);
    }
    for(int i=0; i<n-1; i++) {
      diff = a[i+1] - a[i];
      max = Math.max(diff,max);
      sum += diff;
    }
    if(k-a[n-1]+a[0]<max)
      System.out.println(sum-max+(k-a[n-1]+a[0]));
    else
      System.out.println(sum);
  }
}

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

typedef pair<int, int> P;

int p[10][10], visited[10][10];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int h, w, c;

int dfs(int count) {
    if(count == 5) {
        int ret = 0;
        if(p[0][0] != c) return 0;
        rep(i, 10) rep(j, 10) visited[i][j] = 0;
        queue<P> que;
        que.push(P(0, 0));
        while(!que.empty()) {
            P point = que.front(); que.pop();
            if(visited[point.first][point.second] == 0) {
               visited[point.first][point.second] = 1;
               ret++;
                rep(i, 4) {
                    int ny = point.first + dy[i];
                    int nx = point.second + dx[i];
                    if(nx >= 0 && nx < w && ny >= 0 && ny < h &&
                       visited[ny][nx] == 0 && p[ny][nx] == c) {
                        que.push(P(ny, nx));
                    }
                }
            }
        }
        return ret;
    }
    int org[10][10];
    int ret = 0;
    rep(i, h) rep(j, w) org[i][j] = p[i][j];
    rep(color, 6) {
        int org_c = p[0][0];
        rep(i, 10) rep(j, 10) visited[i][j] = 0;
        queue<P> que;
        que.push(P(0, 0));
        while(!que.empty()) {
            P point = que.front(); que.pop();
            p[point.first][point.second] = color+1;
            visited[point.first][point.second] = 1;
            rep(i, 4) {
                int ny = point.first + dy[i];
                int nx = point.second + dx[i];
                if(nx >= 0 && nx < w && ny >= 0 && ny < h &&
                   visited[ny][nx] == 0 && p[ny][nx] == org_c) {
                    que.push(P(ny, nx));
                }
            }
        }
        ret = max(ret, dfs(count+1));
        rep(i, 10) rep(j, 10) p[i][j] = org[i][j];
    }
    return ret;
}

int main(void){
    while(cin >> h >> w >> c && h) {
        rep(i, h) rep(j, w) cin >> p[i][j];
        cout << dfs(0) << endl;
    }
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  char c;
  scanf("%c", &c);
  c += 1;
  printf("%c\n", c);

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;


class Program
{
    static void Main(string[] args)
    {
        ulong N = ulong.Parse(Console.ReadLine());
        int A_digits; int B_digits;
        int min_digits=N.ToString().Length;

        for(ulong i=1; i<=N/i; i++){
            if(N%i==0){
                A_digits = i.ToString().Length;
                B_digits = (N/i).ToString().Length;
                if(Math.Max(A_digits, B_digits) < min_digits){
                    min_digits = Math.Max(A_digits, B_digits);
                }
            }
        }

        Console.WriteLine(min_digits);
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String str = sc.next();
		int s = 0, e = 0, ans = 0;
		
		for (int i = 0; i < str.length(); i++) {
			if (str.substring(i, i + 1).equals("A")) {
				s = i;
				break;
			}
		}
		
		for (int i = str.length(); i > 0; i--) {
			if (str.substring(i - 1, i).equals("Z")) {
				e = i;
				break;
			}
		}
		
		ans = e - s;
		
		
		System.out.println(ans);

		sc.close();
	}
}


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

using namespace std;

#define ll long long
#define ull unsigned long long

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

    int n, m;
    cin >> m >> n;
    int sm = 0;
    for (int i = 0, a; i < n; i++) {
        cin >> a;
        sm += a;
    }
    cout << max(-1, m - sm) << '\n';
}


Measured memory_bytes: 3656
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

public class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        double n=sc.nextInt();
        double d=sc.nextInt();
        int x=(int)Math.ceil(n/(2d*d+1d));
        System.out.println(x);

    }

}



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

int memo[205][205];

int gcd(int a, int b) { return b?gcd(b,a%b):a;}
int gcd_memo(int a, int b){
    if(memo[a][b] != 0) return memo[a][b];
    else{
        int g = gcd(a,b);
        memo[a][b] = g;
        return g;
    }
}

int main() {
    int k;
    cin >> k;
    int sum = 0;
    for(int i = 1; i <= k; i++)
        for(int j = 1; j <= k; j++)
            for(int l = 1; l <= k; l++)
                sum += gcd_memo(gcd_memo(i,j), gcd_memo(j,l));

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3792
#include<iostream>
#include<string>
#include<cmath>
#include<array>
#include<algorithm>
#include<queue>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n,int r) {
//	n = n + r - 1;
//	return nCr(n,r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI N,MAX = 0,MIN = 0,res = 0;
	bool down = false;
	cin >> N;
	vector<LLI>vec(N + 2);
	for (int i = 0; i < N;i++) {
		cin >> vec[i + 1];
	}
	for (int i = 0; i < N + 1;i++) {
		if (vec[i] < vec[i + 1]) {
			MAX = vec[i + 1];
			down = true;
		}
		if (vec[i] > vec[i + 1] && down) {
			res += MAX - MIN;
			MIN = vec[i + 1];
			down = false;
		}
		else if(vec[i] > vec[i + 1]){
			MIN = vec[i + 1];
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt() - 1;
        int b = sc.nextInt() - 1;
        
        // dist[i][j] = 点i→jの直接距離
        // i→jとj→iの距離が同じとは限らない
        int[][] dist = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                dist[i][j] = Math.abs(j - i);
            }
        }
        dist[a][b] = 1;
        dist[b][a] = 1;
        
        // 「ワーシャルフロイド法」
        // 3つの頂点i, j, kを選んで、
        // i→k→jという道がi→jという道より短ければi→jの距離を更新する
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                int tmp = Math.min(dist[i][a] + dist[a][b] + dist[b][j], dist[i][b] + dist[b][a] + dist[a][j]);
                dist[i][j] = Math.min(dist[i][j], tmp);
            }
        }
        
        int[] array = new int[n];
        for (int i = 0; i < n-1; i++) {
            for (int j = i+1; j < n; j++) {
                array[dist[i][j]]++;
            }
        }
        for (int i = 1; i < n; i++) {
            System.out.println(array[i]);
        }
    }
}

Measured memory_bytes: 54612
#include <iostream>
using namespace std;
int main() {
int a;
cin>>a;
int b=0;
int c=a;
while(a!=0){
  
  b=b+ a%10;
  a=a/10;
  
  
  
 }
  if (c%b==0){
    cout<<"Yes";}
  else{
    cout<<"No";}
  

return 0;



}

Measured memory_bytes: 256
program abc136d
    use,intrinsic :: iso_fortran_env
    implicit none
    character(100000):: s
    integer(int32):: n,i,f,l,m
    integer(int32), allocatable:: ans(:)
    logical,allocatable:: col(:), sep(:)

    read*, s
    n = len_trim(s)
    allocate(col(n-1), sep(0:n), ans(n))
    col(:) = .false.
    sep(:) = .false.
    sep(0) = .true.; sep(n) = .true.

    do i=1,n-1
        if (s(i:i+1) == 'RL') then
            col(i) = .true.
        else if (s(i:i+1) == 'LR') then
            sep(i) = .true.
        end if
    end do
    ! print*, col(:)
    ! print*, sep(1:n-1)
    f=1
    ans(:) = 0
    do i=1,n-1
        if (col(i)) then
            m = i
        else if (sep(i)) then
            l = i
            ! print*, '---',f,l
            if (mod(f,2) /= mod(l,2)) then
                ans(m:m+1) = (l-f+1)/2
                ! print*, ans(m:m+1)
            else if (mod(f,2) /= mod(m,2)) then
                ans(m) = (l-f+1)/2
                ans(m+1) = (l-f+1) - ans(m)
                ! print*, ans(m:m+1)
            else
                ans(m+1) = (l-f+1)/2
                ans(m) = (l-f+1) - ans(m+1)
                ! print*, ans(m:m+1)
            end if
            f = l+1
        end if
    end do

    l=n
    i=n
    ! print*, '---',f,l
    if (mod(f,2) /= mod(l,2)) then
        ans(m:m+1) = (l-f+1)/2
        ! print*, ans(m:m+1)
    else if (mod(f,2) /= mod(m,2)) then
        ans(m) = (l-f+1)/2
        ans(m+1) = (l-f+1) - ans(m)
        ! print*, ans(m:m+1)
    else
        ans(m+1) = (l-f+1)/2
        ans(m) = (l-f+1) - ans(m+1)
        ! print*, ans(m:m+1)
    end if 

    print*, ans(:)
end program abc136d

Measured memory_bytes: 4832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;

int a[10007];

ll calc(ll n){ // a/n ≡ a*n^(p-2)(mod p)
  ll r = 1;
  for(ll m = MOD - 2; m > 0; m >>= 1){
    if(m & 1) r = (r * n) % MOD;
    n = (n * n) % MOD;
  }
  return r;
}

ll comb(ll n,ll r){ // nCr = n! / (n-r)! * r!
  if(n < r) swap(n,r);
  ll child = 1,mother = 1;
  for(int i = 0; i < r; i++){
    child = (child * (n - i)) % MOD;
    mother = (mother *  (r - i)) % MOD;
  }
  return child * calc(mother) % MOD;
}

signed main(){

  int n,m;
  cin >> n >> m;

  int k = 0;
  for(int i = 2; i <= m; i++){
    if(m%i != 0) continue;
    int cnt = 0;
    while(m%i == 0){
      m /= i;
      cnt++;
    }
    a[k++] = comb(n+cnt-1,cnt);
  }

  ll ans = 1;
  for(int i = 0; i < k; i++){
    ans = (ans * a[i]) % MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N,L = map(int,input().split())

if L >= 0:
  ans = int(0.5*(N-1)*(2*(L+1) + N-2))
elif (L + N - 1 ) >= 0:
  ans = int(0.5*(N)*(2*(L) + N-1))
else:
  ans = int(0.5*(N-1)*(2*(L) + N-2))
  
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int l = scanner.nextInt();
			int r = 0;
			while ((1 << (r + 1)) <= l) {
				r++;
			}
			int n = r + 1;
			int count = 2 * r;
			StringBuilder sb = new StringBuilder();
			for (int i = r; i >= 1; i--) {
				// System.out.println("l=" + l + ", r=" + r + ", i=" + i);
				if ((l - (1 << (i - 1))) >= (1 << r)) {
					l -= 1 << (i - 1);
					sb.append(i + " " + n + " " + l).append("\n");
					count++;
				}
			}
			System.out.println(n + " " + count);
			IntStream.rangeClosed(1, r).forEach(i -> {
				System.out.println(i + " " + (i + 1) + " 0");
				System.out.println(i + " " + (i + 1) + " " + (1 << (i - 1)));
			});
			System.out.print(sb.toString());
		}
	}
}


Measured memory_bytes: 41416
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

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

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

struct City {
    int cityNum;
    int prefNum;
    int year;
    string ID = "";
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<pair<pair<int, int>, int>> xyh(N);
    cin >> xyh;


    REP(x, 101) {
        REP(y, 101) {
            int h = -1;
            REP(i, N) {
                if (xyh[i].second <= 0)continue;
                int H = xyh[i].second + abs(x - xyh[i].first.first) + abs(y - xyh[i].first.second);
                if (h == -1)h = H;
                if (h != H) {
                    h = -2;
                    break;
                }
            }
            if (h == -2)continue;

            REP(i, N) {
                if (xyh[i].second != 0)continue;
                if (h > abs(xyh[i].first.first - x) + abs(xyh[i].first.second - y)) {
                    h = -2;
                    break;
                }
            }
            if (h == -2)continue;
            cout << x << " " << y << " " << h << endl;
            return 0;
        }
    }
    return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        class Edge
        {
            internal int to, distance, height;

            public Edge(int to, int distance, int height)
            {
                this.to = to;
                this.distance = distance;
                this.height = height;
            }
        }

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int V = int.Parse(input[0]);
            int E = V - 1;

            Dictionary<int, List<Edge>> G = new Dictionary<int, List<Edge>>();
            for (int i = 0; i < V; i++)
            {
                G.Add(i, new List<Edge>());
            }

            for (int i = 0; i < E; i++)
            {
                input = Console.ReadLine().Split(' ');
                int s = int.Parse(input[0]);
                int t = int.Parse(input[1]);
                int w = int.Parse(input[2]);

                G[s].Add(new Edge(t, w, -1));
                G[t].Add(new Edge(s, w, -1));
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < V; i++)
            {
                int temp = DFS(G, -1, i);
                sb.AppendLine(temp.ToString());
            }
            Console.Write(sb);
        }

        static int DFS(Dictionary<int, List<Edge>> G, int prev, int cur)
        {
            int ret = 0;

            foreach (var e in G[cur])
            {
                int next = e.to;
                if (next == prev) continue;
                if (e.height == -1) e.height = e.distance + DFS(G, cur, next);
                ret = Math.Max(ret, e.height);
            }
            return ret;
        }
    }
}

Measured memory_bytes: 14292
// abc138_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    priority_queue<double, vector<double>, greater<double>> pq;

    REP(i, N){
        double v;
        cin >> v;
        pq.push(v);
    }

    while (pq.size() > 1){
        double x = pq.top(); pq.pop();
        double y = pq.top(); pq.pop();
        pq.push((x + y) / 2);
    }

    print(pq.top());

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a;
    int b;

    scanf("%d %d",&a,&b);

    if(a < b){
        printf("a < b\n");
    }

    else if(a > b){
        printf("a > b\n");
    }

    else if(a == b){
        printf("a == b\n");
    }

    return 0;
}


Measured memory_bytes: 2672
#include <cstdio>

int main()
{
	int		a;

	scanf("%d", &a);

	int s = a % 60;
	int m = a / 60;
	int h = m / 60;
	m = m % 60;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

Measured memory_bytes: 2720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string s1, s2;
            while ((s1 = Console.ReadLine()) != null & (s2 = Console.ReadLine()) != null)
            {
                var hit = 0;
                var blow = 0;
                var a = s1.Split(' ').Select(tryAndParse).ToArray();
                var b = s2.Split(' ').Select(tryAndParse).ToArray();
                var dict = new Dictionary<int, bool>();
                foreach (var v in a) { dict.Add(v, true); }
                for (int i = 0; i < 4; i++)
                {
                    if (a[i] == b[i]) hit++;
                    else
                        try { if (dict[b[i]]) blow++; }
                        catch (Exception e) { e.Equals(e); }
                }
                Console.WriteLine("{0} {1}", hit, blow);
            }
        }

        static int tryAndParse(string s)
        {
            try
            {
                return int.Parse(s);
            }
            catch (FormatException e)
            {
                e.Equals(e);
                return -1;
            }
        }
    }
}

Measured memory_bytes: 6416
(n,*c),a,*q=$<.map{_1.split.map &:to_i}
b=(0..n).map{_1&-_1}
d=b.map{[]}
u=i=k=0
z=q.map{d[_2]<<[_1-1,~k-=1]}
a.map{t=c[_1]
(b[t]-=1;t+=t&-t)until t ?t>n:u+=1
c[_1]=i+=1
d[i].map{|x,y|z[y]=u
(z[y]-=b[x];x&=x-1)while x>0}}
p *z

Measured memory_bytes: 179472
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,P;
  string S;
  cin>>N>>P>>S;
  reverse(S.begin(),S.end());
  if(P==2 || P==5){
    int j=0;
    for(int i=0;i<N;i++)
      if((S[i]-'0')%P==0)
        j+=N-i;
    cout<<j<<endl;
    return 0;
  }
  vector<int> A(N+1,0);
  int k=1;
  for(int i=1;i<=N;i++){
    A[i]=(A[i-1]+(S[i-1]-'0')*k)%P;
    k=k*10%P;
  }
  map<int,int> B;
  for(int i:A)
    B[i]++;
  int i=0;
  for(pair<int,int> p:B)
    i+=p.second*(p.second-1)/2;
  cout<<i<<endl;
}

Measured memory_bytes: 5408
#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>;

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; }
const ll INF = 1LL << 60;

//---main---------------------------------------------
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;
    rep(i,M) t += B[i];
    int j=M;
    int ans = 0;
    
    rep(i,N+1){
        while(j>0 && t > K){
            --j;
            t -= B[j];
        }
        if(t>K) break;
        ans = max(ans,i+j);
        if(i == N) break;
        t += A[i];
    }

    cout << ans << endl;

    /* my answer
    //main
    int N,M,K;
    cin >> N >> M >> K;
    int A[N],B[M];
    rep(i,N) cin >> A[i];
    rep(i,M) cin >> B[i];

    int At[N+1],Amax=-1;
    At[0] = 0;
    rep(i,N){
        At[i+1] = At[i] + A[i];
        if(At[i+1]>K){
            Amax = i;
            break;
        }
    }
    if(Amax==-1) Amax=N;

    int ans = Amax;
    //cout << Amax << endl;
    rep(i,M){
        K -= B[i];
        if(K<0) break;
        for(int j = Amax; j>=0; --j){
            if( At[j] <= K ){
                //if(chmax(ans, j+i+1)) cout << j << " " << i+1 << endl;;
                chmax(ans, j+i+1);
                Amax = j;
                break;
            }
        }
    }

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

Measured memory_bytes: 4844
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int n;
    int tmp_n;
    int tmp_sum=0;
    int tmp_max=0;
    cin >> n;
    vector<int> l(n);
    for(int i=0; i<n; i++){
        cin >> tmp_n;
        l[i] = tmp_n;
        tmp_sum+=tmp_n;
        if(tmp_max<tmp_n){
            tmp_max=tmp_n;
        }
    }
    tmp_sum-=tmp_max;
    if(tmp_max<tmp_sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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


int main() 
{
    int H, W;
    string S[50];

    cin >> H >> W;
    for (int i = 0; i < H; i++)
        cin >> S[i];

    for (int j = 0; j < H; j++)
    {
        for (int k = 0; k < W; k++)
        {
            int count = 0;
            if (S[j][k] == '#')
            {
                cout << "#";
                continue;
            }
            if(j>=1 && k>=1)
                if (S[j - 1][k - 1] == '#')
                    count++;
            if (j >= 1)
                if (S[j - 1][k] == '#')
                    count++;
            if (j >= 1 && k < W-1)
                if (S[j - 1][k + 1] == '#')
                    count++;
            if (k >= 1)
                if (S[j][k - 1] == '#')
                    count++;
            if (k < W - 1)
                if (S[j][k + 1] == '#')
                    count++;
            if (k >= 1 && j < H-1)
                if (S[j + 1][k - 1] == '#')
                    count++;
            if (j < H - 1)
                if (S[j + 1][k] == '#')
                    count++;
            if (k < W - 1 && j < H-1)
                if (S[j + 1][k + 1] == '#')
                    count++;
            cout << count;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256