akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP_1_9_C2
{
    class Program
    {
        static void Main(string[] args)
        {
            // n枚のカードをA、Bが一枚ずつ出し合い、カードに書かれている単語の辞書順が早いほうが勝ち
            // 勝者に3ポイント、引き分けの時は両者に1ポイントを与える
            // A、Bの手持ちのカード情報を読み込み、ゲーム終了時のそれぞれの得点を出力するプログラム

            // 1行目：カード(ターン)の数 n
            // 2～n+1行目：Aのカード情報　Bのカード情報

            int n = int.Parse(Console.ReadLine());                  // 1行目を読み込みターン数nを取得
            string[] str;
            string[] TaroCards = new string[n];
            string[] HanakoCards = new string[n];
            for (int i = 0; i < n; i++)
            {
                str = Console.ReadLine().Split(' ');
                TaroCards[i] = str[0];
                HanakoCards[i] = str[1];
            }

            Player Taro = new Player(n, TaroCards);
            Player Hanako = new Player(n, HanakoCards);
            PointJudge pointJudge = new PointJudge();
            pointJudge.CalcPoint(Taro, Hanako);

            Console.WriteLine(Taro.playerPoint + " " + Hanako.playerPoint);
        }

        public class Player
        {
            public int cardNum;
            public string[] cards;
            public int playerPoint;
            public Player(int n, string[] animalCards)
            {
                cardNum = n;
                cards = animalCards;
                playerPoint = 0;
            }
        }

        public class PointJudge
        {
            public void CalcPoint(Player Taro, Player Hanako)
            {
                for (int i = 0; i < Taro.cardNum; i++)
                {
                    int judge = string.Compare(Taro.cards[i], Hanako.cards[i]);           // cardA、cardBの文字列を比較する

                    if (judge > 0)
                    {
                        Taro.playerPoint += 3;
                    }
                    else if (judge < 0)
                    {
                        Hanako.playerPoint += 3;
                    }
                    else
                    {
                        Taro.playerPoint += 1;
                        Hanako.playerPoint += 1;
                    }
                }
            }
        }
    }
}




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


void solve() {
  string s;
  cin >> s;
  if (s=="SUN") std::cout << 7 << '\n';
  if (s=="MON") std::cout << 6 << '\n';
  if (s=="TUE") std::cout << 5 << '\n';
  if (s=="WED") std::cout << 4 << '\n';
  if (s=="THU") std::cout << 3 << '\n';
  if (s=="FRI") std::cout << 2 << '\n';
  if (s=="SAT") std::cout << 1 << '\n';
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define vi vector<int>
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;

typedef pair<ll,int> P1;
typedef pair<int,P1> P2;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

#define MAX_N 100002

map<int,int> dp[MAX_N];
vector<edge> G1[MAX_N],G2[MAX_N],G3[1000002];
int dp1[MAX_N];
priority_queue<P2,vector<P2>,greater<P2>> que;

P1 a[200001]={};

int main() {
	string s;
	cin>>s;
	int ls=s.length();
	int t=0;
	rep(i,ls){
		if(s[i]=='C'&&t==0)t=1;
		if(s[i]=='F'&&t==1)t=2;
	}
	if(t==2){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 36608
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int big=0;
  int sum=0;
  for(int i=0;i<N;i++){
   int a;
    cin>>a;
    sum+=a;
   	big=max(big,a);
    }
  
  if(big< sum-big ){
  cout<<"Yes"<<endl;
  }
  else{
  cout<<"No";
  }
}

Measured memory_bytes: 3576
function main(input){
    let numArray = [];
    let strArray = input.split(' ');
    for(let i = 0; i<strArray.length; i++){
        numArray.push(parseInt(strArray[i]));
    }
    if(numArray[0] < numArray[1] && numArray[1] < numArray[2]){
        console.log('Yes');
    }else {
            console.log('No');
        }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15096
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  size_t n;
  cin >> n;
  vector<size_t> a(n);
  cin >> a;

  const auto lb = *min_element(begin(a), end(a));
  const auto ub = *max_element(begin(a), end(a));

  if(lb + 1 < ub || n < ub + 1)
  {
    cout << "No";
    return 0;
  }

  if(lb == ub)
  {
    // everyone has a unique hat!
    // or no one has a unique hat!
    if(lb == n - 1 || lb == 1)
    {
      cout << "Yes";
      return 0;
    }

    if(2 * lb < n + 1)
      cout << "Yes";
    else
      cout << "No";
    return 0;
  }

  const size_t x = count(begin(a), end(a), ub);
  const size_t k = count(begin(a), end(a), lb);  // colors w/ only one person
  const size_t s = lb - k + 1; // colors with at least 2

  if(x < s * 2 || lb < k)
  {
    cout << "No";
    return 0;
  }

  // if(n < k + 2 || k != lb || k + 1 != ub)
  // {
  //   cout << "No";
  //   return 0;
  // }

  cout << "Yes";
  return EXIT_SUCCESS;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[1005][1005],mod=1000000007;
char ch[1005][1005];

int main()
{
    ll n,m,i,j,k,a,b,c,x,y,z;
    cin>>n>>m;
    for(i=0;i<n;i++){
        scanf(" %s",ch[i]);
    }
    for(i=n-1;i>=0;i--){
        for(j=m-1;j>=0;j--){
            if(i==n-1&&j==m-1)
                dp[i][j]=1;
            else{
                if(ch[i][j]=='#')
                    dp[i][j]=0;
                else{
                    dp[i][j]=dp[i+1][j]+dp[i][j+1];

                }
            }
            dp[i][j]%=mod;
        }
    }
    cout<<dp[0][0]<<endl;
}


Measured memory_bytes: 9088
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, X, D = map(int, raw_input().split())
if D == 0:
    if X == 0:
        print 1
    else:
        print N + 1
    exit()
if D < 0:
    X = X + D * (N - 1)
    D = -D
m1 = {}
m2 = {}
m1[0] = D
m2[0] = -D
ans = 1
for i in range(1, N + 1):
    p1 = (X + X + D * (i - 1)) * i / 2
    p2 = (X + D * (N - 1) + X + D * (N - i)) * i / 2
    rem = p1 % D
    if rem in m1:
        ans += max(0, (p2 - max(m1[rem], p1)) / D + 1)
        ans += max(0, (min(p2, m2[rem]) - p1) / D + 1)
    else:
        ans += (p2 - p1) / D + 1
    m1[rem] = p2 + D
    m2[rem] = p1 - D
print ans

Measured memory_bytes: 95592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx")

const ll MOD = 1e9+7;
ll fastpow(ll x, ll k) {
    ll ans=1;
    FOR(b,30) {
        if(k & (1LL<<b))
            ans = ans*x % MOD;
        x = x*x % MOD;
    }
    return ans;
}

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

    int N,K; cin>>N>>K;
    map<int,int> mposs;

    REV(i,K, 1) {

        int nums = K / i;
        ll poss =fastpow(nums, N);

        for(int m=2*i; m<=K; m+=i) {
             poss -= mposs[m];
        }

        mposs[i] = (poss % MOD + MOD) % MOD;
    }

    ll ans=0;
    for(auto e : mposs) {
        ans += 1LL * e.first * e.second;
        ans %= MOD;
//        cerr<<e.first<<" "<<e.second<<endl;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 8340
s = input()

ans = [0] * len(s)
s += 'R'
present = 'R'
start = 0
for i in range(len(s)-1):
  if present == 'R':
    if s[i+1] == 'R':
      continue
    r = i
    l = i+1
    present = 'L'
  else:
    if s[i+1] == 'L':
      continue
    end = i
    present = 'R'
    rl = r - start
    ll = end - l
    ans[r] = 1 + rl//2 + (-(-ll//2))
    ans[l] = 1 + (-(-rl//2)) + ll//2
    start = i+1
print(' '.join(map(str, ans)))

Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    
    int res = 0;

    x -= z;

    while (x >= y+z) {
        x -= y;
        x -= z;

        res++;
    }

    cout << res << endl;
    return 0;
}

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

using namespace std;

typedef long long int big;

int main(){
	big h,w,n,z;
	cin>>h>>w>>n;
	big color = min(h,w);
	big count = 0,op = 0;
	while(n>count){
		op++;
		count = count + max(h,w);
	}
	cout<<op<<endl;
	//cin>>z;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  
 
using namespace std;
 
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define MAX 200000
int N;
bool prime[MAX];

int main() {
	memset(prime, true, sizeof(prime));
	prime[0] = false;
	for(int i = 1; i < sqrt(MAX); ++i) {
		if(prime[i]) {
			for(int j = (i + 1); (i + 1) * j <= MAX; ++j) {
				prime[(i + 1) * j - 1] = false;
			}
		}
	}
	while(scanf("%d", &N), N) {
		int cnt = 0;
		ll ans = 0;
		for(int i = 1; i < MAX; ++i) {
			if(prime[i]) {
				ans += i + 1;
				++cnt;
				if(cnt == N) break;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3400
#include <iostream>
#include <cstdio>

using namespace std;

int main (void)
{
    int  n, k, x, y, total_pay = 0;

    cin >> n >> k >> x >> y;
    for (int i = 1; i <= n; i++) {
        int day_pay;
        if (i <= k) {
            day_pay = x;
        } else {
            day_pay = y;
        }
        total_pay += day_pay;
    }
    cout << total_pay << endl;

    return 0;
}

Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M, Q = read_ints()
    dp = [ [0 for _ in range(N)] for _ in range(N) ]
    left = [0 for _ in range(N)]
    right = [0 for _ in range(N)]
    length_to_pairs = [[] for _ in range(N)]

    for _ in range(M):
        L, R = read_ints()
        L -= 1
        R -= 1
        length_to_pairs[R-L].append((L, R))
        if L == R:
            dp[L][L] += 1
            right[L] += 1
            left[L] += 1

    for l in range(1, N):
        for i in range(N-l):
            dp[i][i+l] += right[i]+left[i+l]
            if l > 1:
                dp[i][i+l] += dp[i+1][i+l-1]
        for L, R in length_to_pairs[l]:
            dp[L][R] += 1
            right[L] += 1
            left[R] += 1

    for _ in range(Q):
        q0, q1 = read_ints()
        print(dp[q0-1][q1-1])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 95584
#include<stdio.h>

int a,b,c,d;

int main(){
    scanf("%1d%1d%1d%1d",&a,&b,&c,&d);
    if(a+b+c+d==7)printf("%d+%d+%d+%d=7\n",a,b,c,d);
    else if(a+b+c-d==7)printf("%d+%d+%d-%d=7\n",a,b,c,d);
    else if(a+b-c+d==7)printf("%d+%d-%d+%d=7\n",a,b,c,d);
    else if(a+b-c-d==7)printf("%d+%d-%d-%d=7\n",a,b,c,d);
    else if(a-b+c+d==7)printf("%d-%d+%d+%d=7\n",a,b,c,d);
    else if(a-b+c-d==7)printf("%d-%d+%d-%d=7\n",a,b,c,d);
    else if(a-b-c+d==7)printf("%d-%d-%d+%d=7\n",a,b,c,d);
    else if(a-b-c-d==7)printf("%d-%d-%d-%d=7\n",a,b,c,d);
    return 0;
}


Measured memory_bytes: 128
import sys
import string
import time


def input():
    return sys.stdin.readline().rstrip()


def I():
    return int(input())


def S():
    return input()


def MI():
    return map(int, input().split())


def MS():
    return map(str, input().split())


def LI():
    return list(map(int, input().split()))


def LI_():
    return [int(i) - 1 for i in input().split()]


def StoI():
    return [ord(i) - 97 for i in input()]


def ItoS(nn):
    return chr(nn + 97)


N = {False: 'No', True: 'Yes'}
MOD = 10 ** 9 + 7
inf = float('inf')
IINF = 10 ** 10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10 ** 6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


def main():
    K, S = MI()
    ans = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = x + y - S
            if -K <= z & z <= 0:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
	double a,b,c,d,e,f,S,l,h=0;
	cin>>a>>b>>c;
	e=sin(c*M_PI/180);
	f=cos(c/180*M_PI);
	S=(a*b*e)/2;
	d=sqrt(a*a+b*b-(a*b*f)*2);
	l=a+b+d;
	h=(S*2)/a;
	cout <<setprecision(12)<<S<<" "<<l<<" "<<h <<endl;
	return 0;
}

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

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

int main() {
  ll n,ans=0;
  cin >> n;
  vector<vector<ll>>dp(n+5,vector<ll>(3));
  vector<ll>a(n);vector<ll>b(n);vector<ll>c(n);
  rep(i,n) cin >> a.at(i) >> b.at(i) >> c.at(i);
  dp[0][0]=0;dp[0][1]=0;dp[0][2]=0;
  rep(i,n){
  	chmax(dp[i+1][0],dp[i][1]+a[i]);
  	chmax(dp[i+1][0],dp[i][2]+a[i]);
  	chmax(dp[i+1][1],dp[i][0]+b[i]);
  	chmax(dp[i+1][1],dp[i][2]+b[i]);
  	chmax(dp[i+1][2],dp[i][0]+c[i]);
  	chmax(dp[i+1][2],dp[i][1]+c[i]);
  }
  rep(i,3) ans=max(ans,dp[n][i]);
  cout << ans << endl;
}


Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
lint f(lint a, lint b)
{
    lint aa = 0;
    lint bb = 0;
    while (a > 0)
    {
        aa++;
        a /= 10;
    }
    while (b > 0)
    {
        bb++;
        b /= 10;
    }
    return max(aa, bb);
}
int main()
{
    lint n;
    cin >> n;
    lint ans=1<<20;
    for (lint i = 1; i <= sqrt(n); i++)
    {
        if (n % i != 0){
            continue;
        }else{
            lint j = n / i;
            ans = min(ans, f(i, j));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

const LL INF = 99999999999999;
const int inf = 999999999;

int main()
{
  //freopen("in.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  int n, a, b, c, d;
  scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
  vector<char> s(n+1);
  for (int i = 1; i <= n; i++) cin >> s[i];
  
  for (int i = a + 1; i < max(c, d); i++) {
    if (s[i] == '#' && s[i+1] == '#') {
      puts("No");
      return 0;
    }
  }
  
  if (c < d) {puts("Yes"); return 0; }
  
  for (int i = b - 1; i <= d - 1 ; i++) {
    if (s[i] == '.' && s[i+1] == '.' && s[i+2] == '.') break;
    if (i == d - 1) {puts("No"); return 0; }
  }
  puts("Yes");

}
/*
    input:
    output:
    modeling:
    methods:
    complexity:
    summary:
*/

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  cout << (s < t ? "Yes": "No") << endl;
}


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

int64_t f(int64_t b, int64_t n) {
  int64_t s = 0;
  while (n > 0) {
    s += n % b;
    n /= b;
  }
  return s;
}

int main() {
  int64_t n, s, d, ans = 1e18;
  cin >> n >> s;
  d = n - s;
  if (d < 0) {
    cout << -1 << endl;
    return 0;
  } else if (d == 0) {
    cout << n + 1 << endl;
    return 0;
  }
  for (int64_t i = 1; i * i <= d; i++) {
    if (d % i != 0) continue;
    if (f(i + 1, n) == s) {
      cout << i + 1 << endl;
      return 0;
    } else if (f(d / i + 1, n) == s) {
      ans = d / i + 1;
    }
  }
  if (ans == 1e18) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  string S;
  int K;
  cin>>S>>K;
  
  vector<string> T;
  for(int i=1; i<=min(K,(int)S.size()); ++i){
    for(int j=0; j<=(int)S.size()-i; ++j){
      T.PB(S.substr(j,i));
    }
  }
  
  SORT(T);
  
  if(K==1){
    cout<<T[0]<<endl;
    return 0;
  }
  
  int cnt=1;
  RREP(i,(int)T.size()-1){
    if(T[i]!=T[i-1]) cnt++;
    if(cnt==K){
      cout<<T[i]<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 4256
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        struct Triangle
        {
            public double a { get; set; }
            public double b { get; set; }
            public double C { get; set; }

            double CasRadian
            {
                get
                {
                    return Math.PI / 180.0 * C;
                }
            }

            public double S
            {
                get
                {
                    return Math.Sin(CasRadian) * a * b * 0.5;
                }
            }
            public double c
            {
                get
                {
                    return Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(CasRadian));
                }
            }
            public double L
            {
                get
                {
                    return a + b + c;
                }
            }
            public double h
            {
                get
                {
                    return 2 * S / a;
                }
            }
        }

        static void Main(string[] args)
        {
            var input = Console.In.ReadLine();
            var strings = input.Split(' ');

            if (strings.Length != 3)
            {
                return;
            }

            var triangle = new Triangle { a = double.Parse(strings[0]), b = double.Parse(strings[1]), C = double.Parse(strings[2]) };

            Console.Out.WriteLine("{0:0.########}", triangle.S);
            Console.Out.WriteLine("{0:0.########}", triangle.L);
            Console.Out.WriteLine("{0:0.########}", triangle.h);
        }
    }
}



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

int main(void) {
	int N;
	cin >> N;
	int sn = 0;
	int n = N;
	while (N > 0) {
		sn += (N % 10);
		N /= 10;
	}
	cout << (n % sn == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <string>
#include <sstream>
#include <cstring>
#include <cmath>

using namespace std;

#ifdef DEBUG
#define LOG(args) cout << args << "\n"
#define debug(x) x
#else
#define LOG(args)
#define debug(x)
#endif

#define vi vector<int>
#define ii pair<int, int>
#define vii vector< ii >
#define vvi vector< vi >
#define mp make_pair
#define pb push_back
#define ms(x, v) memset(x, v, sizeof(x))
#define all(x) x.begin(), x.end()
#define REP(x, n) for(int x = 0; x < n; x++)
#define REPV(x, v, n) for(int x = v; x < n; x++)
#define REVE(x, n) for(int x = n; x >= 0; x--)

typedef long long ll;

inline bool ok(int a, int b, int c)
{
    return (a + b > c && b + c > a && a + c > b);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin >> N;
	vi vals(N);
	for(auto &x : vals) cin >> x;
	int cnt = 0;
	REP(i, N)
	    REPV(j, i + 1, N) if(vals[i] != vals[j])
		REPV(k, j + 1, N) if(vals[i] != vals[k] && vals[k] != vals[j])
		{
		    if(ok(vals[i], vals[j], vals[k]))
		    {
			cnt++;
			LOG(i + 1 << ", " << j + 1 << ", " << k + 1);
		    }	
		}
	cout << cnt << "\n";
	return 0;
}


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

using namespace std;

//二次元vector用
void swap(vector<vector<long long>> &heap, int i, int j){
    vector<long long> tmp = heap[i];
    heap[i]=heap[j];
    heap[j]=tmp;
}

void maxHeapify(vector<vector<long long>> &heap, int n){
    int l,r,largest,last;
    l=2*n+1;
    r=2*n+2;
    largest=n;
    last=heap.size();

    if (l<last && heap[l][0] > heap[largest][0])largest=l;
    if (r<last && heap[r][0] > heap[largest][0])largest=r;
    if(largest!=n){
        swap(heap,n,largest);
        maxHeapify(heap,largest);
    }
}

vector<long long> maxHeapPop(vector<vector<long long>> &heap){
    vector<long long> max_=heap[0];
    heap[0]=heap[heap.size()-1];
    heap.pop_back();
    maxHeapify(heap,0);

    return max_;
}

void maxHeapPush(vector<vector<long long>> &heap, vector<long long> vec){
    heap.push_back(vec);
    int i = heap.size()-1;
    int parent = (i-1)/2;
    while (i>0 && heap[parent][0] < heap[i][0]){
        swap(heap,i,parent);
        i=parent;
        parent=(i-1)/2;
    }
}

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

    vector<vector<long long>> heap(N,vector<long long>());
    heap={};
    for(int i=0; i< N; i++){
        long long A,B;
        cin >> A >> B;
        maxHeapPush(heap,{A+B,A,B});
    }
    long long ans=0;
    for(int i=0; i<N; i++){
        if(i&1){
            ans-=maxHeapPop(heap)[2];
        }else{
            ans+=maxHeapPop(heap)[1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

string s;
int n;

ll go(ll cur,ll num,ll total){
	if(cur==n) return total+num;
	ll res=go(cur+1,num*10+s[cur]-48,total);
	if(num>0) res+=go(cur+1,s[cur]-48,total+=num);
	return res;
}

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>s;
	n=s.size();
	cout<<go(0,0,0);
}

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

int main(void) {
    int64_t H,W;
    cin >> H >> W;

    vector<string> S(H);
    for(int i=0;i<H;i++) {
        cin >> S[i];
        S[i] = regex_replace(S[i], regex("\\."), "0");
    }

    for(int i=0;i<H;i++) {
        for(int j=0;j<W;j++) {
            if(S[i][j] != '#') {
                if(i > 0){
                    // 左上
                    if(j>0){
                        if(S[i-1][j-1] == '#')
                            S[i][j]++;
                    }
                    // 上
                        if(S[i-1][j] == '#')
                            S[i][j]++;
                    // 右上
                    if(j<(W-1)){
                        if(S[i-1][j+1] == '#')
                            S[i][j]++;
                    }
                }
                // 左
                if(j>0){
                    if(S[i][j-1] == '#')
                        S[i][j]++;
                }
                // 右
                if(j<(W-1)){
                    if(S[i][j+1] == '#')
                        S[i][j]++;
                }
                if(i < (H-1)){
                // 左下
                    if(j>0){
                        if(S[i+1][j-1] == '#')
                            S[i][j]++;
                    }
                // 下
                        if(S[i+1][j] == '#')
                            S[i][j]++;
                // 右下
                    if(j<(W-1)){
                        if(S[i+1][j+1] == '#')
                            S[i][j]++;
                    }
                }
            }
        }
    }

    for(int i=0;i<H;i++) {
        cout << S[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



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

	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 != 0) {
			cnt++;
		}
	}

	cout << setprecision(10) << (1.0 * cnt) / n << endl;
}


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

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

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

int main() {
  int n,x,t;cin>>n>>x>>t;
  int ans=(n+x-1)/x*t;
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n;
	cin >> n;
	VI a(n);
	REP(i, n)
		cin >> a[i];
	int l = 0, r = a[0], s, s2;
	while (1) {
		s = (r + l) / 2;
		s2 = s;
		REP(i, n) {
			s2 = a[i] - s2;
		}
		if (s2 == s)
			break;
		if (s2 > s)
			l = s + 1;
		else
			r = s - 1;
	}
	REP(i, n) {
		if(i != n - 1)
			cout << s * 2 << ' ';
		else
			cout << s * 2;
		s = a[i] - s;
	}	
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
string f(char c0, char c1) {
  string res;
  res += c0;
  res += c1;
  for (int i = 2; i < n; i++) {
    if (s[i - 1] == 'o' ^ res[i - 1] == 'W') {
      res += res[i - 2];
    } else {
      res += res[i - 2] == 'S' ? 'W' : 'S';
    }
  }
  if (s[0] == 'o' ^ res[0] == 'W') {
    if (res[1] != res[n - 1]) res = "-1";
  } else {
    if (res[1] == res[n - 1]) res = "-1";
  }
  if (s[n - 1] == 'o' ^ res[n - 1] == 'W') {
    if (res[0] != res[n - 2]) res = "-1";
  } else {
    if (res[0] == res[n - 2]) res = "-1";
  }
  return res;
}
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  cin >> n;
  cin >> s;
  string t;
  if ((t = f('S', 'S')) != "-1" or (t = f('S', 'W')) != "-1" or (t = f('W', 'S')) != "-1") {
    cout << t << '\n';
    return 0;
  }
  cout << f('W', 'W') << '\n';
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int calc(int x){
	if(x == 0) return 0;
	if(x == 1) return 1;
	int ans = 0,tmp = 4;
	if(x % 4 == 1 || x % 4 == 2) ans++;
	for(int keta = 1;x * 2 + 1 >= tmp;keta++){
		int num = x % tmp;
		if(num >= tmp / 2 && (num - tmp / 2 + 1) % 2) ans += (1ll << keta);
		tmp *= 2;
	}
	return ans;
}

signed main(){
	int a,b;
	cin >> a >> b;
	cout << (calc(a - 1) ^ calc(b)) << endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';
#define MOD 1000000007

using namespace std;

int main(void){
    ll N;
    string S;
    ll kosu[26];
    cin>>N>>S;
    MEMSET(kosu, 0);
    rep(i, N){
        kosu[S[i]-'a']++;
        kosu[S[i]-'a']%=MOD;
    }
    ll count=1;
    rep(i, 26){
        count*=((kosu[i]+1)%MOD);
        count%=MOD;
    }
    cout<<(count-1+MOD)%MOD<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int N,k;
int h[1000001],f[1000001];
int main () {
	cin>>N>>k;
	for(int i=1;i<=N;i++) {
		scanf("%d",&h[i]);
		f[i]=1<<30;
	}
	f[1]=0;
	for(int i=2;i<=N;i++) {
		for(int j=1;j<=k;j++) {
			if(i-j>=1) f[i]=min(f[i],f[i-j]+abs(h[i]-h[i-j]));
		}
	}
	cout<<f[N];
	return 0; 
}

Measured memory_bytes: 4736
from scipy.sparse import*
f=lambda*z:map(int,input().split())
n,=f()
c=[1]*~-n
print('FSennunkeec'[sum(g>h for g,h in zip(*csgraph.dijkstra(csr_matrix((c,list(zip(*map(f,c)))),[n+1]*2),0,[1,n])))*2>=n::2])

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

int main(){
  int N,T,A;
  cin>>N>>T>>A;
  double m = 10000000;
  vector<int> H(N);
  vector<double> C(N);
  for(int i=0;i<H.size();i++)
    cin>>H.at(i);
  
  for(int i=0;i<H.size();i++){
    C.at(i)=double(T-H.at(i)*0.006);
   
    m = min(m,double(abs(A-C.at(i))));
  }
  
  for(int i=0;i<C.size();i++){
    if(abs(A-C.at(i))==m)
      cout<<i+1<<endl;
  }
}


Measured memory_bytes: 256
N,K,Q = map(int,input().split())
A = [0] * Q
for i in range(Q):
    A[i] = int(input())
    
judge = [K-Q] * N
for j in A:
    judge[j-1] += 1

for k in judge:
    if k > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 51024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	int ma1 = -(1<<30), mi1 = (1<<30);
	int ma2 = -(1<<30), mi2 = (1<<30);
	for (int i = 0; i < N; ++ i) {
		int x, y;
		cin >> x >> y;
		ma1 = max(ma1, x-y);
		mi1 = min(mi1, x-y);
		ma2 = max(ma2, x+y);
		mi2 = min(mi2, x+y);
	}
	cout << max(ma1-mi1, ma2-mi2) << endl;
}


Measured memory_bytes: 3628
S = str(input())
N = len(S)


def palindromic(word):
    if word == word[::-1]:
        return 1
    else:
        return 0


flag = palindromic(S)
flag2 = palindromic(S[0:(N - 1) // 2])
flag3 = palindromic(S[(N + 2) // 2:])
if(flag3 == 1 and flag == 1 and flag2 == 1):
    print('Yes')
else:
    print('No')

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

#define MAXN (200010)

int n;
char s[MAXN], t[MAXN];
int cnt1[30], cnt2[30];

int main() {
    scanf("%s%s", s, t);
    n = strlen(s);
    for (int i = 0; i < n; ++i) {
        ++cnt1[s[i] - 'a'];
        ++cnt2[t[i] - 'a'];
    }
    std::sort(cnt1, 26 + cnt1);
    std::sort(cnt2, 26 + cnt2);
    for (int i = 0; i < 26; ++i) {
        if (cnt1[i] != cnt2[i]) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 640
import java.util.*

tailrec fun gcd(x: Long, y: Long): Long = if (y == 0L) x else gcd(y, x % y)

fun factorize(n: Long): List<Pair<Long, Long>> {
    val list = ArrayList<Pair<Long, Long>>()
    var m = n
    var k = 2L

    while (m > 1 && k * k <= m) {
        var s = 0L
        while (m % k == 0L) {
            m /= k
            s++
        }
        if (s > 0) {
            list.add(Pair(k, s))
        }
        k++
    }

    if (m > 1) {
        list.add(Pair(m, 1L))
    }

    return list
}

fun main(args: Array<String>) {
    val (A, B) = readLine()!!.split(" ").map{it.toLong()}
    val g = gcd(A, B)

    println(factorize(g).size + 1)
}


Measured memory_bytes: 37988
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

#define PI 3.141592

using namespace std;

int main (void){
    int s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }
    return 0;
}

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

using namespace std;

#define ll long long

int n;
string s;

void solve() {
  cin >> n >> s;
  string check = "";
  if (n&1) {
    cout << "No\n";
    return;
  }
  for (int i = 0; i < 2; i++) {
    for (int i = 0; i < n/2; i++) {
      check += s[i];
    }
  }
  if (check.compare(s)==0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
} 

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}


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

using namespace std;

int main()
{
  string a,b;
  cin >> a >> b;
  a += b;
 int n = a.size();
int flag = 1;
  for(int i = 0;i<b.size();i++)
   if(a[i] != a[n-i-1])
    flag = 0;
if(flag)
cout << "YES";
else
cout << "NO";
return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        for (int i = 1; i <= 100; i++) {
            if ( i * A % B == C) {
                System.out.println( "YES" );
                return;
            } 
        }
        System.out.println( "NO" );
    }
}

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

int main()
{
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  int sum = 0;
  sum += ((N < K) ? N : K)*X;
  sum += ((N <= K) ? 0 : N - K)*Y;
  cout << sum;
  return 0;
}


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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e5;

int x, k;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> k >> x;
    cout << (k * 500 >= x ? "Yes" : "No");
    return 0;
}


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

using namespace std;
typedef long long ll;
const int maxN = (int)1e6 + 10;
int prefD[maxN], prefC[maxN];
int n;
char val[maxN];
void solve(int k) {
    ll ans = 0;
    ll cur = 0;
    for (int i = 1; i + 1 <= n; i++) {
        char from = val[i];
        char to = val[i + 1];
        if (from == 'D') {
            cur += prefC[min(n, i + k - 1)] - prefC[i];
        }
        if (to == 'C') {
            cur -= prefD[i] - prefD[max(0, i - k + 1)];
        }
        if (to == 'M') ans += cur;
    }
    cout << ans << '\n';
}
int main() {
    //freopen("input.txt", "r", stdin);
    srand(239);
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> val[i];
        prefD[i] = prefD[i - 1] + (val[i] == 'D');
        prefC[i] = prefC[i - 1] + (val[i] == 'C');
    }
    int q;
    cin >> q;
    for (int i = 1; i <= q; i++) {
        int k;
        cin >> k;
        solve(k);
    }
    return 0;
}



Measured memory_bytes: 9088
package main

import (
    //b "bufio"
    fm "fmt"
    //o "os"
    //s "strconv"
)

func Grading(m, f, r int) string {

			if m < 0 || f < 0 {
				return "F"
			} else {
				switch {
					case m + f >= 80: return "A"
					case m + f >= 65 && m + f < 80: return "B"
					case m + f >= 50 && m + f < 65: return "C"
					case m + f >= 30 && m + f < 50 && r >= 50: return "C"
					case m + f >= 30 && m + f < 50 && r < 50:  return "D"
					case m + f < 30: return "F"
					default:
				}
			}

	return ""
}

func main() {
	var m, f, r int

	for {	
			fm.Scan(&m)
			fm.Scan(&f)
			fm.Scan(&r)

			if m == -1 && f == -1 && r == -1{
				break
			} 

			fm.Println(Grading(m, f, r))
	}
}


Measured memory_bytes: 1120
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;
map<string,int>memo;

int main(void){
  int n;
  cin >> n;
  
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    memo[s]++;
  }
  
  int maxv = 0;
  for(const auto& x : memo){
    int v = x.second;
    if(maxv < v) maxv = v;
  }
  
  for(auto it = memo.begin(); it != memo.end(); it++){
    if(it->second == maxv){
      cout << it->first << endl;
    }
  }
  
  return 0;
}

    
  

Measured memory_bytes: 25216
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<math.h>
#include <cassert>
using namespace std;
typedef long long ll;
int a[100][100];
int b[110];
int b1[110][110][2];
int n,m,t,t1,ans=0;

void dfs(int x)
{
	if (x == n+1)
	{
		for (int i = 1; i <= m; i++)
		{
			if (b1[x-1][i][1] % 2 != b[i])break;
			if (i == m)ans++;
		}
		for (int i = 1; i <= m; i++)
		{
			if (b1[x-1][i][0] % 2 != b[i])break;
			if (i == m)ans++;
		}
		return;
	}
	for (int i = 1; i <= m; i++)
	{
		b1[x][i][1] = b1[x - 1][i][1] + a[x][i];
		b1[x][i][0] = b1[x - 1][i][1];
	}
	dfs(x + 1);
	if (x != 1)
	{
		for (int i = 1; i <= n; i++)
		{
			b1[x][i][1] = b1[x - 1][i][0] + a[x][i];
			b1[x][i][0] = b1[x - 1][i][0];
		}
		dfs(x + 1);
	}
}
int main()
{
	
	cin >> n>>m;
	for (int i = 1; i <= m; i++)
	{
		scanf("%d", &t);
		for (int j = 1; j <= t; j++)
		{
			scanf("%d", &t1);
			a[t1][i] = 1;
		}
	}
	for (int i = 1; i <= m; i++)
	{
		scanf("%d", &b[i]);
	}
	dfs(1);
	printf("%d", ans);
}

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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> people(n+1, k-q);

  while ( q-- > 0 ) {
    int a;
    cin >> a;
    people[a]++;
  }

  for ( int i = 1; i <= n; i++ ) {
    string ans = ( people[i] > 0 ) ? "Yes" : "No";
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3776
import java.io.{PrintWriter, _}
import java.util._


object Main {
  def main(args: Array[String]): Unit = {
    val inputStream = System.in
    val outputStream = System.out
    val in = new InputReader(inputStream)
    val out = new PrintWriter(outputStream)
    val solver = new Task
    solver.solve(1, in, out)
    out.close()
  }

  class Task {
    def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {
      val s = in.next
      val c = s.indexOf('C')
      val f = s.lastIndexOf('F')
      println(if (c > -1 && f  > -1 && c < f) "Yes" else "No")
    }
  }

  class InputReader(val stream: InputStream) extends AutoCloseable {
    //reader = new BufferedReader(new FileReader(stream), 32768);
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer = new StringTokenizer("")


    def next: String = {
      while ( {
        tokenizer == null || !tokenizer.hasMoreTokens
      }) try
        tokenizer = new StringTokenizer(reader.readLine)
      catch {
        case e: IOException =>
          throw new RuntimeException(e)
      }
      tokenizer.nextToken
    }

    def nextLine: String = {
      try
        return reader.readLine
      catch {
        case e: IOException =>
          e.printStackTrace()
      }
      ""
    }

    def nextInt: Int = next.toInt

    def nextLong: Long = next.toLong

    override def close(): Unit = {
    }
  }

}


Measured memory_bytes: 27336
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        sc.close();

        for (int i = 2001; i <= 2010; i++) {
            x = r * x - d;
            System.out.println(x);
        }

    }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define Data_Nerd ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define files freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
using ll = long long;

const int N = 100, MOD = 1e9 + 7, K = 1e5 + 1;

ll memo_1[K], memo_2[K];

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

	memo_1[0] = 1;

	for(int i = 0, a; i < n; ++i) {
		memset(memo_2, 0, sizeof memo_2);

		scanf("%d", &a);

		for(int num = k; num > -1; --num) {
			int smallest_num_to_take = num + 1;
			int largest_num_to_take = min(num + a, k) + 1;

			memo_2[smallest_num_to_take] = (memo_2[smallest_num_to_take] +
					memo_1[num]) % MOD;

			memo_2[largest_num_to_take] = (memo_2[largest_num_to_take] +
					MOD - memo_1[num]) % MOD;
		}

		ll pref = 0;

		for(int num = 0; num <= k; ++num) {
			pref = (pref + memo_2[num]) % MOD;
			memo_1[num] = (memo_1[num] + pref) % MOD;
		}

	}


	cout << memo_1[k];
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 2e9;
const ld EPS = 1e-8;

int main(){
  int x, y;
  cin >> x >> y;

  int res = INF;
  REP(i,2)REP(j,2) {
    int xi = x * (1 - 2 * i);
    int yj = y * (1 - 2 * j);
    if(xi > yj) continue;
    int tmp = i + j + yj - xi;
    res = min(res, tmp);
  }
  cout << res << endl;
  return 0;
}



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

using namespace std;

int main() {
  string S;
  cin >> S;
  auto y = stoi(S.substr(0,4));
  auto m = stoi(S.substr(5,2));

  bool pred = true;
  if (y > 2019) {
    pred = false;
  } else if (y == 2019 && m > 4) {
    pred = false;
  }

  cout << (pred ? "Heisei" : "TBD") << endl;
  return 0;
}


Measured memory_bytes: 256