akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define dame {cout<< "No" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------



//--MAIN-----------------------------------
void Main() {
    ll H,W; cin>>H>>W;
    map<char,ll> mp;
    rep(i,H*W){
        char c; cin>>c;
        ++mp[c];
    }
    ll ki=0,ni=0;
    for(auto x: mp){
        ll ct=x.second;
        if(ct%2==1) ++ki;
        if(ct%4==2 or ct%4==3) ++ni;
    }
    if(H%2 and W%2){
        if(ki>1) dame;
        if(ni>(H/2)+(W/2)) dame;
    } 
    else if(!(H%2) and W%2){
        if(ki>0) dame;
        if(ni>H/2) dame;
    }
    else if((H%2) and !(W%2)){
        if(ki>0) dame;
        if(ni>W/2) dame;
    }
    else if(!(H%2) and !(W%2)){
        if(ki>0) dame;
        if(ni>0) dame;
    }
    cout<< "Yes"<<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        int[] Pz = new int[1000];
        for (int i = 0; i < N; i++){
            Pz[sc.nextInt()] = 1;
        }
//        Pz.sort();
        int ans = 0;
        for (int i = 0; i < 101; i++){

            if (Pz[X - i] != 1){
                ans = X - i;
                break;
            }
//            if (X + i > 100){
//                continue;
//            }
            if (Pz[X + i] != 1){
                ans = X + i;
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35648
import fractions

def factor(x):
  t = x
  p = [1]
  for i in range(2, -int(-x**0.5//1)+1):
    if x % i == 0:
      p += [i]
      while x % i == 0:
        x /= i
  if x != 1:
    p += [x]
  if len(p) == 1 and t != 1:
    p += [t]
  return p

A, B = list(map(int, input().split()))
d = fractions.gcd(A, B)
p = factor(d)
print(len(p))
#p = factorization(d)
#print(p)
#print(len(p) + (0 if p[0][0] == 1 else 1))


Measured memory_bytes: 5048
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
using namespace std;

int key=0;

int binarySearch(int A[],int n){
  int left=0;
  int right=n;
  int mid=0;
  
  while(left<right){
    mid=(left+right)/2;
    if(A[mid]==key)return 1;
    else if(key<A[mid])right=mid;
    else left=mid+1;
  }
  return 0;
}

int main(){
  int n=0,q=0;
  int S[100000];
  int T[100000];
  int count=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>S[i];
  cin>>q;
  for(int i=0;i<q;i++)cin>>T[i];
  for(int i=0;i<q;i++){
    key=T[i];
    //cin>>key;
    if(binarySearch(S,n)==1)count++;
  }
  cout<<count<<endl;
  return 0;
}



Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
int n;
ll a[N];
unordered_map<ll,int>vis;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=vis[i-a[i]];
        vis[i+a[i]]++;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 20096
//Square Route
#include <bits/stdc++.h>
using namespace std;
int n,m,a[1505],b[1505];
int main(){
    while(1){
        scanf("%d%d",&n,&m);
        if(n+m==0) return 0;
        for(int i=1;i<=n;i++) scanf("%d",&a[i]);
        for(int i=1;i<=m;i++) scanf("%d",&b[i]);
        map<int,int>M;
        for(int i=1;i<=n;i++){
            int S = 0;
            for(int j=i;j<=n;j++){
                S += a[j];
                M[S]++;
            }
        }
        long long ans = 0;
        for(int i=1;i<=m;i++){
            int S = 0;
            for(int j=i;j<=m;j++){
                S += b[j];
                ans += M[S];
            }
        }
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 21036
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

int main(void){
    int A,B,K;
    cin>>A>>B>>K;
    int num=0;
    int m = min(A,B);
    vector<int> dd;
    for (int i=1;i<=m;i++){
        if (A%i==0&&B%i==0) {
            dd.push_back(i);
        }
    }
    sort(dd.begin(),dd.end(),greater<int>());
    cout<<dd[K-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
int minCost(int *arr,int n,int *dp,int k){
    for(int i=2;i<n;++i){
        int ans=INT_MAX;
        for(int j=1;j<k+1;++j){
            if(i<j) break;
            int first=dp[i-j]+fabs(arr[i]-arr[i-j]);
            ans=min(ans,first);
        }
    dp[i]=ans;
     }
    return dp[n-1];
}
int main() {
    int n,k;
    cin>>n;
    cin>>k;
    int *arr=new int[n];
    int *dp=new int[n];
    
    for(int i=0;i<n;++i){
        cin>>arr[i];
    }
    dp[0]=0;
    dp[1]=fabs(arr[0]-arr[1]);
    
    cout<<minCost(arr,n,dp,k);
}


Measured memory_bytes: 4400
#include <stdio.h>
int main(void)
{
     int x, i=1;
     scanf("%d",&x);
     
     while(1){
          if(x==0)
             break;
          printf("Case %d: %d\n",i,x);
          scanf("%d",&x);
          i++;
          
       }
      return 0;
}


Measured memory_bytes: 2108
using System;
using System.Collections;

public class p0001{
	p0001(){
		string[] str = new string[10];
		
		while((str[0] = Console.ReadLine()) != null){
			for(int i = 1; i < 10; ++i)
				str[i] = Console.ReadLine();
			
			Array.Sort(str, comp);
			
			for(int i = 0; i < 3; ++i)
				Console.WriteLine("{0}", str[i]);
		}
	}
	
	public static int Main(string[] args){
		new p0001();
		return 0;
	}
	
	public int comp(string s1, string s2){
		if(s1 == s2) return 0;
		if(int.Parse(s1) < int.Parse(s2)) return 1;
		return -1;
	}
}

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

using ll = long long;
using pii = pair<int, int>;

int main(int argc, char **argv) {
#ifdef LOCAL
  freopen("in.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  ll n, k; cin >> n >> k;
  vector<int> a(n);
  vector<int> f(n);
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n; i++) cin >> f[i];

  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());

  auto possible = [&](ll m) {
    ll t = 0;
    for(int i=0; i<n; i++) {
      t += max(a[i] - m/f[i], 0LL);
    }
    return t <= k;
  };

  ll l = 0;
  ll r = 2e18;
  ll res = r+1;
  while(l<=r) {
    ll m = (l+r)/2;
    if(possible(m)) {
      r = m - 1;
      res = min(res, m);
    } else l = m + 1;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1792
N=int(input())
st=input().split()
count=30
for i in range(N):
    a=int(st[i])
    cp=0
    while(True):
        if a%2==1:
            break
        else:
            a=a//2
            cp+=1
    if count>cp:
        count=cp
print(count)


Measured memory_bytes: 2940
#include<stdio.h>

int main()
{
    long long int n,k,s=0;

    scanf("%lld",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&k);
        s=s^k;
    }
    if(s==0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1000000001;
#define MOD 1000000007;
#define INF64 1000000000000000001;

#define F first
#define S second

#define Pii pair<SINT32,SINT32>
#define Pll pair<SINT64,SINT64>


using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 H = 0;
	SINT32 ans = 0;
	SINT32 KMAX = 0;

	cin >> N;
	cin >> H;

	vector<SINT32> KDATA(N);
	vector<SINT32> NDATA(N);
	
	rep(i,0,N) {
		cin >> KDATA[i];
		KMAX = MAX(KMAX,KDATA[i]);
		cin >> NDATA[i];
	}
	sort(NDATA.begin(),NDATA.end(),std::greater<SINT32>());
	NDATA.emplace_back(0);

	SINT32 ncnt = 0;
	while (H > 0) {
		ans++;
		if (NDATA[ncnt] > KMAX) {
			H -= NDATA[ncnt];
			ncnt++;
		} else {
			H -= KMAX;
		}
	}

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

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));	//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/
/* 文字列合成
	string N,M;
	cin >> N >> M;
	SINT64 ans = 0;
	ans = stoi(N+M);
*/



/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 1408
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int k = scanner.nextInt();
        int x = scanner.nextInt();
        for (int i = x - k + 1; i <= x + k - 1; ++i)
            writer.print(i + " ");
        writer.println();
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        private void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        private char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        private String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        private int nextInt() {
            return Integer.valueOf(next());
        }

        private long nextLong() {
            return Long.valueOf(next());
        }

        private double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << std::fixed << setprecision(15);
    auto unit_r = 180.0 / M_PI;

    int64_t a, b, x;
    cin >> a >> b >> x;
    auto aa = a * a;
    auto aaa = aa  * a;
    auto aab = a * a * b;
    auto abb = a * b * b;
    auto idaab = aab / 2;
    auto daab = (double)aab / (double)2;

    if (x == aab) {
        cout << (double)0 << endl;
    } else if (x == idaab) {
        cout << (double)45 << endl;
    } else if (x > daab) {
        auto p = atan(((double)(2 * (aab - x)))/((double)aaa)) * unit_r;
        cout << p << endl;
    } else {
        auto p = 90.0 - atan((double)(2*x)/(double)abb) * unit_r;
        cout << p << endl;
    }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define RANGE(i,a,b) for(int i=(a);i<=(b);i++)
#define RANGER(i,a,b) for(int i=(b);i>=(a);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)
using ll=long long int;
using vi=vector<int>;
using vii=vector<vi>;
using pi=pair<int,int>;
constexpr int INF=1<<30;
constexpr ll INTL=1ll<<60;
int main(){
  int n;
  vi p;
  cin>>n;
  REP(i,n){
    int xx;
    cin>>xx;
    p.push_back(xx);
  }
  int r=0;
  FOR(i,1,n-1){
    if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1])){
      r++;
      // cerr<<i<<" ";
    }
  }
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let n = get();
    let a: Vec<i64> = (0 .. n).map(|_| get()).collect();
    let mut hash = HashMap::new();
    for v in a {
        let oldv = match hash.get(&v) {
            None => 0,
            Some(&x) => x,
        };
        hash.insert(v, oldv + 1);
    }
    println!("{}", hash.into_iter().filter(|&(_, f)| f % 2 == 1).count());
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 16636
n = int(input())

v = list(map(int,input().split()))

a = {}
b = {}
for i in range(n):
	if i % 2 == 1:
		if v[i] in a:
			a[v[i]] += 1
		else:
			a[v[i]] = 1
	else:
		if v[i] in b:
			b[v[i]] += 1
		else:
			b[v[i]] = 1
a[0] = 0
b[0] = 0
a = sorted(a.items(), key=lambda x:x[1])
b = sorted(b.items(), key=lambda x:x[1])
a.reverse()
b.reverse()
c = a[0]
d = b[0]
e = a[1]
f = b[1]
if c[0] == d[0]:
    g = max(c[1]+f[1],d[1]+e[1])
    print(n-g)
else:
    print(n-c[1]-d[1])

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

const int maxn=200005;
int n,last;
int x[maxn],y[maxn],p[maxn],mx[maxn]; 

namespace Dsu{
	int f[maxn],sz[maxn];
	void init(){
		for(int i=1;i<=n;i++)
			f[i]=i,sz[i]=1;
	}
	int find(int x){
		return f[x]==x?x:f[x]=find(f[x]);
	}
	void merge(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return;
		f[x]=y;
		sz[y]+=sz[x];
	}
}

int main(){
	scanf("%d",&n);
	Dsu::init();
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x[i],&y[i]);
		p[x[i]]=y[i];
	}
	for(int i=n;i>=1;i--)
		mx[i]=max(mx[i+1],p[i]);
	for(int i=1;i<=n;i++){
		if(!last||p[i]<p[last]){
			if(last&&mx[i+1]>p[last])
				Dsu::merge(last,i);
			last=i;
		}
		else Dsu::merge(last,i);
	}
	for(int i=1;i<=n;i++)printf("%d\n",Dsu::sz[Dsu::find(x[i])]);
	return 0;
}

Measured memory_bytes: 10892
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int h,w;
  cin >> h >> w;

  vector<string> s(h);
  REP(i,h) cin >> s[i];
  
  vec H(h,0), W(w,0);
  REP(i,h){
    bool flag = true;
    REP(j,w){
      if(s[i][j] == '#') flag = false;
    }
    if(flag) H[i]++;
  }

  REP(j,w){
    bool flag = true;
    REP(i,h){
      if(s[i][j] == '#') flag = false;
    }
    if(flag) W[j]++;
  }

  REP(i,h){
    if(H[i]) continue;
    REP(j,w){
      if(W[j]) continue;
      cout << s[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << max(a*b,c*d);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getval(_T& a) {
	std::cin >> a;
}
template<class _T> static void getval(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getval(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}

static void B();

int main()
{
	B();
	fflush(stdout);
	return 0;
}

static void B()
{
	std::string S, T;
	getval(S, T);
	int ans = 0;
	int len = S.length();
	for (int i = 0; i < len; i++) {
		if (S[i] != T[i]) {
			ans++;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3916
package main

import (
	"fmt"
)

var n, k, r, s, p int
var t string

func main() {
	fmt.Scan(&n)
	fmt.Scan(&k)
	fmt.Scan(&r)
	fmt.Scan(&s)
	fmt.Scan(&p)
	fmt.Scan(&t)
	//initialize dp array
	var dp = make([][]int, n)
	for i := 0; i < n; i++ {
		dp[i] = make([]int, 3)
	}
	for i := 0; i < k; i++ {
		for j := 0; j < 3; j++ {
			dp[i][j] = score(i, j)
		}
	}
	for i := 0; i+k < n; i++ {
		for j := 0; j < 3; j++ {
			var nextHand int
			nextHand = (j + 1) % 3
			if dp[i+k][nextHand] < dp[i][j]+score(i+k, nextHand) {
				dp[i+k][nextHand] = dp[i][j] + score(i+k, nextHand)
			}
			nextHand = (j + 2) % 3
			if dp[i+k][nextHand] < dp[i][j]+score(i+k, nextHand) {
				dp[i+k][nextHand] = dp[i][j] + score(i+k, nextHand)
			}
		}
	}
	var answer int
	for i := n - k; i < n; i++ {
		var subMax int
		for j := 0; j < 3; j++ {
			if subMax < dp[i][j] {
				subMax = dp[i][j]
			}
		}
		answer += subMax
	}
	fmt.Println(answer)
}

func score(loc, hand int) int {
	if loc >= n {
		return 0
	}
	var opponentHand = t[loc]
	if hand == 0 && opponentHand == 's' {
		return r
	}
	if hand == 1 && opponentHand == 'p' {
		return s
	}
	if hand == 2 && opponentHand == 'r' {
		return p
	}
	return 0
}


Measured memory_bytes: 6400
use std::io::stdin;

fn main() {
    let elements: Vec<String> = input().split(" ").map(|s| s.to_string()).collect();
    let d = elements[0].parse::<i32>().unwrap();
    let t = elements[1].parse::<i32>().unwrap();
    let s = elements[2].parse::<i32>().unwrap();

    if s * t >= d {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn input() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim_end().to_string()
}

Measured memory_bytes: 2096
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;

// x^yをINF=1000000007で割ったあまりを繰り返し乗法で解く
long long powINF(long long x, long long y){
    long long n;
    if(y==0) n=1;
    else if(y%2==0) n=powINF(x,y/2)*powINF(x,y/2);
    else if(y%2==1) n=x*powINF(x,y-1);
    return n%1000000007;
}

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    long long INF = 1000000007;
    long long ans=powINF(2,n);
    
    // nCaを求める　x=n(n-1)…(n-a+1),y=a! y^(INF-2)=1/Y(modINF)よりxy^(INF-2)を求める
    long long x=1;
  	long long y=1;
    for(long long i=n-a+1; i<=n; i++){
        x *= i;
        x %= INF;
    }
    for(long long i=1; i<=a; i++){
        y *= i;
        y %= INF;
    }
  	
    long long c;
  	c=powINF(y,INF-2);
  	c *= x;
  	c %= INF;
    long long x1=1;
    long long y1=1;
    for(long long i=n-b+1; i<=n; i++){
        x1 *= i;
        x1 %= INF;
    }
    for(long long i=1; i<=b; i++){
        y1 *= i;
        y1 %= INF;
    }
  	
    long long c1=(powINF(y1,INF-2)*x1)%INF;
	long long c2=(c+c1)%INF;
    ans = (ans -1 -c2)%INF;
    if(ans<0) ans += INF;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

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

int main() {
    int k; 
    cin >> k;
    int ans = 0;
    rrep(a, k) rrep(b, k) rrep(c, k) {
        ans += gcd(a, gcd(b, c));
    } 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
import sys
import math

N = int(input())

mul = 0
quotient = N
dog_name = ""
while(quotient > 26):
    mod = quotient % 26
    if mod == 0:
        mod = 26
    dog_name = chr(mod+96)+ dog_name 
    quotient = math.floor(quotient // 26)
    mul += 1
    if mul > 0 and mod ==26:
        quotient -= 1
#    print(mul, quotient,mod)
if quotient > 0:
    dog_name = chr(quotient+96) + dog_name

print(dog_name)

Measured memory_bytes: 9196
from itertools import*
n=int(input())
a=[[s for s in input().split()]for _ in range(n)]
for b in a:
 b[3],b[4]=b[4],b[3]
def f():
 for d,e in combinations(a,2):
  for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
   f=[d[k]for k in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print(f())


Measured memory_bytes: 5656
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,k; cin >> n >> k;
    int a = 1;
    while (n > 0) {
        if (a < k)
        {
            a *= 2;
        } else {
            a += k;
        }
        n--;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;

inline int read() {
	int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}

const int mod = 1e9 + 7;
char s[200005];
int cnt[100];
LL ans = 0;

void dfs(int x,LL now) {
	if (x == 26) { 
		ans = (ans + now) % mod;
		ans = (ans + 1ll * now * cnt[26] % mod) % mod;
		return ; 
	}
	if (cnt[x]) dfs(x + 1, 1ll * now * cnt[x] % mod);
	dfs(x + 1, now);
}
int main() {
//	freopen("a.in", "r", stdin);
	int n = read();
	scanf("%s", s + 1);
	for (int i = 1; i <= n; ++i) cnt[s[i] - 'a' + 1] ++;
	dfs(1, 1);
	cout << (ans - 1 + mod) % mod;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
using namespace std;

int main() {
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < 4; i++) {
		if (s.at(i)=='+')
			count++;
		else count--;
	}
	cout << count;
}



Measured memory_bytes: 256
import heapq
 
N,M = map(int,input().split())
 
A = [int(i)*-1 for i in input().split()]


heapq.heapify(A)
 
#print(A)

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

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

using namespace __gnu_pbds;
using namespace std;

#define int 		long long
#define vi 			vector<int>
#define vec(x) 		vector<x>
#define matrix 		vector<vector<int>>
#define pii 		pair<int,int>
#define repf(i,s,e)  for(int i=s;i<e;i++)
#define repb(i,e,s) for(int i=e;i>=s;i--)
#define MOD			1000000007
#define pb 			push_back
#define ff 			first
#define ss 			second
#define w(x)		int x; cin>>x; while(x--)
const int INF = 1e18;

#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

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k-1)  returns iterator to kth element starting from 0; Returns the kth smallest element
// order_of_key(k) returns count of elements strictly smaller than k;Returns the number of elements less than k
// erase,insert same as normal set


void solve() {
	int n;
	cin>>n;;

	vector<int> arr(n+1);
	repf(i,1,n+1){
		cin>>arr[i];
	}

	vector<vector<int>> dp(n+1,vector<int>(2,0));
	// dp[i][1]->max sum when we pick the ith element
	// dp[i][0]->max sum when we didn't pick the ith element

	dp[2][0]=arr[1],dp[2][1]=arr[2];
	for(int i=3;i<=n;i++){
		if(i&1){
			dp[i][1]=arr[i]+max({dp[i-3][1],dp[i-3][0],dp[i-2][0],dp[i-2][1]});
			dp[i][0]=max({arr[i-1]+dp[i-2][0],arr[i-2]+dp[i-3][0],arr[i-1]+dp[i-3][1],arr[i-1]+dp[i-3][0]});
		}
		else{
			dp[i][1]=arr[i]+max({dp[i-1][0],dp[i-2][1],dp[i-2][0]});
			dp[i][0]=arr[i-1]+dp[i-2][0];
		}
	}

	cout<<max(dp[n][0],dp[n][1])<<endl;
}

int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	if (fopen("input.txt", "r")) {
		freopen("input.txt", "r", stdin),
		        freopen("output.txt", "w", stdout);
	}

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

Measured memory_bytes: 15600
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let N:usize = sc.read();
    let S:Vec<char> = sc.chars();
    let T:Vec<char> = sc.chars();
    let mut ans:String = "".to_string();
    for i in 0..N{
        ans.push(S[i]);
        ans.push(T[i]);
    }
    println!("{}", ans);
    


}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <complex>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <sstream>
#include <numeric>
#include <functional>
#include <bitset>
#include <iomanip>

using namespace std;


#define INF (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();it++)

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

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

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// useful
#define FST first
#define SND second

#define CK(n,a,b) (a<=n && n<b)

// conversion
template<class T> inline string toStr(T a) { ostringstream oss; oss << a; return oss.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }


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

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

int main() {
  
  int W, H;
  while(cin >> W >> H && (W|H)) {
    int sx, sy, gx, gy, N;
    cin >> sx >> sy >> gx >> gy >> N;
    sx --, sy --, gx --, gy --;
    
    int grid[100][100] = {{}};
    
    for(int i=0; i<N; i++) {
      int c, d, x, y;
      cin >> c >> d >> x >> y;
      x --, y --;
      
      grid[y][x] = grid[y+1][x] = grid[y][x+1] = grid[y+1][x+1] = c;
      if(!d) { grid[y][x+2] = grid[y+1][x+2] = grid[y][x+3] = grid[y+1][x+3] = c; }
      else   { grid[y+2][x] = grid[y+2][x+1] = grid[y+3][x] = grid[y+3][x+1] = c; }
    }
    
    queue<PII> q;
    q.push(MP(sx, sy));
    
    int cost[100][100];
    fill(cost[0], cost[0] + 10000, -1);
    cost[sy][sx] = 0;
    
    while(!q.empty()) {
      PII pii = q.front(); q.pop();
      int x = pii.FST, y = pii.SND;
      
      for(int i=0; i<4; i++) {
	int nx = x + dx[i], ny = y + dy[i];
	if(CK(nx, 0, W) && CK(ny, 0, H)
	   && cost[ny][nx] == -1 && grid[sy][sx] == grid[ny][nx]) {
	  q.push(PII(nx, ny));
	  
	  cost[ny][nx] = cost[y][x] + 1;
	}
      }
    }
    
    if(cost[gy][gx] == -1) {
      cout << "NG" << endl;
    }
    else {
      cout << "OK" << endl;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 1288
#include<iostream>

using namespace std;



int main(){
	int kai,i;
	int a,b,c;


	cin >> kai;

	for(i=0;i<kai;i++){
		cin >> a >> b >> c;

		if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1152
import java.util.Scanner;

class Main{
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        while (true) {
            int n = scan.nextInt();
            int m = scan.nextInt();
            if (n == 0 && m == 0) {
                break;
            }
            int[] nData = new int[n];
            int[] mData = new int[m];
            int nSum=0,mSum=0;
            for (int i = 0; i < n; i++) {
                nData[i] = scan.nextInt();
                nSum=nSum+nData[i];
            }
            for (int i = 0; i < m; i++) {
                mData[i] = scan.nextInt();
                mSum=mSum+mData[i];
            }
            boolean flag=false;
            int nAns=1000,mAns=1000;
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if(nSum-nData[i]+mData[j]==mSum-mData[j]+nData[i]){
                        if(!flag){
                            nAns=nData[i];
                            mAns=mData[j];
                        }
                        if(nAns+mAns>nData[i]+mData[j]){
                            nAns=nData[i];
                            mAns=mData[j];
                        }
//                        System.out.println(nData[i]+" "+mData[j]);
//                        System.out.println(hoge+" "+fuga);
                        flag=true;
                    }
                }
            }
            if(!flag){
                System.out.println("-1");
            }
            else {
                System.out.println(nAns+" "+mAns);
            }
        }
    }
}


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

const int maxn=1e6+5;
int n;
int bj[maxn];
int a[maxn];
int cnta[maxn];
int cntb[maxn];
typedef pair<int,int> pii;

int main()
{

    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i&1)
        {
            cnta[a[i]]++;
        }else{
            cntb[a[i]]++;
        }
    }
    vector<pii> ji,ou;
    for(int i=1;i<=n;i++)
    {
        if(i&1)
        {
            ji.push_back(make_pair(cnta[a[i]],a[i]));
        }else
        {
            ou.push_back(make_pair(cntb[a[i]],a[i]));
        }
    }
    sort(ji.begin(),ji.end());
    ji.erase(unique(ji.begin(),ji.end()),ji.end());
    sort(ou.begin(),ou.end());
    ou.erase(unique(ou.begin(),ou.end()),ou.end());
    int ans=1e9;
    for(int i=1;i<=n;i+=2)
    {
        if(ou[ou.size()-1].second!=a[i])
        {
            ans=min(ans,n/2-cnta[a[i]]+n/2-ou[ou.size()-1].first);
        }else
        {
            if(ou.size()>=2)
            {
//                cout<<ou[n/2-2].first<<" "<<ou[n/2-2].second<<endl;
                ans=min(ans,n/2-cnta[a[i]]+n/2-ou[ou.size()-2].first);
            }else
            {
                ans=min(ans,n/2-cnta[a[i]]+n/2);
            }
        }
    }
    for(int i=2;i<=n;i+=2)
    {
        if(ji[ji.size()-1].second!=a[i])
        {
            ans=min(ans,n/2-cntb[a[i]]+n/2-ji[ji.size()-1].first);
        }else
        {
            if(ji.size()>=2)
            {
                ans=min(ans,n/2-cntb[a[i]]+n/2-ji[ji.size()-2].first);
            }else
            {
                ans=min(ans,n/2-cntb[a[i]]+n/2);
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 9852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll>h(n);
    for(ll i=0;i<n;i++) cin >> h[i];
    vector<ll>dp(n+1,MOD);
    dp[0]=0;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<=k;j++){
            if(i-j<0) continue;
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4752
N, X, Y = map(int, input().split())
ans = [0]*N

for i in range(1,N+1):
  for j in range(i+1,N+1):
    d = min(j-i,abs(i-X)+abs(j-Y)+1)
    #print(i,j,d)
    ans[d]+=1

print(*ans[1:], sep='\n')

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int f(int a){
    int ret;
    if(a%2==0){
        ret = a / 2;
    }else{
        ret = 3 * a + 1;
    }
    return ret;
}
int main()
{
    int s;
    cin >> s;
    vector<int> v(1000001);
    int cnt = 1;
    while (!v[s]){
        v[s]++;
        cnt++;
        s = f(s);
    }
    cout << cnt << endl;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M =1000000007;
//MOD??
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}
int is_product_overflow(ll a, ll b) {

	ll prod = a * b;
	
	if (prod >= 1000000000000000001 || prod<=0){
    return 1;
  }
  else {
    return 0;
  }
}
ll mpow(ll x, ll n){ //x^n(mod M) ????pow(x,n)?????????????mod??
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
int main (){
  int i;
  int n;
  cin>>n;
  ll a,sum=1,f=0;
  for(i=0;i<n;i++){
    cin>>a;
    if(a==0){
      f=0;
      break;
    }
    if(is_product_overflow(sum,a)==1){
      f=1;
      sum=0;
    }
    sum*=a;
      if(sum>=1000000000000000001){
        //cout<<a<<endl;
        sum=0;
        f=1;
      }
    
  }
  if(f==0)
  cout<<sum<<endl;
  else{
    cout<<-1<<endl;
  }
  return 0;
}



Measured memory_bytes: 3624
import itertools, math, collections, sys
input = sys.stdin.readline
H, W, K = [int(_) for _ in input().split()]
A = [input() for _ in range(H)]
for i, j in itertools.product(range(H), range(W)):
    if A[i][j] == 'S':
        A[i] = A[i][:j] + '.' + A[i][j + 1:]
        break
visited = [[False] * W for _ in range(H)]
ans = float('inf')
Q = collections.deque([[i, j, K]])
while Q:
    h, w, res = Q.popleft()
    if not visited[h][w] and A[h][w] == '.':
        visited[h][w] = True
        ans = min([ans, h, H - 1 - h, w, W - 1 - w])
        if res:
            res -= 1
            if h:
                Q += [[h - 1, w, res]]
            if h < H - 1:
                Q += [[h + 1, w, res]]
            if w:
                Q += [[h, w - 1, res]]
            if w < W - 1:
                Q += [[h, w + 1, res]]
print(1 + math.ceil(ans / K))


Measured memory_bytes: 100056
import * as fs from 'fs';

const input: string = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const nextNumbers: number[][] = [];
for (let i = 0; i < 10; i++) {
  const tmp: number[] =
    [i + 9, i, i + 1]
      .map(x => x % 10)
      .filter(x => Math.abs(i - x) <= 1)
      .sort((x, y) => x - y);
  nextNumbers.push(tmp);
}

function getLunlun(n: number): number {
  let tmp = n - 1;
  let a: number[][] = [];
  for (let i = 1; i <= 9; i++) a.push([i]);
  if (tmp < a.length) return getNum(a[tmp])

  while (tmp >= a.length) {
    tmp -= a.length;
    let tmpArray: number[][] = [];
    a.forEach(array => {
      const nexts: number[] = nextNumbers[array[array.length - 1]];
      nexts.forEach(x => {
        tmpArray.push([...array, x]);
      })
    });
    a = tmpArray;
  }
  return getNum(a[tmp])
}

function getNum(ns: number[]): number {
  return ns.reduce((x, y) => 10 * x + y)
}

const k = parseInt(args[0][0]);
console.log(getLunlun(k));

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

int main() {
    int N;
    cin >> N;
    if(N%10 == 7){
        cout << "Yes" << endl;
    }else if((N/10)%10==7){
        cout << "Yes" << endl;
    }else if((N/100)%10==7){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
import java.io.*;
import java.util.*;
import java.math.*;
     
public class Main{
	public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	}

	static class Solver
	{
      void preCalculate(long[] ar)
      {
        ar[0]=1L;
        for(int i=1 ; i<=40 ; i++)
        {
          ar[i] = (1L<<i)+ar[i-1];
          //System.out.println(ar[i]);
        }
        
      }
	    void solve(IO io, PrintWriter out)
	    {
           int i, j=0;
           	long n = io.nextLong();
          long[] pre = new long[41];
          preCalculate(pre);
          	for(i=0 ; i<64 ; i++)
            {
              	if(((1L<<i)&n)!=0)
                {
                  	j=i;
                  //out.println(j);
                }
            }
          	out.print(pre[j]);
	    }
    	
	}
	//Special thanks to Petr (on codeforces) who inspired me to implement IO class!
	static class IO
	{
    	BufferedReader reader;
        StringTokenizer tokenizer;
    	public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            }
     
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public long nextLong() {
            return Long.parseLong(next());
        }
    	double nextDouble()
    	{
    		return Double.parseDouble(next());
    	}
	}
}

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

using namespace std;

const int maxn = 110 ;

int v[maxn] ;
bool vis[maxn] ;

int main() {
	int n ; scanf("%d",&n) ;
	for (int i = 1 ; i <= n ; i ++ ) {
		scanf("%d",&v[i]) ;
	}
	memset(vis ,false ,sizeof(vis)) ;
	bool flag = true ; int cnt = 0 ;
	for (int i = 1 ; i <= n ; i ++ ) {
		if ( i != v[i] && cnt < 1 ) {
			int x ,y ;
			x = i ,y = v[i] ;
			v[x] = v[y] ;
			v[y] = y ;
			cnt ++ ;
		}
		if ( i != v[i] ) {
			flag = false ;
		}
		if ( !flag ) {
			flag = false ;
			break ;
		}
	}
	if ( !flag ) {
		printf("NO\n") ;
	} else {
		printf("YES\n") ;
	}
	return 0;
}

Measured memory_bytes: 256