akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
ll gcd(ll a, ll b) {

	if (a < b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//最大公約数

int main(){

	ll N,S;
	vector<ll> X;
	cin>>N>>S;
	for(ll i=0;i<N;i++){
		ll x;
		cin>>x;
		X.pb(x);
	}
	if(N==1){
		cout<<MAX(S,X[0])-MIN(S,X[0])<<endl;
		return 0;
	}

	ll G=MAX(S,X[0])-min(S,X[0]);
	for(ll i=1;i<N;i++){
		G=gcd(MAX(S,X[i])-MIN(S,X[i]),G);
	}
	cout<<G<<endl;

	return 0;
}

Measured memory_bytes: 1400
import java.io.*;
import java.util.HashSet;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        HashSet<String> dictionary = new HashSet<String>();

        int n = Integer.parseInt(br.readLine());
        String[] input;
        StringBuilder sb = new StringBuilder("");
        for (int i = 0; i < n; i++) {
            input = br.readLine().split(" ");
            if (input[0].equals("insert")) {
                dictionary.add(input[1]);
            } else {
                sb.append(dictionary.contains(input[1]) ? "yes" : "no").append("\n");
            }
        }

        System.out.print(sb.toString());
    }
}

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

//	LLONG_MAX 9.2*1e18	9223372036854775807LL = (2^63)-1
//	INT_MAX 2.1*1e9 2147483647 = (2^31)-1
//	O(1e8) 1.2sec

void Main()
{
	int N;
	cin>>N;
	vecll(L,N);
	vin(L);
	sort(all(L));
	ll ans=0;
	rep(k,N){
		rep(j,k){
			if(L[k]==L[j])break;
			rep(i,j){
				if(L[j]==L[i])break;
				if(L[k]<L[i]+L[j])ans++;
			}
		}
	}

	cout<<ans<<_n;
}


void Test();
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <stdbool.h>

int main(void)
{
    int n, x;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        x = i;
        if (x % 3 == 0)
        {
            printf(" %d", i);
        }
        else
        {
            bool a = true;
            while (a)
            {
                if(x % 10 == 3)
                {
                    printf(" %d", i);
                    break;
                }
                x /= 10;
                if(x == 0)
                {
                    break;
                }
            }
        }
    }
    printf("\n");
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define F first
#define S second
#define um map <ll,ll>
#define rep(i,z,n)  for(int i=z;i<n;i++)
#define repi(i,z,n) for(int i=z;i<=n;i++)
#define repn(i,z,n) for(int i=n-1;i>=z;i--)
#define vec vector<ll>
#define vecp vector<pair<ll,ll>>
#define pi (double)3.14159265358979323846
#define ld long double
#define all(z) z.begin(),z.end()

ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; if (a == 0) return 0; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }
ll modInverse(ll a, ll m) {return power(a, m - 2, m);}
ll binpow(ll a, ll b) {ll res = 1; while (b > 0) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll binlog2(ll n) {ll logValue = -1; while (n) {logValue++; n >>= 1;} return logValue;}
void print(vec a) {rep(i, 0, a.size())cout << a[i] << " "; cout << endl;}
const ll mod = 1e9 + 7;
const ll N = 1e5 + 5;
const ll inf = 2e18;
vec v[N];
ll dp[N];

ll dfs(ll i) {
    if (dp[i] != -1)
        return dp[i];
    ll temp = 0;
    for (auto x : v[i]) {
        temp = max(temp, 1 + dfs(x));
    }

    return dp[i] = temp;
}

void solve() {
    ll n, m;
    cin >> n >> m;

    rep(i, 0, m) {
        ll x, y;
        cin >> x >> y;
        v[x].pb(y);
    }

    memset(dp, -1, sizeof(dp));
    ll ans = 0;
    repi(i, 1, n) {
        ans = max(ans, dfs(i));
    }

    cout << ans << endl;
}





int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    speed;
    int test = 1;
    // cin >> test;
    while (test--) {
        // cout << "Case #" << t1 << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 11820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll a[100];
//ll mony=1000;

ll maxProfit(ll* prices, ll pricesSize)
{
    if(pricesSize==0) return 0;
    ll mony=1000;
    for(int i=1;i<pricesSize;i++)
       if(prices[i]>prices[i-1])
          mony += (mony/prices[i-1])*(prices[i]-prices[i-1]);
    return mony;
}
int main()
{
	ll i=0;
	ll t,k=0,x;
	ll sum=0;
	cin>>n;
	//vector<ll>a(n); 
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	
	}
	ll ans=maxProfit(a,n);
	cout<<ans;	
}

Measured memory_bytes: 3664
N=int(input())
A=list(map(int,input().split()))
r=[0]*N
for i in A:
    r[i-1]+=1
s=0
for i in r:
    if i>1:
        s+=i*(i-1)//2
for i in range(N):
    r[A[i]-1]-=1
    s-=r[A[i]-1]
    print(s)
    s+=r[A[i]-1]
    r[A[i]-1]+=1

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  int cnt=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2==0){
      b[cnt]=a[i];
      cnt++;
    }
  }
  bool can=true;
  for(int i=0;i<cnt;i++){
    if(b[i]%3 == 0 || b[i]%5 == 0){
    }else{
      can=false;
      break;
    }
  }
  if(!can) cout << "DENIED" << endl;
  else cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
/*using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define mr  make_pair

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
    	int a,b,c;
    	cin>>a>>b>>c;
    	cout<<c<<" "<<a<<" "<<b;
    }
    return 0;
}


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

int main(){
	double a,b,c,d,e,f,y,x;
	
	while(cin>>a>>b>>c>>d>>e>>f){
	
	
	x = (double)((e*c-b*f)/(a*e-b*d));
	
	y = (double)((-(d*c)+a*f)/(a*e-b*d));
	
	if(x == 0)
		x = 0;
	if(y == 0)
		y =0;
	
	printf("%.3f %.3f\n",x,y);
	}
}

Measured memory_bytes: 1236
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
typedef long long ll;
using namespace std;
int n;
long long hp[100005],a,b,c,m=100000000000ll;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>a>>b;
	c=ll(a)-ll(b);
	for (int i=1;i<=n;i++){
		cin>>hp[i];
	}
	long long hi=1000000000,lo=1;
	while (lo<=hi){
		long long mid=(lo+hi)/2;
		long long v=mid*b;
		long long cnt=0;
		for (int i=1;i<=n;i++){
			if ((ll(ll(hp[i])-ll(ll(mid)*ll(b))))<=0) continue;
			cnt+=ll((ll(ll(hp[i])-ll(ll(mid)*ll(b))))/ll(c));
			if (ll((ll(ll(hp[i])-ll(ll(mid)*ll(b))))%ll(c))!=ll(0)) cnt++;
		}
		if (cnt>mid){
			lo=mid+1;
		}else{
			if (mid<m) m=mid;
			hi=mid-1;
		}
	}
	cout<<m;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;

if((a==b && a!=c) || (a==c && a!=b) ||(c==b && a!=c))
{
    cout<<"Yes"<<endl;
}
else
{
    cout<<"No"<<endl;
}
}


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

namespace D_ABC157
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int n = s[0];
            int m = s[1];
            int k = s[2];
            var ab = new List<int[]>();
            var cd = new List<int[]>();

            var uf = new UnionFind(n);

            int[] cntlst = new int[n];

            for (int i = 0; i < m; i++)
            {
                int[] tmp = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
                // ab.Add(tmp);
                uf.Unite(tmp[0] - 1, tmp[1] - 1);
                cntlst[tmp[0] - 1]++;
                cntlst[tmp[1] - 1]++;


            }
            for (int i = 0; i < k; i++)
            {
                int[] tmp = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
                // cd.Add(tmp);
                if (uf.Find(tmp[0] - 1) == uf.Find(tmp[1] - 1))
                {
                    cntlst[tmp[0] - 1]++;
                    cntlst[tmp[1] - 1]++;

                }
            }

            for (int i = 0; i < n; i++)
            {
                Write(uf.GetSize(i) - cntlst[i] - 1);
                if (i != n - 1)
                {
                    Write(" ");
                }
                else
                {
                    WriteLine();
                }





            }







        }
    }


    class UnionFind
    {
        public int Size { get; private set; }
        List<int> parent;
        List<int> sizes;
        public UnionFind(int count)
        {
            Size = 0;
            parent = new List<int>(count);
            sizes = new List<int>(count);
            ExtendSize(count);
        }
        public bool Unite(int x, int y)
        {
            int xp = Find(x);
            int yp = Find(y);
            if (yp == xp) return false;
            if (sizes[xp] < sizes[yp])
            {
                var tmp = xp;
                xp = yp;
                yp = tmp;
            }
            parent[yp] = xp;
            sizes[xp] += sizes[yp];
            return true;
        }
        public IEnumerable<int> AllParents => parent.Where(x => x == parent[x]);
        public int GetSize(int x) => sizes[Find(x)];
        public int Find(int x) => parent[x] == parent[parent[x]] ? parent[x] : parent[x] = Find(parent[x]);
        public void ExtendSize(int treeSize)
        {
            if (treeSize <= Size) return;
            parent.Capacity = treeSize;
            sizes.Capacity = treeSize;
            while (Size < treeSize)
            {
                parent.Add(Size);
                sizes.Add(1);
                Size++;
            }
        }
    }
}


Measured memory_bytes: 18028
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll i;
    string T;

    cin >> T;

    for(i=0; i<T.size(); i++){
        if(T[i]=='?') cout << "D";
        else cout << T[i];
    }
    cout << endl;

    return 0;
}

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

using namespace std;

int n;
vector<int> a, b, c;

int main(){
    cin>>n;
    a.resize(n), b.resize(n), c.resize(n);
    for(int i = 0; i < n; i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    vector<int> dp(3);
    dp[0] = a[0], dp[1] = b[0], dp[2] = c[0];
    for(int i = 1; i < n; i++){
        vector<int> ndp(3);
        ndp[0] = a[i] + max(dp[1], dp[2]);
        ndp[1] = b[i] + max(dp[0], dp[2]);
        ndp[2] = c[i] + max(dp[0], dp[1]);
        dp = ndp;
    }
    int res = *max_element(dp.begin(), dp.end());
    cout<<res<<endl;
    return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {  
    Int n, c, k;
    cin >> n >> c >> k;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    Int res = 0;
    Int start = a[0];
    Int cnt = 1;
    for (Int i = 1; i < n; i++) {
        if (cnt == c or a[i] - start > k) {
            res++;
            start = a[i];
            cnt = 1;
        } else {
            cnt++;
        }
    }
    print(res + 1);
}

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


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

int main() {
  long long n, d;
  cin >> n >> d;
  int ans = 0;
  for ( int i = 0; i < n; i++ ) {
    long long x, y;
    cin >> x >> y;
    if ( d*d >= x*x + y*y ) { ans++; }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    N,K = LMIIS()
    ans = 0
    for i in range(K,N+2):
        u = (N + N-i+1)*i//2
        l = (i-1)*i//2
        ans += u - l + 1
        ans %= MOD
    print(ans)

    

if __name__ == '__main__':
    main()

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

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

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

  string ans = "";
  rep(i, input.size()) {
    if (input.at(i) == '1') {
      ans.push_back('1');
    } else if (input.at(i) == '0') {
      ans.push_back('0');
    } else if (input.at(i) == 'B') {
      if (ans.size() > 0) {
        ans.pop_back();
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int A = Integer.parseInt(sc.nextLine());
		long ans;

		long r_List,g_List,b_List;
		r_List=g_List=b_List=0;

		String string = sc.nextLine();

		for (int i = 0; i < A; i++) {
			char c = string.charAt(i);
			if (c == 'R') {
				r_List++;
			} else if(c == 'G'){
				g_List++;
			} else if(c == 'B'){
				b_List++;
			}
		}

		ans = r_List * g_List * b_List;

		for (int i = 0; i < A; i++) {
			for (int j = i+1; j < A; j++) {
				if (string.charAt(i) == string.charAt(j)) {
					continue;
				}
				int k = j * 2 - i;
				if (k >= A || string.charAt(i) == string.charAt(k) || string.charAt(j) == string.charAt(k)) {
					continue;
				}
				ans--;
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 36904
#include<iostream>
#include<queue>

using namespace std;

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

struct edge{int to, len, den;};
vector<edge> ed[111];
int ee[111][111];

int main() {
  int n, m, l;
  for (;;) {
    cin >> n >> m >> l;
    if (n == 0  && m == 0 && l == 0) break;
    rep (i, 111) ed[i].clear();
    rep (i, m) {
      int a, b, c, d;
      cin >> a >> b >> c >> d;
      --a;--b;
      edge e;
      e.to = b;
      e.len = c;
      e.den = d;
      ed[a].push_back(e);
      e.to = a;
      ed[b].push_back(e);
    }
    rep (i, 111) rep(j, 111) ee[i][j] = 1000000000;
    priority_queue<pair<int, pair<int,int> >, vector<pair<int, pair<int,int> > >, greater<pair<int, pair<int,int> > > > que;
    que.push(make_pair(0,make_pair(0,l)));
    while(!que.empty()){
      pair<int, pair<int,int> > now = que.top();
      que.pop();
      int den = now.first;
      int x = now.second.first;
      int money = now.second.second;
      if (ee[x][money] <= den) continue;
      //cout << den << " " << x <<" "<< money << endl;
      rep (i, money + 1) ee[x][i] = min(den, ee[x][i]);
      rep (i, ed[x].size()) {
	que.push(make_pair(den + ed[x][i].den, make_pair(ed[x][i].to, money)));
	if (money >= ed[x][i].len) 
	  que.push(make_pair(den, make_pair(ed[x][i].to, money - ed[x][i].len)));
      }
    }
    cout << ee[n-1][0] << endl;
  }

}

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define MAX_V 100000

#define MOD 1000000007L
#define INF 100000000000

signed main() {
	int n, m;
	cin >> n >> m;
	string a[n], b[m];
	for (size_t i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (size_t i = 0; i < m; i++) {
		cin >> b[i];
	}
	bool finded = false;
	for (size_t i = 0; i < n - m + 1 && !finded; i++) {
		for (size_t j = 0; j < n - m + 1; j++) {
			bool ok = true;
			for (size_t y = 0; y < m && ok; y++) {
				// cout << b[y] << ":" << a[y + i].substr(j, m) << endl << endl;
				if (b[y] != a[y + i].substr(j, m)) {
					ok = false;
				}
			}
			if (ok) {
				finded = true;
				break;
			}
		}
	}
	cout << (finded ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
  
string s,t="";
cin>>s;

int k=s.size();

rep(i,k) if(i%2==0){t+=s[i];}

cout<<t<<endl;

}

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

int base;
int tod(int b,int ka,int t,int w,int ki){
	ka+=b*20;t+=ka*20;w+=18*t;ki+=20*w;
	return base+ki;
}
bool is_uruu(int y){
	return y%4==0&&(y%100!=0||y%400==0);
}
int mn[]{31,28,31,30,31,30,31,31,30,31,30,31};
int calc(int y,int m,int d){
	int res=0;
	for(int i=1;i<y;i++){
		res+=365;if(is_uruu(i))res++;
	}
	for(int i=1;i<m;i++){
		res+=mn[i-1];if(is_uruu(y)&&i==2)res++;
	}
	return res+d;
}
int tod(int y,int m,int d){
	return calc(y,m,d)-base;
}
void tom(int day){
	int b,ka,t,w,ki;
	ki=day%20;day/=20;
	w=day%18;day/=18;
	t=day%20;day/=20;
	ka=day%20;day/=20;
	b=day%13;
	printf("%lld.%lld.%lld.%lld.%lld\n",b,ka,t,w,ki);
}
void tos(int day){
	int y,m;
	for(y=1;365+is_uruu(y)<day;y++)day-=365+is_uruu(y);
	for(m=1;mn[m-1]+(m==2&&is_uruu(y))<day;m++)day-=mn[m-1]+(m==2&&is_uruu(y));
	printf("%lld.%lld.%lld\n",y,m,day);
}
signed main() {
	base=calc(2012,12,21);
	string s;
	while(cin>>s,s!="#"){
		if(count(s.begin(),s.end(),'.')==2){
			int a=s.find('.');
			int y=stoi(s.substr(0,a));
			int b=s.find('.',a+1);
			int m=stoi(s.substr(a+1,b-a));
			int d=stoi(s.substr(b+1));
			tom(tod(y,m,d));
		}
		else{
			int a=s.find('.');
			int ba=stoi(s.substr(0,a));
			int b=s.find('.',a+1);
			int ka=stoi(s.substr(a+1,b-a));
			int c=s.find('.',b+1);
			int t=stoi(s.substr(b+1,c-b));
			int d=s.find('.',c+1);
			int w=stoi(s.substr(c+1,d-c));
			int ki=stoi(s.substr(d+1));
			tos(tod(ba,ka,t,w,ki));
		}
	}
}

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

typedef long long ll;

using namespace std;


int main(){
    int l,a,b,c,d;
    
    scanf("%d%d%d%d%d",&l,&a,&b,&c,&d);
    
    printf("%d\n",l-(int)max(ceil((double)a/c),ceil((double)b/d)));
    
    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <complex>
#include <iomanip>

using namespace std;

typedef complex<double> point;
const double EPS = 1e-9;
const double INF = 1e10;


struct Circle{
    point p;
    double r;
    Circle(double x,double y,double r) : p(x,y),r(r) {}
};

vector<point> circles_point(Circle a,Circle b){
    double d = abs(a.p - b.p);
    double s = (a.r+b.r+d) / 2;
    double S = sqrt(s*(s-a.r)*(s-b.r)*(s-d));
    double h = 2*S / d;
    point v = (b.p-a.p) / abs(b.p-a.p);

    double m = sqrt(a.r*a.r - h*h);

    vector<point> ret;
    ret.push_back(a.p + m*v + (h*v*point(0,1)));
    ret.push_back(a.p + m*v - (h*v*point(0,1)));

    return ret;
}

double cross(point a,point b){
    return imag(conj(a)*b);
}

bool is_intersected_linesegment(point a1,point a2,point b1,point b2){
    if(max(a1.real(),a2.real()) + EPS < min(b1.real(),b2.real())) return false;
    if(max(b1.real(),b2.real()) + EPS < min(a1.real(),a2.real())) return false;
    if(max(a1.imag(),a2.imag()) + EPS < min(b1.imag(),b2.imag())) return false;
    if(max(b1.imag(),b2.imag()) + EPS < min(a1.imag(),a2.imag())) return false;

    return (cross(a2-a1,b1-a1) * cross(a2-a1,b2-a1) < EPS) and
           (cross(b2-b1,a1-b1) * cross(b2-b1,a2-b1) < EPS);
}

double solve(vector<Circle> cs){
    vector<point> ps;
    ps.push_back(cs.front().p);
    for(int i=0;i<cs.size()-1;i++){
        vector<point> pp = circles_point(cs[i],cs[i+1]);
        for(int j=0;j<2;j++){
            ps.push_back(pp[j]);
        }
    }
    ps.push_back(cs.back().p);

    vector<vector<double> > dist(2*cs.size(),vector<double>(2*cs.size(),INF));
    for(int i=0;i<cs.size()*2;i++){
        int cur = (i+1) / 2;
        for(int j=i;j<cs.size()*2;j++){
            int nex = (j+1) / 2;
            bool ok = true;
            for(int k=cur+1;k<nex;k++){
                point a1 = ps[2*k-1];
                point a2 = ps[2*k];
                if(not is_intersected_linesegment(a1,a2,ps[i],ps[j])){
                    ok = false;
                    break;
                }
            }
            if(ok){
                dist[i][j] = dist[j][i] = abs(ps[i]-ps[j]);
            }
        }
    }
    for(int k=0;k<2*cs.size();k++){
        for(int i=0;i<2*cs.size();i++){
            for(int j=0;j<2*cs.size();j++){
                dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    return dist[0][2*cs.size()-1];
}

int main(){
    cout << fixed << setprecision(10);
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        vector<Circle> cs;
        for(int i=0;i<n;i++){
            double x,y,r;
            cin >> x >> y >> r;
            cs.push_back(Circle(x,y,r));
        }
        cout << solve(cs) << endl;
    }
    return 0;
}

Measured memory_bytes: 1532
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define maxn 210

int n, m,t;
int a, b, c;
int main() {
	cin >> a >> b >> c;
	int t = max(0, a - b);
	printf("%d", max(0, c - t));
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;

int n, m;
int link_a, link_b;

class node {
public:
	bool flag;
	vector<int> ptr;
	node() {
		flag = false;
	}
};


bool f(vector<node>& graph, int i) {
	bool flag = false;
	graph[i].flag = true;
	for (int j = 0; j < graph[i].ptr.size(); j++) {
		if ((i == link_a && graph[i].ptr[j] == link_b) || (i == link_b && graph[i].ptr[j] == link_a)) {

		}
		else {
			if (!graph[graph[i].ptr[j]].flag) {
				f(graph, graph[i].ptr[j]);
			}
		}
	}
	//端のとき
	if (i == 0) {
		bool tmp = true;
		for (int i = 0; i < n; i++) {
			if (!graph[i].flag) {
				tmp = false;
			}
			graph[i].flag = false;
		}
		flag = tmp;
	}
	return flag;
}


int main() {
	cin >> n >> m;
	vector<node> graph(n);
	vector<pair<int, int>> link(m);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		graph[a - 1].ptr.emplace_back(b - 1);
		graph[b - 1].ptr.emplace_back(a - 1);
		link[i].first = a-1;
		link[i].second = b-1;
	}

	int ans = 0;

	for (int i = 0; i < m; i++) {
		link_a = link[i].first;
		link_b = link[i].second;
		if (!f(graph, 0)) {
			ans++;
		}
		else {
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
a,b = list(map(int,input().strip().split()))

if a == 1 and b ==1:
  print("Draw")
elif a == 1:
  print("Alice")
elif b == 1:
  print("Bob")
elif a > b:
  print("Alice")
elif b > a:
  print("Bob")
else:
  print("Draw")

Measured memory_bytes: 38384
/*
  AOJ 2460
  Title:Dial Key
  @kankichi573
*/
#include <stdio.h>

int gcd(int a, int b)
{
  int c;
  while (b > 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}

main()
{
  int i,N,M,L;

  scanf("%d %d",&N,&M);
  for(i=0;i<M;i++)
    {	
      scanf("%d",&L);
      N=gcd(N,L);
    }
  printf("%s\n",N==1?"Yes":"No");
    
  return(0);
}

Measured memory_bytes: 580
/*
    author: Salam_35
    Created at :

*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));


const ll MOD = 1e9+7;

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;
vec primes;

ll dp[2*Max];

ll a(ll n)
{
    if(n==1)return 1;
    if(dp[n]!=0)return dp[n];
    return dp[n]=a(n/2)+a(n/2);

}

int main()
{
    ll no=1;
    ll n;
    cin >> n;
    ll cnt=0;
    while(n>1)
    {
        cnt+=(2*no);
        n/=2;
        no*=2;
    }
    cout<<cnt+1<<endl;

}





Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
//#define MOD 998244353
#define MOD 1000000007
#define PI 3.14159265358979
using ll = long long;
using namespace std;

int main(){
    int h,w;
    string s[2005];
    cin>>h>>w;
    rep(i,h){
        cin>>s[i];
    }
    int l[2005][2005]={},r[2005][2005]={},u[2005][2005]={},d[2005][2005]={};
    int ans=0;

    rep(i,h){//y
        rep(j,w){//x
            if(j==0){
                if(s[i][j]!='#') l[i][j]=1;
            }
            else{
                if(s[i][j]!='#') l[i][j]=l[i][j-1]+1;
            }
        }
    }
    for(int i=w-1;i>=0;i--){
        rep(j,h){
            if(i==w-1){
                if(s[j][i]!='#') r[j][i]=1;
            }
            else{
                if(s[j][i]!='#') r[j][i]=r[j][i+1]+1;
            }
        }
    }
    rep(i,w){
        rep(j,h){
            if(j==0){
                if(s[j][i]!='#') u[j][i]=1;
            }
            else{
                if(s[j][i]!='#') u[j][i]=u[j-1][i]+1;
            }
        }
    }
    rep(i,w){
        for(int j=h-1;j>=0;j--){
            if(j==h-1){
                if(s[j][i]!='#') d[j][i]=1;
            }
            else{
                if(s[j][i]!='#') d[j][i]=d[j+1][i]+1;
            }
        }
    }

    rep(i,w){
        rep(j,h){
            int count=l[j][i]+r[j][i]+u[j][i]+d[j][i]-3;
            ans=max(ans,count);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 67200
function prime(max){
   var arr=[];
   for(var i=0;i<=max;i++)arr[i]=i;
   arr[0]=false;
   arr[1]=false;
   var sqrt=Math.floor(Math.sqrt(max));
   for(var i=2;i<=sqrt;i++){
      if(arr[i]==false)continue;
      for(var j=i+i;j<=max;j+=i){
         arr[j]=false;
      }
   }
   var result=[];
   for(var i=0;i<=max;i++){
      if(arr[i]!==false)result.push(arr[i]);
   }
   return result;
}
var p=prime(999999);
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
for(var i=0;i<Arr.length;i++){
   var a=Arr[i];
   if(a==0)break;
   var twin="";
   for(var j=1;j<p.length;j++){
   if(p[j]>a)break;
   if(p[j]-p[j-1]==2)twin=p[j-1]+" "+p[j];
   }
   console.log(twin);
}

Measured memory_bytes: 30752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll n,m;
  cin>>n>>m;
  
  vector<ll> A;
  
  for(int i=1;i<=n;i++)
  {
      ll a;
      cin>>a;
      A.push_back(a);
  }
  
  sort(A.begin(),A.end());
  
  vector<pair<ll,ll>> CB;
  
  for(int i=1;i<=m;i++)
  {
      ll b,c;
      cin>>b>>c;
      CB.push_back({c,b});
  }
  
  sort(CB.rbegin(),CB.rend());
  
  int cur=0;
  
  for(int i=0;i<n;i++)
  {
      if(cur>=m) break;
      if(A[i] > CB[cur].first) break;
      
      A[i] = CB[cur].first;
      
      if(CB[cur].second==1) cur++;
      else CB[cur] = {CB[cur].first,CB[cur].second-1};
  }
  
  ll ans=0;
  
  for(int i=0; i<n; i++)
  {
      ans += A[i];
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const ll INF = LLONG_MAX/3;

/*-----Library-----*/

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

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

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

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
//コンビネーション
/*
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 % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 */
/*-----Library-----*/
const int MOD=1234567;
signed main(){
	int m,n;
	cin>>m>>n;
	int a[110000];
	rep(i,n)cin>>a[i];
	if(m!=2){
		int ans=0;
		int cnt=1;
		rep(i,1,n){
			if(a[i]==a[i-1])cnt++;
			else {
				ans+=cnt/2;
				cnt=1;
			}
		}
		ans+=cnt/2;
		cout<<ans<<endl;
	}else{
		int ans1=0,ans2=0;
		rep(i,n){
			if(i%2==0){
				if(a[i]!=2)ans1++;
			}else{
				if(a[i]!=1)ans1++;
			}
		}
		rep(i,n){
			if(i%2==0){
				if(a[i]!=1)ans2++;
			}else{
				if(a[i]!=2)ans2++;
			}
		}
		cout<<min(ans1,ans2)<<endl;
	}
}




Measured memory_bytes: 3904
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int K;
string S;

signed main(){
	cin >> K >> S;
	if(S.size() <= K) cout << S << endl;
	else cout << S.substr(0, K) << "..." << endl;
}

Measured memory_bytes: 3632
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
using namespace std;
int main(){ 
  int k;
  cin >>k;
  vector<int> vec;
  vec = {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};
    cout <<vec[k-1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	int n;
	cin >> n;

	cout << n * 800 - 200 * (n / 15) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#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 all(v) v.begin(), v.end()
typedef long long ll;

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;

int main(){
  vector<int> a(5);
  rep(i, 3) cin >> a[i];
  a[3] = a[0];
  a[4] = a[1];

  int res = 1001001001;
  REP(i, 1, 3){
    chmin(res, abs(a[i]-a[i+1]) + abs(a[i]-a[i-1]));
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
int a,b,k;
cin >> a >> b;
if((a+b)%2==0)
{
  k=(a+b)/2;
  cout << k <<endl;
}
if((a+b)%2==1)
{
  cout << "IMPOSSIBLE" <<endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    cout << "vowel" << endl;
  else
    cout <<"consonant" << endl;
}

Measured memory_bytes: 256
n = int(input())
e = []
if n % 2 == 0:
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            if i + j == n + 1:
                continue
            e.append([i, j])
else:
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            if i + j == n:
                continue
            e.append([i, j])
print(len(e))
for i in e:
    print(i[0],i[1])

Measured memory_bytes: 4124
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const ll inf = 1ll<<50;

const int maxN=60;
char a[maxN][maxN];
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int b[maxN][maxN];


int main()
{
	int h,w;
	scanf("%d %d",&h,&w);
	for(int i=1;i<=h;i++)
	{
		scanf("%s",a[i]+1);
	}
	int flag = 0;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			int sum = 0;
			if(a[i][j] == '#')
			{
				for(int k=0;k<4;k++)
				{
					int ti = i + dx[k];
					int tj = j + dy[k];
					if(ti>=1 && tj>=1)
					{
						if(a[ti][tj] == '#')
							sum++;	
					}	
				}
				
				if(sum == 0)
				{
					printf("No\n");
					return 0;	
				}	
			}
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B,C;
  cin >> A >> B >> C;
  int count = 0;
  if(A==B)
  {
    count ++;
  }
  if(B==C)
  {
    count ++;
  }
  if(C==A)
  {
    count ++;
  }
  if(count==1)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


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

struct Point
{
  int x;
  int y;
};

class Room
{
  public:
    Room(int n);
    ~Room();

  public:
    int LoopNum();
    bool isLoop(Point& p, bool** this_loop_passed);

  private:
    bool** MakeAlreadyPass();
    void KillAlreadyPass(bool** ptrptr);

  private:
    int m_size;
    Point** m_room;
    bool** m_already_pass; 
};

Room::Room(int n)
{
  m_size = n;
  m_room = new Point*[m_size];
  for (int i = 0; i < m_size; ++i)
  {
    m_room[i] = new Point[m_size];
  }

  for (int i = 0; i < m_size; ++i)
  {
    for (int j = 0; j < m_size; ++j)
    {
      cin >> m_room[i][j].x >> m_room[i][j].y;
    }
  }
  m_already_pass = MakeAlreadyPass();
}

Room::~Room()
{
  for (int i = 0; i < m_size; ++i)
  {
    delete[] m_room[i];
  }
  delete[] m_room;

  KillAlreadyPass(m_already_pass);
}

int Room::LoopNum()
{
  int result = 0;
  for (int i = 0; i < m_size; ++i)
  {
    for (int j = 0; j < m_size; ++j)
    {
      bool** this_loop_passed = MakeAlreadyPass();
      Point p = { i, j };
      if (isLoop(p, this_loop_passed) )
      {
        ++result;
      }
      KillAlreadyPass(this_loop_passed);
    }
  }
  return result;
}

bool Room::isLoop(Point& p, bool** this_loop_passed)
{
  if (this_loop_passed[p.x][p.y])
  {
    return true;
  }
  if (m_already_pass[p.x][p.y])
  {
    return false;
  }
  m_already_pass[p.x][p.y] = this_loop_passed[p.x][p.y] = true;
  return isLoop(m_room[p.y][p.x], this_loop_passed);
}

bool** Room::MakeAlreadyPass()
{
  bool** buf = new bool*[m_size];
  for (int i = 0; i < m_size; ++i)
  {
    buf[i] = new bool[m_size];
  }
  //fill_n(buf[0], m_size * m_size, false);
  for (int i = 0; i < m_size; ++i)
  {
    for (int j = 0; j < m_size; ++j)
    {
      buf[i][j] = false;
    }
  }
  return buf;
}

void Room::KillAlreadyPass(bool** ptrptr)
{
  for (int i = 0; i < m_size; ++i)
  {
    delete[] ptrptr[i];
  }
  delete[] ptrptr;
}

int main(void)
{
  int n;
  while (true)
  {
    cin >> n;
    if (n == 0) break;

    Room room(n);
    cout << room.LoopNum() << endl;
  }
  return 0;
}

Measured memory_bytes: 1308
package main

import "fmt"

func main() {
	var s string
	textPreview(s)
}

func textPreview(s string) {
	/*入力を受け取る*/
	fmt.Scan(&s)

	/*入力をstring→文字の配列*/
	sRune := []rune(s)
	size := len(s)

	/*空の文字列*/
	s2 := make([]string, size+1)
	j := 0

	for i := 0; i < size; i++ {
		switch text := string(sRune[i]); text {
		case "1":
			s2[j] = text
			j++

		case "0":
			s2[j] = text
			j++

		case "B":
			if j > 0 {
				j--
			}

		default:

		}
	}

	for i := 0; i < j; i++ {
		fmt.Printf(s2[i])
	}

	fmt.Printf("\n")

}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>
using namespace std;

int main(void) {
    int i,j;
    int n;
    cin>>n;
    vector<int> a(n);
//    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end());
    int min =0;
    i =0;
    while(i<n){
        j = 0;
        while(a[i]==a[i+j]) j++;
//        cout << c << endl;
        if(j>=a[i]){
            min+=j-a[i];           
        }else {
            min+=j;  
        }
        i+=j;
    }
   
    cout << min << endl;
    
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> V(N);
  for(int i=0;i<N;i++)cin >> V[i];
  int ans=0;
  for(int i=0;i<=min(N,K);i++){
    for(int j=0;j<=i;j++){
      int k=i-j;
      vector<int> v;
      for(int a=0;a<j;a++){v.push_back(V[a]);}
      for(int b=0;b<k;b++){v.push_back(V[N-1-b]);}
      sort(v.begin(),v.end());
      int sum=0;
      for(int l=0;l<v.size();l++){
        if(v[l]<0 && l<K-i)v[l]=0;
        sum+=v[l];
      }
      ans=max(ans,sum);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
class TemplateTree:
  def __init__(self, iterable):
    self.iter_size = self.get_size(iterable)
    self.size = self.iter_size * 2 - 1
    self.value = [None] * self.size
    for i, v in enumerate(iterable):
      self.value[self.iter_size + i - 1] = v
    self.set_value(0)
    self.range = [None] * self.size
    self.set_range(0, 0, self.iter_size - 1)
  
  def get_size(self, iterable):
    ret = 1
    x = len(iterable)
    while ret < x:
      ret *= 2
    return ret
  
  def set_range(self, x, left, right):
    self.range[x] = (left, right)
    if left != right:
      self.set_range(x * 2 + 1, left, (right + left) // 2)
      self.set_range(x * 2 + 2, (right + left) // 2 + 1, right)

  def set_value(self, x):
    if x >= self.iter_size - 1:return self.value[x]
    a = self.set_value(x * 2 + 1)
    b = self.set_value(x * 2 + 2)
    if a == None and b == None:
      self.value[x] = None
    elif a == None:
      self.value[x] = b
    elif b == None:
      self.value[x] = a
    else:
      self.value[x] = a
    return self.value[x]

  def update(self, x, add, left, right):
    x_left, x_right = self.range[x]
    if right < x_left or x_right < left:
      pass
    elif left <= x_left and x_right <= right:
      self.value[x] += add
    else:
      self.update(x * 2 + 1, add, left, right)
      self.update(x * 2 + 2, add, left, right)
  
  def query(self, x, total):
    if x < 0:return total
    total += self.value[x]
    return self.query((x - 1) // 2, total)

  def print_tree(self):
    print(self.value)
    print(self.range)

n, q = map(int, input().split())
tree = TemplateTree([0] * n)

for _ in range(q):
  lst = list(map(int, input().split()))
  if lst[0] == 0:
    s, t, x = lst[1:]
    tree.update(0, x, s - 1, t - 1)
  else:
    i = lst[1]
    print(tree.query(tree.iter_size - 1 + i - 1, 0))




Measured memory_bytes: 37892
#include "stdio.h"

int main(int argc, char const *argv[]) {
  int N,i,j;
  scanf("%d", &N);
  double A[N+1][N+1];
  double P[N+1];
  for (i = 1; i <= N; i++) {scanf("%lf", &P[i]);}

  for (i = 0; i <=N; i++) {for (j = 0; j <=N; j++) {A[i][j]=0.0;}}

  A[0][0]=1.00;
  for (i = 1; i <= N; i++) {
    A[i][0]=A[i-1][0]*(1-P[i]);
    for (j = 1; j <=N; j++) {
      A[i][j]=A[i-1][j-1]*P[i]+A[i-1][j]*(1-P[i]);
    }
  }

  double ans=0;
  for (i = (N+1)/2; i <=N ; i++) {
    ans=ans+A[N][i];
  }
  printf("%.10lf", ans);
  return 0;
}


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

int main(){
    int n; cin >> n;
    int x; cin >> x;
    int m;
    int MIN = 1e5;
    for(int i=0;i<n;i++){
        cin >> m;
        x -= m;
        MIN = min(MIN, m);
    }
    cout << n + x/MIN << endl;
}

Measured memory_bytes: 256
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = [None]*M
X = [None]*M

for i in range(M):
  P[i],X[i] = map(int,input().split())

tmp = sum(T)
for i in range(M):
  print(tmp - T[P[i]-1] + X[i])

Measured memory_bytes: 3060
import collections

n=int(input())
a=list(map(int,input().split()))

aa=[]

for i in range(n):
    aa.append(a[i]-1)
    aa.append(a[i])
    aa.append(a[i]+1)
ans_list=collections.Counter(aa)
print(ans_list.most_common()[0][1])

Measured memory_bytes: 30940
#include <iostream>

using namespace std;

int main() {
    int a, b;
    while(true) {
        cin >> a;
        if(cin.eof()) break;
        cin >> b;
        if(cin.eof()) break;
        int ans=0;
        int temp=a+b;
        while(temp>0) {
            temp/=10;
            ++ans;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3108