akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 305;

int N;
char mat[MAXN][MAXN];

bool check(int diff) {
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			if (mat[i][j] != mat[(j + diff) % N][(i - diff + N) % N])
				return false;
	return true;
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%s", mat[i]);
	
	int sol = 0;
	for (int i = 0; i < N; i++)
		sol += check(i);
	
	printf("%d\n", N * sol);
	
	return 0;
}

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

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000
#define MOD 1000000007

int a[5];
int main() {
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
        if (a[i] == 0)
            cout << i + 1 << endl;
    }
    return 0;
}


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



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

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

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










int main(){
    string s;
    cin >> s;
    if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]){
        cout << "Yes" << endl;
        return 0;
    }
    if(s[0] == s[2] && s[1] == s[3] && s[0] != s[1]){
        cout << "Yes" << endl;
        return 0;
    }
    if(s[0] == s[3] && s[1] == s[2] && s[0] != s[2]){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 764
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main() {
    val n = readLine()?.toInt() ?: return
    val l = longList()
    var c = 0
    0.until(n).forEach { ii ->
        val i = l[ii]
        (ii + 1).until(n).forEach { jj ->
            val j = l[jj]
            (jj + 1).until(n).forEach { kk ->
                val k = l[kk]
                if (i + j > k && j + k > i && k + i > j && i != j && j != k && k != i) {
                    c++
                }
            }
        }
    }
    println(c.toString())
}


Measured memory_bytes: 39384
#include<stdio.h>

int main(void)
{
  int t;
  int n;
  int i,j;
  int data[100][100];
  int up[100] = {0};
  int down[100] = {0};
  int judge;

  scanf("%d",&t);
  
  for(i=0;i<t;i++){
    
    scanf("%d",&n);
    
    for(j=0;j<n;j++){
      
      scanf("%d",&data[i][j]);
	
	}
    
    for(j=0;j<n-1;j++){
      
      judge = data[i][j+1] - data[i][j];
      
      if((judge >= 0) && (judge > up[i])){
	
	up[i] = judge;
	
      }
      
      else if((judge < 0) && (judge < down[i])){
	
	down[i] = judge;
	
      }
      
    }
    
  }
  
  for(i=0;i<t;i++)
    printf("%d %d\n",up[i],-down[i]);
  
  return 0;
  
}

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long ll;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    cout << (a + b == 0 ? 0 : (n / (a + b) * a) + min(a, n % (a + b)));
    // system("pause");
}

Measured memory_bytes: 384
N = str(input())
if (N[0] == N[1] and N[1] == N[2]) \
or (N[1] == N[2] and N[2] == N[3]) \
or (N[0] == N[1] and N[1] == N[2] and N[2] == N[3]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int N;
  ci(N);
  ve<int> p(N);
  rep(i, N){
    ci(p.at(i));
  }
  sort all(p);
  int a = 0;
  rep(i, N - 1){
    a += p.at(i);
  }
  a += p.at(N - 1) / 2;
  co(a);
}

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

ans=[0]*(n+1)

def func():
    cnt=0
    for x in range(1,101):
        for y in range(x,101):
            for z in range(y,101):
                p=x**2+y**2+z**2+x*y+y*z+z*x
                if p<n+1:
                    if x==y and y==z:
                        ans[p]+=1
                    elif x==y or y==z:
                        ans[p]+=3
                    else:
                        ans[p]+=6
func()

for i in range(1,n+1):
    print(ans[i])

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

using namespace std;

const int SIZE = 105;
int a[SIZE];

int main()
{
	int n;
	while (~scanf("%d", &n))
	{
		for(int i=0; i<n; ++i)
		{
			scanf("%d", &a[i]);
		}
		for(int i=0; i<n;++i)
			{
				printf("%d", a[i]);
				if(i!=n-1) printf(" ");
				else printf("\n");
			}
		for(int i=1;i<n; ++i)
		{
			int key=a[i];
			int j = i -1;
			while(j >=0 && a[j]>key)
			{
				a[j+1] = a[j];
				--j;
			}
			a[j+1] = key;
			for(int i=0; i<n;++i)
			{
				printf("%d", a[i]);
				if(i!=n-1) printf(" ");
				else printf("\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3212
def digit_sum2(num):
    total = 0
    for digit in str(num):
        total += int(digit)
    return total
    
n = input()
l = len(n)
n = int(n)

print(max(digit_sum2(n), n // (10 ** (l-1)) - 1 + 9 * (l-1)))

Measured memory_bytes: 2940
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <cstdio>
#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>
#include <complex>

using namespace std;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
#define PB push_back
#define MP make_pair
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1e-10

typedef complex<double> P;
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L(){
  }
};
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
inline double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

inline double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

inline bool intersect(const L &s,const L &t, P &p) {
	double a = -real(s[0]-s[1])*imag(t[0]-t[1])+imag(s[0]-s[1])*real(t[0]-t[1]);
	double b =  real(s[1]-t[1])*imag(t[0]-t[1])-imag(s[1]-t[1])*real(t[0]-t[1]);
	if(abs(a)<EPS)return false;
	p= s[0]*b/a+(1.0-b/a)*s[1];
	return true;
}

inline bool eq(const P &s, const P &t){
	return (norm(s-t)<EPS*EPS);
}

L edge[200];

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)return 0;
		int ret = 1;
		REP(i,n){
			ret++;
			int x1,y1,x2,y2;
			cin>>x1>>y1>>x2>>y2;
			edge[i] = L(P(x1,y1), P(x2, y2));
			vector<P> vp;
			REP(j,i){
				P tp;
				if(intersect(edge[j], edge[i], tp)){
					if(abs(tp.real())<100-EPS && abs(tp.imag())<100-EPS){
						int flag = 1;
						REP(k, vp.size())if(eq(tp, vp[k]))flag = 0;
						if(flag)vp.PB(tp);
						ret += flag;
					}
				}
			}
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const int INF = 1001001001;

int main(){
    int n;
    cin >> n;
    int x[n], y[n];
    rep(i, n) cin >> x[i] >> y[i];
    vec<vec<double>> dist(n, vec<double>(n, 0.0));
    double all = 0;
    rep(i, n) rep(j, n) {
        dist[i][j] = sqrt(pow(x[i]-x[j], 2) + pow(y[i]-y[j], 2));
        all += dist[i][j];
    }
    cout << setprecision(10) << all/n << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define len 100005

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[len];
int head, tail, n;

void enqueue(P x)
{
	Q[tail] = x;
	tail = (tail+1) % len;
}

P dequeue()
{
	P x = Q[head];
	head = (head+1) % len;
	return x;
}

int min(int x, int y)
{
	int z;
	if( x < y ){
		z = x;
	}else{
		z = y;
	}
	
	return z;
}

int main(void)
{
	int elaps = 0, c;
	int i, q;
	P u;
	scanf( "%d %d", &n, &q );
	
	for( i = 1; i <= n; i++ ){
		scanf( "%s", Q[i].name );
		scanf( "%d", &Q[i].t );
	}
	
	head = 1;
	tail = n+1;
	
	while( head != tail){
		u = dequeue();
		c = min(q, u.t);
		u.t = u.t - c;
		elaps = elaps + c;
		if( u.t > 0){
			enqueue(u);
		}else{
			printf( "%s %d\n", u.name, elaps );
		}
	}
	
	return 0;
}
	


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

int main(){
	int a,b;
	cin>>a>>b;
	int m=1001;
	for(int i=0;i<a;i++){
		int c[1000],d[1000];
		cin>>c[i]>>d[i];
		if(d[i]<=b){
			 m=min(m,c[i]);
		}
	}
	if(m==1001){
		cout<<"TLE"<<endl;
		return 0;
	}
	cout<<m<<endl;
}



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

int main() {
    ll x;
    cin >> x;
    ll ans = 0;
    ans += (x / 500) * 1000;
    x -= 500 * (x / 500);
    ans += (x / 5) * 5;
    cout << ans << endl;
    return 0;
}

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

using namespace std; 

const int maxn = 1e7 + 1; 

int n, a[505], G[505][505], col[maxn + 5]; 
int p[maxn + 5], flag[maxn + 5], tot, cnt, mat[205], vis[205];  

int dfs(int u) {
    for (int v = 1; v <= cnt; v++) {
        if (!(a[v] & 1) && !vis[v] && G[u][v]) {
            vis[v] = 1; 
            if (!mat[v] or dfs(mat[v])) {
                mat[v] = u; 
                return 1; 
            }
        }
    }
    return 0; 
}

int main() {
    scanf("%d", &n); 
    for (int i = 1; i <= n; i++) {
        int t; 
        scanf("%d", &t); 
        col[t] = 1;  
    }
    flag[1] = 1; 
    if (col[1] != col[0]) a[++cnt] = 1; 
    for (int i = 2; i <= maxn; i++) {
        if (col[i] != col[i - 1]) a[++cnt] = i; 
        if (!flag[i]) {
            p[++tot] = i; 
        }
        for (int j = 1; j <= tot && i * p[j] <= maxn; j++) {
            flag[i * p[j]] = 1; 
            if (i % p[j] == 0) break ; 
        }
    }
    flag[2] = 1;
    for (int i = 1; i <= cnt; i++) {
        for (int j = i + 1; j <= cnt; j++) {
            if (!flag[abs(a[j] - a[i])]) {
                G[i][j] = G[j][i] = 1; 
            }
        }
    }
    int mx = 0, odd = 0, even; 
    for (int i = 1; i <= cnt; i++) {
        if (a[i] & 1) {
            memset(vis, 0, sizeof(vis)); 
            if (dfs(i)) mx++; 
            odd++; 
        }
    }
    even = cnt - odd; 
    odd -= mx, even -= mx; 
    int ans = mx; 
    if (odd & 1) {
        ans += odd - 1 + even - 1 + 3; 
    }
    else {
        ans += odd + even; 
    }
    cout << ans << '\n'; 
    return 0; 
}

Measured memory_bytes: 82560
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    a, b, c, d = input_to_int_map()

    ret = "No"

    import math

    takahashi = math.ceil(c / b)
    aoki = math.ceil(a / d)

    if takahashi <= aoki:
        ret = "Yes"

    return ret


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*

*/
int main(){
  ll W,H,a,ans=0; cin>>W>>H;
  vector<pair<ll,ll>> V(0,{0,0});
  rep(i,W) cin>>a, V.push_back({a,1LL});
  rep(i,H) cin>>a, V.push_back({a,0LL});
  sort(all(V));
  H++, W++;
  for(auto v: V){
    ll v1=v.first;
    ll v2=v.second;
    if(v2) ans+=v1*H, W--;
    else ans+=v1*W, H--;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 7400
#include<stdio.h>
#define MAX 100
#define WHITE 0
#define BRACK 1

int G[MAX+1][MAX+1];
void init(int n){
  int i, j;
  for(i=1; i<=n; i++){
    for(j=1; j<=n; j++){
      G[i][j] = WHITE;
    }
  }
}

int main(){
  int i, j, n;
  int u, k, v;

  scanf("%d", &n);
  init(n);
  for(i=1; i<=n; i++){
    scanf("%d%d", &u, &k);
    if(k > 0){
      for(j=0; j<k; j++){
        scanf("%d", &v);
        G[u][v] = BRACK;
      }
    }
  }

  for(i=1; i<=n; i++){
    for(j=1; j<=n; j++){
      printf("%d", G[i][j]);
      if(j!=n) printf(" ");
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2088
# from line_profiler import LineProfiler
from collections import deque
from sys import stdin

def main():
    while(True):
        W, H = map(int, stdin.readline().split())
        if not W: break
        tx,ty = map(int, stdin.readline().split())
        kx,ky = map(int, stdin.readline().split())
        ma = [[False]+[bool(1-int(a)) for a in stdin.readline().split()]+[False] for i in range(H)]
        ma = [[False]*(W+2)] + ma + [[False]*(W+2)]
        que = deque([[tx,ty,kx,ky,0]])
        pas = set()
        ans = "NA"
        while(que):
            tx,ty,kx,ky,c = que.popleft()
            if tx == kx and ty == ky:
                ans = c
                break
            if c+1 > 100: continue
            for dx,dy in [[-1,0],[0,-1],[1,0],[0,1]]:
                tdx, tdy = ( dx, dy) if ma[ty+dy][tx+dx] else (0,0)
                kdx, kdy = (-dx,-dy) if ma[ky-dy][kx-dx] else (0,0)
                ttx,tty,kkx,kky = tx+tdx,ty+tdy,kx+kdx,ky+kdy
                if (ttx,tty,kkx,kky) in pas: continue
                que.append([ttx,tty,kkx,kky,c+1])
                pas.add((ttx,tty,kkx,kky))
        print(ans)

if __name__ == "__main__":
    # prf = LineProfiler()
    # prf.add_function(main)
    # prf.runcall(main)
    # prf.print_stats()
    main()


Measured memory_bytes: 35192
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

int main ()
{
    int n, m;
    scanf ("%d%d", &n, &m);
    int now = 1;
    for (int i = 1; i <= m; i ++)
    {
        now *= 2;
    }
    int ans = (m * 1900 + (n - m) * 100) * now;
    printf ("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define MAX 100
int is[MAX];
int main(void) {
	long long a, b, c,d[3];
	for (int i = 0; i < 3; ++i)
	{
		cin >>  d[i];
	}
	sort(d, d + 3);
	a = d[2] / 2 + d[2] % 2;
	b = d[2] / 2;
	a *= d[0] * d[1];
	b *= d[0] * d[1];
	cout << a - b << endl;
	return 0;

}

Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define pi 3.1415926535897



int main() {

    get(n);
    ll c = 2;

    for(ll i=0;i<n-1;i++) {
        for(ll j=i+1;j<n;j++) {
            for(int k=0;k<32;k++) {
                // cout<<(i&(1<<k))<<" "<<(j&(1<<k))<<" "<<i<<" "<<j<<endl;
                if((i&(1<<k))!=(j&(1<<k))) {
                    printf("%d ", k+1);
                    break;
                }
            }
        }
        printf("\n");
    }

    return 0;  
}

Measured memory_bytes: 512
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
	}
	var mx, mi int
	for i := range as {
		if abs(as[i]) > mx {
			mx = abs(as[i])
			mi = i
		}
	}
	fmt.Println(n*2 - 2)
	for i := 0; i < n; i++ {
		if i != mi {
			fmt.Println(mi+1, i+1)
		}
	}
	if as[mi] > 0 {
		for i := 0; i < n-1; i++ {
			fmt.Println(i+1, i+2)
		}
	} else {
		for i := n - 1; i > 0; i-- {
			fmt.Println(i+1, i)
		}
	}
}

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long int LL;
const int INF=2e9+1e8;
const int maxn=1e6+100;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	int odd=0,even=0;
	int n,p;
	scanf("%d%d",&n,&p);
	for(int i=0;i<n;i++)
	{
	    int x;
		scanf("%d",&x);
		if(x&1) odd++;
		else even++;
	}
	LL tot=(1LL<<n);
	LL ans;
	ans=pow(2LL,LL(odd-1));
	ans=ans*pow(2LL,(LL)even);
	if(p&1)
	{
		printf("%lld\n",ans);
	}
	else 
	{
	    printf("%lld\n",tot-ans);
	}
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>

using namespace std;

int main() {
    string s;
    cin>>s;
    int n=s.size();
    int cnt=0;
    if(n%2==0){
      for(int i=0;i<n/2;++i){
        if(s[i]!=s[n-i-1]) cnt++;
      }
    }
    else{
      for(int i=0;i<n/2;++i){
        if(s[i]!=s[n-i-1]) cnt++;
      }
    }

    cout<<cnt<<endl;

   return 0;
 }


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int a[444],b[444];
const int M=1000000007;
int f[444][444],g[444];
int main()
{
	int n=io::F(),c=io::F();
	for(register int i=1;i<=n;++i)a[i]=io::F();
	for(register int i=1;i<=n;++i)b[i]=io::F();
	f[0][0]=1;
	for(register int i=1;i<=n;++i)
	{
		for(register int k=a[i];k<=b[i];++k)
		{
			for(register int j=0;j<=c;++j)g[j]=f[i-1][j];
			for(register int j=1;j<=c;++j)
				g[j]=(g[j]+(long long)g[j-1]*k)%M;
			for(register int j=0;j<=c;++j)
				(f[i][j]+=g[j])%=M;
		}
	}
	printf("%d\n",f[n][c]);
	return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct segmentTree{

    int N;
    vector<long long> node;

    long long _gcd(long long x, long long y){
        if(x == 0LL && y == 0LL){
            return 1LL;
        }else if(x == 0LL){
            return y;
        }else if(y == 0LL){
            return x;
        }
        long long r = x % y;
        while(r != 0LL){
            x = y;
            y = r;
            r = x % y;
        }
        return y;
    }
    
    void init(int siz){
        N = 1;
        while(N < siz){
            N <<= 1;
        }
        node.resize(N * 2 - 1, 1);
        return;
    }

    void build(vector<long long> &dat){
        init(dat.size());
        for(int i = 0, len = dat.size() ; i < len ; ++i){
            node[i + N - 1] = dat[i];
        }
        for(int i = N - 2 ; i >= 0 ; --i){
            node[i] = _gcd(node[i * 2 + 1], node[i * 2 + 2]);
        }
    }

    void update(int k, long long x){
        k += N - 1;
        node[k] = x;
        while(k > 0){
            node[k] = _gcd(node[k * 2 + 1], node[k * 2 + 2]);
        }
    }

    long long getGcd(int a, int b, int k, int l, int r){
        if(r <= a || b <= l){
            return 0LL;
        }
        if(a <= l && r <= b){
            return node[k];
        }
        long long vl = getGcd(a, b, k * 2 + 1, l, (l + r) / 2);
        long long vr = getGcd(a, b, k * 2 + 2, (l + r) / 2, r);
        return _gcd(vl, vr);
    }

    long long getGcd(int a, int b){
        return getGcd(a, b, 0, 0, N);
    }
};

template<typename T>
bool chmax(T &_a, T _b){
    if(_a < _b){
        _a = _b;
        return true;
    }else{
        return false;
    }
}

long long gcd(long long _x, long long _y){
    long long _r = _x % _y;
    while(_r != 0LL){
        _x = _y;
        _y = _r;
        _r = _x % _y;
    }
    return _y;
}

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

    int n;
    cin >> n;

    vector<lint> a(n);
    rep(i, n){
        cin >> a[i];
    }

    segmentTree seg;
    seg.build(a);

    lint ans = max(seg.getGcd(1, n), seg.getGcd(0, n - 1));
    REP(i, 1, n - 1){
        chmax(ans, gcd(seg.getGcd(0, i), seg.getGcd(i + 1, n)));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int a, b, k; cin >> a >> b >> k;
  for (int i = 0; i < k; ++i) {
    if (~i & 1) b += a >>= 1;
    else a += b >>= 1;
  }
  cout << a << ' ' << b << '\n';
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string S;
  cin>>S;
  if(S=="MON")cout<<6<<endl;
  if(S=="TUE")cout<<5<<endl;
  if(S=="WED")cout<<4<<endl;
  if(S=="THU")cout<<3<<endl;
  if(S=="FRI")cout<<2<<endl;
  if(S=="SAT")cout<<1<<endl;
  if(S=="SUN")cout<<7<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main (void){
    char s[3];
    char *arc="ARC";
    char *abc="ABC";

    scanf("%s",s);

    if(strcmp(s,arc)==0){
        printf("ABC");
    }else {
        printf("ARC");
    }



    return 0;
}

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

#define N 100010
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define pii pair <int, int>

using namespace std;

int a, b;

int main()
{
	cin >> a >> b;
	
	cout << a+b/2;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

for a in range(Y // 10000 + 1):
    for b in range((Y - 10000 * a) // 5000 + 1):
        if a + b + (Y - 10000 * a - 5000 * b) // 1000 == N:
            print(a, b, N - a - b)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 2940
#include <iostream>
#include <stack>

int main(){
	std::stack<int> st;
	int num;
	
	while(std::cin >> num){
		if(num == 0){
			std::cout << st.top() << std::endl;
			st.pop();
		}else{
			st.push(num);
		}
	}
	
    return 0;
}

Measured memory_bytes: 1200
#include<iostream>
using namespace std;
unsigned long xor_x=88172645463325252ULL;
unsigned long rng()
{
	xor_x^=xor_x<<7;
	return xor_x^=xor_x>>9;
}
int D;
int c[26],s[365][26];
int t[365],now;
int anst[365],ans;
void calc()
{
	int lst[26];
	for(int i=0;i<26;i++)lst[i]=-1;
	now=0;
	for(int i=0;i<D;i++)
	{
		now+=s[i][t[i]];
		lst[t[i]]=i;
		for(int j=0;j<26;j++)now-=c[j]*(i-lst[j]);
	}
}
int change(int d,int q)
{
	int ret=0;
	ret-=s[d][t[d]];
	ret+=s[d][q];
	{
		int r=d+1;
		while(r<D&&t[r]!=t[d])r++;
		int l=d-1;
		while(l>=0&&t[l]!=t[d])l--;
		ret-=c[t[d]]*(r-d)*(d-l);
	}
	{
		int r=d+1;
		while(r<D&&t[r]!=q)r++;
		int l=d-1;
		while(l>=0&&t[l]!=q)l--;
		ret+=c[q]*(r-d)*(d-l);
	}
	return ret;
}
main()
{
	cin>>D;
	for(int i=0;i<26;i++)cin>>c[i];
	for(int i=0;i<D;i++)for(int j=0;j<26;j++)cin>>s[i][j];
	for(int i=0;i<D;i++)
	{
		anst[i]=t[i]=rng()%26;
	}
	calc();
	ans=now;
	for(int tm=0;tm<3100;tm++)
	{
		int d=rng()%D,q=rng()%26;
		now+=change(d,q);
		t[d]=q;
		for(int k=0;k<3100;k++)
		{
			int d1=rng()%(D-1)+1,d2=rng()%d1;
			int pt1=t[d1],pt2=t[d2];
			int diff=0;
			diff+=change(d1,pt2);
			t[d1]=pt2;
			diff+=change(d2,pt1);
			t[d2]=pt1;
			if(diff>=0)
			{
				now+=diff;
			}
			else
			{
				t[d1]=pt1;
				t[d2]=pt2;
			}
		}
		if(ans<=now)
		{
			ans=now;
			for(int i=0;i<D;i++)anst[i]=t[i];
		}
		else
		{
			now=ans;
			for(int i=0;i<D;i++)t[i]=anst[i];
		}
	}
	for(int i=0;i<D;i++)cout<<anst[i]+1<<endl;
	cerr<<ans<<endl;
}

Measured memory_bytes: 3672
// problem: "https://atcoder.jp/contests/abc151/tasks/abc151_f"

#include<bits/stdc++.h>
#define Pair pair<double,double>

using namespace std;

Pair centerOf(vector<int>&X,vector<int>&Y,int i,int j,int k)
{
    int a1,b1,c1,a2,b2,c2;
    a1 = 2*(X[j]-X[i]);
    b1 = 2*(Y[j]-Y[i]);
    c1 = X[j]*X[j] + Y[j]*Y[j] - X[i]*X[i] - Y[i]*Y[i];
    a2 = 2*(X[j]-X[k]);
    b2 = 2*(Y[j]-Y[k]);
    c2 = X[j]*X[j] + Y[j]*Y[j] - X[k]*X[k] - Y[k]*Y[k];


    if(a1*b2 - a2*b1 == 0)
        return Pair(-10000.0,-10000.0);

    double x,y;
    x = (double)(c1*b2 - c2*b1)/(a1*b2 - a2*b1);
    y = (double)(a1*c2 - a2*c1)/(a1*b2 - a2*b1);

    return Pair(x,y);
}

bool validCand(Pair cand,double rad,vector<int>&X,vector<int>&Y,int n)
{
    int i;
    for(i=0;i!=n;i++)
    {
        double dist = sqrt((cand.first-X[i])*(cand.first-X[i]) + (cand.second-Y[i])*(cand.second-Y[i]));
        if(dist > rad)
            return false;

    }

    return true;
}

double minRadius(vector<int>&X,vector<int>&Y,int n)
{
    if(n == 2)
        return sqrt((X[0]-X[1])*(X[0]-X[1]) + (Y[0]-Y[1])*(Y[0]-Y[1]))/2.0;

    int i,j,k;

    double Min = 100000.0;
    for(i=0;i!=n-1;i++)
        for(j=i+1;j!=n;j++)
        {
            double rad = sqrt((X[i]-X[j])*(X[i]-X[j]) + (Y[i]-Y[j])*(Y[i]-Y[j]))/2.0;
            Pair cand((X[i]+X[j])/2.0,(Y[i]+Y[j])/2.0);

            if(validCand(cand,rad,X,Y,n))
                Min = min(Min,rad);
        }



    for(i=0;i!=n-2;i++)
        for(j=i+1;j!=n-1;j++)
            for(k=j+1;k!=n;k++)
            {
                Pair cand = centerOf(X,Y,i,j,k);      // define

                if(cand.first == -10000.0 && cand.second == -10000.0)
                    continue;

                double rad = sqrt((cand.first-X[i])*(cand.first-X[i]) + (cand.second-Y[i])*(cand.second-Y[i]));

                if(validCand(cand,rad,X,Y,n))       // define
                    Min = min(Min,rad);
            }


    return Min;
}

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

    int t1,t2;
    vector<int>X,Y;

    int i;
    for(i=0;i!=n;i++)
    {
        cin>>t1>>t2;

        X.push_back(t1);
        Y.push_back(t2);
    }

    cout<<setprecision(18)<<fixed<<minRadius(X,Y,n);     // define

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int X,A,B;cin>>X>>A>>B;
  
  if(A>=B){
    cout<<"delicious"<<endl;
  }
  else if(A<=B&&B-A<=X){
    cout<<"safe"<<endl;
  }
  else{
    cout<<"dangerous"<<endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int L; cin >> L;
	int A, B, C, D; cin >> A >> B >> C >> D;
	int ans = max((A+C-1)/C, (B+D-1)/D);
	ans = L-ans;
	cout << ans << endl;
}

Measured memory_bytes: 3108
#include <iostream>

using namespace std;

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

  if(S[0] != S[1] && S[1] != S[2] && S[2] != S[0])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 

int  A(int x){
    if(x>=0)return x;
    else return -x;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x%N;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N)*(y%N) % N;
		k /= 2;
	}
	return res;
}

unsigned long long popCount64bitB(unsigned long long x) 
{ 
    x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) 
      +  (x & 0x5555555555555555UL); 
    x = ((x & 0xccccccccccccccccUL) >> 2) 
      +  (x & 0x3333333333333333UL); 
    x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) 
      +  (x & 0x0f0f0f0f0f0f0f0fUL); 
    x = ((x & 0xff00ff00ff00ff00UL) >> 8) 
      +  (x & 0x00ff00ff00ff00ffUL); 
    x = ((x & 0xffff0000ffff0000UL) >> 16) 
      +  (x & 0x0000ffff0000ffffUL); 
    x = ((x & 0xffffffff00000000UL) >> 32) 
      +  (x & 0x00000000ffffffffUL); 
    return x; 
} 


vector<ll>g[2010];

ll dist[2010]={0};

int main(void){
    ll n,x,y;
    cin>>n>>x>>y;
    for(ll i=1;i<n;i++){
        for(ll j=i+1;j<=n;j++){
            if(i<=x){
                if(j<=x)dist[j-i]++;
                else{
                    if(j>=y){
                        dist[x-i+j-y+1]++;
                    }
                    else{
                        ll d = min(j-i,x-i+1+y-j);
                        dist[d]++;
                    }
                }
            }
            else{
                if(i>=y)dist[j-i]++;
                else{
                    if(j<=y){
                        ll d = min(j-i,i-x+1+y-j);
                        dist[d]++;
                    }
                    else{
                        ll d = min(j-i,i-x+1+j-y);
                        dist[d]++;
                    }
                }
            }
        }
    }
    for(ll i=1;i<=n-1;i++){
        cout<<dist[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int x,y,z,num,num2;
        x=sc.nextInt();
        y=sc.nextInt();
        z=sc.nextInt();

        num = x/(y+z);
        if(num*(y+z)+z <=x) System.out.println(num);
        else System.out.println(num-1);
    }
}


Measured memory_bytes: 23124
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    final List<Integer> list2 = new ArrayList<>();
    //final List<Long> list3 = new ArrayList<>();

    int n = sc.nextInt();
    int count = 0;
    int check = 0;

    for(int i = 0; i < n ; i++){
        list.add(sc.nextInt());
        list2.add(sc.nextInt());
    }

    for(int i = 0; i < n ; i++){
        if(list.get(i).equals(list2.get(i))){
            count++;
        }else{
            count = 0;
        }
        if(count == 3){
            check++;
        }
    }

    if(check == 0){
        System.out.println("No");
    }else{
        System.out.println("Yes");
    }

    

   

    

    




    







}
}

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

int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    for(int i=0;i<n;i++){
        if(a[i]<b[n-1]){
            cout<<b[n-1]<<endl;
        }else{
            cout<<b[n-2]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5160
fun main(args: Array<String>) {
    val s = readLine()!!
    var num = 0
    when(true) {
        s[0] == '1' -> {
            num += 1
        }
    }
    when(true) {
        s[1] == '1' -> {
            num += 1
        }
    }
    when(true) {
        s[2] == '1' -> {
            num += 1
        }
    }
    println(num)
}

Measured memory_bytes: 31568
#include <stdio.h>
#define MAX 100000
#define SEN 2000000000

typedef struct Card{
  char suit;
  int value;
}C;

C L[MAX/2+2],R[MAX/2+2];

void merge(C A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1].value=R[n2].value=SEN;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }
    else {
      A[k]=R[j++];
    }
  }
}

void mergeSort(C A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(C A[],int n,int p,int r){
  int i,j;
  C t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

void quickSort(C A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  C A[MAX],B[MAX];
  char S[10];
  int stable=1;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
  
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);
  
  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit) stable=0;
  }
  
  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}



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

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

   string a,b,c;
   cin >> a >> b >> c;
   int aid = a.size() + 1,bid = b.size() + 1,cid = c.size() + 1,flag = 0;

   int acnt=0,bcnt=0,ccnt=0;
   while(1){
      if(flag == 0){
         aid -= 1;
         if(a[acnt] == 'a') flag = 0;
         if(a[acnt] == 'b') flag = 1;
         if(a[acnt] == 'c') flag = 2;
         acnt++;
      }
      if(flag == 1){
         bid -= 1;
         if(b[bcnt] == 'a') flag = 0;
         if(b[bcnt] == 'b') flag = 1;
         if(b[bcnt] == 'c') flag = 2;
         bcnt++;
      }
      if(flag == 2){
         cid -= 1;
         if(c[ccnt] == 'a') flag = 0;
         if(c[ccnt] == 'b') flag = 1;
         if(c[ccnt] == 'c') flag = 2;
         ccnt++;
      }
      if(aid == 0){
         cout << "A" << endl;
         return 0;
      }
      if(bid == 0){
         cout << "B" << endl;
         return 0;
      }
      if(cid == 0){
         cout << "C" << endl;
         return 0;
      }
   }

   return 0;
}

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

long double calculate_angle(int h,int m){
    return (30.0*h - 5.5*m)*(M_PI/180.0);
}

int main()
{
   int a,b,h,m;
   cin>>a>>b>>h>>m;
   
   double angle = calculate_angle(h,m);

   
   cout<<setprecision(15)<<sqrt(a*a+b*b-2*a*b*(double)cos(angle));
}

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

double m[3];
void solve(){

}
int main(){
  while(cin >> m[0] >> m[1] >> m[2], m[0]||m[1]||m[2]){
    sort(m, m+3);
    double d = sqrt(m[0]*m[0]+m[1]*m[1]);
    int n;
    cin >> n;
    while(n--){
      double r;
      cin >> r;
      cout << (d<(r*2.)?"OK":"NA") << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1240
import java.util.*;

class Main {



	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        int count = 1;

        //AとBの最大公約数を求める
        long gcdAB = Main.gcd(A, B);

        //最大公約数を、「素数 or 1」になるまで素因数分解
        //新しい素数で割れた時にcountを増やす
        for(long i = 2 ; i <= Math.sqrt(gcdAB); i++){
            //自身の平方根より小さい数字で割り切れない場合、その数は素数である
            if(gcdAB % i == 0) count++;
            while(gcdAB % i == 0){
                gcdAB /= i;
            }
        }
        //gcdABが「素数 or 1」になっているので、素数の場合はcountを増やす
        if(gcdAB > 1) count++;

        System.out.println(count);

    }

    //gcd  = greateset common divisor
    public static long gcd(long A, long B){
        if(A%B == 0) return B;
        else return gcd(B, A%B);
    }




}







Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1,51};
	int k;
	cin>>k;
	cout<<a[k-1];
	return 0;
}

Measured memory_bytes: 256
loop do
  h, w = gets.split.map(&:to_i)

  break if h == 0 && w == 0
  
  h.times do |i|
    s = ""
    w.times do |j|
      s += ((i+j)%2==1 ? "." : "#")
    end
    puts s        
  end

  puts
end

Measured memory_bytes: 9316
#include<iostream>

using namespace::std;

long long int dp[1005][1<<13];
pair<int,int> ar[1005];

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
		for(int j=0;j<(1<<13);j++)
			dp[i][j]=1e9;
	for(int i=0,t;i<m;i++){
		cin>>ar[i].first>>t;
		for(int j=0,l;j<t;j++)
			cin>>l,ar[i].second|=(1<<(l-1));
	}
	
	dp[0][0]=0;
	
	for(int i=0;i<m;i++)
		for(int j=0;j<(1<<13);j++)
			dp[i+1][j]=min(dp[i][j],dp[i+1][j]),dp[i+1][j|ar[i].second]=min(dp[i+1][j|ar[i].second],dp[i][j]+ar[i].first);

	//for(int i=0;i<m;cout<<'\n',i++)
	//	for(int j=0;j<=(1<<n)-1;j++)
	//		cout<<dp[i][j]<<' ';
	//cout<<'\n';
	//for(int i=0;i<m;i++)
	//	cout<<ar[i].first<<' '<<ar[i].second<<'\n';

	cout<<(dp[m-1][(1<<n)-1]==1e9?-1:dp[m-1][(1<<n)-1])<<'\n';
}

Measured memory_bytes: 64256
#include <stdio.h>
#include <math.h>
#include <cmath>

using namespace std;

int main(){
	int n;
	double x[100] = {0},y[100] = {0},p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
	scanf("%d",&n);
	for(int i = 0; i < n; i++) scanf("%lf",&x[i]);
	for(int i = 0; i < n; i++) scanf("%lf",&y[i]);

	for(int i = 0; i < n; i++){
		p_1 += abs(x[i] - y[i]);
		p_2 += (x[i] - y[i])*(x[i] - y[i]);
		p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
		p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
 	}
	printf("%.6lf\n",p_1);
	printf("%.6lf\n",sqrt(p_2));
	printf("%.6f\n",cbrt(p_3));
	printf("%.6lf\n",p_infinity);

}


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

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

    int l[n];
    rep(i,n) cin >> l[i];
    sort(l, l+n);

    vector<int> a, b;
    {
        int i = 0;
        while (i < n) {
            a.push_back(l[i]);
            b.push_back(0);

            int j = i;
            while (j < n) {
                if (l[j] == l[i]) b.back()++;
                else break;
                j++;
            }
            i = j;
        }
    }

    int cnt = 0;
    for (int i = a.size()-1; i >= 2; i--) {
        for (int j = i-1; j >= 1; j--) {
            for (int k = 0; k < j; k++) {
                if (a[i] < a[j]+a[k]) cnt += b[i]*b[j]*b[k];
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3588
from collections import deque
h,w=map(int,input().split())
INF=10**9
check=[]
for i in range(h):
    sub_list=[]
    for j in range(w):
        sub_list.append(INF)
    check.append(sub_list)
black=deque([])
for i in range(h):
    sub_list=list(input())
    for j in range(w):
        if sub_list[j]=='#':
            black.append((i,j))
            check[i][j]=0
Max=0
while len(black)>0:
    now=black.popleft()
    U=(now[0]-1,now[1])
    D=(now[0]+1,now[1])
    L=(now[0],now[1]-1)
    R=(now[0],now[1]+1)
    for i in U,D,L,R:
        if 0<=i[0]<=h-1 and 0<=i[1]<=w-1 and check[i[0]][i[1]]==INF:
            check[i[0]][i[1]]=check[now[0]][now[1]]+1
            Max=max(Max,check[i[0]][i[1]])
            black.append(i)
print(Max)
            






        


Measured memory_bytes: 86876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int mod=1e9+7;
const int N = 1e5+5;

ll n,s;

ll f(ll b,ll n){
  return (b>n)?n:(f(b,n/b)+n%b);
}

int main(){
  // freopen("input.txt","r",stdin);
  cin>>n>>s;
  if(s > n) {cout<<"-1"<<endl;return 0;}
  if(s == n) {cout<<n+1<<endl;return 0;}
  ll m = sqrt(n)+1;
  for(ll i = 2;i <= m;i++){
    if(f(i,n) == s){
      cout<<i<<endl;
      return 0;
    }
  }
  n -= s;ll ans = 1e11;
  for(ll i = 1;i*i <= n;i++){
    if(n%i == 0){
      ll b = n/i + 1;
      if(f(b,n+s) == s) ans = min(ans,b);
    }
  }
  if(ans == 1e11) cout<<"-1"<<endl;
  else cout<<ans<<endl;
  return 0;
}






Measured memory_bytes: 384
def f(a, b, c, x):
    return (a * x + b) % c
while 1:
    n, a, b, c, x = map(int, raw_input().split())
    if n == 0:
        break
    t = 0
    Y = map(int, raw_input().split())
    idx = 0
    while t <= 10000 and idx < n:
        if Y[idx] == x:
            idx += 1
            if idx == n:
                break
        x = f(a, b, c, x)
        t += 1
    if t > 10000:
        print -1
    else:
        print t

Measured memory_bytes: 6372
#include<bits/stdc++.h>
#define pa pair<int,int>
#define maxn 100005
using namespace std;
priority_queue<pa>q;
vector<int>v[maxn];
int A,B,a[maxn];
bool used[maxn],has[maxn];
int main(){
    int n;scanf("%d",&n);for(int i=1;i<n;i++){
        scanf("%d%d",&A,&B);
        v[A].push_back(B);
        v[B].push_back(A);}
    int k;scanf("%d",&k);for(int i=0;i<k;i++){
        scanf("%d%d",&A,&B);
        a[A]=B;has[A]=1;q.push(pa(-B,A));}
    while(!q.empty()){
        B=-q.top().first,A=q.top().second;q.pop();
        used[A]=1;for(int i=0;i<(int)v[A].size();i++)
        if(!used[v[A][i]]&&has[v[A][i]]&&a[v[A][i]]!=B+1){puts("No");return 0;}
        else if(!used[v[A][i]]) used[v[A][i]]=1,a[v[A][i]]=B+1,q.push(pa(-B-1,v[A][i])),has[v[A][i]]=1;}
    puts("Yes");
    for(int i=1;i<=n;i++)printf("%d\n",a[i]);
    return 0;
}

Measured memory_bytes: 8448
import unittest
import math


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(20), 23)

    def test_2(self):
        self.assertEqual(think(2), 2)

    def test_3(self):
        self.assertEqual(think(99992), 100003)


def solve():
    x = read()
    result = think(x)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(x):
    index = 0
    while True:
        buf = x + index
        if is_prime(buf):
            return buf
        index += 1


def is_prime(n):
    if n <= 1:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    ceil = int(math.ceil(math.sqrt(n))) + 1
    for i in range(3, ceil + 1):
        if n % i == 0:
            return False
    return True


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 5828
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	int n;
	string s;
	// nyuryoku
	cin >> n >> s;
	int keep[s.size()];
	for(int i=0;i<s.size();i++){
		keep[i] = s[i] - 'A' + n;
		keep[i] = keep[i] % 26;
		printf("%c",'A' + keep[i]);
	}
	// keisan

	// syutsuryoku
}

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

int main() {
  int N,L;
  string str;
  vector<string> v;
  cin >> N >> L;
  for(int i=0; i<N; ++i) {
  	cin >> str;
    v.push_back(str);
  }
  sort(v.begin(), v.end());
  for(string & s: v) cout << s;
}

Measured memory_bytes: 256
#include<iostream>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#include <algorithm>
using namespace std;

int main(){
  int N;
  cin>>N;
  int S[N];
  for(int i=0;i<N;++i){
    cin>>S[i];
  }
  
  sort(S, S + SIZE_OF_ARRAY(S));
  
  int m=0;
  for(int i=0;i<N;++i){
    for (int j=0;j<i;++j){
      for (int k=j-1;k>=0;--k){
        if(S[k]>(S[i]-S[j])){
          m+=1;
        }else{
          break;
        }
      }
    }
  }
  
  cout<<m<<endl;
}

Measured memory_bytes: 256