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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<vector<ll>> nbr(N);
  for (ll i = 0; i < N-1; i++) {
    ll a, b; cin >> a >> b; a--; b--;
    nbr.at(a).push_back(b);
    nbr.at(b).push_back(a);
  }
  vector<ll> nEven, nOdd;
  auto dfs = [&](const auto& recF, ll n, ll p, ll d) -> void {
    if (d == 0) nEven.push_back(n);
    else        nOdd.push_back(n);
    for (ll c : nbr.at(n)) {
      if (c == p) continue;
      recF(recF, c, n, 1-d);
    }
  };
  dfs(dfs, 0, -1, 0);
  vector<ll> ans(N);
  auto ass1 = [&](ll i, ll& p) -> bool {
    if (p <= N) {
      ans.at(i) = p;
      p += 3;
      return true;
    }else {
      return false;
    }
  };
  ll n0 = 3, n1 = 1, n2 = 2;
  if ((ll)nEven.size() <= N / 3) {
    for (ll i : nEven) ass1(i, n0);
    for (ll i : nOdd)  ass1(i, n0) || ass1(i, n1) || ass1(i, n2);
  }else if ((ll)nOdd.size() <= N / 3) {
    for (ll i : nOdd)  ass1(i, n0);
    for (ll i : nEven)  ass1(i, n0) || ass1(i, n1) || ass1(i, n2);
  }else {
    for (ll i : nEven) ass1(i, n1) || ass1(i, n0);
    for (ll i : nOdd)  ass1(i, n2) || ass1(i, n0);
  }
  for (ll i = 0; i < N; i++) {
    if (i > 0) cout << " ";
    cout << ans.at(i);
  }
  cout << endl;
  return 0;
}



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

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

	vector<ll> cnt(30, 0);
	for (int i = 0; i < cnt.size(); i++) {
		vector<ll> ta(N);
		vector<ll> tb(N);
		for (int j = 0; j < N; j++) {
			ll mod = pow(2, i + 1);
			ta[j] = a[j] % mod;
			tb[j] = b[j] % mod;
		}
		sort(tb.begin(), tb.end());

		for (int j = 0; j < N; j++) {
			ll T = pow(2, i);
			auto it1 = lower_bound(tb.begin(), tb.end(), T - ta[j]);
			auto it2 = lower_bound(tb.begin(), tb.end(), T * 2 - ta[j]);
			auto it3 = lower_bound(tb.begin(), tb.end(), T * 3 - ta[j]);
			auto it4 = lower_bound(tb.begin(), tb.end(), T * 4 - ta[j]);
			cnt[i] += (it2 - it1) + (it4 - it3);
		}
	}

	ll res = 0;
	for (int i = 0; i < cnt.size(); i++) {
		res += ((cnt[i] % 2) * pow(2, i));
	}

	cout << res << endl;
	return 0;
}


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

char cake[305][305];
int ans[305][305];

int main(){
	int h,w,k;
	cin >> h >> w >> k;
	rep(i,h) rep(j,w) cin >> cake[i][j];
	
	//まず縦に切る。
	int count = 1;
	rep(i,h){
		rep(j,w){
			if(cake[i][j] == '#'){
				ans[i][j] = count;
				//上方向
				for (int k = i-1; k >= 0 ; --k) {
					if(cake[k][j] == '#') break;
					else ans[k][j] = count;
				}
				//下方向
				for (int k = i+1; k < h; ++k) {
					if(cake[k][j] == '#') break;
					else ans[k][j] = count;
				}
				count++;
			}
		}
	}
	rep(i,h){
		rep(j,w){
			if(ans[i][j] == 0){
				//j列目は全部ゼロになっているはず。
				for (int k = j; k < w; ++k) {
					if(ans[i][k] != 0){
						rep(l, h){
							ans[l][j] = ans[l][k];
						}
						break;
					}
				}
				for (int k = j; k >= 0; --k) {
					if (ans[i][k] != 0) {
						rep(l, h) {
							ans[l][j] = ans[l][k];
						}
						break;
					}
				}
			}
		}
	}
	
	rep(i,h){
		rep(j,w){
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
    return 0;
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const ll mod = 1000000007;

using ld = long double;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N, M;
    cin >> N >> M;
    VI V(N);
    ld sum = 0.0;
    REP(i, N) {
    	cin >> V[i];
    	sum += V[i];
    }
    sort(all(V), greater<int>());
    ld p = (ld) 1.0/ ((ld) 4.0 * (ld) M);
    REP(i, M) {
    	if (V[i] < p * sum) {
    		cout << "No\n";
    		return 0;
    	}
    }
    cout << "Yes\n";


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  int ans = 0;
  while(N >= 500){
    N -= 500;
    ans += 1000;
  }
  while(N >= 5){
    N -= 5;
    ans += 5;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
struct Edge{
    int u,v,d;
    bool operator<(const Edge& a)const{
        return d<a.d;
    }
};
struct P{
    int x,y,id;
    bool operator<(const P&a)const{
        if(x==a.x) return y<a.y;
        return x<a.x;
    }
};
const int maxn=1e5+7;
int fa[maxn];
int Find(int x)
{
    return x==fa[x]?x:fa[x]=Find(fa[x]);
}
void Union(int x,int y)
{
    x=Find(x),y=Find(y);
    fa[y]=x;
}
int main()
{
    for(int i=0;i<maxn;i++) fa[i]=i;
    int n;
    cin>>n;
    vc<P> p(n);
    for(int i=0;i<n;i++) 
    {
        cin>>p[i].x>>p[i].y;
        p[i].id=i;
    }
    sort(p.begin(),p.end());
    vc<Edge> all;
    for(int i=0;i<n;i++)
    {
        if(i)
            all.push_back(Edge{p[i].id,p[i-1].id,p[i].x-p[i-1].x});
    }
    for(int i=0;i<n;i++) swap(p[i].x,p[i].y);
    sort(p.begin(),p.end());
    for(int i=0;i<n;i++)
    {
        if(i)
            all.push_back(Edge{p[i].id,p[i-1].id,p[i].x-p[i-1].x});
    }
    sort(all.begin(),all.end());
    ll ans=0;
    for(auto u:all)
    {
        if(Find(u.u)!=Find(u.v))
        {
            Union(u.u,u.v);
            ans+=u.d;
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 6388
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>

using namespace std;

int main(void)
{
	int N;



	int S = 0;

	int cnt;

	cin >> N;

	int ansN = N;

	while (N)
	{
		cnt = N % 10;
		S = S + cnt;
		N = N / 10;
	}

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

	return 0;
}



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

int main(int argc, char const *argv[]) {
  int a,b,c;
  cin >> a>>b>>c;
  if(a==b&&b==c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n,t;
    cin >> n >> t;
    vector<int> a(n);

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

    vector<pair<int,pair<int,int>>> m(n);
    m[0] = {a[0],{-1,-1}};
    pair<int,int> mn = {a[0],0};
    int mx = -mod;
    int cnt = 0;

    for(int i = 1; i < n; i++){
        m[i] = {a[i]-mn.first,{mn.first,mn.second}};
        if(mn.first >= a[i]) mn = {a[i],i};
        if(mx < a[i]-mn.first){
            mx = a[i]-mn.first;
            cnt = 1;
        }
        else if(mx == a[i]-mn.first) cnt++;
    }

    map<int,int> mpd;
    for(int i = 0; i < n; i++){
        if(get<0>(m[i]) == mx){
            mpd[m[i].second.first]++;
        }
    }
    cout << min((int)mpd.size(),cnt) << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    ll S;
    cin >> S;
    ll x1, y1, x2, y2, x3, y3;
    x1 = y1 = 0;

    ll t = sqrt(S);
    if (t * t == S) {
        x2 = t;
        y2 = 0;
        x3 = 0;
        y3 = t;
    } else {
        x2 = t + 1;
        y2 = x2 * x2 - S;
        x3 = 1;
        y3 = t;
    }

//    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;

    if (t * t == S) {
        cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
//        cout << "0 0 " << t << " " << "0 0 " << t << "\n";
        return 0;
    }
    t += 1;
    ll e = t * t - S;
    cout << x1 << " " << y1 << " " << t << " " << e << " " << "1 " << t << endl;
    return 0;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	map<int, int> mp;
	rep(i, n) {
		int a;
		cin >> a;
		mp[a]++;
	}
	vector<int> v;
	for (auto a : mp) {
		v.push_back(a.second);
	}
	sort(v.begin(), v.end());
	int ans = 0;
	rep(i, (int)v.size() - k) {
		ans += v[i];
	}
	cout << ans << endl;
	return 0;
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var intArr = cin.ReadIntArray(2);
            var result = (intArr[0] * 3 + intArr[1]) / 2;
            WriteLine(result);
        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 

int main(){
    int n ;
    cin >> n ;
    vector<vector<P>> vec (n) ;
    rep(i, n){
        int a ;
        cin >> a ;
        rep(j, a){
            int x, y ;
            cin >> x >> y ;
            x-- ;
            vec[i].push_back(P(x, y)) ;
        }
    }
    int num = 0 ;
    rep(i, 1 << n) {
        vector<int> ans (n, -1) ;
        int res = 0 ;
        bool can = true ;
        rep(j, n){
            if(i >> j & 1){
                rep(k, vec[j].size()){
                    int fi = vec[j][k].first ;
                    int se = vec[j][k].second ; 
                    if(ans[fi] != se && ans[fi] != -1){
                        can = false ;
                    }
                    else {
                        ans[fi] = se ; 
                    }
                }
                res++ ;
            }
        }
        if(can){
                    rep(j, n){
            if((i >> j & 1) != ans[j] && ans[j] != -1){
                res = 0 ;
            }
        }
        num = max(num, res) ;
        }

    }
    cout << num << endl ;
} 

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int x,a,b; cin>>x>>a>>b;
	if(abs(x-a)>=abs(x-b)) cout<<'B'<<endl;
	else cout<<'A'<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5;
char s[N];
int main(){
int x,y;
cin>>x>>y;
cin>>s;

for(int i=0;i<x+y+1; ++i){
if(i==x){
if(s[i]!='-'){
cout<<"No\n";
return 0;
}
}
else{
 if(!(s[i]<='9' && s[i]>='0')){
    cout<<"No\n";
    return 0;
 }

 }

}
cout<<"Yes\n";
}


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

int main() {
	string s; cin >> s;
	int n = s.size(), l = 0, r = 0; bool ok = false;
	for (int i = 0; i < n; i++) {
		if (s[i] == s[i + 1]) {
			l = i + 1;
			r = i + 2;
			ok = true;
			break;
		}
		if (i < n - 2 && s[i] == s[i + 2]) {
			l = i + 1;
			r = i + 3;
			ok = true;
			break;
		}
	}
	if (ok)cout << l << ' ' << r << endl;
	else cout << -1 << ' ' << -1 << endl;

	return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<P> ans;
    if(n%2){
        for(int l = 1, r=n-1;l<r;l++,r--){
            ans.emplace_back(l,r);
        }
    }else{
        bool flag = false;
        for(int l = 1, r=n-1;l<r;l++,r--){
            if(!flag && r-l<=n/2){
                r--;
                flag=true;
            }
            ans.emplace_back(l, r);
        }
    }
    rep(i,m){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 5224
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	vector<int> nums(n); fore(e, nums) cin >> e;
	int cnt = 0;
	forl(i, 0, n) {
		if(nums[i] != i+1) cnt++;
	}
	if(cnt <= 2) println("YES");
	else println("NO");
}


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

int main()
{
	int n;
	cin >> n;
	vector<pair<double,double>> xy(n);
	for(int i  = 0;i<n;i++)
	{
		cin >> xy[i].first >> xy[i].second;
	}
	sort(xy.begin(),xy.end());
	double ans = 0; 
	double cnt = 0;
	do
	{
		for(int i = 0;i<n-1;i++)
		{
			double X1 = xy[i].first,X2 = xy[i+1].first,Y1 = xy[i].second,Y2 = xy[i+1].second;
			ans += sqrt((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2));
		}
		cnt +=1.0;
	}
	while(next_permutation(xy.begin(),xy.end()));
	printf("%.10lf\n",ans/cnt);
	return 0;
}

Measured memory_bytes: 256
a, b, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(m)]

ans = min(a) + min(b)
for x, y, c in xyc:
    ans = min(ans, a[x-1] + b[y-1] - c)

print(ans)

Measured memory_bytes: 82156
def myAnswer(N:int,M:int,A:list,B:list) -> int:
   dic = {key:[] for key in range(1,N+1)}
   for a,b in zip(A,B):
      dic[a].append(b)
   for i in dic[1]:
      for value in dic[i]:
         if(N == value):
            return "POSSIBLE"
   else:
      return "IMPOSSIBLE"

def modelAnswer():
   return
def main():
   N,M = map(int,input().split())
   A = []
   B = []
   for _ in range(M):
      a,b = map(int,input().split())
      A.append(a)
      B.append(b)
   print(myAnswer(N,M,A[:],B[:]))
if __name__ == '__main__':
   main()

Measured memory_bytes: 108368
#include<iostream>
using LL = long long;
using namespace std;


int main() {
	LL A, B, V, W, T;
	cin >> A >> V >> B >> W >> T;
	if (V - W <= 0) {
		cout << "NO" << endl;
	}
	else if ((V - W) * T >= abs(A - B)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
s = gets.chomp.to_s.split(//)
n = gets.chomp.to_i
cnt = 0
same = 1

if s.uniq.size == 1 && s.size. odd?
  puts (s.size * n) / 2
  exit
end

s.size.times do |i|
  if s[i] == s[i+1]
    same += 1
    if same.even?
      cnt += 1
    end
  else
    same = 1
  end
end

s2 = s * 2
cnt2 = 0
same2 = 1

s2.size.times do |i|
  if s2[i] == s2[i+1]
    same2 += 1
    if same2.even?
      cnt2 += 1
    end
  else
    same2 = 1
  end
end

if cnt * 2 == cnt2
  puts cnt * n
else
  puts cnt * n + (n - 1)
end


Measured memory_bytes: 1788
#include <algorithm>
#include <array>
#include <cstdio>

/*
https://atcoder.jp/contests/abc153/submissions/9767872
*/
const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
  if (ci - cn == cm) {
    fread_unlocked(cn, 1, cm, stdin);
    ci = cn;
  }
  return *ci++;
}
inline int getint() {
  int A = 0;
  if (ci - cn + 16 > cm)
    while ((ct = getcha()) >= '0')
      A = A * 10 + ct - '0';
  else
    while ((ct = *ci++) >= '0')
      A = A * 10 + ct - '0';
  return A;
}
/*
https://atcoder.jp/contests/abc153/submissions/9767872
*/

inline constexpr bool test(const int x, const int y) noexcept {
  return x & 1 << y;
}

int main() {
  const int n = getint();
  std::array<int, 100000> v = {};
  for (int i = 0; i != n - 1; i += 1) {
    const int x = getint();
    const int y = getint();
    const int a = getint();
    v[x] ^= a;
    v[y] ^= a;
  }
  int ans = n;
  int b = 0;
  for (int i = 0; i != n; i += 1) {
    const int e = v[i];
    if (e == 0) {
      ans -= 1;
    } else {
      if (test(b, e))
        ans -= 1;
      b ^= 1 << e;
    }
  }

  std::array<int, 65536> dp = {};
  dp[b] = 1;
  for (int s = b; s != 0; s -= 2) {
    if (dp[s] == 0)
      continue;
    int i = 16;
    while (i != 0) {
      i -= 1;
      if (test(s, i))
        break;
    }
    for (int j = 0; j != i; j += 1) {
      if (!test(s, j))
        continue;
      const int k = i ^ j;
      if (k > j)
        continue;
      int &d = dp[s ^ 1 << i ^ 1 << j ^ 1 << k];
      if (test(s, k))
        d = std::max(d, dp[s] + 1);
      else
        d = std::max(d, dp[s]);
    }
  }
  printf("%d", ans - dp[0] + 1);
}

Measured memory_bytes: 896
// Can get test cases;
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9+5;
int dp[100100];
int b[2] = { 6, 9 };

int rec(int n) {
    if (dp[n] < INF) return dp[n];
    int s = rec(n - 1) + 1;
    for (int i = 0; i < 2; ++i) {
        int x = b[i];
        for (int j = 1; j < INF; ++j) {
            int p = pow(x, j);
            if (n - p < 0) break;
            s = min(s, rec(n - p) + 1);
        }
    }
    dp[n] = s;
    return s;
}

void solve() {
    int N;
    cin >> N;
    for (int i = 0; i <= N; ++i) dp[i] = INF;
    dp[0] = 0;
    cout << rec(N) << endl;
}

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


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long int ll;
#define MOD 1000000007
#define INF 1e18
#include <ctime>
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define rev(i, n, x) for (ll i = n; i > x; i--)
#define all(c) (c).begin(), (c).end()
#define int long long int
#define endl "\n"
#ifdef mishra
#define debug(x) cout << " >> " << #x << ": " << x;
#define debugend() cout << endl;
#define __debug ;
#define print_time() cout << setprecision(6) << "time: " << (clock() - start) / (double)CLOCKS_PER_SEC << '\n';
#else
#define debug(x) ;
#define debugend() ;
#define __debug //
#define print_time() ;
#endif

clock_t start;
void FAST(ll argc)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    start = clock();
    if (argc == 2)
        freopen("std2.txt", "r", stdin);
}

/*vector<ll> v;
void seive()
{
    v.pb(2);
    for (int i = 3; i < 100000; i += 2)
    {
        for (int j = 0; j < v.size(); j++)
        {
            if (i % v[j] == 0)
                break;
            if (v[j] * v[j] > i)
            {
                v.pb(i);
                break;
            }
        }
    }
}
/*
void prime_factor(ll x, vector<ll> &r)
{
    ll sqrt_x = sqrt(x);

    for (ll i : v)
    {
        if (i > sqrt_x)
            break;

        if (x % i == 0)
            r.pb(i);

        while (x % i == 0)
        {
            x /= i;
        }
    }

    if (x >= 2)
        r.pb(x);
}
*/
/*
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % MOD;
        y = y >> 1;
        x = (x * x) % MOD;
    }
    return res;
}
*/
/*
inline void dfs(ll curr, ll prev)
{

    for (ll i : a[curr])
        if (i != prev)
            dfs(i, curr);
}
*/
/*
ll multi(ll a, ll b)
{
    return ((a * b) % MOD);
}
*/
//---------------------CODE STARTS HERE---------------------
vector<vector<int>> v;
int ans[100005] = {0}, vis[100005] = {0}, parents[100005] = {0};
void dr(int curr, int ansprev)
{
    if (v[curr].size() == 0)
        return;

    for (auto i : v[curr])
    {
        ans[i] = max(ansprev + 1, ans[i]);
        vis[i]++;
        if (vis[i] != parents[i])
            continue;
        dr(i, ans[i]);
    }
}

signed main(char argc, char *argv[])
{
    FAST(argc);

    ll testcase = 1;
    //cin >> testcase;

    while (testcase--)
    {
        int n, m;
        cin >> n >> m;
        v.resize(n);
        rep(i, 0, m)
        {
            int x, y;
            cin >> x >> y;
            x--, y--;
            v[x].pb(y);
            parents[y]++;
        }
        rep(i, 0, n)
        {
            if (parents[i] == 0)
                dr(i, 0);
        }
        int z = 0;
        for (auto i : ans)
            z = max(z, i);
        cout << z << endl;
        //--------??--------CLEAR VECTORS--------??--------
        v.clear();
    }

    //v.clear();
    print_time();
    return 0;
}

Measured memory_bytes: 11136
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    int max = -1;
    int maxNum = -1;
    for (int i = 1; i <= n; i++) {
        int c = i;
        int count = 0;
        while (c % 2 == 0) {
            count++;
            c /= 2;
        }
        if (max < count) {
            max = count;
            maxNum = i;
        }
    }
    cout << maxNum << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<limits.h>
#include<utility>
#include<cstdlib>
#include<bitset>
#define LP(i,n) for(int i=0;i<n;i++)
#define LPIN(n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++)cin >> v[i];
    sort(v.begin(),v.end());

    cout << v[n/2] - v[n/2-1]<< endl;
    return 0; 
}

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

// int main()
// {
//     string s;
//     cin >> s;
//     int len = s.length();
//     char ans[len+1];
//     for (int i = 0; i < len; i++)
//     {
//         ans[i]='x';
//     }
//     printf("%s", ans);
//     return 0;
// }

int main() {
    char s[101];
    scanf("%s", s);
    for (int i =0; s[i]; i++) {
        s[i]='x';
    }
    printf("%s", s);

    return 0;
}

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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (long long )(1e10+1)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){ 
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

void solve() {
    int n, k;
    cin >> n >> k;
    int vis[n+1] = {0};
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a;
            vis[a] = 1;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(!vis[i])ans++;
    }
    cout << ans << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif
   
    //cin >> t;

    
    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}


Measured memory_bytes: 3656
import copy
import math
c=[0]*(10**5+1)
for n in range(2,10**5+1):
  for k in range(2, int(math.sqrt(n))+1):
    if n%k==0:
      break
  else:
    c[n]=1
cc=[0]*(10**5+1)
for n in range(1,10**5+1,2):
  if c[n] and c[(n+1)//2]:
    cc[n]=1
#print(*c[:100])
for i in range(1,10**5+1):
  cc[i] += cc[i-1]
#print(*c[:100])
#print(*[(i,cc[i]) for i in range(1,54)])
q=int(input())
for i in range(q):
  l,r=map(int,input().split())
  print(cc[r]-cc[l-1])

Measured memory_bytes: 12992
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[2005];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	ll ans=0;
	a[n+1]=2e9;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			int k1=lower_bound(a+1,a+n+2,a[i]+a[j])-a;
			k1--;
			int k2=upper_bound(a+1,a+n+2,a[j]-a[i])-a;
			if(k1>=j&&k2<=i&&k1-k2>=2)
			{
				ans=ans+k1-k2-1;
			}
			else if(k2>i&&k1-k2>=1)
			{
				ans=ans+k1-k2;
			}
			else
			{
				continue;
			}
		///	cout<<k1<<" "<<k2<<"\n";
		}
	}
	cout<<ans/3<<"\n";
	
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int a;
cin >> a;
cout << a + a*a + a*a*a << endl;

return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define ll long long
int main() {
    int t,x=0,c=0;
    cin>>t;
    int arr[t];
    REP(i,t)
    {
        cin>>arr[i];
    }
   int ar2[t]={0};
 int i=0,j=t-1;
while(1){
 while(i<=j)
 {
     if(x==1 && arr[i]==ar2[i]){c++;break;}
     while(arr[i]==ar2[i]){i++;}
     if(i>j) {break;}
     if(arr[i]>ar2[i]) { x=1;
         ar2[i]++;
     }
     if(x==1 && i==j){c++;break;}
     i++;
 }
 if(x==0)break;i=0;x=0;
    
}cout<<c<<endl;
}

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

robot_arms = []
for _ in range(n):
    x, l = map(int, input().split())
    robot_arms.append([x-l, x+l])
robot_arms = sorted(robot_arms, key=lambda x: x[1])

l, r = 0, 1
cnt = 1
while r < n:
    if robot_arms[l][1] <= robot_arms[r][0]:
        l = r
        r += 1
        cnt += 1
    else:
        r += 1
print(cnt)

Measured memory_bytes: 22104
from collections import deque
N,K=map(int,input().split())
L=list(map(int,input().split()))

def factorization(N):
    res=[]
    for i in range(2,int(N**(1/2))+2):
        if not N%i:
            r=0
            while not N%i:
                N//=i
                r+=1
            res.append((i,r))
    if N>1:
        res.append((N,1))
    return res

def factors(n):
    res=[1]
    for i,j in factorization(n):
        res+=[r*i**(b+1) for r in res for b in range(j)]
    return res

A=factors(sum(L))
A.sort()

def check(n):
    B=deque(sorted([a%n for a in L if a%n>0]))
    rp,rm=0,0
    while B:
        if rp<rm:
            rp+=B.popleft()
        else:
            rm+=n-B.pop()
    if rp!=rm:
        return False
    return rp<=K

# ok=-1
# ng=len(A)
# print(A,[check(a) for a in A])
# while abs(ok-ng)>1:
#     mid=(ok+ng)//2
#     if check(A[mid]):
#         ok=mid
#     else:
#         ng=mid
# print(A[ok])

for a in reversed(A):
    if check(a):
        break
print(a)

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

using namespace std;
typedef long long ll;
typedef pair <int, int> pp;
#define MAXN 105
#define MAXC 205
#define MAXP 25
#define A first
#define B second
#define MP make_pair
#define PB push_back
const ll INF = 2e9+13;
const ll MOD = 1e9+7;
int N, A, B;

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> A >> B;
	int gap = B-A;
	if(gap%2) cout << "Borys" << endl;
	else cout << "Alice" << endl;
	
		
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    vector<string> t(n);
    pair<pii,int> p[10];
    rep(i,n){
      int r;
      cin>>t[i];
      p[i].second=i;
      rep(j,n-1){
        cin>>r;
        if(r==0)
          p[i].first.first--;
        else if(r==1)
          p[i].first.second++;
      }
    }
    sort(p,p+n);
    rep(i,n)
      cout<<t[p[i].second]<<endl;
  }
}

Measured memory_bytes: 3008
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();

        //        boolean ans = false;

        int count = 0;
        int[] a = new int[n];

        for (int i = 1; i < n; i++) {
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C')
                count++;
            a[i] = count;
        }

        //        if (1200 <= n)
        //            ans = true;

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

            System.out.println(a[r - 1] - a[l - 1]);
        }
        sc.close();
        //        System.out.println(ans ? "Yes" : "No");

    }
}

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

using namespace std;
#define ll long long


int main()
{
    ll n;
    cin>>n;
    ll ar[n];
    ll mn=1e9,mx=-1e9;
    ll in,ix;
    for(ll i=0;i<n;i++){
        cin>>ar[i];
        if(ar[i]<mn){
            mn=ar[i];
            in=i;
        }
        if(ar[i]>mx){
            mx=ar[i];
            ix=i;
        }
    }
    if(mx==mn&&mn==0){
        cout<<0<<endl;
        return 0;
    }
    vector<pair<ll,ll>> vp;
    if(abs(mx)>=abs(mn)){
        for(ll i=1;i<n;i++){
            if(ar[i]>=ar[i-1]){
                continue;
            }
            else{
                while(ar[i]<ar[i-1]){
                    ar[i]+=mx;
                    vp.push_back({ix,i});
                    if(ar[i]>mx){
                        mx=ar[i];
                        ix=i;
                    }
                }
            }
        }
    }
    else{
        for(ll i=n-2;i>=0;i--){
            if(ar[i]<=ar[i+1]){
                continue;
            }
            else{
                while(ar[i]>ar[i+1]){
                    ar[i]+=mn;
                    vp.push_back({in,i});
                    if(ar[i]<mn){
                        mn=ar[i];
                        in=i;
                    }
                }
            }
        }
    }
    cout<<vp.size()<<endl;
    for(ll i=0;i<vp.size();i++){
        cout<<vp[i].first+1<<" "<<vp[i].second+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}
void YesNo(bool flag){ cout<<(flag? "Yes":"No");}

ll a,b,c,d,n,x;
vector<ll>v[3];
map<ll,ll>m;
string s,s2;
void input(){
    cin>>a>>b;
}
void src(){
    cout<< a+2*(b-a);
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
let n = Int(readLine()!)!
let mod = 1000000007

var ten = 1
var nine = 1
var eight = 1
for _ in 1...n {
    ten *= 10
    ten %= mod

    nine *= 9
    nine %= mod

    eight *= 8
    eight %= mod
}

let result = (ten - eight - ((nine - eight) * 2)) % mod
if result >= 0 {
    print(result)
} else {
    print(mod + result)
}


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

using ll = long long;
int n;
ll T;
string f;

int main(){
    while(cin >> n >> T >> f){
        const double th = log(1.5e9/T);
        bool ok = true;
        ll res = 0;
        for(auto c : f){
            if(!isdigit(c)) continue;
            int exp = c - '0';
            double x = exp * log(n);
            if(x > th){
                ok = false;
                break;
            }
            ll add = 1;
            for(int i = 0; i < exp; ++i){
                add *= n;
            }
            res += add;
        }
        res *= T;
        ok &= res <= 1e9;
        if(ok) cout << res;
        else cout << "TLE";
        cout << endl;
    }
}

Measured memory_bytes: 3444
module Main where
 
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Text.Printf
import Data.Fixed
import Debug.Trace

solve :: Int -> Int -> Int
solve now n
  | n == 0 = now
  | otherwise = solve (floor new) (pred n) where
      new = if q `mod'` 1000 == 0 then q else (q - (q `mod'` 1000)) + 1000
      q = (fromIntegral now) * 1.05

main :: IO ()
main = do
    [n] <- fmap (read :: String -> Int) . words <$> getLine
    -- let n = 10
    putStrLn $ show $ solve 100000 n

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

int main(){
  ll n;
  ll cnt=0;
  cin >> n;
  rep(i,n){
    if((i+1)%3!=0&&(i+1)%5!=0)cnt+=i+1;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3636
import collections

n = int(input());
S = [];

for i in range(n):
  S.append(input());

c = collections.Counter(S)

num = c.most_common()[0][1];
ans = [];

for a,b in c.most_common():
    if b == num:
      ans.append(a);
      continue;
    
    else:
      break;

ans = sorted(ans);

for i in ans:
  print(i);


Measured memory_bytes: 45040
#include <iostream>
#include <vector>
#include <set>
#include <array>
#include <algorithm>

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  int odd_counter = 0;
  for(int i = 0; i < n; i++)
  {
	ll v;
	cin >> v;
	if(v % 2 == 1) odd_counter++;
  }

  if(odd_counter % 2 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
//Author : Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define ll long long
#define INF 100000
const int M=1e9+7;



int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  
  int n;
  cin>>n;
  map<string, int> m;
  string s;
  REP(i,0,n)
  {
  	cin>>s;
  	m[s]++;
  }
  cout<<"AC x "<<m["AC"]<<"\n";
  cout<<"WA x "<<m["WA"]<<"\n";
  cout<<"TLE x "<<m["TLE"]<<"\n";
  cout<<"RE x "<<m["RE"]<<"\n";
  
  
   return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << 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...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	sort(a.begin(),a.end());
	int i = 0;
	int tot = n;
	int ret = 0;
	// while(i < n){
	// 	int cnt = 0;
	// 	for(;i < n && past == a[i];i++)cnt++;
	// 	if(cnt%2)ret ^= tot;
	// 	tot -= cnt;
	// }
	
	for(int i = 0,j;i < n;i = j){
		int cnt = 0;
		for(j = i;j < n && a[j] == a[i];j++)cnt++;
		int tmp;
		if(i)tmp = a[j-1] - a[i-1];
		else tmp = a[j-1];
		// trace(tmp);
		if((tmp)%2)ret ^= tot;
		tot -= cnt;
	}
	
	if(ret == 0)cout << "second" << endl;
	else cout << "first" << endl;
	return 0;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[300],m,n,i,j,res=0;
  cin>>n;
  for(i=0;i<n*2;i++)
  {
      cin>>a[i];
  }

    sort(a,a+(n*2));

    for(i=0;i<n*2;i+=2)
    {
        res+=a[i];



    }
    cout<<res<<endl;

return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> vec;
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    vec.push_back(num);
  }
  vector<int> order = vec;
  sort(order.begin(), order.end());
  int count = 0;
  for(int i=0; i<n; i++){
    if(order[i] != vec[i]){
      count++;
    }
  }
  if(count <= 2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}
  

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

const int MAX = 510000;
const int mod = 1000000007;

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

int main(){
    long long n,m,k;
    cin>>n>>m>>k;
    COMinit();

    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=(n-i)*i*m*m*COM(n*m-2,k-2);
        ans%=mod;
    }
    for(int i=0;i<m;i++){
        ans+=(m-i)*i*n*n*COM(n*m-2,k-2);
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  vector<int> k(1000001,0);
  int u[n];
  rep(i,n)cin >> u[i];
  int g=u[0];
  rep(i,n-1){
    g=gcd(g,u[i+1]);
  }
  set<int> s;
  s.insert(2);
  rep(i,997){
    int y=i+3;
    int v=0;
    rep(j,y-2){
      if(y%(j+2)==0)v++;
    }
    if(v==0)s.insert(y);
  }
  rep(i,n){
    int a=u[i];
    for(int j: s){
      if(a%j==0){
        k[j]++;
        while(a%j==0){
          a/=j;
        }
      }
    }
    if(a>1)k[a]++;
  }
  int x=0;
  rep(i,1000001){
    x=max(x,k[i]);
  }
 // rep(i,10)cout << k[i] << endl;
  if(x<=1){
    cout << "pairwise coprime" << endl;
  }
  else if(g==1){
    cout << "setwise coprime" << endl;
  }
  else cout << "not coprime" << endl;
}


Measured memory_bytes: 11088