akhauriyash/Code-Regression huggingface dataset:
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	
	String INPUT = "";
	
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		out.flush();
	}
	
	void solve(Scanner sc, PrintWriter out) {
		int H, W;
		
		for (;;) {
			H = sc.nextInt();
			W = sc.nextInt();
			if (H == 0 && W == 0) break;
			
			int cnt = 0;
			for (int i = 0; i < H; i++) {
				if (i%2 == 0) cnt=0;
				else cnt=1;
				for (int j = 0; j < W; j++) {
					if (cnt%2 == 0) System.out.print("#");
					else System.out.print(".");
					cnt++;
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}



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

int main(){
	int N,ans(0),n(0);
  	cin >> N;
  	for(int i = 1 ; i <= N ; i ++){
      	if(i % 2 == 0) continue;
    	for(int I = 1 ; I <= i / 2 ; I++){
          	if(I % 2 == 0) continue;
         	if(i % I == 0) n++;
        }
      	n ++;
      	if(n == 8) ans ++;
      	n = 0;
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
using namespace std;
#define N 100009
#define ll long long

int main(){
    int n;
    cin>>n;
    string a;
    cin>>a;
    int count=0;
    for (int i=0; i<n; i++){
        string b;
        b=a.substr(i,3);
        if (b=="ABC") count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  vector<int> cnt(N, 0);
  int b = 0;
  REP(i,1,N){
    if(S[i-1] == 'A' && S[i] == 'C'){
      b++;
    }
    cnt[i] = b;
  }

  rep(i,Q){
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    int ret = cnt[r];
    if(l>=0) ret -= cnt[l];
    cout << ret << endl;
  }
  
  return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  vp p(n);
  cin>>p;
  map<P,int> mp;
  rep(i,n) mp[p[i]] = i;
  sort(rng(p));
  vp s(1,P(INF,0));
  rep(i,n) {
    int x = p[i].se;
    int c = 1;
    int l = x;
    while (s.back().fi < x) {
      mins(l,s.back().fi);
      c += s.back().se;
      s.pop_back();
    }
    s.eb(l,c);
  }
  vi ans(n);
  int ni = 0, r = 0;
  rep(i,n) {
    if (!r) {
      ++ni;
      r = s[ni].se;
    }
    ans[mp[p[i]]] = s[ni].se;
    --r;
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 22384
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  int x,y;
  cin >> x >> y;
  
  for(int i = 0; i <= 100; i++) {
    for(int j = 0; j <=100; j++) {
      if(i+j == x & i*2+j*4 == y) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3556
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define umap unordered_map
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n,a,b,c;
  cin>>n>>a>>b>>c;
  
  vector<int> p(n);
  rep(i,n){
  cin>>p[i];  
  }
  
  ll ans=9000000000000000000;
  
  rep(i,(1<<n)){
    rep(j,(1<<n)){
      int ay=0;
      int by=0;
      int cy=0;
      ll mp=-30;
      rep(k,n){
        if((i & (1<<k)) && (j & (1<<k))) {
          ay+=p[k];
          mp+=10;
        }
        if((i & (1<<k)) && !(j & (1<<k))) {
          by+=p[k];
          mp+=10;
        }
        if(!(i & (1<<k)) && (j & (1<<k))) {
          cy+=p[k];
          mp+=10;
        }
      }
      if(ay==0||by==0||cy==0) continue;
      mp+=abs(a-ay)+abs(b-by)+abs(c-cy);
      ans=min(ans,mp);
    }
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 3608
#if loc||local
#define _GLIBCXX_DEBUG
#endif

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n;
  string s;
  cin>>n>>s;

  vector<ll> r(n+1),w(n+1);
  rep(i,n){
    r[i+1] += r[i];
    w[i+1] += w[i];
    if(s[i]=='R')r[i+1]++;
    else w[i+1]++;
  }

  vector<ll> rb(n+1),wb(n+1);
  reverse(begin(s),end(s));
  rep(i,n){
    rb[i+1] += rb[i];
    wb[i+1] += wb[i];
    if(s[i]=='R')rb[i+1]++;
    else wb[i+1]++;
  }
  reverse(begin(rb),end(rb));
  reverse(begin(wb),end(wb));

  dump(r);dump(rb);dump(w);dump(wb);

  ll ans = INF;
  rep(i,n+1){
    ll tmp = w[i]+rb[i]-min(w[i],rb[i]);
    dump(w[i],rb[i],tmp);
    chmin(ans,tmp);
  }
  cout<<(ans)<<endl;


}

Measured memory_bytes: 9732
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var H = int.Parse(Console.ReadLine());
        var W = int.Parse(Console.ReadLine());
        var N = int.Parse(Console.ReadLine());

        var x = Math.Max(H, W);
        var need = (N + x - 1) / x;

        Console.WriteLine(need);
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

long long func(long long n){
	if(n == 1){
		return 1;
	}else{
		return n*func(n-1);
	}
}

int main(){

	long long n;
	scanf("%lld",&n);
	printf("%lld\n",func(n));

    return 0;
}

Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
		int p = sc.nextInt();
		if(a >=0 && p >= 0 && a <=100 && p <= 100) {
			System.out.println(((a*3)+p)/2);
			}
		
		}
	}

Measured memory_bytes: 21716
import sys
 
s2nn = lambda s: [int(c) for c in s.split(' ')]
 
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
 
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
 
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
 
def main(N, M, PYm):
    # 県番号pと市誕生年yから認識番号を得られる辞書
    # dic[p][y] -> 認識番号
    dic = {}
    # 県ごとに、市誕生年を昇順ソートし、認識番号を1,2,...と対応づける
    # dic2[p] -> [(1, sorted_y1), (2, sorted_y2), ...]
    # dic2tmp[p] -> [y1, y2, ...]
    #dic2 = {}
    dic2tmp = {}
    for p in range(N+1):
        dic[p] = {}
        #dic2[p] = []
        dic2tmp[p] = []
    for p, y in PYm:
        dic2tmp[p].append(y)
    for p in range(N+1):
        dic2tmp[p].sort()
        nby = [(i+1, y) for i, y in enumerate(dic2tmp[p])]
        #dic2[p] = nby
        for nb, y in nby:
            dic[p][y] = nb
    # 表示
    for p, y in PYm:
        nb = dic[p][y]
        print('%06d%06d' % (p, nb))

N, M = i2nn()
PYs = ss2nnn(ii2ss(M))
main(N, M, PYs)


Measured memory_bytes: 97520
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 998244353
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 3010
ll cnt[M][M];
int main(){
    
    ll n,s;cin>>n>>s;
    ll a[n+1];
    rep(i,1,n+1)cin>>a[i];
    cnt[0][0]=1;
    rep(i,1,n+1){
    	rep(j,0,M)cnt[i][j]=(2*cnt[i-1][j])%md;
    	rep(j,0,M){
    		if(j+a[i]>=M)continue;
    		(cnt[i][j+a[i]]+=cnt[i-1][j])%=md;
    	}
    	// rep(j,0,10)cout<<cnt[i-1][j]<<" ";cout<<"\n";
    }
    // rep(j,0,10)cout<<cnt[n][j]<<" ";cout<<"\n";
    cout<<cnt[n][s];
    
    
    return 0;
}

Measured memory_bytes: 74204
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
using P = pair<int, int>;

class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

int main() {
    int n, m; cin >> n >> m;
    V<P> J(n);
    loop (n, i) {
        int a, b; cin >> a >> b;
        J[i] = { b, a };
    }
    sort(J.begin(), J.end(), greater<P>());

    BIT wk((m + 10) * 2);
    ll ans = 0;
    loop (n, i) {
        int a = J[i].second, b = J[i].first;
        int p = m - a;
        if (p < 0) continue;

        int l = 0, r = p + 1;
        while (l + 1 < r) {
            int m = (l + r) / 2;
            if (m <= 0) {
                if (wk.sum(1) == 1) l = -1;
                else l = 0;
                break;
            }
            if (wk.sum(p + 1) - wk.sum(m) == p - m + 1) {
                r = m;
            } else {
                l = m;
            }
        }
        if (l < 0) continue;
        if (wk.sum(l + 1) - wk.sum(l)) continue;
        wk.add(l + 1, 1);
        ans += b;
    }

    // loop (m + 1, i) {
    //     cout << i << ": " << wk.sum(i + 1) - wk.sum(i) << endl;
    // }

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



Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<vector>
double func(int,int);
int main(){
    int n;
    std::cin>>n;
    std::vector<int> pntx(n,0);
    std::vector<int> pnty(n,0);

    for(int i = 0;i < n;i++){
        std::cin>>pntx[i]>>pnty[i];
    }
    int root_kakuhindo = 2;
    int root_zenntouri = 1;
    long double ans = 0;
    for(int i = 1;i <= n;i++){
        root_zenntouri *= i;
    }
    for(int i = 1;i < n;i++){
        root_kakuhindo *= i;
    }
    double ans__;
    for(int i = 0;i < (n - 1);i++){
        for(int j = (i + 1);j < n;j++){
            ans__ = func((pntx[i] - pntx[j]),(pnty[i] - pnty[j]));
            ans__ /= root_zenntouri;
            ans__ *= root_kakuhindo;
            ans += ans__;
        }
    }
    std::cout<<std::fixed<<ans;
    return 0;
}
double func(int a,int b){
    double ret_num;
    double hoge = (a * a) + (b * b);
    ret_num = sqrt(hoge);
    return ret_num;
}

Measured memory_bytes: 256
Sa = list(input())
Sb = list(input())
Sc = list(input())
total_len = len(Sa)+len(Sb)+len(Sc)

x = Sa[0]
Sa.pop(0)
for _ in range(total_len):
    if x == 'a':
        if len(Sa) == 0:
            print('A')
            break
        else:
            pass
        x = Sa[0]
        Sa.pop(0)
    elif x == 'b':
        if len(Sb) == 0:
            print('B')
            break
        else:
            pass
        x = Sb[0]
        Sb.pop(0)
    else:
        if len(Sc) == 0:
            print('C')
            break
        else:
            pass
        x = Sc[0]
        Sc.pop(0)

Measured memory_bytes: 3064
object Main {
  def main(args:Array[String]) {
    val read1 = readLine()
    val N = read1.split(' ')(0).toInt
    val K = read1.split(' ')(1).toInt
    val H = readLine().split(' ').map(_.toLong)

    var sort = H.sorted.reverse
    val ans = sort.drop(K).sum
    
    println(ans)

  }
}


Measured memory_bytes: 74948
#include<bits/stdc++.h>
#define R register
#define ll long long
using namespace std;
const int N = 10010;
const int M = 1e6+100;
const int inf = 2e9;
template <class Ruby> inline void read(Ruby &x)
{
	x=0;
	char ch=getchar(), w=0;
	while(!isdigit(ch))w=(ch=='-'), ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
	x=w?-x:x;
}
int hd[N], cur[N], dep[N], nxt[M], to[M], val[M], bs=1, b[110][110], c[110][110], s, t;
int n, m, pos[N];
inline void addedg(int qa, int qb, int qc)
{
//	printf("addedg %d %d %d\n", qa, qb, qc);
	nxt[++bs]=hd[qa], to[bs]=qb, val[bs]=qc, hd[qa]=bs;
}
queue <int> q;
inline int bfs()
{
	while(q.size())q.pop();
	memset(dep, 0, sizeof(dep));
	memcpy(cur, hd, sizeof(hd));
	dep[s]=1; q.push(s);
	while(q.size())
	{
		int u=q.front(); q.pop();
		for(R int i=hd[u]; i; i=nxt[i])
		{
			int v=to[i];
			if(!dep[v] && val[i])
			{
				dep[v]=dep[u]+1;
				if(v==t)return 1;
				q.push(v);
			}
		}
	}
	return 0;
}
inline int dinic(int u, int sum)
{
	if(u==t || !sum)return sum;
	int res=0;
	for(R int i=cur[u]; i; i=nxt[i])
	{
		int v=to[i]; cur[u]=i;
		if(dep[v]==dep[u]+1 && val[i])
		{
			int tmp=dinic(v, min(sum-res, val[i]));
			val[i]-=tmp, val[i^1]+=tmp;
			res+=tmp;
		}
		if(res==sum)return res;
	}
	if(!res)dep[u]=-1;
	return res;
}
queue <int> buc[110][110];
inline void init()
{
	bs=1; 
	for(R int i=1; i<=n*2+2; i++)hd[i]=0;
	for(R int i=1; i<=n; i++)
		for(R int j=1; j<=n; j++)
			if(buc[i][j].size())
				addedg(i, n+j, 1), addedg(n+j, i, 0);
	for(R int i=1; i<=n; i++)addedg(s, i, 1), addedg(i, s, 0), addedg(i+n, t, 1), addedg(t, i+n, 0);
}
inline void solve(int x)
{
	int maxflow=0;
	while(bfs())maxflow+=dinic(s, inf);
	for(R int i=1; i<=n; i++)
	{
		for(R int j=hd[i]; j; j=nxt[j])
		{
			if(!val[j])
			{
				b[i][x]=buc[i][to[j]-n].front();
				buc[i][to[j]-n].pop();
			}
		}
	}	
/*	for(R int i=1; i<=n; i++)
	{
		for(R int j=1; j<=m; j++)printf("%d ", b[i][j]);
		printf("\n");
	}*/
}
int main()
{
	read(n), read(m); s=n*2+1, t=s+1;
	for(R int i=1; i<=n; i++)
	{
		for(R int j=1, qa; j<=m; j++)
		{
			read(qa);
			buc[i][(qa-1)/m+1].push(qa);
		}
	}
	for(R int i=1; i<=m; i++)
	{
		init();
		solve(i);
	}
	for(R int i=1; i<=n; i++)
	{
		for(R int j=1; j<=m; j++)printf("%d ", b[i][j]);
		printf("\n");
	}


	for(R int i=1; i<=n; i++)
		for(R int j=1; j<=m; j++)
			pos[b[i][j]]=j;
	for(R int i=1; i<=n; i++)
		for(R int j=1; j<=m; j++)
			c[i][pos[(i-1)*m+j]]=(i-1)*m+j;
/*		*/			
//	for(R int i=1; i<=n; i++)
//		sort(c[i]+1, c[i]+1+m);
	for(R int i=1; i<=n; i++)
	{
		for(R int j=1; j<=m; j++)printf("%d ", c[i][j]);
		printf("\n");
	}							
	return 0;											
}


Measured memory_bytes: 12800
/* aoj1350完成形  */
#include<stdio.h>
#include <stdlib.h>  // qsort
#define N 500  //島の数の最大
#define M 50000 //橋の数の最大

int mst[M]={0};  //最初に作った最小木の橋を記憶する
int flag=0;      //最小木が1度作られたかどうか
int rm = -1;     //取り除いた橋の番号(初期値-1)

//橋を定義
typedef struct bridge{  
    //始点の島,終点の島,コスト
    int s; int d; int c;
}bridge_t;

//比較関数(qsort用)
int cmp(const void *a,const void *b){
  return ((bridge_t*)a)->c - ((bridge_t*)b)->c;
}

//与えられた要素の木の根を再帰で求める関数
int u_root(int x,int number[]){
    //根
    if(number[x-1] == x)
        return x;

    //経路圧縮
    else
        return number[x-1] = u_root(number[x-1],number);
}

//xとyが同じ集合に属するか否かを根を見て判断する(同じなら1を返す)
int u_find(int x, int y, int number[]){
    return u_root(x,number) == u_root(y,number);
}

//xとyの属する集合を併合
void u_union(int x, int y, int number[]){     //x,yは島の番号(1~)を表す
    number[y-1] = x;
}


//全ての要素が同じ集合に含まれているかどうかをfindで判定する関数
int allsame(int n, int number[])
{
    int y;
    for(y=2;y<=n;y++)
            if(!u_find(1,y,number)) //一つでも同じ集合に含まれない要素があるなら0を返す
                return 0;
    return 1; //全ての要素が同じ集合に含まれていれば1を返す。
}


//クラスカル法で最小全域木を生成する関数
//異常終了(最小木が生成できなかった)の時は0を返す
int kruskal(bridge_t b[], int n, int m, int number[]){
    int i=0; //配列の添字
    int mc=0;  //最小木のコスト
    //独立した点がなくなるまで繰り返す
    while(!allsame(n,number)){
        //独立していてかつ取り除かれた橋でないならその要素の根を合成する
        if(!u_find(b[i].s,b[i].d,number) && i!=rm){
            u_union(u_root(b[i].s,number),u_root(b[i].d,number),number);
            //まだ一度も最小木が作られていないならどの橋を使ったかを記憶する
            if(!flag)
                mst[i] = 1;
            //コストを足していく
            mc += b[i].c;
        }
        i++;
        //最後まで探索して、一つでも同じ集合にない要素があれば、最小木は作れないということになる
        if(i==m)
          if(!allsame(n,number))
             return 0;
    }
    return mc;
}

int main(void){
    int n,m;        //島の数,橋の数
    bridge_t b[M];  //橋の情報
    int mc;         //最初に作った最小木のコスト
    int mc2;        //2回目以降に作る最小木のコスト
    bridge_t temp;  //橋の情報の一時記憶領域
    int number[N];  //親の番号
    int alt[M] = {0};     //不変の橋の番号(初期値は全てオルタナティブ))
    int acost=0,abridge=0;    //不変の橋のコストの和と、不変の橋の本数の和
    int i,j;

    scanf("%d%d",&n,&m);
    //n要素で初期化(初めは全ての頂点が根)
    for(i=0;i<n;i++)
        number[i] = i+1;
    //橋の始点、終点、コストを入力
    for(i=0;i<m;i++){
        scanf("%d%d%d",&b[i].s,&b[i].d,&b[i].c);
    }
    //qsortによるソート(コストの昇順)
    qsort(b,m,sizeof(bridge_t),cmp);

    //クラスカル法を行う関数を呼び出し
    //全ての要素で最小木を作る
    mc = kruskal(b,n,m,number);
    flag=1;     //１度最小木を作成したかどうか

    //numberを初期化
    for(i=0;i<n;i++){
        number[i] = i+1;
    }
    //作った最小木の中で辺を一つだけ取り除き最小木が作れるかどうかで場合分け
    for(j=0;j<m;j++){
        //最初に作った最小木の橋ならばその橋を取り除く
        if(mst[j]){
            rm = j;   //取り除いた橋の番号を記憶
            mc2 = kruskal(b,n,m,number);    //橋を一つ取り除いて最小木を作る
            //ある橋を一つ取り除いて同じコストの最小木を作れないなら、それは不変の橋である
            if(mc < mc2 || mc2 == 0)
                alt[j]=1;
            //numberを初期化しておく
            for(i=0;i<n;i++)
                number[i] = i+1;
        }
        //不変の橋が見つかれば
        if(alt[j]){
            abridge++;
            acost += b[j].c;
        }
    }
    printf("%d %d\n",abridge,acost);
    
    return 0;
}


Measured memory_bytes: 3048
import java.io.IOException;
 
public class Main {
	/**
	* @param args
	*/

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int		n = parseNum();
		int[][]	c = new int[n][2];
		int[][]	d = new int[n][n];

		// カードを取得
		for (int i = 0; i < n; i++) {
			c[i][0] = parseNum();
			c[i][1] = parseNum();
		}

		for (int l = 1; l < n; l++) {
			for (int i = 0; i+l < n; i++) {
				for (int j = i+l, k = i; k < j; k++) {
					int	t = d[i][k]+d[k+1][j]+c[i][0]*c[k][1]*c[k+1][0]*c[j][1];
					d[i][j] = (d[i][j] == 0)?t:Math.min(d[i][j], t);
				}
			}
		}

		System.out.println(d[0][n-1]);
	}
 
	private static int parseNum() {
		try {
			int	buf = 0;
			int	num = 0;
			int	mns = 0;
			int	skp = 1;
 
			// -,0〜9以外は読み飛ばす
			while (true) {
				buf = System.in.read();
				if (buf == '-') {
					mns = 1;
					skp = 0;
				} else if (buf >= '0' && buf <= '9') {
					num = num * 10 + (buf - '0');
					skp = 0;
				} else if (skp == 0) {
					return (mns == 0)?num:num*(-1);
				}
			}
		} catch (IOException e) {}
		return -1;
	}
}

Measured memory_bytes: 17180
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let ns: Vec<usize> = iter.map(|n| n.parse::<usize>().unwrap()).collect();
    
    let mut min: usize = *ns.iter().min().unwrap();
    
    loop {
        let pre_min = min;
        for n in ns.iter() {
            let sub = n % min;
            if sub != 0 && sub < min {
                min = sub;
            }
        }
        if min == pre_min { break; }
    }
    
    println!("{}", min);
}

Measured memory_bytes: 6396
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String str = sc.nextLine();
            List<String> list = new ArrayList<>();
            for (Character c : str.toCharArray()) {
                list.add(c.toString());
            }
            Collections.sort(list);
            StringJoiner sj = new StringJoiner("");
            for (String s : list) {
                sj.add(s);
            }
            String key = sj.toString();

            if (map.containsKey(key)) {
                map.put(key, map.get(key)  + 1);
            } else {
                map.put(key, 1);
            }

        }
        sc.close();

        long count = 0;
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            int value = entry.getValue();
            if (value >= 2) {
                count += combi(value);
            }
        }
        System.out.print(count);
    }

    private static long combi(long n) {
        if (n <= 1) return 0;
        return n * (n - 1) / 2;
    }
}

Measured memory_bytes: 173940
def gcd(m,n):
    r = m%n if n<m else n%m
    return min(m,n) if r==0 else gcd(n,r)
n = input()
x = map(int,raw_input().split())
g = gcd(x[0],x[1]) if n==2 else gcd(gcd(x[0],x[1]),x[2])
for i in xrange(1,g+1):
    if g%i==0: print i

Measured memory_bytes: 4220
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
    int p,c,a,b;
    cin>>a>>b>>p;
    c=a+b;
    if ((a>500 && b>500) || ( a==0 || b==0)) {
        cout << "No";
        exit(1);
    }
    else {
        if (p <= c) {
            cout << "Yes";
        } else {
            cout << "No";
        }
    }
    return 0;
}


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

int main() {
	while (1) {
		int n, x; cin >> n >> x;
		if (!n && !x) break;
		int cnt = 0;

		for (int i = n; i >= 3; --i) {
			for (int j = i - 1; j >= 1; --j) {
				for (int k = j - 1; k >= 1; --k) {
					if (i + j + k == x) cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
}


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

using namespace std;

typedef long long ll;

const int Nmax = 5005, Mmax = 205, lg = 12;

ll D[Nmax], best[Nmax];
int rmq[Mmax][Nmax][lg+2], opt[Nmax], val[Nmax], a[Nmax][Mmax], loog[Nmax];
int n, m;

void Rmq()
{
    int i, j, t;
    for(i=1; i<=m; ++i)
        for(j=1; j<=n; ++j)
            rmq[i][j][0] = a[j][i];

    for(i=2; i<=n; ++i) loog[i] = loog[i>>1] + 1;

    for(t=0; t<lg; ++t)
    {
        for(i=1; i<=m; ++i)
            for(j=1; j + (1<<(t+1)) - 1 <= n; ++j)
                rmq[i][j][t+1] = max( rmq[i][j][t], rmq[i][j+(1<<t)][t] );
    }
}

void refresh(int x, int y)
{
    int p = loog[y-x+1], i;
    for(i=1; i<=m; ++i)
        val[i] = max( rmq[i][x][p], rmq[i][y - (1<<p) + 1][p] );
}

void divide(int st, int dr, int L, int R)
{
    int mid = (st+dr) / 2, i, j;

    if(L > mid)
        for(i=1; i<=m; ++i) refresh(mid, L-1);
    else for(i=1; i<=m; ++i) val[i] = 0;

    ll act = 0;
    for(i=1; i<=m; ++i) act += val[i];

    best[mid] = -1e18;

    for(i = max(L, mid); i <= R; ++i)
    {
        for(j=1; j<=m; ++j)
            if(a[i][j] > val[j])
            {
                act += a[i][j] - val[j];
                val[j] = a[i][j];
            }

        if(act - D[i] > best[mid])
            best[mid] = act - D[i], opt[mid] = i;
    }

    best[mid] += D[mid];
    if(st < mid) divide(st, mid-1, L, opt[mid]);
    if(mid < dr) divide(mid+1, dr, opt[mid], R);
}

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    int i, j;

    cin >> n >> m;
    for(i=2; i<=n; ++i) cin >> D[i], D[i] += D[i-1];

    for(i=1; i<=n; ++i)
        for(j=1; j<=m; ++j)
            cin >> a[i][j];

    Rmq();
    divide(1, n, 1, n);

    ll ans = 0;
    for(i=1; i<=n; ++i)
        ans = max(ans, best[i]);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 59776
#include<bits/stdc++.h>
int main()
{
  int N,M,A[10000],i,sum;
  scanf("%d %d",&N,&M);
  sum=0;
  for(i=0;i<M;i++)
  {
    scanf("%d",&A[i]);
    sum=sum+A[i];
  }
  if(N-sum>=0)
    printf("%d",N-sum);
  else
    printf("-1");
}
  

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

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

  int n = s.size();
  ll sum  = 0;
  rep(tmp, 1<<(n-1)){
    bitset<10> bs(tmp);
    int cnt = 0;
    rep(i, n){
      sum += (ll)(s[n-1-i]-'0') * (ll)pow(10, cnt);
      if(bs.test(i)) cnt = 0;
      else cnt++;
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
#define PI 3.14159265359


int main() {
    int n;
    cin >> n;
    if(n%1000 == 0){
        cout << 0 << endl;
        return 0;
    }
    int a = 1000 -n%1000;
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt(); int ct = 0;
        long d = sc.nextLong();
        for (int i = 0; i  < n; i++) {
            long x = sc.nextLong();
            long y = sc.nextLong();
            if (x * x + y * y <= d * d) ct++;
        }
        out.println(ct);
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 55180
#include <iostream>
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,m,n) for(int (i)=(m);(i)<(n); i++)
#define REP(i, n) for(int (i)=0;(i)<(n);(i)++)
//------
#define R2(i,in,j,jn) REP(i,in)REP(j,jn)

using namespace std;


int main(void){
	int X;
	cin>>X;
	int r=X%100;
	int n=X/100;
	cout <<(n*5<r?0:1);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi acos(-1)
typedef long long int ll;
using namespace std;

int main()
{
    Fast;
    ll n,m,i,j,k;
    ll ans=0LL;
    string s;
    cin>>n>>s;
    ll v1=0,v2=0,v3=0;
    for(ll i=0; i<n; i++)
    {
        if(s[i]=='R')
        {
            v1++;
        }
        if(s[i]=='G')
        {
            v2++;
        }
        if(s[i]=='B')
        {
            v3++;
        }
    }
    ans=v1*v2*v3;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            k=(j+(j-i));
            if(k<n)
            {
                if(s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i])
                {
                    ans--;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3668
#include<iostream>
using namespace std;
int main()
{
  int a[40]={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 n;cin>>n;
  cout<<a[n-1];
}

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

for i,b in enumerate(B):
    if i + 1 < b:
        print(-1)
        exit()

N = len(B)
ans = []
for _ in range(N):
    for i,b in enumerate(B):
        if i+1 == b:
            t = i+1

    B.pop(t-1)
    ans.append(t)
for i in ans[::-1]:
    print(i)


Measured memory_bytes: 3064
import math

n = int(input())


def koch(d, p1, p2):
    """

    :param int d:
    :param list p1:
    :param list p2:
    :return:
    """
    if d == 0:
        return

    s, t, u = [0, 0], [0, 0], [0, 0]
    s[0] = (2*p1[0]+p2[0]) / 3
    s[1] = (2*p1[1]+p2[1]) / 3
    t[0] = (p1[0] + 2 * p2[0]) / 3
    t[1] = (p1[1]+2*p2[1]) / 3
    u[0] = (t[0]-s[0]) * math.cos(math.pi/3) - (t[1]-s[1]) * math.sin(math.pi/3) + s[0]
    u[1] = (t[0]-s[0]) * math.sin(math.pi/3) + (t[1]-s[1]) * math.cos(math.pi/3) + s[1]

    koch(d-1, p1, s)
    print(s[0], s[1])
    koch(d-1, s, u)
    print(u[0], u[1])
    koch(d-1, u, t)
    print(t[0], t[1])
    koch(d-1, t, p2)


def main():
    print(0.00000000, 0.00000000)
    koch(n, [0, 0], [100, 0])
    print(100.00000000, 0.00000000)


if __name__ == '__main__':
    main()



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

class Dice {
private:
    int* face;
    void SetNumber(int n0, int n1, int n2, int n3, int n4, int n5) {
        face[0] = n0;
        face[1] = n1;
        face[2] = n2;
        face[3] = n3;
        face[4] = n4;
        face[5] = n5;
    };

public:
    Dice() {
        face = new int[6];
    };
    ~Dice() {
        delete[] face;
    };
    void SetLabel(int number[]) {
        for (int i = 0; i < 6; ++i) {
            face[i] = number[i];
        }
    };
    void Roll(char order) {
        switch (order) {
            case 'E':
                SetNumber(face[3], face[1], face[0], face[5], face[4], face[2]);
                break;
            case 'N':
                SetNumber(face[1], face[5], face[2], face[3], face[0], face[4]);
                break;
            case 'S':
                SetNumber(face[4], face[0], face[2], face[3], face[5], face[1]);
                break;
            case 'W':
                SetNumber(face[2], face[1], face[5], face[0], face[4], face[3]);
                break;
        }
    };
    bool isSame(int face2[]) {
        char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
        for (int i = 0; i < 24; ++i) {
            Roll(order[i]);
            for (int j = 0; j < 6; ++j) {
                if (face[j] != face2[j]) {
                    break;
                }
                if (j == 5) {
                    return true;
                }
            }
        }
        return false;
    };
};

int main() {
    int n;
    cin >> n;
    int number[110][6];
    int res;
    Dice dice[110];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 6; ++j) {
            cin >> res;
            number[i][j] = res;
        }
        dice[i].SetLabel(number[i]);
    }
    bool allDifferrent = true;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            allDifferrent *= !dice[i].isSame(number[j]);
        }
    }
    cout << ((allDifferrent) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a + b >= c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  int x,y,a[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
  cin>>x>>y;
  if(a[x]==a[y]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
lim = 10**18
flag = True

ans = a[0]

if a.count(0) >= 1:
    ans = 0
else:
    for i in range(1,n):
        ans *= a[i]
        if ans > lim:
            flag = False
            break
            
if flag:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 21652
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b,c;
    cin >> a >> b >>c;
    
    if(b-a != c-b)cout << "NO" << endl;
    else cout << "YES" <<endl;
    
    return 0;
}



Measured memory_bytes: 256
from collections import Counter
import string


def solve(N, Ss):
    Ss = sorted(Ss)
    if all([s % 10 == 0 for s in Ss]):
        return 0
    allsum = sum(Ss)
    if allsum % 10 != 0:
        return allsum
    for c in Ss:
        if (allsum - c) % 10 != 0:
            return allsum - c
    return 0

if __name__ == "__main__":
    N = int(input())
    Ss = [int(input()) for _ in range(N)]
    print(solve(N, Ss))


Measured memory_bytes: 3820
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class E
{
	static void Main()
	{
		var k = int.Parse(ReadLine());
		var a = ReadLine().Split(' ').Select(int.Parse).ToArray();
		var q = new V(a[0], a[1]);

		if (k % 2 == 0 && q.Norm % 2 == 1)
		{
			WriteLine(-1);
			return;
		}
		var ps = new List<V> { new V() };
		var l = q.Norm % k == 0 ? 2 : q.Norm % 2 == 1 && q.Norm < k ? 4 : 3;
		if (l == 4) ps.Add(q.NextShot4(k));
		if (l >= 3) ps.Add(ps.Last() + (q - ps.Last()).NextShot3(k));
		while ((q - ps.Last()).Norm != 0) ps.Add(ps.Last() + (q - ps.Last()).NextShot2(k));
		WriteLine(ps.Count - 1);
		foreach (var p in ps.Skip(1)) WriteLine("{0} {1}", p.X, p.Y);
	}
}

struct V
{
	public int X;
	public int Y;
	public int Norm => Abs(X) + Abs(Y);

	public V(int x, int y) { X = x; Y = y; }
	public static V operator +(V v, V w) => new V(v.X + w.X, v.Y + w.Y);
	public static V operator -(V v, V w) => new V(v.X - w.X, v.Y - w.Y);

	public V NextShot4(int k) => Abs(X) >= Abs(Y) ? new V(-Sign(X) * (k - Norm), (Y > 0 ? -1 : 1) * Norm) : new V((X > 0 ? -1 : 1) * Norm, -Sign(Y) * (k - Norm));
	public V NextShot3(int k)
	{
		var w2 = k - Norm % k;
		if (w2 % 2 == 1) w2 += k;
		var w = Norm < k ? k - Norm / 2 : w2 / 2;
		return Abs(X) >= Abs(Y) ? new V(Sign(X) * (k - w), (Y > 0 ? -1 : 1) * w) : new V((X > 0 ? -1 : 1) * w, Sign(Y) * (k - w));
	}
	public V NextShot2(int k)
	{
		var d = Min(Abs(X), k);
		return new V(Sign(X) * d, Sign(Y) * (k - d));
	}
}


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

int main(void)
{
  string S, T;
  cin >> S >> T;
  string t = T.substr(0, T.size() - 1);

  if (S == t)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
package main

import (
	"fmt"
)

func main() {
	var s, t, u string
	var a, b int

	fmt.Scan(&s, &t)
	fmt.Scan(&a, &b)
	fmt.Scan(&u)
	if u == s {
		a--
	} else {
		b--
	}
	fmt.Println(a, b)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t


int main(void){
    string s;
    cin >> s;
    int count = 0;
    
    for(int  i = 0 ; i < s.size() ; i++ ){
        if( count == 0 &&s[i] == 'C' ){
            count++;
        }
        if( count == 1 && s[i] == 'F' ){
            count++;
        }
    }
    
    if( count == 2 )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

int A, B, C, D, L, R;

int main() {
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;

  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L < R) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
// 配列に未定義動作があったのでひっかかってました
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  int a[110];
  for (int i = 0; i < 110; i++) {
    a[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    a[t]++; 
  }
  int ans = 0;
  for (int i = 1; i <= 100; i++) {
    if (a[i] > 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*
  ->->->->->-> Vora Mahammadasim <-<-<-<-<-<-
*/
#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
using namespace std;

void solve(){
  string s;
  cin>>s;
  if(s[2] == s[3] && s[4] == s[5]) cout<<"Yes\n";
  else cout<<"No\n";
}

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


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

#define lint long long
#define P pair<int, int>

//エラトステネスの篩
const int MAX_H = 100000;
int prime[MAX_H];
bool bool_prime[MAX_H + 1];
int sieve(int n){
    int p = 0;
    for(int i = 0; i <= n; ++i){
        bool_prime[i] = true;
    }
    
    bool_prime[0] = bool_prime[1] = false;
    
    for(int i = 2; i <= n; ++i){
        if(bool_prime[i]){
            prime[p++] = i;
            for(int j = 2 * i; j <= n; j += i){
                bool_prime[j] = false;
            }
        }
    }
    return p;
}


int main() {
    int Q;
    
    cin >> Q;
    
    int l[Q], r[Q];
    
    for(int i = 0; i < Q; ++i){
        cin >> l[i] >> r[i];
    }
    
    sieve(100000);
    
    vector<int> like;
    for(int i = 0; i <= 100000; ++i){
        if(bool_prime[i] && bool_prime[(i + 1) / 2]){
            like.push_back(i);
        }
    }
    
    for(int i = 0; i < Q; ++i){
        cout << upper_bound(like.begin(), like.end(), r[i]) - lower_bound(like.begin(), like.end(), l[i]) << endl;
    }
    
    
}


Measured memory_bytes: 1536
n = int(input())
t, a = map(int, input().split())
hs = list(map(int, input().split()))
mini = 10 ** 10
res = -1
for i in range(n):
    sample = abs(a - t + hs[i] * 0.006)
    if mini > sample:
        mini = sample
        res = i

print(res+1)

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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for(int i = 0; i < (int)n; i++)


void solve() {
    int a, b;
    cin >> a >> b;
    int v[a+1] = {0};
    for (int i = 0; i < b; i++) {
        int x, y;
        cin >> x >> y;
        v[x]++;
        v[y]++;
    }
    for (int i = 1; i <= a; i++) {
        cout << v[i] << "\n";
    }
}

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

    int t = 1, i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,k;cin>>a>>b>>c>>k;
  if(k<=a)
    cout<<k<<endl;
  else if(k<=a+b)
    cout<<a<<endl;
  else
    cout<<a-(k-a-b)<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100 + 10;
const double eps = 1e-7;
const double pi = acos(-1.0);
int n;
struct Point
{
	ll x, y;
	int id;
	Point() = default;
	Point(const ll & _x, const ll & _y) : x(_x), y(_y) {}
}p[maxn];
Point operator - (const Point & a, const Point & b) { return Point(a.x - b.x, a.y - b.y);}
ll cross(const Point & a, const Point & b) { return a.x * b.y - a.y * b.x;}
ll dot(const Point & a, const Point & b) { return a.x * b.x + a.y * b.y;}
double len(const Point & a) { return sqrt(dot(a, a));}
double clip(double x) { return max(min(x, 1.0), -1.0);}
double angle(const Point & a, const Point & b) { return acos(clip(1.0 * dot(a, b) / (len(a) * len(b))));}
double ans[maxn];
bool cmp(const Point & a, const Point & b)
{
	auto ret = cross(a - p[1], b - p[1]);
	return ret > 0 || (ret == 0 && a.x < b.x);
}
void convex()
{
	int pos = 1;
	for(int i = 2; i <= n; ++i)
		 if(p[i].x < p[pos].x || (p[i].x == p[pos].x && p[i].y < p[pos].y))
		 	pos = i;
	swap(p[pos], p[1]);
	sort(p + 2, p + n + 1, cmp);
	vector<Point> ret = {p[1]};
	for(int i = 2; i <= n; ++i)
	{
		while(ret.size() >= 2 && cross(p[i] - ret[ret.size() - 2], ret.back() - ret[ret.size() - 2]) >= 0)
			ret.pop_back();
		ret.push_back(p[i]);
	}
	for(int i = 0; i < ret.size(); ++i)
		ans[ret[i].id] = 0.5 - angle(ret[(i + 1) % ret.size()] - ret[i], ret[(i - 1 + ret.size()) % ret.size()] - ret[i]) / (2 * pi);
}
int main()
{
	cin >> n;
	for(int i = 1; i <= n; ++i) 
	{
		cin >> p[i].x >> p[i].y;
		p[i].id = i;
	}
	convex();
	for(int i = 1; i <= n; ++i)
		printf("%.10lf\n", ans[i]);
	return 0;
}
	

Measured memory_bytes: 256
function Main(input) {
	var lines = input.split("\n");
	var words = lines[0].split(" ");
	var k = Number(words[0]);
	var x = Number(words[1])
	console.log(k * 500 >= x ? 'Yes' : 'No')
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int N; string s; cin>>N>>s;
  rep(i,s.length()) {
    cout << (char) ((s[i]+N-'A')%26+'A');
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
if(a>b){
    printf("a > b\n");
}
if(a<b){
    printf("a < b\n");
}
if(a==b){
    printf("a == b\n");
}
    return 0;
}



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


using namespace std;
#define max 10005
int main(){
    int n;
    cin >> n;
    int temp = n/15;
    if(temp) cout << (n*800)-(temp*200) << endl;
    else
      cout << (n*800) << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
int main() {
	int k, s, cnt = 0;
	scanf("%d%d", &k, &s);
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - x - y;
			if (0 <= z && z <= k) {
				cnt++;
			}
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    S = list(input().rsplit()[0])

    ans = 0
    for i in range(len(S)):
        s = "".join(S[i:i+3])
        if s == 'ABC':
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    string a,b;
    cin >> a >> b;
    if(a.size() > b.size()) {
      cout << "GREATER" << endl;
    }else if(a.size() < b.size()) {
      cout << "LESS" << endl;
    }else if(a > b) {
        cout << "GREATER" << endl;
    }else if(a < b) {
        cout << "LESS" << endl;
    }else {
        cout << "EQUAL" << endl;
    }
}


Measured memory_bytes: 256