akhauriyash/Code-Regression huggingface dataset:
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
int main()
{
    int n;
    cin >> n;
    vector<int> cnts(n, 0);
    rep(i, 0, n-1)
    {
        int A;
        cin >> A;
        ++cnts[A-1];
    }
    rep(i, 0, n)
        printf("%d\n", cnts[i]);
    return 0;
}


Measured memory_bytes: 4052
N = int(input())

sum_all = (N * (N + 1)) // 2
sum_three = 3 * ((N // 3) * (N // 3 + 1)) // 2
sum_five = 5 * ((N // 5) * (N // 5 + 1)) // 2
sum_fifteen = 15 * ((N // 15) * (N // 15 + 1)) // 2

ans = sum_all - sum_three - sum_five + sum_fifteen

print(ans)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N, A, B, C;
	cin >> N >> A >> B >> C;
	vector<int> l(N);
	for (int i = 0; i < N; i++)cin >> l[i];
	sort(l.begin(), l.end());
	int ans = INF / 2;
	do {
		for (int i = 0; i < N - 2; i++)for (int j = i + 1; j < N - 1; j++)for (int k = j + 1; k < N; k++) {
			int a = 0, b = 0, c = 0;
			for (int n = 0; n <= i; n++)a += l[n];
			for (int n = i + 1; n <= j; n++)b += l[n];
			for (int n = j + 1; n <= k; n++)c += l[n];
			ans = min(abs(A - a) + abs(B - b) + abs(C - c) + i * 10 + (abs(i - j) - 1) * 10 + (abs(j - k) - 1) * 10, ans);
		}
	} while (next_permutation(l.begin(), l.end()));
	cout << ans << endl;
}

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

const int M=1e5+5;
// 3*3*3=27
int dp[M][27];
int pre[M][27];
char ch[M][27];

int getst(int a,int b,int c)
{
	return a*9+b*3+c;
}
void getabc(int st,int &a,int &b,int &c)
{
	a=st/9;
	b=st/3%3;
	c=st%3;
}

char s[M];

int main()
{
	int n,a,b,c;
	scanf("%d%d%d%d",&n,&a,&b,&c);
	if(a>=2) a=2;
	if(b>=2) b=2;
	if(c>=2) c=2;
	dp[0][getst(a,b,c)]=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s);
		for(int j=0;j<27;j++)
		{
			if(!dp[i-1][j]) continue;
			getabc(j,a,b,c);
			if(s[0]=='A'&&s[1]=='B')
			{
				if(a)
				{
					int nst=getst(a-1,min(2,b+1),c);
					dp[i][nst]=1;
					pre[i][nst]=j;
					ch[i][nst]='B';
				}
				if(b)
				{
					int nst=getst(min(2,a+1),b-1,c);
					dp[i][nst]=1;
					pre[i][nst]=j;
					ch[i][nst]='A';
				}
			}
			else if(s[0]=='A'&&s[1]=='C')
			{
				if(a)
				{
					int nst=getst(a-1,b,min(2,c+1));
					dp[i][nst]=1;
					pre[i][nst]=j;
					ch[i][nst]='C';
				}
				if(c)
				{
					int nst=getst(min(2,a+1),b,c-1);
					dp[i][nst]=1;
					pre[i][nst]=j;
					ch[i][nst]='A';
				}
			}
			else
			{
				if(b)
				{
					int nst=getst(a,b-1,min(2,c+1));
					dp[i][nst]=1;
					pre[i][nst]=j;
					ch[i][nst]='C';
				}
				if(c)
				{
					int nst=getst(a,min(2,b+1),c-1);
					dp[i][nst]=1;
					pre[i][nst]=j;
					ch[i][nst]='B';
				}
			}
		}
		
	}
	int u=-1;
	for(int i=0;i<27;i++)
		if(dp[n][i]) u=i;
	if(u==-1) puts("No");
	else
	{
		puts("Yes");
		for(int i=n;i>0;i--)
		{
			s[i-1]=ch[i][u];
			u=pre[i][u];
		}
		for(int i=0;i<n;i++)
			printf("%c\n",s[i]);
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> mt(n);
    for (int i=0; i < n; i++){
        int l_i;
        cin >> l_i; 
        mt[i] = l_i;
    }
    int sum = 1;
    for (int i=1; i< n; i++){
        bool check = true;
        for (int j=0; j < i; j++){
            if ( mt[i] < mt[j]){
                check = false;
                break;
            }
        }
        if (check == true){
            sum = sum + 1;
        }

    }



    cout << sum << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include<sstream>
#include<unordered_set>

using namespace std;



int main(){
    string s;
    int N,A,B;
    cin >> N >> A >> B;
    cin >> s;
    int n = 0, br = 0, t = A + B;
    for(int i = 0; i < N; ++i) {
        if (s[i] == 'c') {
            cout << "No" << endl;
        }
        if (s[i] == 'b') {
            ++br;
            if (n < t) {
                if (br <= B) {
                    ++n;
                    cout << "Yes" << endl;
                }
                else
                    cout << "No" << endl;
            } else
                cout << "No" << endl;
        }
        if (s[i] == 'a') {
            if (n < t) {
                ++n;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }
    }
}



Measured memory_bytes: 896
import java.util.Scanner;

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

		int aa = a + (a - 1);
		int ab = a + b;
		int bb = b + (b - 1);

		System.out.println(Math.max(Math.max(aa, ab), bb));
	}
}

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

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

  int sa = 800;

  for (int i = 0; i < str.size() - 2; i++) {
    int s = stoi(str.substr(i, 3));
    if (abs(753 - s) < sa) {
      sa = (abs(753 - s));
    }
  }

  cout << sa << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=105;
int n,x,l[maxn];
int main()
{
	int now=0,ans=0;
	cin>>n>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>l[i];
		now+=l[i];
		if(now<=x) ans++;
		else break;
	}
	cout<<ans+1;
	return 0;
} 

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

ll X;

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

  std::cin >> X;

  ll cur = 100;
  int t = 0;

  while(cur < X){
      cur += cur / 100;
      t += 1;
  }

  std::cout << t << std::endl;
}


Measured memory_bytes: 3536
INTEGER N,M,C
INTEGER,ALLOCATABLE,DIMENSION(:)::B,A
INTEGER ANS,CHIRASHINOURA
READ*,N,M,C
ALLOCATE(B(M))
ALLOCATE(A(M))
READ*,B
ANS=0
DO I=1,N
  READ*,A
  CHIRASHINOURA=C
  DO J=1,M
    CHIRASHINOURA=CHIRASHINOURA+A(J)*B(J)
  END DO
  IF(CHIRASHINOURA>0)ANS=ANS+1
END DO
PRINT"(I0)",ANS
END

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

#define rep(i, first, to) for(ll i = first; i < to; ++i)

using namespace std;
typedef long long ll;

void solve() {
	list<int> data;
	int v;
	int ans = 0;
	rep(i, 0, 3) {
		cin >> v;
		list<int> :: iterator index = find(data.begin(), data.end(), v);
		if (index == data.end()) {
			++ans;
			data.push_back(v);
		}
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void) {
	int N,X,L[101],i;
	scanf("%d%d",&N,&X);
	for(i=0;i<N;i++){
		scanf("%d",&L[i]);
	}
	int ans=1;
	int d=0;
	for(i=0;i<N;i++){
		d=d+L[i];
		if(d>X){
			ans=ans+i;
			break;
		}
	}
if(d>X){
	printf("%d",ans);
}
else{
	printf("%d",N+1);
}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double m;
    m=n/2+n%2;
    cout<<showpoint;
    cout<<fixed;
    cout<<setprecision(10);
    cout<<m/n<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long k = sc.nextLong();

    if (a <= k) {
      System.out.print(0);
      System.out.print(" ");
      if (b-(k-a)>0) {
        System.out.println(b-(k-a));
      } else {
        System.out.println(0);
      }
    } else {
      System.out.print(a-k);
      System.out.print(" ");
      System.out.println(b);
    }
  }
}


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

using namespace std;
#define li long long int


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    li n,i,x,k;
    cin>>n>>k;

    li dp[n+1]={0},h[n+1]={0};


    for(i=1;i<=n;i++)
    {
        cin>>h[i];
    }


    dp[0]=dp[1]=0;
    dp[2]=abs(h[2]-h[1]);

    for(i=2;i<=n;i++)
    {
        dp[i]=INT_MAX;
        for(li j=1;j<=k;j++)
        {
            if(i-j>0)
                dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }

    }
    cout<<dp[n];

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;
typedef pair<int,int> P;
void read(int &N,int &M,vector<vector<int>> &g,vector<int>&p);
signed main(){
    int N,M;
    vector<vector<int>> to;
    vector<int> p;
    read(N,M,to,p);
    auto dfs = [&](auto&& f,int s,int onf,vector<int> bulb){
        if(onf){
            REP(i,to[s].size()) bulb[to[s][i]]++;
        }
        if(s==N-1){
            REP(i,M) if(bulb[i]%2!=p[i]) return 1LL*0;
            return 1LL*1;
        }
        int ret=0;
        ret=f(f,s+1,0,bulb)+f(f,s+1,1,bulb);
        return ret;
    };
    vector<int> a(M,0);
    cout<<dfs(dfs,-1,0,a)<<endl;
}

void read(int &N,int &M,vector<vector<int>> &g,vector<int>&p){
    cin>>N>>M;
    g.resize(N);p.resize(M);
    REP(i,M){
        int k;cin>>k;
        REP(j,k){
            int s;cin>>s;
            s--;
            g[s].push_back(i);
        }
    }
    REP(i,M) cin>>p[i];
}


Measured memory_bytes: 256
#include<iostream>
int main(void){
  int N;
  std::cin >> N;
  int button[N];
  for (int i=0;i<N;i++){
    std::cin >> button[i];
  }

  int num = 1;
  int count = 0;
  for (int i=0;i<N+1;i++){
    num = button[num-1];
    count++;
    if (num == 2) break;
  }
  if (count == N+1){
    std::cout << -1;
  }else{
    std::cout << count;
  }
  
  return 0;
}

Measured memory_bytes: 3992
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        String S = sc.next();
        System.out.println(solve(n,S));
    }
    private static String solve(int N, String s) {
        if(N%2 == 1) return "No";
        if(s.substring(0, N/2).equals(s.substring(N/2))) return "Yes";
        return "No";
    }
}

Measured memory_bytes: 23252
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    string s;
    cin >> s;
    rep(i,0,3){
	if(s[i] == '1')s[i] = '9';
	else s[i] = '1';
    }
    P(s);
    
    return  0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())

import math

if n%2 == 1:
    print(0)
    exit()

k = 0
while n - 2*5**k >= 0:
    k += 1
k -= 1

ans = 0
for i in range(1, k+1):
    ans += n//(2*5**i)

print(ans)


Measured memory_bytes: 9156
import sys
from collections import deque
import itertools
from collections import deque
sys.setrecursionlimit(10 ** 9)
import heapq
import numpy as np

# map(int, sys.stdin.read().split())


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


def main():
    N,M = map(int,input().split())
    A = list(map(lambda x: int(x)*-1,sys.stdin.read().split()))
    heapq.heapify(A)

    for _ in range(M):
        temp = heapq.heappop(A)
        temp=-temp//2
        heapq.heappush(A,-temp)
    print(-sum(A))




    pass



if __name__ == "__main__":
    main()


Measured memory_bytes: 38460
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
int sdist[100000];
int fdist[100000];
vector<int> graph[100000];
main(){
    int N,A,B;
    cin >> N;
    for(int i = 0;i < N-1;i++){
        cin >> A >> B;
        A--;B--;
        graph[A].push_back(B);
        graph[B].push_back(A);
    }
    queue<int> qa,qb;
    qa.push(0);
    sdist[0] = 1;
    while(!qa.empty()){
        int num = qa.front();
        qa.pop();
        for(auto v:graph[num]){
            if(sdist[v])continue;
            sdist[v] = sdist[num]+1;
            qa.push(v);
        }
    }
    qb.push(N-1);
    fdist[N-1] = 1;
    while(!qb.empty()){
        int num = qb.front();
        qb.pop();
        for(auto v:graph[num]){
            if(fdist[v])continue;
            fdist[v] = fdist[num]+1;
            qb.push(v);
        }
    }
    int cnt = 0;
    for(int i = 0;i < N;i++){
//        cout << sdist[i] << " " << fdist[i] << endl;
        if(sdist[i] <= fdist[i])cnt++;
    }
    if(cnt > N-cnt)cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 700;

map<int, int> mp;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int tmp = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> tmp;
        mp[tmp]++;
    }
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> tmp;
        if(mp[tmp] == 0 || mp.find(tmp) == mp.end())
        {
            cout << "NO\n";
            return 0;
        }
        mp[tmp]--;
    }
    cout << "YES\n";

    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
char s[1000001];
int a[1000001];
void check(int &mx)
{
	for(int i=1;i<=mx;i++)
	{
		if(a[i]>=10)
			a[i+1]+=a[i]/10,a[i]%=10;
		if(a[mx+1]) mx++;
	}
}
signed main()
{
	scanf("%s",s+1);
	int mx=strlen(s+1);
	for(int i=1;i<=mx;i++)
		a[i]=s[mx-i+1]-'0',a[i]*=9;
	check(mx);
	int num=0;
	for(int i=1;i<=mx;i++)
		num+=a[i];
	for(int i=0;i<=600000;i++)
	{
		if(9*i>=num)
		{
			printf("%d",i);
			return 0;
		}
		a[1]+=9;
		num+=9;
		int cur=1;
		while(a[cur]>=10)
			a[cur+1]+=a[cur]/10,a[cur]%=10,cur++,num-=9;
	}
	return 0;
}


Measured memory_bytes: 4608
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		char[] s=sc.next().toCharArray();
		int q=sc.nextInt();
		for(int i=0; i<q; i++){
			int k=sc.nextInt();
			int nd=0;
			int nm=0;
			long ndm=0;
			long ans=0;
			for(int j=0; j<n; j++){
				if(j-k>=0){
					if(s[j-k]=='D'){
						nd--;
						ndm-=nm;
					}else if(s[j-k]=='M'){
						nm--;
					}
				}
				if(s[j]=='D'){
					nd++;
				}else if(s[j]=='M'){
					nm++;
					ndm+=nd;
				}else if(s[j]=='C'){
					ans+=ndm;
				}
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 36180
#include<cstdio>

int main() {
    unsigned long a, b, c, d, e;
    unsigned long kpk, fpb;
    while ( scanf("%ld %ld", &a, &b) != EOF ) {
          c = a;
          d = b;
          while ( c%d != 0 ) {
                e = c % d;
                c = d;
                d = e;
          }
          fpb = d;
          kpk = (a / fpb ) * b;
          printf("%ld %ld\n", fpb, kpk);
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main()
{
    int a;
    cin >> a;
    int ans = a + a*a + a*a*a;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,a,b,p,ct;
    cin>>n;
    string s;
    cin>>s;
    for(ll i=0;i<s.size();i++)
    {
        s[i]+=n;
        if(s[i]>90) s[i]-=26;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
s = input()
ans = [0]*len(s)

lst = []
for i in range(1,len(s)):
    if s[i-1] == 'R' and s[i] == 'L':
        lst.append(i)
index = 0
line = lst[index]

for i in range(len(s)):
    if i < line:
        if (line-i)%2 == 0:
            ans[line] += 1
        else:
            ans[line-1] += 1
    else:
        if s[i-1] == 'L' and s[i] == 'R':
            index += 1
            line = lst[index]
            if (line-i)%2==0:
                ans[line] += 1
            else:
                ans[line-1] += 1
        else:
            if (i-line)%2==0:
                ans[line] += 1
            else:
                ans[line-1] += 1
print(str(ans).replace('[','').replace(']','').replace(',',''))


Measured memory_bytes: 6548
from bisect import bisect_left
n = int(input())
m=list(map(int,input().split()))
k=0
m.sort()
for i in range(n-2):
    for j in range(i+1,n-1):
        z=m[i]+m[j]
        l=bisect_left(m,z)
        k+=l-j-1
print(k)

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

int main() {
    ll h, w;
    cin >> h >> w;
    ll ans = (w * (ll)(h / 2ll));
    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }
    if (h & 1) {
        ans += ((w + 1) / 2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,1){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int main(){
	//source
	int N=inputValue();
	int flowers[N];
	inputArray(flowers,N);
	int count_zero=0;
	bool flag=false;
	int count=0;
	rep(i,N){
		if(flowers[i]==0){
		count_zero++;
		}
	}
	while(count_zero!=N){
		count++;
		flag=false;
		rep(i,N){
			if(flowers[i]>0){
				flowers[i]--;
				flag=true;
				if(flowers[i]==0){
					count_zero++;
				}
			}else{
				if(flag){
					break;
				}
			}
		}
	}
	output(count,0);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define inf 1e18;
#define PI acos(-1)
const int M = 1000000007;
const int N=1e5+5;

//#define rohit
#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif
void solve() {
    int x;
    cin >> x;
    for(int i=-120 ; i<=120; i++){
        for(int j=-120; j<=120 ; j++){
            if(pow(i, 5 ) - pow(j, 5) == x) {
                cout << i << " "<< j << endl;
                return;
            }
        }
    }

}
signed main()
{
    FAST;
    //TODO:  check test cases are there or not?
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++)
    {
        solve();
    }
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std; 
const int N=5e5; 
int l,r,u,d,n,m,len,win,bx,by; 
char s[N],p[N]; 
int main(int argc,char *argv[]){
	scanf("%d%d%d%d%d%s%s",&n,&m,&len,&bx,&by,s,p); p[len-1]=0;
	r=m+1,l=0,u=0,d=n+1; 
	for(int i=len-1;i>=0;--i){
		if(p[i]=='L'&&r<=m)++r;if(p[i]=='R'&&l>=1)--l;
		if(p[i]=='U'&&d<=n)++d;if(p[i]=='D'&&u>=1)--u;
	//	printf("%d %d %d %d\n",l,r,u,d); 
		if(s[i]=='R'&&r>1)--r;if(s[i]=='L'&&l<m)++l;
		if(s[i]=='D'&&d>1)--d;if(s[i]=='U'&&u<n)++u;
		win|=l==m||r==1||u==n||d==1;
	//	printf("%d %d %d %d\n",l,r,u,d); 
	}
	win|=by<=l||by>=r||bx<=u||bx>=d;
	printf("%s",win?"NO":"YES"); 
	return 0; 
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,c=0,mx=0;
    string s;
    cin>>s;
    for(i=0;i<3;i++)
    {
        if(s[i]=='R')
            c++;
        else
        {
            mx=max(c,mx);
            c=0;
        }
    }
    cout<<max(mx,c)<<endl;
}


Measured memory_bytes: 3572
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
L =LI()
cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if L[i] != L[j] and L[j] != L[k] and L[i] != L[k] and abs(L[j] - L[k]) < L[i] < L[j] + L[k]:
                cnt += 1
print(cnt)

Measured memory_bytes: 75892
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
L = []
for i in range(N):
    A,B = I()
    L.append([B,A])
L.sort()
cnt = 0
for i in range(N):
    cnt += L[i][1]
    if cnt > L[i][0]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 105640
#include<iostream>
using namespace std;
int main()
{
 int flag = 0;
char s[5];
  cin>>s;
  for(int i =0; i<4; i++)
  {
    if(s[i]==s[i+1])
    {
flag = 1;
    }
  }
  if(flag  == 1)
  {
cout<<"Bad";
  }
  else
  {
cout<<"Good";
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool k(string S,int l,int r){
    for(int i=0;i<=(r-l)/2;i++){
        if(S[l+i]!=S[r-i])return false;
    }
    return true;
}
int main(){
    string s;
    cin>>s;
    int n=s.size();
    if(k(s,0,n-1) && k(s,0,(n-3)/2) && k(s,(n+1)/2,n-1))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h,w,a,b;
    scanf("%d%d%d%d",&h,&w,&a,&b);
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            printf("%d",(i >= b)^(j < a));
        }
        printf("\n");
    }
}


Measured memory_bytes: 1280
#include <cstdio>

using namespace std;

int mod=1e9+7;

int v[100010],vaz[100010],fact[100010];

int rid_put(int a,int b)
{
    int sol=1;
    for(int i=1;i<=b;i<<=1)
    {
        if(b&i) sol=(1LL*sol*a)%mod;
        a=(1LL*a*a)%mod;
    }
    return sol;
}

int comb(int n,int k)
{
    if(n<k) return 0;
    return (1LL*fact[n]*rid_put((1LL*fact[n-k]*fact[k])%mod,mod-2))%mod;
}

int main()
{
    int n,c;
    scanf("%d",&n);
    for(int i=1;i<=n+1;i++)
    {
        scanf("%d",&v[i]);
        if(vaz[v[i]]==1) c=v[i];
        vaz[v[i]]=1;
    }
    fact[0]=1;
    for(int i=1;i<=n+1;i++)
        fact[i]=(1LL*fact[i-1]*i)%mod;
    int a=-1;
    for(int i=1;i<=n+1;i++)
        if(v[i]==c && a==-1) a=i-1;
        else if(v[i]==c) a+=n+1-i;
    for(int i=1;i<=n+1;i++)
    {
        int c=comb(n+1,i);
        int sol=(comb(n+1,i)-comb(a,i-1)+mod)%mod;
        printf("%d\n",sol);
    }
    return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
const int N=2e8+5;
char s[N],t[N];
int n,m,xx,yy,nex[N];
void kmp_init()
{
    int i=1,k=0;
    while(i<=xx*m)
        if(k==0||t[i]==t[k]) nex[++i]=++k;
    else k=nex[k];
}
int main()
{
    scanf("%s%s",s+1,t+1);
    n=strlen(s+1);m=strlen(t+1);
    xx=2200000/m;
    for(int j=1;j<xx;j++)
    for(int i=1;i<=m;i++)
        t[i+m*j]=t[i];
    kmp_init();
    int ans=0,p=m*xx/n;
    int now=0,pos=0;
    m*=xx;
    for(int l=1;l<=p;l++)
    {
        for(int i=1;i<=n;i++)
        {
            pos++;
            while(pos&&t[pos]!=s[i])
                pos=nex[pos];
            ans=max(ans,pos);
        }
    }
    m/=xx;
    if(ans>=n*(p-1)) printf("-1\n");
    else printf("%d\n",ans/m);
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
    string s;
    cin>>s;
    string ans="No";
    ll n=s.size();
    if(n%2==1){
        cout<<ans<<endl;
        return 0;
    }
    for(ll i=1;i<=n;++i){
        if(i%2==1){
            if(s[i-1]=='h' and s[i]=='i'){
                ans="Yes";
                continue;
            }
            ans="No";
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
from collections import deque


def main():
    N, M, *AB = map(int, sys.stdin.buffer.read().split())
    
    g = [[] for _ in range(N + 1)]

    for A, B in zip(*[iter(AB)] * 2):
        g[A].append(B)
        g[B].append(A)

        #print("->", g)

    queue = deque([1])
    d = [0] * (N + 1)
    d[0] = 1
    d[1] = 1

    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] == 0:
                #d[i] = d[v] + 1
                d[i] = v
                queue.append(i)

    if all(d):
        print("Yes")
        print("\n".join(map(str, d[2:])))
    else:
        print("No")


if __name__ == '__main__':
	main()

exit()


Measured memory_bytes: 46152
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

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

long N, M;

int main() {
  cin >> N >> M;
  long ans = min(N, M/2);
  N -= ans;
  M -= 2*ans;
  if (M>=4) {
    ans += M/4;
  }
  cout << ans << endl;
}


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

int main(){
    int A, B;
    std::cin >> A >> B;
    
    std::cout << 100 << " " << 100 << std::endl;
    
    std::vector< std::string > out(100);
    for(int i=0; i<50; i++){
        std::string out_1line(100, '.');
        if(i % 2 == 0){
            int index = 0;
            while(B != 1 && index != 100){
                out_1line[index] = '#';
                index += 2;
                B--;
            }
        }
        out[i] = out_1line;
    }
    
    for(int i=0; i<50; i++){
        std::string out_1line(100, '#');
        if(i % 2 == 0){
            int index = 0;
            while(A != 1 && index != 100){
                out_1line[index] = '.';
                index += 2;
                A--;
            }
        }
        out[99 - i] = out_1line;
    }
    
    for(int i=0; i<100; i++){
        std::cout << out[i] << std::endl;
    }
    
    
    return 0;
    
}


Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#define MAXN 1000000
#define ll long long
using namespace std;
ll min(ll &x, ll &y) {
    if(x < y)   return x;
    else return y;
}
int a[MAXN];
int main() {
    ll A, B, n, tot = 0;
    scanf("%lld%lld%lld", &n, &A, &B);
    scanf("%d", &a[1]);
    for(int i = 2; i <= n; i++)
        scanf("%d", &a[i]);

    for(int i = 2; i <= n; i++) {
        ll   t1 = A * (a[i] - a[i-1]);
        tot += min(t1, B);
    }
    printf("%lld\n", tot);
    return 0;
}


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

int main(void){
     int n, k;
     int calc1 = 1;
     scanf("%d %d", &n, &k);

     int menor = 0;
     for (int i = 0; i < n; i++) {
          if ((calc1+k) < (calc1*2)) {
               calc1 += k;
          } else {
               calc1 *= 2;
          }
     }

     printf("%d\n", calc1);

     return 0;
}


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

int main(){
    int a, b, t;
    cin >> a >> b >> t;
    cout << t/a*b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;

//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    
    int x1,x2,x3,x4,x5;
    cin >> x1 >> x2 >> x3 >> x4;
    int ans;
    if(x1==0){
        ans = 1;   
    }else if(x2==0){
        ans = 2;
    }else if(x3==0){
        ans = 3;
    }else if(x4==0){
        ans = 4;
    }else if(x5==0){
        ans = 5;
    }

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

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

int main(){
    int A,B,C,X,Y; cin >> A >> B >> C >> X >> Y;
    int ans=1e9;
    for (int i=0; i<=1e5; i++){
        ans=min(ans,C*i*2+A*max(X-i,0)+B*max(Y-i,0));
        if(X-i==0 && Y-i==0) break;
    }
    cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   int[] i1 = new int[3];
   for(int n=0;n<3;n++){
     i1[n] = kbd.nextInt();
   }
   int[] i2 = new int[3];
   for(int n=0;n<3;n++){
     i2[n] = kbd.nextInt();
   }
   int[] i3 = new int[3];
   for(int n=0;n<3;n++){
     i3[n] = kbd.nextInt();
   }
   int n=kbd.nextInt();

   int[] deta = new int[n];
   for(int k=0;k<n;k++){
     deta[k] = kbd.nextInt();
   }

  for(int k=0;k<n;k++){
   for(int l=0;l<3;l++){
     if(deta[k]==i1[l]){
      i1[l]=0;
  }
 }
}
for(int k=0;k<n;k++){
 for(int l=0;l<3;l++){
   if(deta[k]==i2[l]){
    i2[l]=0;
}
}
}
for(int k=0;k<n;k++){
 for(int l=0;l<3;l++){
   if(deta[k]==i3[l]){
    i3[l]=0;
}
}
}

if(i1[0]+i1[1]+i1[2]==0||i2[0]+i2[1]+i2[2]==0||i3[0]+i3[1]+i3[2]==0
||i1[0]+i2[1]+i3[2]==0||i1[2]+i2[1]+i3[0]==0
||i1[0]+i2[0]+i3[0]==0||i1[1]+i2[1]+i3[1]==0||i1[2]+i2[2]+i3[2]==0){
  System.out.println("Yes");
}else{
  System.out.println("No");
}


 }
}

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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int l = 0;
    ll ans = 0;
    int sum = 0;
    for(int r = 0; r < N-1; r++){
        //printf("%d %d %d\n",l, r, sum);
        //cout << l << " " << r << "  " << sum <<  endl;
        sum += A[r];
        //cout << ans << endl;
        while((sum & A[r+1]) != 0){
            sum -= A[l];
            l++;
        }
        ans += r - l + 1;
    }
    cout << ans + N << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int a,b;
  cin>>a>>b;
  if(b%a==0) cout<<a+b<<endl;
  else cout<<b-a<<endl;


}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = [int(Ai) for Ai in input().split()]
c = Counter(A).most_common()
c.sort(key=lambda x: x[0], reverse=True)
e1 = None
result = None
for k, v in c:
    if e1 is None and v >= 4:
        result = k**2
        break
    elif v >= 2:
        if e1 is None:
            e1 = k
        else:
            result = e1 * k
            break
if result is not None:
    print(result)
else:
    print(0)

Measured memory_bytes: 21540
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int w, n, a, b, tmp;
	int[] lots;
	String[] input;
	w = Integer.parseInt(scan.nextLine());
	n = Integer.parseInt(scan.nextLine());
	lots = new int[w + 1];
	for (int i = 1; i <= w; i++) {
	    lots[i] = i;
	}
	for (int i = 0; i < n; i++) {
	    input = scan.nextLine().split(",");
	    a = Integer.parseInt(input[0]);
	    b = Integer.parseInt(input[1]);
	    tmp = lots[a];
	    lots[a] = lots[b];
	    lots[b] = tmp;
	}
	for (int i = 1; i <= w; i++) {
	    System.out.println(lots[i]);
	}
    }
}

Measured memory_bytes: 25656
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back 
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mod2 998244353
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 1000000000000

// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int n,m,t,i,l,k,r,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U;
    // int x,y,a,b,c;
    cin>>n;
    map<string,int> cnt;
    int mx=0;
    while(n--)
    {
        cin>>S;
        cnt[S]++;
        mx=max(mx,cnt[S]);
    }
    vector<string> ans;
    for(auto x:cnt)
    {
        if(x.S==mx) ans.pb(x.F);
    }
    sortA(ans);
    for(auto x:ans) cout<<x<<"\n";
}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    int T=0;
    while(t--)
    {
        T++;
        // if(T>1) cout<<"\n";
        // cout<<"Case #"<<T<<": ";
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 27252
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, const T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int W, H, N; cin >> W >> H >> N;
	V ws(N), hs(N);
	vector<P> v(N);
	rep(i, N) {
		int x, y; cin >> x >> y;
		ws[i] = x; hs[i] = y;
		v[i] = P(x, y);
	}
	sort(all(ws));
	sort(all(hs));

	int xi = N / 2;
	int yi = N / 2;

	VV dists(9, V(N));
	rep(i, N) rep(j, 3) rep(k, 3) {
		dists[j * 3 + k][i] = abs(v[i].first - ws[xi + j - 1]) + abs(v[i].second - hs[yi + k - 1]);
	}
	rep(i, 9) sort(all(dists[i]));

	int ans = 1ll << 62;
	int xpos = 0, ypos = 0;
	for (int i = 0; i < 9; i++) {
		int sum = accumulate(all(dists[i]), 0ll) * 2 - dists[i].back();
		if (sum < ans) {
			xpos = ws[xi + i / 3 - 1];
			ypos = hs[yi + i % 3 - 1];
			ans = sum;
		}
	}
	cout << ans << endl;
	cout << xpos << " " << ypos << endl;

	//system("pause");
}

Measured memory_bytes: 13948
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		long[]A = new long[N];
		string[] str2 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str2[i]);
		}
		var list = new HashSet<long>();
		for(var i=0;i<N;i++){
			long sum = 0;
			for(var j=i;j<N;j++){
				sum += A[j];
				list.Add(sum);
			}
		}
		long ans = 0;
		long at = (long)Math.Pow(2,40);
		for(var i=40;i>=0;i--){
			int ct = 0;
			int ctn = 0;
			foreach(long j in list){
				long aat = j&(at+ans);
				if(aat == at+ans){
					ct += 1;
					if(ct>=K){
						ans += at;
						break;
					}
				} else {
					ctn += 1;
					if(ctn > N*(N+1)/2-K){
						break;
					}
				}
			}
			at /= 2;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 38936
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 100000000

using namespace std;

int main()
{
    long long l_1 = 0, l_2 = 2, l_3 = 1;
    int n;
    cin >> n;

    for (int i = 1; i < n; i++)
    {
        l_1 = l_2;
        l_2 = l_3;
        l_3 = l_1 + l_2;
    }
    cout << l_3 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
ll modpow(ll a, ll n, ll mod = MOD) {
    ll res = 1;
    while(n > 0) {
        if(n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    int n;
    cin >> n;
    vector<int> a(n, 0);
    for(int i = 0; i < n; i++) {
        int b;
        cin >> b;
        a[b]++;
    }
    if(n % 2 == 0) {
        for(int i = 0; i < n; i++) {
            if(i % 2 == 0 && a[i] != 0) {
                cout << 0 << endl;
                return 0;
            }
            if(i % 2 == 1) {
                if(a[i] != 2) {
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
        cout << modpow(2, n / 2) << endl;

    } else {
        if(a[0] != 1) {
            cout << 0 << endl;
            return 0;
        }
        for(int i = 1; i < n; i++) {
            if(i % 2 == 1 && a[i] != 0) {
                cout << 0 << endl;
                return 0;
            }
            if(i % 2 == 0) {
                if(a[i] != 2) {
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
        cout << modpow(2, n / 2) << endl;
    }
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String[] s = in.nextLine().split("");

        for( int i = 0 ; i < s.length ; i++ ){
            if( i % 2 == 0 ){
                if( "R".equals(s[i]) || "U".equals(s[i]) || "D".equals(s[i]) ){

                }
                else {
                    System.out.println("No");
                    return;
                }
            }
            else {
                if( "L".equals(s[i]) || "U".equals(s[i]) || "D".equals(s[i]) ){

                }
                else {
                    System.out.println("No");
                    return;
                }
            }
        }

        System.out.println( "Yes" );

    }

}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int dp[3005][3005];
int main()
{
  string s,t;
  int n,m;
  stack<char> str;

  cin>>s>>t;
  n=s.size();
  m=t.size();

  dp[0][0]=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      if(s[i-1]==t[j-1]){
	dp[i][j]=dp[i-1][j-1]+1;
      }else{
	dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
    }
  }

  int i=n,j=m;
  while(i!=0 && j!=0){
    if(s[i-1]==t[j-1]){
      str.push(s[i-1]);
      i--;
      j--;
    }else{
      if(dp[i-1][j]>=dp[i][j-1]){
	i--;
      }else{
	j--;
      }
    }
  }

  int r=str.size();
  for(int i=0;i<r;i++){
    cout<<str.top();
    str.pop();
  }
  cout<<endl;
  return 0;
}


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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a[] = new int[N];
    for(int i=0;i<N;i++){
      a[i] = sc.nextInt();
    }
    int cnt2 = 0; /*2の倍数の数*/
    int cnt4 = 0; /*4の倍数の数*/
    for(int i=0;i<N;i++){
      if(a[i]%2==0){
        a[i] = a[i]/2;
        if(a[i]%2==0){
          cnt4++;
        }else{
          cnt2++;
        }
      }
    }
    if(cnt2==0){
      cnt2++;
    }
    if((N-1)<=(cnt4*2+cnt2-1)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 51232
n,k = map(int,input().split())
def cmb(n, r, mod):
  if ( r<0 or r>n ):
    return 0
  r = min(r, n-r)
  return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
  g1.append( ( g1[-1] * i ) % mod )
  inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
  g2.append( (g2[-1] * inverse[-1]) % mod )

ans = [0]*k
for i in range(k):
  if n-k+1 < i+1:
    print(0)
    continue
  print((cmb(n-k+1,i+1,mod)*cmb(k-1,i,mod))%mod)

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

int main() {
  string s;
  int q, rev = 0;
  deque<char> dq;
  cin >> s >> q;
  for (char x : s) {
    dq.push_back(x);
  }
  for (int i = 0; i < q; i++) {
    int temp, a;
    string b;
    cin >> temp;
    if (temp == 1) rev = !rev;
    else {
      cin >> a >> b;
      if (rev xor (a-1)) dq.push_back(b[0]);
      else dq.push_front(b[0]);
    }
  }
  while (!dq.empty()) {
    auto t = rev ? dq.back() : dq.front();
    cout << t;
    if (rev) dq.erase(dq.end()-1, dq.end());
    else dq.erase(dq.begin(), dq.begin()+1);
  }
  cout << endl;
}


Measured memory_bytes: 896
i = list(map(int, input().split()))

if i[0]<i[2]:
  
  i[1]=i[1]-(i[2]-i[0])
  i[0]=0
  if i[1]<0:
    i[1]=0
else:
  i[0]-=i[2]

print(i[0],i[1])

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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

const ll MOD = 1000000007;
const int INF = 1<<29;
//const ll INF = (ll)1e18 + 1;
using edge = pair<int, int>;
using Graph = vector<vector<edge>>;

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

  Graph G(N);
  for(int i = 0; i < N - 1; ++i){
    int u, v, w; cin >> u >> v >> w;
    u--, v--;
    G[u].push_back(P(v, w));
    G[v].push_back(P(u, w));
  }

  vector<int> dist(N, -1); //-1が未探索
  queue<int> que;
  que.push(0);
  dist[0] = 0;
  while(!que.empty()){
    int v = que.front(); que.pop();
    for (auto nv: G[v]){
      if (dist[nv.first] == -1){
        if (nv.second % 2 == 0){
          if (dist[v] == 0) dist[nv.first] = 0;
          else dist[nv.first] = 1;
        }
        else{
          if (dist[v] == 0) dist[nv.first] = 1;
          else dist[nv.first] = 0;
        }
        que.push(nv.first);
      }
    }
  }
  for (auto dis: dist){
    cout << dis << endl;
  }
}


Measured memory_bytes: 6784