akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int main(){
  ll N;
  cin >> N;
  vll A(N), B(N), C(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  for(int i = 0; i < N; i++){
    cin >> B.at(i);
  }
  for(int i = 0; i < N; i++){
    cin >> C.at(i);
  }
  sort(ALL(A)); sort(ALL(B)); sort(ALL(C));
  vll BB(N, 0);
  for(int i = 0; i < N; i++){
    ll BBB = B.at(i);
    ll num = distance(upper_bound(ALL(C), BBB), C.end());
    BB.at(i) = num;
  }
  vll Bsum(N+1, 0);
  for(int i = 0; i < N; i++){
    Bsum.at(i+1) = Bsum.at(i) + BB.at(i);
  }
  ll ans = 0;
  for(int i = 0; i < N; i++){
    int AAA = A.at(i);
    auto ite = upper_bound(ALL(B), AAA);
    int s = distance(B.begin(), ite);
    ans += Bsum.at(N) - Bsum.at(s);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4224
#include<iostream>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
const int MAXn=100001;
const int INFTY=1<<21;

int n,col[MAXn],d[MAXn];
vector<pair<int,int>> Q[MAXn];

void dijkstra(int s)
{
	priority_queue<pair<int,int>> PQ;//weight,id
	for(int i=0;i<n;i++)
	{
		d[i]=INFTY;
		col[i]=0;
	}
	d[s]=0;
	PQ.push(make_pair(0,s));
	col[s]=1;
	
	while(!PQ.empty())
	{
		pair<int,int> f=PQ.top();PQ.pop();
		int u=f.second;
		col[u]=2;
		if(d[u]<f.first*(-1))continue;
		for(int j=0;j<Q[u].size();j++)
		{
			int v=Q[u][j].first;
			if(col[v]==2)continue;
			if(d[u]+Q[u][j].second<d[v])
			{
				d[v]=d[u]+Q[u][j].second;
				PQ.push(make_pair(d[v]*(-1),v));
				col[v]=1;
			}
		}
	}
	
	return;
}

int main()
{
	cin>>n;
	int a,b;
	int old[MAXn];
	for(int i=0;i<n;i++)old[i]=-1;
	for(int i=1;i<n;i++)
	{
		cin>>a>>b;
		a--;b--;
		Q[a].push_back(make_pair(b,1));
		Q[b].push_back(make_pair(a,1));
	}
	int k,v,p;cin>>k;
	for(int i=0;i<k;i++)
	{
		cin>>v>>p;v--;
		old[v]=p;
		Q[n].push_back(make_pair(v,p));
	}
	dijkstra(n);
	
	for(int i=0;i<n;i++)
	{
		if(old[i]!=-1)
		{
			if(old[i]!=d[i])
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<Q[i].size();j++)
		{
			if(abs(d[i]-d[Q[i][j].first])!=1)
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	
	cout<<"Yes"<<endl;
	
	for(int i=0;i<n;i++)
	{
		cout<<d[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 9768
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
    
    ll n;
    cin>>n;
    ll arr[n]={0},dp[n]={0};
    for (int i = 0; i < n; i++) {
        cin>>arr[i];
    }
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++)
    {
        ll first=abs(arr[i-1]-arr[i])+dp[i-1];
        ll second=abs(arr[i-2]-arr[i])+dp[i-2];
        dp[i]= first<=second ? first:second;
    }
    cout<<dp[n-1]<<endl;
    return 0;
    
}

Measured memory_bytes: 1792
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<bitset>
#include<map>
#include<algorithm>
using namespace std ;
#define ll  long long int 
int main(){
    ll a , b , c , d ; 
    cin >> a >> b >> c >> d ;
    while(true)
    {
        c -= b ;
        if (c <= 0 )
        {
            cout << "Yes" << endl ;
            break ;
        }
        a -= d ;
        if (a <= 0)
        {
            cout << "No" <<endl ;
            break ;
        }
    }
    
    
    
    return 0 ; 
} 


Measured memory_bytes: 3636
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

using namespace std;

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

    int A[N];
    int total = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        total += A[i];
    }

    int r = 100;
    int b = A[0];
    for (int i = 1; i < N - 1; i++)
    {
        b += A[i];
        int a = abs((total - b) - b);

        r = min(r, a);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string t;
  cin >> t;
  int len = sz(t);
  rep(i,len) {
    if(t[i]=='?') {
      t[i]='D';
    }
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
int N,M,counter;
int main(){
	cin >> N >> M;
  long long h[N+1];
  bool v[N+1];
  for(int i = 1; i <= N; i++){
    cin >> h[i];
  }
  for(int i = 1; i <= N; i++){
    v[i] = false;
  }
  for(int i = 0; i < M; i++){
    int a,b;
    cin >> a >> b;
    if(h[a]<h[b]){
      v[a] = true;
    }else if(h[b]<h[a]){
      v[b] = true;
    }else{
      v[a] = true;
      v[b] = true;
    }
  }
  counter = 0;
  for(int i = 1; i <= N; i++){
    if(v[i] == false){
      counter++;
    }
  }
  cout << counter;
}

Measured memory_bytes: 4432
from fractions import gcd

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

L = [0]
for i in range(n):
    L.append(gcd(L[i], A[i]))

R = [0]
for i in range(n-1, -1, -1):
    R.append(gcd(R[(n-1)-i],A[i]))
R.reverse()

M = []

for i in range(n):
    M.append(gcd(L[i],R[i+1]))
    
print(max(M))

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

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

    int n, c, k;
    cin >> n >> c >> k;
    vector<int> T(n);
    REP(i, n) cin >> T[i];
    
    sort(T.begin(), T.end());

    int ans = 0, cnt = 1;
    long long now = T[0] + k;
    for(int i = 1; i < n; i++){
        if(T[i] <= now) cnt++;
        else{
            ans++;
            cnt = 1;
            now = T[i] + k;
        }
        if(cnt == c or i == n - 1){
            ans++;
            if(i == n - 1) break;
            cnt = 0;
            now = T[i + 1] + k;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <string.h>
#include <map>
#include <iomanip>
#include <time.h>
using namespace std;
typedef long long ll;

void twin(bool b) {
    cout << (b ? "Yay!" : ":(" ) << endl;
}

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

    bool y[100010] = {};
    y[0] = 1;
    for (int i = 0; i <= 100000; i++) {
        for (int j = 0; j <= 5; j++) {
            if (i + 100 + j <= 100000 && y[i]) y[i + 100 + j] = 1;
        }
    }
    cout << y[x] << endl;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

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


void solve(){
	int n,m;
	cin >> n >> m;
	int count = 0;

	if(n&1)
	for(int i =0;i<m;i++){
		cout << i+1 << " " << (n-i) << endl;
	}
	else{
		for(int i=1,j=n/2;i<j;i++,j--){
			if(count>=m)
				break;
			cout << i << " " << j << endl;
			count++;
		}
		for(int i =n/2+1,j=n-1;i<j;i++,--j){
			if(count>=m)
				break;
			cout << i << " " << j << endl;
			
			count++;
		}
		// cout << count << endl;
	}
}

int main(){
	fast;
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif

	// int t;cin >> t;while(t--)
		solve();
}


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

int main() {
  int N, K, x;
  cin >> N >> K ;
  int count = 0;
  
  for(int i=1;i<=N;i++){
    cin >> x; //(x,i)にボール
    if (x*2 < (K-x)*2){
      count += x*2;
    }
    else{
      count += (K-x)*2;
    }
  }
  
  cout << count << endl;
  
}


Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,k;cin>>n>>k;
    vector<int>l(n);
    for(int i=0;i<n;i++)cin>>l[i];
    sort(all(l));
    int sum=0;
    for(int i=n-1;i>=n-k;i--){
        sum+=l[i];
    }
    cout<<sum<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






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

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

using namespace std;

const int INF=1<<29;

int solve(string a,string b,string c){
	auto build=[](string x,string y){
		int nx=x.length(),ny=y.length();
		vector<bool> flag(nx+1,true);
		rep(i,nx+1){
			rep(j,ny){
				if(i+j>=nx) break;
				if(x[i+j]!='?' && y[j]!='?' && x[i+j]!=y[j]){ flag[i]=false; break; }
			}
		}
		return flag;
	};

	int na=a.length(),nb=b.length(),nc=c.length();
	vector<bool> flag_ab=build(a,b);
	vector<bool> flag_ac=build(a,c);
	vector<bool> flag_bc=build(b,c);
	vector<bool> flag_cb=build(c,b);

	int res=INF;
	rep(i,na+1) if(flag_ab[i]) {
		rep(j,na+1) if(flag_ac[j]) {
			if(j<=i && i-j<=nc && flag_cb[i-j]) res=min(res,max({na,i+nb,j+nc}));
			if(j>=i){
				if((j-i<=nb && flag_bc[j-i]) || j-i>=nb) res=min(res,max({na,i+nb,j+nc}));
			}
		}
		for(int j=na;j<=i+nb;j++){
			if(flag_bc[j-i]) res=min(res,max(i+nb,j+nc));
		}
	}
	return res;
}

int main(){
	string s[3];
	rep(i,3) cin>>s[i];

	sort(s,s+3);

	int ans=INF;
	do{
		ans=min(ans,solve(s[0],s[1],s[2]));
	}while(next_permutation(s,s+3));
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std; 
int main(){
  int h1 ,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  if(h1!=h2) cout<<(abs(h2-h1-1)*60)+abs(60-m1+m2)-k;
 if(h1==h2) cout<<m2-m1-k;
  
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll a,b,m;
    cin >> a >> b >> m;
    vector<ll> A(a);
    vector<ll> B(b);
    cins(all(A));
    cins(all(B));
    ll ma = *min_element(all(A));
    ll mb = *min_element(all(B));
    ll ans = ma + mb;
    rep(i, m){
        ll x,y,c;
        cin >> x >> y >> c;
        --x, --y;
        chmin(ans, A[x] + B[y] - c);
    }
    print(ans);


}



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

#define rep(i,n) for(int i=0; i<n; i++)
int main(){
	int N, a, b, c;
	cin >> N;
	rep(i,N){
		cin >> a >> b >> c;
		if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

    return 0;
}

Measured memory_bytes: 1152
import copy

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

cnt = [0]
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        cnt.append(cnt[-1] + 1)
    else:
        cnt.append(cnt[-1])

for i in range(q):
    l, r = map(int, input().split())
    print(cnt[r-1] - cnt[l-1])

Measured memory_bytes: 81056
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,st[3];cin >> n >> st[0] >> st[1] >> st[2];
	vector<string> inp(n);
	vector<char> ans;
	bool valid = true;
	for(int i=0;i<n;i++) cin >> inp[i];
	for(int i=0;i<n;i++){
		int nx1 = inp[i][0]-'A';
		int nx2 = inp[i][1]-'A';
		if(st[nx1] > st[nx2]){
			st[nx1]--,st[nx2]++;
			ans.emplace_back(nx2+'A');
		}else if(st[nx1] < st[nx2]){
			st[nx1]++,st[nx2]--;
			ans.emplace_back(nx1+'A');
		}else{
			bool found = false;
			for(int j=i+1;j<n;j++){
				if(inp[i] == inp[j]) break;
				int nxs1 = inp[j][0]-'A';
				int nxs2 = inp[j][1]-'A';
				if((nxs1 == 0 || nxs2 == 0) && (nx1 == 0 || nx2 == 0) && st[(nxs1 == 0) ? nxs2 : nxs1] == 0){
					if(nx1 == 0){
						ans.emplace_back(nx1+'A');
						st[nx2]--,st[nx1]++;
					}else{
						ans.emplace_back(nx2+'A');
						st[nx2]++,st[nx1]--;
					}
					found = true;
					break;
				}if((nxs1 == 1 || nxs2 == 1) && (nx1 == 1 || nx2 == 1) && st[(nxs1 == 1) ? nxs2 : nxs1] == 0){
					if(nx1 == 1){
						ans.emplace_back(nx1+'A');
						st[nx2]--,st[nx1]++;
					}else{
						ans.emplace_back(nx2+'A');
						st[nx2]++,st[nx1]--;
					}
					found = true;
					break;
				}if((nxs1 == 2 || nxs2 == 2) && (nx1 == 2 || nx2 == 2) && st[(nxs1 == 2) ? nxs2 : nxs1] == 0){
					if(nx1 == 2){
						ans.emplace_back(nx1+'A');
						st[nx2]--,st[nx1]++;
					}else{
						ans.emplace_back(nx2+'A');
						st[nx2]++,st[nx1]--;
					}
					found = true;
					break;
				}
			}if(!found){
				st[nx1]++,st[nx2]--;
				ans.emplace_back(nx1+'A');
			}
		}
		if(st[nx1] < 0 || st[nx2] < 0){
			valid = false;
			break;
		}
	}
	if(!valid) cout << "No\n";
	else{
		cout << "Yes\n";
		for(auto c : ans) cout << c << '\n';
	}
	return 0;
}


Measured memory_bytes: 6696
N = int(input())
A = [int(x) for x in input().split()]

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

L = [None]*(N+1)
R = [None]*(N+1)
L[0] = 0
R[N] = 0

for i, _ in enumerate(A):
  L[i+1] = gcd(L[i], A[i])
  R[N-1-i] = gcd(R[N-i], A[N-1-i])

M = [gcd(L[i], R[i+1]) for i in range(N)]

print(max(M))

Measured memory_bytes: 14432
n,w=map(int,input().split())
st=[]
for i in range(n):
    st.append(list(input())) #0~n-1までの列ができる
if n==w==1:
    print("Yes")
    exit()

for i in range(1,n-1):
    for j in range(1,w-1): #i,jに1足しても引いても範囲内だから安心！
        if st[i][j]=="#":
            if st[i+1][j]=="." and st[i][j-1]=="." and st[i][j+1]=="." and st[i-1][j]==".":
                print("No")
                exit()
        

print("Yes")


Measured memory_bytes: 3064
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}



main(){
    ios
    int n=in();
    vec a;
    rep(i,n)a.pb(in());
    map<ll,ll> mp;
    rep(i,n){
        mp[a[i]]++;
    }
    vecll v;
    for(auto e:mp){
        rep(i,e.second/2){
            v.pb(e.first);
        }
    }
    if(v.size()<2)cout<<0<<endl;
    else{
        sort(all(v),greater<ll>());
        cout<<v[0]*v[1]<<endl;
    }
}



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

int main()
{
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.io.*;

public class Main{
	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException{
		
		try{			
	        InputStreamReader isr = new InputStreamReader(System.in);
	        BufferedReader br = new BufferedReader(isr);
	        
	        //1???????????????????????????????????°???????????????
	        String str = br.readLine();
	        //???????????????????????????????????????????????????
	        int calcCnt = Integer.parseInt(str);
				        
	        for(int calc = 0; calc < calcCnt; calc++){
	        	
				int maxKeta = 100;
				int[] input1 = new int[100];
				int[] input2 = new int [100];
				int[] output = new int [100];
	        	String[] tmp1, tmp2;
	        	
	        	//???????¨??????????2????????°???????????????
	        	tmp1 = br.readLine().split("");
	        	tmp2 = br.readLine().split("");
	        	
				//?????????????????????0??°??????
				for(int i = 0; i < maxKeta; i++){
					input1[i] = 0;
					input2[i] = 0;
					output[i] = 0;
				}
				
				int max = tmp1.length+1;
				int k1 = 0;
				int k2 = tmp1.length - tmp2.length;
				if(tmp1.length < tmp2.length) {
					max = tmp2.length+1;
					k1 = tmp2.length - tmp1.length;
					k2 = 0;
				}
				
	        	//?????????????????????????????°????????????
	        	for(int i = 0; i+k1 < tmp1.length + k1; i++){
	        		if( i >= tmp1.length +k1 || i >= tmp1.length ){
	        			input1[i+1+k1] = 0;
	        		}else{
	        			input1[i+1+k1] = Integer.parseInt(tmp1[i]);
	        		}
	        	}
	        	//for( int i = 0; i < max; i++ ){
	        	for( int i = 0; i+k2 < tmp2.length + k2; i++ ){
	        		if( i >= tmp2.length ){
	        			input2[i+1+k2] = 0;
	        		}else{
	        			input2[i+1+k2] = Integer.parseInt(tmp2[i]);
	        		}
	        	}
				
				//??°??????????????????????????????1????????????????¨?????????????????´?
	        	//??????????????°???????????????0????????????????´?????????????????????§????????????output???????´?
				for(int i = max; i > 0; i--){
					if(output[i] + input1[i] + input2[i] < 10){
						//??°????????????????????¨??????????????????????????????
						output[i] += input1[i] + input2[i];
					}else{
						//?????????????????°??????????????¨???1?????????????????????
						output[i] += input1[i] + input2[i] -10;
						output[i-1] +=1;
					}			
				}
				
				//?¨??????????????????????????????¨????????????
				StringBuilder result = new StringBuilder();
				//input???2????????°????????????????¢???????????????????????????§??????????????????????????????????????´
				int start;
				if(output[0] == 0){//??°??????????????????
					start = 1;
				}else{//??°??????????????????
					start = 0;
				}
				for(int i = start; i < max; i++){
					if(i == max && output[i]==0){
						break;
					}else{
						result.append(output[i]);
					}				
				}	
				if(result.length()<=80){
					System.out.println(result);
				}else{
					System.out.println("overflow");
				}
				
	        }
		}catch(Exception e){
			System.out.println(e);
		}	
		
	}

}

Measured memory_bytes: 24840
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double x,y; cin >> x >> y;
    double ans = 1.0 / ((1.0/x) + (1.0/y));
    cout << setprecision(20) << ans << endl;
    return 0;
}

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

namespace Atc_0042
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            long N = long.Parse(S.Split(' ')[0]);
            long X = long.Parse(S.Split(' ')[1]);

            long i = 0;

            List<long> Nums = new List<long>();

            while (i < N)
            {
                Nums.Add(long.Parse(Console.ReadLine()));

                i++;
            }

            X = X - Nums.Sum();

            X = X / Nums.Min() + N;

            Console.WriteLine(X);

        }
    }
}


Measured memory_bytes: 28264
#include <bits/stdc++.h>
//#include <atcoder/all>

using namespace std;
//using namespace atcoder;
using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
//using u64 = long long;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;


int main(int argc, char *argv[])
{
    
    
    cin.tie(0) ;
    ios::sync_with_stdio(false) ;
    
    int x;
    cin >> x;
    cout << (1 - x) << endl;
    
    return 0;
    
}


Measured memory_bytes: 3616
def main():
    H, W = map(int, input().split())
    s = list()
    s.append('#' * (W + 2))
    s.extend(['#' + input() + '#' for _ in range(H)])
    s.append('#' * (W + 2))
    for ss in s:
        print(ss)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<cstdio>

int n, lim;

int main() {
	scanf("%d%d", &n, &lim);
	long long res = 0LL;
	int last = 0;
	for(int i=0;i<n;i++) {
		int x; scanf("%d", &x);
		int det = x+last-lim;
		if (det>0) {
			res+=det;
			x-=det;
		}
		last = x;
	}
	printf("%lld\n", res);
	
	return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val s = readLine()!!.toString()
    var cur = 0
    var ans = 0
    s.forEach {
        if (it == 'R') {
            cur++
        } else {
            cur = 0
        }
        ans = maxOf(ans, cur)
    }
    println(ans)
}

Measured memory_bytes: 34420
#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);
}

int main() {
    int T;
    long long A, B, C, D;
    scanf("%d", &T);
    for (int i = 0; i < T; i++) {
        scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
        if (A < B) printf ("No\n");
        else if (D < B) printf ("No\n");
        else if (C >= B) printf("Yes\n");
        else {
            long long a, b;
            a = gcd(B, D);
            b = B - a + A % a;
            if (b > C) printf("No\n");
            else printf("Yes\n");
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(void)
{
    int a=0,i;
    char x[11],y[1000],*z;
    gets(x);
    for(i=0;x[i];i++){
        x[i]=tolower(x[i]);
    }
    while(1){
        gets(y);
        if(strcmp(y,"END_OF_TEXT")==0)break;
    z=strtok(y," ");
    while(z!=NULL){
        for(i=0;;i++){
        if(z[i]=='\0')break;
            z[i]=tolower(z[i]);
        }
        if(strcmp(z,x)==0)a++;
        z=strtok(NULL," ");
    }
        
    }
    printf("%d\n",a);
    return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	
	public static void Main(string[] args)
	{
 		var n = Console.ReadLine().ToLong();
 		
 		for(int i = 1; i <= 3500; i++)
 		{
	 		for(int j = 1; j <= 3500; j++)
	 		{
				var k = (double)n * i * j / (4 * i * j - n * i- n * j);
				
				if(k > 0 && k < 3501 && k == (long)k)
				{
					Console.WriteLine("{0} {1} {2}", i, j, k);
					return;
				}
	 			
	 		}
 		}
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 13140
import java.util.Scanner;

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

        int x;
        for(int i = 0; i < 10_000; i++){
            x = sc.nextInt();
            System.out.println("Case "+(i+1) + ": "+x);
            if(x == 0){
                break;
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 41360
n = int(input())
a = list(map(int,input().split()))

sum1 = 0
sum2 = 0
u = 0
for i in range(n):
    u = a[i]
    sum1 = (sum1+u)%(10**9+7)
    sum2 = (sum2+(u**2))%(10**9+7)

sum1 = sum1**2 % (10**9+7)
ans = (10**9+8)//2 * (sum1-sum2) % (10**9+7)
print(ans)

Measured memory_bytes: 31768
def bound(n, x, l):
    coordinate = 0
    for i in range(n):
        coordinate += l[i]
        if x < coordinate:
            return i
        else:
            continue
    return n


n, x = map(int, input().split())
l = list(map(int, input().split()))
countbound = bound(n, x, l)
print(countbound+1)


Measured memory_bytes: 2940
n, k = map(int, input().split())
stones = list(map(int, input().split()))

dp = [False for _ in range(k+1)]

for i in range(1, k+1):
  for j in stones:
    if i >= j and dp[i-j] == False:
      dp[i] = True
      continue
      
if dp[k]:
  print("First")
else:
  print("Second")

Measured memory_bytes: 44784
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int S, W;
    cin >> S >> W;
    if (S <= W){
        cout << "unsafe" << endl;
        return 0;
    }
    cout << "safe"<< endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int64_t> a(n + 1), b(n);
    int64_t ans = 0;
    REP(i, n + 1) cin >> a[i];
    REP(i, n) cin >> b[i];
    REP(i, n) {
        int64_t tmp = min(a[i], b[i]);
        ans += tmp;
        a[i] -= tmp;
        b[i] -= tmp;
        tmp = min(a[i + 1], b[i]);
        ans += tmp;
        a[i + 1] -= tmp;
        b[i] -= tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++){
    cin >> h[i];
  }
  vector<int> dp(N);
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  for (int i = 2; i < N; i++){
    dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i]));
  }
  cout << dp[N - 1];
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <cstdio>
#include <utility>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

int n; bool flag;

int main() {
  
  int n; bool flag=true;
  
  scanf("%d",&n);
  
 for(int i=1; i<=n; i++){
       flag=true;
  if(i%3==0||i%10==3){
     cout<<" "<<i; flag=false;
     } 
  if(flag){
     int j=i; 
   while(1){
     if(j%10==3||j<3){ break; }
     j=j/10;
     if(j%10==3){
     cout<<" "<<i; break;
     }  
    }
   }
  }
  
   
    cout<<endl;
   

}

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

int main(){
    int a,b,c,i,Div=0;
    cin >> a >> b >> c;
    for(i=a;i<=b;i++){
        if(c % a == 0){
            Div++;
        }
        a++;
    }
    cout << Div << endl;
    return 0;
}


Measured memory_bytes: 3120
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

pub fn main() {
    loop {
        let v: Vec<i32> = read_vec();
        let (h,w) = (v[0],v[1]);
        if h==0 && w==0 {
            break;
        }
        for i in 0..h {
            for j in 0..w {
                let c = if i == 0 || i == h-1
                        || j == 0 || j == w-1 {
                            '#'
                        } else {
                            '.'
                        };
                print!("{}", c);
            }
            println!();
        }
        println!();
    }
}


Measured memory_bytes: 5028
import sys
from io import StringIO
import unittest
import heapq

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,m=map(int, readline().rstrip().split())
    arr=list(map(int, readline().rstrip().split()))
    for i in range(n):
        arr[i]*=-1
    heapq.heapify(arr)
    for _ in range(m):
        x=(heapq.heappop(arr)*-1)//2
        heapq.heappush(arr, -x)
    ans=0
    for i in range(n):
        ans+=(arr[i]*-1)
    print(ans)
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Measured memory_bytes: 17372
#include <iostream>
#include <algorithm>
using namespace std;
int main() { 
	int N,i,P1=0,P2; 
	cin >> N;
	int W[N]; 
	for(i=0;i <N;i++){ 
		cin >> W[i]; 
		P1 += W[i]; 
	} 
	for(i=0;i <N;i++){
		P2 = P1; 
		P1 = P2-2*W[i];
		if(P1<=0){
			break;
		}
	} 
	if(P1+P2<=0){ 
		cout << P2;
	} else {
		cout << (-1)*P1;
	}
	return 0;
}


Measured memory_bytes: 256
program main
	implicit none
	integer n
	integer ::i,nin=0,bnin
	integer,allocatable,dimension(:)::a,b
	read(*,*)n
	allocate(a(n))
	allocate(b(n))	
	do i=1,n
		read(*,*)a(i),b(i)
	enddo
	do i=1,n
		if(nin<a(i))then
			nin=a(i)
			bnin=b(i)
		endif
	enddo
	nin=nin+bnin
	write(*,*)nin
end program main


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

using namespace std;

int main(){
  string s; int n,i; cin >> s;
  n = s.length();
  bool q=1;
  for(i=0; i<n/2; i++)
  {
  if(s[i]!=s[n-i-1]){q=0; break;}
  }
  for(i=0; i<(n/2)/2; i++)
  {
  if(s[i]!=s[n/2-i-1]){q=0; break;}
  }
  for(i=n/2+1; i<(n/2)/2+n/2+1; i++)
  {
  if(s[i]!=s[n/2+n-i]){q=0; break;}
  }
  
  if(q){cout << "Yes";}
  else{cout << "No";}

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
int n,k;
cin >> n >> k;
int che = n-n/2;
if(che>=k)cout <<"YES"<<endl;
else cout <<"NO"<<endl;

}


Measured memory_bytes: 256
N = gets.to_i
MOD = 10 ** 9 + 7

# A: 0, G: 1, C: 2, T: 3
# NG: AGC, 1回入れ替えてAGC
# AGC, GAC, ACG, A?GC, AG?C
# 012, 102, 021, 0?12, 01?2

# dp: 文字数、最後から3,2,1文字目がいくつあるか
dp = Array.new(101) { Array.new(4) { Array.new(4) { Array.new(4, 0) } } }
# dp[0][3][3][3] = 1
dp[1][0][3][3] = 1
dp[1][1][3][3] = 1
dp[1][2][3][3] = 1
dp[1][3][3][3] = 1

N.times do |i|
  4.times do |j| # 最後から1文字目の文字
    4.times do |k|
      4.times do |l|
        next if dp[i][j][k][l] == 0
        4.times do |c|
          next if c == 2 && j == 1 && k == 0
          next if c == 2 && j == 0 && k == 1
          next if c == 1 && j == 2 && k == 0
          next if c == 2 && j == 1 && l == 0
          next if c == 2 && k == 1 && l == 0
          dp[i + 1][c][j][k] += dp[i][j][k][l]
          dp[i + 1][c][j][k] %= MOD
        end
      end
    end
  end
end

ans = 0
4.times do |j|
  4.times do |k|
    4.times do |l|
      ans += dp[N][j][k][l]
      ans %= MOD
    end
  end
end

puts ans


Measured memory_bytes: 1916
#include <iostream>

using namespace std;

int main()
{
    int p, q, r;
    cin >> p >> q >> r;

    int min_1 = min(p, min(q, r));
    int max_1 = max(p, max(q, r));
    int min_2 = p  + q + r - min_1 - max_1;

    cout << (min_1 + min_2);
    return 0;
}


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

int main() {

    ll K, N;
    cin >> K >> N;

    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    
    ll max_num = 0;
    ll max_i = 0;
    ll ans = 0;

    for (int i = 0; i < N-1; i++) {
        if ((A.at(i+1) - A.at(i)) > max_num) {
            max_num = A.at(i+1) - A.at(i);
            max_i = i;
        }
    }

    if ((K - A.at(N-1) + A.at(0)) > max_num) {
        max_num = K - A.at(N-1) + A.at(0);
        max_i = N-1;
    }
    
    ans = K - max_num;

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

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    long N = sc.nextInt();
 
    long cou = 0;
    for(long i=1; i<=N; i++){
       if(i*i<=N) {
    	   cou++;
       }
}
 	System.out.println(cou*cou);
    }
}


Measured memory_bytes: 35872
#include<stdio.h>

int main(void){
    int score[200000]={0};
    long N=0,K=0,Q=0;
    scanf("%ld %ld %ld",&N,&K,&Q);
    for(long i=0;i<Q;i++){
        int A=0;
        scanf("%d",&A);
        score[A-1]+=1;
    }
    for(long i=0;i<N;i++){
        if(K-Q+score[i]<=0){
            printf("No\n");
        }
        else{
            printf("Yes\n");
        }
    }
    
    return 0;
    
}

Measured memory_bytes: 1280
#include <stdio.h>

#define M 1000000007

static inline unsigned gcd(unsigned s, unsigned t)
{
  unsigned r;
  if (t == 0) return s;
  for ( ;(r = s % t) != 0; s = t, t = r);
  return t;
}

static inline int inverse(int a)
{
  int x = 1, g = a % M, v = 0, w = M, s, t, q;

  while (w != 0) {
    q = g / w;
    t = g - q * w;
    s = x - q * v;
    x = v;
    g = w;
    v = s;
    w = t;
  }

  x %= M;

  if (x < 0) x += M;

  return x;
}

int
main(int ac, char *av[])
{
  int n;
  unsigned A[10000];
  unsigned L[10000];
  unsigned g, u;
  unsigned long ll = 1, z = 0;

  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%u", &A[i]);
    L[i] = 1u;
  }

  for (int i = 0; i < n; ++i) {
    unsigned a = A[i];

    g = gcd(L[i], a);

    u = a / g;

    z = (z * u + ll * inverse(g)) % M;

    ll = (ll * u) % M;

    for (int j = i + 1; j < n; ++j) {
      L[j] = (unsigned long) L[j] * u % A[j];
    }
  }

  printf("%lu\n", z);

  return 0;
}


Measured memory_bytes: 1764
n = int(input())
a = list(map(int,input().split()))

sort_a = sorted(a,reverse=True)
max_a = sort_a[0]

ans=0
for i in range(n):
  if min(abs(max_a/2-sort_a[i]),abs(max_a/2-ans)) == abs(max_a/2-sort_a[i]):
    ans = sort_a[i]
print(max_a,ans)

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

typedef long long int ll;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0;i < n;i++) cin >> a[i];

    sort(a.begin(), a.end());
    ll al = 0, bo = 0;
    for(ll i = n - 1;i >= 0;i--){
        if((n -  1 - i) % 2 == 0){
            al += a[i];
        }
        else{
            bo += a[i];
        }
        //cout << a[i];
    }

    cout << al - bo;

    return 0;
}

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

using namespace std;

int main(){
    int n,m,x,y;
    int Max,Min;
    Max = -100000;
    Min = 100000;
    int len;
    
    vector<int> kouho;
    cin  >> n >> m >> x >> y;
    vector<int> X(n+1);
    vector<int> Y(m+1);
    for (int i=0;i<n;i++){
        cin >> X[i];
        Max = max(Max,X[i]);
    
        
    }
    for (int i=0;i<m;i++){
        cin >> Y[i];
        Min = min(Min,Y[i]);
        
    }
    
    
    for(int i=x+1;i<=y;i++){
        kouho.push_back(i);
        /*cout << kouho[i-x-1]<<endl;*/
    }
    len = kouho.size();
    for (int i=0;i<len;i++){
        if ((kouho[i]>Max) && (kouho[i]<=Min)){
            cout << "No War"<<endl;
            exit(0);
        }
    }

    
    cout<<"War"<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
from collections import defaultdict

def main():
    H,W,N = map(int,input().split())
    d = defaultdict(int)
    for i in range(N):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        for x in range(3):
            for y in range(3):
                na,nb = a-x,b-y
                if (0 <= na < H-2 and 0 <= nb < W-2):
                    d[na*W+nb] += 1
    
    d = list(d.values())
    ans = (H-2)*(W-2)-len(d)
    print(ans)
    for i in range(9):
        i += 1
        print(d.count(i))

if __name__ == "__main__":
    main()

Measured memory_bytes: 104848
N,T = map(int,input().split())
t = list(map(int,input().split()))
cnt = 0
for i in range(1,N):
    emp_time=(t[i]-t[i-1])-T
    if emp_time >= 0:
        cnt += T
    else:
        cnt += t[i]-t[i-1]
print(cnt+T)

Measured memory_bytes: 85456
class Point
  include Comparable
  attr_accessor :x, :y
  def initialize(x=0.0, y=0.0)
    @x, @y = x, y
  end
  def <=>(p)
    @y != p.y ? @y <=> p.y : @x <=> p.x
  end
  def +(p)
    Point.new(@x+p.x, @y+p.y)
  end
  def -(p)
    Point.new(@x-p.x, @y-p.y)
  end
  def -@
    Point.new(-@x, -@y)
  end
  def angle
    a = Math::atan2(@y, @x)
  end
end

while (n = gets.to_i) != 0 do
  point = Array.new
  n.times do
    point.push(Point.new(*(gets.split(",").map(&:to_f))))
  end
  point.sort!

  convexHull = Array.new
  convexHull.push(point.first)
  convexHull.push(point.drop(1).min_by{|p| (p-point.first).angle})
  while true do
    origin = convexHull.last
    base = (convexHull[-1] - convexHull[-2]).angle
    add = nil
    min = 2.0 * Math::PI
    point.each do |p|
      next if origin == p
      angle = (p-origin).angle - base
      angle += 2.0 * Math::PI if angle < 0.0
      next if min <= angle
      min = angle
      add = p
    end
    break if convexHull.first == add
    convexHull.push(add)
  end
  p n - convexHull.size
end

Measured memory_bytes: 6208
N = int(input())
A = list(map(int, input().split()))

B = [0] * (N)
BB = []
cnt_b = 0
for i in range(N)[::-1]:
    sum_b = 0
    idx = 1
    while True:
        if (i+1) * idx > N:
            B[i] = (A[i] + sum_b)%2
            if B[i] == 1:
                cnt_b += 1
                BB.append(i+1)
            break
        else:
            sum_b += B[(i+1)*idx-1]
        idx += 1
print(cnt_b)
str_b = ' '.join(map(str, BB))
if str_b != '0':
    print(str_b)


Measured memory_bytes: 19876
from math import gcd


class SegTree:
    X_unit = 0
    X_f = gcd

    def __init__(self, N):
        self.N = N
        self.X = [self.X_unit] * (N + N)

    def build(self, seq):
        for i, x in enumerate(seq, self.N):
            self.X[i] = x
        for i in range(self.N - 1, 0, -1):
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def set_val(self, i, x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def fold(self, L, R):
        L += self.N
        R += self.N
        vL = self.X_unit
        vR = self.X_unit
        while L < R:
            if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
            L >>= 1
            R >>= 1
        return self.X_f(vL, vR)


def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    seg = SegTree(N)
    seg.build(A)
    ans = 0
    for i in range(N):
        ans = max(ans, gcd(seg.fold(0, i), seg.fold(i+1, N)))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 87724
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

int H, W, M;
int bx[300001];
int by[300001];

int h_cnt[300001];
int h_flg_cnt[300001];
int w_cnt[300001];

int func()
{
	for (int m = 0; m < M; m++)
	{
		h_cnt[by[m]]++;
	}

	int h_max = 0;
	for (int y = 1; y <= H; y++)
	{
		h_max = max(h_cnt[y], h_max);
	}

	int h_max_cnt = 0;
	for (int h = 1; h <= H; h++)
	{
		if (h_cnt[h] == h_max)
		{
			h_max_cnt++;
		}
	}

	for (int m = 0; m < M; m++)
	{
		if (h_cnt[by[m]] == h_max)
		{
			h_flg_cnt[bx[m]]++;
		}
	}

	for (int m = 0; m < M; m++)
	{
		w_cnt[bx[m]]++;
	}

	int w_max = 0;
	for (int w = 1; w <= W; w++)
	{
		w_max = max(w_cnt[w], w_max);
	}

	for (int w = 1; w <= W; w++)
	{
		if (w_cnt[w] == w_max)
		{
			if (h_flg_cnt[w] < h_max_cnt)
			{
				return (h_max + w_max);
				return 0;
			}
		}
	}

	return (h_max + w_max - 1);
}

signed main()
{
	cin >> H >> W >> M;
	REP(i, M)
	{
		cin >> by[i] >> bx[i];
	}

	//while (true)
	//{
	//	memset(h_cnt, 0, sizeof(h_cnt));
	//	memset(h_flg_cnt, 0, sizeof(h_flg_cnt));
	//	memset(w_cnt, 0, sizeof(w_cnt));

	//	H = 5;
	//	W = 3;

	//	bool field[5][3] = {};
	//	for (int i = 0; i < 15; i++)
	//	{
	//		field[rand() % 3][rand() % 5] = true;
	//	}

	//	int ma = 0;
	//	for (int x = 0; x < W; x++)
	//	{
	//		for (int y = 0; y < H; y++)
	//		{
	//			int cnt = 0;
	//			for (int xx = 0; xx < W; xx++)
	//			{
	//				if (field[xx][y])cnt++;
	//			}
	//			for (int yy = 0; yy < H; yy++)
	//			{
	//				if (yy == y) continue;
	//				if (field[x][yy])cnt++;
	//			}
	//			ma = max(ma, cnt);
	//		}
	//	}

	//	M = 0;
	//	for (int x = 0; x < W; x++)
	//	{
	//		for (int y = 0; y < H; y++)
	//		{
	//			if (field[x][y])
	//			{
	//				bx[M] = x + 1;
	//				by[M] = y + 1;
	//				M++;
	//			}
	//		}
	//	}

	//	if (ma != func())
	//	{
	//		cout << H << " " << W << " " << M << endl;;
	//		REP(i, M)
	//		{
	//			cout << by[i] << " " << bx[i] << endl;
	//		}
	//		return 0;
	//	}
	//	else
	//	{
	//		int a = 0;
	//	}
	//}

	cout << func() << endl;
}



Measured memory_bytes: 14832
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<ll, ll>P;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void SAY(bool YES){cout<<(YES?"YES":"NO")<<endl;};
void Say(bool Yes){cout<<(Yes?"Yes":"No")<<endl;};

const ll MOD = 1000000007;

int main(){

    string s[2];
    cin >> s[0] >> s[1];
    for(ll i = 0; i < s[0].size() + s[1].size(); i++){
        cout << s[i % 2][i / 2];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import qualified Data.Set as S

main :: IO ()
main = do
  getLine
  ws <- words <$> getContents
  putStrLn $ solve ws

solve :: [String] -> String
solve (x:xs) = go (last x) (S.singleton x) xs
  where
    go c st [] = "Yes"
    go c st (x:xs)
      | c /= head x = "No"
      | x `S.member` st = "No"
      | otherwise = go (last x) (S.insert x st) xs


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

int main() {

	using namespace std;
	int i = 0;
	vector<int> x;

	while (true) {

		int tmp;
		cin >> tmp;
		x.push_back(tmp);
		if (tmp == 0) {
			break;
		}

	}

	while (true) {

		int tmp;
		tmp = x[i];

		if (tmp != 0) {
			i++;
			cout << "Case " << i  << ": " << tmp << endl;
		}else {
			break;
		}

	}

	return 0;

}


Measured memory_bytes: 3128