akhauriyash/Code-Regression huggingface dataset:
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto X = new long[](N);
    auto Y = new long[](N);
    auto Z = new long[](N);
    foreach (i; 0 .. N)
        scan(X[i], Y[i], Z[i]);
    auto x = new long[](N);
    auto y = new long[](N);
    auto z = new long[](N);
    long ans = long.min;
    foreach (s; 0 .. 2 ^^ 3)
    {
        x[] = X[];
        y[] = Y[];
        z[] = Z[];
        if ((s & (1 << 0)) != 0)
            x[] *= -1;
        if ((s & (1 << 1)) != 0)
            y[] *= -1;
        if ((s & (1 << 2)) != 0)
            z[] *= -1;
        // writeln(x, X);
        zip(x, y, z).sort!"a[0]+a[1]+a[2]>b[0]+b[1]+b[2]"();
        ans = ans.max(abs(sum(x[0 .. M])) + abs(sum(y[0 .. M])) + abs(sum(z[0 .. M])));
    }
    writeln(ans);
}


Measured memory_bytes: 508
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> 
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

int main(){
    string s;cin>>s;
    REP(i,s.size()){
        if(s[i]=='1'){
            s[i] = '9';
        }else if (s[i] == '9'){
            s[i] = '1';
        }
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ans=0;
	int mini=0;
	int c;
	for(int i=1;i<=n;i++)
	{
		cin>>c;
		if(c>=mini)
		{
			ans++;
			mini=c;
		}
	}
	cout<<ans;
}

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

testimonies_all = []
for i in range(N):
    A = int(input())
    testimonies = []
    for j in range(A):
        x, y = map(int, input().split())
        testimonies.append((x, y))
    testimonies_all.append(testimonies)

import itertools
assumptions = list(itertools.product((0, 1), repeat = N))

answers = []
for i in assumptions:
    assumptions2 = []
    for j in range(N):
        assumptions2.append((j + 1, i[j]))
        if i[j] == 1:
            for k in testimonies_all[j]:
                assumptions2.append(k)
    assumptions2.sort()
    count = 0
    for j in range(len(assumptions2) - 1):
        if assumptions2[j][0] == assumptions2[j + 1][0] and assumptions2[j][1] != assumptions2[j + 1][1]:
            count += 1
            break
    if count == 0:
        answers.append(sum(i))

print(max(answers))


Measured memory_bytes: 9076
#include<stdio.h>
#define N 100000

int main(void){

  int n, q, C=0, i, j;
  int S[N], T[N];
  int left=0, right, mid, key;

  scanf("%d",&n);

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

  scanf("%d",&q);

  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }


  for(j=0;j<q;j++){

    key = T[j];
    right = n;
    left = 0;

    while(left<right){
      mid = (left+right)/2;

      if(S[mid] == key){ C++; break;}
      if(S[mid] != key && S[mid] < key){ left = mid+1;}
      if(S[mid] != key && S[mid] > key){ right = mid;}

    }
  }

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

  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int acc_left[1000000];
int acc_right[1000000];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;

  int acc = 0;
  REP(i,s.size()){
    if (s[i] == '<'){
      acc++;
    }else{
      acc = 0;
    }
    acc_left[i+1] = acc;
  }
  acc = 0;
  for(int i=s.size()-1;i>=0;i--){
    if (s[i] == '>'){
      acc++;
    }else{
      acc = 0;
    }
    acc_right[i] = acc;
  }
  ll ans = 0;
  REP(i,s.size()+1){
    ans += max(acc_left[i],acc_right[i]);
    //cout << acc_left[i]<<acc_right[i] << endl;
  }
  cout << ans  << endl;
}


Measured memory_bytes: 6940
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
data = []
for _ in range(M):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
ans = [0] * N
for i in data:
    ans[i[0]-1] += 1
    ans[i[1]-1] += 1
for j in ans:
    print(j)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D;
  cin>>D;
  if(D==22)cout<<"Christmas Eve Eve Eve"<<endl;
  else if(D==23)cout<<"Christmas Eve Eve"<<endl;
  else if(D==24)cout<<"Christmas Eve"<<endl;
  else cout<<"Christmas"<<endl;
}


Measured memory_bytes: 256
s = input()
q = int(input())
flag = 1
f = ''
b = ''
for i in range(q):
  query = list(map(str, input().split()))
  if query[0] == '1':
    flag *= -1
  else:
    if flag == 1:
      if query[1] == '1':
        f += query[2]
      else:
        b += query[2]
    else:
      if query[1] == '1':
        b += query[2]
      else:
        f += query[2]
ans = f[::-1] + s + b
if flag == -1:
  ans = ans[::-1]
print(ans)

Measured memory_bytes: 10020
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#define ll long long
#define maxn 4001000
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define rep(i,a,b) for(int i=a;i<=b;i++)
const ll P=1e9+7;
using namespace std;
int main(){
	string s,c;
	int n;
	cin>>n;
	cin>>s>>c;
	int idx1 = 0,idx2 = 0;
	for(int i = 0;i < 2*n ;++i){
		if(i&1) cout<<c[idx1++];
		else cout<<s[idx2++];
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int long long
#define mp make_pair
//#define for(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define N 1000000007
#define pq priority queue
#define pb push_back
#define mt make_tuple
#define prec(a) fixed<<setprecision(9)<<a
#define endl "\n"
#define fast_set s.max_load_factor(0.25);s.reserve(500);
const long double PI = (long double)(3.1415926535897932384626433832795);
int parity_check(int n)
{
	int par=n;
	par = par ^ (par >> 1); 
    par = par ^ (par >> 2); 
    par = par ^ (par >> 4); 
    par = par ^ (par >> 8); 
    par = par ^ (par >> 16); 
  
    if(par%2==1)
    {
    	return 1;
    }
    else
    {
    	return 0;
    }
    // true means odd parity
    // false means even parity
}
ll gcd(ll a,ll b)
{
	if(a==0)
	{
		return b;
	}
	return gcd(b%a,a);
}
int sz[100001];
ll lcm(ll a,ll b)
{
	ll pro=a*b;
	ll ans=gcd(a,b);
	pro=pro/ans;
	return pro;
}
ll fast_power(ll a,ll b,ll p)
{
	if(b==0)
	{
		return (1%p);
	}
	ll t=fast_power(a,b/2,p);
	ll ans=(t*t)%p;
	if(b%2)
	{
		ans=(ans*(a%p))%p;
	}
	return ans;
}

void dfs(int s,bool visited[],vector<int> v[])
{
	visited[s]=true;
	for(int i=0;i<v[s].size();i++)
	{
		if(!visited[v[s][i]])
		{
			visited[v[s][i]]=true;
			dfs(v[s][i],visited,v);
			sz[s] = sz[v[s][i]]+sz[s];
		}
	}
	sz[s]=sz[s]+1;
}

void dfs2(int s,bool visited[],vector<int> v[],int dest,int *save,set<int> &save_set,int count)
{
	visited[s]=true;
	if((*save)==0)
		save_set.insert(s);

	for(int i=0;i<v[s].size();i++)
	{
		if(v[s][i]==dest&&(*save)==0)
		{
			(*save)=count+1;
		}
		if(!visited[v[s][i]])
		{
			visited[v[s][i]]=true;
			count++;
			dfs2(v[s][i],visited,v,dest,save,save_set,count+1);
			//sz[s] = sz[v[s][i]]+sz[s];
		}
	}
	//sz[s]=sz[s]+1;
	if((*save)==0)
		save_set.erase(s);
	count--;
}
int main()
{
	fast;
	
	int n,a,b,i,j;
	cin>>n>>a>>b;
	int arr[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	int count1=0,count2=0,count3=0;
	for(i=0;i<n;i++)
	{
		if(arr[i]<=a)
		{
			count1++;
		}
		if(arr[i]>a&&arr[i]<=b)
		{
			count2++;
		}
		if(arr[i]>b)
		{
			count3++;
		}
	}
	cout<<min(count1,min(count2,count3));


	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmax(T &_a, T _b){
    if(_a < _b){
        _a = _b;
        return true;
    }else{
        return false;
    }
}

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

    int n, k;
    cin >> n >> k;

    vector<lint> v(n);
    rep(i, n){
        cin >> v[i];
    }

    lint ans = 0;
    rep(i, n + 1){
        rep(j, i + 1){
            if(i + j > k){
                break;
            }
            rep(l, i + 1){
                priority_queue< lint, vector<lint>, greater<lint> > que;
                rep(m, l){
                    que.push(v[m]);
                }
                rep(m, i - l){
                    que.push(v[n + ~m]);
                }
                rep(m, j){
                    que.pop();
                }
                lint tmp = 0;
                while(!que.empty()){
                    tmp += que.top();
                    que.pop();
                }
                chmax(ans, tmp);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

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

  int n; cin >> n;
  ll march[5] = {0};
  string name;
  for (int i = 0; i < n; i++) {
    cin >> name;
    if (name[0] == 'M') {
      march[0]++;
    } else if (name[0] == 'A') {
      march[1]++;
    } else if (name[0] == 'R') {
      march[2]++;
    } else if (name[0] == 'C') {
      march[3]++;
    } else if (name[0] == 'H') {
      march[4]++;
    }
  }

  ll ans = 0;
  ans += march[0] * march[1] * march[2];
  ans += march[0] * march[1] * march[3];
  ans += march[0] * march[1] * march[4];
  ans += march[0] * march[2] * march[3];
  ans += march[0] * march[2] * march[4];
  ans += march[0] * march[3] * march[4];
  ans += march[1] * march[2] * march[3];
  ans += march[1] * march[2] * march[4];
  ans += march[1] * march[3] * march[4];
  ans += march[2] * march[3] * march[4];

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int r; cin >> r;
    ld ans = (ld)r * 2.0 * pi;
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

def main():
    cur = 0
    ans = 0

    if A[0] != 0:
        print(-1)
        return

    for a in A:
        if a <= cur:
            ans += a
        elif a == cur+1:
            ans += 1
        else:
            print(-1)
            return
        cur = a

    print(ans)

    
main()

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

int main()
{   ll n,w;
    scanf("%lld%lld",&n,&w);
    ll x[n][2];
    for(ll i=0;i<n;i++)
        scanf("%lld%lld",&x[i][0],&x[i][1]);
    ll z[n+1][w+1]={INT_MIN};
    for(ll i=0;i<=n;i++)
        z[i][0]=0;
    for(ll i=0;i<=w;i++)
        z[0][i]=0;
    for(ll i=1;i<=n;i++)
        for(ll j=1;j<=w;j++)
        {   if(j>=x[i-1][0])
                z[i][j]=max(z[i-1][j],x[i-1][1]+z[i-1][j-x[i-1][0]]);
            else
                z[i][j]=z[i-1][j];
        }
    printf("%lld",z[n][w]);
    return 0;
}


Measured memory_bytes: 79104
n,m,x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
rn = [i for i in a if n>=i>=x]
r0 = [i for i in a if x>=i>=0]
print(len(rn)) if len(rn)<len(r0) else print(len(r0))

Measured memory_bytes: 3060
N,A,B=open(0).read().rstrip().split('\n')
N=int(N)
A=list(map(int,A.split()))
B=list(map(int,B.split()))
hunt=0
for i in range(N):
    if A[i]>=B[i]:
        hunt+=B[i]
    elif A[i]+A[i+1]>=B[i]:
        hunt+=B[i]
        suplus=B[i]-A[i]
        A[i+1]=A[i+1]-suplus
    else:
        hunt+=A[i]+A[i+1]
        A[i+1]=0
print(hunt)

Measured memory_bytes: 25808
def tax(a,p):
    return int(a * (1.0 + p))
    
while 1:
    x,y,s = map(int,raw_input().split())
    if x == y == s == 0: break
    x /= 100.0-1e-10
    y /= 100.0-1e-10

    ans = 0
    for a in xrange(1,s):
        b = s - tax(a,x)
        while tax(a,x) + tax(b,x) > s: b -= 1
        if (b < 1 or s-1 < b) or tax(a,x) + tax(b,x) != s: continue
        ans = max(ans, tax(a,y) + tax(b,y))
    print ans        

Measured memory_bytes: 4256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

inline int read () {
    int ret = 0, t = 1;
    char c = getchar();
    while ((c < '0' || c > '9') && c != '-') c = getchar();
    if (c == '-') t = -1, c = getchar();
    while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
    return ret * t;
}

int main () {
    string a, b;
    cin >> a >> b; int ans = 0;
    for (int i = 0; i <= 2; i++) if (a[i] == b[i]) ans++; cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <vector> 
#include <cstring>
using namespace std;
#define N 650
#define fr first
#define se second
#define mp make_pair
#define pr pair<int,int>
int n,d1,d2,i,j,k,l,a[N][N],b[N][N],cnt[4];
bool vis[N][N];
vector<pr > v;
void dfs1(int i,int j)
{
	vis[i][j]=true;
	for (int ii=0;ii<v.size();ii++){
		int k=v[ii].fr,l=v[ii].se;
		if (i>=k&&j>=l&&!vis[i-k][j-l]) a[i-k][j-l]=a[i][j]^1,dfs1(i-k,j-l);
		if (i>=k&&j+l<(n<<1)&&!vis[i-k][j+l]) a[i-k][j+l]=a[i][j]^1,dfs1(i-k,j+l);
		if (i+k<(n<<1)&&j>=l&&!vis[i+k][j-l]) a[i+k][j-l]=a[i][j]^1,dfs1(i+k,j-l);
		if (i+k<(n<<1)&&j+l<(n<<1)&&!vis[i+k][j+l]) a[i+k][j+l]=a[i][j]^1,dfs1(i+k,j+l);
	}
}
void dfs2(int i,int j)
{
	vis[i][j]=true;
	for (int ii=0;ii<v.size();ii++){
		int k=v[ii].fr,l=v[ii].se;
		if (i>=k&&j>=l&&!vis[i-k][j-l]) b[i-k][j-l]=b[i][j]^1,dfs2(i-k,j-l);
		if (i>=k&&j+l<(n<<1)&&!vis[i-k][j+l]) b[i-k][j+l]=b[i][j]^1,dfs2(i-k,j+l);
		if (i+k<(n<<1)&&j>=l&&!vis[i+k][j-l]) b[i+k][j-l]=b[i][j]^1,dfs2(i+k,j-l);
		if (i+k<(n<<1)&&j+l<(n<<1)&&!vis[i+k][j+l]) b[i+k][j+l]=b[i][j]^1,dfs2(i+k,j+l);
	}
}
int main()
{
	scanf("%d%d%d",&n,&d1,&d2);
	for (k=0;k<(n<<1);k++)
	for (l=0;l<(n<<1);l++) if (k*k+l*l==d1) v.push_back(mp(k,l));
	for (i=0;i<(n<<1);i++)
	for (j=0;j<(n<<1);j++) if (!vis[i][j]) dfs1(i,j);
	v.clear();memset(vis,false,sizeof(vis));
	for (k=0;k<(n<<1);k++)
	for (l=0;l<(n<<1);l++) if (k*k+l*l==d2) v.push_back(mp(k,l));
	for (i=0;i<(n<<1);i++)
	for (j=0;j<(n<<1);j++) if (!vis[i][j]) dfs2(i,j);
	for (i=0;i<(n<<1);i++)
	for (j=0;j<(n<<1);j++) cnt[a[i][j]*2+b[i][j]]++;
	int psz=0;
	for (i=0;i<4;i++) if (cnt[i]>cnt[psz]) psz=i;
	int tot=n*n;
	for (i=0;i<(n<<1);i++)
	for (j=0;j<(n<<1);j++) if (a[i][j]*2+b[i][j]==psz&&--tot>=0) printf("%d %d\n",i,j);
	return 0;
}

Measured memory_bytes: 32512
'use strict';

function Main(input) {
  const N = Number(input.split('\n')[0]);
  const T = input.split('\n')[1].split(' ').map(x => Number(x));

  const total = T.reduce((x, y) => x + y) - N;

  console.log(total);

};

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 21192
#include<stdio.h>
 
 void fib(int);
int main(){
  int n;
  scanf("%d",&n);
  fib(n);
  return 0;
}

void fib(int n){
  int F[100],i;
  F[0]=1;
  F[1]=1;
  for(i=2; i<=n ; i++){
    F[i] = F[i-2] + F[i-1];
  }
  printf("%d\n",F[n]);
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  int v[m],soma=0;
  for(int i=0;i<m;i++){
    cin>>v[i];
    soma+=v[i];
  }
  if(soma<=n) cout<<n-soma<<"\n";
  else cout<<-1<<"\n";
  return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    double a, b, c;
    double r;
    double s, l, h;

    cin>>a>>b>>c;
    r = c / 360 * 2 * M_PI;
    s = a * b * sin(r) / 2.0;
    l = a + b + sqrt(a * a + b * b - 2 * a * b * cos(r));
    h = b * sin(r);

    cout<<setprecision(8)<<s<<" ";
    cout<<setprecision(8)<<l<<" ";
    cout<<setprecision(8)<<h<<endl;

    return 0;
}



Measured memory_bytes: 3532
#include<stdio.h>
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    char s[11];
    scanf("%s", s);
    int i;
    for(i=0;i<a;i++)
        if (s[i]<'0' || s[i]>'9')
        {
            printf("No\n");
            return 0;
        }
    if (s[a] != '-')
    {
        printf("No\n");
        return 0;
    }
    for (i = a + 1; i < a + b + 1; i++)
        if (s[i]<'0' || s[i]>'9')
        {
            printf("No\n");
            return 0;
        }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef long long ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())

int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  long double x=powl(a*b,0.5);
  if(2*x<c-a-b){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
signed main(){
int a;
  cin>>a;
  if(a==22)
    cout<<"Christmas Eve Eve Eve";
    if(a==23)
      cout<<"Christmas Eve Eve";
      if(a==24)
        cout<<"Christmas Eve";
        if(a==25)
          cout<<"Christmas";
}


Measured memory_bytes: 256
N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N+1-x):
        z = N - x - y
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            exit()

print("-1 -1 -1")

Measured memory_bytes: 3060
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    T = readline().strip()

    ans = INF
    for i in range(len(S) - len(T) + 1):
        tmp = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                tmp += 1
        if ans > tmp:
            ans = tmp

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 67496
#include <stddef.h>
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
  size_t i, r;
  string s;
  map<char, int> m;
  m['I'] = 1;
  m['V'] = 5;
  m['X'] = 10;
  m['L'] = 50;
  m['C'] = 100;
  m['D'] = 500;
  m['M'] = 1000;
  while (cin >> s) {
    for (i = r = 0; i < s.size(); i++)
      r += m[s[i]] * (m[s[i]] < m[s[i + 1]] ? -1 : 1);
    cout << r << endl;
  }
}

Measured memory_bytes: 1180
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    A, B = LI()

    for money in range(1, 2000):
        if int(money * 0.08) == A and int(money* 0.10) == B:
            print(money)
            return
    print(-1)
    return


main()



Measured memory_bytes: 6732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long hxtype;
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const ll p=998244353ll;
const int N=200005;

int main(){
	ll n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	if((a^b)&1ll)printf("%lld",min(a+b-1ll,(n<<1|1ll)-a-b)>>1);
	else printf("%lld",(b-a)>>1);
	return 0;
}

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

using namespace std;

constexpr int MAXN = 1e6 + 6, MOD = 1e9 + 7;

template<typename T>
inline void read(T& x, T f = 1, char ch = getchar()) {
    x = 0;
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

int n, m, coprime;
array<int, MAXN> a, suf;
vector<int> divisor[MAXN];

int cnt[MAXN];

signed main() {
    read(n);
    for (int i = 1; i <= n; i++) read(a[i]);
    coprime = a[1];
    for (int i = 2; i <= n; i++) coprime = __gcd(coprime, a[i]);
    for (int i = 2; i <= 1e6; i++)
        for (int j = i; j <= 1e6; j += i)
            divisor[j].push_back(i);
    bool judge = true;
    for (int i = n; i >= 1; i--) {
        for (auto& c : divisor[a[i]]) {
            if (cnt[c]) {
                judge = false;
                break;
            }
        }
        if (judge == false) break;
        for (auto& c : divisor[a[i]]) {
            cnt[c]++;
        }
    }
    if (judge) {
        puts("pairwise coprime");
    } else if (coprime == 1) puts("setwise coprime");
    else puts("not coprime");
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<string>s(n);
  for(int i=0;i<n;i++) cin>>s[i];
  sort(s.begin(),s.end());
  string ss=s[0];
  int ans=1;
  for(int i=1;i<n;i++){
    if(s[i]!=ss){
      ans++;
      ss=s[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(ll i=0;i<N;++i)
const ll INF = 1LL<<60;

int main(){
    ll N; cin >> N;
    vector<ll> C(N),S(N),F(N),ans(N);
    rep(i,N-1) cin >> C[i] >> S[i] >> F[i];
    rep(i,N-1){
        ll arrival = C[i] + S[i];
        for(int j=i+1;j<N-1;j++){
            ll departure = S[j];
            if(arrival > departure) arrival += (((arrival - departure - 1) / F[j] + 1) * F[j] - (arrival - departure)) + C[j];
            else arrival = departure + C[j];
        }
        ans[i] = arrival;
    }
    for(auto it : ans){
        cout << it << endl;
    }
}

Measured memory_bytes: 256
/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define pii pair<pair <int, int>, int>
#define vi vector <int>
const ll nmax=1e5+2;
int n, m;
pii v[100001];
int mx[100001], ans;
pi seg[400001];

void Upd(int nod, int l, int r, int p, pi v){
    if(l>p || r<p) return;
    if(l==r){
        seg[nod]=v;
        return;
    }
    int mid=(l+r)/2;
    Upd(2*nod,l,mid,p,v);
    Upd(2*nod+1,mid+1,r,p,v);
    seg[nod]=max(seg[2*nod], seg[2*nod+1]);
}

pi Qry(int nod, int l, int r, int lt, int rt){
    if(l>rt || r<lt) return {0, 0};
    if(l>=lt && r<=rt) return seg[nod];
    else{
        int mid=(l+r)/2;
        return max(Qry(2*nod,l,mid,lt,rt), Qry(2*nod+1,mid+1,r,lt,rt));
    }
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n>>m;
    for(int i=1, a, b; i<=n; i++){
        cin>>a>>b;
        v[i]={{a, b}, i};
    }
    //cout<<endl;
    sort(v+1, v+1+n);
    for(int i=1; i<=n; i++) Upd(1, 1, n, i, {v[i].x.y, i});
    for(int i=m-1; i>=0; i--){
        pi xd=Qry(1, 1, n, 1, lower_bound(v+1, v+n+1, make_pair(make_pair(m-i+1, 0), 0))-v-1);
        ans+=xd.x;
        //cout<<i<<" "<<ans<<endl;
        Upd(1, 1, n, xd.y, {0, 0});
    }
    cout<<ans;
}


Measured memory_bytes: 4992
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

const pos = (x, y) => {
    return { x : x, y : y};
};

const div = (p1, p2, n) => {
    if (n === 0) return [];
    const cos = Math.cos(Math.PI / 3.0);
    const sin = Math.sin(Math.PI / 3.0);

    const s = pos((2 * p1.x + p2.x) / 3, (2 * p1.y + p2.y) / 3);
    const t = pos((p1.x + 2 * p2.x) / 3, (p1.y + 2 * p2.y) / 3);
    const u = pos( (t.x - s.x) * cos - (t.y - s.y) * sin + s.x
                 , (t.x - s.x) * sin + (t.y - s.y) * cos + s.y
                 );
    
    return div(p1, s, n - 1)
               .concat(s)
               .concat(div(s, u, n - 1))
               .concat(u)
               .concat(div(u, t, n - 1))
               .concat(t)
               .concat(div(t, p2, n - 1));
};

const solve = (n) => {
    if (n === 0) return [pos(0.0, 0.0), pos(100.0, 0.0)];
    return [pos(0.0, 0.0), ...div(pos(0.0, 0.0), pos(100.0, 0.0), n), pos(100.0, 0.0)];
};
solve(parseInt(line[0]))
    .forEach(p => {
        console.log(p.x.toFixed(8), p.y.toFixed(8));
    });



Measured memory_bytes: 21660
count = input().split()
switch = int(count[0])
bulb = int(count[1])

condition = []

for i in range(bulb):
    condition.append(input().split()[1:])

# 全ての可能なスイッチの組み合わせ
candidate = []
for j in range(2**switch):
    num = str(bin(j))[2:]
    if len(num) < (switch):
        num = '0'*(switch-len(num)) + num
    candidate.append(num)

wanted = input().split()

bad_count = 0

# 条件に合わないものから消していく
for i in range(len(candidate)):
    judge = 0
    for j in range(len(condition)):
        tasumono = [int(k)-1 for k in condition[j]]
        sum_switch = 0
        for l in tasumono:
            sum_switch += int(candidate[i][l])
        if sum_switch % 2 != int(wanted[j]):
            judge += 1
    if judge != 0:
        bad_count += 1

print(2**switch-bad_count)


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main 
{
	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) 
	{
//		System.out.println("START");
		
		
		int dataSetNum = scan.nextInt();
		List<DataSet> dataSets = new ArrayList<DataSet>();
		
		for(int i = 0; i < dataSetNum; i++)
		{
			dataSets.add(new DataSet());
		}
		for(int i = 0; i < dataSetNum; i++)
		{
			System.out.println(dataSets.get(i).getAnswer());
		}

	}

	static class Method
	{
		int type; //0 for tan, 1 for fuku/compound
		double interest;
		int cost;
		DataSet dataSet;
			
		public Method(DataSet dataSet)
		{
//			System.out.println("Constructing method");
			
			type = scan.nextInt();
			interest = scan.nextDouble();
			cost = scan.nextInt();
			
//			type = Integer.parseInt(scan.next());
//			interest = Double.parseDouble(scan.next());
//			cost = Integer.parseInt(scan.next());
			this.dataSet = dataSet;
			
//			System.out.println("Method constructed: type " + type + " interest " + interest + " cost " + cost);
		}
		
		public int calculate()
		{
			double money = dataSet.startingMoney;
			double celengan = 0;
			
			double curInterest;
			
			for(int year = 0; year < dataSet.years; year++)
			{
				curInterest =  Math.floor(money * interest);
				
				if(type == 0)
				{
					celengan += curInterest;
				}
				else if(type == 1)
				{
					money += curInterest;
				}
				
				money -= cost;
			}
			
			return (int) (money + celengan);
		}
	}
	
	static class DataSet
	{
		double startingMoney;
		double years;
		List<Method> methods = new ArrayList<Method>();
		double numOfMethods;
		
		int answer;
		
		public int getAnswer()
		{
			return answer;
		}

		public DataSet()
		{
			startingMoney = scan.nextInt();
			years = scan.nextInt();
			numOfMethods = scan.nextInt(); 
			
			double biggestMoneyYet = -99999;
			for(int i = 0; i < numOfMethods; i++)
			{
				methods.add(new Method(this));
				
				int ret = methods.get(i).calculate();
				
				if(i == 0) {biggestMoneyYet = ret;}
				else
				{
					if(ret > biggestMoneyYet) {biggestMoneyYet = ret;}
				}
			}
			
			answer = (int) Math.floor(biggestMoneyYet);
			//constructor
		}
	}
}


Measured memory_bytes: 55016
import math
def resolve():
    N, D = map(int, input().split())
    count = 0
    point = []
    for i in range(N):
        x, y = map(int, input().split())
        d = math.sqrt(x**2 + y**2)
        if D >=d:
            count += 1
    print(count)
resolve()

Measured memory_bytes: 69928
#include<stdio.h>
int main(void)
{
	int i;
	char s[19];
	scanf("%s", s);
	for(i=0; i<19; i++)
	{
		if(s[i]==',')
		printf(" ");
		else
		printf("%c", s[i]);
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 128
// Contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include"iostream"
#include"string"
#include"vector"
#include"algorithm"

using namespace std;

int main()
{
	/*int n,k;
	cin >> n;
	vector<char>s(n);
	for (int j = 0; j < n; j++)  cin >> s[j];
	cin >> k;
	for (int i = 0; i < n; i++)
	{
		if (s[i] != s[k-1]) {
			s[i] = '*';
		}
	}

	for (int l = 0; l < n; l++)
	{
		cout << s[l] ;
	}*/
	
	int m;
	string d;
	cin >> m >> d;

	if (m < 3200) {
		cout << "red" << endl;
	}
	else cout << d << endl;

}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll      long long int   
#define ld      long double
#define pii     pair<int ,int>
#define pld     pair<ld ,ld>
#define all(v)  v.begin(),v.end()
#define F       first
#define S       second
#define mod     1000000007
#define pb      push_back
#define MP      make_pair
#define mset(x) memset(x, 0, sizeof(x));
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inf     1000000000000007
const int N=200006;
string s;
ll k,n,i,ans1,ans2,ans3;
void run(){

    cin>>s;
    cin>>k;
    n=s.length();
    string temp=s;
    set<char>ss;
    for(auto it:s) ss.insert(it);
    if((ll)ss.size()==1)
    {
        cout<<(k*n)/2;
        return;
    }
    if(n==1)
    {
        cout<<k/2;
        return;
    }
    for(i=0;i<n-1;i++)
    {
        if(s[i]==s[i+1]) 
        {
            s[i+1]='0';
            ans1++;
        }
    }
    s=temp+temp;
    for(i=0;i<2*n;i++)
    {
        if(s[i]==s[i+1])
        {
            s[i+1]='0';
            ans2++;
        }
    }
    s=temp+temp+temp;
    for(i=0;i<3*n;i++)
    {
        if(s[i]==s[i+1])
        {
            s[i+1]='0';
            ans3++;
        }
    }
    
    ll d=ans2-ans1;
    ll ans=ans1+(k-1)*d;
    cout<<ans;

    
}
 
 
void setup(){
    ios;
    //cout << setprecision(20);
    // #ifndef ONLINE_JUDGE
    // freopen("input", "r", stdin);
    // freopen("output", "w", stdout);
    // #endif
}
 
signed main(){
    setup();
    int tests = 1;
    //cin >> tests;
    for(int i = 1; i <= tests; i++) run();
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD (LL)(1e9+7)

int main(){
	int a;
	cin >> a;
	string S;
	cin >> S;
	if(a < 3200) cout << "red" << endl;
	else cout << S << endl;
}

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

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

    vector<int> b(n);
    for (int i = 0; i < n - 1; i++) cin >> b[i];

    int ans = b[0] + b[n - 2];

    for (int i = 0; i < n - 2; i++) {
    	ans += min(b[i], b[i + 1]);
    }	
    cout << ans << "\n";
    return 0;
}

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

int main(void){
  int W,H,N,xmax,xmin,ymax,ymin;
  cin >> W >> H >> N;
  xmax=ymax=0;
  xmin=W;
  ymin=H;
  for(int i=0;i<N;i++){
    int X,Y,a;
    cin >> X >> Y >> a;
    if(a==1 && xmax<X) xmax=X;
    else if(a==2 && xmin>X) xmin=X;
    else if(a==3 && ymax<Y) ymax=Y;
    else if(a==4 && ymin>Y) ymin=Y;
  }
  if(xmin>xmax && ymin>ymax) cout << (xmin-xmax)*(ymin-ymax) << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 768
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

map<string, int> table;

int main()
{
	string word, frequent, longest="";
	int n = 0;
	while (cin >> word) {
		table[word]++;
		if (table[word] > n) {
			n = table[word];
			frequent = word;
		}
		if (word.size() > longest.size()) {
			longest = word;
		}
	}
	cout << frequent << " " << longest << endl;
	return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll inf=1000000000000000000;
  ll n,W;cin>>n>>W;
  ll w[n],v[n];
  for(ll i=0;i<n;i++)cin>>w[i]>>v[i];
  ll dp[n+1][100001];
  for(ll i=0;i<=n;i++)for(ll j=0;j<=100000;j++)dp[i][j]=inf;
  dp[0][0]=0;
  ll ans=0;
  for(ll i=0;i<n;i++){
    for(ll j=0;j<=100000;j++){
      if(dp[i][j]==inf)continue;
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      if(dp[i][j]+w[i]<=W){
        dp[i+1][j+v[i]]=min(dp[i+1][j+v[i]],dp[i][j]+w[i]);
        ans=max(ans,j+v[i]);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 79104
def c_flip(N, M):
    if N == 1 and M == 1:
        return 1
    elif N == 1 or M == 1:
        return max(N, M) - 2
    elif N == 2 or M == 2:
        return 0
    else:
        return N * M - (N * 2 + M * 2 - 4)
    return None

N,M = [int(i) for i in input().split()]
print(c_flip(N, M))

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
  int n , m , k;
  scanf("%d %d %d",&n ,&m ,&k);

  long long a , b;
  long long atas[200010] = {0} , btas[200010] = {0};

  for(int i = 0;i < n;i ++){
    scanf("%lld",&a);
    atas[i+1] = atas[i] + a;
  }
  atas[n+1] = 10000000000;

  for(int i = 0;i < m;i ++){
    scanf("%lld",&b);
    btas[i+1] = btas[i] + b;
  }
  btas[m+1] = 10000000000;

  int ans = 0 , count = 0;
  long long zan;

  for(int i = 0;i <= n;i ++){
    zan = k - atas[i];
    if(zan < 0){
      i += n+1;
    }
    else{
      int min = 0 , max = m+1 , mid;
      while(max - min > 1){
        mid = (max + min)/2;
        if(btas[mid] > zan){
          max = mid;
        }
        else{
          min = mid;
        }
      }
      count = i + min;
      if(ans < count){
        ans = count;
      }
    }
    
  }

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

  return 0;
}

Measured memory_bytes: 4848
#include<stdio.h>
#include <string.h>

int main() {

  int i,j=0, len, a[26];
  char s[1200];

  for(i = 0; i < 26; i++) {
    a[i] = 0;
  }

  while(scanf("%c", &s[j])==1) j++; 
  len = j;
  
  for(i = 0; i < len; i++) {
    if((s[i] >= 'A' && s[i] <= 'Z') || (s[i] >= 'a' && s[i] <= 'z')) {
      
      if(s[i] >= 'A' && s[i] <= 'Z') {
	s[i] += 'a' - 'A';
      }

      a[s[i]-'a'] += 1;

    }
  }

  for(i = 0; i < 26; i++) {
    printf("%c : %d\n", 'a'+i,a[i]);
  }

  return 0;

}

Measured memory_bytes: 540
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>

using namespace std;

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

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		vector<int> S;
		vector<int> S_old;
		for(int i=0;i<n;i++){
			int s;
			scanf("%d",&s);
			S.push_back(s);
		}

		int c=0;
		while(1){
			map<int,int> freq;
			S_old = S;
			for(int i=0;i<S.size();i++){
				freq[S[i]]++;
			}

			for(int i=0;i<S.size();i++){
				S[i] = freq[S[i]];
			}

			if(S == S_old) break;
			c++;
		}

		cout << c << endl;
		for(int i=0;i<S.size();i++){
			printf("%d%s",S[i],i==S.size()-1 ? "\n" : " ");
		}

	}
}

Measured memory_bytes: 0
#ifdef LOCAL_EXEC
#include "include.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define trace(...)
#endif

using LL = long long;

bool check_bound(vector<int> a, vector<int> b) {
	const int n = a.size();
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for (int i = 0; i < n; i++) {
		if (a[i] > b[i]) return false;
	}
	return true;
}
bool check_unq(vector<int> a, vector<int> b) {
	if (set<int>(a.begin(), a.end()).size() < a.size()) return true;
	if (set<int>(b.begin(), b.end()).size() < b.size()) return true;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for (int i = 1; i < (int) a.size(); i++) {
		if (a[i] <= b[i - 1]) return true;
	}
	return false;
}

bool check_cycle(vector<int> a) {
	set<int> vals(a.begin(), a.end());
	map<int, int> compr;
	for (int x: vals) {
		int sz = compr.size();
		compr[x] = sz;
	}
	for (int& x: a) x = compr[x];
	int len = 0, n = a.size();
	vector<bool> vis(n, false);
	for (int idx = 0; !vis[idx]; idx = a[idx]) {
		vis[idx] = true;
		len++;
	}
	return len == n;
}

bool check(vector<int> a, vector<int> b) {
	if (!check_bound(a, b)) return false;
	if (check_unq(a, b)) return true;
	return !check_cycle(a);
}

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

	int n; cin >> n;
	vector<pair<int, int>> vals(n);
	for (int i = 0; i < n; i++) cin >> vals[i].second;
	for (int i = 0; i < n; i++) cin >> vals[i].first;
	sort(vals.begin(), vals.end());

	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		a[i] = vals[i].second;
		b[i] = vals[i].first;
	}

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

	return 0;
}


Measured memory_bytes: 12332
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def eratosthenes_sieve(n):
    """ 素数列挙(エラトステネスの篩) """

    table = [0] * (n + 1)
    prime_list = []
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
    return prime_list

N = 1000000
primes = eratosthenes_sieve(N)
A = [0] * 1000000
for p in primes:
    A[p] = 1
acc = list(accumulate(A))

while True:
    try:
        a = INT()
        print(acc[a])
    except:
        # 入力が取れなかったら終了
        break



Measured memory_bytes: 58632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif





ll n;
const ll MAX = 200000;

vector<int> v[MAX];

ll ct = 0;

void dfs( int node, int parent ){
	// [L,R]がこのノードを含み、親を含まない場合の数をカウントする
	
	if ( node < parent ){
		ct += (node+1) * (ll)(parent-node);
	}
	else {
		ct += (n-node) * (ll)(node-parent);
	}
	
	
	for ( auto next_node : v[node] ){
		if ( next_node == parent )
			continue;
		dfs( next_node, node );
	}
}

int main(){
	cin >> n;
	rep(i,n-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		
		v[a].push_back(b);
		v[b].push_back(a);
	}
	
	dfs(0,n);
	
	cout << ct << endl;
	
	return 0;
}




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

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    vector<long long> a(n);
    vector<long long> b(n);
    long long sum=0;
    for(int i=0; i<n; i++)
    {
        scanf("%lld %lld", &a[i], &b[i]);
        sum+=a[i];
    }
    long long ans=0;
    for(int i=0; i<n; i++)
    {
        if(a[i]>b[i]) ans=max(ans,sum-b[i]);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 512
/**
 *    Author: "Robin Singh" !!
 *    rob_in_1
**/

#include <bits/stdc++.h>
using namespace std;

#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     
#define bk(i, j, k) for(int i = j-1; i >= k; i--)
#define mem(ptr, val)  memset(ptr, val, sizeof ptr)
#define sbit(n)  __builtin_popcount(n)
#define nl "\n"

typedef long double ld;
typedef pair<int, int> pii;
typedef vector <int> vi;
typedef vector < pair<int,int> > vpii;
const long double eps = 1e-9;
const int mod = 1e9+7;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

//*********************************!Template Ends Here!**********************************//

const int nn = 1e3+5;
int dist[nn][nn];
string s[nn];
int h, w;
queue <pii> q;

void bfs(){
    while(! q.empty()){
        auto p = q.front();
        q.pop();
        int i = p.ff;
        int j = p.ss;

        for(int ii = 0; ii < 4; ii++){
            int x = i + dir[ii].ff, y = j + dir[ii].ss;

            if(x >= 0 and y >= 0 and x < h and y < w and dist[x][y] == -1){
                dist[x][y] = 1 + dist[i][j];
                q.push({x, y});
            }
        }
    }
}

void robin(){
    cin >> h >> w;
    fr(i, 0, h) cin >> s[i];
    int ans = 0;
    memset(dist, -1, sizeof dist);

    fr(i, 0, h){
        fr(j, 0, w){
            if(s[i][j] == '#') {
                dist[i][j] = 0;
                q.push({i, j});
            }
        }
    }
    bfs();
    fr(i, 0, h) fr(j, 0, w) ans = max(ans, dist[i][j]);
    cout << ans;
}

int32_t main(){
    // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        robin();
    }
    return 0;
}

Measured memory_bytes: 25524
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int y = sc.nextInt();
        String ans = "";
        int max = n * 5000;

        if (n * 10000 >= y) {
            calc : for (int i = y / 10000; i >= 0 ; i--) {
                int sum = i * 10000;
                if (y - sum > max) {
                    break;
                }
                for (int j = 0; j <= (n - i) ; j++) {
                    int value = sum;
                    value += j * 5000;
                    int k = n - (i + j);
                    value += k * 1000;
                    if (value == y) {
                        ans = i + " " + j + " " + k;
                        break calc;
                    }
                }
            }
        }

        if (ans.isEmpty()) {
            ans = "-1 -1 -1";
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x,y;
  cin >> x >> y;
  int c=0;
  for(int i = 0;i < x;i++){
    int g;
    cin >> g;
    if(g>=y)c++;
  }
  cout << c << endl;
      
  
}


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

const int MOD = 1000000007;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    string res = "";

    if (a != b) {
        int m = min(a, b);
        int mi = max(a, b);
        rep(i, mi) res += to_string(m);
    }
    else {
        rep(i, a) res += to_string(a);
    }
    
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256