akhauriyash/Code-Regression huggingface dataset:
X,N = map(int, input().split())
if N != 0:
  A = list(map(int, input().split()))
else:
  A =[]
B =[]
for i in range(N):
  B.append(A[i]-X)
  B = sorted(B)
for i in range(100):
  if -i not in B:
    print(X-i)
    break
  elif i not in B:
    print(X+i)
    break
    
  
  
  
  

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000099;
const int OO = 0x3f3f3f3f;

int n, h[MAX];
int dp[MAX], k;

int main()
{
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> h[i];
	memset(dp, 63, sizeof(dp));
	dp[0] = 0;
	for(int i = 0; i < n; i++)
		for(int j = 1; j <= k; j++)
			if(i - j >= 0)
				dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
	cout << dp[n - 1] << '\n';

	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n;
    cin>>n;
    vector<double> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
        v[i]=1/v[i];
    }
    double sum=0.0;
    for(int i=0;i<n;i++){
        sum+=v[i];
    }
    sum=1/sum;
    printf("%.12lf\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FORI(i,n) for(int i=0;i<=n;i++)
#define FOR(i,k,n) for(int i=k;i<n;i++)
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define F first
#define S second
#define reset(x) memset(x,0,sizeof(x))
#define vii vector<pii>
#define pll pair<ll,ll>
#define vll vector<pll>
#define MOD 1000000007

const int infinity = 1e9 + 5;


int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	std::vector<int> dp(3);
	for (int i = 0; i < n; ++i)
	{
		std::vector<int> new_dp(3,0);
		std::vector<int> c(3);
		for (int i = 0; i < 3; ++i)
		{
			cin>>c[i];
		}
		for (int i = 0; i < 3; ++i)
		{
			for(int j=0;j<3;j++){
				if(i!=j){
					new_dp[j] = max(new_dp[j],dp[i]+c[j]);
				}
			}
		}
		dp = new_dp;
	}
	cout<<max(dp[0],max(dp[1],dp[2]));
	return 0;
}

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

int main() {
    ll N;
    cin >> N;
    vector<ll> B(N - 1);
    for (ll i = 0; i < N - 1; i++) {
        cin >> B[i];
    }

    ll ans = B.front() + B.back();
    for (ll i = 1; i < N - 1; i++) {
        ans += min(B[i - 1], B[i]);
    }

    cout << ans << endl;
}

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

int ketasum(int n){
  int sum = 0;
  while (n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int a, b;
  cin >> a >> b;
  int count = 0;
  for (int i = a; i <= b; i++){
    int five = i / 10000;
    int four = (i % 10000) / 1000;
    int two = (i % 100) / 10;
    int one = (i % 10);
    if (five == one && four == two) count++;
  }

  cout << count << endl;
}


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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};


ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b,ll r)
{
    a%=r;
    b%=r;
    return (a+b)%r;
}
ll mulmod(ll a,ll b,ll r)
{
    a%=r;
    b%=r;
    return (a*b)%r;
}
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/


int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
string s,t; cin>>s>>t;
ll n = s.size(),m= t.size();
ll ans = LLONG_MAX;
for(ll i=0;i+m-1<n;i++)
{
    ll cnt = 0;
    rep(j,0,m)
    {
        if(s[i+j]!=t[j])cnt++;
    }
    ans = min(ans,cnt);
}
cout<<ans<<"\n";
return 0;
}
/*
1
4
1 2
2 3
3 4
2
2 2
*/


Measured memory_bytes: 3664
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>
#include<bitset>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const double EPS = 0.000000000001;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

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


	sort(A.begin(), A.end());
	int ans = 0;

	if (N == 1) {
		cout << 1;
		return 0;
	}

	for (int i = 0; i < N - 1; i++) {
		if (A[i] == A[i + 1]) {
			int count = 0;
			for (int j = i; j < N; j++) {
				if (A[j] == A[i]) {
					count++;
					if (j == N - 1) {
						ans += count % 2;
						i = j - 1;
						break;
					}
				}
				else {
					ans += count % 2;
					i = j - 1;
					if (j == N - 1) {
						ans++;
					}
					break;
				}
			}
		}
		else {
			ans++;
			if (i == N - 2) {
				ans++;
			}
		}
	}

	cout << ans;


}

Measured memory_bytes: 1024
#include <stdio.h>

main(){
   int x, y, c;

   scanf("%d %d", &x, &y);


   do {
   if (x < y){
      c = x;
      x = y;
      y = c;
   }

   if (x % y == 0){
      break;
   }

      x = x % y;

   } while(x % y != 0);

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

   return 0;
}


Measured memory_bytes: 2124
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) std::cin>>(P)
#define IN2(P1,P2) std::cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUT(P) std::cout<<P<<std::endl
#define OUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define ALL(C) (C).begin(),(C).end()
using namespace std;
using namespace __gnu_pbds;
int K,N;
int A[100010];
int i;
inline void solve(){
  IN2(N,K);
  INS(i,N,A);
  OUT((N+K-3)/(K-1));
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt();
		if(b*2>=a)
			System.out.println(0);
		else if(b*2<a)
			System.out.println(a-b*2);
	}
}


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

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

   int h[n];
   for(int i=0;i<n;i++) cin>>h[i];

   int dp[n];
   dp[0] = 0;

   for(int i=1;i<n;i++) {
       dp[i] = INT_MAX;

       for(int j=i-1;j>=i-k && j>=0; j--)
          dp[i] = min(dp[i], abs(h[i] - h[j]) + dp[j]);
   }

   cout<<dp[n-1];
   
 return 0;   
}

Measured memory_bytes: 4340
N = int(input())
A = [int(zz) for zz in input().split()]

A = [0] + A + [0]

p = 0
for i in range(1,N+2):
    p += abs(A[i-1]-A[i])

for i in range(1,N+1):
    if A[i-1] <= A[i] <= A[i+1] or A[i-1] >= A[i] >= A[i+1]:
        print(p)
    else:
        q = min(abs(A[i-1]-A[i]),abs(A[i]-A[i+1]))
        print(p-2*q)


Measured memory_bytes: 14048
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		10000									// 最大配列数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 配列数取得
	int liACnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &liACnt);

	// 配列取得
	int li1Array[D_ARRAY_MAX];
	for (i = 0; i < liACnt; i++) {
#ifdef D_TEST
		fscanf(szpFpT, "%d", &li1Array[i]);
#else
		fscanf(stdin, "%d", &li1Array[i]);
#endif
	}
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif

	// 割る回数取得
	int liDCnt = 0;
	for (i = 0; i < liACnt; i++) {
		while (li1Array[i] % 2 == 0) {
			li1Array[i] /= 2;
			liDCnt++;
		}
	}

	// 結果セット
	sprintf(lc1Out, "%d\n", liDCnt);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



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

using namespace std;

int main() {
  int N;
  cin >> N;
  for (int a = 1; a < 10; a++) {
    for (int b = 1; b < 10; b++) {
      if (a * b == N) {
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<vector<vector<vector<int>>>> vvvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<vector<vector<vector<ll>>>> vvvvl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;

int X;

int main() {
  cin >> X;
  int a = X % 100; //下二桁
  int count = 0;
  while(true){
    if(a == 0){
      break;
    }
    for(int i = 0; i < 5; i++){
      if(a - (5 - i) >= 0){
        a -=(5 - i);
        count ++;
        break;
      }
    }
  }
  if(count == 0){
    if(X >= 100){
      cout << 1 <<endl;
      return 0;
    }
    else{
      cout << 0 <<endl;
      return 0;
    }
  }
  if(X/count >= 100){
    cout << 1 <<endl;
  }
  else{
    cout << 0 <<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	long long n, k;
	cin >> n >> k;

	long long ans = 0;
	if (k == 0) {
		ans = n * n;
	} else {
		for (int b = k + 1; b <= n; b++) {
			ans += n / b * (b - k);
			ans += max(0LL, n % b - (k - 1));
	// printf("b %2d: add1 %3d, add2 %3d, ans %lld\n", b, n / b * (b - k), max(0, n % b - (k - 1)), ans);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define F first
#define S second
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
long long INF = 1e9;

ll dp[100010];
ll a[100010];
int main(){
   ll n,m;cin >> n >> m;
    rep(m){
        int x;cin >> x;
        a[x] = 1;
    }
    dp[0] = 1;
    if(a[1] == 1) dp[1] = 0;else dp[1] = 1;
    for(int i = 1;i <= n;i++){
        if(a[i] == 1) dp[i] = 0;
        else dp[i] =( dp[i-1] + dp[i-2]) % mod;
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
    char c1,a1[101];
    int a,b,d,i,l;
    gets(a1);
    l=strlen(a1);

    for(c1='a';c1<=122;c1++)
    {
        d=0;
        for(i=0;i<l;i++)
        {
            if (c1==a1[i])
                d=d+1;
        }
        if(d%2 != 0)
        {
            printf("No");
            break;
        }
    }
    if(d%2 ==0)
        printf("Yes");
    return 0;
}


Measured memory_bytes: 128
def array_integer(a)
	0.upto(a.count) {|x|
		a[x] = a[x].to_i
	}
	return a
end

eof = false

until eof do
	h,w = array_integer(STDIN.gets.split(" "))
	
	if h == 0 && w == 0 then
		return
	end

	1.upto(h) {
		1.upto(w) {
			print "#"
		}
		print "\n"
	}

	print "\n"
end



Measured memory_bytes: 6836
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int h,w,k;
    cin>>h>>w>>k;
    char c[h][w];
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            cin>>c[i][j];
        }
    }

    int ans=0;
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            int black=0;

            for(int p=0;p<h;p++){
                for(int q=0;q<w;q++){
                    if(((i>>p)&1)==0&&((j>>q)&1)==0&&c[p][q]=='#') black++;
                }
            }
            if(black==k) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
#pragma region template

#include <bits/stdc++.h>

using namespace std;

// -type-
using str = string;
using ll = int64_t;
using pii = pair<int64_t, int64_t>;
using pis = pair<int64_t, str>;
using psi = pair<str, int64_t>;
using vi = vector<int64_t>;
using vvi = vector<vector<int64_t>>;
using vs = vector<str>;
using vpii = vector<pair<int64_t, int64_t>>;


//--const
constexpr ll MOD = 1000000007;

constexpr int INFI = int(0x3f000000);
constexpr ll INF = ll(0x3f0000003f000000);
constexpr double EPS = 1e-9;
constexpr int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
              dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// clang-format off
//--define
#define _overload3(_1, _2, _3, name, ...) name
#define   rep(...) _overload3(__VA_ARGS__,  _rep3,  _rep2,)(__VA_ARGS__)
#define  repc(...) _overload3(__VA_ARGS__, _repc3, _repc2,)(__VA_ARGS__)
#define  repr(...) _overload3(__VA_ARGS__, _repr3, _repr2,)(__VA_ARGS__)
#define repcr(...) _overload3(__VA_ARGS__,_repcr3,_repcr2,)(__VA_ARGS__)
#define _rep(i,k,n) for(int i=(k)   , i##_len=(n); i < i##_len; ++i)
#define   _rep2(i  ,n) _rep(i,0,n) 
#define   _rep3(i,k,n) _rep(i,k,n)
#define  _repc2(i  ,n) _rep(i,1,n+1)
#define  _repc3(i,k,n) _rep(i,k,n+1) 
#define _repr(i,k,n) for(int i=(n-1), i##_len=(k); i >=i##_len; --i)
#define  _repr2(i  ,n) _repr(i,0,n)
#define  _repr3(i,k,n) _repr(i,k,n) 
#define _repcr2(i  ,n) _repr(i,1,n+1)
#define _repcr3(i,k,n) _repr(i,k,n+1)
//rep-macro   normal, close, reverse, close+reverse

#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(...) debug_args(__LINE__, __VA_ARGS__)
#define pow2(n) (1LL<<(n))


//--functions
inline bool in(string s, string c) {return (s.find(c) != string::npos);}
inline bool in(string s,   char c) {return (s.find(c) != string::npos);}

template <class T> T udiv(T a, T b) {return (a + b - 1) / b;}
template <class T> T rdiv(T a, T b) {return (a + b / 2) / b;}

void print_args(ostream&) {}
template <class S, class... T>
void print_args(ostream& out,const S& a,const T&... args) {
    out << ' ' << a;
    print_args(out, args...);
}
template <class S, class... T>
void print(const S& a, const T&... args) {
    std::cout << a;
    print_args(std::cout, args...);
    std::cout << '\n';
}
template <class S, class... T>
void debug_args(const S& a, const T&... args) {
    std::cout << "(L:" << std::setw(3) << a << ")";
    print_args(std::cout, args...);
    std::cout << '\n';
}
// clang-format on

struct setup_main {
    setup_main() {
        std::cin.tie(0);
        std::ios::sync_with_stdio(0);
        std::cout << fixed << setprecision(15);
    }
} setup_main_;

ll ans(0);
#pragma endregion

void solve(long long N) {
    print((N + 2 - 1) / 2);
    // print(ans);
}
signed main() {
    long long N;
    scanf("%lld", &N);
    solve(N);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<long long> c(n-1, 0);
    vector<long long> s(n-1, 0);
    vector<long long> f(n-1, 0);
    for(int i = 0; i < n-1; ++i) {
        cin >> c.at(i) >> s.at(i) >> f.at(i);
    }

    vector<vector<long long>> start(n);
    for(int i = 0; i < n-1; ++i) {
        long long first = s.at(i);
        start.at(i).push_back(first);
        int startlen = start.at(i).size();
        for(int j = 0; j < startlen; ++j) {
            if(start.at(i).at(j) < s.at(i)) {
                start.at(i+1).push_back(s.at(i)+c.at(i));
            }else {
                long long x = start.at(i).at(j)-s.at(i);
                long long leave = ((x+f.at(i)-1)/f.at(i)) * f.at(i) + s.at(i);
                start.at(i+1).push_back(leave+c.at(i));
            }
        }
    }
    start.at(n-1).push_back(0);

    int anslen = start.at(n-1).size();
    for(int i = 0; i < anslen; ++i) {
        cout << start.at(n-1).at(i) << endl;
    }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if (d2 == 1) {
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from sys import stdin

n = stdin.readline().rstrip()

count = 0
if (len(n)) % 2 == 1:
  count += int(n)-10**(len(n)-1)+1

for x in range(len(n)):
  if x % 2 == 1:
    count += 10**x - 10**(x-1)

print(count)

Measured memory_bytes: 3060
import Control.Applicative
import Data.List

solve :: [Int] -> Int
solve [] = 0
solve [x] = 0
solve (x:y:xs) = y + solve xs

main :: IO ()
main = do
        getLine
        arr <- map read . words <$> getLine
        let sorted = reverse . sort $ arr
        putStrLn . show . solve $ sorted


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

int main()
{
    string S;
    cin >> S;
    int mini = 753;
    for (int i = 0; i < S.size() - 2; i++)
    {
        int temp = stoi(S.substr(i, 3));
        // cout << temp << endl;
        mini = min(mini, abs(753 - temp));
    }

    cout << mini;
    return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  bool flag=false;
  for(int i=1;i<=b;i++){
    if((a*i%b)==c){
      flag=true;
      break;
    }
  }
  cout<<(flag?"YES":"NO")<<endl;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  map<string, ll> cnt;
  rep(i, n) {
    string s; std::cin >> s;
    sort(rng(s));
    cnt[s]++;
  }
  ll ans = 0;
  for (auto &p : cnt) if (p.se > 1) {
    ans += p.se * (p.se-1) / 2;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 11264
main(){float a,b,c,d,e,f,g,h;while(~scanf("%f%f%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f,&g,&h)){printf("%s\n",(c-a)*(g-e)+(d-b)*(h-f)?"NO":"YES");}exit(0);}

Measured memory_bytes: 608
package main 


import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)


var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := scanInt()
	tl := make([]int, n)
	pl := make([][]int, n)

	for i := 0; i < n; i++ {
		tl[i] = scanInt()
		pl[i] = []int{scanInt(), scanInt()}
	}

	loc := make([]int, 2)
	btime := 0
	for i := 0; i < n; i++ {
		xd := abs(pl[i][0], loc[0])
		yd := abs(pl[i][1], loc[1])
		t := tl[i] - btime

		if t < xd+yd || (xd+yd)%2 != t%2 {
			fmt.Println("No")
			return
		}
		loc[0] = pl[i][0]
		loc[1] = pl[i][1]
		btime = tl[i]
	}
	fmt.Println("Yes")
}

func abs(x int, y int) int {
	d := x - y
	if d < 0 {
		return -d
	}
	return d
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  unsigned long long n;
  long long a[5];
  
  cin >> n;
  for(int i = 0; i < 5; i++)
  {
    cin >> a[i];
  }
  /* */
  
  unsigned long long timer = 0;
  
  long long min = 1000000000000000000000;
  int minitr = -1;
  
  for(int i = 0; i < 5; i++)
  {
    if(min > a[i])
    {
      min = a[i];
      minitr = i;
    }
  }
  
  timer += ceil(static_cast<double>(n) / static_cast<double>(min)) + 4;
  
  cout << timer << endl;
  
  return 0;
}


  /*
  int hito[6];
  
  hito[0] = n;
  for(int i = 1; i <= 5; i++) hito[i]=0;
  
  int trans = 0;
  
  while(hito[5] != n)
  {
    timer++;
    
    for(int i = 4; i >= 0; i--)
    {
      trans = min(hito[i], a[i]);
      hito[i] -= trans;
      hito[i+1] += trans;
      trans = 0;
    }
  }
  */

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e4+5;
int n,sum;
int main()
{
	scanf("%d",&n);
	vector<int> f(n+1),zs;
	vector<long long> a(n+1);
	for(int i=n;i>=0;i--)
		scanf("%lld",&a[i]);
	for(int i=2;i<=n;i++)
		if(!f[i])
		{
			zs.push_back(i);
			for(int j=i+i;j<=n;j+=i)
				f[j]=1;
		}
	sum=abs(a[n]);
	for(int i=2;i*i<=sum;i++)
		if(sum%i==0)
		{
			if(i>n)zs.push_back(i);
			while(sum%i==0)sum/=i;
		}
	if(sum>max(1,n))zs.push_back(sum);
	for(int x:zs)
	{
		vector<long long> b=a;
		for(int j=n;j>=x;j--)b[j-(x-1)]+=b[j];
		int fl=1;
		for(int j=0;j<=min(n,x-1) && fl;j++)
			fl&=b[j]%x==0;
		if(fl)printf("%d\n",x);
	}
} 

Measured memory_bytes: 556
N, M, Q = map(int,input().split())

C = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(M):
	L,R = map(int,input().split())
	C[L][R] += 1


D = [[0 for i in range(N+4)] for j in range(N+4)]
for i in range(N+1):
	for j in range(N+1):
		D[i][j+1] = D[i][j] + C[i][j]

for j in range(Q):
	p,q = map(int,input().split())
	s = 0
	for i in range(p,q+1):
		s += (D[i][q+1] - D[i][i])
	print(s)


Measured memory_bytes: 55896
import java.util.*

fun main(args: Array<String> ) {
    val sc = Scanner( System.`in` )
    val cost = LongArray( 4, { sc.nextLong() } )
    val n = sc.nextLong()
    val best = cost.indices.minBy { cost[it] shl ( 3 - it ) }!!
    if ( best < cost.lastIndex ) {
        println( n * cost[best] shl ( 2 - best ) )
    } else if ( n % 2 == 0L ) {
        println( n / 2 * cost[best] )
    } else {
        val secondBest = ( 0 .. 2 ).minBy { cost[it] shl ( 3 - it ) }!!
        println( n / 2 * cost[best] + ( 1 shl ( 2 - secondBest ) ) * cost[secondBest] )
    }
}

Measured memory_bytes: 35912
n = int(input())
ws = list(map(int, input().split()))

full = sum(ws)
half = full / 2
total = 0

for w in ws:
  total += w
  if total >= half:
    total_min = total - w
    dif = abs(total - (full - total))
    dif_min = abs(total_min - (full - total_min))
    print(min(dif, dif_min))
    exit()

Measured memory_bytes: 3316
import fractions

a, b, c, d = map(int, input().split(" "))

def howmany(num, div1, div2):
  tsumugi = num // div1
  matsuri = num // div2
  kaori = num // (div1 * div2 //fractions.gcd(div1, div2))
  mizuki = num - tsumugi - matsuri + kaori
  return mizuki

A = howmany(a - 1, c, d)
B = howmany(b, c, d)

ans = B - A

print(ans)

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

int main() {
    int a, b;
    char op;
    while (cin >> a >> op >> b, op != '?') {
        if (op == '+') {
            cout << a + b << endl;
        } else if (op == '-') {
            cout << a - b << endl;
        } else if (op == '*') {
            cout << a * b << endl;
        } else if (op == '/') {
            cout << a / b << endl;
        }
    }
    return 0;
}

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int maxn = 100050;

int n, K, x[maxn], y[maxn];
int m1, m2;

int main()
{
	#ifdef MPS
		fp("1.in","r",stdin);
		fp("1.out","w",stdout);
		db mps = clock();
	#endif
	sf("%d%d",&n,&K);
	fo(i,1,n) 
	{
		int w; sf("%d",&w);
		if(w < 0) x[++m1] = w; 
		else if(w > 0) y[++m2] = w;
		else K --;
	}
	int ans = inf;
	reverse(x+1,x+m1+1);
	fo(num,1,K-1) 
	{
		if(num > m2 || K-num > m1) continue;
		gmin(ans, y[num] - x[K-num] + min(y[num], -x[K-num]));
	} 
	if(K <= m1) gmin(ans, -x[K]);
	if(K <= m2) gmin(ans, y[K]);
	pf("%d\n",ans);
	#ifdef MPS
		pf("Time Elapsed: %.3fms\n",clock()-mps);
	#endif
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    private const ulong MOD9 = 1000000007;

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var answer = new List<Tuple<int, int>>();

        if (n % 2 == 1)
        {
            for (var i = 1; i < n; ++i)
                answer.Add(Tuple.Create(i, n));
            --n;
        }

        for (var i = 1; i < n; ++i)
        {
            var t = n - i + 1;
            for (var j = i + 1; j <= n; ++j)
            {
                if (j != t)
                    answer.Add(Tuple.Create(i, j));
            }
        }

        Console.WriteLine(answer.Count);
        foreach (var t in answer)
            Console.WriteLine($"{t.Item1} {t.Item2}");
    }
}


Measured memory_bytes: 13268
import sys
import math
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))

n = ini()
a = inl()
x = sum(a) // n
ans = 0
for i in a:
    ans += (i - x) * (i - x)
x = math.ceil(sum(a) / n)
ans2 = 0
for i in a:
    ans2 += (i - x) * (i - x)
print(min(ans, ans2))

Measured memory_bytes: 9212
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct edge
{
	long long to; long long len;
	bool operator<(const edge& rhs) const {
		return len > rhs.len;
	}
};

ll const MAX = 3e5 + 5;
ll const INF = 1e18 + 5;
vector<vector<edge>> G(MAX);
vll a(MAX);
vll p(MAX, INF);
vll ax(MAX), ay(MAX);

bool dfs(ll start, ll val) {
	stack<ll> st;
	ll minx = INF, miny = INF;
	st.push(start);
	p[start] = 0;
	while (!st.empty()) {
		ll cur = st.top();
		st.pop();
		if (cur % 2 == 0) {
			miny = min(miny, p[cur]);
		}
		else {
			minx = min(minx, p[cur]);
		}
		for (auto next_edge : G[cur]) {
			ll next = next_edge.to;
			ll cost = next_edge.len;
			if (p[next] == INF) {
				p[next] = cost - p[cur];
				st.push(next);
			}
			else {
				if (p[next] != cost - p[cur]) {
					return false;
				}
			}
		}
	}
	return (minx + miny >= 0);
}

int main() {
	ll r, c, n;
	cin >> r >> c >> n;
	REP(i, 1, n) {
		ll x, y, t;
		cin >> x >> y >> t;
		x = 2 * x - 1;
		y = 2 * y;
		G[x].push_back({ y,t });
		G[y].push_back({ x,t });
	}
	REP(i, 1, max(r * 2 + 1, c * 2)) {
		if (p[i] == INF) {
			if (!dfs(i, 0)) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

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

int main()
{
    int N, sum1=0, sum2=0;
    cin >> N;
    vector<int> L(N);

    for (int i = 0; i < N; i++){
        cin >> L.at(i);
    }

    sort(L.begin(), L.end());
    for (int i = 0; i < N; i++)
    {
        sum1 += L.at(i);
    }
    sum2 = L.at(N - 1);
    sum1 -= sum2;
    //cout << sum1 << endl;
    //cout << sum2 << endl;
    if(sum2<sum1){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N,L;
  cin>>N>>L;
  int a[N];
  int sum=0;
  for(int i=1;i<=N;i++) {
    a[i-1]=L+i-1;
    sum+=a[i-1];
  }
  if(a[0]>=0) {
    cout<<sum-a[0]<<endl;
  }
  else if(a[0]<=0&&a[N-1]>=0) {
    cout<<sum<<endl;
  }
  else if(a[N-1]<=0) {
    cout<<sum-a[N-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  long long M=0;
  cin>>N;
  vector<int>vec(N-1);
  for(int X=0;X<N;X++){
    if(X<N-1){
      cin>>vec.at(X);
    }
    if(X>0 && X<N-1){
      M+=min(vec.at(X),vec.at(X-1));
    }
    else if(X==0){
      M+=vec.at(X);
    }
    else{
      M+=vec.at(N-2);
    }
  }
  cout<<M<<endl;
}

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

int main(){
  int s ,i = 2;
  cin >> s;

  if (s == 1 || s ==2)
    cout << 4 << endl;
  else{
    while(1){
      if(s % 2 == 0) {
	s /= 2;
      }
      else {
	s = 3 * s + 1;
      }
      if(s == 1 && i >= 3) {
	break;
      }
      i++;
    }
    cout << i + 1 << endl;
  }
}


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

int main(){
  char x;
  cin>>x;
  if(x=='A')
    cout<<'T'<<endl;
  else if(x=='C')
    cout<<'G'<<endl;
  else if(x=='G')
    cout<<'C'<<endl;
  else if(x=='T')
    cout<<'A'<<endl;

  return 0;
}


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

int main(){
  int X, A, B;
  cin >> X >> A >> B;

  cout << (X - A) % B << endl;
}

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

#define eb emplace_back
#define pb push_back
#define INF LLONG_MAX
#define FLT_INF pow(10.0, 16)


using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<ll, ll>;
using int3 = tuple<ll, ll, ll>;

template <typename A> string to_string(const A& v);
string to_string(const string& s) { return '"'+ s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(const pair<A, B>& p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C> string to_string(const tuple<A, B, C>& p) {
  return "(" + to_string(std::get<0>(p)) + ", " + to_string(std::get<1>(p)) +  ", " + to_string(std::get<2>(p)) + ")";
}

template <typename A> string to_string(const A& v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T>& val) {
  sort(val.begin(), val.end());
}

template <typename T>
void reverse(vector<T>& val) {
  reverse(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T>& val) {
  sort(val.begin(), val.end(), greater<T>());
}

template <typename T>
T pair_sum(pair<T, T>& val) {
  return val.first + val.second;
}


template <typename T>
T min(T a, T b, T c) {
  return min(min(a, b), c);
}

template <typename T>
T max(T a, T b, T c) {
  return max(max(a, b), c);
}


template <typename T>
T mul_mod(T a, T b, T mod) {
  T res = 0;
  a %= mod;
  while (b) {
    if (b & 1) {
      res = (res + a) % mod;
    }
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...);
#endif

#define COMMON_MOD pow(10, 9) + 7
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;
/* printf("%lld %lld \n", cur_n, m / 2 + 1);
*/

class mytask {
public:

  mytask() { }



  int solve() {


    ll n, m;
    cin >> n >> m;

    if (m >= n) {
      cout << "Yes";
    } else {
      cout << "No";
    }


    return 0;
  }

};


int main() {

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

  auto task = mytask();
  task.solve();

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main () {
	char S[5];
	scanf("%s", S);
	for(int i = 0; i < 3; ++i){
		if(S[i] == S[i + 1]) {
			puts("Bad");
			return 0;
		}
	}
	puts("Good");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

inline int read() {
  int f = 1;
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    f = (ch == '-') ? -1 : 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}

const int N = 1000 + 5;

int sum[N << 1][N << 1];

int n;
int k;

inline void init() {
  for (int i = 0; i < k * 2; ++i) {
    for (int j = 0; j < k; ++j) {
      if (i - 1 >= 0) {
        sum[i][j] += sum[i - 1][j];
      }
      if (j - 1 >= 0) {
        sum[i][j] += sum[i][j - 1];
      }
      if (i - 1 >= 0 && j - 1 >= 0) {
        sum[i][j] -= sum[i - 1][j - 1];
      }
    }
  }
}

int getSum(int x1, int y1, int x2, int y2) {
  if (x2 < 0 || y2 < 0) {
    return 0;
  }
  int ret = sum[x2][y2];
  if (x1 - 1 >= 0) {
    ret -= sum[x1 - 1][y2];
  }
  if (y1 - 1 >= 0) {
    ret -= sum[x2][y1 - 1];
  }
  if (x1 - 1 >= 0 && y1 - 1 >= 0) {
    ret += sum[x1 - 1][y1 - 1];
  }
  return ret;
}

int calc(int x, int y) {
  if (x <= k) {
    return getSum(x, y, x + k - 1, k - 1) + getSum(0, 0, x - 1, y - 1) + getSum(x + k, 0, 2 * k - 1, y - 1);
  } else {
    return getSum(x, y, 2 * k - 1, k - 1) + getSum(x - k, 0, x - 1, y - 1) + getSum(0, y, x - k - 1, k - 1);
  }
}

int main() {
  n = read();
  k = read();
  for (int i = 0; i < n; ++i) {
    int x = read();
    int y = read();
    static char buf[2];
    scanf("%s", buf);
    if (buf[0] == 'B') {
      x += k;
    }
    x %= k << 1;
    y %= k << 1;
    if (y >= k) {
      y -= k;
      x += k;
    }
    x %= k << 1;
    ++sum[x][y];
  }
  init();
  int ans = 0 ;
  for (int i = 0; i < 2 * k; ++i) {
    for (int j = 0; j < k; ++j) {
      ans = max(ans, calc(i, j));
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 16000
#include<iostream>
using namespace std;
int main()
{
	int r, c,a[101],b[100],d=0;
	int h[101][101]={0};
	cin >> r >> c;
	for (int i=0; i < r;i++){
		for (int j=0; j < c; j++){
			cin >> h[i][j];
		}
	}
	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			h[i][c] += h[i][j];
		}
	}
	
	for (int j = 0; j <= c; j++){
		for (int i = 0; i < r; i++){
			h[r][j] += h[i][j];
		}
	}
	for (int i = 0; i < r+1; i++){
		for (int j = 0; j < c+1; j++){
			if (d) cout << " "; 
			cout << h[i][j];
			d = 1;
		}
		d = 0;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
int main(){
    string s; cin >> s;
    ll n = s.size(); 
    ll k; cin >> k;
    ll i = 0;
    while(i < n){
        if(s[i] != '1'){
            if(i < k){
                cout << s[i] << endl;
                return 0;
            }else{
                cout << 1 << endl;
                return 0;
            }
        }
        i++;
    }
    cout << 1 << endl;
    return 0;
}

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

int main() {
    long long N; cin >> N;
    vector<long long>A(N);
    for (long long i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    long long ans = 0;
    for (long long i = 0; i < N - 2; i++) {
        for (long long j = i + 1; j < N - 1; j++) {
            for (long long k = j + 1; k < N; k++) {
                if (A.at(i) + A.at(j) > A.at(k) && A.at(i) + A.at(k) > A.at(j) && A.at(j) + A.at(k) > A.at(i) && (A.at(i) != A.at(j) && A.at(j) != A.at(k) && A.at(k) != A.at(i))) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
n = int(input())
arr = list(map(int, input().split()))
dp = [float("inf")] * len(arr)
dp[0] = 0
dp[1] = abs(arr[1]-arr[0])
for j in range(2, len(arr)):
    dp[j] = min(dp[j-1] + abs(arr[j] - arr[j - 1]),
                dp[j-2] + abs(arr[j] - arr[j - 2]))
print(dp[-1])


Measured memory_bytes: 13928
#include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
using namespace std;

int main(){
    int H, N;
    cin >> H >> N;
    long long S = 0, d;
    for(int i = 0; i < N; i ++){
        cin >> d;
        S += d;
    }
    if (H <= S){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main()
{
  uint64_t X, Y, Z, K;
  std::cin >> X >> Y >> Z >> K;
  
  std::vector<uint64_t> A(X), B(Y), C(Z);
  for (uint64_t x = 0; x < X; ++x) { std::cin >> A[x]; }
  for (uint64_t y = 0; y < Y; ++y) { std::cin >> B[y]; }
  for (uint64_t z = 0; z < Z; ++z) { std::cin >> C[z]; }
  
  std::vector<uint64_t> D(Y * Z);
  for (uint64_t y = 0; y < Y; ++y) {
    for (uint64_t z = 0; z < Z; ++z) {
      D[y * Z + z] = B[y] + C[z];
    }
  }
  
  std::sort(A.begin(), A.end(), std::greater<uint64_t>());
  std::sort(D.begin(), D.end(), std::greater<uint64_t>());
  
  uint64_t M1 = std::min(K, X), M2 = std::min(K, Y * Z);
  std::vector<uint64_t> S(M1 * M2);
  for (uint64_t i = 0; i < M1; ++i) {
    for (uint64_t j = 0; j < M2; ++j) {
      S[i * M2 + j] = A[i] + D[j];
    }
  }
  std::sort(S.begin(), S.end(), std::greater<uint64_t>());
  
  for (uint64_t i = 0; i < K; ++i) {
    std::cout << S[i] << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 31616
import math
import itertools
n = int(input())
a_ls = list(map(int, input().split()))

index_ls = list(range(n))
c = itertools.combinations(index_ls, 2)
c = list(c)

ans = 0
for i in range(len(c)):
    recover = a_ls[c[i][0]] * a_ls[c[i][1]]
    ans += recover
print(ans)

Measured memory_bytes: 3060
# 後だし

import collections

H, W = map(int, input().split())
C = tuple((int(x)-1 for x in input().split()))
D = tuple((int(x)-1 for x in input().split()))
S = list()
for _ in range(H):
    S.append(list(input()))

queue = collections.deque()
visited = collections.deque()
queue.append(C)
cy, cx = C
S[cy][cx] = 0

while len(queue):
    while len(queue):
        y, x = queue.popleft()
        visited.append((y, x))
        cost = S[y][x]
        for i, j in [(y-1, x), (y+1, x), (y, x-1), (y, x+1)]:
            if not (0 <= i < H and 0 <= j < W):
                continue
            if S[i][j] == '.':
                S[i][j] = cost
                queue.append((i, j))

    while len(visited):
        y, x = visited.popleft()
        cost = S[y][x]
        for i in range(y-2, y+2+1):
            for j in range(x-2, x+2+1):
                if not (0 <= i < H and 0 <= j < W):
                    continue
                if S[i][j] == '.':
                    S[i][j] = cost+1
                    queue.append((i, j))

dy, dx = D
result = S[dy][dx]
if result == '.':
    print(-1)
else:
    print(result)


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2 - x1, dy = y1 - y2;
	cout << x2 + dy << ' ' << y2 + dx << ' ';
	cout << x2 + dy - dx << ' ' << y2 + dx + dy << endl;
	return 0;
}

Measured memory_bytes: 3528
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
int main() {
    cout.precision(15);
    cout << fixed;
    ll lim=(1000*1000*1000ll)*(1000*1000*1000ll);
    ll A=1,B;
    ll N;
    cin >>N;
    vector<ll> As(N);
    REP(i,N) {
        cin>>As[i];
    }
    REP(i,N) {
        if (As[i]==0) {
            cout<<0<<endl;
            exit(0);
        }
    }
    REP(i,N) {
        if (A>lim/As[i]+1) {
            cout<<-1<<endl;
            exit(0);
        }
        if (A*As[i]>lim) {
            cout<<-1<<endl;
            exit(0);
        }
        A*=As[i];

    }
    if (A*B>lim) {
        cout<<-1<<endl;
        exit(0);
    }
    cout<<A<<endl;

}



Measured memory_bytes: 4380
#include  <functional>
#include  <algorithm>
#include  <exception>
#include  <stdexcept>
#include  <streambuf>
#include  <iterator>
#include  <string.h>
#include  <stdlib.h>
#include  <typeinfo>
#include  <valarray>
#include  <iostream>
#include  <sstream>
#include  <istream>
#include  <stdio.h>
#include  <climits>
#include  <clocale>
#include  <complex>
#include  <csetjmp>
#include  <csignal>
#include  <cstdarg>
#include  <cstddef>
#include  <ctype.h>
#include  <cassert>
#include  <cstdlib>
#include  <utility>
#include  <cstring>
#include  <numeric>
#include  <ostream>
#include  <cwctype>
#include  <fstream>
#include  <iomanip>
#include  <math.h>
#include  <bitset>
#include  <cctype>
#include  <string>
#include  <vector>
#include  <limits>
#include  <memory>
#include  <cerrno>
#include  <time.h>
#include  <iosfwd>
#include  <cfloat>
#include  <cstdio>
#include  <cwchar>
#include  <cmath>
#include  <ctime>
#include  <deque>
#include  <queue>
#include  <stack>
#include  <ios>
#include  <map>
#include  <set>
#include  <new>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair<int,int>
using namespace std;
const int maxn=100005;
int n,m;
vector<pair<int,pii> > v;
bool cmp(pair<int,pii> a,pair<int,pii> b)
{
    if(a.se.fi!=b.se.fi)
    return a.se.fi<b.se.fi;
    if(a.se.se!=b.se.se)
    return a.se.se<b.se.se;
    return a.fi<b.fi;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        v.pb(mp(i,mp(x,1)));
        v.pb(mp(i,mp(y,0)));
    }
    sort(v.begin(),v.end(),cmp);
    int kl=0,kr=0,ans=0;
    bool flag=0;
    set<int> s;
    for(int i=0;i<v.size();i++)
    {
        if(v[i].se.se==1)
        {
            s.insert(v[i].fi);
        }
        else
        {
            if(s.find(v[i].fi)!=s.end())
            {
                ans++;
                s.clear();
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4980
N = int(input())
W = list(map(int,input().split()))
A = 0
B = sum(W)
dif = B

for i in range(N):
  w = W[i]
  A += w
  B -= w
  if(abs(A-B) > dif):
    print(dif)
    break
  else:
    dif = abs(A-B)

Measured memory_bytes: 3060