akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int[] nm = SpIntRead(' ');
        int[] h = new int[nm[0]];
        for (int i = 0; i < nm[0]; i++) h[i] = intRead();
        Array.Sort(h);
        int ans = h[nm[1] - 1] - h[0];
        int box;
        for (int i = nm[1]; i < nm[0]; i++)
        {
            box = h[i] - h[i - nm[1] + 1];
            ans = Math.Min(ans, box);
        }
        Console.WriteLine(ans);
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = strReverce(ret);
        return ret;
    }

}


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

typedef long long ll;
const int MOD = 1000000007;

int main(){
  int N,M;
  cin >> N >> M;
  string A[N];
  string B[M];
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  for(int i = 0; i < M; i++){
    cin >> B[i];
  }
  bool flag1 = false;
  for(int i = 0; i <= N - M; i++){
    for(int j = 0; j <= N - M; j++){
      bool flag = true;
      for(int x = 0; x < M; x++){
	for(int y = 0; y < M; y++){
	  if(A[i+x][j+y] != B[x][y]){
	    flag = false;
	  }
	}
      }
      if(flag == true){
	flag1 = true;
      }
    }
  }
  if(flag1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner in = new Scanner(System.in);

	class P{

		double x;

		double y;

		int i;

		P(double x,double y,int i){

			this.x = x;

			this.y = y;

			this.i = i;

		}

		P dir;

	}

	void run(){

		for(;;){

			Scanner sc = new Scanner(in.nextLine().replace(',', ' '));

			int n= sc.nextInt();

			if(n==0) break;

			if(n==1){

				System.out.println("0");

				continue;

			}

			P[] p = new P[n];

			boolean[] used = new boolean[n];

			double minx = Double.MAX_VALUE;

			int first = 0;

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

				sc = new Scanner(in.nextLine().replace(',', ' '));

				p[i] = new P(sc.nextDouble(),sc.nextDouble(),i);

				if(minx > p[i].x){

					first = i;

					minx = p[i].x;

				}

			}

			p[first].dir = new P(0,1,-1);

			P now = p[first];

			used[now.i] = true;

			for(;;){

//				System.out.println(" "+now.i);

				double min = Double.MAX_VALUE;

				int next = 0;

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

					if(i == now.i) continue;

					double y = Math.atan2((p[i].y-now.y)*now.dir.x - (p[i].x-now.x)*now.dir.y,-(p[i].y-now.y)*now.dir.y - (p[i].x-now.x)*now.dir.x);

					if(min > y){

						min = y;

						next = i;

					}

				}

//				System.out.println("  "+min/Math.PI*180);

				if(used[next]){

					break;

				}

				used[next] = true;

				P dir = new P(p[next].x-now.x,p[next].y-now.y,next);

				now = p[next];

				p[next].dir = dir;

			}

			int sum = 0;

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

				if(!used[i]) sum++;

			}

			System.out.println(sum);

		}

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

	}

}

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

int main(){
    string n;
    cin >> n;
    int sum = 0;
    for(int i = 0; i<n.length();i++){
        sum += n[i] - '0';
    }
    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }else if(sum % 9 != 0){
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> v;
  for(int i = 0; i < H; i++){
    string tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  vector<string> ans;
  
  string x = "";
  for(int i = 0; i < W; i++){
    x = x + "#";
  }
  for(int i = 0; i < H; i++){
    ans.push_back(x);
  }
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(v[i][j] == '#'){
        cout << "#";
      } else {
      int tmp = 0;
      if(i-1 >= 0 && j-1 >= 0 && v[i-1][j-1] == '#'){
        tmp++;
      }
      if(i-1 >= 0 && v[i-1][j] == '#'){
        tmp++;
      }
      if(i-1 >= 0 && j+1 < W && v[i-1][j+1] == '#'){
        tmp++;
      }
      if(j-1 >= 0 && v[i][j-1] == '#'){
        tmp++;
      }
      if(j+1 < W && v[i][j+1] == '#'){
        tmp++;
      }
      if(i+1 < H && j+1<W && v[i+1][j+1] == '#'){
        tmp++;
      }
      if(i+1 < H && v[i+1][j] == '#'){
        tmp++;
      }
      if(i+1 < H && j-1>=0 && v[i+1][j-1] == '#'){
        tmp++;
      }
      cout << tmp;
      }
      if(j == W-1) cout << endl;
    }
  } 
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

const int MAX = 1010;
const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int cnt[MAX];
bool prime[MAX];

// エラトステネスの篩（素数は配列primeがfalseになる添え字）
void eratosthenes(int N) {
  prime[0] = prime[1] = true;
  for (int i = 2; i < sqrt(N); i++) {
    for (int j = i; i * j < N; j++) {
      prime[i*j] = true;
    }
  }
}

int main() {
  // 入力
  int N;
  cin >> N;

  eratosthenes(MAX);
  for (int i = 1; i <= N; i++) {
    int x = i;
    for (int j = 2; j <= i; j++) {
      if (prime[j]) continue;

      int c = 0;
      while (x % j == 0) {
        x /= j;
        c++;
      }
      cnt[j] += c;
    }
  }

  ll ans = 1;
  for (int i = 1; i <= N; i++) {
    ans *= cnt[i] + 1;
    ans %= MOD;
  }

  // 解答
  cout << ans << endl;

  return 0;
}


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

int main() {
  
  int a, b;
  cin >> a >> b;
  
  int s = a-1;
  int t = b-1;
  int ans = (t+s-1)/s;
  
  cout << ans << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+10;
const ll MOD=2019;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
ll arr[MAX];
int n;
ll solve(ll val){
	ll res=0;
	for(int i=0;i<n;i++)
		res=res+abs(arr[i]-val);
	return res;
}
int main() 
{
	int n;
	cin>>n;
	int p=n%10;
	if(p==2||p==4||p==7||p==5||p==9)
		cout<<"hon";
	else if(p==0||p==1||p==6||p==8)
		cout<<"pon";
	else
		cout<<"bon";
}

Measured memory_bytes: 3620
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t X;
  cin >> X;
  int64_t result;
  for (int64_t m = 1; m <= X; ++m) {
    if (X <= m * (m + 1) / 2) {
      result = m;
      break;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3636
n = int(input())
costs = list(map(int, input().split()))

if n == 2:
    print(abs(costs[-1] - costs[-2]))
else:
    best = [abs(costs[n - 2] - costs[n - 1]), 0]

    for i in range(n - 3, -1, -1):
        current = min(abs(costs[i] - costs[i + 1]) + best[0], abs(costs[i] - costs[i + 2]) + best[1])
        best[0], best[1] = current, best[0] 

    print(best[0])



Measured memory_bytes: 20344
from collections import defaultdict
N, C = map(int, input().split())
D = []
for i in range(C):
    K = list(map(int, input().split()))
    D.append(K)
Before = []
for i in range(N):
    K = list(map(int, input().split()))
    Before.append(K)
Num = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(N):
        Num[i][j] = (i + j + 2) % 3
Zero = defaultdict(int)
One = defaultdict(int)
Two = defaultdict(int)

for i in range(N):
    for j in range(N):
        if Num[i][j] == 0:
            Zero[Before[i][j] - 1] += 1
        elif Num[i][j] == 1:
            One[Before[i][j] - 1] += 1
        else:
            Two[Before[i][j] - 1] += 1
Cost = [[0]*C for _ in range(3)]
for i in range(C):
    for k, v in Zero.items():
        Cost[0][i] += v * D[k][i]
    for k, v in One.items():
        Cost[1][i] += v * D[k][i]
    for k, v in Two.items():
        Cost[2][i] += v * D[k][i]
ans = float("inf")
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i != j and j != k and k != i:
                ans = min(ans, Cost[0][i] + Cost[1][j] + Cost[2][k])
print(ans)

Measured memory_bytes: 73376
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

typedef ll Node; // Node番号

class TopologicalSort {
public:
  void Init(ll size) {
    V = size;
    graph.resize(size);
    indegree.resize(size);
  }

  void AddEdge(Node from, Node to) {
    graph[from].push_back(Edge{to});
    indegree[to]++;
  }

  vector<Node> Sort() {
    stack<Node> st; //入次数が0の頂点の集合
    REP(i, V) {
      if (indegree[i] == 0) {
        st.push(i);
      }
    }
    vector<Node> ans;
    while (st.size()) {
      Node i = st.top();
      st.pop();
      ans.push_back(i);
      for (const auto &j : graph[i]) {
        indegree[j.to]--;
        if (indegree[j.to] == 0)
          st.push(j.to);
      }
    }
    return ans;
  }

private:
  ll V;
  struct Edge {
    Node to;
  };
  vector<vector<Edge>> graph;
  vector<ll> indegree;
};

map<ll, ll> node_to_order;

bool comp(const pair<ll, ll> &l, const pair<ll, ll> &r) {
  if (l.second < r.second) {
    return true;
  } else if (l.second > r.second) {
    return false;
  } else {
    return node_to_order[l.first] > node_to_order[r.first];
  }
}

void solve(long long N, long long M, std::vector<long long> A,
           std::vector<long long> B) {
  TopologicalSort t;
  t.Init(N);
  REP(i, A.size()) {
    t.AddEdge(A[i] - 1, B[i] - 1);
  }
  auto ans = t.Sort();
  for (int i : ans) {
    node_to_order[ans[i]] = i;
  }
  vector<pair<ll, ll>> C(A.size());
  REP(i, A.size()) {
    C[i].first = A[i] - 1;
    C[i].second = B[i] - 1;
  }
  sort(ALL(C), comp);
  vector<ll> parent(N, 0);
  ll prev = -1;
  REP(i, C.size()) {
    if (prev == C[i].second) {
      C[i].first = -1;
    } else {
      parent[C[i].second] = C[i].first + 1;
    }
    prev = C[i].second;
  }
  REP(i, N) { std::cout << parent[i] << std::endl; }
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> A(N - 1 + M);
  std::vector<long long> B(N - 1 + M);
  for (int i = 0; i < N - 1 + M; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, M, std::move(A), std::move(B));
  return 0;
}


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

int main(){
  int k,t;
  cin >> k >> t;
  vector<int> v(t,0);
  r(i,t)cin >> v.at(i);
  sort(v.begin(),v.end());
  cout << max(0,v.at(t-1)*2-k-1)<<endl;
}

Measured memory_bytes: 256
import itertools

def Warshall_Floyd(edges,N):
  for k in range(N):
    for i in range(N):
      for j in range(N):
        edges[i][j]=min(edges[i][j],edges[i][k]+edges[k][j])
  return edges

def main():
    n,m,r = map(int,input().split())
    ls = [int(x) for x in input().split()]
    map_ls = [[float("inf") for _ in range(n+1)] for _ in range(n+1)]
    for _ in range(m):
        a,b,c = map(int,input().split())
        map_ls[a][b] = c
        map_ls[b][a] = c
    edes = Warshall_Floyd(map_ls,n+1)
    ans = int(10**9+7)
    for i in list(itertools.permutations(ls)):
        cnt = 0
        for j in range(1,r):
            now_,next_ = i[j-1],i[j]
            
            cnt += edes[now_][next_]
        ans = min(ans,cnt)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 66264
#include <stdio.h>

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	int arr[n];
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &arr[i]);
	}
	for(int i = k; i < n; i++)
	{
		if(arr[i-k] < arr[i])
		{
			puts("Yes");
		} else
		{
			puts("No");
		}
	}
	return 0;
}

Measured memory_bytes: 2396
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 211;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

map < int, int > M;
int n, a[N], ans;

main () {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		ans += M[i - a[i]];	
		++M[a[i] + i];
	}

	cout << ans << endl;
}





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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



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

	int n, k;
	cin >>n >>k;
	
	
	/*ll zas =0;
	for(int i=1, j=1; i<=n; i++){
		for(j=1;j<=n;j++) if(j%i >=k) zas++;
	}
	cout << zas <<"\n";*/
	
	ll ans = 0;
	if(k==0){cout<<(ll)n*n <<"\n";return 0;}
	rep2(i,k+1,n+1){
		ll s=i-k;
		ans += (ll)n / i * s;
		ll amr = n%i;
		if( amr >= k) ans += amr+1-k;
	}
	cout << ans <<"\n";
	return 0;
}


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

/*sortの仕方
 * ■ string s の場合
 * 昇順: sort(s.begin(), s.end())
 * 降順:  sort(s.rbegin(), s.rend())
 *
 * ■ int a[N] の場合
 * 昇順: sort(a, a+N)
 * 降順: 不明
 */

int alph2int(char character) {
    int x = character - 'a';
    return x;
}


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

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

    sort(a, a+N);

    int ans = 0;
    int a_temp = 0;
    int count = 0;
    for (int i=0; i<N; i++) {
        if (a_temp < a[i]) {
            if (count > a_temp) {
                ans += count - a_temp;
            } else if (count < a_temp) {
                ans += count;
            }

            a_temp = a[i];
            count = 1;
        } else if (a_temp == a[i]){
            count++;
        }
    }

    if (count > a_temp) {
        ans += count - a_temp;
    } else if (count < a_temp) {
        ans += count;
    }

    cout << ans << endl;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

bool ok(const string& s,int x)
{
	int n=s.size();
	if(2*x<=n)
		return true;
	if(count(end(s)-x,begin(s)+x,'1')%(2*x-n)==0)
		return true;
	return false;
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(string s;cin>>s;){
		int n=s.size();
		int lo=0,hi=n+1;
		while(lo<hi){
			int mi=(lo+hi)/2;
			if(ok(s,mi))
				lo=mi+1;
			else
				hi=mi;
		}
		cout<<lo-1<<endl;
	}
}


Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut hash = std::collections::HashSet::new();

    for &x in &a {
        hash.insert(x);
    }

    println!("{}", hash.len() - if hash.len() & 1 == 0 { 1 } else { 0 });
}


Measured memory_bytes: 8444
#define TST 0
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

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

void printM(vector<vector<int> > &vec, long height, long width){
    F(i, 0, height){
        F(j, 0, width){
            cout << vec[i][j] << space;
        }
        cout << endl;
    }
}

vector<int> seen;
vector<int> done;
int timestamp;

// Graph: グラフを表した隣接リスト
// v: 何番目のノードを訪問するのか
void dfs(vector<vector<int> > &Graph, int v){
    timestamp++;
    seen[v] = timestamp; //訪問済みにする

    // 隣接するノードを再帰的に訪問
    for(int next_v = 0; next_v < Graph[v].size();next_v++) {
        if(seen[Graph[v][next_v]] != -1) continue;
        dfs(Graph, Graph[v][next_v]);
    }
    // 出るときの時間が増える
    timestamp++;
    done[v] = timestamp; // 隣接ノードを全て調べ終えた
}

int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    long n;
    cin >> n;
    vl A,B,C;
    A.resize(n);
    B.resize(n);
    C.resize(n);
    vl result;
    result.resize(n);
    F(j, 0, n){

        cin >> A[j];
    }
    F(i, 0, n){
        cin >> B[i];

    }
    F(i, 0, n){
        cin >> C[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    F(i, 0, n){
        auto it = lower_bound(A.begin(), A.end(), B[i]);
        size_t dist = distance(A.begin(), it);
        if(i == 0)result[i] = dist;
        else result[i] = result[i-1] + dist;
    }
    ll ans = 0;
    F(i, 0, n){
        auto it = lower_bound(B.begin(), B.end(), C[i]);
        long dist = distance(B.begin(), it);
        if(dist > 0)ans += result[dist-1];
    }
    cout << ans << endl;


#if TST==1
#endif
}


Measured memory_bytes: 3328
// atcoder - dp - E
#include <bits/stdc++.h>

using namespace std;

const long long N = 100005, INF = 1e9 + 5;

long long n, W; 

void min_self(long long& a, long long b)
{
	a = min(a, b);
}

void max_self(long long& a, long long b)
{
	a = max(a, b);
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	// dp[i] the minimum weight of the items has exact value i
	cin >> n >> W;
	std::vector<long long> w(n+1), v(n+1);//0..n
	long long sum_value = 0; 
	for (long long i = 0; i < n; i++){
		cin >> w[i] >> v[i];
		sum_value += v[i];
	}
	// cout << sum_value << endl;
	vector<long long> dp(sum_value+1, INF);
	dp[0] = 0;
	for (long long i = 0; i < n; i++){
		for (long long j = sum_value - v[i]; j >= 0; j--) {
			min_self(dp[j+v[i]], dp[j]+w[i]);
		}
	}
	// for (long long i = 0; i <= sum_value; i++) {
	// 	cout << i << ": "<< dp[i] << " ";
	// }
	// cout << endl;
	long long ans = 0;
	for (long long i = 0; i <= sum_value; i++){
		if (dp[i] <= W){
			max_self(ans, i);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
w=input()
dic = {
  'a': 0,
  'b': 0,
  'c': 0,
  'd': 0,
  'e': 0,
  'f': 0,
  'g': 0,
  'h': 0,
  'i': 0,
  'j': 0,
  'k': 0,
  'l': 0,
  'm': 0,
  'n': 0,
  'o': 0,
  'p': 0,
  'q': 0,
  'r': 0,
  's': 0,
  't': 0,
  'u': 0,
  'v': 0,
  'w': 0,
  'x': 0,
  'y': 0,
  'z': 0
}
for i in w:
  dic[i] +=1

flg=True
for key in dic:
  if dic[key] != 0 and dic[key] % 2 != 0:
    flg=False
print('Yes' if flg else 'No')


Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String s = sc.next();
		char[] ch = s.toCharArray();
		
		int result = 0;
		for (int i = 0; i < s.length() / 2; ++i) {
			if (ch[i] != ch[s.length() - i - 1]) result++;
		}
		
		
		System.out.println(result);
		
	}
	
	
	
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21204
#include<iostream>
#include<sstream>
#include<iomanip>

using namespace std;

int main() {
	long int N;
	cin >> N;
	long double x, y;

	x = (long double)N / 3;

	y = (long double)x * x * x;

	cout << fixed;
	cout <<setprecision(12) <<y << endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define N 1000002
#define mod 1000000007
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mxN = 2005;
void solve(){
	ll k;
	cin>>k;
	ll i = 7;
	ll cnt = 1;
	ll rem = i%k;
	if(k%2==0){
		cout<<"-1\n";
		return;
	}
	if(rem==0){
		cout<<cnt<<'\n';
		return;
	}
	map<ll,ll> mp;
	mp[rem] = 1;
	while(rem!=0){
		rem*=10;
		rem+=7;
		rem%=k;
		if(mp[rem])
			break;
		mp[rem]=1;
		cnt++;
	}
	if(rem==0)
		cout<<cnt<<'\n';
	else
		cout<<"-1\n";

}

int main() {	
	IOS
	ll T;
	// cin>>T;
	T = 1;
	// ll i = 1;
	while(T--){
		// cout<<"Case #"<<i<<": ";
		solve();
		// i++;
	}
	return 0;
	
}

Measured memory_bytes: 66064
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pii pair<int, int>
#define pcc pair<char, char>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
#define ALL(x) (x).begin(), (x).end()
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = (1 << 26) + 10;
string s;
int n, ans, a[N];
int main()
{
	cin >> s;
	n = s.size();
	s = " " + s;
	int now = 0;
	a[0] = 1;
	ans = 2e9;
	rep(i, 1, n)
	{
		now = now ^ (1 << (s[i] - 'a'));
		int tmp = 2e9;
		if(a[now]) tmp = a[now];
		rep(j, 0, 25)
		{
			int ret = now ^ (1 << j);
			if(a[ret]) tmp = min(tmp, a[ret]);
		}
		if(i == n) ans = tmp + 1;
		if(!a[now]) a[now] = tmp + 1;
		else a[now] = min(a[now], tmp + 1);
	}
	cout << ans - 1;
	return 0;
}


Measured memory_bytes: 262464
#include<bits/stdc++.h>
using namespace std;
long long int i,n,a[100000],m,g,b[100000];
int main(void)
{
	while(1){
		scanf("%lld",&n);
		if(n==0) break;
		m=0;
		g=0;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
			m+=a[i];
		}
		for(i=0;i<n-1;i++){
			scanf("%d",&b[i]);
		}
		sort(b,b+(n-1));
		b[n-1]=0;
		for(i=n-1;i>=0;i--){
			if(g<(m+b[i])*(i+1)){
				g=(m+b[i])*(i+1);
			}
			m+=b[i];
		}
		printf("%lld\n",g);
	}
	return 0;
}


Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 52;
ll n;

int main(){
	cin>>n;
	ll w=0;
	ll f=1e9+1;;
	FOR(i,1,n+1){
		w+=i;
		if(w>=n){
			f=i;
			break;
		}
	}
	FOR(i,1,n+1){
		if(i==w-n)continue;
		cout<<i<<endl;
		if(i==f)break;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<cmath>
#include<cstring>
#include<map>
#include<climits>
#include <iomanip>
#include<unordered_map>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
int main(){
  FAST
  int n;
  cin >> n;
  bool flag = false;
  for(int i=1; i<=9; i++){
    if(n % i == 0 && n/i >= 1 && n/i <= 9) {flag = true; break;}
  }
  if(flag) cout << "Yes";
  else cout << "No";
  return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for ((i) = 0; (i) < (n); (i)++)
#define rep2(i, s, e) for ((i) = (s); (i) < (e); (i)++)
#define repd(i, n) for ((i) = (n)-1; (i) >= 0; (i)--)
#define rep2d(i, s, e) for ((i) = (e)-1; (i) >= (s); (i)--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define abs(a) ((a) > 0 ? (a) : (-1 * (a)))

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b)
{
    return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "None";

vector<ull> p[200020];
ull st[200020];
ull f[200020];

int main()
{

    ull i, j, k, n, m, a, b, sti;

    cin >> n >> m;

    rep(i, m)
    {
        cin >> a >> b;
        p[a].pb(b);
        p[b].pb(a);
    }
    rep(i, n + 1)
        f[i] = -1;

    st[1] = 1;
    sti = 2;
    f[1] = 0;
    rep(i, n + 1)
    {
        for (auto &j : p[st[i]])
        {
            if (f[j] == -1)
            {
                st[sti] = j;
                sti++;
                f[j] = st[i];
            }
            if (sti == n + 1)
            {
                cout << YES << endl;
                rep2(k, 2, n + 1)
                {
                    cout << f[k] << endl;
                }
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 15900
#include<bits/stdc++.h>
using namespace std;
#define li long long int



li min(li a,li b)
{
    if(a>b) a=b;
    return a;
}


li fun(int arr[],int i,int n,int k)
{
    li dp[n+1];
    dp[0]=0;
    dp[1]=0;
   // dp[2]=abs( arr[1]-arr[0] );

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

        
        if(i-j >=0 ) 
        { 
            
            a=   dp[i-j+1]+ abs(arr[i]-arr[i-j] );
 
           if(dp[i+1]>a) dp[i+1]=a;
           
          // cout<< dp[i+1]<<" ";
            
        }else break;
        
         
        
    }
  //  cout<< endl;
    
}

    return dp[n];
}




int main()
{
    int n,k;
    cin >> n>>k;
    int arr[n];
    for(int i=0;i<n;i++) cin >> arr[i];
    
cout<<    fun(arr,0,n,k);
    
    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin >> n;
    ll d[n][2];
    for (ll i = 0; i < n; i++) {
        cin >> d[i][0] >> d[i][1];
    }
    ll flag = 0;
    for (ll i = 0; i < n - 3; i++) {
        if (d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] && d[i + 2][0] == d[i + 2][1])
        {
            flag = 1;
            break;
        }
    }
    if(n == 3)
    {
        ll i = 0;
        if (d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] && d[i + 2][0] == d[i + 2][1])
        {
            flag = 1;
        }

    }
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/


int main(){
    fIO

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

    cout << max(0, c - (a - b));
}









Measured memory_bytes: 256
import math
r,c = input().split()
r = int(r)
c = int(c)
if(r==1 or c==1):
    print(1)
else:    
    ans = r*c/2
    if r%2==1 and c%2==1:
        print(math.floor(ans)+1)
    else:
        print(math.floor(ans))

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


long long gcm(long long m,long long n){
  while(1){
    if(n == 0){
      return m;
    }
    long long tmp = m % n;
    m = n;
    n = tmp;
  }
}


int main(){
  int n;
  long long t[100];

  cin >> n;


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

  sort(t,t+n,greater<long long>());
  long long ans = t[0];

  for(int i = 1;i < n;i++){
    if(ans % t[i] != 0){
      long long tmp = gcm(ans,t[i]);
      ans = ans /tmp  * t[i];
    }
  }


  cout << ans << endl;

  return 0;
}


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

    using namespace std;

    #define INF 2000000000
    #define MOD 1000000007
    typedef long long ll;
    typedef pair<int, int> P;


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

    	ll sum = a[0];
    	ll prev = a[0];
    	ll ret = 0;
	if (a[0]==0) {
		sum++;
		prev++;
		ret++;
	}

    	for (int i = 1; i < n; i++) {
    		sum += a[i];
    		if (sum>0&&prev<0) {
			prev = sum;
    			continue;
    		}
    		if (sum<0&&prev>0) {
			prev = sum;
    			continue;
    		}
    		if (sum==0&&prev<0) {
    			ret += 1;
    			sum += 1;
			prev = sum;
    			continue;
    		}
    		if (sum==0&&prev>0) {
    			ret += 1;
    			sum -= 1;
			prev = sum;
    			continue;
    		}
    		if (sum<0&&prev<0) {
    			ll cnt = abs(sum)+1;
    			ret += cnt;
    			sum += cnt;
			prev = sum;
    			continue;
    		}
    		if (sum>0&&prev>0) {
    			ll cnt = abs(sum)+1;
    			ret += cnt;
    			sum -= cnt;
			prev = sum;
    			continue;
    		}

    	}

	ll c = abs(a[0])+1;
    	ll ret2;
	if (a[0]<0) {
		sum = 1;
		prev = 1;
		ret2 = c;
	} else if (a[0]>0) {
		sum = -1;
		prev = -1;
		ret2 = c;
	} else {
		sum = -1;
		prev = -1;
		ret2++;
	}
    	for (int i = 1; i < n; i++) {
    		sum += a[i];
    		if (sum>0&&prev<0) {
			prev = sum;
    			continue;
    		}
    		if (sum<0&&prev>0) {
			prev = sum;
    			continue;
    		}
    		if (sum==0&&prev<0) {
    			ret2 += 1;
    			sum += 1;
			prev = sum;
    			continue;
    		}
    		if (sum==0&&prev>0) {
    			ret2 += 1;
    			sum -= 1;
			prev = sum;
    			continue;
    		}
    		if (sum<0&&prev<0) {
    			ll cnt = abs(sum)+1;
    			ret2 += cnt;
    			sum += cnt;
			prev = sum;
    			continue;
    		}
    		if (sum>0&&prev>0) {
    			ll cnt = abs(sum)+1;
    			ret2 += cnt;
    			sum -= cnt;
			prev = sum;
    			continue;
    		}

    	}
    	cout << min(ret,ret2) << endl;

}


Measured memory_bytes: 1024
N = int(input())

res = 'Yes'

k = 0

while 2 ** (k + 1) - 1 <= N:
    k += 1

K = 2 ** k - 1


if N == 1:
    res = 'No'
if N == K + 1:
    res = 'No'
# print(N, K)

if N % 2 == 0:
    M = N - 1
else:
    M = N
if (M - K) % 4 == 0 and M > K:
    L = M - 2
else:
    L = M

P = N - K
if P % 2 == 0:
    P = 2

print(res)

if res == 'Yes':
    line = list(range(1, K + 1))
    line.remove(P)
    line = [1, P] + line[1:]
    
    for i in range(K - 1):
        print(line[i], line[i + 1])
    print(line[-1], N + 1)
    for i in range(K - 1):
        print(N + line[i], N + line[i + 1])
    if L > K:
        print(1, K + 1)
        for i in range(K + 1, L):
            print(i, i + 1)
        for i in range(K + 1, L):
            print(N + i, N + i + 1)
        print(N + L, 1)
    if M > L:
        print(N + 1, M - 1)
        print(M - 1, M)
        print(N + M - 1, N + M)
        print(N + M, N + 1)
    if N > M:
        print(N, K + 1)
        print(N + N, P)



Measured memory_bytes: 60376
n, m = gets.split.map(&:to_i)
ab = []
n.times { ab << gets.split.map(&:to_i) }
cd = []
m.times { cd << gets.split.map(&:to_i) }
ab.each { |a, b|
  ds = cd.map { |c, d| (a - c).abs + (b - d).abs }
  puts ds.index(ds.min) + 1
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    int ans = 0;
    rep(i,n){
        int a; cin >> a;
        while(a%2 == 0){
            ans++;
            a /= 2;
        }
    }
    ANS;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vb vector<bool>
#define PB push_back
#define MP make_pair
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=s; i>=e; i--)
#define vasort(v) sort(v.begin(), v.end())
#define vdsort(v) sort(v.begin(), v.end(),greater<ll>())
#define arrasort(arr,n) sort(arr,arr+n)
#define arrdsort(arr,n) sort(arr,arr+n,greater<ll>())

#define F first
#define S second

#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6

#define mz(a,val)   memset(a,val,sizeof(a))
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007

void file()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

// code starts here


int main()
{
    //file();

    ll t;
    t = 1;

    //cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        cout << (1000 - n % 1000) % 1000;
    }
    return 0;
}

Measured memory_bytes: 3588
package main

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

func main() {
	var n, m int
	fmt.Scan(&n , &m)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]bool, n)
	for i := 0; i < m; i++ {
		sc.Scan()
		num, _ := strconv.Atoi(sc.Text())
		as[num] = true
	}

	dp := make([]int, n+1)
	mod := 1000000007

	dp[0] = 1
	dp[1] = 1
	for i := 2; i <= n; i++ {
		// i - 1段目が安全なら
		if !as[i-1] {
			dp[i] += dp[i-1]
		}

		// i - 2段目が安全なら
		if !as[i-2] {
			dp[i] += dp[i-2]
		}
		dp[i] %= mod
	}
	fmt.Println(dp[n])

}



Measured memory_bytes: 3272
#include <iostream>                                             
using namespace std;                                            
                                                                
int main() {                                                    
  int W, H, x, y, r;                                            
  cin >> W >> H >> x >> y >> r;                                 
  if (x>=r && W-x>=r && y>=r && H-y>=r) {                       
    cout << "Yes" << endl;                                      
  } else {                                                      
    cout << "No" << endl;                                       
  }                                                             
  return 0;                                                     
}                                                               
                                                                
                                                                
                                    

Measured memory_bytes: 3120
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(30<=x) System.out.println("Yes");
		else System.out.println("No");
    }
}

Measured memory_bytes: 35676