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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll D, G;
    cin >> D >> G;

    vector<ll> p(D);
    vector<ll> c(D);

    REP(i, D){
        cin >> p[i] >> c[i];
    }

    // for(ll i=0 ; i<D; i++){

    // }
    ll ans = INF;
    for(ll d=0; d<D; d++){
        for (ll bit = 0; bit < (1<<D); ++bit){
            // cout << "bit: " << bit << endl;
            ll temp = 0;
            ll count = 0;
            for (ll i = 0; i < D; ++i){
                // 半選択の場合はとばす
                if(i == d) continue;
                if (bit & (1<<i)){
                    // cout << i;
                    //　全部選択する場合
                    temp += p[i]*(i+1)*100 +c[i];
                    count += p[i];
                }
            }
            for(ll i=1; i<=p[d]; i++){
                temp += (d+1)*100;
                count++;
                if(i == p[d]) temp += c[d];
                if(temp >= G){
                    ans = min(ans, count);
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata.Ecma335;

namespace AtCoder.D
{
    public class Program
    {
        private static long[] _allCount;
        private static long[] _patyCount;

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, X) = Read2Longs();

            _allCount = new long[51];
            _patyCount = new long[51];
            for (int i = 0; i < 51; i++)
            {
                if (i == 0)
                {
                    _allCount[i] = 1;
                    _patyCount[i] = 1;
                    continue;
                }
                _allCount[i] = _allCount[i - 1] * 2 + 3;
                _patyCount[i] = _patyCount[i - 1] * 2 + 1;
            }

            // 前半に存在する場合
            var count = GetPatyCount(N, X);
            return count;
        }

        private static long GetPatyCount(long level, long x)
        {
            if (level == 0)
            {
                return 1;
            }
            // バンしかない
            if (x <= level)
            {
                return 0;
            }
            // 中央だったら
            if (_allCount[level] / 2 + 1 == x)
            {
                return _patyCount[level - 1] + 1;
            }
            // 中央より右だったら
            else if (_allCount[level] / 2 < x)
            {
                // 逆から数えて全体から引く
                return _patyCount[level] - GetPatyCount(level, _allCount[level] - x);
            }
            // 中央より左だったら
            else
            {
                return GetPatyCount(level - 1, x - 1);
            }
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28060
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#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
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	int n;
	cin >> n;
	
	cout <<1110-n<< endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean[] prime = new boolean[N+1];
        Arrays.fill(prime, true);
        prime[0] = false;
        prime[1] = false;
        
        for(int i = 0; i < prime.length; i++){
            if(prime[i]){
                for(int j = i * 2; j < prime.length; j += i){
                    prime[j] = false;
                }
            }
        }
        
        // N! の素因数分解の指数
        int[] e = new int[N+1];
        // N! を素因数分解
        for(int i = 1; i <= N; i++){
            for(int j = 2; j < prime.length; j++){
                if( prime[j] ) {
                    int target = i;
                    while( target % j == 0 ){
                        target /= j;
                        e[j]++;
                    }
                }
            }
        }

        int[][] dp = new int[N+1][76];
        dp[0][1] = 1;
        
        for(int i = 1; i <= N; i++){
            for(int j = 0; j <= e[i]; j++){
                for(int k = 0; k <= 75; k++){
                    if( (j+1) * k > 75 ) break;
                    dp[i][ (j+1) * k ] += dp[i-1][k];
                }
            }
        }
        
        System.out.println(dp[N][75]);
    }
}



Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int h  = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		
		long ans = h;
		if(h == 1 || w == 1) {
			System.out.println(1);
			return;
		}
		if(w % 2 == 0) {
			ans *= w/2;
		}
		else {
			ans *=(long)(w-1)/2;
			if(h % 2 == 0) {
				ans += (long)h/2;
			}
			else {
				ans += (long)(h+1)/2;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
// 158 B - Count Balls 2020/3/7

#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    uint64 n , a , b;
    cin >> n >> a >> b;
    uint64 c = n / ( a + b );
    uint64 d = n % ( a + b );
    if ( a == 0 ) { cout << 0 << endl; return 0; } 
    if ( d > a ) cout << a * c + a << endl; 
    else cout << a * c + d << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

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


Measured memory_bytes: 256
# D - Dice in Line

n,k=map(int, input().split())
p=list(map(int, input().split()))
q=[0]*n

for i in range(n):
    q[i]=(p[i]+1)/2

max=0
for i in range(k):
    max+=q[i]

sum=max
for i in range(1, n-k+1):
    sum=sum-q[i-1]+q[i+k-1]
    if sum > max:
        max=sum
print(max)


Measured memory_bytes: 25060
from sys import stdin

n, q = map(int, stdin.readline().split())
s = stdin.readline().strip()
counts = [0 for i in range(n)]
count = 0
for i in range(1, n):
    if s[i-1:i+1] == 'AC':
        count += 1
    counts[i] = count

for i in range(q):
    l, r = map(int, stdin.readline().split())
    print(counts[r-1] - counts[l-1])


Measured memory_bytes: 6368
#include <iostream>
#include <algorithm>

using namespace std;

using ll =  long long;

int main() {
    ll n, u, v;
    cin >> n;
    ll ans = (n * (n+1) * (2*n+1) / 6 + n * (n+1) / 2) / 2;
    for(int i=0;i<n-1;++i) {
        cin >> u >> v;
        ans -= min(u, v) * (n - max(u, v) + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
    
}

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


int main(){
    string s;cin>>s;
    long long bcnt = 0,total = 0;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'B') bcnt += 1;
        else total += bcnt;
    }
    cout<<total<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

int main()
{
    IOS;
    ll n;
    cin>>n;
    if(n%2)
    {
        cout<<0<<endl;
        return 0;
    }
    ll val=n/10;
    ll ans=val;
    ll p=5;
    while(val/p!=0)
    {
        ans+=val/p;
        p*=5;
    }
    cout<<ans<<endl;
}  

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include <cstdlib>
#include <stdlib.h>
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
#define MOD 1000000007
using namespace std;
using ll=long long;
int cnt,element;
int main()
{
ll n,i,j,k,taka=0,rafi=0;
cin>>n;
    taka=100;
    while(taka<n)
    {
        taka=taka+(taka/100);
        rafi++;
    }
    cout<<rafi<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	switch(s.back()) {
		case '2': case '4': case '5': case '7': case '9': cout<<"hon\n"; break;
		case '0': case '1': case '6': case '8': cout<<"pon\n"; break;
		case '3': cout<<"bon\n"; break;
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] & s[2] == s[3])) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll a[114514];
ll n;
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	ll memo = 0;
	rep(i, n - 1) {
		if (a[i] > a[i + 1]) {
			if (memo == 0)memo = a[i];
			else {
				if (memo - a[i + 1] >= 2) {
					puts("No");
					ggr
				}
			}
		}
		if (a[i] < a[i + 1])memo = 0;
	}
	rep(i, n - 1) {
		if (a[i] > a[i + 1]) {
			if (a[i] - a[i + 1] >= 2) {
				puts("No");
				ggr
			}
		}
	}
	puts("Yes");
	ggr
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
static const ull MOD = 1e9 + 7;

int n;
char s[100005];
ull dp[100005][13];

int main()
{
    scanf("%s", s);
    n = strlen(s);
    //cout << "n:" << n << endl;
    dp[0][0] = 1;
    for(int i = 0; i < n; ++i) {

        /*
        for(int j = 0; j < 13; ++j) {
            for(int i = 0; i < n+1; ++i) {
                cout << dp[i][j] << " ";
            }
            cout << endl;
        }
        cout << endl;
        */

        int c;
        if(s[i] =='?') c = -1;
        else c = s[i] - '0';

        for(int j = 0; j < 10; ++j) {
            if(c != -1 && c != j) continue;
            for(int ki = 0; ki < 13; ++ki) {
                dp[i+1][(ki*10 + j)%13] += dp[i][ki];
            }
        }
        for(int j = 0; j < 13; ++j) dp[i+1][j] %= MOD;
    }

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

Measured memory_bytes: 10496
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define IN freopen("in.txt", "r", stdin);
#define endl '\n'
#define mp make_pair
#define pb push_back
#define lowb lower_bound
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mem0(a) memset((a), 0, sizeof(a))
#define mem(a, b) memset((a), (b), sizeof(a))
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int maxn = 3e6+10;

int c[100000];

int32_t main(){
    IOS;
    int n, m;
    for(int i = 0; i <= 4400; i++)c[i] = inf;

    cin>>n>>m;
    for(int i = 1; i <= m; i++){
        int x, y; cin>>x>>y;
        int cnt = 0;
        for(int j = 1; j <= y; j++){
            int zz; cin>>zz;
            cnt |= (1<<(zz-1));
        }
        c[cnt] = min(c[cnt], x);
    }
    for(int i = 1; i <= 13; i++){
        for(int j = 0; j <= 4200; j++){
            for(int z = j+1; z <= 4200; z++){
                if(j != z && c[j] && c[z]){
                    c[j|z] = min(c[j|z], c[j]+c[z]);
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i <= n-1; i++)ans |= (1<<i);
    if(c[ans] != inf)cout<<c[ans];
    else cout<<-1;
    return 0;
}






Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main(){

  int a;
  string s;
  cin >> a;
  cin >> s;

  if (a >= 3200)
    cout << s << endl;
  else
    cout << "red" << endl;

  return 0;
}


Measured memory_bytes: 256
## coding: UTF-8


N, M, Q = map(int,input().split())
'''
lq = []
for i in range(Q):
    lq.append(list(map(int,input().split())))
'''
lq = [list(map(int, input().split())) for _ in range(Q)]
#print(lq)

dfs = []
for i in range(1, M+1):
    dfs.append([i])
#print(dfs)

def add(l):
    ret = []
    for i in range(len(l)):
        last = l[i][-1]
        for j in range(last, M+1):
            ret.append(l[i] + [j])
    return ret

for i in range(N-1):
    dfs = add(dfs)
#print(dfs)


m = -1
for i in range(len(dfs)):
    A = dfs[i]
    tmp = 0
    for j in range(len(lq)):
        aj = lq[j][0]
        bj = lq[j][1]
        cj = lq[j][2]
        dj = lq[j][3]
        #print('i:{}, j:{}, A:{}, [aj, bj, cj, dj]:{}'.format(i, j, A, lq[j]))
        #print('A[bj-1]:{}, A[aj-1]:{}, A[bj-1]-A[aj-1]:{}, cj:{}, ==?:{}, dj:{}'.format(A[bj-1], A[aj-1], A[bj-1]-A[aj-1], cj,   A[bj-1]-A[aj-1]==cj  , dj))
        #print('i:{}, j:{}, A:{}, lq[j]:{}'.format(i, j, A, lq[j]))
        #print('A[lq[j][i]-1]:{}, A[lq[j][0] - 1]:{}'.format(A[lq[j][i]-1], A[lq[j][0] - 1]))
        #if(A[lq[j][i]-1] - A[lq[j][0] - 1] == lq[2]):
            #tmp += lq[3]
        if(A[bj-1]-A[aj-1] == cj):
            tmp += dj
    #print('i:{}, A:{}, tmp:{}'.format(i, A, tmp))
    if(tmp > m):
        m = tmp    
print(m)

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M,K; cin >> N >> K ;
  vl a(N),sa(N+1),b(N),sb(N+1);
  rep(i,N){
    cin >> a[i] ;
    b[i] = max(0LL,a[i]);
  }
  rep(i,N) sa[i+1] = sa[i] + a[i];
  rep(i,N) sb[i+1] = sb[i] + b[i];
  ll ans = -LINF;
  rep(i,N-K+1){
    ll temp;
    // [i,i+K) を white
    temp = sb[N] - sb[i+K] + sb[i];
    chmax(ans,temp);
    // [i,i+K) を black
    temp += sa[i+K] - sa[i];
    chmax(ans,temp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3456
import sys

input = sys.stdin.readline

S = input().strip()
K = int(input())

fs = S[0]
fnum = 1
fi = len(S)-1
for i, ts in enumerate(S[1:]):
	if ts==fs:
		fnum += 1
	else:
		fi = i+1
		break
fnum = fnum//2

if fi==len(S)-1:
	ans = (len(S)*K)//2
else:
	ls = S[-1]
	lnum = 1
	for i, ts in enumerate(S[-2::-1]):
		if ts==ls:
			lnum += 1
		else:
			li = len(S)-i-2
			break
	lnum = lnum//2

	mnum = 0
	pre = ''
	num = 0
	for ts in S:
		if ts==pre:
			num += 1
		else:
			mnum += num//2
			num = 1
			pre = ts
	mnum += num//2
	mnum = mnum - fnum - lnum

	if S[0]==S[-1]:
		clen = len(S)-(li-fi+1)
		cnum = clen//2
		ans = fnum + lnum + mnum*K + cnum*(K-1)
	else:
		ans = (fnum+mnum+lnum)*K

print(ans)

Measured memory_bytes: 38384
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  char s[10];
  scanf("%s", s);
  if (s[0] == 'S')
    puts("Cloudy");
  else if (s[0] == 'C')
    puts("Rainy");
  else
    puts("Sunny");
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        final String SPACE = " ";
        final String EMPTY = "";
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();

        try {
            String str = br.readLine();
            int a;
            int b;
            String[] temp = new String[2];
            for (int i = 0; i < 200; i++) {
                // 最終行であれば抜ける
                if (EMPTY.equals(str) || str == null) {
                    break;
                }

                temp = str.split(SPACE);
                a = Integer.parseInt(temp[0]);
                b = Integer.parseInt(temp[1]);
                sb.append(String.valueOf(a + b).length() + "\r\n");

                str = br.readLine();
            }
        } catch (IOException e) {
            // NOP
        } finally {
            if (br != null) {
                br.close();
            }
        }

        System.out.print(sb);
    }
}

Measured memory_bytes: 17008
#include <bits/stdc++.h>
using namespace std;
#define fast_io cin.tie(0);ios_base::sync_with_stdio(0);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cout << endl; }
void show() { cout << endl; }
void pret() { cout << endl; exit(0);}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cout << " " << to_string(H); debug_out(T...);}
template <typename Head, typename... Tail> void show(Head H, Tail... T) {cout <<H<<" "; show(T...);}
template <typename Head, typename... Tail> void pret(Head H, Tail... T) {cout <<H<<" "; pret(T...);}
#define pr(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
// #define int ll
typedef long double ld;
#define disp(x) cout<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(int)b;i++)
#define fo(i,a,b) for(int i=a;i<=(int)b;i++)
#define rf(i,a,b) for(int i=a;i>=(int)b;i--)
#define mp make_pair
#define pb emplace_back
#define F first
#define S second
#define endl '\n'
//cout.setf(ios::fixed);cout.precision(18)
const int MOD = 1e9+7;
const int N = 300000+10;

int32_t main(){
	fast_io;
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < int(s.size()); ++i)
	{
		int curr = s[i] - 'A';
		curr += n;
		curr %= 26;
		s[i] = char('A' + curr);
	}
	show(s);
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long  x;
    cin>>x;
    long long sum=0,y;
    y=x/500;
    sum+=1000*y;
    y=x%500;
    y=y/5;
    sum+=5*y;
    cout<<sum<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int aa[100010];

int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<int> q;
    rep(i,n){
        int a;
        cin>>a;
        q.push(a);
    }
    rep(i,m){
        int b=q.top();
        q.pop();
        b/=2;
        q.push(b);
    }
    ll ans=0;

    while(!q.empty()){
        int b=q.top();
        q.pop();
        ans+=b;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 892
s = input()
q = int(input())
rev = False
bef = ""
aft = ""
for _ in range(q):
    t = list(input().split())
    if t[0] == "1":
        rev = not rev
    else:
        f = t[1]
        c = t[2]
        if rev:
            if f == "1":
                aft += c
            else:
                bef += c
        else:
            if f == "1":
                bef += c
            else:
                aft += c
if rev:
    ans = aft[::-1] + s[::-1] + bef
else:
    ans = bef[::-1] + s + aft
print(ans)

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

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

    rep(i, m) {
        int k; cin >> k;
        rep(j, k) {
            int s; cin >> s;
            --s;
            // i番目のスイッチでORをとる
            a[s] |= 1 << i;
        }
    }

    int p = 0;
    rep (i, m) {
        int x;
        cin >> x;

        p |= x<<i;
    }
    int ans = 0;
    // 2^n通りの全探索
    rep (s, (1<<n)) {
        int t = 0;
        rep (i, n) {
            // sのi番目のフラグがたっているかどうか
            if (s>>i & 1) {
                t ^= a[i];
            }
        }
        if (t == p) {
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int a[200100];
string cal(){
	int n;cin>>n;rep(i,n) cin>>a[i];sort(a,a+n);
	rep(i,n-1){
		if(a[i]==a[i+1]){
			return "NO";
		}
	}
	return "YES";
}

int main()
{
	cout<<cal()<<endl;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
value = [list(map(int, input().split())) for _ in range(n)]
value.sort(key=lambda x: x[0])

ans = 0
for i in range(n):
    if m >= value[i][1]:
        ans += value[i][0] * value[i][1]
        m -= value[i][1]
    else:
        ans += value[i][0] * m
        break
print(ans)

Measured memory_bytes: 64600
import sys
from math import pi, cos, sqrt
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)
    h = list(geta(int))
    h += [10**10]

    cur = 0
    ans, tmp = 0, 0
    while cur < n:
        if h[cur] >= h[cur + 1]:
            tmp += 1
        else:
            if tmp > ans:
                ans = tmp
            tmp = 0
        cur += 1
    print(ans)


if __name__ == "__main__":
    main()

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

#define deb(x)        cerr << #x << " = " << x << "\n";
#define deb2(x, y)    cerr << #x << " = " << x << ", " << #y << " = " << y << "\n";
#define deb3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << "\n";

#define pb push_back
#define mp make_pair
#define F  first
#define S  second

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;  
const ll MOD = 1e9 + 7;

void solve() {
    ll n;
    cin >> n;
    vector<int> dp(n+1);
    dp[0] = 1;
    for (int i = 3; i <= n; ++i) {
        for (int j = i - 3; ~j; --j) {
            dp[i] += dp[j];
            dp[i] %= MOD;
        }
    }
    cout << dp[n];
}

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

    ll tc = 1;
    //cin >> tc;

    while(tc--) {
        solve();
        cout << '\n';
    }

    return 0;
}


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

int main() {
  int K;
  string S;
  cin >> K >> S;
  
  int N = S.size();
  if (N <= K){
    cout << S << endl;
  }
  else{
    for(int i=0; i<K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >> y[i];
typedef long long int ll;
using namespace std;

string t[10]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
string s;
int main(){
	int a; cin >>a;
	for(int i=0;i<a;i++){
		cin >>s;
		int line=0;
		char now='0';
		for(int i=0;i<s.size();i++){
			if(now!=s[i]){
				if(now!='0'){
					cout << t[now-'0'][(line-1)%t[now-'0'].size()];
				}
				line=1;
				now=s[i];
			}
			else{
				line++;
			}
		}
		cout << endl;
	}
}


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

using namespace std;
int main() {
  int n;
  cin >> n;
  bool result = false;
  for (int i = 0; i <= n / 4; i++) {
    for (int j = 0; j <= n / 7; j++) {
      int price = i * 4 + j * 7;
      if (price == n) result = true;
    }
  }
  cout << (result ? "Yes" : "No") << endl;

  return 0;
}

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

using namespace std;

int main() {
#ifdef  DEBUG
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
#endif  // for local.
  int a, b, c;
  string ans;
  
  cin >> a >> b >> c;
  if (a * b * c == 5 * 7 * 5) {
    ans = "YES";
  } else {
    ans = "NO";
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    cout << (n - 1) / 2 << endl;
}

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

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

cost=2*10**6
count=0
for i in range(2**n) :    #参考書の買う場合の数
    cost1=0
    B=[[] for i in range(m)]
    for j in range(n) :   #どの本を買うか
        if ((i>>j)&1) :
            cost1+=A[j][0]
            for k in range(1,m+1) :
                B[k-1].append(A[j][k])

    for k in range(m) :
        if x<=sum(B[k]) :
            continue
        else :
            count+=1
            break
    else :
        cost=min(cost,cost1)
            
if count==2**n :
    print(-1)
else :
    print(cost)    

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

int main() {
  int S, s1, s2, s3;
  
  cin >> S;
  
  s1 = S / 100;
  s2 = (S - s1 * 100) / 10;
  s3 = S - s1 *100 - s2 *10;
  
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int D;
	scanf("%d", &D);
	switch (D) {
	case 25:
		puts("Christmas");
		break;

	case 24:
		puts("Christmas Eve");
		break;

	case 23:
		puts("Christmas Eve Eve");
		break;

	case 22:
		puts("Christmas Eve Eve Eve");
		break;

	default:
		puts("Errer");
		break;
	}
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	a := -1
	z := -1
	for i := 0; i < len(s); i++ {
		if s[i:i+1] == "A" && a < 0 {
			a = i
		}
		if s[len(s)-1-i:len(s)-i] == "Z" && z < 0 {
			z = len(s) - 1 - i
		}
	}
	fmt.Println(z - a + 1)
}

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  rep(i, n) {
      int a;
      cin >> a;
    
    if(i%2==0) {
      if(a%2==1) ++ans;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
const int COMMAX = 2000001;
const int MOD = 1000000007;
vector<long long> fac, finv, inv, power25;
 
void InitializeCombination(void){
    fac.push_back(1LL);
    fac.push_back(1LL);
    finv.push_back(1LL);
    finv.push_back(1LL);
    inv.push_back(0LL); //Though 0^(-1) cannot be defined, there should be some number in inv[0]
    inv.push_back(1LL);
    for (int i = 2; i < COMMAX; i++){
        fac.push_back(fac[i-1] * (long long)i % (long long)MOD);
        inv.push_back((long long)MOD - inv[MOD%i] * (long long)(MOD/i) % (long long)MOD);
        finv.push_back(finv[i-1] * inv[i] % (long long)MOD);
    }
}
 
long long Combination(int n, int r){
    if (n < r) return 0LL;
    if (n < 0 || r < 0) return 0LL;
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}

void InitializePower25(int expmax){
    long long powerbuf = 1LL;
    for(int i=0; i<=expmax; i++){
        power25.push_back(powerbuf);
        powerbuf = powerbuf * 25 % MOD;
    }
}

long long Powermod(int base, int exponent){
    long long b = base;
    int e = exponent;
    long long res = 1LL;
    for(;e>0;b=b*b%MOD, e>>=1){
        if(e&1)res = res * b % MOD;
    }
    return res;
}

int main(void){
    int K;
    string S;
    cin >> K;
    cin >> S;
    InitializeCombination();
    int N = S.size();
    InitializePower25(N+K);
    long long res = Powermod(26, N+K);
    for(int i=0; i<N; i++){
        res = (res + MOD - (power25[N+K-i]*Combination(N+K, i)%MOD))%MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 75704
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  int arr[n];
  for(int i=0;i<n;i++) cin>>arr[i];
  sort(arr,arr+n);
  int total=0;
  for(int i=0;i<n;i++)
  {
    for(int j=i+1;j<n;j++)
    {
      int idx=lower_bound(arr,arr+n,arr[i]+arr[j])-arr;
      total+=idx-j-1;
    }
  }
  cout<<total;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

const int NIL = -1;
const int MAX = 2147483647;
const int N = 100001;
clock_t START, END;
bool debug = false;

int maxv[500000], addv[500000];
int l, r, _max, v = 1;

void maintain(int o, int L, int R)
{
	int lc = o * 2, rc = 2 * o + 1;
	maxv[o] = 0;
	if (R > L) {
		maxv[o] = max(maxv[lc], maxv[rc]);
	}
	maxv[o] += addv[o];
}

void query(int o, int L, int R, int add)
{
	int M = L + (R - L) / 2;
	if (l <= L && r >= R) {
		_max = max(_max, maxv[o] + add);
	}
	else {
		if (l <= M)
			query(o * 2, L, M, add + addv[o]);
		if (r > M)
			query(o * 2 + 1, M + 1, R, add + addv[o]);
	}
}

void update(int o, int L, int R)
{
	int M = L + (R - L) / 2;
	int lc = o * 2, rc = o * 2 + 1;
	if (l <= L && r >= R) {
		addv[o] += v;
	}
	else {
		if (l <= M)
			update(lc, L, M);
		if (r > M)
			update(rc, M + 1, R);
	}
	maintain(o, L, R);
}


int main(void)
{
	if (debug) {
		START = clock();
		freopen("in12.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int n, t;
	scanf("%d%d", &n, &t);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &l, &r);
		l++;
		update(1, 1, t);
	}
	l = 1;
	r = t;
	query(1, 1, t, 0);
	printf("%d\n", _max);
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 5260
L,R = map(int,input().split())
if R-L>=2019:print(0)
else:
    L%=2019
    R%=2019
    if R<L:R+=2019
    ans = 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans = min(ans,i*j%2019)
    print(ans)

Measured memory_bytes: 40812
n = int(input())
vs = list(map(int, input().split()))
def mmm(vs):
    minimum = 10000
    for v in vs:
        if v < minimum:
            minimum = v
    vs.remove(minimum)
    return minimum

for i in range(len(vs)-1):
    m1 = mmm(vs)
    m2 = mmm(vs)
    vs.append((m1+m2)/2)

print(vs[0])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <iostream> 
#include <string> 
#define lli long long int
#define deb1(x) cout<<#x<<" :: "<<x<<"\n";
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define deb(v) for(lli i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define all(a) a.begin(),a.end()
#define ll long long
using namespace std;
#define f first
#define sd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(x) (ll)x.size()
#define vl vector<lli>
#define pii pair<lli,lli>
lli mod=1e9+7;
using namespace std;
lli t,n,u,x,y,k;
const lli N = 100001;
int main(){
    fast
     t=1;
//    cin>>t;
    while(t--){
        cin>>n;
        int a[n][2];
        int cnt=0,fl=0;
        for(int i=0;i<n;++i)cin>>a[i][0]>>a[i][1];
        for(int i=0;i<n;++i){
            if(a[i][0]==a[i][1])++cnt;
            else{
                if(cnt>=3)fl=1;
                cnt=0;
            }
        }
        if(cnt>=3)fl=1;
        if(fl)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

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

int n;
int s[11];
double f[333][333][333];

double dp(int s1, int s2, int s3) {
	double &t = f[s1][s2][s3];
	if (s1+s2+s3<=0) t = 0;
	if (t>=-1e-10) return t;
	
	t = 0;
	int s = s1+s2+s3;
	double det = 1.*n/s;
	if (s1>0) t += (1.*s1/s) * (dp(s1-1, s2, s3) + det);
	if (s2>0) t += (1.*s2/s) * (dp(s1+1, s2-1, s3) + det);
	if (s3>0) t += (1.*s3/s) * (dp(s1, s2+1, s3-1) + det);
	
	// printf("%d %d %d %d, %.5lf %.5lf\n", s1, s2, s3, s, t, det);
	return t;
}

int main() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++) {
		int x; scanf("%d", &x);
		s[x]++;
	}
	
	int ma = s[1]+s[2]+s[3];
	for(int i=0;i<=ma;i++)
	for(int j=0;j<=ma;j++)
	for(int k=0;k<=ma;k++)
		f[i][j][k] = -1;
	printf("%.10lf\n", dp(s[1], s[2], s[3]));
	
	return 0;
}

Measured memory_bytes: 262272
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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;}

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  string a, b, c;
  cin >> a >> b >> c;
  if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
} 






Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

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

    double r = 0;
    for (int i = 0; i < n; i++)
    {
        double a;
        cin >> a;
        r += 1.0 / a;
    }

    cout << setprecision(20) << 1.0 / r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define vd vector<ld>
#define vvd vector<vector<ld>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define SZ(a) ll((a).size())
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  ll n, m;
  ll ans = 1;

  cin >> n >> m;
  if (n < m) swap(n, m);
  if (n == m) {
    REP(i, n) {
      ans = ans * (i + 1) % MOD;
    }
    ans = ans * ans % MOD;
    ans = ans * 2 % MOD;
  } else if (n == m + 1) {
    REP(i, n - 1) {
      ans = ans * (i + 1) % MOD;
    }
    ans = ans * ans % MOD;
    ans = ans * n % MOD;
  } else {
    ans = 0;
  }
  cout << ans << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

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


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

#define ll long long int
#define str string
#define sec .second

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30;
ll A[1000000] = {}, B[1000000] = {}, weight[1000] = {}, value[1000] = {};
ll dp[100][10] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
ll a = 0, b = 0, aka = 0, kaijou = 1, e = 0, f = 0, n = 0, su = 0, ma = INF, mi = -1;
double ans;
str S;
pair<str, ll> Sp[1000];
bool an = true, bn = false;
long long mod = 1e9 + 7;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Code Line
	cin >> n;
	cout << 3 * n * n << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll p=998244353ll,p1=998244352ll;
inline ll add(ll a){return a<p  ?a:a-p;}
inline ll sub(ll a){return a<0ll?a+p:a;}
inline ll e(ll a,int b=998244351){
	ll c=1ll;
	while(b){
		if(b&1)c=c*a%p;
		b>>=1; a=a*a%p;
	}
	return c;
}
ll a[1<<18],b[1<<18],c[1<<18];
int n,k;
inline void hdminit(int _,int __){n=_;k=__;}
inline void hdm(ll *a){
	int i,j,k;ll e,o;
	for(i=1;i!=n;i<<=1){
		for(j=0;j!=n;j+=i<<1){
			for(k=j;k<j+i;++k){
				e=a[k  ];
				o=a[k+i];
				a[k  ]=add(e+o);
				a[k+i]=sub(e-o);
			}
		}
	}
}
int f[1<<18];
int main(){
	int k,n,i,x,t=0;ll t1;
	scanf("%d",&k);n=1<<k;
	for(i=1;i!=n;++i)f[i]=f[i&(i-1)]^1;
	for(i=0;i!=n;++i){
		scanf("%d",&x);
		a[i]=x;
		t+=x;
	}
	t1=e(t);
	a[0]=(a[0]*t1+p1)%p;
	for(i=1;i!=n;++i)a[i]=a[i]*t1%p;
	b[0]=n-1;
	for(i=1;i!=n;++i)b[i]=p1;
//	for(i=0;i!=n;++i)printf("%lld ",a[i]);printf("\n");
//	for(i=0;i!=n;++i)printf("%lld ",(a[i]<<2)%p);printf("\n");
//	for(i=0;i!=n;++i)printf("%lld ",b[i]);printf("\n");
	hdminit(n,k);
	hdm(a);
	hdm(b);
//	printf("hdm\n");
//	for(i=0;i!=n;++i)printf("%lld ",a[i]);printf("\n");
//	for(i=0;i!=n;++i)printf("%lld ",b[i]);printf("\n");
	for(i=1;i!=n;++i)b[i]=e(a[i])*b[i]%p;
//	for(i=0;i!=n;++i)printf("%lld ",b[i]);printf("\n");
	hdm(b);
//	printf("ihdm\n");
//	for(i=0;i!=n;++i)printf("%lld ",b[i]);printf("\n");
	putchar('0');
	t1=e(n);
	for(i=1;i!=n;++i)printf("\n%lld",sub(b[i]-b[0])*t1%p);
	return 0;
}

Measured memory_bytes: 8960