akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> ii;
main(){
    int h,w;
    cin >> h >> w;
    char grid[h][w];
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> grid[i][j];
    int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
    int ans = 0;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (grid[i][j] == '#') continue;
            int visit[h][w];
            for (int k = 0; k < h; k++) for (int l = 0; l < w; l++) visit[k][l] = -1;
            queue<ii> q;
            visit[i][j] = 0;
            q.push(ii(i,j));
            while (!q.empty()){
                ii u = q.front();
                q.pop();
                int x = u.first,y = u.second;
                for (int k = 0; k < 4; k++){
                    int nx = x+dx[k],ny = y+dy[k];
                    if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                    if (visit[nx][ny] != -1 || grid[nx][ny] == '#') continue;
                    visit[nx][ny] = visit[x][y]+1;
                    q.push(ii(nx,ny));
                    ans = max(ans,visit[nx][ny]);
                }
            }
        }
    }
    cout << ans;
}


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

int solve (string s, int k, string sub) {
  int sum = 0;
  for (int i = 1; i <= s.size() - k; i++) {
    if (i <= k) {
      int now = s[i] - '0';
      now = (now + sum) % 2;
      if (now == 1) {
        sum++;
        sub[i] = '1';
      }  
    }    
    else {
      if (sub[i - k] == '1') {
        sum++;  
      }  
      int now = s[i] - '0';
      now = (now + sum) % 2;
      if (now == 1) {
        sum++;
        sub[i] = '1';
      }
    }
  } 

  // sub[i] == '1'→ 0と1を回転させた.

  int first = 0; 
  for (int i = (s.size() - k); i < s.size(); i++) {
    int now = s[i] - '0';
    if (i == (s.size() - k)) {
      now = (now + sum) % 2;
      first = now;  
      if (first == 1) {
        sub[i] = '1';  
      }
      else {
        sub[i] = '0';  
      }
    }  
    else {
      if (i - k >= 1) {
        if (sub[i - k] == '1') {
          sum++;  
        }  
      }
      now = (now + sum) % 2;
      if (now == 1) {
        sub[i] = '1';  
      }
    }
  }
  // まずは，連続しているか確かめる
  bool follow = true;
  char last;
  int count = 0; 
  int num = 0;
  for (int i = s.size() - k; i <= s.size() - 1; i++) {
    if (sub[i] == '1') {
      if (k <= (i - 1)) {
        // ok  
      }    
      else {
        follow = false;  
      }
    }
  }
  if (follow) {
    return 1;  
  }
  return - 1;
}

int main () {
  string s;
  cin >> s;
  s = "a" + s;
  string sub;
  for (int i = 0; i < s.size(); i++) {
    sub = sub + "0";  
  }
  int left = 0;
  int right = s.size();
  /*
  for (int i = 1; i <= s.size() - 1; i++) {
    cout << i << " " << solve(s, i, sub) << endl;  
  }
  */
  while (left < right - 1) {
    int mid = (left + right) / 2;
    if (solve(s, mid, sub) == 1) {
      left = mid;  
    }  
    else {
      right = mid;  
    }
  }
  cout << left << endl;
  
}

Measured memory_bytes: 880
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	cin>>N;
	vector<LL>v;
	REP(i,N){
		LL a;
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	if(N%2==1){
		LL ans=0;
		for(int i=N/2;i<N;i++){
			if((i==N/2)||(i==N/2+1)){
				ans+=v[i];
			}else{
				ans+=2*v[i];
			}
		}
		REP(i,N/2){
			ans-=2*v[i];
		}
		LL ans2=0;
		for(int i=N/2+1;i<N;i++){
			ans2+=2*v[i];
		}
		REP(i,N/2+1){
			if((i==N/2-1)||(i==N/2)){
				ans2-=v[i];
			}else{
				ans2-=2*v[i];
			}
		}
		cout<<max(ans,ans2)<<endl;
	}else{
		LL ans=0;
		for(int i=N/2;i<N;i++){
			if(i==N/2){
				ans+=v[i];
			}else{
				ans+=2*v[i];
			}
		}
		REP(i,N/2){
			if(i==(N/2-1)){
				ans-=v[i];
			}else{
				ans-=2*v[i];
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1400
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int lMax = 1;
        int rMin = n;

        for (int i = 0; i < m; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            lMax = lMax < l ? l : lMax;
            rMin = rMin > r ? r : rMin;
        }
        int answer = rMin - lMax >= 0 ? rMin - lMax + 1 : 0;
        System.out.println(answer);
    }
}


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

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=200005;
const int INF=1e9+7;
int n;
ll a[100005];
ll dp[100005];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+n+1);
    ll ent=0;
    ll ant=1;
    for(int i=n;i>=2;i--)
    {
        if(ent+a[i]>2*a[i-1])
        {
            break;
        }
        else
        {
            ant++;
            ent+=a[i];
        }
    }
    ll bnt=0;
    ll dnt=1;
    for(int i=1;i<=n-1;i++)
    {
        if(2*(bnt+a[i])<a[i+1])
        {
            dnt=1;
            bnt+=a[i];
            //cout<<i<<" "<<bnt<<" "<<a[i+1]<<endl;
        }
        else
        {
            dnt++;
            bnt+=a[i];
        }
    }
    //cout<<ant<<" "<<dnt<<endl;
    printf("%lld\n",max(ant,dnt));
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>b){
        printf("a > b\n");
    }
    else if(a<b){
        printf("a < b\n");
    }
    else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2036
n=int(input())
h=list(map(int, input().split()))

ans="Yes"
for i in range(n-1,0,-1):
    if(h[i-1] - h[i] == 1):
        h[i-1]-=1
    elif(h[i-1] - h[i] > 1):
        ans="No"
        break
print(ans)

Measured memory_bytes: 14228
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;

ll gcd(ll n, ll m) {
    if( m == 0 ) return n;
    else {
        return gcd(m, n%m);
    }
}

int main() {
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    if( n > m ) {
        swap(n, m);
        swap(s, t);
    }   
    ll x = gcd(max(n, m), min(n, m));
    if( x == 1 ) {
        if( s[0] == t[0] ) {
            dump(n*m);  
        }
        else {
            dump(-1);
        }
    }
    else {
        bool res = true;
        for( int i = 0; i*(n/x) < (int)s.size(); i++ ) {
            if( s[i*(n/x)] != t[i*(m/x)] ) res = false;
        }
        if( res ) {
            dump(n*m/x);
        }
        else {
            dump(-1);
        }
    }
    return 0;  
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main()
{
  string S; cin>>S;
  if(S=="RRR") cout<<3<<endl;
  else if(S=="SSS") cout<<0<<endl;
  else if(S=="RSS"||S=="SRS"||S=="SSR"||S=="RSR") cout<<1<<endl;
  else cout<<2<<endl;
  return 0;
}

Measured memory_bytes: 3624
function main(arg) {
  const lines = arg.trim().split('\n');
  const [A, B] = lines[0].split(' ').map((x) => Number(x));
  const res = (A * B) % 2 !== 0 ? 'Yes' : 'No';
  console.log(res);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29540
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
int i=9999,m=0;
if(a<=i)
i=a;
if(b<=i)
i=b;
if(c<=i)
i=c;
if(a<=i)
i=a;
if(a>=m)
m=a;
if(b>=m)
m=b;
if(c>=m)
m=c;
cout<<m*10+i+(a+b+c)-m-i;
return 0;
}

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

int main(){
	int a, b, ans;
	string op;

	for (;;){
		cin >> a;
		cin >> op;
		cin >> b;
		if (op == "+"){
			ans = a + b;
		}
		else if (op == "-"){
			ans = a - b;
		}
		else if (op == "*"){
			ans = a * b;
		}
		else if (op == "/"){
			ans = a / b;
		}
		else if (op == "?"){
			break;
		}
		cout << ans << endl;
	}
}


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

int main(){
  int cities,roads;
  cin>>cities>>roads;
  vector<int> result(cities,0);
  for(int i=0;i<roads;i++){
    int a,b;
    cin>>a>>b;
    result.at(a-1)++;
    result.at(b-1)++;
  }
  for(int i=0;i<cities;i++){
    cout<<result.at(i)<<endl;
  }
}

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

int main(){
    ll n;
    cin>>n;
    ld ans=0;
    for(ll i=0;i<n;++i){
        ld x;
        string u;
        cin>>x>>u;
        if(u=="JPY"){
            ans+=x;
        }else{
            ans+=x*380000;
        }
    }
    cout<<setprecision(8)<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int n = sc.nextInt();

		int sum = 0;
		int[] s = new int[n];

		s[0] = sc.nextInt();

		for(int i=1;i<n;i++){
			s[i] = s[i-1]+sc.nextInt();
		}

		int ans = 999;

		for(int x=0;x<n-1;x++){
			ans = Math.min(ans,s[x]>(s[n-1]-s[x])?s[x]-(s[n-1]-s[x]):s[n-1]-s[x]-s[x]);
		}

		// 出力
		System.out.println(ans);
	}
}

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

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

  int rCnt = 0;
  int wCnt = 0;
  vector<int> rVec;
  vector<int> wVec;
  rep(i, n){
    if(C[i] == 'W'){
       wVec.push_back(i);
       wCnt++;
    } else {
      rVec.push_back(i);
      rCnt++;
    }
  }
  // 全部Rなら問題なし、または全部Wなら問題なし
  if (wCnt == n || rCnt == n){
    cout << 0 << endl;
    return 0;
  }

  reverse(rVec.begin(), rVec.end());
  int cnt = 0;
  // 一番左のWの位置と一番右のRの位置の関係が正しくなるまで実行
  while(wVec[cnt] < rVec[cnt]){
    cnt++;
  }
  cout << cnt << endl;
}


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

int main()
{
 int n;
  cin>>n;
  vector<int> v(n);
  for(int &i:v) cin>>i;
  sort(v.rbegin(),v.rend());
  int sum=0;
  sum+=v[0]/2;
  for(int i=1;i<n;i++)
    sum+=v[i];
  cout<<sum<<"\n";
  
  
  return 0;
}

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

int main(){
	bool C[11];
	int C1, C2, C3;
	int res;
	
	while((scanf("%d%d%d", &C1, &C2, &C3)) != EOF){
		for(int i = 1; i <= 10; i++) C[i] = false;
		C[C1] = true; C[C2] = true; C[C3] = true;
		
		res = 0;
		for(int i = 1; i <= 10 && i <= 20 - (C1 + C2); i++){
			if(!C[i]) res++;
		}
		
		if(res >= 4) printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 1008
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	unsigned a[n];
	for (int i = 0; i < n; ++i){
		scanf("%u", a + i);
		a[i] <<= 1;
	}
	sort(a, a + n);
	a[n-1] >>= 1;
	unsigned closest_to_half = distance(a, lower_bound(a, a + n - 1, a[n-1]));
	if(closest_to_half == n-1){
		printf("%u %u\n", a[n-1], a[n-2]>>1);
		return 0;
	}
	if(closest_to_half && a[closest_to_half] - a[n-1] > a[n-1] - a[closest_to_half - 1]) closest_to_half--;
	printf("%u %u\n", a[n-1], a[closest_to_half]>>1);
	return 0;
}

Measured memory_bytes: 512
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n,d = inm()
cnt = 0
for i in range(n):
    x,y = inm()
    if x*x+y*y<=d*d:
        cnt += 1
print(cnt)


Measured memory_bytes: 69856
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m =-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);
#define pi 3.14159265359

const int maxn = (i64)1e9+7;

int arr[200005];
int main()
{
    //read;
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(s.size()<=n) cout<<s;
    else {for(int i=0;i<n;i++)cout<<s[i];cout<<"...";}
    return 0;
}


Measured memory_bytes: 3588
import numpy as np

n, m, x = map(int, input().split())
book = [list(map(int, input().split())) for _ in range(n)]
book = np.array(book)

ans = 13*10**5
for b in range(2**n):
    bit=[0]*n
    for i in range(n):      
        bit[i]=b%2
        b//=2 
    bit = np.array(bit).astype(bool)
    if bit.sum()==0:
      continue
    score = book[bit].sum(axis=0)
    if (score[1:] < x).sum() == 0:
      if ans > score[0]:
        ans = score[0]
if ans == 13*10**5:
  ans = -1
print(ans)

Measured memory_bytes: 27348
#include <stdio.h>
#include <functional>

using namespace std;
typedef long long llong;

#define MAX
const llong mod = 1000000000 + 7;

int main()
{
  llong A, B, N;
  scanf("%lld %lld %lld", &A, &B, &N);

  llong x = min(B - 1, N);

  printf("%lld\n", (A * x) / B);

  return 0;
}

Measured memory_bytes: 1708
//To compile : type "$     g++ test.cpp -std=c++14 -I .    "
#include <atcoder/mincostflow>
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
using namespace atcoder;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
    cin>>N>>K;
    const int start = (int)N * 2, goal = start + 1, cost_base = (int)1e+9;
	mcf_graph<int, ll> G(N * 2 + 2);
	G.add_edge(start, goal, N * K, cost_base);
    mat a(N, vec(N));
    rep(i, N) {
        G.add_edge(start, i, K, 0);
        G.add_edge(i + N, goal, K, 0);
        rep(j, N) {
            scanf("%lld", &a[i][j]);
            G.add_edge(i, j + N, 1, cost_base - a[i][j]);
        }
    }
	auto res = G.flow(start, goal, N * K);
    cout<<N * K * cost_base - res.second <<endl;
    vector<string> ans(N, string(N, '.'));
	auto edges = G.edges();
    for(auto &e : edges){
		if(e.from == start || e.to == goal || e.flow == 0) continue;
		ans[e.from][e.to - N] = 'X';
	}
	rep(i,N) cout<<ans[i]<<endl;
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;
int main(){
  int n;cin >> n;
  int a;cin >> a;
  int max = a;
  int ans = 1;
  rep(i,n-1){
    int a;cin >> a;
    if(max<=a){
      ans++;
      max = a;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))//数组(结构体)清零 
#define ll long long
//int A(int a,int b){if(a<b||a<1||b<0)return 0;int k=1;while(b--){k*=a--;}return k;}//数学中的Aab,传递ab,返回Cab//类型为int//如果不符合条件则返回0 
//int C(int a,int b){if(a<b||a<1||b<0)return 0;b=min(a-b,b);int k=A(a,b),t=1;while(--b)k/=++t;return k;}//数学中的Cab,传递ab,返回Cab//类型为int//如果不符合条件则返回0 
//int HW(char*HWa,int HWl,int HWr){if(HWr<HWl)swap(HWl,HWr);for(int i=0;i<(HWr-HWl)/2+1;i++)if(HWa[HWl+i]!=HWa[HWr-i])return 0;return 1;}//传递字符串名,判断区间l r,如果是回文字符串就返回1,否则返回0 
//int SS(int a){if(a>4&&((a-1)%6)&&((a+1)%6))return 0;for(int i=2;i<=sqrt(a);i++)if(a%i==0)return 0;return 1;}//判断一个数是不是质数，是1 否0；请确保a>1; 
/*记得如果改int为long long,就把printf与scanf中相应的%d也改成%lld*/

int main()
{
	int a[105];
	int n,m,i,S=0,s=0;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		S+=a[i];
	}
	for(i=0;i<n;i++)
	{
		if(a[i]*4*m>=S)s++;
	}
	if(s<m)cout<<"No";
	else cout<<"Yes";
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  char sign;
  char current = '=';
  int ans = 1;
  
  for (int i = 1; i < N; i++){
    if (A.at(i) > A.at(i-1)) sign = '+';
    else if (A.at(i) < A.at(i-1)) sign = '-';
    else continue;
    
    if (sign != current && current != '='){
      ans++;
      current = '=';
      continue;
    }
    
    current = sign;
  }
  
  cout << ans << endl;  
}

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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    int ans = N;
    int num = 0;
    rep(i, N - 1) {
        if (S[i + 1] == 'E') num++;
    }
    ans = min(ans, num);
    rep(i, N - 1) {
        if (S[i] == 'W') num++;
        if (S[i + 1] == 'E') num--;
        ans = min(ans, num);
    }
    cout << ans << endl;

    return 0;
}


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

#define mod 1000000007
typedef long long ll;

ll power(ll a,ll n)
{
    ll res=1;
    while(n)
    {
        if(n&1)
            res=(res*a)%mod;
        n=n/2;
        a=(a*a)%mod;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin>>n;
    vector<ll>v(n+1);

    for(int i=1;i<=n;i++)
        cin>>v[i];

    ll E=0,X=0,R=0,P=0;

    for(int i=1;i<=n;i++)
    {
        E=(E+v[i])%mod;
    }
    E=(E%mod*E%mod)%mod;

    for(int i=1;i<=n;i++)
    {
        R=(v[i]%mod*v[i]%mod)%mod;
        X=(X+R)%mod;
    }

    P=((E-X)*power(2,mod-2))%mod;
    if(P<0)
        P=(P+mod)%mod;
    cout<<P<<"\n";
}


Measured memory_bytes: 4760
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      String s;
      int num;
      s=sc.next();

      num=Integer.parseInt(s.substring(0,1))*10000000+
      Integer.parseInt(s.substring(1,2))*1000000+
      Integer.parseInt(s.substring(2,3))*100000+
      Integer.parseInt(s.substring(3,4))*10000+
      Integer.parseInt(s.substring(5,6))*1000+
      Integer.parseInt(s.substring(6,7))*100+
      Integer.parseInt(s.substring(8,9))*10+
      Integer.parseInt(s.substring(9,10));

      if(num<=20190430){
        System.out.println("Heisei");
      }else{
        System.out.println("TBD");
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 23892
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    s = input()
    k = i_input()

    ans = []

    for i in range(1,6):
        t = 0
        while t+i <= len(s):
            ans.append(s[t:t+i])
            t += 1
    ans = list(set(ans))
    ans.sort()

    print(ans[k-1])


if __name__=="__main__":
    main()


Measured memory_bytes: 68736
#include <bits/stdc++.h>
using namespace std;
#define re register
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> P;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
int read() {
	int x = 0, f = 0; char ch = 0;
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}
bool f;
int get(string s)
{
	int ans = 0;
	if (f) ans++, s[0] = '#';
	for (int i = 1; i < s.size(); i++)
		if (s[i] == s[i - 1]) ans++, s[i] = '#';
	if (s[s.size() - 1] == s[0] && s[s.size() - 1] != '#') f = 1;
	if (s[s.size() - 1] == '#') f = 0;
	return ans;
}
int main(){
	string s; cin >> s; int k = read();
	ll ans = get(s); 
	if (f) {
		int nxt = get(s);
		if (f) ans += 1ll * nxt * (k - 1);
		else ans += 1ll * nxt * (k - 1 - k / 2) + 1ll * ans * ( k / 2);
	}
	else ans += 1ll * (k - 1) * get(s);
	printf("%lld\n", ans); 
	return 0;
}
//

Measured memory_bytes: 256
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]

def main():
    k = ni()
    p = k // 2
    q = k - p
    print(p * q)

main()


Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {
	int cnt, max = 0;
	char S[10], s[4];
	char *c = &S[0];
	s[0] = 'A';
	s[1] = 'C';
	s[2] = 'G';
	s[3] = 'T';

	scanf("%s", S);

	while (1) {
		c = strpbrk(c, s);
		if (c == NULL) break;
		cnt = strspn(c, s);
		if (cnt > max) max = cnt;
		c += cnt;
	}

	printf("%d", max);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>

#define MOD (1000000007)
using namespace std;

typedef long long ll;

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

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

    ll minv = 99999999999999;
    for(int i = 1; i <= 100; i++) {
        ll value = 0;
        for(int j = 0; j < N; j++) {
            value += pow(X[j] - i, 2);
        }
        if (minv > value) minv = value;
    }


    cout << minv << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

//vector<ll> a;

int main()
{
	ll a,b,t;

	cin >> a >> b >> t;
	cout << b*(t/a) << endl;
	
	

	return 0;
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,b;cin>>a>>b;
  int x = b-a;
  cout<<(x*(x+1))/2-b<<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 R = sc.nextInt();
			int G = sc.nextInt();
			int B = sc.nextInt();
			int N = sc.nextInt();
			int ret = 0;
			
			for(int r=0;r*R<=N;r++) {
				for(int g=0;g*G<=N;g++) {
					if(r*R+g*G>N) {
						break;
					}
					if((N-r*R-g*G)%B==0) {
						ret++;
					}
				}
			}
			
			
			System.out.println(ret);
			
	    }
		
		
	}


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

int S[101], top = 0;

void push(int x){
  if(top == 100) return;
  S[++top] = x;
}

int pop(){
  if(!top) return 0;
  return S[top--];
}

int main(){
  int n1, n2, x;
  string a;
  while(cin >> a){
    if(a[0] >= '0' && a[0] <= '9'){
      istringstream iss(a);
      iss >> x;
      push(x);
    }
    else switch(a[0]){
      case '+':
	n1 = pop();
	n2 = pop();
	push(n1 + n2);
	break;
      case '-':
	n1 = pop();
	n2 = pop();
	push(n2 - n1);
	break;
      case '*':
	n1 = pop();
	n2 = pop();
	push(n1 * n2);
      }
  }
  cout << pop() << endl;
  return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(void) {
  ll n, k;
  cin >> n >> k;
  int c = 0;
  while(n){
    n /=k;
    c++;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN	505
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int a[MAXN], b[MAXN], ans[MAXN * MAXN];
bool cmp(int x, int y) {
	return a[x] < a[y];
}
int main() {
	int n; read(n);
	for (int i = 1; i <= n; i++) {
		read(a[i]); b[i] = i;
		ans[a[i]] = i;
	}
	sort(b + 1, b + n + 1, cmp);
	int pos;
	pos = 1;
	for (int i = 1; i <= n; i++) {
		int all = b[i] - 1;
		for (int j = 1; j <= all; j++) {
			while (ans[pos]) pos++;
			ans[pos] = b[i];
		}
		if (pos > a[b[i]]) {
			printf("No\n");
			return 0;
		}
	}
	pos = n * n;
	for (int i = n; i >= 1; i--) {
		int all = n - b[i];
		for (int j = 1; j <= all; j++) {
			while (ans[pos]) pos--;
			ans[pos] = b[i];
		}
		if (pos < a[b[i]]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	for (int i = 1; i <= n * n; i++)
		printf("%d ", ans[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 2176
import sys

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


def main():
    N, K = map(int, readline().split())

    ans = 0
    for i in range(K, N + 2):
        left = i * (i - 1) // 2
        right = i * (2 * N - i + 1) // 2
        ans = (ans + right - left + 1) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return true; } return false;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return true; } return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  vector<int32> a(n),b(n);
  bool flg = true;
  REP(i,n){
    cin >> a[i] >> b[i];
    if(a[i] != b[i])flg = false;
  }
  if(flg){
    ANS(0);
    return 0;
  }
  int64 asum = 0;
  REP(i,n)asum += a[i];
  int64 ans = 0;
  REP(i,n){
    if(a[i] > b[i])
      ans = max(ans, asum - a[i] + a[i] - b[i]);
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 640
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/9/6 13:41:01
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
const int maxx=5e5+10,mod=1000000007;
int n,k,be[maxx],ne[maxx],to[maxx],dep[maxx],e=0;
LL val[maxx],ans=1;
void add(int x,int y){
	to[++e]=y;
	ne[e]=be[x];
	be[x]=e;
}
void dfs(int x,int fa){
	LL j=0;
	for(int i=be[x];i;i=ne[i]){
		int go=to[i];
		if(go==fa) continue;
		dep[go]=dep[x]+1;
		if(dep[go]==1) val[go]=k-1;
		else val[go]=k-2;
		val[go]-=j;
		++j;
		dfs(go,x);
	}
}
void get_ans(int x,int fa){
	if(val[x]<=0) ans=0;
	ans=ans*val[x]%mod;
	for(int i=be[x];i;i=ne[i]){
		int go=to[i];
		if(go==fa) continue;
		get_ans(go,x);
	}
}
		
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	n=read(); k=read();
	For(i,1,n-1){
		int u=read(), v=read();
		add(u,v); add(v,u);
	}
	val[1]=k; dep[1]=0;;
	dfs(1,0);
	get_ans(1,0);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 12600
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,m; cin >> n >> m;
    ll temp = 1;
    ll ans = 1;
    rep(i,n) temp = (temp * (i+1)) % MOD;
    ans *= temp;
    temp = 1;
    rep(i,m) temp = (temp * (i+1)) % MOD;
    ans = (ans * temp) % MOD;
    if(n == m)ans *= 2;
    else if(abs(n-m) > 1)ans = 0;
    ans %= MOD;
    cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vvi> vvvi;

#define all(x) x.begin(), x.end()

const int MOD = 1000000009;
const int INF = 2e9;

//TO_STRING
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(char ch){
	string s;
	s += ch;
	return s;
}

string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + 
  	to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + 
  	to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

//DEBUG 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL //compile with -DLOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define pb push_back
#define fi first
#define se second  

void solve() {
  string s;
  cin >> s;
  bool ok = 0;
  if (s[0] == '7' || s[1] == '7' || s[2] == '7') ok = 1;
  cout << (ok ? "Yes" : "No");
}

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


Measured memory_bytes: 3656
n = gets.to_i
arr = gets.chomp.split.map(&:to_i)

def puts_arr(arr)
  puts arr.join(' ')
end

def insertionSort(arr, n)
  1.upto(n-1) do |i|
    v = arr[i]
    j = i-1
    while j>=0 && arr[j] > v
      arr[j+1] = arr[j]
      j -= 1
    end
    arr[j+1] = v
    puts_arr(arr)
  end
end

puts_arr(arr)
insertionSort(arr, n)

Measured memory_bytes: 8708
#include <stdio.h>

int main(void){
    int n1=0;
    int n2=0;
    int n3=0;
    int n4=0;
    int n[4];
     
    for(int i=0;i<4;i++){
        scanf("%d",&n[i]);
        if(n[i]==1){
            n1++;
        }
        else if(n[i]==4){
            n2++;
        }
        else if(n[i]==7){
            n3++;
        }
        else if(n[i]==9){
            n4++;
        }
    }
    if(n1 == 1 && n2 == 1 && n3 == 1 && n4 == 1){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (long i = 0; i < (n); i++)
using namespace std;
int main()
{
    long l, r;
    cin >> l >> r;
    long mod = 2019;
    r = r - l + 1;
    l = l % mod;
    if (r >= mod || l == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    long list[r];
    rep(i, r) list[i] = (l + i) % mod;
    l = 2019;
    rep(i, r - 1)rep(j, r - i - 1) l = min(l, list[i] * list[i + j + 1]%mod);
    cout << l << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
int N, M;
vector <int> edge[1005];
bool vis[1005];
int dist[1005];
int previous[1005];
int best = INT_MAX;
vector <int> ans;

int bfs(int v){
    queue <int> q;
    q.push(v);
    dist[v] = 0;
    vis[v] = true;
    while (!q.empty()){
        int node = q.front();
        q.pop();
        for (int e: edge[node]){
            if (!vis[e]) {
                q.push(e);
                dist[e] = dist[node] + 1;
                previous[e] = node;
                vis[e] = true;
            } else if (e == v){
                if (dist[node] + 1 < best){
                    best = dist[node] + 1;
                    return node;
                }
            }
        }
    }
    return -1;
}

int main() {
    scanf("%d %d", &N, &M);
    for (int i=0; i<M; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        edge[a].push_back(b);
    }
    for (int i=1; i<=N; i++) {
        memset(vis, false, sizeof(vis));
        memset(dist, 0, sizeof(dist));
        memset(previous, 0, sizeof(previous));
        int p = bfs(i);
        if (p != -1){
            ans.clear();
            while (p != 0) {
                ans.push_back(p);
                p = previous[p];
            }
        }
    }
    if (best == INT_MAX) printf("-1\n");
    else {
        printf("%d\n", best);
        for (int a: ans){
            printf("%d\n", a);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#define maxn 1000005
#define lowbit(x) x&-x
#define LL long long int
using namespace std;
LL c[maxn];
LL line[maxn];
LL n,k;
void update(LL pos,LL v){
	while(pos<=n){
		c[pos]+=v;
		pos+=lowbit(pos);
	}
}
LL get(LL pos){
	LL ans=0;
	while(pos>0){
		ans+=c[pos];
		pos-=lowbit(pos);
	}
	return ans;
}
struct point {
	LL x,y;
	point(LL x,LL y):x(x),y(y){}
	point(){}
}save[maxn];
bool cmp(point a,point b){
	LL fa=-k*a.x+a.y;
	LL fb=-k*b.x+b.y;
	if(fa!=fb)return fa>fb;
	return a.x>b.x;
}
void init(){
	sort(save+1,save+n+2,cmp);
	for(int i=1;i<=n+1;i++){
		update(i,1);
	}
}
void scan(){
	init();
	LL ans=0;
	for(int i=1;i<=n+1;i++){
		if(save[i].x==0){
			update(1,-1);
			continue;
		}
		ans+=get(save[i].x);
		update(save[i].x+1,-1);
	}
	printf("%lld",ans);
}
int main(){
	scanf("%lld%lld",&n,&k);
	LL now=0;
	save[1]=point(0,0);
	for(int i=2;i<=n+1;i++){
		scanf("%lld",&line[i]);
		now+=line[i];
		save[i]=point(i-1,now);
	}
	scan();
	return 0;
}

Measured memory_bytes: 12416
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for(int i = 0;i < n;i++) a[i] = sc.nextLong();

        Map<Long, Integer> map = new HashMap<>();
        long count = 0;
        for(int i = 0;i < n;i++) {
            long tmp = i - a[i];
            Integer e = map.get(tmp);
            if(e != null) count = count + e.intValue();
            Integer tmpCount = map.get(a[i] + i);
            if(tmpCount == null) tmpCount = 0;
            map.put(a[i] + i, tmpCount + 1);
        }

        System.out.println(count);
    }

}


Measured memory_bytes: 70924
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int M = sc.nextInt();
		int N = sc.nextInt();
		int ans = 0;
		for (int i = 0; i < M; ++i) {
			int count = 0;
			for (int j = 0; j < N; ++j) {
				if (sc.nextInt() != 0) {
					++count;
				}
			}
			ans = Math.max(ans, count);
		}
		System.out.println(ans);
	}

}

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

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

int main()
{   
    string s, res, res2;
    int s_max, cnt = 0;
    map<string, int> mp;

    while (cin >> s) {
        if (s_max < s.size()) {
            s_max = s.size();
            res = s;
        }

        mp[s]++;
    }

    for (const auto &x: mp) {
        if (cnt < x.second) {
            cnt = x.second;
            res2 = x.first;
        }
    }

    cout << res2 << " " << res << endl;
    
}


Measured memory_bytes: 3060
#include <stdio.h>

char S[100000];

void Do(int N){
  int i;
  int s[32];
  long long c;
  scanf("%s", S);
  c = 1;
  for(i = 0;i <= 'z' - 'a';i++) s[i] = 0;
  for(i = 0;i < N;i++) s[S[i]-'a']++;
  for(i = 0;i <= 'z' - 'a';i++) c = c * (s[i] + 1) % ((long long) (1e9 + 7));
  printf("%lld\n", (c - 1) % ((long long) (1e9 + 7)));  
}

int main(void){
  int N;
  scanf("%d", &N);
  Do(N);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

//全体  
long long func1( long long l ) {
    if ( l == 0 ) { return 1; }
    else {
        long long ret = 1;
        while ( l > 0 ) {
            ret *= 2;
            ret += 3;
            l--;
        }
        return ret;
    }
}


//P
long long func2( long long l ) {
    long long ret = func1(l);
    return (ret+1)/2;
}


long long func3( long long l, long long k ) {
    if ( l == 0 ) { return 1; }
    if ( k <= 1 ) { return 0; }

    long long s = func1(l);
    long long p = func2(l);
    
    if ( s == k ) { return p; }

    if ( (s+1)/2 == k ) { return func2(l-1)+1; }
    else if ( (s+1)/2 > k ) { return func3(l-1, k-1); }
    else if ( (s+1)/2 < k ) { return func2(l-1)+1+func3(l-1,k-(2+func1(l-1)) ); }
}


int main() {
    
    long long N;
    long long X;
    cin >> N >> X;

    if ( X <= 1 ) { cout << 0 << endl; return 0; }

    cout << func3( N, X ) << endl;

    return 0;
}

Measured memory_bytes: 256
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int a, b;
  cin >> a >> b;
  cout << max(a - b, 0ll) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define maxn 500086

using namespace std;

const int p = 1e9 + 7;

inline void getNext(char *s, int *nxt){
	int n = strlen(s);
	for(int i = 1;i < n;i++){
		int j = nxt[i - 1];
		while(j && s[j] != s[i]) j = nxt[j - 1];
		if(s[j] == s[i]) j++;
		nxt[i] = j;
	} 
}

int n;
char s[2][maxn];
int nxt[2][maxn];
int ans;

int main(){
	scanf("%s", s[0]);
	int n = strlen(s[0]);
	strcpy(s[1], s[0]);
	reverse(s[1], s[1] + n);
	getNext(s[0], nxt[0]), getNext(s[1], nxt[1]);
	if(!nxt[0][n - 1] || n % (n - nxt[0][n - 1])) return printf("1\n1"), 0;
	if(n - nxt[0][n - 1] == 1) return printf("%d\n1", n), 0;
	for(int i = 0;i < n - 1;i++){
		if((!nxt[0][i] || (i + 1) % (i + 1 - nxt[0][i])) && (!nxt[1][n - i - 2] || (n - i - 1) % (n - i - 1 - nxt[1][n - i - 2]))) ans++;
	}
	printf("2\n%d", ans);
}


Measured memory_bytes: 8704
n = int(input())
red = [list(map(int, input().split())) for i in range(n)]
red = sorted(red, reverse=True)
blue = [list(map(int, input().split())) for i in range(n)]
blue = sorted(blue, key=lambda x: x[1])
ans = 0
for re in red:
    a, b = re
    for i, bu in enumerate(blue):
        c, d = bu
        if a < c and b < d:
            ans += 1
            blue.pop(i)
            break
print(ans)

Measured memory_bytes: 3064
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func()
    top_str = input_raw.strip().split()
    [A, B] = [int(top_str[0]), int(top_str[1])]
    T = (A + B) % 24
    print T

if __name__ == '__main__':
    main()

Measured memory_bytes: 2692
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<(int)n;i++)
#define REP(i,n)	for(int i=0;i<=(int)n;i++)
#define srep(i,a,n)	for(int i=a;i<(int)n;i++)
#define SREP(i,a,n)	for(int i=a;i<=(int)n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrt(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-15;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

int main() {
	ll n, c;	cin >> n >> c;
	vector<ll> x(n), v(n);
	rep(i, n)	cin >> x[i] >> v[i];
	vector<ll> revx(n), revv(n);
	rep(i, n) {
		revx[n - i - 1] = c - x[i];
		revv[n - i - 1] = v[i];
	}
	x.insert(x.begin(), 0);	v.insert(v.begin(), 0);
	revx.insert(revx.begin(), 0);	revv.insert(revv.begin(), 0);
	vector<ll> cw(n + 1);
	vector<ll> cwmax(n + 1);
	SREP(i, 1, n) {
		cw[i] = -x[i] + x[i - 1] + v[i] + cw[i - 1];
		cwmax[i] = max(cw[i] - x[i], cwmax[i - 1]);
	}
	vector<ll> ccw(n + 1);
	vector<ll> ccwmax(n + 1);
	SREP(i, 1, n) {
		ccw[i] = -revx[i] + revx[i - 1] + revv[i] + ccw[i - 1];
		ccwmax[i] = max(ccw[i] - revx[i], ccwmax[i - 1]);
	}
	ll ret = 0;
	REP(i, n) {
		ret = max(ret, cw[i] + ccwmax[n - i]);
		ret = max(ret, ccw[i] + cwmax[n - i]);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 6464
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,l;
  cin>>n>>l;
  string s[n];
  for(int i=0;i<n;i++)
  {
    cin>>s[i];
  }
  sort(s,s+n);
  for(int i=0;i<n;i++)
  {
    cout<<s[i];
  }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,B,M;
int AA[101010];
int BB[101010];




void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B>>M;
	FOR(i,A) cin>>AA[i];
	FOR(i,B) cin>>BB[i];
	
	ll ret=*min_element(AA,AA+A)+*min_element(BB,BB+B);
	FOR(i,M) {
		cin>>x>>y>>r;
		ll tmp=AA[x-1]+BB[y-1]-r;
		ret=min(ret,tmp);
	}
	
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1024