akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    ll dp[100010][4];
    cin>>s;
    int n=s.size();
    repr(i,n+1){
        repr(j,4){
            if(i==n){
                dp[i][j] =(j==3 ? 1 : 0);
            }
            else{
                dp[i][j]=dp[i+1][j] * (s[i]=='?' ? 3 :1);
                if(j<3 && (s[i]=='?' || s[i] == "ABC"[j])){
                    dp[i][j] += dp[i+1][j+1];
                }
            }
            dp[i][j] %=MOD;
        }
    }
    cout<<dp[0][0]<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  int64_t n, k;
  cin >> n >> k;
  vector <pair <int, int>> v(n);
  rep(i, n) cin >> v.at(i).first >> v.at(i).second;
  sort(v.begin(), v.end());
  rep(i, n) {
    if (k > v.at(i).second) {
      k -= v.at(i).second;
    } else {
      cout << v.at(i).first << endl;
      break;
    }
  }
}

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

r = 0
i = 1
k = 0
while True:
    if a[k] == i:
        i += 1
        k += 1
    else:
        k += 1
        r += 1
    if k >= len(a):
        if r == len(a):
            print(-1)
        else:
            print(r)
        exit()

Measured memory_bytes: 26140
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <map>
using namespace std;

int main()
{
  cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);

  int n;
  cin >> n;

  int house[4][3][10];
  memset(house, 0, sizeof(house));

  for(int i=0; i<n; i++)
    {
      int b,f,r,v;

      cin >> b >> f >> r >> v;

      house[b-1][f-1][r-1] += v;
    }

  for(int i=0; i<4; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<10; k++){
	cout << " " <<  house[i][j][k];
	if(k==9)
	  cout << endl;
      }
      }
    if(i!=3)
      {
	for(int i=0; i<20; i++)
	  cout << "#";
	cout << endl;
      }
    }
  }

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const ll mod = 1000000007;
char x[200001];
int main() {
	char*s;
	scanf("%s", x);
	int len = strlen(x), d = 0, nest = 0;
	s = x;
	while (*s) {
		if (*s == 'S')nest++;
		else nest--;
		if (nest < 0)nest = 0;
		else d++;
		s++;
	}
	printf("%d\n", len - d + nest);
	return 0;
}


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

#define ll long long int
#define mem(n) memset(n,0,sizeof(n))
#define LCM(a,b) (a / __gcd(a,b) ) * b
#define gcd(a,b) __gcd(a,b)
#define for0(l,n) for(int l=0;l<n;l++)
#define for1(l,n) for(int l=1;l<=n;l++)
#define bug(n) cout<<">> "<<n<<" <<";
#define pb push_back
#define P1(a) cout<<a<<endl;
#define P2(a,b) cout<<a<<" "<<b<<endl;
#define P3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define S1(a) cin>>a
#define S2(a,b)cin>>a>>b
#define S3(a,b,c) S2(a,b),S2(c)
#define squerit(n) (ll)n*n
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)

bool vowel(char a)
{
    a= toupper(a);
    if((a=='A')||(a=='E')||(a=='I')||(a=='O')||(a=='U'))return 1;
    return 0;
}

ll n,m,q,a,b,c,sum=0,cnt=0;
//ll arr[1000055];
map<ll,bool>mp;
string str;

struct my
{
    int tm, x,y;
}arr[100005];


bool cmp(my f,my s)
{
    return f.tm < s.tm;
}
int main()
{
    FastRead;

    cin>>n;
    for0(i,n)
    {
        cin>>arr[i].tm>>arr[i].x>>arr[i].y;
    }
//    sort(&arr[0],&arr[n],cmp);
    int atx = 0, aty = 0;
    int lsttime = 0;
    for0(i,n)
    {
       int dist = abs(arr[i].x - atx) + abs(arr[i].y - aty);
        int time = arr[i].tm - lsttime;

        if(time < dist)
        {
            cout<<"No"<<endl;
            return 0;
        }
        else
        {
            if(time % 2 == dist%2)
            {
                lsttime = arr[i].tm;
                atx = arr[i].x;
                aty = arr[i].y;
            }
            else
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;


}















Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

LLI dp[110][101000];

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

  int N, W; cin >> N >> W;
  vector<LLI> w(N), v(N);
  REP(i,N) cin >> w[i] >> v[i];

  
  REP(i,N){
    REPE(j,W){
      chmax(dp[i+1][j], dp[i][j]);
      if(j+w[i]<=W) chmax(dp[i+1][j+w[i]], dp[i][j]+v[i]);
    }
  }
  
  cout << dp[N][W] << endl;
  
  return 0;
}


Measured memory_bytes: 79360
#include<iostream>
#include<bitset>
using namespace std;
int main(){
    int A,B,C,D,a,b,c,d;
    cin>>A;
    D=A%10,A/=10;
    C=A%10,A/=10;
    B=A%10,A/=10;
    bitset<3>s(0);
    for(int i=0;i<8;i++){
        s=i;
        a=A,b=B,c=C,d=D;
        if(s[0])b*=-1;
        if(s[1])c*=-1;
        if(s[2])d*=-1;
        if(a+b+c+d==7){cout<<A<<(s[0]?"-":"+")<<B<<(s[1]?"-":"+")<<C<<(s[2]?"-":"+")<<D<<"=7"<<endl;return 0;}
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
 
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        
        if(A==1&&B==1)  System.out.println("Draw");
        else if(A==1)System.out.println("Alice");
        else if(B==1)System.out.println("Bob");
        else if(A<B) System.out.println("Bob");
        else if(A>B) System.out.println("Alice");
        else if(A==B) System.out.println("Draw");

       
    }

}

Measured memory_bytes: 25044
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return (i for i in range(self.n) if self.find(i) == root)

    def roots(self):
        return (i for i, x in enumerate(self.parents) if x < 0)

    def group_count(self):
        return len(self.roots())

    def sizes(self):
        return {x: self.size(x) for x in self.roots()}

    def all_group_members(self):
        d = {}
        for i in range(self.n):
            p = self.find(i)
            d[p] = d.get(p, []) + [i]
        return d

    def __str__(self):
        return '\n'.join('{}: {}'.format(k, v) for k, v in self.all_group_members().items())


def resolve():
    import sys
    input = sys.stdin.readline
    n, m = map(int, input().split())
    u = UnionFind(n)
    for _ in range(m):
        a, b = map(int, input().split())
        u.union(a - 1, b - 1)
    ans = 0
    for i in u.sizes().values():
        ans = max(i, ans)
    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 100948
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum =0;
		int a=N;
		while (N>0) {
			sum += N%10;
			N=N/10;
		}
		if (a%sum==0) {
			System.out.println("Yes");
			return ;
		}
		System.out.println("No");

	}

}

Measured memory_bytes: 21588
n = int(input())
ans = 0


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

for i in range(1,n+1):
    if i%2:
        if len(make_divisors(i)) == 8:
            ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> a >> b >> c;
    if (a == b){
        if (a != c) cout << "Yes";
        else cout << "No";
    }
    else if (a == c){
        if (a != b) cout << "Yes";
        else cout << "No";
    }
    else if (b == c){
        if (b != a) cout << "Yes";
        else cout << "No";
    }
    else cout << "No";
}

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>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

template<int size>
struct BIT
{
	// [0,size]
	LL tree[size+1];
	void add(int i,LL v){
		i++;
		while(i<=size){
			tree[i]+=v;
			i+=(i&-i);
		}
	}

	// [0,i]
	LL collect(int i){
		i++;
		LL r=0;
		while(i>0){
			r+=tree[i];
			i-=(i&-i);
		}
		return r;
	}

	// [a,b]
	LL collect(int a, int b){
		return collect(b)-collect(a-1);
	}
};

BIT<100*1000> sum, num;
vector<int> as[100*1000+1];
int N;
int main() {
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		as[b].push_back(a);
	}
	LL r=0;
	for(int b=100*1000;b>0;b--){
		if(as[b].size()==0)continue;
		for(auto a:as[b]){
			sum.add(a,a);
			num.add(a,1);
		}
		int low=b;
		int hi=100*1000+1;
		while(low+1<hi){
			int mid=(low+hi)/2;
			LL k=num.collect(mid);
			LL s=sum.collect(mid);
			if(s<=k*b){
				low=mid;
				r=max(r,k);
			}
			else{
				hi=mid;
			}
		}
		{
			LL k=num.collect(low);
			LL kk=num.collect(low+1);
			LL s=sum.collect(low);
			r=max(r,k+min(kk-k,(k*b-s)/(low+1-b)));
		}
	}
	printf("%lld\n",r);

}

Measured memory_bytes: 8476
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int l[10];

int main(){
    INIT;
    cin >> n;
    REP(i, n)cin >> l[i];
    int sum = 0,maxl = 0;
    REP(i, n){
        sum += l[i];
        maxl = max(maxl, l[i]);
    }
    cout << (sum - maxl > maxl ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << "\n";
    return 0;
}

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

int main() {
    int X;
    cin >> X;
    int sum = 0;
    for (int i = 1; i < 100000; i++) {
        sum += i;
        if (sum >= X) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int C, N, M;
  cin >> C >> N >> M;
  vector<int> s(N), p(N);
  for (int i = 0; i < N; i++){
    cin >> s[i] >> p[i];
  }
  vector<int> dp(C + 1, 0);
  for (int i = 0; i < N; i++){
    for (int j = C; j >= s[i]; j--){
      dp[j] = max(dp[j], dp[j - s[i]] + p[i]);
    }
  }
  for (int i = 1; i <= M; i++){
    cout << dp[C / i] * i << endl;
  }
}


Measured memory_bytes: 3192
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
// #include <utility>
using namespace std;

typedef long long int ll; 
typedef pair<int,int> Pii;

int main(){
    int N,ans,minn;
    minn = 200001;
  ans = 0;
    cin >> N;
    vector <int>nums();
    vector <int>bools();
    for (size_t i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        
        if (tmp < minn){
            ans ++;
            minn = min(minn,tmp);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INFINITY 1000000001
#define N 500000

int count=0;
void mergeSort(int *,int,int);
void merge(int *,int,int,int);

int main(){

  int n,k;
  int A[N];
  int left,right;

  scanf("%d",&n);

  left=0;
  right=n;

  for(k=0;k<n;k++){
    scanf("%d",&A[k]);
  }

  mergeSort(A,left,right);

  for(k=0;k<n;k++){
    printf("%d",A[k]);
    if(k==n-1) printf("\n");
    else printf(" ");
  }

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

  return 0;
  
}


void mergeSort(int *A,int left,int right){

  int mid;

  if(left+1 < right){

    mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
    
  }
  
}

void merge(int *A,int left,int mid,int right){

  int n1,n2,i,j,k,lcount=0,rcount=0;
  int L[N],R[N];
  
  n1=mid-left;
  n2=right-mid;
  
  for(i=0;i<=n1-1;i++){
    L[i] = A[left+i];
    lcount++;
  }
 
  for(i=0;i<=n2-1;i++){
    R[i] = A[mid+i];
    rcount++;
  }
 

  L[n1]=INFINITY;
  R[n2]=INFINITY;

  i=0;
  j=0;
  
  for(k=left;k<=right-1;k++){

    if(L[i]<=R[j]){

      A[k]=L[i];
      lcount--;
      if(lcount>0){
	i++;
      }else{
	L[i]=INFINITY;
      }
      
    }else{

      A[k]=R[j];
      rcount--;
      if(rcount>0){
	j++;
      }else{
	R[j]=INFINITY;
      }
      
    }//if
    
    count++;
    
  }//for

}






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

void solve()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 0;
    if ((b - a) % 2 == 0)
        ans = (b - a) / 2;
    else
        ans = min(a - 1, n - b) + 1 + (b - a) / 2;
    cout << ans << endl;
}

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

Measured memory_bytes: 3540
#include<stdio.h>
int main ()
{
    int A,B;
    scanf("%d%d",&A,&B);
    if (A==1 && B==2)
    printf("3\n");
    else if (A==2 && B==3)
    printf("1\n");
    else if (A==2 && B==1)
    printf("3\n");
    else if (A==3 && B==2)
    printf("1\n");
    else
    printf("2\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,i=0,e=0,w=0,s=1e9,a[300003];
	char c[300003];
	for(cin>>n;i<n;cin>>c[i],a[i]=w,w+=c[i++]==87);
	for(;i>0;s=min(s,a[--i]+e),e+=c[i]==69);
	cout<<s<<endl;
}

Measured memory_bytes: 1664
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);


    int n;
    cin >> n;

    vector<long long> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    auto mm = minmax_element(A.begin(), A.end());
    auto mn = *mm.first;
    auto mx = *mm.second;

    vector<pair<int,int>> res;
    if (mn >= 0) {
        for (int i = 0; i + 1 < n; ++i) {
            res.emplace_back(i, i + 1);
        }
    } else if (mx <= 0) {
        for (int i = n - 1; i > 0; --i) {
            res.emplace_back(i, i - 1);
        }
    } else {
        int neg = -1, pos = -1;
        for (int i = 0; i < n; ++i) {
            if (A[i] == mn) {
                neg = i;
            }
            if (A[i] == mx) {
                pos = i;
            }
        }
        assert(neg >= 0 && A[neg] < 0);
        assert(pos >= 0 && A[pos] > 0);

        if (mn + mx >= 0) {
            for (int i = 0; i < n; ++i) {
                if (A[i] < 0) {
                    res.emplace_back(pos, i);
                }
            }
            for (int i = 0; i + 1 < n; ++i) {
                res.emplace_back(i, i + 1);
            }
        } else {
            for (int i = 0; i < n; ++i) {
                if (A[i] >= 0) {
                    res.emplace_back(neg, i);
                }
            }
            for (int i = n - 1; i > 0; --i) {
                res.emplace_back(i, i - 1);
            }
        }
    }

    cout << res.size() << '\n';
    for (auto& p : res) {
        cout << p.first + 1 << ' ' << p.second + 1 << '\n';
    }

    return 0;
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#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 (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end() å
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

string S, T;

signed main()
{
    cin >> S >> T;

   vector<int> atb(26,-1),bta(26,-1);



    rep(i,S.size()){
        int a = S[i]-'a';
        int b = T[i]-'a';

        if(atb[a]<0){atb[a]=b;}
        else{
            if(atb[a]!=b){
                cout <<"No"<<endl;
                return 0;
            }
        }

        if(bta[b]<0){bta[b]=a;}
        else{
            if(bta[b]!=a){
                cout<<"No"<<endl;
                return 0;
            }
        }
        
    }

    cout <<"Yes"<<endl;


    return 0;
}


Measured memory_bytes: 776
#cording: utf-8

S = str(input())
S = list(S)

ind = 0
three_numbers = []
while ind < len(S)-2:
    tmp = S[ind]+S[ind+1]+S[ind+2]
    three_numbers.append(int(tmp))
    ind += 1

for i in range(len(three_numbers)):
    three_numbers[i] = abs(three_numbers[i]-753)

print(min(three_numbers))


Measured memory_bytes: 3060
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = arrayInt(sc, n);
		sc.close();
		boolean ans = true;
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 0) {
				if (a[i] % 3 != 0) {
					if (a[i] % 5 != 0) {
						ans = false;
					}
				}
			}
		}
		System.out.println(ans ? "APPROVED" : "DENIED");
	}

	public static int arrayMax(int[] array) {
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static Integer[] arrayInteger(Scanner sc, int n) {
		Integer[] array = new Integer[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  vector<bool> h(H), w(W);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
      if (A.at(i).at(j) == '#') h.at(i) = w.at(j) = true;
    }
  }
  for (int i = 0; i < H; i++) {
    if (!h.at(i)) continue;
    for (int j = 0; j < W; j++) {
      if (!w.at(j)) continue;
      cout << A.at(i).at(j);
    }
    cout << "\n";
  }
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int a, b, c;
	cin >> a >> b >> c;

	if ((a * 100 + b * 10 + c) % 4 == 0) {
		out("YES");
	}
	else {
		out("NO");
	}

	return 0;
}

Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d", $K);
  fscanf(STDIN, "%d %d", $A, $B);

	for (;$A<=$B;$A++) {
      	if ($A%$K == 0) {
          	echo "OK";
          	exit(0);
        } 
    }
	echo "NG";

	

Measured memory_bytes: 16088
#include <iostream>
#include <vector>

int main(){
    int n;
    std::cin >> n;
    std::vector<int> h;
    for(int i=0;i<n;i++){
	int h_i;
	std::cin >> h_i;
	h.push_back(h_i);
    }
    int sum = 0;
    int max = 0;
    for(int i=0;i<n;i++){
	if(max <= h[i]) {
	    sum++;
	    max = h[i];
	}
    }
    std::cout << sum << std::endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;
   int a[n-1];
   int c[n+1];
   fill(c,c+n+2,0);
   for(int i=0;i<n-1;i++)
   {
   	cin>>a[i];
   	c[a[i]]++;
   }
   for(int i=1;i<=n;i++)
   cout<<c[i]<<endl;
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
#include <iostream>
#include<cstdio>
#include<cstring>
#define endl '\n'
using namespace std;
int main()
{
	string S,T;
	cin>>S>>T;
	int n = S.size();
	int cnt = 0;
	for(int i=0; i<n; i++)
	{
		if(S.at(i)!=T.at(i))
			cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

struct A {
  ll a;
  ll b;
  ll c;
  ll d;
};

void out(A aa) {
  cout << aa.a + 1 << " " << aa.b + 1 << " " << aa.c + 1 << " " << aa.d + 1
       << endl;
}

signed main() {
  init();
  ll H, W;
  cin >> H >> W;
  vector<vll> m(H, vll(W));
  rep(i, H) rep(j, W) cin >> m[i][j];

  vector<A> ans;

  rep(i, H - 1) {
    rep(j, W) {
      if (m[i][j] % 2 == 1) {
        m[i][j]--;
        m[i + 1][j]++;
        ans.pb(A({i, j, i + 1, j}));
        continue;
      }
    }
  }

  rep(j, W - 1) {
    if (m[H - 1][j] % 2 == 1) {
      m[H - 1][j]--;
      m[H - 1][j + 1]++;
      ans.pb(A({H - 1, j, H - 1, j + 1}));
    }
  }

  COUT(ans.size());
  rep(i, ans.size()) {
    out(ans[i]);
  }

  return 0;
}

Measured memory_bytes: 9344
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

ll N, Q;
map<ll, vector<ll> > query;

vector<pair<ll,ll> > road;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> Q;
    rep(i,Q){
        ll a, b;
        cin >> a >> b;
        query[a].pb(b);
    }
    rep(i, N){
        ll index = i+1;
        if(query[index].size() == 0) continue;
        sort(all(query[index]));
        road.pb(mp(index, query[index][0]));
    }
    
    ll ans = 0;
    pair<ll,ll> now = mp((ll)0,(ll)0);
    rep(i, road.size()){
        
        //cerr << now.first << "+"<< now.second << "||||" << road[i].first << "-" << road[i].second << endl;
        pair<ll,ll> nxt = road[i];
        if(now.second <= nxt.first){
            ans ++;
            now.first = nxt.first;
            now.second = nxt.second;
        }
        else if(now.second <= nxt.second){
            now.first = nxt.first;
        }
        else{
            now.first = nxt.first;
            now.second = nxt.second;
        }
    }
    cout << ans << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 13428
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; // [9,223,372,036,854,775,807 to -9.....808] 19 digits
typedef long double ld;
#define inc(i, a, b) for (long long int i = a; i <= b; i++)
#define dec(i, a, b) for (long long int i = a; i >= b; i--)
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define lv vector<ll>
#define cv vector<char>
#define dv vector<ld>
#define rall(c) (c).rbegin(), (c).rend()
#define lpr pair<ll, ll>
#define mp make_pair
#define cin(c) \
    ll c;      \
    cin >> c;
#define lmap unordered_map<ll, ll>
#define vinp(a, n) \
    inc(i, 1, n)   \
    {              \
        cin(k);    \
        a.pb(k);   \
    }
#define LIM 1000000007
#define F first
#define S second
#define fr(i, n) inc(i, 0, n - 1)
#define fri(n, a) \
    inc(i, 0, n - 1) { cin >> a[i]; }
//#define end cout<<"\n";
#define debug(p) cout << p;
#define umap unordered_map
#define uset unordered_set
#define fill(a, val, n) \
    inc(i, 0, n - 1) { a[i] = val; }
void i_love_Accepted()
{
    ll n;
    cin>>n;
    lmap arr;
    ll k;
    ll sum=0;
    fr(i,n)
    {
        cin>>k;
        arr[k]++;
        sum+=k;
    }
    ll q;
    cin>>q;
    inc(i,1,q)
    {
        ll b,c;
        cin>>b>>c;
        sum+=arr[b]*(c-b);
        cout<<sum<<"\n";
        arr[c]+=arr[b];
        arr.erase(b);
    }
}   
int main()
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        i_love_Accepted();
        //end;
    } 
}


Measured memory_bytes: 6652
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <complex>
#include <cstdio>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		a[i]--;
	}
	int ans = 0;
	for (int i = 0; i < N - 1; i++) {
		if (a[i] > i && a[a[i]] == i)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  long a, b;
  cin >> a >> b;
  
  if(a == 1 || b == 1){
    cout << 1 << endl;
  }
  else{
    
  if(a % 2 == 0){
    cout << (a / 2) * b << endl;
  }
  else{
    if(b % 2 == 0){
    cout << a * (b / 2) << endl;
    }
   if(b % 2 == 1){
    cout << ((a + 1) * (b + 1) + (a - 1) * (b - 1)) / 4 << endl;
    }
  }
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        int[] numbers = new int[n];
        String ans = "APPROVED";
        
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.parseInt(input[i]);
            if(numbers[i] % 2 == 0){
                if(numbers[i] % 3 != 0 && numbers[i] % 5 != 0){
                    ans = "DENIED";
                    break;
                }
            }
        }
        
        out.println(ans);
        out.close();
        
    }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/06/22  Problem: ABC 131 C / Link: http://abc131.contest.atcoder.jp/tasks/abc131_c  ----- */

/*最大公約数を求める関数(再帰版ユーグリッドの互除法)*/
long long  gcd(long long  a, long long  b) { return b ? gcd(b, a%b) : a; }
// minusのときはabsしておけばOK
/*最小公倍数を求める関数。最小公倍数の性質( a×b÷[aとbの最大公約数] )を利用。*/
long long  lcm(long long  a, long long  b) { return a / gcd(a, b) * b; }

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

	LL A, B, C, D; cin >> A >> B >> C >> D;
	auto solve = [&](LL x) {
		LL ret = x;
		ret -= x / C;
		ret -= x / D;
		ret += x / (lcm(C, D));
		return ret;
	};
	cout << solve(B) - solve(A - 1) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
int a[10],b,j,i;
   for(i=0;i<10;i++)
   {
    scanf("%d",&a[i]);
   }
   for(j=0;j<20;j++)
   {
      for(i=0;i<9;i++)
      {
         if(a[i]<a[i+1])
         {
         b=a[i];
         a[i]=a[i+1];
         a[i+1]=b;
         }
      }
   }
   printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
   return 0;
}

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

int a, b;


int main() {
	cin >> a >> b;
	if (a > b) {
		for (int i = 0; i < a; i++) {
			cout << b;
		}
	}
	else if (a < b) {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
	}
	else {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),k=nxt();
    int test=0;
    while(n!=0)
    {
        n/=k;
        test++;
    }
    cout<<test<<endl;

    return 0;   
}


 
 


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>

// https://youtu.be/1oLDDdWRu6Y の回答をみて写経。

#define rep(i, n) for (int i=0; i< (n); ++i)
typedef long long ll;
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; }

using namespace std;

typedef pair<int, int> P;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
    int H, W;
    int ans = 0;
    cin >> H >> W;

    string sij[H];
    rep(i, H) cin >> sij[i];

    rep(si, H) {
        rep(sj, W) {
            if (sij[si][sj] == '#')
                continue;

            vector<vector<int>> dist(H, vector<int>(W, -1));
            queue<P> q;
            auto update = [&](int i, int j, int x) {  // マス i, j の値を x で上書き
                if (dist[i][j] != -1)
                    return;
                dist[i][j] = x;
                q.push(P(i, j));
            };

            update(si, sj, 0);

            while (!q.empty()) {
                int i = q.front().first;
                int j = q.front().second;
                q.pop();  // これを忘れないこと！

                rep(dir, 4) {
                    int ni = i + di[dir], nj = j+dj[dir];
                    if (ni < 0 || ni >= H || nj < 0 || nj >= W)
                        continue;
                    if (sij[ni][nj] == '#')
                        continue;
                    update(ni, nj, dist[i][j] + 1);
                }
            }

            rep(i, H) {
                rep(j, W) {
                    chmax(ans, dist[i][j]);
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from sys import stdin
N, K = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(stdin.readline().rstrip()) for _ in range(N)]
h.sort()
diff = [h[k + K - 1] - h[k] for k in range(N - K + 1)]
diff.sort()
print(diff[0])

Measured memory_bytes: 11292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int a[105000];

int main() {
    //cout.precision(10);
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> a[i];
    }
    if(N % 3 != 0) {
        for(int i = 1; i <= N; i++) {
            if(a[i] != 0) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
    set<int> st;
    map<int, int> mp;
    for(int i = 1; i <= N; i++) {
        st.insert(a[i]);
        mp[a[i]]++;
    }
    if(st.size() > 3) {
        cout << "No" << endl;
        return 0;
    }
    vector<int> v;
    for(auto itr = st.begin(); itr != st.end(); itr++) {
        while(mp[*itr] > 0) {
            if(mp[*itr] % (N / 3) != 0) {
                cout << "No" << endl;
                return 0;
            }
            mp[*itr] -= N / 3;
            v.push_back(*itr);
        }
    }
    cerr << v[0] << " " << v[1] << " " << v[2] << endl;
    if((v[0] ^ v[1]) == v[2]) {
        cerr << (v[0] ^ v[1]) << endl;
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 7808
def showList(A, N):
    for i in range(N-1):
        print(A[i],end=' ')
    print(A[N-1])

def inserationSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return A, cnt

def shellSort(A,n):
    cnt = 0
    G = [1]
    i = 0
    while G[i] < n:
        G.append(3*G[i]+1)
        i += 1
    G.pop(len(G)-1)
    G.reverse()
    for j in range(len(G)):
        A, cnt = inserationSort(A, n, G[j], cnt)
    return A, cnt, G

n = int(input())
A = []
cnt = 0
for i in range(n):
    A.append(int(input()))
A, cnt, G = shellSort(A,n)

if len(G) != 0:
    print(len(G))
    showList(G, len(G))
elif len(G) == 0:
    print(1)
    print(1)
if n != 1:
    print(cnt)
    for i in range(n):
        print(A[i])
elif n == 1:
    print(cnt)
    print(A[0])


Measured memory_bytes: 45516
//Name : Rupa Dey
  //Date : 29 august 2020
//joi sri gour hori gobindo...
//gobindo ja hobe vlor jonnoi hobe..
#include<bits/stdc++.h>
#define ll long long
#define d double
#define ld long double
#define vi vector<int>
#define vul vector<ull>
#define vl vector<ll>
#define pb push_back
#define si set<int>
#define sl set<ll>
#define yes cout<<"YES\n"<<endl
#define no cout<<"NO\n"<<endl
#define ys cout<<"Yes\n"<<endl
#define n cout<<"No\n"<<endl
#define test cin>>t; while(t--)
#define for(i,a,n) for(i=a;i<n;i++)
#define mp make_pair
#define ft first
#define sc second
#define gap " ";
#define MAX 9999999
#define MOD 1000000007
#define nd endl
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;
    ll store;
    cin>>a>>b>>c;
    store = c*b;
    if(a<=store)
        ys;
    else
        n;
}
//hare krishna...
//hey gobindo kripa koro......
//only gobindo exists..^..


Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>
int main (){
    int n, a=0, b=0;
    char s[102], t[102];
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf(" %s %s", s, t);
        if(strcmp(s, t)<0){
            b+=3;
        }
        else if(strcmp(s, t)>0){
            a+=3;
        } 
        else{
            a++;
            b++;
        }
    }
    printf("%d %d\n", a, b);
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main(){
    ll N, G[100][100];
    cin >> N;
    for(int i = 0 ; i < N ; i++){
	for(int j = 0 ; j < N ; j++){
	    cin >> G[i][j];
	}
    }
    ll ans = 0;
    for(int i = 0 ; i < N ; i++){
	for(int j = 0 ; j < i ; j++){
	    ans += min(G[i][j],G[j][i]);
	}
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 3160
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B = map(int, readline().split())
    print(max(A+B,A-B,A*B))




if __name__ == '__main__':
    main()


Measured memory_bytes: 9156
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = (1 << 19);
const long long MNN = 2e3 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, a[MXN], cnt = 2;
multiset<int> l;

void rec(){
    vector<int> v;
    v.pb(*l.begin());
    l.erase(l.begin());
    for(int i = 1; i <= n; i++){
        vector<int> nx;
        for(int j = 0; j < v.size(); j++){
            if(l.upper_bound(v[j]) == l.end()){
                cout << "No";
                exit(0);
            }else{
                nx.pb(*l.upper_bound(v[j]));
                l.erase(l.upper_bound(v[j]));
            }
        }
        for(int j = 0; j < nx.size(); j++){
            v.pb(nx[j]);
        }
    }
}

int main () {
    ios;
    cin >> n;
    for(int i = 1; i <= (1 << n); i++){
        cin >> a[i];
        l.insert(-a[i]);
    }
    rec();
    cout << "Yes";
    return 0;
}

/*
 5
 1 1 1 1 4
 1 1 0 1 4
 
 
 
 */


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

int main() {
  int x,sum=0;
  cin >> x;
  int t=x/500;
    sum+=t*1000;
  x-=t*500;
  int p=x/5;
  	sum+=p*5;
   x-=p*5;
  cout<< sum << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

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

        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();

        int ans = 0;

        if (h>w){
            int cnt = 0;
            while (n>0){
                if (cnt<w){
                    cnt++;
                    ans++;
                    n -= h;
                }else {
                    n -= (h - w);
                    ans++;
                }
            }
        }else {
            int cnt = 0;
            while (n>0){
                if (cnt<h){
                    cnt++;
                    ans++;
                    n -= w;
                }else {
                    n -= (h - h);
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764