akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	bool flag = 0;
	for(int i=1;i<=1250;i++){
		if((int)(i * 0.08 )== a && (int)(i *0.1)==b){
			cout<<i<<endl;
			flag = 1;
			break;
		}
	}
	if(!flag) cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	private static final String BR = System.getProperty("line.separator");

	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));

			StringBuilder s = new StringBuilder();
			String[] strArray;
			String line = br.readLine();

			while (line.equals("0 0") == false) {
				strArray = line.split("\\s");
				for (int i = 0; i < Integer.parseInt(strArray[0]); i++) {
					for (int j = 0; j < Integer.parseInt(strArray[1]); j++) {
						if (i % 2 == 0) {
							if (j % 2 == 0) {
								s.append("#");
							} else {
								s.append(".");
							}
						} else {
							if (j % 2 == 0) {
								s.append(".");
							} else {
								s.append("#");
							}
						}
					}
					s.append(BR);
				}
				System.out.println(s);
				s.delete(0, s.length());
				line = br.readLine();
			}
			br.close();
		} catch (Exception e) {
			System.err.println(e);
		}
	}
}

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

int main() {
	int x, k;

	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> x;
	
	k = 2;
	if(360%x == 0)
		cout << 360/x << endl;
	else {
		while(1) {
			int tmp = 360*k;
			if(tmp%x == 0) {
				//cout << "tmp=" << tmp << endl;
				cout << tmp/x << endl;
				break;
			}
			else
				k++;
		}
	}

	return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priotity_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
ll n,a,b;

int main(){
	cin >> n >> a >> b;
	cout << (a>b?0:(n==1 and a!=b?0:(n==2?1:(n-2)*b-(n-2)*a+1))) << endl;
	return 0;
}


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

using namespace std;

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

    for(int i = N; i >= 1; i--) {
        for(int j = 2; j*i <= N; j++) {
            b[i] += b[i*j];
        }

        if(b[i]%2 == a[i]) {
            b[i] = 0;
        } else {
            b[i] = 1;
        }
        M += b[i];
    }

    cout << M << endl;
    for(int i = 1; i <= N; i++) {
        if(b[i] == 1) {
            cout << i << " ";
        }
    }
    cout << endl;

}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n;
bool ans[N];

int main(){
    readi(n);
    if(n == 3) return cout <<"2 5 63", 0;

    int i,cnt,m=0;
    for(i = 2, cnt = 0; i <= 30000 and cnt < n-2; i += 2, ++cnt)
        ans[i] = true, m = (m + i) % 3;

    if(m or (n - cnt) & 1){
        for(int j = i-2; j >= 2; j -= 2) if(((m - j) % 3 + 3) % 3 == 0)
            m = 0, ans[j] = false, j = 0, --cnt;
        if((n - cnt) & 1){
            for(; i <= 30000; i += 2) if(i % 3 == 0){
                ++cnt;
                ans[i] = true;
                break;
            }
        }
    }

    i = 3, cnt = n - cnt;
    while(cnt--){
        ans[i] = true;
        i += 6;
    }

    vi v;
    ll sum = 0, gcd = 0;
    lp(i,1,30000) if(ans[i]) v.pb(i), sum += i, gcd = __gcd(gcd, 1ll*i);

    assert(sz(v) == n);
    assert(gcd == 1);
    for(int i : v) assert(__gcd(1ll*i, sum-i) > 1);

    for(int i : v) cout <<i <<" ";
}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;



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

	//input
	int n, m;
	cin >> n >> m;

	vector<int> a;
	for (int i = 0; i < m; i++){
		int ai;
		cin >> ai;
		a.push_back(ai);
	}


	//calc
	if (2 <= m){
		int prev_broken_index = a[0];
		for (int i = 1; i < m; i++){
			if (prev_broken_index + 1 == a[i]){
				cout << "0" << endl;
				return 0;
			}
		}
	}

	int prev = 0;
	int ans = 1;
	int m_index = 0;
	for (int i = 0; i < n;){
		if (m_index < m && i + 1 == a[m_index]){
			prev = ans;
			ans = 0;

			m_index++;
			i++;
		}
		else{
			int next_ans = (prev + ans) % 1000000007;
			prev = ans;
			ans = next_ans;
			i++;
		}

	}



	//ans
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}

double dp[310][310][310];

double calc(auto i, auto j, auto k, auto &N)
{
  if (dp[i][j][k] >= 0) return dp[i][j][k];
  if (i+j+k == 0) return dp[0][0][0] = 0.0;
  if (i == 1 && j == 0 && k == 0) return dp[1][0][0] = N;
  double y1 = 0.0, y2 = 0.0, y3 = 0.0;
  if (k != 0) y3 = (1.0 + calc(i, j+1, k-1, N)) * (double)k/N;
  if (j != 0) y2 = (1.0 + calc(i+1, j-1, k, N)) * (double)j/N;
  if (i != 0) y1 = (1.0 + calc(i-1, j, k, N)) * (double)i/N;
  return dp[i][j][k] = (N*(y3+y2+y1)+N-i-j-k)/(double)(i+j+k);
}

int main()
{
  double N;
  cin >> N;
  vector<double> a(N);
  INPUT(a);
  int ct_1 = 0, ct_2 = 0, ct_3 = 0;
  REPx(x, a)
  {
    if (x == 1) ct_1++;
    if (x == 2) ct_2++;
    if (x == 3) ct_3++;
  }
  memset(dp, -1, sizeof(dp));
  cout << setpre(10) << calc(ct_1, ct_2, ct_3, N) << endl;

  return 0;
}

Measured memory_bytes: 233088
import java.util.Scanner;

public class Main {

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

        int N = scanner.nextInt();
        scanner.nextLine();
        String s = scanner.nextLine();
        char[] c = s.toCharArray();

        int left = 0;
        int right = N-1;
        int answer = 0;
        while(true){
            while(left < N && c[left]!='W') left++;
            while(0 <= right && c[right]!='R') right--;
            if (left < right) {
                answer++;
                left++;
                right--;
            }
            else {
                break;
            }
        }

        System.out.println(answer);
    }

}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
            var firstLine = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToList();
			var n = firstLine[0];
			var t = firstLine[1];

			var costs = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToList();

			var minValue = long.MaxValue;

			var profitDictionary = new Dictionary<long, long>();

			for (int i = 0; i < n; i++)
			{
				minValue = Math.Min(minValue, costs[i]);

				var profit = costs[i] - minValue;
				if(!profitDictionary.ContainsKey(profit))
				{
					profitDictionary.Add(profit, 1);
				}
				else
				{
					profitDictionary[profit]++;
				}
			}

			var maxProfit = profitDictionary.Keys.Max();

			Console.WriteLine(profitDictionary[maxProfit]);
		}
	}
}


Measured memory_bytes: 30304
package main

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

func main() {
	s, t := readS(), readS()
	fmt.Println(t + s)
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 1788
n,k=map(int,input().split())

l=[]
for i in range(n):
    l.append(list(map(int,input().split())))
    
l.sort()

i=0
ans=0
while k>0:
    k=k-l[i][1]
    ans=l[i][0]
    i=i+1
print(ans)

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

int main(){
    int n;
    cin>>n;
    vector<vector<pair<int,int>>> v;
    v.resize(n);
    for(int i=0;i<n;++i){
        int a;
        cin>>a;
        v[i].resize(a);
        for(int j=0;j<a;++j){
            cin>>v[i][j].first>>v[i][j].second;
            v[i][j].first--;
        }
    }
    int ans=0;
    bool out;
    for(int bit=0;bit<(1<<n);++bit){
        //
        out=false;
        for(int i=0;i<n;++i){
            if(!(bit&(1<<i)))continue;
            for(pair<int,int> xy:v[i]){
                int x=xy.first;
                int y=xy.second;
                if(y==1&&!(bit&(1<<x))){
                    out=true;
                    break;
                }
                if(y==0&&(bit&(1<<x))){
                    out=true;
                    break;
                }
            }
            if(out)break;
        }
        if(out)continue;
        //
        int cnt=0;
        for(int i=0;i<n;++i){
            if(bit&(1<<i)){
                cnt++;
            }
            ans=max(ans,cnt);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O2147483647")
//#pragma GCC optimize("inline")
//#pragma GCC optimize("-ffast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("inline-small-functions")
//#pragma GCC optimize("-finline-small-functions")
//#pragma GCC optimize("-fexpensive-optimizations")
//#pragma GCC optimize("-funsafe-loop-optimizations")
//#pragma GCC optimize("inline-functions-called-once")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx")
//#pragma GCC optimze("fast-math")
//#define GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include "testlib.h"
#define rep(i, j, k) for (int i = (int)(j); i<(int)(k); i++)
#define per(i, j, k) for (int i = (int)(k); i>=(int)(j); i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)((x).size())
#define fprd fprintf(stderr,
#define fi first
#define se second
#define endl '\n'
using namespace std;
typedef long long ll;
//#define int ll
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;


const int N=1005;
int a[N],b[N],dp[10*N],h,n;

int main() {
    scanf("%d%d",&h,&n);
    rep(i,0,n) scanf("%d%d",a+i,b+i);
    rep(i,1,h+1) {
        dp[i]=1e9;
        rep(j,0,n) {
            int New=max(0,i-a[j]);
            int Cost=b[j];
            dp[i]=min(dp[i],dp[New]+Cost);
        }
    }
    printf("%d\n",dp[h]);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[100005],f[100004];
int main()
{ 
    int n,k;
    cin>>n>>k;
    for (int i=1;i<=n;++i)
        cin>>a[i];
    for (int i=0;i<=k;++i)
    {
        bool ok=0;
        for (int j=1;j<=n;++j)
        {
            if (i>=a[j])
                if (f[i-a[j]]==0)
                {
                    ok=1;
                    break;
                }
        }
        f[i] = ok;
    }   
    if (f[k]==1) cout<<"First"; else cout<<"Second";
    return 0;
}

Measured memory_bytes: 4016
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
using namespace std;
long long int n,a,b,m[200000];
int erfen(long long int mid)
{
    long long int sum=0;
    for(int i=0; i<n; i++)
    {
        long long int t=(long long int )m[i]-mid*b;
        if(t>0)
        {
            sum+=(int)ceil(t*1.0/(a-b));
            if(sum>mid||sum<0)
            {
                return 0;
            }
        }
    }
    return 1;
}

int main()
{
    while(scanf("%d %d %d",&n,&a,&b)!=EOF)
    {
       long long  int p=0;int i;
        for( i=0;i<n;++i)
        {
            scanf("%d",&m[i]);
            p=max(p,m[i]);
        }
        long long int l=0,r=p;
        while(l<r)
        {
            long long mid=l+r>>1;
            if(erfen(mid)==1)
            {
                r=mid;
            }
            else
            {
                l=mid+1;
            }
        }
        cout<<r<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
N = int(input())
mn = 10 ** 10
mx = -10 ** 10
mn2 = 10 ** 10
mx2 = -10 ** 10
qs = [tuple(map(int, input().split())) for _ in range(N)]
qs.sort()
for i in range(N):
  x, y = qs[i]
  mn = min(mn, x + y)
  mx = max(mx, x + y)
  mn2 = min(mn2, x - y)
  mx2 = max(mx2, x - y)
print(max(abs(mx2 - mn2), abs(mx - mn)))

Measured memory_bytes: 102340
//   HVARDHANSINGH   //
 
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
 
#define ll      long long
#define F       first
#define S       second
#define endl    "\n"

const ll M =    500006;
const int mod = 1000000007;

ll binExp(ll x, ll n)
{
	if(n==0)	return 1;
	else if(n%2==0)			return binExp((x*x), n/2);
	else					return (x*binExp((x*x), (n-1)/2));
}

void solve()
{
	ll n;	cin>>n;
	vector<double> v(n);
	for(int i=0; i<n; i++)	cin>>v[i];
	
	double den = binExp(2ll, n-1);
	
	double nu = 0;
	
	sort(v.begin(), v.end());
	
	double p = binExp(2, n-2);
	
	for(int i=n-1; i>0; i--)
	{
		nu+= p*v[i];
		p/=2;
	}
	nu+= v[0];
	// cout<<nu<<" "<<den<<endl;
	
	double ans = nu/den;
	
	printf("%.10f", ans);
	
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int T = 1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[int(input())for _ in range(n)]
if n==2:print(abs(a[0]-a[1]));exit()
f=[-1]
for i in range(1,n-1-(n%2==0)):
  if i%2:f.append(2)
  else:f.append(-2)
if n%2:f+=[-1]
else:f+=[-2,1]
b=[]
c=[]
for i in f:
  b.append(i)
  c.append(-i)
b.sort()
c.sort()
sb=sc=0
a.sort()
for i in range(n):
  sb+=a[i]*b[i]
  sc+=a[i]*c[i]
print(max(sb,sc))


Measured memory_bytes: 9932
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
      String a=sc.nextLine();
      String po[]=a.split(" ",0);
      System.out.println(po[0].substring(0,1)+po[1].substring(0,1)+po[2].substring(0,1));
    }
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

map<ll, int>  prime_factorization_map(ll x) {
  map<ll, int> res;
  for(ll i = 2; i*i <= x; ++i) {
    while(x % i == 0) {
      if(res.find(i) == res.end()) res[i] = 0;
      ++res[i];
      x /= i;
    }
  }
  if(x != 1) res[x] = 1;

  return res;
}
int main()
{
  ll n, p;
  cin >> n >> p;
  auto primes = prime_factorization_map(p);
  ll ans = 1;
  for(auto x : primes) {
    ans *= (ll)pow(x.first, x.second/n);
  }
  cout << ans << endl;
}


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

int main()
{
	int n;
	int a[200][3];

	cin >> n;

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

	for (int j = 0; j < 3; j++) {
		vector<pair<int, int> > b;

		for (int i = 0; i < n; i++)
			b.push_back(make_pair(a[i][j], i));

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

		for (int i = 0; i < n - 1; i++) {
			if (b[i].first == b[i + 1].first) {
				a[b[i].second][j] = 0;
				a[b[i + 1].second][j] = 0;
			}
		}
	}

	for(int i = 0; i < n; i++)
		cout << a[i][0] + a[i][1] + a[i][2] << endl;

	return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 100005

//const int INF = 1e9 + 7;


int main(){

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

	ll res = 0;

	for (int digit = 28; digit >= 0; digit--)
	{
		int bekihigh = 1 << (digit + 1);
		int bekilow = 1 << (digit);
		for (int i = 0; i < n; i++)
		{
			a[i] %= bekihigh;//2^(k+1)の余りを取る
			b[i] %= bekihigh;
		}
		sort(b.begin(), b.end());

		ll num = 0;

		for (int i = 0; i < n; i++)
		{
			num += lower_bound(b.begin(), b.end(), 2 * bekilow - a[i]) - lower_bound(b.begin(), b.end(), bekilow - a[i]) + lower_bound(b.begin(), b.end(), 4 * bekilow - a[i]) - lower_bound(b.begin(), b.end(), 3 * bekilow - a[i]);
		}

		if (num & 1) {
			res += bekilow;
		}
	}
	cout << res << endl;


	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef long double ld;

int MOD=1000000007;


int main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    while(1){
        C=C-B;
        if(C<=0){cout << "Yes" << endl; return 0;}
        A=A-D;
        if(A<=0){cout << "No" << endl; return 0;}
    }
    }


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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vec;
typedef std::vector<ld> vecld;
typedef std::vector< std::vector<ll> > vecvec;
typedef std::pair<ll, ll> pr;
typedef std::vector< pr > vpr;

#define tin ll t;cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define sz(a) (ll)((a).size())
#define pb push_back
#define trvect(c,i) for(vector<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trset(c,i) for(set<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trmap(c,i) for(map<ll,ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define present(c,x) ((c).find(x) != (c).end())
#define ff first
#define ss second
#define mp make_pair
#define sq(a) (a)*(a)
#define cube(a) (a)*(a)*(a)
#define cnti(x) (__builtin_popcount(x)) //number of set bits in x
#define mod 1000000007
#define N 100005

ll qpow (ll n, ll m) {
	ll ret = 1;
	while (m) {
		if (m & 1) ret = ret * n % mod;
		n = n * n % mod;
		m >>= 1;
	}
	return ret;
}
ll inv (ll a) {
	return qpow(a, mod - 2);
}

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



int main(){
    
    // double r;
    // cin>>r;
    // double c = 2*M_PI*r;
    // cout<<fixed;
    // // cout<<M_PI;
    // cout<<setprecision(10)<<c<<"\n";
    ll n;
    cin>>n;
    ll arr[n],freq[n+1]={0};
    rep(i,0,n-1) cin>>arr[i],freq[arr[i]]++;

    repp(i,1,n)
    	cout<<freq[i]<<"\n";
}


Measured memory_bytes: 6748
package main

import "fmt"

func main() {
	var a int
	fmt.Scan(&a)
	var kotae int
	if a % 2 == 0 {
		kotae = a / 2 * a / 2
	}else {
		kotae = (a + 1) / 2 * (a - 1) / 2
	}
	fmt.Println(kotae)
	
}



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

int main() {
  int n;
  cin >> n;
  LL sum = 0;
  vector<LL> a(n);
  for (int i = 0; i < n; i ++) {
    cin >> a.at(i);
    sum += a.at(i);
  }

  LL x = 0, ans = 1000000000000000000;
  for (int i = 0; i < n - 1; i ++) {
    x += a.at(i);
    ans = min(ans, abs(sum - x * 2));
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC122_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string strACGT;
            int ACGTcount = 0;
            int maxCount = 0;
            for (int i = 0; i < S.Length; i++)
            {
                strACGT = S.Substring(i, 1);
                if (strACGT == "A" || strACGT == "C" || strACGT == "G" || strACGT == "T")
                {
                    ++ACGTcount;
                }
                else
                {
                    if (maxCount < ACGTcount)
                    {
                        maxCount = ACGTcount;
                    }
                    ACGTcount = 0;
                }
            }
            if (maxCount < ACGTcount)
            {
                maxCount = ACGTcount;
            }
            Console.WriteLine(maxCount.ToString());
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
int main(void)
{
  int mount[10];
  int top[3];
  int i;
  for (i = 0; i < 3; i++){
      top[i] = 0;
  }
  for (i = 0; i < 10; i++){
      scanf("%d", &mount[i]);
      if (mount[i] > top[0]){
	  	top[2] = top[1];
	  	top[1] = top[0];
        top[0] = mount[i];
      }
      else if (mount[i] > top[1]){
	  	top[2] = top[1];
        top[1] = mount[i];
      }
      else if (mount[i] > top[2]){
        top[2] = mount[i];
      }
  }
  for (i = 0; i < 3; i++){
      printf("%d\n", top[i]);
  }
  return (0);
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))


def count_2(x, num):
    if x % 2 == 0:
        return count_2(x // 2, num + 1)
    else:
        return num


ans = 0
for i in range(n):
    ans += count_2(a[i], 0)

print(ans)


Measured memory_bytes: 9968
#include <iostream>

int main(int argc, char **argv){
    int K, S;
    std::cin >> K >> S;

    int cnt = 0;
    for(int x = 0; x <= K; x++){
        for(int y = 0; y <= K; y++){
            int z = S - (x + y);
            if(0 <= z && z <= K){
                cnt++;
            }
        }
    }

    std::cout << cnt << std::endl;
}


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

using namespace std;
int main ()
{
    string S;
    cin >> S;
    for(int i=0;i<3;i++){
        switch(S[i]){
            case '1':
            cout << '9';
            break;
            case '9':
            cout << '1';
            break;
            default:break;
        }
    }
    cout << endl;
    return 0;
    
}












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

int A[1000000], n;

int binarySearch(int key) {
	int left = 0;
	int right = n;
	int mid;
	while(left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

int main(){
	int i, q, k, sum = 0;

	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &A[i]);
	}

	scanf("%d", &q);
	for(i = 0; i < q; i++){
		scanf("%d", &k);
		if(binarySearch(k)) sum++;
	}
	printf("%d\n", sum);

	return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
 
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);
 
int main () {
  ios::sync_with_stdio(0); cin.tie(0);
 
  int TT = 1;
//  cin >> TT;
  while (TT--) {
    ll n;
    cin >> n;
    string s;
    while (n) {
      s += 'a' + ((n-1) % 26);
      n = (n-1)/26;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;

    
  }
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code
vector<int> v[3];

int main()
{
  v[0] = {1, 3, 5, 7, 8, 10, 12};
  v[1] = {4, 6, 9, 11};
  v[2] = {2};

  int a, b;
  cin>>a>>b;
  int f;
  int s;
  for(f = 0; f < 3; f++)
  {
    if(find(v[f].begin(), v[f].end(), a) != v[f].end()) break;
  }
  for(s = 0; s < 3; s++)
  {
    if(find(v[s].begin(), v[s].end(), b) != v[s].end()) break;
  }
  if(s == f) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 12160
#include <stdio.h>
#include <stdlib.h>

const int MOD = 1000000007;

int main () {
	int n, m;
	long long tmp;
	long long dxs=0, dys=0;
	scanf ("%d %d", &n, &m);
	for (int i=0; i<n; i++) {
		scanf ("%lld", &tmp);
		dxs += (2*i - n + 1)*tmp % MOD;
		dxs %= MOD;
	}
	for (int i=0; i<m; i++){
		scanf ("%lld", &tmp);
		dys += (2*i - m + 1)*tmp % MOD;
		dys %= MOD;
	}

	printf ("%lld\n", dxs*dys%MOD);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define repe(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define mst(a, b)   memset((a), (b), sizeof(a))
#define gc() gutchar()
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pr;
typedef long long ll;
const double eps = 1e-5;
const int inf = 0x3f3f3f3f;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
const ll mod = 1e9+7;
const int N = 2e4+5;

int dp[N];

int main()
{
	int h, n, res = inf;
	cin >> h >> n;
	mst(dp, 0x3f);
	dp[0] = 0;
	rep(i, 0, n){
		int v, w;
		scanf("%d %d", &v, &w);
		for (int j = v; j < N; j++)
			dp[j] = min(dp[j], dp[j-v] + w);
	}
	for (int j = N - 1; j >= h; j--)
		res = min(res, dp[j]);
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer a = nil -> next;
  for(a = nil -> next; a != nil ;a = a -> next){
      if(a -> key == key) return a;
  }
  return a;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t -> prev -> next = t -> next;
  t -> next -> prev = t -> prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer a,b;
  a = nil -> prev;
  b = a -> prev;
  b -> next = nil;
  nil -> prev = b;
  free(a);
}

void delete(int key){
  NodePointer a;
  a = listSearch(key);
  if ( a == nil ) return;
  a -> prev -> next = a -> next;
  a -> next -> prev = a -> prev;
  free(a);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x -> next = nil -> next; 
  nil -> next -> prev = x;
  nil -> next = x;
  x -> prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 32964
//
// Created on 2020/05/31.
//


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

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


vector<pair<ll,ll>>prime_factorize(ll n){
    vector<pair<ll,ll>>ret;
    for (ll i = 2; i * i < n ; ++i) {
        if(n % i == 0){
            ll ex = 0;//指数
            while(n % i == 0){
                ex++;
                n /= i;
            }
            ret.push_back({i, ex});
        }
    }
    if(n != 1){
        ret.push_back({n,1});
    }
    return ret;
    //example n = 12, ret = [[2,2],[3,1]と返す
}

int main() {
    ll n;
    cin>>n;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    vector<int>sum(1000);
    sum[1] = 1;
    for (int i = 2; i < 1000; ++i) {
        sum[i] = sum[i - 1] + i;
    }

    auto p = prime_factorize(n);

    ll ans = 0;

    for(auto t_p : p){
        int u = 1000;
        int l = 0;
        int i = (u + l)/2;
        while(!(sum[i] <= t_p.second && t_p.second < sum[i + 1])){
            if(t_p.second < sum[i]){
                u = i;
                i = (u + l)/2;
            }else{
                l = i;
                i = (u+l)/2;
            }
        }
        ans += i;
    }


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


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

double a[501],sum[501];
double dp[501][501];
int main(){
    int n,m;
    cin>>n>>m;
    rep(i,n) cin>>a[i];
    rep(i,n) sum[i+1]+=a[i]+sum[i];
    rep(i,n)rep(j,n)dp[i][j]=-1000100010;
    dp[0][0]=0;
    rep(i,n)rep(j,m)if(dp[i][j]>=0){
        FOR(k,i,n){
            dp[k+1][j+1]=max(dp[k+1][j+1],dp[i][j]+(sum[k+1]-sum[i])/(k-i+1));
        }
    }
    double mx=0.0;
    FOR(i,1,m+1) mx=max(mx,dp[n][i]);
    cout<<fixed<<setprecision(12)<<mx<<endl;
    return 0;
}


Measured memory_bytes: 5256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#define long long ll
using namespace std;

int main()
{
	int n,m;
	while(cin>>n>>m)
	{
		int k=pow(2,m);
		cout<<(m*1900+(n-m)*100)*k<<endl;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
class fastio {
public:
    fastio() {
        ios_base::sync_with_stdio(false);
        cout.tie(nullptr);
        cin.tie(nullptr);
    }
} __fastio;
void solve() {
  int n; cin >> n;
  int a[n];
  for(int i=0; i<n; i++) 
    cin >> a[i];
  
  int ans = 0;
  for(int i=1; i<n-1; i++) {
    if(a[i] > a[i-1] && a[i] < a[i+1])
      ans++;
    else if(a[i] < a[i-1] && a[i] > a[i+1])
      ans++;
  }
  cout << ans << endl;
}
int main() {
  __fastio;
  solve();
  return 0;
}

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

int main() {

  int n;
  cin >> n;

  vector<vector<int>> count(n, vector<int>(27));
  for (int i = 0; i < n; i++) {
    string S;
    cin >> S;
    for (int j = 0; j < S.size(); j++){
      count[i][(int) S[j] - 'a']++;
    }
  }

  vector<int> answer(27);

  for (int i = 0; i < 27; i++) {
    int count_ = 100;
    for (int j = 0; j < n; j++) {
      count_ = min(count_, count[j][i]);
    }
    if (count_ == 100) {
      answer[i] = 0;
    } else {
      answer[i] = count_;
    }
  }

  for (int i = 0; i < 27; i++) {
    for (int j = 0; j < answer[i]; j++) {
      cout << char(i + 'a');
    }
  }

  cout << endl;

  return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n);
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end());
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define reverse(a)      reverse((a).begin(), (a).end());
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d);
#define outl(d)         std::cout<<(d)<<"\n";
#define Yes()           printf("Yes\n");
#define No()            printf("No\n");
#define YES()           printf("YES\n");
#define NO()            printf("NO\n");
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int a, b; cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    outl("Possible")
  } else {
    outl("Impossible")
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12)

  solve();
}


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

int main () {
  int N, M;
  cin >> N >> M;
  
  vector <int> L(M);
  vector <int> R(M);
  for (int i = 0; i < M;i++) cin >> L.at(i) >> R.at(i);
  
  sort(L.begin(),L.end());
  sort(R.begin(),R.end());
  if (L.at(M-1) > R.at(0)) cout << 0 << endl;
  else cout << R.at(0) - L.at(M-1) +1 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(n,v) for(int64_t i=0;i<(n);i++){cin >> (v).at(i);}

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  string s = "ACGT";
  I n;
  cin >> n;
  if (n==3){
    cout << 61 << endl;
    return 0;
  }
  map<vector<char>, I> cur;
  REP(i,s.size()){
    REP(j,s.size()){
      REP(k,s.size()){
        REP(l,s.size()){
          vector<char> tmp(4);
          string s2 = "";
          s2 += s.at(i);
          s2 += s.at(j);
          s2 += s.at(k);
          s2 += s.at(l);
          tmp.at(0) = s.at(i);
          tmp.at(1) = s.at(j);
          tmp.at(2) = s.at(k);
          tmp.at(3) = s.at(l);
          if (s2.find("AGC")==string::npos && s2.find("GAC")==string::npos && s2.find("ACG")==string::npos &&
              s2.find("AGGC")==string::npos && s2.find("ATGC")==string::npos && s2.find("AGTC")==string::npos){
            cur[tmp] = 1;
          }
        }
      }
    }
  }
  I i = 5;
  while (true){
    if (i <= n){
      map<vector<char>, I> tmpV;
      //for(auto [key,value]: cur){
      for(auto itr = cur.begin(); itr != cur.end(); ++itr){
        auto key = itr->first;
        auto value = itr->second;
        REP(i,s.size()){
          vector<char> tmp(4);
          string s2;
          s2 += key.at(1);
          s2 += key.at(2);
          s2 += key.at(3);
          s2 += s.at(i);
          tmp.at(0) = key.at(1);
          tmp.at(1) = key.at(2);
          tmp.at(2) = key.at(3);
          tmp.at(3) = s.at(i);
          if (s2.find("AGC")==string::npos && s2.find("GAC")==string::npos && s2.find("ACG")==string::npos &&
              s2.find("AGGC")==string::npos && s2.find("ATGC")==string::npos && s2.find("AGTC")==string::npos){
            if (cur.find(tmp) == cur.end()){
              tmpV[tmp] = value % MOD;
            }else{
              tmpV[tmp] = (tmpV[tmp] + value) % MOD;
            }
          }
        }
      }
      cur = tmpV;
    }else{
      break;
    }
    i++;
  }
  I t=0;
  //for(auto [key,value]: cur){
  for(auto itr = cur.begin(); itr != cur.end(); ++itr){
    auto key = itr->first;
    auto value = itr->second;
    t = (t + value) % MOD;
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

		int n = sc.nextInt();

		String[] spi = new String[n];
		for (int i = 0; i < spi.length; i++) {
			String s = sc.next();
			int p = sc.nextInt();
			spi[i] = s + "_" + (1100 - p) + "_" + (i + 1);
		}
		sc.close();

		Arrays.sort(spi);

		for (String s : spi) {
			System.out.println(s.split("_")[2]);
		}
	}
}


Measured memory_bytes: 22996
#include <cstdio>
#include <algorithm>
using namespace std;
#define maxn 100010
int a[maxn],b[maxn],c[maxn],d[maxn];
int main(){
	int A,B,M,i,x,y,z,mna=200010,mnb=200010,mnd=200010;
	scanf("%d%d%d",&A,&B,&M);
	for(i=1;i<=A;i++)scanf("%d",&a[i]),mna=min(mna,a[i]);
	for(i=1;i<=B;i++)scanf("%d",&b[i]),mnb=min(mnb,b[i]);
	for(i=1;i<=M;i++){
		scanf("%d%d%d",&x,&y,&z);
		d[i]=a[x]+b[y]-z;
		mnd=min(mnd,d[i]);
	}
	if(mnd<mna+mnb)printf("%d\n",mnd);
	else printf("%d\n",mna+mnb);
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<utility>

using namespace std;

char s[101];
int x;
const pair<int,bool> fail(-1,false);

pair<int,bool> exp();
pair<int,bool> mexp();
pair<int,bool> elm();

bool valid(int x){
  return 0<=x&&x<1<<10;
}

pair<int,bool> elm(){
  if(s[x]=='('){
    x++;
    auto e=exp();
    if(!valid(e.first)||!e.second||s[x]!=')')return fail;
    x++;
    return make_pair(e.first,false);
  }else if(s[x]=='0'||s[x]=='1'){
    int n=0;
    while(s[x]=='0'||s[x]=='1'){
      n=n*2+s[x]-'0';
      if(!valid(n))return fail;
      x++;
    }
    return make_pair(n,false);
  }else{
    return fail;
  }
}
    
pair<int,bool> mexp(){
  auto f=elm();
  if(!valid(f.first))return fail;
  while(s[x]=='*'){
    x++;
    auto l=elm();
    if(!valid(l.first))return fail;
    f.first*=l.first;
    if(!valid(f.first))return fail;
    f.second=true;
  }
  return f;
}

pair<int,bool> exp(){
  auto f=mexp();
  if(!valid(f.first))return fail;
  while(s[x]=='+'||s[x]=='-'){
    int sign=(s[x]=='+')?1:-1;
    x++;
    auto l=mexp();
    if(!valid(l.first))return fail;
    f.first+=sign*l.first;
    if(!valid(f.first))return fail;
    f.second=true;
  }
  return f;
}

int dfs(){
  for(int i=0;s[i];i++){
    if(s[i]=='.'){
      int m=-1;
      for(const char *p="01+-*()";*p;p++){
	s[i]=*p;
	int r=dfs();
	if(valid(r)){
	  m=max(m,r);
	}
      }
      s[i]='.';
      return m;
    }
  }
  x=0;
  auto r=exp().first;
  return s[x]?-1:r;
}

int main(){
  cin>>s;
  cout<<dfs()<<endl;
}

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

using namespace std;
typedef long long ll;
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
#define max(a,b) (a)>=(b)? (a) : (b) 
#define fileio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
const double pi = 3.14159265358979323846;



#define F first
#define S second
const int MX = 1e5 + 10, MD = 1e9 + 7;
long long n, m, a[MX], ans, tmp, mx, t1, t2, ind, res;
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > mx) {
			mx = a[i];
			ind = i;
		}
	}
	ans = mx + 1;
	for (ll i = 0; i < pow(10, 10); )
	{
		i++;
	}
	if (mx % 2 == 0) {
		t1 = mx / 2;
		for (int i = 0; i < n; i++) {
			if (ind == i)continue;
			if (abs(a[i] - t1) < ans) {
				ans = abs(a[i] - t1);
				res = a[i];
			}
		}
	}
	else {
		t1 = mx / 2;
		t2 = mx / 2 + 1;
		for (int i = 0; i < n; i++) {
			if (ind == i)continue;
			if (abs(a[i] - t1) < ans) {
				ans = abs(a[i] - t1);
				res = a[i];
			}
			else if (abs(a[i] - t2) < ans) {
				ans = abs(a[i] - t2);
				res = a[i];
			}
		}
	}
	cout << mx << " " << res;

}






Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

const int N = 1e5+5;
int n;
int color[N];
vector<pii> adj[N];

void bfs(int root){
	color[root] = 0;
	queue<int> q;
	q.push(root);
	while(!q.empty()){
		int v = q.front();
		q.pop();
		for(pii e : adj[v]){
			int u = e.fs;
			int w = e.sc;
			if(color[u] == -1){
				if(w%2 == 0) color[u] = color[v];
				else color[u] = color[v]^1;
				q.push(u);
			}
		}
	}
}

int main(){
	fastio;
	memset(color, -1, sizeof color);
	cin >> n;
	for(int i = 1; i < n; i++){
		int a, b, w;
		cin >> a >> b >> w;
		adj[a].emplace_back(b, w);
		adj[b].emplace_back(a, w);
	}
	bfs(1);
	for(int i = 1; i <= n; i++) cout << color[i] << '\n';
	return 0;
}

Measured memory_bytes: 6784
#include<iostream>
#include<string>

using namespace std;

int main() {
	int a, b;
	string op;
	while (1) {
		cin >> a >> op >> b;
		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;
		}
		else if (op == "?") {
			break;
		}
	}
}

Measured memory_bytes: 1208