akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
// #include<numeric>

using namespace std;
int n;
long int a,b;

// 最大公約数(ユークリッドの互除法)
long int gcd(long int a, long int b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

long int lcm(long int a , long int b){
    return a / gcd(a,b) * b;

}

long int multi_lcm(int n, long int t[n],int i, long int ans){
    if (i == n) return ans;

    ans = lcm(ans,t[i]);
    return multi_lcm(n, t, i+1, ans);
}

int main(){
    
    scanf("%d", &n);
    long int t[n];
    for (int i = 0; i < n; i++){
        scanf("%ld", &t[i]);
        
    }
    long int ans = t[0];

    ans = multi_lcm(n, t, 1, ans);
    printf("%ld\n", ans);
    
    
}

Measured memory_bytes: 760
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    info = [[k+1, a] for k, a in enumerate(A)]
    info = sorted(info, key = lambda x: x[1])
    print(' '.join([str(i[0]) for i in  info]))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 34228
#include<iostream>

using namespace std;

int main()
{
	int a, b;

	cin >> a >> b;

	if (((a + b) % 3) == 0)
	{
		cout << "Possible" << endl;
	}
	else if ((a % 3) == 0)
	{
		cout << "Possible" << endl;
	}
	else if ((b % 3) == 0)
	{
		cout << "Possible" << endl;
	}
	else
	{
		cout << "Impossible" << endl;
	}
	return 0;
}

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

int main() {
    vector<int> a(3);
    for (auto &ai: a) cin >> ai;
    sort(a.rbegin(), a.rend());
    cout << (a[0] * 10 + a[1]) + a[2] << endl;
    return 0;
}


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

int main(){
  ll n,k,s;
  cin>>n>>k>>s;
  if(s==1000000000){
    rep(i,n){
      if(i<k) cout<< s <<" ";
      else cout<< s-1 <<" ";
    }
    cout<<endl;
  }else{
    rep(i,n){
      if(i<k) cout<< s <<" ";
      else cout<< s+1 <<" ";
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int main()
{
    int val = 50;
    ll k;
    cin >> k;
    ll m = k/val;
    ll n = k%val;
    cout << val << endl;
    for(ll i = m, j = 1; j <= val; i++,j++){
        if(j <= val - n) cout << i << ' ';
        else cout << i+1 << ' ';
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())

CSF = [tuple(map(int, input().split())) for _ in range(n-1)]

for i in range(n-1):
    t = 0
    for j in range(i, n-1):
        if t <= CSF[j][1]:
            t = CSF[j][1]
        elif t % CSF[j][2] == 0:
            pass
        else:
            t += CSF[j][2] - t % CSF[j][2]
        t += CSF[j][0]
    print(t)
print(0)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int n;
	cin >> n;
	vector<int> p(22);
	for(int i=1;i<=n;i++)cin >> p[i];
	int ans = 0;
	for(int i=2;i<=n-1;i++){
		if(p[i]>=p[i-1]&&p[i+1]>p[i])ans++;
		else if(p[i]<p[i-1]&&p[i+1]<=p[i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back


const int N = 1e6 + 51 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

//gp_hash_table<int, int> table;

int a[N], dp[N];

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        dp[i] = INF;
    }
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i + j >= n) break;
            dp[i + j] = min(dp[i + j], abs(a[i] - a[i + j]) + dp[i]);
        }
    }
    cout << dp[n - 1];
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;


int main() {
	str S,T;cin>>S>>T;
    ll m=S.size()-1;
    rep0(i,S.size()){
        char hold=S[0];
        rep0(j,m+1){
            if(j!=m)S[j]=S[j+1];
            else S[j]=hold;
        }
        if(S==T){cout<<"Yes"<<endl;return 0;}
    }
    cout<<"No"<<endl;
}



Measured memory_bytes: 256
import java.util.*;
	
	
	
	public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			Integer a[] = new Integer[N];
			for (int i = 0;i<N;i++) {
				a[i] = sc.nextInt();
			}
			
			Arrays.sort(a,Collections.reverseOrder());
			
			int res = 1;
			
			for (int j = 1;j<N;j++) {
				if (a[j] < a[j-1]) {
					res++;
				}
			}
			
			System.out.println(res);
			
			sc.close();
		}
		
		
	}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,k,i,j,rem1,sum;
    cin>>a>>b>>k;
    if(k>=a){
        rem1=k-a;
        b=b-rem1;
        a=0;
        if(b<=0)
            b=0;
    }
    else if(k<a){
        a=a-k;
        b=b;
    }
    cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
        return 0;        
    }

return 0;
}


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

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

	//答えansを仮置きする。
	//これが十分に大きくないと不正解となるので、
	//この値なら絶対に正しい答えが出る、という値を仮置きすること
	int ans = T.size();

	//Sの何文字目から調べるかを全探索する
	for (int start = 0; start <= S.size() - T.size(); start++)
	{
		int diff = 0;
		for (int i = 0; i < T.size(); i++)
		{
			if (T[i] != S[start + i]) {
				diff++;
			}
		}
		ans = min(ans, diff);
	}

	cout << ans << endl;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    if (b - a <= 2) {
        cout << 1 + k << endl;
        ret();
    }

    // aにするまで
    ll ab = a - 1;
    k -= ab;

    ll ans = a + (b - a) * (k / 2) + k % 2;

    cmax(ans, 1 + k);
    cout << ans << endl;

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
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; }



int main(){

	lli H,W;
	cin>>H>>W;

	lli h,w;
	cin>>h>>w;

	cout<<H*W-(h*W+w*H - h*w)<<endl;


    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long

string X,Y;
int q,Z;
int dp[1001][1001]={};

int main() {
	cin>>q;
	for(int ds=0;ds<q;ds++){
		cin>>X>>Y;
		int xs=X.size(),ys=Y.size();
		for(int i=0;i<xs;i++){
			for(int j=0;j<ys;j++){
				int tmp=0;
				if(X[i]==Y[j]){
					if(i*j==0)dp[i][j]=1;
					else dp[i][j]=dp[i-1][j-1]+1;
				}
				else {
					if(i+j==0)dp[0][0]=0;
					else if(i==0)dp[0][j]=dp[0][j-1];
					else if(j==0)dp[i][0]=dp[i-1][0];
					else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				}
			}
		}
		cout<<dp[xs-1][ys-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 7088
N, K = (int(c) for c in input().split())
A = [int(c) for c in input().split()]

i1 = A.index(1)

k0_min = max(i1 - K + 1, 0)
k0_max = min(i1, N - K)

nmin = N

for k0 in range(k0_min, k0_max+1):
    nl = -(-k0 // (K-1))
    nr = -(-(N-k0-K) // (K-1))
    n = nl + nr + 1
    nmin = min(n, nmin)

print(nmin)

Measured memory_bytes: 13880
n, a, b = map(int, input().split())
S = list(input())

t_pass = 0
f_pass = 1

for e in S:
    if e == 'a':
        if t_pass < a + b:
            t_pass += 1
            print('Yes')
        else:
            print('No')
    elif e == 'b':
        if t_pass < a + b and f_pass <= b:
            t_pass += 1
            f_pass += 1
            print('Yes')
        else:
            print('No')
    else:
        print('No')


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

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

    // solve
    int a[26] = {0};
    for (int i = 0; i < S.length(); ++i) {
        a[S[i] - 'a']++;
    }
    bool flag = false;
    for (int i = 0; i < S.length(); ++i) {
        if (a[i] >= 2) flag = true;
    }

    // output
    cout << (flag ? "no" : "yes") << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int a,b,c;
string s;

int main()
{

    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>a;
    const double pi=3.14159;

    double ans=(double) 2*pi*a;
    printf("%.6f",ans);
    
    
	
	
}







Measured memory_bytes: 3760
x1, y1, x2, y2 = map(int, input().split())
a = x1 + y1 * 1j
p = (x2 - x1) + (y2 - y1) * 1j
q = p * 1j
r = p + q

d = a + q
c = a + r

x3 = int(c.real)
y3 = int(c.imag)
x4 = int(d.real)
y4 = int(d.imag)

print(x3, y3, x4, y4)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

const int MOD = (1e+9) + 7,MAX_N = 2010;
vec nCm1(MAX_N+1,0);
vec fact1(MAX_N+1,0);
vec fact_inv1(MAX_N+1,0);
vec nCm2(MAX_N+1,0);
vec fact2(MAX_N+1,0);
vec fact_inv2(MAX_N+1,0);

ll fastpow(ll a, ll pw) {
	ll res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}
void makefact(ll n,vec &fact, vec &fact_inv){//MODは素数かつnより大きい
    ll ans = 1;
    fact.at(0) = ans;
    fact_inv.at(0) = ans;
    reps(i,1,n+1){
        (ans *= i)%=MOD;
        fact.at(i) = ans;
        fact_inv.at(i) = fastpow(ans,MOD-2);
    }
    return;
}
void makenCm1(ll n, vec &fact, vec &fact_inv){
    rep(i,n+1){
        ll ans = fact.at(n);
        (((ans*=fact_inv.at(n-i))%=MOD)*=fact_inv.at(i))%=MOD;
        nCm1.at(i) = ans;
    }
    return;
}
void makenCm2(ll n, vec &fact, vec &fact_inv){
    rep(i,n+1){
        ll ans = fact.at(n);
        (((ans*=fact_inv.at(n-i))%=MOD)*=fact_inv.at(i))%=MOD;
        nCm2.at(i) = ans;
    }
    return;
}

int main() {
    cin>>N>>K;
    makefact(K-1,fact1,fact_inv1);
    makenCm1(K-1,fact1,fact_inv1);
    makefact(N-K+1,fact2,fact_inv2);
    makenCm2(N-K+1,fact2,fact_inv2);
    rep(i,K){
        if(N-K<i)cout<<0<<endl;
        else cout<<(nCm1.at(i)*nCm2.at(i+1))%MOD<<endl;
    }
    /*rep(i,N+1) cout<<nCm1.at(i)<<' ';
    cout<<endl;
    rep(i,N+1) cout<<nCm2.at(i)<<' ';
    cout<<endl;*/
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int a[60][27] ;

int main() {
  int n ;
  string s ,ans ;

  scanf("%d", &n) ;

  for(int i = 0 ;i<n ;i++){
    cin >> s ;
    for(int j = 0 ; j<s.length() ; j++)
      a[i][s[j] - 'a']++ ;
  }

  for(int i = 0 ; i<26 ; i++){
    int min_letter = INT_MAX ;
    for(int j = 0; j<n ; j++)
      min_letter = min(min_letter, a[j][i]) ;
    for(int k = 0 ; k<min_letter ; k++)
      ans+=(i+'a') ;
  }
  cout << ans << endl; 	
  return 0 ;
}

Measured memory_bytes: 256
def biserch(n,List):
    left = 0
    right = len(List)
    while left < right:
        mid = (left+right)//2
        if n <= List[mid]:
            right = mid
        else:
            left = mid + 1
    
    return left
    
N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N):
        key = L[i] + L[j]
        anchor = biserch(key,L)
        
        ans += max(anchor - (j+1),0)

print(ans)

Measured memory_bytes: 74420
#include <iostream>
#include <string>
#include <vector>
#include <climits>
using namespace std;

struct Color {
    string name; int r, g, b;
};
vector<Color> colors = {
    (Color){"black", 0, 0, 0},
    (Color){"blue", 0, 0, 255},
    (Color){"lime", 0, 255, 0},
    (Color){"aqua", 0, 255, 255},
    (Color){"red", 255, 0, 0},
    (Color){"fuchsia", 255, 0, 255},
    (Color){"yellow", 255, 255, 0},
    (Color){"white", 255, 255, 255}
};

int dec(char c) {
    if (isdigit(c)) return c - '0';
    return c - 'a' + 10;
}

int sq(int x) {
    return x * x;
}

int main() {
    string s;
    while (cin >> s, s != "0") {
        int r = dec(s[1]) * 16 + dec(s[2]);
        int g = dec(s[3]) * 16 + dec(s[4]);
        int b = dec(s[5]) * 16 + dec(s[6]);
        int mn = INT_MAX, k = -1;
        for (int i=0; i<(int)colors.size(); ++i) {
            int t = sq(r-colors[i].r) + sq(g-colors[i].g) + sq(b-colors[i].b);
            if (t < mn) {
                mn = t;
                k = i;
            }
        }
        cout << colors[k].name << endl;
    }
    return 0;
}

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

using namespace std;

template <typename monoid>
struct segment_tree {
    using M = monoid;
    using T = typename M::value_type;

    std::size_t sz;
    std::vector<T> x;

    segment_tree(std::size_t n = 0) {
        sz = 1;
        while (sz < n) sz *= 2;
        x.assign(sz * 2, M::id());
        initialize();
    }

    template <typename iterator>
    segment_tree(iterator first, iterator last) {
        sz = 1;
        std::size_t n = std::distance(first, last);
        while (sz < n) sz *= 2;
        x.assign(sz * 2, M::id());
        std::copy(first, last, x.begin() + sz);
        initialize();
    }

    void fill(const T &val) {
        std::fill(x.begin() + sz, x.end(), val);
        initialize();
    }

    void initialize() {
        for (int i = (int)sz - 1; i >= 1; --i) {
            x[i] = M::op(x[i * 2 + 0], x[i * 2 + 1]);
        }
    }

    T accumulate(std::size_t l, std::size_t r) const {
        T al = M::id(), ar = M::id();
        for (l += sz, r += sz; l < r; l /= 2, r /= 2) {
            if (l & 1) al = M::op(al, x[l++]);
            if (r & 1) ar = M::op(x[--r], ar);
        }
        return M::op(al, ar);
    }

    void update(std::size_t i, const T &val) {
        x[i += sz] = val;
        while (i > 1) {
            x[i / 2] = M::op(x[i], x[i ^ 1]);
            i /= 2;
        }
    }

    T operator[](std::size_t i) const { return x[sz + i]; }
};

struct max_monoid {
    using value_type = pair<int, int>;
    static constexpr value_type id() { return {std::numeric_limits<int>::max(), 0}; }
    static value_type op(const value_type &a, const value_type &b) { 
        if(a.second>b.second || (a.second==b.second && a.first < b.first)) return a;
        else return b;
    }
};



int main() {
    int n, q;
    cin >> n >> q;
    segment_tree<max_monoid> segtree(n+1);
    for(int i=1; i<=n; i++) segtree.update(i, {i, 0});
    while(q--) {
        int a, v;
        cin >> a >> v;
        const auto& now = segtree[a];
        segtree.update(a, {a, now.second+v});
        auto&& top = segtree.accumulate(1, n+1);
        cout << top.first << " " << top.second << endl;
    }
    
    return 0;
}



Measured memory_bytes: 19132
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

// ===============================================================

int main() {
	ll n; cin >> n;
	string s; cin >> s;
	ll a, b, c;
	a = b = c = 0;
	vl x(n);
	vl y(n);
	vl z(n);
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') a++; 
		if (s[i] == 'G') b++;
		if (s[i] == 'B') c++;
		x[i] = a;
		y[i] = b;
		z[i] = c;
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int k = j * 2 - i;
			if (k >= n || s[k] == s[j] || s[i] == s[j] || s[i] == s[k])continue;
			ans++;
		}
	}
	cout << a * b * c - ans << endl;
	return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  rep(i, n){
    cout << s.at(i) << t.at(i);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3584
while gets
  n,m=$_.split.map(&:to_i)
  break if n==0 and m==0
  mem=(1..n).map{|i| i}
  idx=m-1
  while mem.size>1
    mem.delete_at(idx)
    idx=(idx+m-1)%mem.size
  end
  puts mem
end

Measured memory_bytes: 8628
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define int ll
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    int n; cin>>n;
    vector<int>v(3*n);
    rep(i,3*n) cin>>v[i];
    priority_queue<int,vector<int>,greater<int>>lque;
    priority_queue<int,vector<int>>sque;
    int ls=0,ss=0;
    vector<int>lv;
    vector<int>sv;
    rep(i,n){
        lque.push(v[i]);
        sque.push(v[2*n+i]);
        ls+=v[i];
        ss+=v[2*n+i];
    }
    lv.push_back(ls);
    sv.push_back(ss);
    int ans=-INF*INF;
    cmax(ans,ls-ss);
    rep(i,n){
        lque.push(v[n+i]);
        sque.push(v[2*n-i-1]);
        ls+=v[n+i]-lque.top();
        ss+=v[2*n-i-1]-sque.top();
        lv.push_back(ls);
        sv.push_back(ss);
        sque.pop();
        lque.pop();
    }
    rep(i,lv.size())cmax(ans, lv[i]-sv[n-i]);
    cout<<ans<<endl;
}



Measured memory_bytes: 6636
#include <iostream>
#include <cstdio>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  stack<int> S1;
  stack<pair<int,int> > S2;
  char ch;
  int A=0;
  for (int i=0; cin >> ch; i++) {
    if (ch=='\\') {
      S1.push(i);
    } else if (ch=='/' && S1.size()>0) {
      int j=S1.top();
      S1.pop();
      A+=i-j;
      int a=i-j;
      while (S2.size()>0 && S2.top().first>j) {
	a+=S2.top().second;
        S2.pop();
      }
      S2.push(make_pair(j,a));
    }
  }
  vector<int> L;
  while (S2.size()>0) {
    L.push_back(S2.top().second);
    S2.pop();
  }
  reverse(L.begin(),L.end());
  printf("%d\n",A);
  printf("%d",L.size());
  for (int k=0; k<L.size(); k++) {
    printf(" %d",L[k]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 3340
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

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


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

#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define all(x) x.begin(),x.end()
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define endl "\n"
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

int main()
{
    IOS;
    ll t,k,n,d,m,u,v;
    t=1;
    //cin >> t;
    while(t--)
    {
        cin >> n;
        vector<ll> a(n);
        vector<ll> b(n);
        for(int i=0;i<n;i++)
            cin >> a[i];
        for(int i=0;i<n;i++)
            cin >> b[i];

        reverse(all(b));
        ll start=-1,end=-1;
        for(int i=0;i<n;i++)
        {
            if(a[i]==b[i])
            {
                if(start==-1)
                    start = i;
                end = i;
            }
        }

        if(start==-1)
        {
            cout << "Yes" << endl;
            for(int i=0;i<n;i++)
                cout << b[i] << " ";
            return 0;
        }

        for(int i=0;i<n;i++)
        {
            if(a[i]!=a[end] && b[i]!=a[end] && start<=end)
            {
                swap(b[i],b[start]);
                start++;
            }
        }

        if(start<=end)
        {
            cout << "No" << endl;
            return 0;
        }

        cout << "Yes" << endl;
        for(int i=0;i<n;i++)
            cout << b[i] << " ";

    }
    return 0;
}



Measured memory_bytes: 6344
s=sorted(list(input()))
t=sorted(list(input()))[::-1]
for i in range(min(len(s),len(t))):
  if(s[i]<t[i]):
    print('Yes')
    break
  elif(s[i]>t[i]):
    print('No')
    break
  else:
    if(i<min(len(s)-1,len(t)-1)):pass
    else:#sの長さまでは同じ。sの方が短ければYes、そうでなければNo
      if(len(s)<len(t)):
        print('Yes')
        break
      else:
        print('No')
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin>>s;
int ans=700;
rep(i,3){
    if(s[i]=='o')ans+=100;
}
cout<<ans<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[] ) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if(x - r < 0 || y - r < 0 || x + r > W || y + r > H){
    	System.out.println("No");
        }else{
    	System.out.println("Yes");
        }
    }
}



Measured memory_bytes: 26276
#include <iostream>
using namespace std;
int main(void){
    int a=0,b=0;
    int money=0;
    cin >> a>>b;
    while(money<1010){
        
        if(money*8/100==a&&money*10/100==b){
        break;
        }
        money++;
        if(money==1009){
            money=-1;
            break;
        }
    }
    cout << money<<endl;
}


Measured memory_bytes: 256
array = Array.new

gets.to_i.times do
  input = gets.split

  if(input[0] == "insert")
    array.unshift(input[1])
  elsif(input[0] == "delete" && (index = array.index(input[1])) != nil)
      array.delete_at(index)
  elsif(input[0] == "deleteFirst")
    array.shift
  elsif(input[0] == "deleteLast")
    array.pop
  end
end

puts array.join(" ")



Measured memory_bytes: 78268
#include <bits/stdc++.h>
#define ll long long int
#define MAX 1000000007

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    if(n<=8&&m<=8){
        cout<<"Yay!\n";
    }else{
    cout<<":(\n";
        }
    return 0;
}


Measured memory_bytes: 256
import collections

n=int(input())


X=list(map(int,input().split()))
odd=[]
even=[]
for i in range(int(n/2)):
    odd.append(X[2*i+1])
    even.append(X[2*i])

odd_counter=collections.Counter(odd) #登場回数とその値の辞書型
even_counter=collections.Counter(even)

odd_count=sorted(odd_counter.values(),reverse=True) #登場回数の多い順に並べた配列
even_count=sorted(even_counter.values(),reverse=True)

max_odd_value=max(odd_counter,key=odd_counter.get) #登場回数が最大の値
max_even_value=max(even_counter,key=even_counter.get)

if max_odd_value!=max_even_value:
    print(n-odd_count[0]-even_count[0])
elif len(set(odd))!=1 and len(set(even))!=1:
    print(min(n-odd_count[0]-even_count[1],n-odd_count[1]-even_count[0]))
elif len(set(odd))==1 and len(set(even))==1:
    print(int(n/2))
elif len(set(odd))==1:
    print(int(n/2)-even_count[1])
elif len(set(even))==1:
    print(int(n/2)-odd_count[1])

Measured memory_bytes: 19960
s = input()
t = input()

s2t = {}
t2s = {}
ans = 'Yes'
for si, ti in zip(s, t):
    if si not in s2t:
        s2t[si] = ti
    elif s2t[si] != ti:
        ans = 'No'
        break
    if ti not in t2s:
        t2s[ti] = si
    elif t2s[ti] != si:
        ans = 'No'
        break

print(ans)

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

int f(int n) {
  if (n == 0) return 1;
  return n * f(n - 1);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<double> x(N), y(N);
  for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];
  double fact = f(N);
  vector<int> v(N);
  for (int i = 0; i < N; ++i) v[i] = i;
  double ans = 0;
  do {
    double sum = 0;
    for (int i = 0; i < N - 1; ++i) {
      sum += sqrt((x[v[i + 1]] - x[v[i]]) * (x[v[i + 1]] - x[v[i]]) + (y[v[i + 1]] - y[v[i]]) * (y[v[i + 1]] - y[v[i]]));
    }
    ans += sum / fact;
  } while (next_permutation(v.begin(), v.end()));
  printf("%.10f\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int d, n;
	cin >> d >> n;
	int ans;
	if (n == 100) {
		ans = 101;
		rep(i, d) ans *= 100;
	}
	else {
		ans = n;
		rep(i, d) ans *= 100;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,i,j,minv,maxv;
    scanf("%d",&n);
    int R[n];
    for(i = 0;i < n;i++)
    {
        scanf("%d",&R[i]);
    }
    maxv = R[1] - R[0];
    minv = R[0];
    for(j = 1;j < n;j++)
    {
        if(maxv < R[j] - minv)
        {
            maxv = R[j] - minv;
        }
        if(minv > R[j])
        {
            minv = R[j];
        }
    }
    printf("%d\n",maxv);
    return 0;
}


Measured memory_bytes: 2580
group = {
    1: 0,
    3: 0,
    5: 0,
    7: 0,
    8: 0,
    10: 0,
    12: 0,
    4: 1,
    6: 1,
    9: 1,
    11: 1,
    2: 2
}
x, y = map(int, input().split(' '))
print('Yes' if group[x] == group[y] else 'No')

Measured memory_bytes: 3060
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_T _DEF(T,in,){return in<T>(gcu());}
_DEF(int,in,){return in<int>(gcu());}
struct _IN{inline operator int(){return in();}}IN;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?n=0,false:(n=in<T>(c),true);}
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int main() {
	for (int d; (d = in());) {
		int n(IN), m(IN), r {};
		vector<int> D {0, d};
		while (--n)
			D.push_back(in());
		sort(begin(D), end(D));
		while (m--) {
			int t {in()};
			auto o = lower_bound(begin(D), end(D), t);
			r += min(t - *(o - 1), *o - t);
		}
		outl(r);
	}
}


Measured memory_bytes: 2900
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
  string s;
    cin >> s;
  int ans=700;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i]=='o')ans+=100;
    }
    cout << ans << "\n";
}


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

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

    ll cnt_in = 0;
    char prec = 'A';
    for(auto c : s)
    {
        if(prec == c)
        {
            cnt_in++;
            prec = 'A';
        }
        else prec = c;
    }

    ll cnt_soto_begin = 0;
    prec = s[0];
    for(auto c : s)
    {
        if(prec == c) cnt_soto_begin++;
        else break;
    }
    ll cnt_soto_end = 0;
    for(int i=s.size()-1; i>=0; i--)
    {
        if(prec == s[i]) cnt_soto_end++;
        else break;
    }
    if(cnt_soto_begin == s.size())
    {
        cout << K * s.size() / 2 << endl;
        return 0;
    }

    cout << K * cnt_in + (K-1) * ((cnt_soto_begin%2==1 && cnt_soto_end%2==1) ? 1 : 0) << endl;




    return 0;
}


Measured memory_bytes: 3668
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;

namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        static List<List<int>> G;
        static bool[] seen;
        static int N, M;

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var input = cin.SplitRead();
            N = input[0];
            M = input[1];
            G = new List<List<int>>();
            seen = new bool[N];
            for (var i = 0; i < N; i++) G.Add(new List<int>());
            for(var i = 0; i < M; i++)
            {
                var p = cin.SplitRead();
                p[0]--;
                p[1]--;

                G[p[0]].Add(p[1]);
                G[p[1]].Add(p[0]);
            }

            long ans = 0;
            for(var i = 0; i < N; i++)
            {
                if (seen[i]) { continue; }
                ans++;
                Dfs(i);
            }
            Console.WriteLine(ans);
            

            //Console.Out.Flush();

        }
        static void Dfs(int v)
        {
            seen[v] = true;
            foreach(var nx in G[v])
            {
                if (seen[nx]) { continue; }
                Dfs(nx);
            }
        }
    }


    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }

}


Measured memory_bytes: 40952
def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


def main():
    import collections
    N = int(input())
    G = [[-1]*N for i in range(N)]

    ans = 2**(N-1)
    for i in range(N-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a][b] = i
        G[b][a] = i
    ans = 0
    g = [[0]*N for i in range(N)]
    for i in range(N):
        q = collections.deque()
        q.append((i, 0))
        r = [True]*N
        r[i] = False
        while(q):
            x, s = q.popleft()
            for y in range(N):
                if G[x][y] >= 0 and r[y]:
                    g[i][y] = s | 1 << G[x][y]
                    q.append((y, g[i][y]))
                    r[y] = False
    M = int(input())
    s = [0 for i in range(M)]
    for i in range(M):
        u, v = map(int, input().split())
        u -= 1
        v -= 1

        s[i] = g[u][v]

    # print(s)
    for i in range(2**M):
        tmp = 2**(N-1) - 1
        c = 0
        for j in range(M):
            if (i >> j) % 2 == 1:
                tmp &= ~s[j]
                c += 1
        ans += ((-1)**(c))*(1 << popcount(tmp))

    print(ans)


main()


Measured memory_bytes: 43584
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=100010;
int a[maxn],n;
int gcd(int a,int b){return (b==0)?a:gcd(b,a%b);}
bool pd(){
	 ll sum=0;
	 int ex=0,tot=0;
	 for(int i=1;i<=n;++i){
			 sum+=a[i]-1;
			 if(a[i]&1)tot++;
			 if(a[i]==1)ex=1;
	 }
	 if(ex)return sum%2;
	 if((n-tot)%2)return 1;
	 if(tot==1){
				int g=0;
				for(int i=1;i<=n;++i)if(a[i]&1)a[i]--;
				for(int i=1;i<=n;++i)g=gcd(g,a[i]);
				for(int i=1;i<=n;++i)a[i]/=g;
				return pd()^1;
	 }
	 return 0;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
			scanf("%d",&a[i]);
	}
	if (pd()) printf("First");
 	else printf("Second");
 	//system("pause");
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#define INT long long int
using namespace std;
int n, a[1010], c[8], v[8] = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200}, cnt, cnt2;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0 ; i < n ; i++ )
    {
        cin>>a[i];
        if( a[i] >= 3200 ) cnt++;
        else for(int j = 0 ; j < 8 ; j++ )
            if( a[i] < v[j] )
            {
                c[j]++;
                break;
            }
    }
    for(int i = 0 ; i < 8 ; i++) if( c[i] ) cnt2++;
    cout<<max(1,cnt2)<<" "<<cnt2+cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
N=gets.to_i
A=gets.split.map(&:to_i)
r=0
x=A[0]
result=0
(0 .. N-1).each{|l|
    loop{
        break if r>=N-1
        break if x^A[r+1] != x+A[r+1]
        r+=1
        x+=A[r]
    }
    result+=r-l+1
    x-=A[l]
}
puts result


Measured memory_bytes: 32860
#include<iostream>
using namespace std;
int main(){
	int a;
	cin>>a;
	int b[a];
	for(int i=0;i<a;i++){
	cin>>b[i];	
	}
	int c=1,d=b[0];
	for(int i=1;i<a;i++){
		if(b[i]>=b[i-1]&&b[i]>=d){
			c++;
			d=b[i];
		}
	}
	cout<<c<<endl;
	return 0;
}

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

using namespace std;

#define reset(x) memset(x, 0, sizeof(x));
#define recopy(a, b) memcpy(b, a, sizeof(a));
typedef unsigned long long ULL;
typedef long long LL;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;

int main() {
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int num = 0;
    for (char i : s) num += i - 48;
    if (num % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3784
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


N = int(input())
table = list(map(int,input().split()))

num_query = int(input())
for _ in range(num_query):
    tmp = int(input())
    L = 0
    R = len(table)-1
    mid = (L+R)//2
    loc = BIG_NUM
    while L <= R:
        if table[mid] == tmp:
            loc = mid
            break
        elif table[mid] > tmp:
            R = mid-1
        else:
            L = mid+1
        mid = (L+R)//2

    if loc == BIG_NUM:
        print("0")
    else:
        print("1")


Measured memory_bytes: 17380
N, T = map(int,input().split())
cntn = [list(map(int,input().split())) for _ in range(N)]
cost = pow(10,10)
for n in range(N):
  if cntn[n][1] <= T: cost = min(cost,cntn[n][0])
print("TLE" if cost == pow(10,10) else cost)

Measured memory_bytes: 3060
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    p = -1
    r = 0
    for i in range(N):
        r += B[A[i]-1]
        if p + 1 == A[i]:
            r += C[p - 1]
        p = A[i]
    return r
print(main())


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] d = new int[n];
		for(int i = 0 ; i < n ; i++) d[i] = sc.nextInt();
		int m = sc.nextInt();
		int[] t = new int[m];
		for(int i = 0 ; i < m ; i++) {
			t[i] = sc.nextInt();
		}
		Arrays.sort(d);
		Arrays.sort(t);
		int pos = 0;
		for(int i = 0 ; i < n && pos<= m - 1 ; i++) {
			if(d[i] == t[pos]) {
				t[pos] = -1;
				pos++;
			}
		}
		for(int i = 0 ; i < m ; i++) {
			if(t[i] != -1) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}


Measured memory_bytes: 107640
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0;

int main (){
  ll n,d;   cin >> n >> d;
  int a[n][d];

  for(int i=0;i<n;i++){//input
      for(int j=0;j<d;j++){
          cin >> a[i][j];
      }
  }

  int ch=0;
  double all=0;

  for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
          for(int k=0;k<d;k++){
              all+=pow(a[i][k]-a[j][k],2.0);
          }
          all = pow(all,0.5);
          ch = all;
          if(all == ch){
              cnt++;
              }
          all=0; ch=0;    
      }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
ans = True
a, b = map(int, input().split())
s = input()
try:
    astr, bstr = s.split('-')
    x = int(astr)
    x = int(bstr)
    if len(s) != a + b + 1: ans = False
    if len(astr) != a: ans = False
    if len(bstr) != b: ans = False
except: ans = False
    
print('Yes' if ans else 'No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll dp[21][1<<21],n,a[21][21];
ll f(ll i,ll mask)
{
	if(i==n)
		return 1;
	if(dp[i][mask]!=-1)
		return dp[i][mask];
	ll ans=0;
	rep(j,0,n)
	{
		if(a[i][j]&&(!(mask&(1<<j))))
			ans=(ans+f(i+1,mask|(1<<j)))%M;
	}
	dp[i][mask]=ans;
	return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    memset(dp,-1,sizeof(dp));
    cin>>n;
    rep(i,0,n)
    {
    	rep(j,0,n)
    		cin>>a[i][j];
    }
    cout<<f(0,0);
}


Measured memory_bytes: 344320
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
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 long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 5124