akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
from collections import deque
from bisect import bisect_left

def solve(N: int, A: "List[int]"):
    deq = deque([-1])

    for i in range(N):
        index = bisect_left(deq,A[i])
        if index == 0:
            deq.appendleft(A[i])
        else:
            deq[index-1] = A[i]
    print(len(deq))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 49756
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int n,q; cin >> n >> q;
    string s; cin >> s;
    vector<int> l(q),r(q);
    for(int i = 0;i < q;i ++) cin >> l.at(i) >> r.at(i);

    for(int i = 0;i < q;i ++){
        l.at(i) --;
        r.at(i) --;
    }

    vector<int> ans(n);
    for(int i = 1;i < n;i ++){
        ans.at(i) = ans.at(i-1);
        if(s.at(i-1) == 'A' && s.at(i) == 'C') ans.at(i) ++;
    }

    for(int i = 0;i < q;i ++){
        cout << ans.at(r.at(i)) - ans.at(l.at(i)) << endl;
    }
}

Measured memory_bytes: 5828
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var yy = int.Parse(line[0]);
            var mm = int.Parse(line[1]);
            var dd = int.Parse(line[2]);
            var a = getYearDay(yy + 1);
            var b = get1020(yy, mm, dd);
            Console.WriteLine(a + b  + 1);
        }
    }
    public static int getYearDay(int yy)
    {
        var count = 0;
        for (int i = yy; i <= 999; i++) if (i % 3 == 0) count++;
        return count * 200 + (999 - yy + 1 - count) * 195;
    }
    public static int get1020(int yy, int mm, int dd)
    {
        if (yy % 3 == 0) return (10 - mm) * 20 + 20 - dd;
        else
        {
            var m20 = (10 - mm) / 2;
            var m19 = 10 - mm - m20;
            var d = mm % 2 == 0 ? 19 - dd : 20 - dd;
            return m20 * 20 + m19 * 19 + d;
        }
    }
}



Measured memory_bytes: 9176
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
using namespace std;
namespace mine
{
	typedef long long ll;
	#define pr pair<int,int>
	#define FR first
	#define SE second
	#define MP make_pair
	#define PB push_back
	#define vc vector
	void chmax(int &x,const ll y) {x=(x>y?x:y);}
	void chmin(int &x,const ll y) {x=(x<y?x:y);}
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) putchar('-'),num=-num;
		if(num>=10) write(num/10);
		putchar('0'+num%10);
	}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	const int INF=0x3f3f3f3f;
	const int MOD=19930726;
	void add(ll &a,ll b){a+=b;if(a>=MOD)a-=MOD;if(a<=-MOD)a+=MOD;}
	ll qpower(ll x,int e)
	{
		ll ans=1;
		while(e)
		{
			if(e&1) ans=ans*x%MOD;
			x=x*x%MOD;e>>=1;
		}
		return ans;
	}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=1e7+10;

	int nxt[N];
	char A[N],B[N];
	void pre(int m)
	{
		nxt[1]=0;
		for(int i=2;i<=m;i++)
		{
			int j=nxt[i-1];while(j and B[j+1]!=B[i]) j=nxt[j];
			nxt[i]=j+(B[j+1]==B[i]);
		}
	}
	int kmp(int n,int m)
	{
		int mx=0;
		for(int now=0,i=1;i<=n;i++)
		{
			while(now and B[now+1]!=A[i]) now=nxt[now];
			now+=(B[now+1]==A[i]);
			if(now%m==0) mx=max(mx,now/m);
		}
		return mx;
	}

	void main()
	{
		scanf("%s%s",A+1,B+1);int n=strlen(A+1),m=strlen(B+1);
		for(int i=n+1;i<N;i++) A[i]=A[(i-1)%n+1];
		for(int i=m+1;i<N;i++) B[i]=B[(i-1)%m+1];pre(N-1);
		// for(int i=1;i<=3*m;i++) write1(nxt[i]);

		int k=max(ceil(1.0*m/n),2.0),nn=n*k,gg=kmp(nn,m);
		if(gg==0) {puts("0");return;}
		int qq=kmp(nn*3,m),pp=kmp(nn*4,m);
		if(pp!=qq) puts("-1");
		else write(pp);
	}
};
int main()
{
	srand(time(0));
	mine::main();
}


Measured memory_bytes: 58880
n = int(input())
i = 0
N = []
while i < n:
  N.append(int(input()))
  i += 1
  
mep = max(N)
idm = N.index(mep)
N[idm] = mep /2

price = sum(N)
price = int(price)

print(price)

           
  

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S_1,S_2;
    cin >> S_1 >> S_2;
    if(S_1.at(0) == S_2.at(2) && S_1.at(1) == S_2.at(1) && S_1.at(2) == S_2.at(0)){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


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

    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end());
    int m1 = b[n / 2 - 1];
    int m2 = b[n / 2];
    for(int i = 0; i < n; i++){
        if(a[i] <= m1)
            cout << m2 << endl;
        else
            cout << m1 << endl;
    }
}


Measured memory_bytes: 3840
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;
int a[15][15];
int c[205][205];
int d[15][15];
void dij()
{
    FOR(k,0,9)
    FOR(i,0,9)
    FOR(j,0,9)
    a[i][j] = min(a[i][j], a[i][k]+a[k][j]);

}
int main()
{
    int h, w;
    cin >> h >> w;
    FOR(i,0,9)
    FOR(j,0,9)
    cin >> a[i][j];
    dij();
    FOR(i,1,h)
    FOR(j,1,w)
    cin >> c[i][j];
    int sum = 0;
    FOR(i,1,h)
    FOR(j,1,w)
    {
        if(c[i][j] == 1|| c[i][j] == -1)continue;
        sum += a[c[i][j]][1];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,d;
	int i;
	int j;
	int x;
	cin>>d>>n;
	i=0;
	int cnt=0;
	while(1){
		x=i;
		j=i;
		//cout<<x<<endl;
		if(d==0){
			if(x%100!=0){
				cnt++;
			}
		}
		else{
			if(d==1){
				if(x%10000!=0&&x%100==0){
					cnt++;
				}
			}
			else{
				if(x%10000==0&&x%1000000!=0){
					cnt++;
				}
			}
		}
		if(cnt==n){
			cout<<j<<endl;
			break;
		}
		i++;
	}
	
				
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],ans=0,ab[220];
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>n>>m;
    for(int i=n;i<m+1;i++){
        s=to_string(i);
        if(s[0]==s[4]&&s[1]==s[3]){
            cnt++;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 10516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, cnt[20];

string cal(){
	ll mp[10];
	memset(mp, -1, sizeof(mp));
	ll ab = 0;
	zep(i, 0, n){
		if(mp[cnt[i]] == -1){
			mp[cnt[i]] = ab;
			ab++;
		}
	}
	string res = "";
	zep(i, 0, n){
		res += char(mp[cnt[i]]+'a');
	}
	return res;
}

ll fac(ll x){
	ll res = 1;
	while(x){
		res *= x;
		x--;
	}
	return res;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	
	memset(cnt, 0, sizeof(cnt));
	set<string> s;
	
	//print(fac(n))
	zep(i, 0, fac(n)){
		string tmp = cal();
		s.insert(tmp);
		
		cnt[n-1]++;
		rrep(j, n-1, 1){
			if(cnt[j] > j){
				cnt[j] = 0;
				cnt[j-1]++;
			}
		}
	}
	
	for(auto it = s.begin(); it != s.end(); it++){
		print(*it);
	}
	
	return 0;
}

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

int n;
ll mod = 1e9 + 7;
ll ans = 1;
ll pos[100010];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> pos[i];
    ll cnt = 0;
    for (int i = 1; i <= n; i++) {
        cnt++;
        if (pos[i] >= cnt * 2 - 1) continue;
        ans *= cnt--;
        ans %= mod;
    }
    while (cnt > 0) {
        ans *= cnt--;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
import numpy as np
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
atc = ["A", "C", "G", "T"]

ans = 0

for l in range(len(S)):
	r = l
	while r < len(S) and S[r] in atc:
		r += 1

	ans = max(ans, r-l)

print(ans)



Measured memory_bytes: 12500
#include <bits/stdc++.h>
#define boost ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define M 1000000007
#define eb emplace_back
#define watch(x) cout << (#x) <<" is "<< x <<"\n";


using namespace std;
//const int N = 1e6;

int32_t main(){
  boost;
  int tc = 1; //cin >> tc;
  while(tc--)
  {
    int ans = 0;
    int n; cin >> n;
    for(int i=1; i<=n; i++)
    {
      for(int j=1; j<=n; j++)
      {
        int a = __gcd(i, j);
        for(int k=1; k<=n; k++)
        {
          ans += __gcd(a, k);
        }
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3608
#include<stdio.h>

int main(){
  int N,A,am=0,am2=0,ind;
  scanf("%d",&N);
  for(int i = 0;i < N;i++){
  	scanf("%d",&A);
    if(A > am){am2 = am;am = A;ind = i;}
    else if(A > am2){am2 = A;}
  }
  for(int i = 0;i < N;i++){
    printf("%d\n",i == ind?am2:am);
  }
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n, k;
	cin >> n >> k;
	int f[200001] = {};
	for (int i = 1; i <= n; ++i)
		++f[i%k];
	ll res = 0;
	for (int i = 0; i <= n; ++i)
		if ((i + i) % k == 0)
			res += (ll)f[i] * f[i] * f[i];
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
def main():
    import sys
    input = sys.stdin.readline

    INF = 1 << 30

    H, N = map(int, input().split())

    dp = [INF] * (H + 1)
    dp[0] = 0

    for _ in range(N):
        A, B = map(int, input().split())
        for j in range(H):
            nj = min(H, j + A)
            dp[nj] = min(dp[nj], dp[j] + B)
    print(dp[H])


if __name__ == '__main__':
    main()


Measured memory_bytes: 40432
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;

int n, l, tab[N], i, d, le, pr;
LL res, rRe, rLe, SL[N], SR[N];

int main() {
scanf("%d %d", &l, &n);
for (i=1;i<=n;i++) scanf("%d", &tab[i]);
res = 0;
SL[0] = 0;;
for (i=1;i<=n;i++) SL[i] = SL[i - 1] + tab[i];
SR[n + 1] = 0;
for (i = n;i>=1;i--) SR[i] = SR[i + 1] + (l - tab[i]);
for (i=1;i<=n;i++) {
	le = i - 1;
	pr = n - i;
	if (pr > le) {
		d = pr - 1 - le;
		rLe = (SR[i + 1] - SR[n  + 1 - d]) * 2 + SL[i - 1] * 2 + tab[i];
	} else {
		d = le - pr;
		rLe = SR[i + 1] * 2 + (SL[i - 1] - SL[d]) * 2 + tab[i];
	}
	if (le > pr) {
		d = le - 1 - pr;
		rRe = (SL[i - 1] - SL[d]) * 2 + SR[i + 1] * 2 + (l - tab[i]);
	} else {
		d = pr - le;
		rRe = SL[i - 1] * 2 + (SR[i + 1] - SR[n + 1 - d]) * 2 + (l - tab[i]);
	}
	//cout << tab[i] << " " << rLe << " " << rRe << endl;
	res = max(res, rLe);
	res = max(res, rRe);
}
cout << res << endl;
return 0;
}



Measured memory_bytes: 4096
Anum, Bnum, Cnum, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

yum = []
for ia in range(Anum):
    if(ia > K):
        break
    for ib in range(Bnum):
        if(ia * ib > K):
            break
        for ic in range(Cnum):
            if(ia * ib * ic > K):
                break
            yum.append(A[ia] + B[ib] + C[ic])
yum.sort(reverse=True)
for k in range(K):
    print(yum[k])


Measured memory_bytes: 112344
from sys import stdin
N=int(input())
nodes=[None]*N
class node_tree():
    def __init__(self,node):
        self.node=node
        self.left=None
        self.right=None
        self.brother=None
        self.up=None

def ino(u):

    if u.left is not None:
        ino(u.left)
    print("",u.node,end="")
    if u.right is not None:
        ino(u.right)
def pre(u):
    print("",u.node,end="")
    if u.left is not None:
        pre(u.left)
    if u.right is not None:
        pre(u.right)
def search(u,key):
    if u.node <=key.node:
        if u.right is not None:
            search(u.right,key)
        else:u.right=key
    else:
        if u.left is not None:
            search(u.left,key)
        else:u.left=key
def find(u,key):
    if u.node==key:
        print("yes",end="")
        return
    if u.node < key:
        if u.right is not None:
            find(u.right, key)
        else:
            print("no",end="")
            return
    else:
        if u.left is not None:
            find(u.left, key)
        else:
            print("no",end="")
            return
command_list=[]*N
for i in range(N):
    command_list.append((stdin.readline().strip().split()))
for i,command in enumerate(command_list):
    if len(command)!=1:
        if command[0]=="find":
            find(nodes[0],int(command[1]))
            print()
        else:
            key=int(command[1])
            if i==0:
                nodes[i]=node_tree(key)
            else:
                ins=node_tree(key)
                search(nodes[0],ins)
                nodes[i]=ins
    else:
        ino(nodes[0])
        print()
        pre(nodes[0])
        print()




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

int main(){ 
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d || ( abs(a - b)  <= d && abs(b - c) <= d)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
} 

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

int main(){
    int n; cin >> n; 
    pair<int, int> w[n];
    for(int i = 0; i < n; i++){
        int a,b; cin >> a >> b;
        w[i] = make_pair(b,a);
    }
    sort( w, w+n);
    int now = 0;
    for(int i = 0; i < n; i++){
        now += w[i].second;
        if(now > w[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  set< char > st;
  for(int i = 0 ; i < s.size() ; i++){
		st.insert(s[i]);
  }
  if(st.size() == 2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
  ll k, a, b;
  cin >> k >> a >> b;
  ll ans = 1;
  if (a >= b) {
    cout << ans + k << endl;
    return 0;
  }

  if (k < a - 1) {
    cout << ans + k << endl;
    return 0;
  }

  if (a + 1 == b) {
    cout << ans + k << endl;
    return 0;
  }

  k -= (a - 1);
  if (k == 1) {
    cout << ans + a << endl;
    return 0;
  }
  if (k == 0) {
    cout << a << endl;
    return 0;
  }

  ans = a;
  if (k % 2 == 0) {
    ans += (b - a) * k / 2;
  } else {
    ans += (b - a) * (k / 2) + 1;
  }

  cout << ans << endl;
}


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

int main(){
  int i,j,cnt=0;
  ll w,h,x,y;
  cin>>w>>h>>x>>y;
  if(w%2==0 && h%2==0 && w/2==x && h/2==y)cnt=1;
  printf("%.10lf %d\n",(double)(w*h)/2,cnt);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int N,u,k,x,r=0;
vector<int>V[105];
bool f[105]={0};
P c[105];

void dfs(int p)
{
	if(f[p])return;
	r++;
	f[p]=1;
	c[p].first=r;
	for(int i=0;i<V[p].size();i++)
	{
		dfs(V[p][i]);
	}
	r++;
	c[p].second=r;
}

int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		scanf("%d%d",&u,&k);u--;
		for(int j=0;j<k;j++)
		{
			scanf("%d",&x);x--;
			V[u].push_back(x);
		}
		sort(V[u].begin(),V[u].end());
	}
	for(int i=0;i<N;i++)
		dfs(i);
	for(int i=0;i<N;i++)
		printf("%d %d %d\n",i+1,c[i].first,c[i].second);
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int x; cin >> x;
	cout << (x < 1200 ? "ABC" : "ARC") << endl;  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int k;
  cin >> k;
  vector<int> firstGcd;
  for (int i = 1; i <= k; i++)
  {
    for (int j = 1; j <= k; j++)
    {
      firstGcd.push_back(gcd(i, j));
    }
  }

  vector<int> secondGcd;
  for (auto i : firstGcd)
  {
    for (int j = 1; j <= k; j++){
      secondGcd.push_back(gcd(i, j));
    }
  }

  ll sum = 0;
  for (auto g : secondGcd)
  {
    sum += g;
  }

  cout << sum << endl;
}

Measured memory_bytes: 36392
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=200050;
int x[N],n,X,y[N];
ll Solve(int mid)
{
	int i;
	ll ans=0;
	for(i=n;i>=1;i--)
	{
		if((n-i)%mid==0) y[i]=y[i+1]+1;
		else y[i]=y[i+1];
		if(y[i]==1) ans+=(ll)2*x[i];
		ans+=(ll)(y[i]+1)*(y[i]+1)*x[i]-(ll)y[i]*y[i]*x[i];
	}
	return ans+(ll)mid*X+(ll)n*X;
}
int main()
{
    int i;
    scanf("%i %i",&n,&X);
    for(i=1;i<=n;i++) scanf("%i",&x[i]);
    int top=n-1,bot=1,mid;
    ll ans=Solve(n);
    while(top>=bot)
	{
		mid=top+bot>>1;
		ll x=Solve(mid),y=Solve(mid+1);
		if(x<y) ans=x,top=mid-1;
		else bot=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long N, M;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N;
	int A[4][100+2] = {0};

	cin >> N;
	for(int i=1; i<=2; i++){
		for(int j=1; j<=N; j++){
			cin >> A[i][j];
		}
	}

	long long ans = 0;
	for(int i=1; i<=N; i++){
		long long c = 0;
		//マス(i, N)で下に折れる
		for(int j=1; j<=i; j++){
			c += A[1][j];
		}
		for(int j=i; j<=N; j++){
			c += A[2][j];
		}
		if(ans < c){
			ans = c;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

ll gcd(ll a,ll b){
    if(a<b) return gcd(b,a);
    ll r;
    while((r=a%b)){
        a=b;
        b=r;
    }
    return b;
}

ll dp[201][201][201];

ll gcd3(ll a,ll b,ll c){
    if(dp[a][b][c] != -1) return dp[a][b][c];
    dp[a][b][c] = gcd(gcd(a,b),c);
    return dp[a][b][c];
}

int main(void){
    ll k;
    cin>>k;
    ll ans = 0;
    rep(a,201) rep(b,201) rep(c,201) dp[a][b][c] = -1;
    for(int a=1;a<=k;++a){
        for(int b=1;b<=k;++b){
            for(int c=1;c<=k;++c){
                ans += gcd3(a,b,c);
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 67064
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x%N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x)%N;
		y = y >> 1;
		x = (x * x)%N;
	}
	return res;
}
double dist(ll x1,ll y1, ll x2,ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	vector<ll> arr(n, 0);
	f(i, 0, n)
	{
		cin >> arr[i];
	}
	ll ans = 0;
	f(i, 0, n)
	{
		f(j, i + 1, n)
		{
			ans += arr[i] * arr[j];
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long[] a=new long[n];
		long sum=0;
		for(int i=0; i<n; i++){
			a[i]=sc.nextLong();
			sum+=a[i];
		}
		long ans=Long.MAX_VALUE;
		long ss=0;
		for(int i=0; i<n; i++){
			ss+=a[i];
			ans=Math.min(ans,Math.abs(sum-2*ss));
		}
		System.out.println(ans);
	}
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            abc079_a();
        }

        static void abc079_a()
        {
            // A - Good Integer
            int N = int.Parse(Console.ReadLine());
            int[] dig = new int[4];
            for (int i=0; i < 4; i++)
            {
                dig[i] = N % 10;
                N /= 10;  // 整数と整数の除算は整数、端数を0に近いほうに丸めた値
            }
            string ans = "No";
            if (dig[0] == dig[1] && dig[1] == dig[2]) ans = "Yes";
            if (dig[1] == dig[2] && dig[2] == dig[3]) ans = "Yes";
            Console.WriteLine(ans);
        }
    }
}

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



int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    
    if(a < k) {
        k -= a;
        a = 0;
        
        b -= k;
        if(b < 0)
            b = 0;
    }
    else {
        a -= k;
    }
    
    cout << a << " " << b << endl;
    
    
    
    return 0;
}




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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const ll _INF = 1e18+7;
const int mxn = 2e5+7;

ll a[mxn], pf[mxn], ans = 0;

int main(){
	setIO();
	int n; cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		pf[i] = (a[i]+(i?pf[i-1]:0))%INF;
	}
	for (int i = 1; i < n; i++){
		ans = (ans+(pf[i-1]*a[i])%INF)%INF;
	}
	cout << ans%INF << endl;
}

Measured memory_bytes: 6760
#include <iostream>
#include <vector>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> dp(n+2);
    rep(i, 0, m){
        cin >> a[i];
        dp[a[i]] = 1;
    }
    dp[n] = 1;
    dp[n+1] = 0;
    int mod = 1e9+7;
    for(int i = n-1; i >= 0; i--){
        if(dp[i] == 1){
            dp[i] = 0;
        }else{
            dp[i] = (dp[i+1] + dp[i+2]) % mod;
        }
    }
    cout << dp[0] << endl;
    return 0;
}


Measured memory_bytes: 1024
public class Main {
  private static void solve() {
    int h = ni();
    int a = ni();

    System.out.println((h + a - 1) / a);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
 
#define IOS 		ios_base::sync_with_stdio(false);; cin.tie(0); cout.tie(0)
#define sd(n)       scanf("%d", &n)
#define sdd(a,b)    scanf("%d %d", &a, &b)
#define sddd(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sld(n)      scanf("%lld", &n)
#define slld(a,b)   scanf("%lld %lld", &a, &b)
#define sllld(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define slu(n)      scanf("%llu", &n)
#define sllu(a,b)   scanf("%llu %llu", &a, &b)
#define slllu(a,b,c) scanf("%llu %llu %llu", &a, &b, &c)
#define ss(a)		scanf("%s", a)
#define inStrAftInSome cin.ignore(numeric_limits<streamsize>::max(),'\n')		//input string(with whitespace) after input something(char, int, bool, str)
#define all(a) 		a.begin(),a.end()
#define unq(x)      x.erase(unique(all(x)), x.end()
#define mp 			make_pair
#define mt 			make_tuple
#define sz(av) 		int((av).size())					//return size of vec
#define CLR(arr)    memset(arr, 0, sizeof(arr))			//assign 0 to whole arr
#define SET(vec)    memset(arr, -1, sizeof(arr))		//assign -1 to whole arr
#define CLRV(vec)	fill(vec.begin(), vec.end(), 0)		//assign 0 to whole vec
#define SETV(vec,n,a) vec.assign(n, a)	
#define vtd(rowsize,colsize,type,name) 		vector < vector <type> > name(rowsize,vector <type> (colsize)); 	//assign to first n elements value a in vec
#define SETB(a)		memset(a, true, sizeof(a))			//boolean array initialize by true value
#define CLRB(a)		memset(a, false, sizeof(a))			//boolean array initialize by false value
#define vintitr 	vector<int>::iterator
#define vlnlnitr 	vector<long long>::iterator
#define sintitr 	set<int>::iterator
#define slnlnitr 	set<long long>::iterator
#define aa			first
#define bb			second
#define mod 		1000000007
#define PI 			acos(-1.00)
#define psb 		push_back
#define ppb			pop_back
#define ppb			pop_back
#define psf			push_front
#define ppf			pop_front
#define in 			inset
#define rep(i, n) 	for(int i=0; i<n; i++)
#define repi(i,j,n) for(int i=j; i<n; i++)
#define rof(i, n)   for(int i=n-1; i>=0; i--)
#define roff(i, n, f)	for(int i = n-1; i>=f; i--)
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define __lcm(a, b)	a*b / __gcd(a, b)
#define __builtin_zerocount(a)	8*sizeof(a)-__builtin_popcount(a)-__builtin_clz(a)-__builtin_ctz(a)
#define D(t)        cerr << #t " = " <<t  << '\n'
#define DBG         cerr << "Hi!" << '\n'
 
 
typedef long long	 		ll;
typedef unsigned long long	llu;
typedef long double			ld;
typedef vector< int > 		vi;
typedef vector< vi >		vvi;
typedef pair<int, int> 		pii;
typedef tuple<int,int,int>  tiii;

int main()
{
//	freopen("t.in","r",stdin);
//	freopen("t.out","w",stdout);
	IOS;
	string str;	cin >> str;
	int k;	cin >> k;
	vi fre;
	for (int i = 0; i < str.length(); ++i)
	{
		int cnt = 1;
		while(str[i] == str[++i])	cnt++;
		i--;
		fre.psb(cnt);
	}
	if(fre.size() == 1)
	{
		cout <<1LL*fre[0]*k / 2 << endl;
		return 0;
	}
	llu ans = 0;
	for(auto x : fre)
		ans += x / 2;
	ans = ans*k;
	if(fre.front() % 2 == 1 && fre.back() % 2 == 1 && str[0] == str[str.length()-1])
		ans += k-1;
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeMap;
import java.util.Map;
import java.util.Set;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    // int[] a = new int[n];
    TreeMap<Double,Integer> a = new TreeMap<>();

    for(int i = 0; i < n ; i++){
      double tmp = (double)sc.nextInt();
      Integer value = a.remove(tmp);
      // System.out.println(value + "," + tmp);
      if(value == null){
        a.put(tmp, 1);
      } else {
        a.put(tmp, value + 1);
      }
    }
    // System.out.println();

    for(int i = 0; i < m ; i++){
      Map.Entry<Double,Integer> tmp = a.pollLastEntry();
      Double value = tmp.getKey();
      Integer zan = tmp.getValue();
      // System.out.println(value + "," + zan);
      if(zan > 1) {
        a.put(value, zan - 1);
      }
      Double key = value / 2d;
      Integer count = a.remove(key);
      if(count == null){
        count = 0;
      }
      a.put(key, count + 1);

    }

    // System.out.println();
    long ans = 0l;

    Set<Double> keySet = a.keySet();
    for(double key: keySet){
      // System.out.println(key + "," + a.get(key));
      ans += (long)key * (long)a.get(key);
    }

    System.out.println(ans);
  }
}


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

int main() {
    int n,m,a,b;
    cin>>n>>m;
    vector<int> ans(n);
    rep(i,m) {
        cin>>a>>b;
        ans[a-1]++;
        ans[b-1]++;
    }
    rep(i,n) cout<<ans[i]<<endl;
}


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

using namespace std;

struct edge
{
	int a;
	int b;
};

int main()
{
	int n, m;
	cin >> n >> m;
	
	vector<edge> v(m);
	vector<int> x;
	for(int i = 0; i < m; i++)
	{
		cin >> v[i].a >> v[i].b;
	}
	
	x.push_back(1);
	vector<bool> flag(n,false);
	vector< vector<bool> > tmp_flag;
	int ans = 0;
	
	while(x.empty() == false)
	{
		int tmp = x.back();
		x.pop_back();
		
		flag[tmp - 1] = true;
		
		for(int i = 0; i < n; i++)
		{
			if(flag[i] == false)
			{
				break;
			}
			if(i == n - 1)
			{
				ans++;
			}
		}
		
		int cnt = 0;
		for(int i = 0; i < m; i++)
		{
			if(v[i].a == tmp && flag[v[i].b - 1] == false)
			{
				cnt++;
				x.push_back(v[i].b);
			}
			
			if(v[i].b == tmp && flag[v[i].a - 1] == false)
			{		
				cnt++;
				x.push_back(v[i].a);
			}
		}
		
		if(cnt > 1)
		{
			for(int i = 0; i < cnt - 1; i++)
			{
				tmp_flag.push_back(flag);
			}
		}
		
		if(cnt == 0 && x.empty() == false)
		{
			flag = tmp_flag.back();
			tmp_flag.pop_back();
		}
		
	}
	
	cout << ans << endl;
	return 0;
}

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

#pragma warning(disable:4996)
using namespace std;
string root_sts = "C ,C#,D ,D#,E ,F ,F#,G ,G#,A ,A#,B ";

int get_num(string name) {

	int k= root_sts.find(name);
	string l= root_sts.substr(0,k);
	return count(l.begin(),l.end(),',');
}
bool check(vector<int>a, vector<int>b) {
	for (auto& k : a) {
		k%=12;
	}
	for (auto& k : b) {
		k %= 12;
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	return a==b;
}

int main() {
	int Q;cin>>Q;
	while (Q--) {
		int N;cin>>N;
		vector<int>nums(N);
		for (int i = 0; i < N; ++i) {
			string name;cin>>name;nums[i]=get_num(name);
		}
		sort(nums.begin(),nums.end());

		vector<vector<int>>components = {
			vector<int>{0,4,7},
			vector<int>{0,4,7,10},

			vector<int>{0,4,7,11},

			vector<int>{0,3,7},
			vector<int>{0,3,7,10},

		};
		vector<string>chord_names = {
			"",
			"7",
			"M7",
			"m",
			"m7"
		};
		vector<string>anss;
		for (int root = 0; root < 12; ++root) {
			string root_name = root_sts.substr(root * 3, 2);

			if(root_name[1]==' ')root_name.pop_back();
			for (int chord = 0; chord < 5; ++chord) {
				string chord_name=chord_names[chord];
				string tension_name;
				{
					vector<string>tension_bases{
						"5",
						"9"
						,"11",
						"13"
					};
					for (int tension_part = 0; tension_part < 4; ++tension_part) {
						for (int plus = -1; plus <= 1; plus++) {
							string minus;
							if (plus == 1) {
								minus="+";
							}
							else if (plus == -1) {
								minus="-";
							}
							string tension_name="("+
								minus+tension_bases[tension_part]
								+")";
							vector<int>voices(components[chord]);
							if (tension_part == 0) {
								if (plus == 0) {
									tension_name="";
								}
								voices[2]+=plus;
							}
							else {
								if (tension_part == 1) {
									voices.push_back(2+plus);

								}
								else if (tension_part == 2) {
									voices.push_back(5+plus);
								}
								else if (tension_part == 3) {
									voices.push_back(9+plus);
								}
							}
							for(auto &vo:voices)vo+=root;
							if (check(voices, nums)) {
								string ans=root_name
									+chord_name+tension_name;
								anss.push_back(ans);
							}
						}
					}
					
				}
			}
		}
		if (anss.empty()) {
			cout<<"UNKNOWN"<<endl;
		}
		else {
			for (int i = 0; i < anss.size(); ++i) {
				cout<<anss[i];
				if(i==anss.size()-1)cout<<endl;
				else cout<<" ";
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3016
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, a: "List[int]"):
    visited = [False]*N
    curr = 1
    counter = 0
    while curr != 2:
        if visited[curr-1]:
            print(-1)
            return
        visited[curr-1] = True
        curr = a[curr-1]
        counter += 1
    print(counter)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


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

int main() {
    int a, b;
    cin >> a >> b;
    int tmp = b - a;
    cout << (1 + tmp)*tmp/2 - b << endl;
    return 0;
}

Measured memory_bytes: 256
/*
_____________________$$o____________________o$$$$$o__
___________________o$o_$$o____oo$$$$$$$oo______o$$$$o
______________$o________o$$$$$o___oo$$$$$$$o______$$$
______________$$$ooo________o$$$$o______o$$$$$o_____o
____________oo_____oo_____oo___o$$$$$______$$$$$$____
_________ooooo___$$o_$___oooooo___o$$$$o__o__o$$$$___
_______ooo__ooo$$$$o_$$ooooooooooo__o$$$o__oo_oo$$$o_
______oo_o$$o_$$_o$o_o$o__oooooooooo__o$$$o_oo__o$$$o
____oooooo$$$$o___oo__$$o_ooo_oooooooo__o$$o_ooo_o$$$
___ooooooo__o___oooo__$$ooooo$_oooooooo__o$$__ooo_$$$
_$$o_ooooo___o$$$$$o__o$o__o_$o__oooooooo_o$$o_oo__$$
_$$$o_ooo_________o$$_$$o____$$o_ooooooooo_$$$o_oo_$$
__oo________o$$o____o_$$o____o$ooooooooooo_o$$o_oo_o$
___o$$$$$$$$$$$$$o___$$$o____$$o_oooooooooo_$$$o_o_o$
________o__oo$$$$$o__$$$o____$$o____oooooo__$$$o_o_o$
_________$$$$$$$$$o__$$_____$$$o___________$$$oooooo_
__________o$$$$$$$o_________$$___________o$o___oooooo
___________o$$$$o_______________ooooo__oo$__ooo__oooo
________________________________ooo_$$oo___oooo$o____
________________________________oooo_$$$$$o___oo$$$o_
________________________________ooooo_o$$$$$o_____$$$
________________________________oooooo_o$$$$$$ooo___o
________________________________ooooooo__o$$$$$o_____
*/
#include<bits/stdc++.h>
#define ll long long
#define ft first
#define sd second
#define HageBaIO_KPOCCbI int LOL;scanf("%d", &LOL);for(int i = 0; i < LOL; i++)
#define Terrorist ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
//BY |3 |<
const int dx[] = {1, 0, -1,  0};
const int dy[] = {0, 1,  0, -1};
//Where I am?
const ll N = 1e5 + 5;
const ll NN = 1e3 + 3;
const ll MOD = (1e9 + 7);
const ll MOD1 = 998244353;
const double PI = 3.14159265;
const int INF32 = 2e9;
const ll INF64 = 2e18;
//Don`t believe!!!//
string s;
void KEK(){
	cin>>s;
	if(s[2] == s[3] && s[4] == s[5])printf("Yes");
	else printf("No");
}
int main(){
	Terrorist
	//HageBaIO_KPOCCbI
	KEK();
	return 0;
}
//TAUMAC, 9| BbIWEJI 3A TObOU!!!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=300000;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////

int main(){
  string s;
  cin>>s;
  string ans;
  ans=s.substr(0,3);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3628
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a <= 8 && b <= 8) {
			pr.println("Yay!");
		} else {
			pr.println(":(");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()

vvi matmul(vvi a, vvi b){
	int n=a.size();
	vector<ll> c(n,0),d(n,0);
	vvi r(n,vi(n,0));
	rep(i,n)rep(j,n){
		c[i]=c[i]*2+a[i][j];
		d[j]=d[j]*2+b[i][j];
	}
	rep(i,n)rep(j,n){
		r[i][j]=!!(c[i]&d[j]);
	}
	return r;
}

vector<vvi> memo(101);
vvi matpow(vvi a,int p){
	if(memo[p].size()==0)
		memo[p]=(p&1)?matmul(matpow(a,p-1),a):matmul(matpow(a,p/2),matpow(a,p/2));
	return memo[p];
}

int main(){
	int n,m,a[3];
	while(cin>>n>>m>>a[0]>>a[1]>>a[2]){
		vvi z(n,vi(n,0)), e=z;
		rep(_,m){
			int p,q; cin>>p>>q;
			e[p-1][q-1]=1;
		}
		fill(all(memo),vvi());
		memo[1]=e;

		vector<vvi> d(3);
		rep(p,3) d[p]=matpow(e,a[p]);
		
		vi g(n,0), ng(n,0);
		g[n-1]=1;
		rep(t,1000){
			bool next=0;
			fill(all(ng),0);
			rep(i,n) if(!g[i]){
				bool ok=1,r;
				rep(p,3) [&]{r=0; rep(j,n) r|=(g[j]&d[p][i][j]); ok&=r;}();
				if(ok) ng[i]=next=1;
			}
			if(!next){
				cout<<"IMPOSSIBLE"<<endl;
				break;
			} else if(ng[0]){
				cout<<t+1<<endl;
				break;
			}
			rep(i,n)g[i]|=ng[i];
		}
	}
	return 0;
}



Measured memory_bytes: 3300
#include <stdio.h>

int main(void){
  int a, b ,c;
  scanf("%d%d%d", &a , &b , &c );
  if(a == 5 && b == 7 && c == 5){
    printf("YES\n");
  }else if(a == 5 && b == 5 && c == 7){
    printf("YES\n");
  }else if(a == 7 && b == 5 && c == 5){
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
const int MX = 200005;
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------

void Main(){
  ll n,m;
  cin>>n>>m;
  if(n<m) swap(n,m);
  if( m>=2 ){
    cout<<(n-2)*(m-2)<<endl;
  }else if(n>=2 and m==1){
    cout<<(n-2)<<endl;
  }else{
    cout<<1<<endl;
  }
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int a, b,aux;
	cin >> a >> b;
	int counter = 1;
	aux = a;

	if (b == 1) 
	{
		cout << 0 << endl;
		return 0;
	}

	while (aux < b)
	{
		aux += (a - 1);
		counter++;
	}

	cout << counter << 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()

using ll = long long;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int sum = 0;
    if(c != b) sum++;
    if(c != a) sum++;
    if(b != a) sum++;
    if(sum  == 0) sum++;
    cout << sum << endl; 
}

Measured memory_bytes: 256
# 26
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


R, G, B, N = LI()
ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        bB = N - r * R - g * G
        b = bB // B
        if bB >= 0 and bB % B == 0 and R * r + G * g + B * b == N:
            # print(f'{(r, g, b)=}')
            ans += 1
print(ans)


Measured memory_bytes: 68548
N = int(input())
a = [1]
t = 6
while t <= N:
    a.append(t)
    t *= 6
t = 9
while t <= N:
    a.append(t)
    t *= 9
INF = 10 ** 9
dp = [0] + [INF for _ in range(N)]
for i in range(1, N + 1):
    for x in a:
        if x <= i and dp[i - x] + 1 < dp[i]:
            dp[i] = dp[i - x] + 1
print(dp[N])

Measured memory_bytes: 45680