akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 using  namespace  std; 
#define int long long 
int32_t  main()
{
 int n, m,s1=0,k=1e18,i,j; cin>>n; 
 int a[n];
 for(i=0;i<n;i++)
 {
  cin>>a[i];if(a[i]==0) s1++;}
 if(s1>0) cout<<"0";
else 
{
  int p=1;bool hi=true;
 for(i=0;i<n;i++)
 { 
  if(p>k/a[i]) {hi=false;break;} p=p*a[i];
}
 if(hi) cout<<p; 
 else cout<<"-1";}
}


Measured memory_bytes: 4360
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for l in range(n)]
a = a[0] + a[1] + a[2]
A = [False]*9
for h in range(len(a)):
  A[h] = a[h] in b
flag = 'No'
for k in range(3):
  if A[k*3] ==  A[k*3+1] ==  A[k*3+2] == True:
    flag = 'Yes'
  if A[k] == A[k+3] ==  A[k+6] == True:
    flag = 'Yes'
  if A[0] ==  A[4] == A[8] == True:
    flag = 'Yes'
  if A[2] ==  A[4] ==  A[6] == True:
    flag = 'Yes'
print(flag)

Measured memory_bytes: 3064
using System;
class Program
{
    static void Main(string[] args)
    {
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int b = int.Parse(input[0]);
        int c = int.Parse(input[1]);
        int d = int.Parse(input[2]);
        int e = int.Parse(input[3]);
        if (b + c == d + e)
        {
            Console.WriteLine("Balanced");
        } else if((b + c > d + e))
        {
            Console.WriteLine("Left");
        }
        else
        {
            Console.WriteLine("Right");
        }
    }
}

Measured memory_bytes: 11092
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
acac
acm

output:
2
"""

import sys


def solve():
    dp = [[0] * (len_w2 + 1) for _ in range(len_w1 + 1)]

    for i in range(len_w1 + 1):
        for j in range(len_w2 + 1):
            if not i:
                dp[i][j] = j
            elif not j:
                dp[i][j] = i

            elif w1[i - 1] == w2[j - 1]:
                dp[i][j] = dp[i - 1][j - 1]

            else:
                dp[i][j] = min(dp[i][j - 1], dp[i - 1][j], dp[i - 1][j - 1]) + 1

    return dp[-1][-1]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    w1, w2 = _input
    len_w1, len_w2 = len(w1), len(w2)
    print(solve())

Measured memory_bytes: 43688
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
const lld MAXQ = 1e5;

int main()
{
	string s,t;
	lld q,a[MAXQ] = {0},b[MAXQ] = {0},c[MAXQ] = {0},d[MAXQ] = {0};

	cin >> s >> t;
	cin >> q;
	for(int i = 0; i < q; i++)
	{
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	lld ss[MAXQ+1] = {0},tt[MAXQ+1] = {0};

	if (s[0] == 'A')
	{
		ss[1] = 1;
	}else
	{
		ss[1] = 2;
	}

	for(int i = 1; i < s.size(); i++)
	{
		if (s[i] == 'A')
		{
			ss[i+1] += ss[i] + 1;
		}else
		{
			ss[i+1] += ss[i] + 2;
		}

		//cout << ss[i+1] << endl;
	}

	if (t[0] == 'A')
	{
		tt[1] = 1;
	}else
	{
		tt[1] = 2;
	}

	for(int i = 1; i < t.size(); i++)
	{
		if (t[i] == 'A')
		{
			tt[i+1] += tt[i] + 1;
		}else
		{
			tt[i+1] += tt[i] + 2;
		}
	}

	for(int i = 0; i < q; i++)
	{
		lld qs = ss[b[i]] - ss[a[i] - 1];
		//cout << qs << endl;
		lld qt = tt[d[i]] - tt[c[i] - 1];
		//cout << qt << endl;

		qs %= 3,qt %= 3;

		if (qs == qt)
		{
			cout << "YES" << endl;
		}else
		{
			cout << "NO" << endl;
		}
	}

	return 0;
}
	

Measured memory_bytes: 5632
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010;
int main(){
	int n;cin>>n;
	ll x[200010],y[200010];
	ll ma=-1,mi=INF;int miid;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i];
		if(x[i]<y[i])swap(x[i],y[i]);
		if(ma<x[i]){
			ma=x[i];
		}
		if(mi>y[i]){
			mi=y[i];
			miid=i;
		}
	}
	ll ans=LINF;
	ll rmi=INF,bma=-1;
	for(int i=0;i<n;i++){
		bma=max(bma,y[i]);
		rmi=min(rmi,x[i]);
	}
	ans=min(ans,(ma-rmi)*(bma-mi));
	ll rma=ma;rmi=mi;
	mi=LINF;
	ll bmi=LINF;
	int co=n;
	vector<P> v;
	for(int i=0;i<n;i++){
		if(i!=miid){
			v.push_back(P(y[i],i));
			bmi=min(bmi,y[i]);
			bma=max(bma,y[i]);
		}else{
			v.push_back(P(x[i],i));
			bmi=min(bmi,x[i]);
			bma=max(bma,x[i]);
		}
	}
	sort(all(v));
	ll bmi2=LINF;
	for(int i=0;i<n;i++){
		mi=min(mi,bma-min(bmi2,v[i].first));
		bma=max(bma,x[v[i].second]);
		bmi2=min(bmi2,x[v[i].second]);
		if(v[i].second==miid)break;
	}
	ans=min(ans,(rma-rmi)*mi);
	cout<<ans<<endl;
}


Measured memory_bytes: 9584
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

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

#define REP(i, n) for(ll i = 0; i < n; i++)


























int main(){
    ll r, d, x;
    cin >> r >> d >> x;
    for(ll i = 1; i <= 10; i++){
        x = r * x - d;
        cout << x << endl;
    }
}

Measured memory_bytes: 256
K,N=list(int(i) for i in input().split())
A=list(int(i) for i in input().split())
ans=10**20
for i in range(N):
    if i>0 and i<N-1:
        ans=min(K-(A[i]-A[i-1]),ans,K-(A[i+1]-A[i]))
    elif i==0:
        ans=min(A[-1]-A[0],ans,K-(A[1]-A[0]))
    else:
        ans=min(A[-1]-A[0],K-(A[i]-A[i-1]),ans)
print(ans)


Measured memory_bytes: 76028
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int calc(int x, int y) {
    if(x == 0 or y == 0) return 0;
    if(x == 1 or y == 1) return max(x, y);
    return x + y - 1;
}
 
signed main() {
    int A, B, C, D; cin >> A >> B >> C >> D;
    int X = abs(A - C), Y = abs(B - D);

    int g = __gcd(X, Y);
    int P = X / g, Q = Y / g;
    cout << calc(P, Q) * g << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

int main() {
  int soinsu[] = {7,11,13,17,19,23,29,31,37,41,43};
  int a[3]={2,3,5};
  // for(int i=0;i<soinsu.size();i++){
  //
  // }
  int n,temp;
  int num4=0,num2=0,num14=0,num24=0,num74=0,num4_2=0,num2_2=0;
  cin >> n;
  int num[n];
  for (size_t i = 0; i < n; i++) {
    num[i] = 0;
  }
  for (size_t i = 1; i <= n; i++) {
    temp = i;
    for (size_t j = 2; j < n; j++) {
      while(temp%j==0){
        num[j-1] += 1;
        temp = temp/j;
      }
    }
  }
  for (size_t i = 0; i < n; i++) {
    if(num[i] >= 4)num4++;
    else if(num[i] >= 2) num2++;
    if(num[i] >= 14) num14++;
    else if(num[i] >= 4)num4_2++;
    if(num[i] >= 24) num24++;
    else if(num[i] >= 2) num2_2++;
    if(num[i] >= 74) num74++;
  }
  int result = 0;
  result += num4 * (num4-1) / 2 * num2;
  result += num4 * (num4-1) * (num4-2) /2;
  result += num14 * num4_2;
  result += num14 * (num14-1);
  result += num24 * num2_2;
  result += num24 * (num24-1);
  result += num74;
  cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		cnt+=(int)(s[i]-'0');
	}
	if(cnt%9)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3748
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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

int main(){
    string S; cin >> S;
    int cnt = 0;
    REP(i, S.length()){
        if(S[i] == '2') ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

ans=0
for i in range(1,int(input())+1):
    if len(str(i))%2==1:
        ans+=1
print(ans)

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

using namespace std;

int main() {
    string s;
    getline(cin, s);
    
    for(int i = 0; i < s.size(); i++){
        char ch=s[i];
        if('A'<=ch&&ch<='Z'){
            ch+=32;
            printf("%c",ch);
        }
        else if('a'<=ch&&ch<='z'){
            ch-=32;
            printf("%c",ch);
        }
        else {
            printf("%c",ch);
        }
    }
    cout<< endl;
    return 0;
}


Measured memory_bytes: 3224
def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    d = []
    d_set = set()
    s = 1
    for _ in range(N):
        if s in d_set:
            if K < len(d):
                return print(d[K])
            idx = d.index(s)
            K -= idx
            d = d[idx:]
            break
        d.append(s)
        d_set.add(s)
        s = A[s-1]

    # print(idx, d)
    K %= len(d)
    print(d[K])


if __name__ == '__main__':
    main()


Measured memory_bytes: 124580
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const int INF = 1001001001;
ll N;
map<ll, ll> sisuu;

vector<P> prime_factorize(ll n){
  vector<P> ret;
  for(ll i = 2; i*i <= n; i++){
    if(n%i) continue;
    int num = 0;
    while(n%i == 0){
      n /= i;
      num++;
    }
    ret.emplace_back(P(i, num));
  }
  if(n != 1) ret.emplace_back(P(n, 1));
  return ret;
}

ll rec(map<ll, ll>::iterator itr, ll mul){
  if(itr == sisuu.end()) return (mul == 1) ? 1 : 0;

  ll ret = 0;
  REP(i, itr->second+1){
    if(mul%(i+1)) continue;
    ret += rec(++itr, mul/(i+1));
    itr--;
  }
  return ret;
}

int main(void){
  cin >> N;
  FORe(i, 2, N){
    auto pf = prime_factorize(i);
    for(P p : pf) sisuu[p.first] += p.second;
  }
  cout << rec(sisuu.begin(), 75) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    ll n; cin >> n;
    vector<pll> pv(n);
    for(auto&& p:pv) cin>>p.first>>p.second; // auto&& は万能型です.参照なのでコピーは作りません
    ld ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            ans+=std::hypot(pv.at(i).first - pv.at(j).first, pv.at(i).second - pv.at(j).second);
        }
    }
    std::cout<<ans*2/n<<'\n';
}

Measured memory_bytes: 384
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

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

const int N = 2e5 + 123;
int n , m , k;
int a[N] , col[N] , b, w;

vector < int > gr[N];
string s;
bool fnd = 0;
int len , pth[N];
void dfs(int u , int par = -1 , int cnt = 1){
	len = cnt;
	pth[cnt] = u;
	if(u == n){
		fnd = 1;
		return;
	}

	for(auto to : gr[u])
		if(to != par and !fnd)
			dfs(to , u , cnt + 1);
		
}
void dfs1(int u , int par = -1){
	for(auto to : gr[u]){
		if(col[to] != 0 or par == to)
			continue ;
		if(col[u] == 1)
			b++;
		else if(col[u] == 2) w++;
		col[to] = col[u];	
		dfs1(to, u);
	}
}
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n;
//	ll ans = 1e18;
	for(int i =1;  i < n; i++){
		int a , b ;
		cin >> a >> b;
		gr[a].pb(b);
		gr[b].pb(a);
	}	
	dfs(1);
	//12345
	//1234
	for(int i = 1 ; i <= len/2 + len%2 ; i++){
		 col[pth[i]] = 1;
		 b++;
	}
	for(int i = len / 2 + len % 2 + 1 ;  i <= len ; i++){
		col[pth[i]] = 2;
		w++;
	}
	for(int i = 1 ; i <= len/2 + len%2 ; i++){
		dfs1(pth[i] , pth[i - 1]);
	}
	for(int i =  len;  i >= len / 2 + len % 2 + 1 ; i--){
		dfs1(pth[i] , pth[i + 1]);
	}

	if(b > w)
		ret("Fennec");
	ret("Snuke");	
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  int n,k;
  cin >> n >>  k;
  vi a(n);
  vi s,t;
  rep(i,n){
    cin >> a[i];
    if(a[i]<0) t.push_back(a[i]);
    else s.push_back(a[i]);
  }
  
  int S = s.size();
  int T = t.size();
  bool ok = false;
  if(S>0){
    if(n==k) ok=(T%2==0);
    else ok=true;
  }else{
    ok=(k%2==0);
  }
  
  mint ans=1;
  if(!ok){
    sort(a.begin(), a.end(),[](int x, int y) {return abs(x)<abs(y);});
    rep(i,k) ans *= a[i];
  }else{
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    if(k%2==1){
      ans *= s.back();
      s.pop_back();
    }
    vector<ll> p;
    while(s.size() >= 2){
      ll x = s.back(); s.pop_back();
      x *=s.back(); s.pop_back();
      p.push_back(x);
    }
    while(t.size() >= 2){
      ll x = t.back(); t.pop_back();
      x *=t.back(); t.pop_back();
      p.push_back(x);
    }
    sort(p.rbegin(),p.rend());
    rep(i,k/2) ans*=p[i];
  }
  
  cout << ans << "\n";
  return 0;
}

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


int main(){
	int N;cin >> N;
	vector<int> X(N);
	
	rep(i,N) cin >> X[i];
	int ans = 10000000;
	rep(i,101){
		int tmp = 0;
		rep(j,N){
			tmp += (i - X[j]) *(i - X[j]);
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;

}














Measured memory_bytes: 3556
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size();
    int res = 0;
    REP(i, N) {
        int cnt = 0;
        FOR(j, i, N, 1) {
            char s = S[j];
            if (s == 'A' || s == 'C' || s == 'G' || s == 'T') {
                cnt++;
            } else {
                break;
            }
        }
        amax(res, cnt);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
stdin = open(0).read().split('\n')
N, M = map(int,stdin[0].split())
flag=False
if N==1:
    l=['0']
    flag=True
    for j in range(M):
        s, c = stdin[j+1].split()
        if l[int(s)-1]!=c:flag=False
    if flag:
        print(0)
if not flag:
    for i in range(10**(N-1),10**N):
        l=[str(i)[_] for _ in range(len(str(i)))]
        flag=True
        for j in range(M):
            s, c = stdin[j+1].split()
            if l[int(s)-1]!=c:flag=False
        if flag:            
            print(i)
            break
    if not flag:print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, m, d[100000];
bool vis[100000];
vector<int> g[100000];
set<pair<int, int>> ans;

int dfs(int v, int p) {
	if(exchange(vis[v], true)) { return 0; }
	
	RF(e, g[v]) {
		if(e == p) { continue; }
		d[v] += dfs(e, v);
	}
	
	if(d[v] % 2 != 0 && p != -1) {
		if(ans.count({ v, p }) == 1) {
			ans.erase({ v, p });
			ans.emplace(p, v);
		} else {
			
			ans.erase({ p, v });
			ans.emplace(v, p);
		}
	}
	return d[v] % 2;
}

int main() {
	cin >> n >> m;
	inc(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].PB(b);
		g[b].PB(a);
		d[a]++;
		ans.emplace(a, b);
	}
	
	int s = dfs(0, -1);
	assert(SI(ans) == m);
	
	if(s == 0) {
		RF(e, ans) { cout << e.FI + 1 << " " << e.SE + 1 << "\n"; }
	} else {
		cout << -1 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 18304
using System.Collections.Generic;
using static System.Console;
using static System.Linq.Enumerable;

static class Program
{
  static void Main()
  {
    var dict = new Dictionary<string, int>();
    var x = ReadLine().Split();
    var y = ReadLine().Split();
    var u = ReadLine();
    
    foreach (int i in Range(0, 2)) {
      dict[x[i]] = int.Parse(y[i]);
    }
    
    dict[u]--;
    
    WriteLine($"{dict[x[0]]} {dict[x[1]]}");
  }
}

Measured memory_bytes: 13268
#include<stdio.h>

int main(void){

    char S[4],T[4];
    int i,ans=0;

    scanf("%s",S);
    scanf("%s",T);

    for(i = 0;i < 3;i++){
        if(S[i] == T[i]){
            ans++;
        }
    }

    printf("%d",ans);
    return 0;
}

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

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

  for(int i = n;i <= 999;i++){
    if(i % 10 == (i/10) % 10 && i % 10 == i/100){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int a=gi();
	    String s=gs();
	    //int c=gi();

	   
	    //System.out.print(Math.max(a+b, Math.max(a-b, a*b)));

        if (a>=3200) {
        	System.out.print(s);
        }else {
        	System.out.print("red");
        }


	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35736
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);

    string s, t;
    cin >> s >> t;
    vector<int> char_pos[26];

    rep(i, s.length()) {
        char_pos[(int) (s[i] - 'a')].push_back(i);
    }

    int before_pos = -1;
    ll loop = 0;
    for (auto c : t) {
        int index = (int) (c - 'a');
        auto itr = upper_bound(all(char_pos[index]), before_pos);
        if (itr == char_pos[index].end()) {
            itr = upper_bound(all(char_pos[index]), -1);
            if (itr == char_pos[index].end()) finish();
            before_pos = *itr;
            loop++;
        } else {
            before_pos = *itr;
        }
    }

    cout << before_pos + 1 + loop * s.length() << endl;

    return 0;
}


Measured memory_bytes: 1228
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))

#define MOD(x, y) ((x) % (y))
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))
#define DIVFLOOR(x, y) (((x) + ((y) / 2)) / (y))
#define DIVROUND(x, y) ((x) - MOD(x, y) >= MOD(x, y) ? DIVCEIL(x, y) : DIVFLOOR(x, y))

using P = pair<int, int>;

constexpr int MAX_N = 100000;

int N;
P p[MAX_N];

int main() {
  scanf("%d", &N);
  for (int i{}; i < N; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    p[i] = P{a, b};
  }
  sort(p, p+N, [](P p1, P p2) {
    return p1.first + p1.second > p2.first + p2.second;
  });

  long taka{}, aoki{};
  for (int i{}; i < N; ++i) {
    if (i % 2 == 0) {
      taka += p[i].first;
    } else {
      aoki += p[i].second;
    }
  }

  printf("%ld\n", taka - aoki);
  return 0;
}


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


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
//  int  a, b, c, d, e, X, Y ,r;
  long long  a, b, c, d, e, X, Y;
  //  double  c;
// long long  A[200003]={};
  int  A[200003]={};
  int  B[100003]={};
//  int  C[100003][100001]={};
  int  C[100003]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
  int sosuu[46] ={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199};
  int min =100000001;
  int len=0;
  int l=0;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%lld%lld", &a, &b);
  for(i=0;i<b;i++){
    scanf("%lld", &c);
    a=a-c;
  }
  if(a<0)  printf("-1\n");
  else printf("%lld\n", a);
  
return 0;
}


Measured memory_bytes: 1708
import sys
from collections import defaultdict

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

count = 0
n = int(input())
d = defaultdict(int)
ans = prime_factorize(n)
for i in ans:
    d[i] += 1
for j in d.values():
        if j < 3:
            count +=1
        elif j < 6:
            count +=2
        elif j < 10:
            count +=3
        elif j < 15:
            count +=4
        elif j < 21:
            count +=5
        elif j < 28:
            count +=6
        elif j < 36:
            count +=7
        elif j < 45:
            count +=8
        elif j < 55:
            count +=9
print(count)

Measured memory_bytes: 9472
#include<iostream>
#include<vector>
#include<algorithm>

#define INF (1<<29)

using namespace std;

int main(void){
  int n,m,d[21];
  
  cin >> n >> m;
  for(int i=0;i<m;i++)cin >> d[i];
  int dp[50001];
  fill(dp,dp+50001,INF);
  dp[0]=0;
  for(int i=0;i<m;i++){
    for(int j=0;j<=n;j++){
      if(j+d[i]<=n)dp[j+d[i]]=min(dp[j+d[i]],dp[j]+1);
    }
  }
  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 1356
#  search

n = int(input())
S = list(set(map(int,input().split())))
q = int(input())
T = list(map(int,input().split()))

S.sort()
T.sort()
ans = 0

i = 0
for elm in S:
    if elm > T[i]:
        while i < q-1 and elm > T[i]:
            i += 1
        
        if elm == T[i]:
            ans += 1
    elif elm == T[i]:
        ans += 1
    elif elm < T[i]:
        pass

print(ans)


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

int main() {
	char c, b[26];
	int a[26] = {0};
	while(cin >> c){
		if(c >= 'A' && c <= 'Z'){
			c += 32;
		}
		a[c - 'a']++;
	}
	for(char ch = 'a'; ch <= 'z'; ch++){
		b[ch - 'a'] = ch;
	}
	for(int i = 0; i <= 25; i++){
		cout << b[i] << ' ' << ":" << ' ' << a[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
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.LinkedHashMap;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int S = sc.nextInt();
			
			int[] DP = new int[S + 1];
			int[] nextDP = new int[S + 1];
			DP[0] = 1;
			
			final long MOD = 1000000007;
			
			long answer = 0;
			for(int times = 0; times < S; times++) {
				Arrays.fill(nextDP, 0);

				boolean updated = false;
				for(int pos = 0; pos <= S; pos++) {
					if(DP[pos] == 0) { continue; }
					if(DP[pos] > 0) { updated = true; }
					
					for(int i = 3; i + pos <= S; i++) {	
						nextDP[pos + i] += DP[pos];
						nextDP[pos + i] %= MOD;
					}
				}
				
				if(!updated) { break; }
				
				answer += nextDP[S];
				answer %= MOD;
				
				{
					int[] tmp = DP;
					DP = nextDP;
					nextDP = tmp;
				}
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


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

int main() {

    uint N, K;
    cin >> N >> K;

    vector<int> C(N+1, 0);
    for (size_t i=0; i<N; ++i) {
        uint A;
        cin >> A;
        ++C[A];
    }
    sort(C.begin(), C.end(), greater<int>());
    int last = 0;
    for (size_t i=0; i<C.size(); ++i) {
        if (C[i] == 0) break;
        ++last;
    }
    int num = 0;
    for (uint i=K; i<last; ++i) {
        num += C[i];
    }
    cout << num << endl;
}


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

    string s;
    int n;

	cin >> s;   // 文字列の読み込み
    n = s.length();   // 文字列の長さ


    string ssub1, ssub2;

    ssub1 = s.substr(0,1);  // 最初から1文字
    ssub2 = s.substr(1);    // インデックス1から最後まで

    if(ssub1 == ssub2){
        cout << 0 << endl;
        return 0;
    }
    

    int cp = 1; // 前回分割したポイント
    int i, j;
    bool findFlg;

    string ssub1new, ssub2new;


    for(j=2; j<n; j++){


        findFlg = false;

        for(i=1; i<n-cp; i++){
            ssub1new = ssub2.substr(0,i);

            if(ssub1new != ssub1){
                ssub2new = ssub2.substr(i);
                
                ssub1 = ssub1new;
                ssub2 = ssub2new;
                findFlg = true;
                break;
            }
        }

        if(findFlg == false){
            if(ssub2new == ssub1new)
                j -= 1;
            break;
        }

        cp += i;

    }


    cout << j << endl;

    return 0;       
}


Measured memory_bytes: 1084
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n, k;
    cin >> n >> k;
    int ans = 0;
    if(k!=1)ans = n - k;
    cout << ans << endl;
}


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

using namespace std;

int n;

int main() {
	scanf("%d", &n);
	while (n) {
		if (n % 10 == 9) {
			printf("Yes\n");
			return 0;
		}
		n /= 10;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

            String[] s = new String[] { "Sunny", "Cloudy", "Rainy", };

            for (int i = 0; i < s.length; i++) {
                if (s[i].equals(S)) {
                    System.out.println(s[(i + 1) % 3]);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 26892
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
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(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 998244353
#define SQ(x) ((x)*(x))

const int N = 200005;

LL x[N];
LL sx[N];

int main() {
	LL n, c;
	cin >> n >> c;
	REP(i, n)scanf("%lld", &x[i + 1]);
	REP(i, n)sx[i + 1] = sx[i] + x[i + 1];
	LL ret = 0x7fffffffffffffff;
	FOR(r, 1,n+1) {
		LL e = n;
		LL m = 3;
		LL tmp = n*c+r*c;
		while (e > 0) {
			tmp += max(m,5LL)*(sx[e]- sx[max(e-r, 0LL)]);
			e -= r;
			m += 2;
			if (tmp > ret)break;
		}
		ret = min(ret, tmp);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3328
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
n = int(input())
a = list(map(int, input().split()))
q = int(input())
req = [list(map(int, input().split())) for _ in range(q)]
count = [0]*100001
sum = sum(a)

for i in a:
    count[i] += 1

for k in range(q):
    sum += (req[k][1] - req[k][0]) * count[req[k][0]]
    count[req[k][1]] += count[req[k][0]]
    count[req[k][0]] = 0
    print(sum)


Measured memory_bytes: 32252
#include <bits/stdc++.h>
using namespace std; typedef long long ll;
int main(void){
	ll n;cin>>n;vector<ll>v(n);
	for(ll i=0;i<n;i++)cin>>v[i];
	ll c=0,ans=0;
	for(ll i=1;i<=n;i++){
		if(v[i]==v[i-1]){
			c++;
		}else {
			ans+=(c+1)/2; c=0;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#define mod 998244353
typedef long long ll;
int main(){
    int n,x[200],y[200],cnt;
    ll c[201]={},two[201],ans;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d %d",&x[i],&y[i]);
    }
    two[0]=1;
    for(int i=1;i<=n;i++){
        two[i]=2*two[i-1];
        two[i]%=mod;
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            cnt=0;
            for(int k=0;k<n;k++){
                if(x[i]*y[j]-y[i]*x[j]+x[j]*y[k]-y[j]*x[k]+x[k]*y[i]-y[k]*x[i]==0){
                    cnt++;
                }
            }
            c[cnt]++;
        }
    }
    ans=two[n];
    ans-=n+1;
    ans+=mod;
    ans%=mod;
    for(ll i=2LL;i<=n;i++){
        c[i]*=2LL;
        c[i]/=i;
        c[i]/=(i-1LL);
        ans-=(two[i]-i-1LL)*c[i];
        ans%=mod;
        ans+=mod;
        ans%=mod;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(s: String);

    let mut count = 0;
    let mut max = 0;
    for v in s.chars() {
        if v == 'R' {
            count += 1;

            max = if max < count { count } else { max };
        } else {
            count = 0;
        }
    }

    println!("{}", max);
}


Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> X(M);
    for(ll i=0; i<M; i++) cin >> X[i];
    sort(X.begin(), X.end());
    if(M == 1){
        cout << 0 << endl;
        return 0;
    }
    vector<ll> x_sa(M-1);
    ll ans = X[M-1] - X[0];
    for(ll i=0; i<M-1; i++){
        x_sa[i] = X[i+1]-X[i];
    }
    sort(x_sa.begin(), x_sa.end());
    reverse(x_sa.begin(), x_sa.end());
    for(ll i=0; i<N-1; i++){
        if(i >= M-1) break;
        ans -= x_sa[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
n=int(input())
B=[]
S = 0
for i in range(0,n):
    B.append((input()))
C = set(B)
if len(B) != len(C):
    print("No")
else:
    for m in range(n-1):
        if B[m][-1] == B[m+1][0]:
            S += 1
    if S == n-1:
        print("Yes")
    else: 
        print("No")

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    // スペース区切りの整数の入力
    int a,b;
    cin >> a >> b;
    
  	int x = a+b;
    int y = a-b;
    int z = a*b;
  	
  	if(x < y){
    	if(z < y){
        	cout << y << endl;
        }else{
        	cout << z << endl;
        }
    }else{
        if(z < x){
        	cout << x << endl;
        }else{
        	cout << z << endl;
        }
    }
  	
  
    return 0;
}

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

int main() {
	string S;
	cin >> S;
	string T;
	int t, s;
	s = S.size();
	if (s < 5)cout << "NO" << endl;
	else {
		while (T.size() + 5 <= S.size()) {
			t = T.size();
			if (S.at(t) == 'd') {
				if (s > t + 6 && S.at(t + 5) == 'e' && S.at(t + 6) == 'r') {
					if (s > t + 7 && (S.at(t + 7) == 'd' || S.at(t + 7) == 'e')) T += "dreamer";
					else T += "dream";
				}
				else T += "dream";
			}
			else if (S.at(t) == 'e') {
				if (s > t + 5 && S.at(t + 5) == 'r') T += "eraser";
				else T += "erase";
			}
			else break;
		}
		if (T == S) cout << "YES" << endl;
		else {
			if (T.at(T.size() - 1) == 'm')T += "er";
			else if (T.at(T.size() - 1) == 'e')T += "r";
			if (T == S)
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 640
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    long long a[n], b[n];
    //int sa = 0;
    long long sb = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        //     sa += a[i];
    }   
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        //b[i] -= a[i];
        b[i] = a[i] - b[i];
        sb += b[i];
    }   
    if (sb < 0) {
        cout << -1; 
        return 0;
    }   
    sort(b, b + n); 
    int ans = 0;
    long long smin = 0;
    for (int i = 0; i < n; i++) {
        if (b[i] >= 0) {
            break;
        }
        smin += b[i];
        ans++;
    }   
    for (int i = n - 1; i > 0; i--) {
        if (smin >= 0) {
            break;
        }
        smin += b[i];
        ans++;
    }   
    cout << ans;
}


Measured memory_bytes: 1792
import sys

def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a


stdout_write = sys.stdout.write

for line in sys.stdin:
  a, b, k = (int(i) for i in line.strip().split())
  ans = gcd(a, b)
  while True:
    if (a % ans) == 0 and (b % ans) == 0:
      k -= 1
      if k == 0: break
    ans -= 1

stdout_write('{}\n'.format(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define pii pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<ii>
#define li long int
#define ll long long
#define lli long long int
#define vlli vector<lli>
#define vll vector<ll>
#define vl vector<long>
#define ld long double
#define ulli unsigned long long int
 
using namespace std;

void solve() {
    string s, t;
    cin>>s>>t;
    int res = INT_MAX;
    int ns = s.length();
    int nt = t.length();
        int maxSimilar = INT_MIN;
        REP(i, ns - nt + 1) {
            int tmp = 0;
            REP(j, nt)
                if(s[i + j] == t[j]) tmp++;
            maxSimilar = max(tmp, maxSimilar);
        }
        res = t.length() - maxSimilar;
    cout<<res;
}
// s = d / t; t = d / s
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 3600