akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void){
  int i,num;
  int h1,m1,s1,
      h2,m2,s2;
  int minute;
  int ah[3],am[3],as[3];

  for(i=0;i<3;i++){
    scanf("%d%d%d",&h1,&m1,&s1);
    scanf("%d%d%d",&h2,&m2,&s2);
    minute=(s2-s1)+(m2-m1)*60+(h2-h1)*3600;
    ah[i]=minute/3600;
    minute%=3600;
    am[i]=minute/60;
    minute%=60;
    as[i]=minute;
  }
  for(i=0;i<3;i++){
    printf("%d %d %d\n",ah[i],am[i],as[i]);
  }
  return 0;
}

Measured memory_bytes: 0
N=int(input())
A=[]
xy=[]
for i in range(N):
  A.append(int(input()))
  temp=A[-1]
  xy_temp=[]
  for j in range(temp):
    x, y=map(int, input().split())
    x-=1
    xy_temp.append([x, y])
    
  xy.append(xy_temp)
  
def num2bi(x, k):
  #10進数xを2進数k桁(string)で出力
  out=format(x, '0'+str(k)+'b')
  return out

n=2**N
counter=0
for i in range(n):
  temp=num2bi(i, N)
  a=True
  for i in range(N):
    if temp[i]=='1':
      for j in range(A[i]):
        if temp[xy[i][j][0]]!=str(xy[i][j][1]):
          a=False
        
  if a==True:
    count=0
    for i in range(N):
      if temp[i]=='1':
        count+=1
    counter=max(counter, count)
    
print(counter)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, z, w;
  cin >> n >> z >> w;
  vll a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  ll ans = abs(a[n - 1] - w);
  if (n >= 2) ans = max(ans, abs(a[n - 2] - a[n - 1]));
  cout << ans << endl; 
}

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

int main() {
  ll n;
  cin>>n;
  int a[n];
  int b[100000]={0};
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[a[i]]++;
  }
  int res=0;
  for(int i=0;i<100000;i++){
    int temp;
    if(i==0){
      res=b[0]+b[1];
    }
    else if(i==99999){
      temp=b[99998]+b[99999];
      res=max(res,temp);
    }
    else{
      temp=b[i-1]+b[i]+b[i+1];
      res=max(res,temp);
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
map<int , int> nb;
int32_t main()
{
	int N , K;
	cin >> N >> K;
	int total = 0;
	nb[0] = 1;
	int somme = 0;
	int tS[N + 1];
	tS[0] = 0;
	for (int i  = 0 ; i < N ; i++)
	{
		if (i >= K - 1)
		{
			nb[(((tS[i - K + 1] - (i - K  + 1)  + K) % K) + K) % K]--;
			//cout<<i<<"eee"<<(((tS[i - K + 1] - (i - K  + 1) + K) % K) + K) % K<<endl;

		}
		int actu;
		cin>>actu;
		somme += actu;
		int pp = (((somme - i - 1+ K) % K) + K) % K;
		total += nb[(((somme - i - 1+ K) % K) + K) % K];
		//for (int j = 0 ; j < K ; j++)
		//{
		//	cout<<nb[j]<<" ";
		//}
		//cout<<endl;
		//cout<<total<<endl;
		nb[(((somme - i - 1 + K) % K) + K) % K]++;
		tS[i + 1] = somme;

	}
	cout<<total<<endl;
}

Measured memory_bytes: 14336
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
for i in range(n):
    if a[i]>=b[i]:
        c+=b[i]
    else:
        c+=a[i]
        if a[i+1]>=b[i]-a[i]:
            c+=b[i]-a[i]
            a[i+1]=a[i+1]+a[i]-b[i]
        else:
            c+=a[i+1]
            a[i+1]=0
print(c)

Measured memory_bytes: 18624
//Author : Siriuslight
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0),cout<<setprecision(10)<<fixed;
#define int long long
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const ll inf = 1e9+100, N = 3e3+5, OFF = 3e3;
const ll INF = 1e18+100, MOD = 1e9+7;

ll powmod(ll a,ll b,ll m=MOD){ll r=1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}
ll power(ll a,ll b){ll r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
ll gcd(ll a,ll b){if(!b)return a;return gcd(b,a%b);}
ll inv(ll a, ll m = MOD){return powmod(a,m-2,m);}
ll lcm(ll a,ll b){return(a*b)/gcd(a,b);}

//ordered_set X;
//X.insert(3);
//X.order_of_key(3) no of elements less than 3
//*X.find_by_order(n) nth greatest element(0-indexed)
int n;
ld p[N];
ld dp[N][2 * N];
bool vis[N][2 * N];

ld solve(int id, int hmt){
    if(id == 0)
        return (hmt > OFF);
    if(vis[id][hmt]) return dp[id][hmt];
    vis[id][hmt] = true;
    return dp[id][hmt] = p[id] * solve(id - 1, hmt + 1) + (1.0 - p[id]) * solve(id - 1, hmt - 1);
}

int32_t main(){
    FIO;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> p[i];
    }
    cout << solve(n, OFF);
}


Measured memory_bytes: 299520
#include <stdio.h>//?????¨????????¨
#define H 250
int main() {
  int A[H];
  int count, i;

  scanf("%d",&count);
  for( i=1 ; i<=count ; i++ ) scanf("%d", &A[i]);
  for( i=1 ; i<=count ; i++ ){
    printf("node %d: key = %d, ", i, A[i]);
    if( i!=1 && i%2==0 ) printf("parent key = %d, ", A[i/2]);
    if( i!=1 && i%2==1 ) printf("parent key = %d, ", A[(i-1)/2]);
    if( i*2-1 < count ) printf("left key = %d, ", A[i*2]);
    if( i*2 < count ) printf("right key = %d, ", A[i*2+1]);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	string S, T;
	cin >> S >> T;
	
	T.pop_back();

	if (S == T) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

#include<unordered_set>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 1000000009;
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first	
#define sc  second


using R = long double;

int main() {
	ll n, m, d;
	cin >> n >> m >> d;
	--m;
	R x = (R)(n-d)*m *2/(n*n);
	if(d==0) x = (R)(n - d)*m / (n*n);
	printf("%.10lf\n", (double)x);


	return 0;
}

/*
n d
3 1  1,2 2,3

5 1  1,2 2,3 3,4 4,5

2 1  1,2 2,1

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100001
#define rank dfasodfhdasoif
using namespace std;
vector<int> G[2][100001];
 
/*Union_Find_Tree
  O(a(n))<O(log(n))
*/
 
int par[MAX_N];
int rank[MAX_N];
 
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    rank[i]=0;
  }
}
 
int find(int x){
  if(par[x]==x)return x;
  return par[x]=find(par[x]);
}
 
void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(rank[x]<rank[y])par[x]=y;
  else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}
 
bool same(int x,int y){return find(x)==find(y);}
 
 
int main(){
  int n,w,h,flg=0;
  cin>>n>>w>>h;
  init(n);
   
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    if(x==1||y==1||x==w||y==h)flg=1;
    G[0][x].push_back(i);
    G[1][y].push_back(i);
  }
   
  for(int i=1;i<=h;i++)
    for(int j=1;j<G[1][i].size();j++)unite(G[1][i][j],G[1][i][j-1]);
   
  for(int i=1;i<=w;i++)
    for(int j=1;j<G[0][i].size();j++)unite(G[0][i][j],G[0][i][j-1]);
 
  int cnt=0,used[100001]={};
  for(int i=0;i<n;i++){
    par[i]=find(i);
    cnt+=!used[find(i)];
    used[find(i)]=1;
  }
  if(cnt==1)cout <<n-cnt<<endl;
  else cout <<n+(cnt-1)-flg<<endl;  
    return 0;
}

Measured memory_bytes: 10568
#include <iostream>
using namespace std;
int main()
{
 int H, N ,i, A , sum=0;
  cin>> H;
  cin>> N;
 for (i=0;i<N;i++)
 {
  cin>>A;
  sum=sum+A;
 }
 if(sum>=H)
    cout<<"Yes"<< endl;
 else
    cout<<"No"<< endl;

}

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

struct xy {
	int x, y;
};

int main()
{
	vector<xy> answer;
	while (1) {
		int m, n;
		cin >> m;
		if (m == 0)break;
		vector<xy> seiza, stars;
		xy point;

		{
			int x, y;
			cin >> x >> y;
			point = { x,y };
			seiza.push_back({ 0,0 });
		}

		for (int i = 1; i < m; i++) {
			int x, y;
			cin >> x >> y;
			seiza.push_back({ x - point.x, y - point.y });
			//cout << x - point.x << " " << y - point.y << endl;
		}

		cin >> n;

		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			stars.push_back({ x,y });
		}

		for (int i = 0; i < n; i++) {
			int count = 0;
			for (int j = 0; j < m; j++) {
				for (int k = 0; k < n; k++) {
					if ((stars[i].x + seiza[j].x == stars[k].x) && (stars[i].y + seiza[j].y == stars[k].y)) {
						count++;
					}
				}
			}
			if (count == m) {
				answer.push_back({ stars[i].x - point.x, stars[i].y - point.y });
				break;
			}
		}
	}
	for (int i = 0; i < answer.size(); i++) {
		cout << answer[i].x << " " << answer[i].y << endl;
	}
	return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ar array
#define db double
#define pow pw
const db pi = 3.14159265358979323846;
int pw(int a,int b){
    int ans=1;
    while(b){
    if (b%2) ans*=a;
    a*=a;
    b/=2;
    }
    return(ans);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int ans=0,mx=0;
    for (int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if (i==0) mx=x;
        else
        {
            ans+=max(0ll,mx-x);
            mx=max(mx,x);
        }
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

#define endl "\n"

int main()
{
	faster;
	
	int n;
	cin >> n;
	bool contains = false;
	while(n > 0){
		if(n%10 == 7) contains = true;
		n /= 10;
	}

	cout << (contains ? "Yes" : "No") << endl;
	
	return 0;
}

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

typedef pair<int, int> P;
const int INF = 999999;

int H, W;
char s[50][50];
int x[4] = {-1, 0, 1, 0};
int y[4] = {0, -1, 0, 1};

int d[50][50];

void Main() {
  cin >> H >> W;
  int white_cnt = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> s[i][j];
      if (s[i][j] == '.') white_cnt++;
      d[i][j] = INF;
    }
  }

  queue<P> q;
  q.push(P(0, 0));
  d[0][0] = 0;
  while (q.size() > 0) {
    P point = q.front(); q.pop();
    if (point.second == W - 1 && point.first == H - 1) break;
    for (int i = 0; i < 4; i++) {
      int n_x = point.second + x[i];
      int n_y = point.first + y[i];
      if (n_x < 0 || n_x >= W || n_y < 0 || n_y >= H || s[n_y][n_x] == '#' || d[n_y][n_x] != INF) continue;
      d[n_y][n_x] = d[point.first][point.second] + 1;
      q.push(P(n_y, n_x));
    }
  }
  if (d[H - 1][W - 1] == INF) cout << -1 << endl;
  else cout << white_cnt - d[H - 1][W - 1] - 1 << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
    string s,t,u;
    int a,b;
    
cin >> s;
REP(i,s.size())cout << 'x';
}

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

int n, k;
int a[100000];

int gcd(int a, int b){
    return b ? gcd(b, a % b) : a;
}

int main(){
    cin >> n >> k;
    rep(i, n){
        cin >> a[i];
    }
    int g = a[n - 1];
    rep(i, n - 1){
        g = gcd(g, a[i]);
    }
    int m = *max_element(a, a + n);
    if(k % g == 0 && k <= m){
        cout << "POSSIBLE" << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;   
    }
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<string> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	for (int i = 0; i < n; i++){
		if (i > 0) {
			if (v[i][0] != v[i - 1][v[i-1].size()-1]) {
				cout << "No" << endl;
				return 0;
			}
		}
			for (int j = 0; j < i; j++){
				if (v[i] == v[j]) {
					cout<<"No"<<endl;
						return 0;
				}
			}
			
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll int64_t
#define ld long double
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll,null_type , less<ll>,rb_tree_tag,tree_order_statistics_node_update> set_2i;
typedef tree<ld,null_type , less<ld>,rb_tree_tag,tree_order_statistics_node_update> set_2d;
typedef tree<string,null_type , less<string>,rb_tree_tag,tree_order_statistics_node_update> set_2s;
const ll INF = 99999999999;
string yes = "YES", no = "NO";

void Oli(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ac = a * c;
    ll ad = a * d;
    ll bc = b * c;
    ll bd = b * d;
    cout<<max(max(max(ac,ad),bc),bd);
}
int main()
{
    int times  = 1;
    //cin>>times;
    while( times--) Oli();
    //BY ME
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[5];
    int i;
    for(i=0;i<5;i++)
    {
        cin >> arr[i];
        if(arr[i]==0)
        {
            cout << i+1;
            break;
        }
    }
}

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

int main(){
  long long N,M;
  cin>>N>>M;
  
  if(min(M,N)>=2){
    cout<<M*N - (M+N)*2 +4;
  }
  
  else if(min(M,N)==1 && max(M,N)>=2)
    cout<<M*N-2;
  
  else 
    cout<<1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(998244353)
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

signed main(){

    fastIO

	int n, k;
	cin >> n >> k;
    int a[n];
    for (int &it : a) cin >> it, --it;
    set<int> s;
	vector<int> steps;
	int nxt = a[0];
	steps.pb(0);
	s.insert(0);
	while (s.find(nxt) == s.end()){
		s.insert(nxt);
		steps.pb(nxt);
		nxt = a[nxt];
	} 
	int index = 0;
	for (int i = 0; i < steps.size(); i++){
		if (steps[i] != nxt){
			if (k == 0){
				cout << steps[i]+1 << endl;
				exit(0);
			}
			k--;
		}else{
			index = i;
			break;
		}
	}
	if (index != 0){
		steps.erase(steps.begin(), steps.begin() + index);
	}
	index = k%steps.size();
	cout << steps[index]+1 << endl;
    
    return 0;
}

Measured memory_bytes: 15968
def factorization(n):
    res = []
    tmp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            res.append([i, cnt])
    if tmp != 1:
        res.append([tmp, 1])
    if res == []:
        res.append([n, 1])
    return res


N = int(input())
MOD = 10**9 + 7
fact = [[0, 0]]

for i in range(2, N+1):
    for fi in factorization(i):
        primes = [f[0] for f in fact]
        if fi[0] in primes:
            ind = primes.index(fi[0])
            fact[ind][1] += fi[1]
        else:
            fact.append(fi)

ans = 1
for f in fact:
    ans *= (f[1] + 1)
    ans %= MOD

print(ans)


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(void)
{
	int d;
	scanf("%d",&d);
	while(d--) printf("ACL");
	return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,num[200005],sum[200005],ans=1e18,tot;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&num[i]),sum[i]=sum[i-1]+num[i];
	for(int i=1;i<n;i++) tot=abs(sum[n]-sum[i]*2),ans=min(tot,ans);
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int main(void) {
    int n, coin[] = {500, 100, 50, 10, 5, 1};
    while (cin >> n, n) {
        int ans = 0;
        n = 1000 - n;
        for (int i = 0; n; i++) {
            ans += n / coin[i];
            n %= coin[i];
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2992
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var M = input[1];
            var S = N - M;
            var F = Math.Pow(2, M);

            Console.WriteLine(100 * S * F + 1900 * M * F);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

    private static final long MOD = 1_000_000_007;

    private static long factorial(long n) {
        long ans = 1;
        for (long i = 2; i <= n; i++) {
            ans *= i;
            ans %= MOD;
        }
        return ans;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if (Math.abs(n - m) > 1) {
            System.out.println(0);
            return;
        }
        long ans = factorial(n) * factorial(m) % MOD;
        if (n == m) {
            ans *= 2;
            ans %= MOD;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


   String[] xy = br.readLine().split(" ");
   double x1 = Double.parseDouble(xy[0]);
   double x2 = Double.parseDouble(xy[2]) ;

   double y1 = Double.parseDouble(xy[1]);
   double y2 = Double.parseDouble(xy[3]);
   double distance = Math.pow( x2-x1, 2 ) +Math.pow(y2 - y1 , 2);


   distance = Math.sqrt(distance);
   System.out.println(distance);


  }
}

Measured memory_bytes: 24264
import sys,collections
sys.setrecursionlimit(100000)

INF = float("inf")

X,Y,E = map(int,sys.stdin.readline().split())
xy = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(E)) # multi line with multi param
#uvc = [[0,1,1],[0,2,3],[1,2,1],[2,3,2]]
V = X+Y+2
uvc = [[x+1,y+X+1,1] for x,y in xy]
for i in range(X):
    uvc.append([0,i+1,1])
for i in range(Y):
    uvc.append([X+i+1,V-1,1])
G = {i:{} for i in range(V)}
mG = {i:{} for i in range(V)}

for u,v,c in uvc:
    G[u][v] = c
    G[v][u] = 0 # reverse edge
    mG[u][v] = 0
    mG[v][u] = 0
# print(G)
# print(mG)
def dfs(current,flow):
    if current == V-1:
        return flow
    visited.add(current)
    for nex,nex_c in G[current].items():
        if not nex in visited and nex_c != 0:
            f = dfs(nex,min(flow,nex_c))
            if f != 0:
                mG[current][nex] = mG[current][nex] + f
                G[current][nex] = G[current][nex] - f
                G[nex][current] = G[nex][current] + f
                return f
    return 0

visited = set()
while dfs(0,INF) != 0:
    visited = set()
    # print("mG:",mG)
    # print("G:",G)
    pass
print(sum(mG[0].values()))



Measured memory_bytes: 9656
unittest
{
	assert( [ "3", "2 1 4", "2", "1 1", "2 3" ].parse.expand.solve == "6\n9" );
	assert( [ "5", "7 2 3 8 5", "3", "4 2", "1 7", "4 13" ].parse.expand.solve == "19\n25\n30" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto ts = input.front.split.to!( long[] );
	input.popFront;
	auto m = input.front.to!( long );
	auto pxs = new long[][]( m, 2 );
	foreach( ref px; pxs )
	{
		input.popFront;
		px = input.front.split.to!( long[] );
	}
	
	return tuple( ts, pxs );
}

auto solve( long[] ts, long[][] pxs )
{
	// ドリンクを飲まなかった時の合計必要時間
	auto tt = ts.sum;
	
	// 各ドリンクを飲んだ時の合計必要時間
	auto anss = new long[ pxs.length ];
	foreach( ref ans, px; lockstep( anss, pxs ) )
	{
		ans = tt - ts[ px[ 0 ] - 1 ] + px[ 1 ];		// 合計から飲む前の時間を引いて飲んだ後の時間を足す
	}
	
	return anss.to!( string[] ).join( "\n" );
}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int a, b, c; cin >> a >> b >> c;
  int k; cin >> k;

  int cnt = 0;
  while (b <= a) b *= 2, ++cnt;
  while (c <= b) c *= 2, ++cnt;

  if (k >= cnt) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  int a, b;
  char op;
  cin >> a >> op >> b;
  while(op != '?'){
  if (op == '+') cout << a + b << endl;
  else if (op == '-') cout << a - b << endl;
  else if (op == '*') cout << a * b << endl;
  else if (op == '/') cout << a / b << endl;
  cin >> a >> op >> b;
  }
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3160
n, m = list(map(int, input().split()))
switches = [list(map(int, input().split())) for i in range(m)]
ps = list(map(int, input().split()))

ans = 0
for idx in range(2**n):
    switch_on = [False] * n
    for s in range(n):
        if 2**s & idx > 0:
            switch_on[s] = True

    ok = True
    # ビット上位がN，下位が1
    for lamp in range(m):
        num_on_switch = 0
        for s in switches[lamp - 1][1:]:
            if switch_on[s-1] == True:
                num_on_switch += 1
        
        if num_on_switch % 2 != ps[lamp-1]:
            ok = False
        if not ok:
            break
    
    if ok:
        ans += 1

print(ans)


Measured memory_bytes: 9216
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

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

int main()
{
    ll x,y;
    scanf("%lld%lld",&x,&y);
    if((x+y)%3 != 0) printf("0\n");
    else{
    	ll k = (x+y)/3;
    	ll l = x-k;
    	ll r = y-k;
    	if(l < 0 || r < 0) printf("0\n");
    	else{
    		if(l > r) swap(l,r);
    		ll ans = 1;
    		for(int i = 1;i <= l+r;++i) ans = (ans*i)%MOD;
    		for(int i = 1;i <= l;++i) ans = (ans*inv(i))%MOD;
			for(int i = 1;i <= r;++i) ans = (ans*inv(i))%MOD; 
    		printf("%lld\n",(ans+MOD)%MOD);
		}
	}
    return 0;
} 

Measured memory_bytes: 256
# 13:45~
n, q = map(int, input().split())
s = input()

queries = []
for i in range(q):
    l, r = map(int, input().split())
    queries.append((l, r))

count = [0]*(n+1)

for i in range(n):
    count[i+1] = count[i] + (1 if s[i: i + 2] == 'AC' else 0)


for i, query in enumerate(queries):
    l = query[0]
    r = query[1]
    print(count[r-1] - count[l-1])

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	string s;
	cin >> s;
	int a[4] = {0};
	REP(i,s.size()){
		if(s[i] == 'N') a[0]++;
		if(s[i] == 'W') a[1]++;
		if(s[i] == 'S') a[2]++;
		if(s[i] == 'E') a[3]++;
	}
	if((a[0] == 0 && a[2] !=0 )|| (a[2] == 0 && a[0] !=0 ) 
		|| (a[1] == 0 && a[3] !=0 )|| (a[3] == 0 && a[1] !=0 ) ) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n, m;
	cin >> n >> m;
	vector<string> s(n);
	vector<string> t(n);
	rep(i, n) {
		cin >> s[i];
	}
	rep(i, m) {
		cin >> t[i];
	}
	bool cheak = false;
	rep(i, n - m + 1) rep(j, n - m + 1) {
		bool ok = true;
		rep(k, m) rep(l, m) {
			if (s[i + k][j + l] != t[k][l]) ok = false;
		}
		if (ok) cheak = true;
	}
	puts((cheak) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    	int n,inum;   //initial number
    	cin>>n;
    	
    	if(n/100==(n%100)/10&&n/100==n%10) cout<<n<<endl;   //number check
    	else{
    		inum=n/100;
    		if(n/100>(n%100)/10) cout<<inum*111<<endl;
    		else if(n/100==(n%100)/10&&(n%100)/10>n%10) cout<<inum*111<<endl;
    		else cout<<(inum+1)*111<<endl;
    	}
    	
    	return 0;
    }

Measured memory_bytes: 256
from math import ceil

N = int(input())
T = []
A = []

for _ in range(N):
    t, a = list(map(int, input().split()))
    T.append(t)
    A.append(a)

t_num = T[0]
a_num = A[0]
for i in range(1, N):
    tn = (t_num + T[i] - 1) // T[i]
    an = (a_num + A[i] - 1) // A[i]
    n = max(tn, an)
    t_num = T[i] * n
    a_num = A[i] * n

print(t_num + a_num)


Measured memory_bytes: 9180
n = int(input())
h = list(map(int,input().split()))
lis = []
for i in range(1,n):
  if h[i]<=h[i-1]:
    lis.append(1)
  else:
    lis.append(0)

lis.append(2)
cnt = 0
ans = 0
for k in lis:
  if k== 1:
    cnt += 1
  else:
    ans = max(ans,cnt)
    cnt = 0
    
print(ans)
    
    
    
    

Measured memory_bytes: 64228
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

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

  while (true) {
    int n, w, d;
    cin >> n >> w >> d;
    if (n == 0 && w == 0 && d == 0)
      break;

    vector<pair<int, int>> pieces;
    pieces.push_back({d, w});
    REP(i, n) {
      int p, s;
      cin >> p >> s;
      p--;

      // カットする
      auto t = pieces[p];
      if (s > t.first + t.second) {
        s %= t.first + t.second;
      }
      if (s < t.second) {
        if (s < t.second - s) {
          pieces.push_back({t.first, s});
          pieces.push_back({t.first, t.second - s});
        } else {
          pieces.push_back({t.first, t.second - s});
          pieces.push_back({t.first, s});
        }
      } else {
        s -= t.second;
        if (s < t.first - s) {
          pieces.push_back({s, t.second});
          pieces.push_back({t.first - s, t.second});
        } else {
          pieces.push_back({t.first - s, t.second});
          pieces.push_back({s, t.second});
        }
      }

      pieces.erase(pieces.begin() + p);
    }

    vi ans;
    int size = pieces.size();
    REP(i, size) { ans.push_back(pieces[i].first * pieces[i].second); }
    sort(ALL(ans));
    REP(i, size) { cout << ans[i] << (i == size - 1 ? "\n" : " "); }
  }
  return 0;
}



Measured memory_bytes: 3164
#include <stdio.h>

int main(){
  int i,j,k,n,u,v[101][101];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&u,&k);
    for(j=1;j<=k;j++)scanf("%d",&v[u][j]);
  }
  for(i=1;i<=n;i++){
    k=1;
    for(j=1;j<=n;j++){
      if(v[i][k]==j){
	printf("1");
	k++;
      }
      else printf("0");
      if(j==n)break;
      printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // Initialize
          	var intN = cin.ReadInt;
          	var intM = cin.ReadInt;
            // Process
            // Output
        	WriteLine( intN == intM ? "Yes" : "No" );
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 27544
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	int cnt = 1;
	int i = 1;
	while (cnt < N) {
		if (A[i - 1] == 2) break;
		++cnt;
		i = A[i - 1];
	}
	cout << (cnt == N ? -1 : cnt) << "\n";

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(a) signed(a.size())
using namespace std;

void solve(){
	ll h,w,m;
	cin >> h >> w >> m;
	vector<ll> row(h,0),col(w,0);
	set<pair<ll,ll>> s;
	ll mr=0,mc=0;
	for(ll i=1;i<=m;i++){
		  ll a,b;
		  cin >> a >> b;
		  row[a-1]++;
		  col[b-1]++;
		  s.insert({a-1,b-1});
		  mr = max(mr,row[a-1]);
		  mc = max(mc,col[b-1]);
	}
	ll dec_points = 0;
	for(auto i : s){
		if(row[i.first] == mr && col[i.second] == mc)
		dec_points++;
	}
	ll mrows = count(row.begin(),row.end(),mr);
	ll mcols = count(col.begin(),col.end(),mc);
	cout << mr + mc - (mrows*mcols == dec_points) << "\n";
}

int main() {
    FAST;
    ll t=1;
    //cin>>t;
    while(t--) solve();	
    return 0;
}



Measured memory_bytes: 26696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+9, INF = 0x3f3f3f3f;
int dt[105];

void insertionSort( int n ) {
    for( int i = 1; i < n; ++i ) {
        int v = dt[i];
        int j = i - 1;
        while( j >= 0 && v < dt[j] ) {
            dt[j + 1] = dt[j];
            --j;
        }
        dt[j + 1] = v;
        for( int i = 0; i < n; ++i ) cout << dt[i] << ( i == n - 1 ? '\n' : ' ' );
    }
}

int main( void ) {
    ios::sync_with_stdio( false );
    int n;
    cin >> n;
    for( int i = 0; i < n; ++i ) cin >> dt[i];
    for( int i = 0; i < n; ++i ) cout << dt[i] << ( i == n - 1 ? '\n' : ' ' );
    insertionSort( n );
    return 0;
}



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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  if (regex_match(s, regex("^(dream|dreamer|erase|eraser)+$"))) {
    cout << "YES\n";
  } else
    cout << "NO\n";
  return 0;
}

Measured memory_bytes: 28236
def examA():
    S = SI()
    ans = "Good"
    for i in range(len(S)-1):
        if S[i+1]==S[i]:
            ans = "Bad"
    print(ans)
    return

def examB():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()


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

int main(){
  int n,k;
  cin >> k >> n;
  int a[n];
  rep(i,n){
    cin >> a[i];
  }
  int max_dis =0;
  rep(i,n-1){
  	max_dis = max(max_dis,a[i+1]-a[i]);
  }
  max_dis = max(max_dis,a[0]+k-a[n-1]);
  cout << k-max_dis << endl;
}
  


Measured memory_bytes: 1024
s = input()


def dfs(i,f):
  if i == len(s)-1:
    return sum(list(map(int,f.split("+"))))
  
  return dfs(i+1,f+s[i+1]) + dfs(i+1,f+"+"+s[i+1])

print(dfs(0,s[0]))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#include<math.h>

int main() {
  int n, d, res = 0;
  cin >> n >> d;
  double x, y;
  for(int i = 0; i < n; i++) {
    cin >> x >> y;
    if(sqrt((x*x)+(y*y)) <= d) res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 3804
N,M=gets.split(" ").map(&:to_i)
A=Hash.new(0)
for i in 1..M do
    a,b=gets.split(" ").map(&:to_i)
    A[a]+=1
    A[b]+=1
end
for i in 1..N do
    puts(A[i])
end

Measured memory_bytes: 1788
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
#endif

#ifdef _DEBUG
void init_global_B() {}
#else

#endif

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, K; cin >> N >> K;
    vi x(N + 1, 0); FOR(i, 1, N + 1) cin >> x[i];

    int ans = 0;
    FOR(i, 1, N+1) {
        int dist = min(x[i], K - x[i]) * 2;
        ans += dist;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<bitset>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> l;
	for(int i=0; i<n; i++){
		int li;
		cin >> li;
		l.push_back(li);
	}
	sort(l.rbegin(), l.rend());
	int ans=0;
	for(int i=0; i<k; i++)
		ans += l[i];
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
MOD=10**9+7
ans=0
X=[0]*K
for k in range(1,K+1):
  k=K+1-k
  x=K//k
  if x>1:
    _=pow(x,N,MOD)
    for i in range(x-1):
      _-=X[k*(i+2)-1]
    X[k-1]=_
    ans+=k*_
  else:
    X[k-1]=pow(x,N,MOD)
    ans+=k*X[k-1]
print(ans%MOD)

Measured memory_bytes: 11124
n=int(input())
AC=0
WA=0
TLE=0
RE=0
for i in range(n):
    x=input()
    if(x=="AC"):
        AC+=1
    elif(x=="WA"):
        WA+=1
    if(x=="TLE"):
        TLE+=1
    if(x=="RE"):
        RE+=1
print("AC x",AC)
print("WA x",WA)
print("TLE x",TLE)
print("RE x",RE)



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

int main() {
  int h,n,inf = 1e9;
  cin >> h >> n;
  vector<int>a(n),b(n),dp(h+1,inf);
  rep(i,0,n) cin >> a[i] >> b[i];
  dp[0] = 0;
  rep(i,0,h+1){
    if(dp[i] == inf) continue;
    rep(j,0,n){
      int pos = i+a[j];
      if(pos >= h) pos = h;
      dp[pos] = min(dp[pos],dp[i]+b[j]);
    }
  }
  cout << dp[h] << endl;
}

Measured memory_bytes: 3612
import java.util.*;

public class Main {

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

        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();

        int nowY = 0;
        int nowX = 0;

        int[][] ans = new int[h][w];

        for (int i = 1; i <= n; i++) {
            int a = sc.nextInt();
            while (a > 0) {
                // 奇数行
                if (nowY % 2 == 0) {
                    int decreased = Math.min(w - nowX, a);
                    a -= decreased;
                    for (int j = 0; j < decreased; j++) {
                        ans[nowY][nowX++] = i;
                    }
                    if (nowX == w) {
                        nowY++;
                    }
                }
                // 偶数行
                else {
                    int decreased = Math.min(nowX, a);
                    a -= decreased;
                    for (int j = 0; j < decreased; j++) {
                        ans[nowY][--nowX] = i;
                    }
                    if (nowX == 0) {
                        nowY++;
                    }
                }
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w - 1; j++) {
                System.out.print(ans[i][j] + " ");
            }
            System.out.println(ans[i][w - 1]);
        }
    }
}

Measured memory_bytes: 32220
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N,p,w,g,y=0;
    
    cin >>N;
    for (int i=0; i<N; i++){
        string B;
        cin >> B;

        if (B=="Y") y=1;
    }
    if (y==0) cout << "Three"<<endl;
    else cout <<"Four" <<endl;
}

Measured memory_bytes: 256