akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
struct Card {
	char suit, value;
};

void BubbleSort(struct  Card A[],int N) {
	for (int i = 0;i < N;i++) {
		for (int j = N - 1;j > i;j--) {
			if (A[j].value < A[j - 1].value) {
				struct Card dumy = A[j];
				A[j] = A[j-1];
				A[j-1] = dumy;
			}
		}
	}
}

void SelectionSort(struct Card D[], int N) {
	for (int i = 0;i < N; i++) {
		int minj = i;
		for (int j = i;j < N;j++) {
			if (D[j].value < D[minj].value)
				minj = j;
		}
		struct Card dumy = D[i];
		D[i] = D[minj];
		D[minj] = dumy;
	}
}
void print(struct Card A[],int N) {
	for (int i = 0;i < N;i++) {
		if (i > 0) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}
bool isStable(struct Card C[],struct Card D[],int N) {
	for (int i = 0;i < N;i++) {
		if (C[i].suit != D[i].suit)
			return false;
	}
	return true;
}
int main() {
	struct Card C[100], D[100];
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> C[i].suit >> C[i].value;
	}

	for (int i = 0;i < N;i++)
		D[i] = C[i];
	
	BubbleSort(C, N);
	SelectionSort(D, N);

	print(C, N);
	cout << "Stable" << endl;
	print(D, N);
	if (isStable(C, D, N)) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}
	return 0;
}


Measured memory_bytes: 3100
// AOJ Volume 0 Problem 0049

#include <stdio.h>


int main(void)
{
    char blood[3];
    int no;
    int no_a, no_b, no_o, no_ab;

    no_a = no_b = no_o = no_ab = 0;
	
    while (scanf("%d,%s", &no, blood) != EOF){
        if (blood[0] == 'B'){
            no_b++;
        }
        else if (blood[0] == 'O'){
            no_o++;
        }
        else if (blood[1] == 'B'){
            no_ab++;
        }
        else {
            no_a++;
        }
    }
    printf("%d\n%d\n%d\n%d\n", no_a, no_b, no_ab, no_o);
    
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll a; cin >> a;
  ll ans = a + a*a + a*a*a;
  cout << ans << endl;
}


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

using namespace std;

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

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

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

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main(int argc, char const* argv[])
{
	LL n,m;
	cin >> n >> m;
	LL ans = 0;
	
	array<LL,1000> x,y,z;
	array<LL,1000> a,b,c;
	for (LL i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> z[i];
	}
	for (LL i = 0; i < (1<<3); i++) {
		LL tans = 0;
		for (LL j = 0; j < n; j++) {
			a[j] = x[j];
			b[j] = y[j];
			c[j] = z[j];
		}
		array<array<LL,1000>,3> s{a,b,c};
		for (LL j = 0; j < 3; j++) {
			if (i & (1<<j)) {
				for (LL k = 0; k < n; k++) {
					s[j][k] = -s[j][k];
				}
			}
		}
		array<LL,1000> sum;
		for (LL j = 0; j < n; j++) {
			sum[j] = s[0][j] + s[1][j] + s[2][j];
		}
		sort(sum.begin(),sum.begin() + n,greater<LL>());
		for (LL j = 0; j < m; j++) {
			tans += sum[j];
		}
		//dump(tans);
		ans = max(ans,tans);

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

}


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

using namespace std;

int main(void){
    int n, m;
    cin >> n >> m;
    int left = -1, right = n+1;
    for(int i = 0; i < m; i++){
        int l, r;
        cin >> l >> r;
        left = max(left,l);
        right = min(right, r);
    }
    int ans = (right - left) < 0 ? 0 : right - left + 1; 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string w;
	string t;
	cin >> w;
	int i;
	for (i = 0; i < w.size(); i++)
	{
		if ('A' <= w[i] && w[i] <= 'Z')
		{
			w[i] += 'a' - 'A';
		}
	}
	int o = 0;
	cin >> t;
	while (t != "END_OF_TEXT")
	{
		for (i = 0; i < t.size(); i++)
		{
			if ('A' <= t[i] && t[i] <= 'Z')
			{
				t[i] += 'a' - 'A';
			}
		}
		if (w == t)
		{
			o++;
			//cin >> t;
		}
		cin >> t;
	}
	cout << o << endl;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int m[10];
    for (int i = 0; i < 10; i++) cin >> m[i];
    sort(m, m+10, greater<int>());
    printf("%d\n%d\n%d\n", m[0], m[1], m[2]);
}


Measured memory_bytes: 3168
N, M, X=map(int,input().split())
query=[[] for _ in range(N)]
for i in range(N):
  query[i]=input().split()

answer=0
answerlist=[]
for i in range(2**N):
  brain=[0]*M
  answer=0
  for j in range(N):
    if ((i>>j)&1):
      answer+=int(query[j][0])
      for l in range(M):
        brain[l]+=int(query[j][l+1])
  if (all([i>=X for i in brain])):
      answerlist.append(answer)
if answerlist==[]:
  print(-1)
else:
  print(min(answerlist))
      

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define maxN 2005
#define mod 1000000007
using namespace std;

int n, k, a[maxN];
int sum[maxN];

int main()
{
    scanf("%d%d", &n, &k);
    int ans = 0;
    for (int i = 0; i < n; ++ i)
    {
        scanf("%d", &a[i]); ++ sum[a[i]];
        for (int j = 0; j < i; ++ j)
            if (a[j] > a[i])
            ans ++;
    }
    ans = (1LL * ans * k) % mod;
    if (k > 1)
    {
        for (int i = 1; i < maxN; ++ i)
            sum[i] = (sum[i] + sum[i - 1]) % mod;
        for (int i = 0; i < n; ++ i) if (a[i])
        {
            int cnt = ((1LL * k * (k - 1)) / 2) % mod;
            ans = (1LL * cnt * sum[a[i] - 1] + ans) % mod;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
import sys
def main():
    input = sys.stdin.readline
    NK = list(map(int, input().split()))
    N = NK[0]
    K = NK[1]
    S = input()
    firsth = 0
    for i in range(N):
      if i != N - 1:
        if S[i] == S[i+1]:
          firsth += 1
    ans = min([firsth + 2 * K, N - 1])
    print(ans)
if __name__ == '__main__':
    main()

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

int main (){
  int n;
  cin >> n;
  vector<int>vec(n);
  for(int i=0;i<n;i++){
    cin >> vec[i];
  }
  
  sort(vec.begin(),vec.end());
  
  int a;
  for(int i=0;i<vec.size();i++){
    a+=vec[i];
  }
  if(a-vec[n-1]>vec[n-1]){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

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

int main()
{
	ll n;cin>>n;string s;cin>>s;
	ll i=0;ll j=s.size()/2;ll flag=0;
	if(s.size()%2!=0)
	cout<<"No"<<"\n";
	else
	{
		while(i<s.size()/2 && j<s.size())
		{
			if(s[i]!=s[j])
			{
				flag=1;
			}
			i++;j++;
		}
		if(flag==1)
		cout<<"No"<<"\n";
		else
		cout<<"Yes"<<"\n";
	}
	
}

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

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

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    A = readInts()
    cnt = 0
    i = 0
    while i<n:
        while i+1 < n:
            if A[i] == A[i+1]:
                i += 1
            else:
                break
        if i+1 < n:
            if A[i] > A[i+1]:
                while i+1 < n:
                    if A[i] >= A[i+1]:
                        i += 1
                    else:
                        break
            elif A[i] < A[i+1]:
                while i+1 < n:
                    if A[i] <= A[i+1]:
                        i += 1
                    else:break
        cnt += 1
        i += 1
    print(cnt)
if __name__ == '__main__':
  main()


Measured memory_bytes: 16340
#include<stdio.h>


int main(){
    int H, W;
    while(1){
        scanf("%d %d", &H, &W);
        if((H && W) == 0){
            break;
        }for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2624
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn merge(a: &mut Vec<u64>, left: usize, mid: usize, right: usize) -> usize {
    let n1: usize = mid - left;
    let n2: usize = right - mid;
    let mut count: usize = 0;
    let mut l: Vec<u64> = (0..n1)
        .map(|i| {
            let number: u64 = a[left + i];
            number
        })
        .collect();
    let mut r: Vec<u64> = (0..n2)
        .map(|i| {
            let number: u64 = a[mid + i];
            number
        })
        .collect();
    l.push(u64::max_value());
    r.push(u64::max_value());
    let mut i: usize = 0;
    let mut j: usize = 0;
    for k in left..right {
        if l[i] <= r[j] {
            a[k] = l[i];
            i += 1;
        } else {
            a[k] = r[j];
            j += 1;
            count += n1 - i;
        }
    }
    return count;
}

fn merge_sort(a: &mut Vec<u64>, left: usize, right: usize) -> usize {
    let mut count: usize = 0;

    if left + 1 < right {
        let mid: usize = (left + right) / 2;
        count += merge_sort(a, left, mid);
        count += merge_sort(a, mid, right);
        count += merge(a, left, mid, right);
    }
    return count;
}

fn main() {
    let n: usize = read();
    let mut a: Vec<u64> = (0..n)
        .map(|_| {
            let number: u64 = read();
            number
        })
        .collect();
    let count_number = merge_sort(&mut a, 0, n);
    println!("{}", count_number);
}



Measured memory_bytes: 10084
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int  t,nr,ng,nb;
ll ans;
ll sq(int x){return 1ll*x*x;}
#define mod 1000000007
void solve(vector<int>a,vector<int>b,vector<int>c)
{
  for(auto x:a)
  {
   auto y=lower_bound(b.begin(),b.end(),x);
   auto z=upper_bound(c.begin(),c.end(),x);
   if(y==b.end()||z==c.begin())
        continue;
   z--;
   ans=min(ans,sq(x-*y)+sq(*y-*z)+sq(x-*z));
  }

}
int main()
{ios_base::sync_with_stdio(false);
ll n,k;
cin>>n>>k;
ll ans=0;
ll x,y;
for(ll i=k;i<=n+1;i++)
{
    x=i*(i-1);x/=2;
    y=n*i;y-=x;
    ans+=(y-x+1);
    ans%=mod;
}cout<<ans<<endl;

}


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

int main() {
  long long N,M,x,y,z;
  cin >>N;
  vector<long long>a(N),b(N),c(M),d(M),e(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  x=0;
  y=0;
  z=100000000000;
    for(int i=-100;i<101;i++){
        for(int j=0;j<N;j++){
   x+=(i-a[j])*(i-a[j]);
        }
      z=min(z,x);
      x=0;
    }
  cout<<z<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    //int n,x,t;cin>>n>>x>>t;
    // int a,b,c;cin>>a>>b>>c;
    // string str;cin>>str;
    //vector<int> l(n);
    // vector<string> s(n);
    Int n;cin>>n;
    Int ans=n*(n-1)/2;

    cout<<ans;


    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] T = new long[n];
        Arrays.setAll(T, i -> Long.parseLong(sc.next()));
        Arrays.sort(T);
        long res = 1;
        for(long t : T) res = lcm(Math.max(res, t), Math.min(res, t));
        System.out.println(res);
    }
    static long gcd(long x, long y) {
        long m;
        while((m = x % y) != 0) {
            x = y;
            y = m;
        }
        return y;
    }
    static long lcm(long x, long y) {
        return x / gcd(x, y) * y;
    }
}


Measured memory_bytes: 26836
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n,m;
    cin >> n >> m;
    vector<ll> x(m);
    for(int i=0;i<m;i++){
        cin >> x[i];
    }
    sort(ALL(x));

    vector<ll> dis(m-1);
    for(int i=0;i<m-1;i++){
        dis[i] = x[i+1] - x[i];
    }
    sort(ALL(dis),greater<>());

    ll ans = 0;
    for(int i=n-1;i<m-1;i++){
        ans += dis[i];
    }

    cout << ans <<endl;

    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{

	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	vector<int> A(n,0);
	vector<int> B(n,0);
	vector<int> C;
	int  a=0;
	for(int i=0; i<n; i++){
		if(s[i]=='o'){
			A[i]++;
			i=i+c;
			a++;
		}
	}

	for(int i=(n-1); i>=0; i--){
		if(s[i]=='o'){
			B[i]++;
			i=i-c;
		}
	}
	
	
	for(int i=0; i<A.size(); i++){
		if(A[i]==B[i] && A[i]>0){
			C.push_back(i+1);
		}
	}
		
	if(a>(c+k)){
		cout<<" ";
	}
	else{
		for(int i=0; i<C.size(); i++){
			cout<<C[i]<<endl;
		}
	}

}


Measured memory_bytes: 4216
#include <stdio.h>
int main(void)
{
    int n, a[51] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                    12, 14, 15, 16, 18, 20, 21, 24, 25, 27,
                    28, 30, 32, 35, 36, 40, 42, 45, 48, 49,
                    54, 56, 63, 64, 72, 81};
    int i;
    scanf("%d", &n);
    for (i = 0; i < 36; i++)
        if (n == a[i])
        {
            printf("Yes\n");
            return 0;
        }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
typedef long long LL;
using namespace std;

const LL mod = 1e9 + 7;
const int MAXN = 1e3 + 10;

int main() {
	LL a, b;
	char ch;
	scanf("%lld %c %lld", &a, &ch, &b); 
	if(ch == '+') printf("%lld\n", a + b);
	else printf("%lld\n", a - b);
	return 0;
}

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

void solve(){
  char c; cin >> c;
  cout << char(c + 1) << endl;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
h,w =map(int,input().split())
s = [input() for i in range(h)]
s_out =[]

for i in range(h):
    s_out.append("")

def mine(a):
    count = 0
    for i in range(len(a)):
        if a[i] == "#":
            count += 1
    return count

if h == 1 and w == 1:
    if s[0][0] == "#":
        print("#")
        
    else:
        print("0")
        

elif h==1:
    for j in range(w):
        if s[0][j] == "#":
            s_out[0] += "#"
        elif j == 0:
            s_out[0] += str(mine(s[0][1]))
        elif j == w-1:
            s_out[0] += str(mine(s[i][j-1]))
        else:
            s_out[0] += str(mine(s[i][j-1])+mine(s[i][j+1]))
    print(s_out[0])
    
    
elif w == 1:
    for i in range(h):
        if s[i][0] == "#":
            s_out[i] += "#"
        elif i == 0:
            s_out[i] += str(mine(s[1][0]))
        elif i == h-1:
            s_out[i] += str(mine(s[i-1][0]))
        else:
            s_out[i] += str(mine(s[i+1][0])+mine(s[i-1][0]))
    for i in s_out:
        print(i)
    
else:
    for i in range(h):
            for j in range(w):
                if s[i][j] == "#":
                    s_out[i] += "#"
                elif i == 0 and j == 0:
                    s_out[i] += str(mine(s[0][1])+mine(s[1][0:2]))
                elif i == 0 and j == w-1:
                    s_out[i] += str(mine(s[i][j-1])+mine(s[i+1][j-1:j+1]))
                elif i == 0:
                    s_out[i] += str(mine(s[i][j-1])+mine(s[i][j+1])+mine(s[i+1][j-1:j+2]))
                elif i == h-1 and j == 0:
                    s_out[i] += str(mine(s[i-1][j:j+2])+mine(s[i][j+1]))
                elif i == h-1 and j == w-1:
                    s_out[i] += str(mine(s[i-1][j-1:j+1])+mine(s[i][j-1]))
                elif i == h-1:
                    s_out[i] += str(mine(s[i-1][j-1:j+2])+mine(s[i][j-1])+mine(s[i][j+1]))
                elif j == 0:
                    s_out[i] += str(mine(s[i-1][j:j+2])+mine(s[i][j+1])+mine(s[i+1][j:j+2]))
                elif j == w-1:
                    s_out[i] += str(mine(s[i-1][j-1:j+1])+mine(s[i][j-1])+mine(s[i+1][j-1:j+1]))
                else:
                    s_out[i] += str(mine(s[i-1][j-1:j+2])+mine(s[i][j-1])+mine(s[i][j+1])+mine(s[i+1][j-1:j+2]))
    for i in s_out:
        print(i)

Measured memory_bytes: 3320
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

void solve(){
	int n;
	cin>>n;
	vector<pair<int,int>>groups;
	if(n%2==0){
		for(int i=0;i<n/2;i++){
			groups.pb({i+1,n-i});
		}
	}
	else{
		for(int i=0;i<n/2;i++){
			groups.pb({i+1,n-i-1});
		}
		groups.pb({n,-1});
	}
	vector<pair<int,int>>ans;
	for(int i=0;i<groups.size();i++){
		for(int j=i+1;j<groups.size();j++){
			ans.pb({groups[i].F,groups[j].F});
			if(groups[j].S!=-1){
				ans.pb({groups[i].F,groups[j].S});
			}
			if(groups[i].S!=-1){
				ans.pb({groups[i].S,groups[j].F});
				if(groups[j].S!=-1){
					ans.pb({groups[i].S,groups[j].S});
				}
			}
		}
	}
	cout<<ans.size()<<"\n";
	for(auto i:ans){
		cout<<i.F<<' '<<i.S<<"\n";
	}
			
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 512
// ABC105B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

int main()
{
	int N;
	cin >> N;
	int a=0;
	for (int i = 0; i <=25; i++)
	{
		for (int j=0; j <=14; j++)
		{
			int total = 4 * i + 7 *j;
			if (total == N)
			{
				a= N;			
			}
		}
	}
	
	if(a==N) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=200005;
int mx,mn,val[N];
vector<ii> v[N];
bool vis[N];
void getlost()
{
  cout<<"No"<<endl;
  exit(0);
}
void dfs(int u)
{
  mx=max(mx,val[u]); mn=min(mn,val[u]);
  vis[u]=true;
  for(ii it:v[u])
    {
      int v1=it.fi;
      if(vis[v1])
	{
	  if(val[v1]!=val[u]+it.se) getlost();
	}
      else
	{
	  val[v1]=val[u]+it.se;
	  dfs(v1);
	}
    }
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,m,x,y,z;
  cin>>n>>m;
  rep(i,1,m+1)
    {
      cin>>x>>y>>z;
      v[x].pb(mp(y,z)); v[y].pb(mp(x,-z));
    }
  rep(i,1,n+1)
    {
      if(vis[i]) continue;
      mx=0,mn=0;
      dfs(i);
      if(mx-mn>1e9) getlost();
    }
  cout<<"Yes"<<endl;
  return 0 ;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
#define ull unsigned long long
#define ld long double
#define uint unsigned int
struct debug {
~debug() {cerr << "\n";}template<class C> debug& operator<<(C c) {cerr << c;return *this;}
};
#define var(x) " [" << #x << ": " << x << "]"

constexpr ll INF=-1e18-5;
ll a, b, c, d, ans=INF;

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

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

    solve();
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main(){
  int N, M; cin >> N >> M;
  vi H(N+1,0); rep2(i,1,N+1) cin >> H[i];
  vvi rt(N+1, vi());
  rep(i,M){
    int a, b; cin >> a >> b;
    rt[a].push_back(b);
    rt[b].push_back(a);
  }
  
  int count = 0;
  rep2(i,1,N+1){
    int maxH = H[i];
    bool highest = true;
    for(int x : rt[i]){
       if(maxH <= H[x]) highest = false;
    }
    if(highest)count++;
  }
  cout << count << endl;  
  return 0;
}

Measured memory_bytes: 8796
#include<bits/stdc++.h>
using namespace std;
int main(){
  double n;cin >> n;
  vector<double> x(n),y(n);
  double t=1;
  vector<int> c(n);
  for(int i=0;i<n;i++){
    cin >> x[i] >> y[i];
    c[i]=i;
  }
  for(double i=2;i<=n;i++){
    t*=i;
  }
  double sum=0;
  
  do{
    for(int i=0;i<n-1;i++){
      sum+=sqrt((x[c[i]]-x[c[i+1]])*(x[c[i]]-x[c[i+1]])+(y[c[i]]-y[c[i+1]])*(y[c[i]]-y[c[i+1]]));
    }
  }while(next_permutation(c.begin(),c.end()));
  cout << fixed << setprecision(15) << sum/t << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,m;
  cin >> n >> m;
  int k[n];
  rep(i,n)k[i]=0;
  rep(i,2*m){
    int o;
    cin >> o;
    o--;
    k[o]++;
  }
  int ans=0;
  rep(i,n)ans+=k[i]%2;
  if(ans==0)cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;
int main(){
	long int n, a[200000], b[200000];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		b[i] = a[i];
	}
	sort(a, a + n);
	for(int i = 0;i < n;i++){
		if(a[n - 1] == b[i]){
			cout << a[n - 2] << endl;
		}else{
			cout << a[n - 1] << endl;
		}
	}
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    vint a(3);
    rep(i, 3) cin >> a[i];
    sort(ALL(a));

    cout << abs(a[0] - a[1]) + abs(a[1] - a[2]) << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

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

    int cnt=0,mans=0,p=0,k=0;
    ll ans=0;
    while(true){
        k=s.find_first_of(t[cnt],p);
        if(k==-1){
            if(p==0){
                ans=-1;
                mans=0;
                break;
            }else{
                ans+=s.size();
                p=0;
                mans=0;
            }
        }else{
            cnt++;
            mans=k+1;
            if(cnt==t.size())break;
            p=k+1;
        }
    }
    cout << ans+mans <<endl;
    return (0);
}

Measured memory_bytes: 640
H,W=map(int,input().split())
a=[]
for i in range(H):
    aa=list(input())
    if "#" in aa:
	    a.append(aa)
#print(a)

l=[]
for j in range(W):
  b = [x[j] for x in a]
  if '#' in b:
    #print(b)
    l.append(b)
    

for k2 in range(len(l[0])):
  for k in range(len(l)):
  	print(l[k][k2],end='')
  print("")

    

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



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


    string s,t;
    cin >> s >> t;

    rep(i,n){
        cout << s[i]<<t[i];
        }
    
    cout << endl;

    return 0;
}


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

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long llint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double pi = 3.14159265358979323846;

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

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

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

  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && a != c) {
    cout << "Yes" << endl;
  } else if (a == c && a != b) {
    cout << "Yes" << endl;
  } else if (b == c && b != a) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

using namespace std;

int main(){
    int N;
    string S;
    cin >> N >> S;
    int K = N/2;
    if(N%2==1 || N==1){
        cout << "No" << endl;
        return 0;
    }
    if(S.substr(0,K) == S.substr(K,N)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
using namespace std;

#define rep(i,n)for(int i=0; i<(int)(n); i++)
#define bitrep(tmp, N)for (int tmp=0; tmp < (1<<N);tmp++)
#define all(v) v.begin(), end.bigin()

vector<char> inputs(4);
int n = 4;
string ans = "";

bool dfs(int i, string imme, int res){
  if (i==n){
    if (res==7){
      ans = imme+"=7";
      return true;  
    }else{
      return false;
    }
    
  }else{
    int input = inputs.at(i)-'0';
    if(dfs(i+1, imme+"+"+inputs.at(i),  res+input)) return true;
    if(dfs(i+1, imme+"-"+inputs.at(i),  res-input)) return true;
  }

  return false;
}

int main(){
  
  rep(i,4) cin >> inputs.at(i);
  int input = inputs.at(0)-'0';
  string imme = "";
  imme =inputs.at(0);
  dfs(1, imme, input);
  cout << ans << endl;
}

Measured memory_bytes: 256
N = input()

if N == 2:
    a,b = map(int,raw_input().split())
    if a != 0:
        print 0
    else:
        print 1
else:
    odd = [0 for i in range(100000)]
    even = [0 for i in range(100000)]
    v = map(int,raw_input().split())

    for i in range(N):
        if i%2 == 0:
            even[v[i]-1] += 1
        else:
            odd[v[i]-1] += 1
    
    if odd.index(max(odd)) != even.index(max(even)):
        print N-max(odd)-max(even)
    else:
        oddnum = max(odd)
        evennum = max(even)
        odd.remove(oddnum)
        even.remove(evennum)
        if max(odd) < max(even):
            print N-oddnum-max(even)
        else:
            print N-max(odd)-evennum

Measured memory_bytes: 13692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	string s, t;
	cin >> s >> t;
	ll ans = 0;
	for (int i = 0; i < sz(s); i++) {
		if (s[i] != t[i])ans++;
	}
	cout << ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 3792
MOD = int(1e9+7)
N = int(input())
A = list(map(int, input().split()))
if N % 2 == 0:
    B = [0] * N
    for i in range(N // 2):
        B[2*i] = 2*i+1
        B[2*i+1] = 2*i+1
    if sorted(A) != B:
        print(0)
    else:
        ans = 1
        for i in range(N // 2):
            ans = ans * 2 % MOD
        print(ans)
else:
    B = [0] * N
    for i in range((N-1) // 2):
        B[2 * i + 1] = 2 * i + 2
        B[2 * i + 2] = 2 * i + 2
    if sorted(A) != B:
        print(0)
    else:
        ans = 1
        for i in range((N-1) // 2):
            ans = ans * 2 % MOD
        print(ans)

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


int main(){
    int n;
    cin >> n;
    vector<int> num(n);
    vector<bool> p(n);
    for(int i = 0; i < n; i++){
        cin >> num.at(i);
        if(num[i] % 2 == 1) p.at(i) = 1;
        else p.at(i) = 0;
    }
    int odd = 0, even = 0;
    for(int i = 0; i < n; i++){
        if(p[i] == 0) even++;
        else odd++;
    }
    string ans;
    if(odd % 2 == 1) ans = "NO";
    else ans = "YES";
    if(even == 0 and odd == 1) ans = "YES";
    cout << ans << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a[200010],vis[200010];
int main()
{
  long long n,k;
  cin>>n>>k;
  for(int i=1;i<=n;i++)
    cin>>a[i];
  int id=1,t=0;
  while(!vis[id]&&t<k)
  {
    vis[id]=t;
    id=a[id];t++;
  }
 if(t<k)
  {
    int r=t-vis[id];
    assert(r>0);
    k=(k-vis[id])%r;
    t=0;
  }
  while(t<k)
  {
    vis[id]=t;
    id=a[id];t++;
  }
  cout<<id;
  
  
  
  
  
 return 0; 
}

Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int a[m],b[m];
  bool route1[n];
  bool route2[n];
  for(int i=0;i<n;i++){
    route1[i]=false;
    route2[i]=false;
  }
  for(int i=0;i<m;i++){
    cin >>a[i] >>b[i];
    if(a[i]==1)route1[b[i]-1]=true;
    if(b[i]==n)route2[a[i]-1]=true;
  }
  bool ok=false;
  for(int i=1;i<n-1;i++){
    if(route1[i]==true && route2[i]==true)ok=true;
  }
  if(ok)cout <<"POSSIBLE" <<endl;
  else cout << "IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 2176
l, r = map(int, input().split())

least = 2*(10**9)+1
for i in range(l, r):
    for j in range(i+1, r+1):
        if (i * j % 2019) == 0:
            print(0)
            exit()
        least = min(least, (i * j % 2019))

print(least)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   ll n,m;
   cin>>n>>m;
   
   ll arr[n];
   rep(n)
        cin>>arr[i];
   ll sum = 0;
   rep(n)
        sum+=arr[i];
   ll cnt = 0;
   rep(n)
        if(arr[i]*m*4>=sum)
            cnt++;
   if(cnt>=m)
        cout<<"Yes";
   else cout<<"No";        
   
   return 0;        
}  
   

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  int s1,s2;
  cin >>s1 >> s2;
  
  if (s1==s2){
  cout << "Draw";
  }else if( (s1>s2 && s2!=1) || s1==1 ){
  cout << "Alice";
  }else{
    cout << "Bob";
  }
    return 0;
}






Measured memory_bytes: 256
N = int(input())
*H, = map(int, input().split())
ans = 0
A = [0]*N
update = 1
h = 0
while update:
    update = 0
    cnt = 0
    for i in range(N):
        if H[i] > h:
            cnt += 1
        else:
            if cnt > 0:
                update = 1
                ans += 1
            cnt = 0
    if cnt > 0:
        update = 1
        ans += 1
    h += 1
print(ans)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long Hs[] = new long[N];
		long min = 999999999;
		for (int i = 0; i < N; i++) {
			Hs[i] = sc.nextInt();
		}
		Arrays.sort(Hs);

		for (int i = 0; i <= N - K; i++) {

			long min_ = (Hs[i + K - 1] - Hs[i]);

			if (min > min_) {
				min = min_;
			}


		}

		System.out.println(min);
	}
}


Measured memory_bytes: 50440
#134
N=int(input())
a=list(map(int,input().split()))
b_l=[1]*N
b_ll=[]
for i in range(N,0,-1):
    b_i=0
    j=i
    while j<=N:
        b_i+=b_l[j-1]
        j+=i     
    if b_i%2 != a[i-1]:
        b_l[i-1]-=1
    else:
        b_ll.append(i)
print(sum(b_l))
print(*b_ll)

Measured memory_bytes: 14008
def f(v, edges, r)
  mins = []
  edges.each{|s, t, w|
    mins[t] = [w, s] if mins[t] == nil || mins[t][0] > w
  }
  mins[r] = [-1, -1]
  group = Array.new(v){0}
  comp = Array.new(v){false}
  cnt = 0

  used = {}

  v.times{|i|
    unless used[i] then
      chain = []
      cur = i
      while used[cur] == nil && cur != -1
        chain << cur
        used[cur] = 1
        cur = mins[cur][1]
      end
      if cur != -1
        cycle = false
        chain.each{|e|
          group[e] = cnt
          if e == cur
            cycle = true
            comp[cnt] = true
          end
          cnt += 1 unless cycle
        }
        cnt += 1 if cycle
      else
        chain.each{|e|
          group[e] = cnt
          cnt += 1
        }
      end
    end
  }

  if cnt == v then
    return mins.map {|w, s| w}.inject(:+) + 1
  end

  res = 0
  v.times{|i|
    next if i == r
    if comp[group[i]]
      res += mins[i][0]
    end
  }
  n_es = []
  ii = 0
  edges.each{|s, t, w|
    gs = group[s]
    gt = group[t]
    next if gs == gt
    if comp[gt]
      n_es[ii] = [gs, gt, w - mins[t][0]]
    else
      n_es[ii] = [gs, gt, w]
    end
    ii += 1
  }
  return res + f(cnt, n_es, group[r])
end

v, e, r = gets.split.map(&:to_i)
edges = []
e.times{|i|
  s, t, w = gets.split.map(&:to_i)
  edges[i] = [s, t, w]
}
puts f(v, edges, r)

Measured memory_bytes: 9332
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
using namespace std;

//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
#define RREP(i, m, n) for(int i=(int)m; i>=(int)n; --i)
#define rrep(i, m) RREP(i, m, 0)

//簡略化
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> P;

//定義
const int INF = 1e9+7;
const ll LINF = 1e18;
const ll MOD = 1e9+7;

void chmin(ll &a, const ll &b) {
  if(a>b) a = b;
}

void chmax(ll &a, const ll &b) {
  if(a<b) a = b;
}

//GCD&LCM
ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

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

//-----------------------

int main() {

  int n, a, b;
  cin >> n >> a >> b;

  cout << min(a*n, b) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
using namespace std;
typedef long long LL;
typedef pair<double,double> P;

vector<P> C1;
vector<P> C2;
struct P3
{
	P3(){}
	P3(double a, double b, double c):
		x(a),
		y(b),
		z(c)
	{

	}
	double x;
	double y;
	double z;
};
P3 operator-(P3 a, P3 b){
	return P3(a.x-b.x,a.y-b.y,a.z-b.z);
}
int sectionAt(double x, vector<P>& C, double v[2]){
	int c=0;
	for(int i=1;i<C.size();i++){
		if(C[i].first==x){
			v[c++]=C[i].second;
		}
		else
		{
			if(C[i-1].first<x&&x<C[i].first||
			   C[i].first<x&&x<C[i-1].first)
			{
				double d=(x-C[i-1].first)/(C[i].first-C[i-1].first);
				v[c++]=d*C[i].second+(1-d)*C[i-1].second;
			}
		}
	}
	if(c==1){
		v[1]=v[0];
	}
	else if (c==2&&v[0]>v[1]){
		swap(v[0],v[1]);
	}
	return c;
}
double volume(P3 a, P3 b, P3 c,P3 d)
{
	a=a-d;
	b=b-d;
	c=c-d;
	double v=a.x*(b.y*c.z-b.z*c.y)
		     +a.y*(b.z*c.x-b.x*c.z)
		   	 +a.z*(b.x*c.y-b.y*c.x);
	//cout << abs(v/6);
	return abs(v/6);
}
double volume(P3 p[2][2][2])
{
	double v=0;
	int a=0,b=0,c=0;
	v+=volume(p[a][b][c],p[a^1][b][c],p[a][b^1][c],p[a][b][c^1]);
	a=0,b=1,c=1;
	v+=volume(p[a][b][c],p[a^1][b][c],p[a][b^1][c],p[a][b][c^1]);
	a=1,b=0,c=1;
	v+=volume(p[a][b][c],p[a^1][b][c],p[a][b^1][c],p[a][b][c^1]);
	a=1,b=1,c=0;
	v+=volume(p[a][b][c],p[a^1][b][c],p[a][b^1][c],p[a][b][c^1]);
	a=0,b=0,c=0;
	v+=volume(p[1][1][1],p[a^1][b][c],p[a][b^1][c],p[a][b][c^1]);
	return v;
}

void debug(P3 p)
{
	cout << p.x << ", " << p.y << ", " << p.z << endl;
}
void debug(P3 p[2][2][2])
{
	cout << "[" << endl;
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<2;k++){
				debug(p[i][j][k]);
			}
		}
	}
	cout << "]" << endl;
}
void exec()
{
	//cout << "#" << endl;
	int m,n;
	cin >> m >> n;
	if(m==0&&n==0){
		exit(0);
	}
	C1.clear();
	C2.clear();
	vector<double> xs;
	for(int i=0;i<m;i++){
		double x,y;
		cin >> x >> y;
		C1.push_back(P(x,y));
		xs.push_back(x);
	}
	C1.push_back(C1[0]);
	for(int i=0;i<n;i++){
		double x,z;
		cin >> x >> z;
		C2.push_back(P(x,z));
		xs.push_back(x);
	}
	C2.push_back(C2[0]);
	sort(xs.begin(),xs.end());
	P3 ps[2][2][2];
	P3 (*cur)[2]=ps[0];
	P3 (*pre)[2]=ps[1];
	bool ok=false;
	double ret=0;
	for(int i=0;i<xs.size();i++){
		double ys[2];
		int c1=sectionAt(xs[i],C1,ys);
		double zs[2];
		int c2=sectionAt(xs[i],C2,zs);
		if(c1&&c2)
		{
			//cout << xs[i] << endl;
			int c=0;
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
					cur[j][k]=P3(xs[i],ys[j],zs[k]);
				}
			}
			if(ok)
			{
				//debug(ps);
				double v=volume(ps);
				//cout << v << endl;
				ret+=v;
			}
			ok=true;
		}
		swap(cur,pre);
	}
	cout << ret << endl;
}
int main() {
	cout.precision(20);
	while(1)
		exec();
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a==b){
    cout << "Draw" << endl;
  }else{
    if(a==1){
      cout << "Alice" << endl;
    }else if(b==1){
      cout << "Bob" << endl;
    }else{
      if(a>b){
        cout << "Alice" << endl;
      }else{
        cout << "Bob" << endl;
      }
    }
  }
}

Measured memory_bytes: 256