akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


void Warshall_Floyd(ll N, vector<vector<ll>> &g) {
	repn(k, N) {
		repn(i, N) {
			repn(j, N) {
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}
}


int main() {

	cout << fixed << setprecision(15);

	double L;
	cin >> L;

	double h = L / 3.0;
	double ans = h * h*h;

	cout << ans;


	

	system("PAUSE");

}


Measured memory_bytes: 504
#include <iostream>
#define ERA_MAX 300000
#define ROO_MAX 547
using namespace std;
bool Eratos[300000];

int main()
{
	Eratos[1] = 0;
	for (int i = 7; i - 1 < ERA_MAX; i += 7)
		Eratos[i - 1] = true;
	for (int i = 7; i + 1 < ERA_MAX; i += 7)
		Eratos[i + 1] = true;
	for (int i = 7; i - 1 < ROO_MAX; i += 7) {
		if (Eratos[i - 1]) {
			for (int j = 7; (i - 1) * (j - 1) < ERA_MAX; j += 7)
				Eratos[(i - 1) * (j - 1)] = false;
			for (int j = 7; (i - 1) * (j + 1) < ERA_MAX; j += 7)
				Eratos[(i - 1) * (j + 1)] = false;
		}
		if(Eratos[i + 1]) {
			for (int j = 7; (i + 1) * (j - 1) < ERA_MAX; j += 7)
				Eratos[(i + 1) * (j - 1)] = false;
			for (int j = 7; (i + 1) * (j + 1) < ERA_MAX; j += 7)
				Eratos[(i + 1) * (j + 1)] = false;
		}
	}
	int n;
	while (cin >> n, n != 1) {
		cout << n << ":";
		for (int i = 7; i - 1 < ERA_MAX; i += 7) {
			if (Eratos[i - 1] && n % (i - 1) == 0)
				cout << " " << i - 1;
			if (i + 1 < ERA_MAX && Eratos[i + 1] && n % (i + 1) == 0)
				cout << " " << i + 1;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1452
#include<stdio.h>
int main()
{
    int N;
    scanf("%d",&N);
    if(N==1){
        printf("Hello World\n");



    }else if(N==2){

    int A,B;
    scanf("%d",&A);
    scanf("%d",&B);
    printf("%d\n",A+B);


    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 e[4];
  cin >> e[0] >> e[1] >> e[2] >> e[3];
  sort(e, e + 4);
  if (e[0] == e[1] && e[2] == e[3])
    cout << "yes" << endl;
  else
    cout << "no" << endl;
  return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair <int, int> pp;
#define MAXN 1050005
#define MP make_pair
#define PB push_back
#define A first
#define B second
const ll INF = 2e9;
const ll MOD = 1e9+7;
const int MAGIC = 100;
int N;
int V[MAXN];
ll P[MAXN];
ll X[MAXN];
int nxt[MAXN]; // {closest non-zero to the left}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for(int i=1; i<=N; i++) {
		cin >> V[i];
		P[i] = P[i-1] + V[i];
		X[i] = X[i-1] ^ V[i];
	}
	for(int i=1; i<=N; i++) nxt[i] = 0;
	for(int i=1; i<=N; i++) if(V[i] != 0) nxt[i] = i;
	for(int i=1; i<=N; i++) nxt[i] = max(nxt[i], nxt[i-1]);
	ll ans = 0;
	for(int i=1; i<=N; i++) {
		ll psum = P[i];
		ll xsum = X[i];
		for(int j=max(1, i-MAGIC); j<=i; j++) {
			if((psum - P[j-1]) == (xsum ^ X[j-1])) ans++;
		}
		int times = 0;
		for(int j=i-MAGIC-1; j>=1; j--) {
			++times;
			if(V[j] == 0) {
				int n = nxt[j];
				if((psum - P[n]) == (xsum ^ X[n])) ans += (ll)(j-n);
				j = n+1;
			}
			else if((psum - P[j-1]) == (xsum ^ X[j-1])) ans++;
			if(times > MAGIC) break;
		}
 	}
	cout << ans << endl;
	
}

Measured memory_bytes: 7168
#include "bits/stdc++.h"

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
	int t,p;
	char ch;
	vector<pii > data;
	while(cin>>t>>ch>>p){
		if(t==0 && p==0)break;
		data.pb(pii(50-p,t));
	}
	sort(all(data));
	int x;
	while(cin>>x){
		int c=0;
		int bef=0;
		rep(i,data.size()){
			if(bef!=data[i].first)c++;
			bef=data[i].first;
			if(data[i].second==x){
				cout<<c<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1200
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N, K;
  ci(N, K);
  int a = K;
  rep(i, N - 1){
    a *= K - 1;
  }
  co(a);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// vector 要素の総和算出
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// vector 最大値( return ite )
#define _max_element(v) max_element(v.begin(),v.end())
// vector 最大値が格納されている要素値
#define _max_element_number(v) distance(v.begin(),max_element(v.begin(),v.end()))
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値
#define _ceil(x) ceil(x)
// 指定された要素以上の値が現れる最初の位置のイテレータを取得する
#define _lower_bound(v,min) lower_bound(v.begin(), v.end(), min)
// 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
#define _upper_bound(v,min) upper_bound(v.begin(), v.end(), min)

// 順列 n個の数が与えられる
// 0,1,2,...,n-1
// 全ての並べ方を1行ごとに出力する
// ex 0 1 2 / 0 2 1 / 1 0 2 / 1 2 0 / 2 0 1 / 2 1 0
#define _next_permutation(v) do {   \
	for (auto num : v) {            \
		printf("%d ", num);         \
	}                               \
	printf("\n");                   \
} while (next_permutation(v.begin(), v.end()))

// 絶対値
static int32_t _abs(const int32_t x) { return  (x > 0 ? x : -x); }

// 多次元 std::vector 生成
template<class T>
vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }

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

	for (size_t i = 0; i < s.size()-1; i++) {
		if (s[i] == s[i + 1]) { continue; }
		printf("Yes\n");
		return 0;
	}
	printf("No\n");

	return 0;
}

Measured memory_bytes: 256
import java.awt.Point;
import java.awt.geom.*;
import java.awt.geom.Point2D.Double;
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        new Main(); 
    }
 
    public Main() {
    	new aoj0059().doIt();
    }
    class aoj0059{
    	void doIt(){
    		while(sc.hasNext()){
    			boolean in = false;
    			Point2D p[] = new Point2D[4];
    			Point2D p2[] = new Point2D[4];
    			Line2D l[] = new Line2D[4];
    			Line2D l2[] = new Line2D[4];
    			for(int i = 0;i < 2;i++){
    				p[i*2] = new Point2D.Double(sc.nextDouble(),sc.nextDouble());
    			}
    			p[1] = new Point2D.Double(p[0].getX(),p[2].getY());
    			p[3] = new Point2D.Double(p[2].getX(),p[0].getY());
    			for(int i = 0;i < 2;i++){
    				p2[i*2] = new Point2D.Double(sc.nextDouble(),sc.nextDouble());
    			}
    			p2[1] = new Point2D.Double(p2[0].getX(),p2[2].getY());
    			p2[3] = new Point2D.Double(p2[2].getX(),p2[0].getY());
    			for(int i = 0;i < 4;i++){
    				l[i] = new Line2D.Double(p[i],p[(i+1)%4]);
    				l2[i] = new Line2D.Double(p2[i],p2[(i+1)%4]);
    			}
    			for(int i = 0;i < 4;i++){
    				for(int j = 0;j < 4;j++){
    					if(isIntersectSS(l[i],l2[j]))in = true;
    				}
    			}
    			for(int i = 0;i < 4;i++){
                    if(contains(p,p2[i]) >= 0)in = true;
                }
    			for(int i = 0;i < 4;i++){
                    if(contains(p2,p[i]) >= 0)in = true;
                }
    			if(in)System.out.println("YES");
    			else System.out.println("NO");
            }
    	}
    	boolean isIntersectSS(Line2D l, Line2D m) {
    	    return l.intersectsLine(m);
    	}
    	int contains(Point2D[] plist,Point2D p) {
            boolean isin = false;
            int n = plist.length;
            for(int i=0;i<n;i++){
                Point2D a = sub(plist[i], p);
                Point2D b = sub(plist[(i+1) % n], p);
                if(a.getY() > b.getY()){
                    Point2D temp = (Point2D) a.clone();
                    a = b;
                    b = temp;
                }
                if(a.getY() <= 0 && 0 < b.getY()){
                    if(cross(a,b) < 0) isin = ! isin;
                }
                if(cross(a,b) == 0 && dot(a, b) <= 0) return 0;
            }
            return isin ? 1 : -1;
        }
        Point2D sub(Point2D p2, Point2D p1) {
            double x = p2.getX() - p1.getX();
            double y = p2.getY() - p1.getY();
            return new Point2D.Double(x, y);
        }
        double cross(Point2D p1, Point2D p2){
            double res = p1.getX() * p2.getY() - p1.getY() * p2.getX();
            return res;
        }
        double dot(Point2D p1,Point2D p2){
            return p1.getX() * p2.getX() + p1.getY() * p2.getY();
        }
    }
}

Measured memory_bytes: 28972
let ascii_p c = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')

let uppercase_p c = c >= 'A' && c <= 'Z'

let lowercase c = Char.chr ((Char.code c) - (Char.code 'A') + (Char.code 'a'))

let plus tbl c =
  match
    try Some (Hashtbl.find tbl c) with _ -> None
  with
  | None -> Hashtbl.replace tbl c 1
  | Some n -> Hashtbl.replace tbl c (n + 1)

let print_tbl tbl =
  for i = Char.code 'a' to Char.code 'z' do
    let c = Char.chr i in
    match
      try Some (Hashtbl.find tbl c) with _ -> None
    with
    | None -> Printf.printf "%c : 0\n" c
    | Some n -> Printf.printf "%c : %d\n" c n
  done

let () =
  let tbl = Hashtbl.create ~random:true 26 in
  let rec doit () =
    match
      try Some (read_line ()) with _ -> None
    with
    | None -> ()
    | Some l -> begin
        String.iter (fun c ->
          if ascii_p c then plus tbl (if uppercase_p c then lowercase c else c)
        ) l;
        doit ();
      end
  in
  doit ();
  print_tbl tbl

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

int main(void){
        int n;
        scanf("%d", &n);
        long long  a[n+1];
        a[0] = 0;
        for(int i=1; i<=n; i++){
                scanf("%lld", &a[i]);
                a[i] += a[i-1];
        }

        long long ans = 1e18;
        for(int i=1; i<n; i++){
                long long x = llabs(a[n]-a[i]*2);
                if(x<ans) ans = x;
        }
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;
const int mod1=998244353;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	bool flg=true;
	ll ans=0;
	if(a.at(0)!=0) flg=false;
	rep(i,n-1){
		if(a.at(i+1)>a.at(i)+1) flg=false;
	}
	if(flg){
		ans+=a.at(n-1);
		for(int i=n-2;i>=0;--i){
			if(a.at(i)+1!=a.at(i+1)) ans+=a.at(i);
		}
		cout << ans << endl;
	}
	else cout << -1 << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,p,i=1,ans=0;
int main(void){
    cin>>n>>p;
    if(n==1){
        cout<<p<<endl;
        return 0;
    }
    else{
        for(int i=1;i<=1000000;i++){
            if(p%(ll)pow(i,n)==0){
                ans=i;
            }
            if(p<=(ll)pow(i,n)){
                break;
            }
            
        }
        cout<<ans<<endl;
        return 0;
    }
}


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

int main(){
  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int h11=h1*60+m1;
  int h22=h2*60+m2;
  int ans=h22-(h11+k);
  if(ans<0){
    ans=0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n,v[105],m,sum;
int main(){
    scanf("%d",&n);
    for(register int i=1;i<=n;i++) scanf("%d",&v[i]),sum+=v[i];
    scanf("%d",&m);
    while(m--){
        int x,p;
        scanf("%d%d",&x,&p);
        printf("%d\n",sum-v[x]+p);
    }
    return 0;
}

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

int main(){
  long long N,K,sub;
  bool b=true;
  cin>>N>>K;
  while(b){
    sub=N%K;
    N-=K;
    N=abs(N);
    if(N>sub||N==0){b=false;}
  }
  if(sub>abs(sub-K)){sub=abs(sub-K);}
  cout<<sub;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,p,i;
    cin>>n>>p;
    set<ll> s;
    for(i=1;i*i<=p;i++)
        if(p%i==0)
            s.insert(i),s.insert(p/i);
    vector<ll> div;
    for(auto in:s)
        if(in!=1)
            div.push_back(in);
    vector<ll> v;
    ll tmp=p;
    for(auto in:div)
        while(tmp%in==0)
            v.push_back(in),tmp/=in;
    map<ll,ll> m;
    for(auto in:v)
        m[in]++;
    ll ans=1;
    for(auto in:m)
    {
        ll x=in.second/n;
        ll y=1;
        for(i=0;i<x;i++)
            y*=in.first;
        ans*=y;
    }
    cout<<ans<<endl;
}



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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int cnt[31][100001] = {0};
int main(){
  int N,C;
  cin>>N>>C;
  for(int i(0);i<N;i++){
    int s,t,c;
    cin>>s>>t>>c;
    for(int j(s);j<=t;j++){
      cnt[c][j] = 1;
    }
  }
  int ans(0);
  for(int i(0);i<=100000;i++){
    int tmp(0);
    for(int j(1);j<=C;j++){
      if(cnt[j][i] == 1) tmp++;
    } 
    ans = max(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}



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

#define y1 as214
#define ii pair < int , ll >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back

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

#define ll long long
#define oo INT_MAX

/// dp[i] là quãng đường dài nhất để xuất phát từ 1 và kết thúc tại i.

const int N = 1e5 + 5;
ll n , k;
ll dp[N] , f[N];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    FOR(i , 1 , n)
        cin >> f[i];
    memset(dp , 0x1f , sizeof(dp));
    dp[1] = 0;
    FOR(i , 2 , n)
    {
        FOR(j , max((ll)1 , i - k) , i - 1)
            dp[i] = min(dp[i] , dp[j] + abs(f[i] - f[j]));
    }
    cout << dp[n] << endl;
}


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

#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define endl "\n" 
#define all(c) c.begin(),c.end()
#define present(c,element) (c.find(element)!=c.end())
#define cpresent(c,element) (find(c,element)!=c.end())
#define forr(i,a,b) for(int i=a;i<int(b);i++)
#define tr(i,a) for(auto i:a)
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
const double PI=acos(-1);
const ll mod=1e9+7;


int32_t main()
{
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

int test=1;
//cin>>test;
while(test--)
{
	int n,k;
	cin>>n;
	int a[n][3];
	for (int i = 0; i < n; ++i)
	{
		/* code */
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	int dp[n][3];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for (int i = 1; i < n; ++i)
	{
		/* code */
		for (int j = 0; j < 3; ++j)
		{
			/* code */
			dp[i][j]=max(dp[i-1][(j+1)%3]+a[i][j],
						dp[i-1][(j+2)%3]+a[i][j]);
			//cout<<res<<" ";
		}
		//dp[i]=res;//cout<<endl;
		
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;



}
return 0;
}










Measured memory_bytes: 2560
#include <iostream>

int main () {
    std::ios_base::sync_with_stdio(0);
    int n;
    std::cin >> n;
    int current = 1;
    for (int i=0;i<n;++i) {
        int a;
        std::cin >> a;
        if (current == a) ++current;
    }
    if (current == 1) std::cout << -1 << std::endl;
    else std::cout << n-current+1 << std::endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    s_lst = [str(input()) for _ in range(n)]
    alp = list('abcdefghijklmnopqrstuvwxyz')

    lst = []
    for i in range(n):
        count_lst = [0] * 26
        s = s_lst[i]
        for j in range(len(s)):
            s_alp = s[j]
            count_lst[alp.index(s_alp)] += 1

        lst.append(count_lst)

    minimum_lst = [0] * 26
    for i in range(26):
        minimum_count = lst[0][i]
        for j in range(n):
            minimum_count = min(minimum_count, lst[j][i])

        minimum_lst[i] = minimum_count

    answer = ''
    for i in range(26):
        alphabet = alp[i] * minimum_lst[i]
        answer += alphabet
    print(answer)


if __name__ == '__main__':
    main()

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

namespace AtTest.ABC_127
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            long[] rdx = ReadLongs();
            long r = rdx[0];
            long d = rdx[1];
            long x = rdx[2];
            long now = x;
            for(int i = 0; i < 10; i++)
            {
                now = r * now - d;
                WriteLine(now);
            }
        }

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


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

int main(){
    long int k,x1_min,x2_min,sum=0;
    cin >> k;
    for(long int i = 1; i <= k; i++){
        for (long int j = 1; j <= k; j++)
        {
            x1_min = __gcd(i,j);
            for(long int l = 1;l <= k;l++){
                x2_min = __gcd(x1_min, l);
                sum += x2_min;
            }
        }
    }

    cout << sum << endl;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long ans = 0;
    int n;
    cin >> n;
    vector<int> a(n+1);
    if(n == 2)
    {
        int x;
        cin >> x;
        cout << x*2;
        return 0;
    }
    int last,curr;
    cin >> last;
    long long res = last;
    for(int i = 2; i<= n-1; ++i)
    {
        cin >> curr;
        a[i]=min(last,curr);
        res+= a[i];
        last = curr;
    }
    cout << res+last;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 
#include <stdlib.h>
int main(void)
{
	int w, h, x, y, r;
	
	scanf("%d %d %d %d %d", &w, &h, &x, &y,&r);
	
	
	if((x + r <= w  && x - r >= 0) && (y + r <= h && y - r >= 0))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


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

int main(){
  while(1){
  string str;
  cin>>str;
  if(str=="#")break;
  int mp[10][10]={};

  int  x=0,y=0;
  int w,h;
  for(int i=0;i<str.size();i++){
    if(str[i]=='/'){
      y++;
      h=y;
      w=x;
      x=0;
      continue;
    }
    if(str[i]=='b') mp[y][x++]=1;
    else if('0'<=str[i]&&str[i]<='9') x+=str[i]-'0';
  }


  int a,b,c,d;
  cin>>a>>b>>c>>d;
  a--,b--,c--,d--;
  mp[c][d]=mp[a][b];
  mp[a][b]=0;

  string ans;
  for(int i=0;i<=h;i++){
    int cnt=0;
    for(int j=0;j<w;j++){
      if(mp[i][j]==0) cnt++;
      else if(cnt) ans+=(cnt+'0'),cnt=0;
      if(mp[i][j]==1) ans+='b';
    }
    if(cnt) ans+=(cnt+'0');
    if(i!=h)ans+='/';
  }
  cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3240
#include<cstdio>
#include<algorithm>
int main(){
	int n;
	scanf("%d",&n);
	long long int ans=0;
	long long int a=0;
	for(int i=0;i<n;i++){
		scanf("%lld",&a);
		while(a%2==0){
			a=a/2;
			ans++;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;
 
int N, K;
//vector<int> v;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //freopen("5.txt", "r", stdin);
  cin >> N >> K;
  cout << (N-1)/(K-1) + (((N-1)%(K-1) == 0) ? 0 : 1) << "\n";
  return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
p = gets.chomp.split(" ").map(&:to_i)
q = gets.chomp.split(" ").map(&:to_i)
x = (1..n).to_a
x = x.permutation.to_a
a = x.index(p)
b = x.index(q)
print (a-b).abs

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

int main() {
  long long int x;
  cin>>x;
  int i=-120;
  bool ans=true;
  while(ans){
    i++;
    for(int j=-120;j<120;j++){
      if(i*i*i*i*i-j*j*j*j*j==x){
        cout<<i<<" "<<j<<endl;
        ans=false;
        break;
      }
    }
  }
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,k;
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>k;
	int w=0;
	while(n){
		w++;
		n/=k;
	}
	cout<<w;
	re 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false
	
int main(void){
    
    ll H,W,K;
    ll x1,y1,x2,y2;
    vector<string> C;
    
    cin >> H >> W >> K;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--;y1--;x2--;y2--;
    C.resize(H);
    REP(i,H){
        cin >> C[i];
    }
    
    vector<vector<ll>> cost(H,vector<ll>(W,INF));
    cost[x1][y1]=0;
    queue<pair<ll,ll>> bfs;
    bfs.push({x1,y1});
    
    ll dx[4]={1,0,-1,0};
    ll dy[4]={0,1,0,-1};
    
    while(!bfs.empty()){
        pair<ll,ll> t = bfs.front();
        bfs.pop();
        
        //cout << t.first MM t.second MM cost[t.first][t.second] << endl;
        
        REP(i,4){
            ll x = t.first,y=t.second;
            REP(j,K){
                x+=dx[i];
                y+=dy[i];
                
                if(x<0 || H<=x)break;
                if(y<0 || W<=y)break;
                if(C[x][y]=='@')break;
                if(cost[x][y]<=cost[t.first][t.second])break;
                
                if(cost[x][y]>cost[t.first][t.second]+1){
                    cost[x][y]=cost[t.first][t.second]+1;
                    bfs.push({x,y});
                }
            }
        }
    }
    
    if(cost[x2][y2]==INF){
        cout << -1 << endl;
    }else{
        cout << cost[x2][y2] << endl;
    }
    
    #if debug
    REP(i,H){
        REP(j,W){
            if(cost[i][j]==INF){
                cout << -1 << " ";
            }else{
                cout << cost[i][j] << " ";
            }
        }cout << endl;
    }
    #endif
    
    return 0;
}



Measured memory_bytes: 20020
from collections import defaultdict

def prime_factorize(n):
    res = []
    for i in range(2, int(n**(1/2))+1):
        if n % i != 0: continue
        num = 0
        while n % i == 0:
            num += 1
            n /= i
        res.append((i, num))
    if n != 1:
        res.append((n, 1))
    
    return res

mod = 10**9 + 7
n = int(input())

cnt = defaultdict(int)
for i in range(1,n+1):
    res = prime_factorize(i)
    for j, v in res:
        cnt[j] += v

ans = 1
for i, v in cnt.items():
    ans *= (v+1)
print(ans % mod)


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

al = list(map(int, input().split()))
sl = [i for i in range(n)]

c = [x - y for (x, y) in zip(al,sl)]
cs = sorted(c)

m = n//2
b = cs[m]
ssl = [i+b for i in range(n)]

cc = [x-y for (x,y) in zip(al,ssl)]
res = sum(list(map(lambda x:abs(x),cc)))
print(res)

Measured memory_bytes: 54832
x, y, a, b, c = map(int, input().split())
pn = list(map(int, input().split()))
qn = list(map(int, input().split()))
rn = list(map(int, input().split()))

pn.sort(reverse=True)
qn.sort(reverse=True)

pqr = pn[:x] + qn[:y] + rn
pqr.sort(reverse=True)
  
print(sum(pqr[:x+y]))


Measured memory_bytes: 22720
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

void fin(){
	freopen("test.txt", "r", stdin);
}

int a[] = {0, 4, 9, 4};

int main(){
	while(1){
		int n;
		cin >> n;
		if(!n) break;
		vector<vi> snack(n, vi(5, 0)); //i p q r c
		rep(i, n){
			int cal = 0;
			rep(j, 4){
				cin >> snack[i][j];
				cal += snack[i][j]*a[j];
			}
			snack[i][4] = cal;
		}
		int lim[5];
		rep(i, 4){
			cin >> lim[i+1];
		}
		bool na = true;
		rep(i, n){
			bool ok = true;
			FOR(j, 1, 5){
				ok &= (snack[i][j] <= lim[j]);
			}
			if(ok){
				cout << snack[i][0] << endl;
				na = false;
			}
		}
		if(na) cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 1268
Scanf.scanf "%d %s %s" @@ fun n s t ->
  let ls,lt = String.(length s, length t) in
  Array.init (ls+1) (fun i ->
    i, String.sub s 0 i ^ t) |> Array.to_list
  |> List.filter (fun (i, st) ->
      String.(sub st 0 ls = s && sub st i lt = t))
  |> List.hd |> snd |> String.length |> Printf.printf "%d\n"


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

struct query{char c,lr;};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,q;
  string s;
  cin>>n>>q>>s;
  vector<query>qu(q);
  rep(i,q)
  {
    cin>>qu[i].c>>qu[i].lr;
  };
  auto okl=[&](int idx)
  {
    int  now=idx;
    rep(i,q)
    {
      if(s[now]==qu[i].c)
      {
        if(qu[i].lr=='L')now--;
        else now++;
        if(now==-1)return 0;
        if(now==n)return 1;
      }
    }
    return 1;
  };
  auto okr=[&](int idx)
  {
    int  now=idx;
    rep(i,q)
    {
      if(s[now]==qu[i].c)
      {
        if(qu[i].lr=='L')now--;
        else now++;
        if(now==n)return 0;
        if(now==-1)return 1;
      }
    }
    return 1;
  };
  int res=n;
  int ok=n,ng=-1;
  while(ok-ng>1)
  {
    int mid=(ok+ng)/2;
    if(okl(mid))ok=mid;
    else ng=mid;
  }
  res-=ok;
  ok=-1,ng=n;
  while(ng-ok>1)
  {
    int mid=(ok+ng)/2;
    if(okr(mid))ok=mid;
    else ng=mid;
  }
  res-=(n-ng);
  cout<<res<<endl;



  return 0;

}


Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
#define endl '\n'
typedef pair<int, int> pii;

unordered_set<int> vis;
queue<int> q[N];
queue<pii> Q, nQ;

int getint(){
	int w=0,q=1;
	char c=getchar();
	while(c<'0'||c>'9'&&c!='-') c=getchar();
	if(c=='-') q=-1;
	while(c>='0'&&c<='9') w=10*w+c-'0',c=getchar();
	return q*w;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n, sum, cnt, temp;
	n=getint();
	for (int i = 1; i <= n; i++)
		for (int j = 1; j < n; j++) {
			temp=getint();
			q[i].push(temp);
		}
	for (int i = 1; i <= n; i++) {
		int cp = q[i].front();
		if (vis.find(i) == vis.end() && vis.find(cp) == vis.end() && i == q[cp].front()) {
			Q.push({ i,cp });
			q[i].pop();
			q[cp].pop();
			vis.insert(i);
			vis.insert(cp);
			cnt += 2;
		}
	}
	sum = cnt= 0;
	while (1) {
		if (Q.empty()) {
			if (cnt == n * (n - 1)) {
				cout << sum << endl;
				return 0;
			}
			else {
				cout << -1 << endl;
				return 0;
			}
		}
		vis.clear();
		while (!Q.empty()) {
			pii p = Q.front();
			Q.pop();
			cnt+=2;
			if (vis.find(p.first) == vis.end() && !q[p.first].empty()) {
				int cp = q[p.first].front();
				if (vis.find(cp) == vis.end() &&p.first==q[cp].front()) {
					nQ.push({ p.first,cp });
					q[p.first].pop();
					q[cp].pop();
					vis.insert(p.first);
					vis.insert(cp);
				}
			}
			if (vis.find(p.second) == vis.end() && !q[p.second].empty()) {
				int cp = q[p.second].front();
				if (vis.find(cp) == vis.end() &&p.second==q[cp].front()) {
					nQ.push({ p.second,cp });
					q[p.second].pop();
					q[cp].pop();
					vis.insert(p.second);
					vis.insert(cp);
				}
			}
		}
		sum++;
		while (!nQ.empty()) {
			Q.push(nQ.front());
			nQ.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 4736
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 parent[20000];
int num[20000];

int toint(string u) {
    int ret = 0;
    reverse(all(u));
    int pw = 1;
    rep(i, u.size()) {
        ret += (u[i] - '0') * pw;
        pw *= 10;
    }
    return ret;
}

vector<vector<int>> g;

void dfs(int v, int p) {
    if(g[v].size() == 1 and g[v][0] == p) return;
    vector<int> res;
    for(int nv: g[v]) {
        if(nv == p) continue;
        dfs(nv, v);
        res.pb(num[nv]);
    }
    sort(all(res));
    int ret = 0;
    rep(i, ((int)res.size() + 1) / 2) ret += res[i];
    // cerr << ret << endl;
    num[v] = ret;
}

void solve() {
    rep(i, 20000) {
        parent[i] = num[i] = inf;
    }
	string s; cin >> s;
    int n = (int)s.size();
    int d = 0, cur = 0;
    int nxt = 1;
    int i = 0;
    parent[0] = -1;
    string t = "";
    for(; i < n; ++ i) {
        if(s[i] == '[') {
            ++ d;
            parent[nxt] = cur;
            cur = nxt;
            ++ nxt;
        } else if(s[i] == ']') {
            -- d;
            cur = parent[cur];
        } else {
            t += s[i];
            while(i + 1 < n and (s[i + 1] != '[' and s[i + 1] != ']')) {
                ++ i;
                t += s[i];
            }
            // cerr << toint(t) << endl;
            num[cur] = (toint(t) + 1) / 2;
            t = "";
        }
    }
    g.assign(nxt, vector<int>());
    rep(i, nxt) {
        if(parent[i] != -1) {
            g[i].pb(parent[i]);
            g[parent[i]].pb(i);
            // cerr << num[i] << " ";
        }
    }
    // cerr << endl;
    dfs(0, -1);
    cout << num[0] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	int t; cin >> t; rep(i, t)solve();
	//solve();
    return 0;
}


Measured memory_bytes: 3496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int a,p;cin>>a>>p;
    co((3*a+p)/2);
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
N, M = map(int, sys.stdin.readline().split())
G = [[] for i in range(N)]
for i in range(M):
    l, r, q = map(int, sys.stdin.readline().split())
    G[l - 1].append((r - 1, q))
    G[r - 1].append((l - 1, -q))

R = [None] * N


def dfs(u):
    global R, G
    for w, d in G[u]:
        if R[w] is None:
            R[w] = R[u] + d
            if not dfs(w):
                return False
        else:
            if R[w] != R[u] + d:
                return False
    return True


flag = True
for i in range(N):
    if R[i] is None:
        R[i] = 0
        flag &= dfs(i)

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 128888
# 累積和(gcd)
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
lcg = A[:]
rcg = A[:]
for i in range(1, N):
  lcg[i] = gcd(lcg[i], lcg[i - 1])
for i in range(N - 2, -1, -1):
  rcg[i] = gcd(rcg[i], rcg[i + 1])
t = [0] * N
t[0] = rcg[1]
for i in range(1, N - 1):
  t[i] = gcd(lcg[i - 1], rcg[i + 1])
t[N - 1] = lcg[N - 2]
print(max(t))


Measured memory_bytes: 16152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int h,w;
int dx[] = {0,1,0,-1},dy[] = {-1,0,1,0};
bool isok(int x,int y){
  if((0 <= x && x <= (w - 1)) && (0 <= y && y <= (h - 1)))return true;
  else return false;
}
int dist[1010][1010];
int main(){
  cin >> h >> w;
  int ch,cw,dh,dw;
  cin >> ch >> cw >> dh >> dw;
  vector<string>s(h);
  rep(i,h)cin >> s[i];
  rep(i,1010)rep(j,1010)dist[i][j] = 1010100;
  priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>>q;
  ch--,cw--,dh--,dw--;
  dist[ch][cw] = 0;
  q.push({0,{cw,ch}});
  while(!q.empty()){
    int nowx = q.top().second.first,nowy = q.top().second.second,nowcost = q.top().first;
    q.pop();
    rep(i,4){
      if(!isok(nowx + dx[i],nowy + dy[i]))continue;
      if(s[nowy + dy[i]][nowx + dx[i]] == '#')continue;
      if(nowcost >= dist[nowy + dy[i]][nowx + dx[i]])continue;
      dist[nowy + dy[i]][nowx + dx[i]] = nowcost;
      q.push({nowcost,{nowx + dx[i],nowy + dy[i]}});
    }
    for(int i = -2; i <= 2; i++)for(int j = -2; j <= 2; j++){
      if(i == 0 && j == 0)continue;
      if(!isok(nowx + i,nowy + j))continue;
      if(s[nowy + j][nowx + i] == '#')continue;
      if((nowcost + 1 >=  dist[nowy + j][nowx + i]))continue;
      dist[nowy + j][nowx + i] = nowcost + 1;
      q.push({nowcost + 1,{nowx + i,nowy + j}});
    }
  }
  if(dist[dh][dw] == 1010100)cout << -1 << endl;
  else cout << dist[dh][dw] << endl;
  return 0;
}


Measured memory_bytes: 9608
s = input()
ans = 'Yes'
for i in range(len(s)):
  if i % 2 == 1 and s[i] == 'R':
    ans = 'No'
    break
  elif i % 2 == 0 and s[i] == 'L':
    ans = 'No'
    break
print(ans)

Measured memory_bytes: 2940
#include<stdio.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>

/*
	入力例：
	3
	1 1 3
*/
int main(){
	int iDataNum,st,sx,sy,i;
	int ct,cx,cy;
	int strInput[2];
	for(int i=0;i<2;i++){
	 scanf("%d", &strInput[i]);
	}
	if(strInput[1]== 0){
		printf("%d",strInput[0]);
		return 0;
	}

	int strInput2[strInput[1]];
	for(int i=0;i<strInput[1];i++){
	 scanf("%d", &strInput2[i]);
	}
	
	int tmp=-1;
	  for (int i=0; i<strInput[1]; ++i) {
	    for (int j=i+1; j<strInput[1]; ++j) {
	      if (strInput2[i] > strInput2[j]) {
		tmp =  strInput2[i];
		strInput2[i] = strInput2[j];
		strInput2[j] = tmp;
	      }
	    }
	  }

	int bExist = 1;
	for(int i=0;i<=101;i++){
			bExist=1;
			for(int j=0;j<strInput[1];j++){
				if(strInput2[j]==strInput[0]-i){
					bExist=-1;
					break;
				}

			}
			if (bExist==1) {
				printf("%d",strInput[0]-i);
				return 0;
			}

			bExist = 1;
			for(int j=0;j<strInput[1];j++){
				if(strInput2[j]==strInput[0]+i){
					bExist=-1;
					break;
				}

			}
			if (bExist==1) {
				printf("%d",strInput[0]+i);
				return 0;
			}
	}

	printf("%d",strInput[0]);

  return 0;
}

Measured memory_bytes: 1728
//Template.cpp
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
		int a;
          cin >> a;
      int ans = a + a*a + a*a*a;
	cout<<ans<<'\n';
return 0;
}

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

using namespace std;

int main(){
    long N;
    string S, T;
    cin>>N;
    cin>>S>>T;
    
    string ans = "";
    for(int i=0; i<N; ++i){
        ans+=S[i];
        ans+=T[i];
    }

    cout<<ans<<endl;

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define ll long long int
#define sci(x) sca nf("%d",&x);
#define scd(x) scanf("%lf",&x);
#define pb(x) push_back(x)
#define FasterIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mkp(x,y) make_pair(x,y)
#define pii pair<int , int>
#define SEIVE seive(){ prime[1]=1; for(ll i=2; i*i<=1000000; i++) { if(prime[i]) continue; for(ll j=i*i; j<=1000000; j+=i) prime[j]=1; } }
bool prime[1000006];
vector<int>vec[20000],root;
int vis[20002];

int main()
{
    map<int,int>mp;
    ll n,sum=0;
    cin>>n;
    int a[n+3];
    for(ll i=0; i<n; i++)
    {
        cin>>a[i];
        sum+=a[i];
        mp[a[i]]++;
    }
    ll q,b,c;
    cin>>q;
    for(ll i=0; i<q; i++)
    {
        cin>>b>>c;
        if(mp[b]==0)
            cout<<sum<<endl;
        else
        {
            if(b<c)
            {
                sum+=(mp[b]*(abs(b-c)));
            }
            else
                sum-=(mp[b]*(abs(b-c)));

            cout<<sum<<endl;
            mp[c]+=mp[b];
            mp[b]=0;
        }
    }
    return 0;


}

Measured memory_bytes: 8572
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>

using namespace std;

typedef long long ll;

const int MAX=2500;
int main(){
  int n, a; cin >> n >> a;
  ll x[n+1];
  // dp[i][j][k] means "select j cards from x_1, ... , x_i then sum is k"
  ll dp[n+1][n+1][MAX+1];
  for(int i=1;i<=n;i++){
    cin >> x[i];
  }
  dp[0][0][0]=1;
  for(int j=0;j<=n;j++){
    for(int k=0;k<=MAX;k++){
      if(j*k != 0) dp[0][j][k]=0;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=0;j<=n;j++){
      for(int k=0;k<=MAX;k++){
        if(k < x[i]) dp[i][j][k]=dp[i-1][j][k];
        else if(j >= 1) dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]];
        else dp[i][j][k]=0;
      }
    }
  }
  ll sum=0;
  for(int j=1;j<=n;j++){
    if(a*j > MAX) break;
    sum = sum+dp[n][j][a*j];
    //cout << dp[n][j][a*j] << endl;
  }
  cout << sum << endl;
}

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

int main(void){
    int n = 0; 

    scanf("%d", &n);

    if(n / 10 == 9 || n % 10 == 9){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;

} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define int long long  
#define INF 1145141919810893
signed main(){
    string S;
    int Ans=0;
    int sum=0;
    int calc=0;
    cin >> S;
    int N = S.size();
    for(int i=0;i<(int)pow(2,N-1);i++){
        sum=0;
        calc=0;
        for(int j=0;j<N;j++){
            calc*=10;
            calc+=S[j]-'0';
            if((i>>(j))%2==0){
            }else{
                sum+=calc;
                //cout << calc << " ";
                calc=0;
            }
        }
        sum+=calc;
        Ans+=sum;
        //cout << sum << endl;
    }
    cout << Ans << endl;
	return 0;
}


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

const int N = 2e5 + 10, mod = 1e9 + 7;

int n, cnt[N];

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    //scanf("%d", &tc);
    while(tc--) {
        scanf("%d" ,&n);
        for(int i = 0; i < n - 1; i++) {
            int x; scanf("%d", &x);
            cnt[x]++;
        }
        for(int i = 1; i <= n; i++) printf("%d\n", cnt[i]);
    }    
    return 0;
}

Measured memory_bytes: 4536
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b&&b==c&&a==c){
			printf("No\n");
	}
	else if(a!=b&&b!=c&&a!=c){
			printf("No\n");
	}
	else{
			printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 1620
s = list(input())
n = len(s)

ans = 0
for i in range(1<<(n-1)):
    form = ""
    for j in range(n-1):
        form += s[j]
        if i & 1<<j:
            form += "+"
    form += s[-1]
    ans += eval(form)

print(ans)


Measured memory_bytes: 9032
using System;
using System.Collections.Generic;

namespace abc091_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Dictionary<string,int> dic = new Dictionary<string,int>();
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                if (!dic.ContainsKey(s)) dic[s] = 0;
                dic[s]++;
            }
            n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                if (!dic.ContainsKey(s)) dic[s] = 0;
                dic[s]--;
            }
            int ret = 0;
            foreach (var item in dic)
            {
                ret = Math.Max(item.Value,ret);
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13152
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>
#include <memory.h>

// pi = atan(1)*4;

using namespace std;

int n;
string s;
bool make(string res)
{
	for (int i = 1; i < n - 2; i++)
	{
		if (s[i] == 'o')
		{
			if (res[i] == 'S')
			{
				res[i + 1] = res[i - 1];
			}
			else
			{
				if (res[i - 1] == 'S')
				{
					res[i + 1] = 'W';
				}
				else
				{
					res[i + 1] = 'S';
				}
			}
		}
		else
		{
			if (res[i] == 'W')
			{
				res[i + 1] = res[i - 1];
			}
			else
			{
				if (res[i - 1] == 'S')
				{
					res[i + 1] = 'W';
				}
				else
				{
					res[i + 1] = 'S';
				}
			}
		}
	}

	for (int i = 0; i < n; i++)
	{
		int prev, next;
		prev = i - 1;
		next = i + 1;
		if (prev == -1)
		{
			prev = n - 1;
		}
		if (next == n)
		{
			next = 0;
		}
		if (s[i] == 'o')
		{
			if (res[i] == 'S')
			{
				if (res[prev] != res[next])
				{
					return false;
				}
			}
			else if (res[i] == 'W')
			{
				if (res[prev] == res[next])
				{
					return false;
				}
			}
		}
		else if (s[i] == 'x')
		{
			if (res[i] == 'S')
			{
				if (res[prev] == res[next])
				{
					return false;
				}
			}
			else if (res[i] == 'W')
			{
				if (res[prev] != res[next])
				{
					return false;
				}
			}
		}
	}
	cout << res << '\n';
	return true;
}
int main(void)
{
	string res;

	cin >> n;
	cin >> s;

	res.resize(n);
	if (s[0] == 'o')
	{
		//sheep
		res[0] = 'S';
		res[1] = 'S';
		res[n - 1] = 'S';
		if (make(res) == true)
		{
			return 0;
		}
		res.clear();
		res.resize(n);
		res[0] = 'S';
		res[1] = 'W';
		res[n - 1] = 'W';
		if (make(res) == true)
		{
			return 0;
		}
		res.clear();
		res.resize(n);
		//wolf
		res[0] = 'W';
		res[n - 1] = 'W';
		res[1] = 'S';
		if (make(res) == true)
		{
			return 0;
		}
		res.clear();
		res.resize(n);
		res[0] = 'W';
		res[1] = 'W';
		res[n - 1] = 'S';
		if (make(res) == true)
		{
			return 0;
		}
	}
	else
	{
		//WOLF
		res[0] = 'W';
		res[1] = 'S';
		res[n - 1] = 'S';
		if (make(res) == true)
		{
			return 0;
		}
		res.clear();
		res.resize(n);
		res[0] = 'W';
		res[1] = 'W';
		res[n - 1] = 'W';
		if (make(res) == true)
		{
			return 0;
		}
		res.clear();
		res.resize(n);
		//SHEEP
		res[0] = 'S';
		res[n - 1] = 'W';
		res[1] = 'S';
		if (make(res) == true)
		{
			return 0;
		}
		res.clear();
		res.resize(n);
		res[0] = 'S';
		res[1] = 'W';
		res[n - 1] = 'S';
		if (make(res) == true)
		{
			return 0;
		}
	}

	cout << -1 << '\n';
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,a=0,b=0;
    cin>>n;
    string x,y;
    for(int i=1;i<=n;i++){
        cin>>x>>y;
        if(x==y){
            a++;
            b++;
        }
        else if(x>y){
            a+=3;
        }
        else {
            b+=3;
            
        }
        
    }
    cout<<a<<" "<<b<<endl;
    
    return 0;
}


Measured memory_bytes: 3144