akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

hun=[]
hun.append(a)
hun.append(b)
hun.append(c)
hun.append(d)
hun.append(e)

hun.sort()

risso=hun[0]
if n<=risso:
  print(5)
else:
  if n%risso==0:
    print(5+(n//risso)-1)
  else:
    print(5+(n//risso)+1-1)


Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

// 約数の列挙
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) {
                res.push_back(n / i);
            }
        }
    }
    return res;
}

int main(){
  ll N,M; cin>>N>>M;

  vector<ll> v;
  v = divisor(M);
  v.pb(1);
  v.pb(M);
  SORT(v);

  ll ans = max((ll)POSU(v,M/N)-1 ,(ll)0);
  cout<<v[ans]<<endl;

}


Measured memory_bytes: 256
def isSquare(x)
    ok = 0
    ng = x + 1
    while ng - ok > 1
        mid = (ng + ok) / 2
        if mid * mid <= x
            ok = mid
        else
            ng = mid
        end
    end
    return ok * ok == x
end

x = gets.chomp.split.join.to_i
puts isSquare(x) ? "Yes" : "No"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}

int main(){
    int n,m,x;cin >> n >> m >> x;
    vi c(n);
    vector<vi> a(n, vi(m,0));
    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    int ans = INF;
    for(int i=0;i<(1<<n);++i){
        bitset<12> bit(i);
        vi num(m, 0);
        int tmp = 0;
        rep(j,n) if(bit.test(j)){
            rep(k,m) num[k] += a[j][k];
            tmp += c[j];
        }
        bool ok = true;
        rep(j,m) if(num[j] < x){
            ok = false;
            break;
        }
        if(!ok) continue;
        chmin(ans, tmp);
    }
    if(ans == INF){
        ans = -1;
    }
    cout << ans << "\n";
}

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

int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a+b+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  sort(A.begin(), A.end());
  
  int ans = A[0];
  int temp;
  for (int i = 0; i < N; i++) {
    int a = ans;
    int b = A[i];
    while (a > 0) {
      temp = a;
      a = b % a;
      b = temp;
    }
    ans = b;
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
private val scanner = java.util.Scanner(System.`in`)

private fun readInts(n: Int) = Array(n) { scanner.nextInt() }
private fun readLongs(n: Int) = Array(n) { scanner.nextLong() }
private fun readLineInts() = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
private fun readLineLongs() = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()

fun main(args: Array<String>) {
    val (H, W) = readLineInts()
    val S = Array(H) { readLine()!! }

    S.forEachIndexed { indexLine, line ->
        line.forEachIndexed { indexRow, ch ->
            print(
                if (ch == '.') {
                    var sum = 0
                    for (x in -1..1) for (y in -1..1) {
                        if (x == 0 && y == 0) continue
                        try {
                            if (S[indexLine + x][indexRow + y] == '#') ++sum
                        } catch (ignored: Throwable) {
                            continue
                        }
                    }
                    sum
                } else ch
            )
        }
        println("")
    }
}

Measured memory_bytes: 38368
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <stack>
//#include <deque>
#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	vll p(n) ;
	for(auto &i:p) cin >> i ;
	ll ans = 0 ;
	for(int i=1;i<(1<<n);i++){
		bitset<25> bit(i) ;
		ll num = -1 ;
		bool ok = true ;
		for(int j=0;j<n;j++){
			if(bit[j]){
				if(num==-1) num = p.at(j) ;
				else num = lcm(num,p.at(j)) ;
			}
		}
		for(int j=0;j<n;j++){
			if(!bit[j]){
				if(num%p.at(j)==0){
					ok = false ;
					break ;
				}
			}
		}
		ans += ok ;
	}
	cout << ans << endl ;
}



Measured memory_bytes: 3136
#include <iostream>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,j) for(int i=0;i<n;i++)

int main(){
	int a, b, c;
	int t = 0;
	cin >> a >> b >> c;
	if(b < a){
		t = a; a = b; b = t;
	}
	if(c < b){
		t = b; b = c; c = t;
	}
	if(b < a){
		t = a; a = b; b = t;
	}
	cout << a << " " << b << " " << c << "\n";

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}


int main() {
    string a[51];
    ll h,w;
    cin>>h>>w;
    rep(i, h) {
        cin>>a[i];
    }
    bool flg = true;
    rep(i, h) {
        rep(j, w){
            char c=a[i][j];
            if (c=='#') {
                bool b = false;
                if(i<h-1){
                    char x = a[i+1][j];
                    if(x == '#') b = true;
                }
                if(j<w-1){
                    char x = a[i][j+1];
                    if(x == '#') b = true;
                }
                if(i>0){
                    char x = a[i-1][j];
                    if(x == '#') b = true;
                }
                if(j>0){
                    char x = a[i][j-1];
                    if(x == '#') b = true;
                }
                if(b==false)flg=false;
            }
        }
    }
    pr(flg ? "Yes": "No");
    
}


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

int main(){
    string s;
    cin >> s;
    int price=700;
    if(s.at(0)=='o') price += 100;
    if(s.at(1)=='o') price += 100;
    if(s.at(2)=='o') price += 100;
    cout << price << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(' ');
                int p = int.Parse(temp[0]);
                int q = int.Parse(temp[1]);

                List<int> xs = new List<int>();
                List<int> ys = new List<int>();

                int n = 0, m = 0, pos = 0;

                while (true)
                {
                    n = p / q;
                    m = p % q;

                    if (m == 0)
                    {
                        ys.Add(n);
                        break;
                    }

                    pos = -1;

                    for (int i = 0; i < xs.Count; i++)
                    {
                        if (xs[i] == m)
                        {
                            pos = i;
                            break;
                        }
                    }

                    if (pos >= 0)
                    {
                        ys.Add(n);
                        break;
                    }

                    xs.Add(m);
                    ys.Add(n);

                    p = m * 10;
                }

                if (pos == -1)
                {
                    for (int i = 1; i < ys.Count; i++)
                    {
                        sb.Append(ys[i]);
                    }
                    sb.Append("\n");
                }
                else
                {
                    for (int i = 1; i < ys.Count; i++)
                    {
                        sb.Append(ys[i]);
                    }
                    sb.Append("\n");

                    for (int i = 0; i < ys.Count - 1; i++)
                    {
                        if (i < pos) sb.Append(" ");
                        else sb.Append("^");
                    }
                    sb.Append("\n");
                }
            }
            Console.Write(sb);
        }
    }
}

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

const long long inf = 1LL << 61;
struct Dinic {
    struct edge {int to, rev; long long flow, w; int id;};
	int n, s, t, mxid;
	vector<int> d, flow_through; vector<int> done;
	vector<vector<edge>> g;
	Dinic() {}
	Dinic(int _n) {
		n = _n + 10; mxid = 0;
		g.resize(n);
	}
	void add_edge(int u, int v, long long w, int id = -1) {
		edge a = {v, (int)g[v].size(), 0, w, id};
		edge b = {u, (int)g[u].size(), 0, 0, -2};//for bidirectional edges cap(b) = w
		g[u].emplace_back(a);
		g[v].emplace_back(b);
		mxid = max(mxid, id);
	}
	bool bfs() {
		d.assign(n, -1); d[s] = 0;
		queue<int> q; q.push(s);
		while (!q.empty()) {
			int u = q.front(); q.pop();
			for (auto &e: g[u]) {
				int v = e.to;
				if (d[v] == -1 && e.flow < e.w) d[v] = d[u] + 1, q.push(v);
			}
		}
		return d[t] != -1;
	}
	long long dfs(int u, long long flow) {
		if (u == t) return flow;
		for (int &i = done[u]; i < (int)g[u].size(); i++) {
			edge &e = g[u][i];
			if (e.w <= e.flow) continue;
			int v = e.to;
			if (d[v] == d[u] + 1) {
				long long nw = dfs(v, min(flow, e.w - e.flow));
				if (nw > 0) {
					e.flow += nw;
					g[v][e.rev].flow -= nw;
					return nw;
				}
			}
		}
		return 0;
	}
	long long max_flow(int _s, int _t) {
		s = _s; t = _t;
		long long flow = 0;
		while (bfs()) {
			done.assign(n, 0);
			while (long long nw = dfs(s, inf)) flow += nw;
		}
		flow_through.assign(mxid + 10, 0);
        for(int i = 0; i < n; i++) for(auto e: g[i]) if(e.id >= 0) flow_through[e.id] = e.flow;
		return flow;
	}
};
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i];
	long long ans = 0;
	for (int i = 1; i <= n; i++) ans += max(0, a[i]);
	Dinic F(n + 3);
	int s = n + 1, t = n + 2;
	for (int i = 1; i <= n; i++) {
		if (a[i] < 0) F.add_edge(s, i, -a[i]);
		else F.add_edge(i, t, a[i]);
		for (int j = i + i; j <= n; j += i) {
			F.add_edge(i, j, inf);
		}
	}
	cout << ans - F.max_flow(s, t) << '\n';
    return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
long long MAX(long long a,long long b){
    if(a>b){
        return a;
    }else{
        return b;
    }
}
int main()
{   
    long long n,W;
    scanf("%lld%lld",&n,&W);
    long long w[n],v[n];
    for(int i=0;i<n;i++){
        scanf("%lld%lld",&w[i],&v[i]);
    }
    long long dp[n+1][W+2];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=W+1;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=W;j++){
            dp[i+1][j]=dp[i][j];
            if(j>=w[i]){
            dp[i+1][j]=MAX(dp[i][j-w[i]]+v[i],dp[i][j]);
            }else{
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    printf("%lld",dp[n][W]);
    return 0;
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
} 

/* compress
    (X1,Y1),(X2,Y2)という二点で表されるもの（長方形や直線など）について、行か列の片方（X1とX2 or Y1とY2）を座標圧縮する（副作用）
    返り値: ソートされ重複要素を除いた値
    計算量: O(n log n)
*/
template <typename T>
vector<T> compress(vector<T> &C1, vector<T> &C2) {
    vector<T> vals;
    int N = (int)C1.size();
    for (int i = 0; i < N; i++) {
        for (T d = 0; d <= 1; d++) {  // for (T d = 0; d <= 0; d++) でも良い
            T tc1 = C1[i] + d;
            T tc2 = C2[i] + d;
            vals.push_back(tc1);
            vals.push_back(tc2);
        }
    }
    // ソート
    sort(vals.begin(), vals.end());
    // 隣り合う重複を削除(unique), 末端のゴミを削除(erase)
    vals.erase(unique(vals.begin(), vals.end()), vals.end());
    for (int i = 0; i < N; i++) {
        C1[i] = lower_bound(vals.begin(), vals.end(), C1[i]) - vals.begin();
        C2[i] = lower_bound(vals.begin(), vals.end(), C2[i]) - vals.begin();
    }
    return vals;
}
 
int main(){
    ll n;cin >> n;
    vl x1(n),x2(n),y1(n),y2(n);
    rep(i,n)cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    vl x=compress(x1,x2),y=compress(y1,y2);
    ll h=x.size(),w=y.size();
    //cout << h <<" " << w <<endl;
    vector<vector<int>> g(h,vector<int>(w));
    rep(i,n){
        g[x1[i]][y1[i]]++;g[x2[i]][y2[i]]++;
        g[x1[i]][y2[i]]--;g[x2[i]][y1[i]]--;
    }
    rep(i,h-1){
        rep(j,w){
            g[i+1][j]+=g[i][j];
        }
    }
    rep(i,h){
        rep(j,w-1){
            g[i][j+1]+=g[i][j];
        }
    }
    ll ans=0;
    rep(i,h){
        rep(j,w){
            if(g[i][j]){
                ans+=(x[i+1]-x[i])*(y[j+1]-y[j]);
            }
        }
    }
    cout << ans <<endl;
}


Measured memory_bytes: 253324
#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int n,m,k,x[N],y[N],r[N],c[N],mr,mc,sr,sc,s;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
		r[x[i]]++;
		c[y[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(r[i]>mr)
		{
			mr=r[i];
			sr=1;
		}
		else if(r[i]==mr)
			sr++;
	}
	for(int i=1;i<=m;i++)
	{
		if(c[i]>mc)
		{
			mc=c[i];
			sc=1;
		}
		else if(c[i]==mc)
			sc++;
	}
	for(int i=1;i<=k;i++)
		if(r[x[i]]==mr&&c[y[i]]==mc)
			s++;
	printf("%d\n",mr+mc-(sr*sc==s));
	return 0;
}

Measured memory_bytes: 8488
#include <iostream>
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(1){
    c-=b;
    if(c<=0){
      cout << "Yes";
      break;
    }
    a-=d;
    if(a<=0){
      cout << "No";
      break;
    }
  } 
  return 0;
}

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

int d, n, m, shops[100001], order, ans = 0;

void solve(){
	int lb = 0, ub = n;
	while(ub - lb > 1){
		int mid = (ub + lb) / 2;
		if(shops[mid] > order){
			ub = mid;
		} else{
			lb = mid;
		}
	}
	
	ans += min(order - shops[lb], shops[ub] - order);
	
	return;
}

int main() {
	while(cin >> d >> n >> m && d){
		for(int i = 1; i < n; i++){
			cin >> shops[i];
		}
		shops[n] = d;
		
		sort(shops, shops + n + 1);
		
		for(int i = 0; i < m; i++){
			cin >> order;
			solve();
		}
		
		cout << ans << endl;
		
		ans = 0;
	}
	return 0;
}

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

using namespace std;

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

    int max = -1;
    int min = 1001;

    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;

        if (a < min)
            min = a;
        if (max < a)
            max = a;
    }

    cout << (max - min) << endl;

    return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int l=s.length();
    int v=l;
    int p=0;
    for(int i=0;i<l;i+=2){
        if(s.at(i)=='L'){
            p++;
        }
    }
    for(int i=1;i<l;i+=2){
        if(s.at(i)=='R'){
            p++;
        }
    }
    if(p>0){
        cout<<"No";
    }
   else if(p==0){
        cout<<"Yes";
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;

int main(){
	ll n,p;
	map<ll,ll> yakusuu;
	cin >> n >> p;
	while(p%2==0){
		yakusuu[2]++;
		p/=2;
	}
	for(ll i=3;i*i<=p;i+=2){
		while(p%i==0){
			yakusuu[i]++;
			p/=i;
		}
	}
	yakusuu[p]++;
	ll ans=1;
	for(auto itr=yakusuu.begin();itr!=yakusuu.end();itr++){
		ll x=itr->second/n;
		while(x--) ans*=itr->first;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 5e5 + 7;
int sx, sy, tx, ty, anscnt, nodecnt = 0;
int ans[MAXN];
struct point {
	int id, x, y;
} p[MAXN];
struct node {
	int pos, l, r;
} nodes[MAXN];
bool cmpx(point p1, point p2) {
	return p1.x < p2.x;
}
bool cmpy(point p1, point p2) {
	return p1.y < p2.y;
}
int make2D(int l, int r, int dep) {
	if (l >= r) return -1;
	int mid = (l + r) >> 1, cur = nodecnt++;
	if (dep % 2) sort(p + l, p + r, cmpy);
	else sort(p + l, p + r, cmpx);
	nodes[cur].pos = mid;
	nodes[cur].l = make2D(l, mid, dep + 1);
	nodes[cur].r = make2D(mid + 1, r, dep + 1);
	return cur;
}
void find(int cur, int dep) {
	int x = p[nodes[cur].pos].x, y = p[nodes[cur].pos].y;
	if (sx <= x && x <= tx && sy <= y && y <= ty) ans[anscnt++] = p[nodes[cur].pos].id;
	if (dep % 2) {
		if (nodes[cur].l != -1 && sy <= y) find(nodes[cur].l, dep + 1);
		if (nodes[cur].r != -1 && y <= ty) find(nodes[cur].r, dep + 1);
	}
	else {
		if (nodes[cur].l != -1 && sx <= x) find(nodes[cur].l, dep + 1);
		if (nodes[cur].r != -1 && x <= tx) find(nodes[cur].r, dep + 1);
	}
}
int main() {
    int n, q;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
    	p[i].id = i;
    	scanf("%d%d", &p[i].x, &p[i].y);
	}
	int root = make2D(0, n, 0);
	scanf("%d", &q);
	while (q--) {
		anscnt = 0;
		scanf("%d%d%d%d", &sx, &tx, &sy, &ty);
		find(root, 0);
		sort(ans, ans + anscnt);
		for (int i = 0; i < anscnt; i++) {
			printf("%d\n", ans[i]);
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 14064
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
double a,b,b2,p=3.14159265358979323846;
    scanf("%lf",&a);
    b=a*a*p;
    b2=2*a*p;
    printf("%.6f %.6f",b,b2);
    return 0;
}

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

using namespace std;

static const uint m_max = 50;
bool m[m_max+2][m_max+2];

typedef unsigned int uint;
typedef unsigned long long ll;
typedef pair<uint, uint> Pos;

const uint dx[] = { 2, 1, 0, 1 };
const uint dy[] = { 1, 2, 1, 0 };
uint h, w;

uint wfs(Pos s, Pos g)
{
	uint c[m_max+2][m_max+2];
	for(uint i = 1; i <= h; ++i)
		for(uint j = 1; j <= w; ++j)
            c[i][j] = UINT_MAX;

	queue<Pos> q;
	c[s.second][s.first] = 0;
	q.push(s);
	while ((q.front().first != g.first)||(q.front().second != g.second)) {
		// cerr << q.front().second << ", " << q.front().first;
		for(uint i = 0; i < 4; ++i) {
			// Pos n;
			uint nx, ny;
			nx = q.front().first + dx[i] - 1;
			ny = q.front().second + dy[i] - 1;
			if ( m[ny][nx] && (c[ny][nx] == UINT_MAX)) {
				// cerr << ": push " << nx << ", " << ny << endl;
				c[ny][nx] = c[q.front().second][q.front().first]+1;
				q.push(make_pair(nx, ny));
			}
		}

		q.pop();
		if (q.empty())
			return UINT_MAX;
	}

	return c[g.second][g.first];
}

int main(int, char**)
{
	uint n;
	uint ans = 0;
	uint nb = 0;
	cin >> h >> w;

	for (uint i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (uint j = 0; j < w; j++) {
			if (s[j] == '.') {
				m[i+1][j+1] = true;
			} else {
				++nb;
			}
		}
	}

	ans = wfs(make_pair((uint)1, (uint)1), make_pair(w, h));
	if (ans < UINT_MAX)
		cout << h*w-1-nb-ans << endl;
	else
		cout << -1 << endl;
	return 0;
}



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

#define FOR(i , num) for(i = 0; i < num; i++)
#define REP(i, n) for(int i = 0;i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;

int main()
{
    int N, M, K, i, k;

    int a, b;

    cin >> a >> b;
    cout << a * b << endl;

    return 0;   
}

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

namespace CSharpSample01
{
	class Program
	{

		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());

			var ansDic = new Dictionary<string, int>() {
				{ "AC",0 },
				{ "WA",0 },
				{ "TLE",0 },
				{ "RE",0 },
			};
			for(int i = 0; i < N; i++)
			{
				var input = Console.ReadLine();
				ansDic[input]++;
			}

			Console.WriteLine($"AC x {ansDic["AC"]}");
			Console.WriteLine($"WA x {ansDic["WA"]}");
			Console.WriteLine($"TLE x {ansDic["TLE"]}");
			Console.WriteLine($"RE x {ansDic["RE"]}");

		}
	}
}

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

int main() {
  string S;
  cin >> S;
  int Ans = 0;
  
  for (int i = 0; i < S.size() / 2; i++) {
    if (S.at(i) != S.at(S.size() - i - 1)) {
      Ans++;
    }
  }
  
  cout << Ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int ransu(int);
int ruijou(int);

main(){
  int i, n, j, num;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%d", &num);

    printf("Case %d:\n", i+1);
    for(j=0;j<10;j++){
      num=ransu(num);
      printf("%d\n", num);
    }
  }
  return 0;
}

int ransu(int x){
  int data[10];
  int i, x2, temp, t, ans;

  temp=x2=x*x;

  for(i=7;i>=0;i--){
    t=ruijou(i);
    data[i]=temp/t;
    temp-=data[i]*t;
  }

  ans=data[5]*1000+data[4]*100+data[3]*10+data[2];
  return ans;
}

int ruijou(int a){
  int i, sum=1;

  for(i=0;i<a;i++){
    sum*=10;
  }

  return sum;
}

Measured memory_bytes: 0
import sys
import math
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()

x = math.ceil(N / 1.08)
if math.floor(x * 1.08) == N:
    print(x)
else:
    print(":(")



Measured memory_bytes: 38384
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9

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

int N;
ll h[100010];

ll dp[100010];

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

    for(int i=0;i<100010;++i) dp[i]=N;
    
    dp[0]=0;
    
    for(int n=0;n<N;n++){
        for(int pow6=1;n+pow6<=N;pow6*=6){
            dp[n+pow6]=min(dp[n+pow6],dp[n]+1);
        }
        for(int pow9=1;n+pow9<=N;pow9*=9){
            dp[n+pow9]=min(dp[n+pow9],dp[n]+1);
        }
    }
    
    cout<<dp[N]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

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

    int attack = 0;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        attack += temp;
    }

    if (attack >= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int m;
    scan(m);
    auto ans = 24 - m + 24;
    writeln(ans);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){
    ll n,d;
    cin >> n >> d;
     
    ll cnt = 0;
    rep(i,0,n){
        ll x,y;
        cin >> x >> y;
        if(x*x+y*y <= d*d) cnt++;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
long long gcd(long long a,long long b){
    while(a&&b){
        if(a>b)a = a%b;
        else b = b%a;
    }
    return a+b;
}
int main()
{
    int n,x;
    std::cin>>n>>x;
    std::vector<int> dist(n);
    for(int i=0;i<n;i++){
        int tmp;
        std::cin>>tmp;
        dist[i] = std::abs(tmp-x);
    }
    int g = gcd(dist[0],dist[1]);
    for(int i=1;i<n-1;i++){
        g = gcd(g,dist[i]);
    }
    std::cout<<g<<std::endl;
}

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

int main() {
  int n, a = 0, b;
  cin >> n;
  b = n;
  while(b > 0){
    a += b % 10;
    b /= 10;
  }
  if(n % a == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): return k.join(list(map(str, lst)))
INF = float('inf')

def solve():
    n = II()
    S = list(input())

    if n % 2 == 0:
        h = n // 2
        if S[:h] == S[h:]:
            print('Yes')
            return
    print('No')


if __name__ == '__main__':
    solve()


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

int main()
{
  int n;
  int s[1000];
  double E_x,E_x2;

  while(1){
    cin >> n;
    if(n==0)
      break;
    for(int i=0;i<n;i++)
      cin >> s[i];

    E_x=0;
    E_x2=0;
    for(int i=0;i<n;i++)
      {
	E_x+=s[i];
	E_x2+=s[i]*s[i];
      }
    E_x/=n;
    E_x2/=n;
    cout.precision(10);
    cout.setf(ios::fixed);
    cout << sqrt(E_x2-E_x*E_x) << endl;

  }
  return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<typeinfo>
using namespace std;

int main() {
	int n,m,x;
	cin >> n>>m>>x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));

	int min_sum=500000001;
		for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
		for (int bit = 0; bit < (1 << n); bit++) {
			bool flag = true;
			vector<int> undst(m, 0);
			int sum = 0;
			for (int i = 0; i < n; i++) {
				if (bit & (1 << i)) {
					for (int j = 0; j < m; j++) {
						undst[j] += a[i][j];
					}
					sum += c[i];
				}
			}
			for (int j = 0; j < m; j++) {
				if (undst[j] < x) {
					flag = false;
					break;
				}
			}
			if (flag&&min_sum>sum) {
				min_sum = sum;
			}
		}
		if (min_sum > 500000000) {
			cout << "-1";
		}
		else {
			cout << min_sum;
		}
}

Measured memory_bytes: 3636
package main

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

func main() {
	scanner.Split(bufio.ScanBytes)
	a := getInt()
	b := getInt()
	c := getInt()
	d := getInt()

	ans := ""
	for i := 0; i < 2; i++ {
		for j := 0; j < 2; j++ {
			for k := 0; k < 2; k++ {
				tmp := a
				if i == 0 {
					tmp += b
				} else {
					tmp -= b
				}

				if j == 0 {
					tmp += c
				} else {
					tmp -= c
				}

				if k == 0 {
					tmp += d
				} else {
					tmp -= d
				}
				if tmp == 7 {
					ans = solve(i, j, k, a, b, c, d)
				}
			}
		}
	}
	fmt.Println(ans)
}

func solve(i, j, k int, s ...int) string {
	ans := itoa(s[0])

	ans += string('+'+i*2) + itoa(s[1])
	ans += string('+'+j*2) + itoa(s[2])
	ans += string('+'+k*2) + itoa(s[3])

	ans += "=7"

	return ans
}

func itoa(n int) string {
	return strconv.Itoa(n)
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
import math
n = int(input())
T = [0]*n
A = [0]*n
for i in range(n):
    T[i], A[i] = map(int,input().split())

a = 1
b = 1
for ti, ai in zip(T,A):
    #n = max(math.ceil(a/ti),math.ceil(b/ai))
    n = max((a+ti-1)//ti,(b+ai-1)//ai)
    a = n*ti
    b = n*ai
    #print(a,b)
print(a+b)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
const int N=3e5+5,mod=1e9+7,ch[2][7]={{5,3,2,4,3,6,5},{1,2,2,1,3,0,5}};
int i,j,f[N][7];
char c[N];
inline void add(int&x,const int&y){
	x+=y-mod;
	x+=x>>31&mod;
}
int main(){
	scanf("%s",c+1);f[0][0]=1;
	for(i=1;c[i];++i)for(j=0;j<7;++j){
		if(c[i]!='0'){
			add(f[i][ch[1][j]],f[i-1][j]);	
		}
		if(c[i]!='1'){
			add(f[i][ch[0][j]],f[i-1][j]);
		}
	}
	printf("%d\n",(f[i-1][1]+f[i-1][2])%mod);
	return 0;
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll n;
 cin>>n;
 n--;
 vector<char> ans;

 while(n>=0){
  ans.push_back( 'a'+n%26 );
  n/=26;
  n--;
  //if(n%26==0)break;
 }
 for(int i=ans.size()-1;i>=0;i--)cout<<ans[i];
 cout<<endl;
    return 0;
}


Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

int main(){	
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt_a=0;
	int cnt_b=0;
	vector<int> v(s.size(),0);
	for(int i=0;i<s.size();i++){
		if(s[i]=='(')cnt_b++;
		else cnt_a++;
		v[i]=cnt_a-cnt_b;
	}
	vector<int> x(v.size(),0);
	cnt_a=cnt_b=0;
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]==')')cnt_b++;
		else cnt_a++;
		x[i]=cnt_a-cnt_b;
	}
	string t;
	int mx=*max_element(v.begin(),v.end());
	for(int i=0;i<mx;i++){
		t+='(';
	}
	s=t+s;
	mx=*max_element(x.begin(),x.end());
	for(int i=0;i<mx;i++){
		s+=')';
	}
	cout << s << endl;	
	return 0;
}


Measured memory_bytes: 3596
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

def binary_search(n,li):
    low = 0
    high = len(li)-1
    while low <= high:
        mid = (low+high)//2
        if li[mid] == n:
            return True
        elif n < li[mid]:
            high = mid -1
        else:
            low = mid + 1
    return False
n = int(input())
a = list(map(int,input().split()))
t = int(input())
u = list(map(int,input().split()))
cnt = 0
a.sort()
for i in range(len(u)):
    if binary_search(u[i],a):
        cnt += 1
print(cnt)


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  string s;
  cin >> s;

  rep(i, s.length())
  {
    if (s[i] == '9')
      cout << 1;
    else
      cout << 9;
  }
  return 0;
}


Measured memory_bytes: 3564
import java.util.*;
import java.util.Scanner;

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

        int n = sc.nextInt();

        int[] digits = new int[3];

        for (int i = 2; i >= 0; i--) {
           digits[i] = n % 10;
           if (digits[i] == 1) {
               digits[i] = 9;
           } else {
               digits[i] = 1;
           }
           n = n / 10;
        }
        System.out.println(digits[0] + "" + digits[1] + "" + digits[2]);
    }
}

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

int main(){
  int N, L, X;
  cin >> N >> X;

  int sum = 0;
  int ans = 1;

  for(int i = 1; i <= N; i++){
    cin >> L;
    sum += L;
    if(sum > X){
      break;
    }
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)

int n,R=0,G=0,Y=0;
bool done[204][204][204][3];
int r[404],g[404],y[404],memo[204][204][204][3],bitree[404],c[204][204][204][3];


void update(int p, ll v){
	while(p<=n){
		bitree[p] += v;
		p += (p&(-p));
	}
}

int query(int p){
	int v = 0;
	while(p){
		v += bitree[p];
		p -= (p&(-p));
	}
	return v;
}

int solve(int i, int j, int k, int col){
	int l;
	bool f[3]={true,true,true};
	if(done[i][j][k][col]){
		return memo[i][j][k][col];
	}
	done[i][j][k][col] = true;
	memo[i][j][k][col] = INF;
	if(i==R && j==G && k==Y){
		memo[i][j][k][col] = 0ll;
		return memo[i][j][k][col];
	}
	f[col] = false;
	if(i==R){
		f[0] = false;
	}
	if(j==G){
		f[1] = false;
	}
	if(k==Y){
		f[2] = false;
	}
	if(f[0]){
		memo[i][j][k][col] = min(memo[i][j][k][col],solve(i+1,j,k,0)+c[i][j][k][0]);
	}
	if(f[1]){
		memo[i][j][k][col] = min(memo[i][j][k][col],solve(i,j+1,k,1)+c[i][j][k][1]);
	}
	if(f[2]){
		memo[i][j][k][col] = min(memo[i][j][k][col],solve(i,j,k+1,2)+c[i][j][k][2]);
	}
	return memo[i][j][k][col];
}

int main(void){
	int i,j,k;
	string s;
	ll ans;
	fill(done[0][0][0],done[204][0][0],false);
	cin >> n;
	cin >> s;
	for(i=0; i<n; ++i){
		if(s[i]=='R'){
			r[R] = i+1;
			++R;
		}else if(s[i]=='G'){
			g[G] = i+1;
			++G;
		}else{
			y[Y] = i+1;
			++Y;
		}
	}
	if(R>200 || G>200 || Y>200){
		cout << -1 << endl;
		return 0;
	}
	for(i=0; i<R; ++i){
		c[i][G][Y][0] = 0;
	}
	for(j=0; j<G; ++j){
		c[R][j][Y][1] = 0;
	}
	for(k=0; k<Y; ++k){
		c[R][G][k][2] = 0;
	}
	for(i=0; i<R; ++i){
		for(j=0; j<G; ++j){
			for(k=0; k<Y; ++k){
				c[i][j][k][0] = r[i] - query(r[i]) - 1;
				c[i][j][k][1] = g[j] - query(g[j]) - 1;
				c[i][j][k][2] = y[k] - query(y[k]) - 1;
				update(y[k],1);
			}
			c[i][j][Y][0] = r[i] - query(r[i]) - 1;
			c[i][j][Y][1] = g[j] - query(g[j]) - 1;
			for(k=0; k<Y; ++k){
				update(y[k],-1);
			}
			update(g[j],1);
		}
		for(j=0; j<G; ++j){
			update(g[j],-1);
		}
		update(r[i],1);
	}
	for(j=0; j<G; ++j){
		for(k=0; k<Y; ++k){
			c[R][j][k][1] = g[j] - query(g[j]) - 1;
			c[R][j][k][2] = y[k] - query(y[k]) - 1;
			update(y[k],1);
		}
		for(k=0; k<Y; ++k){
			update(y[k],-1);
		}
		update(g[j],1);
	}
	for(i=R-1; i>=0; --i){
		update(r[i],-1);
		for(k=0; k<Y; ++k){
			c[i][G][k][0] = r[i] - query(r[i]) - 1;
			c[i][G][k][2] = y[k] - query(y[k]) - 1;
			update(y[k],1);
		}
		for(k=0; k<Y; ++k){
			update(y[k],-1);
		}
	}
	ans = (min(solve(0,0,0,0),min(solve(0,0,0,1),solve(0,0,0,2))));
	cout << ((ans<INF)?ans:(-1ll)) << endl;
	return 0;
}


Measured memory_bytes: 138376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) sort(v.begin(), v.end())
typedef long long ll;
using Graph = vector<vector<int>>;

int main()
{
  int a, b, t;
  cin >> a >> b >> t;
  int cnt = 0;
  for (int i = a; i < t + 0.5; i = i + a)
  {
    cnt += b;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int sum = 0;
    int n = sc.nextInt();
    int [][] a = new int [3][n];
    for(int i =0; i < n; i++){
      a[0][i] = sc.nextInt();
      }
    for(int i =0; i < n; i++){
      a[1][i] = sc.nextInt();
      }
    for(int i =0; i < n; i++){
        if((i+1)==n){
          a[2][i]=0;
        }else{
          a[2][i] = sc.nextInt();
        }
      }
    for(int i = 0; i < n; i++){
      sum += a[1][i];
    }
    for(int i = 0;i < n -1;i++){
      if(((a[0][i])-(a[0][i + 1])) == -1){
        sum += a[2][a[0][i]-1];
      }
    }
    System.out.println(sum);
  }
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

map<ll, ll> mp;

void prime_fact(int n)
{
    for (int i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            n /= i;
            mp[i]++;
        }
    }
    if (n != 1)
        mp[n]++;
}

ll f[100060], invf[100060];
ll p = 1e9 + 7;

ll mod_pow(ll x, ll n, ll p)
{
    if (n == 0)
        return 1;
    ll res = mod_pow(x * x % p, n / 2, p);
    if (n & 1)
        res = res * x % p;
    return res;
}

void init()
{
    f[0] = 1;
    invf[0] = 1;
    for (ll i = 1; i <= 100050; i++)
    {
        f[i] = f[i - 1] * i % p;
        invf[i] = (mod_pow(i, p - 2, p) * invf[i - 1]) % p;
    }
}

ll mod_conv(ll n, ll k)
{
    ll tmp = invf[n - k] * invf[k] % p;
    return f[n] * tmp % p;
}

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

    init();

    prime_fact(m);
    ll ans = 1;

    for (auto x : mp)
    {
        ans = ans * mod_conv(n - 1 + x.second, x.second) % p;
        // ans *=  mod_conv(n - 1 + x.second, x.second) % p; でwrongとなるのはなぜ？
    }

    OP(ans);

    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define PI 3.141592653589
using namespace std;

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

  int cnt =0, ans=0;

  for(int i=0; i<s.size(); i++){
    if(s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G'){
      cnt++;
    }
    else{
      ans = max(cnt, ans);
      cnt = 0;
    }
  }
  ans = max(cnt, ans);
  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
 
 
int main(){
    ll a,b; char op; cin >> a >> op >> b;
    if(op == '+') cout << a+b << endl;
    else cout << a-b << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = 2000001;
        int count = 0;
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            if (min > tmp) {
                min = tmp;
                count++;
            }
        }
        System.out.println(count);
    }
}

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

int main(){
    int count;
    int n,x;
    while(1){
        count = 0;
        cin >> n >> x;
        if(n == 0) break;
        int i, j, k;
        for(i=1; i <= n ; i++){
            
            for(j=i+1; j<=n; j++){
              
                for(k=j+1; k <= n; k++ ){
                    if(i+k+j>x)break;
                    if(i+j+k == x){
                        count++;
                        break;
                    }
                }
            }
        }
        cout << count << endl;
    }

    return 0;
}


Measured memory_bytes: 3080
//youtubeの解説動画を見て書きました。
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int[][] c = new int[3][3];
    int[] rx = new int[3];
    int[] ry = new int[3];
    boolean flag = true;

    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
        c[i][j] = scan.nextInt();
      }
    }

    ry[0] = 0;
    for(int j = 0; j < 3; j++){rx[j] = c[0][j] - ry[0];}
    for(int j = 1; j < 3; j++){ry[j] = c[j][0] - rx[0];}

    outside:for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
        if(rx[j]+ry[i] != c[i][j]){
          flag = false;
          System.out.println("No");
          break outside;
        }
      }
    }

    if(flag){System.out.println("Yes");}
  }
}
//aを決めてしまえば他も決まるという発想は合っていたが、
//aの決め方が理解できていなかったなという感じ。
/*outside:for(int i = 0; i < 3; i++){
  int a = 101;
  for(int j = 0; j < 3; j++){
    a = Math.min(c[i][j], a);
  }
  if(i == 0){
    for(int j = 0; j < 3; j++){
      r[j] = c[i][j] - a;
    }
  }
  if(i > 0){
    for(int j = 0; j < 3; j++){
      if(r[j] != c[i][j]-a){
        flag = false;
        System.out.println("No");
        break outside;
      }
    }
  }
}

if(flag == true){System.out.println("Yes");}*/


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

ll gcd(ll a, ll b){
	if(a<b) swap(a,b);
    if(b==0) return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
	return a*b/gcd(a, b);
}

int main(){
	ll a, b;
	cin >> a >> b;
	cout << lcm(a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using GraphI = vector<vector<int>>;
using GraphC = vector<vector<char>>;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  string S;
  cin >> S;
  int ans = INF;
  rep(i, 0, S.size() - 2) {
    int x = stoi(S.substr(i, 3));
    ans = min(ans, abs(753 - x));
  }
  cout << ans << endl;
  return 0;
}


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

#define F(i,a,b) for(int i=a;i<b;i++)

using namespace std;

int n,x;

int main()
{
	cin>>n>>x;
	int m[n+5];
	F(i,0,n)scanf("%d",&m[i]);
	
	int ans=0;
	F(i,0,n)x-=m[i];
	ans+=n;
	sort(m,m+n);
	
	ans+=x/m[0];
	
	cout<<ans;	
	return 0;
}

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

ll N,K;
vector< ll > A(200000);

// 各 Ai を a で割っていって、K 個以下に分割できたら true
// K 個より分割が多くなるなら false
bool check(ll k){
  ll divn = 0;
  REP(i,N) {
    divn += (A[i]-1) / k;
    if ( divn > K ) return false;
  }
  return true;
}

int main(){
  cin >> N >> K;
  REP(i,N) {
    cin >> A[i];
    A[i] *= 100;
  }
  ll l = 1;
  ll r = 100000000000;
  while ( l+1 < r ) {
    ll mid = (l + r) / 2;
//    cout << l << " " << mid << " " << r << " : ";
    if ( check( mid ) )
      r = mid;
    else
      l = mid;
//    cout << " -> " << l << " " << r << endl;
  }
  cout << ((r+99)/100) << endl;
}


Measured memory_bytes: 4708
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	int n, k;
	cin >> n >> k;
	if (n%k==0) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

import javax.xml.crypto.Data;

import java.math.*;
import java.awt.geom.*;
import java.io.*;
     
     
public class Main {
	static int W;
	static int H;
	static int N;
	static boolean[][] fld;
	static int[] vx = new int[] {0,1,0,-1};
	static int[] vy = new int[] {1,0,-1,0};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int r = sc.nextInt();
			int n = sc.nextInt();
			if(r == 0 && n == 0) break;
			int[] L = new int[50];
			int[] R = new int[50];
			for(int i = 0; i < n; i++) {
				int xa = sc.nextInt();
				int xb = sc.nextInt();
				int h = sc.nextInt();
				L[xa + 20] = Math.max(h, L[xa + 20]);
				R[xb + 20] = Math.max(h, R[xb + 20]);
				for(int j = xa + 21; j < xb + 20; j++) {
					L[j] = Math.max(h, L[j]);
					R[j] = Math.max(h, R[j]);
				}
			}
			double t = Integer.MAX_VALUE;
			
			for(int i = 0; i < 50; i++) {
				int x = i-20;
				int y = Math.min(L[i], R[i]);
				int D = 4 * (r + y)*(r + y) - 4 * (x * x + y * y + 2 * r * y);
				if(D <= 0) continue; 
				double tt = (2 * (r + y) - Math.sqrt(4 * (r + y)*(r + y) - 4 * (x * x + y * y + 2 * r * y))) / 2 + 0.0000000000000001;
				t = Math.min(tt, t);
			}
			System.out.printf("%.20f\n",t);
			
			
			
			
		}
	}
}

Measured memory_bytes: 37444