akhauriyash/Code-Regression huggingface dataset:
from collections import deque, defaultdict

N = int(input())
ab = []
for i in range(N - 1):
    ab.append(tuple(map(int, input().split())))

c_list = list(map(int, input().split()))
c_list.sort()
c_que = deque(c_list)

cnt = defaultdict(int)
outs = defaultdict(list)
for a, b in ab:
    cnt[a - 1] += 1
    cnt[b - 1] += 1
    outs[a - 1].append(b - 1)
    outs[b - 1].append(a - 1)

cnt = sorted(cnt.items(), key=lambda x: x[1])
top = cnt[0][0]
tar = defaultdict(lambda: 0)

import sys

sys.setrecursionlimit(10 ** 9)
visit = [False] * N


def dfs(start):
    tmp = []
    visit[start] = True
    for v2 in outs[start]:
        if visit[v2]:
            continue
        q = c_que.pop()
        tar[v2] = q
        tmp.append(v2)
    for v2 in tmp:
        if visit[v2]:
            continue
        dfs(v2)


tar[top] = c_que.pop()
dfs(top)
ans = 0
for a, b in ab:
    a -= 1
    b -= 1
    ans += min(tar[a], tar[b])
print(ans)
for i in range(N):
    print(tar[i], end=" ")


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

int main(){
  long long n,b,ans=10000,sum=0;
  cin>>n;

  for(int day=1;day<=n;day++){
    cin>>b;
    sum+=b;
    ans=min(ans, sum/day);
  }

  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << char(s1[0]-'a'+'A') << char(s2[0]-'a'+'A') << char(s3[0]-'a'+'A') << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main() {
    string s;
    cin >> s;
    rep(i,s.size()){
        switch(s[i]){
            case 'R':
                if(i%2==1){
                    cout << "No" << endl;
                    return 0;
                }
                break;
            case'L':
                if(i%2==0){
                    cout << "No" << endl;
                    return 0;
                }
                break;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int h,w;
	cin >> h >> w;
	vector<string> S(h);
	for(int i =0;i<h;i++)
	{
		cin >> S[i];
	}
	for(int i = 0;i<h;i++)
	{
		for(int j = 0;j<w;j++)
		{
			if(S[i][j]=='#')
			{
				bool isno = true;
				if(i-1>=0)if(S[i-1][j]=='#')isno = false;
				if(i+1<h)if(S[i+1][j]=='#')isno = false;
				if(j-1>=0)if(S[i][j-1]=='#')isno = false;
				if(j+1<w)if(S[i][j+1]=='#')isno = false;
				if(isno)
				{
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

namespace C_ABC164
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            var dic = new Dictionary<string,int>();
            for(int i = 0;i<s[0];i++){
                string str = ReadLine();
                // dic.Add(str,1);
                if(dic.ContainsKey(str)){
                    dic[str]++;
                }else{
                    dic.Add(str,1);
                }
            }
            WriteLine(dic.Count);
        }
    }
}


Measured memory_bytes: 50272
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void primeNumber(int N, vector<bool>& prime)
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    primeNumber(1120, prime);

    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;

        vector<vector<int> > dp(m+1, vector<int>(n+1, 0));
        dp[0][0] = 1;
        for(int i=0; i<=n; ++i){
            if(!prime[i])
                continue;
            for(int j=m-1; j>=0; --j){
                for(int k=i; k<=n; ++k){
                    dp[j+1][k] += dp[j][k-i];
                }
            }
        }

        cout << dp[m][n] << endl;
    }
}

Measured memory_bytes: 980
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    map<int, int> A;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        A[a]++;
    }
    int ans = 0;
    for (auto it = A.rbegin(); it != A.rend(); ++it) {
        while (it->second) {
            it->second -= 1;
            int power = 1;
            while (power <= it->first) power *= 2;
            auto it2 = A.find(power - it->first);
            if (it2 != A.end() && it2->second) {
                ans++;
                it2->second -= 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  // ios::sync_with_stdio(false);
  // cin.tie(nullptr);
  ll h, w;
  cin >> h >> w;
  vector<vector<char>> s(w, vector<char>(h));
  vector<vector<ll>> cost(w, vector<ll>(h, INF));
  REP(y, h) REP(x, w) cin >> s[x][y];
  queue<tuple<ll, ll, ll>> q;
  q.push({(s[0][0] == '#' ? 1 : 0), 0, 0});

  while (!q.empty()) {
    auto [c, x, y] = q.front();
    q.pop();
    if (cost[x][y] <= c) continue;
    cost[x][y] = c;

    if (x + 1 < w) {
      ll nc = (s[x][y] == '.' && s[x + 1][y] == '#' ? c + 1 : c);
      if (cost[x + 1][y] > nc) q.push({nc, x + 1, y});
    }
    if (y + 1 < h) {
      ll nc = (s[x][y] == '.' && s[x][y + 1] == '#' ? c + 1 : c);
      if (cost[x][y + 1] > nc) q.push({nc, x, y + 1});
    }
  }

  // REP(y, h) {
  //   REP(x, w) cout << cost[x][y];
  //   cout << '\n';
  // }
  cout << cost[w - 1][h - 1] << "\n";
  return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <string>
#define MAX 100000

using namespace std;

int R,S,P;
int value(char);
int main(void){
  int N,K;
  cin >> N >> K;
  cin >> R >> S >> P;
  string str;
  string myhand = "";
  cin >> str;
  long ans = 0;
  for(int i=0;i<N;i++){
    long score = (long)value(str[i]);
    if(i-K >= 0 && str[i] == str[i-K]){
      // 前の手
      if(myhand[i-K] == 'w'){
	myhand = myhand + "l";
      }else{
	ans = ans + score;
	myhand = myhand + "w";
      }
    }else{
      ans = ans + score;
      myhand = myhand + "w";
    }
    //cout << myhand[i] << endl;
  }
  cout << ans << endl;
  return 0;
}

int value(char c){
  if(c == 'r')
    return P;
  if(c == 's')
    return R;
  if(c == 'p')
    return S;
  return 0;
}

Measured memory_bytes: 932
# abc171_a.py
# https://atcoder.jp/contests/abc171/tasks/abc171_a

# A - αlphabet /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 英大文字か英小文字のいずれか 1文字 α が入力されます。αが英大文字なら A、英小文字なら a と出力してください。

# 制約
#     αは英大文字 (A - Z) または英小文字 (a - z) である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# α

# 出力
# αが英大文字なら A、英小文字なら a を出力せよ。

# 入力例 1
# B

# 出力例 1
# A

# B は英大文字であるため、A と出力します。

# 入力例 2
# a

# 出力例 2
# a

# a は英小文字であるため、a と出力します。


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    A = lines[0]
    # N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = 'A'
    if A in 'abcdefghijklmnopqrstuvwxyz':
        result = 'a'

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['B']
        lines_export = ['A']
    if pattern == 2:
        lines_input = ['a']
        lines_export = ['a']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


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

int main() {
	double r, a, c;
	cin >> r;
	a=r*r*3.1415926535897932384626433832795028841971693993751058209749;
	c=r*2*3.1415926535897932384626433832795028841971693993751058209749;
	cout << fixed << setprecision(5);
	cout << a << " " << c << endl;
	return 0;
}



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

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

int find(string str, const string& word) {
  int count = 0;
  for (string::size_type pos = 0; (pos = str.find(word, pos)) != string::npos; pos += word.size()) {
    ++count;
  }
  return count;
}

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << c <<" "<< a <<" "<< b <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
ll exp(ll a, ll b){
  if(b==0)return 1;
  if(a==1||a==0)return a;
  if(b%2==0){
    int t =exp(a,b/2);
    return t*t%big;
  }
  else return exp(a,b-1)*a%big;
}

int main(){
    int a,b,s;cin >> a >> b >> s;
    for(int i=min(a,b);i>=1;i--){
        if(a%i!=0||b%i!=0)continue;
        s--;
        if(s==0){printf("%d\n",i);break;}
    }
}

Measured memory_bytes: 256
import itertools

n = int(input())
d = list(map(int, input().split()))

'''
ans = 0
for v in list(itertools.combinations(d, 2)):
    ans += (v[0] * v[1])

print(ans)
'''

ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += d[i] * d[j]

print(ans)


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

int main(void){
    int a,b;
    cin >> a >> b;
    if(a > b){
        cout << "a > b" << endl;
    }
    if(a < b){
        cout << "a < b" << endl;       
    }
        if(a == b){
        cout << "a == b" << endl;       
    }

    return 0;
}


Measured memory_bytes: 3128
#include <cstdio>
#include <cmath>
int main(){
	int n;
	for(;;){
		scanf("%d",&n);
		if(n==0) break;
		int y;
		scanf("%d",&y);
		double ma=0,now;
		int gnum;
		int b,t,r;
		for(int i=0;i<n;i++){
			scanf("%d%d%d",&b,&r,&t);
			if(t==1) now=1+y*r/100.0;
			else now=pow(1+r/100.0,y);
			if(now>ma){
				ma=now;
				gnum=b;
			}
		}
		printf("%d\n",gnum);
	}
}

Measured memory_bytes: 1120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn =2e3+5;
const double pi=acos(-1);

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double jiao1=2.0*pi*m/60.0;
	double shi=h*60.0+m;
	double jiao2=2.0*pi*shi/720.0;
	/*if(jiao1>=pi)
    {
        jiao1=2.0*pi-jiao1;
    }
    if(jiao2>=pi)
    {
        jiao2=2.0*pi-jiao2;
    }*/
    //cout<<jiao1<<" "<<jiao2<<'\n';
    double jiao=abs(jiao1-jiao2);
    double ans=pow(a*a+b*b-2.0*a*b*cos(jiao),0.5);
    //double ans=sqrt(a*a+b*b-2.0*a*b*cos(jiao));
    cout<<fixed<<setprecision(15)<<ans<<'\n';



}


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

int main(){
  int n,c=-1;
  cin>>n;
  while(n){
    n/=2;
    c++;
  }
  cout<<pow(2,c)<<endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;cin>>s;
  
  int len = s.length();
  
  if (s[len-1] == 's') {
    cout<<s<<"es";
  } else {
    cout<<s<<'s';
  }
  
  return 0;
}

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

  string s;
  
  cin >> s;
  
  
  for(int i=0;i<s.size();i++){
    
   if(s[i] == s[i-1] && i > 0 ){
      cout << i << " " << i+1 << endl;
      return 0;
      
    }
    
    else if(s[i] == s[i-2] && i > 1){
      cout << i-1 << " " << i+1 << endl;
      
      return 0;
    }
      
  
  }
    cout << "-1" << " " << "-1" << endl;
    
  }


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll A, B;
    cin >> A >> B;
    _PR(A*B);

    return 0;
}

/*



*/

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s; cin>>s;
  int y = stoi(s.substr(0, 4));
  int m = stoi(s.substr(5, 2));
  if (y < 2019) cout << "Heisei" << endl;
  else if (m < 5) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R) >> 1)
using namespace std;
typedef long long LL;
const int N = 500500;
int a[N], b[N], d, n;
bool ans[N];
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	scanf("%d%d", &n, &d);
	a[0] = d;
	for (int i = 0; i < n; ++i) scanf("%d", &b[i]);
	for (int i = 1; i < n; ++i) {
		a[i] = min(a[i - 1], abs(a[i - 1] - b[i - 1]));
	}
	LL can = 0;
	bool flag = true;
	for (int i = n - 1; i >= 0; --i) {
		if (can >= a[i]) {
			ans[i] = true;
		}
		if (can + can + 1 >= b[i]) {
			can += b[i];
		}
	}
	int Q;
	scanf("%d", &Q);
	while (Q--) {
		int u;
		scanf("%d", &u);
		printf("%s\n", ans[u - 1] ? "NO" : "YES");
		// printf("%d ", ans[u]);
	}
	return 0;
}

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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define YES(f) if((f)){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(f) if((f)){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))

#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	vector<int> v;
	string s;
	cin >> s;
	int res = 0;
	rep(i, s.length()) {
		int x = s[i]-'0';
		if (v.size() == 0) {
			v.PB(x);
		} else {
			if (v.back() != x) {
				res+=2;
				v.pop_back();
			} else {
				v.PB(x);
			}
		}
	}
	cout << res << endl;
}


void solve()
{
}





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

template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }

    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }

    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};

using mint = ModInt<1000000007>;

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

    int n, m;
    cin >> n >> m;

    vector<vector<mint>> dp(n + 1, vector<mint>(m + 1));
    for (int i = 0; i <= n; i++) dp[i][0] = 1;
    for (int j = 0; j <= m; j++) dp[0][j] = 1;
    vector<int> s(n), t(m);
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < m; i++) cin >> t[i];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            dp[i + 1][j + 1] += dp[i + 1][j] + dp[i][j + 1] - dp[i][j];
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] += dp[i][j];
            }
        }
    }
    cout << dp[n][m] << endl;
}


Measured memory_bytes: 16000
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main(){
    string s;
    cin >> s;
    int K;
    cin >> K;
    int L = (int)s.size();
    vector<vector<vector<ll>>> dp(L+1, vector<vector<ll>>(K+1, vector<ll>(2, 0)));
    dp[1][0][0] = 0;
    dp[1][1][0] = 1;
    dp[1][0][1] = 1;
    dp[1][1][1] = s[0] - '1';
    for(int i = 2; i <= L; i++){
        for(int j = 0; j <= K; j++){
            if(s[i-1] - '0' == 0){
                dp[i][j][0] = dp[i-1][j][0];
            } else dp[i][j][1] = dp[i-1][j][0];
            dp[i][j][1] += dp[i-1][j][1];
            if(j != 0){
                dp[i][j][1] += dp[i-1][j-1][1] * 9;
                if(s[i-1] - '0' != 0){
                    dp[i][j][1] += dp[i-1][j-1][0] * (s[i-1] - '1');
                    dp[i][j][0] += dp[i-1][j-1][0];
                }
            }
        }
    }
    cout << dp[L][K][0] + dp[L][K][1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<queue>
using namespace std;
typedef long double ld;
typedef long long int ll;
const ll INF = (1LL << 63);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0; i < n;i++)
const int MAX = 1000000010;
const ll MOD = 1000000007;
int n, m,k,sum = 0,l; string s;
int main() {
    cin >> n >> m >> k >> l;
    vector<int> a(120, 0);
    a[n]++; a[m]--; a[k]++; a[l]--;
    rep(i, 110) a[i + 1] += a[i];
    rep(i, 101) {
        if (a[i] == 2) sum++;
    }cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = __LONG_LONG_MAX__;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b,c,d; cin >> a >> b >> c >> d;
    int x = (c+b-1)/b;
    int y = (a+d-1)/d;
    if(x<=y){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>

int main ( void ) {
    
    int n, c1 = 0, c2 = 0;
    char s1[100], s2[100];
    scanf ( "%d", &n );

    for ( int i = 0; i < n; i++ ) {
        scanf ( "%s %s", s1, s2 );
        if ( strcmp ( s1, s2 ) == 0 ) {
            c1++, c2++;
        } else if ( strcmp ( s1, s2 ) > 0 ) {
            c1 += 3;
        } else {
            c2 += 3;
        }
    }

    printf ( "%d %d\n", c1, c2 );

    return 0;
}


Measured memory_bytes: 2732
#include <iostream>
using namespace std;
 
int main() { 
    string s, s_f;
    int ans, flag;
    cin >> s;

    for(int i = 0; i < 8; ++i) {
        ans = s[0] - '0';
        if(i & 0x0001) {
            ans += s[1] - '0';
        } else {
            ans -= s[1] - '0';
        }
        if(i & 0x0002) {
            ans += s[2] - '0';
        } else {
            ans -= s[2] - '0';
        }
        if(i & 0x0004) {
            ans += s[3] - '0';
        } else {
            ans -= s[3] - '0';
        }

        if(ans == 7) {
            flag = i;
            break;
        }
    }

    cout << s[0];
    if(flag & 0x0001) {
        cout << '+';
    } else {
        cout << '-';
    }
    cout << s[1];
    if(flag & 0x0002) {
        cout << '+';
    } else {
        cout << '-';
    }
    cout << s[2];
    if(flag & 0x0004) {
        cout << '+';
    } else {
        cout << '-';
    }
    cout << s[3];
    cout << "=7" << '\n';
}

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

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define iter_r(i, n) for (int i = n; i >= 1; --i)

#define NR 202000

typedef long long i64;

const i64 lnf = 1e18;

#define lx x << 1
#define rx x << 1 | 1
#define RT 1, 1, xsz
#define SL lx, l, mid
#define SR rx, mid + 1, r

int n, K, L[NR], R[NR], t[NR << 2], X[NR], xsz;
i64 a[NR], dpL[NR];
int b[NR];

void down(int x) { if (t[x]) t[lx] = t[rx] = t[x], t[x] = 0; }

void modify(int x, int l, int r, int ml, int mr, int d) {
	if (ml > mr) return;
//	printf("[%d %d] %d\n", ml, mr, d);
	if (ml <= l && r <= mr) { t[x] = d; return; }
	down(x); int mid = (l + r) / 2;
	if (ml <= mid) modify(SL, ml, mr, d);
	if (mr > mid) modify(SR, ml, mr, d);
}

int sget(int x, int l, int r, int pos) {
//	printf("[%d %d] %d\n", l, r, pos);
	if (l == r) return t[x];
	down(x); int mid = (l + r) / 2;
	return pos <= mid ? sget(SL, pos) : sget(SR, pos);
}
int id(int x) { return lower_bound(X + 1, X + xsz + 1, x) - X; }


int main() {
	scanf("%d%d", &n, &K);

	iter(i, n) {
		scanf("%lld%d", &a[i], &b[i]);
		if (b[i] == 1 && 2 * a[i] > K) { puts("-1"); return 0; }
		a[i] += a[i - 1];
		if (b[i] == 2) continue;
		L[i] = ((-2 * a[i - 1]) % K + K) % K;
		R[i] = ((-2 * a[i]) % K + K) % K;
		X[++xsz] = L[i]; X[++xsz] = R[i];
		//printf("!%d %d\n", L[i], R[i]);
	}
	X[++xsz] = 0, X[++xsz] = K - 1;
	sort(X + 1, X + xsz + 1);
	xsz = unique(X + 1, X + xsz + 1) - X - 1;
	iter(i, n) L[i] = id(L[i]), R[i] = id(R[i]);
//	printf("!%d\n", X[0]);

//	printf("!%d %d\n", id(0), id(K - 1));
	modify(RT, id(0), id(K - 1), n + 1);
	iter_r(i, n) if (b[i] == 1) {
		int k0 = sget(RT, L[i]);
		int k1 = sget(RT, R[i]);

		dpL[i] = k0 <= n ? dpL[k0] + (X[L[k0]] - X[L[i]] + K) % K : 0;
//		dpR[i] = k1 <= n ? dpL[k0] + (L[k0] - R[i] + K) % K : 0;

	//	printf("[%d %d] %d %lld\n", L[i], R[i], i, dpL[i]);

		if (L[i] <= R[i]) {
			modify(RT, 1, L[i] - 1, i);
			modify(RT, R[i] + 1, xsz, i);
		} else {
			modify(RT, R[i] + 1, L[i] - 1, i);
		}
	}

	i64 ans = lnf;

	iter(i, n) if (b[i] == 1) {
		int k0 = sget(RT, L[i]);
		int k1 = sget(RT, R[i]);
		//printf("%d %d %d %d(%d)\n", L[i], R[i], k0, k1, R[i]);
		ans = min(ans, k0 <= n ? dpL[k0] + (X[L[k0]] - X[L[i]] + K) % K : 0);
		ans = min(ans, k1 <= n ? dpL[k1] + (X[L[k1]] - X[R[i]] + K) % K : 0);
		
	}
	//printf("%lld\n", ans);
	printf("%lld\n", ans + 2 * a[n]);
	return 0;
}

Measured memory_bytes: 7936
import queue
h,w=map(int,input().split())
maze=[list(input()) for i in range(h)]
#print(maze)
dx=[1,0,-1,0]
dy=[0,1,0,-1]

def maze_long(sx,sy,maze):
  if maze[sy][sx]=='#':
    return -1
  else:
    ans=[[10**9]*w for i in range(h)]
    q=queue.Queue()

    q.put([sy,sx])
    ans[sy][sx]=0
    while q.qsize():
      p=q.get()
      for i in range(4):
        nx=p[1]+dx[i]
        ny=p[0]+dy[i]
        if 0<=nx<w and 0<=ny<h: 
          if maze[ny][nx]!='#' and ans[ny][nx]>10**8:
            q.put([ny,nx])
            ans[ny][nx]=ans[p[0]][p[1]]+1
    ans2=0
    for i in range(h):
      for j in range(w):
        if ans[i][j]>10**8:
          ans[i][j]=0
    #print(ans)
    for i in range(h):
      k=max(ans[i])
      if k>ans2:
        ans2=k
    return ans2

ans=0

for i in range(h):
  for j in range(w):
    sx=j
    sy=i
    l=maze_long(sx,sy,maze)
    if l>ans:
      ans=l
print(ans)     
   

Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#pragma region mod
int p = 1e9 + 7; //10^9 + 7
struct mint
{
    ll x;
    mint(ll x = 0) : x(x % p) {}
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += p - a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= p;
        return *this;
    }

    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const
    {
        mint r = 1;
        mint a = *this;
        while (true)
        {
            if (t & 1)
            {
                r *= a;
            }
            t >>= 1;
            if (t == 0)
                break;
            a *= a;
        }

        return r;
    }

    mint inv() const
    {
        return pow(p - 2);
    }

    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
};

#pragma endregion

int main()
{
    int n;
    cin >> n >> p;
    string st;
    cin >> st;
    ll ans = 0;
    if (p == 2 || p == 5)
    {
        rep(i, n)
        {
            int x = st.at(i) - '0';
            if (x % p == 0)
            {
                ans += (i + 1);
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<mint> ten(n, 1);
    rep(i, n - 1) ten[i + 1] = ten[i] * 10;
    vector<mint> s(n + 1);
    map<int, int> cnt;
    for (int i = 1; i < n + 1; i++)
    {
        int j = n - i;
        int x = st.at(j) - '0';
        s[i] = s[i - 1] + ten[i - 1] * x;
    }

    rep(i, n + 1)
    {
        ans += cnt[s[i].x];
        cnt[s[i].x]++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3972
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

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

using namespace std;
int main() {
	int n,ans=0,old=-2;
	cin >> n;
	vector<int> a(n + 1,0), b(n + 1), c(n + 1);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n-1) {
		cin >> c[i];
	}
	for (int i = 0; i < n ;i++) {
		
		if (old + 1 == a[i]) {
			ans += c[old-1];
		}
		ans += b[a[i]-1];
		old = a[i];
	}

	cout << ans;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    bool flg=false;
    ll n;cin >>n;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        a[i]--;
    }
    vector<bool>c(n,true);
    ll u=0;
    ll ans=0;
    while (1){
        ans++;
        if(u==1){
            flg=true;
            break;
        }
        if(!c[u])break;
        c[u]=false;
        u=a[u];
    }
    if(flg)cout<<ans-1<<endl;
    else cout <<-1<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(void){
    // Your code here!
    double r;
    scanf("%lf", &r);
    printf("%lf %lf\n", M_PI*r*r, 2*M_PI*r);

    return 0;
}



Measured memory_bytes: 3208
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Random;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static final int INF = 0xFFFFFFF;
	static long[][] hash = new long[32][32];
	static int[][][] buf = new int[2][8192][32];
	static long finish;

	public static void main(String[] args) {
		Random rnd = new Random();
		for (int i = 0; i < 32; ++i) {
			for (int j = 0; j < 32; ++j) {
				hash[i][j] = rnd.nextLong();
			}
		}
		for (int i = 0; i < 4; ++i) {
			for (int j = 2; j <= 7; ++j) {
				finish ^= hash[(j - 1) * 4 + i][i * 8 + j];
			}
		}
		int T = sc.nextInt();
		for (int i = 0; i < T; ++i) {
			System.out.println(solve());
		}
	}

	static int solve() {
		ArrayList<Board> cur = new ArrayList<Board>();
		HashSet<Long> hashes = new HashSet<Long>(30000);
		cur.add(new Board(buf[0][0]));
		if (cur.get(0).h == finish) return 0;
		hashes.add(cur.get(0).h);
		int i = 1;
		for (; !cur.isEmpty(); ++i) {
			//			System.out.println("turn:" + i + " size:" + cur.size());
			ArrayList<Board> next = new ArrayList<Board>(cur.size());
			for (Board b : cur) {
				for (int j = 4; j < 32; ++j) {
					if (b.f[j] == INF && (b.f[j - 4] & 7) != 7) {
						Board created = new Board(buf[i & 1][next.size()], b, j);
						if (hashes.contains(created.h)) continue;
						if (created.h == finish) return i;
						hashes.add(created.h);
						next.add(created);
					}
				}
			}
			cur = next;
		}
		return -1;
	}

	static class Board {
		int[] f;
		long h;

		Board(int[] buf) {
			f = buf;
			for (int i = 0; i < 4; ++i) {
				for (int j = 1; j <= 7; ++j) {
					String v = sc.next();
					int suit = v.charAt(0) - '1';
					int num = v.charAt(1) - '0';
					int card = suit * 8 + num;
					if (num == 1) {
						f[j * 4 + i] = INF;
						f[suit] = card;
					} else {
						f[j * 4 + i] = card;
						h ^= hash[j * 4 + i][card];
					}
				}
			}
		}

		Board(int[] buf, Board orig, int pos) {
			this.f = buf;
			System.arraycopy(orig.f, 0, this.f, 0, 32);
			this.h = orig.h;
			final int target = orig.f[pos - 4] + 1;
			for (int i = 4; i < 32; ++i) {
				if (orig.f[i] == target) {
					this.f[i] = INF;
					this.h ^= hash[i][target];
					break;
				}
			}
			this.f[pos] = target;
			this.h ^= hash[pos][target];
		}
	}
}

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

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

int main() {
	string s;
	cin>>s;
	int ans=0;
	rep(i,3){
		if(s[i]=='1')++ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

def two_count(n)
  ret = 0
  while n % 2 == 0
    ret += 1
    n /= 2
  end
  ret
end

two_counts = A.map { |a| two_count(a) }
if two_counts.uniq.size != 1
  puts 0
  exit 0
end
first = A.reduce(1) do |acc, a|
  acc.lcm(a / 2)
end

rest = M - first
if rest >= 0
  ans = 1 + rest / (first * 2)
  puts ans
else
  puts 0
end

Measured memory_bytes: 13452
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

int n,h[100005],dp[100005];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> h[i];
        if(i>1){
            if(i>2) dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
            else dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        }
    }
    cout << dp[n];
}


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

int main()
{
  int one = 0, zero = 0;
  
  string s;
  cin >> s;
  
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      zero++;
    else
      one++;
  }
  
  cout << 2 * ((one > zero) ? zero : one) << endl;
  
  return 0;
}

Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<String>().chars().collect::<Vec<char>>();
    for i in 0..a.len() {
        if i%2 == 0 {
            if  a[i] == 'L' {
                println!("No");
                return;
            }
        } else {
            if a[i] == 'R' {
                println!("No");
                return;
            }
        }
    }
    println!("Yes")
}

Measured memory_bytes: 4352
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 998244353;
const int N = 1e2 + 10, M = 1e6 + 10;
const double INF = 1e20;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;

#define pi acos(-1)


int main()
{
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
        puts("Yes");
    else
    {
        puts("No");
    }
    
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val (D, X) = readLine()!!.split(" ").map { it.toInt() }
    val As = (1..N).map { readLine()!!.toInt() }

    val ans = As.map { (D-1) / it + 1}.sum() + X
    println(ans)
}

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

class Card {
public:
    char mark;
    int num;

    Card() {}
    Card(char mark, int num) {
        this->mark = mark;
        this->num = num;
    }
};

void bsort(vector<Card> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = v.size() - 1; j > i; j--)
            if (v[j - 1].num > v[j].num)
                swap(v[j - 1], v[j]);
    }
}

void ssort(vector<Card> &v) {
    for (int i = 0; i < v.size(); i++) {
        int minj = i;
        for (int j = i; j < v.size(); j++) {
            if (v[j].num < v[minj].num)
                minj = j;
        }
        swap(v[i], v[minj]);
    }
}

bool isStable(vector<Card> &v, map<int, string> &m) {
    bool ok = true;
    int idx = 0;
    for (int i = 0; i < v.size(); i++) {
        if (v[i].mark != m[v[i].num][idx++])
            ok = false;
        if (m[v[i].num].size() == idx)
            idx = 0;
    }
    
    return ok;
}

void disp(const vector<Card> &v) {
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i].mark << v[i].num;
        if (i < v.size() - 1)
            cout << " ";
    }
    cout << '\n';
}
int main()
{
    int n;
    cin >> n;
    vector<Card> card(n), card_(n);
    map<int, string> mark;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        card[i] = Card(s[0], atoi(&s[1]));
        mark[atoi(&s[1])] += s[0];
    }

    card_ = card;
    bsort(card);
    disp(card);
    cout << (isStable(card, mark) ? "Stable" : "Not stable") << '\n';
    ssort(card_);
    disp(card_);
    cout << (isStable(card_, mark) ? "Stable" : "Not stable") << '\n';
    return 0;
}


Measured memory_bytes: 3160
N = int(input())
A = list(map(int,input().split()))
mans = 0
msum = 0
for i in range(N):
    if i%2:
        if msum + A[i] <= 0:
            mans += abs(msum + A[i])+1
            msum = 1
        else:
            msum += A[i]
    else:
        if msum + A[i] >= 0:
            mans += msum + A[i]+1
            msum = -1
        else:
            msum += A[i]
pans = 0
psum = 0
for i in range(N):
    if i%2:
        if psum + A[i] >= 0:
            pans += psum + A[i]+1
            psum = -1
        else:
            psum += A[i]
    else:
        if psum + A[i] <= 0:
            pans += abs(psum + A[i])+1
            psum = 1
        else:
            psum += A[i]

print(min(pans,mans))

Measured memory_bytes: 14468
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		if(n <= 999){

			if(n%10 == 2 || n%10==4 || n%10==5 || n%10==7 || n%10==9) {

				System.out.println("hon");

			}else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) {

				System.out.println("pon");

			}else if (n%10 ==3) {

				System.out.println("bon");
			}
			}
		}
	}




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

    N, M, P = map(int, input().split())

    INF = 10 ** 9
    #入力

    # 入力は1-index
    # 内部で0-indexにして処理
    G = []
    for _ in range(M): #M個の辺の情報を受け取る
        A, B, C = map(int, input().split()) #lからrへ重みsの辺が存在
        G += [[A - 1, B - 1, P - C]] #有向グラフのときはここだけ

    check = [False] * N
    d = [INF] * N #距離を記録

    def shortest_path(s): #S番目の頂点から各頂点への最短距離を求める
        s -= 1
        d[s] = 0
        j = 0
        while j < N - 1:
            for i in range(M): #無向グラフのときは辺は実質的には2倍
                e = G[i]
                if d[e[0]] != INF and d[e[1]] > d[e[0]] + e[2]:
                    d[e[1]] = d[e[0]] + e[2]
            j += 1
        
        j = 0
        while j < N:
            for i in range(M):
                e = G[i]
                if d[e[0]] == INF:
                    continue
                if d[e[0]] != INF and d[e[1]] > d[e[0]] + e[2]:
                    d[e[1]] = d[e[0]] + e[2]
                    check[e[1]] = True
                if check[e[0]]:
                    check[e[1]] = True
            j += 1

    shortest_path(1)
    if check[N - 1]:
        print (-1)
    else:
        ans = d[N - 1]
        print (max(0, -ans))
    # print (d)

if __name__ == '__main__':
    main()

Measured memory_bytes: 42224
#include <stdio.h>

int main(void) {
	int hyou[11][11];
	int datakazu;
	int i,j;
	int sum;
	while(1) {
		scanf("%d",&datakazu);
		if(datakazu==0)break;
		for(j=0;j<datakazu;j++) {
			sum=0;
			for(i=0;i<datakazu;i++) {
				scanf("%d",&hyou[i][j]);
				sum+=hyou[i][j];
			}
			hyou[datakazu][j]=sum;
		}
		for(i=0;i<=datakazu;i++) {
			sum=0;
			for(j=0;j<datakazu;j++) {
				sum+=hyou[i][j];
			}
			hyou[i][datakazu]=sum;
		}
		for(j=0;j<=datakazu;j++) {
			for(i=0;i<=datakazu;i++) {
				printf("%5d",hyou[i][j]);
			}
			puts("");
		}
	}
	return 0;
}

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

using namespace std;

int main(void){
    int n, m;
    cin >> n >> m;
    vector<int> s(n+2, 0);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        s[a]++;
        s[b]--;
    }
    for (int i = 0; i < n+2; i++) s[i+1] += s[i];
    
    int l = 0, ans = 0;
    for (int i = 0; i < n+2; i++) {
        if (l == 0 && s[i]) l = i;
        if (l > 0 && !s[i]) {
            ans += (i-l)*2;
            l = 0;
        }
    }
    cout << ans+n+1 << endl;
}

Measured memory_bytes: 3124
#include <stdio.h>

int main(){
  int S;
  int hour;
  int minute;
  int sec;

  scanf("%d" , &S);

  if( S >= 3600)
  {
    hour = S / 3600;
    minute = (S % 3600)/60;
    sec = (S % 3600)%60;

    printf("%d:%d:%d\n",hour,minute,sec);
    return 0;
  }

  if( S >= 60)
  {
    minute = S / 60;
    sec = S % 60;
    printf("0:%d:%d\n",minute,sec);
    return 0;
  }

  printf("0:0:%d\n",S);

  return 0;
}

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

int main() {
  int X, Y;
  cin >> X >> Y;
  for (int i = 0; i <= X; i++) {
    for (int j = 0; j <= X; j++) {
      if (i + j == X) {
        if (i * 2 + j * 4 == Y) return cout << "Yes" << "\n", 0;
      }
    }
  }
  cout << "No" << "\n";
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
const long long INF = 1e9 + 7;

int dp[110][10010]={0};
int main(){
    int N,W; cin >> N >> W;
    int value[110],weight[110];
    for (int i=0; i<N; i++) cin >> value[i] >> weight[i];

    for (int i=0; i<N; i++){
        for (int j=0; j<=W; j++){
            if (weight[i]<=j) dp[i+1][j]=max(dp[i][j-weight[i]]+value[i],dp[i][j]);
            else dp[i+1][j]=dp[i][j];
        }
    }
    
    int ans=0;
    for (int i=0; i<N+1; i++){
        for (int j=0; j<=W; j++){
            ans=max(ans,dp[i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7036
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

inline int waste(int a, int b, int m) { return (((a % m) + (b % m)) % m); }
inline int worse(int a, int b, int m) { return (((a % m) * (b % m)) % m); }
inline int worst(int a, int b, int m) { return (((a % m) - (b % m) + m) % m);}

using namespace std;

int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif
   string a,b;
   cin >> a >> b;
   int c = 0;
   for(int i = 0 ; i < a.size() ; i++){
    if(a[i]!=b[i]){
      c++;
    }
   }
   cout << c;
   
}

Measured memory_bytes: 3800