akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
h, w, k = map(int, input().split())
s = []
a = [[] for _ in range(h)]
for i in range(h):
    s.append(list(input()))

cnt = 1
ki = 1
written = 0
a_row = [0 for _ in range(w)]
for row in s:
    cnt_s = 0
    for i, sij in enumerate(row):
        if cnt_s > 0 and sij == '#':
            ki += 1
        
        if sij == '#':
            cnt_s += 1
        a_row[i] = ki

    if cnt_s == 0:
        cnt += 1
        continue
    
    ki += 1
    for _ in range(cnt):
        a[written].extend(list(a_row))
        written += 1

    cnt = 1

if written < h:
    for i in range(h - written):
        a[written + i].extend(a[written - 1])

for row in a:
    print(" ".join(map(str, row)))


Measured memory_bytes: 8052
s = list(input())
l_ans = [0 for _ in range(len(s)+1)]
r_ans = [0 for _ in range(len(s)+1)]
ans = [0 for _ in range(len(s)+1)]
l_level = 0
r_level = 0
for i in range(len(s)):
    if s[i] == '<':
        l_level += 1
    else:
        l_level = 0
    l_ans[i+1] = l_level

for i in range(1,len(s)+1):
    if s[-i] == '<':
        r_level = 0
    else:
        r_level += 1
    r_ans[-(i+1)] = r_level

for i in range(len(ans)):
    ans[i] = max(l_ans[i], r_ans[i])
# print(ans,sum(ans))
# print(l_ans,r_ans)
print(sum(ans))


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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 100005;
int n , ara[N];
int tree[4 * N];

void update(int node,int L,int R,int pos,int val)
{
    if(pos < L or pos > R)return;
    if(pos == L and pos == R){
        tree[node] = val;
        return;
    }
    int mid = (L + R)/2;
    update(2 * node,L,mid,pos,val);
    update(2 * node + 1,mid + 1,R,pos,val);
    tree[node] = max(tree[2 * node] ,tree[2 * node + 1]);
}
int query(int node,int L,int R,int from,int val)
{
    int mid = (L + R)/2;
    if(L >= from){
        if(L == R){
            if(tree[node] > val)return L;
            return 2e9;
        }
        if(tree[2 * node] > val){
            return query(2 * node,L,mid,from,val);
        }else if(tree[2 * node + 1] > val){
            return query(2 * node + 1,mid + 1,R,from,val);
        }else{
            return 2e9;
        }
    }else{
        if(R < from)return 2e9;
        return min(query(2 * node,L,mid,from,val),query(2 * node + 1,mid + 1,R,from,val));
    }
}
int main()
{
    FastRead
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> ara[i];
        update(1,1,n,i,ara[i]);
    }

    set<int>st;
    for(int i = 1;i <= n;i++)st.insert(i);

    int done = 0,ans = 1,val = -1;
    while(st.size() > 0){
        auto it = st.upper_bound(done);
        if(it == st.end()){
            done = 0;
            val = -1;
            ans++;
            continue;
        }
        int in = query(1,1,n,*it,val);
        if(in == 2e9){
            done = 0;
            val = -1;
            ans++;
            continue;
        }
        update(1,1,n,in,0);
        done = in;
        st.erase(in);
        val = ara[in];
    }
    cout << ans << "\n";

}




Measured memory_bytes: 6400
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define ar array
#define mxn 2700
#define mod 1000000007
#define ld long double
#define pb push_back
#define inf 1e9+5
#define fi first
#define se second
typedef long long int ll;
using namespace std;
ll a[mxn];
int main(void){
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	fast;
	int n;
	cin>>n;
	if(n<3) puts("0"),exit(0);
	if(n==3) puts("1"),exit(0);
	a[3]=a[4]=a[5]=1,a[6]=2;
	for(int i=7; i<=n; i++) { 
		a[i]=1; 
		for(int j=3; j+3<=i; j++) 
		a[i]+=a[j],a[i]%=mod; 
	}
	printf("%lld\n",a[n]);
}


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

int main() {
	int d;
	cin >> d;
	vector<int> c(30);
	vector<int> co(d+5);

	rep(i,26) {
		cin >> c[i];
	}

	vector<int> last(26);

	rep(i, 26) {
		last[i]=0;
	}

	int coun = 0;

	vector<int> t(d + 5);
	
	rep(j, d) {
		vector<int> s(26);
		int count = 0;

		rep(i, 26) {
			cin >> s[i];
		}
		int max=s[0];
		int max_d=0;

		rep(i, 26) {
			if (max <= s[i]) {
				max = s[i];
				max_d = i;
			}
		}

		last[max_d] = j+1;
		count = max;

		rep(i, 26) {
			count -= c[i] * (j+1-last[i]);
		}
		co[j] = max_d;
	}

	rep(j, d) {
		cout << 24<<endl;
	}

	return 0;
}

Measured memory_bytes: 3632
//import java.io.BufferedReader;
import java.io.IOException;
//import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scan = new Scanner(System.in);

		int n;

		int min_sowa = 1000000;
		int sowa = 0;

		int shukai_p_point;
		int min_p_point;

		n = scan.nextInt();

		List<Integer> list = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			list.add(scan.nextInt());
		}

		//最大座標の取得
		shukai_p_point = list.stream().max(Integer::compareTo).get();
		//最小座標の取得
		min_p_point = list.stream().min(Integer::compareTo).get();

		//中間地点
		int half_p_point;
		half_p_point = (shukai_p_point - min_p_point) / 2;

		//最小座標と最大座標でループ
		for (int i = min_p_point; i <= shukai_p_point; i++) {
			sowa = 0;//初期化

			for (int j = 0; j < list.size(); j++) {
				sowa += (list.get(j) - i) * (list.get(j) - i);
			}

			if (min_sowa > sowa) {
				min_sowa = sowa;
			}
		}

		System.out.println(min_sowa);

	}

}

Measured memory_bytes: 28244
import sys
n = int(input())

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

dp = [sys.maxsize]*n
dp[0] = 0
for i in range(n):
  for j in range(i+1,i+2+1):
    if j<n:
      dp[j]= min(dp[j],dp[i]+abs(a[i]-a[j]))
      
      
print(dp[n-1])

Measured memory_bytes: 13980
w, h, n = map(int, input().split())
x1 = [0]
x2 = [w]
y1 = [0]
y2 = [h]

for i in range(n):
  x, y, a = map(int, input().split())
  if a == 1:
    x1.append(x)
  elif a == 2:
    x2.append(x)
  elif a == 3:
    y1.append(y)
  elif a == 4:
    y2.append(y)

left = max(x1)
right = min(x2)
bottom = max(y1)
top = min(y2)

ans =max(0, right - left)*max(0, top - bottom)
print(ans)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);

using namespace std;

int main(){_
    string s;
    cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3624
N = int(input())
S = [int(input()) for i in range(N)]
a = sum(S)
if a%10:
    print(a)
else:
    if all(n%10==0 for n in S):
        print(0)
    else:
        for n in sorted(S):
            if n%10==0: continue
            print(a-n)
            exit()

Measured memory_bytes: 3060
import math
def C():
    A, B, H, M = map(int, input().split())
    h = 360*H//12 + 360//12*(M/60)
    m = 360*M//60
    angle = abs(h-m)
    print(math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(angle))))
    
C()

Measured memory_bytes: 9496
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

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

vector<int> children[200005];

int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    int a,b;
    REP(i,n-1){
        scanf("%d%d",&a,&b);
        children[a].push_back(b);
        children[b].push_back(a);
    }
    ll adds[200005]={};
    int p,x;
    REP(i,q){
        scanf("%d%d",&p,&x);
        adds[p]+=x;
    }
    ll scores[200005]={};
    int visited[200005]={};
    queue<pair<int,ll>> que;
    que.push(make_pair(1,0));
    visited[1]=1;
    while(!que.empty()){
        auto keep=que.front();
        que.pop();
        int node=keep.first;
        ll score=keep.second+adds[node];
        //printf("###%d %d\n",node,score);
        scores[node]=score;
        visited[node]=1;
        for(auto i : children[node]){
            if(visited[i]==0){
                que.push(make_pair(i,score));
            }
        }
    }
    REP(i,n){
        printf("%lld ",scores[i+1]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 21108
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int l = sc.nextInt();
    int min = Integer.MAX_VALUE;
    int ans = 0;

    for (int i = 1; i <= n; i++) {
      int tmp = (l + i) - 1;
      ans += tmp;
      if (Math.abs(min) > Math.abs(tmp)) {
        min = tmp;
      }
    }

    System.out.println(ans - min);

  }
}

Measured memory_bytes: 35632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	ll T1, T2, A1, A2, B1, B2;
	cin >> T1 >> T2;
	cin >> A1 >> A2;
	cin >> B1 >> B2;

	ll a1 = (A1 - B1)*T1;
	ll a2 = (A2 - B2)*T2;
	if(a1 > 0) {
		a1 = -a1;
		a2 = -a2;
	}
	ll w = a1 + a2;
	if(w < 0) {
		cout << 0 << endl;
		return 0;
	} else if(w == 0) {
		cout << "infinity" << endl;
		return 0;
	}

	ll ret = (a2/w)*2 - 1;
	if((a2%w) == 0) 
		ret--;
	cout << ret << endl;
	return 0;
}

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

public class Main {
  static class Data {
    public final long cost;
    public final long count;

    public Data(long cost, long count) {
      this.cost = cost;
      this.count = count;
    }
  }

  public static void main(String... args) {

    try (Scanner sc = new Scanner(System.in)) {
      long N = sc.nextLong();
      long M = sc.nextLong();
      List<Data> list = new ArrayList<>();
      for (int i = 0; i < N; ++i) {
        list.add(new Data(sc.nextLong(), sc.nextLong()));
      }
      list.sort(
          (a, b) -> {
            if (a.cost > b.cost) {
              return 1;
            }
            if (a.cost < b.cost) {
              return -1;
            }
            return 0;
          });

      long total = 0;
      for (Data d : list) {
        if (d.count < M) {
          total += d.cost * d.count;
          M -= d.count;
        } else {
          total += d.cost * M;
          break;
        }
      }
      System.out.println(total);
    }
  }

}

Measured memory_bytes: 87008
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, d; cin >> a >> b >> c >> d;
	cout << max(0, min(b, d) - max(a, c)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    ll f[1000][15], p[1000][15];
    for(ll i = 0; i < n; i++)
        for(ll j = 0; j < 10; j++)
            cin >> f[i][j];
    for(ll i = 0; i < n; i++)
        for(ll j = 0; j <= 10; j++)
            cin >> p[i][j];
    ll ans = -1e+11;
    for(ll bit = 0; bit < (1<<10); bit++){
        ll check = 0;
        vector<bool> all(n, false);
        for(ll i = 0; i < n; i++){
            ll count = 0;
            for(ll j = 0; j < 10; j++){
                if((bit>>j) & f[i][j]){
                    count++;
                    all[j] = true;
                }
            }
            check+=p[i][count];
        }
        bool zero = true;
        for(ll i = 0; i < n; i++){
            if(all[i]==true) break;
            if(i==n-1) zero = false;
        }
        if(zero==true)
            ans = max(check, ans);
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	int n,k;cin>>n>>k;
		int mi;
	
	int h[n+1],dp[n+1];
	
	for(int i=0;i<n;i++)
{	cin>>h[i];}
	
	dp[0]=0;dp[1]=abs(h[1]-h[0]);
	
	
	for(int i=2;i<n;i++)
	{
	mi=1001010100;
		for(int j=1;j<=k;j++)
		{	if(i>=j)
		mi=min(mi,dp[i-j]+abs(h[i]-h[i-j]));
		else
		break;
		}
		dp[i]=mi;
	}
		cout<<dp[n-1]<<endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<cmath>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
int main() {

   string s, a;
   cin>>s>>a;
   int res = a.size();

   for(int i = 0 ; i < s.size() - a.size() + 1; i++) {
       int ko = 0;
       for(int j = 0; j < a.size(); j++) {
           if(a[j] != s[i + j])ko++;
       }
       res = min(res, ko);
   }
   cout<<res<<endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int a=0;
  int b=0;
  int ba=0;
  
  int ans = 0;
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    if(S[0] != 'B' && S[S.size()-1] == 'A') a++;
    if(S[0] == 'B' && S[S.size()-1] != 'A') b++;
    if(S[0] == 'B' && S[S.size()-1] == 'A') ba++;
    
    
    for(int i = 0; i < S.size() -1; i++){
      if(S[i] == 'A' && S[i+1] == 'B') ans++;
    } 
  }
  cerr << a << " "<< b << " " << ba << " " << ans << endl;
  if(ba == 0){
    ans += min(a,b);
  } else { 
    if(a + b > 0){
      ans += ba + min(a,b);
    }
    if(a+b==0){
      ans += ba-1;
    }
  }
  
  cout << ans << endl;
}

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

using namespace std;
char s[200010];
int main()
{
    cin>>s;
    int len=strlen(s);
    int sum =0;
    for(int i = 0;i<len;i++){
        sum+=s[i]-'0';
    }
    if(sum %9 == 0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }

    return 0;
}


Measured memory_bytes: 3744
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

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

  ll ans = 0;
  rep(i,n){
      ans+=i;
  }
  cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
S = list(map(int,input()))
tmp = 1
nums = []
cont = 0
for s in S:
    if int(s) == tmp:
        cont += 1
    else:
        nums.append(cont)
        cont = 1
        tmp = 1 - tmp
if cont != 0:
    nums.append(cont)
if len(nums) % 2 == 0:
    nums.append(0)
cml = [0]
for n in nums:
    cml.append(cml[-1]+n)
ans = []
for i in range(0,len(cml),2):
    ans.append(cml[min(len(cml)-1,i+K*2+1)]-cml[i])
print(max(ans))

Measured memory_bytes: 10608
#include <stdio.h>

int main(){
	int K,count;
	char S[101];
	
	scanf("%d",&K);
	scanf("%s",&S);
	
	for(count = 0;S[count] |= '\0';count++) {}
	
	if(count <= K){
		printf("%s",S);
	}else{
		for(int i = 0;i<K;i++){
			printf("%c",S[i]);
		}
		printf("...\n");
	}
	return 0;
}

Measured memory_bytes: 3148
/*===================*\
|ID : harryPotter_421  |
|      LANG: C++       |
\*====================*/
#include <iostream>
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define f(j,m,n) for(lli j=m;j<n;j++)
#define harry ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
lli n,m,color[100005];
vector<lli> vec[100005];
lli len(lli v)
       {lli l=0;
       if(color[v]!=-1)
           return color[v];
        for(int i=0;i<vec[v].size();i++)
          {
            l=max(l,len(vec[v][i])+1);
          }
          color[v]=l;
          return l;
      }
int main()
   {harry
    cin>>n>>m;
    lli a,b;
    for(lli i=1;i<=n;i++)
        color[i]=-1;
    for(lli i=1;i<=m;i++)
       {cin>>a>>b;
        vec[a].pb(b);}
    lli ma=0;
    for(lli i=1;i<=n;i++)
        ma=max(ma,len(i));

    cout<<ma;


    }

















Measured memory_bytes: 8576
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	int a,b,x=1,c=0;
	cin>>a>>b;
	while(x<b){
		x--;
		x += a;
		c++;
		}
	cout<<c<<nw;
	return 0;
}

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

ans = 0

# if N % 2 == 0:
#     i = 1
#     while N % 2**i == 0:
#         N //= 2**i
#         ans += 1
#         i += 1

# if N % 3 == 0:
#     i = 1
#     while N % 3**i == 0:
#         N //= 3**i
#         ans += 1
#         i += 1

# if N % 5 == 0:
#     i = 1
#     while N % 5**i == 0:
#         N //= 5**i
#         ans += 1
#         i += 1

# if N % 7 == 0:
#     i = 1
#     while N % 7**i == 0:
#         N //= 7**i
#         ans += 1
#         i += 1

# if N % 11 == 0:
#     i = 1
#     while N % 11**i == 0:
#         N //= 11**i
#         ans += 1
#         i += 1

# if N % 13 == 0:
#     i = 1
#     while N % 13**i == 0:
#         N //= 13**i
#         ans += 1
#         i += 1

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)

prime_list = prime_factorize(N)

if prime_list:
    for prime_num in prime_list:
        if N % prime_num == 0:
            for j in range(1, 100):
                if N < prime_num**j:
                    break
                if N % prime_num**j == 0:
                    # print(prime_num, j)
                    N //= prime_num**j
                    ans += 1
# print(N)
# print(prime_list)
print(ans)


Measured memory_bytes: 9212
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}


Measured memory_bytes: 256
N, T = [int(x) for x in input().split()]
t = [int(x) for x in input().split()]
ans = 0

for i in range(N -1):
	if t[i + 1] -t[i] < T:
		ans += t[i + 1] -t[i]
	else:
		ans += T
ans += T
		
print(ans)

Measured memory_bytes: 25200
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mp make_pair
#define pi pair<int,int>
#define pl pair<long long int,long long int>
#define pb push_back
#define fi first
#define se second
#define len(a) (int)(a).length()
#define sz(a) (int)(a).size()

using namespace std;

ll n, a[3000], dp[3000][3000][2];

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	for (int i=0; i<n; ++i)
		cin >> a[i];
	for (int i=0; i<n; ++i) {
		dp[i][i][0] = a[i];
		dp[i][i][1] = -a[i];
	}
	for (int d=1; d<n; ++d) {
		for (int i=0; i+d<n; ++i) {
			dp[i][i+d][0] = max(a[i] + dp[i+1][i+d][1], a[i+d] + dp[i][i+d-1][1]);
			dp[i][i+d][1] = min(-a[i] + dp[i+1][i+d][0], -a[i+d] + dp[i][i+d-1][0]);
		}
	}
	cout << dp[0][n-1][0] << endl;
	return 0;
}


Measured memory_bytes: 139648
A,B,C,D = input().split()
A = int(A)
B = int(B)
C = int(C)
D = int(D)

if A*B>C*D:
    print(A*B)
elif C*D>A*B:
    print(C*D)
elif A*B==C*D:
    print(A*B)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=998244353;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int x;
    cin>>x;
    int sum=0;
    for(int i=0;i<=360;++i){
        sum+=x;
        if(sum%360==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var list = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        var num = (int)((list[2] + 0.5) / list[0]);

        Console.Write(num * list[1]);
    }
}



Measured memory_bytes: 13268
S = input()
n = len(S)-1
ans = 0
for i in range(1 << n):
    p = 0
    for j in range(n):
        if i >> j & 1 == 0:
            continue
        else:
            ans += int(S[p:j+1])
            p = j+1
    ans += int(S[p:])

print(ans)

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

using lint = long long;

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<lint> xs(n);
    for (auto& x : xs) std::cin >> x;

    std::vector<int> rs(n, 1);
    while (m--) {
        int l, r;
        std::cin >> l >> r;
        --l;
        rs[l] = std::max(rs[l], r);
    }

    for (int i = 1; i < n; ++i) {
        rs[i] = std::max({rs[i], rs[i - 1], i + 1});
    }

    std::vector<lint> dp(n + 1, 0);
    for (int i = n - 1; i >= 0; --i) {
        dp[i] = std::max(dp[i + 1], xs[i] + dp[rs[i]]);
    }

    std::cout << dp[0] << "\n";
}

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

    solve();

    return 0;
}



Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=5e5+5,mod=1e9+7;
int a[N],f[1<<20][2],pre[1<<20];
void add(int &x,int y){
	x=(x+y)%mod;
}
int ksm(int b,int n){
	int res=1;
	while(n){
		if(n&1) res=res*b%mod;
		b=b*b%mod; n>>=1;
	}
	return res;
}
signed main(){
	int n,sum=0,ans=0;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i],a[i]^=a[i-1];
	for(int i=1;i<=n;++i)
		f[a[i]][0]=1;
	for(int i=1;i<n;++i)
		if(a[i]==0) ++sum;
		else{
			add(f[a[i]][0],f[a[i]][1]*(sum-pre[a[i]])%mod);
			add(f[a[i]][1],f[a[i]][0]);
			pre[a[i]]=sum;
		}  
	if(a[n]==0){
		++sum;
		ans=ksm(2,sum-1);
		for(int i=1;i<(1<<20);++i)
			add(ans,f[i][1]);
	}
	else{
		ans=f[a[n]][0]+f[a[n]][1]*(sum-pre[a[n]])%mod;
		ans%=mod;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int N;
    cin >> N;

    deque<ll> dq;

    ll tmp;
    for(int i = 0; i < N; i++){
      cin >> tmp;
      int ind = lower_bound(dq.begin(), dq.end(), tmp) - dq.begin();
      if(ind == 0){
        dq.push_front(tmp);
      }else{
        dq[ind-1] = tmp;
      }
    }

    cout << dq.size() << endl;


    return 0;
}



Measured memory_bytes: 1024
from collections import deque
h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1

WALL = -100
INI = -1
PASSED = 0

S = [[0] * w for _ in range(h)]
for i in range(h):
    tmp = input()
    for j in range(w):
        if tmp[j] == '#':
            S[i][j] = WALL
        else:
            S[i][j] = INI

S[Ch][Cw] = 0
direction = [[0, -1], [-1, 0], [0, 1], [1, 0]]


def dfs(y, x, d):
    d.append((y, x))
    if y == Dh and x == Dw:
        print(S[y][x])
        exit()
    for dy, dx in direction:
        next_y = y + dy
        next_x = x + dx
        if next_y < 0 or next_y >= h or next_x < 0 or next_x >= w:
            continue
        if S[next_y][next_x] == INI:
            #print("y = ", y, "x = ", x, "next_y = ", next_y, "next_x = ", next_x)
            S[next_y][next_x] = S[y][x]
            dfs(next_y, next_x, d)

def bfs(y, x, d):
    for dy in range(-2, 3):
        for dx in range(-2, 3):
            next_y = y + dy
            next_x = x + dx
            if next_y < 0 or next_y >= h or next_x < 0 or next_x >= w:
                continue
            if S[next_y][next_x] == INI:
                d.append((next_y, next_x))
                #print("S[u][x] = ", S[y][x])
                S[next_y][next_x] = S[y][x] + 1
    return False

def show(S):
    for y in range(h):
        for x in range(w):
            if S[y][x] == WALL:
                print("#", end="")
            elif S[y][x] == INI:
                print(".", end="")
            else:
                print(S[y][x], end="")
        print()

d = deque()
d.append((Ch, Cw))
d2 = deque()
while len(d):
    while(len(d)):
        y, x = d.popleft()
        dfs(y, x, d2)

    while len(d2):
        y2, x2 = d2.popleft()
        #print("y2 = ", y2, "x2 = ", x2)
        #show(S)
        bfs(y2, x2, d)

print(-1)

Measured memory_bytes: 104924
from collections import deque


def p_f():
    m, k = map(int, input().split())
    length = 1 << (m + 1)
    n = 1 << m
    if n <= k:
        print(-1)
        exit()

    if m == 1 and k == 0:
        print("0 0 1 1")
        exit()
    elif m == 1 and k == 1:
        print(-1)
        exit()

    d = deque()
    d.append(k)
    for i in range(n):
        if i == k:
            continue
        d.append(i)
        d.appendleft(i)
    d.append(k)
    print(*d)


if __name__ == '__main__':
    p_f()


Measured memory_bytes: 55272
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,c,d;
ll gcd(ll x,ll y) {return (y==0)?x:gcd(y,x%y);}
ll lcd(ll x,ll y) {return x*(y/gcd(x,y));}
int main()
{
    //freopen("C.in","r",stdin);
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> a >> b >> c >> d;
    ll a1=a,a2=a,b1=b,b2=b,e=lcd(c,d),a3=a,b3=b;
    if (a%c!=0) a1+=c-(a%c);
    if (a%d!=0) a2+=d-(a%d);
    if (a%e!=0) a3+=e-(a%e);
    if (b%c!=0) b1-=(b%c);
    if (b%d!=0) b2-=(b%d);
    if (b%e!=0) b3-=(b%e);

    cout << (b-a+1) - ((b1-a1)/c+1+(b2-a2)/d+1) + (b3-a3)/e+1;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

	int N,T;
	int j=0;
	int b[1000];
	cin>>N>>T;
	int a[1000][2];
	for(int i=0;i<N;i++){
		cin>>a[i][0]>>a[i][1];
	}
	for(int i=0;i<N;i++){
		if(a[i][1]<=T){
			b[j]=a[i][0];
			j++;
		}
		
	}
	if(j==0){
		cout<<"TLE"<<endl;
		return 0;
	}
	for(int i=0;i<j-1;i++){
		for(int x=i+1;x<j;x++){
			if(b[i]>b[x]){
				int tmp=b[i];
				b[i]=b[x];
				b[x]=tmp;
			}
		}
	}
	
	cout<<b[0]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main(int argc, char** argv) {
  int n, k;
  cin >> n >> k;
  int i = 0;
  while (n > 0) {
    n /= k;
    ++i;
  }
  cout << i;
  return 0;
}

Measured memory_bytes: 760
n,k = map(int,input().split())
s = input()+'22'
change = []
cnt = 0
for i in range(1,n+2):
  if s[i] == s[i-1]:
    cnt += 1
  else:
    cnt += 1
    change.append(cnt)
    cnt = 0


l = len(change)
ans = [0]*(l)
zero = [0]*(2*k)
change.extend(zero)

if s[0] == '0':
  ans[0] = sum(change[0:2*k])
  for i in range(1,l):
    if i%2 == 1:
      ans[i] = ans[i-1]-change[i-1]+change[i+2*k-1]+change[i+2*k]
    else:
      ans[i] = ans[i-1]-change[i-1]
else:
  ans[0] = sum(change[0:2*k+1])
  for i in range(1,l):
    if i%2 == 1:
      ans[i]= ans[i-1] -change[i-1]
    else:
      ans[i]= ans[i-1]-change[i-1]+change[i+2*k-1]+change[i+2*k]
    
print(max(ans))
      
      
          
  

Measured memory_bytes: 48368
#include <iostream>

using namespace std;

int main() {

	int n, m ,l;
	int a[100][100], b[100][100];
	long int c[100][100];

	cin >> n >> m >> l;


	//??\???
	//??????a
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	//??????b
	for (int j = 0; j < m; j++) {
		for (int k = 0; k < l; k++) {
			cin >> b[j][k];
		}
	}

	//??????c????¨??????¨??¨???
	for (int i = 0; i < n; i++) {
		for (int k = 0; k < l; k++) {
			//?????????
			c[i][k] = 0;
			for (int j = 0; j < m; j++) {
				c[i][k] += a[i][j] * b[j][k];
			}
			cout << c[i][k];
			if (k != l - 1) {
				cout << " ";
			}
			else {
				cout << endl;
			}
		}
	}

	return 0;

}

Measured memory_bytes: 3116
A, B, C=map(int,input().split())
K=int(input())
ab=int(A/B)
if ab==0:
  x=0
else:
  x=int(len(bin(ab))-2)
B1=B*(2**x)
bc=int(B1/C)
if bc==0:
  y=0
else:
  y=int(len(bin(bc))-2)
if x+y<=K:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9100
#include <stdio.h>

void quicksort(int array[], int left, int right) {
    int l = left;
    int r = right;
    int pivot = array[(left + right) / 2]; // 中央からピボットを選択
    int buf;

    while (1) {
        while (array[l] < pivot) l++;
        while (array[r] > pivot) r--;

        if (l > r) break;

        // pivotより小さい値を左、大きい値を右に入れ替え
        buf = array[l];
        array[l] = array[r];
        array[r] = buf;

        l++, r--;
    };

    // pivotより小さい領域と大きい領域をそれぞれ再帰的にソート
    if (left < r)  quicksort(array, left, r);
    if (l < right) quicksort(array, l, right);
}

void quicksort2(int array[],int array2[], int left, int right) {
    int l = left;
    int r = right;
    int pivot = array[(left + right) / 2]; // 中央からピボットを選択
    int buf;

    while (1) {
        while (array[l] < pivot) l++;
        while (array[r] > pivot) r--;

        if (l > r) break;

        // pivotより小さい値を左、大きい値を右に入れ替え
        buf = array[l];
        array[l] = array[r];
        array[r] = buf;
        buf = array2[l];
        array2[l] = array2[r];
        array2[r] = buf;

        l++, r--;
    };

    // pivotより小さい領域と大きい領域をそれぞれ再帰的にソート
    if (left < r)  quicksort2(array,array2, left, r);
    if (l < right) quicksort2(array,array2, l, right);
}


int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  int a[100000],b[100000],c[100000];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(int i=0;i<m;i++){
    scanf("%d %d",&b[i],&c[i]);
  }
  quicksort(a,0,n-1);
  quicksort2(c,b,0,m-1);
  int i=0;
  for(int j=m-1;j>=0;j--){
    for(int k=0;k<b[j];k++) {
      if(a[i]>c[j]) break;
      if(i>=n)goto res;
      a[i++]=c[j];
    }
  }
  long long sum=0;
  res:

  for(int j=0;j<n;j++) sum += a[j];
  printf("%lld",sum);
  return 0;
}

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

#define pb push_back
#define ll long long int
#define mpi map<int, int>
#define vi vector<int>
#define si set<int>
#define pii pair<int, int>
#define vpi vector<pii>
#define vs vector<string>
#define pri priority_queue<int>
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define For(i, n) for (int i = 0; i < n; i++)
#define Ford(i, a, b) for (int i = a; i >= b; i--)
#define Rep(i, x, y) for (int i = x; i <= y; i++)
#define mem(a, b) memset(a, b, sizeof(a))
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

double tick()
{
    static clock_t oldt, newt = clock();
    double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;
    oldt = newt;
    return diff;
}

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;

    For(i, n)
    {
        ll c1 = 0, c2 = 0;
        if (s[i] == 'R')
        {
            Rep(j, i + 1, n - 1)
            {
                if (s[j] == 'G')
                    c1++;
                else if (s[j] == 'B')
                    c2++;
            }
        }
        else if (s[i] == 'G')
        {
            Rep(j, i + 1, n - 1)
            {
                if (s[j] == 'R')
                    c1++;
                else if (s[j] == 'B')
                    c2++;
            }
        }
        else
        {
            Rep(j, i + 1, n - 1)
            {
                if (s[j] == 'G')
                    c1++;
                else if (s[j] == 'R')
                    c2++;
            }
        }
        ans += c1 * c2;
    }
    For(i, n)
    {
        for (int j = 1; 2 * j < n - i; j++)
        {
            if (s[i] != s[i + j] && s[i] != s[i + 2 * j] && s[i + j] != s[i + 2 * j])
            {
                ans--;
            }
        }
    }
    cout << ans << endl;
    cerr << "execution time is: " << tick() << "\n";
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  1000000007;

     signed main(){
     
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    if(n==2){
         cout<<max(a[0],a[1])<<endl;
         return 0;
    }
    int x[n][3];
    x[0][0]=a[0];x[0][1]=MOD*MOD;x[0][2]=MOD*MOD;
    x[1][0]=MOD*MOD;x[1][1]=a[1];x[1][2]=MOD*MOD;
    x[2][0]=a[0]+a[2];x[2][1]=MOD*MOD;x[2][2]=a[2];
    x[3][0]=MOD*MOD;x[3][1]=max(a[1],a[0])+a[3];x[3][2]=MOD*MOD;
    for(int i=4;i<n;i++){
      
              if(x[i-2][0]!=MOD*MOD)x[i][0]=x[i-2][0]+a[i];
              else x[i][0]=MOD*MOD;
         
        
            if(x[i-3][0]!=MOD*MOD)  x[i][1]=x[i-3][0]+a[i];
            else x[i][1]=MOD*MOD;
             if(x[i-3][1]!=MOD*MOD)  x[i][2]=x[i-3][1]+a[i];
            else x[i][2]=MOD*MOD;

        if(x[i-4][0]!=MOD*MOD){
             if(x[i][2]!=MOD*MOD)x[i][2]=max(x[i][2],x[i-4][0]+a[i]);
             else x[i][2]=x[i-4][0]+a[i];
        }
        if(x[i][2]!=MOD*MOD)x[i][2]=max(x[i][2],x[i-2][2]+a[i]);
      else x[i][2]=x[i-2][2]+a[i];
       if(x[i][1]!=MOD*MOD)x[i][1]=max(x[i][1],x[i-2][1]+a[i]);
      else x[i][1]=x[i-2][1]+a[i];
    }
    if(n%2){
         if(n==3)cout<<x[n-2][1]<<endl;
        else  cout<<max(x[n-2][1],x[n-1][2])<<endl;
    }else{
         cout<<max(x[n-2][0],x[n-1][1])<<endl;
       //  cerr<<x[n-2][0]<<' '<<x[n-1][1]<<endl;
    }
      }

        


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

int main() {
 int64_t N;
 cin >> N;
 int64_t sum=0;

for (int i=1; i<=N; i++) {
if (i%3!=0 && i%5!=0) {
 sum += i;
}
}

 cout << sum << endl;
}

Measured memory_bytes: 3584
import sys
import itertools
sys.setrecursionlimit(10000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n = int(input())
    cnt = 0
    flag = 0
    for i in range(n):
        d1,d2 = map(int,input().split())
        if d1 == d2:
            cnt+=1
            if cnt>=3:
                flag = 1
        else:
            cnt = 0
    if flag  == 1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 68052
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x;
		int countDeta;
		int[] deta = new int[10000];
		for (countDeta = 0; countDeta < 10000; countDeta++) {
			x = sc.nextInt();
			if (x == 0) {
				break;
			}
			deta[countDeta] = x;
		}
		for (int i = 0; i < countDeta; i++) {
			System.out.println("Case" + " " + (i + 1) + ": " + deta[i]);
		}
		sc.close();
	}
}


Measured memory_bytes: 43112
#include "bits/stdc++.h"
using namespace std;

long long gcd(long long a, long long b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

long long ge(long long a, long long b) {
	return a / gcd(a, b) * b;
}

int main() {
	
	long long n, k;
	cin >> n >> k;
	long long arr[n];
	for (int i=0; i<n; i++) {
		cin >> arr[i];
	}
	
	long long lc = 1;
	
	for (long long i=0; i<n; i++) {
		lc = ge(lc, arr[i]);
		if (lc >= INT_MAX) {
			cout << 0 << endl;
			exit(0);
		}
	}
	
	long long res = lc / 2;
	for (int i=0; i<n; i++) {
		int ha = arr[i] / 2;
		if (res % arr[i] != ha) {
			cout << 0 << endl;
			exit(0);
		}
	}
	
	cout << k / lc + ((k % lc) >= (lc / 2)) << endl; 
	
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
   int n;
   cin>>n;
   int l=0;
   int p=-1;
   while(true){
       int k=n-7*l;
       if(k<0)
       break;
       if(k%4==0){
           p=1;
           break;
       }
       l++;
   }
   if(p==1) cout<<"Yes";
   else cout<<"No";
}


Measured memory_bytes: 256
H, W = map(int, raw_input().split())
HW = [[0 for i in range(W+1)] for j in range(H+1)]
for i in range(H):
    tmp = map(int, raw_input().split())
    for j in range(W):
        HW[i][j] = tmp[j]
    HW[i][W] = sum(HW[i])
for i in range(W+1):
    tmp = 0
    for j in range(H):
        tmp+=HW[j][i]
    HW[H][i] = tmp
        
    
for i in range(H+1):
    print " ".join(map(str, HW[i]))


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    string s; cin >> s;
    int N = s.size();
    int ans = 0;
    rep(i, N) ans += s[i]-'0';
    ans = max(ans, (s[0]-'0'-1) + 9*(N-1));
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
import math
import itertools

N, D = map(int, input().split())
cnt = 0
L = []

for i in range(N):
    X = list(map(int, input().split()))
    L.append(X)

for i in itertools.combinations(L,2):
    y, z, dis = i[0], i[1], 0
    for a, b in zip(y, z):
        dis += (a-b)**2
    if math.sqrt(dis) == int(math.sqrt(dis)):
        cnt += 1

print(cnt)


Measured memory_bytes: 9072
BEF_STR= "A"
AFT_STR = "Un"

def get_data():
    data = input()
    return data

def make_data_list(num):
    data_list = [None] * num
    for i in range(num):
        data_list[i] = get_data()
    return data_list

#A-Unでワンセットとなるかを確認する関数を作りたい
def check_STR1_to_STR2_correspondence(data_list):
    count = 0
    if len(data_list) % 2 != 0 or data_list[0] == AFT_STR:
        return False
    for s in data_list:
        if s == BEF_STR:
            count += 1
        else:
            count -= 1
            if count < 0:
                return False
    if count != 0:
        return False
    return True

if __name__ == "__main__":
    speak_sum = int(get_data())
    record_list = make_data_list(speak_sum)
    is_A_Un = check_STR1_to_STR2_correspondence(record_list)
    if is_A_Un is False:
        print("NO")
    else:
        print("YES")




Measured memory_bytes: 5600
//判断C是否不小于A，也不大于B。
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    while(cin>>a>>b>>c){


    if(c>=a&&c<=b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
        }
    return 0;
}


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

int n, t, x, mn=2e9, a1, a2;

int main() {
    scanf("%d%d", &n, &t);
    while (n--) {
        scanf("%d", &x);
        if (x - mn > a1) a1 = x-mn, a2 = 1;
        else if (x - mn == a1) a2++;
        mn = min(mn, x);
    }
    printf("%d\n", a2);
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let (a, b, m): (usize, usize, usize) = (read(), read(), read());
    // let mut discp: HashMap<(usize, usize), usize> = HashMap::new();
    let mut av: Vec<usize> = vec![];
    let mut bv: Vec<usize> = vec![];
    for _ in 0..a {
        av.push(read());
    }
    for _ in 0..b {
        bv.push(read());
    }
    let mut ans = std::usize::MAX;
    for _ in 0..m {
        let (r, d, k): (usize, usize, usize) = (read(), read(), read());
        ans = min(av[r - 1] + bv[d - 1] - k, ans);
    }
    av.sort();
    bv.sort();
    println!("{:?}", min(av[0] + bv[0], ans));
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 6396
a = [int(i) for i in input().split()] 
W = a[0]
H = a[1]
x = a[2]
y = a[3]

menseki = W * H / 2
answer = 0
if x == (W/2):
  if y == (H/2):
    answer = 1
print(str(menseki) + " " + str(answer))

Measured memory_bytes: 3064
# assign prize of the 3 places
first = 300000
second = 200000
third = 100000
extra = 400000
no = 0
# get two integers as the competitions
X, Y = map(int, input().split())
# output
if X == 1 and Y == 1:
    {
        print(first + first + extra)
    }
elif X == 1 and Y == 2:
    {
        print(first + second)
    }
elif X == 1 and Y == 3:
    {
        print(first + third)
    }
elif X == 2 and Y == 1:
    {
        print(second + first)
    }
elif X == 2 and Y == 2:
    {
        print(second + second)
    }
elif X == 2 and Y == 3:
    {
        print(second + third)
    }
elif X == 3 and Y == 1:
    {
        print(third + first)
    }
elif X == 3 and Y == 2:
    {
        print(third + second)
    }
elif X == 3 and Y == 3:
    {
        print(third + third)
    }
elif X == 1 and Y > 3:
    {
        print(first + no)
    }
elif X == 2 and Y > 3:
    {
        print(second + no)
    }
elif X == 3 and Y > 3:
    {
        print(third + no)
    }
elif X > 3 and Y == 3:
    {
        print(no + third)
    }
elif X > 3 and Y == 2:
    {
        print(no + second)
    }
elif X > 3 and Y == 1:
    {
        print(no + first)
    }
else:
    {
        print(0 + no)
    }

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int main(int argc, char** argv) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s; cin >> s;
	ll ans = 0;
	for (int i = 0; i < s.size(); i++)
		ans = (ans + s[i] - '0') % 9;
	if (ans == 0)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 3712