akhauriyash/Code-Regression huggingface dataset:
n = int(input())
cnt = 0
flag = False
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2 and flag == False:
        cnt += 1
        flag = True
    elif d1 == d2 and flag == True:
        cnt += 1
    else:
        flag = False
        cnt = 0
    if cnt >= 3:
        break
print('Yes' if cnt >= 3 else 'No')

Measured memory_bytes: 9196
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

    int n;
    cin>>n;
    vector<pair<double,double>> xy(n+2);
    rep(i,n){
        cin>>xy[i].first>>xy[i].second;
    }

    double nn=1;
    for(int i=1; i<=n; i++){
        nn*=i;
    }

    double sum=0.0;

    rep(i,n){
        for(int j=i+1; j<n; j++){
            double l = (double)pow(((double)pow(xy[i].first - xy[j].first, 2) + (double)pow(xy[i].second - xy[j].second, 2)), 0.5);
            sum += (double)l*(nn/n)*2.0;
        }
    }
    sum = sum/nn;

    cout<<fixed<<setprecision(10)<<sum<<endl;
}

Measured memory_bytes: 4144
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ll 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;

int main(void) {
    int a, b;
    cin >> a >> b;

    char aaa = a + '0', bbb = b + '0';

    string aa = string(a, bbb);
    string bb = string(b, aaa);

    if (aa < bb) {
        cout << aa << endl;
    } else {
        cout << bb << endl;
    }


    return 0;
}



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

bool is_check[101];

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    is_check[a] = is_check[b] = is_check[c] = true;
    int ans = 0;
    for (int i = 1; i <= 100; i++) {
        if (is_check[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int arr[N];
  int tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    tmp--;
    arr[tmp] = i;
  }
  int ans = 0;
  tmp = 1;
  for(int i=0;i<N-1;++i) {
    if(arr[i]<arr[i+1]) tmp++;
    else {
      ans = max(ans, tmp);
      tmp = 1;
    }
  }
  ans = max(ans, tmp);
  cout<<N-ans<<endl;
}



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



int main (){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0; i<N; i++)
    cin>>A.at(i);
    int MaxNum=0;
    int NextNum=0;
    for(int i=0; i<N; i++){
        if(MaxNum<A.at(i)+1){
          	NextNum=MaxNum;
            MaxNum=A.at(i);      
        }
      	else{
          NextNum=max(A.at(i), NextNum);
        }
    }
    if(MaxNum>NextNum){
        for(int i=0; i<N; i++){
            if(MaxNum==A.at(i)){
                cout<<NextNum<<endl;
            }
            else{
                cout<<MaxNum<<endl;
            }
        }
    }
    else{
        for(int i=0; i<N; i++){
            cout<<MaxNum<<endl;
        }
    }

}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	
	if((b - a) / 2 >= k)
		{
		for(int i = 0; i < k; i++)
		{
			cout << a + i << endl;
		}
		
		for(int i = k - 1; i >= 0; i--)
		{
			cout << b - i << endl;
		}
	}
	else
	{
		for(int i = a; i != b + 1; i++)
		{
			cout << i << endl;
		}
	}
	return 0;
}	

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		double[] x = new double[20];
		double[] y = new double[20];
		int i = 0;
		String string;
		
		while((string = reader.readLine()) != null){
			x[i] = Double.valueOf(string.split(",")[0]);
			y[i] = Double.valueOf(string.split(",")[1]);
			i++;
		}
		
		double a = Math.hypot(x[1] - x[0], y[1] - y[0]);
		double b = Math.hypot(x[2] - x[0], y[2] - y[0]);
		double c = Math.hypot(x[2] - x[1], y[2] - y[1]);
		double z = (a + b + c) / 2;
		double S = Math.sqrt(z * (z - a) * (z - b) * (z - c));
		for(int j = 2; j < i - 1; j++){
			a = Math.hypot(x[j] - x[0], y[j] - y[0]);
			b = Math.hypot(x[j + 1] - x[0], y[j + 1] - y[0]);
			c = Math.hypot(x[j + 1] - x[j], y[j + 1] - y[j]);
			z = (a + b + c) / 2;
			S += Math.sqrt(z * (z - a) * (z - b) * (z - c));
		}
		System.out.println(S);
	}
}

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

ll fact[200001];
ll finv[200001];
ll mod = 1e9+7;

ll mpow(ll a, ll b) {
    ll ret = 1;
    while (b > 0) {
        if (b&1) ret = ret * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}

ll c(ll n, ll k) {
    return fact[n] * finv[n-k] % mod * finv[k] % mod;    
}

int main() {
    string s;
    cin >> s;
    string ns;
    for (char c : s) {
        if (c == 'B') {
            if (!ns.empty()) ns.pop_back();
        } else ns += c;
    }
    cout << ns << endl;
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VI xs(N);
  cin >> xs;

  LL sum = 0;
  LL sum_x = 0;
  LL ans = 0;
  LL n = 0;
  for(int i=0,prv=0;i<N;++i){
	sum += xs[i];
	sum_x ^= xs[i];
	while(prv<i && sum != sum_x){
	  sum -= xs[prv];
	  sum_x ^= xs[prv];
	  prv++;
	  --n;
	}

	++n;
	ans += n;
  }

  cout << ans << endl;

  return 0;
}
	

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

// x が (a[i] * f[i]) の最大値になるなら true
bool check(ll x, vll &a, vll &f, ll k){
    ll n = a.size();
    ll cnt = 0;
    REP(i, n){
        if (a[i] * f[i] > x) {
            cnt += (a[i] * f[i] - x) / f[i];
            if ((a[i] * f[i] - x) % f[i]) cnt++;
        }
    }
    if (cnt > k) return false;
    else return true;
}

// max(a[i] * f[i]) の最小値 x を二分探索
ll search(vll &a, vll &f, ll k){
	ll ng = -1;
	ll ok = 1e18;

    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (check(mid, a, f, k)) ok = mid;
        else ng = mid;
    }
    return ok;
}

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

    ll n, k;
    cin >> n >> k;

    vll a(n), f(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> f[i];
    VSORTR(a);
    VSORT(f);

    ll res = search(a, f, k);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;

int main() {

    int n;
    cin >> n;

    long long ans = 0;
    for(int i=2; i<=n; i++) {
        ans += (i - 1);
    }

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


Measured memory_bytes: 256
import math
n = int(input())
a = list(map(int,input().split()))
maxlog = int(math.log2(max(a)))
answer = 0
for _ in range(maxlog):
  a = [aa/2 for aa in a if aa%2==0]
  answer+= len(a)
  if not a:
    break
print(answer)

Measured memory_bytes: 4148
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;

typedef complex<double> P;

#define X real()
#define Y imag()

double is_X (P p1, P p2, P p3, P p4) {
    return ((p1.X-p2.X) * (p3.Y-p1.Y) + (p1.Y-p2.Y) * (p1.X-p3.X)) * ((p1.X-p2.X) * (p4.Y-p1.Y) + (p1.Y-p2.Y) * (p1.X-p4.X));
}

int main(){
    int mod=1000000007;
    int a,b,c;
    double xa,xb,xc,xd,ya,yb,yc,yd;
    while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF) {
        P a(xa,ya);
        P b(xb,yb);
        P c(xc,yc);
        P d(xd,yd);

        if (is_X(a,c,b,d)>0.0 || is_X(b,d,a,c)>0.0) {
            printf("NO\n");
        } else {
            printf("YES\n");
        }
    }
    return 0;
}

Measured memory_bytes: 3260
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

T1, T2 = MAP()
A1, A2 = MAP()
B1, B2 = MAP()

if T1*A1+T2*A2 == T1*B1+T2*B2:
    print("infinity")
    exit()
if (A1 < B1 and A2 < B2) or (B1 < A1 and B2 < A2):
    print(0)
    exit()

if A1 > B1:
    A1, B1 = B1, A1
    A2, B2 = B2, A2

if A1*T1+A2*T2 < B1*T1+B2*T2:
    print(0)
    exit()

F = A1*T1-B1*T1
L = A2*T2-B2*T2

S, T = divmod(-F, F+L)

if T == 0:
    print(2*S)
else:
    print(2*S+1)


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

void fff(string s = "") {
	if (s == "1") cin >> s;
	if ((int)s.size() >= 4) {
		freopen(s.c_str(),"r",stdin);
	}
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  fff("");
  string s = "ACL";
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cout << s;
} 

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, ans = 0;
	cin >> n;
	vector<string> s(n);
	vector< vector<int> > path(n), child(1, vector<int>(26));
	vector<bool> isend(1, 0);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		reverse(s[i].begin(), s[i].end());
		int node = 0;
		for (int j = 0; j < s[i].size(); j++) {
			path[i].push_back(node);
			if (!child[node][s[i][j] - 'a']) {
				child[node][s[i][j] - 'a'] = child.size();
				child.push_back(vector<int>(26));
				isend.push_back(0);
			}
			node = child[node][s[i][j] - 'a'];
		}
		isend[node] = 1;
	}
	for (int i = 0; i < n; i++) {
		set<char> suffix;
		for (int j = s[i].size() - 1; j >= 0; j--) {
			suffix.insert(s[i][j]);
			int node = path[i][j];
			for (set<char>::iterator k = suffix.begin(); k != suffix.end(); k++) ans += isend[child[node][*k - 'a']];
		}
	}
	cout << ans - n << "\n";
	return 0;
}

Measured memory_bytes: 142516
using System.Linq;
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var result = GettingStarted.SmallLargeOrEqual();
            System.Diagnostics.Trace.WriteLine(result);
            Console.WriteLine(result);
        }
    }

    public static class GettingStarted
    {
        public static string SmallLargeOrEqual() {
            var input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            if (input[0] == input[1])
            {
                return "a == b";
            }
            return input[0] < input[1] ? "a < b" : "a > b";
        }
    }
}

Measured memory_bytes: 20004
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   if(a+b==c+d)
        cout<<"Balanced"<<endl;
   else if(a+b>c+d)
   cout<<"Left"<<endl;
   else
    cout<<"Right"<<endl;

    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    long int const mod = 1000000007;
    long int n;
    cin >> n;
    long int ans = 1;
    rep(i, n){
        ans *= i + 1;
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#include<set>
#define ws " "
#define nl "\n"
#define tc ll test; cin>>test; while(test--)
#define f(i, a, b) for(ll i = a; i<b; i++)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#include<fstream>

using namespace std;

#define pll pair<ll, ll>
bool compare(pll a, pll b)
{
	//for descending order replace with a.roll >b.roll
   if((a.ff < b.ff)||((a.ff==b.ff)&&a.ss<b.ss))
        return 1;
	else
		return 0;
}

ll power(ll x,  ll y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}


void solve()
{
  int x;
  cin>>x;

  if(x>=30)
    cout<<"Yes"<<nl;
  else cout<<"No"<<nl;
}


int main()
{
    fastIO;
   // tc

    //cout<<"Case #"<<i+1<<" :"<<nl;
    solve();


}


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

const int MOD = 998244353;

const int N = 5000001;
long long fact[N];
long long invfact[N];
long long inv[N];
void init() {
        fact[0] = fact[1] = 1;
        for (int i = 2; i < N; i ++) fact[i] = fact[i - 1] * i % MOD;
        inv[1] = 1;
        for (int i = 2; i < N; i ++) inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
        invfact[0] = invfact[1] = 1;
        for (int i = 2; i < N; i ++) invfact[i] = invfact[i - 1] * inv[i] % MOD;
}
long long C(long long n, long long r) {
        if (n < 0 || r < 0 || n < r) return 0;
        return fact[n] * invfact[n - r] % MOD * invfact[r] % MOD;
}

long long Pow(long long a, long long x) {
	long long res = 1;
	while (x) {
		if (x & 1) res = res * a % MOD;
		a = a * a % MOD;
		x >>= 1;
	}
	return res;
}

int main() {
	init();
	int k, n;
	scanf("%d%d", &k, &n);
	for (int sum = 2; sum <= 2 * k; sum ++) {
		int s = 0;
		for (int one = 1; one <= k; one ++) {
			int other = sum - one;
			if (one < other && other <= k) {
				s ++;
			}
		}
		long long ans = 0;
		if (sum & 1) {
			for (int t = 0; t <= min(n, s); t ++) {
				ans += Pow(2, t) * C(s, t) % MOD * C(k - s + t - s + (n - t) - 1, n - t) % MOD;
			}
		} else {
			for (int t = 0; t <= min(n, s); t ++) {
				ans += Pow(2, t) * C(s, t) % MOD * C(k - s + t - s + (n - t) - 2, n - t) % MOD;
				ans += Pow(2, t) * C(s, t) % MOD * C(k - s + t - s + (n - t) - 3, n - t - 1) % MOD;
			}
		}
		printf("%lld\n", ans % MOD);
	}
        return 0;
}


Measured memory_bytes: 117504
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
int64 gcd(int64 a, int64 b) {
	return b != 0 ? gcd(b, a % b) : a;
}
int64 lcm(int64 a, int64 b) {
	int64 g = gcd(a, b);
	return a / g * b;
}
void solve() {
	int n; cin >> n;
	vector<int64> t(n);
	rep (i, n) {
		cin >> t[i];
		if (n == 1) {
			cout << t[0] << endl;
			return;
		}
	}
	int64 ans = t[0];
	for (int i = 1; i < n; ++i) {
		if (ans != t[i]) {
			ans = lcm(ans, t[i]);
		}
	}
	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>

long long n;
namespace solver1 {
  int a[20];
  void main() {
    int cnt = 0;
    while(n) a[++cnt] = n % 10, n /= 10;
    int ans = 0, cur = 0;
    for (int i = cnt; i >= 1; i--) {
      if (a[i]) ans = std::max(ans, cur + a[i] - 1 + (i - 1) * 9);
      cur += a[i];
    }
    ans = std::max(ans, cur);
    printf("%d\n", ans);
  }
}
int main() {
  scanf("%lld", &n);
  solver1::main();
}


Measured memory_bytes: 128
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

long a[100000];
long b[100000];
long c[100000];
long dp[100010][3];

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

	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}

	for (int i = 1; i <= n; i++)
	{
		dp[i][0] = max(dp[i - 1][1] + a[i-1], dp[i - 1][2] + a[i - 1]);
		dp[i][1] = max(dp[i - 1][0] + b[i - 1], dp[i - 1][2] + b[i - 1]);
		dp[i][2] = max(dp[i - 1][0] + c[i - 1], dp[i - 1][1] + c[i - 1]);
	}

	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}


Measured memory_bytes: 36224
S = input()
if S[0] == S[1] == S[2] == 'R':
    print(3)
elif S[0] == S[1] == 'R' or S[2] == S[1] == 'R':
    print(2)
elif S[0] == S[1] == S[2] == 'S':
    print(0)
else:
    print(1)

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

const int N = 200010;
int p[N] , Size[N] , n , m , ans;

int find(int x)
{
	return p[x] == x ? x : p[x] = find(p[x]);
}

int main()
{
	scanf("%d%d" , &n , &m);
	for(int i = 1 ; i <= n ; i++)
		p[i] = i ;
	for(int i = 1 , x , y ; i <= m ; i++)
	{
		scanf("%d%d" , &x , &y);
		int X = find(x) , Y = find(y);
		if(X == Y) continue;
		else
			p[X] = p[Y];
	}
	for(int i = 1 ; i <= n ; i++)
		Size[find(i)]++;
	for(int i = 1 ; i <= n ; i++)
		ans = max(ans , Size[i]);
	printf("%d" , ans);
	return 0;
}

Measured memory_bytes: 10580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll sum=0;
  ll p=1e9+7;
  for(ll i=0;i<n;i++){
    cin >> a.at(i);
    if(i==0){
      continue;
    }
    sum+=a.at(i);
    sum%=p;
  }
  ll ans=0;
 for(ll i=0;i<n-1;i++){
    ans+=sum*a.at(i);
    sum=sum-a.at(i+1);
   if(sum<0){
     sum=sum+p;
   }
    ans=ans%p;
  }
  cout << ans;
}

Measured memory_bytes: 4840
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define Max 1001
#define INF 0x3f3f3f3f
using namespace std;
int main()
{
    long long n,a[100] = {2,1};
    cin>>n;
    for(int i = 2;i <= n;i ++)
        a[i] = a[i - 1] + a[i - 2];
    cout<<a[n];
}


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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

int val[3010][3010];
ll dp[3010][3010][4];

int main(){
	int n, m, k;
	sii(n, m);
	si(k);
	while(k--){
		int a, b;
		sii(a, b);
		si(val[a][b]);
	}

		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= m; j++){
				for(int c = 1; c <= 3; c++){
					ll ans = max(dp[i-1][j][3], dp[i][j-1][c]);
					ans = max(ans, max(dp[i-1][j][3], dp[i][j-1][c-1]) + val[i][j]);
					dp[i][j][c] = ans;
				}
			}
	ll ans = max(dp[n][m][1], dp[n][m][2]);
	ans = max(ans, dp[n][m][3]);
	printf("%lld\n", ans);
	return 0;
}


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

int n;
string s;
int data[1111];
int memo[1111][11];

int solve(int p, int bit){

  if((data[s[p]] & bit) == 0) return 0;
  if(p == n-1) return 1;
  if(~memo[p][bit]) return memo[p][bit];

  int ret = 0;
  for(int i=0;i<8;i++) if((i & bit)) ret = (ret + solve(p+1, i)) % 10007;

  return memo[p][bit] = ret;
}

int main(){

  data['J'] = 1; data['O'] = 2; data['I'] = 4;
  
  cin >> n >> s;

  memset(memo, -1, sizeof(memo));
  int ans = 0;
  for(int i=0;i<8;i++) if(data['J'] & i) ans += solve(0, i);
  
  cout << ans%10007 << endl;

}

Measured memory_bytes: 1324
n = int(input())
s = 0
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

for i in range(n-1):
    for j in range(i+1,n):
        s += ((x[i]-x[j])**2 + (y[i]-y[j])**2) ** (1/2)

print(s * (n-1) / (n*(n-1)/2))


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

int main(){

  int n, k;
  while( cin >> n >> k, n+k ) {
    int max_sum, sum = 0, data[100000];
    
    for(int i=0; i<k; i++) {
      cin >> data[i];
      sum += data[i];
    }
    max_sum =sum;

    for(int i=k; i<n; i++) {
      cin >> data[i];
      sum -= data[i-k];
      sum += data[i];
      max_sum = max(max_sum, sum);
    }

    cout << max_sum << endl;
  }
}

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

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

    if (N % (2 * D + 1) == 0)
    {
        cout << N / (2 * D + 1) << endl;
    }
    else
    {
        cout << N / (2 * D + 1) + 1 << endl;
    }
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll dfs(Graph& g,Array& used,Array& d,ll v){
		bool ret=true;
		for(auto e:g[v]){
			if(used[e.to]){
				if(d[e.to]!=d[v]+e.cap){
					ret=false;
				}
			}else{
				used[e.to]=true;
				d[e.to]=d[v]+e.cap;
				if(!dfs(g,used,d,e.to))ret=false;
			}
		}
		return ret;
}

void solve(){
	ll n,m;
	cin>>n>>m;
	Graph g(n);
	REP(i,m){
		ll l,r,d;
		cin>>l>>r>>d;
		l--;r--;
		add_edge(g,l,r,d,true,-d);
	}

	Array used(n,false);
	Array d(n,-1);

	REP(i,n){
		if(used[i]) continue;
		used[i]=true;
		d[i]=0;
		if(!dfs(g,used,d,i)){
			cout<<"No"<<en;
			return;
		}
	}

	cout<<"Yes"<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 23296
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	char a, b; cin >> a >> b;
	
	if((a == 'H') ^ (b == 'H')) cout << "D" << endl;
	else cout << "H" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>
#include <bitset>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
static const int MOD = 10000007;
static const int MAX = 100005;
// static const int NMAX = 5005;

int h, w, a, b;


int main(){
  cin >> h >> w >> a >> b;
  if ( a != 0 && b != 0) {
    rep(i, h) {
      rep(j, w) {
        if ((i < b && j < a) || (i >= b && j >= a)) {
          cout << 1;
        } else {
          cout << 0;
        }
        if (j == w-1) cout << endl;
      }
    }
  } else if ( a == 0 && b != 0) {
    rep(i, h) {
      rep(j, w) {
        if (i < b) {
          cout << 0;
        } else {
          cout << 1;
        }
        if (j == w-1) cout << endl;
      }
    }
  } else if (b == 0 && a != 0) {
    rep(i,h){
      rep(j,w){
        if ( j < a ) {
          cout << 0 ;
        } else {
          cout << 1 ;
        }
        if (j == w-1) cout << endl;
      }
    }
  } else {
    rep(i, h)rep(j,w) {
      cout << 0;
      if (j == w-1) cout << endl;
    }
  }
}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

ll mod_pow(ll a, ll n, ll p) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		ll tmp = mod_pow(a, n / 2, p);
		return (tmp * tmp) % p;
	}
	return (a * mod_pow(a, n - 1, p)) % p;
}

// 多項式P(x)を受け取って(x-s)P(x)+tという多項式を返す
// 係数はmod p
vector<ll> mul(const vector<ll> &P, int s, int t, ll p) {
	vector<ll> Q(P.size() + 1);
	for (int i = 0; i < P.size(); i++) {
		(Q[i + 1] += P[i]) %= p;
		(Q[i] += P[i] * (p - s) % p) %= p;
	}
	(Q[0] += t) %= p;
	return Q;
}

ll inv[2999];
ll a[2999];
int main() {
	int p;
	cin >> p;
	for (int i = 1; i < p; i++) {
		inv[i] = mod_pow(i, p - 2, p);
	}
	for (int i = 0; i < p; i++) cin >> a[i];
	vector<ll> s, t;
	for (int i = 0; i < p; i++) {
		s.push_back(i);
		t.push_back(a[i]);
		for (int j = i + 1; j < p; j++) {
			(a[j] += p - a[i]) %= p;
			(a[j] *= inv[j - i]) %= p;
		}
	}
	vector<ll> P = { 1 };
	for (int i = p - 1; i >= 0; i--) {
		P = mul(P, s[i], t[i], p);
	}
	(P[1] += P[p]) %= p;
	for (int i = 0; i < p; i++) cout << P[i] << " ";
	cout << endl;
}


Measured memory_bytes: 512
N,K = map(int, input().split())
V = list(map(int, input().split()))
ans = -1 * (10**10)
for left in range(min(K+1, N+1)):
	for right in range(0, min(K-left+1, N-left+1)):
		push = K - left - right
		items = []
		items.extend(V[:left])
		items.extend(V[N-right:])
		items.sort()
		tmp = 0
		for idx in range(len(items)):
			if(idx >= push or items[idx] > 0):
				tmp += items[idx]
		ans = max(ans, tmp)
print(ans)

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

#define debug(x)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sq(x) ((x) * (x))
#define PRECISION 30

using namespace std;

template<class T> int check_mod(T a, T b) { return (a % b) ? 1 : 0; }
template<class T> void maxi(T &a, T b) { a = max(a, b); return; }
template<class T> void mini(T &a, T b) { a = min(a, b); return; }

bool is_prime(int a) { if (a == 2) return true; if (!(a & 1) || a == 1) return false; for (int i = 3; i * i <= a; i += 2) if (!(a % i)) return false; return true; }
bool is_prime(ll a) { if (a == 2) return true; if (!(a & 1) || a == 1) return false; for (ll i = 3; i * i <= a; i += 2) if (!(a % i)) return false; return true; }
bool is_palindrome(string s) { int len = (int)s.length(); int mid = len >> 1; for (int i = 0; i < mid; i++) if (s[i] != s[len - i - 1]) return false; return true; }
int gcd(int a, int b) { while (b) { int mod = a % b; a = b; b = mod; } return a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int binpow(int a, int b) { int res = 1; while (b) { if (b & 1) res *= a; a *= a; b >>= 1; } return res; }
int binpow(int a, int b, int MODULO) { int res = 1; while (b) { if (b & 1) { res *= a; res %= MODULO; } a *= a;  a %= MODULO; b >>= 1; } return res; }
ll gcd(ll a, ll b) { while (b) { ll mod = a % b; a = b; b = mod; } return a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll binpow(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res *= a; a *= a; b >>= 1; } return res; }
ll binpow(ll a, ll b, ll MODULO) { ll res = 1; while (b) { if (b & 1) { res *= a; res %= MODULO; } a *= a;  a %= MODULO; b >>= 1; } return res; }
string binary(int N) { if (!N) return "0"; string bin = ""; while (N) { bin += '0' + (N & 1); N >>= 1; } reverse(all(bin)); return bin; }
string binary(ll N) { if (!N) return "0"; string bin = ""; while (N) { bin += '0' + (N & 1); N >>= 1; } reverse(all(bin)); return bin; }
           
const int INF = 2147483547;           // Max int value - 100 so it will not overflow
const int MODULO = 1000000007;
const int _MODULO = 998244353;
const ll INF64 = 9223372036854775707; // Max long long value - 100 so it will not overflow
const ll MODULO64 = 1000000007;
const ll _MODULO64 = 998244353;
const double epsilon = 10e-6;
const double PI = acos(-1);

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	auto t1 = chrono::high_resolution_clock::now();
    #define debug(x) cerr << #x << " = " << x << "\n";                        
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll H;
	cin >> H;
	ll pw = 1LL, ans = 0;
	while (pw <= H) {
		ans += pw;
		pw <<= 1LL;
	}
	cout << ans << '\n';
#ifdef LOCAL
	auto t2 = chrono::high_resolution_clock::now();
	cerr << "Running time " << chrono::duration_cast<chrono::nanoseconds>(t2 - t1).count() << " nanoseconds" << endl;
#endif
	return 0;
}

Measured memory_bytes: 256
A, B, C, D = [int(_) for _ in input().split()]

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

def lcm(a, b):
    return a * b // gcd(a, b)

def dvi_num2(b, c, d):
    return b - b // c - b //d + b // lcm(c, d)

ans = dvi_num2(B, C, D) - dvi_num2(A - 1, C, D)
print(int(ans))

Measured memory_bytes: 3064
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
max = 0
for ss in s:
  if s.count(ss) -t.count(ss) > max:
    max = s.count(ss) - t.count(ss)
print(max)

Measured memory_bytes: 3060
n=input().split()
rap=int(n[0])
sap=int(n[1])
map=[]
hap=[[] for i in range(1,rap+1)]
count=0
visited=[0 for i in range(1,1+rap)]
for i in range(sap):
    knight=input().split()
    morn=int(knight[0])-1
    after=int(knight[1])-1
    hap[morn].append(after)
    hap[after].append(morn)
    map.append([morn,after])
def dfs(u):
    visited[u]=1
    for v in king[u]:
        if visited[v]==0:
            dfs(v)
for j in range(sap):
    king=hap.copy()
    visited=[0 for i in range(1,rap+1)]
    king[map[j][0]].remove(map[j][1])
    king[map[j][1]].remove(map[j][0])
    dfs(map[j][0])
    king[map[j][0]].append(map[j][1])
    king[map[j][1]].append(map[j][0])
    sum=0
    for i in range(len(visited)):
        sum+=visited[i]
    if sum<rap:
        count+=1
print(count)


Measured memory_bytes: 3064
#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 () {
    int n;
	cin >> n;

    ll sum = 0;
    for (int i = 0; i <= n ; i++) {
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        sum += i;
    }

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3600
##RGBからひとつづつ
##かつ
from collections import Counter

n=int(input())
s = input()
sc= Counter(list(s))
ans= 0
try:
    ans =  sc["R"]*sc["G"]*sc["B"]
except:
    print(0)
    exit()

for j in range(n):
    for i in range(j):
        if 2*j-i<n:
            flag = True
            for c in {"R","G","B"}:
                if c not in {s[i],s[j],s[2*j-i]}:
                    flag = False
            if flag:
                ans-=1
                

print(ans)


Measured memory_bytes: 74724
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll cnt;

int main(){
	ll l,r,d;
	cin >> l >> r >> d;
	ll num = d; 
	ll tmp=d;
	while(d<=r){
		if(d>=l)
			cnt++;
		d+=num;
	}	
	cout << cnt << endl;
}

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef pair <ll ,ll> pll;
typedef pair <int ,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define print(a) {for (auto iiiiiiiiii : a) cout << iiiiiiiiii << ' '; cout << '\n';}
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()

ll next() {ll x; cin >> x; return x;}

const ll inf = 1e18 , mod = 998244353;
const int intf = 2e9 , maxn = 1e5;
const double PI = 3.141592653589 , eps = 1e-8;


void solve(){
    string s; cin >> s;
    int cnta = 0 , n = s.size();
    ll ans = 0;
    for (int i = 0 ; i < n; i ++){
        if (s[i] == 'A') cnta++;
        if (s[i] == 'C') cnta = 0;
        if (s[i] == 'B' && (i + 1 >= n || s[i + 1] != 'C')) cnta = 0;
        if (i + 1 < n && s[i] == 'B' && s[i + 1] == 'C'){
            ans += cnta;
            i++;
        }
    }
    cout << ans;
}

int main()
{
    #ifdef HERE
        freopen("input.txt" , "r" , stdin);
    #else
        //freopen(".in" , "r" , stdin); freopen(".out" , "w" , stdout);
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #endif
    cout.precision(20);

    int t = 1;
    while(t --> 0){
        solve();
    }


    #ifdef HERE
        cout << setprecision(3) << fixed << "\n\nRuntime: " << (long double)(clock()) / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}
/*

*/


Measured memory_bytes: 720
dice = input().rstrip().split(' ')
indication = "EEENEEENEEESEEESEEENEEENSWWSWWWNWWWNWWWSWWWSWWW"
indic = list(indication)
length = len(indic)
num = int(input())
for j in range(num):
  s = input().rstrip().split(' ')
  top = int(s[0])
  front = int(s[1])
  for i in range(length):
    newdice = [0] * 6
    if str(indic[i]) == "N":
      newdice[0] = dice[1]
      newdice[1] = dice[5]
      newdice[2] = dice[2]
      newdice[3] = dice[3]
      newdice[4] = dice[0]
      newdice[5] = dice[4]
      dice = newdice
      if int(dice[0]) == top and int(dice[1]) == front:
        print(int(dice[2]))
        break;
    elif str(indic[i]) == "S":
      newdice[0] = dice[4]
      newdice[1] = dice[0]
      newdice[2] = dice[2]
      newdice[3] = dice[3]
      newdice[4] = dice[5]
      newdice[5] = dice[1]
      dice = newdice
      if int(dice[0]) == top and int(dice[1]) == front:
        print(int(dice[2]))
        break;
    elif str(indic[i]) == "E":
      newdice[0] = dice[3]
      newdice[1] = dice[1]
      newdice[2] = dice[0]
      newdice[3] = dice[5]
      newdice[4] = dice[4]
      newdice[5] = dice[2]
      dice = newdice
      if int(dice[0]) == top and int(dice[1]) == front:
        print(int(dice[2]))
        break;
    elif str(indic[i]) == "W":
      newdice[0] = dice[2]
      newdice[1] = dice[1]
      newdice[2] = dice[5]
      newdice[3] = dice[0]
      newdice[4] = dice[4]
      newdice[5] = dice[3]
      dice = newdice
      if int(dice[0]) == top and int(dice[1]) == front:
        print(int(dice[2]))
        break;



Measured memory_bytes: 5624
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  ll x;
  cin >>x;
  /*
  vector<ll> fifth;
  for(ll i=-700; i<=700; i++){
    fifth.push_back(i*i*i*i*i);
  }
  int siz=fifth.size();
  rep(i,siz){
    for(int j=i+1; j<siz; j++){
      if(fifth[j]-fifth[i]==x){
        cout << fifth[j] << " " << fifth[i] << endl;
        return 0;
      }
    }
  }*/
  for(ll i=-700; i<=700; i++){
    for(ll j=i+1; j<=700; j++){
      if(j*j*j*j*j-i*i*i*i*i==x){
        cout << j<< " " << i << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3612
<?php
$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
$ans = 0;
foreach ($a as $key => $value) {
    if ((1 + $key) % 2 !== 0 and $value % 2 !== 0) {
        ++$ans;
    }
}
echo $ans . PHP_EOL;

Measured memory_bytes: 16212
package main

import (
    "fmt"
    "os"
    "bufio"
    "strconv"
    "sort"
    "math"
)

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
    sc.Split(bufio.ScanWords)

    n, k := nextInt(), nextInt()

    n1 := n - (n / k) * k
    n2 := math.Abs(float64(n - ((n / k) + 1) * k))

    fmt.Println(min(n1, int(n2)))
}

// Library

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func nextInt() int {
    sc.Scan()
    i, _ := strconv.Atoi(sc.Text())
    return i
}

func nextIntArr(n int) []int {
    var a []int
    for i := 0; i < n; i++ {
        a = append(a, nextInt())
    }
    return a
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}

func strReverse(s string) string {
    runes := []rune(s)
    for i := 0; i < len(s)/2; i++ {
        runes[i], runes[len(s)-1-i] = runes[len(s)-1-i], runes[i]
    }
    return string(runes)
}



Measured memory_bytes: 640
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int nth(int S, int n) {
  return (S>>n)&1;
}

int main() {
  int h, w, k; cin >> h >> w >> k;
  vector<string> A(h);
  loop(i,0,h) cin >> A[i];
  ll ans = 0;
  for (int R=0; R<1<<h; R++) {
    for (int C=0; C<1<<w; C++) {
      ll cnt = 0;
      loop(i,0,h) {
        loop(j,0,w) {
          if (nth(R, i) or nth(C, j)) continue;
          cnt += A[i][j] == '#';
        }
      }
      ans += cnt == k;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double x1 = scan.nextDouble(), y1 = scan.nextDouble(),
                x2 = scan.nextDouble(), y2 = scan.nextDouble();
        double dx = Math.abs(x2 - x1), dy = Math.abs(y2 - y1);
        double distance = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));

        System.out.println(distance);
    }
}

Measured memory_bytes: 27980
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    string o, e;
    cin >> o >> e;
    string ans = "";
    for (int i = 0; i < (int)o.size(); i++) {
        ans.push_back(o[i]);
        if (i < (int)e.size()) ans.push_back(e[i]);
    }
    cout << ans << endl;
}


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

#define For(i, j, k) for (int i = j; i <= k; i++)
#define Forr(i, j, k) for (int i = j; i >= k; i--)

using namespace std;

const int N = 1e6 + 10;

int n, a, b;
int A[N], S[N];
int buffer[N << 1], *dp;

int main() {

	scanf("%d%d%d", &n, &a, &b);
	n -= 2;
	For(i, 1, n - 1) scanf("%d", &A[i]), S[i] = S[i - 1] + A[i];
	dp = buffer + N - 5;
	For(i, 0, S[n - 1]) dp[i] = i;
	For(i, 1, n - 1) {
		dp -= A[i];
		For(j, 0, A[i] - 1) dp[j] = dp[2 * A[i] - j];
	}
	
	int q;
	scanf("%d", &q);
	For(T, 1, q) {
		scanf("%d", &A[n]);
		printf("%d%c", A[n] > S[n - 1] ? A[n] - S[n - 1] + a - b : dp[A[n]] + a - b, T == q ? '\n' : ' ');
	}

	return 0;
}

Measured memory_bytes: 16512
N = int(input())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))
ans = 0
carry = 0
for i in range(1, N+1):
    if A[i] - carry >= B[i]:
        carry = 0
        ans += B[i]
    else:
        ans += min(B[i], A[i] + A[i+1] - carry)
        carry = min(A[i+1], B[i] + carry - A[i])

print(ans)

Measured memory_bytes: 18348
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,(n))
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	int N, K;
	string S;
	cin >> N >> S >> K;

	REP(i, N) {
		if (S[i] != S[K - 1]) {
			S[i] = '*';
		}
	}

	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
typedef pair<string, string> P;
map<P, int> mp;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    rep(bit, (1 << N)) {
        string S1, S2;
        rep(i, N) {
            if(bit & (1 << i)) S1 += S[i];
            else S2 = S[i] + S2;
        }
        //cout << S1 << " " << S2 << endl;
        mp[{S1, S2}]++;
    }
    ll ans = 0;
    rep(bit, (1 << N)) {
        string S1, S2;
        rep(i, N) {
            if(bit & (1 << i)) S1 += S[N + i];
            else S2 = S[N + i] + S2;
        }
        ans += mp[{S2, S1}];
    }

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


Measured memory_bytes: 60888