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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int gcd(int a,int b){
  if(a%b==0){
    return b;
  }else{
    return(gcd(b,a%b));
  }
}
int main(){
  string week[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string s;
  cin>>s;
  REP(i,7){
    if(week[i]==s){
      cout<<7-i<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k;
  cin >> n >> k;
  int ans = 1;
  REP(i,n){
    ans = min(ans*2, ans+k);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
c = 0
for i in range(n-2):
	if p[i]<p[i+1] and p[i+1]<p[i+2]:
		c = c+1
	elif p[i]==p[i+1] and p[i+1]<p[i+2]:
		c = c+1
	elif p[i+2]<p[i+1] and p[i+1]<p[i]:
		c = c+1
	elif p[i+2]==p[i+1] and p[i+1]<p[i]:
		c = c+1

print(c)

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

/*
5
H4 C9 S4 D2 C3
*/

#define S 0
#define H 1
#define C 2
#define D 3

void BubbleSort(int **A,int N){
	int tmp;
	for(int i=0;i<N-1;i++){
		for(int j=(N-1);j>i;j--){
			if(A[j][1]<A[j-1][1]){
				tmp=A[j][0];
				A[j][0]=A[j-1][0];
				A[j-1][0]=tmp;
				tmp=A[j][1];
				A[j][1]=A[j-1][1];
				A[j-1][1]=tmp;
			}
		}
	}
}

void SelectionSort(int **A,int N){
	int tmp;
	int min;
	for(int i=0;i<N-1;i++){
		min=i;
		for(int j=i+1;j<N;j++){
			if(A[j][1]<A[min][1]){
				min=j;
			}
		}
		tmp=A[i][0];
		A[i][0]=A[min][0];
		A[min][0]=tmp;
		tmp=A[i][1];
		A[i][1]=A[min][1];
		A[min][1]=tmp;
	}
}

char convert(int a){
	switch(a){
	case S:
		return 'S';
		break;
	case H:
		return 'H';
		break;
	case C:
		return 'C';
		break;
	case D:
		return 'D';
		break;
	}
}

int convert_to_int(char x){
	switch(x){
	case 'S':
		return S;
	case 'H':
		return H;
		break;
	case 'C':
		return C;
		break;
	default:
		return D;
		break;
	}
}

char *check_Stable(int N,int **B,int B3[10][4],int B_count[10]){
	int count=0;
	for(int i=1;i<10;i++){
		for(int j=0;j<B_count[i];j++){
			if(B[count][0]!=B3[i][j]){
				return "Not stable";
			}
			count++;
		}
	}

	return "Stable";
}

void show(int **A,int N){
	for(int i=0;i<N;i++){
		printf("%c%d",convert(A[i][0]),A[i][1]);
		if(i!=N-1){
			printf(" ");
		}
	}printf("\n");
}

int main(){
	int N;
	char **A;
	int **B,**B2;
	int t0;
	int B3[10][4];
	int B_count[10];

	scanf("%d",&N);

	for(int i=0;i<10;i++){
		B_count[i]=0;
	}
	
	A=(char**)malloc(N*sizeof(char*));
	B=(int**)malloc(N*sizeof(int*));
	B2=(int**)malloc(N*sizeof(int*));
	for(int i=0;i<N;i++){
		A[i]=(char*)malloc(3*sizeof(char));
		B[i]=(int*)malloc(2*sizeof(int));
		B2[i]=(int*)malloc(2*sizeof(int));
		scanf("%s",A[i]);
		switch(A[i][0]){
		case 'S':
			t0=S;
			break;
		case 'H':
			t0=H;
			break;
		case 'C':
			t0=C;
			break;
		case 'D':
			t0=D;
			break;
		}
		B[i][0]=t0;
		B[i][1]=A[i][1]-'0';
		B2[i][0]=B[i][0];
		B2[i][1]=B[i][1];
		t0=(A[i][1]-'0');
		B3[t0][B_count[t0]]=convert_to_int(A[i][0]);
		B_count[t0]++;
	}
	

	BubbleSort(B,N);
	show(B,N);
	printf("%s\n",check_Stable(N,B,B3,B_count));
	SelectionSort(B2,N);
	show(B2,N);
	printf("%s\n",check_Stable(N,B2,B3,B_count));

	return 0;
}


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

bool char_is_ACGT(char c)
{
	char ACGT[4] = { 'A', 'C', 'G', 'T' };

	for (int n = 0; n < 4; n++) {
		if (c == ACGT[n]) {
			return true;
		}
	}

	return false;
}

int main(void)
{
	string S;
	int max, count;

	cin >> S;

	max = 0;
	count = 0;
	for (int i = 0; i < S.size(); i++) {
		if (char_is_ACGT(S[i])) {
			count++;
		}
		else {
			if (count > max) {
				max = count;
			}
			count = 0;
		}
	}
	if (count > max) {
		max = count;
	}

	cout << max << endl;

	return 0;
}

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

int main() {
  int x;
  cin >> x;
  cout << (x < 1200 ? "ABC" : "ARC") << endl;
}

Measured memory_bytes: 3516
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,T;
ll A[100010];
ll minA[100010];
unordered_map<ll,ll> cnt;
int main(){
    cin>>N>>T;
    for(ll i=0;i<N;i++){
        cin>>A[i];
    }
    minA[0]=A[0];
    ll maxDiff=0;
    for(ll i=1;i<N;i++){
        maxDiff=max(maxDiff,A[i]-minA[i-1]);
        cnt[A[i]-minA[i-1]]++;
        minA[i]=min(minA[i-1],A[i]);
    }
    cout<<cnt[maxDiff]<<endl;
    return 0;
}

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

int main() {
    int64_t H, W;
    cin >> H >> W;
    if(H==1 || W==1){
        cout << 1 << endl;
    }else if(H%2 == 1 && W%2 == 1){
        cout << (H * W + 1)/2 << endl;
    }else{
        cout << H * W / 2 << endl;
    }
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()
#define PI 3.14159265359

using ll = long long;

int main(){
    int r;
    cin >> r;
    cout <<  r * 2 * PI << endl;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define il inline
il int read()
{
	int re=0,k=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')k=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){re=re*10+ch-48;ch=getchar();}
	return re*k;
}
il void write(int x)
{
	if(x<0)return putchar('-'),write(-x),void();
	if(x<=9)return putchar(x+48),void();
	return write(x/10),write(x%10),void();
}
int t,n,l,r,ans;
const int M=4e18+7;
signed main()
{
//	freopen("c.in","r",stdin);
//	freopen("c.out","w",stdout);
	t=1;
	while(t--)
	{
		n=2;l=read();r=read();
		if(l==r)
		{
			puts("1");continue;
		}
		if(n==1ll)
		{
			write((r-l+1ll)%M);puts("");continue;
		}
		int rr,ll,rrr;
		int lim=62ll;
		while(lim>=0ll)
		{
			if(((l>>lim)&1ll)!=((r>>lim)&1ll))
			{
				ll=l&((1ll<<(lim+1ll))-1ll);
				rr=(1ll<<(lim))+ll;
				int tt=lim-1ll;
				while(tt>=0ll&&!((r>>tt)&1ll))tt--;
				rrr=(1ll<<lim)+(1ll<<(tt+1ll))-1ll;
				break;
			}
			lim--;
		}
	//	cerr<<lim<<" "<<(l>>3ll)<<" "<<(r>>3ll)<<endl;
		//cerr<<ll<<" "<<rrr<<" "<<rr<<" "<<(1ll<<(lim+1ll))<<endl;
		if(rrr>=rr)
		{
			ans=(1ll<<(lim+1ll))-ll;
		}
		else
		{
			ans=(1ll<<(lim+1ll))-rr+rrr-ll+1ll;
		}
		write(ans%M);
		puts("");
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  string A,B; cin >> A >> B;
  string ans = "EQUAL";
  int a_size = A.size();
  int b_size = B.size();
  if(a_size > b_size) {
    ans = "GREATER";
  } else if (a_size < b_size) {
    ans = "LESS";
  } else {
    if(A > B) ans = "GREATER";
    else if(A < B) ans = "LESS";
    else ans = "EQUAL";
  }

  cout << ans << endl;
}


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

using namespace std;

int main(void)
{
    int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
    int total = a + b + c + d + e;
    int soma = 0;

    int v[5];
   
    v[0] = a < 10 ? 10 - a : a % 10 == 0 ? 0: 10 - (a % 10);
    v[1] = b < 10 ? 10 - b : b % 10 == 0 ? 0: 10 - (b % 10);
    v[2] = c < 10 ? 10 - c : c % 10 == 0 ? 0: 10 - (c % 10);
    v[3] = d < 10 ? 10 - d : d % 10 == 0 ? 0: 10 - (d % 10);
    v[4] = e < 10 ? 10 - e : e % 10 == 0 ? 0: 10 - (e % 10);

    int maior = 0;

    for(int i = 0; i < 5; ++i)
    {
        if(v[i] > maior)
            maior = v[i];
    }
    bool hasnt_bigger = true;
    for(int i = 0; i < 5; ++i)
        if(maior == v[i] and hasnt_bigger)
        {
            v[i] = 0;  
            hasnt_bigger = false;  
        }
        else
            soma += v[i];
    
    cout << total + soma << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	var s []byte
	fmt.Scan(&s)
	p := n
	ans := make([]int, 0)
	for p > 0 {
		var fs int
		for sp := min(m, p); sp >= 1; sp-- {
			if s[p-sp] == '0' {
				fs = sp
				break
			}
		}
		if fs == 0 {
			fmt.Println(-1)
			return
		}
		p -= fs
		ans = append(ans, fs)
	}
	for i := len(ans) - 1; i >= 0; i-- {
		fmt.Print(ans[i])
		if i == 0 {
			fmt.Println()
		} else {
			fmt.Print(" ")
		}
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 6784
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <numeric>

#define INF 10000000000;
#define mod 1000000007;
using namespace std;

int main(void){
   char str1[12];
   cin>>str1;
   char str2[]={'2','0','1','9','/','0','4','/','3','0','\n'};
   int ans=strcmp(str1,str2);
   if(ans<=0){cout<<"Heisei";}
   else {cout<<"TBD";}
   return 0;
}


Measured memory_bytes: 256
def main():
    t1, t2 = map(int, input().split())
    a1, a2 = map(int, input().split())
    b1, b2 = map(int, input().split())
    x, y = (a1-b1)*t1, (a2-b2)*t2
    if x//abs(x) == y//abs(y):
        print(0)
    else:
        if abs(x) == abs(y):
            print("infinity")
        else:
            x, y = abs(x), abs(y)
            if y < x:
                print(0)
            else:
                if x%(y-x) != 0:
                    print((x+(y-x)-1)//(y-x)*2-1)
                else:
                    print(x//(y-x)*2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	int n,i;cin>>n;
	vector<double>a(n);for(i=0;i<n;i++){cin>>a[i];}
	SO(a);
	double ans=0;
	for(i=1;i<n;i++){//c
		if(i+1==n){
			maxeq(ans,(a[n-3]+a[n-4])/(a[i]-a[i-1]));
			maxeq(ans,(a[n-2]+a[n-4])/(a[i]-a[i-2]));
			maxeq(ans,(a[n-2]+a[n-3])/(a[i]-a[i-3]));
		}else if(i+2==0){
			maxeq(ans,(a[n-1]+a[n-4])/(a[i]-a[i-1]));
			maxeq(ans,(a[n-1]+a[n-3])/(a[i]-a[i-2]));
		}else{
			maxeq(ans,(a[n-1]+a[n-2])/(a[i]-a[i-1]));
		}
	}
	cout<<ans<<endl;
		
	return 0;
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  cout << (x^1) << endl;
  return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()
#define BETWEEN(a, x, b) (a) <= (x) && (x) <= (b) 

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;


void solve()
{
    string w;
    cin >> w;
    vi alphabet('z'-'a', 0);
    REP(i, w.length())
    {
        alphabet[w[i]-'a']++;
    }
    REP(i, 'z'-'a')
    {
        if(alphabet[i] % 2 == 1)
        {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
    {
        static long mod = 998244353;
        static long pow(long a, long n)
        {
            a %= mod;
            long ret = 1;
            long buf = a;
            while (true)
            {
                if((n & 1) == 1) ret = ret * buf % mod;
                else if (n == 0) break;
                buf = buf * buf % mod;
                n >>= 1;
            }
            return ret;
        }
        static long inv2 = pow(2, mod - 2);
        static void Main(string[] args)
        {   
            int n = int.Parse(Console.ReadLine());
            int[] a = new int[n+1];
            for (int i=0; i<n; i++) a[i+1] = int.Parse(Console.ReadLine());
            long[,] dp = new long[n + 1, 300 * n + 1];
            long[,] dp2 = new long[n + 1, 300 * n + 1];
            dp[0, 0] = pow(2, n);
            dp2[0, 0] = 1;
            int sum = 0;
            for (int i=1; i<=n; i++)
            {
                sum += a[i];
                for (int j=0; j<=sum; j++)
                {
                    if (j < a[i])
                    {
                        dp[i,j] = dp[i-1, j];
                        dp2[i, j] = dp2[i-1, j];
                    }
                    else 
                    {
                        dp[i, j] = (dp[i-1, j] + dp[i-1, j-a[i]] * inv2) % mod;
                        dp2[i, j] = (dp2[i-1, j] + dp2[i-1, j-a[i]]) % mod;
                    }
                }
            }
            long ngCase = 0;
            for (int i=sum/2+1; i<=sum; i++)
            {
                ngCase += dp[n, i];
                ngCase %= mod;
            }
            ngCase = ngCase * 3 % mod;
            if (sum % 2 == 0)
            {
                ngCase = (ngCase + 3 * dp[n, sum/2] % mod - 3 * dp2[n, sum/2]) % mod;
            }
            long ans = pow(3, n) - ngCase;
            ans %= mod;
            if (ans < 0) ans += mod;
            Console.WriteLine(ans);

        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 432088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(void){
    ll n;
    cin >> n;
    string str, t;
    cin>>str>>t;
    ll result = 0;
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < n; j++){ 
            if(str[i+j]!=t[j]){ 
                result=max(result, j);
                break;
            }
            if(j == n-1)
                result = n;
        }
    }
    cout<<n*2-result;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];



signed main(){
	IOS;
	ll n;
	cin >> n;
	vec<ll> p(n),q(n);
	REP(i,n){
		cin >> p[i];
		q[p[i] - 1] = i;
	}
	ll ans = 1,tmp = 1;
	REP(i,n - 1){
		if(q[i + 1] > q[i])tmp++;
		else {
			ans = max(ans,tmp);
			tmp = 1;
		}
	}
	ans = max(ans,tmp);
	dump(n - ans);
}

Measured memory_bytes: 3456
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#else
#define VS_ENDPAUSE()
#endif

#include <stdio.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;

#define INT8_MIN	(-127)
#define INT8_MAX	( 128)
#define UINT8_MAX	( 255)
#define INT16_MIN	(-32768)
#define INT16_MAX	( 32767)
#define UINT16_MAX	( 65535)
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18


void func(void);
#pragma endregion

int main(void)
{
	func();

	VS_ENDPAUSE();
	return 0;
}



void func(void)
{
	int32 x, y;
	uint8 array[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

	cin >> x >> y;
	if(array[x] == array[y]){
		cout << "Yes";
	} else {
		cout << "No";
	}

	cout << endl;
}




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

int h, w, ans;
vector<string> v;
vector<vector<int>> a, b;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> h >> w;
	v.resize(h);
	for(auto &i:v) cin >> i;
	a.resize(h, vector<int>(w, 0));
	b.resize(h, vector<int>(w, 0));
	for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j)
			if(v[i][j] == '.')
				a[i][j] = 1;
	for(int i=0; i<h; ++i)
		for(int j=1; j<w; ++j)
			if(a[i][j-1] != 0 && a[i][j] != 0)
				a[i][j] += a[i][j-1];
	for(int i=0; i<h; ++i)
		for(int j=w-2; j>=0; --j)
			if(a[i][j] != 0 && a[i][j+1] != 0)
				a[i][j] = max(a[i][j], a[i][j+1]);
	for(int i=0; i<w; ++i)
		for(int j=0; j<h; ++j)
			if(v[j][i] == '.')
				b[j][i] = 1;
	for(int i=0; i<w; ++i)
		for(int j=1; j<h; ++j)
			if(b[j-1][i] != 0 && b[j][i] != 0)
				b[j][i] += b[j-1][i];
	for(int i=0; i<w; ++i)
		for(int j=h-2; j>=0; --j)
			if(b[j][i] != 0 && b[j+1][i] != 0)
				b[j][i] = max(b[j][i], b[j+1][i]);
	for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j)
			ans = max(ans, a[i][j] + b[i][j] - 1);
	cout << ans << "\n";
}

Measured memory_bytes: 35968
#include <stdio.h>
#include<string.h>
#include<math.h>

int main()
{
  int a,b,h,m;
  
  scanf("%d%d%d%d",&a,&b,&h,&m);
  
  double rad=0;
  double ans;
  
  double l,s;
  
  l=m*6;
  s=h*30+0.5*m;

  rad=fabs(l-s);
  if(rad>=180.0){
    rad=360.0-rad;
  }
  if(rad==0.0){
    ans=abs(a-b);
  }
  else{
  ans=a*a+b*b-2*a*b*cos(rad*M_PI/180);
  ans=sqrt(ans);
  }

  printf("%.20f\n",ans);
  return 0;
}

Measured memory_bytes: 2548
a,b=map(int,input().split())
import math

d=math.gcd(a,b)

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
r=make_divisors(d)
l=len(r)
ans=1
w=[True]*l
if l>=2:
  for x in range(1,l):
    if w[x]==True:
      ans+=1
      for y in range(x,l):
        if r[y]%r[x]==0:
          w[y]=False
          
print(ans)

Measured memory_bytes: 9376
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

manzoku = 0
add_manzoku = 0
for i in range(n):
    manzoku += b[a[i]-1]
    if i < n-1 and a[i]+1 == a[i+1]:
        add_manzoku += c[a[i]-1]

print(manzoku+add_manzoku)

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

using namespace std;
typedef long long LL;
const int N=1e5+5;

int head[N],nxt[N<<1],to[N<<1],siz[N],z[N],k[N];
int n,m,num,X,Y,odd,sum,tot,mid;
LL ans;

int read()
{
    int x=0,p=1; char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') p=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return x*p;
}

void add(int x,int y)
{
	nxt[++num]=head[x],to[num]=y,head[x]=num;
}

void dfs1(int x,int fa)
{
	for(int i=head[x]; i ;i=nxt[i])
	{
		int y=to[i];
		if(y==fa) continue ;	
		if(siz[y])
		{
			if(siz[y]==siz[x]) odd=1;
			X=x,Y=y;
		}
		else
		{
			siz[y]=-siz[x];
			dfs1(y,x);
		}
	}
}

void dfs2(int x,int fa)
{
	for(int i=head[x]; i ;i=nxt[i])
	{
		int y=to[i];
		if(y==fa || (x==X&&y==Y) || (x==Y&&y==X))
			continue ;
		dfs2(y,x);
		siz[x]+=siz[y];
		k[x]+=k[y];
	}
}

int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);

	n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		add(x,y),add(y,x);
	}

	siz[1]=1;
	dfs1(1,0);
	for(int i=1;i<=n;i++) sum+=siz[i];

	if(n-1==m)
	{ if(sum) return printf("-1\n"),0; }
	else
		if(odd)
		{
			if(sum&1) return printf("-1\n"),0;
			ans+=abs(sum>>1); 
			siz[X]-=sum>>1,siz[Y]-=sum>>1;
		}
		else
		{
			if(sum) return printf("-1\n"),0;
			k[X]=1,k[Y]=-1;
		}

	dfs2(1,0);
	for(int i=1;i<=n;i++)
		if(k[i]) z[++tot]=k[i]*siz[i];
		else ans+=abs(siz[i]);
	sort(z+1,z+tot+1);
	mid=z[tot+1>>1];
	for(int i=1;i<=tot;i++) ans+=abs(z[i]-mid);
	ans+=abs(mid);
	
	printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 8064
N,M,C = list(map(int,input().split()))
b = list(map(int,input().split()))
count = 0
for i in  range(N):
	a = list(map(int,input().split()))
	s = 0
	for j in range(M):
		s += a[j]*b[j]
	if s+C>0:
		count+=1
print(count)


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

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


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

    int n, m; cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    REP(k, 1, m+1) {
        rep(j, n-1) {
            if(a[j]%k > a[j+1]%k) swap(a[j], a[j+1]);
        }
    }
    for(auto e : a) cout << e << '\n';
    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define Int long long
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
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() {
  int N, K; cin >> N >> K;
  vector<int> dp(N+1, 0);
  dp[0] = 1;
  for(int i=1; i<=N; ++i) {
    dp[i] = dp[i-1]*2;
    chmin(dp[i], dp[i-1]+K);
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
	string n;
	cin >> n;
	if(n[0] == '7' || n[1] == '7' || n[2] == '7')
    {
    	cout << "Yes" << endl; 
    }
  	else
    {
     	cout << "No" << endl;
    }
}

Measured memory_bytes: 3560
import java.util.Arrays;
import java.util.Scanner;

	public class Main {

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

			int N = sc.nextInt();
			double v[]= new double[N];

			for(int i = 0; i < N; i++) {
				v[i] = sc.nextDouble();
			}

			for(int i=0; i<N-1; i++) {
				Arrays.parallelSort(v);
				v[0] = (v[0] + v[1]) / 2;
				v[1] = 9999;
			}

    		System.out.println(v[0]);

    	    // Scannerクラスのインスタンスをクローズ
    		sc.close();
    	}

    }

Measured memory_bytes: 37140
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct{
  int p;
  int r;
  int l;
} Node;
int main(){
  int n,i,j,degree,num,point,temp,a,flag=0,depth=0,sum=0;
  char str[20];
  Node T[100000];
  for(i=0;i<100000;i++){
    T[i].p=T[i].r=T[i].l=-1;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&point,&degree);
    sum+=degree;
    for(j=0;j<degree;j++){
      scanf("%d",&num);
      if(j==0){
      T[point].l=num;
      T[num].p=point;
      }
      else {
	T[num].p=point;
	T[temp].r=num;
      }
      temp=num;
    }
  }
  
  for(i=0;i<=sum;i++){
    depth=0;
    flag=0;
    j=i;
    while(T[j].p!=-1){
      depth++;
      j=T[j].p;
    }
      
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth);
    if(T[i].p==-1) printf("root, ");
    else if(T[i].l==-1){ printf("leaf, []\n"); continue;}
  else printf("internal node, ");
    if(T[i].l!=-1){
      flag=1;
      num=T[i].l;
      printf("[%d",num);
      while(T[num].r!=-1){
	printf(", %d",T[num].r);
	num=T[num].r;
      }
      printf("]");
    }
    if(flag==0)printf("[]");	
    printf("\n");
  }
  return 0;
}

  
  
   
    
      
    
  
	   



Measured memory_bytes: 2972
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll inf = 1e5;
ll w[105], v[105];
ll dp[105][100005];
ll a[200005];
int main() {
	int n, W;
	cin >> n >> W;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}

	for (int i = 0; i <= W; i++) {
		dp[0][i] = 0;
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= W; j++) {
			if (j >= w[i]) {
				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	cout << dp[n][W] << endl;
	return 0;

}

Measured memory_bytes: 80640
#include<iostream>
int main(){
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a > b){
		int d = b;
		b = a;
		a = d;
	}
	if (b > c){
		int e = c;
		c = b;
		b = e;
	}
	if (a > b){
		int f = b;
		b = a;
		a = f;
	}
	std::cout << a << " " << b << " " << c << std::endl;
	return 0;
}

Measured memory_bytes: 1164
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=2005;

int N,x;
int A[MAXN];
int best[MAXN][MAXN];

int main()
{
    scanf("%d%d",&N,&x);
    for(int i=1;i<=N;i++)
        scanf("%d",&A[i]);
    for(int i=1;i<=N;i++)
    {
        best[i][0]=A[i];
        for(int k=1;k<N;k++)
            best[i][k]=min(best[i][k-1],A[(i-k+N-1)%N+1]);
    }
    long long ans=0x3F3F3F3F3F3F3F3FLL;
    for(int k=0;k<N;k++)
    {
        long long tmp=0;
        for(int i=1;i<=N;i++)
            tmp+=best[i][k];
        ans=min(ans,tmp+1LL*k*x);
    }
    printf("%lld\n",ans);

    fclose(stdin);
    fclose(stdout);
    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
int usage(int a, int digit = 0) {
	if (digit == 4) return 0;
	return (1 << (a % 10)) + usage(a / 10, digit + 1);
}
int hit(int a, int b) {
	int res = 0;
	for (auto i = 0; i < 4; ++i) {
		res += (a % 10 == b % 10) ? 1 : 0;
		a /= 10; b /= 10;
	}
	return res;
}
int brow(int a, int b) {
	int ua = usage(a); int ub = usage(b);
	int res = -hit(a, b);
	for (auto i = 0; i < 10; ++i) {
		res += (ua & ub & 1);
		ua >>= 1; ub >>= 1;
	}
	return res;
}
int main() {
	int a, b;
	std::cin >> a >> b;
	while (a != 0 && b != 0) {
		std::cout << hit(a, b) << ' ' << brow(a, b) << std::endl;
		std::cin >> a >> b;
	}
}


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

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}

    int find(int x) {
        if (par[x] < 0) 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 (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -par[find(x)];
    }
};

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

    int N;
    cin >> N;
    vector<int> loc(N), ind(N);
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        loc[x] = y;
        ind[y] = i;
    }
    UnionFind uf(N);
    vector<int> v;
    for (int x = 0; x < N; x++) {
        if (v.empty() || v.back() > loc[x]) {
            v.push_back(loc[x]);
            continue;
        }
        for (int i = v.size() - 1; i >= 0 && v[i] < loc[x]; i--) uf.unite(v[i], loc[x]);
    }
    vector<int> ans(N);
    for (int i = 0; i < N; i++) ans[ind[i]] = uf.size(i);
    for (int i = 0; i < N; i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 6596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define CL(a,x) memset(a, x, sizeof(a))
#define ar2 array<int, 2>
typedef long long LL;
const int P = 998244353;
const int N = 1e5+5;
const double PI = acos(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<ar2> a[N];
int n, m, l, r, c;
LL tr[N*4], d[N];

void upd(int i,LL x,int id=1,int l=1,int r=n){
	if(l==r){ tr[id] = x; return; }
	int m = l + r >> 1;
	if(i<=m) upd(i,x,id<<1,l,m);
	else upd(i,x,id<<1|1,m+1,r);
	tr[id] = min(tr[id<<1], tr[id<<1|1]);
	return; 
}

LL qry(int l1,int r1,int id=1,int l2=1,int r2=n){
	if(l1<=l2 && r1>=r2) return tr[id];
	
	LL res1 = 1e18, res2 = 1e18;
	int m = l2 + r2 >> 1;
	if(l1<=m) res1 = qry(l1,r1,id<<1,l2,m);
	if(r1>m) res2 = qry(l1,r1,id<<1|1,m+1,r2);
	//cout<<l1<<" "<<r1<<" "<<l2<<" "<<r2<<" "<<min(res1, res2)<<endl;
	return min(res1, res2);
}

int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,m) scanf("%d%d%d",&l,&r,&c),a[r].push_back({l,c});
	
	rep(i,1,n*4) tr[i] = 1e18;
	rep(i,2,n) d[i] = 1e18;
	d[1] = 0, upd(1, d[1]);
	
	rep(i,2,n){
		//rep(j,1,n) cout<<qry(j,j)<<" ";cout<<endl;
		for(auto x:a[i])
			d[i] = min(d[i], qry(x[0], i-1) + x[1]);
		upd(i, d[i]);
		//cout<<i<<" "<<d[i]<<" "<<a[i].size()<<endl;
	}
	cout<<(d[n]==1e18?-1:d[n])<<endl;
	return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

template<class T, class... Args>
auto create(size_t n, Args&&... args) {
	if constexpr(sizeof...(args) == 1)
		return vector<T>(n, args...);
	else
		return vector(n, create<T>(args...));
}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef OJ
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define sz(x) ((int)x.size())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const char en = '\n';
const int MOD = 0;
const int MAXN = 0;
const int INF = 1e9+1;

int solve() {
    string s;
    cin >> s;
    if(s[sz(s)-1] == 's') cout << s << "es" << en;
    else cout << s << 's' << en;
    return 0;
} 

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int ntest = 1;
    //cin >> ntest;
    fori(test, ntest) {
        //cout << "Case #" << test+1 << ": ";
        solve();
    }

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	auto sum = X;

	auto l = N;
	auto w = N - X;

	auto isFirst = true;
	while (true)
	{
		if (l % w == 0)
		{
			if (isFirst)
			{
				sum += (l / w - 1) * 2 * w;
			}
			else
			{
				sum += (l / w * 2 - 1) * w;
			}
			break;
		}

		if (isFirst)
		{
			sum += (l / w * 2 - 1) * w;
		}
		else
		{
			sum += (l / w) * 2 * w;
		}
		isFirst = false;

		auto prevW = w;
		w = l % w;
		l = prevW;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
#define int ll
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    int n; cin>>n;
    vector<int>v;
    vector<pii>data;
    pii now=pii(0,0);
    int ans=0;
    rep(i,n){
        pii temp; cin>>temp.first>>temp.second;
        v.push_back(temp.first+temp.second);
        data.push_back(temp);
    }
    rep(i,v.size()){
        if(!i){ans=v[0];now=data[i];continue;}
        if(data[i].first>=now.first&&data[i].second>=now.second){
            ans=v[i];
            now=data[i];
            continue;
        }else{
            pii cal=data[i];
            int power;
            if(now.second<data[i].second&&now.first>data[i].first)
                power=now.first/data[i].first+(now.first%data[i].first ? 1:0);
            else if(now.first<data[i].first&&now.second>data[i].second)
                power=now.second/data[i].second+(now.second%data[i].second ? 1:0);
            else
                power=max(
                          now.first/data[i].first+(now.first%data[i].first ? 1:0),
                          now.second/data[i].second+(now.second%data[i].second ? 1:0)
                          );
            // cout<<power<<endl;
            now=pii(cal.first*power,cal.second*power);
        }
    }
    
    cout<<now.first+now.second<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

bool is_prime(long long n)
{
    if (n == 1) {
        return false;
    }

    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main()
{
    std::string s;
    std::cin >> s;

    long long ans = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] != s[s.size() - 1 - i]) {
            ans++;
        }
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		int a= in.nextInt();
		int b= in.nextInt();
		if(a+b>=10){
			System.out.println("error");
		}
		else{
			System.out.println(a+b);
		}
		
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

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

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


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<string, ll>;
using PP = pair<P, ll>;

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

    ll n;
    cin >> n;
    string s;
    ll a;
    vector<PP> p;
    REP(i, n){
        cin >> s >> a;
        p.push_back(PP{P{s, -a}, i + 1});
    }
    VSORT(p);
    REP(i, n){
        ll res = p[i].second;
        cout << res << endl;
    }
    return 0;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;
}

Measured memory_bytes: 256
// g++ -std=c++14

//Difficulty according to solve count during contest:
//A B C D H F E I G K L M N P S O Q R J U Z Y X T V W

#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(c) (c.begin(),c.end())
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define inf 1000000000000000001

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

#define int ll
int n, m;
vector<vector<int> > graph;
vector<int> visited;
vector<int> dp;
vector<int> v;
void topSort(int node){
  visited[node] = 1;
  for(auto &x: graph[node])
    if(!visited[x])
      topSort(x);
  visited[node] = 2;
  v.push_back(node);
}
void func(int node){
  for(auto &x: graph[node]){
    dp[x] = max(dp[x], dp[node] + 1);
  }
}
int32_t main(){ _
  cin >> n >> m;
  graph.resize(n + 1);
  visited.resize(n + 1, 0);
  dp.resize(n + 1, 0);
  for(int i = 0; i < m; i++){
      int x, y;
      cin >> x >> y;
      graph[x].push_back(y);
  }
  for(int i = 1; i <= n; i++)
    if(!visited[i])
      topSort(i);
  reverse(v.begin(), v.end());
  for(int i = 0; i < n; i++){
    func(v[i]);
  }
  int ans = 0;
  for(int i = 1; i <= n; i++)
    ans = max(ans, dp[i]);
  cout << ans << endl;
}


Measured memory_bytes: 13432
N,M=map(int,input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
    m=0#最小の距離
    for j in range(M):
        if j==0:
            m=abs(cd[j][0]-ab[i][0])+abs(cd[j][1]-ab[i][1])
            ans=j+1
        else:
            if m>abs(cd[j][0]-ab[i][0])+abs(cd[j][1]-ab[i][1]):#最小値を更新する場合
                m=abs(cd[j][0]-ab[i][0])+abs(cd[j][1]-ab[i][1])
                ans=j+1
        #print("j=",str(j),",","m=",str(abs(cd[j][0]-ab[i][0])+abs(cd[j][1]-ab[i][1])))
    print(ans)


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

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

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

  long long ans=0;
  long long i=5;
  if(n%2==0){
  while(n/i>0){
    ans += (n/i)/2;
    i*=5; 
  }
  }
  cout << ans;
}

Measured memory_bytes: 256
from itertools import chain
op_list = ["+","-"]
s = input()

res=""
for i in range(8):
	op1 = op_list[i%2]
	op2 = op_list[i // 2 % 2]
	op3 = op_list[i // 4]
	expr = "".join(chain.from_iterable(zip(s,[op1, op2, op3, ""])))
	if eval(expr) == 7:
		res = expr + "=7"
		break

print(res)

Measured memory_bytes: 3060
n=gets.to_i
A=gets.chomp.split(' ').map(&:to_i)

L=[];R=[];L[0]=0;R[0]=0

n.times do |i|
    L[i+1] = L[i].gcd(A[i])
    R[i+1] = R[i].gcd(A[n-i-1])
end

ans = 0
n.times do |i|
   ans = [L[i].gcd(R[n-i-1]),ans].max
end
puts ans

Measured memory_bytes: 13756
import collections
import sys

readline = sys.stdin.buffer.readline


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


def main():
    N, M, K = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(M)]
    CD = [list(map(int, readline().split())) for _ in range(K)]

    E = UnionFind(N)

    ans = [0 for _ in range(N)]
    for a, b in AB:
        a -= 1
        b -= 1
        E.unite(a, b)
        ans[a] -= 1
        ans[b] -= 1

    for i in range(N):
        E.find(i)

    ll = collections.defaultdict(int)
    for i in E.par:
        ll[i] += 1

    for i in range(N):
        ans[i] += ll[E.par[i]] - 1

    for i, j in CD:
        i -= 1
        j -= 1
        if E.same(i, j):
            ans[i] -= 1
            ans[j] -= 1

    print(*ans)


main()


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

int main(int argc, char* argv[]) {
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256