akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define vll vector<long long int>
#define vpii vector<pair<int,int>>
#define dsc [](int a,int b)->bool {return a>b;}
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define MAX 1000000000000000000
#define test int t; cin>>t;
#define MOD 1000000007LL
#define all(x) (x).begin(),(x).end()

using namespace std;

ll nxt(){
    ll x;
    cin>>x;
    return x;
}

// ll n,m,currX,currY,destX,destY;
// vector<string> a;
// vector<vector<bool>>visited;

// ll magic;

// void dfs(){

// }

int main()
{
    #ifndef ONLINE_JUDGE
        fio
    #endif
    IOS
    
    // n = nxt(),m = nxt();
    // currX = nxt(), currY = nxt();
    // destX = nxt(), destY = nxt();
    // a.resize(n+1);
    // visited.resize(n+1, vector<bool>(m+1,0));
    // for(int i = 1; i<=n; i++){
    //     string tmp;
    //     cin>>tmp;
    //     a[i] = " "+tmp;
    // }
    // magic = LLONG_MAX;
    // dfs(currX, currY);

    ll h,w,m;
    cin>>h>>w>>m;
    vector<pair<ll,int>>H;
    vector<pair<ll,int>>W;
    for(int i = 0; i<=h; i++){
        H.pb({0,i});
    }

    for(int i = 0; i<=w; i++){
        W.pb({0,i});
    }

    map<pair<ll,ll>,bool> cell;
    for(int i = 0; i<m; i++){
        ll x,y;
        cin>>x>>y;
        H[x].first++;
        W[y].first++;
        cell[{x,y}] = 1;
    }
    sort(all(H));
    sort(all(W));
    ll tmp1 = 0, tmp2 = 0;
    int i = h;
    int j = w;

    while(j>0){
        ll tmp;
        if(cell[{H[i].second,W[j].second}]) tmp = H[i].first+W[j].first-1;
        else tmp = H[i].first+W[j].first;
        if(tmp>tmp1) tmp1 = tmp;
        j--;
    }

    i = h,j = w;
    while(i>0){
        ll tmp;
        if(cell[{H[i].second,W[j].second}]) tmp = H[i].first+W[j].first-1;
        else tmp = H[i].first+W[j].first;
        if(tmp>tmp2) tmp2 = tmp;
        i--;
    }

    cout<<max(tmp1, tmp2)<<endl;

    return 0;
}

Measured memory_bytes: 68776
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;


int main() {
	ll N;cin>>N;
    vel T(N);rep0(i,N){cin>>T[i];}
    ll M;cin>>M;
    vector<pair<ll,ll>> data(M);
    rep0(i,M){
        ll a,b;cin>>a>>b;
        data[i]=make_pair(a,b);
    }
    vel ans(M);
    rep0(i,M){
        ll hold,sum=0;hold=T[data[i].first-1];
        T[data[i].first-1]=data[i].second;
        rep0(i,N){sum+=T[i];}
        ans[i]=sum;
        T[data[i].first-1]=hold;
    }
    rep0(i,M){cout<<ans[i]<<endl;}
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int INF = numeric_limits<int>::max() / 2;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
//#define int long long int
const int MOD = 1000000007;
const int INF = 1001001000;
const double EPS = 0.000000001;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool pairCompare(const P& pair1, const P& pair2) {
    return pair1.second > pair2.second;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  int ans;
  if (a >= 13) {
    ans = b;
  }
  else if(a >= 6 && a <= 12) {
    ans = b / 2;
  }
  else ans = 0;
  cout << ans << endl;
  return 0;
}


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

const int N = 100005;

int n, m, a[N], p[N], c;
vector<int> v;

int Find (int X) {
	if(p[X] == X) return X;
	return p[X] = Find(p[X]);
}

void Union (int A, int B) {
	A = Find(A);
	B = Find(B);
	if(a[A] > a[B]) swap(A, B);
	p[B] = A;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
		p[i] = i;
	}
	for(int i=1;i<=m;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		Union(A, B);
	}
	long long ans = 0;
	for(int i=0;i<n;i++) {
		if(Find(i) != i) v.push_back(a[i]);
		else {
			ans += a[i];
			c++;
		}
	}
	if(c == 1) {
		puts("0");
		return 0;
	}
	sort(v.begin(), v.end());
	if((int)v.size() < c-2) {
		puts("Impossible");
		return 0;
	}
	for(int i=0;i<c-2;i++) {
		ans += v[i];
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n,k;
  cin >> n >> k;
  vector<pair<ll,ll>> pa(n);
  rep(i,n){
    ll a,b;
    cin >> a >> b;
    pa.at(i)=make_pair(a,b);
  }
  sort(pa.begin(),pa.end());
  ll ans=0,sum=0;
  rep(i,n){
    sum+=pa.at(i).second;
    if(sum>=k){
      ans=pa.at(i).first;
      break;
    }
  }
  cout << ans;
}

Measured memory_bytes: 4800
import time
import sys
sys.setrecursionlimit(10000)


n = int(input())
a = list(map(int, input().split()))

start = time.time()

ans = 0
for i in range(n):
    while a[i] % 2 == 0:
        a[i] //= 2
        ans += 1

print(ans)

elapsed_time = time.time() - start
#print ("{:.2f}".format(elapsed_time * 1000) + " [msec]")



    

Measured memory_bytes: 4144
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    6月で水色になるぞ〜!!!
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{one, zero, One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

// code...
// #[fastout]
fn main() {
    input! {
        x: i32, n: usize,
        p: [i32; n]
    }

    let pos = (0..105).filter(|z| !p.contains(z)).sorted_by_key(|z| (x - z).abs()).collect_vec();
    let ans = pos[0];
    println!("{}", ans);
}


Measured memory_bytes: 2124
N = int(input())
A = list(map(int, input().split()))
neg = 0
for a in A:
  if a < 0:
    neg += 1
tot = 0
for i in range(N):
  if A[i] < 0:
    A[i] = -A[i]
  tot += A[i]
if neg % 2 == 0:
  print(tot)
else:
  print(tot - 2 * min(A))


Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
  int N;
  int L[]={3,5,7};
  int d=0;
  cin>>N;  int T=N;
  while(N>0){
    N/=10; d++;
  }
  int ans=0;
  for(int dig=3;dig<(d+1);dig++){
    int p=1;
    for(int t=0;t<dig;t++){
      p*=3;
    }
    for(int i=1;i<=p;i++){
      bool check0=false,check1=false,check2=false;
      int a,num=i,n=0,c=dig-1;
      while(c>=0){
        a=num%3; n+=(c!=0?pow(10,c):1)*L[a]; c--;
        if(a==0) check0=true;
        else if(a==1) check1=true;
        else check2=true;
        num/=3; 
      }
      //cout<<n<<endl;
      if(check0&&check1&&check2&&n<=T) ans++;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
//by sdfzchy
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int inf=(1<<30),N=100010;
int n,m,a[5];
bool ok;
inline int in()
{
	char ch=getchar();
	int f=1,tmp=0;
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {tmp=(tmp<<1)+(tmp<<3)+(ch-'0');ch=getchar();}
	return tmp*f;
}
char s[5];
char ans[5];
void dfs(int pos,int x)
{
	if(x==7&&pos==5)
	{
		printf("%d%c%d%c%d%c%d=7",a[1],ans[2],a[2],ans[3],a[3],ans[4],a[4]);
		ok=1;
		return;
	}
	if(pos==5) return;
	if(ok) return;
	ans[pos]='+';
	dfs(pos+1,x+a[pos]);
	if(ok) return;
	ans[pos]='-';
	dfs(pos+1,x-a[pos]);
}
int main()
{
//	freopen("in.in","r",stdin);
//	freopen("out.out","w",stdout);
	scanf("%s",s+1);
	for(int i=1;i<=4;i++) a[i]=s[i]-'0';
	dfs(2,a[1]);
	return 0;
}


Measured memory_bytes: 256
"""
a < b + c
b < c + a
c < a + b
↓
a < b < c && c < a+b
"""
import bisect
n = int(input())
l = list(map(int, input().split()))

ans = 0
l.sort()

for i in range(n):
    for j in range(i+1, n):
        index = bisect.bisect_left(l, l[i]+l[j], j, n)
        ans += index - j - 1
        # print(l)
        # print(l[i]+l[j])
        # print("index: "+str(index))
        # print("j: "+str(j))
        # print("index - j: "+str(index - j))
        # print("---------------")

print(ans)

Measured memory_bytes: 3188
/*空港 A, B, C があり、それぞれの空港の間では、双方向に飛行機が運航しています。

空港 A, B 間の飛行時間は片道 
P時間、
空港 B, C 間の飛行時間は片道 
Q時間、
空港 C, A 間の飛行時間は片道 
R時間です。

いずれかの空港からスタートして他の空港に飛行機で移動し、さらにそのどちらでもない空港に飛行機で移動するような経路を考えます。

飛行時間の和は最短で何時間になるでしょうか。*/

#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<vector>

using namespace std;

int main(){
	int x,a;

	cin>>x>>a;

	if(x<a){
		printf("0\n");
	}else if(x>=a){
		printf("10\n");
	}
	return 0;
}



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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;


ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/******************************************
** A main function is start from here  ****
*******************************************/
int main(){
  int N;
  cin >> N;
  int ans = 0;
  rep(i, N){
    int a; cin >> a;
    while(a%2==0){
      ans++;
      a = a/2;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;
  vector<int> cnt_list(N, 0);
  int len;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      len = min(j - i, abs(X - i) + 1 + abs(Y - j));
      cnt_list[len]++;
    }
  }
  for (int k = 1; k < N; k++) {
    cout << cnt_list[k] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    # import math
    input = stdin.readline

    n, m, q = map(int, input().split())

    abcd = [0]*q
    for i in range(q):
        a, b, c, d = map(int, input().split())
        abcd[i] = (a-1, b-1,c,d)

    # print(abcd)
    ans = 0

    for a in range(1,m+1):
        for b in range(a,m+1):
            for c in range(b,m+1):
                for d in range(c,m+1):
                    for e in range(d,m+1):
                        for f in range(e,m+1):
                            for g in range(f,m+1):
                                for h in range(g,m+1):
                                    for i in range(h,m+1):
                                        for j in range(i,m+1):
                                            num = [a, b, c, d, e, f, g, h, i, j]
                                            num_sum = 0
                                            for k, l, o, p in abcd:
                                                if num[l]-num[k] == o:
                                                    num_sum += p
                                            # print(num_sum)
                                            if num_sum > ans:
                                                ans = num_sum
    print(ans)






Measured memory_bytes: 9268
#include<stdio.h>
#include<string.h>
#include<math.h>

int N,S,A,C,R[257],I[257],X[257],i,j,rS,rA,rC;
double H,r;
int main()
{
	for(;scanf("%d",&N),N;)
	{
		for(i=0,r=-1;i<N;i++)
			scanf("%d",&I[i]);
		for(S=0;S<16;S++)
			for(A=0;A<16;A++)
				for(C=0;C<16;C++)
				{
					memset(X,0,sizeof(X));
					for(R[0]=S,i=1;i<=N;i++)
						R[i]=(A*R[i-1]+C)%256;
					for(i=0;i<N;i++)
						X[(I[i]+R[i+1])%256]++;
					for(H=i=0;i<256;i++)
					{
						if(X[i])
							H+=-(double)X[i]/N*log((double)X[i]/N);
					}
					if(r==-1||r-H>0.0000001)
					{
						rS=S;
						rA=A;
						rC=C;
						r=H;
					}
				}
		printf("%d %d %d\n",rS,rA,rC);
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int main() {

  string S;
  cin>>S;

  for(int i = 0; i<S.size(); i++){
    if(i == 5 || i == 13) cout<<" ";
    else cout<<S[i];
  }
  cout<<endl;

  return 0;
}


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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;
int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
vector<int> g[1000005];
int fa[1000005],d[1000005];
map<pii,int> mp;

int c[1005][1005];
char a[1005][1005];
bool vis[1005][1005];
int sx,sy,ex,ey;
int n,m;

int find(int x){ return fa[x]==x?x:fa[x]=find(fa[x]); }

int id(int x,int y){
	return (x-1)*m+y;
}

pii pos(int x){
	return pii((x-1)/m,x%m);
}

void dfs(int x,int y){
	int f=find(id(x,y));
	for(int i=0;i<4;i++){
		int nx=x+dx[i],ny=y+dy[i];
		if(nx<1||nx>n||ny<1||ny>m)continue;
		if(vis[nx][ny]||a[nx][ny]=='#')continue;
		int ff=find(id(nx,ny));
		fa[ff]=f;
		vis[nx][ny]=true;
		dfs(nx,ny);
	}
}

int main(){
	io;
	cin>>n>>m;
	for(int i=1;i<=n*m;i++){ d[i]=-1;fa[i]=i; }
	cin>>sx>>sy>>ex>>ey;
	for(int i=1;i<=n;i++)cin>>(a[i]+1);
	int ccc=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(vis[i][j]||a[i][j]=='#')continue;
			dfs(i,j);
			ccc++;
		}
	}
	// dbg(ccc);
	int s=find(id(sx,sy)),t=find(id(ex,ey));
	if(s==t){ cout<<0<<endl;return 0; }
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]=='#')continue;
			for(int nx=i-2;nx<=i+2;nx++){
				for(int ny=j-2;ny<=j+2;ny++){
					if(nx<1||nx>n||ny<1||ny>m)continue;
					if(nx==i&&ny==j)continue;
					if(a[nx][ny]=='#')continue;
					int f1=find(id(i,j)),f2=find(id(nx,ny));
					if(f1==f2)continue;
					if(mp[pii(f1,f2)])continue;
					// dbg(f1);dbg(f2);
					g[f1].pb(f2);g[f2].pb(f1);
					mp[pii(f1,f2)]=mp[pii(f2,f1)]=1;
				}
			}
		}
	}
	// dbg(0);
	queue<int> que;
	que.push(s);
	d[s]=0;
	int ans=-1;
	while(!que.empty()){
		int u=que.front();que.pop();
		// dbg(u);
		if(u==t){ ans=d[u];break; }
		for(int v:g[u]){
			if(d[v]==-1){
				d[v]=d[u]+1;
				que.push(v);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 65624
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
int val[3]={0};
vector<ll> mod_k[100005];
ll dp[100005][3]={0};
bool ispoint[3][3];
ll solve(ll now_k){
  ll vs=mod_k[now_k].size();
  for(int i=0;i<=vs;i++){
    for(int j=0;j<3;j++) dp[i][j]=0;
  }
  for(int i=0;i<vs;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(i!=0&&j==k) continue;
        ll kval=dp[i][j];
        if(mod_k[now_k][i]==k){
          kval+=val[k];
        }
        dp[i+1][k]=max(dp[i+1][k],kval);
      }
    }
  }
  return max({dp[vs][0],dp[vs][1],dp[vs][2]});
}
int main(){
  ll n,k;
  cin>>n>>k;
  for(int i=0;i<3;i++) cin>>val[i];
  for(int i=0;i<n;i++){
    char c;
    cin>>c;
    int a;
    if(c=='r') a=2;
    else if(c=='s') a=0;
    else a=1;
    mod_k[i%k].push_back(a);
  }
  ll ans=0;
  for(int i=0;i<k;i++) {

    ll kans=solve(i);
    ans+=kans;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5876
from functools import lru_cache
@lru_cache(None)
def f(n,k):
  if k<1: return 1
  if n<10:
    if k<2: return n
    return 0
  d,m=n//10,n%10
  return f(d,k-1)*m+f(d-1,k-1)*(9-m)+f(d,k)
print(f(int(input()),int(input())))

Measured memory_bytes: 3940
#include <stdio.h>

#define NO_DATA -1
#define MAX_COUNT 100

int main(int argc, const char * argv[]) {
    double result[MAX_COUNT][2];
    double a,b,c,d,e,f;
    int scanResult;
    
    for (int i = 0; i < MAX_COUNT; i++ ) {
        result[i][0] = NO_DATA;
        result[i][1] = NO_DATA;
    }
    int count=0;
    scanResult = scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f);
    while (scanResult!=EOF) {
        result[count][0]=(e*c+(-b*f))/(a*e-d*b);
        result[count][1]=(-d*c+a*f)/(a*e-d*b);
        count++;
        scanResult = scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f);
    }
    
    for (int i=0;i<count;i++) {
        double x = (int)(1000 * result[i][0] + 2 * (1000 * result[i][0] - (int)(1000 * result[i][0]))) / 1000.0;

        double y = (int)(1000 * result[i][1] + 2 * (1000 * result[i][1] - (int)(1000 * result[i][1]))) / 1000.0;
        printf("%.3lf %.3f\n", x, y);
    }
    return 0;
}




Measured memory_bytes: 1932
#include <iostream>
#include<string>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <cstdlib>
//#include <vector.h>
//#include <malloc.h>

#include <math.h>
using namespace std;
#include<stdlib.h>
#include<stdio.h>
int main(){
    int n,m;
    string s;
    cin>>s;
    bool b=false;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-1-i]){
            b=true;
            break;
        }
    }
    if(b){
        cout<<"No\n";
        return 0;
    }
    int l = (s.size()-1)/2;
    for(int i=0;i<l/2;i++){
        if(s[i]!=s[l-i-1]){
            b=true;
            break;
        }
    }
    
    if(b){
           cout<<"No\n";
           return 0;
    }
     l = (s.size()+3)/2;
    int d=s.size()-l+1;
    
    for(int i=l-1,j=0;i<d/2;i++,j++){
        if(s[i]!=s[s.size()-j-1]){
            b=true;
            break;
        }
    }
    if(b){
              cout<<"No\n";
              return 0;
       }
    else{
        cout<<"Yes\n";
    }
    return 0;
}


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

#define ENDL '\n'
#define io ios_base::sync_with_stdio(false);cin.tie(0);
#define sayy cout<<"YES"<<ENDL;
#define sayn cout<<"NO"<<ENDL;


int main(){
    io

    int n;
    cin >> n;
    string a,b;
    cin >> a >> b;

    for(int i(0); i<n; i++){
        cout << a[i];
        cout << b[i];
    }

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cctype>
using namespace std;
int main()
{
	int w, a, b;
	while(scanf("%d%d%d", &w, &a, &b) != EOF)
	{
		if((b >= a && b <= a + w) || (b+w >= a && b + w <= a + w))
			printf("0\n");
		else
		{
			if(b > a + w)
			{
				printf("%d\n", b - a - w);
			}
			else if(b + w < a) printf("%d\n", a - b - w);
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    H, W = map(int, input().split())
    if H == 1 or W == 1:
        print(1)
    elif H % 2 == 1 and W % 2 == 1:
        print(H * W // 2 + 1)
    else:
        print(H * W // 2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

int main()
{
	int n, k;
	string s;
	cin >> n;
	cin >> k;
	cin >> s;
	char x = tolower(s.at(k-1));
	s.at(k-1) = x;
	cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
#define mod 1000000007
#define ll long long
int i,j,k,l;
static const int MAX_N=10e5;

int main(void){
	int N,K;cin >> N >> K;
	string h;cin >> h;
	int res=0;
	rep(i,1,N){
		if(h[i-1]==h[i])res++;
	}puts(min(res+K*2,N-1));
	
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

#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)

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
vector<int>G[10010];
vector<int>c(10010,0);
int num[10010];
bool used[10010];
int now_c=0;
int dfs(int s){
    if(used[s]){
        return 0;
    }else{
        used[s]=true;
    }

    num[s]=c[now_c];
    now_c++;

    for(int i=0; i<G[s].size(); i++){
        dfs(G[s][i]);
    }
    return 0;
}
int main() {
    int P,Q,R; cin >> P >> Q >> R;

    cout<< min({P+Q, Q+R, R+P}) << endl;
    return 0;
}


Measured memory_bytes: 512
// 深さ優先探索
package main

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

type edge struct {
	To int
	ID int
}

var (
	edges  [][]edge
	colors []int
)

func main() {
	N := readInt()

	edges = make([][]edge, N)
	for i := 0; i < N-1; i++ {
		a := readInt() - 1
		b := readInt() - 1
		edges[a] = append(edges[a], edge{To: b, ID: i})
		edges[b] = append(edges[b], edge{To: a, ID: i})
	}

	colors = make([]int, N)
	q := make([][3]int, 1, N)
	q = append(q, [3]int{0, -1, -1})
	for len(q) != 0 {
		current, usedColor, from := q[len(q)-1][0], q[len(q)-1][1], q[len(q)-1][2]
		q = q[:len(q)-1]
		color := 1
		for _, e := range edges[current] {
			if e.To == from {
				continue
			}
			if color == usedColor {
				color++
			}
			colors[e.ID] = color
			q = append(q, [3]int{e.To, color, current})
			color++
		}
	}

	K := -1
	for _, color := range colors {
		if color > K {
			K = color
		}
	}
	fmt.Println(K)

	for i := 0; i < N-1; i++ {
		fmt.Println(colors[i])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 12800
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int make(int w);
int puls(int a,int b);
int multi(int a,int b);
int X=16;
int n;
vector<vector<int> > a(100,vector<int>(X,-4));

int main(){
  scanf ("%d",&n);
  while(n){
    string s;
    for(int t=int(a.size());t<100;t++){
      a.push_back(vector<int>(X,-4));
    }
    for(int t=0;t<100;t++){
      for(int z=0;z<X;z++){
        a[t][z]=-4;
      }
    }
    for(int t=0;t<n;t++){
      cin >> s;
      for(int p=0;p<int(s.size());p++){
        switch(s[p]){
          case 42:
            a[t][p]=-2;
            break;
          case 43:
            a[t][p]=-1;
            break;
          case 48:
          case 49:
          case 50:
          case 51:
          case 52:
          case 53:
          case 54:
          case 55:
          case 56:
          case 57:
            a[t][p]=s[p]-48;
            break;
        }
      }
    }
    for(int t=X-1;t>=1;){
      if(make(t)<0){
        t--;
      }
    }
    printf("%d\n",a[0][0]);
    scanf ("%d",&n);
  }
}


int make(int w){
  int q=0;
  int end=-4;
  for(int i=0;i<n;i++){
    if(a[i][w]!=-4){
      if(a[i-1][w-1]==-1){
        q=0;
      }
      if(a[i-1][w-1]==-2){
        q=1;
      }
      for(int k=i;a[k][w]!=-4;){
        if(a[i-1][w-1]==-1){
          q=puls(q,a[k][w]);
          a.erase(a.begin() + k);
          n--;
        }
        if(a[i-1][w-1]==-2){
          q=multi(q,a[k][w]);
          a.erase(a.begin() + k);
          n--;
        }
      }
      a[i-1][w-1]=q;
      end=q;
      break;
    }
  }
  return end;
}


int puls(int a,int b){
  return a+b;
}

int multi(int a,int b){
  return a*b;
}



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

int main(int argc, const char * argv[])
{
    int N;
    cin >> N;
    
    vector<int> P0;
    vector<int> P1;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        P0.push_back(tmp);
        P1.push_back(tmp);
    }
    
    sort(P0.begin(), P0.end());
    
    int count = 0;
    for (int i = 0; i < N; i++) {
        if (P0[i] != P1[i]) {
            count++;
        }
        if (count >= 3) {
            break;
        }
    }
    
    if (count >= 3) {
        cout << "NO" << endl;
    }else {
     cout << "YES" << endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e9+7;
const int mod = 1e9+7;

int n;
vector<vi> dp;
vector<vi> AdjList;

int solve(int ind, int mask) {
    
    if(dp[ind][mask] != -1) return dp[ind][mask];
    int ans = 0;
     
    for(int i = 0; i < (int)AdjList[ind].size(); ++i) {
        if((mask & (1 << AdjList[ind][i]))) continue;
        ans += (ind < n-1 ? solve(ind+1, mask | (1 << AdjList[ind][i])) : 1);
        if(ans >= mod) ans -= mod;
    }
    return dp[ind][mask] = ans;
}

int main() {
    
    scanf("%d",&n);
    
    dp.resize(n);
    AdjList.resize(n);
    
    for(int i = 0; i < n; ++i) {
        dp[i].assign((1 << n), -1);
        for(int j = 0; j < n; ++j) {
            int x; scanf("%d",&x);
            if(x & 1) AdjList[i].push_back(j);
        }
    }
     
    int ans = solve(0, 0);
    printf("%d\n", ans);
    
    return 0;
}




Measured memory_bytes: 172416
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int main() {
	int N;
	cin >> N  ;
	vector<string>v(N);
	vector<int>u(N);
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
		cin >> u.at(i);
	}
	vector<int>ans(N);
	for (int i = 0; i < N; i++) {
		ans.at(i) = i + 1;
	}
	int flag = 1;
	while (flag == 1) {
		flag = 0;
		for (int i = 0; i < N - 1; i++) {
			if ((v.at(i) > v.at(i + 1))||((v.at(i)==v.at(i+1))&&(u.at(i)<u.at(i+1)))){
				swap(v.at(i), v.at(i + 1));
				swap(u.at(i), u.at(i + 1));
				swap(ans.at(i), ans.at(i + 1));
				flag = 1;
			}
				
		}
	}
	for (int i = 0; i < N; i++) {
		cout << ans.at(i) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, end) for (long long int i=0; i<end; i++)
#define repp(i, begin, end) for (long long int i=begin; i<end; i+)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vs = vector<string>;
ll sm(vll x) {ll sum=0; rep(i, x.size()) sum+=x[i]; return sum;}
void vdeb(string s, vector<int> x) {cout<<s<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<endl;}
//=======================================================================================================

int main() {
    int n;
    cin >> n;
    vi p(n);
    rep(i, n) cin >> p[i];

    int cnt = 0;
    rep(i, n-2) {
        if((p[i] < p[i+1] && p[i+1] < p[i+2]) || (p[i] > p[i+1] && p[i+1] > p[i+2]))
            cnt++;
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
			
		if(N * A <= B){
			System.out.println(N * A);
		}else{
			System.out.println(B);
		}
	}
}

Measured memory_bytes: 21972
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,M = map(int,input().split())
fr = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    fr[a].append(b)
    fr[b].append(a)
used = [-1]*N 
MAX = 0
def dfs(fr,cur,parent):
    global cnt
    children = fr[cur]
    for chi in children:
        if used[chi] != -1:
            continue
        if chi == parent:
            continue
        used[chi] = 0
        cnt += 1
        dfs(fr,chi,cur)
    return

for i in range(N):
    cnt = 1
    if used[i] != -1:
        continue
    used[i] = 0
    dfs(fr,i,-1)
    MAX = max(MAX, cnt)
print(MAX)




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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;
const int N = 2e5 + 5;
int n, t;
ii a[N];
int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].second >> a[i].first;
    }
    sort(a, a + n);
    for (int i = 0; i < n; ++i) {
        t += a[i].second;
        if (t > a[i].first) {
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main() {
  int n, cnt = 0;
  long a;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a % 2 != 0) cnt++;
  }

  cnt % 2 == 0 ? cout << "YES" : cout << "NO";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
            using namespace std;
            int main()
            {
                int n;
                cin>>n;
                string s;
                cin>>s;
                if(n%2!=0)
                    cout<<"No";
                else
                {
                    for(int i=0;i<n/2;i++)
                    {
                        if(s[i]!=s[i+n/2])
                        {
                            cout<<"No";
                            return 0;
                        }
                    }
                    cout<<"Yes";
                }
                return 0;
            }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,c[110000],cnt=0;
string s;
signed main()
{
	cin>>a>>b;
	rep(i,a){
		cin>>c[i];
	}
	while(1){
		sort(c,c+a);
		int d=a-1;
		int e=c[a-1];
		while(1){
			if(c[d]>=e/2){
				c[d]=c[d]/2;
				b--;
				d--;
			}else{
				break;
			}
			if(b==0){
				rep(i,a){
					cnt+=c[i];
				}
				cout<<cnt;
				return 0;
			}
			if(d==0||c[d]==0){
				break;
			}
		}
		if(b==0){
			rep(i,a){
				cnt+=c[i];
			}
			cout<<cnt;
			return 0;
		}
		if(c[a-1]==0){
			cout<<0;
			return 0;
		}
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define All(a) (a).begin(),(a).end()

int main(){ 
  int a,b,c,x,y;
  ll ans=0;
  cin >> a>> b>>c>>x>>y;
  if(a+b<2*c){
    cout<<a*x+b*y<<endl;
    return 0;
  }else{
    int tmp=min(x,y);
    x-=tmp;y-=tmp;
    ans+=c*tmp*2;

    if(x>0 && a>2*c){
      ans+=x*c*2;
      x=0;
    }else if(y>0 && b>2*c){
      ans+=y*c*2;
      y=0;
    }else{
      ans+=a*x+b*y;
    }
    
    cout << ans <<endl;
  }

  return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    cin >> N;
    cout << N*(N-1)/2 << endl;
}



Measured memory_bytes: 3600
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		char[] input = Console.ReadLine().ToCharArray();
		var S = new StringBuilder();
        for(var i = 0; i < input.Length; i++)
		{
			if (input[i] == ',')
			{
				S.Append(" ");
			}
			else { S.Append(input[i].ToString()); }
		}

		Console.WriteLine(S);
	}
}


Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;


void solve(){
  string s;
  cin>>s;
  int q;
  cin>>q;
  int x=0;
  vector<pair<int,pair<int,char>>>v;
  int cnt=0;
  vector<int>sum(q+10);
  rep(i,q){
    int t;
    cin>>t;
    if(t==1){
      ++cnt;
    }
    else{
      int f;
      char c;
      cin>>f>>c;
      f--;
      v.eb(i,make_pair(f,c));
    }
    sum[i]=cnt;
  }
  if(cnt%2)reverse(all(s));
  string st="";
  rep(i,v.size()){
    char c=v[i].second.second;
    if((cnt-sum[v[i].first])%2==1){
      v[i].second.first=1-v[i].second.first;
    }
    if(v[i].second.first==0)st+=string{c};
    else s+=string{c};
  }
  reverse(all(st));
  s=st+s;
  cout<<s;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 5828
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n;
int a[100010];
int prefix[100010];
int postfix[100010];

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

	cin>>n;
	for(int i=0;i<n;i++)
        cin>>a[i];
    prefix[0]=a[0];
    for(int i=1;i<n;i++)
        prefix[i]=__gcd(prefix[i-1],a[i]);

    postfix[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--)
        postfix[i]=__gcd(postfix[i+1],a[i]);

    postfix[n]=prefix[n-2];
    int maxi=postfix[1];
    for(int i=1;i<n;i++)
        maxi=max(maxi,__gcd(prefix[i-1],postfix[i+1]));

    cout<<maxi;

	return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 998244353;

ll dp[3001][3002];

void init(){
    rep(i, 3001) rep(j, 3002) dp[i][j] = 0;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    init();
    int N, K; cin >> N >> K;
    int A[N+1]; rep(i, N) cin >> A[i+1];
    dp[0][0] = 1;
    for(int i = 0; i < N; i++){
        int item = A[i+1];
        for(int j = 0; j <= K; j++){
            dp[i+1][j] = (dp[i+1][j] + dp[i][j]*2) % mod;
            dp[i+1][min(j + item, 3001)] = (dp[i+1][min(j + item, 3001)] + dp[i][j]) % mod;
        }
    }
    cout << dp[N][K] << endl;
    return 0;
}

Measured memory_bytes: 74024
s=int(input())
v=[s]
for i in range(1000000):
    if v[i]%2==0:
        v.append(v[i]//2)
        if v.count(v[i])==2:
            print(i+1)
            break
    
    if v[i]%2==1:
        v.append(3*v[i]+1)
        if v.count(v[i])==2:
            print(i+1)
            break

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

//def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    int num500 = x / 500;
    int num5 = (x - 500 * num500) / 5;
    ll ans = num500 * 1000 + num5 * 5;
    out(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>

using namespace std;
#define DEBUG(x) cout<<#x<<": "<<x<<endl

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INT(a) int((a)+1e-9)
int DX[9]={1,1,1,1,1,2,2,2,3};
int DY[9]={-2,-1,0,1,2,-1,0,1,0};

typedef pair<int,int> Pii;
typedef pair<Pii,Pii> G;  //.F.F=cost, .F.S=0:hidari;1:migi, .S.F=y, .S.S=x

#define INF 100000
#define SUPxl 30
#define SUPyl 60

int xl,yl;
char tizu[SUPyl][SUPxl];
int isVisiteds[2][SUPyl][SUPxl];
priority_queue< G, vector<G>, greater<G> > que;

int isIkisugi(int y, int x){
	return (y<0 || yl<=y || x<0 || xl<=x);
}

int dijkstra(){
	while(!que.empty()){
		G g = que.top(); que.pop();
		int cost=g.F.F, turn=g.F.S, y=g.S.F, x=g.S.S;
		//DEBUG(cost); DEBUG(turn); DEBUG(y); DEBUG(x);
		if(tizu[y][x]=='T') return cost;
		if(isVisiteds[turn][y][x]) continue;
		isVisiteds[turn][y][x]=true;
		FOR(di,0,9){
			int ny = y + DY[di];
			int nx = x + (turn ? -DX[di] : DX[di]);
			if(isIkisugi(ny,nx)||tizu[ny][nx]=='X') continue;
			que.push( MP(MP( cost+((tizu[ny][nx]=='T')?0:(tizu[ny][nx]-'0')) , 1-turn ),MP( ny , nx )) );
		}
	}
	return -1;
}




int main(){
	while(true){
		cin >> xl >> yl;			if(!xl) return 0;
		que = priority_queue< G, vector<G>, greater<G> >();
		FOR(yi,0,yl) FOR(xi,0,xl){ isVisiteds[0][yi][xi]=false; isVisiteds[1][yi][xi]=false;}
		FOR(yi,0,yl) FOR(xi,0,xl){
			cin>>tizu[yi][xi];
			if(tizu[yi][xi]=='S'){
				que.push(MP(MP(0,0),MP(yi,xi)));
				que.push(MP(MP(0,1),MP(yi,xi)));
			}
		}
		cout<<dijkstra()<<endl;
	}
}

Measured memory_bytes: 1324
function main (s) {
	s=s.split(" ");
	if(s[0][0]<s[1][0])console.log("<\n");
	else if(s[0][0]>s[1][0])console.log(">\n");
	else console.log("=\n");
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
a = 0
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
for i in range(N):
    if(A[i] >= B[i]):
        a += B[i]
    else:
        a += A[i]
        B[i] -= A[i]
        if(A[i+1] > B[i]):
            a += B[i]
            A[i+1] -= B[i]
        else:
            a += A[i+1]
            A[i+1] = 0
print(a)

Measured memory_bytes: 18476
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
using ld = long double;
using ulli = unsigned long long int;
#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(args...) do {cerr << #args << " : "; debug(args); } while(0)
#define all(v) ((v).begin()),((v).end()) 
#define pb emplace_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
void debug () {cerr << endl;}
template < typename T, typename ... hello>void debug( T arg, const hello &... rest) {cerr << arg << ' ';debug(rest...);}
int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
void solve(){
	int n,m;
	cin>>n>>m;
	int sum = 0;
	for(int i = 0;i<m;i++){
		int x;
		cin>>x;
		sum += x;
	}
	cout<<(sum > n ? -1 : n - sum);
}
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}



Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;

  int a = 0;
  for(int i = 1; i < 100000; i++){
    if(i*i > n) { 
      cout << (i - 1)*(i - 1) << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<int, int> pii;

namespace io
{
	const int maxb = 1 << 15;
	char b[maxb], *s = b, *t = b;
	bool Getchar(char &ch)
	{
		return ch = s == t && (t = (s = b) + fread(b, 1, maxb, stdin)) == b ? 0 : *s ++;
	}
	int Getint()
	{
		char ch;
		while (Getchar(ch) && (ch < '0' || ch > '9'));
		int s = ch - '0';
		while (Getchar(ch) && ch >= '0' && ch <= '9')
			s = s * 10 + ch - '0';
		return s;
	}
}

using io::Getint;

template<typename ty> bool Chkmax(ty &x, const ty &y) { return x < y ? x = y, 1 : 0; }
template<typename ty> bool Chkmin(ty &x, const ty &y) { return x > y ? x = y, 1 : 0; }

const int maxn = 2e5 + 10;
const int inf = 1e9 + 10;

int M, Mn[maxn * 4];

void Init(int n)
{
	for (M = 1; M < (n + 2); M <<= 1);
	for (int i = M + M; i; -- i) Mn[i] = inf;
}

void Modify(int t, int val)
{
	for (t += M; t; t >>= 1) Chkmin(Mn[t], val);
}

int Query(int s, int t)
{
	int res = inf;
	for (s += M - 1, t += M + 1; s ^ t ^ 1; s >>= 1, t >>= 1)
	{
		if (~ s & 1) Chkmin(res, Mn[s ^ 1]);
		if (  t & 1) Chkmin(res, Mn[t ^ 1]);
	}
	return res;
}

bool b[maxn];
vector<int> opt[maxn];
int f[maxn];

int main()
{
	int n = Getint(), ans = 0;
	for (int i = 1; i <= n; ++ i)
	{
		b[i] = Getint();
		ans += !b[i];
	}
	int Q = Getint();
	for (int i = 1; i <= Q; ++ i)
	{
		int l = Getint(), r = Getint();
		opt[l].push_back(r);
	}
	Init(n);
	for (int i = 0; i <= n; ++ i)
	{
		if (i) f[i] = min(f[i - 1] + (b[i] ? 1 : -1), Query(i, i));
		int size = opt[i + 1].size();
		sort(opt[i + 1].begin(), opt[i + 1].end());
		for (int j = size - 1; ~ j; -- j)
			Modify(opt[i + 1][j], min(Query(i + 1, opt[i + 1][j]), f[i]));
	}
	ans += f[n];
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 12416
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    X = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    ans = 'Yes' if X >= 30 else 'No'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61692