akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

ll p[11], c[11];
int main(void) {
  cin >> n >> m;
  rep(i, n) {
	cin >> p[i] >> c[i];
  }

  rep(bit, (1 << n)) {
	tmp = 0; cnt = 0;
	rep(i, n) {
	  if (!(bit >> i & 1)) continue;
	  tmp += p[i] * 100 * (i + 1) + c[i];
	  cnt += p[i];
	}

	if (tmp < m) {
	  ma = -1;
	  rrep(i, n) {
		if (!(bit >> i & 1)) {
		  ma = i;
		  break;
		}
	  }
	  if (ma != -1) {
		ll x = (m - tmp + (ma + 1) * 100 - 1) / ((ma + 1) * 100);
		if (x <= p[ma]) {
		  tmp += (ma + 1) * 100 * x;
		  cnt += x;
		}
	  }
	}

	if (tmp < m) continue;
	
	mi = min(mi, cnt);
  }

  cout << mi << endl;

  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int S=s.size();
  string ans="First";
  if(s[0]==s[S-1]){
    if(S%2==1){ans="Second";}
  }
  else{
    if(S%2==0){ans="Second";}
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(){

  int h,w,i,j,k=0;

  scanf("%d%d",&h,&w);

  while(h!=0&&w!=0){
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if((i+j)%2==1){
	  printf(".");
	}
	else printf("#");
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d%d",&h,&w);
  }

  return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll n,m;
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
// ll intpoint(ll x1, ll y1, ll x2, ll y2) { return ( __gcd(abs(x1-x2),abs(y1-y2))+1); }
bool isvalid(ll x,ll y) { return (x>=1&&x<=n&&y>0&&y<=m); }
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int pp = uniform_int_distribution<int>(0, kk-1)(rng);
// ---------------------///////////////---------------------------------
// ---------------------///////////////----------------------------------
// -------------/////////////////---------------------------------///////



int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    ll n;

    cin>>n;

    cout<<((n*(n-1))/2);

    // ll ap[n+11];
    // for(ll i=0;i<n;i++){
    //     cin>>ap[i];
    // }
    // ll ans[n+11];
    // ll ans1 = 1;
    // ans[n-1] = 1;

    // for(ll i=n-2;i>=0;i--){

    //     if(ap[i+1]<=ap[i]){
    //         ans[i] = ans[i+1]+1;
    //         ans1 = max(ans1,ans[i]);
    //     }else{
    //         ans[i] = 1;
    //         // ans1
    //     }
    // }

    // cout<<ans1-1;
    
    return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)-1 #隙間の個数
ko=2**n
en=[""]*n
total=0
for i in range(ko):
    en=[""]*n
    for j in range(len(s)):
        if((i>>j)&1)==True:
            en[j]="+"
    formula=""
    for x,y in zip(s,en+[""]):
        formula+=(x+y)
    total+=eval(formula)
print(total)

Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.range;

enum long PRIM = 10^^9+7;

void main()
{
    auto nm = readln.chomp.split(" ").map!(to!long);
    auto n = nm[0];
    auto m = nm[1];

    auto xs = readln.chomp.split(" ").map!(to!long);
    auto ys = readln.chomp.split(" ").map!(to!long);
    
    long xa;
    foreach (x; 0..n)
        xa = (xa + x*xs[x] - (n-x-1)*xs[x])%PRIM;
    
    long ya;
    foreach (y; 0..m)
        ya = (ya + y*ys[y] - (m-y-1)*ys[y])%PRIM;

    writeln((xa*ya)%PRIM);
}

Measured memory_bytes: 8716
#include<bits/stdc++.h>
#define ll long long
const int md=1000000007;
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
/* VECTORS */
#define pb push_back
#define g(v,i,j) get<i>(v[j])
#define co(v,x) count(v.begin(),v.end(),x)
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define vi vector<int>
#define vll vector<ll>
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.begin(),v.end(),greater<int>())
/* INPUT/OUTPUT*/
#define pr printf
#define sc scanf
#define pi(a) printf("%d\n",a)
#define pll(a) printf("%lld\n",a)
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
/* LOOPS*/
#define fi(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
using namespace std::chrono;
ll pw(ll a, ll b)
{
    ll c=1,m=a;
    while (b)
    {
        if(b&1) c=(c * m);
        m=(m*m);
        b/=2;
    }
    return c;
}
ll pwmd(ll a,ll b)
{
    ll c=1,m=a;
    while(b)
    {
        if(b&1) c=(c*m)%md;
        m=(m*m)%md;
        b/=2;
    }
    return c;
}
ll modinv(ll n)
{
    return pwmd(n, md - 2);
}
ll inverse(ll i){
    if(i==1) return 1;
    return (md - ((md/i)*inverse(md%i))%md+md)%md;
}
ll ceel(ll a,ll b)
{
    if(a%b==0) return a/b;
    else return a/b+1;
}
ll my_log(ll n, ll b)
{
    ll i=1;
    ll ans=0;
    while(1)
    {
        if(i>n)
        {
            ans--;
            break;
        }
        if(i==n) break;
        i*=b;
        ans++;
    }
    return ans;
}
bool sortbysec(const pair<ll,ll> &a,
              const pair<ll,ll> &b)
{
    return (a.second < b.second);
}
   /* auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cerr << "Time taken: "
         << duration.count()<< "ms" <<"\n";*/
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
vector<char> capl={'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'};
vector<char> sml={'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'};
string conv(ll a)
{
    string b;
    ll e=2;
    ll c=my_log(a,e);
    c++;
    b='1';
    for(int i=0;i<c-1;i++)
    {
        ll k=a>>(c-2-i);
        if(k&1) b+='1';
        else b+='0';
    }
    if(a==0) return "0";
    return b;
}
ll mysqt(ll a)
{
    ll ans=1;
    while(ans*ans<=a) ans++;
    ans--;
    return ans;
}
bool isprime(int p)
{
    int i=2;
    while(i<=sqrt(p))
    {
        if(p%i==0)
        {
            return false;
        }
        i++;
    }
    return true;
}
int main()
{
    fast;
    string s;
    cin>>s;
    int n=s.length();
    if(n==1)
    {
        if(s[0]=='s') cout<<s<<"es";
        else cout<<s<<"s";
    }
    else
    {
        if(s[n-1]=='s') cout<<s<<"es";
        else cout<<s<<"s";
    }
}









Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    string s;
    cin >> s;
    if (s.size() % 2 != 0) {
        cout << "No\n";
        return 0;
    }
    rep(i,s.size()) {
        if (i % 2 == 0) {
            if (s[i] != 'h') {
                cout << "No\n";
                return 0;
            }
        } else {
            if (s[i] != 'i') {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int dp[2][1024];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  REP(q, N) {
    string X, Y;
    cin >> X >> Y;
    int LX = X.size(), LY = Y.size();
    REP(i, 2) REP(j, LY+1) dp[i][j] = 0;
    REP(i, LX) REP(j, LY) {
      if (X[i] == Y[j]) {
	dp[(i+1)%2][j+1] = max(dp[i%2][j] + 1, max(dp[(i+1)%2][j], dp[i%2][j+1]));
      } else {
	dp[(i+1)%2][j+1] = max(dp[(i+1)%2][j], dp[i%2][j+1]);
      }
    }
    cout << dp[LX%2][LY] << endl;
  }
  return 0;
}

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

int i,j;
char str[50];

int main(){
	scanf("%s",str);
	
	for(i=0;i<strlen(str);i++)printf("%c",str[strlen(str)-i-1]);
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 0
import sys
inf = float("inf")
from bisect import bisect_left,bisect_right

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n = int(input())
Arr = get_array()
Arr.sort()

ans = 0
for i in range(n):
    for j in range(i+1,n):
        new = Arr[i]+Arr[j]
        ans+=bisect_left(Arr[j+1:], new)
print(ans)

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

using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  vector<int> a(n);
  for(int i=0;i<n;i++){
   cin >>a[i];
  }
  
  long res=0;
  if(a[0]>x){ res+=a[0]-x;
    a[0]=x;}
 
  
  for(int i=1;i<n;i++){
    if(a[i-1]+a[i]>x){res+=a[i]-(x-a[i-1]);
    a[i]=x-a[i-1];
                     }
  }
  
 cout << res << endl;
  
  
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

LOAD = '.'
WALL = '#'
NOT_REACHED = -1

h, w = [int(i) for i in input().split()]

s = [0] * h
for i in range(h):
    s[i] = input().strip()

def bfs(graph, queue, dist):
    _max = 0
    while queue:
        current = queue.pop(0)

        top = (current[0] - 1, current[1])
        bottom = (current[0] + 1, current[1])
        left = (current[0], current[1] - 1)
        right = (current[0], current[1] + 1)

        for target in (top, bottom, left, right):
            if (target[0] < 0) or (target[0] >= h) or (target[1] < 0) or (target[1] >= w):
                continue
            if dist[target] != NOT_REACHED:
                continue
            if graph[target[0]][target[1]] == LOAD:
                dist[target] = dist[current] + 1
                _max = max(dist[target], _max)
                queue.append(target)
    return _max

ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == WALL:
            continue
        queue = [(i, j)]
        dist = {}
        for inner_i in range(h):
            for inner_j in range(w):
                dist[(inner_i, inner_j)] = NOT_REACHED
        dist[(i, j)] = 0
        ans = max(bfs(s, queue, dist), ans)

print(ans)

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

using namespace std;

int main(){
	int n;
	while(cin >>n,n){
		vector<int> a(n);
		for(int i=0;i<n;i++){
			cin >> a[i];
		}
		sort(a.begin(),a.end());
		int mini = INT_MAX;
		int idx;
		for(int i=0;i<n-1;i++){
			mini = min(mini,abs(a[i]-a[i+1]));
		}
		cout << mini<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 h; scanf("%lld", &h);

	i64 ans = 0, now = h, cnt = 1;
	while(now) {
		ans += cnt;
		cnt *= 2;
		now /= 2;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 2000001
#define vmax 10000
constexpr ll inf = 1000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

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

int main() {
    ll n;
    ll x=0;
    cin>>n;
    ll y;
    rep(i,n){
        cin>>y;
        x+=y-1;
    }
    cout<<x<<endl;
    return 0;
}












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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	string s;
	cin >> s;
	int32 cnt = 0;
	int32 Tc = 0;
	for(int32 i = s.size()-1;i >= 0;i--){
		if(s[i] == 'T') Tc++;
		else{
			if(Tc){
				Tc--;
				cnt += 2;
			}
		}
	}
	cout << s.size()-cnt << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

auto main() -> int {
  int X, Y;
  std::cin >> X >> Y;
  std::cout << (X + Y / 2) << std::endl;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s;
	cin>>s;
	int out=700;
	rep(i,3)if(s[i]=='o')out+=100;
	cout<<out<<endl;
}






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

int main(){
    string s;
    string snext;
    cin >> s;
    if (s == "Sunny") {
        snext = "Cloudy";
    }
    else if (s == "Cloudy") {
        snext = "Rainy";
    }
    else snext = "Sunny";
    cout << snext << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include<set>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;///////////////////////////////////////////////////////////
int main(){
 ll x,a,b;
 sc(x);sc(a);sc(b);
 
 if(b-a<=0)puts("delicious");
 else if(b-a<=x)puts("safe");
 else puts("dangerous");
 
return 0;}

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

using namespace std;

bool can(int x, int a, int b, int c)
{
    return x == (a * 500) + (b * 100) + (c * 50);
}

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

    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int answer = 0;

    for(int i = 0; i <= a; ++i)
    {
        for(int j = 0; j <= b; ++j)
        {
            for(int k = 0; k <= c; ++k)
            {
                if(can(x, i, j, k))
                    ++answer;
            }
        }
    }

    cout << answer << '\n';

}


Measured memory_bytes: 256
package main

import "fmt"

var (
	d   []int
	ans [][]int
)

func calc(x, i int) {
	for j := range ans[i-1] {
		ans[i][(x*d[i]+j)%13] += ans[i-1][j]
		ans[i][(x*d[i]+j)%13] %= 1000000007
	}
}

func main() {
	var s string
	fmt.Scan(&s)

	d = make([]int, len(s)+1)
	d[1] = 1
	ans = make([][]int, len(s)+1)
	ans[0] = make([]int, 1)
	ans[0][0] = 1
	for i := 1; i <= len(s); i++ {
		if i > 1 {
			d[i] = d[i-1] * 10 % 13
		}

		ans[i] = make([]int, 13)
		r := s[len(s)-i]
		if r != '?' {
			calc(int(r-'0'), i)
			continue
		}
		for j := 0; j <= 9; j++ {
			calc(j, i)
		}
	}
	fmt.Println(ans[len(s)][5])
}


Measured memory_bytes: 15360
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;

int main(){

    int n;
    cin >> n;

    string ans = "Christmas";

    for(int i = n;  i < 25; i++){
        ans = ans + " Eve";
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int vl[6][7]={
        {0,300,500,600,700,1350,1650},
        {0,0,350,450,600,1150,1500},
        {0,0,0,250,400,1000,1350},
        {0,0,0,0,250,850,1300},
        {0,0,0,0,0,600,1150},
        {0,0,0,0,0,0,500}
    };
    int dis[7]={0,6,13,18,23,43,58};
    int t,m,pos1,pos2;
    while(scanf("%d",&pos1),pos1){
        bool flag=false;
        scanf("%d%d",&t,&m);
        t=t*100+m;
        if(t>=1730&&t<=1930)flag=true;
        scanf("%d%d%d",&pos2,&t,&m);
        t=t*100+m;
        if(t>=1730&&t<=1930)flag=true;

        if(pos1>pos2)swap(pos1,pos2);
        pos1--;pos2--;
        int ans=vl[pos1][pos2];
        if(dis[pos2]-dis[pos1]>40)flag=false;

        if(flag){
            if(ans%100){
                ans=(ans-50)/2+50;
            }
            else ans/=2;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1028
n = gets.to_i
s = n.times.map { gets.chomp.chars.sort.join }.sort
ans = 0
c = 1
(1...n).each do |i|
  if s[i - 1] == s[i]
    c += 1
  else
    ans += c * (c - 1) / 2
    c = 1
  end
end
p ans += c * (c - 1) / 2


Measured memory_bytes: 28152
#include <iostream>
using namespace std;
int main()
{
    long long n, s = 0;
    cin >> n;
    for(long long i = 1; i <= n; i++) {
        if(i % 3 != 0 && i % 5 != 0) s += i;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3624
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;

lli solve(long long N, long long A, long long B) {
  if((B-A)%2==0){
    return (B-A)/2;
  }else{
    lli dist = min(A + solve(N, 1, B-A), N-B+1+solve(N, A+N-B+1, N));
    return dist;
  }
}

int main() {
  int a;
  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  cout << solve(N, A, B) << endl;
  return 0;
}


Measured memory_bytes: 256
import Data.List

main = do
    s' <- getLine
    t  <- getLine
    let s = restore (reverse s') (reverse t)
    putStrLn $ if canRestore s' t 
        then reverse $ map (\c->if c=='?' then 'a' else c) s
        else "UNRESTORABLE"

restore s' t = let
    s = restore' s' t
    in if s == s' then s 
                  else restore s t

canRestore [] _ = False
canRestore (s:ss) key = canReplace (s:ss) key || canRestore ss key

restore' [] _ = []
restore' s' t = if canReplace s' t 
 then t ++ drop (length t) s'
 else head s' : restore' (tail s') t
 
canReplace _ [] = True
canReplace [] _ = False
canReplace (x:xs) (y:ys) = (x=='?' || y=='?' || x==y) && canReplace xs ys
    

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n;
  cin >> n;
  vector<ll> p(n + 10);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] == -1) continue;

    if (p[i] == i) {
      p[i + 1] = -1;
      ans++;
    }
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 1024
import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    # https://qiita.com/drken/items/97e37dd6143e33a64c8c#3-%E3%82%81%E3%81%90%E3%82%8B%E5%BC%8F%E4%BA%8C%E5%88%86%E6%8E%A2%E7%B4%A2%E3%81%AE%E3%81%95%E3%82%89%E3%81%AA%E3%82%8B%E5%88%A9%E7%82%B9

    n,a,b=map(int,input().split())
    h=[int(input()) for _ in range(n)]
    def is_ok(t):
        cnt=0
        for i in range(n):
            if h[i]-b*t>0:
                cnt+=math.ceil((h[i]-b*t) / (a-b))
        return cnt<=t

    def bin_search_meguru():
        """
        初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
        まずis_okを定義すべし
        ng, okは,とり得る最小の値-1,とり得る最大の値+1
        """
    
        # 適当にいじる
        ng = 0  # ind=0が条件を満たすこともあるため
        ok = 10**18  # ind=len(a)-1が条件を満たさないこともあるため
    
        # いじらない
        # okとngのどちらが大きいかわからないことを考慮
        while (abs(ok - ng) > 1):
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok
    print(bin_search_meguru())
    

    
resolve()

Measured memory_bytes: 77888
#include<iostream>
    using namespace std;
    int A[100100],B[100100];
    int main()
    {
      int N;
      long long ans=0;
      cin>>N;
      for(int i=0;i<=N;i++)
        cin>>A[i];
     for(int i=0;i<N;i++)
       	cin>>B[i];
      for(int i=0;i<N;i++)
      {
        int h1=min(A[i],B[i]);
        ans+=h1;
        B[i]-=h1;
        int h2=min(A[i+1],B[i]);
        ans+=h2;
        A[i+1]-=h2;
      }
      cout<<ans<<endl;
      return 0;
    }

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
inline bool isprime(ll num)
{if(num==2||num==3)return true;
if(num%6!=1&&num%6!=5)return false;
for(int i=5;1ll*i*i<=num;i+=6){if(num%i==0||num%(i+2)==0)return false;}
return true;}
const int mod = 1e9+7;
inline ll mul(ll a,ll b,ll c){return (a*b-(ll)((ld)a*b/c)*c+c)%c;}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll g = exgcd(b,a%b,y,x);y-=a/b*x;return g;}
inline ll quick_pow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res=mul(res,a,mod);a=mul(a,a,mod);b>>=1;}return res;}
inline ll quick_pow(ll a,ll b){ll res=1;while(b){if(b&1)res=mul(res,a,mod);a=mul(a,a,mod);b>>=1;}return res;}
inline ll inv(ll x){return quick_pow(x,mod-2);}
inline ll inv(ll x,ll mod){return quick_pow(x,mod-2,mod);}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
   ll n,k;
   cin>>n>>k;
   printf("%lld\n",min(n%k,abs(k-(n%k))));	
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int a, b;
	cin >> a >> b;
	int mx = INT_MIN;
	if (mx < a + b) mx = a + b;
	if (mx < a - b) mx = a - b;
	if (mx < a * b) mx = a * b;
	cout << mx << "\n";	
	return 0;
}


Measured memory_bytes: 256
def solve(string):
    n, k, s = string.split()
    n, k = map(int, [n, k])
    flip = [0] + [i for i, (s0, s1) in enumerate(zip(s, s[1:]), start=1) if s0 != s1] + [n]
    start = int(s[0])
    l = len(flip) - 1
    return str(max([flip[min(l, i + 2 * k + (i % 2 ^ start))] - flip[i] for i in range(l + 1)]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 11080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define sz(x) ((int) x.size())
#define rd(type, ...) type __VA_ARGS__; sc(__VA_ARGS__)
#define rdv(type, v, n) vector<type> v(n); rep(__ii, 0, n) cin >> v[__ii]
#define rdm(type, v, h, w) vector<vector<type>>(h, vector<type>(w)) v; rep(__ii, 0, h) rep(__jj, 0, w) cin >> v[__ii][__jj]
typedef long long ll;
void solve();
signed main() {ios::sync_with_stdio(false); cin.tie(0);
  cout << fixed; cout.precision(12); solve(); return 0;}
template<typename T> void prv(vector<T> v) {rep(__ii, 0, sz(v)) {if (__ii) cout << ' '; cout << v[__ii];} cout << '\n';} 
template<typename T> void prm(vector<vector<T>> v) {rep(__ii, 0, sz(v)) {rep(__jj, 0, v[__ii].size()) {if (__jj) cout << ' '; cout << v[__ii][__jj];} cout << '\n';}}
template<typename T> void sc(T& x) {cin >> x;}
template<typename Head, typename... Tail> void sc(Head& head, Tail&... tail) {cin >> head; sc(tail...);}
template<typename T> void pr(const T& x) {cout << x << '\n';}
template<typename Head, typename... Tail> void pr(const Head& head, const Tail&... tail) {cout << head << ' '; pr(tail...);}
template<typename... T> void err(const T&... cod) {pr(cod...); exit(0);}

void solve() {
  rd(int, n);
  n *= n;
  pr(3 * n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;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 ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

int main() {
  int x1,y1,x2,y2,x3,y3,x4,y4,xlen,ylen;
  cin >> x1 >> y1 >> x2 >> y2;
  xlen = x2 -x1;
  ylen = y2 -y1;
  x3 = x2 - ylen;
  y3 = y2 + xlen;
  x4 = x3 - xlen;
  y4 = y3 - ylen;
  cout << x3 << " " << y3 << " " << x4 << " " << y4;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int e = sc.nextInt();
    int k = sc.nextInt();
    if (e - a <= k) {
      System.out.println("Yay!");
    } else {
      System.out.println(":(");
    }
  }
}

Measured memory_bytes: 20948
import java.util.Scanner;
class Main{
    public static void main(String args[]){
        Scanner scn = new  Scanner(System.in);
        String s = scn.nextLine();
        if(s.equals("Sunny")){
            System.out.println("Cloudy");
        }else if(s.equals("Cloudy")){
            System.out.println("Rainy");
        }else{
            System.out.println("Sunny");
        }
    }
}

Measured memory_bytes: 20692
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    h = sorted(int(input()) for _ in range(N))
    print(min(j - i for i, j in zip(h, h[K - 1:])))

main()


Measured memory_bytes: 70488
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		String[] n = str.split("");
		int ans = 0;
		for (int i = 0, j = str.length() - 1; i < str.length() / 2; i++) {
			if (!n[i].equals(n[j--]))ans++;
		}
		System.out.println(ans);
	}
}

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

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	for (string s; cin >> s;) {
		int g = 0, p = 0;
		int w = 0,l=0;
		rep(i, 0, s.size()) {
			if (s[i] == 'g') {
				if (p < g) {
					p++;
					w++;
				}
				else {
					g++;
				}
			}
			else {
				if (p < g) {
					p++;
				}
				else {
					g++;
					l++;
				}
			}
		}
		cout << w - l << endl;
	}
	return 0;
}

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

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n, x, m; cin >> n >> x >> m;
  map<ll,ll> cnt;
  vll sum;

  ll c = 1;

  while (true) {
    if (cnt[x]) break;

    cnt[x] = c++;
    sum.eb(x);

    x = x % m * x % m;
  }

  ll ans = 0;
  rep(i, cnt[x]-1) ans += sum[i];

  ll roop_sum = accumulate(sum.begin()+cnt[x]-1,sum.end(),0LL);
  ll roop_len = c - cnt[x];
  ll still_roop = n - cnt[x] + 1;
  ll amari = still_roop % roop_len;

  ans += roop_sum * (still_roop / roop_len);
  rep(i, amari) ans += sum[cnt[x]-1+i];

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

Measured memory_bytes: 6692
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int P2 = 50;
const int P5 = 22;
int cnt[P2+1][P5+1];


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	cin>>n;
	
	vector<int> a;
	for(int i=0;i<n;++i){
		string x;
		cin>>x;
		int p = find(ALL(x),'.') - begin(x);
		if(p==size(x)){
			x+=".0";
		}
		
		string b = x.substr(p+1);
		while(size(b)>1 && b.back()=='0') b.pop_back();
		while(size(b)<9) b+='0';
		ll num = stoll(x.substr(0,p) + b);
		
		int t2 = 0;
		for(ll t=num; t%2==0; t/=2) ++t2;
		int t5 = 0;
		for(ll t=num; t%5==0; t/=5) ++t5;
		
		++cnt[t2][t5];
	}
	
	ll ans = 0, ans2 = 0;
	for(int i=0;i<=P2;++i)
	for(int j=0;j<=P5;++j)
	for(int ii=0;ii<=P2;++ii)
	for(int jj=0;jj<=P5;++jj) if(i+ii>=18 && j+jj>=18){
		ll c = cnt[i][j];
		ll d = cnt[ii][jj];
		if(i==ii && j==jj){
			ans+=(c-1)*c/2;
		}else{
			ans2+=c*d;
		}
	}
	ans+=ans2/2;
	cout<<ans<<endl;
	
	
	
	return 0;
}


Measured memory_bytes: 3640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class FPure {
public:
    int N, M;
    vvc<int> G;

    vc<int> check(int s){
        vc<int> dist(N, N+1), par(N, -1);
        dist[s] = 0;
        queue<int> que;
        que.emplace(s);
        int len = N + 1;
        while(not que.empty()){
            int u = que.front();
            que.pop();
            for(auto& v : G[u]){
                if(v==s and chmin(len, dist[u]+1)){
                    par[s] = u;
                } else if(dist[v]==N+1){
                    par[v] = u;
                    dist[v] = dist[u] + 1;
                    que.emplace(v);
                }
            }
        }
        if(par[s]==-1) return {};
        vc<int> cycle;
        int cur = s;
        while(par[cur]!=s){
            cycle.pb(par[cur]);
            cur = par[cur];
        }
        cycle.pb(s);
        return cycle;
    }

    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        in>>N>>M;
        G.resize(N);
        REP(i, M){
            int a, b;
            in>>a>>b;
            a--, b--;
            G[a].pb(b);
        }
        vc<int> ans;
        REP(i, N){
            vc<int> tmp = check(i);
            if(not tmp.empty() and (ans.empty() or LEN(tmp)<LEN(ans))){
                ans = tmp;
            }
        }
        if(ans.empty()) out<<"-1\n";
        else{
            out<<LEN(ans)<<'\n';
            for(auto& a : ans) out<<a+1<<'\n';
        }
    }
};


int main() {
	FPure solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3732
a,b,c = map(int, input().split())
i = abs(a - b)+abs(b - c)
i2= abs(a - c)+abs(b - c)
j = abs(a - b)+abs(a - c)
j2= abs(c - b)+abs(a - c)
k = abs(a - c)+abs(b - a)
k2= abs(c - b)+abs(b - a)
n = min(i,i2,j,j2,k,k2)
print(n)


Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
 
namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

			var hash = new HashSet<int>();
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				if (hash.Contains(a[i])) {
					++cnt;
				} else {
					hash.Add(a[i]);
				}
			}

			if (cnt % 2 != 0) {
				++cnt;
			}

			int ans = n - cnt;
			Console.WriteLine(ans);
		}
	}
}

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

int main() {
    int A, B;
    std::cin >> A >> B;

    if (A == 1) {
        A = 14;
    }

    if (B == 1) {
        B = 14;
    }

    if (A > B) {
        std::cout << "Alice\n";
    } else if (A < B) {
        std::cout << "Bob\n";
    } else {
        std::cout << "Draw\n";
    }

    return 0;
}


Measured memory_bytes: 256
def RanLengthEncoding(S):
    N = len(S)
    RLE = []
    now_char = S[0]
    now_cnt = 1
    for i in range(1, N):
        if now_char == S[i]:
            now_cnt += 1
        else:
            RLE.append([now_char, now_cnt])
            now_char = S[i]
            now_cnt = 1
    RLE.append([now_char, now_cnt])
    return RLE

S = input()
K = int(input())
rle = RanLengthEncoding(S)
if len(rle) == 1:
    ans = rle[0][1] * K // 2
    print(ans)
    exit()
cnt = 0
for i in range(1, len(rle)-1):
    cnt += rle[i][1] // 2

if rle[0][0] != rle[-1][0]:
    cnt += rle[0][1] // 2
    cnt += rle[-1][1] // 2
    ans = cnt * K
else:
    tmp = (rle[0][1] + rle[-1][1]) // 2
    ans = cnt * K
    ans += tmp * (K-1)
    ans += rle[0][1] // 2
    ans += rle[-1][1] // 2
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));

  ll ans = 1;
  for (ll& x : a) {
    if (ans > ll(1e9) && x > ll(1e9)) {
      cout << -1 << endl;
      return 0;
    }
    ans *= x;
    if (ans > 1000000000000000000LL) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3996
s = gets.chop.chars

color = '0'
count1 = 0
s.each do |c|
    count1 += 1 if c != color
    color = color == '0' ? '1' : '0'
end
   
color = '1'
count2 = 0
s.each do |c|
    count2 += 1 if c != color
    color = color == '0' ? '1' : '0'
end
   
ans = [count1, count2].min
puts ans

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

namespace ABC164A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int S = int.Parse(input[0]);
            int W = int.Parse(input[1]);
            if (S <= W)
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }
        }
    }
}


Measured memory_bytes: 27312
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    int n;
    while(cin>>n&&n){
        vector<char> vc(n);
        rep(i,n)cin>>vc[i];
        
        vector<int> data(26,0);
        bool f=false;
        int time=-1;
        rep(i,n){
            int res = n-i-1;
            data[ vc[i]-'A' ]++;
            
            vector<int> tmp = data;
            sort(tmp.rbegin(),tmp.rend());
            
            if(tmp[0]>tmp[1]+res){
                f=true;
                time = i+1;
                break;
            }
        }
        
        
        if(f==false)cout<<"TIE"<<endl;
        else{
            cout<<(char)('A'+(max_element(all(data))-data.begin()))<<" "<<time<<endl;
        }
    }
}

Measured memory_bytes: 3048
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		List<Integer> box = new ArrayList<>();
		int count = 0;
 
		// 与えられた初期値によってリストを作成
		for (int i = 1; i <= a; i++) {
			box.add(sc.nextInt());
		}
		while (check(box)) {
			box = divide(box);
			count++;
		}
		System.out.println(count);
	}
 
	/**
	 * 格納された全ての値が偶数かそうではないかをチェックするメソッド
	 * 
	 * @param box
	 * @return boolean
	 */
	private static boolean check(List<Integer> box) {
		for (int i = 0; i < box.size(); i++) {
			if (box.get(i) % 2 == 1) {
				return false;
			}
		}
		return true;
	}
 
	/**
	 * リストを受け取って、各値を2で割った値を返す
	 * 
	 * @param box
	 * @return List<Integer>
	 */
	private static List<Integer> divide(List<Integer> box) {
		List<Integer> dividedBox = new ArrayList<>();
		for (int i = 0; i < box.size(); i++) {
			dividedBox.add(box.get(i) / 2);
		}
		return dividedBox;
	}
}


Measured memory_bytes: 19924
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5
int main(){
	ll n,k,q;
	cin>>n>>k>>q;
	vl v(n);
	rep(i,q){
		int a;
		cin>>a;
		v[a-1]++;
	}
	rep(i,n){
		if(k-(q-v[i])>0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

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

int main()
{
  int N;
  string S;

  cin >> N >> S;

  int countLeft = 0;
  int countRight = 0;

  int finalLeft = 0;
  int finalRight = 0;

  for(int i=0;i<N;i++){
    if(S[i] == ')'){
      countLeft++;
    }else{
      countRight++;
    }
    if(countLeft > countRight){
      finalLeft++;
      countLeft--;
    }
  }

  for(int i=0;i<finalLeft;i++){
    cout << "(";
  }
  cout << S;
  for(int i = 0;i<countRight - countLeft;i++){
    cout << ")";
  }
  cout << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int x,y;
    int a,b,c,i,j,count=0;
    while (scanf("%d%d",&x,&y) != EOF){
        if(x > y){
            a=x;
            b=y;
            for(;;){
                c = a % b;
                if(a % b == 0){
                    break;
                }
                a=b;
                b=c;
            }
        }
        else if(x < y){
            a=y;
            b=x;
            for(;;){
                c = a % b;
                if(a % b == 0){
                    break;
                }
                a=b;
                b=c;
            }
        }
        else if(x == y){
            b=x;
            j=x;
        }
        j=(x/b)*(y/b)*b;
        printf("%d %d\n",b,j);
    }
    return 0;
}

Measured memory_bytes: 0
open System

let isSubArray xs ys =
    let n, m = Array.length xs, Array.length ys
    let rec f i j =
        if i = n then true
        elif j = m then false
        elif xs.[i] = ys.[j] then f (i+1) (j+1)
        else f i (j+1)
    f 0 0

let n = stdin.ReadLine() |> int
let s = stdin.ReadLine().ToCharArray()

let a = List.length [
    for i in ['0'..'9'] do
    for j in ['0'..'9'] do
    for k in ['0'..'9'] do
    if isSubArray [| i; j; k |] s then yield () ]
 
printfn "%d" a

Measured memory_bytes: 21356
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X = int(readline())

    ans = 10 - X // 200

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61856
N = int(input())
A = list(map(int, input().split()))
B = A.copy()
for i in range(N):
    B[i] -= i+1
B.sort()
if N%2==0:
    n = N//2
    b = (B[n-1]+B[n]) // 2
else:
    b = B[(N-1)//2]
ans = 0
for i,a in enumerate(A):
    ans += abs(a - (b+i+1))
print(ans)


Measured memory_bytes: 26708
a = 2
N = int(input())

#最大公約数
def gcd(a,N):
    while N!=0:
        a,N = N, a%N
    return a
##2つの整数a,bに対し，最大公約数g,最小公倍数lとおくと，
##ab=gl
print(int(a*N/gcd(a,N)))

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

int main(){
  int n,m; cin >>n >>m;
  int x = (1900*m+100*(n-m));
  rep(i,m) x*=2;
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 3636
// ABC064_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second

int main() {
    // input
    ll A, B, C;
    cin >> A >> B >> C;
    
    // calculation
    cout << ((A*100+B*10+C)%4 == 0 ? "YES": "NO") << "\n";
    
    return 0;
}

Measured memory_bytes: 256