akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int a, b, x;
    cin >> a >> b >> x;
    if ( (x>= a) && (a + b  >= x)) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll r;
	while(cin>>r) {
		ll ans = 3*r*r;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<time.h>
#include<sstream>
#define MINN -1e8 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF=0x3f3f3f3f3f3f;
const int P=1e9+7;
const int MAXN=32000;
const double pi=atan(1)*4;
//const int MINN=-1e8;
const ll mod=998244353;

//map<string,ll> m;
//map<ll,ll> m;

//set<ll> s;

//vector<ll> v;

//scanf("%lld",&t);
ll n;
ll a[100005];
ll ans=1;
ll powmod(ll a,ll b)     //快速幂 
{
	ll tmp=a%mod;
	ll ans=1;
	while(b)
	{
		if(b&1)ans=ans*tmp%mod;
		tmp=tmp*tmp%mod;
		b>>=1;
	}
	return ans%mod;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	if(a[0]!=0)
	{
		cout<<0;return 0;
	}
	else
	{
		sort(a+1,a+n);
//		for(int i=0;i<n;i++)
//		{
//			cout<<a[i]<<" ";
//		}
//		cout<<endl;
		ll cur=0,cnum=1,plen=1,pnum=0;
		for(int i=1;i<n;i++)
		{
			if(a[i]!=cnum)
			{
				if(a[i]!=cnum+1)
				{
					cout<<0;return 0;
				}
				else
				{
					ans=ans*powmod(plen,cur)%mod;
					plen=cur;pnum=cnum;cur=1;cnum=a[i];
				}
			}	
			else cur++;
		}
		ans=ans*powmod(plen,cur)%mod;
		cout<<ans;
	}
	return 0;
}
//ll n,m,t,a,x,ans,res;
//ll powmod(ll a,ll b)     //快速幂 
//{
//	ll tmp=a%mod;
//	ll ans=1;
//	while(b)
//	{
//		if(b&1)ans=ans*tmp%mod;
//		tmp=tmp*tmp%mod;
//		b>>=1;
//	}
//	return ans%mod;
//}


//bool is_prime(ll a)     //判断素数 
//{
//	if(a==2)return 1;
//	else if(a==1||a%2==0)return 0;
//	else
//	{
//		for(ll i=3;i*i<=a;++i)
//		{
//			if(a%i==0)return 0;
//		}
//	}
//	return 1;
//}


Measured memory_bytes: 1024
import java.util.*;
 
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		int N = c.length;
		boolean ans = true;
		
		for (int i=0; i<N/2; i++) {
			if (c[i] != c[N-1-i]) {
				ans = false;
				break;
			}
		}
		
		for (int i=0; i<(N/2)/2 ;i++) {
			if (c[i] != c[N/2-1-i]) {
				ans = false;
				break;
			}
		}
		System.out.println(ans ? "Yes" : "No");
	}
}

Measured memory_bytes: 23636
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const ll INF = 1LL << 60;

struct edge{
	int to; ll cost;
};
class Graph{
	public:
	vector<vector<edge> > adj;
	Graph(){}
	Graph(int V){
		adj.resize(V);
	}
	void add_edge(int s, edge e){
		adj[s].push_back(e);
	}
	bool comp(edge &a, edge &b){
		return a.cost < b.cost;
	}
	vector<ll> dijkstra(int s){
		priority_queue<pair<ll, int> , vector<pair<ll, int> > , greater<pair<ll, int> > > pqa;
		vector<ll> dist(adj.size(), INF);
		dist[s] = 0;
		pqa.push(make_pair(0, s));
		while(!pqa.empty()){
			pair<ll, int> p = pqa.top(); pqa.pop();
			int u = p.second;
			if(dist[u] < p.first) continue;
			for(int v = 0; v < adj[u].size(); v++){
				edge e = adj[u][v];
				if(dist[e.to] > dist[u] + e.cost){
					dist[e.to] = dist[u] + e.cost;
					pqa.push(make_pair(dist[e.to], e.to));
				}
			}
		}
		return dist;
	}
};

int main(){
	int V, E, r;
	cin >> V >> E >> r;
	Graph G(V);
	for(int i = 0; i < E; i++){
		int s, t, d;
		cin >> s >> t >> d;
		G.add_edge(s, (edge){t, d});
	}
	vector<ll> dist = G.dijkstra(r);
	for(int i = 0; i < V; i++){
		if(dist[i] == INF) cout << "INF" << endl;
		else cout << dist[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 19500
#include<bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
double PI=acos(-1);
int n,k,arr[105],dp[100005][2];
bool solve(int sum,int p){
    bool check=1;
    bool ret;
    if(dp[sum][p]!=-1) return dp[sum][p];
    if(p) ret=1;
    else ret=0;
    for(int i=0;i<n;i++){
        if(sum>=arr[i]){
            check=0;
            if(p) ret=ret && solve(sum-arr[i],1-p);
            else ret= ret||solve(sum-arr[i],1-p);
        }
    }
    if(check==0) return dp[sum][p]=ret;
    return dp[sum][p]=p;
}

int main(){
    IO
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++) cin>>arr[i];
    //solve(k,0);
    if(solve(k,0)==1) cout<<"First\n";
    else cout<<"Second\n";
    //for(int i=0;i<=k;i++) cout<<dp[i][0]<<" "<<dp[i][1]<<'\n';
    return 0;
}


Measured memory_bytes: 12212
#include <stdio.h>

int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    /* 0 1
     * -1 0
     */
    int x=a-c,y=b-d;
    int e,f,g,h;
    e=c+y;f=d-x;
    g=e+x;h=f+y;
    printf("%d %d %d %d",e,f,g,h);
    return 0;
}   

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

using namespace std;

const int nax=1e5+5;
long long int dp[111][nax];




int main()
{
    int n,w; cin>>n>>w;
    long long int waga[111];
    long long int val[111];
    for(int i=1;i<=n;i++)
    {
        cin>>waga[i]>>val[i];
    }
    //dp[i][j]=minimalna waga na prefixie i o koszcie j
    for(int i=0;i<nax;i++) dp[0][i]=1e18;
    dp[0][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<nax;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j>=val[i]) dp[i][j]=min(dp[i][j],dp[i-1][j-val[i]]+waga[i]);
        }
    }
    for(int i=nax-1;i>=1;i--)
    {
        if(dp[n][i]==0 || dp[n][i]>w) continue;
        cout<<i<<endl; return 0;
    }
    return 0;
}


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

int main() {
  string X;
  cin >> X;
  int N = X.size();
  
  int S = 0;
  int count = 0;
  for (int i = 0; i < N; i++){
    if (X[i] == 'S'){
      S++;
    }
    if (X[i] == 'T'){
      if (S > 0){
        count++;
        S--;
      }
    }
  }
  
  cout << N - 2 * count;
}

Measured memory_bytes: 3728
fn read() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    read();
    let mut v: Vec<u32> = read()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    v.sort();
    let ans = v.iter().fold(v[0] as f64, |x, &y| (x + y as f64) / 2.0);
    println!("{}", ans);
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n;
    cin>>n;

    Vi dp(n+1,INF);
    dp[0]=0;
    REP(i,1,n+1){
        dp[i]=dp[i-1]+1;
        int j=1;
        while(pow(6,j)<=i){
            chmin(dp[i],dp[i-pow(6,j)]+1);
            j++;
        }
        j=1;
        while(pow(9,j)<=i){
            chmin(dp[i],dp[i-pow(9,j)]+1);
            j++;
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){
    int N;
    int count=0;
    cin>>N;
    int A[N];
    for(int i=0; i<N; i++){
        cin>>A[i];
    }
    for(int i=0; i<N; i++){
        int minj=i;
        for(int j=i; j<N; j++)  if(A[j]<A[minj])    minj=j;
        int memo=A[i];
        A[i]=A[minj];
        A[minj]=memo;
        if(A[minj]!=A[i]) count++;//{   count++; cout<<i+1<<" change"<<endl;}
        /*for(int k=0; k<N-1; k++){
            cout<<A[k]<<" ";
        }
        cout<<A[N-1]<<endl;*/
    }
    for(int i=0; i<N-1; i++)    cout<<A[i]<<" ";
    cout<<A[N-1]<<endl;
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define pb push_back

typedef long long int ll;
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie();
	
	set<ll> se;
	ll n, k;
	cin >> n >> k;
	for (ll i = 0; i < k; i++) {
		ll x;
		cin >> x;
		se.insert(x);
	}
	ll tmp = n;
	while (true) {
		bool ya = true;
		ll tmp2 = tmp;
		while (tmp2) {
			if (se.count(tmp2%10)) {
				ya = false;
			}
			tmp2 /= 10;
		}
		if (ya) {
			cout << tmp;
			return 0;
		}
		tmp++;
	}
	
	return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll S;
ll a;
int main(){
    scanf("%lld", &S);
        ll a = 1e9;
        ll d = S / a;
        ll b = d + (S % a ? 1 : 0);
        ll c = S - a * d;
        printf("%lld %lld %lld 0 0 %lld", a, b, c, d);

    return 0;
}

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

int main()
{
	int x, y;

	while (1)
	{
		cin >> x >> y;

		if (x == 0 && y == 0)
		{
			return 0;
		}
		if (x <= y)
		{
			cout << x << " " << y << "\n";
		}
		if(x > y)
		{
			cout << y << " " << x << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 2988
n, m, l = map(int, input().split())

a=[list(map(int,input().split())) for _ in range(n)] # n x m                    
b=[list(map(int,input().split())) for _ in range(m)] # m x l                    
c=[[0 for _ in range(l)] for _ in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k]*b[k][j]

for i in c:
    print(' '.join(map(str, i)))


Measured memory_bytes: 6892
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N;cin>>N;
    int T[N];
    int sum=0;
    REP(i,N){
        cin>>T[i];
        sum+=T[i];
    }
    int M;cin>>M;
    int A[M][2];
    REP(i,M){
        cin>>A[i][0]>>A[i][1];
        cout<<sum-T[A[i][0]-1]+A[i][1]<<endl;
    }
}

Measured memory_bytes: 256
module modu
        implicit none
        
        contains
        
        recursive function solve( h ) result( r )
          implicit none
          integer(16) :: h,r
          
          if( h==1 )then
            r = 1
          else
            r = 1 + 2*solve( h/2 )
          end if
        end function
      end module
      
      PROGRAM piyo
      use modu
      IMPLICIT NONE
      integer(16) :: h
      
      read*,h
      
      print*,solve( h )
      
      
      
      END PROGRAM

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long int> X(N);
    vector<long long int> x(N);
    for(int n=0; n<N; n++) {
        cin >> X[n];
        x[n] = X[n];
    }
    
    sort(x.begin(), x.end());
    
    for(int n=0; n<N; n++) {
        if(X[n]<=x[N/2-1]) {
            cout << x[N/2] << endl;
        } else if(X[n]>=x[N/2]) {
            cout << x[N/2-1] << endl;
        }
    }


    return 0;
    
}

Measured memory_bytes: 5376
import sys
sys.setrecursionlimit(10**7)
n = int(input())
ls = []


def dfs(s):
    if len(s) == n:
        ls.append(s)
        return 0
    else:
        for x in map(chr, range(97, ord(max(s))+2)):
            dfs(s+x)


dfs("a")
ls.sort()
for x in ls:
    print(x)


Measured memory_bytes: 12664
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
  long long N, M;

  cin >> N >> M;

  if(2*N >= M){
    cout << M/2 << endl;
  }
  else{
    cout << N+(M-2*N)/4 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split(" ");
  var N = Number(input[0]);
  var D = Number(input[1]);
  var result = 0;

  if(N > D){
    result = Math.ceil(N/(D*2 + 1));
  }
  else{
    result = 1;
  }
  
 	console.log(result);
 }
 //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int maxEven(int n, vector<int> a){
    int index = -1;
    for(int i = 0; i < n; i++){
        if(a[i] % 2 == 0){
                index = i;
                return index;
        }
    }
    return index;
}

int main(){
    int N;
    int c = 0;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    int i = maxEven(N, a);
    while(i != -1){
        a[i] = a[i] / 2;
        c++;
        i = maxEven(N,a);
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
const int MOD = 1000000007;

int main() {
    // 10^5回以上で偶数回移動ならば10^100回移動したのと同じ結果になる
    // RL部分に人が集まる RLでループ L|Rと境界ができる
    // 例) RRLLLL | RL | RRLL
    // ループ部分のR(L)から偶数個or奇数個離れているかで最終状態が決まる
    // ランレングス法でRのグループとLのグループを作る

    string s;
    cin >> s;

    long long size = s.size();

    vector<long long> ans(size, 0);

    // Rグループ
    long long count = 0;
    rep(i, size) {
        if (s.at(i) == 'R') {
            count++;
            continue;
        } else {
            long long even_num = count / 2;
            long long odd_num = count - even_num;
            ans.at(i) += even_num;
            ans.at(i - 1) += odd_num;
            count = 0;
        }
    }

    // Lグループ
    count = 0;
    for (long long i = size - 1; i >= 0; i--) {
        if (s.at(i) == 'L') {
            count++;
            continue;
        } else {
            long long even_num = count / 2;
            long long odd_num = count - even_num;
            ans.at(i) += even_num;
            ans.at(i + 1) += odd_num;
            count = 0;
        }
    }

    rep(i, size) {
        cout << ans.at(i) << " ";
    }
}


Measured memory_bytes: 4300
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL dp[200010][4];

void add(LL &a, LL b) {
	a = (a + b) % MOD;
}

//dp i番目までみたときの、状態jをそれまでに完成させた文字列で決めておく

//j=0 ""
//j=1 "A"
//j=2 "AB"
//j=3 "ABC"

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


	//dp初期化、場合の数を数える問題なので0で初期化
	for (int i = 0; i < 100010; i++) {
		for (int j = 0; j < 4; j++) {
			dp[i][j] = 0;
		}
	}

	//0番目までみて文字列が何も無い状態が一通り
	dp[0][0] = 1;

	for (int i = 0; i < s.size(); i++) {
		//siを使わない

		for (int j = 0; j < 4; j++) {
			//si=?でないなら、状態i,jの数はそのまま引き継ぐ
			if (s[i] != '?') {
				dp[i + 1][j] = dp[i][j];
			}
			//si=?ならA,B,C 3文字分違う文字列になるので、3倍してやる
			else {
				dp[i + 1][j] = dp[i][j]*3%MOD;
			}
		}


		//siを使って遷移する

		if (s[i] == '?') {
			//""→A

			dp[i + 1][1] += dp[i][0];
			dp[i + 1][1] %= MOD;

			//A→AB

			dp[i + 1][2] += dp[i][1];
			dp[i + 1][2] %= MOD;
			//AB→ABC

			dp[i + 1][3] += dp[i][2];
			dp[i + 1][3] %= MOD;
		}

		if (s[i] == 'A') {
			dp[i + 1][1] += dp[i][0];
			dp[i + 1][1] %= MOD;
		}

		if (s[i] == 'B') {
			dp[i + 1][2] += dp[i][1];
			dp[i + 1][2] %= MOD;
		}

		if (s[i] == 'C') {
			dp[i + 1][3] += dp[i][2];
			dp[i + 1][3] %= MOD;
		}
	}

	cout << dp[s.size()][3] << endl;
	return 0;
}

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

int main() {
  int S;
  cin >> S;
  
  int s1 = S / 100;
  int s2 = S - s1*100;
  
  if( s1 == 0 ){ //s1 = 00のとき
    if( s2 < 13 && s2 != 0 ){
      cout << "YYMM" << endl;
      return 0;
    }else{
      cout << "NA" << endl;
      return 0;
    }
  }else if( s1 < 13 ){ //s1が0ではなく、かつ12以下の時
    if( s2 < 13 && s2 != 0 ){
      cout << "AMBIGUOUS" << endl;
      return 0;
    }else{ //s2が12より大きいか0のとき
      cout << "MMYY" << endl;
      return 0;
    }
  }else if( s1 > 12 ){ //s1が13以上の時
    if( s2 < 13 && s2 != 0 ){
      cout << "YYMM" << endl;
      return 0;
    }else{
      cout << "NA" << endl;
    }
  }
      
}

Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
x,y = readInts()
if x % y == 0:
    print(-1)
    exit()
while x <= 10**18:
    if x % y != 0:
        print(x)
        exit()
    x += x
print(-1)


Measured memory_bytes: 5276
using System;
namespace kozaiyApp
{
    public class Factorization
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            int restM = M;
            long ans = 1;

            // 素因数分解
            for (int i = 2; i * i <= restM; i++)
            {
                if (restM % i == 0)
                {
                    int cnt = 0; // cntは2^Xとか3^XとかのXの部分　何乗か
                    while (restM % i == 0)
                    {
                        cnt++;
                        restM /= i;
                    }
                    ans *= calcComb(cnt + N - 1, N - 1); // N-1はcntと同じ
                    ans %= mod;
                }
            }

            // 最後に素数が残っている分を処理する
            if (restM != 1)
            {
                ans *= calcComb(1 + N - 1, N - 1); // N-1はcntと同じ
                ans %= mod;
            }

            Console.WriteLine(ans);
        }

        static long mod = 1000000007;

        // コンビネーションを求める
        // (10*9*8) / (3*2*1)
        // 10*9*8 -> ansMul
        // 3*2*1 -> ansDiv
        public static long calcComb(int a, int b)
        {
            if (b > a - b) return calcComb(a, a - b);
            long ansMul = 1;
            long ansDiv = 1;
            for (int i = 0; i < b; i++)
            {
                ansMul *= (a - i);
                ansDiv *= (i + 1);
                ansMul %= mod;
                ansDiv %= mod;
            }
            // ansMul / ansDiv を求めたい
            // ansDivの逆元を使って求める
            long ans = ansMul * modpow(ansDiv, mod - 2) % mod;
            return ans;
        }

        // aのp乗を求めるアルゴリズム
        // p=62の時、pの変化は、62->31->30->15->14->7->6->3->2->1->0 と半分半分になっていく
        // よって計算量はO(logp)になる
        public static long modpow(long a, long p)
        {
            if (p == 0) return 1;
            if (p % 2 == 0) // pが偶数の時
            {
                long halfP = p / 2;
                long half = modpow(a, halfP);
                // a^(p/2)をhalfとして、hlf*halfを計算
                return half * half % mod;
            }
            else // pが奇数の時
            {
                // pを偶数にするために1減らす
                return a * modpow(a, p - 1) % mod;
            }
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string ss;
	cin>>ss;
	ll x,y,z,n,ans=1;
	n=ss.size();
	char s[n+1];
	for(int a=0;a<n;a++)
	s[a+1]=ss[a];
	for(int a=1;a<=n;a++)
	{
		if(s[a]!=s[n+1-a])
		{
			ans=0;
			break;
		}
	}
	ll m=(n-1)/2;
	for(int a=1;a<=m;a++)
	{
		if(s[a]!=s[m+1-a])
		{
			ans=0;
			break;
		}
	}
	ll mm=(n+3)/2;
	for(int a=mm;a<=n;a++)
	{
		if(s[a]!=s[n+1-a])
		{
			ans=0;
			break;
		}
	}
	if(ans==0)
	cout<<"No";
	else 
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
// Aizu Vol-1 0148: Candy and Class Flag
// 2017.8.2

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);
char buf[50];

int main()
{
	while (gets(buf) != NULL) {
		printf("3C%02d\n", (atoi(buf)-1) % 39 + 1);
	}
	return 0;
}

Measured memory_bytes: 536
a, b, x = gets.chomp.split(' ').map(&:to_i)

r = 45.to_f
if x <= a * a * b / 2
  r = (Math.atan(x.to_f / (b**2 * a) * 2) - Math::PI / 2) * 180 / Math::PI * -1
else
  r = Math.atan(((a.to_f * a * b) - x) /(a**3) * 2) * 180 / Math::PI
end

puts r



Measured memory_bytes: 14552
a,b=map(int,input().split())
list=[[0 for i in range(2)] for j in range(a)]
for i in range(a):
    list[i]=input().split()
n=0
s=0
while n!=a:
    if int(list[n][1])>b:
        list[n][1]=int(list[n][1])-b
        list.append(list[n])
        list.pop(n)
        s+=b
    else:
        print(list[n][0],s+int(list[n][1]))
        s+=int(list[n][1])
        n+=1



Measured memory_bytes: 17068
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,j,x,n,k,y,c;
    cin>>a>>b>>c;
     x=a-b;
     k=c-x;
     if(k<0)
        k=0;
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

char s[110], t[110], tmp[10];
int main()
{
  scanf("%s%s", s, t);
  for (int j = 0; j < strlen(s) - 1; j++)
  {
    for (int i = 0; i < strlen(s) - 1; i++)
    {
      if (s[i] > s[i + 1])
      {
        tmp[0] = s[i];
        s[i] = s[i + 1];
        s[i + 1] = tmp[0];
      }
    }
  }
  for (int j = 0; j < strlen(t) - 1; j++)
  {
    for (int i = 0; i < strlen(t) - 1; i++)
    {
      if (t[i] < t[i + 1])
      {
        tmp[0] = t[i];
        t[i] = t[i + 1];
        t[i + 1] = tmp[0];
      }
    }
  }
  puts(strcmp(s, t) < 0 ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 128
// ABC086C - Traveling
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	nowt, nowx, nowy := 0, 0, 0
	txy := make([]int, 3)
	flag := true

	for i := 0; i < n; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scan(&txy[j])
		}
		dt := txy[0] - nowt
		dx := int(math.Abs(float64(txy[1] - nowx)))
		dy := int(math.Abs(float64(txy[2] - nowy)))

		if dt < dx+dy || dt%2 != (dx+dy)%2 {
			flag = false
			break
		}
	}

	if flag {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  bool ans=0;
  rep(i,100100100){
    if(a*i%b==c){
      ans=1;
    }
  }
  if(ans){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

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

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

long long lcm(long long m, long long n ) {
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

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

    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    // long long lcm_val = 1;
    // for (int i = 0; i < n - 1; ++i) {
    //     lcm_val = lcm(lcm_val, a[i]);
    // }
    //
    // long long res = 0;
    // for (int i = 0; i < n; ++i) {
    //     res += (lcm_val - 1) % a[i];
    // }
    long long res = 0;
    for (int i = 0; i < n; ++i) {
        res += a[i];
    }

    cout << res - n << endl;
    return 0;
}


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

typedef long long ll;
ll n, mn = 2, mx = 2, a[N];
int main()
{
	ll i;
	cin >> n;
	for (i = 0; i < n; i++) scanf("%lld", &a[i]);
	for (i = n - 1; i >= 0; i--) {
		mn = (mn + a[i] - 1) / a[i] * a[i];
		mx = mx / a[i] * a[i] + a[i] - 1;
		if (mn > mx) {cout << "-1"; return 0;}
	}
    cout << mn << ' ' << mx << endl;
    return 0;
}

Measured memory_bytes: 1024
def main():
    n = int(input())
    ss = {}
    max_s = 0
    for _ in range(n):
        s = input()
        if s not in ss:
            ss[s] = 0
        else:
            ss[s] += 1
            max_s = max(max_s, ss[s])

    ss = sorted(ss.items(), key=lambda x: x[0])
    anss = [s for s, i in ss if i == max_s]
    for ans in anss:
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 45852
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (x, y) = i.read2::<usize, usize>();
    writeln!(o, "{}", x + y / 2).unwrap();
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n; cin >> n;
	vector<int> A(n);
	rep(i,n)cin>>A[i];
	ll hoge=0;
	rep(i,n)
	{
		hoge+= i%2 ? -A[i]: A[i];
	}
	vector<int> ans(n);
	ans[0]=hoge;
	rep(i,n)A[i]*=2;

	for(int i=1;i<n;i++)
	{
		ans[i]=A[i-1]-ans[i-1];
	}
	rep(i,n)
	cout<<ans[i]<<endl;
	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  ll a, b, c; std::cin >> a >> b >> c;
  ll i = 4 * a * b, j = c - a - b;
  if (j < 0) std::cout << "No" << "\n";
  else std::cout << (i < j*j ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
$N=<>;
map{
	$t="";
	<>=~$",vec($t,$`-1,8)=$'+49 for 1..<>;
	$T[$_-1]=$t;
}1..$N;
printf sort{$b-$a}map{
	$t=$_;
	map{$i=0;/2/&&($t|=$T[$i]),$i++for$t=~/./g}1..5;
	$_=$t;
	!/3/*y/2//
}glob'{0,2}'x$N;

Measured memory_bytes: 6808
a, b = map(int, input().split())
if a > 0 and b > 0: ans = "Positive"
elif a < 0 and b > 0: ans = "Zero"
else:
  if abs(a-b+1) % 2 == 0: ans = "Positive"
  else: ans = "Negative"
print(ans)

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

int main()
{
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; i++)
        printf("%c%c", s[i], t[i]);
    return 0;
}

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

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long
#define line puts("")


const int INF = 1e9+7;
const ll INFLL = 1e17;
const double EPS = 1e-6;

using namespace std;

pii a[5];
ll n;

int cmp(pii x,pii y){
	return x.fi * y.se< y.fi * x.se;
}
int main(){
	rep(k,0,4)cin>>a[k].fi;	
	cin>>n;
	n*= 4;
	a[0].se = 1;
	a[1].se = 2;
	a[2].se = 4;
	a[3].se = 8;
	
	sort(a,a+4,cmp);
	
	ll ret = 0;
	rep(k,0,4){
		ll x= n/a[k].se;
		ret += x * a[k].fi;
		n -= x*a[k].se;
	}
	
	cout<<ret<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define A(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
void _read();
#define int long long

main () { _read(); 

      int a,b,c,d;
      cin >> a >> b >> c >> d;
      int ans = a*c;
      for( int x : {a,b}) {
            for( int y : {c,d}) {
                  ans = max({ans,x*y});
            }
      }
      cout << ans << "\n";
      return 0;
};

void _read() {
      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
}


Measured memory_bytes: 3648
#include <iostream> 
#include <algorithm> 
using namespace std; 
	 
bool cmp(int a,int b)
{  
	return a>b; 
} 
	 
int main()
{  
	int n,k,x;  
	cin>>n>>k; 
	 
	int a[200000+5]={0}; 
	 	 
	for(int i=0;i<n;i++)
	{    
	    cin>>x;    
	    a[x]++; 
	}
	          
	sort(a+1,a+200000+1,cmp); 
	         
	int count=0;          
	for (int i=k+1;i<=200000;i++) count+=a[i]; 
	    cout<<count<<endl;  
		   
	return 0; 
} 


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int h,w;
    cin>>h>>w;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--,b--,c--,d--;
    vs s(h);
    rep(i,h)cin>>s[i];
    vvi cost(h,vi(w,inf));
    deque<pair<int,pi>> q;
    q.push_back({0,{a,b}});
    while(!q.empty()){
        auto p=q.front();
        q.pop_front();
        int t=p.fi;
        int y=p.se.fi,x=p.se.se;
        if(cost[y][x]<=t)continue;
        cost[y][x]=t;
        REP(i,-2,2)REP(j,-2,2){
            if(i==0&&j==0)continue;
            int ny=y+i,nx=x+j;
            if(ny<0||ny>=h||nx<0||nx>=w)continue;
            if(s[ny][nx]=='#')continue;
            if(abs(i)+abs(j)==1){
                q.push_front({t,{ny,nx}});
            }
            else{
                q.push_back({t+1,{ny,nx}});
            }
        }
    }
    cout<<(cost[c][d]==inf?-1:cost[c][d])<<endl;
}

Measured memory_bytes: 14980
from sys import stdin
k,n = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]
b = [0] * n
for i in range(n-1):
    b[i] = a[i+1] - a[i]
b[n-1] = k - a[n-1] + a[0]
print(sum(b) - max(b))


Measured memory_bytes: 73204
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define sp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 
}



void solve()
{
	int n;
	cin >> n;
	ll a[n];
	vector<ll> p;
	rep(i, n) cin >> a[i];
	sort(a, a + n);
	rep(i, n){
		if(i && a[i] == a[i - 1]) p.pb(a[i++]);
	}
	sort(p.rbegin(), p.rend());
	if(sz(p) <= 1) cout << 0;
	else cout << p[0] * p[1];
}

 
int main()
{
	// freopen("crosses.in", "r", stdin);
	// freopen("crosses.out", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 4656
#include<stdio.h>
int main(void)
{
    int x,y,z;
    int countT = 0, countH = 0;
    while(scanf("%d,%d,%d",&x,&y,&z) != EOF){
        if(x == y) countH++;
        if((x * x) + (y * y) == (z * z)) countT++;
    }
    printf("%d\n%d\n",countT,countH);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 1005;
const int INF = (LL)1e9 + 5;
const LL MOD = 1000000007;

struct Edge {
	int fr, to, w;
	bool operator < (const Edge &e) const {
		return w < e.w;
	}
};

struct DSU {
	int pa[MAXN];
	void init(int N) {
		for (int i = 0; i <= N; i++) pa[i] = i;
	}
	int find(int x) {
		return pa[x] == x ? x : pa[x] = find(pa[x]);
	}
	void merge(int x, int y) {
		x = find(x);
		y = find(y);
		pa[y] = x;
	}
} dsu;

int N, M, heavy[MAXN][MAXN];
bool vis[MAXN], used[2005];
LL X, mst;
vector<Edge> es, G[MAXN];

LL MST() {
	LL ans = 0;
	dsu.init(N);
	sort(es.begin(), es.end());
	for (int i = 0; i < es.size(); i++) {
		int u = es[i].fr, v = es[i].to, w = es[i].w;
		if (dsu.find(u) != dsu.find(v)) {
//			cout << "Pick " << u << " " << v << "\n";
			dsu.merge(u, v);
			used[i] = true;
			G[u].push_back({u, v, w});
			G[v].push_back({v, u, w});
			ans += w;
		}
	}
	return ans;
}

void dfs(int s, int v, int p) {
	for (Edge &e : G[v]) {
		if (e.to == p) continue;
		heavy[s][e.to] = max(heavy[s][v], e.w);
		dfs(s, e.to, v);
	}
}

LL qpow(LL a, LL p) {
	LL ans = 1;
	while (p) {
		if (p & 1) ans = ans * a % MOD;
		a = a * a % MOD;
		p >>= 1; 
	}
	return ans;
}

LL all_black() {
	for (int i = 1; i <= N; i++) {
		heavy[i][i] = 0;
		dfs(i, i, i);
	}
	
	LL gt = 0, eq = 0, lt = 0;
	for (int i = 0; i < es.size(); i++) {
		if (used[i]) continue;
		Edge &e = es[i];
		LL st = mst - heavy[e.fr][e.to] + e.w;
//		cout << e.fr << " " << e.to << " " << heavy[e.fr][e.to] << "\n";
		if (st > X) gt++;
		if (st == X) eq++;
		if (st < X) lt++;
	}
	
	if (eq == 0) return 0;
	return (qpow(2, eq) - 1) * qpow(2, gt) % MOD * 2 % MOD;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M >> X;
	for (int i = 0; i < M; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		es.push_back({u, v, w});
	}
	
	LL ans = 0;
	mst = MST();
	if (mst > X || N <= 2) {
		cout << "0\n";
		return 0;
	}
	
//	cout << "MST = " << mst << "\n";
	if (mst == X) ans = (qpow(2, N - 1) - 2) * qpow(2, M - (N - 1)) % MOD;
//	cout << "Tier 1 -> " << ans << "\n";
	ans += all_black();
	
	cout << ans % MOD << "\n";
	
	return 0;
	
	/**** Note MAXN ****/
}


Measured memory_bytes: 4352
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll NN, MM;
  std::cin >> NN>>MM;

  ll ans_flag[MM];
  for (size_t i = 0; i < MM; i++) {
    ans_flag[i] = 1;
  }

  for (size_t i = 0; i < NN; i++) {
    ll K;
    std::cin >> K;
    ll k_pref[K];
    for (size_t j = 0; j < K; j++) {
      std::cin >> k_pref[j];
    }
    for (size_t j = 0; j < MM; j++) {
      ll flag = 0;
      for (size_t kl = 0; kl < K; kl++) {
        if(j == k_pref[kl]-1)flag = 1;
      }
      if (flag == 0) {
        ans_flag[j] = 0;
      }
    }
  }

  ll ans = 0;
  for (size_t i = 0; i < MM; i++) {
    ans+= ans_flag[i];
  }

  std::cout << ans << '\n';


  return 0;
}


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

int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a>c)
    swap(a,c),swap(b,d);

  cout<<max(0,min(d,b) - c)<<"\n";


  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=input()
B=input()
C=input()

ans=0
for i in range(N):
  if A[i]!=B[i]:
    if A[i]!=C[i] and B[i]!=C[i]:
      ans+=2
    else:
      ans+=1
  else:
    if A[i]!=C[i]:
      ans+=1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define inf 1e9
#define pi 3.1415926536
#define mod 1000000007
#define fr(i,a,b,in) for(int i=a;i<b;i+=in)
#define frn(i,a,b,dc) for(int i=a;i>=b;i-=dc)
#define test(t) int t; cin>>t; while(t--)
int main()
{
	fastio();
	string st,t;
	cin>>st>>t;
	int ans=100000,l1=st.size(),l2=t.size();
	fr(i,0,l1-l2+1,1){
		int c=0;
		fr(j,0,l2,1) if(st[j+i]!=t[j]) c++;
		ans=min(ans,c);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3644
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.ByteString.Char8 as BS

main = do
  [n,k] :: [Int] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  print $ sum [ 1/fromIntegral n * (1/2)^l
              | d <- [1..n]
              , let q = (k+d-1) `quot` d
                    l = ceiling (logBase 2 (fromIntegral q) :: Double)
              ]


Measured memory_bytes: 1020