akhauriyash/Code-Regression huggingface dataset:
// 17 52 ¨@WA18 -> 25´öª©Á½? ->@ÏÈfoOÉYÜ³ê31ªño 


#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
string data[12];

/* ûüpÏ */
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};

/* »èÖ */
bool iscorrect(int y,int x){
	if(y>11 || y<0)return false;
	if(x<0 || x>5)return false;
	return true;
}
bool ispuyo(int i,int j){
	return data[i][j] != 'O' && data[i][j] != '.';
}

/* Âð¦é */
int chainCount;
bool done[12][6];
void search(int y,int x,int c){
	if(data[y][x] != c)return;
	
	if(done[y][x])return;
	chainCount++;
	done[y][x] = true;
	rep(i,4){
		int nx = x+dx[i];
		int ny = y+dy[i];
		if(iscorrect(ny,nx))search(ny,nx,c);
	}
}

/* í·é */
void del(int y,int x,int c){
	if(data[y][x] != c)return;
	data[y][x] = '.';

	rep(i,4){
		int nx = x+dx[i];
		int ny = y+dy[i];
		if(iscorrect(ny,nx)){
			if(data[ny][nx]=='O') data[ny][nx]='.'; //×ÚµÄ¢½çÂ¢ÅÉÁ·
			del(ny,nx,c);
		}
	}
	
}

/* º³¹é */
void down(){
	rep(x,12){
		rep(w,6){
			rep(i,12-1){
				if(data[i+1][w] == '.'){
					swap(data[i+1][w],data[i][w]);
				}
			}
		}
	}
} 


int main(){
	int n;
	cin >>n;
	while(n--){
	
		rep(i,12)cin >> data[i];
		down();
		
		for(int retCount = 0;;retCount++){
			bool flag = true;
			
			rep(i,12)rep(j,6){
				if( ispuyo(i,j)){
				
					memset(done,0,12*6), chainCount = 0, search(i,j,data[i][j]);
					
					if(chainCount >= 4){
						del(i,j,data[i][j]);
						flag = false;
					}
				}
			}
			if(flag){
				cout << retCount << endl;
				break;
			}
			down();
		}
	}
}

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

int main() {
    long double a, b, x;
    long double ans;
    cin>>a>>b>>x;
    if(x <= a*a*b/2){
        ans = atan(a*b*b/(2*x))*180.0/M_PI;
    }else{
        ans = atan(2*(a*a*b-x)/(a*a*a))*180.0/M_PI;
    }
    cout << setprecision(10) << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    string s;
    ll k;
    cin>>s>>k;
    k--;

    ll cnt = 0;
    ll res = 1;

    rep(i,(ll) s.size()){
        if(s[i]!='1'){
            res = s[i]-'0';
            cnt = i;
            break;
        }
    }
    if(cnt<=k){
        cout<<res<<endl;
    }else{
        cout<<'1'<<endl;
    };

    return  0;
}


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

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

int main(){

  int n; cin>> n;
  using i64=long long;
  vector<i64> a(n);
  rep(i, n) cin>> a[i];

  vector<i64> sub(n+1, 0LL);
  rep(i, n) sub[i+1]=sub[i]+a[i];

  auto f=[&](i64 p, i64 q, i64 r, i64 s){
    i64 ret=max({p, q, r, s})-min({p, q, r, s});
    return ret;
  };

  // rep(i, n+1) cout<< i<< " "<< sub[i]<< endl;
  i64 mn=1e18;
  for(int i=2; i+1<n; i++){ // [0, i), [i, n)
    i64 sl=sub[i], sr=sub[n]-sub[i];
    // cout<< i<< " "<< sl<< " "<< sr<< endl;
    int j=(int)(upper_bound(sub.begin(), sub.end(), sl/2)-sub.begin());
    int k=(int)(upper_bound(sub.begin(), sub.end(), sub[i]+sr/2)-sub.begin());
    // assert(j>0);
    // cout<< "i j k"<< endl;
    // cout<< i<<" "<< j<<" "<< k<< endl;
    // i64 p=sub[j-1], q=sub[i]-sub[j-1];
    // // assert(k-1>i);
    // i64 r=sub[k-1]-sub[i], s=sub[n]-sub[k-1];
    // cout<< "p q r s"<< endl;
    // cout<< p<< " "<< q<< " "<< r<< " "<< s<< endl;
    // mn=min(mn, max({p, q, r, s})-min({p, q, r, s}));
    rep(t, 2)rep(u, 2) mn=min(mn, f(sub[j-t], sub[i]-sub[j-t], sub[k-u]-sub[i], sub[n]-sub[k-u]));
  }
  cout<< mn<< endl;

  // i64 sss=0;
  // rep(i, n) sss+=a[i];
  // for(int i=0; i<n; i++){
  //   for(int j=i+1; j<n; j++){
  //     for(int k=j+1; k<n; k++){
  //       i64 p=0, q=0, r=0;
  //       for(int t=0; t<=i; t++) p+=a[t];
  //       for(int t=i+1; t<=j; t++) q+=a[t];
  //       for(int t=j+1; t<=k; t++) r+=a[t];
  //       auto s=sss-(p+q+r);
  //       if(s==0) continue;
  //       if(max({p, q, r, s})-min({p, q, r, s})==36){
  //         cout<< i<< " "<< j<< " "<<k <<endl;
  //         cout<< p<< " "<<q <<" "<<r<< " "<<s<<endl;
  //       }
  //     }
  //   }
  // }
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll a,b;
  cin >> a >> b;
  cout << max(max(a+b,a-b),a*b);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a);
        a=(a*a);
        b/=2;
        if(res>INT_MAX){
            return INT_MAX;
        }
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return pro;
}
vector<int> prime;
void seive(){
    vector<bool > isprime(101,true);
    for(int i=2;i*i<=100;i++){
        if(isprime[i]){
            for(int j=i*i;j<=100;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=100;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,a;
    cin>>n>>m;
    set<ll> s;
    for(int i=0;i<m;i++){
        cin>>a;
        s.insert(a);
    }
    if(m==0) cout<<n;
    else{
        ll i=n;
        while(1){
            ll j=i;
            int flag=0;
            while(j>0){
                ll rem=j%10;
                j/=10;
                if(s.find(rem)!=s.end()){
                    flag=1;
                    break;
                }
            }
            if(flag==0) {
                cout<<i;
                return 0;
            }
            i++;
        }
    } 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int a = 0;
  
  for (int i = A; i < B + 1; i++) {
    int x_1 = i / 10000;
    int x_2 = (i % 10000) / 1000;
    int x_3 = ((i % 10000) % 1000) / 100;
    int x_4 = (((i % 10000) % 1000) % 100) / 10;
    int x_5 = i % 10;
    
    if (x_1 == x_5 && x_2 == x_4) {
      a += 1;
    }
  }
  
  cout << a << endl;
  
}

Measured memory_bytes: 256
use proconio::input;
use std::cmp;

fn main() {
    input! {
        a: isize,
        b: isize,
        c: isize,
        d: isize,
    }

    let ans = cmp::max(cmp::max(a*c, a*d), cmp::max(b*d, b*c));
    println!("{}", ans); 
}


Measured memory_bytes: 2164
// https://atcoder.jp/contests/abc130/tasks/abc130_a

#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, a;
    cin >> x >> a;
    if (x < a) {
        cout << "0\n";
    } else {
        cout << "10\n";
    }

    return 0;
}


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

using namespace std;

#define NMAX 121

int main() {
    int_fast64_t x;

    cin >> x;

    vector<int_fast64_t> n(NMAX);

    for(int_fast64_t i = 0; i < NMAX; ++i) {
        n.at(i) = i*i*i*i*i;
    }

    for(int i = 0; i < NMAX; ++i) {
        for(int j = 0; j <= i; ++j) {
            if(n.at(i) - n.at(j) - x == (int_fast64_t)0) {
                printf("%d %d\n", i, j);
                return 0;
            } else if (n.at(i) + n.at(j) - x == (int_fast64_t)0) {
                printf("%d %d\n", i, -j);
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3644
n = int(input())
d,x = map(int,input().split())
a = [int(input()) for _ in range(n)]
for i in range(n):
    cnt = 0
    for j in range(1000000):
        cnt = j * a[i] +1
        if cnt > d:
            break
    x += j
print(x)

Measured memory_bytes: 65076
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    string s;
    
    cin >>s;
    s[3]='8';
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	int team[101]={0};
	int ans[101] = {0};
	int n;
	int a,b,c,d;
	cin >> n;
	for(int i = 0; i < n * (n - 1) / 2; i++){
        scanf("%d %d %d %d",&a,&b,&c,&d);
        if(c > d){
            team[a] += 3;
            //printf("team[%d]の勝ち\n",a);
            //printf("team[%d]に勝ち点3プラス,team[%d]に勝ち点0プラス\n",a,b);
        }
        else if(c < d){
            team[b] += 3;
            //printf("team[%d]の勝ち\n",b);
            //printf("team[%d]に勝ち点0プラス,team[%d]に勝ち点3プラス\n",a,b);
        }
        else{
            //printf("引き分けです\n");
            //printf("team[%d]に勝ち点1プラス,team[%d]に勝ち点1プラス\n",a,b);
            team[a]++,team[b]++;
        }
	}

	int cn = 1;
	for(int l = 1; l <= n; l++){
	    int mx = 0;
	    int cnt = 0;
        for(int i = 1; i <= n; i++){
            mx = max(mx,team[i]);
        }
        for(int j = 1; j <= n; j++){
            if(team[j] == mx){
                team[j] = -1;
                ans[j] = cn;
                cnt++;
            }
        }
        cn += cnt;
	}
	for(int i = 1; i <= n; i++) cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define invrep(i,n) for(int i = (int)(n); i > 0; i++)
using ll = long long;
int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
    if (A.size() == n+1) {
        int now=0;
        rep(i, q) {
            if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}
int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    
    dfs(vector<int>(1,1));

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

Measured memory_bytes: 3604
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  const long long mod = 1e9 + 7;
  int x[2];
  cin >> x[0] >> x[1];
  static long long line[2][100000] = {};
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < x[i]; j++) {
      cin >> line[i][j];
    }
  }
  long long sum[2] = {};
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < x[i]; j++) {
      sum[i] += line[i][j] * j;
      sum[i] = (sum[i] % mod + mod) % mod;
      sum[i] -= line[i][j] * (x[i] - 1 - j);
      sum[i] = (sum[i] % mod + mod) % mod;
    }
  }
  cout << sum[0] * sum[1] % mod << endl;
  return 0;
}

Measured memory_bytes: 1792
N = int(input())
d = [[], []]
for i in range(N):
    x, y = map(int, input().split())
    d[0].append(x-y)
    d[1].append(x+y)

ans = 0
for i in range(2):
    ans = max(ans, max(d[i])-min(d[i]))
print(ans)


Measured memory_bytes: 100488
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}

int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int x,a;
	cin>>x>>a;
	if( x < a ) cout<<0<<endl;
	else cout<<10<<endl;
	
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <random>
#include <iomanip>
#include <map>

using namespace std;

typedef long long ll;

int N, M, P, Y;
string S[100010];

int main() {
    cin >> N >> M;
    vector<vector<pair<int, int>>> v(N+1);
    for (int i = 0; i < M; i++) {
        cin >> P >> Y;
        v[P].push_back({Y, i});
    }
    for (int i = 1; i <= N; i++) {
        sort(v[i].begin(), v[i].end());
        for (int j = 0; j < v[i].size(); j++) {
            string l = to_string(i), r = to_string(j + 1);
            while(l.size() < 6) l = '0' + l;
            while(r.size() < 6) r = '0' + r;
            S[v[i][j].second] = l + r;
        }
    }
    
    for (int i = 0; i < M; i++) cout << S[i] << endl;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e6 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

int K;
void input() {
  ;
  cin >> N >> K;
  va.resize(N);
  rep(i, 0, N - 1) { cin >> va[i]; };
}
void solve() {
  int ans = 0;
  for (auto x : va) {
    if (x >= K) ans++;
  }
  cout << ans << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 2025
#define ll long long
 
using namespace std;

ll n,k,num2[N];

int main()
{
	cin >> n >> k;
	const ll MOD=1e9+7;
	int tmp,num[N];
	ll ans=0;
	for(int i=1;i<=n;++i){
		cin >> num[i];
		for(int j=i-1;j>0;--j){
			if(num[i]<num[j])
				++ans;
		}
		++num2[num[i]];
	}
	ans=(ans*k)%MOD;
//	cout << ans << endl;
	for(int i=1;i<=n;++i){
		for(int j=num[i]+1;j<N;++j){
			ans=(ans+(num2[j]*((k*(k-1)/2)%MOD))%MOD)%MOD;
		}
	}

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


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

ll INF=20000000000000000;
 
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;  vector<vector<edge>> G;  vector<ll> d;

  graph(ll n){init(n);}

  void init(ll n){
    V = n;  G.resize(V);  d.resize(V);
    for(int i=0;i<V;i++){d[i] = INF;}
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;  e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    for(int i=0;i<V;i++){d[i] = INF;}
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top();  que.pop();  ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){d[e.to] = d[v]+e.cost;  que.push(P(d[e.to],e.to));}
      }
    }
  }
};

int N,M;
int main() {
  cin >> N >> M;
  vector<int> L(M),R(M),C(M);
  for(int i=0;i<M;i++)cin >> L[i] >> R[i] >> C[i];
  graph g1(N+10);
  for(int i=0;i<M;i++){
    g1.add_edge(L[i]-1,R[i]-1,C[i]);
  }
  for(int i=0;i<N;i++){g1.add_edge(N-i,N-i-1,0);}
  g1.dijkstra(0);
  if(g1.d[N-1]==INF)g1.d[N-1]=-1;
  cout << g1.d[N-1] << endl;
}

Measured memory_bytes: 10488
#include <stdio.h>

int main() {
    char s[1001];
    char t[1001];
    int si, ti, count, max = 0, tiCount = 0;
    gets(s);
    gets(t);

    for(si = 0; s[si] != '\0'; si++) {
        count = 0;
        for(ti = 0; t[ti] != '\0' && s[si + ti] != '\0'; ti++) {
            if(s[si + ti] == t[ti]) {
                count++;
            }
        }
        if(t[ti] == '\0' && count > max) max = count;
        if(si == 0) tiCount = ti;
    }

    printf("%d", tiCount - max);

    return 0;
}

Measured memory_bytes: 1588
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 while(sc.hasNext()) {
			int n = sc.nextInt();
			int[] a = new int[n];
			for(int i=0;i<n;i++) {
				a[i] = sc.nextInt();
			}
			Arrays.sort(a);
			List<Integer> A = new ArrayList<>();
			int min = Math.min(4, n);
			for(int i=0;i<min;i++)
				for(int j=0;j<min;j++) {
					if(i==j)continue;
					String aa = String.valueOf(a[i]);
					String bb = String.valueOf(a[j]);
					A.add(Integer.parseInt(aa+bb));
				}
			Collections.sort(A);
			System.out.println(A.get(2));
	  }	 
	}
}


Measured memory_bytes: 38796
package main

import(
	"fmt"
)

func main() {
	var n int
	var a string
	var b string
	var c string
	var ans int
	

	fmt.Scan(&n)
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	for i:=0; i<n; i++ {
		if a[i] != b[i] && a[i] != c[i] && b[i] != c[i] {
			ans += 2
		} else if a[i] == b[i] && a[i] == c[i] && b[i] == c[i] {
			ans += 0
		} else {
			ans += 1
		}
	}

	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N, M;
  int i,j,k;
  int money2=0;

  cin >>N;
  vector<string> blue(N);
  for(i=0;i<N;i++){
    cin >> blue.at(i); 
  }

  cin >> M;
  vector<string> red(M);
  for(i=0;i<M;i++){
    cin >> red.at(i);
  }

  for(i=0;i<N;++i){
      int money1=0;
    for(j=0;j<N;++j){
      if(blue.at(i) == blue.at(j))
        money1 += 1;
    }
    for(k=0;k<M;++k){
      if(blue.at(i) == red.at(k))
        money1 -= 1;
    }
    if(money1 > money2)
      money2 = money1;
    }

    if (money2 <= 0){
      cout << 0 << endl;
    }else{
      cout << money2 << endl;
    }

  }
  


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;


int main() {

    int H, W;
    cin >> H >> W;
    vector <string> ss;
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        ss.push_back(s);
    }

    vector<int> p = {-1, 0, 1};

    vector <string> result;


    for (int h = 0; h < H; h++) {

        result.emplace_back("");

        for (int w = 0; w < W; w++) {

            if (ss[h][w] == '.') {

                int count = 0;
                for (int i = 0; i < 3; i++) {
                    for (int j = 0; j < 3; j++) {

                        if (((h + p[i]) >= 0)
                            and ((h + p[i]) < H)
                            and ((w + p[j]) >= 0)
                            and ((w + p[j]) < W)
                            and ss[h + p[i]][w + p[j]] == '#') {
                            count += 1;
                        }
                    }
                }
                result[h] += std::to_string(count);
            } else {
                result[h] += '#';
            }
        }
    }

    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            cout << result[h][w];
        }

        if (h != H - 1) {
            cout << "\n";
        }
    }

    return 0;

}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;
const int MOD = 998244353;

struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = (node[i*2+1] + node[i*2+2])%MOD;
    }

    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = (node[2*k+1] + node[2*k+2])%MOD;
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return (vl + vr)%MOD;
    }
};

int main() {
    IOS;
    ll N, K;
    cin >> N >> K;
    // 一見DPっぽいが，データ構造っぽくも見える
    // mapでdとなりうるものを全部メモして，全探索 -> O(N * N)
    // vectorでdとなりうるものを全部メモして，全探索 -> O(size(ds)*N)
    // dp配列をセグ木でもって区間add する O(KN log N)
    LazySegmentTree seg( vector<ll>(N, 0) );
    // 高橋くん0にいるため
    seg.add(0,1,1);

    vector<pair<ll, ll>>lrs(K);
    
    for (int i=0; i<K; i++){
        ll li, ri;
        cin >> li >> ri;
        ri++;    
        pair<ll, ll>pr = {li,ri};
        lrs[i] = pr;
    }


    for (ll i=0; i<N; i++){
        // iから移動できるところにnowiを足す
        ll nowi = seg.getsum(i, i+1);

        for (ll j=0; j<K; j++){
            pair<ll,ll>pr = lrs[j];
            ll li, ri;
            // [li, ri)にnowiを加算
            li = pr.first+i;
            ri = pr.second+i;
            chmin(ri, N);
            

            seg.add(li, ri, nowi);
        }

    }

    //cout << seg.getsum(N, N+1) << endl;
    cout << seg.getsum(N-1, N)%MOD << endl;
    //cout << seg.getsum(N-2, N-1) << endl;
    //cout << seg.getsum(N-3, N-2) << endl;
    //cout << seg.getsum(N-4,N-3) << endl;
}

Measured memory_bytes: 12972
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    long long n,h[100005],dp[100005]={};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    for(int i=0;i<n;i++){
        dp[i]=10000000000;
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
    }
    cout<<dp[n-1]<<endl;
    return(0);
}

Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a == 5 && b == 5 && c == 7) {
			System.out.println("YES");
		} else if (a == 7 && b == 5 && c == 5) {
			System.out.println("YES");
		} else if (a == 5 && b == 7 && c == 5) {
			System.out.println("YES");
		} else {
			System.out.println("NO");

		}
	}

}


Measured memory_bytes: 21588
# coding: utf-8

N = int(input())
ai = [int(_) for _ in input().split()]

d = sum(ai)
ave = d / N

i = 0
ret = None
for i in range(N):
    a = ai[i]
    if(abs(a - ave) < d):
        d = abs(a - ave)
        ret = i

print(ret)

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

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int count = int.Parse(Reader.ReadLine());
        int[] list = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        Dictionary<int, int> dic = new Dictionary<int, int>();
        list.ToList().ForEach(a =>
        {
            if (dic.ContainsKey(a))
            {
                dic[a]++;
            }
            else
            {
                dic[a] = 1;
            }
        });

        bool isCorrect = true;
        if (count % 2 == 0)
        {
            if (dic.Keys.Any(a => a == 0 || a > count -1))
            {
                isCorrect = false;
            } else {
                for(int i=1; i<=count-1; i+=2) {
                    if(!dic.ContainsKey(i)) {
                        isCorrect = false;
                        break;
                    }
                    if(dic[i] != 2) {
                        isCorrect = false;
                        break;
                    }
                }
            }
        }
        else
        {
            if (dic.Keys.Any(a => a > count- 1))
            {
                isCorrect = false;
            }
            else
            {
                for (int i = 0; i <= count-1; i+=2)
                {
                    if (!dic.ContainsKey(i))
                    {
                        isCorrect = false;
                        break;
                    }
                    if (i == 0)
                    {
                        if (dic[i] != 1)
                        {
                            isCorrect = false;
                            break;
                        }
                    }
                    else
                    {
                        if (dic[i] != 2)
                        {
                            isCorrect = false;
                            break;
                        }
                    }
                }
            }
        }

        if (isCorrect)
        {
            long ans = 1;
            long mod = 1000000000 + 7;

            for (int i = 0; i < count / 2; i++)
            {
                ans *= 2;
                ans = ans % mod;

            }
            Console.WriteLine(ans);
        }
        else
        {
            Console.WriteLine(0);
        }

    }


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

7
6 4 0 2 4 0 2


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 14296
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int x;
  cin >> x;
  if(x>=30) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
#!/usr/bin/python
from sys import stdin

a, p = [1], [1]

def main():
    N, X = [int(x) for x in stdin.readline().rstrip().split()]
    for i in range(N):
        a.append(a[i] * 2 + 3)
        p.append(p[i] * 2 + 1)

    print(f(N, X))

def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)

int main(){
  int N,Q;
  int A[114514],B[114514];
  cin >> N >> Q;
  vector<int>V;
  REP(i,Q){
    cin >> A[i] >> B[i];
  }
  V.assign(N+2,0);
  /*V[1] = 2;
  REP(i,Q){
    if(V[A[i]]==2){
      V[B[i]]=max(V[B[i]],2);
      V[B[i]+1]=max(V[B[i]+1],1);
      V[B[i]-1]=max(V[B[i]-1],1);
      V[A[i]]=max(V[B[i]],0);
    }
    else if(V[A[i]]==1||V[A[i]+1]==2||V[A[i]-1]==2){
      V[B[i]]=max(V[B[i]],1);
    }
    V[0]=0;
    V[N+1]=0;
  }*/
  V[1]=2;
  V[2]=1;
  int now=1;//2はここにいる
  REP(i,Q){
    swap(V[A[i]],V[B[i]]);
    if(A[i]==now){
      now=B[i];
    }else if(B[i]==now){
      now=A[i];
    }
    V[now-1]=1;
    V[now+1]=1;


  }
  int ans=0;
  for(int i=1;i<=N;i++){
    //cout<<V[i]<<endl;
    if(V[i]>0)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t

int main(){
    int A, B;
    cin >> A >> B;
    
    int x = 1;
    int ans = 0;
    while (x < B){
        x  = x -1 + A;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, x, m = i_map()

    if x == 0:
        print(0)
        exit()

    ans = x
    tmp = x

    tmp_list = [x]

    has_find = False

    for i in range(n-1):
        if tmp*tmp%m in tmp_list:
            before_index = tmp_list.index(tmp*tmp%m)
            loop_list = []
            for l in range(before_index, i+1):
                loop_list.append(tmp_list[l])
            has_find = True
            break
        tmp_list.append(tmp*tmp%m)
        tmp = tmp*tmp%m
        ans += tmp

    if not has_find:
        print(ans)
        exit()

    # print(i,before_index)
    # print(loop_list)

    if before_index == 0:
        ans = 0
    else:
        ans = x
    tmp = x
    for _ in range(before_index-1):
        tmp = tmp*tmp%m
        ans += tmp

    n -= before_index

    loop_sum = sum(loop_list)

    loop_num = n // len(loop_list)
    mod_num = n % len(loop_list)

    ans += loop_sum * loop_num

    for i in range(mod_num):
        ans += loop_list[i]

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 77664
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main() {
	ll H, W;

	cin >> H >> W;
	if (H % 3 == 0 || W % 3 == 0) {
		cout << 0 << endl;
		return 0;
	}

	ll h1 = H / 2, h2 = (H + 1) / 2;
	ll w1 = W / 2, w2 = (W + 1) / 2;
	ll S1, S2, S3, ans = 1e+10;

	ll T, U;
	FOR(i, 1, W) {
		S1 = h1 * i;
		S2 = h2 * i;
		S3 = (W - i)*H;

		T = max(max(S1, S2), S3);
		U = min(min(S1, S2), S3);
		ans = min(T - U, ans);
	}
	FOR(i, 1, H) {
		S1 = w1 * i;
		S2 = w2 * i;
		S3 = (H - i)*W;

		T = max(max(S1, S2), S3);
		U = min(min(S1, S2), S3);
		ans = min(T - U, ans);
	}

	T = ((W + 2) / 3)*H;
	U = (W / 3)*H;

	ans = min(T - U, ans);

	T = ((H + 2) / 3)*W;
	U = (H / 3)*W;

	ans = min(T - U, ans);



	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 3e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;

int A[MAXN];
char S[MAXN];
int depth[MAXN][3];

void dfs(int here,int num)
{
    int there;

    for(int i=0;i<graph[here].size();i++)
    {
        there = graph[here][i];
        if(depth[there][num]!=-1)continue;
        depth[there][num] = depth[here][num]+1;
        dfs(there,num);
    }
    return;
}

int getlength(int n)
{
    for(int i=1;i<=n;i++)
        depth[i][0]= depth[i][1] = -1;

    depth[1][0] = 0;

    dfs(1,0);

    int idx = 1;
    int mx = 0;

    for(int i=1;i<=n;i++){
        if(mx<depth[i][0]){
            mx = depth[i][0];
            idx = i;
        }
    }
    depth[idx][1] = 0;
    dfs(idx,1);

    for(int i=1;i<=n;i++)
        mx = max(mx,depth[i][1]);
    return mx;
}

int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;

    scanf("%d",&n);

    graph = vector<vector<int> > (n+1);

    for(int i=1;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        graph[x].push_back(y);
        graph[y].push_back(x);
    }

    int len = getlength(n);

    if(len%3==1)printf("Second");
    else printf("First");

    return 0;
}


Measured memory_bytes: 22912
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    int x, y;
    cin >> x >> y;
    int sm;
    rep(i, x + 1){
        sm = i * 4 + (x - i) * 2;
        if(sm == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3592
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    double r;
    cin>> r;

    cout << r * r * M_PI / M_PI << endl;
    return 0;
}


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

void printrec(int h, int w){
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(i==0 || i==h-1 || j==0 || j==w-1) putchar('#');
      else putchar('.');
    }
    putchar('\n');
  }
}

int main(){
  int h, w;
  vector<int> hv;
  vector<int> wv;
  while(true){
    cin >> h >> w;
    if(h==0 && w==0){
      break;
    }

    hv.push_back(h);
    wv.push_back(w);
  }

  for(int i=0; i<(int)hv.size(); i++){
    printrec(hv[i], wv[i]);
    putchar('\n');
  }

  return 0;
}



Measured memory_bytes: 3168
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

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

using namespace std;
int a,b;

int main(){
  cin >> a >> b;
  int ans =0;
  for(int i = a; i<=b;i++){
    string s = to_string(i);
    string s2 = s;
    reverse(s2.begin(),s2.end());
    if(s==s2) ans ++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N;
    cin >> N;
    ll ans = 0, mae = -1;
    for(ll i = 0; i < N; i++){
        ll a;
        cin >> a;
        if(a == mae){
            ans++;
            mae = -1;
        }else{
            mae = a;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define MAX 100000

int partition(int [],int,int);
int x,i,p=1;

int main(){

  int A[MAX];
  int n,p=1,q;

  scanf("%d",&n);

  for( i = 1 ; i <= n ; i++ ) {
    scanf("%d",&A[i]);
  }
  
  //for( i = 1 ; i <= n ; i++ ) {
    q = partition(A,p,n);

  for( i = 1 ; i < n ; i++ ){
    if(i == q) {
      printf("[%d] ",A[i]);
      continue;
    }
    printf("%d ",A[i]);
  }

  printf("%d\n",A[i]);

  return 0;
}
  
int partition(int A[],int p,int n){
  int j,key;

  x = A[n];
  i = p-1;
  for( j = p ; j <= n-1 ; j++ ){
    if( A[j] <= x ){
      i = i+1;
      key = A[j];
      A[j] = A[i];
      A[i] = key;
    }
  }
      key = A[n];
      A[n] = A[i+1];
      A[i+1]= key;
  return i+1;
}

Measured memory_bytes: 988
import sys


def input():
    return sys.stdin.readline().rstrip()

def euc(a,b):

    while b!=0:
        a,b =b,a%b

    return a

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append(i)

    if temp != 1:
        arr.append(temp)

    if arr == []:
        arr.append(n)
    return arr



def main():

    N =int(input())
    A =list(map(int,input().split()))

    PS =set()

    current =A[0]
    for i in range(N-1):
        current =euc(current,A[i+1])
        if current ==1:
            break

    else:
        print("not coprime")
        exit()


    for i in range(N):
        if A[i]==1:
            continue
        aa =factorization(A[i])
        for i in aa:
            if i in PS:
                print("setwise coprime")
                exit()
            else:
                PS.add(i)

    print("pairwise coprime")
    exit()



if __name__ == "__main__":
    main()


Measured memory_bytes: 196788
#include<stdio.h>
int main(void)
{
	int a[31] = {0};
	int n, m, k, b;
	int sum = 0;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &k);
		for(int j = 0; j < k; j++)
		{
			scanf("%d", &b);
			a[b]++;
		}
	}
	for(int i = 1; i <= m; i++)
	{
		if(a[i] == n)
		{
			sum++;
		}
	}
	printf("%d", sum);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int H, W;
string S[25];

int dis[25][25];

int INF = 9999;

void SHOKI(void) {
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			dis[i][j] = INF;
		}
	}
}

queue<pair<int,int> > q;

void BFS(int i, int j) {
	
	q.push(make_pair(i, j));

	while (q.size() > 0) {
		pair<int, int> p;
		p= q.front();
		int u = p.first;
		int v = p.second;
		q.pop();

		if (S[u - 1][v] == '.' && dis[u - 1][v] == INF) { dis[u - 1][v] = dis[u][v] + 1;  q.push(make_pair(u - 1, v)); }
		if (S[u +1][v] == '.' && dis[u + 1][v] == INF) { dis[u + 1][v] = dis[u][v] + 1;  q.push(make_pair(u + 1, v)); }
		if (S[u][v-1] == '.' && dis[u][v-1] == INF) { dis[u][v-1] = dis[u][v] + 1;  q.push(make_pair(u , v-1)); }
		if (S[u][v + 1] == '.' && dis[u][v +1] == INF) { dis[u][v + 1] = dis[u][v] + 1;  q.push(make_pair(u, v +1)); }

	}

}

int CALC(void) {
	int ret = 0;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (dis[i][j] == INF) { continue; }
			ret = max(ret, dis[i][j]);
		}
	}

	return ret;
}

int main(void) {

	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		cin >> S[i];
	}

	for (int i = 0; i <= W; i++) {
		S[0] += "#";
		S[H + 1] += "#";
	}

	for (int i = 1; i <= H; i++) {
		S[i] = "#" + S[i] + "#";
	}

	int ans = 0;

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (S[i][j] != '.') { continue; }
			SHOKI();
			dis[i][j] = 0;
			BFS(i, j);
			ans = max(ans, CALC());
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

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

int alpha[30];

int main() {
    string S;
    while (cin >> S) {
        int num = 30;
        rep(i, S.size()) {
            num = tolower(S[i]) - 'a';
            if (0 <= num&&num <= 26)alpha[num]++;
        }
    }

    rep(i, 26) {
        cout << char('a' + i) << ' ' << ':' << ' ' << alpha[i] << endl;
    }
}


Measured memory_bytes: 3224
n = int(input())
red = [list(map(int, input().split())) for _ in range(n)]
blue = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for c, d in sorted(blue, key=lambda x: x[0]):
    for a, b in sorted(red, key=lambda x: x[1], reverse=True):
        if a < c and b < d:
            ans += 1
            red.remove([a, b])
            break
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include<queue>
using namespace std;

int main() {
	long long int X, Y;
	cin>>X >> Y;
	long int Z = 0;

	while (X <= Y) {
		X = X * 2;
		Z++;
	}

	cout << Z << endl;
	
	return 0;
}

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

int main() {
  int N,A,X,Ans;
  Ans=0;
  cin >> N;
  for(int i=0; i<N; i++){
  cin>>A;
    X=0;
    while(A%2 == 0){
    A/=2;
    X++;
    }
    if(i==0){
      Ans = X ;
    }
    if(X < Ans){
      Ans = X ;
    }
  }
  cout << Ans << endl;
}


Measured memory_bytes: 256
def main():
    N, T = map(int, input().split())
    t = list(map(int, input().split()))
    s, e = 0, 0
    ans = 0
    for i in range(N):
        if t[i] <= e:
            e = t[i] + T
        else:
            ans += e - s
            s = t[i]
            e = t[i] + T
    ans += e - s
    print(ans)


main()


Measured memory_bytes: 25200
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"unsafe":"safe");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int a,b; cin>>a>>b;
  bool ok = a<=b;
  ok();
  return 0;
}

Measured memory_bytes: 3608
n = int(input())
p = list(map(int,input().split()))
counter = 0
for i in range (n-2):
    if p[i] < p[i + 1] and p[i + 1] < p[i + 2] or p[i + 2] < p[i + 1] and p[i + 1] < p[i]:
        counter +=1
print(counter)

Measured memory_bytes: 3060