akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

#define yes printf("Yes\n")
#define Yes printf("YES\n")
#define no printf("No\n")
#define No printf("NO\n")

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 1e16;
const string sp = " ";
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = max(a, b);
		return true;
	}
	return false;
}
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = min(a, b);
		return true;
	}
	return false;
}

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

int n;
int a[100010];
map<int, int>mp;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		mp[a[i]] = i;
	}
	for (P p : mp) {
		cout << p.second + 1 << sp;
	}
	cend;
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,X;
  cin >> A >>  B >> C >> X;
  int count=0;
  for(int i=0;i<A+1;i++){
    for(int j=0;j<B+1;j++){
      for(int k=0;k<C+1;k++){
        if(500*i+100*j+50*k==X){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int a, b;
    cin >> a >> b;

    string po = "Possible", im = "Impossible";
    if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0){
        cout << po << endl;
    }else{
        cout << im << endl;
    }
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
  int n;
  cin >> n;
  cout << (1110 - n) << endl;
 
}


Measured memory_bytes: 256
n = int(input())
vl = list(map(int, input().split()))
vl_s = sorted(vl)

n1 = vl_s[0]
for i in range(1, n):
    n2 = vl_s[i]
    ave = (n1 + n2) / 2
    n1 = ave

print(ave)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace kyopro
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ab = Console.ReadLine().Split(' ');
            int a = int.Parse(ab[0]);
            int b = int.Parse(ab[1]);
            var kotae = new List<int>();
            kotae.Add(a + b);
            kotae.Add(a - b);
            kotae.Add(a * b);
            kotae.Sort((c,d) => d - c);
            Console.WriteLine(kotae[0]);
        }
    }
}

Measured memory_bytes: 11220
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
    a[i] = input()

row = [False] * h
col = [False] * w
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end='')
        print()


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


int main(){


    long long n, t, i;

    long long a = 0;

 
    cin >> n >> t;


    vector<long long> x(n);


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> x.at(i);

         a += t;

         }


    for( i = 0 ; i < n - 1 ; i = i + 1 ){ 

         if( x.at(i) + t >= x.at(i + 1) ) a -= x.at(i) + t - x.at(i + 1);

         }


    cout << a << endl;


    return 0;


    }

Measured memory_bytes: 1792
#if 0



#endif // 0

#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 1e5 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;
int M,N;
int p[MAXN];
vector<pair<int, pair<int,int> > > g;

int Find(int x){
    return p[x]==x ? x : p[x]=Find(p[x]);
}

int same(int u,int v){
    return Find(u)==Find(v);
}

void unite(int u,int v){
    p[Find(u)]=Find(v);
}

int Kruskal(int l,int r){
    int cnt=0;
    for(int i=1;i<=N;i++) p[i]=i;
    for(int i=l;i<r;i++){
        int u=g[i].second.first;
        int v=g[i].second.second;
        if(!same(u,v)){
            cnt++;
            unite(u,v);
        }
    }
    return cnt==N-1;
}

void work(){
    while(~scanf("%d%d",&N,&M)){
        if(N==0&&M==0) break;
        g.clear();
        for(int i=0;i<N;i++) p[i]=i;
        for(int i=0;i<M;i++){
            int u,v,w; scanf("%d%d%d",&u,&v,&w);
            g.push_back(make_pair(w,make_pair(u,v)));
        }
        sort(g.begin(),g.end());
        int ans=INF;
        int L=0,R=10000;
        int siz=g.size();
        while(L<=R){
            int mid=(L+R)>>1;
//            printf("L = %d , R = %d\n",L,R);
            int l=0,r=0,ok=0;
            while(!ok&&r<siz){
                while(r<siz&&g[r].first-g[l].first<=mid) r++;
                if(Kruskal(l,r)) ok=1;
                l++;
            }
            if(ok) ans=mid,R=mid-1;
            else L=mid+1;
        }
        printf("%d\n",ans == INF ? -1 : ans);
    }
}

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



Measured memory_bytes: 3316
#include <bits/stdc++.h>
 
typedef long long ll;
 
using namespace std;
 
vector<int> par;
 
int find(int n){
	if(par[n]==n)return n;
	else return par[n]=find(par[n]);
}
 
void uni(int a,int b){
	a=find(a);
	b=find(b);
	if(a!=b)par[b]=a;
}
 
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.in","w",stdout);
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int i,j,n,m,a,b;
    cin>>n>>m;
    par=vector<int>(n+1);
    for(i=1;i<=n;i++)par[i]=i;
    while(m--){
    	cin>>a>>b;
    	uni(a,b);
    }
    set<int> s;
    for(i=1;i<=n;i++)s.insert(find(i));
    cout<<s.size()-1;
 
 
	return 0;
}

Measured memory_bytes: 7656
#include <iostream>
#include <cmath>
#include <iomanip>

int main(int argc, char *argv[])
{
  unsigned long n, k;
  unsigned long i, j, x;
  double p;
  
  std::cin >> n >> k;

  p = 0.0;
  for (i=1; i<=n; ++i) {
    if (i >= k) {
      p += 1.0;
    } else {
      for (j=1; ; ++j) {
        x = i * pow(2.0, j);
        if (x >= k) {
          p += pow(0.5, j);
          break;
        } else {
          ;
        }
      }
    }
  }
  p /= n;

  std::cout << std::fixed << std::setprecision(12);
  std::cout << p << std::endl;
  
  return 0;
}


Measured memory_bytes: 888
X,Y=map(int,input().split())
MOD=10**9+7

def modinv(a):
	return pow(a,MOD-2,MOD)

x=(2*Y-X)//3
y=(2*X-Y)//3

if (2*Y-X)%3!=0 or (2*X-Y)%3!=0 or x<0 or y<0:
	print(0)
else:
	r=1
	n=x+y
	k=min(x,y)
	for i in range(k):
		r*=(n-i)
		r*=modinv(i+1)
		r%=MOD
	print(r)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
int main(){
    ll n, k;
    cin >> n >> k;
    n = n % k;
    ll ans = n;
    ll cur = n;
    
    set<ll> s;
    decltype(s)::iterator it = s.find(n);
    while(it == s.end()){
        s.insert(cur);
        cur = abs(cur - k);
        ans = min(ans, cur);
        it = s.find(cur);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

c = []
for _ in range(3):
    c.append(III())

for j in range(2):
    if c[0][j+1]-c[0][j]==c[1][j+1]-c[1][j]==c[2][j+1]-c[2][j]:
        pass
    else:
        print('No')
        exit()

for i in range(2):
    if c[i+1][0]-c[i][0]==c[i+1][1]-c[i][1]==c[i+1][2]-c[i][2]:
        pass
    else:
        print('No')
        exit()
    
print('Yes')

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

int n,k;
int a[100006];

int minCost(){
	int dp[n+1];
	dp[1]=0;
	for(int i=2;i<=n;i++){
		dp[i]=INT_MAX;
		for(int j=i-1;j>=1 && (i-j)<=k;j--){
			dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
		}
	}
	return dp[n];
}

int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	cout<<minCost()<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include<iostream>
using namespace std;

int main() {
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	while (1) {
		c -= b;
		if (c <= 0) {
			printf("Yes\n");
			break;
		 }
		a -= d;
		if (a <= 0) {
			printf("No\n");
			break;
		}
	}
	return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int r,g,b; cin>>r>>g>>b;
  if ((r*100+g*10+b)%4==0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int n, k;
	cin >> n >> k;
	V a(k);
	rep(i, k) {
		cin >> a[i];
	}
	V other(n,0);
	rep(i, k) {
		rep(j, k) {
			if (i != j) other[i] += a[j];
		}
	}
	int ans = 0;
	rep(i, k) {
		chmax(ans, max(0, (a[i] - 1) - other[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];
void merge(struct Card A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1].value = SENTINEL;
  R[n2].value = SENTINEL;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
    }
  }
}


void mergeSort(struct Card A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}
void quickSort(struct Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable=1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit = B[i].suit = S[0];
    A[i].value=B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);
  for(i=0;i<n;i++){
    if(A[i].suit != B[i].suit){
      stable=0;
    }
  }
  if(stable==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}

	    
	 



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

using namespace std;

int main()
{
    int n,a,s,cnt=0;
    cin>>n;
    vector<int> v,h;

    for(int i=0;i<n;i++)
    {
        cin>>a;
        v.push_back(a);
        h.push_back(a);
    }
    sort(v.begin(),v.end());

     for(int i=0;i<n;i++)
     {
        if(h[i]!=v[i])
        {
            cnt++;
        }
     }

    if(cnt==2|| cnt==0){cout<<"YES"<<endl;}
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 5555, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  cin >> N;
  cin >> S;
  int x, y, z;
  ;
}
int dp[MX][MX] = {};
void solve() {
  rrep(i, N - 1, 0) {
    rrep(j, N - 1, 0) {
      if (S[i] != S[j]) {
        dp[i][j] = 0;
      } else {
        dp[i][j] = dp[i + 1][j + 1] + 1;
      }
    }
  }
  int ans = -INF;
  rep(i, 0, N - 1) {
    rep(j, 0, N - 1) {
      if (i >= j) {
        continue;
      }
      int now = min(dp[i][j], j - i);
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 217344
#include <bits/stdc++.h>
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)


#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vec{
    double x, y;
};

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;
}

template<class T>
T min(T a, T b)
{
    if (a < b) return a;
    return b;
}

template<class T>
T max(T a, T b)
{
    if (a > b) return a;
    return b;
}

using namespace std;

int f(int n)
{
    ll a = 0;
    int cnt = 0;
    repi(x, 1, (int)sqrt(n) ) repi(y, x, (int)sqrt(n) ) repi(z, y, (int)sqrt(n) ) {
        a = (x+y+z) * (x+y+z) - x*y - y*z - z*x;
        if (a == n){
            if (x == y && y == z){
                cnt++;
            }
            else if (x == y || y == z || x == z){
                cnt += 3;
            }
            else cnt += 6;
        }
    }
    return cnt;
}

int main()
{
    int N;
    cin >> N;
    repi(i, 1, N + 1) {
        cout << f(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll A,B,C; cin >> A >> B >> C;
    ll cnt = 0;
    ll M = max({A,B,C});
    cnt += (M-A)/2; A += (M-A)/2*2;
    cnt += (M-B)/2; B += (M-B)/2*2;
    cnt += (M-C)/2; C += (M-C)/2*2;
    ll cnt2 = 0;
    if(M != A) cnt2++;
    if(M != B) cnt2++;
    if(M != C) cnt2++;
    
    if(cnt2 == 0) cout << cnt << endl;
    else if(cnt2 == 1) cout << cnt + 2 << endl;
    else cout << cnt + 1 <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int k;
    cin >> k;
    queue<ll> que;
    rep(i, 1, 10) {
        que.push(i);
    }
    int cnt = 1;
    while (1) {
        ll x = que.front();
        que.pop();
        if (cnt == k) {
            cout << x << endl;
            return 0;
        }
        int mod = x % 10;
        if (mod != 0) que.push(x * 10 + mod - 1);
        que.push(x * 10 + mod);
        if (mod != 9) que.push(x * 10 + mod + 1);
        cnt++;
    }
    return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		int N = Integer.parseInt(tokenizer.nextToken());
		int R = Integer.parseInt(tokenizer.nextToken());
		int L = Integer.parseInt(tokenizer.nextToken());
		int[] po = new int[N];
		int[] c = new int[N];
		PriorityQueue<Pair> pq = new PriorityQueue<Pair>();
		for (int i = 0; i < N; i++) {
			pq.offer(new Pair(i, 0));
		}
		int now = 0;
		int index = 0;

		for (int i = 0; i < R; i++) {
			tokenizer = new StringTokenizer(reader.readLine());
			int d = Integer.parseInt(tokenizer.nextToken()) - 1;
			int t = Integer.parseInt(tokenizer.nextToken());
			int x = Integer.parseInt(tokenizer.nextToken());
			c[index] += t - now;
			po[d] += x;
			pq.offer(new Pair(d, po[d]));
			while (true) {
				Pair p = pq.peek();
				if (po[p.id] == p.point) {
					index = p.id;
					break;
				}
				pq.poll();
			}

			now = t;
		}
		c[index] += L - now;
		int ans = 0;
		int max = 0;
		for (int i = 0; i < N; i++) {
			if (c[i] > max) {
				max = c[i];
				ans = i;
			}
		}
		System.out.println(ans + 1);

	}

	class Pair implements Comparable<Pair> {
		int id, point;

		public Pair(int id, int point) {
			super();
			this.id = id;
			this.point = point;
		}

		@Override
		public String toString() {
			return "Pair [id=" + id + ", point=" + point + "]";
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + id;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Pair other = (Pair) obj;
			if (!getOuterType().equals(other.getOuterType()))
				return false;
			if (id != other.id)
				return false;
			return true;
		}

		@Override
		public int compareTo(Pair o) {
			if (this.point == o.point)
				return this.id - o.id;
			return o.point - this.point;
		}

		private Main getOuterType() {
			return Main.this;
		}

	}
}

Measured memory_bytes: 110172
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


vector<P> between;
vector<int> ans;

int get_dist(int a, int b){
    cout << "? " << a << " " << b << endl;
    cout.flush();
    int res;
    cin >> res;
    return res;
}

void answer(){
    cout << "!";
    for(auto n:ans)cout << " " << n;
    cout << endl;
    cout.flush();
}

int dist[210800];

int main(){
    int n, s, t;
    cin >> n >> s >> t;
    Int shortest = get_dist(s, t);
    dist[s] = 0;
    dist[t] = shortest;
    for(int i = 1;i <= n;i++){
        if(i == s || i == t)continue;
        dist[i] = get_dist(s, i);
        int r = get_dist(i, t);
        if(dist[i] + r != shortest)continue;
        between.push_back(P(dist[i], i));
        
    }
    sort(between.begin(), between.end());
    between.push_back(P(shortest, t));

    ans.push_back(s);
    int now = 0;
    while(ans.back() != t){
        int nxt = between[now].second;
        if(get_dist(ans.back(), nxt) == dist[nxt] - dist[ans.back()]){
            ans.push_back(nxt);
        }
        now++;
    }
    answer();
    return 0;
}


Measured memory_bytes: 4652
#include<stdio.h>

int main(void)
{
  int h,n,i;
  scanf("%d%d",&h,&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    h = h - a[i];
  }
  if(h<=0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    X=int(input())
    n=X//100
    m=X%100
    print(1 if -(-m//5)<=n else 0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = unsigned long long;

int main() {

	ll L, R;
	int num = 10003;

	cin >> L >> R;

	if (L<2019&&R>=2019){
		cout << "0" << endl;
		return 0;
	}
	for (ll i = L; i < R; i++) {
		for (ll j = i + 1; j <= R; j++) {
			if ((j * i) % 2019 == 0) {
				cout << "0" << endl;
				return 0;
			}
			if ((j * i) % 2019 < num)num = (j * i) % 2019;
		}
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int selectionSort(int A[],int N){
    int i,j,t,sw = 0,minj;
    for(i=0;i<N;i++){
        minj=i;
        for(j=i;j<N;j++){
            if(A[j]<A[minj]) minj = j;
        }
        t = A[i]; A[i]=A[minj]; A[minj]=t;
        if(i != minj) sw++;
    }
    return sw;
}

int main(){
    int A[100],N,i,sw;
    
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    
    sw = selectionSort(A,N);
    
    for(i=0;i<N;i++){
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",sw);
    
    return 0;
}


Measured memory_bytes: 2708
// B - Counting Roads
#include <bits/stdc++.h>
using namespace std;
int N, M;

int solve();

vector<int> a, b,c;
int main(){
  cin >> N >> M;
  a = vector<int>(M);
  b = vector<int>(M);
  for(int i = 0; i<M; i++){
    cin >> a.at(i) >> b.at(i);
  }
  solve();
}

int solve(){
  c = vector<int>(N+1, 0);
  // cout << "check" << endl;
  for(int i=0; i<M; i++){
    // cout << "check a "  << a.at(i)<<endl;
    c.at(a.at(i))++;
    // cout << "check b "  << b.at(i)<<endl;
    c.at(b.at(i))++;
  }
  // cout << "end";


  for(int i=1; i<N+1; i++){
    cout << c.at(i) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import std.stdio;alias L=long;L M=998244353,n,z,r;L[]U;L[L]R;void main(){readf("%d\n",&n);foreach(c;readln[0..n])U~=c-'0';L h(L m){L f;foreach(u;U[0..m])f=f*2%M+u;foreach(i,u;U)if(i/m&1^U[i%m]^u)return f+u;return f+1;}foreach(m;1..n+1)if(n%m<n/m%2){r=h(m);foreach(l,q;R)r+=m%l?0:M-q;z+=r*m*2%M;R[m]=r%M;}writeln(z%M);}

Measured memory_bytes: 4092
n = int(input())
r = [tuple(map(int, input().split())) for i in range(n)]
b = [tuple(map(int, input().split())) for i in range(n)]
r.sort(key=lambda x: x[1], reverse=True) # yの降順
b.sort(key=lambda x: x[0])
used = [0]*n

ans = 0
for i in range(n):
    bx,by = b[i]
    j = 0
    while j < n:
        rx,ry = r[j]
        if rx < bx and ry < by and used[j] == 0:
            ans += 1
            used[j] = 1
            break
        j += 1
print(ans)


Measured memory_bytes: 9212
#include<stdio.h>

int main(){
    int D;

    scanf("%d", &D);
    if(D==25){
        printf("Christmas");
    }
    if(D==24){
        printf("Christmas Eve");
    }
    if(D==23){
        printf("Christmas Eve Eve");
    }
    if(D==22){
        printf("Christmas Eve Eve Eve");
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <climits>

using namespace std;

#define LIM 1000001

long int n, tet[501] = {0}, dp[LIM] = {0}, dp_odd[LIM] = {0};

void solve()
{
	for(int j = 0; j < LIM; j++)
	{
		for(int i = 1; j+tet[i] < LIM; i++)
		{
			if( dp[j+tet[i]] > dp[j] + 1 )
				dp[j+tet[i]] = dp[j] + 1;
		}
	}

	for(int j = 0; j < LIM; j++)
	{
		for(int i = 1; j+tet[i] < LIM; i++)
		{
			if( dp_odd[j+tet[i]] > dp_odd[j] + 1 && tet[i] % 2 == 1)
				dp_odd[j+tet[i]] = dp_odd[j] + 1;
		}
	}

	return;
}

int main()
{
	for( int i = 1; i < 501; i++)
		tet[i] = i*(i+1)*(i+2)/6;

	for( int i = 1; i < LIM; i++)
	{
		dp[i] = INT_MAX;
		dp_odd[i] = INT_MAX;
	}

	solve();

	while( cin >> n, n)
	{
		cout << dp[n] << " ";
		cout << dp_odd[n] << endl;
	}

	return 0;
}

Measured memory_bytes: 8560
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
bc = []
for i in range(M):
    bc.append(list(map(int,input().split())))

bc = sorted(bc,key=lambda x : -x[1])
i = 0
for b,c in bc:
    for j in range(i,min(N,i+b)):
        if A[j] < c:
            A[j] = c
    i += b
print(sum(A))


Measured memory_bytes: 83736
def main():
    import sys 
    input = sys.stdin.readline
    n = int(input())
    l = list(map(int,input().split()))
    
    
    mod = 10**9+7
    ans = 0
    ni = 1
    for j in range(60):
        x = 0
        for i in l:
            if (i >> j) & 1:
                x += 1
        now = x*(n-x)*ni%mod
        ans = (ans+now)%mod
        ni = (ni*2)%mod

    print(ans%mod)
if __name__ == "__main__":
    main()


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

int main() { 
  int n,x,y=0;
  long long sum=0;

  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  rep(i,n){for(int j=i+1;j<n;j++){sum+=a[i]*a[j];}}

  
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
using namespace std;

int main(){
    int n,m; cin>>n>>m;
    int a=-1e9,b=1e9;
    for(int i=0;i<m;i++){
        int l,r; cin>>l>>r;
        a=max(l,a);
        b=min(r,b);
    }
    if(b>=a) cout<<b-a+1<<endl;
    else cout<<0<<endl;
}   

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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> h(n);
    for(int i = 0; i < n; i++){
        std::cin >> h[i];
    }

    // 右から見ていく
    for(int i = n - 1; i >= 1; i--){
        if(h[i - 1] > h[i]){
            h[i - 1]--;
            if(h[i - 1] > h[i]){
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "Yes" << std::endl;
    return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, R;
    cin >> N >> R;
    if (N >= 10)
        cout << R << endl;
    else
        cout << R + 100 * (10 - N) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[200005];
int n;
int main()
{
	scanf("%s",s);
	n=strlen(s);
	for(int i=0;i<n;i++)if(s[i]=='?')s[i]='D';
	printf("%s",s);
	return 0;
}

Measured memory_bytes: 1916
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
L = sorted(LI())


left = 0
right = n
while left <= right:
    mid = (left + right) // 2
    ret = sum(L[:mid + 1])
    i = mid + 1
    flag = False
    while ret * 2 >= L[i]:
        ret += L[i]
        i += 1
        if i >= n:
            flag = True
            break
    if flag:
        right = mid - 1
    else:
        left = mid + 1



if flag:
    print(n - mid)
else:
    print(n - mid - 1)

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

 #define waru 1000000007
long long N, M;



int main(){
    unsigned long long ans = 2;
    cin >> N >> M;
    if(abs(N-M) >1){
        cout << 0 <<endl;
        return 0;
    }else{
        if(N != M ){
            ans = 1;
        }
        for(int i=1; i<N+1; i++){
            ans *= i;
            ans %= waru;
        }

        for(int i=1; i<M+1; i++){
            ans *= i;
            ans %= waru;
        }
        cout << ans << endl;
        
    }

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
	int a, b;
	cin >> a >> b;

	if (a >= 13)	cout << b << endl;
	else if (a < 13 && a >= 6)	cout << b / 2 << endl;
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = input()
B = input()
C = input()

ans = 0 
for i in range(N):
  if A[i] == B[i] and B[i] == C[i]:
    ans += 0
  elif A[i] == B[i] or B[i] == C[i] or A[i] == C[i]:
    ans += 1
  else:
    ans += 2
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=10005;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
//inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,k,len,l[MAXN];string s,t,ans;char c;
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),k=read(),cin>>s,n=s.size();c='z';
	Red(i,n-1,0)s.push_back(s[i]),c=min(c,s[i]);
	if(k>=15){Rep(i,1,n)putchar(c);return 0;}
	if(k==1){
		ans=s.substr(0,n);
		Rep(i,1,n)ans=min(ans,s.substr(i,n));
		cout<<ans;return 0;
	}int Mx=0;k--;
	Rep(i,0,2*n-1)Mx=max(Mx,i==0?l[i]=1:s[i]==c?l[i]=l[i-1]+1:0);
	if(Mx<<k>=n){Rep(i,1,n)putchar(c);return 0;}
	int len=Mx<<k,opt=0;
	Rep(i,0,n+Mx-1)if(l[i]==Mx){
		t=s.substr(i-Mx+1,n);
		if(!opt)ans=t,opt=1;else ans=min(ans,t);
	}Rep(i,1,Mx<<k)putchar(c);ans.resize(n);
	Rep(i,len,n-1)putchar(ans[i-len+Mx]);
	return 0;
}




Measured memory_bytes: 3684
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
//#include <intrin.h>
//#include <chrono>
//#include <random>
//#include <unordered_map>

using namespace std;

typedef long long ll;

void solve() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (i % 2 != a % 2 && a % 2)
			ans++;
	}
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

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

int selectionSort(int A[], int N){
    int sw = 0;
    int minv;
    bool flag;
    
    for(int i = 0; i < N-1; i++){
        minv = i;
        flag = 0;
        for(int j = i+1; j < N; j++){
            if(A[minv] > A[j]){
                minv = j;
                flag = 1;
            }
        }
        if(flag){
            swap(A[i],A[minv]);
            sw++;
        }
    }
    
    return sw;
}

int main(){
    int A[100], N, sw;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    
    sw = selectionSort(A, N);
    
    for(int i = 0; i < N; i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;
    return 0;
}

Measured memory_bytes: 1160
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll N;cin>>N;
    ll h[110000];REP(i,N)cin>>h[i];
    ll dp[110000];REP(i,110000)dp[i]=INF;dp[0]=0;
    REP(i,N){
        dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
        dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    }
    cout<<dp[N-1]<<"\n";
}

Measured memory_bytes: 5212
#include<stdio.h>
int partition(int A[],int p,int r){
    int x,i,j,t;
    x=A[r];
    i=p-1;
    for(j=p;j<=r-1;j++){
        if(A[j]<=x){
            i++;
            t=A[i];
            A[i]=A[j];
            A[j]=t;
        }
    }
    t=A[i+1];
    A[i+1]=A[r];
    A[r]=t;
    return i+1;
}

int main(){
    int n;
    scanf("%d",&n);
    int A[n];
    int i;
    for(i=0;i<=n-1;i++)scanf("%d",&A[i]);
    int q;
    q=partition(A,0,n-1);
    for(i=0;i<=n-1;i++){
        if(i)printf(" ");
        if(i==q)printf("[");
        printf("%d",A[i]);
        if(i==q)printf("]");
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 996
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<iomanip>
#include<limits.h>
#include<climits>
#include<queue>
using namespace std;
const int M=1e3*2;
char s[M][M];
int n,m;
int s_x,s_y,t_x,t_y,ans[M][M];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
struct node{
	int x,y;
};
void bfs(){
	deque<node> q;
	node a,b;
	a.x=s_x;
	a.y=s_y;
	ans[s_x][s_y]=0;
	q.push_back(a);
	while(q.size()){
		a=q.front();
		q.pop_front();
		if(a.x==t_x&&a.y==t_y){
			printf("%d",ans[t_x][t_y]);
			return;
		}
		for(int i=0;i<4;i++){
			int nx=a.x+dx[i];
			int ny=a.y+dy[i];
			if(nx<=0||nx>n||ny<=0||ny>m) continue;
				if(s[nx][ny]=='.'){
					if(ans[nx][ny]>ans[a.x][a.y]){
						b.x=nx;
						b.y=ny;
						ans[nx][ny]=ans[a.x][a.y];
						q.push_front(b);
					}	
				}
		}
		for(int i=a.x-2;i<=a.x+2;i++){
			for(int j=a.y-2;j<=a.y+2;j++){
				int nx=i;
				int ny=j;
				if(nx<=0||nx>n||ny<=0||ny>m) continue;
				if(s[nx][ny]=='.'){
					if(ans[nx][ny]>ans[a.x][a.y]+1){
						b.x=nx;
						b.y=ny;
						ans[nx][ny]=ans[a.x][a.y]+1;
						q.push_back(b);
					}	
				}
			}
		}
	}	
	printf("-1");
	return ;
}
int main(){
		memset(ans,0x3f,sizeof(ans));
		scanf("%d %d",&n,&m);
		scanf("%d %d",&s_x,&s_y);
		scanf("%d %d",&t_x,&t_y);
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				cin>>s[i][j];
			}
		}
	//	printf("%c %c\n",s[1][2],s[1][3]);
		bfs();
	
	
	return 0;
}



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

int main() {
  int n, m, M[100][100], TATE[100], YOKO[100];
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      M[i][j] =0;
    }
    TATE[i]=0; YOKO[i]=0;
  }
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> M[i][j];
    }
  }

  int sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      YOKO[i] += M[i][j];
    }
    sum += YOKO[i];
  }

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      TATE[i] += M[j][i];
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << M[i][j] << " ";
      if (j==m-1) {cout << YOKO[i] << endl;}
    }
  }
  for (int j = 0; j < m; j++) {
    cout << TATE[j] << " ";
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3108
h, w = map(int, input().split())
ma = []
id = []
for i in range(h):
    ma.append(list(map(int, input().split())))
for i in range(h):
    for j in range(w):
        if ma[i][j] % 2 == 1:
            if i != h - 1 and ma[i + 1][j] % 2 == 1:
                ma[i + 1][j] += 1
                id.append([i+1, j+1, i + 2, j+1])
            elif j != w - 1 and ma[i][j+1] % 2 == 1:
                ma[i][j + 1] += 1
                id.append([i+1, j+1, i+1, j + 2])
            elif i != h - 1:
                ma[i + 1][j] += 1
                id.append([i+1, j+1, i + 2, j+1])
            elif j != w - 1:
                ma[i][j + 1] += 1
                id.append([i+1, j+1, i+1, j + 2])
print(len(id))
for i in range(len(id)):
    print(" ".join(map(str, id[i])))

Measured memory_bytes: 29768
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		int n, q;
		char[] input;
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		q = scanner.nextInt();
		scanner.nextLine();
		input = scanner.nextLine()
					   .toCharArray();
		int[][] ranges = new int[q][2];
		for (int i = 0; i < q; i++)
		{
			ranges[i][0] = scanner.nextInt();
			ranges[i][1] = scanner.nextInt();
		}
		int[] temp = new int[n];
		int t = 0;
		for (int i = 0; i < n - 1; i++)
		{
			if (input[i] == 'A' && input[i + 1] == 'C')
			{
				t++;
			}
			temp[i + 1] = t;
		}
		for (int[] range : ranges)
		{
			System.out.println(temp[range[1] - 1] - temp[range[0] - 1]);
		}
	}
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

long long N, M, K, H, W, L, R;

int main() {
  cin >> N >> K;
  long long int ans = 0;
  cin >> M;
  ans = abs(M - K);
  for (int i = 1; i < N; i++) {
    cin >> M;
    ans = gcd(ans, abs(M - K));
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    string s = to_string(n);
    for (int i=0; i<s.size(); i++) {
        if (s[i] == '1')
            s[i] = '9';
        else
            s[i] = '1';
    }
    int num = stoi(s);
    cout << num << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;


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

  char str[ n ][ l + 1 ];

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

  for( int i = 0; i < n - 1; i++ ) {
    for( int j = n - 1; j > i; j-- ) {
      if( strcmp( str[ j ], str[ j - 1 ] ) < 0 ) {
        char buf[ l + 1 ];
        sprintf( buf, "%s", str[ j ] );
        sprintf( str[ j ], "%s", str[ j - 1 ] );
        sprintf( str[ j - 1 ], "%s", buf );
      }
    }
  }

  for( int i = 0; i < n; i++ ) {
    cout << str[ i ];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 888
// Created by sz
#include<bits/stdc++.h>
using namespace std;


int main() {
//    freopen("./input.txt", "r", stdin);
    int D;
    scanf("%d", &D);
    int num = 25 -D;
    printf("Christmas");
    for (int i = 0; i< num; i++){
        printf(" Eve");
    }
    printf("\n");
    return 0;
}



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



int main()
{
     
   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,i,j;
    cin>>n;
    string s;
    cin>>s;
    vector <ll> r,g,b;
    for(i=0;i<n;i++)
    {
        if(s[i]=='R')
            r.push_back(i);
        else if(s[i]=='G')
            g.push_back(i);
        else
            b.push_back(i);

    }
    ll count = 0;
    r.push_back(100000);
    g.push_back(100000);
    b.push_back(100000);

    /*for(auto a:r)
        cout<<a<<' ';
    cout<<endl;

    for(auto a:g)
        cout<<a<<' ';
    cout<<endl;

    for(auto a:b)
        cout<<a<<' ';
    cout<<endl;*/

    ll x1,x2;
    for(i=0;i<r.size()-1;i++)
    {
        for(j=0;j<g.size()-1;j++)
        {
            x1 = r[i];
            x2 = g[j];
            ll nind = abs(x1-x2) + max(x1,x2);

            ll lim2 = lower_bound(b.begin(),b.end(),max(x1,x2)) - b.begin();
            ll lim1 = lower_bound(b.begin(),b.end(),nind) - b.begin();
            //cout<<lim1<<endl;
            count = count + (lim1-lim2);
            if(b[lim1]==nind)
            {
                count+=(b.size() - lim1 - 2);
            }
            else
                count+=(b.size() - lim1 - 1);   
            //cout<<nind<<" "<<count<<" "<<lim1<<endl;

        }
    }
    for(i=0;i<r.size()-1;i++)
    {
        for(j=0;j<b.size()-1;j++)
        {
            x1 = r[i];
            x2 = b[j];
            
            ll nind = abs(x1-x2) + max(x1,x2);
            ll lim2 = lower_bound(g.begin(),g.end(),max(x1,x2)) - g.begin();
            ll lim1 = lower_bound(g.begin(),g.end(),nind) - g.begin();
            //cout<<lim1<<endl;
            count +=(lim1-lim2);
            
            if(g[lim1]==nind)
            {
                count+=(g.size() - lim1 - 2);
            }
            else
                count+=(g.size() - lim1 - 1);   

        }
    }
    for(i=0;i<g.size()-1;i++)
    {
        for(j=0;j<b.size()-1;j++)
        {
            x1 = g[i];
            x2 = b[j];
            
            ll nind = abs(x1-x2) + max(x1,x2);
            ll lim1 = lower_bound(r.begin(),r.end(),nind) - r.begin();
            ll lim2 = lower_bound(r.begin(),r.end(),max(x1,x2)) - r.begin();
            //cout<<lim1<<endl;
            
            count+=(lim1-lim2);
            
            if(r[lim1]==nind)
            {
                count+=(r.size() - lim1 - 2);
            }
            else
                count+=(r.size() - lim1 - 1);   

        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3688
a, b, x = map(int, input().strip().split())


def func(num1, num2, divide_num):
    ans = num2 // divide_num - (num1 - 1) // divide_num
    # if num1 % divide_num == 0:
    #     ans += 1

    print(ans)


func(num1=a, num2=b, divide_num=x)


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

template<typename T>
class tRMQ {
  vector<T> data;
  T unit;

public:
  static const long long INF = 100000000000;
  int n;
  function<T(const T &, const T &)> f;

  tRMQ(int _, T u, function<T(T, T)> bi) {
    unit = u;
    f = bi;
    n = 1;
    while (n < _) {
      n <<= 1;
    }
    data.resize(n * 4);
    for (int i = 0; i < n * 4; i++)
      data[i] = unit;
  }

  void update(int index, T val) {
    int i = index + n - 1;
    data[i] = val;
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  // [a, b)
  T query(int a, int b, int k, int l, int r) {
    if (a < 0 || r <= a || b <= l)
      return unit;
    if (a <= l && r <= b)
      return data[k];
    else
      return f(query(a, b, k * 2 + 1, l, (l + r) / 2),
               query(a, b, k * 2 + 2, (r + l) / 2, r));
  }

  T query(int a, int b) { return query(a, b, 0, 0, n); }
};

tRMQ<ll> minrmq(int n) {
  return tRMQ<ll>(n, 10000000000000000LL, [](ll r, ll l) { return min(l, r); });
}

tRMQ<ll> maxrmq(int n) {
  return tRMQ<ll>(n, -10000000000000000LL,
                  [](ll r, ll l) { return max(l, r); });
}

tRMQ<ll> sumrmq(int n) {
  return tRMQ<ll>(n, 0, [](ll l, ll r) { return l + r; });
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m, x;
  cin >> n >> m >> x;
  auto r = sumrmq(n);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    r.update(a - 1, 1);
  }
  cout << min(r.query(0, x), r.query(x, n)) << endl;
  return 0;
}


Measured memory_bytes: 256