akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    int h, w, k; cin >> h >> w >> k;
    char a[h][w];

    int b = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
            if (a[i][j] == '#') {
                ++b;
            }
        }
    }
    
    int n = h + w;
    int ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
        vector<pii> v;
        int cnt = 0;
        for (int j = 0; j < n; ++j) {
            if (i & (1 << j)) {
                if (j >= h) {
                    for (int x = 0; x < h; ++x) {
                        if (a[x][j % w] == '#') {
                            v.push_back({x, j % w});
                            a[x][j % w] = '.';
                            ++cnt;
                        }
                    }

                } else {
                    for (int x = 0; x < w; ++x) {
                        if (a[j][x] == '#') {
                            v.push_back({j, x});
                            a[j][x] = '.';
                            ++cnt;
                        }
                    }
                }
            }
        }

        if (b - cnt == k) {
            ++ans;
        }
        for (pii p : v) {
            a[p.first][p.second] = '#';
        }
        v.clear();
    }
    
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1; 
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 3648
#133_E
import sys
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7
n, k = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
    
def dfs(frm, cur):
    if frm == -1:
        color_num = k - 1
    else:
        color_num = k - 2
        
    mul = 1
    for to in edges[cur]:
        if to == frm:
            continue
        mul *= color_num
        mul %= mod
        color_num -= 1
        
    for to in edges[cur]:
        if to == frm:
            continue
        mul *= dfs(cur, to)
        mul %= mod
    
    return mul

print(k * dfs(-1, 0) % mod)

Measured memory_bytes: 87340
N, P = map(int, input().split())
A = list(map(int, input().split()))

k = len(list(filter(lambda x: x % 2 == 0, A)))
l = len(list(filter(lambda x: x % 2 == 1, A)))

if k == N:
    print(2 ** N if P == 0 else 0)
else:
    print(2 ** (N - 1))


Measured memory_bytes: 2940
H,N=list(map(int,input().split()))
M=[list(map(int,input().split())) for i in range(N)]
A=[M[i][0] for i in range(len(M))] #AT
B=[M[i][1] for i in range(len(M))] #MP


dp=[0]*(max(A)+H)

for h in range(1,H+1):
    dp[h]=min(dp[h - a] + b for a, b in zip(A,B))  

print(dp[H])

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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int MAXN=2010;

char str[MAXN];
int mp[MAXN][MAXN],up[MAXN][MAXN],down[MAXN][MAXN],L[MAXN][MAXN],R[MAXN][MAXN],n,m;

int main()
{
	int Ans=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",str+1);
		for(int j=1;j<=m;j++)
			mp[i][j]=str[j]=='#';
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(mp[i][j])
				up[i][j]=L[i][j]=0;
			else
			{
				up[i][j]=up[i-1][j]+1;
				L[i][j]=L[i][j-1]+1;
			}
		}
	for(int i=n;i;i--)
		for(int j=m;j;j--)
		{
			if(mp[i][j])
				R[i][j]=down[i][j]=0;
			else
			{
				down[i][j]=down[i+1][j]+1;
				R[i][j]=R[i][j+1]+1;
			}
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(!mp[i][j])
				Ans=max(Ans,L[i][j]+R[i][j]+up[i][j]+down[i][j]-3);
	printf("%d\n",Ans);
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"


int main(){
    int h,w;
    while(cin>>h>>w){
        if(h==0&&w==0) break;
        REP(i,h){
            REP(i,w){
                cout <<'#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
uses crt,math;
var a,b:longint;
    i,j:qword;
begin
        clrscr;
        readln(a,b);
        i:=a;
        j:=b;
        while (true) do begin
                if (a=0) or (b=0) then break;
                if (a>b)  then a := a mod b else
                        if (b>a) then b := b mod a else break;
        end;
        write((i*j)div max(a,b));
        readln
end.



Measured memory_bytes: 128
##input##
Nvar = int(input())
T_list = list(map(lambda x:int(x),input().split(" ")))
M_var = int(input())
P_list = []
for i in range(M_var):
    P_list.append(list(map(lambda x:int(x),input().split(" "))))
##

for d_num in range(M_var):
    time_sum = 0
    for q_num in range(Nvar):
        if q_num==P_list[d_num][0]-1:
            time_sum += P_list[d_num][1]
        else:
            time_sum += T_list[q_num]
    print(time_sum)


Measured memory_bytes: 3060
A,B,C,D=map(int,input().split())
m=998244353
d=[[0]*(D+1) for _ in range(C+1)]
d[A][B]=1
for i in range(A,C+1):
 for j in range(B,D+1):
        d[i][j]+=(d[i][j-1]*i+d[i-1][j]*j-d[i-1][j-1]*(i-1)*(j-1))%m
print(d[C][D])

Measured memory_bytes: 133584
/*
 * 2509.cc: Sim Forest 2013
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

bool ok(int ct, int wn, int tr) {
  int h = ct / 60 % 24, d = (ct / (24 * 60)) % 7;
  return
    ((wn == -1 || wn == d) &&
     (tr == 0 ||
      (tr == 1 && h >= 6 && h < 18) ||
      (tr == 2 && (h < 6 || h >= 18))));
}

/* main */

int main() {
  for (;;) {
    int s, n, t, p, m;
    string wd, tm;
    cin >> s >> n >> t >> wd >> tm >> p >> m;
    if (s == 0) break;

    int wn = -1;
    if (wd == "Sun") wn = 0;
    else if (wd == "Mon") wn = 1;
    else if (wd == "Tue") wn = 2;
    else if (wd == "Wed") wn = 3;
    else if (wd == "Thu") wn = 4;
    else if (wd == "Fri") wn = 5;
    else if (wd == "Sat") wn = 6;

    int tr = 0;
    if (tm == "Day") tr = 1;
    else if (tm == "Night") tr = 2;

    double pn = pow((double)(p - 1) / p, n);
    double minp = 1.0;
    
    for (int st = 0; st < 7 * 24 * 60; st++) {
      double pmul = 1.0;
      for (int i = 0; i < m; i++) {
	int ct0 = st + i * t, ct1 = ct0 + s;

	if (ok(ct0, wn, tr) && ok(ct1, wn, tr)) pmul *= pn;
      }
      if (minp > pmul) minp = pmul;
    }

    printf("%.10lf\n", 1.0 - minp);
  }
  return 0;
}

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

int main() {
    //入力
    string S;
    cin >> S;

    //処理
    vector<string> vec{"dream", "dreamer", "erase", "eraser"};
    string T;

    // 反転させると、各要素で前方一致しなくなるから
    reverse(S.begin(), S.end());

    for (string& element : vec) {
        reverse(element.begin(), element.end());
    }

    while(true) {
        bool flag = false;
        for (string& element : vec) {
            string current = T + element;
            if(S.compare(current) == 0) {
                //OK
                cout << "YES" << endl;
                return 0;
            }
            if(current.size() <= S.size() && S.compare(0, current.size(), current) == 0) {
                // 前方一致
                T = current;
                flag = true;
                break;
            }
        }

        if(!flag) {
            cout << "NO" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3976
from collections import Counter
import math
n = int(input())
pp = []
a0 = 0
b0 = 0
z = 0

for i in range(n):
  a,b = map(int,input().split())
  if a==0 and b==0:
    z += 1
  elif a==0:
    a0 += 1
  elif b==0:
    b0 += 1
  else:
    gomi = math.gcd(a,b)
    if a < 0:
      a *= -1
      b *= -1
    pp.append((a//gomi,b//gomi))
    
mod = 10**9+7
a0 %= mod
b0 %= mod
z %= mod
p = Counter(pp)
r = 1
s = set()

for i,j in p.keys():
  if (i,j) in s:
    continue
  ans = p[(i,j)]
  if j < 0:
    f = (-j,i)
  else:
    f = (j,-i)
  chk = p[f]
  r *= (pow(2,ans,mod)+pow(2,chk,mod)-1)%mod
  r %= mod
  s.add(f)
r *= (pow(2,a0,mod)+pow(2,b0,mod)-1)%mod
r %= mod
print((r+z-1)%mod)

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if((a == b && b != c) || (b == c && c != a) || (c == a && a != b)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

using namespace std;

using ull = unsigned long long;

ull solve(string N, ull K) {
    vector<vector<vector<ull>>> dp(N.length() + 1, vector<vector<ull>>(2, vector<ull>(K + 2, 0)));

    dp[0][0][0] = 1;

    int D;
    for (int i = 0; i < N.length(); i++) {
        D = N[i] - '0';
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k <= K; k++) {
                for (int d = 0; d <= (j ? 9 : D); d++) {
                    dp[i + 1][j || (d < D)][k + (d == 0 ? 0 : 1)] += dp[i][j][k];
                }
            }
        }
    }

    ull ans = dp[N.length()][0][K] + dp[N.length()][1][K];
    return ans;
}


int main() {
    string N;
    ull K;
    cin >> N >> K;
    cout << solve(N, K) << endl;
}


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

int main() {
    int N,M,K;
    cin >> N >> M >> K;
    vector<ll> A(N+1),B(M+1);
    
    rep(i,N){
        cin >> A[i+1];
    }
    rep(i,M){
        cin >> B[i+1];
    }
    rep(i,M){
        B[i+1] += B[i];
    }

    int ans = 0;
    ll sum = 0;
    int j = M;
    rep(i,N+1){
        sum += A[i];
        if(sum > K){
            break;
        }
        while(true){
            if(sum + B[j] <= K){
                break;
            }
            if(j == 0){
                break;
            }
            j--;
        }
        ans = max(ans, i+j);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6428
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/priank/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    cin>>n>>m;
    n-=m;
    n%=2;

    cout<<(n%2?"Borys":"Alice")<<endl;

}   aryanc403();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int N;
  int S=0;
  scanf("%d",&N);
  for(int i=1; i<10; i++){
    for(int j=1; j<10; j++){
      if(i*j==N){
        S=S+1;
      }
    }
  }
  if(S>0){
    printf("Yes");
  }
  if(S==0){
    printf("No");
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int MAX = (2e4)+1;

int n, p[MAX], b[MAX];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> p[i];
	b[p[1]] = n*n;
	for(int i = 2; i <= n; i++) b[p[i]] = b[p[i-1]]-n*(p[i]-p[i-1])+1;
	for(int i = 1; i <= n; i++) cout << n*i << ' ';
	cout << endl;
	for(int i = 1; i <= n; i++) cout << b[i] << ' ';
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 100000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int main()
{
    int n,x,t; scanf("%d%d%d",&n,&x,&t);
    printf("%d\n",(n+x-1)/x*t);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii ;
const int mod = 1e9 + 7;

ll binPow(ll x, ll y, ll md = mod){
    ll res = 1;
    x %= mod;
    while(y){
        if(y & 1){
            res = (res * x) % mod;
        }
        y >>= 1;
        x = (x * x) % mod;
    }
    return res;
}

void solve(){
   ll a, b;
   cin >> a >> b;
   cout << a * b << "\n";
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3652
n = int(input())
s = [input() for i in range(n)]
a = s.count("AC")
b = s.count("WA")
c = s.count("TLE")
d = s.count("RE")
print("AC x "+str(a))
print("WA x "+str(b))
print("TLE x "+str(c))
print("RE x "+str(d))

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

int main() {

 int a,b,c;
  cin>>a>>b>>c;
  
  int max,mid,min;
  int x,y;
  
  if(a>=b&&b>=c){max=a;mid=b;min=c;}
  else if(a>=b&&c>=b&&a>=c){max=a;mid=c;min=b;}
  else if(b>=a&&a>=c){max=b;mid=a;min=c;}
  else if(b>=a&&c>=a&&b>=c){max=b;mid=c;min=a;}
  else if(c>=a&&a>=b){max=c;mid=a;min=b;}
  else{max=c;mid=b;min=a;}
 
  int count=0;
  
  while(max-1>mid){mid=mid+2;count++;}
  while(max-1>min){min=min+2;count++;}
  
  if(max==mid&&max==min){cout<<count<<endl;}
  else if(max>mid&&max>min){cout<<count+1<<endl;}
  else{cout<<count+2<<endl;}
  

}



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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 50);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b, q;
    vector<ll> s, t, x;
    cin >> a >> b >> q;
    for (int i = 0; i < a; i++)
    {
        int tmp;
        cin >> tmp;
        s.push_back(tmp);
    }
    for (int i = 0; i < b; i++)
    {
        int tmp;
        cin >> tmp;
        t.push_back(tmp);
    }
    for (int i = 0; i < q; i++)
    {
        int tmp;
        cin >> tmp;
        x.push_back(tmp);
    }

    for (int i = 0; i < q; i++)
    {
        int xx = x[i];
        int ss[] = {INF, INF};
        int tt[] = {INF, INF};
        auto itr = lower_bound(s.begin(), s.end(), xx);
        auto itr2 = lower_bound(t.begin(), t.end(), xx);
        if (*itr == xx)
        {
            ss[0] = xx;
            ss[1] = xx;
        }
        else
        {
            if (itr != s.end())
            {
                ss[1] = *itr;
            }
            if (itr != s.begin())
            {
                ss[0] = *(itr - 1);
            }
        }
        if (*itr2 == xx)
        {
            tt[0] = xx;
            tt[1] = xx;
        }
        else
        {
            if (itr2 != t.begin())
                tt[0] = *(itr2 - 1);
            if (itr2 != t.end())
                tt[1] = *(itr2);
        }
        // cout << ":" << ss[0] << "," << ss[1] << endl;
        // cout << ":" << tt[0] << "," << tt[1] << endl;
        int l1 = abs(xx - ss[0]) + abs(ss[0] - tt[0]);
        int l2 = abs(xx - ss[1]) + abs(ss[1] - tt[0]);
        int l3 = abs(xx - ss[0]) + abs(ss[0] - tt[1]);
        int l4 = abs(xx - ss[1]) + abs(ss[1] - tt[1]);
        int l5 = abs(xx - tt[0]) + abs(ss[0] - tt[0]);
        int l6 = abs(xx - tt[1]) + abs(ss[0] - tt[1]);
        int l7 = abs(xx - tt[0]) + abs(ss[1] - tt[0]);
        int l8 = abs(xx - tt[1]) + abs(ss[1] - tt[1]);
        cout << min(min(min(l1, l2), min(l3, l4)), min(min(l5, l6), min(l7, l8))) << endl;
    }
}


Measured memory_bytes: 3828
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////
int main(){
    int n;
    cin >> n;
    ll ans = 0;
    int a = n - 1;
    for (int i = 1;i <= a;i++){
        ans += a/i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

void solve() {
    cini(x);
    int ans=8;
    if(x<=599)
        ans=8;
    else if(x<=799)
        ans=7;
    else if(x<=999)
        ans=6;
    else if(x<=1199)
        ans=5;
    else if(x<=1399)
        ans=4;
    else if(x<=1599)
        ans=3;
    else if(x<=1799)
        ans=2;
    else if(x<=1999)
        ans=1;
    else
        assert(false);

    cout<<ans<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3688
#include<iostream>
#include<stdio.h>
#include<cctype>
#include<string>

using namespace std;

int main()
{
  char ch;
  int counter[26]={};
  while (cin>>ch){
    // ここで ch がアルファベットなら、数える
    ch=tolower(ch);
    if(isalpha(ch)){
      int num = ch - 'a';  // 文字 ch の番号
      counter[num]++;}
  }
  for(int i=0;i<26;i++){
    cout<<(char)('a'+i)<<" : "<<counter[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3112
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug (fprintf(stderr,"orzyrt\n"),fflush(stderr))
	#define debug(__a...) (fprintf(stderr,__a),fflush(stderr))
#else
	#define Debug ('orzyrt')
	#define debug(__a...) ('orzyrt')
#endif
inline void Compile(R char *s){
	char com[111];
	sprintf(com,"g++ %s.cpp -lm -o %s",s,s);
	system(com);
}
inline void setfile(R char *s){
	char inname[111],outname[111];
	sprintf(inname,"%s.in",s);
	sprintf(outname,"%s.out",s);
	freopen(inname,"r",stdin);
	freopen(outname,"w",stdout);
}
#ifdef __DEBUG__
	#define setfile(__a) (1)
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline TT cmin(R TT &a,R TT b){(b<a)&&(a=b);}
template<class TT>inline TT cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

namespace Night{
	int n;
	int x[1111],y[1111];
	vector<int>ans;
	int main(){
		read(n);
		for(R int i=1;i<=n;++i){
			read(x[i]);read(y[i]);
			if(abs(x[i])+abs(y[i])&1^abs(x[1])+abs(y[1])&1){
				cout<<-1;
				return 0;
			}
		}
		for(R int i=0;i<31;++i)ans.push_back(1<<i);
		if(abs(x[1])+abs(y[1]) &1 ^1)ans.push_back(1);
		sort(ans.begin(),ans.end(),greater<int>());
		printf("%ld ",ans.size());
		for(R auto i:ans)printf("%d ",i);
		puts("");
		for(R int i=1;i<=n;++i){
			for(R auto j:ans){
				if(Abs(x[i])>Abs(y[i])){
					if(x[i]>0){
						x[i]-=j;
						putchar('R');
					}else{
						x[i]+=j;
						putchar('L');
					}
				}else{
					if(y[i]>0){
						y[i]-=j;
						putchar('U');
					}else{
						y[i]+=j;
						putchar('D');
					}
				}
			}
			puts("");
		}
		return 0;
	}
}
int main(){
	return Night::main();
}

Measured memory_bytes: 256
package main
import(
  "fmt"
)
func main(){
  var s string
  var i, n int
  fmt.Scan(&s)
  ans:=0
  n=len(s)
  for i=0;i<n/2;i++{
    if s[i]!=s[n-i-1]{
      ans++
    }
  }
  fmt.Println(ans)
}


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

int main()
{
    int n,ans;
    char s[10];

    cin >> n;

    ans = 0;
    rep(i,n) {
        sprintf(s, "%d", i + 1);
        if (strlen(s) % 2 == 1)
            ++ans;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >>n;
  string s;
  cin >> s;
  int  x = 0, _max = 0;
  for(int i=0;i<n;i++){
    if(s[i] == 'I')x++;
    else if(s[i] == 'D')x--;
    _max = max(_max, x);
  }
  cout<<_max<<"\n";
  return 0;
}

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

using namespace std;
int arra[10001];
int main()

{
    int n,temp,j,mini;
    scanf("%d",&n);
    int ara[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&ara[i]);
        arra[ara[i]]++;
    }
    int frst=1;
    for(int i=0;i<10001;i++)
    {
        if(arra[i]!=0)
        {
            for(j=0;j<arra[i];j++)
            {


            if(!frst)
            {
                printf(" ");
            }
            else
            {
                frst=0;
            }
             printf("%d",i);
        }
    }
    }
    cout<<endl;



}

Measured memory_bytes: 11052
#include<bits/stdc++.h>
using namespace std;
string s;
int n;
bool zz[100000];
int main(){
	int n;
	cin>>n>>s;
	for(int i=0;i<2;i++)
	for(int j=0;j<2;j++)
	{
		zz[0]=i;
		zz[1]=j;
		for(int k=1;k<n-1;k++)
		{
			zz[k+1]=zz[k-1]^zz[k]^(s[k]=='x');
		}
		if((s[n-1]=='x')==(zz[n-2]^zz[n-1]^zz[0])&&(s[0]=='x')==(zz[n-1]^zz[0]^zz[1]))
		{
			for(int k=0;k<n;k++)
			cout<<(zz[k]?'W':'S');
			return 0; 
		}
	}
	cout<<-1;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	string s; cin>>s;
	long a=0,b=0,c=0;
	rep(i,0,N){
		if(s[i] == 'R') a++;
		else if(s[i] == 'G') b++;
		else c++;
	}
	long sum = a * b * c;
	rep(i,0,N){
		rep(j,1,min(i+1, N-i)){
			if(s[i-j] + s[i] + s[i+j] == 'R' + 'G' + 'B') sum--;
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int N;
int F[50];
int main(){
  cin >> N;
  F[0] = F[1] = 1;
  for(int i = 2; i <= N; i++){
    F[i] = F[i-1] + F[i-2];
  }
  cout << F[N] << endl;

}

Measured memory_bytes: 3112
K = int(input())

a = [0] * (K + 2)
a[0] = 7%K

for i in range(1, K + 1):
    a[i] = (a[i-1]*10 + 7) % K

f = 0

for i in range(K + 1):
    if a[i] == 0:
        print(i + 1)
        f = 1
        break

if f == 0:
    print("-1")

Measured memory_bytes: 48548
import sys
input=sys.stdin.readline
f=lambda:map(int,input().split())
n,m=f()
l=list(f())
t=[1]*n
g=[[] for _ in range(n)]
for _ in range(m):
  a,b=f()
  if l[a-1]<=l[b-1]: t[a-1]=0
  if l[b-1]<=l[a-1]: t[b-1]=0
print(sum(t))

Measured memory_bytes: 87272
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
 
int main() {
    ll h, w;
    cin >> h >> w;
    
    vector<string> board(h);
    vvl dist(h, vl(w, -1));  // dist[i][j] : (sx, sy)から(i, j)への最短距離(未訪問のとき-1)
    queue<P> Q;
    rep(i, h) {
        cin >> board[i];
        rep(j, w) {
            if(board[i][j] == '#') {
                Q.push(make_pair(i, j));
                dist[i][j] = 0;
            }
        }
    }
    
    while(!Q.empty()) {
        ll x = Q.front().first;
        ll y = Q.front().second;
        rep(dir, 4) {
            ll nx = x + dx[dir];
            ll ny = y + dy[dir];
            if(nx < 0 || h <= nx || ny < 0 || w <= ny) {
                continue;
            }
            if(board[nx][ny] == '#') {
                continue;
            }
            if(0 <= dist[nx][ny]) {
                continue;
            }
            dist[nx][ny] = dist[x][y] + 1;
            Q.push(make_pair(nx, ny));
        }
        Q.pop();
    }
    
    ll ans = 0;
    rep(i, h) {
        rep(j, w) {
            chmax(ans, dist[i][j]);
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 25524
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define maxn 100010
int tmp[10];
int a[maxn];
bool check(int m,int n,int z)
{

	int sum=m+n;
	if(sum>z)
	return true;
	return false;
	
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=(i+1);j<=n;j++)
		{
			for(int k=(j+1);k<=n;k++)
			{
				
					if(check(a[i],a[j],a[k]))
					{
						cnt++;
					}
				 
			}
		}
	}
     cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define max(a,b)((a)>(b)?(a):(b))
const int N=2e5+3;
struct edge{int v,nxt;}g[N+N];
int n,dfn[N],siz1[N],ord[N],p[N],siz[N],f[N],fa[N],bt[N],head[N],k,t;
inline int Sum(int k){int s=0;for(;k;k-=k&-k)s+=bt[k];return s;}
inline void Add(int k,int a){for(;k&&k<=n;k+=k&-k)bt[k]+=a;}
int Find(int u){return p[u]==u?u:p[u]=Find(p[u]);}
struct query{int u,a,f;}q[N+N];
bool Cmp(const query&a,const query&b){return a.a<b.a;} 
inline void Insert(int u,int v){g[++k]=(edge){v,head[u]};head[u]=k;}
void Dfs0(int u){
	int v;
	ord[dfn[u]=++t]=u,siz1[u]=1;
	for(int i=head[u];i;i=g[i].nxt)if((v=g[i].v)!=fa[u])
	  fa[v]=u,Dfs0(v),siz1[u]+=siz1[v];
}
void Dfs1(int u,int x){
	int v;
	x=max(x,fa[fa[u]]);
	if(u<x)f[u]--,q[++k]=(query){u,x,-1};
	f[u]++,q[++k]=(query){u,max(fa[u],x),1};
	for(int i=head[u];i;i=g[i].nxt)if((v=g[i].v)!=fa[u])
	  Dfs1(v,x);
}
signed main(){
	int u,v,j;
	scanf("%d",&n);
	for(int i=1;i<n;i++)scanf("%d%d",&u,&v),Insert(u,v),Insert(v,u);
	for(u=1;u<=n;u++)p[u]=u,siz[u]=1;
	t=0,Dfs0(1);
	k=0,Dfs1(1,0);
	std::sort(q+1,q+1+k,Cmp);
	for(u=1,j=1;u<=n;u++){
	  for(;q[j].a<=u&&j<=k;j++)f[q[j].u]+=q[j].f*(Sum(dfn[q[j].u]+siz1[q[j].u]-1)-Sum(dfn[q[j].u]-1));
	  p[u]=Find(fa[u]),siz[Find(fa[u])]+=siz[u];
	  Add(dfn[fa[u]],siz[u]),Add(dfn[fa[Find(fa[u])]],-siz[u]);
	}
	for(int i=2;i<=n;i++)f[ord[i]]+=f[fa[ord[i]]];
	for(u=2;u<=n;u++)printf("%d ",f[u]-1);
	return 0;
}

Measured memory_bytes: 25728
import java.io.*;
import java.util.*;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();
        int max = Integer.MAX_VALUE;
        String s = "", str = "";
        for (long i = 1; i * i <= num; i++) {
            if (num % i == 0) {
                s = (num / i) + "";
                str = i + "";
                int x = Math.max(s.length(), str.length());
                if (x < max) {
                    max = x;
                }
            }
        }
        System.out.println(max);
        bw.flush();
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
constexpr int qlim = 80;
using ll = long long;
using namespace std;

int n, q, kk[qlim];
string s;

ll solve(int k){
  ll d = 0, m = 0, dm = 0, ans = 0;
  
  REP(i, n){
    switch(s[i]){
      case 'D':{
        d++;
        break;
      }
      case 'M':{
        m++;
        dm += d;
        break;
      }
      case 'C':{
        ans += dm;
        break;
      }
    }

    if(i >= k-1){
      switch(s[i-k+1]){
        case 'D':{
          d--;
          dm -= m;
          break;
        }
        case 'M':{
          m--;
          break;
        }
      }
    }
  }

  return ans;
}

int main(){
  cin >> n >> s >> q;
  REP(i, q) cin >> kk[i];

  REP(i, q) cout << solve(kk[i]) << endl;

  return 0;
}


Measured memory_bytes: 1412
def solve():
    p = int(input())
    *A, = map(int, input().split())
    B = [0]*p

    C = [0]*p
    C[0] = 1
    zeros = [0]*p

    Y = [0]*p
    R = [0]*p
    for i in range(p):
        v = 0
        b = 1
        for j in range(i):
            v += Y[j] * b
            b = b * (i-j) % p
        Y[i] = y = (A[i]-v) * pow(b, p-2, p) % p

        for j in range(i+1):
            R[j] += y * C[j]

        if i < p-1:
            C[1:] = ((b - a*i) % p for a, b in zip(C[1:], C))
            C[0] = 0
    for i in range(p):
        R[i] %= p
    print(*R)
solve()

Measured memory_bytes: 56156
import collections as c

N = int(input())
A = c.Counter(list(map(int,input().split())))
key = list(A.keys())
val = list(A.values())


ans = 0
for i in range(len(key)):
	tmp = 0

	if i <= len(key) - 3:
		tmp += val[i]
		if key[i+1] <= key[i]+2:
			tmp  += val[i+1]
		if key[i+2] <= key[i]+2:
			tmp += val[i+2]
	elif i == len(key) - 2:
		tmp += val[i]
		if key[i+1] <= key[i]+2:
			tmp += val[i+1]
	else:
		tmp += val[i]

	ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 14564
n,b,sta=map(int,input().split())
A=list(map(int,input().split()))
Z=["F" for i in range(n+1)]
for i in A:
  Z[i]="B"
fi=Z[:sta:]
se=Z[sta+1::]
print(min(fi.count("B"),se.count("B")))


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
#include<numeric>

using namespace std;

long long MOD = 1000000007;

int n,m;
long long a[100005];

int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int x,y;cin>>x>>y;
    x--;y--;
    a[x]++;
    a[y]++;
  }
  bool ans = true;
  for(int i=0;i<n;i++){
    if(a[i]%2) ans = false;
  }
  if(ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 1024
def ds(n):
    s = str(n)
    array = list(map(int, s))
    return sum(array)

n,a,b = map(int,input().split())
y=[]
for i in range(n+1):
    x = ds(i)
    if x >= a:
        if x <= b:
            y.append(i)
print(sum(y))

Measured memory_bytes: 3424
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	final Scanner sc=new Scanner(System.in);
	int[] sum=new int[51];
	for(int i=0;i<51;i++)sum[i]=0;
	for(int i=0;i<=9;i++)
	    for(int j=0;j<=9;j++)
		for(int k=0;k<=9;k++)
		    for(int l=0;l<=9;l++)
			sum[i+j+k+l]++;
	while(sc.hasNext()){
	    System.out.println(sum[sc.nextInt()]);
	}
    }
}

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

namespace AtCoder.Contest.C
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			int n = cin.NextInt();
			int m = cin.NextInt();
            if (n >= m) Console.WriteLine(0);
            else
            {
				var a = cin.ArrayInt(m);
				Array.Sort(a);
				var b = new List<int>();
                for (int i = 0; i < m - 1; i++)
                {
					b.Add(a[i + 1] - a[i]);
                }
				b.Sort();
				long ans = 0;
                for (int i = 0; i < m - 1 - n + 1; i++)
                {
					ans += b[i];
                }
                Console.WriteLine(ans);
            }

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 19552
let n = stdin.ReadLine() |> int
let s = stdin.ReadLine()

if n % 2 = 1 then "No" |> stdout.WriteLine
 else
 let k = (n / 2)
 let rec f acc flag =
  match acc with
  |(-1) -> flag
  |_ -> if s.[acc] = s.[k + acc] then f (acc - 1) flag else f (acc - 1) "false"
 let fla = f (k - 1) "true"
 if fla = "true" then "Yes" |> stdout.WriteLine else "No" |> stdout.WriteLine

Measured memory_bytes: 11220
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <set>
using namespace std;

#define N 105
#define ll long long int
#define ld long long double



int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int R;
    cin>>R;
    
    float pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286;
    
    cout<<setprecision(7)<<2*R*pi<<endl;
    
    return 0;
}


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

int main()
{
	array<int, 3> a;
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	if (a[0] == 5 && a[1] == 5 && a[2] == 7)
		cout << "YES\n";
	else
		cout << "NO\n";
}


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

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

	string s;
	cin >> s;

	set<char> ss;
	for (auto c : s) ss.insert(c);
	if (ss.size() > 1) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int main(){
	int n;
	int t[2]={0};
	cin>>n;
	char ca[105];
	cin>>ca;
	for(int i=0;i<n;i++){
		if(ca[i]=='R')t[0]++;
		else t[1]++;
	}
	print_Yes_No(t[0]>t[1]);
}


Measured memory_bytes: 256
//A-別

#include <iostream>
using namespace std;

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 5148
<?php
$N = intval(fgets(STDIN));
for($i = 0; $i < $N; $i++)$map[] = trim(fgets(STDIN));

$max = -1;
for($i = 0; $i < $N; $i++){
    $visited = array_fill(0, $N, 0);
    $distance = array_fill(0, $N, 300);
    $current = [$i];
    $visited[$i] = 1;
    $d = 0;
    $distance[$i] = $d;
    while($current){
        $d++;
        $next = [];
        foreach($current as $c){
            for($j = 0; $j < $N; $j++){
                if($map[$c][$j] == "1"){
                    if(!$visited[$j]){
                        $visited[$j] = 1;
                        $distance[$j] = $d;
                        $next[] = $j;
                    }elseif($distance[$j] == $d-2 || $distance[$j] == $d){
                    }else{
                        continue 4;
                    }
                }
            }
        }
        $current = $next;
    }
    if($d > $max){
        $max = $d;
    }
}
echo $max,"\n";



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

using ll = long long;

int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h);
    for(int i = 0; i < h; ++i) {
        cin >> s[i];
    }

    constexpr int dx[4] = {0, 1, 0, -1};
    constexpr int dy[4] = {1, 0, -1, 0};
    bool ans = true;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(s[i][j] == '.') continue;
            bool b = false;
            for(int d = 0; d < 4; ++d) {
                int ny = i + dy[d], nx = j + dx[d];
                if(ny < 0 || h <= ny || nx < 0 || w <= nx || s[ny][nx] == '.') continue;
                b = true;
            }
            ans &= b;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
int main() {
  std::string a,b;
  std::cin >> a >> b;
  
  std::string c = a+b;
  double d = std::stod(c);
  int count = 0;
  for (int i = 1;i < 400;++i) {
    if (pow(i,2)==d) {
      count +=1;
    } else {
      count += 0;
    }
  }
  if (count!= 0) {
    std::cout << "Yes" << "\n";
  } else {
    std::cout << "No" << "\n";
  }
  return 0;
}

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

int main()
{
	string ordor;

	cin >> ordor;

	ordor[0] = '2';
	ordor[1] = '0';
	ordor[2] = '1';
	ordor[3] = '8';

	cout << ordor;

	return 0;
}

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

using namespace std;

const int INF = numeric_limits<int>::max() / 2;

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

    int e;
    while (cin >> e, e)
    {
        int res = INF;
        for (int y = 0; y * y <= e; y++)
        {
            for (int z = 0; z * z * z <= e; z++)
            {
                int x = e - y * y - z * z * z;
                if (x < 0)
                    continue;
                res = min(res, x + y + z);
            }
        }
        cout << res << endl;
    }
}



Measured memory_bytes: 3100
fun main(args: Array<String>) {
    cf16FinalA()
}

fun cf16FinalA() {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val list = (1..h).map { readLine()!!.split(' ') }

    val alp = ('A'..'Z').toList()

    for (i in 0 until h) {
        for (j in 0 until w) {
            if (list[i][j] == "snuke") return println("${alp[j]}${i + 1}")
        }
    }

    error("なんで？")
}


Measured memory_bytes: 37876
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int(i)=0 ; (i)<(int)(n) ; ++(i))
#define per(i,n) for(int(i)=(int)(n-1) ; (i)>=0 ; --(i))
#define replu(i,l,u) for(int(i)=(int)(l) ; (i)<=(int)(u) ; ++(i))
#define repul(i,u,l) for(int(i)=(int)(u) ; (i)>=(int)(l) ; --(i))
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
typedef vector<int>  vi ;
typedef pair<int,int> pii ;
typedef vector<pair<int,int> > vpii ;
typedef long long ll ;
const long mod=1e9+7 ;
const ll inf=2e9+10 ;

const ll maxx = 1e18 ;
int x, y ;
ll ans ;
int main() {
   ios::sync_with_stdio(false) ;
   cin.tie(NULL) ;
   cin >> x >> y ;
   int m = x%y ;
   int n = x/y ;
   if(m==0) cout << "-1\n" ;
   else {
      ans = n*y*1LL + m*1LL ;
      if(ans<=maxx) cout << ans << "\n" ;
   }

   return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  int a[200000];
  
  for(int i=0; i<n; i++) cin >> a[i];
  
  int p=0,count=0;
  bool flg=1;
  bool exist=0;
  for(int i=1; i<=n; i++){
    flg=1;
  	for(int j=p; j<=n; j++){
    	if(a[j]==i){ count++;flg=0;exist=1;p=j+1; break;}
    }
    if(flg) break;
  }
  
  if(exist) cout << n-count << endl;
  else cout << -1 << endl;
  
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int n,k,a[120000];
int aa[120000];
int l[120000],tl;
int r[120000],tr;
ll ans =3000000000;
ll ta;

ll min(ll a, ll b)
{
    return a<b?a:b;
}

int main()
{
    cin>>n>>k;
    for (int i=0; i<n; ++i)
    {
        cin>>a[i];
        if (a[i]<=0)
            l[tl++]=a[i];
        else r[tr++]=a[i];
    }
    for (int i=0; i<tl; ++i)
        aa[i]=l[tl-i-1];
    for (int i=0; i<tl; ++i)
        l[i]=aa[i];
    if (tr>=(k)) ans = r[k-1]; 
    if (tl>=(k)) ans = min(ans,-l[k-1]);
    for (int i=0; i<min(tl,k); ++i)
    {
        ta = -l[i]*2;
        if (k-i-2>=0 && k-i-2<tr)
            ta += r[k-i-2];
        else continue;
        if (ta<ans) ans=ta;
    }
    for (int i=0; i<min(tr,k); ++i)
    {
        ta=r[i]*2;
        if (k-i-2>=0 && k-i-2<tl)
            ta+= -l[k-i-2];
        else continue;
        if (ta<ans) ans = ta;
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+2], b[n+2], c[n+2];
    for(int i = 0; i < n; i++)
        cin>>a[i];
    for(int i = 1; i <= n; i++)
        cin>>b[i];
    for(int i = 1; i <= n - 1; i++)
        cin>>c[i];
    int ans = b[a[0]];
    for(int i = 1; i < n; i++)
    {
        if(a[i] - a[i-1] == 1)
            ans+=c[a[i]-1];
        ans += b[a[i]];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		int A[] = new int[N];
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextInt();
		}
		// 1 3 2 1 3 2 1 3 2
		long ret = 0;
		long MOD = 1000000007;
		// 10 9 8 7 5 6 3 4 2 1 10 9 8 7 5 6 3 4 2 1
		// 1 C0
		// 2 C0 * 2 + C1
		// 3 C0 * 3 + C1 * 2
		// K C0 * K + C1 * (K - 1)
		long KS = (K * (1 + K) / 2) % MOD;
		long KS2 = ((K - 1) * (K) / 2) % MOD;
		for(int i = 0 ; i < N ; ++i){
			long C0 = 0;
			long C1 = 0;
			for(int j = 0 ; j < i ; ++j){
				if(A[i] > A[j]){
					++C0;
				}
			}
			for(int j = i + 1 ; j < N ; ++j){
				if(A[i] > A[j]){
					++C1;
				}			
			}
			long add = KS2 * C0 + KS * C1;
			ret = (ret + add) % MOD;
//			System.out.println(C0 + " " + C1 + " " + ret);
		}
		System.out.println(ret);
	}
}


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

int main() {
	int n;\
	int temp;
	long maxnum, minnum, sum;
	//vector<int> v;
	cin >> n;
	if (n > 0) {
		cin >> temp;
		maxnum = temp;
		minnum = temp;
		sum = temp;
		for (int i = 0; i < n - 1; i++) {
			cin >> temp;
			if (maxnum <= temp) {
				maxnum = temp;
			}
			if (minnum >= temp) {
				minnum = temp;
			}
			sum += temp;

			//v.push_back(temp);
		}
	}

	//maxnum = *max_element(v.begin(), v.end());
	//minnum = *min_element(v.begin(), v.end());
	//sum = accumulate(v.begin(), v.end(), 0);

	printf("%ld %ld %ld", minnum, maxnum, sum);

	cout << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 3212
r1, c1, r2, c2 = map(int, input().split())

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
MOD = 10**9+7
for i in range(2, 2*10**6+3):
    g1.append((g1[-1] * i) % MOD)
    inverse.append((-inverse[MOD % i] * (MOD // i)) % MOD)
    g2.append((g2[-1] * inverse[-1]) % MOD)

def memo_comb(n, r, mod=MOD):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n-r] % mod

def g(r, c):
  return memo_comb(r+c+2, r+1) - 1

ans = g(r2, c2) - g(r2, c1-1) - g(r1-1, c2) + g(r1-1, c1-1)
ans %= MOD
print(ans)

Measured memory_bytes: 133036
while True:
    n = int(raw_input())
    if n == 0:
        break

    bridge = {}
    for i in range(n):
        m, a, b = map(int, raw_input().split())
        bridge[a] = bridge.setdefault(a, 0) + m
        bridge[b] = bridge.setdefault(b, 0) - m

    w = 0
    for key in sorted(bridge.keys()):
        w += bridge[key]
        if w > 150:
            break

    print "OK" if w <= 150 else "NG"

Measured memory_bytes: 4252