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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

typedef long long ll;

using namespace std;

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

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a,b,c,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;

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

       cin >> s;
       rep(i,s.size()){
           if(s[i]=='1'){
               ans++;
           }
       }
       Cout(ans);
return 0;
}


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

using namespace std;

//vector<int> G[100010];
struct edge { int to, cost; };
vector<edge> G[100010];

int V[100010];
bool is_visited[100010];

void cal(int v, int parity) {
    if (is_visited[v]) return;
    is_visited[v] = true;
    V[v] = parity;
    for (int i = 0; i < G[v].size(); ++i) {
        int to = G[v][i].to;
        int cost = G[v][i].cost;
        if (is_visited[to]) continue;
        cal(to, (parity + cost) % 2);
    }
}

int main() {
    int N;
    int v;
    int u;
    int w;

    cin >> N;

    for (int i = 0; i < N - 1; ++i) {
        cin >> v >> u >> w;
        G[v].push_back({u, w});
        G[u].push_back({v, w});
    }
    
    cal(1, 0);

    for (int i = 1; i <= N; ++i) {
        cout << V[i] << endl;
    }
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;

int main(){
    int c[3][3];
    rep(i,3)rep(j,3)cin>>c[i][j];
    bool ok=true;
    int de[3]={};
    rep(i,3){
        de[i]=c[1][i]-c[0][i];
    }
    if(de[0]!=de[1]||de[1]!=de[2])ok=false;
    rep(i,3){
        de[i]=c[2][i]-c[1][i];
    }
    if(de[0]!=de[1]||de[1]!=de[2])ok=false;
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
//#include"stdc++.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define md 1000000007
#define pb push_back
#define pi pair<ll,ll>
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
ll min(ll a,ll b)
{
    if(a<b)
        return a;
    return b;
}
#define cases ll t;cin>>t;while(t--)
ll n;
vector<vector<ll> > adj(100005);
ll dp[100005][2];
bool visited[100005];
void dfs(ll u)
{
    visited[u]=true;
    ll white=1,pro=1;
    for(auto &i:adj[u])
    {
        if(!visited[i])
        {
            dfs(i);
            white=(white*dp[i][0])%md;
            pro=(pro*(dp[i][0]+dp[i][1]))%md;
        }
    }
        dp[u][0]=pro;
        dp[u][1]=white;
}
int main()
{
    memset(visited,false,sizeof(visited));
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        ll a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    dfs(1);
    cout<<(dp[1][0]+dp[1][1])%md<<endl;
    return 0;
}


Measured memory_bytes: 12928
N = int(input())
ans = N//11
ans1 = N % 11
if(ans1 >= 7):
  ans2 = ans * 2 + 2
elif(ans1 <= 6) and (ans1 >= 1):
  ans2 = ans * 2 + 1
else:
  ans2 = ans * 2
print(ans2)


Measured memory_bytes: 38384
from math import floor, ceil

A, B = map(int,input().split(" "))

#print(A/0.08,B/0.10)

candidates = [floor(A/0.08),ceil(A/0.08),floor(B/0.10),ceil(B/0.10)]

#print(candidates)

ans = -1
for candidate in candidates:
    #print(candidate*0.08,candidate*0.10)
    if floor(candidate*0.08) == A and floor(candidate*0.10) == B:
        ans = candidate
        break
print(ans)

Measured memory_bytes: 38384
n = int(input())
V = list(map(int, input().split(' ')))
V.sort()
for i in range(n - 1):
  tmp1 = V[i]
  tmp2 = V[i + 1]
  tmp3 = (tmp1 + tmp2) / 2
  V[i + 1] = tmp3
print(V[n - 1])

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

int main(){
  double h,w,x,y;
  cin>>h>>w>>x>>y;
  double ans=h*w/2;
  printf("%.10f",ans);
  if(h/2==x&&w/2==y) cout<<" 1";
  else cout<<" 0";
}


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

using namespace std;

void solve()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
	}
	long long int minAns = 1e18;
	long long int sum = 0;
	bool isPlus = true;
	long long int ans = 0;
	for (int i = 0; i < N; ++i)
	{
		sum += a[i];
		if (isPlus)
		{
			if (sum >= 0)
			{
				ans += sum + 1;
				sum = -1;
			}
		}
		else
		{
			if (sum <= 0)
			{
				ans += abs(sum) + 1;
				sum = 1;
			}
		}
		isPlus = !isPlus;
	}
	minAns = min(minAns, ans);
	isPlus = false;
	sum = 0;
	ans = 0;
	for (int i = 0; i < N; ++i)
	{
		sum += a[i];
		if (isPlus)
		{
			if (sum >= 0)
			{
				ans += sum + 1;
				sum = -1;
			}
		}
		else
		{
			if (sum <= 0)
			{
				ans += abs(sum) + 1;
				sum = 1;
			}
		}
		isPlus = !isPlus;
	}
	minAns = min(minAns, ans);
	cout << minAns << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(3, 0);
	for(int i=0; i<n; i++){
		int tmp;
		cin >> tmp;
		if(tmp%4==0) a[2]++;
		else if(tmp%2==0) a[1]++;
		else a[0]++;
	}
	
	if(a[1]==0 && a[0]<=a[2]+1){
		cout << "Yes" << endl;
	}else if(a[1]!=0 && a[0]<=a[2]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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


long long  INF=1000000000000000000;
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<long long >weight;
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main(){

int N,M;
cin>>N>>M;

int A[N+1]={};

int a,b;
for(int i=0;i<M;i++){
cin>>a>>b;
A[a]++;
A[b]++;
}

for(int i=0;i<=N;i++){
    if(A[i]%2!=0){
        cout<<"NO"<<endl;
        return 0;
    }
}
cout<<"YES"<<endl;
 return 0;
}

Measured memory_bytes: 640
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
//typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class UnionFind{
	public:
	vi parent;
	vi dist;
	UnionFind(int x=1){
		parent=vi(x,-1);
		dist=vi(x);
	}
	int find(int x){
		if(parent[x]<0)return x;
		int r=find(parent[x]);
		dist[x]+=dist[parent[x]];
		return parent[x]=r;
	}
	Def depth(int x){
		find(x);
		return dist[x];
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	int size(int x){
		return -parent[find(x)];
	}
	void unite(int x,int y,Def k=0){
		k+=depth(y);
		k-=depth(x);
		k*=-1;
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(size(x)<size(y)){
			swap(x,y);
			k*=-1;
		}
		parent[x]+=parent[y];
		parent[y]=x;
		dist[y]=k;
	}
};
int main(){
	int n,q;
	while(cin>>n>>q,n){
		UnionFind T(n);
		for(int i=0;i<q;i++){
			char type;
			int x,y;
			cin>>type>>x>>y;
			x--;y--;
			if(type=='!'){
				int a;
				cin>>a;
				T.unite(x,y,a);
			}else{
				if(!T.same(x,y))printf("UNKNOWN\n");
				else printf("%lld\n",T.depth(x)-T.depth(y));
			}
		}
	}
	return 0;
}



Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main() {
    string s,t;
    int cnt = 0;
    cin >> s >> t;
    for(int i = 0;i < 3;i++){
        if(s[i] == t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

ans = 12*(10**5)+1
for i in range(2**n):
    a = [0] * m
    cs = 0
    for j in range(n):
        if (i >> j) & 1:
            cs += ca[j][0]
            for k in range(1, m+1):
                a[k-1] += ca[j][k]
    flag = True
    for j in range(m):
        if a[j] < x:
            flag = False
            break
    if flag:
        ans = min(ans, cs)
if ans == 12*(10**5)+1:
    ans = -1
print(ans)

Measured memory_bytes: 9120
#include<stdio.h>

int main() {

	int i = 0, x[3000], y[3000], x1, y1;

	do {
		scanf("%d %d", &x[i], &y[i]);

		if (x[i] == 0 && y[i] == 0)
			break;

		i++;
	} while (1);

	i = 0;

	do {
		if (x[i] == 0 && y[i] == 0)
			break;
		if (x[i] < y[i]) {
			x1 = x[i];
			y1 = y[i];
		}
		else {
			x1 = y[i];
			y1 = x[i];
		}
		printf("%d %d\n", x1, y1);

		i++;
	} while (1);

	return 0;
}

Measured memory_bytes: 624
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <bits/stdc++.h>
const int maxn = 1e5;
using namespace std;
int a[maxn];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	sort(a, a + n);
	long long sum = 0;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (i == 0)
			cnt++;
		else if (i > 0 && i < n - 1){
			if (a[i] == a[i - 1])
				cnt++;
			else {
				if (cnt < a[i - 1])
					sum += cnt;
				else 
					sum += cnt - a[i - 1];
				cnt = 1;
			}
		}
		else {
			if (a[i] != a[i - 1]) {
				if (cnt < a[i - 1])
					sum += cnt;
				else
					sum += cnt - a[i - 1];
				sum++;
			}
			else {
				cnt++;
				if (cnt < a[i])
					sum += cnt;
				else
					sum  += cnt - a[i];	
			}
		}
	}
	if (n != 1) 
		cout << sum << endl;
	else {
		if (a[0] == 1)
			cout << "0" << endl;
		else
			cout << "1" << endl;
	}
	return 0;
} 

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


int main(){
  int n;
  int m;
  cin >> n >> m;
  vector<int> k(n);
  vector<vector<int> > a(n);

  rep(i, n){
    int b;
    cin >> b;
    k[i] = b;
    rep(j, b){
      int c;
      cin >> c;
      c--;
      a[i].push_back(c);
    }
  }

  vector<int> ans(m);

  for(int i = 0; i < n; ++i){
    for(int j = 0; j < k[i]; ++j){
      ans[a[i][j]]++;
    }
  }

  int tmp = 0;
  for(int i = 0; i < m; ++i){
    if(ans[i] == n)  tmp++;
  }
  cout << tmp << endl;
}


Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]
ansl = [1] * N
height = [int(x) for x in input().split()]
for i in range(M):
  a, b = [int(x)-1 for x in input().split()]
  if height[a] <= height[b]:
    ansl[a] = 0
  if height[b] <= height[a]:
    ansl[b] = 0
print(sum(ansl))

Measured memory_bytes: 20756
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : September 01, 2020 3:53 PM
 *    Problem Name  : A - 500 Yen Coins
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc150/tasks/abc150_a
 *    @genarated by : ai-virtual-assistant
**/

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

int main(){
    ios_base::sync_with_stdio(false);

    int k,x;
    cin >> k >> x;

    if(k*500 < x) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0 ;
}


Measured memory_bytes: 3580
import itertools

n,m,q = map(int,input().split())

a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q

for i in range(q):
  a1,b1,c1,d1 = map(int,input().split())
  a[i] = a1
  b[i] = b1
  c[i] = c1
  d[i] = d1

x = itertools.combinations_with_replacement(range(1,m+1),n)
tmp = 0
ans = 0
for xi in x:
  tmp = 0

  for i in range(q):
    if xi[b[i]-1] - xi[a[i]-1] == c[i]:
      tmp += d[i]
  ans = max(ans,tmp)

print(ans)

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

const int mod=1e9+7;

int h,w;
string arr[1010];
ll dp[1010][1010];

int main()
{
    cin>>h>>w;
    for(int i=0;i<h;i++)
        cin>>arr[i];
    for(int i=0;i<w;i++)
        dp[h-1][i]=0;
    for(int i=0;i<h;i++)
        dp[i][w-1]=0;

    for(int i=w-2;i>=0;i--)
        if(arr[h-1][i]!='#')
            dp[h-1][i]=1;
        else
            break;
    for(int i=h-2;i>=0;i--)
    {
        if(arr[i][w-1]!='#')
            dp[i][w-1]=1;
        else
            break;
    }

    for(int i=h-2;i>=0;i--)
    {
        for(int j=w-2;j>=0;j--)
        {
            if(arr[i][j]=='.')
                dp[i][j]=(dp[i+1][j]+dp[i][j+1])%mod;
            else
                dp[i][j]=0;
        }
    }
    cout<<dp[0][0];
    return 0;
}



Measured memory_bytes: 9216
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(void){
  int i,j,k,l;
  int card[5];
  int poker_hand;
  bool flag;

  while(true){
    poker_hand=0;
    for(i=0;i<5;i++){
      if(scanf("%d,",&card[i])==EOF)return(0);
    }
    sort(card,card+5);
    for(i=0;i<4;i++){
      if(card[i]==card[i+1])poker_hand=1;
    }
    if(card[0]==card[1]&&card[2]==card[3])poker_hand=2;
    if(card[0]==card[1]&&card[3]==card[4])poker_hand=2;
    if(card[1]==card[2]&&card[3]==card[4])poker_hand=2;
    for(i=0;i<3;i++){
      if(card[i]==card[i+1]&&card[i]==card[i+2])poker_hand=3;
    }
    flag=true;
    for(i=1;i<5;i++){
      if(card[i]!=card[0]+i)flag=false;
    }
    if(flag)poker_hand=4;
    flag=true;
    if(card[0]==1&&card[1]==10){
      for(i=1;i<4;i++){
	if(card[i+1]!=card[1]+i)flag=false;
      }
    }else{
      flag=false;
    }
    if(flag)poker_hand=4;
    if(card[0]==card[1]&&card[0]==card[2]&&card[3]==card[4])poker_hand=5;
    if(card[0]==card[1]&&card[2]==card[3]&&card[2]==card[4])poker_hand=5;
    if(card[0]==card[3])poker_hand=6;
    if(card[1]==card[4])poker_hand=6;

    
    switch (poker_hand) {
      case 0:
	printf("null\n");
	break;
      case 1:
	printf("one pair\n");
	break;
      case 2:
	printf("two pair\n");
	break;
      case 3:
	printf("three card\n");
	break;
      case 4:
	printf("straight\n");
	break;
      case 5:
	printf("full house\n");
	break;
      case 6:
	printf("four card\n");
	break;
    }
  }
  return(0);
}

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

using namespace std;

int main() {
    unsigned int n, q;
    cin >> n >> q;

    vector<stack<int> > st(n);
    while (q--) {
        int op, t;
        cin >> op >> t;
        if (op == 0) {
            int x;
            cin >> x;
            st[t].push(x);
        } else if (op == 1) {
            if (st[t].empty()) continue;
            cout << st[t].top() << endl;
        } else if (op == 2) {
            if (st[t].empty()) continue;
            st[t].pop();
        }
    }
    return 0;
}


Measured memory_bytes: 4324
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
const int mod = 1000000007;
const int max_n = 200005;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    string s;cin >> s;
    if(s=="SAT")cout << 1 <<endl;
    if(s=="FRI")cout << 2 <<endl;
    if(s=="THU")cout << 3 <<endl;
    if(s=="WED")cout << 4 <<endl;
    if(s=="TUE")cout << 5 <<endl;
    if(s=="MON")cout << 6 <<endl;
    if(s=="SUN")cout << 7 <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

string S;


int main(void) {

	int A, B, X;
	
	cin >> A >> B >> X;

	if (A > X) {
		printf("NO");
	}
	else if (A + B >= X) {
		printf("YES");
	}
	else {
		printf("NO");
	}

	return 0;
}

Measured memory_bytes: 256
s = input()
s_0 = s[:]
s_0 = s_0.replace('A', '.').replace('G', '.').replace('C', '.').replace('T', '.')
count = 0
ans = 0

for i in range(len(s_0)):
    if s_0[i] == '.':
        count += 1
        if ans < count:
            ans = count
    else:
        count = 0

print(ans)

Measured memory_bytes: 3064
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n = inp()

a = inlist()
count = [0] * (100001)

for i in a:

    count[i] += 1
    if i > 0:
        count[i-1] += 1
    count[i+1] += 1

m = 0
ind = 0
print(max(count))


Measured memory_bytes: 13964
def solve():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    if sum(A) < sum(B):
        return -1
    AB = [a - b for a, b in zip(A, B)]
    plus = [x for x in AB if x > 0]
    minus = [x for x in AB if x < 0]
    t = sum(minus)
    ans = len(minus)
    for m in sorted(plus, reverse=True):
        if t >= 0:
            break
        t += m
        ans += 1
    return ans
print(solve())


Measured memory_bytes: 18356
import sys
from io import StringIO
import unittest


def resolve():
    n = int(input())
    s = [input() for _ in range(n)]

    print(len(set(s)))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3
apple
orange
apple"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """5
grape
grape
grape
grape
grape"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """4
aaaa
a
aaa
aa"""
        output = """4"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 42820
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main() {
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    int kai,ans=0;
    while(1){
        kai=0;
        rep(i,n){
            if(a[i]%2==0){
                kai++;
            }
        }
        if(kai==n){
            ans++;
            rep(i,n){
                a[i]=a[i]/2;
            }
        }
        else{            
            break;
        }
    }
    cout<<ans<<endl;
}


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

int main() {
  string s;
  getline(cin, s);
  for (int i = 0; i < s.size(); ++i) {
    if (s.at(i) >= 'a' && s.at(i) <= 'z') s.at(i) += 'A' - 'a';
    else if (s.at(i) >= 'A' && s.at(i) <= 'Z') s.at(i) += 'a' - 'A';
  }
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <set>
#include <map>

using namespace std;

typedef pair<int, int> P;

int main(){
    map<P, int> mp;
    int N;
    int cnt_max = 0;
    cin >> N;
    int x[50], y[50];
    for(int i = 0; i < N; i++) cin >> x[i] >> y[i];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i == j) continue;
            int p = x[i]-x[j];
            int q = y[i]-y[j];
            if(mp.count(P(p, q)) == 0){
                mp[P(p, q)] = 1;
            }else{
                mp[P(p, q)]++;
            }
            
        }
    }
    for(auto iter = mp.begin(); iter != mp.end(); iter++){
        cnt_max = max(cnt_max, iter->second);
    }
    cout << N-cnt_max << endl;
}

Measured memory_bytes: 384
from operator import itemgetter

N = int(input())
SP = []
for i in range(N):
  s,p=input().split()
  SP.append([s,int(p)])

A = sorted(SP, key = itemgetter(1), reverse = True)
A = sorted(A, key = itemgetter(0))

for x in A:
    ans = SP.index(x)
    print(ans + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max({a*c,a*d,b*c,b*d}) << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<string>


using namespace std;



int main(void){
    string X;
    cin>>X;
    int Y,M,D;
    Y=(X[0]-'0')*1000+(X[1]-'0')*100+(X[2]-'0')*10+(X[3]-'0');
    M=(X[5]-'0')*10+(X[6]-'0');
    D=(X[8]-'0')*10+(X[9]-'0');
    
    if(Y>=2020){
        cout<<"TBD"<<endl;
    
    }else if(Y<=2018){
        cout<<"Heisei"<<endl;
    }else if(M>=5){
        cout<<"TBD"<<endl;
    }else{
        cout<<"Heisei"<<endl;
    }

          
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n >> k;
  int ans = 0;
  for (; n; n /= k, ++ans);
  cout << max(1, ans) << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if ((a+b) % 2 == 0) {
        cout << "Alice" << endl;
    } else {
        cout << "Borys" << endl;
    }
    return 0;
}


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010, M = 110;

int n;
int a[N];
int cnt[N];

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i ++ )
	{
		int x;
		scanf("%d", &x);
		a[i] = x;
		cnt[x] ++ ;
	} 
	
	LL tot = 0;
	for (int i = 1; i <= n; i ++ ) tot += (LL)cnt[i] * (cnt[i] - 1) / 2LL;
	
	for (int i = 0; i < n; i ++ )
	{
		LL t = tot;
		int x = a[i];
		t -= (LL)cnt[x] * (cnt[x] - 1) / 2LL;
		t += (LL)(cnt[x] - 2) * (cnt[x] - 1) / 2LL;
		printf("%lld\n", t);
	}
	return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner  sc= new Scanner (System.in);
		String M1 = sc.next();
		String D1 = sc.next();
		String M2 = sc.next();
		String D2 = sc.next();

		if(M1.equals(M2)) {
			System.out.println("0");
		}else{
			System.out.println("1");
		}
	}

}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main() {
  int N, s1, s2, s3;
  cin >> N;
  for(int i = 0; i < N; ++i) {
	cin >> s1 >> s2 >> s3;
	if(s1*s1 + s2*s2 == s3*s3) cout << "YES" << endl;
	else if(s2*s2 + s3*s3 == s1*s1) cout << "YES" << endl;
	else if(s1*s1 + s3*s3 == s2*s2) cout << "YES" << endl;
	else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 3044
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <complex>
#include <queue>
#include <stack>


#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const ld pi = acos(-1.0);
const ld e  = exp(1.0);

const int N = 50;
ll k;
ll a[N];

void invstep(){
	ll* x = min_element(a, a+N);
	(*x) = (*x) + N;
	for(int i =0; i<N; i++) if(a+i != x) a[i]--;
}

int main(){
	
	cin >> k;
	for(int i=0; i<N; i++) a[i] = i;
	for(int i=0; i<N; i++) a[i] += (k/N);
	for(int i=0; i<k%N; i++) invstep();
	printf("%d\n", N);
	for(int i=0; i<N; i++){
		printf("%lld", a[i]);
		if(i<N-1) printf(" ");
	}
	printf("\n");
    return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import qualified Data.IntMap as M
import Data.Maybe (fromJust)
import Data.List

main = do
  [n,x] <- map read . words <$> getLine :: IO [Int]
  a <- getIntListBC
  print $ min (solve a x x) (solve (reverse a) x x)


bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getIntListBC :: IO [Int]
getIntListBC = map bsToInt . BC.words <$> BC.getLine

solve :: [Int] -> Int -> Int -> Int
solve [] _ _ = 0
solve (a:as) x r = if r >= a then solve as x $ x - a
                             else (+(a - r)) . solve as x $ x - r


Measured memory_bytes: 14844
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////

int main(){
    string str;
    getline(cin,str);
    int N = str.length();
    integer ans = 0;

        for (int b = 0; b < (1<<(N-1)); b++){
            integer nans = 0;
            stringstream ss(str);
            string tmp = "";

                REP(i,N-1){ //bit loop
                    tmp += ss.get();
                    if (b & (1<<i)){ //i-th digit(bitにi-thのフラグが立っているかどうか)
                        nans += stoll(tmp);
                        tmp = "";
                    }
                }
            
            tmp += ss.get();
            nans += stoll(tmp);
            ans += nans;
            //PRINTD(nans);
        }

    PRINTLLD(ans);
}

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

int main(){
  LL a,b,c,d;
  cin >> a >> b >> c >> d;
  
  LL ansA = max(a*c,a*d);
  LL ansB = max(b*c,b*d);
  
  cout << max(ansA,ansB);
  
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
  long long n,mi=10000000000,ma=-10000000000,t;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> t;
    ma=max(ma, t-mi);
    mi=min(mi, t);
  }
  cout << ma << endl;
  return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main()
{
    string s,t;
    cin >> s >> t;
    cout << t << s;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
for(int i = 0; i < n; i++) {
  if(s[i] != s[i+1]) {
    ans++;
  }
}
cout << ans << endl;

}


Measured memory_bytes: 512
type t = { v : int; w : int }

let solve n w a =
  let z = 100*n in
  let t = Array.make (z + 1) (w + 1) in
  t.(0) <- 0;
  for i = 0 to n - 1 do
    for j = z downto a.(i).v do
      if t.(j - a.(i).v) + a.(i).w < t.(j) then
        t.(j) <- t.(j - a.(i).v) + a.(i).w
    done
  done;
  let rec doit i =
    if i < 0 then assert false
    else if t.(i) <= w then i
    else doit (i - 1) in
  doit z

let () =
  let (n, w) = Scanf.scanf "%d %d " (fun n w -> n, w) in
  Array.init n (fun _ -> Scanf.scanf "%d %d " (fun v w -> { v; w }))
  |> solve n w |> Printf.printf "%d\n"

Measured memory_bytes: 2540
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n = get_int()
    if n == 1:
        print(1)
        return
    X, Y = get_data(n, [int, int])
    vecs = Counter()
    for i in range(n):
        for j in range(i+1, n):
            if X[i] > X[j] or (X[i] == X[j] and Y[i] > Y[j]):
                vecs[(X[i]-X[j], Y[i]-Y[j])] += 1
            else:
                vecs[(X[j]-X[i], Y[j]-Y[i])] += 1
    print(n-vecs.most_common()[0][1])
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;


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


Measured memory_bytes: 256
import java.util.Scanner;

class Dice{
	int[] dice = new int[7];
	
	void Setdice(int[] box)
	{
		dice[0] = 0;
		for(int i = 1;i< 7;i++)
		{
			dice[i] = box[i - 1];
		}
	}
	
	void diceroll(char[] roll)
	{
		for(int i = 0;i < roll.length;i++)
		{
			int temp =0;
			if(roll[i] == 'N'){
				temp = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[6];
				dice[6] = dice[5];
				dice[5] = temp;
			}else if(roll[i] == 'E'){
				temp = dice[1];
				dice[1] = dice[4];
				dice[4] = dice[6];
				dice[6] = dice[3];
				dice[3] = temp;
			}else if(roll[i] == 'S'){
				temp = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[6];
				dice[6] = dice[2];
				dice[2] = temp;
			}else if(roll[i] == 'W'){
				temp = dice[1];
				dice[1] = dice[3];
				dice[3] = dice[6];
				dice[6] = dice[4];
				dice[4] = temp;
			}else if(roll[i] == 'R'){
				temp = dice[2];
				dice[2] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[4];
				dice[4] = temp;
			}else if(roll[i] == 'L'){
				temp = dice[2];
				dice[2] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[3];
				dice[3] = temp;
			}
		}
	}
	
	int Getdice(int num)
	{
		return dice[num];
	}
}

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		Dice dice = new Dice();
		int[] box = new int[6];
		for(int i = 0;i < 6;i++)
		{
			box[i] = scan.nextInt();
		}
		int questions = scan.nextInt();
		
		for(int i = 0;i < questions;i++)
		{
			dice.Setdice(box);
			int top = scan.nextInt();
			int front = scan.nextInt();
			String str = "";
			
			for(int j = 1;j < 7;j++)
			{
				if(top == dice.Getdice(j))
				{
					switch(j)
					{
						case 1:
							break;
						case 2:
							str = "N";
							break;
						case 3:
							str = "W";
							break;
						case 4:
							str = "E";
							break;
						case 5:
							str = "S";
							break;
						case 6:
							str = "SS";
							break;
						default:
							break;
					}
				}
			}
			dice.diceroll(str.toCharArray());
			
			for(int j = 2;j < 6;j++)
			{
				if(front == dice.Getdice(j))
				{
					switch(j)
					{
						case 2:
							System.out.println(dice.Getdice(3));
							break;
						case 3:
							System.out.println(dice.Getdice(5));
							break;
						case 4:
							System.out.println(dice.Getdice(2));
							break;
						case 5:
							System.out.println(dice.Getdice(4));
							break;
						default:
							break;
					}
				}
			}
		}
	}
}

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

using namespace std;

const int MOD=1000000007;

int N;
int A[10005];
int cnt[1000005];
int ans=1;

inline int fpow(int a, int b)
{
	int ret=1;
	for (; b; b>>=1)
	{
		if (b&1) ret=1LL*ret*a%MOD;
		a=1LL*a*a%MOD;
	}
	return ret;
}

inline int inv(int x)
{
	return fpow(x,MOD-2);
}

int main()
{
	cin >> N;
	for (int i=1; i<=N; i++) cin >> A[i];
	for (int i=1; i<=N; i++)
	{
		vector<int> f;
		int x=A[i];
		for (int j=2; j*j<=x; j++)
		{
			while (x%j==0)
			{
				f.push_back(j);
				x/=j;
			}
		}
		if (x!=1) f.push_back(x);
		sort(f.begin(),f.end());
		vector< pair<int,int> > v;
		for (size_t j=0; j<f.size(); )
		{
			size_t pos=j;
			while (pos!=f.size()&&f[j]==f[pos]) pos++;
			v.push_back(pair<int,int>(f[j],pos-j));
			j=pos;
		}
		for (size_t j=0; j<v.size(); j++) cnt[v[j].first]=max(cnt[v[j].first],v[j].second);
	}
	for (int i=2; i<=1000000; i++) while (cnt[i]--) ans=1LL*ans*i%MOD;
	int tmp=0;
	for (int i=1; i<=N; i++) tmp=(tmp+inv(A[i]))%MOD;
	cout << 1LL*ans*tmp%MOD << endl;
	return 0;
}

Measured memory_bytes: 4224
import java.util.*;

public class Main {

    public static class Pair<A, B>{
        public A a;
        public B b;

        public Pair(A a, B b) {
            this.a = a;
            this.b = b;
        }
    }

    public static Integer dfs(int node, 
                              HashMap<Integer, List<Integer>> graph,
                              int currTime,
                              HashSet<Integer> discovered, 
                              HashMap<Integer, Pair<Integer, Integer>> times) {

        if(discovered.contains(node))
            return currTime - 1;
        else;
            int startTime = currTime;
            discovered.add(node);
            for(int i : graph.get(node)) {
                currTime  = dfs(i, graph, currTime + 1, discovered, times); 
            }
            times.put(node, new Pair<>(startTime, currTime + 1));
            return currTime + 1;
    }

    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int vs = sc.nextInt();
        HashMap<Integer, List<Integer>> graph = new HashMap<>();
        for(int i = 0; i < vs; i++) {
            int currNode = sc.nextInt();
            int es = sc.nextInt();
            List<Integer> edges = new LinkedList<>();
            for(int j = 0; j < es; j++)
                edges.add(sc.nextInt());
            graph.put(currNode, edges);
        }
        HashMap<Integer, Pair<Integer, Integer>> times = new HashMap<>();
        HashSet<Integer> discovered = new HashSet<>();
        int lastTime = 1;
        for (int i = 1; i <= graph.size(); i++) {
            if(!times.containsKey(i))
                lastTime += dfs(i, graph, lastTime, discovered, times);
                //lastTime += dfs(1, graph, lastTime, new HashSet<>(), times);
        }

        for (int i = 1; i <= graph.size(); i++) {
            if(times.containsKey(i)) {
                Pair<Integer, Integer> p = times.get(i);
                System.out.println(i + " " + p.a + " " + p.b);
            }
        }
    
    }

}



Measured memory_bytes: 28476
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],ans[100005];
int read() {
	char c=getchar(); int x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
long long calc() {	
	long long res=0;
	for (int i=1; i<n; i++) {
		res+=abs(ans[i]-ans[i+1]);
	}
	return res; 
}
int main() {
	n=read();
	for (int i=1; i<=n; i++) {
		a[i]=read();
	}
	sort(a+1,a+n+1);
	long long res=0;
	if (n&1) {
		ans[n/2+1]=a[1];
		int j=n,k=2,f=1; 
		for (int i=n/2; i>=1; i--) {
			if (f==1) {
				ans[i]=a[j--];
				ans[n+1-i]=a[j--];
			}
			else {
				ans[i]=a[k++];
				ans[n+1-i]=a[k++];
			}
			f^=1;
		}
		res=max(res,calc());
		ans[n/2+1]=a[n];
		j=n-1,k=1,f=1; 
		for (int i=n/2; i>=1; i--) {
			if (f==0) {
				ans[i]=a[j--];
				ans[n+1-i]=a[j--];
			}
			else {
				ans[i]=a[k++];
				ans[n+1-i]=a[k++];
			}
			f^=1;
		}
		res=max(res,calc());
	}
	else {
		int j=n,k=1,f=1; 
		for (int i=n/2; i>=1; i--) {
			if (f==1) {
				ans[i]=a[k++];
				ans[n+1-i]=a[j--];
			}
			else {
				ans[i]=a[j--];
				ans[n+1-i]=a[k++];
			}
			f^=1;
		}
		res=max(res,calc());
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
    unsigned long long n, ans, k = 1;
    cin >> n;
    if(n & 1){
        cout << 0 << endl;
        return 0;
    }
    ans = n / 10;
    while ((k*=5) <= n) {
        ans += n / (k*10);
    }
    
    cout << ans << endl;
    return 0;
}

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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int n;
	cin >> n;
	vector<ll> ma(n-1);
	REP(i,n-1) cin >> ma[i];
	int ans = 0;
	ans += ma[0]+ ma[n-2];
	REP(i,n-2) ans+=min(ma[i],ma[i+1]); 
  cout << ans << endl;
}


Measured memory_bytes: 3620
import math
n,k = map(int,input().split())
sum = 0
if k == 0:
	print(n**2)
else:
	for b in range(1,n+1):
		if n%b == 0:
			sum += math.floor(n/b)*max(b-k,0)
		else:
			sum += math.floor(n/b)*max(b-k,0) + max((n%b - k + 1),0)
	print(sum)

Measured memory_bytes: 9056
#include <stdio.h>

int main(void)
{
	int n,i;
	
	scanf("%d",&n);
	
	for(i=1;i<=n;i++){
		if(i%3==0){
			printf(" %d",i);
			continue;
		}
		else{
			int j=i;
			if(j/1000==3){
				printf(" %d",i);
				continue;
			}
			j%=1000;
			if(j/100==3){
				printf(" %d",i);
				continue;
			}
			j%=100;
			if(j/10==3){
				printf(" %d",i);
				continue;
			}
			j%=10;
			if(j==3){
				printf(" %d",i);
				continue;
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1028
import java.util.*;

class Main {
	Scanner sc;

	Main() {
		sc = new Scanner(System.in);
	}
	
	void calc() {
		int N = sc.nextInt();
		String S = sc.next();
		
		int prev = -1;
		int cnt = 0;
		for (int i = 0; i < S.length(); i++) {
			int col = S.charAt(i);
			if (col != prev) cnt++;
			prev = col;
		}
		System.out.println(cnt);
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}

Measured memory_bytes: 24332
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int K;
    cin >> K;
    int ans;
    if(K%2 != 0)ans = (K/2+1)*(K/2);
    else ans = (K/2)*(K/2);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int H,W;
char maze[50][50];
int d[50][50];
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1}; 

int bfs(){
    queue<P> que;
    for(int i = 0;i < H;i ++)
        for(int j = 0;j < W;j ++) d[i][j] = -1;
    que.push(P(0,0));
    d[0][0] = 1;

    while(que.size() != 0){
        P p = que.front(); que.pop();
        if(p.first == H-1 && p.second == W-1) break;

        for(int i = 0;i < 4;i ++){
            int nx = p.first + dx[i], ny = p.second +dy[i];

            if(0<=nx && nx<H && 0<=ny && ny<W && maze[nx][ny]!='#' && d[nx][ny]==-1 ){
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    return d[H-1][W-1];
}

int main(){
    int ans,cnt = 0;
    cin >> H >> W;
    for(int i = 0;i < H;i ++)
        for(int j = 0;j < W;j ++){
             cin >> maze[i][j];
             if(maze[i][j] == '.') cnt ++;
        }
    int dis = bfs();
    if(dis == -1) ans = dis;
    else ans = cnt - dis;
    cout << ans << endl;
    return 0;
}



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

int main()
{
    int N, M;
    cin>>N>>M;
    vector<int> A(M), B(M);
    for (int i=0; i<M; i++)
    {
        cin>>A[i]>>B[i];
        A[i]--;
        B[i]--;
    }

    vector<int> D(M);
    vector<vector<int>> E(N);
    vector<vector<int>> EI(N);
    vector<int> C(N);
    for (int i=0; i<M; i++)
    {
        E[A[i]].push_back(B[i]);
        E[B[i]].push_back(A[i]);
        EI[A[i]].push_back(i);
        EI[B[i]].push_back(i);
        C[A[i]] ^= 1;
    }

    int c = 0;
    for (int i=0; i<N; i++)
        c += C[i];
    if (c%2!=0)
    {
        cout<<-1<<endl;
        return 0;
    }

    vector<int> PV;
    vector<int> PE;
    vector<int> V(N);
    function<void(int)> f = [&](int c)
    {
        PV.push_back(c);
        V[c] = true;

        for (int i=0; i<(int)E[c].size(); i++)
        if (!V[E[c][i]])
        {
            PE.push_back(EI[c][i]);
            f(E[c][i]);
            PE.push_back(EI[c][i]);
            PV.push_back(c);
        }
    };
    f(0);

    for (int i=0; i<(int)PV.size()-1;)
    {
        if (C[PV[i]]==0)
        {
            i++;
        }
        else
        {
            while (C[PV[i]]!=0 && i<(int)PV.size()-1)
            {
                C[PV[i]] ^= 1;
                C[PV[i+1]] ^= 1;
                D[PE[i]] ^= 1;
                i++;
            }
        }
    }

    for (int i=0; i<M; i++)
    {
        if (D[i]==0)
            cout<<A[i]+1<<" "<<B[i]+1<<endl;
        else
            cout<<B[i]+1<<" "<<A[i]+1<<endl;
    }
}


Measured memory_bytes: 22380
#include <iostream>

using namespace std;

int main(){
  int N,h,h_max=0,res=0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> h;
    if(h>=h_max) res++;
    h_max=max(h_max,h);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256