akhauriyash/Code-Regression huggingface dataset:
#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 ll mod = 1000000007;
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);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k; cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    ll INF = 1e15;
    vector<ll> dp(n);
    rep(i, n) dp[i] = INF;
    dp[0] = 0;
    rep(i, n)rep(j, k + 1){
        if(i + j < n){
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 4788
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  deque<ll> q;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i % 2 == 0) {
      q.push_back(a[i]);
    } else {
      q.push_front(a[i]);
    }
  }
  ll x;
  if (n % 2 == 0) {
    for (int i = 0; i < n; i++) {
      x = q.front();
      q.pop_front();
      cout << x << " ";
    }
  } else {
    for (int i = 0; i < n; i++) {
      x = q.back();
      q.pop_back();
      cout << x << " ";
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << " ";} cout << "\n";

int main(){
    IOS;
    char ch;
    cin >> ch;
    if(isupper(ch))cout << "A\n";
    else cout << "a\n";
    return 0;
}

Measured memory_bytes: 3608
import math
a, b, c = [int(x) for x in input().split()]
def pred(a, b, c):
    d = c - a - b
    if d <= 0:
        return False
    return 4 * a * b < d ** 2

if pred(a, b, c):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second

 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;


const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
int dp [N];
bool blocked [N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); 
  int n, m;
  cin >> n >> m;
  F0R (i, m) {
    int foo;
    cin >> foo;
    blocked[foo] = 1;
  }
  dp[0] = 1;
  auto add = [] (int &a, int b) {
    a += b;
    a %= MOD;
  };
  FOR (i, 1, n + 1) {
    if (blocked[i]) continue;
    add (dp[i], dp[i - 1]);
    if (i >= 2) add (dp[i], dp[i - 2]);
  }
  cout << dp[n] << '\n';
  return 0;
}


Measured memory_bytes: 768
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	s := map[string]bool{}
	for i := 0; i < n; i++ {
		s[scanString()] = true
	}

	fmt.Fprintln(wr, len(s))

}


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

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題162

            //Console.WriteLine("aaa");

            int k = int.Parse(Console.ReadLine());

            int amari = 0;
            int ans = 0;

            for (int i = 0; i < k; i++)
            {
                ans++;

                amari = (amari * 10 + 7) % k;

                if (amari == 0)
                {
                    Console.WriteLine(ans);
                    return;
                }
            }

            Console.WriteLine(-1);




        }

    }





    
}


Measured memory_bytes: 27488
N = int(input())
b = list(map(lambda s: int(s) - 1, input().split()))

ops = []

for i in range(N, 0, -1):
    for j in range(i - 1, -1, -1):
        if b[j] == j:
            ops.append(j)
            b = b[:j] + b[j + 1:]
            break
    else:
        ops = [-2]
        break

for i in range(len(ops) - 1, -1, -1):
    print(ops[i] + 1) # 1-based indexing

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

typedef long long  LL;
int a,b,c;
LL k;

void work()
{
	scanf("%d %d %d %lld",&a,&b,&c,&k);
	printf("%d",(k&1?b-a:a-b));
}

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


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

using namespace std;

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

int main(){
    int n, ans=0;
    string s;
    cin >> n >> s;
    for(int i = 2; i < s.size(); i++)
        if(s[i-2]=='A'&&s[i-1]=='B'&&s[i]=='C')
            ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    int h,w;
    char a[105][105];
    cin >> h >> w ;
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
        }
    }
    vector<int> cnt,cnt2;
    rep(i,h){
        if(a[i][0]!='.'){
            cnt.push_back(i);
        } else{
            int idx=0;
            rep(j,w){
                if(a[i][j]=='.') idx++;
            }
            if(idx!=w) cnt.push_back(i);
        }
    }
    rep(j,w){
        if(a[0][j]!='.'){
            cnt2.push_back(j);
        } else{
            int idx2=0;
            rep(i,h){
                if(a[i][j]=='.') idx2++;
            }
            if(idx2!=h) cnt2.push_back(j);
        }
    }
    for(auto i:cnt){
        for(auto j:cnt2){
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
A,B,M = map(int,input().split())
A_li = list(map(int,input().split()))
B_li = list(map(int,input().split()))

inf = float("inf")
posibility = inf

for m in range(M):
    x,y,c=map(int,input().split())
    tmp_posibility=A_li[x-1]+B_li[y-1]-c
    posibility=min(posibility,tmp_posibility)
 

no_c = min(A_li)+min(B_li)
decition = min(posibility,no_c)

print(decition)

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

/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

int pow3(int X) {
	int res = 1;
	for(int i = 0;i < X;i++) res *= 3;
	return res;
}

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

	int N,ev = 0;
	cin>>N;
	vector<int> a(N);
	for(int i = 0;i < N;i++) cin>>a[i],ev += a[i]%2 == 0;
	int num = pow3(N);
	num -= (1<<ev);
	cout<<num<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cmath>
#include<string.h>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<stdlib.h>
#include<stack>
#define oo 0x3f3f3f3f

using namespace std;
int n, m;
char str[105][105];
int ans[4][2]={{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int vis[105][105];
void dfs(int x, int y, char c)
{
    if(str[x][y]!=c)
        return ;
    vis[x][y]=1;
    for(int i=0; i<8; i++)
    {
        int nx=x+ans[i][0];
        int ny=y+ans[i][1];
        if(nx>=0&&nx<n&&ny>=0&&ny<m&&str[nx][ny]==c&&!vis[nx][ny])
        {
            vis[nx][ny]=1;
            dfs(nx, ny, c);
        }
    }
    return ;
}
int main()
{
    while(scanf("%d%d", &n, &m), n+m)
    {
       for(int i=0; i<n; i++)
        scanf("%s", str[i]);
        memset(vis, 0, sizeof(vis));
        int sum=0;
       for(int i=0; i<n; i++)
       {
           for(int j=0; j<m; j++)
           {
               if(!vis[i][j])
               {
                   dfs(i, j, str[i][j]);
                   sum++;
               }
           }
       }
       printf("%d\n", sum);
    }
    return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	string s;
	cin >> s;
	int ans = 0;
	FOR(i, 0, SZ(s) / 2) ans += s[i] != s[SZ(s) - 1 - i];
	cout << ans;
	
	return 0;
}



Measured memory_bytes: 256
S = input()

rst = 0
for i in range(0,3):
  cnt = 0
  if S[i] == "R":
    cnt += 1
    for j in range(i+1,3):
      if S[j] == "R":
        cnt+= 1
      else:
        break
  rst = max(rst,cnt)
print(rst)

Measured memory_bytes: 9044
#include <stdio.h>
#define mod 1000000007
typedef long long ll;
ll fact[100010];

ll exp(ll a, ll b) {
   ll now = 1;
   while(b) {
     if(b & 1) now *= a;
     a *= a;
     now %= mod, a %= mod;
     b = b >> 1;
   }
  return now;
}

ll comb(ll a, ll b) {
  if(a < b) return 0;
  ll t = fact[a];
  t *= exp(fact[b], mod - 2);
  t %= mod;
  t *= exp(fact[a - b], mod - 2);
  t %= mod;
  return t;
}

int main(void) {
  long long i, j, n, a, ans = 1, d;
  scanf("%lld", &n);
  ll flg[n + 1];
  fact[0] = 1;
  for(i = 1; i < 100010; ++i) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= mod;
  }
  for(i = 0; i <= n; ++i) flg[i] = -1;
  for(i = 0; i <= n; ++i) {
    scanf("%lld", &a);
    if(flg[a] != -1) {
      d = i - flg[a];
      break;
    }
    flg[a] = i;
  }
  for(i = 1; i < n + 2; ++i) {
    printf("%lld\n", (comb(n + 1, i) - comb(n - d, i - 1) + mod) % mod);
  }
  return 0;
}

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

int main() {

    for (int i = 1; i <=5 ; ++i) {
        int a;
        cin >> a;
        if (a == 0) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

map<int,int>vis;
vector<int>v,vt,vk,r;
int n;
bool check()
{
  int i;
  for(i=0; i<n; i++)
  {
    if(vk[i]!=r[i])return false;
  }
  return true;
}

int fact(int n)
{
  int f=1,i;
  for(i=1; i<=n; i++)
  {
    f=f*i;
  }
  return f;
}

int main()
{
  int m, a, ok=0, res=0, flag=0,pos1=1,pos2=1, i;
  cin>>n;

  for(i=0; i<n; i++)
  {
    cin>>m;
    v.push_back(m);
  }
  for(i=0; i<n; i++)
  {
    cin>>m;
    vt.push_back(m);
  }
  for(i=1; i<=n; i++)
  {
    vk.push_back(i);
  }
 int f=fact(n);
  for(i=1;i<f;i++)
  {
    next_permutation(vk.begin(),vk.end());
    r=v;
    if(check()){
      pos1=i+1;
      flag++;
      r.clear();
    }
    r=vt;

    if(check()){
      pos2=i+1;
      flag++;
      r.clear();
    }
    if(flag==2)break;
  }
  cout<<abs(pos1-pos2)<<endl;

}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N;

	public void solve() {
		N = nextInt();

		int max = 0;
		int min = Integer.MAX_VALUE;

		for(int i = 0;i < N;i++){
			int a = nextInt();
			max = Math.max(max,a);
			min = Math.min(min,a);
		}

		out.println(max-min);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

Measured memory_bytes: 21204
#include <iostream>

using namespace std;

int main() {
    
    long long x, y;
    cin >> x;
    cin >> y;
    
    int count = 0;
    for (long long i = x; i <= y; i *= 2)
    {
        count++;
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll a, b,c;
    
    cin >> a>>b>>c;
    
    
    cout <<a-b- ((a-b)/c) * c<< endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll ans;
int main(void){
    string s; cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='?'){
            s[i]='D';
        }
    }
    cout<<s<<endl;

    return 0;
}



Measured memory_bytes: 3752
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


#define REP(i, n) for(ll i = 0; i < n; i++)
























int main(){
    ll n;
    cin >> n;
    cout << (1000 - (n % 1000)) % 1000 << endl;
}

Measured memory_bytes: 3620
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
int s,t;

vi ad[100001];



int main()
{
io

int testcases=1;//cin>>testcases;
while(testcases--)
{
	int n,m;
cin>>n>>m;

int a,b;
for(int i=1;i<=m;i++)
{
	cin>>a>>b;
	ad[a].pb(b);
	//ad[b].pb(a);
}

cin>>s>>t;


//cout<<"deb\n";

int dis[n+1][3];
for(int i=0;i<n+1;i++)
{
	for(int j=0;j<3;j++)
	dis[i][j]=ima;
}
queue<pi> q;
dis[s][0]=0;
q.push(mp(s,0));

while(!q.empty())
{
	pi f=q.front();
	q.pop();
	a=f.fi;
	b=f.se;
	
		
		for(int i=0;i<ad[a].size();i++)
		{
			int j=ad[a][i];
			int p=(b+1)%3;
		
			if(dis[j][p]==ima)
			{
			dis[j][p]=dis[a][b]+1;
			q.push(mp(j,p));
		}
		}
	
	
}



if(dis[t][0]==ima)
cout<<-1;

else
cout<<(dis[t][0])/3;

}return 0;}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll ans = 1;
    bool large = false;
    cin >> N;
    rep(i, N) {
        ll temp;
        cin >> temp;
        if(temp == 0) {
            cout << 0 << endl;
            return 0;
        }
        if(1000000000000000000 / ans / temp == 0) {
            large = true;
            continue;
        }
        ans *= temp;
    }
    if(large) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// ouls
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(int, N, T);

  i64 minv = LINF;
  rep(i, N) {
    var(int, c, t);
    if (t <= T) chmin(minv, c);
  }

  if (minv == LINF) outl("TLE");
  else outl(minv);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef std::vector<pii> vii;
#define INF 0x3f3f3f3f

int main(int argc, char const *argv[])
{
	//freopen("in.txt" , "r", stdin);
 	//freopen("out.txt" , "w", stdout);

  	string s; cin>>s;
  	bool ok=true;
  	for (int i = 0; i < s.size(); i++)
  	{
  		if(i&1){
  			if(s[i]!='L' and s[i]!='U' and s[i]!='D')
  				ok=false;
  		}
  		else{
  			if(s[i]!='R' and s[i]!='U' and s[i]!='D')
  				ok=false;
  		}
  	}
  	if(ok){
  		cout<<"Yes\n";
  	}
  	else{
  		cout<<"No\n";
  	}
	return 0;
}

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

a = [[[0 for iii in range(10)] for ii in range(3)] for i in range(4)]

for i in range(n):
    b, f, r, m = map(int, input().split())
    a[b - 1][f - 1][r - 1] += m

for i in range(4):
    for ii in range(3):
        for iii in range(10):
            print(" " + str(a[i][ii][iii]), end="")
        print()
    if i == 3: break
    print("####################")


Measured memory_bytes: 5620
#include<bits/stdc++.h>
#define H 70
using namespace std;
typedef unsigned long long ull;

int n;
ull k[H], dis, A, B;
int ans;

ull f(ull x, int p)
{
	if(!x) return 0;
	ull ret = 0; int h = 0;
	for(; (1ull << h) <= (ull)x; h++); h--;
	for(; p <= h; )
	{
		if(p == h) ret += x - (1ull << h) + 1;
		else ret += 1ull << (h - 1);
		x -= 1ull << h;
		if(!x) break;
		for(; ((1ull << h) & x) == 0; h--);
	}
	return ret;
}

void check(ull a, ull b)
{
	if(a > b) return;
	if(!a) return;
	if(b > 1000000000000000000ll) return;
// printf("check %llu %llu\n",a,b);
	for(int i = 0; i < n; i++) 
		if(f(b,i) != k[i] + f(a-1,i))
			return;
	if(a != A || b != B)
		++ans, A = a, B = b;
}

void solve(ull L, ull R, ull d, int p)
{
	if(p < 0)
	{
		check(L,L);
		return;
	}
	ull mid = (L+R) >> 1;
	if(d == 2333366)
	{
		if(k[p])
		{
			if(k[p] <= R - mid)
			{
				check(mid + k[p] - dis + 0, mid + k[p]);
				check(mid + k[p] - dis + 1, mid + k[p]);
				check(mid + k[p] - dis + 2, mid + k[p]);
				solve(mid+1, R, k[p], p-1);
			}
		}
		else
		{
			solve(L, mid, d, p-1);
		}
	}
	else
	{
		if(k[p])
		{
			if(k[p] <= d)
			{
				check(mid + k[p] - dis + 0, mid + k[p]);
				check(mid + k[p] - dis + 1, mid + k[p]);
				check(mid + k[p] - dis + 2, mid + k[p]);
			}
			if(d == k[p])
			{
				solve(mid+1, R, d, p-1);
			}
		}
		else
		{
			solve(L, mid, d, p-1);
		}
	}
}

int main()
{
	for(; scanf("%d",&n) != EOF; )
	{
		if(!n) break;
			
		for(int i = 0; i < n; i++) scanf("%llu",&k[i]);
		dis = k[0] << 1; ans = 0;
		
		solve(0,(1ull<<n)-1,2333366,n-1);

		if(ans > 1) puts("Many");
		else if(!ans) puts("None");
		else printf("%llu %llu\n",A,B);
		
	}
}


Measured memory_bytes: 3100
let n = stdin.ReadLine() |> int
let s = seq{for _ in 1.. n -> stdin.ReadLine()}
 
let combi2 x =int64 x * int64 (x-1L) / 2L
s |> Seq.map (fun str -> str.ToCharArray() |> Array.sort |> fun x -> new string(x) )
|> Seq.countBy (fun x -> x)
|> Seq.filter (fun (_, count) -> count > 1)
|> Seq.sumBy (fun (_, count) -> combi2 <| int64 count)
|> string
|> stdout.WriteLine

Measured memory_bytes: 28364
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
const int maxn=3000;
LL f[maxn+10][maxn+10][2];
const LL kcz=1000000000+7;
void upd(LL &a, LL b)
{
    a = (a + b) % kcz;
}
void solve(long long n, long long m){
	f[0][0][1]=1;
	for(int i=1; i<=n; ++i) {
		f[0][i][0]=1;
	}	
	for(int i=0; i<m; ++i) {
		for(int j=0; j<=n; ++j) 
			for(int k=0; k<=1; ++k)
				//f[i+1][j][k]=f[i][j][k]*2;
				upd(f[i+1][j][k],f[i][j][k]*2);
		for(int j=1; j<=n; ++j)
			for(int k=0; k<=1; ++k)
				upd(f[i+1][j-1][k],f[i][j][k]);
		for(int j=0; j<n; ++j) 
			for(int k=0; k<=1; ++k) 
				upd(f[i+1][j+1][k],f[i][j][k]);
		upd(f[i+1][0][1],f[i+1][0][0]);
		f[i+1][0][0]=0;
	}
	LL ans=0;
	for(int i=0; i<=n; ++i) {
		upd(ans,f[m][i][1]);
	}
	cout<<ans*4%kcz<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	freopen("in.txt","r",stdin);
#endif
	long long M;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&M);
	solve(N-1, M-1);
	return 0;
}



Measured memory_bytes: 141568
def abc(N, M, A):
    # 答えの準備
    ans = N
    
    # 繰返し引き算
    for i in range(0, M):
        ans -= A[i]
    
    # 負数の処理
    if ans < 0:
        ans = -1
    
    # 答え
    return(ans)


# バッチスタート
if __name__ == "__main__":
    # 標準入力処理
    # 1行目の入力を空白で分割された2つの数値として扱う
    N, M = map(int, input().split())
    
    # 2行目の入力を数値のリストとして扱う
    A = list(map(int, input().split()))
    
    # 関数呼び出し
    f = abc(N, M, A)
    
    # 答えの出力
    print(f)


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, 0, n) cin >> v[i];
    sort(v.begin(), v.end());
    int sum = 0;
    rep(i, 0, n-1) sum += v[i];
    if(sum > v[n-1]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
	int n, u1, v1, u2, v2, x, y, ans;
	cin>>n>>x>>y;
	u1=v1=x+y;
	u2=v2=x-y;
	while(--n){
		cin>>x>>y;
		u1=min(u1,x+y);
		v1=max(v1,x+y);
		u2=min(u2,x-y);
		v2=max(v2,x-y);
	}
	ans=max(v1-u1, v2-u2);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3156
#include<iostream>
#include<algorithm>
using namespace std;
const int M=1400;
int main()
{
	int h,w;cin>>h>>w;
	int c[M+1][M+1],dp[M+1][M+1]={};
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)
	{
		cin>>c[i][j];
	}
	int ma=0;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(!c[i][j])dp[i][j]=min(dp[i][j-1],min(dp[i-1][j-1],dp[i-1][j]))+1,ma=max(ma,dp[i][j]);
		}
	}
	
	cout<<ma*ma<<endl;
	return 0;
}

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

int main() {
  string S;
  cin >> S;

  for (int i = 2; i < S.size(); i += 2) {
    string s = S.substr(0, S.size() - i);
    bool flag = true;
    for (int i = 0; i < s.size() / 2; i++) {
      if (s[i] != s[s.size() / 2 + i]) flag = false;
    }
    if (flag) {
      cout << s.size() << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>


long long attack(long long recH)
{
    long long acc =0;
    long long half = recH/2;
    if (recH == 1)
    {
       acc++; 
    }
    else if (recH == 0)
    {
        // Do nothing
    }
    else 
    {
        acc= 2* (attack(half))+1;
    }
    
    return acc;
}

int main()
{
   long long h, finNum;
   
   scanf("%lli", &h);
   
   finNum = attack(h);

   printf("%lli", finNum);
   
   return 0;
}

Measured memory_bytes: 128
#include "iostream"
#include "vector"
#include "algorithm"
 
using namespace std;
 
int main()
{
  int n, m;
  cin >> n >> m;
  int p[100100], y[100100];
  for (int i = 0; i < m; i++)
  {
    cin >> p[i] >> y[i];
  }
  vector<int> yd[100100];
  for (int i = 0; i < m; i++)
  {
    yd[p[i]].push_back(y[i]);
  }
  for (int i = 0; i < n + 1; i++)
  {
    sort(yd[i].begin(), yd[i].end());
  }
  for (int i = 0; i < m; i++)
  {
    int ans_first = p[i];
    int ans_second = lower_bound(yd[p[i]].begin(), yd[p[i]].end(), y[i]) - yd[p[i]].begin() + 1;
    printf("%06d", ans_first);
    printf("%06d", ans_second);
    cout << "\n";
  }
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
#define INF (1<<29)
#define LLINF (1LL<<59)
#define F first
#define S second
using namespace std;
typedef pair<long long,long long> Pii;
typedef struct{
  vector<Pii> to;
  long long min;
}Edge;
Edge edge[100005];
bool check[100005];
bool tika[100005];
main(){
  long long n,m,c;
  long long a,b,d;
  long long sum=0;
  vector<Pii> vec;
  memset(check,0,sizeof(check));
  memset(check,0,sizeof(tika));
  cin>>n>>m>>c;
  for(int i=2;i<=n;i++){
    edge[i].min=LLINF;
  }
  for(int i=0;i<m;i++){
    cin>>a>>b>>d;
    sum+=d;
    edge[a].to.push_back(Pii(b,d));
    edge[b].to.push_back(Pii(a,d));
  }
  edge[1].min=0;
  priority_queue<Pii,vector<Pii>,greater<Pii> > que;
  que.push(Pii(0,1));
  while(!que.empty()){
    long long nowc=que.top().F;
    int nowp=que.top().S;
    que.pop();
    check[nowp]=true;
    for(int i=0;i<edge[nowp].to.size();i++){
      long long nextp=edge[nowp].to[i].F;
      long long nextc=edge[nowp].to[i].S;
      long long nextmin=edge[nextp].min;
      if(check[nextp]==false&&nextmin>nowc+nextc){
    edge[nextp].min=nowc+nextc;
    que.push(Pii(nowc+nextc,nextp));
      }
    }
  }
  for(int i=2;i<=n;i++){
    vec.push_back(Pii(edge[i].min,i));
  }
  sort(vec.begin(),vec.end());
  long long ans=sum;
  tika[1]=true;
  for(int i=0;i<vec.size();){
    long long nowp=vec[i].F;
    while(nowp==vec[i].F){
      for(int j=0;j<edge[vec[i].S].to.size();j++){
    if(tika[edge[vec[i].S].to[j].F]){
      sum-=edge[vec[i].S].to[j].S;
    }
      }
      tika[vec[i].S]=true;
      i++;
    }
    ans=min(ans,sum+c*nowp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 17524
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
typedef long long ll;
using namespace std;

int main() {
    int a, b, count = 0, d;
    cin >> a >> b;
    vector<int>x(5);
    
    for(int i = a; i <= b; i++) {
        d = i;
        for(int j = 0; j < 5; j++) {
            x[j] = d%10;  d /= 10;
        }
        if(x[0] == x[4] && x[1] == x[3]) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
l=list(map(int,input().split()))
n=l[0]
w=l[1]
va=[0]*n
wa=[0]*n
for i in range(n):
        
    x=list(map(int,input().split()))
    wa[i]=x[0]
    va[i]=x[1]
dp=[[0 for i in range(w+1)] for j in range(n+1)]
for i in range(1,n+1):
  for j in range(1,w+1):
    if wa[i-1]>j:
      dp[i][j]=dp[i-1][j]
    else:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-wa[i-1]]+va[i-1])
print(dp[-1][-1])


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

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORTASC(c) sort((c).begin(), (c).end())
#define SORTDESC(c, t) sort((c).begin(), (c).end(), std::greater<t>());
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

const double PI = acos(-1.0);

using ll = long long;
using namespace std;

int main()
{
    ll n, r;

    cin >> n >> r;

    if (n >= 10){
        cout << r << endl; 
    } else {
        cout << r + 100 * (10-n) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
using namespace std;
int main() {
    int H,N;
    cin >> H >> N;
    bool flg=false;
    for (int i=0; i<N; i++) {
        int A; cin >> A;
        H -= A;
        if (H<=0) flg=true;
    }
    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

int a, b;

inline bool isLeap(int y)
{
  if(!(y % 400)) return true;
  if(!(y % 100)) return false;
  if(!(y % 4))   return true;
  return false;
}

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

  while(a && b){
    int res = 0;
    bool flag = false;
    erep(i, a, b) if(isLeap(i)){
      flag = true;
      cout << i << endl;
    }
    if(!flag) cout << "NA" << endl;
    if((cin >> a >> b) && a && b) cout << endl;
  }

  return 0;
}

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

int main() {
    cin.tie(0); ios_base::sync_with_stdio(0);
    int n, sum = 0; cin >> n;
    for(int i = 1;;i++) {
        sum += i;
        if(sum >= n) {
            cout << i << "\n";
            break;
        }
    }
}

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

int main()
{
  int n;
  int count=0;
  int s=0;
  int min=10000000;
  
  cin>>n;
  
  vector<int> p(n);
  vector<int> check(n);
  fill(check.begin(),check.end(),0);
    
    for(int i=0;i<n;i++)
    {
      cin>>s;
      if(min>=s)
      {
        min=s;
        count++;
      }
    }
  
  	
      cout<<count<<endl;
  
	return 0;
    }

Measured memory_bytes: 1792
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

N,K=rl()
h=[0]*N
for i in range(N):
    h[i] = ri()

h.sort()
s = h[K-1]-h[0]
ans = s

for i in range(1,N-(K-1)):
    s = h[i+K-1] - h[i]
    if ans > s:
        ans = s

print(ans)


Measured memory_bytes: 7472
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
	int n, k; cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 1e9;
	for (int i = 0; i < n-k+1; ++i) {
		int L = a[i];
		int R = a[i + k-1];
		ans = min(ans, R - L);
	}
	cout << ans << endl;
	return 0;
}



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

def gcd(a,b):
  aa=max(a,b)
  bb=min(a,b)
  cc=aa%bb
  return gcd(bb,cc) if cc else bb
  
p=gcd(a[0],a[1])
for i in range(2,n):
  p=gcd(p,a[i])
print(p)
  



Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
int main()
{
	int n,i,j,x,y;
	cin>>n;
	set<pair<int,int> > st;
	for(i=0;i<n;i++)
	{
		cin>>x;
		st.insert(mp(x,i+1));
	}
	set<pair<int,int> >::iterator it = st.begin();
	for(;it!=st.end();it++)
		cout<<(it->s)<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;

int S[maxn];
int n,q;

int query(int x) {
	int ans=0;
	for (int i=x;i>0;i-=i&-i)
		ans+=S[i];
	return ans;
}

int main() {
	cin>>n>>q;
	for (int i=0;i<q;i++) {
		bool op; cin>>op;
		if (op) {
			int s,t; cin>>s>>t;
			cout<<query(t)-query(s-1)<<'\n';
		}
		else {
			int k,x; cin>>k>>x;
			for (int i=k;i<=n;i+=i&-i)
				S[i]+=x;
		}
	}
}


Measured memory_bytes: 3484
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    vector<char> v = {'A', 'T', 'G', 'C'};
    string s;
    cin >> s;
    int ans = 0;
    REP(i, s.length()){
        for(int j=i; j<s.length(); j++){
            string t = s.substr(i, j - i + 1);
            //cout << t << endl;
            bool flag = true;
            REP(k, t.length()){
                if(find(all(v), t[k]) == v.end()){
                    flag = false;
                    break;
                }
            }
            if(flag){
                ans = max(ans, (int)t.length());
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
index = 0
suml = 0
sumr = sum(A)
diff = sumr
ans = 0
for i in range(n):
    suml += A[i]
    sumr -= A[i]
    tmp  = abs(sumr -suml)
    if diff < tmp:
        ans = diff
        break
    diff = tmp
print(ans)


Measured memory_bytes: 26764
//#####   #####   #####   #####   #####   #       #####   #   #//
//#   #   #   #   #       #       #   #   #       #   #   ## ##//
//#####   #####   #####   #       #####   #       #####   # # #//
//##      #   #       #   #       #   #   #       #   #   #   #//
//# #     #   #       #   #       #   #   #       #   #   #   #//
//#  #    #   #       #   #       #   #   #       #   #   #   #//
//#   #   #   #   #####   #####   #   #   #####   #   #   #   #//


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ppb pop_back
#define cs(n) cout<<n<<" "
#define cn(n) cout<<n<<"\n"
#define rep(i,j,k) for(int i=j;i<k;i++)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int n, k;
vector<ll>q;
ll bin(ll a, ll b, ll mod)
{
	if (b == 0)
		return 1;
	if (b % 2 == 0)
		return bin((a * a) % mod , b / 2 , mod) % mod;
	return ((a % mod) * (bin((a * a) % mod , b / 2 , mod) % mod)) % mod;
}
bool func(int mid) {
	if (mid == 0) {
		return false;
	}
	int c = 0;
	for (auto j : q) {
		if (j <= mid) {
			break;
		}
		c += (ll)(j / mid);
	}
	if (c <= k) {
		return true;
	}
	return false;
}
void solve()
{
	cin >> n >> k;
	rep(i, 0, n) {
		ll a;
		cin >> a;
		q.pb(a);
	}
	sort(q.rbegin(), q.rend());
	int lo = 1, hi = q[0];
	while (hi - lo > 1) {
		int mid = (hi + lo) / 2;
		if (func(mid)) {
			hi = mid;
		}
		else {
			lo = mid + 1;
		}
	}
	if (func(lo)) {
		cout << lo;
	}
	else {
		cout << hi;
	}
	// for (auto k : q) {
	// 	cout << k << " ";
	// }
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif
	fastio;
	int t;
	t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
	}
#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int p[n],ans=0;
  for(int i=0; i<n; i++) cin >> p[i];
  for(int i=0; i<=100; i++) {
    int cnt=0;
    for(int j=0; j<n; j++) if(p[j]>=i) cnt++;
    if(cnt>=i) ans=i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3068
#include<iostream>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

int a[1111][1111];
int count[1111][1111];

int main(){
  int h, w, n;
  for (;;) {
    cin >> h >> w >> n;
    if (h == 0 && w == 0 && n == 0) break;
    rep (i, h) rep (j, w) cin >> a[i][j];
    rep (i, h) rep (j, w) count[i][j] = 0;
    count[0][0] = n - 1;
    rep (i, w - 1) count[0][i + 1] = (count[0][i] + a[0][i]) / 2;
    rep (i, h - 1) count[i + 1][0] = (count[i][0] + 1 - a[i][0]) / 2;
    rep (i, h - 1) rep (j, w - 1) {
      count[i + 1][j + 1] = (count[i + 1][j] + a[i + 1][j]) / 2
	+ (count[i][j + 1] + 1 - a[i][j + 1]) / 2;
    }
    rep (i, h) rep (j, w) a[i][j] ^= count[i][j] % 2;
    int x = 0, y = 0;
    while (x < w && y < h) {
      if (a[y][x] == 1) ++x;
      else ++y;
    }
    cout << y + 1 << " " << x + 1 << endl;
  }
}

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

int GCD(int a,int b){return b? GCD(b,a%b):a;}

int main(){
    long long res=0;
    int N;cin>>N;
    for(int i=1;i<N+1;i++){
        for(int j=1;j<N+1;j++){
            for(int k=1;k<N+1;k++){
                res+=GCD(i,GCD(j,k));
                
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3636
package main
import "fmt"
func main(){
    // Your code here!
    var n int
    fmt.Scan(&n)
    t := make([]int, n)
    var k int
    fmt.Scan(&k)
    for i := 0; i < n; i++ {
        fmt.Scan(&t[i])
    }
    tt := make([]float64, n-(k-1))
    //fmt.Println(tt)
    for i := 0; i < k; i++{
        tt[0] += ev(t[i])
    }
    //fmt.Println(tt)
    for i := 1; i < len(tt); i++{
        //fmt.Println(t[i-1], t[i+k-1])
        tt[i] = tt[i-1] - ev(t[i-1]) + ev(t[i+k-1])
        //fmt.Println(tt)
    }
    
    max := 0.0
    //fmt.Println(tt)
    for i := 0; i < len(tt); i++{
        if max < tt[i]{
            max = tt[i]
        }
    }
    fmt.Println(max)
}

func ev(v int) float64{
    var sum int
    for i := 1; i <= v; i++{
        sum += i
    }
    return float64(sum)/float64(v)
}

Measured memory_bytes: 6272
N, M = [int(x) for x in input().split()]

def check(x):
  if M < 2*x:
    return False
  s = max(0, x-N)
  if M < 2*s + 2*x:
    return False
  return True

ok = 0
ng = 2**60
while ng - ok > 1:
  m = (ok + ng) // 2
  if check(m):
    ok = m
  else:
    ng = m
print(ok)

Measured memory_bytes: 3064