akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

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

   if (S[0] == 'W' || S[2 * N - 1] == 'W') {
      cout << 0 << endl;
      return 0;
   }
   string S2 = "L";
   int cntL[2 * N];
   int cntR[2 * N];
   cntR[0] = 0;
   cntL[0] = 1;
   for (int i = 1; i < 2 * N - 1; i++) {
      if (S[i] == 'W') {
         if ((cntL[i - 1] - cntR[i - 1]) % 2 == 1) {
            S2 += "L";
            cntL[i] = cntL[i - 1] + 1;
            cntR[i] = cntR[i - 1];
         } else {
            S2 += "R";
            cntR[i] = cntR[i - 1] + 1;
            cntL[i] = cntL[i - 1];
         }
         if (cntL[i] < cntR[i]) {
            cout << 0 << endl;
            return 0;
         }
      } else {
         if ((cntL[i - 1] - cntR[i - 1]) % 2 == 0) {
            S2 += "L";
            cntL[i] = cntL[i - 1] + 1;
            cntR[i] = cntR[i - 1];
         } else {
            S2 += "R";
            cntR[i] = cntR[i - 1] + 1;
            cntL[i] = cntL[i - 1];
         }
         if (cntL[i] < cntR[i]) {
            cout << 0 << endl;
            return 0;
         }
      }
   }
   S2 += "R";
   cntL[2 * N - 1] = cntL[2 * N - 2];
   cntR[2 * N - 1] = cntR[2 * N - 2] + 1;
   if (cntL[2 * N - 1] != cntR[2 * N - 1]) {
      cout << 0 << endl;
      return 0;
   }
   // cout << S2 << endl;
   /*   
   for (int i = 0; i < 2 * N; i++) {
      cout << i << " " << cntL[i] << " " << cntR[i] << endl;
   }
   */
   ll ans = 1;
   for (int i = 1; i < 2 * N; i++) {
      if (S2[i] == 'L') continue;
      ans *= cntL[i - 1] - cntR[i - 1];
      // cout << i << " " << cntL[i - 1] - cntR[i - 1] << endl;
      ans %= MOD;
   }
   // cout << ans << endl;
   for (int i = 1; i <= N; i++) {
      ans *= i;
      ans %= MOD;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 2312
#include <stdio.h>

int main(){
    long long int n;scanf("%lld",&n);
    long long int h[n];
    for (int i = 0; i <n ; ++i) {
        scanf("%lld",&h[i]);
    }
    long long int ans1=0,ans2=0;
    for (int i = 0; i <n ; ++i) {
        if(h[i]>=h[i+1]) {
            ans2++;
        }else {
            if (ans2>ans1) {
                ans1 = ans2;

            }
            ans2=0;
        }
    }
    printf("%lld",ans1);
}

Measured memory_bytes: 896
N,Q = [int(x) for x in input().split()]
S = input()
l = [0]*Q
r = [0]*Q
li = [0]*(N+1)
for i in range(Q):
    l[i],r[i] = [int(x) for x in input().split()]
state = 0
for index,j in enumerate(S):
    li[index+1]=li[index]
    if(state == 1):
        if(j == 'C'):
            li[index+1]+=1
        state = 0
    if(j == 'A'):
        state = 1
        
for i in range(Q):
    print(li[r[i]]-li[l[i]])


Measured memory_bytes: 14212
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

class FastPF {
private:
	vector<int> primes;
	vector<bool> isprime;
	vector<int> min_factor;
public:
	FastPF(int MAX) : primes(), isprime(MAX+1, true), min_factor(MAX+1, -1) {
		isprime[0] = isprime[1] = false;
		min_factor[0] = 0, min_factor[1] = 1;
		for (int i = 2; i <= MAX; ++i) {
			if (!isprime[i]) continue;
			primes.push_back(i);
			min_factor[i] = i;
			for (int j = i*2; j <= MAX; j += i) {
				isprime[j] = false;
				if (min_factor[j] == -1) min_factor[j] = i;
			}
		}
	}

	// prime factorization
	vector<pair<int,int>> prime_factorize(int n) {
		vector<pair<int,int>> res;
		while (n != 1) {
			int prime = min_factor[n];
			int exp = 0;
			while (min_factor[n] == prime) {
				++exp;
				n /= prime;
			}
			res.push_back(make_pair(prime, exp));
		}
		return res;
	}
};

ll get_gcd(ll x, ll y) {
	if (y > 0) return get_gcd(y, x % y);
	else return x;
}

int A[1000000];

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

	FastPF fpf(1000000);

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

	unordered_map<int, int> cnt;
	bool is_pairwise_coprime = true;
	for (int i=0; i<N; i++) {
		vector<pair<int,int>> pf = fpf.prime_factorize(A[i]);
		for (pair<int, int> p : pf) {
			cnt[p.first]++;
			if (cnt[p.first] >= 2) is_pairwise_coprime = false;
		}
	}

	if (is_pairwise_coprime) {
		cout << "pairwise coprime" << endl;
		return 0;
	}

	bool setwise_coprime = true;
	int gcd = A[0];
	for (int i=1; i<N; i++) {
		gcd = get_gcd(gcd, A[i]);
	}

	if (gcd != 1) setwise_coprime = false;

	if (setwise_coprime) {
		cout << "setwise coprime" << endl;
		return 0;
	} else {
		cout << "not coprime" << endl;
	}

	return 0;
}

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

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    ll n; cin >> n;
    vll a(n); rep(i,n) cin >> a[i];

    //0mod2 -> +
    ll sum = 0;
    ll answer0 = 0;
    rep(i,n){
        sum += a[i];
        if(i%2 == 0){
            if(sum <= 0){
                answer0 += (1 - sum);
                sum = 1;
            }
        }
        else{
            if(sum >= 0){
                answer0 += (1 + sum);
                sum = -1;
            }
        }
    }

    //1mod2->+
    sum = 0;
    ll answer1 = 0;
    rep(i,n){
        sum += a[i];
        if(i%2 == 1){
            if(sum <= 0){
                answer1 += (1 - sum);
                sum = 1;
            }
        }
        else{
            if(sum >= 0){
                answer1 += (1 + sum);
                sum = -1;
            }
        }
    }

    cout << min(answer1, answer0) << '\n';
}

Measured memory_bytes: 1024
def main():
  n,k,*t=map(int,open(0).read().split())
  e=tuple(set()for _ in[0]*n)
  for a,b in zip(t[::2],t[1::2]):
    e[a-1].add(b-1)
    e[b-1].add(a-1)
  c,q=k,[0]
  while q:
    v,i=q.pop(),1
    for w in e[v]:
      c=c*(k-i-(v>0))%(10**9+7)
      e[w].remove(v)
      q.append(w)
      i+=1
  print(c)
main()

Measured memory_bytes: 47976
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int be[][] = new int[100000+1][2];
        int bo[][] = new int[100000+1][2];
        for (int i=0; i<N/2; i++) {
            int e = sc.nextInt();
            int o = sc.nextInt();
            be[e][0] = e;
            bo[o][0] = o;
            be[e][1]++;
            bo[o][1]++;
        }
        Arrays.sort(be, Comparator.comparing((int[] a) -> a[1]).reversed());
        Arrays.sort(bo, Comparator.comparing((int[] a) -> a[1]).reversed());
        if(be[0][0] != bo[0][0]) System.out.println(N-be[0][1]-bo[0][1]);
        else System.out.println(Math.min(N-be[0][1]-bo[1][1], N-be[1][1]-bo[0][1]));
	}
}

Measured memory_bytes: 66564
function Main(input) {
    var input = input.split("\n");
    var an = true;
    var one = 0;
    var two = 0;
    var three = 0;
    var four = 0;
    t = 0;
    for(i = 0; i < 3; i++){
        n = input[i].split(" ");
        n[0] = Number(n[0]);n[1] = Number(n[1]);
        if(n[0] === 1) one++;
        else if(n[0] === 2) two++;
        else if(n[0] === 3) three++;
        else if(n[0] === 4) four++;
        if(n[1] === 1) one++;
        else if(n[1] === 2) two++;
        else if(n[1] === 3) three++;
        else if(n[1] === 4) four++;
    }
    if(one > 2 || two > 2 || three > 2 || four > 2) an = false;
    if(an) console.log("YES");
    else console.log("NO")
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int t[3];
double limit,r;
int n;
int main(){
  while(cin>>t[0]>>t[1]>>t[2]){
    if(t[0]==0)break;
    sort(t,t+3);
    limit=sqrt(t[0]*t[0]+t[1]*t[1]);
    cin>>n;
    while(n--){
      cin>>r;
      if(r*2>limit){
	cout<<"OK"<<endl;
      }else{
	cout<<"NA"<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1240
#include<stdio.h>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)

int main(){
	int n;
	ll m = 1ll;
	scanf("%d",&n);
	FOR(i,1,n+1) m = (m * i) % 1000000007;
	printf("%lld",m);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x; cin >> x;
	auto is_prime = [&](){
		if(x <= 1) return false;
		for(int i = 2; i * i <= x; i++){
			if(x % i == 0) return false;
		}
		return true;
	};
	while(!is_prime()) x++;
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
/*
	?§£????????????:Area of Polygon
	(http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0079)

	-status:???(???????????±??????????????¨?????????...?)

	-comment
        ??¢???????±?????????¢??°?????§??????????????§?????????????°?????????£??????????????????????????????????°?????????£?????????????????????
*/
var log = console.log;
if (typeof process != "undefined") {
    var input = "";
    process.stdin.resume();
    process.stdin.setEncoding('utf8');
    process.stdin.on('data', function(chunk) {
        input += chunk;
    });
    process.stdin.on('end', function() {
        var lines = input.split("\n");
        main(lines);
    });
}


function main(lines) {
    lines = lines.map(function(line) {
        return line.split(" ").filter(function(e) {
            return e != "";
        }).map(function(e) {
            var n = Number(e);
            if (n.toString() == "NaN") {
                return e.replace(/(\r)|(\n)/g, "");
            }
            return n;
        });
    });
    var last = lines.pop();
    if (last.length == 2) {
        lines.push(last);
    }
    lines.shift(); //????????????n???????????????
    var points = lines;
    //points.reverse();


    var p0 = points[0];
    var ps, pe;
    var S = 0;
    var length = points.length;
    for (var i = 1; i < length - 1; i++) {
        //i = 1,2,3,,,,length-2
        ps = points[i];
        pe = points[i + 1];
        S += sign_s(p0, ps, pe);
    }
    //??????????????????????????????2??§??????
    var r_S = "" + (S / 2);
    var idx = r_S.indexOf(".");
    if (idx == -1) {
        //??´??°
        r_S += ".0";
    } else {
        //?????????
        //????????¨?????§????????????
        r_S = r_S.slice(0, idx + 2);
    }
    log(r_S);
}

function sign_s(p1, p2, p3) {
    //??????????§????
    var pa = [p2[0] - p1[0], p2[1] - p1[1]];
    var pb = [p3[0] - p1[0], p3[1] - p1[1]];
    //a->b??§????¨???????
    return sign_s_main(pa, pb);
}

function sign_s_main(pa, pb) {
    //?????????2??§????????????
    return (pa[0] * pb[1] - pa[1] * pb[0]);
}

Measured memory_bytes: 16004
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int main(){
    int N;
    cin >> N;
    bool can = true;
    REP(i,N){
        int a;
        cin >> a;
        if(a%2==0){
            if(a%3!=0 && a%5!=0) can = false;
        }
    }
    if(can) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 3636
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 
 using namespace std;
 
 const double EPS=0.000000000005;
 
 double abs(double x)
 {
   if(x<0) return -x;
   else return x;       
 }

 int main()
 {
   int N;
   while(cin>>N)
   {
     long long int h,n,w;
     int flag=0; 
     for(h=1;h<=3500;h++)
     {
       for(n=1;n<=3500;n++)
       {
         if((4*h*n-N*n-N*h)==0) continue;
         double k=1.0*(N*h*n)/(1.0*(4*h*n-N*n-N*h));
         int kk=(int)k;
         if(abs(k-kk)<EPS&&kk>=1)
         {
           w=kk;
           flag=1;
           break;
         }        
       }        
       if(flag) break;
     } 
     cout<<h<<" "<<n<<" "<<w<<endl;
   }
   return 0;    
 }
 
 
 
 
 

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

int somesum(int n);

int main(){
    int N,A,B,sum=0;;
    cin >> N >> A >> B;
    for(int i=1;i<=N;i++){
        if((A<=somesum(i)) && (B>=somesum(i))) sum += i;
    }
    cout << sum;
    return 0;
}

int somesum(int n){
    int somesum=0,temp;
    for(int i=10000;i>0;i=i/10){
        temp=n/i;
        if(temp) n=n-temp*i;
        somesum+=temp;
    }
    return somesum;
}

Measured memory_bytes: 256
// Wall
// 所要時間 分
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int h, w;
    cin >> h >> w;
    vector<vector<int>> c(10, vector<int>(10));
    rep(i, 10){
        rep(j, 10){
            cin >> c[i][j];
        }
    }
    vector<vector<int>> a(h, vector<int>(w));
    rep(i, h){
        rep(j, w){
            cin >> a[i][j];
        }
    }

    rep(k, 10){
        rep(i, 10){
            rep(j, 10){
                c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
            }
        }
    }

    int ans = 0;
    rep(i, h){
        rep(j, w){
            if(a[i][j] != -1){
                ans += c[a[i][j]][1];
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int n, d, x;  cin >> n >> d >> x;
    int *a = new int[n];

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

    int ans = x;

    for (int i = 0; i < n; i++)
        ans += (d-1)/a[i] + 1;

    cout << ans << endl;

    return 0;
}

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

signed main(){

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;
  int m;
  cin>>m;
  vector<int> b(m);
  for(auto& bi:b)cin>>bi;

  vector<int> r;
  set_symmetric_difference(
    a.begin(),a.end(),
    b.begin(),b.end(),
    back_inserter(r)
  );

  for(auto x:r)cout<<x<<"\n";

}


Measured memory_bytes: 6372
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VVL a(n, VL(3));
    REP(i,n){
        REP(j,3) a[i][j] = in();
    }
    VVL dp(n, VL(3));
    REP(j,3){
        dp[0][j] = a[0][j];
    }
    FOR(i,1,n-1) REP(j,3) REP(k,3){
        if (j != k){
            dp[i][k] = max(dp[i][k], dp[i-1][j] + a[i][k]);
        }
    }
    ll ans = 0;
    REP(j,3) ans = max(ans, dp[n-1][j]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int main() {
  int n;cin>>n;
  cout << (n&1==1 ? n*2 : n) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF=1e18;
#define PI 3.14159265358979323846
const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int pickUpNumbersFromStr(string S, int first, int second) {
    string strResult = S.substr(first-1, second - first + 1);
    return atoi(strResult.c_str());
}

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

    ll X;
    cin >> X;
    ll current = 100;
    ll count = 0;
    while(true) {
        ll plusValue = current / 100;
        current += plusValue;
        count++;
        if (current >= X) {
            break;
        }
    }

    cout << count << '\n';

    return 0;
}

Measured memory_bytes: 3644
n,m,x = gets.split(" ").map(&:to_i)
arr = gets.split(" ").map(&:to_i)
s = 0
b = 0
for i in 0..n do
    if arr.include?(i)
        if i < x 
            s += 1
        else
            b += 1
        end
    end
end

puts [s,b].min


Measured memory_bytes: 1788
use proconio::{fastout, input};

#[fastout]
#[allow(non_snake_case)]
#[allow(unused)]
fn main() {
    input! {
        N: usize,
        X: usize,
        T: usize
    }

    let dt = (N / X) + if N % X == 0 { 0 } else { 1 };
    println!("{}", dt * T);
}


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

int main()
{
  int i,j,len,ang,b,a[20];
  string dir;

  for(;;){
    cin>>dir;
    if(dir[0]=='#') break;

    len=dir.size(); ang=0;
    if(dir[len-1]=='h'){
      a[0]=0; len-=5;
    } else {
      a[0]=90; len-=4;
    }
    if(!len){
      cout<<a[0]<<endl; continue;
    }
    for(i=len-1,j=0;i>0;j++){
      if(dir[i]=='h'){
	a[j+1]=-90;
	i-=5;
      } else if(dir[i]=='t'){
	a[j+1]=90;
	i-=4;
      }
    }
    b=pow(2,j);
    for(i=0;i<j;i++){
      a[i]*=pow(2,j-i);
      ang+=a[i];
    }
    ang+=a[j];
    for(;;){
      if(ang%b==0){
	cout<<ang/b<<endl; break;
      } else{
	if(ang%2==0&&b%2==0){
	  ang/=2; b/=2;
	} else {
	  cout<<ang<<"/"<<b<<endl; break;
	}
      }
    }
  }
}


Measured memory_bytes: 1228
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
int n;
int a[300000];

int main(){
  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  if(n%2==0){
    cout << a[n];
    REP(i,n/2-1){
      cout << " " << a[n-2-2*i];
    }
    REP(i,n/2){
      cout << " " << a[2*i+1];
    }
    cout << endl;
  }
  if(n%2==1){
    cout << a[n];
    REP(i,n/2){
      cout << " " << a[n-2-2*i];
    }
    REP(i,n/2){
      cout << " " << a[2*i+2];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 2944
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    final int A, B, C;

    AtCoder(FastScanner sc) {
        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
    }

    void solve(PrintWriter out) {
        int a = A * 10 + B + C;
        int b = B * 10 + A + C;
        int c = C * 10 + A + B;
        out.println(Math.max(Math.max(a, b), c));
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

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


Measured memory_bytes: 23252
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(10);
}

#define int ll
void solve() {
	while (true) {
		int n, m, p;
		cin >> n >> m >> p;
		if (n == 0) return;
		vector<int> inputs;
		int sum = 0;
		REP(i, n) {
			int a;
			cin >> a;
			inputs.push_back(a);
			sum += a;
		}
		m--;
		if (inputs[m] == 0) {
			cout << 0 << endl;
		}
		else {
			cout << (sum * (100 - p)) / inputs[m] << endl;
		}
	}
}
#undef int

int main() {
	init();
	solve();
}


Measured memory_bytes: 3192
// Example program
#include <iostream>
#include <string>
#include <stdio.h>

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    int lowerLimit = a/0.08;
    int upperLimit = b/0.1;
    int flag = 0;
    if(lowerLimit>upperLimit){
        int temp = upperLimit;
        upperLimit = lowerLimit;
        lowerLimit = temp;
    }
    for(int i = lowerLimit; i<=upperLimit+1;i++){
        int ans1 = i*0.08;
        int ans2 = i*0.1;
        if(ans1==a && ans2==b){
            printf("%d",i);
            flag = 1;
            break;
        }
    }
    if(flag==0){
        printf("-1");
    }
}


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

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

using namespace std;

int main(void){
    
    int student = 0;
    int maxN,minN = 0;
    int gap = 0,gapMax = 0,gapnumber  = 0;
    int score[1020] = {0};
    
    while(cin >> student >>minN >>maxN,student+maxN+minN)
    {
        REP(i,student)
        cin >> score[i];
  
    
    FOR(j,minN,maxN+1)
        {
            gap = score[j-1] - score[j];

            if(gapMax <= gap)
            {
                gapnumber = j;
                gapMax = gap;
                
            }
        }
        cout << gapnumber << endl;
        gapMax  =-1;
        gapnumber = 0;
    
    }
    return 0;
}

Measured memory_bytes: 3096
void main() {
	auto ip = readAs!(long[]), N = ip[0], K = ip[1];
	auto arr = new long[](K);
	foreach(i; 1..N+1) arr[i%K]++;
	ulong res = 0;
	foreach(a; 0..K) {
		auto b = (K - a) % K;
		auto c = (K - a) % K;
		if((b+c) % K != 0) continue;
		res += arr[a] * arr[b] * arr[c];
	}
	writeln(res);
}

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

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

using namespace std;

int main(){
    int n;
    scanf("%d", &n);

    vector<int> num(n);

    long long total_sum = 0;
    long long sum = 0;

    for(int i = 0; i < n ; i++){
        scanf("%d", &num[i]);
        total_sum += num[i];
    }

    long long best_delta = 1000000000000;

    for(int i = 0; i < n - 1; i++){
        sum += num[i];

        if(abs(sum - (total_sum - sum)) < best_delta)
            best_delta = abs(sum - (total_sum - sum));
    }

    printf("%lld", best_delta);

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;


void solve(){
  bool DBG = false;
  int n, m; cin  >> n >> m;
  V<int> a(m), b(m), k(m,0);
  V2<int> c(m);
  FOR(i,0,m){
    cin >> a[i] >> b[i];
    c[i] = V<int>(b[i]);
    FOR(j,0,b[i]) {cin >> c[i][j]; k[i] += (1<<(c[i][j]-1));}
  }
  int INF = 1<<29;
  V<int> dp((1<<n)+1, INF);
  dp[0] = 0;
  FOR(i,0,m){
    FOR(j,0,(1<<n)){
      dp[j|k[i]] = min(dp[j|k[i]], dp[j] + a[i]);
    }
  }
  if(dp[(1<<n)-1] < INF) cout << dp[(1<<n)-1]  << '\n';
  else cout << -1 << '\n';
}

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

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll n; cin>>n;
  vector<int> a(n);
  rep(i, n) cin>>a[i];
  sort(a.rbegin(),a.rend());

  if (n%2) {
    ll r1 = 0;
    for (int i=0; i<n/2-1; i++) {
      r1 += a[i]*2;
    }
    r1 += a[n/2-1] + a[n/2];
    for (int i=n/2+1; i<n; i++) {
      r1 -= a[i]*2;
    }

    ll r2 = 0;
    for (int i=0; i<n/2; i++) {
      r2 += a[i]*2;
    }
    r2 -= a[n/2] + a[n/2+1];
    for (int i=n/2+2; i<n; i++) {
      r2 -= a[i]*2;
    }
    cout << max(r1, r2) << endl;

  } else {
    ll r = 0;
    for (int i=0; i<n/2-1; i++) {
      r += a[i]*2;
    }
    r += a[n/2-1] - a[n/2];
    for (int i=n/2+1; i<n; i++) {
      r -= a[i]*2;
    }
    cout << r << endl;

  }

  return 0;
}


Measured memory_bytes: 3788
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define INF 1000000000
#define EPS 1e-9
#define PI acos(-1)

typedef long long ll;

#define MAX_N 50
#define MAX_P 50

int n, p;
int h[MAX_N];

vector<int> ans_list;

int main(){

  while(true){
    cin >> n >> p;
    if(n == 0 && p == 0)
      break;
    memset(h, 0, sizeof(h));
    int step = 0;
    int turn = 0; //現在のターン
    int num = p; //碗の中に入っている石の数
    while(true){

      if(num == 1 && num+h[turn] == p){
	ans_list.push_back(turn);
	break;
      }
      
      if(num > 0){
	h[turn]++;
	num--;
	turn++;
	if(turn == n)
	  turn = 0;
      }

      else{
	num += h[turn];
	h[turn] = 0;
	turn++;
	if(turn == n)
	  turn = 0;
      }

    }

  }

  for(int i = 0; i < ans_list.size(); i++){
    cout << ans_list[i] << endl;
  }

  return 0;

}

Measured memory_bytes: 1216
import math
from functools import reduce

K = int(input())

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans = 0

for i in range(1, K+1):
  for j in range(i, K+1):
    for k in range(j, K+1):
      if i == k:
        ans += gcd(i, j, k)
      elif i == j or j == k:
        ans += 3 * gcd(i, j, k)
      else:
        ans += 6 * gcd(i, j, k)

print(ans)

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


auto solve(long long W, long long a, long long b){
    if((b <= (a + W)) && (a <= (b + W))) {
        return 0LL;
    }
    return min(abs((a + W) - b), abs(a - (b + W)));
}

int main(){
    long long W;
    scanf("%lld",&W);
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    auto result = solve(W, a, b);
    cout << result << endl;
    return 0;
}


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

#define IS_DEBUG true

#define DEBUG_OUTPUT(X) if (IS_DEBUG) cout << X << endl
#define RESULT_OUTPUT(X) cout << X << endl

int main()
{
  int N, Y;
  cin >> N >> Y;
  
  bool found = false;
  int i, j, k;
  for (i = 0; i <= N; i++)
  {
    for (j = 0; j <= N - i; j++)
    {
      k = N - i - j;
      if (10000 * i + 5000 * j + 1000 * k == Y)
      {
        found = true;
        break; 
      }
    }
    if (found)
      break;
  }
  
  if (!found)
    i = j = k = -1;
  
  cout << i << " " << j << " " << k;
  
  
  if (IS_DEBUG)
  {
    int end;
    cin >> end;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  cout << ((a[0]+a[1] == a[2] || a[1]+a[2] == a[0] || a[0]+a[2] == a[1]) ? "Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
n, m, x = (int(i) for i in input().split())
a = [0] * (n+1)

for i in input().split():
    k = int(i)
    a[k] = 1

left = right = 0
for i in range(n+1):
    if i < x:
        left += a[i]
    else:
        right += a[i]

ans = min(left, right)
print(ans)
    

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
    int a,b;
    char op;
    do {
        scanf("%d %c %d", &a, &op, &b);
        if (op != '?')
        {
            switch (op)
            {
                case '+':
                    printf("%d\n", a + b);
                    break;
                case '-':
                    printf("%d\n", a - b);
                    break;
                case '*':
                    printf("%d\n", a * b);
                    break;
                case '/':
                    printf("%d\n", a / b);
                    break;
            }
        }
    } while (op != '?');

    return 0;    
}


Measured memory_bytes: 2112
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    int count=0;

    while(a<=b){
      b-=a;
      count++;
    }

    if (count<c) {
      System.out.println(count);
    }else{
      System.out.println(c);
    }
  }
}


Measured memory_bytes: 23252
N, M = map(int, input().split())
ABZ = [list(map(int, input().split())) for _ in range(M)]
 
root = [i for i in range(N + 1)]
comp_size = [1] * (N+1)
 
def root_find(x):
  y = root[x]
  if x == y:
    return x
  else:
    z = root_find(y)
    root[x] = z
    return z

def merge(x, y):
  #print(x, y)
  rx = root_find(x)
  ry = root_find(y)
  sx = comp_size[rx]
  sy = comp_size[ry]
  if rx == ry:
    return 0
  else:
    if sx >= sy:
      root[ry] = rx
      comp_size[rx] = sx + sy
    else:
      root[rx] = ry
      comp_size[ry] = sx + sy
    return sx * sy

for a, b, z in ABZ:
  merge(a, b)
#print("root:", root)

check = [0] * (N + 1)
answer = 0
for i in range(1, N + 1):
  ri = root_find(i)
  if check[ri] == 0:
    answer += 1
    check[ri] = 1

print(answer)

Measured memory_bytes: 86488
#include<stdio.h>
main()
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
        printf("Yes\n");
    }else printf("No\n");
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define gc() getchar()
using namespace std;
const int N = 4010;
int sz[N],a,b,n,t,ans[N],q[N],tmp[N],cnt,tcnt,fa[N];
vector<int> threw;
int get_fa(int x) {
  return x == fa[x] ? x : fa[x] = get_fa(fa[x]);
}
bool ask(int x,int y) {
  static char tmp;
  printf("? %d %d\n",x,y);
  fflush(stdout);
  for (tmp = gc() ; tmp != 'Y' && tmp != 'N' ; tmp = gc());
  return (tmp == 'Y');
}
void solve() {
  if (cnt == 0) return;
  tcnt = 0;
  for (int i = 0 ; i+1 < cnt ; i += 2) {
    if (ask(q[i],q[i+1]) == 1 && ask(q[i+1],q[i]) == 1) {
      sz[q[i]] += sz[q[i+1]];
      fa[q[i+1]] = q[i];
      tmp[tcnt++] = q[i];
    } else threw.push_back(q[i]), threw.push_back(q[i+1]);
  }
  if (cnt&1) t = q[cnt-1], threw.push_back(q[cnt-1]);
  for (int i = 0 ; i < tcnt ; ++ i) q[i] = tmp[i];
  cnt = tcnt;
  solve();
}
int main() {
  scanf("%d%d",&a,&b);
  if (a <= b) return 0 * printf("Impossible\n");
  n = a + b;
  for (int i = 0 ; i < n ; ++ i)
    sz[i] = 1, q[i] = i, fa[i] = i;
  cnt = n;
  solve();
  for (int i = 0 ; i < n ; ++ i) get_fa(i);
  for (int i = 0 ; i < (int)threw.size() ; ++ i) {
    if (threw[i] == t) continue;
    ans[threw[i]] = ask(t,threw[i]);
  }
  ans[t] = 1;
  for (int i = 0 ; i < n ; ++ i)
    ans[i] = ans[fa[i]];
  printf("! ");
  for (int i = 0 ; i < n ; ++ i)
    printf("%d",ans[i]);
  puts("");
  return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
int main() {
  #define int long long
  int X,Y,A,B,C,D,N;
  
  cin >> N;
  vector<string>S(N);
  for(int i=0;i<N;i++){
    cin >> S[i];
  }
  std::sort(S.begin(),S.end());
  C=0;
  for(int i=1;i<N;i++){
    if(S[i]==S[i-1]){
      C++;
    }
  }
  cout << S.size()-C << endl;
}






Measured memory_bytes: 9596
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;

int main()
{
	int x1[maxn],x2[maxn];
	int y1[maxn],y2[maxn]; 
	int h,w,a[550][550],i,j,n=0;
	scanf("%d%d",&h,&w);
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++)
			scanf("%d",&a[i][j]);
	}
	for(i=1;i<=h;i++){
		for(j=1;j<w;j++){
			if(a[i][j]%2==1){
			y1[n]=i;
			y2[n]=i;
			x1[n]=j;
			x2[n]=j+1;
			n++;
			a[i][j]--;
			a[i][j+1]++;
			}
		}
	}
	for(i=1;i<h;i++){
		if(a[i][w]%2==1){
			y1[n]=i;
			y2[n]=i+1;
			x1[n]=w;
			x2[n]=w;
			n++;
			a[i][w]--;
			a[i+1][w]++;
		}
	}
	printf("%d\n",n);
	for(i=0;i<n;i++)
		printf("%d %d %d %d\n",y1[i],x1[i],y2[i],x2[i]);
	return 0;
} 



Measured memory_bytes: 6016
#include <iostream>
#define int long long
using namespace std;

int a, b, c;

signed main() {
	cin >> a >> b >> c;
	
	int i;
	int MAX = 1000000;
	for (i = 0; i < MAX; i++) {
		if (a % 2 || b % 2 || c % 2) break;
		int A = (b + c) / 2;
		int B = (c + a) / 2;
		int C = (a + b) / 2;
		a = A;
		b = B;
		c = C;
	}
	
	if (i == MAX) { cout << -1 << endl; }
	else { cout << i << endl; }
	
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int n,rt,tot,sum[N],ans[N],t[N][3],lz[N];
char s[N];
void build(int &now,int n,int b,int c)
{
    now=++tot;
    if(n==0){sum[now]=c;return;}
    build(t[now][0],n-1,b*3,c);
    build(t[now][1],n-1,b*3,c+b);
    build(t[now][2],n-1,b*3,c+b+b);
}
void updata(int now,int n)
{
    swap(t[now][1],t[now][2]);
    lz[t[now][0]]^=1;
    lz[t[now][1]]^=1;
    lz[t[now][2]]^=1;
    lz[now]=0;
}
void solve(int now,int n)
{
    if(n==0) return;
    if(lz[now]) updata(now,n);
    int a=t[now][0],b=t[now][1],c=t[now][2];
    t[now][1]=a;t[now][2]=b;t[now][0]=c;
    solve(t[now][0],n-1);
}
void getans(int now,int n,int b,int c)
{
    if(n==0){ans[sum[now]]=c;return;}
    if(lz[now]) updata(now,n);
    getans(t[now][0],n-1,b*3,c);
    getans(t[now][1],n-1,b*3,c+b);
    getans(t[now][2],n-1,b*3,c+b+b);
}
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    build(rt,n,1,0);
    for(int i=1;s[i];i++)
    {
        if(s[i]=='S') lz[rt]^=1;
        else solve(rt,n);
    }
    getans(rt,n,1,0);
    int sum=1;for(int i=1;i<=n;i++) sum*=3;
    for(int i=0;i<sum;i++) printf(i==sum-1?"%d\n":"%d ",ans[i]);
}


Measured memory_bytes: 21884
public class Main {


  private static void solve() {
    int n = ni();
    int[] a = na(n);
    int ret = 0;
    for (int i = 1; i < n; i ++) {
      if (a[i] == a[i - 1]) {
        a[i] = 100000;
        ret ++;
      }
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 21972
using System;
using static System.Console;
using static System.Convert;
class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var coordinate = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        Array.Sort(coordinate);
        WriteLine(coordinate[num - 1] - coordinate[0]);
    }
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;cin>>n>>m;
	vector<pair<int,string>> arrmv;
	for(int i=0;i<m;i++){
	
		int t;string str;cin>>t>>str;
		arrmv.push_back({t,str});
	}
	set<int> ms;
	map<int,int> mm;
	int fans=0;
	for(int i=0;i<m;i++){
		if(arrmv[i].second==string ("AC")){
			ms.insert(arrmv[i].first);
			mm[arrmv[i].first]=0;
			
		}
	}
	int sans=0;
	for(int i=0;i<m;i++){
		if(mm.count(arrmv[i].first)){
			if(arrmv[i].second==string("WA"))mm[arrmv[i].first]++;
			else{
				sans+=mm[arrmv[i].first];
				mm.erase(arrmv[i].first);
			}
		}
	}
	fans=ms.size();
	cout<<fans<<" "<<sans<<endl;
	return 0;
}

Measured memory_bytes: 15856
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	const inputLines = input.split("\n");
	const line0 = inputLines[0];
	const line0vars = line0.split(" ");
	// const line1 = inputLines[1];
	// const line1vars = line1.split(" ");

	for (var i = 0; i < 5; i++) {
		const a = parseInt(line0vars[i], 10);
		if (a === 0) {
			console.log(i+1);
		}
	}
	// const a = parseInt(line0vars[0], 10);
	// const b = parseInt(line0vars[1], 10);
	
	// const c = parseInt(line1vars[0], 10);
	// const d = parseInt(line1vars[1], 10);

	// tmp = input[1].split(" ");
	// //文字列から10進数に変換するときはparseIntを使います
	// var a = parseInt(input[0], 10);
	// var b = parseInt(tmp[0], 10);
	// var c = parseInt(tmp[1], 10);
	// var s = input[2];

	//出力
	// console.log('%d %s',a+b+c,s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

// node index.js
// 1
// 2 3
// test
// (Ctrl + D)


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

int main() {
#ifdef HOME
	freopen("agc6a.in", "r", stdin);
	freopen("agc6a.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string str, a, b;
	int n;

	cin >> n >> a >> b;
	for (int i = 0; i < n; ++i) {
		str = a, str.resize(i);
		str+= b;
		str.resize(n);
		if (str == a) {
			cout << n + i << endl;
			return 0; } }

	cout << 2 * n << endl;

	return 0; }


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int maxn = 100100;
const int maxj = 17;
 
int n,res,mask,nn,a[maxn],cnt[maxn],dp[(int)1<<maxj],good[(int)1<<maxj];
 
int main() {
  //  freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=1;i<n;i++) {
        int x,y,z;
        cin>>x>>y>>z;
        a[x]^=z;
        a[y]^=z;
    }
    for (int i=0;i<n;i++) cnt[a[i]]++;
    for (int i=1;i<=maxj;i++) {
        res+=cnt[i]/2;
        cnt[i]%=2;
    }
    for (int i=1;i<=maxj;i++)
        if (cnt[i]!=0) {
            mask|=(1<<i);
            nn++;
        }
    for (int tt=0;tt<(1<<maxj);tt++) {
        int x=0;
        for (int i=0;i<maxj;i++)
            if (tt&(1<<i)) x^=i;
        good[tt] = (x==0);
    }
    for (int tt=0;tt<(1<<maxj);tt++) {
        if (tt&1) continue;
        int u=tt;
        while (u>0) {
            if (good[u]) dp[tt] = max(dp[tt],dp[tt^u] + 1);
            u = (u-1)&tt;
        }
    }
    cout<<res+nn-dp[mask];
}

Measured memory_bytes: 1664
#include <stdio.h>

char s[114514];

int main(void) {
	size_t i;
	if (scanf("%114513s", s) != 1) return 1;
	for (i = 0; s[i] != '\0'; i++) {
		if (i % 2 == 0) putchar((unsigned char)s[i]);
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 256
/*
ID: 5ak0
PROG:
LANG: C++11
*/

#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7, MAXN = 1e5 + 10;

ll a, b, n;

int main(){
    #ifndef SAKO
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    #endif // SAKO
    ios_base::sync_with_stdio(0);

    cin >> n >> a >> b;
    if (a > b)
        return !(cout << 0);
    if (n == 1){
        if (a == b)
            return !(cout << 1);
        else
            return !(cout << 0);
    }
    cout << (b - a) * (n - 2) + 1;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)

	for i := x; ; i++ {
		if isPrime(i) {
			fmt.Println(i)
			return
		}
	}
}

func isPrime(n int) bool {
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}


Measured memory_bytes: 512