akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(){
    int a = 10;

    int N;

    cin >> N;
    VI avec(N);

    REP(i,N){
        cin >> avec[i];
    }
    priority_queue<int> q(avec.begin(), avec.end());

    int olda = -1;
    int newa = -1;
    int count = 0;
    int ans = 0;

    if(q.empty()){
        cout << "0" << endl;
        return 0;
    }
    
    while(!q.empty()){        
        do{
            olda = q.top();
            count++;
            q.pop();
        }while(!q.empty() && olda == q.top() );
        if( count < olda) ans += count;
        else               ans += count - olda;
        count = 0;
    }

    cout << ans << endl;
   
}





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

int main(){
	string s;
  	cin>>s;
  	int len = s.length();
  	if(len%2==0){
  		string s1 = s.substr(0, len/2);
  		string s2 = s.substr(len/2, len/2);
  		int count = 0;
  		for(int i=0;i<len/2;i++){
  			if(s1[i] != s2[len/2 - i - 1])
  				count++;
  		}
  		cout<<count;
  	}
  	else{
  		string s1 = s.substr(0, len/2);
  		string s2 = s.substr(len/2 + 1, len/2);
  		int count = 0;
  		for(int i=0;i<len/2;i++){
  			if(s1[i] != s2[len/2 - i - 1])
  				count++;
  		}
  		cout<<count;
  	}
  	return 0;
}

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

lenList = [0 for x in range(N)]
for start in range(1,N):
    for end in range(start+1,N+1):
        len = end - start
        if start <= X:
            if end <= X:
                lenList[len] += 1
            elif end < Y:
                len = min(len,((X-start) + 1 + (Y-end)))
                lenList[len] += 1
            else:
                len = (X-start) + 1 + (end-Y)
                lenList[len] += 1
        elif start < Y:
            if end < Y:
                len = min(len,(start-X) + 1 + (Y-end))
                lenList[len] += 1
            else:
                len = min(len,(start-X) + 1 + (end-Y))
                lenList[len] += 1
        else:
            lenList[len] += 1

for k in range(1,N):
    print(lenList[k])


Measured memory_bytes: 47196
#include <iostream>

int main(){
   char S[3];
   for(int i=0; i<3; ++i)
      std::cin >> S[i];

   bool flags[3] = {false, false, false};
   for(int i=0; i<3; ++i){
      if(S[i]=='a') flags[0] = true;
      else if(S[i]=='b') flags[1] = true;
      else if(S[i]=='c') flags[2] = true;
   }
   if(flags[0] && flags[1] && flags[2]) std::cout << "Yes" << std::endl;
   else std::cout << "No" << std::endl;

   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define mp make_pair
#define pb push_back
typedef pair<int, int> pii;
////////

int const N = 1e5 + 41;
int const D = 11;

int n, m;
vector<int> e[N];
int was[N][D];
int v[N], d[N], c[N], col[N][D];
int q;

void solve(){
	scanf("%d %d",&n,&m);
	fi(0, m){
		int u, v;
		scanf("%d %d",&u,&v);
		--u;--v;
		e[u].pb(v);
		e[v].pb(u);
	}
	scanf("%d",&q);
	fi(1, q+1){
		scanf("%d %d %d",&v[i],&d[i],&c[i]);
		--v[i];
	}
	deque<pii> dq;
	for(int i=q;i>0;--i){	
		if(was[v[i]][d[i]]) continue;
		dq.clear();
		dq.push_back(mp(v[i], d[i]));
		was[v[i]][d[i]] = 1;
		while(sz(dq)){
			pii ver = dq.front();
			dq.pop_front();
			col[ver.first][ver.second] = i;
			if(ver.second == 0) continue;
			fj(0, sz(e[ver.first])){
				int to = e[ver.first][j];
				int toD = ver.second - 1;
				if(!was[to][toD]){
					was[to][toD] = 1;
					dq.pb(mp(to, toD));
				}
			}
		}
	}
	fi(0, n) fj(1, D) col[i][j] = max(col[i][j], col[i][j-1]);
	fi(0, n) printf("%d\n",c[col[i][D-1]]);
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();



	return 0;
}

Measured memory_bytes: 16808
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var a = new int[n];
            for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine().Trim());
            var t = int.Parse(Console.ReadLine().Trim());
            Console.WriteLine(getAns(a,n,t));
        }
    }
    static int getAns(int[] a, int n, int t)
    {
        var count = 0;
        var L = 0; var r = n - 1; 
        while (true)
        {
            count++;
            var mid = (L + r) / 2;
            var w = a[mid];
            if (w == t) break;
            else if (w > t) r = mid - 1;
            else L = mid + 1;
            if (r < L) break;
        }
        return count;
    }
}



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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;

int main(){

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

    vector<vector<int>> connect(m);

    rep(i,m){
        int k;
        cin >> k;

        rep(j,k){
            int tmp;
            cin >> tmp;

            connect[i].pback(tmp);
        }
    }

    vector<int> p(m);

    rep(i,m){
        cin >> p[i];
    }

    int ans = 0;

    for(int bit = 0; bit < (1<<n); bit++){

        bool able = true;
        
        rep(i, m){
            int count = 0;

            rep(j, connect[i].size()){
                if(bit & (1<<(connect[i][j] - 1))){
                    count++;
                }
            }

            if(count % 2 != p[i]){
                able = false;
                break;
            }
        }

        if(able) ans++;
    }

    cout << ans << endl;

    return 0;
}


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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

l = make_divisors(n)
x = n // l[-1]
print(x + l[-1]-2)

Measured memory_bytes: 3264
import sys; sys.setrecursionlimit(50000)
input = sys.stdin.readline

H, W = map(int, input().split())
grid = [list(input()) for _ in range(H)]
dir4 = ((0, 1), (0, -1), (1, 0), (-1, 0))
dir8 = ((0, 1), (0, -1), (1, 0), (-1, 0), (-1, -1), (1, 1), (-1, 1), (1, -1))

for i in range(H):
    for j in range(W):
        if grid[i][j] != "#": continue
        for d in dir8:
            nx = i + d[0]
            ny = j + d[1]
            if not (0 <= nx < H): continue
            if not (0 <= ny < W): continue
            if grid[nx][ny] == ".":
                grid[nx][ny] = "1"
            elif grid[nx][ny] == "#" or grid[nx][ny] == "\n":
                pass
            else:
                grid[nx][ny] = str(int(grid[nx][ny]) + 1)

for s in grid:
    print("".join(s).replace(".", "0").replace("\n",""))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n;cin>>n;
    int mx=1;
    int before=1;
    int ans = 0;
    rep(i,n){
        int tmp;cin>>tmp;
        if(before<=tmp)ans++;
        before = max(before, tmp);
    }
    co(ans);
}


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

#define rep(i,n) for(int i= 0; i < n; ++i)
using namespace std;

int main(void){
  int n, t;
  vector<int> tn;
  int ans = 0;
  int begin = -1;

  cin >> n >> t;
  tn.resize(n);
  for(auto& x: tn) cin >> x;

  begin = tn[0];
  for(int i = 1; i < n; ++i){
    if(begin + t > tn[i]){
      ans += tn[i] - begin;
    }else{
      ans += t;
    }
    begin = tn[i];
  }
  ans += t;


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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
long long xi, yi, x2, y2, N, x, y;
vector<pair<int, int> > A;
int dp[1<<20];
 
const long double pi = 3.141592653589793;
 
bool inside() {
    if(x < min(xi, x2)) return false;
    if(x > max(xi, x2)) return false;
    if(y < min(yi, y2)) return false;
    if(y > max(yi, y2)) return false;
    return true;
}
 
bool f_type = false;
 
int LIS() {
    if((int)A.size() == 0)
        return 0;
 
    dp[0] = A[0].second;
    int C = 1;
 
    for(int i = 1;i < (int)A.size();i++) {
        if(A[i].second > dp[C-1]) {
            dp[C++] = A[i].second;
            continue;
        }
 
        dp[lower_bound(dp, dp+C, A[i].second)-dp] = A[i].second;
    }
 
    return C;
}
 
int main() {
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
 
    cin>>xi>>yi>>x2>>y2;
    cin>>N;
    for(int i = 0;i < N;i++) {
        cin>>x>>y;
        if(inside()) {
            A.push_back(make_pair(x, y));
        }
    }
 
    if((xi < x2 and yi < y2) or (xi > x2 and yi > y2))
        f_type = true;
 
 
    if(f_type) sort(A.begin(), A.end());
    else sort(A.begin(), A.end(), greater<pair<int, int> >());
 
    int length = LIS(), tlength;
 
    cout << fixed << setprecision(15);
 
    long long tans = (abs(xi-x2)+abs(yi-y2))*100;
 

/*    if(f_type) tlength = abs(yi-y2)+1;
    else tlength = abs(xi-x2)+1;
*/

   tlength = min(abs(xi-x2)+1, abs(yi-y2)+1);
 
    if(xi == x2) tlength = 1;
    if(yi == y2) tlength = 1;
 
    if(length == tlength) {
        cout << tans + (10*pi-20) + (5*pi-20)*(length-1) << endl;
    } else {
        cout << tans + (5*pi-20)*(length) << endl;
    }
 
    return 0;
}

Measured memory_bytes: 2672
#include<bits/stdc++.h>
using namespace std;
const int N=55;
int a[N],b[N],mp[N][N];
deque<int> ans,D;
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];
    for(int i=50;i>=1;i--)
    {
        D.clear();
        for(int j=0;j<ans.size();j++)
            D.push_back(ans[j]);
        for(int j=1;j<i;j++)
            D.push_back(j);
        for(int j=0;j<=50;j++)
            for(int k=0;k<=50;k++)
                mp[j][k]=0;
        for(int j=0;j<=50;j++)
            mp[j][j]=1;
        for(int j=1;j<=50;j++)
            for(int k=0;k<D.size();k++)
                mp[j][j%D[k]]=1;
        for(int j=0;j<=50;j++)
            for(int k=0;k<=50;k++)
                for(int t=0;t<=50;t++)
                    if(mp[k][j] && mp[j][t])
                        mp[k][t]=1;
        for(int j=0;j<n;j++)
        {
            if(!mp[a[j]][b[j]])
            {
                ans.push_back(i);
                break;
            }
        }
    }
    if(ans.size()==50)
    {
        cout<<-1<<endl;
        return 0;
    }
    long long res=0;
    for(int i=0;i<ans.size();i++)
        res+=(1LL<<ans[i]);
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 510000;
const int MOD =  998244353;
const int INV2 = (MOD+1)/2;

     signed main(){
     
     int n;
     string a;
     set<string> s;
     cin>>n;
     for(int i=0;i<n;i++){
       cin>>a;
       if(s.find(a)==s.end())s.insert(a);
     //  cerr<<i<<endl;
     }
     cout<<s.size();
}


        


Measured memory_bytes: 19224
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static int E;
		 static int F;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int A = 100*sc.nextInt();
	        int B = 100*sc.nextInt();
	        int C = sc.nextInt();
	        int D = sc.nextInt();
	        E = sc.nextInt();
	        F = sc.nextInt();
	        boolean[] a = new boolean[40];
	        for(int i=0;A*i<=F;i++) {
	        	for(int j=0;A*i+B*j<=F;i++) {
	        		a[(A*i+B*j)/100]=true;
	        	}
	        }
	        boolean[] bi = new boolean[3005];
	        for(int i=0;C*i<F;i++) {
	        	for(int j=0;C*i+D*j<F;j++) {
	        		bi[C*i+D*j]=true;
	        	}
	        }
	        int cnt=0;
	        int[] b = new int[3005];
	        for(int i=0;i<3005;i++) {
	        	if(bi[i]==true) {
	        		b[cnt]=i;
	        		cnt++;
	        	}
	        }
	        	        
	        Arrays.sort(b);
	        double max = -1;
	        String ans ="";
	        for(int i=1;i<40;i++) {
	        	if(a[i]==false)continue;
	        	int w = i*100;
	        	int l=-1;
	        	int r=3005;
	        	while(r-l>1) {
	        		int m = l+(r-l)/2;
	        		int s = b[m];
	        		if(Isok(w,s)==true) {
	        			l=m;
	        		} else {
	        			r=m;
	        		}
	        	}
	        	double t=0;
	        	if(l>=0&&l<3005) {
	        		t = 100.0*b[l]/(i*100+b[l]);
	        	} 
	        	if(max<t) {
	        		ans=(i*100+b[l]) + " " + b[l];
	        		max=t;
	        	}
	        }
	        
	        System.out.println(ans);
	    }
		 
		static boolean Isok(int a,int b) {
			double p=E*a/100;
			int w=a+b;
			if(p<b)return false;
			if(w>F)return false;
			
			return true;
		}
	}

Measured memory_bytes: 23764
import std.stdio, std.conv, std.string;

void main()
{
  int N = to!int(chomp(readln()));
  string str = to!string(N);
  int count;
  foreach(char chr; str) {
    count += to!int(chr)-48;
  }
  if(N % count == 0) {
    writeln("Yes");
  } else writeln("No");

}


Measured memory_bytes: 256
n=int(input())
x=[0]*n
y=[0]*n
z=[]
w=[]
for i in range(n):
    x[i],y[i]= list(map(int, input().strip().split()))
    z.append(x[i]+y[i])
    w.append(x[i]-y[i])
a=max(z)-min(z)
b=max(w)-min(w)
print(max(a,b))

Measured memory_bytes: 40556
<?php
    for($i = 1; $i <= 9; $i++){
        for($j = 1; $j <= 9; $j++){
            echo $i ."x" .$j ."=" .$i*$j;
            if($i==9 && $j==9){
                continue;
            }
            echo "\n";
        }
    }
?>

Measured memory_bytes: 15360
from bisect import bisect_left
n=int(input())
A=list(map(int,input().split()))
q=int(input())
Q=list(map(int,input().split()))

B=[20*2000+1]
for i in range(2**n):
    num=format(i,"b").zfill(n)
    ans=0
    for j,k in enumerate(num):
        if k=="1":ans +=A[j]
    B.append(ans)

B.sort()
for i in Q:
    if B[bisect_left(B,i)]==i:print("yes")
    else:print("no")


Measured memory_bytes: 47152
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#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;

ll manhattan(ll x1, ll y1, ll x2, ll y2) {  // (x1, y1) と (x2, y2) のマンハッタン距離
    return abs(x1 - x2) + abs(y1 - y2);
}

int main() {
    ll h, w, d;
    cin >> h >> w >> d;

    vl px(h*w+1), py(h*w+1);
    rep(i, h) {
        rep(j, w) {
            ll a;
            cin >> a;
            px[a] = i, py[a] = j;
        }
    }

    vl dist(h*w+1);
    rep(i, h*w+1) {
        if(i > d) {
            dist[i] = dist[i-d] + manhattan(px[i], py[i], px[i-d], py[i-d]);
        }
    }

    ll q;
    cin >> q;
    rep(i, q) {
        ll L, R;
        cin >> L >> R;
        out(dist[R] - dist[L]);
    }

    re0;
}

Measured memory_bytes: 3200
#include <iostream>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007LL;

ll moddiv(ll a, ll b) {
    ll t = MOD-2;
    while(t) {
        if(t & 1) {
            a *= b;
            a %= MOD;
        }
        b *= b;
        b %= MOD;
        t >>= 1;
    }
    return a;
}

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

    ll fact = 1LL;
    for(ll i=2;i<=n;++i) (fact *= i) %= MOD;

    ll ra[n+1];
    ra[0] = 0;
    for(ll i=1;i<=n;++i) {
        ra[i] = (ra[i-1] + moddiv(fact, i)) % MOD;
    }


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

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;

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

	int ans = (t / a) * b;

	cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
n,m=(int(i) for i in input().split())
p=[[int(i) for i in input().split()] for i in range(m)]
c=[0]*(n)
i={}
for pe,pk in sorted(p, key=lambda x: x[1]):
  c[pe-1]+= 1
  i[pk]='%06d%06d' % (pe, c[pe-1])
for _,pk in p:
  print(i[pk])

Measured memory_bytes: 37632
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,i,j,cnt=0;
cin >> N;
for(i=1;i<=9;i++){
    for(j=1;j<=9;j++){
        if(i*j==N){
            cnt++;
            break;
        }
    }
}
if(cnt==0){
    cout << "No" << endl;

}
else{
    cout << "Yes" << endl;

}
return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

const int MOD=1e9+7;
//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int dp[n+5][4][4][4];
    memset(&dp, 0, sizeof dp);

    for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 4; j++) {
            for(int k = 0; k < 4; k++) {
                if((i==0 && j==1 && k==2)||(i==1 && j==0 && k==2)||(i==0 && j==2 && k==1)) continue;
                dp[3][i][j][k]=1;
            }
        }
    }

    for(int idx = 3; idx <= n; idx++) {
        for(int i = 0; i < 4; i++) {
            for(int j = 0; j < 4; j++) {
                for(int k = 0; k < 4; k++) {
                    for(int l = 0; l < 4; l++) {
                        if((j==0 && k==1 && l==2)||(j==0 && k==2 && l==1)||(j==1 && k==0 && l==2)||(i==0 && j==1 && l==2)||(i==0 && k==1 && l==2)) continue;
                        dp[idx+1][j][k][l] = (dp[idx+1][j][k][l]+dp[idx][i][j][k])%MOD;
                    }
                }
            }
        }
    }

    int cnt=0;
    for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 4; j++) {
            for(int k = 0; k < 4; k++) {
                cnt = (cnt+dp[n][i][j][k])%MOD;
            }
        }
    }
    cout << cnt << "\n";

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
const ll INF=99999999999999999;
ll a,b,c,d,e,f,ans=0;
vector<vector<ll>> day(33);
ll n,k;
bool hantei(ll x){
    bool flag=false;
    rep(i,n){
        vl v(n,0);
        v[i]=1;
        for(ll j=x;j>-1;j--){
            a=0;
            rep(l,day[j].size()){
                a+=v[day[j][l]];
            }
            if(a>0){
            rep(l,day[j].size()){
                v[day[j][l]]=1;
            }
            }
        }
        a=0;
        rep(i,n){
            a+=v[i];
        }
        if(a==n)flag=true;
    }
    return flag;
}
int main(){
  while(1){
  cin>>n;
    if(n==0)break;
    vector<vector<ll>> k(33);
    day=k;  
  rep(i,n){
        cin>>a;
        rep(j,a){
            cin>>b;
            day[b-1].push_back(i);
        }
    }

    ll ok=30;
    ll ng=-1;

    while(ok-ng>1){
        ll mid=(ok+ng)/2;
        if(hantei(mid)){
            ok=mid;
        }
        else {
            ng=mid;
        }
    }

    if(ok==30)cout<<-1<<endl;
    else cout<<ok+1<<endl;
}
}


Measured memory_bytes: 3116
using System;
using System.Collections.Generic;
namespace I_am_the_brown_coder{
    class Inonoa{
        static void Main(){
            string[] n_k = Console.ReadLine().Split();
            int n = int.Parse(n_k[0]);
            int k = int.Parse(n_k[1]);
            if(k==1){
                Console.WriteLine(0);
                return;
            }
            Console.WriteLine(n-(k-1)-1); 
        }
    }
}

Measured memory_bytes: 13140
import java.io.*;
import java.math.*;
import java.util.*;
public class Main{ 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		long N = I.nextLong();
		long M = I.nextLong();
		long ans = 0;
		if (N==1&&M==1)ans=1;
		else if (N==1||M==1) ans=Math.max(N, M)-2;
		else ans=(N-2)*(M-2);
		ans=Math.max(ans, 0);
		O.pln(ans);
	}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25512
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, a[100];
int main() {
	while (~scanf("%d", &n)) {
		if (n == 0) break;
		for (int i = 0; i < n; i++) scanf("%d", &a[i]);
		sort(a, a + n);
		int ret = 0;
		for (int i = 0; i < n; i++) {
			ret += a[i] * (n - i);
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2672
def mod_comb(n, k, p):
    if k > n - k:
        k = n - k
    
    numerator = 1
    denominator = 1
    for i, j in zip(range(n - k + 1, n + 1), range(1, k + 1)):
        numerator = (numerator * i) % p
        denominator = (denominator * j) % p
    
    return (numerator * pow(denominator, p - 2, p)) % p

def solve():
    mod = 10 ** 9 + 7
    X, Y = map(int, input().split())
    s = 2 * Y - X
    t = 2 * X - Y
    if s >= 0 and s % 3 == 0 and t >= 0 and t % 3 == 0:
        s //= 3
        t //= 3
        print(mod_comb(s + t, s, mod))
    else:
        print(0)

solve()

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

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int[] xx = new int[n];
		int[] yy = new int[m];
		List<Integer> xList = new ArrayList<>();
		List<Integer> yList = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			xx[i] = sc.nextInt();
			xList.add(xx[i]);
		}
		for (int i = 0; i < m; i++) {
			yy[i] = sc.nextInt();
			yList.add(yy[i]);
		}
		Optional<Integer> xmax = xList.stream().max((a, b) -> a.compareTo(b));
		Optional<Integer> ymin = yList.stream().min((a, b) -> a.compareTo(b));
		int point = xmax.get() + 1;
		if (xmax.get() < point && point <= ymin.get() && x < point && point <= y) {
			System.out.println("No War");
		} else {
			System.out.println("War");
		}
 	}
}

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    string s; cin >> s;
    int a, b;
    for(int i = 0; ; i++)
        if(s[i] == 'A'){
            a = i; break;
        }

    for(int i = s.length() - 1;; i--)
        if(s[i] == 'Z'){
            b = i; break;
        }
    cout << b - a + 1;
}


Measured memory_bytes: 720
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
rate = 0
for i in range(1, n + 1):
  count = 0
  while True:
    if i * (2 ** count) >= k:
      break
    count += 1
  rate = rate + ((1 / n) * (1 / (2**count)))

print(rate)


Measured memory_bytes: 2940
import math
import sys

# 比較回数をここに記録
# 理論上 n * lg n を越えることはない。
_exchange = 0

def merge_sort(A, left, right):
    """数列 A を in place に昇順にソートする。

    left は A の先頭のインデックス、right は末尾のインデックスのひとつ後ろ。
    """
    if left + 1 < right:
        mid = (left  + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)

def merge(A, left, mid, right):
    """ソート済みの部分列をマージする。

    数列 A の left から mid - 1 の要素、mid から right - 1 までの
    ２つの部分列はソート済みである。これをマージして、left から right - 1 まで
    ソートする。
    """
    first = A[left:mid]
    first.append(math.inf)  # 番兵
    second = A[mid:right]
    second.append(math.inf) # 番兵

    global _exchange
    i = j = 0
    for k in range(left, right):
        _exchange += 1
        if first[i] <= second[j]:
            A[k] = first[i]
            i += 1
        else:
            A[k] = second[j]
            j += 1


if __name__ == '__main__':
    n = int(input())
    A = list(map(int, sys.stdin.readline().split()))

    merge_sort(A, 0, n)
    print(*A)
    print(_exchange)



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

#define ll long long
#define pi acos(-1)
#define valid(a , b) a >= 0 && a < r && b >= 0 && b < c && arr[a][b] == '.'
int h , n;
int dm[1005];
int mp[1005];
int dp[1005][10005];

int call(int i , int h1)
{
    //cout << i << " " << h1 << endl;
    if(dp[i][h1] != -1)return dp[i][h1];
    if(h1 <= 0){
        return 0;
    }
    int ret1 = 1000000000 , ret2 = 1000000000;
    ret1 = mp[i] + call(i , h1 - dm[i]);
    if(i < n)ret2 = call(i + 1 , h1);
    dp[i][h1] = min(ret1 , ret2);
    return dp[i][h1];
}

int main()
{
    //ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.cpp", "r" , stdin);
    //freopen("output.cpp" , "w" , stdout);
    #endif // ONLINE_JUDGE
    //*/
    memset(dp , -1 , sizeof(dp));
    cin >> h >> n;
    for(int i = 1 ; i <= n ; i++){
        cin >> dm[i];
        cin >> mp[i];
    }
    cout << call(1 , h) << endl;
    return 0;
}


Measured memory_bytes: 40064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[] args)throws IOException{
		int time,h,m,s;
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		time=Integer.parseInt(br.readLine());
		h=time/3600;
		m=(time%3600)/60;
		s=time-h*3600-m*60;
		System.out.println(h+":"+m+":"+s);
	}
}

Measured memory_bytes: 24236
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N; cin >> N;
    string s, t; cin >> s >> t;

    constexpr int MOD = int(1e9) + 7;
    intmax_t res = 1;
    bool isSide = false;
    for (size_t i = 0; i < s.length(); ++i) {
        if (i + 1 < s.length() && s[i] == s[i + 1]) {
            if (i == 0) res *= 6;
            else {
                if (isSide) {
                    res *= 3;
                } else {
                    res *= 2;
                }
            }
            isSide = true;
            ++i;
        } else if (s[i] == t[i]) {
            if (i == 0) res *= 3;
            else {
                if (isSide) {
                    res *= 1;
                } else {
                    res *= 2;
                }
            }
            isSide = false;
        }
        res %= MOD;
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

string g[12];
bool vis[12][12];
bool clr[12][12];
const int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};

int dfs(int y,int x,int col){
  if(g[y][x] != col)return 0;
  if(vis[y][x])return 0;
  vis[y][x] = true;

  int res = 1;
  rep(i,4){
    int ny = y+dy[i], nx = x+dx[i];
    if(ny<0 || nx<0 || ny>=12 || nx>=6)continue;
    res += dfs(ny,nx,col);
  }
  return res;
}


int chain(void){
  memset(clr,0,sizeof(clr));
  rep(i,12){
    rep(j,6){
      if(g[i][j] != '.' && g[i][j] != 'O' && !clr[i][j]){
	memset(vis,0,sizeof(vis));
	if(dfs(i,j,g[i][j])>=4){
	  rep(ii,12)rep(jj,6)clr[ii][jj] |= vis[ii][jj];
	}
      }
    }
  }

  rep(i,12){
    rep(j,6){
      if(g[i][j] == 'O'){
	rep(k,4){
	  int ny = i+dy[k], nx = j+dx[k];
	  if(ny<0 || nx<0 || ny>=12 || nx>=6)continue;
	  if(g[ny][nx] != 'O' && clr[ny][nx]){
	    clr[i][j] = true;
	  }
	}
      }
    }
  }

  int num = 0;
  rep(i,12){
    rep(j,6){
      if(clr[i][j])g[i][j] = '.', num++;
    }
  }
  if(num==0)return 0;

  rep(i,6){
    for(int j=11;j>=0;j--){
      if(g[j][i] != '.'){
	for(int k=j+1;k<12;k++){
	  if(g[k][i] == '.')swap(g[k][i],g[k-1][i]);
	  else break;
	}
      }
    }
  }

  return chain()+1;
}

int main(){
  int n;
  cin >> n;
  while(n--){
    rep(i,12)cin >> g[i];
    cout << chain() << endl;
  }
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> m(n,0);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }

    for(int i=0;i<n;i++){
        m.at(a.at(i)-1)++;
    }

    /*
    for(int i=0;i<n;i++){
        cout << "m.at(" << i << ")=" << m.at(i) << endl;
    }
    */
    for(int i=0;i<n;i++){
        //cout << "m.at(" << i <<")=" <<  m.at(i) << endl;
    }

    sort(m.begin(),m.end(),greater<int>());
    int p =0;
    for(int i=0;i<k;i++){
        p += m.at(i);
        //cout << "p=" << p << endl;
    }

    //cout << "m.size()=" << m.size() << endl;

    //cout <<"p= " << p << endl;
    cout << n-p << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
 	string str;
  	while(cin>>str){
    	int flag=0;
      for(int i=0;i<str.length();i++){
      	if(str[i]=='7'){
        	flag=1;
          	break;
        }
      }
      if(flag)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
  return 0;
}

Measured memory_bytes: 3624
n = int(input())
d = {}
for _ in range(n):
  s = input()
  if not s in d:
    d[s] = 1
  else:
    d[s] += 1
m = int(input())
for _ in range(m):
  s = input()
  if s in d:
    d[s] -= 1
print(max(0, max(d.values())))

Measured memory_bytes: 3060
#N=gets.to_i
#S=gets.chomp
#A=(0...N).map{gets.to_i}
#sum=A.inject(&:+)
#B=gets.split.map(&:to_i)

N,A=gets.split.map(&:to_i)
s=gets.chomp

if s[A-1]=="A"
  s[A-1]="a"
elsif s[A-1]=="B"
  s[A-1]="b"
else
  s[A-1]="c"
end

puts s



Measured memory_bytes: 1788
#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 pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[100001];
pint cb[100001];
int main(){
    int n,m;
    ll ans=0;
    cin>>n>>m;
    rep(i,n){
        cin>>a[i];
        ans+=a[i];
    }
    sort(a,a+n);
    int ci,bi;
    rep(i,m){
        cin>>bi>>ci;
        cb[i]={ci,bi};
    }
    sort(cb,cb+m,greater<pint>());
    int cur=0,card=0;
    while(cur<n){
        if(cb[card].second==0) ++card;
        if(card>=m) break;
        if(a[cur]<cb[card].first){
            ans+=cb[card].first-a[cur];
            --cb[card].second;
            ++cur;
        }
        else break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1408
<?php
$s = fgets(STDIN);
$s = str_split($s);
for($i = 0; $i<count($s); $i++){
	if($i%2 == 0 && $s[$i] == 'L'){
        echo "No";
        return;
    }elseif($i%2 == 1 && $s[$i] == 'R'){
        echo "No";
		return;
    }
}
echo "Yes";

Measured memory_bytes: 3576
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
#define inf 0x3f3f3f3f

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b && a==c)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {


    public void solve() throws IOException {
        int H = nextInt(), W = nextInt(), h = nextInt(), w = nextInt();
        if(H % h == 0 && W % w == 0){
            out.print("No");
            return;
        }else out.println("Yes");
        int min = ((h * w - 1) * 4000 + 1) * (-1);
        int res[][] = new int[H][W];
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                res[i][j] = 4000;
            }
        }
        for(int i = 0; i < H / h; i++){
            for(int j = 0; j < W / w; j++){
                res[(i + 1) * h - 1][(j + 1) * w - 1] = min;
            }
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                out.print(res[i][j] + " ");
            }
            out.println();
        }
    }


    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Main().run();
    }

    void run() throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
//            br = new BufferedReader(new FileReader("queue.in"));
//            out = new PrintWriter(new File("queue.out"));
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
}

Measured memory_bytes: 49688
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			if (a[i] == a[j]) continue;
			for (int k = j+1; k < n; k++) {
				if (a[i] + a[j] <= a[k]) continue;
				if (a[i] + a[k] <= a[j]) continue;
				if (a[k] + a[j] <= a[i]) continue;
				if (a[i] == a[k]) continue;
				if (a[j] == a[k]) continue;
				ans++;
			}
		}
	}
	cout << ans << endl;
}


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

map<int,int> a,b;
signed main(){
	int n,v;
	cin>>n;
	rep(i,n){
		cin>>v;
		if(i%2)a[v]++;
		else b[v]++;
	}
	int ma=0;
	int ans=0,ans2=0;
	int f;
	for(auto i=a.begin();i!=a.end();i++){
		int z=ma;
		ma=max((*i).second,ma);
		if(z!=ma)f=(*i).first;
	}
	ans+=(n+1)/2-ma;
	ma=0;
	for(auto i=b.begin();i!=b.end();i++){
		if(f!=(*i).first)ma=max((*i).second,ma);
	}
	ans+=n/2-ma;
  	ma=0;
	for(auto i=b.begin();i!=b.end();i++){
		int z=ma;
		ma=max((*i).second,ma);
		if(z!=ma)f=(*i).first;
	}
	ans2+=n/2-ma;
	ma=0;
	for(auto i=a.begin();i!=a.end();i++){
		if(f!=(*i).first)ma=max((*i).second,ma);
	}
	ans2+=(n+1)/2-ma;
	cout<<min(ans,ans2)<<endl;
	return 0;
}

Measured memory_bytes: 6528
using System;

class Program
{
    static void Main()
    {
        while (true)
        {
            string[] raw = Console.ReadLine().Split(' ');
            if(raw[0]=="0")break;
            int h = int.Parse(raw[0]);
            int w = int.Parse(raw[1]);
            for(int y=0;y<h;y++){
                for(int x=0;x<w;x++)Console.Write("#");
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 5292
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

unsigned int randInt() {
	static unsigned int tx = 123456789, ty = 362436069, tz = 521288629, tw = 88675123;
	unsigned int tt = (tx ^ (tx << 11));
	tx = ty; ty = tz; tz = tw;
	return (tw = (tw ^ (tw >> 19)) ^ (tt ^ (tt >> 8)));
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    int x[51], y[51];
    rep(i, N) cin >> x[i] >> y[i];
    double bestX = 500, bestY = 500;
    double best = INF;
    int loop = 5000000;
    double temperature = 1000.0;
    while(loop--) {
        double now = 0.0;
        double tmpX = bestX + (((double)randInt()/UINT_MAX) - 0.5) * temperature;
        double tmpY = bestY + (((double)randInt()/UINT_MAX) - 0.5) * temperature;
        
        rep(i, N) {
            double dx = tmpX - x[i];
            double dy = tmpY - y[i];
            now = max(now, sqrt(dx * dx + dy * dy));
        }
        //cout << best << " " << now << " " << tmpX << " " << tmpY << endl;
        if(now < best) {
            best = now;
            bestX = tmpX;
            bestY = tmpY;
        }
        //if (loop % 100000 == 0)
        //    cout << fixed << setprecision(16)<< now << " " << bestX << " " << bestY << endl;
        temperature *= 0.99999;
    }
    cout << fixed << setprecision(16) << best << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <string>

using namespace std;

#define LEFT false
#define RIGHT true

int main()	{
  long long n;
  cin >> n;
  long long a[n] = {0};
  for (int i = 0; i < n; i++)	{
    cin >> a[i];
  }
  deque<long long> b;
  bool insert;
  if (n % 2 == 0)	{
    //start insert from left
    insert = LEFT;
  }
  else {
    insert = RIGHT;
  }
  b.push_back(a[0]);
  for (long long i = 1; i < n; i++)	{
    if (insert == RIGHT)	{
      b.push_back(a[i]);
    }
    else	{
      b.push_front(a[i]);
    }
    insert = !insert;
  }
  for (long long i = 0; i < n; i++)	{
    cout << b[i] << " ";
  }
  cout << endl;
  return 0;
}

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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[5];
            for (int b = 0; b < 5; b++)
                a[b] = int.Parse(Console.ReadLine());
            if (a[0] < 40)
                a[0] = 40;
            if (a[1] < 40)
                a[1] = 40;
            if (a[2] < 40)
                a[2] = 40;
            if (a[3] < 40)
                a[3] = 40;
            if (a[4] < 40)
                a[4] = 40;
            Console.WriteLine((a[0] + a[1] + a[2] + a[3] + a[4]) / 5);



        }
    }
}

Measured memory_bytes: 9108
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;

double distance(double a,double b,double c,double d){
    return sqrt((a-c)*(a-c)+(b-d)*(b-d));
}

int main()
{
    double a,b,c,d;
    cin >> a >> b >> c >> d;
    printf("%lf",distance(a,b,c,d));
}


Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n,ans=0;
string s;
bool check(ll kouho){
    bool flag=false;
    map<string,ll> bubun;
    string k=s.substr(0,kouho);
    bubun[k]=kouho;
    For(j,kouho,n){
        k.erase(0,1);
        k+=s.at(j);
        ll ik=bubun[k];
        if(ik==0){
            bubun[k]=j+1;
        }
        else if(ik+kouho<=j+1){
            flag=true;
            break;
        }
    }
    return flag;    
}
int main(){    
    cin>>n>>s;
    s+="*****";
    ll kouho=n/4;
    ll kouho2=0;
    For(num,0,10){
        bool flag=check(kouho);
        ll div=pow(2,num+2);
        if(flag){
            kouho2=max(kouho2,kouho);
            kouho+=n/div;
        }
        else kouho-=n/div;
        if(kouho==0){
            kouho2=0;
            break;
        }
    }
    ans=kouho2;
    For(i,ans+1,1+n/2){
        bool flag=check(i);
        if(!flag)break;
        ans=i;
    }      
    cout<<ans<<endl;
}


Measured memory_bytes: 22168
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);

        char [] c = in.next().toCharArray();
        if(c[2] == c[3] && c[4] == c[5]) {
            out.println("Yes");
        }
        else {
            out.println("No");
        }
        out.flush();
    }
}

class Interval {
    int start;
    int end;

    public int getStart() {
        return start;
    }

    public int getEnd() {
        return end;
    }

    public Interval(int start, int end) {
        this.start = start;
        this.end = end;
    }

    @Override
    public String toString() {
        return
                "start=" + start +
                ", end=" + end +
                '}';
    }
}


class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return tokenizer.nextToken();
    }

    public Integer nextInt(){
        return Integer.valueOf(next());
    }
    public Long nextLong() {
        return  Long.valueOf(next());
    }
    public Double nextDouble() {
        return Double.valueOf(next());
    }
    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}


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

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  ll max_num = max(a, max(b, c));
  ll ans;
  if (max_num == a) ans = b * c * abs(max_num / 2 - (max_num - max_num / 2));
  else if (max_num == b) ans = c * a * abs(max_num / 2 - (max_num - max_num / 2));
  else if (max_num == c) ans = b * a * abs(max_num / 2 - (max_num - max_num / 2));
  
  cout << ans << endl;
  
  
}


Measured memory_bytes: 256