akhauriyash/Code-Regression huggingface dataset:
# Acceptance of input

import sys

file_input = sys.stdin

V, E = map(int, file_input.readline().split())

adj_mat = [[0] * V for i in range(V)]

for line in file_input:
    u, v, c = map(int, line.split())
    adj_mat[u][v] = c

# Ford???Fulkerson algorithm

import collections

# BFS for residual capacity network
def bfs(start, goal, parent):
    unvisited = [True] * V
    queue = collections.deque()
    queue.append(start)
    unvisited[start] = False
    while queue:
        u = queue.popleft()
        for v, r_capacity in enumerate(adj_mat[u]):
            if unvisited[v] and (r_capacity > 0):
                queue.append(v)
                unvisited[v] = False
                parent[v] = u
                if v == goal:
                    return not unvisited[goal]

def ford_fulkerson(source, sink):
    parent = [None] * V
    max_flow = 0
    while bfs(source, sink, parent):
        aug_path_flow = 10000
        v = sink
        while (v != source):
            aug_path_flow = min(aug_path_flow, adj_mat[parent[v]][v])
            v = parent[v]
        max_flow += aug_path_flow
        v = sink
        while (v != source):
            u = parent[v]
            adj_mat[u][v] -= aug_path_flow
            adj_mat[v][u] += aug_path_flow
            v = u
    return max_flow

# output
print(ford_fulkerson(0, V - 1))

Measured memory_bytes: 8172
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    double r,r1,r2,r3=3.141592653589793238462643383279;
    scanf("%lf",&r);
    r1=r3*r*r;
    r2=2*r3*r;
    printf("%f %f\n",r1,r2);
    return 0;
}



Measured memory_bytes: 2036
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,random
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

S = list(map(int,list(str(input()))))
N = len(S)
ans = 0
for i in range(N):
    if i%2 == 0 and S[i] == 0:
        ans += 1
    elif i%2 == 1 and S[i] == 1:
        ans += 1

print(min(ans,N-ans))


Measured memory_bytes: 6180
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        boolean[] sieve = sieve(100000 + 10);
        int[] like = new int[100000 + 10 + 1];
        like[0] = 0;
        like[1] = 0;
        like[2] = 0;
        for (int i = 3; i < 100000 + 10; i += 2) {
            if (sieve[i] == true && sieve[(i + 1) / 2] == true) {
                like[i] = like[i-2] + 1;
            } else {
                like[i] = like[i-2];
            }
        }

        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();

            int ans = 0;
            if (l == 1) ans = like[r];
            else ans = like[r] - like[l - 2];
            System.out.println(ans);
        }
    }

    public static boolean[] sieve(int n) {
        final boolean[] sieve = new boolean[n+1];
        sieve[0] = false;
        sieve[1] = false;
        sieve[2] = true;
        for (int i = 3; i <= n; i += 2) {
            sieve[i] = true;
        }

        for (int i = 3; i * i <= n; i += 2) {
            if (sieve[i]) {
                for (int j = i * 2; j <= n; j += i) {
                    sieve[j] = false;
                }
            }
        }

        return sieve;
    }
}


Measured memory_bytes: 65436
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

void solve(std::string A){
    ll n=A.size();

    ll cnt=0;
    vl exs(26);
    vl idxs;
    idxs.push_back(n);
    ll k=1;
    vvl pos(26);
    rep(i,26)pos[i].push_back(n);
    for(ll i=n-1;i>=0;i--){
        ll x=A[i]-'a';
        if(!exs[x])cnt++;
        exs[x]++;
        if(cnt==26){
            k++;
            idxs.push_back(i);
            exs.assign(n,0);
            cnt=0;
        }
        pos[x].push_back(i);
    }
    rep(i,26)reverse(all(pos[i]));
    reverse(all(idxs));

    string ans;
    ll idx=-1;
    rep(i,k){
        rep(j,26){
            ll nxt=*upper_bound(all(pos[j]),idx);
            if(nxt>=idxs[i]){
                ans+=(char)('a'+j);
                idx=nxt;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

int main(){
    std::string A;
    std::cin >> A;
    solve(A);
}


Measured memory_bytes: 4228
import java.io.*;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner cin = new Scanner(System.in);
		
		String classname;
		int before,after;
		
		while(cin.hasNext())
		{	
			classname = cin.next();
			before = cin.nextInt();
			after = cin.nextInt();
			
			System.out.println(classname+" "+(before+after)+" "+(before*200+after*300));
		}
	}
}

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

const int MAX_N = 1000000;
const int MAX_F = 1000;
int num[1001][1001];
int dp[1001][1001], last[1001][1001];

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

bool isProperXY(int x, int y, int m) {
	return 0 <= x && x <= MAX_F && 0 <= y && y <= MAX_F && 0 < num[y][x] && num[y][x] <= m;
}

int main() {
	vi isPrime(MAX_N + 1, true);
	isPrime[0] = isPrime[1] = false;
	FOR(i, 2, 1000) {
		for (int j = i*i; j <= MAX_N; j += i) {
			isPrime[j] = false;
		}
	}

	memset(num, INF, sizeof(num));
	int x = 500, y = 500, cur = 1, step = 1;
	while (cur <= MAX_N) {
		REP(i, (step + 1) / 2) {
			num[y][x] = cur;
			cur++;
			x += dx[step % 4];
			y += dy[step % 4];
		}
		step++;
	}

	int m, n;
	while (cin >> m >> n, m) {
		int stx, sty;
		FOR(i, 0, MAX_F) {
			FOR(j, 0, MAX_F) {
				if (num[i][j] == n) {
					sty = i, stx = j;
				}
			}
		}
//		cout << sty << " " << stx << endl;

		memset(dp, 0, sizeof(dp));
		memset(last, 0, sizeof(last));
		if (isPrime[num[sty][stx]]) {
			dp[sty][stx] = 1;
			last[sty][stx] = num[sty][stx];
		}
		int ans = dp[sty][stx], lastp = last[sty][stx], minx = stx, maxx = stx;
		bool cont = true;
		y = sty;
		while (cont) {
			cont = false;
			int nminx = INF, nmaxx = -INF;
			FOR(x, minx, maxx) {
				FOR(d, 1, 3) {
					int nx = x + dx[d], ny = y + 1;
					if (isProperXY(nx, ny, m)) {
						cont = true;
						nminx = min(nminx, nx);
						nmaxx = max(nmaxx, nx);
						if (isPrime[num[ny][nx]]) {
							last[ny][nx] = num[ny][nx];
						}
						else {
							last[ny][nx] = last[y][x];
						}
						int ndp = dp[y][x] + (isPrime[num[ny][nx]] ? 1 : 0);
						if (ans == ndp && lastp < last[ny][nx]) {
							lastp = last[ny][nx];
						}
						else if (ans < ndp) {
							ans = ndp;
							lastp = last[ny][nx];
						}
						dp[ny][nx] = max(dp[ny][nx], ndp);
//						cout << num[y][x] << " " << num[ny][nx] << " " << dp[ny][nx] << endl;
					}
				}
			}
			minx = nminx, maxx = nmaxx;
			y++;
		}

		cout << ans << " " << lastp << endl;
	}

	return 0;
}

Measured memory_bytes: 16772
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

int main(){
	int N,l[10]={},maxi=0,sum=0;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>l[i];
		maxi=max(maxi,l[i]);
		sum+=l[i];
	}
	if(sum-maxi>maxi)cout<<"Yes";
	else cout<<"No";
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	ll x,cost;
};
int main() {

	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b!=c)cout<<"Yes"<<endl;
	else if(a!=b&&b==c)cout<<"Yes"<<endl;
	else if(a==c&&a!=b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    string s; cin >> s;
    for(int i = 1; i < s.size(); i++)
    {
        if(s[i] == s[i - 1])
        {
            cout << i - 1 + 1 << " " << i + 1 << endl;
            return;
        }
    }
    for(int i = 1; i < (int)s.size() - 1; i++)
    {
        string t = s.substr(i - 1, 3);
        map<char, int> mp;
        for(const auto &ch : t) mp[ch]++;
        for(const auto &x : mp)
        {
            if(x.second == 2)
            {
                cout << i - 1 + 1 << " " << i + 1 + 1 << endl;
                return;
            }
        }
    }
    cout << -1 << " " << -1 << endl;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

  int main(void){

    int a,b,c;
    int y = 0, x = 0;

    scanf("%d %d %d",&a,&b,&c);

    for (x = a;x <= b;x++)
      {
      if (c % x == 0)
	y++;
      }
    printf("%d\n",y);

    return 0;
  }

Measured memory_bytes: 596
#include <cstdio>
#include <algorithm>
#define rep(i,j,k) for (i=j;i<=k;i++)
#define down(i,j,k) for (i=j;i>=k;i--)
using namespace std;
const int N=1e5+5,K=20;
int n,i,j,u,v,ans;
int En,used[N][K],fst[N],nxt[N*2],to[N*2];
void add(int u,int v) { En++; nxt[En]=fst[u]; fst[u]=En; to[En]=v; }
void dfs(int x,int fa)
{
	int i,j,v,g;
	for (j=fst[x];j;j=nxt[j])
	if (to[j]!=fa)
	{
		v=to[j];
		dfs(v,x);
		rep(i,0,K-1)
		  used[x][i]+=used[v][i];
	}
	down(g,K-1,0)
		if (used[x][g]>1) break;
	g++;
	while (used[x][g]) g++;
	used[x][g]=1;
	rep(i,0,g-1) used[x][i]=0;
	ans=max(ans,g);
}
int main()
{
//	freopen("uninity.in","r",stdin);
//	freopen("uninity.out","w",stdout);
	scanf("%d",&n);
	rep(i,1,n-1)
	{
		scanf("%d%d",&u,&v);
		add(u,v); add(v,u);
	}
	dfs(1,1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 15616
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int I[]={1,1,-1,-1};
int J[]={1,-1,1,-1};
int N;
string s;

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

    vector<int> v(N+1,0);
    rep(n,4){
        v[0]=I[n];
        v[1]=J[n];
        repn(i,N-1){
            if(v[i]==1){
                if(s[i]=='o') v[i+1]=v[i-1];
                if(s[i]=='x') v[i+1]=-v[i-1];
            }else if(v[i]==-1){
                if(s[i]=='o') v[i+1]=-v[i-1];
                if(s[i]=='x') v[i+1]=v[i-1];
            }
        }
        if(v[0]==v[N] && ((v[0]==1 && s[0]=='o' && v[N-1]==v[1]) 
        || (v[0]==1 && s[0]=='x' && v[N-1]==-v[1])
        || (v[0]==-1 && s[0]=='x' && v[N-1]==v[1]) 
        || (v[0]==-1 && s[0]=='o' && v[N-1]==-v[1]))){
            //cout<<n<<endl;
            //repr(e,v) cout<<e<<' ';cout<<endl; 
            rep(i,N){
                if(v[i]==1) cout<<'S';
                else cout<<'W';
            }
            cout<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;
}

Measured memory_bytes: 3800
var main = standardInput => {
  var input = standardInput.split('\n').map(function(v){
    return v
  });
  var N = input[0];
  var S = input[1];
  var K = parseInt(input[2],10);

  var letter = "[^" + S[K-1] + "]";

  console.log(S.replace(new RegExp(letter,"g"),"*"));

};
main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

Measured memory_bytes: 7372
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

// get(k): binary search on BIT
template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0;						// to be set
    vector<Abel> dat;
    
    /* [1, n] */
    BIT(int n) : dat(n + 1, UNITY_SUM) { }
    void init(int n) { dat.assign(n + 1, UNITY_SUM); }
    
    /* a is 1-indexed */
    inline void add(int a, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            dat[i] = dat[i] + x;
    }
    
    /* [1, a], a is 1-indexed */
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[i];
        return res;
    }
    
    /* [a, b), a and b are 1-indexed */
    inline Abel sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }

    /* k-th number (k is 0-indexed) */
    int get(long long k) {
        ++k;
        int res = 0;
        int N = 1; while (N < (int)dat.size()) N *= 2;
        for (int i = N / 2; i > 0; i /= 2) {
            if (res + i < (int)dat.size() && dat[res + i] < k) {
                k = k - dat[res + i];
                res = res + i;
            }
        }
        return res + 1;
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat.size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

//--------------------------- Solve ---------------------------//

void solve() {
    int N, Q; cin >> N >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    vector<int> pi(N+1, -1);
    vector<vector<int>> ps(N);
    for (int i = 0; i < N; i++) {
        int l = pi[a[i]];
        if (l != -1) ps[l].push_back(i);
        pi[a[i]] = i;
    }

    vector<vector<pair<int, int>>> qs(N);
    for (int i = 0; i < Q; i++) {
        int l, r; cin >> l >> r;
        l--; r--;
        qs[l].push_back(make_pair(r, i));
    }

    vector<int> ans(Q);
    BIT<int> d(N);
    for (int x = N-1; x >= 0; x--) {
        for (int y : ps[x]) d.add(y, 1);
        for (pair<int, int> query : qs[x]) {
            int r = query.first, i = query.second;
            ans[i] = (r-x+1) - d.sum(r);
        }
    }

    print(ans);
}

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

    solve();

    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

template<int64 mod>
struct ModInt{
  int64 x;
  constexpr ModInt(int64 y = 0):x((y%mod+mod)%mod){}
  constexpr ModInt& operator+=(const ModInt& a){
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt& operator-=(const ModInt& a){
    if((x -= a.x) < 0)x += mod;
    return *this;
  }
  constexpr ModInt& operator*=(const ModInt& a){
    x = x * a.x % mod;
    return *this;
  }
  constexpr ModInt& operator/=(const ModInt& a){
    *this *= a.inv();
    return *this;
  }
  constexpr ModInt operator-() const {
    return ModInt(-x);
  }
  constexpr ModInt operator+(const ModInt& a) const {
    return ModInt(*this) += a;
  }
  constexpr ModInt operator-(const ModInt& a) const {
    return ModInt(*this) -= a;
  }
  constexpr ModInt operator*(const ModInt& a) const {
    return ModInt(*this) *= a;
  }
  constexpr ModInt operator/(const ModInt& a) const {
    return ModInt(*this) /= a;
  }
  constexpr ModInt operator++(){
    *this += ModInt(1);
    return *this;
  }
  constexpr ModInt operator++(int){
    ModInt old = *this;
    ++*this;
    return old;
  }
  constexpr ModInt operator--(){
    *this -= ModInt(1);
    return *this;
  }
  constexpr ModInt operator--(int){
    ModInt old = *this;
    --*this;
    return old;
  }
  constexpr bool operator==(const ModInt& a) const {
    return x == a.x;
  }
  constexpr bool operator!=(const ModInt& a) const {
    return x != a.x;
  }
  constexpr ModInt pow(int64 r) const {
    if(!r)return 1;
    ModInt res = pow(r>>1);
    res *= res;
    if(r & 1) res *= *this;
    return res;
  }
  constexpr ModInt inv() const {
    return pow(mod-2);
  }
  friend istream& operator>>(istream& is, ModInt& a){
    int64 t;
    is >> t;
    a = ModInt(t);
    return is;
  }
  friend ostream& operator<<(ostream& os, const ModInt& a){
    return os << a.x;
  }
};
using mint = ModInt<MOD>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<int32> c(n);
    REP(i,n)cin >> c[i];
    sort(c.rbegin(), c.rend());
    mint ans = 0;
    REP(i,n){
        ans += (mint)(i + 2) * (mint)c[i];
    }
    ans *= mint(4).pow(n-1);
    ANS(ans);
    return 0;
}

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

int main() {
  int k,a,b;
  cin >> k >> a >> b;
  int c = a/k;
  int d = b/k;
  if(c!=d || k==1 || a%k==0)
  cout << "OK" << endl;
  else
    cout << "NG" << endl;
}



Measured memory_bytes: 3620
#include<iostream>
#include<queue>
using namespace std;
int main()
{
	queue<long long int>sq;
	long long int d,n,k,s,ans=0,cnt=1;
	cin>>n>>k>>s;
    while(cnt<=k){
    	sq.push(s);
    	cnt++;
	}
	if(s==1e9) {
		s=1;
	for(int i=1;i<=n-k;i++){
        sq.push(s);
	} 
	}
	else {
	s=s+1;
	for(int i=1;i<=n-k;i++){
        sq.push(s);
	} 
	} 
	while(!sq.empty()){
		cout<<sq.front()<<' ';
		sq.pop();
	}
	return 0;
 }  

Measured memory_bytes: 2176
ARGF.each do |line|
n, x = line.split.map(&:to_i)
break if n == 0 && x == 0
ary = []
(1..n).each do |a|
  (1..n).each do |b|
    (1..n).each do |c|
      if a + b + c == x && !(a==b) && !(a==c) && !(b==c)
        ary << [a,b,c].sort
      end
    end
  end
end
  puts ary.uniq.count
end

Measured memory_bytes: 6848
object Main {
	def main(args: Array[String]): Unit = {
		var counter = 0
		var A = readInt()
		var B = readInt()
		var C = readInt()
		var X = readInt()
		for (currentA <- 0 to A) {
			for (currentB <- 0 to B) {
				for (currentC <- 0 to C) {
					if (currentA * 500 + currentB * 100 + currentC * 50 == X) {
						counter += 1
					}
				}
			}
		}
		println(counter)
	}
}

Measured memory_bytes: 28600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8101145141919364364,LMOD=998244353;
// const int dx[]={1,1,0,-1,-1,-1,0,1},dy[]={0,-1,-1,-1,0,1,1,1};

const int MAX=510000;

//階乗,逆元,逆元の階乗
long long 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%LMOD;
        inv[i]=LMOD-inv[LMOD%i]*(LMOD/i)%LMOD;
        finv[i]=finv[i-1]*inv[i]%LMOD;
    }
}

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

int main(){
    //前処理
    COMinit();
    long long n,a,b,k; cin>>n>>a>>b>>k;
    long long ans=0;
    for(long long i=0;i<=n;i++){
        if((k-a*i)%b==0&&(k-a*i)/b>=0){
            ans+=(COM(n,i)*COM(n,(k-a*i)/b))%LMOD;
            ans%=LMOD;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int n, m;

int main() {

    cin >> n >> m;

    int dist[n][n];
    int edge[n][n];

    rep(i, n) rep(j, n) dist[i][j] = (i == j ? 0 : INF);
    vector<pii> check_edge;

    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        dist[a][b] = c;
        dist[b][a] = c;
        edge[a][b] = c;
        edge[b][a] = c;
        check_edge.push_back(MP(a, b));
    }

    rep(k, n) rep(i, n) rep(j, n) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

    int cnt = 0;

    for (auto e : check_edge) {

        rep(s, n) {
            if (dist[s][e.first] + edge[e.first][e.second] == dist[s][e.second]) {
                cnt++;
                break;
            }
        }
    }

    cout << m - cnt << endl;

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int k;
	cin >> k;

	char sk;
	sk = s[k-1];

	string out_s(n, '*');

	for(int i=0;i<n;++i){
		if(sk == s[i]) out_s[i]=sk;
	}

	cout << out_s << endl;

}


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

int main(void){
    long long n, k;
    cin >> n >> k;
    
    long long num[100001] = {0};
    long long a, b;
    long long i;
    for(i = 1; i <= n; i++){
        cin >> a >> b;
        num[a] += b;
    }
    
    long long cnt = 0;
    for(i = 1; i <= 100000; i++){
        cnt += num[i];
        if(cnt >= k){
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

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

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

void solve()
{
    double A, B, H, M;
    cin >> A >> B >> H >> M;

    double s = fabs((30 * H + 0.5 * M) - 6 * M);
    cout << sqrt(A * A + B * B - 2 * A * B * cos(PI * s / 180));
}

signed main()
{

    solve();

    return 0;
}


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




int main(){

   ll l,r;
   cin >> l >> r;

   r=min(r,l+4038);

   ll m=2018;

   for(ll i=l;i<r;i++){
       for(ll j=i+1;j<=r;j++){
           m=min(m,i*j%2019);
       }
   }


   

   cout << m << endl;



    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N; cin >> N;
    int oddCount = 0;
    int A;
    rep(i, N) {
        cin >> A;
        if(A % 2)
            ++oddCount;
    }
    cout << ((oddCount % 2) ? "NO" : "YES") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  int k = K-1;
  string s;
  cin >> s;
  if (s[k] == 'A') s[k] = 'a';
  if (s[k] == 'B') s[k] = 'b';
  if (s[k] == 'C') s[k] = 'c';
  cout << s.substr(0,k) + s[k] + s.substr(k+1,N-k) << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    while (1){
    int a,b;
    char op;    //文字にする
    cin >> a >> op >> b;
    if (op == '?') break;
    else if (op == '+') {
        cout << (a+b) << endl;
    }
    else if (op == '-') {
        cout << (a-b) << endl;
    }
    else if (op == '*') {
        cout << (a*b) << endl;
    }
    else if (op == '/') {
        cout << (a/b) << endl;
    }
    }
}


Measured memory_bytes: 3080
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var S = ReadLine();
            var wCnt = new long[N + 1];//[0,i)でWを向いている人の数
            var eCnt = new long[N + 1];//[i,N)でEを向いている人の数
            for (var i = 1; i <= N; ++i)
                wCnt[i] = wCnt[i - 1] + (S[i - 1] == 'W' ? 1 : 0);
            for (var i = N - 1; 0 <= i; --i)
                eCnt[i] = eCnt[i + 1] + (S[(int)i] == 'E' ? 1 : 0);
            var cnt = long.MaxValue;
            for (var i = 0; i < N; ++i)//[0,i)と[i+1,N)
                cnt = Min(cnt, wCnt[i] + eCnt[i + 1]);
            WriteLine(cnt);
        }


        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 34000
n=int(input())
l=[[] for i in range(n)]
for i in range(n-1):
    x,y = map(int,input().split())
    x-=1
    y-=1
    l[x].append(y)
    l[y].append(x)
from collections import deque
q=deque([0])
lf=[10**100 for i in range(n)]
lf[0]=0
while q:
    p=q.popleft()
    for i in l[p]:
        if lf[p]+1<lf[i]:
            lf[i]=lf[p]+1
            q.append(i)
q=deque([n-1])
ls=[10**100 for i in range(n)]
ls[n-1]=0
while q:
    p=q.popleft()
    for i in l[p]:
        if ls[p]+1<ls[i]:
            ls[i]=ls[p]+1
            q.append(i)
s,f=0,0
for i in range(n):
    if lf[i]<=ls[i]:
        f+=1
    else:
        s+=1
if f<=s:
    print("Snuke")
else:
    print("Fennec")

Measured memory_bytes: 67616
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k, x;
  cin >> k >> x;
  vector<int> res(0);
  FOR(i,x-k+1,x+k) res.push_back(i);
  print_array(res);
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int		main(void)
{
	int k, x;
	cin >> k >> x;
	if (k * 500 >= x)
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 256
L = int(input())
rec = []
r = 0
K = L
while K > 1:
    K //= 2
    r += 1

N = r + 1
for i in range(1, N):
    rec.append([i, i + 1, 0])
    rec.append([i, i + 1, 2 ** (i - 1)])

for i in range(N - 1, 0, -1):
    if L - 2 ** (i - 1) >= 2 ** r:
        rec.append([i, N, L - 2 ** (i - 1)])
        L -= 2 ** (i - 1)

rec.sort()
print(N, len(rec))
for i, j, k in rec:
  print(i, j, k)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define GC getchar
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define FOR(i,a,b) for(int i=(a),__l=(b);i<=__l;++i)
#define DEP(i,a,b) for(int i=(a),__l=(b);i>=__l;--i)
using namespace std;
typedef double db;
typedef long long LL;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int inf=1000000005;
const int _L=1<<21;char _Buf[_L],*__S,*__T;
inline char Fast_getchar(){
if(__S==__T){__T=(__S=_Buf)+fread(_Buf,1,_L,stdin);if(__S==__T)return EOF;}return *__S++;}
template <class __T> inline void read_string(__T s[]){
	char c;for(c=GC();c<33||c>126;c=GC());
	for(;33<=c&&c<=126;*s++=c,c=GC());*s=0;}
template <class __T> inline void read(__T& x){
	x=0;char c=GC();int f=1;
	for(;!isdigit(c);c=GC())c=='-'?f=-1:0;
	for(;isdigit(c);c=GC())x=(x<<1)+(x<<3)+(c^'0');f<0?x=-x:0;}

/*----------------------------------------------------------------------------*/
typedef int INT;
#define int long long
int n,a[2000005];
INT main() {
	//freopen("in.in","r",stdin);
	read(n);
	FOR(i,1,n)read(a[i]),a[i]-=i;
	sort(a+1,a+n+1);
	int b=a[(n+1)/2],ans=0;
	FOR(i,1,n) ans+=abs(a[i]-b);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    ll t,a; cin >> t >> a;
    vl h(n);
    rep(i,n) cin >> h[i];
    double mn = INF;
    ll ans;
    rep(i,n){
        double temp = t - h[i] * 0.006;
        if(mn >= fabs(a-temp)){
            ans = i+1;
            mn = abs(a-temp);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[21], b[21], c[21];

int main() {
    int n;
    cin >> n;
    for(int i=1; i<=n; i++) cin >> a[i];
    for(int i=1; i<=n; i++) cin >> b[i];
    for(int i=1; i<n; i++) cin >> c[i];
    
    int ans=0;
    for(int i=1; i<=n; i++) {
        ans += b[a[i]];
        if(i!=n && a[i+1]-a[i]==1) ans += c[a[i]];
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[3][101],dp[3][101];
signed main()
{
	//freopen(".INP", "r", stdin);
	//freopen(".OUT", "w", stdout);
	cin >> n;
	for(int i=1;i<=2;i++) {
		for(int j=1;j<=n;j++) cin >> a[i][j];
	}
	for(int i=1;i<=2;i++) {
		for(int j=1;j<=n;j++) {
			if(i==1&&j==1) {
				dp[i][j]=a[i][j];
			}
			else dp[i][j]=max(dp[i][j-1],dp[i-1][j])+a[i][j];
		}
	}
	cout << dp[2][n];
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define INF (~(1<<31))
#define N_INF (1<<31)
using namespace std;

void split(string str, char chr, vector< string > *res){
	stringstream ss(str);
	string itm;
	while(getline(ss, itm, chr)){
		(*res).PB(itm);
	}
}

class RangeMaxQuery{
private:
    vector< int > value;
    int _size;
public:
	
    void Init(int size){
        int bitcount = 0;
        int t = size;
         
        while(t != 0){
            t /= 2;
            ++bitcount;
        }
        if(size % (1 << (bitcount - 1)) != 0) bitcount++;
        _size = (1 << bitcount) - 1;
         
        value.resize(_size);
         
        for(vector< int >::iterator it = value.begin(); it != value.end(); ++it){
            (*it) = 0;
        }
    }
	
    void Update(int index, int v){
        int n = index + (_size>>1);
        value[n] += v;
         
        while(n > 0){
            n = (n - 1) / 2;
            value[n] = max(value[n * 2 + 1], value[n * 2 + 2]);
        }
    }
    
    void RunQuery(int *max, int *node){
    	*max = value[0];
    	*node = 0;
    	
    	while(*node < (_size>>1)){
    		if(value[2 * (*node) + 1] == *max){
    			*node = 2 * (*node) + 1;
    		}else{
    			*node = 2 * (*node) + 2;
    		}
    	}
    	
    	*node -= (_size >> 1);
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, q, a, v, maximum, node;
	RangeMaxQuery rmq;
	
	cin >> n >> q;
	rmq.Init(n);
	
	REP(i, q){
		cin >> a >> v;
		
		rmq.Update(a - 1, v);
		rmq.RunQuery(&maximum, &node);
		
		cout << node + 1 << " " << maximum << endl;
	}
	return 0;
}

Measured memory_bytes: 9252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
//void chmin(int &a, int b) { if (a > b) a = b; }
//void chmax(int &a, int b) { if (a < b) a = b; }


int main() {
    int n;
    cin >> n;
    if(n%2 == 0) cout << n/2 << endl;
    else cout << n/2+1 << endl;
    return 0;
}

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() {
    int N,M,sum=0;
    cin >> N >> M;
    int A[M];
    rep(i,M){
        cin >> A[i];
        sum += A[i];
    }
    if(N >= sum){
        cout << N - sum << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3632
<?php


    $arr1 = explode(' ', trim(fgets(STDIN)));
    $k = $arr1[0];
    $n = $arr1[1];
    $arr2 = explode(' ', trim(fgets(STDIN)));
    
    $kyori = $k; // 初期値セット
    for ($i=0; $i < $n; $i++) { 
        # code...
        $p = $arr2[$i];

        // ひとつ前までの距離
        if ($i == 0) {
            $mae = $arr2[0] + $k - $arr2[$n -1];
        } else {
            $mae = $arr2[$i] - $arr2[$i - 1];
        } 

        // ひとつ後への距離
        if ($i == $n - 1){
            $ato = $arr2[0] + $k - $arr2[$n -1];
        } else {
            $ato = $arr2[$i + 1] - $arr2[$i];
        }

        // 時計回りの距離
        $tmp = $k - $mae;
        if ($kyori > $tmp) {
            $kyori = $tmp;
        }

        // 反時計回りの距離
        $tmp = $k - $ato;
        if ($kyori > $tmp) {
            $kyori = $tmp;
        }
    }

    echo $kyori;

?>

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

inline long long read(){
	long long s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}

int main(){
	string s;
	cin >> s;
	int len = s.size();
	int ans = 0;
	int left = 0;
	len--;
	while (left < len){
		if (s[left] != s[len]){
			ans++;
		}
		left++;
		len--;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  l <- getl toInt
  unless (l == 0) $ do
    solve l <$> replicateM 12 (getl $ wrds toInt) >>= putStrLn
    main
  
solve :: Int -> [[Int]] -> String
solve l xs = f 1 0 xs
  where
    f _ _ [] = "NA"
    f a c ([m, n]:ys) = if l <= c + m - n then (show a) else f (a + 1) (c + m - n) ys
    
toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastInput in = new FastInput(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ABC175A solver = new ABC175A();
		solver.solve(1, in, out);
		out.close();
	}

	static class ABC175A {

		public void solve(int testNum, FastInput in, PrintWriter out) {
			
			String s = in.next();
			
			int cnt = 0;
			int ans = 0;
			for(int i = 0 ; i < 3 ;i++) {
				if(s.charAt(i) == 'R') {
					cnt++;
					ans = Math.max(ans,cnt);
				}
				else {
					cnt = 0;
				}
			}
			
			out.println(ans);

		}

	}
static class FastInput{
	private final BufferedReader in;
	private String[] buff;
	private int index = 0;
	
	public FastInput(InputStream im) {
		in = new BufferedReader(new InputStreamReader(im));
	}
	String nextLine() {
		try {
			return in.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	String next() {
		while (buff == null || index >= buff.length) {
			buff = nextLine().split(" ");
			index = 0;
		}
		return buff[index++];
	}
	int nextInt() {
		return Integer.parseInt(next());
	}
	
	long nextLong() {
		return Long.parseLong(next());
	}
	
	Double nextDouble() {
		return Double.parseDouble(next());
	}
	
	BigInteger nextBigInteger() {
		return new BigInteger(next());
	}
	
	BigDecimal nextBigDecimal() {
		return new BigDecimal(next());
	}
	
	public int[] nextIntArray(final int n) {
		final int[] res = new int [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextInt();
		}
		return res;
	}
	
	public long[] nextLongArray(final int n) {
		final long[] res= new long [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextLong();
		}
		return res;
	}
	
	public double[] nextDoubleArray(final int n ) {
		final double[] res = new double [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextDouble();
		}
		return res;
	}
	
	
	public int[][] nextInt2DArray(final int n , final int m){
		int [][]res = new int [n][m];
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j < m ;j++) {
				res[i][j] = nextInt();
			}
		}
		return res;
	}
	public long[][] nextLong2DArray(final int n , final int m){
		long [][]res = new long [n][m];
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j < m ;j++) {
				res[i][j] = nextLong();
			}
		}
		return res;
	}
	
	public char[][] nextChar2DArray(final int n){
		char [][]res = new char [n][];
		
		for(int i = 0 ; i < n ;i++) {
			String s = next();
			res[i] = s.toCharArray();
		}
		
		return res;
	}
}
}


Measured memory_bytes: 32924
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
    int n;
vector<int> arr(1000001);

void Eratosthenes(int N){
    //素数だったら1,素数じゃなかったら0
	for(int i = 0; i <= N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i *i <=N; i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}
}
int main(){

    cin>>n;
    Eratosthenes(n);
    int64_t ans=0;
    for(int c=1;c<=n;c++){
        int num = n - c;
        if(num==0){}
        else if(num==1)ans++;
        else if(arr[num]){
            ans += 2;
        }
        else{
            for(int i=1;i*i<=num;i++){
                if(num%i==0){
                    if(i*i==num){
                        ans++;
                    }
                    else{
                        ans+=2;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7048
n = int(input()) + 1
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

# 1を一つだけ選ぶやつは重複する可能性
d = [False] * (n + 1)

left = right = 0
for i in range(n):
    if d[a[i]]:
        right = i
        left = a.index(a[i])
        break
    d[a[i]] = True


fac = [1] * (n + 1)
for i in range(1, n + 1):
    fac[i] = fac[i - 1] * i % mod


def inv(x):
    return pow(x, mod - 2, mod)


def c(n, k):
    if n < 0 or k < 0 or n < k:
        return 0
    return fac[n] * inv(fac[n - k] * fac[k] % mod) % mod


left_len = left
right_len = n - right - 1
print(n - 1)
for i in range(2, n + 1):
    ans = c(n, i) - c(left_len + right_len, i - 1)
    print(ans % mod)


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

using namespace std;

int main(){
    int N,x,sum=0;
    cin >> N >> x;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }

    sort(a.begin(),a.end());

    for(int i=0;i<N;i++){
        sum += a[i];
        
        if(x<sum){
            cout << i << endl;
            break;
        }else if(x==sum){
            cout << i+1 << endl;
            break;
        }
        if(i==N-1){
            cout << i << endl;
        }
    }
}

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

int main() {
    int n;
    cin >> n;
    int v[n], c[n];
    for (int i = 0; i < n; i++) cin >> v[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        int x = 0, y = 0;
        for (int i = 0; i < n; i++) {
            if (bit >> i & 1) {
                x += v[i];
                y += c[i];
            }
        }
        ans = max(ans, x - y);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256