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

int main()
{
    int N, M;

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

    cin >> M;
    vector<string> T(M);
    for (int i = 0; i < M; i++)
    {
        cin >> T.at(i);
    }

    int ret = 0;
    for (int i = 0; i < N; i++)
    {
        int r = 0;
        for (int j = 0; j < N; j++)
            if (S.at(i) == S.at(j))
                r++;
        for (int j = 0; j < M; j++)
            if (S.at(i) == T.at(j))
                r--;

        if (ret < r)
            ret = r;
    }

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
// Problem: C - A x B + C
// Contest: AtCoder - AtCoder Beginner Contest 179
// URL: https://atcoder.jp/contests/abc179/tasks/abc179_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define deb(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

vector<ll> a;
ll numDiv(ll N) {
    ll i = 0, f = a[i], ans = 1;
    
    while (f*f <= N) {
        ll ex = 0;
        while (N % f == 0) {
            N /= f;
            ex++;
        }
        
        ans *= (ex + 1);
        f = a[++i];
    }
    
    if (N != 1) {
        ans *= 2;
    }
    
    return ans;
}

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    bool sieve[1000005] = {};
    

    
    for (ll i = 2; i < 1000005; ++i) {
        sieve[i] = true;
    }
    
    for (ll i = 2; i*i < 1000005; ++i) {
        if (sieve[i]) {
            a.pb(i);
            for (ll j = i+i; j < 1000005; j += i) {
                sieve[j] = false;
            }
        } else {
            continue;
        }
    }
    
    for (ll i = a[a.size()-1]+1; i < 1000005; ++i) {
        if (sieve[i]) {
            a.pb(i);
        }
    }
    
    ll n;
    cin >> n;
    
    // ab = n-c
    
    ll res = 0;
    
    for (ll c = n-1; c > 0; --c) {
        ll ab = n-c;
        res += numDiv(ab);
    }
    
    cout << res << endl;
    
	return 0;
}

Measured memory_bytes: 5228
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest20191112
{
    class Program
    {
        static void Main(string[] args)
        {
            string sInput = Console.ReadLine();
            int[] s = new int[sInput.Length];
            int count = 0;

            for (int i = 0; i < sInput.Length; i++) 
            {
                s[i] = int.Parse(sInput.Substring(i , 1));
            }


            for (int i = 0; i < s.Length - 1; i++)
            {
                if (s[i] + s[i + 1] == 0)
                {
                    s[i + 1] = 1;
                    count++;
                }
                else if (s[i] + s[i + 1] == 2) 
                {
                    s[i + 1] = 0;
                    count++;
                }

            }

            Console.WriteLine(count);
            

        }
    }
}


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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.14159265;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' '; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
	vi a;
    cin >> n;
    for (int i=0;i<n;++i){
      cin >> m;
      a.push_back(m);
    }
    sort(ALL(a));
    REP(j,n-1) {
        if (a[j] == a[j+1]) {
          cout << "NO" << endl;
          return 0;
        }
      }
  cout << "YES" << endl;
}


Measured memory_bytes: 2420
#include <bits/stdtr1c++.h>
// typedef __int128 int128;
// typedef __float128 float128;

using namespace std;
using namespace rel_ops;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ld> vd;
typedef vector<vd> vvd;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;
#define pb push_back


int main(){

  // freopen("A.in", "r", stdin);

  ll N;
  cin >> N;

  ll K;
  cin >> K;

  ll h[100010], prev[100010];
  for (ll i = 1; i <= N; i++) {
    cin >> h[i];
    if(i == 1) continue;
    prev[i] = prev[i-1] + abs(h[i] - h[i-1]);
    for (ll j = 2; j <= K && i - j > 0; j++) {
      prev[i] = min(prev[i], prev[i - j] + abs(h[i] - h[i - j]));
    }

  }

  cout << prev[N] << endl;


}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n;
    cin>>n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin>>s;
        mp[s]++;
    }
    int ans=0;
    for(auto& v: mp) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 19228
A, B, C, D = map(int, input().split())


def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


def lcm(x, y):
    return x * y // gcd(x, y)


# A以上B以下の整数の総数から「Cで割り切れる または Dで割り切れる」数の総数を引く
s = B - A + 1
# print(s)

# Cで割り切れる数
c = B // C - (A - 1) // C

# Dで割りきれる数
d = B // D - (A - 1) // D

# CとDで割り切れる数
candd = B // lcm(C, D) - (A - 1) // lcm(C, D)

# CまたはDで割りきれる数
cord = c + d - candd

s -= cord
# print(s, c, d, candd, cord, s)
print(s)


Measured memory_bytes: 3060
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val (n, m) = nextListOfInt()

    //グラフ入力受け取り
    val graph  = (0 until n).map{ mutableListOf<Int>()}
    for(i in 0 until m){
        val (a, b) = nextListOfInt()
        graph[a-1].add(b-1)
        graph[b-1].add(a-1)
    }

    //BFSの為のデータ構造
    val dist = Array(n){ -1 }
    val que = LinkedList<Int>()

    val ans = Array(n){-1}

    //初期条件(頂点0を初期ノードに)
    dist[0] = 0
    que.add(0)

    //BFS
    while(que.isNotEmpty()){
        val v = que.poll()!!

        for(nv in graph[v]){
            if(dist[nv] != -1) continue //発見済み

            //未発見の頂点nvの距離情報を追加してキューに追加
            dist[nv] = dist[v] + 1
            ans[nv] = v + 1
            que.add(nv)
        }
    }

   // for(v in 0 until n){
   //     println("${v+1} : ${dist[v]}")
   // }

    if(dist.all { it != -1 }){
        println("Yes")
        for(i in 1 until n){
            println(ans[i])
        }
    }else{
        println("No")
    }

}

fun abc000a() {

}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }

Measured memory_bytes: 82164
using System;
 
namespace AOJ
{
    class DigitNumber
    {
        public static void Main(string[] args)
        {
            for (int i = 0; i < 200; i++)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }
 
                var tmp = input.Split(' ');
 
                int test = int.Parse(tmp[0]) + int.Parse(tmp[1]);
                Console.WriteLine(test.ToString().Length);
            }
        }
    }
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        VI A(n);
        FOR(i,0,n)
            cin >> A[i];
        sort(ALL(A)); vector<PII> step;
        if (A[n-1] > 0) {
            int j = 1;
            while (j < n-1 && A[j] < 0)
                j++;
            FOR(k,j,n-1) {
                const int x = A[0];
                const int y = A[k];
                A[0] = x-y;
                step.push_back(PII(x,y));
            }
            FOR(i,0,j) {
                const int x = A[n-1];
                const int y = A[i];
                A[n-1] = x-y;
                step.push_back(PII(x,y));
            }
        }
        else {
            const int x = A[n-1];
            const int y = A[n-2];
            A[n-1] = x-y;
            step.push_back(PII(x,y));
            FOR(i,0,n-2) {
                const int x = A[n-1];
                const int y = A[i];
                A[n-1] = x-y;
                step.push_back(PII(x,y));
            }
        }
        cout << A[n-1] << endl;
        FOR_ALL(x,step)
            cout << x->first << ' ' << x->second << endl;
    }
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

vector<vector<int> > G;
int dp[100100],flag[100100];

int f(int x){
    if(flag[x])return dp[x];
    flag[x]=1;
    int res=0;
    for(auto y:G[x]){
        res=max(res,f(y)+1);
    }
    return dp[x]=res;
}

int main(){
    int N,M;
    cin >> N >> M;
    G.assign(N,vector<int>());
    rep(i,M){
        int a,b;cin >> a >> b;
        G[--a].push_back(--b);
    }
    int res = 0;
    for(int i=0;i<N;i++)res = max(res,f(i));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8576
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
int main() {
	string s;
	cin >> s;
	vector<string>c = { "dream","dreamer","erase","eraser" };
	reverse(s.begin(), s.end());
	for (int i = 0; i < 4; i++) {
		reverse(c[i].begin(), c[i].end());
	}
	
	for (int i = 0; i < s.size();) {
		bool can = false;
		for (int j = 0; j < 4; j++) {
			string d = c[j];
			if (s.substr(i, d.size()) == d) {
				can = true;
				i += d.size();
				break;
			}
		}
		if (!can) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 512
N,M  = map(int, input().split())

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


Road = []
for i in range(N):
  Road.append(0)


for i in range(M):
  A,B   = map(int, input().split())
  if H[A-1] >= H[B-1]:
    Road[B-1] = 1
  if H[A-1] <= H[B-1]:
    Road[A-1] = 1


print(Road.count(0))

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int i;
	for (i = 0; i < n - 8; i++) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int L = sc.nextInt();
        int R = sc.nextInt();
        int D = sc.nextInt();
        for(int i=L;i<=R;i++){
            if(i%D==0)ans++;
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 35600
X,Y = map(int,input().split())

X_aaa=0
Y_aaa=0

if X ==1 and Y ==1:
    print(1000000)
    exit()

if X==1 :
    X_aaa+=300000
elif X==2 :
    X_aaa+=200000
elif X==3 :
    X_aaa+=100000

if Y==1 :
    Y_aaa+=300000
elif Y==2 :
    Y_aaa+=200000
elif Y==3 :
    Y_aaa+=100000

print(X_aaa+Y_aaa)

Measured memory_bytes: 3064
n,m = map(int, input().split())
ab = [[] for _ in range(n)]
for _ in range(m):
  a,b = map(lambda i: int(i)-1, input().split())
  ab[a].append(b)
  ab[b].append(a)

for i in ab[0]:
  if ab[i].count(n-1) >= 1:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")

Measured memory_bytes: 41756
#include <iostream>

using namespace std;

const int maxn = 1e5 + 9;
int n, m, maxL, minR;

void Enter()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n >> m;
    maxL = -1, minR = INT_MAX;
    for (int i = 1, l, r; i <= m; i++)
    {
        cin >> l >> r;
        maxL = max(maxL, l);
        minR = min(minR, r);
    }
}

void Solve()
{
    if (maxL <= minR)
        cout << minR - maxL + 1;
    else
        cout << 0;
}

int main()
{
    Enter();
    Solve();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
divisors = []

for i in range(1, int(N**0.5)+1):
  if N % i == 0:
    divisors.append(i)
    if i != N // i:
      divisors.append(N//i)

divisors.sort()
ans = []
j_list = []

for j in divisors:
  if int(N/j) in j_list:
    break
  ans.append(j+int(N/j)-2)
  j_list.append(j)

print(min(ans))


Measured memory_bytes: 3424
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define xrep(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define vl vector<long long>
#define vs vector<string>

int main() {
    vl A(3);
    rep(i,3){
        cin >> A[i];
    }

    sort(A.begin(),A.end());

    if(A[0] == 5 && A[1] == 5 && A[2] == 7){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;i++)
#define ft(i,x,y) for(int i=x;i<y;i++)
#define frd(i,x,y) for(int i=y;i>=x;i--)
#define ii pair<int,int>
#define in freopen("test.inp","r",stdin)
#define out freopen("test.out","w",stdout)
#define fi first
#define se second
#define add push_back
#define ad push
#define ll long long
using namespace std;
ll n,m ;
ll dd[200001],par[200001],sum,res[200001],cnt;
typedef struct
{
    int id;
    int x;
    int y;
}chiendaica;
chiendaica a[200001];
struct oo
{
    int u,v;
    ll w ;
}ed[200001];
bool cmp1(chiendaica u,chiendaica v)
{
    return u.x<v.x;
}
bool cmp2(chiendaica u,chiendaica v)
{
    return u.y<v.y;
}
bool cmp(oo u,oo v)
{
    return u.w<v.w;
}
int Find(int u)
{
    while(par[u] != u)
        u = par[u] ;
    return par[u];
}
bool join(int u,int v)
{
    int x = Find(u) ;
    int y = Find(v) ;
    if( x == y )
        return false;
    if(dd[x] < dd[y])
        par[x] = y;
    else
    {
        par[y] = x;
        if(dd[x] == dd[y] )
            dd[x] ++;
    }
    return true;
}
int main()
{

    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].x>>a[i].y;
        a[i].id=i;
    }
    cnt=0;
    sort(a+1,a+n+1,cmp1);
    for(int i=2;i<=n;i++)
    {
        cnt++;
        ed[cnt].u=a[i-1].id;
        ed[cnt].v=a[i].id;
        ed[cnt].w=a[i].x-a[i-1].x;
    }
    sort(a+1,a+n+1,cmp2);
    for(int i=2;i<=n;i++)
    {
        cnt++;
        ed[cnt].u=a[i-1].id;
        ed[cnt].v=a[i].id;
        ed[cnt].w=a[i].y-a[i-1].y;
    }
    sort(ed + 1, ed+cnt+1,cmp) ;
    for(int i=1; i<=n+1; i++)
    {
        par[i]=i;
        dd[i]=0;
    }
    int tg;
    for(int i=1; i<=cnt; i++)
    {
        int u = ed[i].u, v = ed[i].v ;
        if(join(u,v))
        {
            tg ++ ;
            sum += ed[i].w;
            if(tg == n -1 )
                break;
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 9216
N = int(input())

def dfs(s): # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方な

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

int main()
{
   ll a,b,c,k;
   cin>>a>>b>>c>>k;

   ll sum=0;

   if(k<=a)
    sum=k;

   else
   {
      int m=k-a;
      sum+=a;
      if(m>b)
      {
          int n=m-b;
          sum-=n;
      }

   }

   cout<<sum;

    return 0;
}


Measured memory_bytes: 3616
n = gets.to_i
s = n.times.map {gets.chomp}

dp = Array.new(n) {Array.new(n, 10000)}
s.each_with_index do |e, i|
    dp[i][i] = 0
    e.each_char.with_index {|c, j| dp[i][j] = 1 if c == ?1}
end

n.times do |k|
    n.times do |i|
        n.times do |j|
            dp[i][j] = dp[i][k] + dp[k][j] if dp[i][j] > dp[i][k] + dp[k][j]
        end
    end
end

x = Array.new(n)
x[0] = true
que = [0]
while y = que.shift
    s[y].each_char.with_index do |c, i|
        next if c == ?0
        if x[i].nil?
            x[i] = x[y] ^ true
            que << i
        elsif !(x[i] ^ x[y])
            puts -1
            exit
        end
    end
end

#dp.each {|e| p e}
puts dp.map(&:max).max + 1

Measured memory_bytes: 2300
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("fail");
    let vec: Vec<&str> = buf.split_whitespace().collect();
    let a: u32 = vec[0].parse().unwrap();
    let b: u32 = vec[1].parse().unwrap();
    if a > 9 || b > 9 {
        println!("-1");
    } else {
        println!("{}", a * b);
    }
}


Measured memory_bytes: 4352
S=input()
if S[0]!="k":
    if S[-7:]!="keyence":
        print("NO")
else:
    if S[:7]=="keyence":
        print("YES")
    elif S[:6]=="keyenc":
        if S[-1:]=="e":
            print("YES")
        else:
            print("NO")
    elif S[:5]=="keyen":
        if S[-2:]=="ce":
            print("YES")
        else:
            print("NO")
    elif S[:4]=="keye":
        if S[-3:]=="nce":
            print("YES")
        else:
            print("NO")
    elif S[:3]=="key":
        if S[-4:]=="ence":
            print("YES")
        else:
            print("NO")
    elif S[:2]=="ke":
        if S[-5:]=="yence":
            print("YES")
        else:
            print("NO")
    elif S[0]=="k":
        if S[-6:]=="eyence":
            print("YES")
        else:
            print("NO")

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  string S;
  cin >> S;

  string ans = "Yes";
  // 0-index
  for (ll i = 0; i < S.length(); i++) {
    if (i % 2 == 0) {
      if (S[i] == 'L') {
        ans = "No";
      }
    } else {
      if (S[i] == 'R') {
        ans = "No";
      }
    }
  }

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


Measured memory_bytes: 384
object Main extends App {
	val q = scala.io.StdIn.readInt
	val ans = new Array[Long](q)

	for(i<-0 until q){
		val Array(a, b) = scala.io.StdIn.readLine.split(" ").map(_.toLong)

		val x = math.min(a,b)
		val y = math.max(a,b)

		if(x == y){
			ans(i) = 2L*x - 2L
		}else if(x+1L == y){
			ans(i) = 2L*x - 2L
		}else{
			lazy val z = {
				val tp = math.sqrt(a*b).toLong
				if(tp*tp == a*b){
					tp - 1L
				}else{
					tp
				}
			}

			if(z*(z+1L) >= x*y){
				ans(i) = 2L*z - 2L
			}else{
				ans(i) = 2*z - 1L
			}
		}

		
	}

	for(x<-ans){
		println(x)
	}
}

Measured memory_bytes: 27312
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Vector;

public class Main extends Thread {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int a=sc.nextInt();
		int b=a;
		int sum=0;
		while(a!=0){
			sum+=a%10;
			a/=10;
		}
		if(b%sum==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
ll A[200000+1];

int main()
{
    ll n,i;
    cin >> n;
    string a[n];
    ll b[n];
    cn(a,n);
    sort(a,a+n);
   //map<string,ll>m;
   // ov(a,n);
   ll cnt=1;
   b[0]=1;
   for(i=1;i<n;i++)
   {
      if(a[i]==a[i-1]) 
        cnt++;
        else
        {
         //   b[i]=cnt;
            cnt=1;
        }
         b[i]=cnt;
   }
   ll x;
   x=maxa(b,n);
   
   for(i=0;i<n;i++)
   {
       if(b[i]==x)
       {
           cout << a[i] << endl;
       }
   }
    
        
    
   }
    
    

    
    
    

Measured memory_bytes: 15872
A = int(input())
rist = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(rist[A-1])

Measured memory_bytes: 3060
// ABC179C - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

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

	ull ans = 0;
	for (int i = 1; i <= N - 1; i++) {
//		cout << (N - 1) / i << endl;
		ans += (N - 1) / i;
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
 int n;
 cin >> n;
 int l , r;
 int sum = 0;
 for(int i = 0;i < n;++i){
   cin >> l >> r;
   sum += r + 1 - l;
 }
 cout << sum << endl;
}

  

  


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint p(n);
    REP(i,n){
        cin >> p[i];
    }
    int ans = 0;
    REP(i,n-2){
        if(p[i]<p[i+1]&&p[i+1]<p[i+2]){
            ans++;
        }else if(p[i]>p[i+1]&&p[i+1]>p[i+2]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

long pow2[60];

long R(long x, int l){
  if(l==1){
    if(x==1)return 0;
    if(x<=4)return x-1;
    if(x==5)return 3;
  }
  if(x==1)return 0;
  if(x<=pow2[l+1]-2)return R(x-1, l-1);
  if(x==pow2[l+1]-1)return pow2[l];
  if(x<=pow2[l+2]-4)return pow2[l]+R(x-pow2[l+1]+1, l-1);
  if(x==pow2[l+2]-3)return pow2[l+1]-1;
}

int main(){
  pow2[0]=1;
  for(int i=1; i<60; i++){
    cerr << pow2[i-1] << endl;
    pow2[i]=2*pow2[i-1];
  }
  long n, x;
  cin >> n >> x;
  cout << R(x, n);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define f(i,a,b) for(int i=(a);i<(b);++i)
#define rush() int T;scanf("%d",&T);while(T--)
typedef long long ll;
const int maxn= 100005;
const ll mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;

int a[maxn];
int ans,flag;
map<int,int>mp;

void fun(int n)
{
    if(n==2)
    {
        flag=1;
        return;
    }
    if(mp[n]>1)
        return;
    mp[n]++;
    ans++;
    n=a[n];
    fun(n);
}

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        mp.clear();
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        ans=0;
        flag=0;
        fun(1);
        if(flag)
            printf("%d\n",ans);
        else puts("-1");
    }
}

Measured memory_bytes: 13184
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#define _USE_MATH_DEFINES

#include<math.h>
#include<unordered_map>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	int n[30] = { 0 };

	string s;

	while (getline(cin, s))
	{
		for (auto& c : s)
		{
			if ('a' <= c&&c <= 'z')
			{
				n[c - 'a']++;
			}
			else if ('A' <= c&&c <= 'Z')
			{
				n[c - 'A']++;
			}
		}
	}

	for (int i = 0; i < 26; i++)
	{
		printf("%c : %d\n", 'a' + i, n[i]);
	}

	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  string s;
  cin >> s;
  vector<bool> used(26);
  for (char &c : s) used[c-'a'] = true;
  for (int i = 0; i < 26; i++) {
    if (used[i]) continue;
    cout << (char)('a'+i) << '\n';
    return 0;
  }
  cout << "None" << '\n';
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int T;
  cin >> N >> T;
  vector<int> c(N);
  vector<int> t(N);
  
  for(int i=0;i<N;i++)
    cin >> c[i] >> t[i];
  
  vector<int> erabaresic;
  for(int i=0;i<N;i++){
    if(t[i]<=T){
      erabaresic.push_back(c[i]);
    }
  }
  if(erabaresic.size()==0)
    cout << "TLE";
  else
    cout << *min_element(erabaresic.begin(),erabaresic.end());
}

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



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

    int res;

    vector <int> a(n);
    vector <int> c(n);
    vector <int> ix(n);
    for (int i=0; i<n; i++)
        cin >> a[i], a[i]--;





                ix[0] = 1;

                int st = a[0];  k--;
                if (!k) {cout << st+1; return 0;}
                int cnt = 2;
                while (ix[st]==0){  ix[st] = cnt;   st = a[st]; cnt++; k--; if (!k) {cout << st+1; return 0;}}
                c[st] = cnt - ix[st];

                //cout << st << " " << c[st] << "\n";

                k%=c[st];
                while (k){k--; st = a[st];}
                    cout << st+1;

   // cout << (5&(1<<1)!=0)  << "\n"  << ((5&(1<<1))!=0);      why??






}


Measured memory_bytes: 5636
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=(1<<21);
main(){
  int n,m,h;
  int from,to,cost,time;
  int roadmoney[101][101];
  int roadtime[101][101];
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)break;
    for(int i=0;i<=m;i++){
      for(int j=0;j<=m;j++){
	roadmoney[i][j]=INF;
	roadtime[i][j]=INF;
      }
    }
    for(int i=0;i<n;i++){
      cin>>from>>to>>cost>>time;
      roadmoney[from][to]=roadmoney[to][from]=cost;
      roadtime[from][to]=roadtime[to][from]=time;
    }
    for(int i=1;i<=m;i++){
      for(int j=1;j<=m;j++){
	for(int k=1;k<=m;k++){
	  roadmoney[j][k]=min(roadmoney[j][k],roadmoney[j][i]+roadmoney[i][k]);
	  roadtime[j][k]=min(roadtime[j][k],roadtime[j][i]+roadtime[i][k]);
	}
      }
    }
    cin>>h;
    int q,p,r;
    for(int i=0;i<h;i++){
      cin>>q>>p>>r;
      if(r==0){
	cout<<roadmoney[q][p]<<endl;
      }
      else{
	cout<<roadtime[q][p]<<endl;
      }
    }
  }
}

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


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = arr[0], M = arr[1];
            var indexes = new int[N];
            var list = new List<Tuple<int, int, int, int>>();
            for (int i = 0; i < M; i++)
            {
                arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                list.Add(Tuple.Create(arr[0] - 1, arr[1], i, 0));
            }

            list.Sort((val1, val2) => val1.Item2 - val2.Item2);
            for (var i = 0; i < list.Count; i++)
            {
                list[i] = Tuple.Create(list[i].Item1 + 1, list[i].Item2, list[i].Item3, ++indexes[list[i].Item1]);
            }

            list.Sort((val1, val2) => val1.Item3 - val2.Item3);
            list.ForEach(val => Console.WriteLine($"{val.Item1:D6}{val.Item4:D6}"));
        }
    }
}

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

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    k--;
    s[k] = tolower(s[k]);
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  int N, M; std::cin >> N >> M;
  std::vector<std::vector<char>> A(N, std::vector<char>(N));
  std::vector<std::vector<char>> B(M, std::vector<char>(M));

  for(int i=0; i<N; i++) for(int j=0; j<N; j++) std::cin >> A[i][j];
  for(int i=0; i<M; i++) for(int j=0; j<M; j++) std::cin >> B[i][j];

  if( N == M ) {
    for(int i=0; i<N; i++) {
      for(int j=0; j<M; j++) {
        if ( A[i][j] != B[i][j] ) {
          std::cout << "No" << std::endl;
          return 0;
        }
      }
    }
    std::cout << "Yes" <<std::endl;
    return 0;
  }
  for(int i=0; i<N-M; i++) {
    for(int j=0; j<N-M; j++) {

      bool check = true;
      for(int k=0; k<M; k++) {
        for(int l=0; l<M; l++) {
          if ( B[k][l] != A[i+k][j+l] ) check = false;
          if(false) break;
        }
        if(false) break;
      }
      if(check){
        std::cout << "Yes" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "No" << std::endl;

  return 0;
}

Measured memory_bytes: 256
import sys
m,k = map(int, input().split( ))
if k>=2**m:
    print(-1)
    sys.exit()
if m==1:
    if k ==0:
        print(0,0,1,1)
    else:
        print(-1)
    sys.exit()
if m==0:
    print(0,0)
    sys.exit()
    
    
for i in range(2**m-1,-1,-1):
    if i!=k:
        print(i,end = " ")
print(k, end = " ")
for i in range(2**m):
    if i!=k:
        print(i, end = " ")
print(k)
    


Measured memory_bytes: 52440
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

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

    // 1 2 3 4 5 6 7 8 9

    // 10 11 12 
    // 21 22 23
    // 87 88 89
    // 98 99

    // 100 101 110 111 112 121 122 123
    // 210 211 212 221 222 223 232 233 234
    // 321 322 323 332 333 334 343 344 345
    // 876 877 878 887 888 889 898 899
    // 987 988 989 998 999

    // 末尾09 -> 2 その他 -> 3

    queue<ll> que;
    REP(i, 9) que.push(i + 1);
    ll cnt = 1;
    while (1) {
        ll cur = que.front();
        que.pop();
        if (cnt == k) {
            cout << cur << endl;
            return 0;
        }
        ll back = cur % 10, nxt = 10 * cur + back;
        if (back != 0) que.push(nxt - 1);
        que.push(nxt);
        if (back != 9) que.push(nxt + 1);
        cnt++;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
    
int main(){
    ll N; cin >> N;
    vvi f(N, vi(10, 0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> f[i][j];
        }
    }
    vvl p(N, vl(11, 0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= 10; j++) {
            cin >> p[i][j];
        }
    }
    
    ll ret = -LINF;
    for (int i = 1; i < 1 << 10; i++) {
        vi c(N, 0);
        for (int j = 0; j < 10; j++) {
            if(i >> j & 1){
                for (int k = 0; k < N; k++) {
                    if(f[k][j] == 1){
                        c[k]++;
                    }
                }
            }
        }
        ll tmp = 0;
        for (int j = 0; j < N; j++) {
            tmp += p[j][c[j]];
        }
        ret = max(ret, tmp);
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 256
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
   

void add_self(int &a, int b){
   a += b;
   a %= mod;
}

int main(){
   IOS

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

   vi a(m);
   for(int & x : a)cin>>x;

   vi dp(n+1);
   dp[0] = 1;
  
   for(int i = 0; i < m; i++)dp[a[i]] = -1;

   for(int i = 1; i <= n; i++){
      if(dp[i] == -1)continue;
      if(dp[i-1] != -1)
         add_self(dp[i], dp[i-1]);
      if(dp[i-2] != -1)
         add_self(dp[i], dp[i-2]);
      }

      cout<<dp[n]<<"\n";


}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
   if(b&1)
       res = res * a % mod;
        a = a * a % mod;
   b >>= 1;
    }

    return res;
}



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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 1;
    REP(i, N) {
        ans = ans * (i + 1) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int res=0,i,n,j,k;
    cin>>n;
    int x=n;
    while(n!=0)
    {
        int r=n%10;
        n=n/10;
        res=res+r;
    }
    if(x%res==0)cout<<"Yes"<<'\n';

   else  cout<<"No"<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int H, W;
int Ch, Cw;
int Dh, Dw;
bool ok = false;
vector<vector<char>> S(1010, vector<char>(1010));
vector<vector<bool>> used_magic(1010, vector<bool>(1010, false));
int dx[4] = {-1, 0, 1, 0 };
int dy[4] = {0, -1, 0, 1 };
queue<P> q1;  //Bを使わず行ける場所用
queue<P> q2;  //Bを使って行ける場所用

int main(){
    cin >> H >> W;
    cin >> Ch >> Cw;
    cin >> Dh >> Dw;

    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++) cin >> S[i][j];
    }

    /*以下処理*/

    q1.push({Ch, Cw}); used_magic[Ch][Cw] = true;
    int res = 0, px, py, npx, npy;
    P p;

    while(true){
        while(!q1.empty()){
            p = q1.front(); q1.pop(); //座標を取得
            q2.push(p);  //実はpで魔法を使って行ける座標はまだ洗ってない
            px = p.first, py = p.second;
            if(px == Dh && py == Dw){ ok = true; break; }  //到達

            for(int i = 0; i < 4; i++){
                npx = px+dx[i], npy = py+dy[i];  //行き先

                if(npx < 1 || npx > H) continue;
                if(npy < 1 || npy > W) continue;
                if(S[npx][npy] == '#') continue;

                /*px,pyから行けるので...*/
                if(used_magic[npx][npy]) continue;
                used_magic[npx][npy] = true;
                q1.push({npx, npy});
                q2.push({npx, npy});
            }
        }

        if(ok) break;  //目的地に到達

        while(!q2.empty()){
            p = q2.front(); q2.pop();
            px = p.first, py = p.second;

            for(int i = -2; i <= 2; i++){
                for(int j = -2; j <= 2; j++){
                    npx = px+i, npy = py+j;
                    if(npx < 1 || npx > H) continue;
                    if(npy < 1 || npy > W) continue;
                    if(S[npx][npy] == '#') continue;

                    if(used_magic[npx][npy]) continue;
                    used_magic[npx][npy] = true;
                    q1.push({npx, npy});  //へだたりワープ
                }
            }
        }

        if(q1.empty()){ res = -1; break; } //辿り着けないかつ行ける場所無し
        ++res;
    }

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

Measured memory_bytes: 4852
N = int(input())
a = list(map(int, input().split()))
s_right = [0] * (N + 1)
s_left = [0] * (N + 1)
for i in range(N):
    s_left[i + 1] = s_left[i] + a[i]
    s_right[i + 1] = s_right[i] + a[N - 1 - i]
ans = float('Inf')
for i in range(1, N):
    #print(ans)
    if ans > abs(s_left[i] - s_right[N - i]):
        ans = abs(s_left[i] - s_right[N - i])
print(ans)


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

int main() {
    string s; cin >> s;
    int A = 0;
    ll ans = 0;
    for (int i = 0; i < s.length() - 1; i++) {
        if (s[i] == 'A') {
            A++;
        } else if (s[i] == 'B' && s[i+1] == 'C') {
            ans += A;
            i++;
        } else {
            A = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <set>

using namespace std;

int main() {
  int64_t a, b;
  cin >> a >> b;
  int ans = 1;
  set<int64_t> set;
  auto n = min(a, b);
  auto m = max(a, b);
  for (int64_t i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      if (set.find(i) == set.end()) {
        if (m % i == 0) ans++;
        set.insert(i);
      }
      n /= i;
    }
  }
  if (n != 1 && m % n == 0) ++ans;
  cout << ans << endl;
  return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  double r;
  cin >> r;

  r *= (2 * M_PI);

  cout << r << endl;

};


Measured memory_bytes: 3808
#include <iostream>
#include <algorithm>
#include <queue>

const int MAX_K = 5005;
const int MAX_LEN = 5005;
const int INF = 1023456789;

using namespace std;

int arr [MAX_LEN], last [MAX_K];

bool unnecessary (int number, int k, int length) {
  if (arr[number] >= k) {
    return false;
  }

  for (int i = 0; i < MAX_K; i++) {
    last[i] = INF;
  }
  last[0] = -1;

  for (int i = 0; i < k; i++) {
    for (int j = last[i] + 1; j < length; j++) {
      if (j != number && i + arr[j] < k) {
        last[i + arr[j]] = min(last[i + arr[j]], j);
      }
    }
  }

  bool flag = false;
  for (int i = k - arr[number]; i < k; i++) {
    if (last[i] < INF) {
      flag = true;
    }
  }

  return !flag;
}

int main () {
  int length, k;
  cin >> length >> k;

  for (int i = 0; i < length; i++) {
    cin >> arr[i];
  }

  sort(arr, arr + length, greater<int>());
  
  if (unnecessary(0, k, length)) {
    cout << length << endl;
  } else {
    int ans = 0;
    for (int i = 1 << 13; i > 0; i /= 2) {
      int cur = ans + i;
      if (cur < length && !unnecessary(cur, k, length)) {
        ans = cur;
      }
    }
    cout << length - (ans + 1) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 500000

int parent(int i) {return i / 2;}
int left(int i) {return i * 2;}
int right(int i) {return i * 2 + 1;}

int H;

void maxHeapify(int A[], int i) {
  int l = left(i);
  int r = right(i);
  int max_index;
  if (l <= H && A[l] > A[i]) {
    max_index = l;
  } else {
    max_index = i;
  }
  if (r <= H && A[r] > A[max_index]) {
    max_index = r;
  }

  if (max_index != i) {
    swap(A[i], A[max_index]);
    maxHeapify(A, max_index);
  }
}

void buildMaxHeap(int A[]) {
  for (int i = H/2; i > 0; i--) {
    maxHeapify(A, i);
  }
}

int main() {
  int A[MAX+1];
  cin >> H;
  for (int i = 1; i <=H; i++) {
    cin >> A[i];
  }
  buildMaxHeap(A);
  for (int i = 1; i <=H ; i++) {
    cout << " " << A[i];
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 4952
from collections import defaultdict
from sys import stdin
input = stdin.readline


def main():
  N, X, Y = list(map(int, input().split()))

  dic = defaultdict(int)
  for l in range(1, N):
    for r in range(l+1, N+1):
      spath = r - l
      if l <= X and Y <= r:
        spath -= (Y-X-1)
      elif l <= X and X < r <= Y:
        spath = min(spath, X-l+1+Y-r)
      elif X <= l < Y and Y <= r:
        spath = min(spath, l-X+1+r-Y)
      elif X < l < Y and X < r < Y:
        spath = min(spath, l-X+1+Y-r)
      dic[spath] += 1

  for k in range(1, N):
    print(dic[k])


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 75504
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i;
	string s;
	cin >> s;
	if (s == "ABC")
		printf("ARC\n");
	else
		printf("ABC\n");
	return 0;
}

Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int a,b,t; cin>>a>>b>>t;
    cout<<t/a*b<<endl;
}

Measured memory_bytes: 256