akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
	#define int long long int
	int n;
	cin>>n;
	int h[n+1];
	for(int i=1;i<=n;i++)
		cin>>h[i];
	int dp[n+1];
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n]<<endl;
	

}

Measured memory_bytes: 1792
n, x, y = map(int, input().split())
ans = [0] * n
for i in range(1, n):
    for j in range(i + 1, n + 1):
        ans[min(j - i, abs(x - i) + abs(y - j) + 1)] += 1
print(*ans[1:], sep="\n")

Measured memory_bytes: 45148
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1,-1, 0, 0};
int dy[4] = {0, 0, 1,-1};
signed main() {
    int T1,T2,A1,A2,B1,B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    if((A1 <= B1 && A2 <= B2) || (A1 >= B1 && A2 >= B2)) {
        cout << 0 << endl;
        return 0;
    }
    int X = (A1-B1)*T1;
    int Y = (A2-B2)*T2;
    if(X < 0) {
        X*=-1;Y*=-1;
    }
    if(X == -Y) {
        cout << "infinity" << endl;
    }
    // X-Y+X-Y+X-Y
    else if(X+Y > 0) {
        cout << 0 << endl;
    }
    else {
        // 2 3 2 3 2 3 2 3 2 3 2 3
        // 2 -1 1 -2 0 -3 -1
        if(X%(abs(X+Y)) == 0) {
            cout << X/(abs(X+Y))*2 << endl;
        }
        else {
            cout << X/(abs(X+Y))*2+1 << endl;
        }
    }
}


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

int main() {
     
     long long n,h,i,j,t,m,l,r,q;
     long long p=0,k,w,z,x,y,d;
     q=1;
     for(l=0;l<q;l++)
     {
          std::cin >> n;
          x=0;
          x=n+(n*n)+pow(n,3);
          std::cout << x << std::endl;
     }
     return 0;
}

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

int gcd(int a,int b){
	if(!b)return a;
	return gcd(b,a%b);
}
int main(){
	int x,y;cin>>x>>y;
	int g=gcd(x,y);
	cout<<(x/g+y/g-1)*g+1<<endl;
}

Measured memory_bytes: 3092
#include <iostream>

using namespace std;

int main()
{
    int N, L, sum = 0;
    cin >> N >> L;
    if (L < 0 && N + L > 0)
    {
        for (int i = L; i < N + L; i++)
            sum += i;
    }
    else if (L < 0)
    {
        for (int i = L; i < N + L - 1; i++)
            sum += i;
    }
    else
    {
        for (int i = L + 1; i < N + L; i++)
            sum += i;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
#define mod 1000000007
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
void fastio()
{					
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

}
ll int multiply(ll int a,ll int b)
{
	ll int ans=(a%mod*b%mod)%mod;
	return ans;
}
ll int add(ll int a, ll int b)
{
	ll int ans=(a%mod+b%mod)% mod;	
	return ans;
}


void solve()
{
	ll int n;
	cin>>n;
	ll int a[n+1],i;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];

	}
	ll int dp[n+1];
	dp[0]=0;
	dp[1]=0;
	for(i=2;i<=n;i++)
	{
		
			ll int op1=abs(a[i]-a[i-1])+dp[i-1];
			ll int op2=(i>2)? abs(a[i]-a[i-2])+dp[i-2]:1e18;
			dp[i]=min(op1,op2);
		
	}
	cout<<dp[n]<<endl;

	
}
int  main()
{
	fastio();
	ll int t;
	t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	
	

	
}




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

int main() {
	ll x;
	cin >> x;
	long double r = 1.01;
	ll now = 100;
	for (ll i = 0;; ++i) {
		now = now * 1.01;
		if (now >= x) {
			cout << i + 1 << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
typedef long long ll;

unsigned gcd(int a, int b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	int i, j, k, l, m, n, len, a, b, c;
	int A, B, C, N, K;
	char S[3];
	ll sum = 0;

	scanf("%d", &K);

	for (a = 1; a <= K; a++){
		for (b = 1; b <= K; b++){
			for (c = 1; c <= K; c++){
				sum += gcd(gcd(a, b), c);
			}
		}

	}
	printf("%lld\n", sum);
	return 0;

}
    


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

int main(void){
	int N;
	cin >> N;
	vector<vector<int>> to(N);
	vector<vector<int>> cost(N);
	for(int i=0;i<N-1;i++){
		int a,b,w;
		cin >> a >> b >> w;
		a--;
		b--;
		to[a].push_back(b);
		to[b].push_back(a);
		cost[a].push_back(w);
		cost[b].push_back(w);
	}
	vector<int>ans(N,0),visit(N,0);
	ans[0] = 0;
	visit[0]=1;
	for(int i=0;i<N;i++){
		queue<int> q;
		q.push(0);
		while(!q.empty()){
			int v = q.front();
			q.pop();
			for(int i=0;i<to[v].size();i++){
				int u = to[v][i];
				int w = cost[v][i];
				if(visit[u]!=0)continue;
				ans[u] = (ans[v]+w)%2;
				visit[u]=1;
				q.push(u);
			}
		}
	}
	for(int i=0;i<N;i++)cout << ans[i] << endl;
}

Measured memory_bytes: 12288
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)

def cnt2(n):
    ans = 0
    while n%2 == 0:
        ans += 1
        n //= 2
    return ans

def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans = INF
    for num in a:
        ans = min(ans,cnt2(num))
    
    print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 1000005;

deque<int> dq;

int main(){
	int n; scanf("%d",&n);
	for(int i=1; i<=n; i++){
		int x; scanf("%d",&x);
		if(i % 2 == 1) dq.push_back(x);
		else dq.push_front(x);
	}
	if(n & 1) reverse(dq.begin(), dq.end());
	for(auto &i : dq) printf("%d ", i);
}


Measured memory_bytes: 2944
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if a < b:
    if a + t * v >= b + t * w: print('YES')
    else: print('NO')
else:
    if a - t * v <= b - t * w: print('YES')
    else: print('NO')

Measured memory_bytes: 61668
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, maxv = -1;
    cin >> n;
    int A[n];
    rep(i,n) {
        cin >> A[i];
        maxv = max(maxv, A[i]);
    }

    int secv = -1;

    rep(i,n) {
        if (A[i] == maxv) {
            if (secv != -1) {
                cout << secv << endl;
                continue;
            }
            rep(j,n) {
                if (j == i) j++;
                secv = max(secv, A[j]);
            }
            cout << secv << endl;
        } else cout << maxv << endl;
    }
}

Measured memory_bytes: 2432
import sys

N, K = map(int, input().split())
x = list(map(int, input().split()))

ans = sys.maxsize

for i in range(K, N + 1):
    a = x[i - K]
    b = x[i - 1]

    ans = min(ans, max(abs(a), abs(b)) + min(abs(a), abs(b)) * 2 * (a * b < 0))

print(ans)

Measured memory_bytes: 14252
def dfs(a='', b=chr(ord('a'))):
	if len(a) == N:
		print(a)
	else:
		i = chr(ord('a'))
		while i < b:
			dfs(a + i, b)
			i = chr(ord(i) + 1)
		dfs(a + b, chr(ord(b) + 1))

N = int(input())
dfs()

Measured memory_bytes: 4412
#include <iostream>

using namespace std;
int a [101] = { 0 };
bool dp [100001] = { false };
int main ()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    // dp[0] = true;
    for (int stone = 0; stone <= k; ++stone) {
        for (int i = 0; i < n; ++i) {
            if (stone - a[i] >= 0 && !dp[stone - a[i]]) {
                dp[stone] = true;
            }
        }
    }
    // for (int i = 0; i <= k; ++i) {
    //     cout << dp[i] << endl;
    // }
    cout << (dp[k] ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int i,j;
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            //printf("%dx%d=%d\n",i,j,(i*j));
            cout << i <<'x' <<  j << '=' << i*j << endl;
        }
    }
    return 0;
}

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

using namespace std;

#define inf 1ll<<60
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
#define int llong
typedef pair<int, int> P;
typedef pair<P, int> PP;

signed main(){
	int N, K, kind = 0;
	multiset<PP> sushi;
	int use[100001] = {0};
	cin >> N >> K;
	int t, d;
	for(int i = 0; i < N; i++){
		cin >> t >> d;
		if(use[t] == false)
			kind++;
		use[t]++;
		sushi.insert(PP(P(d, t),d));
	}

	while(sushi.size() > K){
		// for(auto it = sushi.begin(); it != sushi.end(); it++)
		// 	cerr << it->first.first << " ";
		// cerr << endl;

		PP target = *(sushi.begin());
		sushi.erase(sushi.begin());

		if(use[target.first.second] == 1){
			int human = kind*kind - (kind-1)*(kind-1);
			if(target.first.first != target.second + human){
				// cerr << "check" << endl;
				target.first.first = target.second + human;
				sushi.insert(target);
				continue;
			}
		}

		use[target.first.second]--;
		if(use[target.first.second] == 0)
			kind--;
	}

	int ans = kind*kind;
	for(auto it = sushi.begin(); it != sushi.end(); it++)
		ans += it->second;

	cout << ans << endl;

	return 0;
}

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

int main(){
    int n;
    int t[100000];
    int m;
    int p[100];
    int x[100];
    int sum=0;
    cin >>n;
    for(int i=0;i<n;i++){
        cin>> t[i];
        sum+=t[i];
    }
    cin >> m;
    for(int i=0;i<m;i++){
        cin >> p[i] >> x[i];
        cout << sum-t[p[i]-1]+x[i] << endl;
    }
}

Measured memory_bytes: 256
hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

s_list = []
c_list = []

for i in range(M):
  hoge = input().split()
  s_list.append(int(hoge[0]))
  c_list.append(int(hoge[1]))
num = [10] * N

for i in range(len(s_list)):
  if s_list[i] == 1 and c_list[i] == 0 and N!= 1:
    num[s_list[i]-1] = 100
  elif num[s_list[i]-1] == 10:
    num[s_list[i]-1] = c_list[i]
  elif num[s_list[i]-1] != c_list[i]:
    num[s_list[i]-1] = 100
    
if 100 in num:
  print(-1)
elif N == 1 and M == 0:
  print(0)
elif 10 in num:
  for i in range(len(num)):
    if num[i] == 10 and i == 0:
      num[i] = 1
    if num[i] == 10 and i != 0:
      num[i] = 0
  for i in range(len(num)):
    print(num[i], sep="", end="")
else:
  for i in range(len(num)):
    print(num[i], sep="", end="")

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

int n, a, b, c, d;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> a >> b >> c >> d;
    --a, --b, --c, --d;
    string s;
    cin >> s;
    for (int i = a; i + 1 < d; ++i) {
        if (s.substr(i, 2) == "##") {
            cout << "No" << endl;
            return 0;
        }
    }

    if (c < d) {
        cout << "Yes" << endl;
    } else {
        for (int i = b - 1; i < d; ++i) {
            if (s.substr(i, 3) == "...") {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

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

    int minv = INT_MAX;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (minv >= p[i]) ans++;
        minv = min(minv, p[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <chrono>
#include <complex>
using namespace std;


void solve (){

    int x;
    cin >> x;

    if (x >= 400 && x <= 599)
        cout << "8\n";
    else if (x >= 600 && x <= 799)
        cout << "7\n";
    else if (x >= 800 && x <= 999)
        cout << "6\n";
    else if (x >= 1000 && x <= 1199)
        cout << "5\n";
    else if (x >= 1200 && x <= 1399)
        cout << "4\n";
    else if (x >= 1400 && x <= 1599)
        cout << "3\n";
    else if (x >= 1600 && x <= 1799)
        cout << "2\n";
    else if (x >= 1800 && x <= 1999)
        cout << "1\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3648
#-*- coding:utf-8 -*-
"""
外出しているXさんは、ABCに参加するためにスマートウォッチで最適な帰宅経路を調べることにしました。
スマートウォッチであるあなたは、N個の帰宅経路を見つけました。
Xさんがi番目の経路を使う場合、コストciかけて時間tiで帰宅できます。
時間T以内に帰宅できる経路のうち、コストが最小となる経路のコストを求めてください。
"""
def main():
    NT = list(map(int, input().split()))
    N = NT[0]
    T = NT[1]
    CandT = []
    for i in range(0, N):
        CandT.append(list(map(int, input().split())))

    CandT = sorted(CandT)  # コストで昇順ソート

    for i in range(0, N):
        if CandT[i][1] <= T:
            print(CandT[i][0])
            exit(0)
        else:
            pass
    print("TLE")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
N = int(input())
l =list(map(int,input().split()))

dame =0

for x in l:
  if x%2 == 0:
    if (x%3 == 0) or (x%5 == 0):
      continue
    else:
      dame = dame +1   
  else:
    continue

if dame > 0:
  print("DENIED")
else:
  print("APPROVED")

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  long long x=(long long)a*b;
  int r;
  int M=max(a,b);
  int m=min(a,b);
  r=M%m;
  while(r){
    M=m;
    m=r;
    r=M%m;
  }
  cout << x/m;
  return(0);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int n,w,d;
char tem[10];
int a[1000+10][2];
int get(int x,int y,int type)
{
    if(type==0)
    {
        int xx=min(x,y);
        x-=xx;y-=xx;
        if(x==0)return y;
        else return w+w+d+d-x;
    }
    else if(type==1)
    {
        int xx=min(x,d-y);
        x-=xx;
        y+=xx;
        if(x==0)return y;
        else return d+x;
    }
    else if(type==2)
    {
        int xx=min(w-x,d-y);
        x+=xx;y+=xx;
        if(y==d)return d+x;
        else return d+w+d-y;
    }
    else if(type==3)
    {
        int xx=min(w-x,y);
        x+=xx;y-=xx;
        if(x==w)return w+d+d-y;
        else return w+d+d+w-x;
    }
}
int ans=0;
struct P
{
    int x;
    bool l;
    int ori;
    bool operator <(const P &b)const
    {
        if(x!=b.x)return x<b.x;
        else return (l!=b.l)&&l;
    }
}p[4000+10];
bool vis[1000+10];
int sta[4000+10];
void solve(int st)
{
    int res=1;
    int tail=0;
    for(int i=1;i<=n;i++)
    {
        vis[i]=false;
        int new1=a[i][0]-st,new2=a[i][1]-st;
        while(new1<=-(w+w+d+d)){new1+=w+w+d+d;new2+=w+w+d+d;}
        if(new1<=0&&new2>=0)continue;
        p[tail++]=(P){new1,true,i};
        p[tail++]=(P){new2,false,i};
    }
    sort(p,p+tail);
    int m=tail;
    tail=0;
    for(int i=0;i<m;i++)
    {
        if(vis[p[i].ori])continue;
        if(p[i].l)
        {
            sta[tail++]=p[i].ori;
        }
        else
        {
            res++;
            while(tail)vis[sta[--tail]]=true;
        }
    }
    ans=min(ans,res);
}
int main()
{
    scanf("%d%d%d",&n,&w,&d);
    for(int i=1;i<=n;i++)
    {
        int x,y;
        scanf("%d%d%s",&x,&y,tem);
        if(tem[0]=='W')a[i][0]=get(x,y,0),a[i][1]=get(x,y,1);
        else if(tem[0]=='N')a[i][0]=get(x,y,1),a[i][1]=get(x,y,2);
        else if(tem[0]=='E')a[i][0]=get(x,y,2),a[i][1]=get(x,y,3);
        else if(tem[0]=='S')a[i][0]=get(x,y,3),a[i][1]=get(x,y,0);
        if(a[i][0]>a[i][1])a[i][0]-=w+w+d+d;
    }
    ans=0x3f3f3f3f;
    for(int i=1;i<=n;i++)
    {
        solve(a[i][0]);solve(a[i][1]);
    }
    printf("%d\n",ans);
    return 0;
}

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

int main() {
  double N;
  cin >> N;
  cout << std::fixed << std::setprecision(10);
  if(N==1) cout <<  1.0 << endl;
  else if(int(N)%2==0) cout<<0.5<<endl;
  else cout << ((N+1)/(2*N))<<endl;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s.size() == 1)
    {
        cout << s << "\n";
    }
    else
    {
        int count = 0;
        for(int i = 1;i < s.size();i++)
        {
            if(s[i] == '9')
            {
                count++;
            }
        }
        if(count == s.size() - 1)
        {
            cout << (s[0] - '0') + 9 * (s.size() - 1) << "\n";
        }
        else
        {
            cout << (s[0] - '0') + 9 * (s.size() - 1) - 1 << "\n";
        }
        
    }
    

    return 0;
}

Measured memory_bytes: 256
S=input()
if len(S)==1:
    print(0)
else:
    l=0
    r=0
    T=S[::-1]
    for i in range(1,len(S)):
        if S[i]==S[i-1]:
            if S[i]=='1':
                S=S[:i]+'0'+S[i+1:]
            else:
                S=S[:i]+'1'+S[i+1:]
            l+=1
    #print(l)
    #print(T)
    for i in range(1,len(T)):
        if T[i]==T[i-1]:
            if T[i]=='1':
                T=T[:i]+'0'+T[i+1:]
            else:
                T=T[:i]+'1'+T[i+1:]
            r+=1
    #print(r)
    print(min(l,r))



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

using namespace std;

typedef long long ll;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

const int mxN = 1e5;
const ll MOD = 1e9 + 7;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

ll gcd(ll a, ll b) {
	return b ? gcd(b, a%b) : a;
}

int main() {
	fast();
	char c;
	cin >> c;
	if (c >= 'A' && c <= 'Z') {
		cout << "A\n";
	} else {
		cout << "a\n";
	}
}

Measured memory_bytes: 3648
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cmath>
#include<cstring>
#include<climits>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
inline int read() {
	bool f=0;int x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c==EOF)exit(0);if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return !f?x:-x;
}
#define MAXN 100000
#define INF 0x3f3f3f3f
char S[MAXN+5];
int main(){
	scanf("%s",S+1);
	int len=strlen(S+1);
	for(int i=1;i<=len;i++)
		putchar('x');
	puts("");
	return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())

white = '.'
black = '#'
grid = [[black * 100] for i in range(50)] + [[white * 100] for i in range(50)]

for i in range(A-1):
    grid[(i // 50)*2][0] = grid[(i // 50)*2][0][:(i % 50) * 2] + white + grid[(i // 50)*2][0][(i % 50) * 2 + 1:]

for i in range(B-1):
    grid[(i // 50)*2 + 51][0] = grid[(i // 50)*2 + 51][0][:(i % 50) * 2] + black + grid[(i // 50)*2 + 51][0][(i % 50) * 2 + 1:]

print(100, 100)
for g in grid:
    print(g[0])

Measured memory_bytes: 3064
N,K = map(int,input().split())
Ni = list(map(int,input().split()))
    
K_bit = format(K, 'b')
max_K = 0
max_bit = len(K_bit)

cnt_bit = 1 << (max_bit-1)

for i in range(max_bit):
    cnt = 0
    for j in Ni:
        if j & cnt_bit:
            cnt += 1
            
    if cnt*2 <= N and (max_K + cnt_bit) <= K: #1が半分より少なかったら，増えるのでビットを立てる
        max_K += cnt_bit
        
    cnt_bit >>= 1
    
ans = sum([max_K ^ j for j in Ni])
        
print(ans)

Measured memory_bytes: 14176
#include <bits/stdc++.h>
using namespace std;
int main(void){
    const int xx=2647079;
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,v,i;
    while(cin>>h>>v,h){
        string s="",e="";
        char tmp;
        for(i=0;i<9;i++){
            cin>>tmp;
            s+=tmp;
        }
        for(i=0;i<9;i++){
            cin>>tmp;
            e+=tmp;
        }
        priority_queue<pair<int,string>> q;
        q.push(make_pair(0,s));
        vector<bool> mp(xx,false);
        pair<int,string> now;
        int num,zero;
        while(!q.empty()){
            now=q.top();q.pop();
            now.first*=-1;
            num=stoi(now.second);
            if(now.second==e){
                cout<<now.first<<endl;
                break;
            }
            if(!mp[num%xx]){
                mp[num%xx]=true;
            }else{
                continue;
            }
            zero=now.second.find('0');
            string ns=now.second;
            ns[zero]=ns[(zero+1)%9];
            ns[(zero+1)%9]='0';
            if(!mp[stoi(ns)%xx])
            q.push(make_pair(-now.first-h,ns));
            ns[(zero+1)%9]=ns[zero];
            ns[zero]='0';
             
            ns[zero]=ns[(zero-1<0)?8:(zero-1)];
            ns[(zero-1<0)?8:(zero-1)]='0';
            if(!mp[stoi(ns)%xx])
            q.push(make_pair(-now.first-h,ns));
            ns[(zero-1<0)?8:(zero-1)]=ns[zero];
            ns[zero]='0';
             
            ns[zero]=ns[(zero+3)%9];
            ns[(zero+3)%9]='0';
            if(!mp[stoi(ns)%xx])
            q.push(make_pair(-now.first-v,ns));
            ns[(zero+3)%9]=ns[zero];
            ns[zero]='0';
             
            ns[zero]=ns[(zero-3>=0)?zero-3:(9-(3-zero))];
            ns[(zero-3>=0)?zero-3:(9-(3-zero))]='0';
            if(!mp[stoi(ns)%xx])
            q.push(make_pair(-now.first-v,ns));
        }
    }
}


Measured memory_bytes: 14580
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

void debug(const vector<int>& v, int c=0){
	cout << "{";
	for(int i=0 ; i < v.size() ; i++ ){
		cout << v[i];
		if( i+1 != v.size() ) cout << ", ";
	}
	cout << "} cost:" << c << endl;
}

int main(){
	int n;
	cin >> n;
	
	vector<int> a(n), b(n);
	for(int i=0 ; i < n ; i++ ){
		cin >> a[i];
		b[i] = i+1;
	}
	// d[v] := スタートからのコスト, h[v] := ゴールからの距離
	map<vector<int>,int> d, h;
	// 解は最大でも n-1 
	int ans = n-1;
	// ゴールから探索
	{
		h[b] = 0;
		queue<vector<int> > q;
		q.push( b );
		while( !q.empty() ){
			vector<int> v = q.front();
			int cost = h[v];
			q.pop();
			
			if( v == a ){
				ans = cost;
				break;
			}
			if( cost >= 4 ) break;
			
			for(int i=0 ; i < n ; i++ ){
				for(int j=i+1 ; j < n ; j++ ){
					vector<int> next = v;
					//debug(v,cost);
					reverse( next.begin()+i , next.begin()+j+1 );
					//cout << "reveese(" << i << "," << j << ")" << endl;
					//debug(next,cost);
					//cout << endl;
					if( !h.count(next) ){
						h[next] = cost+1;
						q.push(next);
					}
				}
			}
		}
	}
	// スタートから探索
	{
		d[a] = 0;
		queue<vector<int> > q;
		q.push( a );
		while( !q.empty() ){
			vector<int> v = q.front();
			int cost = d[v];
			q.pop();
			
			if( h.count(v) ){
				ans = cost + h[v];
				break;
			}
			if( cost >= 4 ) break;
			
			for(int i=0 ; i < n ; i++ ){
				for(int j=i+1 ; j < n ; j++ ){
					vector<int> next = v;
					reverse( next.begin()+i , next.begin()+j+1 );
					if( !d.count(next) ){
						d[next] = cost+1;
						q.push(next);
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 81196
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private static final int INF = Integer.MAX_VALUE / 2;

    private static final long MOD = 1_000_000_007;

    private void solve(Scanner sc) {
        String s = sc.nextLine();
        long[][] dp = new long[s.length() + 1][4];
        dp[s.length()][3] = 1;
        for (int i = s.length() - 1; i >= 0; --i) {
            char ch = s.charAt(i);
            for (int j = 3; j >= 0; --j) {
                if (j == 3) {
                    long m = (ch == '?' ? 3 : 1);
                    dp[i][j] = (m * dp[i + 1][j]) % MOD;
                } else {
                    long m1 = (ch == '?' ? 3 : 1);
                    long m2 = (ch == '?' || j == ch - 'A' ? 1 : 0);
                    dp[i][j] = (m1 * dp[i + 1][j] + m2 * dp[i + 1][j + 1]) % MOD;
                }
            }
        }
        _out.println(dp[0][0]);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 30308
import java.util.Scanner;

//
class Main{
    final static long MOD = (long)(Math.pow(10, 9) + 7);

    static long[] cumulativeSum(long[] a) {
        long[] b = new long[a.length + 1];
        b[0] = 0L;
        for(int i = 0; i < a.length; i++)
            b[i + 1] = (b[i] + a[i]) % MOD;

        return b;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N];

        for(int i = 0; i < N; i++)
            a[i] = sc.nextLong();

        long[] b = cumulativeSum(a);

        long sum = 0L;
        for(int i = 0; i < N - 1; i++) {
            sum += (a[i] * (b[N] - b[i + 1] + MOD)) % MOD;
            sum %= MOD;
        }

        System.out.println(sum % MOD);
    }

}


Measured memory_bytes: 61468
def main():

    n = int(input())
    actividad = []
    for i in range(n):
        puntos = list(map(int, input().split()))
        actividad.append(puntos)

    primer_puntos = [0] * 3

    for i in range(len(primer_puntos)):
        primer_puntos[i] = actividad[0][i]

    for i in range(1, n):
        siguiente = [0] * 3
        for j in range(3):
            for k in range(3):
                if j != k :
                    siguiente[j] = max(siguiente[j], primer_puntos[k] + actividad[i][j])
        primer_puntos = siguiente

    print(max(primer_puntos))
if __name__ == "__main__":
    main()

Measured memory_bytes: 30076
def modpow(x, n, mod):
    res = 1
    while (n > 0):
        if (n & 1):
            res *= x
            res %= mod
        x *= x
        x %= mod
        n >>= 1
    return res


def comb(a, b, p):
    if (b > a - b):
        return comb(a, a - b, p)
    c = d = 1
    for i in range(b):
        c *= (a - i)
        d *= (b - i)
        c %= p
        d %= p
    return c * modpow(d, p - 2, p) % p


n, a, b = map(int, input().split())
mod = 10**9 + 7
all = modpow(2, n, mod)
res = (all - 1 - comb(n, a, mod) - comb(n, b, mod)) % mod
print(res)


Measured memory_bytes: 3064
N = int(input())
alist = list(input().split())
if N % 2 == 0:
    a1 = alist[1::2]
    a2 = alist[0::2]
    a1.reverse()
    a1.extend(a2)
else:
    a1 = alist[0::2]
    a2 = alist[1::2]
    a1.reverse()
    a1.extend(a2)
c = ' '.join(a1)
print(c)

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

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).end()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a,n) sort(a, a+n)
#define sortvec(V) sort(all(V))

typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

void solve()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        if(i & 1 && x & 1)  ans++;
    }
    cout << ans << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

Measured memory_bytes: 3800
#include <cstdio>
#include <cmath>
#include <queue>
#include <limits>
using namespace std;

typedef pair<double, int> P;

int x[1002], y[1002], r[1002];
double cost[1002][1002];
double d[1002];

int main()
{
    scanf("%d%d%d%d", &x[0], &y[0], &x[1], &y[1]);
    r[0] = r[1] = 0;

    int N;
    scanf("%d", &N);
    N += 2;
    for (int i = 2; i < N; i++)
        scanf("%d%d%d", &x[i], &y[i], &r[i]);

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            cost[i][j] = max(hypot(x[i] - x[j], y[i] - y[j]) - r[i] - r[j], 0.);

    for (double &nd : d)
        nd = numeric_limits<double>::infinity();
    d[0] = 0;
    priority_queue<P, vector<P>, greater<P>> q;
    q.push(P(0, 0));

    while (!q.empty()) {
        auto p = q.top();
        double nowd = p.first;
        int v = p.second;
        q.pop();
        if (nowd < d[v])
            continue;
        for (int i = 0; i < N; i++) {
            double nextd = d[v] + cost[v][i];
            if (d[i] > nextd) {
                d[i] = nextd;
                q.push(P(nextd, i));
            }
        }
    }

    printf("%.12f\n", d[1]);
}


Measured memory_bytes: 12272
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
int main()	{
  int n,k;
  cin>>n>>k;
  vector<int>l(n);
  rep(i,n){cin>>l[i];}
  sort(l.rbegin(),l.rend());
  int length=0;
  rep(i,k){
    length+=l[i];
  }
  cout<<length<<endl;
}

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

long long BASE = 219LL;
long long MOD = 2147483647LL;
long long power[1 << 18], hash_val[1 << 18];

void init(string S) {
	power[0] = 1;
	for (int i = 1; i <= 100000; i++) power[i] = (BASE * power[i - 1]) % MOD;
	for (int i = 1; i <= S.size(); i++) hash_val[i] = (BASE * hash_val[i - 1] + 1LL * (long long)(S[i - 1] - 'a' + 1)) % MOD;
}

long long getval(int cl, int cr) {
	// [cl, cr]
	return (hash_val[cr + 1] - hash_val[cl] * power[cr - cl + 1] + MOD * MOD) % MOD;
}

bool check(string S, int K) {
	map<long long, int> Map;
	for (int i = 0; i <= (int)S.size() - K; i++) {
		long long D = getval(i, i + K - 1);
		if (Map[D] == 0) Map[D] = i + 1;
		else if (Map[D] <= i - K + 1) return true;
	}
	return false;
}

int main() {
	string S; int N; cin >> N >> S;
	init(S);

	int cl = 0, cr = S.size(), cm, maxn = 0;
	for (int i = 0; i < 20; i++) {
		cm = (cl + cr) / 2;
		bool I = check(S, cm);
		if (I == true) { maxn = max(maxn, cm); cl = cm; }
		else { cr = cm; }
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 2688
import copy
n, m = map(int, input().split())

graph = [list() for i in range(n+1)]
for i in range(m):
   a, b = map(int, (input().split()))
   graph[a] += [b]
   graph[b] += [a]

def dfs(visited, now):
    tv = copy.copy(visited)
    tv[now-1] = 1
    if all(tv) == 1:
        return 1

    count = 0
    for i in graph[now]:
        if tv[i-1] == 0:
            count += dfs(tv, i)
    return count

print(dfs([0] * n, 1))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,a,b)	for(int i=a;i<=b;i++)
using namespace std;
const int N=2e5+5,M=6008;
int n,k,x,y,m;
string c;
int f[M][M];
int calc(int x1,int y1)
{
	int x2=x1+k-1,y2=y1+k-1;
	x1=max(1,x1),y1=max(1,y1);
	x2=min(x2,m),y2=min(y2,m);
	if(x2<1||y2<1)
		return 0;
	return f[x2][y2]-f[x1-1][y2]-f[x2][y1-1]+f[x1-1][y1-1];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;	
	m=2*k;
	memset(f,0,sizeof(f));
	rep(i,1,n)
	{
		cin>>x>>y>>c;
		if(c=="W")
			y+=k;
		x%=m,y%=m;
		x++,y++;
		f[x][y]++;
	}
	for(int i=1;i<=2*m;i++)
		for(int j=1;j<=2*m;j++)
			f[i][j]=f[i][j]+f[i][j-1]+f[i-1][j]-f[i-1][j-1];
	int res=0;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=m;j++)
		{
			int cnt=calc(i,j);
			cnt+=calc(i-k,j-k)+calc(i-k,j+k)+calc(i+k,j-k)+calc(i+k,j+k);
		//	cnt+=calc(i,j+m)+calc(i+m,j);
			cnt+=calc(i-m,j)+calc(i+m,j)+calc(i,j-m)+calc(i,j+m);
			res=max(res,cnt);
		}
	}
	cout<<res<<endl;
	return 0;
	
}

Measured memory_bytes: 141312
let cnt = ref 0

let insertion_sort n ?(gap=1) a =
  for i=gap to n-1 do
    let v = a.(i) in
    let j = ref (i - gap) in
    while !j >= 0 && a.(!j) > v do
      a.(!j+gap) <- a.(!j);
      j := !j - gap;
      incr cnt;
    done;
    a.(!j+gap) <- v
  done;
  a

let shell_sort array n =
  let rec gen_gaps = function
      [] -> gen_gaps [1]
    | h::t when h > n -> t
    | h::_ as l -> gen_gaps ((3*h + 1)::l) in
  let gaps = gen_gaps [] in
  let m = List.length gaps in
  let rec loop a = function
      [] -> a
    | h::t -> loop (insertion_sort n ~gap:h a) t in
  let a = loop array gaps in
  Printf.printf "%d\n" m;
  Array.iteri
    (fun i x -> Printf.printf (if i=m-1 then "%d\n" else "%d ") x)
    (Array.of_list gaps);
  Printf.printf "%d\n" !cnt;
  a

let () =
  let n = read_int () in
  let rec read a = function
      i when i = n -> a
    | i -> a.(i) <- (read_int ());
      read a (i+1) in
  let a = read (Array.make n 0) 0 in
  Array.iter (Printf.printf "%d\n") (shell_sort a n)

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

int main()
{
    int K;
    cin >> K;
    int ret = 0;
    for (int a = 1; a <= K; a++)
    {
        for (int b = 1; b <= K; b++)
        {
            int gcdab = gcd(a, b);
            for (int c = 1; c <= K; c++)
            {
                ret += gcd(gcdab, c);
            }
        }
    }
    cout << ret << "\n";
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=100005;
struct SegTree{
	ll mn[N<<2];
	#define mid ((l+r)>>1)
	void init(){memset (mn,0x3f,sizeof(mn));}
	void insert(int root,int l,int r,int x,int v){
		if (l==r){mn[root]=v;return;}
		if (x<=mid) insert(root<<1,l,mid,x,v);
		else insert((root<<1)|1,mid+1,r,x,v);
		mn[root]=min(mn[root<<1],mn[(root<<1)|1]);
	}
	ll query(int root,int l,int r,int L,int R){
		if (r<L||l>R) return 1ll<<60;
		if (L<=l&&r<=R) return mn[root];
		return min(query(root<<1,l,mid,L,R),query((root<<1)|1,mid+1,r,L,R));
	}
	#undef mid
}Seg1,Seg2;
int a[N];
ll dp[N];
int main (){
	int n,e,t;scanf ("%d%d%d",&n,&e,&t);
	for (int i=1;i<=n;i++) scanf ("%d",&a[i]);
	dp[0]=0;Seg1.init(),Seg2.init();
	Seg1.insert(1,0,n,0,-2ll*a[1]);
	Seg2.insert(1,0,n,0,0);
	for (int i=1;i<=n;i++){
		dp[i]=1ll<<60ll;
		int l=1,r=i-1,pos=-1;
		while (l<=r){
			int mid=(l+r)>>1;
			if (2ll*(a[i]-a[mid])>=t) pos=mid,l=mid+1;
			else r=mid-1;
		}
		if (pos!=-1) dp[i]=Seg1.query(1,0,n,0,pos-1)+2ll*a[i];
		dp[i]=min(dp[i],Seg2.query(1,0,n,pos,n)+t);
		Seg1.insert(1,0,n,i,dp[i]-2ll*a[i+1]);
		Seg2.insert(1,0,n,i,dp[i]);
	}
	printf ("%lld",dp[n]+e);
	return 0;
}


Measured memory_bytes: 7680
#include <iostream>

using namespace std;

const int NMAX=1000*100;
int valeurs[NMAX],compteur[3];

int main(){
    int n,placeLibre,autre;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> valeurs[i];
        if(valeurs[i]%4==0){
            compteur[2]++;
        }
        else if(valeurs[i]%2==0){
            compteur[1]++;
        }
        else{
            compteur[0]++;
        }
    }
    if(compteur[2]==0){
        placeLibre=0;
    }
    else{
        placeLibre=compteur[2]+1;
    }
    if(compteur[1]>=1){
        autre=compteur[0]+1;
    }
    else{
        autre=compteur[0];
    }

    if(placeLibre>=autre || (compteur[0]==0 && compteur[2]==0)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
 
#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define mp make_pair
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)
		
#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container
 
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
//#define mod (((ll)1000000000) * ((ll)1000000000))
using namespace std;
 
typedef  long long     int ll;
typedef unsigned long long int ull;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;
typedef pair < int , int > ii;
const ll mod=1e9+7;
const ll mod2=1e9+9;
const ll maxn = 2e5+5;
const ll maxn1 = 1e7+1;
const int root=1e6+5;
const long long inf = 1e18 + 18;
double pie4=3.1415926535;
vector<ll>v ;
ll a[maxn] ;	
vector<pair<double,pair<ll,ll> > >v1 ;
	
int main(){
	
	ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
	
	ll i, n, x, y, p ;
	double z ;
	
	cin >> n;
	
	for (i = 1; i <= n; i++){

		cin >> a[i] ;
		
		//if(a[i])
		v.eb(a[i]);
	}
	
		
		
	
	sort(v.begin(), v.end());
	
	if(n == 2){
	
	cout << v[1] << " "<< v[0] << endl;
	return 0 ;
}
	
	for (i = 0; i < siz(v);i++){
		
		x = v[i] ;
		
		if(x==0)
		continue ;
		
		y = upper_bound(v.begin(), v.end(), x/2) - v.begin() ;
		
		//trace2(x,y) ;
		
		if(y>=0 && y<siz(v) && v[y]!=x){
		p = v[y] ;
		z = (1.0*x)/(1.0* (x-p)*(p)) ;
		v1.eb({z,{x,p}});
	}
		
		
		
		
		y--;	 
		
		//trace2(x,y);
		
		if(y>=0 && y<siz(v) && v[y]!=x)
		p = v[y] ;
		
		else
		continue ;
		
		z = (1.0*x)/(1.0* (x-p)*(p)) ;
		
		//trace4(z,x,p,y);
		
		v1.eb({z,{x,p}});
	}
	
	sort(v1.begin(), v1.end());
	
	//if(siz(v1)>0)
	cout<<v1[0].Y.X<<" "<<v1[0].Y.Y;
	
	//cout<<
}
	


Measured memory_bytes: 10732
#include <iostream>
using namespace std;
int main(void){
    int _n,_m,_l;
    cin >> _n >> _m >> _l;
    
    int a[_n][_m];
    int b[_m][_l];
    long c[_n][_l];

    for(int n=0;n<_n;n++){
        for(int l=0;l<_l;l++){
            for(int m=0;m<_m;m++){
                a[n][m]=0;
                b[m][l]=0;
                c[n][l]=0;
            }
        }
    }
    
    for(int n=0;n<_n;n++){
        for(int m=0;m<_m;m++){
            int v;
            cin >> v;
            a[n][m] = v;
        }
    }
    
    for(int m=0;m<_m;m++){
        for(int l=0;l<_l;l++){
            int v;
            cin >> v;
            b[m][l] = v;
        }
    }
    
    for(int n=0;n<_n;n++){
        for(int l=0;l<_l;l++){
            for(int m=0;m<_m;m++){
                c[n][l] += a[n][m] * b[m][l];
            }
        }
    }
    
    for(int n=0;n<_n;n++){
        for(int l=0;l<_l;l++){
            if(l)cout<< " ";
            cout << c[n][l];
        }
        cout << endl;
    }

}

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

int main() {
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  map<int ,int> m;
  for(int i=0;i<N;i++){
    m[a.at(i)]=i;
  }
  //sort(a.begin(),a.end());
  for(int i=1;i<=N;i++){
    cout<<m.at(i)+1<<" ";
  }
  
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  ll X,K,D;
  cin >> X >> K >> D;
  ll r = abs(X) % D;
  ll q = abs(X) / D;
  if(q > K){
    cout << abs(X) - K*D << endl;
    return 0;
  }
  if((K - q) % 2 == 0){
    cout << r << endl;
  }
  else{
    cout << D - r << endl;
  }
  return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <ctime>
#include <numeric>
#include <cstdlib>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

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

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

int N;
int a[100];
double avr = 0;
double num = 100;
int ans = 0;

int main(){
	
	cin>>N;
	
	REP( i, N ){
		cin>>a[i];
		avr += a[i];
	}
	avr /= (double)N;
	
	REP( i, N ){
		if( abs(a[i] - avr) < num ){
			num = abs(a[i] - avr);
			ans = i;
		}
	}
	cout<<ans<<endl;
	
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    string s; cin>>s;
    if(s.size()==26){
        string t=s;
        bool fl=next_permutation(t.begin(),t.end());
        if(fl){
            int i=0;
            while(s[i]==t[i]){
                cout<<t[i];
                i++;
            }
            cout<<t[i]<<endl;;
        }else{
            cout<<-1<<endl;
        }
    }else{
        int a[26]={};
        FOR(i,0,s.size()){
            a[s[i]-'a']++;
        }
        int k=0;
        while(a[k]) k++;
        s+='a'+k;
        cout<<s<<endl;
    }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
k = [0] * M
s = [0] * M
for i in range(M):
    ks = list(map(int, input().split()))
    k[i], s[i] = ks[0], ks[1:]
p = list(map(int, input().split()))

count = 0
for i in range(2**N):
    switch = (("{:0"+str(N)+"b}").format(i))[::-1]
    judge = True
    for m in range(M):
        if sum(int(switch[j-1]) for j in s[m]) % 2 != p[m]:
            judge = False
            break
    if judge:
        count += 1

print(count)

Measured memory_bytes: 3064
# include <bits/stdc++.h>
typedef long long lint;
using namespace std;

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  int h,w,k; cin >> h >> w >> k;
  vector<string> c(h); for(int i=0;i<h;i++) { cin >> c[i]; }
  // for(int i=0;i<h;i++) { cout << c[i] << endl; }

  vector<int> row(h,0), col(w,0); // count nuumber of '#'
  int cnt=0; // total number of '#'
  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      if(c[i][j] == '#') { row[i]++; }
    }
    cnt += row[i];
  } // count row

  for(int i=0;i<w;i++) {
    for(int j=0;j<h;j++) {
      if(c[j][i] == '#') { col[i]++; }
    }
  } // count col

  int ans=0;
  for(int bit_i=0;bit_i<(1<<h);bit_i++) {
    for(int bit_j=0;bit_j<(1<<w);bit_j++) {

      int chk=0;
      for(int i=0;i<h;i++) {
        for(int j=0;j<w;j++) {
          if((bit_i&(1<<i)) || (bit_j&(1<<j))) {
            if(c[i][j]=='#') {
              chk++;
            }
          } 
        }
      }

      if(chk == cnt-k) { ans++; }
    }
  }   

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


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
 
 
int main() {
	
	string s;
	cin >> s;
	int dif = 1000;
	for(int i=0; i<s.size()-2; i++){
		int x = (s[i]-'0')*100 + (s[i+1]-'0')*10 + s[i+2]-'0';
		dif = min(dif, abs(x-753));
	}
	cout << dif <<endl;
 
}

Measured memory_bytes: 256