akhauriyash/Code-Regression huggingface dataset:
N = int(input())
MAX = 10 ** 2 + 10
ans = [0] * (N+1)
for x in range(1,MAX):
    for y in range(1,MAX):
        for z in range(1,MAX):
            tmp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if tmp <= N:
                ans[tmp] += 1

print(*ans[1:], sep="\n")


Measured memory_bytes: 9428
n = int(input())
w = [input() for i in range(n)]
count = 0
for i in range(n):
     if len(set(sorted(w))) != n:
          count += 2
for i in range(n-1):
     if w[i][-1] == w[i+1][0]:
          count += 1
if count == n-1:
     print("Yes")
else:
     print("No")


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

int main (){
    int a, b;
    char op;

    while(1){
        cin >> a >> op >> b;
        if (op == '?') break;

        if (op == '+') cout << a + b << endl;
        else if (op == '-') cout << a - b << endl;
        else if (op == '*') cout << a * b << endl;
        else if (op == '/') cout << a / b << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 100000;
int main(void){

    int N , M; cin >> N >> M;
    pair<long long , long long> shop[MAX_N];
    for(int i = 0 ; i < N ; i++){
        cin >> shop[i].first >> shop[i].second;
    }
    sort(shop , shop + N);
    long long bought = 0 , ans = 0;
    for(int i = 0 ; bought < M ; i++){
        //目標本数かその店で買える限界数まで購入
        ans += shop[i].first * min(M - bought , shop[i].second);
        bought += shop[i].second;
    }
    cout << ans << endl;


    return 0;
}

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

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

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
main()
{
  int n,x;
  cin>>n;
  int f[n+1]={0};
  for(int i=1;i<n;i++)
  {
    cin>>x;
    f[x]++;
  }
  for(int i=1;i<=n;i++)
    cout<<f[i]<<endl;
}

Measured memory_bytes: 4368
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod1=998244353;


vector<ll> fact(200010,1);


// a^n%mod
template<class T=int64_t>
T bin_pow(T a,T n,T mod=mod1){
    T ans=1;
    while(n>0){
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans%mod;
}

//a^(-1)(mod)=a^(mod-2)
template<class T=int64_t>
T inv_mod(T a,T mod=mod1){
  return bin_pow(a,mod-2);
}

// //a!%mod
// template<class T=int64_t>
// T fact(T a,T mod=mod1){
//     T ans=1;
//     for(int i=2;i<=a;++i){
//         ans=ans*i%mod;
//     }
//     return ans;
// }

//nCr%mod
template<class T=int64_t>
T comb(T n,T r,T mod=mod1){
    return fact[n]*inv_mod(fact[r])%mod1*inv_mod(fact[n-r])%mod;
}

int main()
{
  for (int i = 0; i < fact.size()-1; ++i)
  {
    fact[i+1]=fact[i]*(i+1);
    fact[i+1]%=mod1;
  }

  ll n,m,k;
  cin>>n>>m>>k;
  vector<ll> n_1Ck(k+1);
  for (ll i = 0; i < k+1; ++i)
  {
    n_1Ck[i]=comb(n-1,i)%mod1;
  }
  ll ans=0;
  for (ll i = 0; i <= k; ++i)
  {
    ans+=(n_1Ck[i]*(m*bin_pow(m-1,n-1-i)%mod1))%mod1;
    ans%=mod1;
  }
  cout<<ans<<endl;
}

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

int main()
{
    int cnt5 = 0, cnt7 = 0;
    int a, b, c;
    cin >> a >> b >> c;

    if(a == 5)  cnt5++;
    if(a == 7)  cnt7++;
    if(b == 5)  cnt5++;
    if(b == 7)  cnt7++;
    if(c == 5)  cnt5++;
    if(c == 7)  cnt7++;

    if(cnt5 == 2 && cnt7 == 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int;
using namespace std;
#define ll long long int
#define F first
#define S second
//#define endl "\n"
//#define nl cout<<endl;
#define pb push_back
#define ull unsigned long long 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define mod 100000007
#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 
bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
    return false;
}
bool cmp(int n, pair<int, int> const& p)
{
    return (p.first < n);
}
//me
ll const mod = 1e9+7;//998244353;
ll const inf = 1e18;
ll const maxn = 2e5+1;

vector<ll> nodes[maxn];
void solve()
{    

     ll n; cin >> n;
     vector<pair<ll,ll>> vv;
     f(i,1,n){
          ll u,v;
          cin >> u >> v;
          vv.pb({u,v});
          nodes[u].pb(v);
          nodes[v].pb(u);
     }
     ll usedcol[n+1],vis[n+1];
     fill(usedcol, usedcol+n+1,0);
     fill(vis, vis+n+1,0);
     map<pair<ll,ll>, ll> ans;
     queue<ll> q;
     q.push(1);
     vis[1]=1;
     ll maxx = 0;
     while(!q.empty()){

          ll cur = q.front();
          q.pop();
          ll col = 1;
          maxx = max(maxx, (ll)nodes[cur].size());
          for(auto ch : nodes[cur]){
               if(vis[ch]==0){
                    vis[ch]=1;
                    if(usedcol[cur]==col)col++;
                    usedcol[ch] = ans[{ch,cur}] = ans[{cur,ch}]=col++;
                    q.push(ch);
               }
          }

     }

     cout << maxx << endl;
     for(auto e : vv){
          cout << ans[e]<< endl;
     }
}

int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/ 
          
          ll t;
          /**/t=1;
          /*/cin>>t;/**/
          f(testcases,0,t){
               //cout << "Case #" <<testcases+1<<": ";
               solve();
          }
 
 
    return 0;
}

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

vector<int>g[100005];

int dp[100005]={0};

bool visited[100005]={false};

void dfs(int u)
{
	visited[u]=true;
	for(int i=0;i<g[u].size();i++)
	{
		int v=g[u][i];
		if(visited[v]==false)
			dfs(v);

		dp[u]=max(dp[u],dp[v]+1);
	}
}

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

    while(m--)
    {
    	int x,y;
    	cin>>x>>y;

    	g[x].push_back(y);
    }

    for(int i=1;i<=n;i++)
    {
    	if(visited[i]==false)
    		dfs(i);
    }

    int ans=0;
    for(int i=1;i<=n;i++)
    {
    	ans=max(ans,dp[i]);
    }

    cout<<ans;
}

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

int main() {
   int a, b;
   cin >> a >> b;

   if ((a * b) % 2 == 0) {
       cout << "Even" << endl;
   } else {
       cout << "Odd" << endl;
   }
}

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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long double db;

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

template<typename T> void print(const T& a, ostream& out){	
	for(auto i: a) out << i << ' ';
	out << endl;
}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n; cin >> n;
	vector<int> a(n);
	int ans = 0;
	FOR(i, 0, n) cin >> a[i];
	sort(ALL(a));
	FOR(i, 0, n) FOR(j, 0, i) FOR(k, 0, j){
		if (a[i] != a[j] && a[j] != a[k]){
			ans += a[j] + a[k] > a[i];
		}
	}
	
	cout << ans << endl;
	
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    vector<vector<ll>> B(N, vector<ll>(33, 0));
    vector<ll> C(33, 0);
    rep(i, N){
        cin>>A[i];
        ll AI=A[i];
        ll Key=0;
        while(AI>0){
            B[i][Key]=AI%2;
            C[Key]+=B[i][Key];
            AI/=2;
          	Key++;
        }
    }
    rep(i, 33){
        C[i]%=2;
      	//cout<<C[i]<<endl;
    }
    rep(i, N){
        ll Ans=0;
        ll Key=1;
        rep(j, 33){
            if(C[j]==0){
                Ans+=Key*B[i][j];
            }else{
                Ans+=Key*(1-B[i][j]);
            }
            Key*=2;
        }
        cout<<Ans<<endl;
    }

}
     

Measured memory_bytes: 62632
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func YesOrNo(b bool) {
	if b {
		puts("Yes")
	} else {
		puts("No")
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	h, w := nextInt2()
	cnt := map[byte]int{}
	for i := 0; i < h; i++ {
		a := next()
		for j := 0; j < w; j++ {
			cnt[a[j]]++
		}
	}

	odd := 0
	set2, set4 := 0, 0
	for _, v := range cnt {
		if v%2 == 1 {
			odd++
		}
		set2 += v / 2
		set4 += v / 4
	}

	if h%2 == 0 && w%2 == 0 {
		// 各文字の個数が4の倍数ならOK
		for _, v := range cnt {
			if v%4 != 0 {
				puts("No")
				return
			}
		}
		puts("Yes")
	} else if h%2 == 1 && w%2 == 1 {
		// 文字数奇数個の文字が1つで
		// 4つセットが一定数以上作れるならOK
		YesOrNo(odd == 1 && 4*set4 >= (h*w-(h+w-1)))
	} else if h%2 == 0 {
		YesOrNo(odd == 0 && 4*set4 >= (h*(w-1)))
	} else {
		YesOrNo(odd == 0 && 4*set4 >= (w*(h-1)))
	}
}


Measured memory_bytes: 640
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
diff = [-1, 0, 1]
for i in range(H):
	for j in range(W):
		count = 0
		for x in diff:
			for y in diff:
				if 0 <= i + x < H and 0 <= j + y < W and S[i+x][j+y] == '#':
					count += 1
		if S[i][j] == '.':
			S[i][j] = count
for s  in S:
	print(''.join(map(str, s)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,d;
  cin >> n >> d;
  int ans = 0;
  double ret = 0;
  
  int x,y;
  for(int i=0;i<n;i++){
    cin >> x >> y;
    ret = sqrt(pow(x,2) + pow(y,2));
    if(ret <= d){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
import java.util.*;
// warm-up
// Even better without extra space with a simple branch. Thanks to Editorial. 
// Technically no need for another loop and a map to cross check.
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt(), s = sc.nextInt(), t=0;
		for (int i=0; i<=K; i++) {
			for (int j=0; j<=K; j++) {
				int z = s-i-j;
				if (z>=0 && z<=K) t++;
			}
		}
		System.out.println(t);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35568
#include "bits/stdc++.h"
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n; i++) cin >> c[i];

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

    long long ans = 0;
    for(int i = 0; i < n; i++){
        int t = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        int s = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        ans += (long long)t * s;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		if(n/10 == 9 || n%10 == 9) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    ll h[n+1];
    for(ll i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    int dp[n+1];
    dp[1]=0;
    for(ll i=2;i<=n;i++)
    {
        if(i==2)
        {
            dp[i]=h[2]-h[1];
            dp[i]=dp[i]>=0?dp[i]:-dp[i];
        }
        else
        {
            ll x,y;
            x=h[i-1]-h[i];x=x>=0?x:-x;
            y=h[i-2]-h[i];y=y>=0?y:-y;
            dp[i]=min(dp[i-1]+x,dp[i-2]+y);
        }
    }
    cout<<dp[n]<<"\n";
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    string s;
    cin >> s;
    rep(i, 3){
        if(s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}




Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define setNil(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
#define setNegINF(x) memset((x),192,sizeof(x)) //NegINF=-INF-1
#define setNeg1(x) memset((x),255,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=3005;
int n,dp[N][N];
string s;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>s;
	dp[1][1]=1;
	for(int i=2;i<=n;i++){
		ll sum=0;
		if(s[i-2]=='<'){
			for(int j=1;j<=i;j++){
				dp[i][j]=sum;
				(sum+=dp[i-1][j])%=MOD;
			}
		}
		else{
			for(int j=i;j;j--){
				(sum+=dp[i-1][j])%=MOD;
				dp[i][j]=sum;
			}
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++)(ans+=dp[n][i])%=MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 34176
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    #define double long double
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    void chmax(int &x,const ll y) {x=(x>y?x:y);}
    void chmin(int &x,const ll y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):0;}
    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;
        while(e)
        {
            if(e&1) ans=ans*x%MOD;
            x=x*x%MOD;e>>=1;
        }
        return ans;
    }
    inline int invm(int x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    int fa[N],cnt[N];
    int findfa(int x){return fa[x]==x?x:fa[x]=findfa(fa[x]);}
    struct Nod{int x,y,c;}e[N];bool cmp(Nod a,Nod b){return a.c>b.c;}
    void main()
    {
        int n=qread(),h=qread(),w=qread();
        for(int i=1;i<=n;i++){int x=qread(),y=qread(),c=qread();e[i]=(Nod){x,y,c};}
        sort(e+1,e+n+1,cmp);for(int i=1;i<=h+w;i++) fa[i]=i;
        ll ans=0;
        for(int i=1;i<=n;i++)
        {
            int fx=findfa(e[i].x),fy=findfa(h+e[i].y);
            if(fx!=fy) {
                if(cnt[fx]+cnt[fy]<2){
                    if(cnt[fx])swap(fx,fy);
                    fa[fx]=fy,ans+=e[i].c;
                }
            }
            else if(cnt[fx]==0)
                cnt[fx]=1,ans+=e[i].c;
        }
        write(ans);
    }
};
int main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 9600
import heapq
N,M = map(int,input().split())
A=[-int(i) for i in input().split()]
heapq.heapify(A)
for _ in range(M):
    s = heapq.heappop(A)
    if s % 2 == 0:
        heapq.heappush(A, s//2)
    else:
        heapq.heappush(A, s//2 + 1)
print(-sum(A))

Measured memory_bytes: 73624
while True:
  a, b, c = map(int, input().split())
  if a == b == c == -1:
    break
  if a == -1 or b == -1:
    print('F')
  elif a + b >= 80:
    print('A')
  elif a + b >= 65:
    print('B')
  elif a + b >= 50 or c >= 50:
    print('C')
  elif a + b >= 30:
    print('D')
  else:
    print('F')


Measured memory_bytes: 5592
#include <iostream>

using namespace std;

int main()
{
    int A, B, C;

    cin >> A >> B >> C;

    bool ans = false;

    if (A == 5 && B == 5 && C == 7)
        ans = true;
    else if (A == 5 && B == 7 && C == 5)
        ans = true;
    else if (A == 7 && B == 5 && C == 5)
        ans = true;

    if (ans)
        cout << "YES";
    else
        cout << "NO";

    cout << endl;

    return 0;
}

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


int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < n-k; i++) {
        if (a.at(i) < a.at(i+k)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{	
	ll n,t[50]={};
	cin>>n;
	t[0]=1;
	t[1]=1;
	for(int i=2;i<=44;i++)t[i]=t[i-1]+t[i-2];
	cout<<t[n]<<endl;
	return 0;	
}


Measured memory_bytes: 3104
n=int(input())
t,a=input().split()
t,a=int(t),int(a)
h1=input().split()
h2=[]
for i in h1:
    h2.append(int(i))

d=abs(t-h2[0]*0.006-a)
j=1
for i in range(n-1):
    #print(t-h2[i]*0.006)
    if d>abs(t-h2[i+1]*0.006-a):
        d=abs(t-h2[i+1]*0.006-a)
        j=i+2

print(j)


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

int main() {
  long N,A,B;
  cin>>N>>A>>B;
  if(A>B){
    cout<<0<<endl;
    return 0;
  }
  if(N==1){
    if(A!=B) cout<<0<<endl;
    if(A==B) cout<<1<<endl;
    return 0;
  }
  long ans = (A+(N-1)*B)-(A*(N-1)+B);
  cout<<ans+1<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fd(i,b,a) for(int i=b;i>=a;--i)
#define efo(i,v,u) for(int i=BB[v],u=B[BB[v]][1];i;i=B[i][0],u=B[i][1])
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define cmax(x,y) ((x)<(y)?(x)=(y):(x))
#define cmin(x,y) ((x)>(y)?(x)=(y):(x))
#define mset(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
char ch;
int read(){int n=0,p=1;for(ch=getchar();ch<'0' || ch>'9';ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=1e5+5;
int n,a[N];
int gcd(int x,int y)
{
	if(x%y==0) return y;
	return gcd(y,x%y);
}
bool work()
{
	int cnteven=0,cntodd=0,ps=0;
	fo(i,1,n)
		if(a[i]&1) ++cntodd,ps=i;else ++cnteven;
	if(cnteven&1) return 0;
	if(cntodd==1 && a[ps]>1)
	{
		a[ps]--;
		int t=a[1];
		fo(i,1,n) t=gcd(t,a[i]);
		fo(i,1,n) a[i]/=t;
		return work()^1;
	}
	else return 1;
}
int main()
{
	n=read();
	fo(i,1,n) a[i]=read();
	puts(work()?"Second":"First");
	return 0;
}

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

int main() {
    int n, d;
    cin >> n >> d;
    
    int num_monitor = 2 * d + 1;
    int ans = 0;
    
    if (n % num_monitor == 0) ans = n / num_monitor;
    else ans = n / num_monitor + 1;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int cnt[100001];
int label[100001];
int N, M;
int ans[100001];

int A[100001];
int B[100001];

int parent[100001] = {};

int GetParent(int n)
{
	int cur = n;
	vector<int> history;
	while (true)
	{
		if (parent[cur] == cur)
		{
			for (int h : history)
			{
				parent[h] = cur;
			}
			return cur;
		}
		cur = parent[cur];
		history.push_back(cur);
	}
	return -1;
}

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

	REP(i, M)
	{
		int a, b;
		cin >> a >> b;
		A[i] = a;
		B[i] = b;
	}

	REP(i, N + 1)
	{
		label[i] = i;
		cnt[i] = 1;
		parent[i] = i;
	}

	int fuben = 0;
	for (int i = 1; i < N; i++)
	{
		fuben += i;
	}

	for (int i = M - 1; i >= 0; i--)
	{
		ans[i] = fuben;

		int p1 = GetParent(A[i]);
		int p2 = GetParent(B[i]);

		if (p1 == p2)
		{
			continue;
		}

		int f = cnt[p1] * cnt[p2];
		fuben -= f;

		int min = (A[i] < B[i]) ? A[i] : B[i];
		int max = (A[i] > B[i]) ? A[i] : B[i];

		int max_p = GetParent(max);
		int min_p = GetParent(min);

		cnt[min_p] = cnt[min_p] + cnt[max_p];

		parent[max_p] = min_p;

		
	}

	for (int i = 0; i < M; i++)
	{
		cout << ans[i] << endl;
	}
}









Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "A"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))

int d[]={-1,0,1,0};
int c[]={0,1,0,-1};

const int N=1010;

int m,n,ret;
int dd[N][N];
queue<ii> q;

main()
{
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    fasty;
    cin>>m>>n;
    forinc(i,1,m) forinc(j,1,n)
    {
        char ch; cin>>ch;
        if(ch=='#') q.push({i,j}), dd[i][j]=1;
    }
    while(q.size())
    {
        int u,v; tie(u,v)=q.front(); q.pop();
        ret=max(ret,dd[u][v]);
        forinc(i,0,3)
        {
            int x,y; x=u+d[i], y=v+c[i];
            if(1>x||x>m||1>y||y>n||dd[x][y]) continue;
            dd[x][y]=dd[u][v]+1, q.push({x,y});
        }
    }
    cout<<ret-1;
}


Measured memory_bytes: 12432
fun main(array: Array<String>) {
    val n = readLine()!!.toInt()
    val list = mutableListOf<String>()
    for(i in 0 until n) {
        val s = readLine()!!
        if(i == 0) {
            list.add(s)
            continue
        }
        for(j in list.indices) {
            if(s == list[j]) {
                print("No")
                return
            }
        }
        if(s[0] == list[i-1][list[i-1].length-1]) {
        }
        else {
            print("No")
            return
        }
        list.add(s)
    }
    print("Yes")
}

Measured memory_bytes: 33732
#include <stdio.h>
int main(void){
    int s,a,b;
    
    scanf("%d",&s);
    
    a=s%100;
    b=(s-a)/100;
    
    if(a==0&&b==0){
        printf("NA");
    }else if(a==0&&b>=13){
        printf("NA");
    }else if(b==0&&a>=13){
        printf("NA");
    }else if(a<=12&&b==0){
        printf("YYMM");   
    }else if(a==0&&b<=12){
        printf("MMYY");
    }else if(a<=12&&b<=12){
        printf("AMBIGUOUS");
    }else if(a<=12&&b>=13){
        printf("YYMM");
    }else if(a>=13&&b<=12){
        printf("MMYY");
    }else if(a<=12&&b==0){
        printf("YYMM");   
    }else if(a==0&&b<=12){
        printf("MMYY");
    }else {
        printf("NA");
    }
    
  
   return 0;
}

Measured memory_bytes: 128
#include <cstdio>
using namespace std;
int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a > b) {
		int t = a;
		a = b;
		b = t;
	}
	if (a <= 0 and b >= 0) {
		printf("Zero\n");
		return 0;
	}
	if (a > 0) {
		printf("Positive\n");
		return 0;
	}
	if ((b - a) % 2 == 0) {
		printf("Negative\n");
		return 0;
	}
	else {
		printf("Positive\n");
		return 0;
	}
	return 0;
}

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

int main() {
  long a,b,c;cin>>a>>b>>c;
  long d = c-a-b;
  if (d>0 and 4*a*b < d*d) cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int A, B, C;
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);

    if((A==B)&&(A==C)){
        printf("No");
    }else if((A!=B)&&(A!=C)&&(B!=C)){
        printf("No");
    }else{
        printf("Yes");
    }        
    return 0;
}

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

// ----本問について----
// 問題：Frog2
// 問題文URL：https://atcoder.jp/contests/dp/tasks/dp_b
// 所要時間：
// 学んだこと：
// ------------------

// ----ここから本問のソースコード----

const ll N_MAX = pow(10, 5) + 10;

// グローバル変数（入力）
ll N,K, h[N_MAX], dp[N_MAX];

ll solve(ll i) {               // メモ化再帰（？）
  if (dp[i] != -1) { return dp[i]; } // 計算済みならその値を返す

  if (i == 1) {
    dp[i] = 0;
  } else if (i == 2) {
    dp[i] = abs(h[2] - h[1]);
  } else {
    ll mini = LONG_LONG_MAX;  // 以下のループを回してコストの最小値をとる
    for (ll j = i - 1; j >= max(i - K, (ll)1); j--) {
      mini = min(mini,solve(j) + abs(h[i] - h[j]));
    }
    dp[i] = mini;
  }

  return dp[i];
}

int main() {
  // cout << fixed << setprecision(10);
  cin >> N >> K;
  for (ll i = 1; i <= N; i++) {
    cin >> h[i];
  }
  rep(i, N_MAX) {
    dp[i] = -1; // dpを全部未計算(-1)に初期化
  }
  cout << solve(N) << endl;

  return 0;
}


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

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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

#define MAX 11111

int main(void) {
  vll a;
  cin >> n;
  FOR(i, 0, n) {
	cin >> temp;
	m = max(m, temp);
	a.pb(temp);
  }
  sort(ALL(a));

  temp = lower_bound(ALL(a), m / 2) - a.begin();

  if (llabs((m - a[temp - 1])- a[temp - 1]) > llabs((m - a[temp]) - a[temp])) {
	cout << m << " " << a[temp] << endl;
  }
  else {
	cout << m << " " << a[temp - 1] << endl;
  }

  return 0;
}

Measured memory_bytes: 1400
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	
		int M = sc.nextInt();
		int D = sc.nextInt();
      	int count = 0;

      	int d10,d1,dnum;
      	for(int i = 1;i<=M;i++){
        	for(int j = 1; j<=D;j++){
              d10 = j/10;
              d1 = j - (d10*10);
              dnum = d10*d1;
              if(d10>=2 && d1 >=2){
   	              if(i == dnum){
               		count++;
	              }
              }
            }
        }
		// 出力
		System.out.println(count);
	}
}

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

namespace AtTest.AGC_Challenge
{
    class _008_D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] xs = ReadInts();
            int[][] xIndexes = new int[n][];
            for(int i = 0; i < n; i++)
            {
                xIndexes[i] = new int[2] { xs[i] - 1, i + 1 };
            }
            Array.Sort(xIndexes, (a, b) => a[0] - b[0]);
            Queue<int> que = new Queue<int>();
            for(int i = 0; i < n; i++)
            {
                for(int j = 1; j < xIndexes[i][1]; j++)
                {
                    que.Enqueue(xIndexes[i][1]);
                }
            }
            int[] res = new int[n * n];
            int now = 0;
            int[] cnts = new int[n];
            for(int i = 0; i < n * n; i++)
            {
                if (now < n && i == xIndexes[now][0])
                {
                    if (cnts[xIndexes[now][1] - 1] == xIndexes[now][1] - 1)
                    {
                        res[i] = xIndexes[now][1];
                        cnts[xIndexes[now][1] - 1]++;
                        for (int j = xIndexes[now][1]; j < n; j++)
                        {
                            que.Enqueue(xIndexes[now][1]);
                        }
                        now++;
                    }
                    else
                    {
                        WriteLine("No");
                        return;
                    }
                }
                else
                {
                    if (que.Count > 0)
                    {
                        res[i] = que.Peek();
                        cnts[que.Dequeue() - 1]++;
                    }
                    else
                    {
                        WriteLine("No");
                        return;
                    }
                }
            }

            WriteLine("Yes");
            for(int i = 0; i < n*n; i++)
            {
                Write(res[i]+" ");
            }
            WriteLine();
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;


typedef pair <long long ,long long>	PII;
typedef vector <int>	VI;
typedef vector <PII>    VII;
typedef priority_queue<PII,vector<PII>,greater<PII>> pairMinHeap;
typedef priority_queue<PII> pairMaxHeap;
typedef priority_queue<long long ,vector<long long>,greater<long long>> minHeap;
typedef priority_queue<long long> maxHeap;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;
#define getarr(n,d) for(int i=0;i<n;i++)cin>>d[i];
#define getgraph(n,g) for(int i=1;i<n;i++){int a,b;cin>>a>>b;a--;b--;g[a].push_back(b);g[b].push_back(a);}
#define getpartree(n,tree) for(int i=1;i<n;i++){int a;cin>>a;tree[a-1].push_back(i);}

struct POS{
    int x=0,y=0;
    POS():x(0),y(0){}
    POS(int _x,int _y):x(_x),y(_y){}
};

struct triple{
    int f,s,t;
    triple():f(0),s(0),t(0){}
    triple(int _f,int _s,int _t):f(_f),s(_s),t(_t){}
};

const int INF = 1e9+9;
const long long LINF = 1e17+9;
const long long MD=998244353 ;

inline long long po(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1)ans = (ans*a)%MD;
        a = (a*a)%MD;
        b/=2;
    }
    return ans;
}


const int N=2e3+33;

long long n,m,k,t;
long long arr[N];
string s[N];
int mark[N][N];

PII f(int x,int y){
    mark[x][y]=1;
    int w=0,b=0;
    PII tmp;
    if(s[x][y]=='#'){
        b++;
        if(x+1<n && mark[x+1][y]==0 && s[x+1][y]=='.'){tmp=f(x+1,y);w+=tmp.first;b+=tmp.second;}
        if(x-1>=0 && mark[x-1][y]==0 && s[x-1][y]=='.'){tmp=f(x-1,y);w+=tmp.first;b+=tmp.second;}
        if(y+1<m && mark[x][y+1]==0 && s[x][y+1]=='.'){tmp=f(x,y+1);w+=tmp.first;b+=tmp.second;}
        if(y-1>=0 && mark[x][y-1]==0 && s[x][y-1]=='.'){tmp=f(x,y-1);w+=tmp.first;b+=tmp.second;}
    }else{
        w++;
        if(x+1<n && mark[x+1][y]==0 && s[x+1][y]=='#'){tmp=f(x+1,y);w+=tmp.first;b+=tmp.second;}
        if(x-1>=0 && mark[x-1][y]==0 && s[x-1][y]=='#'){tmp=f(x-1,y);w+=tmp.first;b+=tmp.second;}
        if(y+1<m && mark[x][y+1]==0 && s[x][y+1]=='#'){tmp=f(x,y+1);w+=tmp.first;b+=tmp.second;}
        if(y-1>=0 && mark[x][y-1]==0 && s[x][y-1]=='#'){tmp=f(x,y-1);w+=tmp.first;b+=tmp.second;}
    }
    return {w,b};
}


int main() {
	ios_base::sync_with_stdio(false);cout.tie(nullptr);cin.tie(nullptr);cout << fixed;cout << setprecision(10);
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    long long res=0;
    PII l;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i][j]=='#'&& mark[i][j]==0){
                l=f(i,j);
                res+=l.first*l.second;
                //wis(i,j)what_is(res)
            }
        }
    }
    cout<<res;
    return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

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

  auto max_abs = [&]() {
    int max_a = va.front(), idx = 0;
    for (int i = 0; i < va.size(); ++i) {
      if (abs(max_a) < abs(va[i])) {
        max_a = va[i];
        idx = i;
      }
    }

    return idx;
  };

  int idx = max_abs();
  int max_a = va[idx];
  cout << (n - 1) * 2 << '\n';
  for (int i = 0; i < n; ++i) {
    if (idx != i) {
      cout << idx + 1 << ' ' << i + 1 << '\n';
    }
  }

  if (max_a >= 0) {
    for (int i = 0; i < n - 1; ++i) {
      cout << i + 1 << ' ' << i + 2 << '\n';
    }
  } else if (max_a < 0) {
    for (int i = n - 1; i > 0; --i) {
      cout << i + 1 << ' ' << i << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 3596
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

bool check(const vector<ll>& a, const vector<ll>& b, const vector<ll>& c, ll K) {
  const ll n = a.size();
  assert(b.size() == n);
  assert(c.size() == n);
  map<ll, ll> cnt;
  each(x, a) cnt[x]++;
  each(x, b) cnt[x]++;
  each(x, c) cnt[x]++;
  rep(i, K, K+3*n) if (cnt[i] != 1) return false;
  rep(i, n) if (a[i] + b[i] > c[i]) return false;
  return true;
}

void solve() {
  ll n, K; cin >> n >> K;
  if (K <= (n+1) / 2) {
    vector<ll> a(n), b(n), c(n);
    ll n1 = n/2, n2 = n-n1;
    rep(i, n) c[n-i-1] = K+2*n+i;
    rep(i, n2) {
      a[i] = K+n1+i;
      b[i] = K+2*n-1-2*i;
    }
    rep(i, n1) {
      a[n2+i] = K+i;
      b[n2+i] = K+2*n-2-2*i;
    }
    rep(i, n) {
      cout << a[i] << " " << b[i] << " " << c[i] << endl;
    }
    assert(check(a, b, c, K));
  }
  else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve(long long N, long long A, long long B){
    if(A==0){
        cout << 0 << endl;
        return;
    }
    ll cnt=N/(A+B);
    ll sum=cnt*A;
    if(N%(A+B)>0){
        ll res=N%(A+B);
        if(res>=A){
            sum+=A;
        }else{
            sum+=res;
        }
    }
    cout << sum << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  B - Tax Rate
//
//  Created by Hashizo on 2019/12/01.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {

	ll n;
	cin >> n;


	ll x;
	
	x = n / 1.08;
	
	if (floor((x * 1.08)) == n) {
		cout << x << endl;
	}
	else if	 (floor(((x-1)) * 1.08) == n) {
		cout << x-1 << endl;
	}
	else if	 (floor(((x+1) * 1.08)) == n) {
		cout << x+1 << endl;
	}
	else {
		cout << ":(" << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
//#define P pair<ll, ll>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;


int main() {
  string S, T; cin >> S >> T;
  int N = S.size(), M = T.size();
  vector<vector<int>> dp(N + 1, vector<int>(M + 1, 0));

  rep(i, 0, N){
    rep(k, 0, M){
      if(S[i] == T[k]) dp[i + 1][k + 1] = dp[i][k] + 1;
      else {
        dp[i + 1][k + 1] = max(dp[i + 1][k], dp[i][k + 1]);
      }
    }
  }

  string ans = "";
  while(N > 0 && M > 0){
    if(dp[N][M] == dp[N - 1][M]){
     --N;
    } else if(dp[N][M] == dp[N][M - 1]){
      --M;
    } else {
      ans = S[N - 1] + ans;
      --N, --M;
    }
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 38908
// In The Name Of Allah
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;
 
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
 
const ll MAXN = 1e6 + 10;
const ll N = 4000 + 10;
const ll MN = 200 + 10;
const ll mod = 1e9 + 7;

ll dp[N][N];

int main()	
{
	faster();
	int n;
	cin >> n;
	string g , s , t;
	cin >> g;
	for (int i = 0; i < n; i++)
	{
		s.push_back(g[i]);
	}
	for (int i = 0; i < n; i++)
	{
		t.push_back(g[i + n]);
	}
	map <pair< string, string> , int> m;
	for (int mask = 0; mask < (1 << n); mask++)
	{
		string k , a;
		for (int j = 0; j < n; j++)
		{
			if(mask & (1 << j))
			{
				k.push_back(s[j]);
			}
			else
				a.push_back(s[j]);
		}
		m[{k, a}]++;
	}
	ll ans = 0;
	for (int mask = 0; mask < (1 << n); mask++)
	{
		string k, a;
		for (int i = 0; i < n; i++)
		{
			if(mask & (1 << i))
			{
				k.push_back(t[i]);
			}
			else
				a.push_back(t[i]);
		}
		reverse(k.begin(), k.end());
		reverse(a.begin(), a.end());
		ans += m[{a, k}];
	}
	cout << ans << endl;
}

Measured memory_bytes: 87040
#include <bits/stdc++.h>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
using namespace std;

const int N = (int)(2e5 + 500);

int n;
int a[N], res[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                
    #ifndef _LOCAL          
    #endif // _LOCAL

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

    int all_xor = 0;
    for (int i = 0; i < n - 1; ++i)
        all_xor ^= a[i];

    res[n - 1] = all_xor;

    for (int i = n - 2; i >= 0; --i)
        res[i] = a[i] ^ a[i + 1] ^ res[i + 1];

    for (int i = 0; i < n; ++i)
        cout << res[i] << " ";

    return 0;
}

Measured memory_bytes: 5216
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	strByte := make([]byte, 100000)
	readLen, _ := reader.Read(strByte)
	ans := make([]byte, 0, readLen/2)
	for i := 0; i < readLen; i += 2 {
		ans = append(ans, strByte[i])
	}
	fmt.Println(string(ans))
}

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

int main(){
	long long L, R;
	cin >> L >> R;
	//2019 = 3 * 673
	if(R - L + 1 >= 673) cout << 0 << endl;
	else{
		long long ans = 2019;
		for(long long i = L; i < R; i++){
			for(long long j = i + 1; j <= R; j++){
				long long mod = (i * j) % 2019;
				ans = min(ans, mod);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);
    int ave = accumulate(all(A), 0);

    int min_D = 1000000;
    int pos;
    rep(i, N) {
        if(abs(A.at(i) * N - ave) < min_D) {
            min_D = abs(A.at(i) * N - ave);
            pos = i;
        }
    }
    cout << pos << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;
    cin>>N;
    multiset<int>s;
    rep(i,N){
        int a;cin>>a;s.insert(a);
    }
    
    int M;cin>>M;
    while(M--){
        int a;cin>>a;
        auto it=s.find(a);
        if(it==s.end()){
            cout<<"NO"<<endl;
            return 0;
        }
        s.erase(it);
    }
    cout<<"YES"<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 2333;
const ll MOD = 1e9 + 7;

int N, M;
int S[MAX_N], T[MAX_N];
ll f[MAX_N][MAX_N];

int main() {
    scanf("%d%d", &N, &M);
    for (int i = 1; i <= N; i++) scanf("%d", &S[i]);
    for (int i = 1; i <= M; i++) scanf("%d", &T[i]);
    for (int i = 0; i <= N; i++) f[i][0] = 1;
    for (int i = 0; i <= M; i++) f[0][i] = 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            f[i][j] = (f[i - 1][j] + f[i][j - 1]) % MOD;
            if (S[i] != T[j]) (f[i][j] += MOD - f[i - 1][j - 1]) %= MOD;
        }
    }
    printf("%lld\n", f[N][M]);
}


Measured memory_bytes: 37120
#include<stdio.h>
int main(void)
{
	char s[10];
	char a[10];
	int i,j;
	j=0;
	scanf("%s",s);
	for(i=0;i<10;i++){
		if(s[i]=='0'  || s[i]=='1'){
			a[j]=s[i];
			a[j+1]='\0';
			j++;
		}
		else if(s[i]=='B'){
			if(j!=0){
				a[--j]='\0';
			}
		}
	}
	printf("%s\n",a);
	return 0;
}

Measured memory_bytes: 128