akhauriyash/Code-Regression huggingface dataset:
#! python3

fives = 0
sevens = 0
for x in input().strip().split():
    x = int(x)
    if x == 5:
        fives += 1
    if x == 7:
        sevens += 1
if fives == 2 and sevens == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A;
  cin>>N>>A;
  
  if (A>=499){
    cout<<"Yes"<<endl;
  }
  else if (N%500<=A){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}

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

using namespace std;

using int64 = long long;

int main() {
  int N, A[100];
  cin >> N;
  int sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] *= N;
    sum += A[i];
  }
  sum /= N;
  int64 ret = 1LL << 60;
  for(int i = 0; i < N; i++) {
    ret = min(ret, llabs(sum - A[i]));
  }
  for(int i = 0; i < N; i++) {
    if(abs(sum - A[i]) == ret) {
      cout << i << endl;
      return 0;
    }
  }
}

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

char s [123456] ;

int main ( )  {
	scanf ( "%s", s ) ;

	int n = strlen ( s ) ;

	int ans ( INT_MAX ) ;
	
	for ( int i = 0 ; i < n - 1 ; ++ i )  {
		if ( s [i] ^ s [i + 1] )  ans = std :: min ( ans, std :: max ( i + 1, n - i - 1 ) ) ;
	}

	return ! printf ( "%d\n", ans != INT_MAX ? ans : n ), 0 ;
}


Measured memory_bytes: 384
import itertools

s = input()
sum_formula = 0
for pluses in itertools.product(['+', ''], repeat=len(s)-1):
    formula = s[0]
    for i in range(len(s) - 1):
        formula += pluses[i] + s[i + 1]
    sum_formula += eval(formula)
print(sum_formula)


Measured memory_bytes: 40912
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)

ABC = []
for i in range(X):
    if (i + 1) > K:
        break
    for j in range(Y):
        if (i + 1) * (j + 1) > K:
            break
        for l in range(Z):
            if (i + 1) * (j + 1) * (l + 1) > K:
                break
            ABC.append(A[i] + B[j] + C[l])
ABC = sorted(ABC, reverse=True)
print(*ABC[:K])

Measured memory_bytes: 9548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++) 
#define ltype int
#define rep(i,j,k) for(ltype (i)=(j);(i)<=(k);(i)++)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,
mod=1000000007;
const double pi=3.1415926535897932,
eps=1e-6;
int n,m,h[2005][2005],w[2005][2005],ans;char mp[2005][2005];
int main()
{
    scanf("%d%d",&n,&m);
    rep(i,1,n) scanf("%s",mp[i]+1);
    rep(i,1,n){
        int lst=1;
        rep(j,1,m)
        if(mp[i][j]=='#'){rep(k,lst,j-1) h[i][k]=j-lst;lst=j+1;}
        rep(k,lst,m) h[i][k]=m+1-lst;
    }
    rep(i,1,m){
        int lst=1;
        rep(j,1,n)
        if(mp[j][i]=='#'){rep(k,lst,j-1) w[k][i]=j-lst;lst=j+1;}
        rep(k,lst,n) w[k][i]=n+1-lst;
    }
    //rep(i,1,n) rep(j,1,m) printf("%d%c",w[i][j],j==m?'\n':' ');
    rep(i,1,n) rep(j,1,m) ans=max(ans,h[i][j]+w[i][j]-1);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 35584
#include<iostream>
using namespace std;
int main(){
  string s;
  getline(cin,s);
  for(int i=0; i<s.size(); i++)
    if(s[i]>='a' && s[i]<='z')
      s[i]+='A'-'a';
  cout <<s<<endl;
  return 0;
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if (S == U)
        A--;
    else
        B--;
    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())
X = [["#"]*100 for _ in range(50)]+[["."]*100 for _ in range(50)]
A -= 1
B -= 1
for i in range(10):
    for j in range(50):
        if A > 0:
            X[10+i*2][j*2] = "."
            A -= 1
            
for i in range(10):
    for j in range(50):
        if B > 0:
            X[60+i*2][j*2] = "#"
            B -= 1
            
print(100, 100)
for x in X:
    print(*x, sep = "")

Measured memory_bytes: 4468
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int data_num = Integer.parseInt(sc.nextLine());
        for (int i = 0; i < data_num; i++) {
            String[] line = sc.nextLine().split(" ");
            IntStream intLine = Arrays.stream(line)
                    .mapToInt(Integer::parseInt)
                    .sorted();
            int[] intAraay = intLine.toArray();
            int a = intAraay[0];
            int b = intAraay[1];
            int c = intAraay[2];
            if (c * c == a * a + b * b) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }

    }
}

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

int main(){
    int n;
    cin >> n;
    map<string, ll> mp;
    rep(i, n){
        string s0;
        cin >> s0;
        sort(s0.begin(), s0.end());
        mp[s0]++;
    }
    ll ans = 0;
    for(auto s0: mp){
        ans += (ll)(s0.second - 1) * s0.second / 2;
    }
    cout << ans << endl;
    return 0;
}

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

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

int main(){
    string s;
    cin >> s;
    int N = s.size();
    int res = 0;
    for(int i =0; i < N/2; i++){
        if(s[i] != s[N - 1 - i]) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
typedef long long ll;

int main()
{
	int N;
	char arare;
	scanf("%d", &N);
	bool flag = false;
	for (int i = 0; i <= N; i++) {
		scanf("%c", &arare);
		if (arare == 'Y')
			flag = true;
	}

	if (flag)
		printf("Four\n");
	else
		printf("Three\n");
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[1010],dp[1<<12];

int main(void){
	int n,m,i,j,b,c,x;
	ll a;
	cin >> n >> m;
	fill(dp,dp+(1<<n),INFLL);
	dp[0] = 0ll;
	for(i=0; i<m; ++i){
		cin >> a >> b;
		x = 0;
		for(j=0; j<b; ++j){
			cin >> c; --c;
			x |= (1<<c);
		}
		for(j=0; j<(1<<n); ++j){
			dp[j|x] = min(dp[j|x],dp[j]+a);
		}
	}
	cout << ((dp[(1<<n)-1]<INFLL)?dp[(1<<n)-1]:-1ll) << endl;
	return 0;
}


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

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int N_MAX = 400;

int n, m;
vector<Pll> graph[N_MAX];
vector<ll> memo(N_MAX, 0LL);

ll dfs(int node) {
    if(node == n-1) return 0LL;
    ll ret = 0LL;
    int child; ll cost;
    for(Pll p: graph[node]) {
        tie(child, cost) = p;
        if(memo[child]) ret = max(ret, memo[child] + cost);
        else ret = max(ret, dfs(child) + cost);
    }
    return memo[node] = ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m, x, y; ll c;
    cin >> n >> m;
    for(int i=0;i<m;++i){
        cin >> x >> y >> c;
        graph[x].emplace_back(y, c);
    }

    cout << dfs(0) << endl;
}



Measured memory_bytes: 3232
using System;

namespace _065b
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = new int[N+1];
            for(int i = 1; i<= N;i++){
                a[i] = int.Parse(Console.ReadLine());
            }
            int count = 0;
            int array_num = 1;
            bool[] tyouhukuFlag = new bool[N+1];
            while(true){
                if(array_num == 2){
                    break;
                }else if(tyouhukuFlag[array_num]){
                    count = -1;
                    break;
                }else{
                    tyouhukuFlag[array_num] = true;
                    array_num = a[array_num];
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 15456
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> V(N), C(N);
    for (int i = 0; i < N; i++)
    {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += max(V[i] - C[i], 0);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(int i = a ; i < b ; ++i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 1e9+9 ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  

ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}
ll power(ll a, ll n) { ll r=1;while(n){if(n&1)r=(r*a)%MOD;n>>=1;a=(a*a)%MOD;}return r%MOD;}
ll sq(int x) { ll ans = x*x ; return ans ; }
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
void read(vt<int> &a) {
	rep(i,0,a.size()) 
	cin >> a[i] ; 
}
void read(vt<ld> &a) {
	rep(i,0,a.size()) 
	cin >> a[i] ; 
}

// ==========Start Here==============

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	
	int n ; 
	cin >> n ; 
	vt<ld> a(n) ; 
	read(a) ; 
	set<pair<ld,int>> s ; 
	rep(i,0,n) {
		s.insert({a[i],i}) ; 
	}

	rep(i,0,n-1) {
		auto it1 = *s.begin() ; 
		s.erase(it1) ; 
		auto it2 = *s.begin() ; 
		s.erase(it2) ; 
		s.insert(mp((it1.ff+it2.ff)/2, it1.ss )) ; 
	}
	cout << fixed << setprecision(10) << (*s.begin()).ff << endl ;

 	
 	return 0 ; 
 	
}

Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5,mo=998244353;
int l[10],r[10],f[N],s[10];
int main(){
	int n,k;scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++)scanf("%d%d",l+i,r+i),r[i]++;
	f[1]=1;
	for(int i=2;i<=n;i++){
		for(int j=0;j<k;j++){
			if(i-r[j]>=0)(s[j]-=f[i-r[j]])%=mo;
			if(i-l[j]>=0)(s[j]+=f[i-l[j]])%=mo;
			(f[i]+=s[j])%=mo;
		}
	}
	printf("%d",(f[n]+mo)%mo);
	return 0;
}

Measured memory_bytes: 4588
#include<stdio.h>
 
int main(){

  int a,b,c;
 
  (void) scanf("%d %d %d",&a,&b,&c);
  
  if ((a==b && a!=c)||(b==c && a!=b)||(a==c && a!=b))
  {
    printf("Yes");
    return 0;
  }
    printf("No");
  
 return 0; 
}

Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
using i64 = int64_t;
const int INF = 1e9;
const int MOD = INF+7;
const i64 LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)
#define int int64_t 

signed main(){
    string s;
    cin >> s;
    if(s[5] == '0' && s[6]-'0' <= 4) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
    
}


Measured memory_bytes: 256
// D - Handstand 2
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using PII = pair<int,int>;

int N;

PII first_bottom(int x){
	int f=0, b=x%10;
	while(x){
		f = x;
		x/=10;
	}
	return PII(f,b);
}

ll solve(){
	ll ans=0;
	map<PII,int> C;//[{i,j}]<int>=count

	rp(k,1,N+1) C[first_bottom(k)]++;

	for(auto m:C){
		int i,j; tie(i,j) = m.first;
		ans += C[{i,j}]*C[{j,i}];
	}

	return ans;
}

int main(){
	cin>>N;
	cout<< solve() <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;


int main()
{
    int n,m;
    vector<pair<long long,int>> x;
    
    cin >> n >> m;
    long long k;
    for (int i = 0;i < n;i++){
        cin >> k;
        x.push_back({k,1});
    }
    long long q;
    int p;
    for (int i = 0;i < m;i++){
        cin >> p >> q;
        x.push_back({q,p});
    }
    sort(x.begin(),x.end());
    
    long long ans = 0;
    int j = 0;
    for (int i = 1;i <= n;i++){
        ans += x[n+m-i].first*min(n-j,x[n+m-i].second);
        j += x[n+m-i].second;
        if (j >= n){
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6384
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int n,sn,cnt,tmp,a[21][21],dp[2097153];
const int MOD=1e9+7;

int main()
{Tie
	cin>>n,sn=1<<n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	dp[0]=1;
	for(int i=1;i<sn;i++)
	{
		tmp=i,cnt=-1;
		while(tmp)
			cnt++,tmp-=tmp&-tmp;
		for(int j=1,rj=0;j<sn;j<<=1,rj++)
			if((i&j)&&a[cnt][rj])
				dp[i]=(dp[i]+dp[i^j])%MOD;
	}
	cout << dp[sn-1]<<'\n';
}

Measured memory_bytes: 8448
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

    if (n % 1000) cout << 1000 - n % 1000;
    else cout << 0;
}

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

int n,a[100005],ans=0,s=0;

int main(void){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(int i=2;i<=n;i++){
		if(a[i]<=a[i-1])s++;
		else{
			ans=max(ans,s);
			s=0;
		}
	}
	ans=max(ans,s);
	printf("%d",ans);
}

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

int main() {
  int N , l , r , i ,A ;
  A = 0 ;
  cin >> N ;
    while ( i < N ){
      cin >> l >> r ;
      A += (r-l+1) ;
      i++ ;
    }
  cout << A << endl ;
}


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

typedef struct{double x;
			 double y;
			 }Point;

void koch (int n, Point a, Point b)
{
	if(n==0)
	{
		return;
	}
	Point s, t, u;
	double th = M_PI*60.0/180.0;
	
	s.x =(2.0*a.x+1.0*b.x)/3.0;
	s.y =(2.0*a.y+1.0*b.y)/3.0;
	t.x =(1.0*a.x+2.0*b.x)/3.0;
	t.y =(1.0*a.y+2.0*b.y)/3.0;
	u.x =(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
	u.y =(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
	
	koch(n-1,a,s);
	printf("%.8f %.8f\n",s.x,s.y);
	koch(n-1,s,u);
	printf("%.8f %.8f\n",u.x,u.y);
	koch(n-1,u,t);
	printf("%.8f %.8f\n",t.x,t.y);
	koch(n-1,t,b);

}

int main()
{
	Point a,b;
	int n;
	scanf("%d",&n);
	a.x=0;
	a.y=0;
	b.x=100;
	b.y=0;
	
	printf("%.8f %.8f\n",a.x,a.y);
	koch(n,a,b);
	printf("%.8f %.8f\n",b.x,b.y);
	return 0;

}



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

using namespace std;

int main() {
	vector <vector<int>> A(3, vector<int>(3));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A.at(i).at(j);
		}
	}

	int N;
	cin >> N;

	vector<int> b(N);
	for (int i = 0; i < N; i++) {
		cin >> b.at(i);
	}

	bool ans = false;

	for (int i = 0; i < 3; i++) {
		int cnt = 0;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < N; k++) {
				if (b.at(k) == A.at(i).at(j)) cnt++;
			}
		}
		if (cnt == 3) ans = true;
	}

	for (int j = 0; j < 3; j++) {
		int cnt = 0;
		for (int i = 0; i < 3; i++) {
			for (int k = 0; k < N; k++) {
				if (b.at(k) == A.at(i).at(j)) cnt++;
			}
		}
		if (cnt == 3) ans = true;
	}

	int cnt = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < N; j++) {
			if (b.at(j) == A.at(i).at(i)) cnt++;
		}
	}
	if (cnt == 3) ans = true;

	cnt = 0;

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < N; j++) {
			if (b.at(j) == A.at(i).at(2 - i)) cnt++;
		}
	}
	if (cnt == 3) ans = true;

	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int K; cin >> K;
  string S; cin >> S;
  string result = S.size()<=K ? S : S.substr(0,K) + "...";
  cout << result << endl;
  return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);

//int dxy[5] = {0, 1, 0, -1, 0};
// assign

signed main()
{
    Int(n);
    int sum = 0;
    vi data(n, 0);
    rep(i, n) {
        cin >> data[i];
        sum += data[i];
    }

    int k = sum / (n * (n + 1) / 2);
    if (k * (n * (n + 1) / 2) != sum) {
        cout << "NO" << endl;
        return 0;
    }

    vi dist(n, 0);

    rep(i, n-1) {
        dist[i] = data[i+1] - data[i] - k;
    }
    dist[n-1] = data[0] - data[n-1] - k;

    rep(i, n) {
        if (dist[i] > 0 or (-dist[i]) % n) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int w,h,c;
	int x,y,r;
	cin>>w>>h>>c;
	x=w;
	y=h;
	if(x<y){
		swap(x,y);
	}
	while(1){
		r=x%y;
		if(r==0){
			r=y;
			break;
		}
		x=y;
		y=r;
	}
	
	cout<<(w/r)*(h/r)*c<<endl;
	return 0;
}



Measured memory_bytes: 3112
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int N,X;
  vector<int> a(N);
  cin >> N >> X;
  rep(i,N){
    cin >> a[i];
  }
  vector<int> S(N+1);
  S[0]=0;
  rep(i,N){
    S[i+1]=S[i]+a[i];
  }
  rep(i,N+1){
    if(S[i]>X){
      cout << i << endl;
      return 0;
    }
  }
  cout << N+1 << endl;
}


Measured memory_bytes: 49920
#include <iostream>
#define MOD 998244353

using namespace std;
long long dp[3001][3001];
int main() {
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    
    dp[0][0] = 1;
    for (int j=0; j<D-B; j++) {
        dp[0][j+1] = (dp[0][j] * A) % MOD;
    }
    for (int i=0; i<C-A; i++) {
        dp[i+1][0] = (dp[i][0] * B) % MOD;
    }
    for (int i=0; i<C-A; i++) {
        for (int j=0; j<D-B; j++) {
            dp[i+1][j+1] = (dp[i+1][j] * (A+i+1)) % MOD;
            dp[i+1][j+1] += (dp[i][j+1] * (B+j+1)) % MOD;
            dp[i+1][j+1] %= MOD;
            long long minus = (((dp[i][j] * (A+i))%MOD) * (B+j))%MOD;
            dp[i+1][j+1] += MOD - minus;
            dp[i+1][j+1] %= MOD;
        }
    }
    cout << dp[C-A][D-B] << endl;
    
    return 0;
}



Measured memory_bytes: 73872
import std;

long calc(long[] a) {
    long ans = 0;
    long[long] d;
    for (int i = 0; i < a.length; i++) {
        ans += d.get(i + 1 - a[i], 0);
        d[i + 1 + a[i]]++;
    }
    return ans;
}

void main() {
    read;
    auto a = reads!long;
    writeln(calc(a));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;


Measured memory_bytes: 24816
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long int ll;
const ll INF=pow(10,15);
ll N;
//29
int main()
{
scanf("%lld",&N);
int ans=1000;
for(int i=1;i<=min(N,(ll)100000);i++)
{
	if(N%i==0)
	{
		ll a=N/i,b=i;
		int diga=0,digb=0;
		for(;;){diga++; a/=10; if(a==0){break;}}
		for(;;){digb++; b/=10; if(b==0){break;}}
		diga=max(diga,digb);
		ans=min(ans,diga);
	}
}
printf("%d\n",ans);
} 

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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,w;
    cin >> h >> w;
    vector<int> coord_x;
    vector<int> coord_y;
    char table[h][w];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> table[i][j];
            if(table[i][j] == '#'){
                coord_x.push_back(i);
                coord_y.push_back(j);
            }
        }
    }
    int count = 0;
    int before_size = 0;

    while(true){
        int flag = 0;
        int now_size = coord_x.size();
        for(int i=before_size; i<now_size; i++){
            //cout << coord_x[i] << coord_y[i] << endl;
            if(true){
                for(int j=-1; j<=1; j++){
                    for(int k=-1; k<=1; k++){
                        if(!(k&&j)){
                            if(coord_x[i] + j >= 0 && coord_x[i] + j < h){
                                if(coord_y[i] + k >= 0 && coord_y[i] + k < w){
                                    if(table[coord_x[i]+j][coord_y[i]+k]=='.'){
                                        flag = 1;
                                        table[coord_x[i]+j][coord_y[i]+k] = '#';
                                        coord_x.push_back(coord_x[i]+j);
                                        coord_y.push_back(coord_y[i]+k);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if(flag==1){
            count++;
            before_size = now_size;
        }else{
            break;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 11232
#include <bits/stdc++.h>
using namespace std;
int main() {
 	string s; cin >> s;
  	int n = s.length();
  	int ret = n, cur = 0;
  	for (int i = 0; i < n; i++) {
     	if (i%2==0&&s[i]=='0')cur++;
      	if(i%2==1&&s[i]=='1')cur++;
    }
  	ret = min(ret,cur);
  	cur = 0;
  	for (int i = 0; i < n; i++) {
     	if (i%2==0&&s[i]=='1')cur++;
      	if(i%2==1&&s[i]=='0')cur++;
    }
  	ret = min(ret,cur);
  	cout << ret << endl;
}

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


void solve(long long X, long long N, std::vector<long long> p){
    set<long long> rest;
    for (int i = 0; i <= 101; i++) {
        rest.insert(i);
    }
    for (auto e: p) {
        rest.erase(e);
    }
    long long ans = -1;
    long long ans_diff = 1000;
    for (auto e: rest) {
        if (abs(e - X) < ans_diff) {
            ans = e;
            ans_diff = abs(e - X);
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(X, N, std::move(p));
    return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main() {
    int D;
    cin >> D;
    if(D == 25) cout << "Christmas" << endl;
    else if(D == 24) cout << "Christmas Eve" << endl;
    else if(D == 23) cout << "Christmas Eve Eve" << endl;
    else if(D == 22) cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, m;
int deg[110];
int graph[110][110];
vector<int> use;

ll calc(int depth, int need) {
  if ((int)use.size() == need) {
    ll ret = 0;
    FORIT(it1, use) {
      ll lans = 1LL << 30;
      FORIT(it2, use) {
        if (*it1 == *it2) { continue; }
        lans = min(lans, (ll)graph[*it1][*it2]);
      }
      ret += lans;
    }
    return ret;
  }
  if (depth == n) { return 0; }
  ll ret = calc(depth + 1, need);
  if (deg[depth] >= need - 1) {
    FORIT(it, use) {
      if (graph[depth][*it] == 0) { return ret; }
    }
    use.push_back(depth);
    ret = max(ret, calc(depth + 1,  need));
    use.pop_back();
  }
  return ret;
}

int main() {
  while (scanf("%d %d", &n, &m) > 0) {
    MEMSET(deg, 0);
    MEMSET(graph, 0);
    REP(i, m) {
      int x, y, c;
      scanf("%d %d %d", &x, &y, &c);
      x--; y--;
      graph[x][y] = graph[y][x] = c;
      deg[x]++;
      deg[y]++;
    }
    ll ans = 0;
    FOR(i, 2, 16) {
      use.clear();
      ans = max(ans, calc(0, i));
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
 
int main(){
  char c[300];
  int m,h,i,j,k,num=0,temp;
  while(1){
    scanf("%s",&c);
    if(c[0]=='-')break;
    for(num=0; num<300; num++)if(c[num]=='\0')break;
    scanf("%d",&m);
    for(i=0; i<m; i++){
      scanf("%d",&h);
      for(j=0; j<h; j++){
    temp=c[0];
    for(k=0; k<num; k++){
          c[k]=c[k+1];
    }
        c[num-1]=temp;
      }
    }
    printf("%s\n",&c);
  }
  return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll A, B, C, D;
    string input;
    cin >> input;
    A = (int)input.at(0) - 48;
    B = (int)input.at(1) - 48;
    C = (int)input.at(2) - 48;
    D = (int)input.at(3) - 48;
    ll sum = A;
    string ans = to_string(A);
    repi(i, 2, 0)
    {
        repi(j, 2, 0)
        {
            repi(k, 2, 0)
            {
                sum = (i == 0) ? sum + B : sum - B;
                sum = (j == 0) ? sum + C : sum - C;
                sum = (k == 0) ? sum + D : sum - D;
                if (sum == 7)
                {
                    ans = (i == 0) ? ans + "+" + to_string(B) : ans + "-" + to_string(B);
                    ans = (j == 0) ? ans + "+" + to_string(C) : ans + "-" + to_string(C);
                    ans = (k == 0) ? ans + "+" + to_string(D) : ans + "-" + to_string(D);
                    ans += "=7";
                    cout << ans << endl;
                    return 0;
                }
                sum = A;
            }
        }
    }
}


Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
A = [int(input()) for _ in range(N)]

def gcd(a, b):
    while b != 0:
        a, b = b, a % b

    return a

def lcm(a, b):
    return a // gcd(a, b) * b


ans = 1
for a in A:
    ans = lcm(ans, a)

print(ans)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int a[1000];

int main() {
  int n ;
  while (cin >> n) {
    inputs(a, n);
    int hoge = INF;
    int ans = 0;
    REP(i,n) {
      if (a[i] % 10)
        chmin(hoge, a[i]);
      ans += a[i];
    }
    if (ans % 10 == 0) {
      if (hoge != INF)
        ans -= hoge;
    }
    cout << (ans % 10 == 0 ? 0 : ans) << endl;
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr long long LONGINF = 1005000000000000000;



/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

int dy[] = { 0, 1, 0, -1 };
int dx[] = { 1, 0, -1, 0 };


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/



/*まだ使えないテクニックのメモだよ。

for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ

*/


int main() {
	int h, w; cin >> h >> w;

	char c[50][50];

	vector<pair<int, int> > v;

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c[i][j];
			if (c[i][j] == 'B') { v.push_back(make_pair(i, j)); }
		}
	}
	int ans = 0;
	for (auto x : v) {
		int s = x.first;
		int t = x.second;
		for (auto y : v) {
			int f = y.first;
			int g = y.second;
			if (s == f && t == g) { }
			else {
				ans = max(ans, abs(s - f) + abs(t - g));
			}
		}
	}

	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 3140
#python3
def main():
    s = input()
    A_index = s.index('A')
    t = [i for i in reversed(s)]
    Z_index = len(s) - t.index('Z') - 1

    if Z_index - A_index >= 0:
        print(Z_index - A_index + 1) 

main()


Measured memory_bytes: 5096
#include <bits/stdc++.h>
using namespace std;
using lint = long;
using ll = long long;
#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)
#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))
using lpair = pair<lint,lint>;
using Vecint = vector<lint>;
using Llist = list<lint>;

ll pow(ll k,ll l) {
	ll ret = 1;
	rep(i,l) {
		ret *= k;
	}
	return ret;
}

template <typename T>
T sum(vector<T> vec) {
	ll ret = 0;
	rep(i,vec.size()) {
		ret += vec.at(i);
	}
	return ret;
}

void Main() {
	lint A,B,M,x,y,c;
	cin >> A >> B >> M;
	Vecint a(A),b(B),d(M);
	rep(i,A) {
		cin >> a[i];
	}
	rep(i,B) {
		cin >> b[i];
	}
	rep(i,M) {
		cin >> x >> y >> c;
		d[i] = a[x-1] + b[y-1] - c;
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(d.begin(),d.end());
	if (a[0]+b[0] > d[0]) {
		cout << d[0] << '\n';
		return;
	}
	cout << a[0]+b[0] << '\n';
}

signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	Main();
	return 0;
}

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

int main() {
	int N, num, count = 0;
	int a[50];
	cin >> N;
	rep(i, N) {
		cin >> num;
		if(i+1 != num) count++;
	}
	if(count < 3) cout << "YES";
	else cout << "NO";
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
 
typedef struct{
  int p;
  int l;
  int r;
}Node;
 
int rec(int,int);
 
Node T[MAX];
int n,D[MAX];
 
int main(){
 
  int n,i,j,d,v,c,l,r;
 
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;
 
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
     
    for(j=0;j<d;j++){
      scanf("%d",&c);
 
      if(j==0) T[v].l=c;
      else T[l].r=c;
       
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL) r=i;
  }
 
  rec(r,0);
   
  for(i=0;i<n;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",T[i].p);
    printf("depth = %d, ",D[i]);
     
    if(T[i].p==NIL) printf("root, ");
    else if(T[i].l==NIL)printf("leaf, ");
    else printf("internal node, ");
 
    printf("[");
    for(j=0,c=T[i].l;c!=NIL;j++,c=T[c].r){
      if(j!=0) printf(", ");
      printf("%d",c);
    }
     
    printf("]\n");
  }
   
    return 0;
}
 
int rec(int u,int p){
 
  D[u]=p;
  if(T[u].r!=NIL) rec(T[u].r,p);
  if(T[u].l!=NIL) rec(T[u].l,p+1);
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = 1e9;
const LL LLINF = 1e18;
#define TENS(n) int(1e##n + n)

// i 番目から出発したときの最長経路
int dp[TENS(5)];
int deg_o[TENS(5)];
int visited[TENS(5)];
vector<int> A[TENS(5)];
int N, M;

int dfs(int v)
{
    if (visited[v])
        return dp[v];

    visited[v] = 1;
    int ans = 0;

    for (auto j : A[v])
    {
        ans = max(ans, dfs(j) + 1);
    }
    return dp[v] = ans;
}

void solve()
{
    cin >> N;
    cin >> M;
    // A[i]...iに向かう頂点の配列

    REP0(i, M)
    {
        int x, y;
        cin >> x >> y;
        A[y].push_back(x);
        deg_o[x]++;
    }

    int ans = 0;

    REP1(i, N)
    {
        if (deg_o[i] == 0) // 終点
        {
            ans = max(ans, dfs(i));
            //         queue<int> S;
            //         S.push(i);
            //         while (S.size())
            //         {
            //             int v = S.front();
            //             S.pop();

            //             for (auto j : A[v])
            //             { // j : vへ向かう頂点
            //                 S.push(j);
            //                 dp[j] = max(dp[j], dp[v] + 1);
            //                 ans = max(ans, dp[j]);
            //             }
            //         }
        }
    }

    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 11648
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
lst = [a%10,b%10,c%10,d%10,e%10]
lst.sort()
cnt = 0
for i in range(len(lst)):
  if lst[i] == 0:
    cnt += 1
if cnt == 5:
  print(a+b+c+d+e)
else:
  print((a//10+b//10+c//10+d//10+e//10+4-cnt)*10+lst[cnt])


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

int main()
{
    int n;
    cin >> n;
    map<string, int> m;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        m[s]++;
    }
    
    int top = 0;
    for(auto& e: m) top = max(e.second, top);
    for(auto& e: m){
        if(e.second == top) cout << e.first << endl;
    }
    
    return 0;
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
	int n, sum_all = 0;
	
	cin >> n;
	vector<int> a(n + 2);
	vector<int> a_diff(n + 1);

	a[0] = 0;
	a[n + 1] = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i + 1];
		a_diff[i] = abs(a[i + 1] - a[i]);
		sum_all += a_diff[i];
	}
	a_diff[n] = abs(a[n + 1] - a[n]);
	sum_all += a_diff[n];
	for (int i = 0; i < n; i++)
		cout << sum_all - a_diff[i] - a_diff[i + 1] + abs(a[i] - a[i + 2]) << endl;
}


Measured memory_bytes: 4076
#include <cstdio>
#include <queue>
#include <vector>

#define MAX 1000000

typedef std::pair<int, int> P;

int n, q, as[MAX];

int main(){
    std::priority_queue<P> que;

    scanf("%d %d", &n, &q);
    for(int i = 0; i < q; i++){
        int a, v;
        scanf("%d %d", &a, &v);
        as[a - 1] += v;

        que.push(P(as[a - 1], -1 * (a - 1)));
        while(!que.empty()){
            P p = que.top();

            if(as[-1 * (p.second)] == p.first){
                printf("%d %d\n", -1 * p.second + 1, p.first);
                break;
            }
            que.pop();
        }
    }

    return 0;
}

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

const size_t arr_size = 32 * 24;
int arr[arr_size][arr_size];

pair<int, int> edge(pair<int, int> orig) {
    int h, w;
    tie(h, w) = orig;
    int rh = h, rw = w;
    while(arr[rh][w] > 0) rh++;
    while(arr[h][rw] > 0) rw++;
    return make_pair(rh, rw);
}

bool solve() {
    int N, M, T, P;
    cin >> N >> M >> T >> P;

    if(!(N + M + T + P)) return false;

    for(int i = 0; i < arr_size; i++) for(int j = 0; j < arr_size; j++) {
        arr[i][j] = (0 <= i && i < M &&
                     0 <= j && j < N);
    }

    pair<int, int> orig(0, 0);
    while(T--) {
        int d, c;
        cin >> d >> c;
        int oh, ow;
        tie(oh, ow) = orig;
        int bh, bw;
        tie(bh, bw) = edge(orig);
        if(d == 1) {
            int nh = oh, nw = ow + c;
            int w_sum = 2 * c - 1;
            for(int h = oh; h < bh; h++) {
                for(int dw = 0; dw < w_sum - dw; dw++) {
                    arr[h][ow + w_sum - dw] += arr[h][ow + dw];
                    arr[h][ow + dw] = 0;
                }
            }
            orig = make_pair(nh, nw);
        } else {
            int nh = oh + c, nw = ow;
            int h_sum = 2 * c - 1;
            for(int dh = 0; dh < h_sum - dh; dh++) {
                for(int w = ow; w < bw; w++) {
                    arr[oh + h_sum - dh][w] += arr[oh + dh][w];
                    arr[oh + dh][w] = 0;
                }
            }
            orig = make_pair(nh, nw);
        }
    }

    int oh, ow;
    tie(oh, ow) = orig;
    while(P--) {
        int x, y;
        cin >> x >> y;
        cout << arr[oh + y][ow + x] << endl;
    }
    return true;
}

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



Measured memory_bytes: 5400
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if(a>=k){
        ans += 1*k;
        cout << ans << endl;
        return 0;
    }
    ans += 1*a;
    k-=a;
    if(b>=k){
        cout << ans << endl;
        return 0;
    }
    k-=b;
    if(c>=k){
        ans -= 1*k;
        cout << ans << endl;
        return 0;
    }
    ans -= c;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	int totac=0,totwa=0,tottle=0,totre=0;
	while(n--){
		cin>>s;
		if(s=="AC")
			++totac;
		if(s=="WA")
			++totwa;
		if(s=="TLE")
			++tottle;
		if(s=="RE")
			++totre;
	}
	cout<<"AC x "<<totac<<endl;
	cout<<"WA x "<<totwa<<endl;
	cout<<"TLE x "<<tottle<<endl;
	cout<<"RE x "<<totre<<endl;
	return 0;
}

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

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a == 0 && b == 0){
    cout << 0 << endl;
    return 0;
  }
  if(c == 0 && d == 0){
    cout << 0 << endl;
    return 0;
  }
  if(a == 0){
    if(c > 0){
      cout << b * d << endl;
      return 0;
    }
    if(d < 0){
      cout << 0 << endl;
    }
  }
  if(b == 0){
    if(c > 0){
      cout << 0 << endl;
      return 0;
    }
    if(d < 0){
      cout << a * c << endl;
      return 0;
    }
  }
  if(c == 0){
    if(a > 0){
      cout << b*d << endl;
      return 0;
    }
    if(b < 0){
      cout << 0 << endl;
      return 0;
    }
  }
  if(d == 0){
    if(a > 0){
      cout << 0 << endl;
      return 0;
    }
    if(b < 0){
      cout << a * c << endl;
      return 0;
    }
  }
  if(a > 0 &&  c > 0){
    cout << b * d << endl;
    return 0;
  }
  if(b < 0 && d < 0){
    cout << a * c << endl;
    return 0;
  }
  if(a > 0 && d < 0){
    cout << a * d << endl;
    return 0;
  }
  if(b < 0 && c > 0 ){
    cout << b * c << endl;
    return 0;
  }
    if(a*c < b*d){
      cout << b*d << endl;
    } else {
      cout << a*c << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int ans = 0;
    string line;
    while(cin >> line) {
        int l = 0, r = line.size()-1;
        bool ok = true;
        while(l < r) {
            if(line[l++] != line[r--]) {
                ok = false;
                break;
            }
        }
        if(ok) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(5e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n;
    cin >> n;
    if(n==3 || n==5 || n==7){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	ll n;
	cin >> n;
	ll c[3];
	c[0] = c[1] = c[2] = 0;

	vector<ll> a;

	rep(i, n)
	{
		ll t;
		cin >> t;
		auto it = find(a.begin(), a.end(), t);
		if (it == a.end())
		{
			a.push_back(t);
			if (a.size() > 3)
			{
				cout << "No" << endl;
				return 0;
			}
			c[a.size() - 1]++;
		}
		else
			c[distance(a.begin(), it)]++;

	}

	if (a.size() == 1 && a[0] == 0)
		cout << "Yes" << endl;
	else if (a.size() == 2 && ((c[0] / 2 == c[1] && a[1] == 0) || (c[1] / 2 == c[0] && a[0] == 0)))
		cout << "Yes" << endl;
	else if (c[0] == c[1] && c[1] == c[2] && ((a[0] ^ a[1]) == a[2]) && ((a[1] ^ a[2]) == a[0]) && ((a[0] ^ a[2]) == a[1]))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 256