akhauriyash/Code-Regression huggingface dataset:
import Control.Monad
import Data.IntMap.Strict ((!), fromList, IntMap)
import Data.IntSet hiding (map, fromList)
import qualified Data.IntSet as S
import Data.Function

main :: IO ()
main = do
  l1 <- getLine
  l2 <- getLine
  let [n, m] = map read $ words l1 :: [Int]
      h = fromList $ zip [1..] $ map read $ words l2 :: IntMap Int
  lm <- replicateM m getLine
  let ab = map (map read . words) lm :: [[Int]]

  print $ size $ proc h (S.fromList [1..n]) ab

proc h s [] = s
proc h s ([a, b]:ab) = proc h s' ab
  where
    c = (compare `on` (h !)) a b
    s' = case c of
      EQ -> delete a $ delete b s
      LT -> delete a s
      GT -> delete b s


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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    string S;
    int K;
    cin >> S >> K;
    string T = S;
    set<string> st;
    bool frag = 0;
    int b = 0;
    for(int i = 0;i < 26;i++){
      char a = 'a' + i;

      for(int j = 1;j <= S.size();j++){
        for(int k = 0;k < S.size();k++){
          if(S[k] == a && k + j - 1 < S.size()){
            //cout << S.substr(k,j) << endl;
            st.insert(S.substr(k,j));
            if(st.size() > K){
              frag = 1;
            }
            b++;
            //cout << st.size() << endl;
          }
        }
        if(b > 100000){
          break;
        }
        /*if(frag){
          break;
        }*/
      }
      if(frag){
        break;
      }
    }
    ll N = st.size();
    //cout << N << endl;
    int cnt = 0;
    for(auto x : st){
      cnt++;
      if(cnt == K){
        cout << x << endl;
      }
    }
}


Measured memory_bytes: 49664
import sys
from collections import deque

input = sys.stdin.readline


def bfs(N):
    res = 0
    queue = deque(["3", "5", "7"])
    while queue:
        num = queue.popleft()
        if int(num) > N:
            break
        if all(("3" in num, "5" in num, "7" in num)):
            res += 1
        queue.append("".join([num, "3"]))
        queue.append("".join([num, "5"]))
        queue.append("".join([num, "7"]))
    return res


def main():
    N = int(input())

    ans = bfs(N)

    print(ans)


if __name__ == "__main__":
    main()


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

int field[20][20];
int w,h;
int bfs(int, int);

int main(){
  int x,y;

  while(cin>>w>>h&&w!=0&&h!=0){
    for(int j=0;j<h;j++){
      for(int i=0;i<w;i++){
        char c;
        cin >> c;
        if(c=='.')field[i][j]=1;
        else if(c=='#')field[i][j]=-1;
        else if(c=='@'){
          field[i][j]=0; 
          x=i;
          y=j;
        }
      }
    }
    int ans=bfs(x, y);
    cout << ans+1 << endl;
  }

  return 0;
}

int bfs(int x, int y){
  int count=0;
  if(y-1>=0&&field[x][y-1]==1){
    field[x][y-1]=-1;
    count++;
    count+=bfs(x, y-1);
  }
  if(y+1<h&&field[x][y+1]==1){
    field[x][y+1]=-1;
    count++;
    count+=bfs(x, y+1);
  }
  if(x-1>=0&&field[x-1][y]==1){
    field[x-1][y]=-1;
    count++;
    count+=bfs(x-1, y);
  }
  if(x+1<w&&field[x+1][y]==1){
    field[x+1][y]=-1;
    count++;
    count+=bfs(x+1, y);
  }
  return count;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define maxs 2020022
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
int fa[maxs];

void init(int n)
{
    for(int i=0;i<=n;i++){
        fa[i]=i;
    }
}

int getfa(int x){
    return x==fa[x]?x:fa[x] = getfa(fa[x]);
}

void Merge(int x,int y){
    int rx = getfa(x),ry = getfa(y);
    if(rx != ry) fa[rx]  = ry;
}

struct node{
    int x,y;
    int id;
}a[maxs];

struct newnode{
    int u,v;
    int dis;
}nd[maxs];


bool cmpx(node ax,node ay){
    return ax.x<ay.x;
}

bool cmpd(newnode ax,newnode ay){
    return ax.dis<ay.dis;
}

bool cmpy(node ax,node ay){
    return ax.y<ay.y;
}

int main(){
    int n;
    while(~scanf("%d",&n)){
        for(int i=1;i<=n;i++){
            scanf("%d%d",&a[i].x,&a[i].y);
            a[i].id = i;
        }

        init(n);
        int len=0;
        sort(a+1,a+1+n,cmpx);
        for(int i=1;i<n;i++){
            nd[len].u = a[i].id;
            nd[len].v = a[i+1].id;
            nd[len++].dis = a[i+1].x-a[i].x;
        }
        sort(a+1,a+n+1,cmpy);
        for(int i=1;i<n;i++){
            nd[len].u=a[i].id;
            nd[len].v=a[i+1].id;
            nd[len++].dis = a[i+1].y-a[i].y;
        }
        sort(nd,nd+len,cmpd);
        long long ans = 0;

        for(int i=0;i<len;i++){
            int ri = getfa(nd[i].u),rii = getfa(nd[i].v);
            if( ri != rii){
                ans+=nd[i].dis;
                Merge(nd[i].u,nd[i].v);
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}

/*
6
8 3
4 9
12 19
18 1
13 5
7 6

3
1 5
3 9
7 8
*/

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

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)1e5+100;


int main(void) {
   ll M,D;
   cin>>M>>D;
   ll M2,D2;
   cin>>M2>>D2;
   cout<<!(M2==M)<<endl;






   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
const ll mod = 1e9+7;

int main(){
    int a,b;
    cin >> a >> b;
    PRINT(6-a-b);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    
    
    
    int tmp,x,y,i=0,k,count=0,ans=0,arr[3];
    for(i=0;i<3;i++){
        scanf("%d",&arr[i]);
    }
    x = arr[0];
    y = arr[1];
    k = arr[2];
    while (x % y != 0) {
        tmp = y;
        y = x % y;
        x = tmp;
    }
    
        for(i=y; i >0; i--)
        {
            if (y%i == 0)
            {
                ans = i;
                count++;
                if(count==k){
                    printf("%d",ans);
                    break;
                }
            }
        }
    
    
    
    return 0;
}

Measured memory_bytes: 128
x, n = map(int, input().split())
p_list = [int(i) - x for i in input().split()]
p_list.sort()
for i in range(200):
    if i * (-1) not in p_list:
        print(i * (-1) + x)
        exit()
    elif i not in p_list:
        print(i + x)
        exit()

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define f first
#define s second
using namespace std;
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;

void solve() {
	int n; cin >> n;
	ll ans = 1;
	vector<ll> a(n);
	for (int i = 0; i < n; i ++) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << 0 << '\n';
			return;
		}
	}
	for (int i = 0; i < n; i ++ ){
		if (INFl / a[i] < ans) {
			cout << -1 << '\n';
			return;
		}
		ans *= a[i];
	}
	
	cout << ans << '\n';
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int q = 1;
	//cin >> q;
	while (q--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3992
import math
n, k = map(int, input().split())
a_list = []
a_index = 0
for i, a in enumerate(input().split()):
    if a == 1:
        a_index = i
    a_list.append(a)

left = a_index
right = n - a_index - 1

# k-1ずつへる
print(math.ceil((left + right)/(k-1)))


Measured memory_bytes: 10740
using System;
using System.Text;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string input;
            var sb = new StringBuilder();
            while ((input = Console.ReadLine())!=null)
            {
                sb.Append(input.ToLower());
            }

            var di = new int[26];
            for (int i = 0; i < sb.Length; i++)
            {
                if (char.IsLetter(sb[i]))
                {
                    di[sb[i] - 'a']++;
                }
            }

            for (char i = 'a'; i <= 'z'; i++)
            {
                Console.WriteLine("{0} : {1}", i, di[i - 'a']);
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 5668
#pragma region 
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<string>
typedef long long ll;
template <typename T>void read(T &x){x=0;char ch=getchar();ll f=1;while(!isdigit(ch)){if(ch=='-')f*=-1;ch=getchar();}while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}x*=f;}
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
#pragma endregion
const int maxn = 105;
int a[maxn], b[maxn], c[maxn], d[maxn];
int n, m, q;
int A[maxn];
ll ans = 0;
void check() {
    ll maxx = 0;
    for (int i = 1; i <= q;++i) 
        if (A[b[i]]-A[a[i]]==c[i])
            maxx += d[i];
    ans = max(ans, maxx);
}
void dfs(int k,int x) {
    if (k==n+1) {
        check();
        return;
    }
    for (int i = x; i <= m;++i) {
        A[k] = i;
        dfs(k + 1, i);
    }
}
int main() {
    IO;
    cin >> n >> m >> q;
    for (int i = 1; i <= q;++i)
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(1,1);
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int m, n;
	while (cin >> n >> m, n) 
	{
		vector<int> p(n+1);

		for (int i = 1; i <= n; i++)cin >> p[i];

		sort(p.begin(), p.end());
		reverse(p.begin(), p.end());

		ll sum = 0;
		for (int i = 1; i <= n; i++) {
			if (i%m != 0)sum += p[i-1];
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
#include<stdio.h>
int main()
{
    long long int n, a, b;
    scanf("%lld %lld %lld", &n, &a, &b);
    if(a>b || (n==1 && a!=b))
    {
        printf("0");
    }
    else
    {
        printf("%lld", (n-1)+((b-a-1)*(n-2)));
    }
    return 0;
}

Measured memory_bytes: 1696
x, n = map(int, input().split())
p = list(map(int, input().split()))
MIN = float('inf')
ans = 0

if x not in p:
    print(x)
else:
    i = 1
    while True:
        if x-i not in p:
            print(x-i)
            break
        elif x+i not in p:
            print(x+i)
            break
        else:
            i += 1

Measured memory_bytes: 9132
N = int(input())
a_list = list(map(int, input().split()))

evaluate_value = 1
cnt = 0

for i in range(N):
  if evaluate_value == a_list[i]:
    evaluate_value += 1
    cnt += 1

if cnt == 0:
  print(-1)
else:
  print(N - cnt)

Measured memory_bytes: 26140
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p=sum(a)
b.append(0)
for i in range(len(a)):
    if a[i]-b[i]<0:
        if a[i+1]-b[i]+a[i]<0:
            a[i+1]=0
        else:
            a[i+1]-=b[i]-a[i]
        a[i]=0
    else:
        a[i]-=b[i]
print(p-sum(a))

Measured memory_bytes: 18624
import java.io.*;
import java.math.BigDecimal;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));

        StringTokenizer st = new StringTokenizer(br.readLine());
        BigDecimal a = new BigDecimal(st.nextToken());
        BigDecimal b = new BigDecimal(st.nextToken());

        BigDecimal prod = a.multiply(b);
        prod = prod.setScale(0, BigDecimal.ROUND_DOWN);

        pw.println(prod);
        pw.close();
    }
}


Measured memory_bytes: 33084
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=2e5+10;

int n;
long long a[N];

long long solve()
{
	long long Ans=0;
	long long now=a[1];
	int opt=a[1]>0;
	for(int i=2;i<=n;i++)
	{
		if(opt==1)
		{
			if(now+a[i]>=0)
			{
				Ans+=now+a[i]+1;
				now=-1;
			}
			else now+=a[i];
		}
		else
		{
			if(now+a[i]<=0)
			{
				Ans-=now+a[i]-1;
				now=1;
			}
			else now+=a[i];
		}
		opt^=1;
	}
	return Ans;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	long long Ans;
	if(a[1]==0)
	{
		a[1]=1;
		Ans=solve();
		a[1]=-1;
		Ans=min(Ans,solve());
		cout<<Ans+1<<endl;
		return 0;
	}
	else Ans=solve();
	if(a[1]>0)
	{
		long long x=a[1]+1;
		a[1]=-1;
		Ans=min(Ans,solve()+x);
	}
	else 
	{
		long long x=1-a[1];
		a[1]=1;
		Ans=min(Ans,solve()+x);
	}	
	cout<<Ans<<endl;
}
				

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


int main(){
  ll x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x),b(y),c(z);
  for(int i=0;i<x;++i) cin >> a[i];
  for(int i=0;i<y;++i) cin >> b[i];
  for(int i=0;i<z;++i) cin >> c[i];

  ll xy=x*y;
  vector<ll> ab(xy,0);
  int index=0;
  for(int i=0;i<x;++i){
    for(int j=0;j<y;++j){
      ll tmp=a[i]+b[j];
      ab.push_back(tmp);
    }
  }
  sort(ab.rbegin(),ab.rend());
  sort(c.rbegin(),c.rend());
  vector<ll> ans(k*k,0);
  ll cal=min(k,xy);
  ll cal2=min(z,k);
  for(int i=0;i<cal;++i){
    for(int j=0;j<cal2;++j){
      ll tmp=ab[i]+c[j];
      ans.push_back(tmp);
      //cout << tmp << endl;
    }
  }
  sort(ans.rbegin(),ans.rend());
  for(int i=0;i<k;++i) cout << ans[i] << endl;

  return 0;
}


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

int main()
{
  string s;
  cin>>s;
  int n=s.length();
  if(s[n-1]!='s')
  {
    s=s+"s";
    cout<<s<<endl;
  }
  else
  {
    s=s+"es";
    cout<<s<<endl;
  }
  return 0;
}
    

Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
  int N, K;
  cin >> N >> K;
  int x;

  int s{0};
  for (int i = 0; i < N; ++i) {
    cin >> x;
    s += 2*min(x,abs(x-K));
  }
  cout << s<< endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;


struct edge { int to, cost;};

class Dijkstra{
private:
    vector< vector<edge> > g;

public:
    Dijkstra(){};
    Dijkstra(int size){
        g.resize(size);
    }

    vi dist;

    void add(int a, int b, int c){//無向辺
        edge e1 = {b, c}, e2 = {a, c};
        g[a].push_back(e1);
        g[b].push_back(e2);//有向辺の場合はここをコメントアウトする
    }

    void calc(int s){
        priority_queue< pii, vector<pii>, greater<pii> > q;
        int n = g.size();
        dist = vi (n, (ll)INF*INF);
        dist[s] = 0;
        q.push(pii(0, s));

        while(!q.empty()){
            pii p = q.top();
            q.pop();
            int v = p.second;
            if(dist[v] < p.first)continue; //更新されていたら何もしない
            for(int i = 0; i < g[v].size(); i++){
                edge e = g[v][i];
                if(dist[e.to] > dist[v] + e.cost){
                    dist[e.to] = dist[v] + e.cost;
                    q.push(pii(dist[e.to], e.to));
                }
            }
        }
    }

};



signed main(void) {
    int i,j;
    int n,m,s,t;
    cin>>n>>m>>s>>t;
    s--,t--;
    Dijkstra g1 = Dijkstra(n);
    Dijkstra g2 = Dijkstra(n);
    rep(i,m){
        int u,v,a,b;
        cin>>u>>v>>a>>b;
        u--,v--;
        g1.add(u,v,a);
        g2.add(u,v,b);
    }

    g1.calc(s);
    g2.calc(t);
    vi ans(n+1);
    ans[n]=(ll)100000000000000000;

    for(int i = n-1; i >= 0; i--){
        ans[i]=min(ans[i+1], g1.dist[i]+g2.dist[i]);
    }
    rep(i,n)
        cout << (ll)1000000000000000-ans[i] << endl;


}


Measured memory_bytes: 19012
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();

		if (n % 500 <= a) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから
#define int64_t ll
bool is_prime(int64_t x) {
  if(x==0||x==1)return false;
  for(int64_t i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}

void solve(){
  int q;
  cin>>q;
  const int maxv=1e5;
  vector<bool>v(maxv+5);
  rep(i,maxv+3)v[i+1]=is_prime(i+1);
  vector<int>sum(maxv+5);
  rep(i,maxv+1){
    bool flag=false;
    if((i+1)%2==1&&v[i+1]==true&&v[(i+2)/2]==true)flag=true;
    sum[i+1]=sum[i]+flag;
  }
  while(q--){
    int l,r;
    cin>>l>>r;
    cout<<sum[r]-sum[l-1]<<"\n";
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))

maxv = [0]
for t, v in zip(T, V):
    maxv[-1] = min(maxv[-1], v)
    for i in range(2 * t):
        maxv.append(v)

T = len(maxv)
for i in range(1, T):
    maxv[i] = min(maxv[i - 1] + 0.5, maxv[i])

maxv[-1] = 0
for i in reversed(range(T - 1)):
    maxv[i] = min(maxv[i], maxv[i + 1] + 0.5)

ans = 0
for i in range(T - 1):
    ans += (maxv[i] + maxv[i + 1]) * 0.5 / 2

print(ans)


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

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> v(N, K - Q);
    int A;
    for (int i = 0; i < Q; i++) {
        cin >> A;
        v[A - 1]++;
    }
    for (int i = 0; i < N; i++) {
        if (v[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll int
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,m,k,x1,yy1,x2,y2,lt,rt;
vector<vl>dis;
string s;
set<ll>r[1000005],c[1000005],rr[1000005],cc[1000005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>k>>x1>>yy1>>x2>>y2;
    x1--;
    yy1--;
    x2--;
    y2--;
    rep(i,0,n)
    {
        cin>>s;
        rep(j,0,m)
        {
            if(s[j]=='@')
            {
                r[i].insert(j);
                c[j].insert(i);
            }
            else
            {
                rr[i].insert(j);
                cc[j].insert(i);
            }
        }
    }
    dis.resize(n);
    rep(i,0,n)
        dis[i].resize(m);
    dis[x1][yy1]=0;
    dis[x2][y2]=-1;
    rr[x1].erase(yy1);
    cc[yy1].erase(x1);
    queue<pll>q;
    q.push({x1,yy1});
    while(!q.empty())
    {
        pll g=q.front();
        q.pop();
        x1=g.F;
        yy1=g.S;
        lt=0;
        rt=m-1;
        auto it=r[x1].lb(yy1);
        if(it!=r[x1].begin())
            lt=(*prev(it))+1;
        if(it!=r[x1].end())
            rt=(*it)-1;
        lt=max(lt,yy1-k);
        rt=min(rt,yy1+k);
        for(auto it=rr[x1].lb(lt);it!=rr[x1].end() and (*it)<=rt;)
        {
            if((*it)<yy1)
                dis[x1][*it]=dis[x1][yy1]+1;
            else
                dis[x1][*it]=dis[x1][yy1]+1;
            q.push({x1,*it});
            cc[*it].erase(x1);
            it=rr[x1].erase(it);
        }

        lt=0;
        rt=n-1;
        it=c[yy1].lb(x1);
        if(it!=c[yy1].begin())
            lt=(*prev(it))+1;
        if(it!=c[yy1].end())
            rt=(*it)-1;
        lt=max(lt,x1-k);
        rt=min(rt,x1+k);
        for(auto it=cc[yy1].lb(lt);it!=cc[yy1].end() and (*it)<=rt;)
        {
            if((*it)<x1)
                dis[*it][yy1]=dis[x1][yy1]+1;
            else
                dis[*it][yy1]=dis[x1][yy1]+1;
            q.push({*it,yy1});
            rr[*it].erase(yy1);
            it=cc[yy1].erase(it);
        }
    }
    cout<<dis[x2][y2];

}


Measured memory_bytes: 289420
z=10
m=z**9+7
k=13
t=input()[::-1]
dp=[0]*k
dp[0]=1
for d in range(len(t)):
  p=[0]*k
  f=(t[d]=='?')
  for i in range(k):
    l=pow(z,d,k)
    for x in range(1+f*9):
      r=l*int(x if f else t[d])
      p[(i+r)%k]+=dp[i]
  dp=[j%m for j in p]
print(dp[5]%m)


Measured memory_bytes: 45496
#include <iostream>

using namespace std;

int n, a[4][14];

void solve() {
    for(int i = 0; i < 4; i++) {
        for(int j = 1; j < 14; j++) {
            if(a[i][j] != 1) {
                char ch ;
                if(i == 0) ch ='S';
                if(i == 1) ch ='H';
                if(i == 2) ch ='C';
                if(i == 3) ch ='D';
                cout << ch << " " << j << endl;
            }
        }
    }
}

int main() {
    cin >> n;
    char mark;
    int num;
    for(int i = 0; i < n; i++) {
        cin >> mark >> num;
        if(mark == 'S') a[0][num] = 1;
        if(mark == 'H') a[1][num] = 1;
        if(mark == 'C') a[2][num] = 1;
        if(mark == 'D') a[3][num] = 1;
    }
    solve();
}


Measured memory_bytes: 3060
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

A=gets.to_i
B=gets.to_i
if A==B
    puts "EQUAL"
elsif A>B
    puts "GREATER"
else
    puts "LESS"
end

Measured memory_bytes: 3836
#include <stdio.h>
int main(){

    int n, i, x;

    scanf("%d",&n);
    for(i = 1; i <= n; i++){
        x = i;
        if(x%3 == 0){
            printf(" %d",x);
        }
        else{
            while(x != 0){
                if(x%10 == 3){
                    printf(" %d",i);
                    break;
                }
                x = x/10;
            }
        }
    }
    printf("\n");

    return 0;
}


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

signed main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    int sum = 0;
    int t = 0;
    for(int i=0; i<=500; ++i) {
        for(int j=0; j<=500; ++j) {
            if(i==0&&j==0) continue;
            for(int k=0; k<=500; ++k) {
                for(int l=0; l<=500; ++l) {
                    int A = a*i, B = b*j, C = c*k, D = d*l;
                    if((100*A+100*B+C+D)>f) {
                        break;
                    }
                    if((double)(C+D)/(double)(100*(A+B))*1000>e*10) break;
                    if(sum==0 || (double)t*100/(double)sum< 100*(double)(C+D)/(double)(100*A+100*B+C+D)) {
                        //cout << A << " " << B << " " << C << " " << D << endl;
                        sum = 100*A+100*B+C+D;
                        t = C+D;
                    }
                }
            }
        }
    }
    cout << sum << " " << t << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1, typename T2>
inline bool cmn (T1& a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
inline bool cmx (T1& a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T>
class bellman_ford {
  using edge_t = tuple<T, int, int>;
  const int n, r;
  const vector<edge_t>& edg;
  bool flg;
  vector<long long> dst;
  void cal () {
      dst[r] = 0;
      for (int q = n; q--;) {
        flg = false;
        for (auto const& e : edg) {
          T d; int s, t; tie(d, s, t) = e;
          if (dst[s] == inf) continue;
          if (cmn(dst[t], dst[s] + d)) flg = true;
        }
      }
  }
  public:
    const T inf;
    bellman_ford (
        const int n, const int r,
        const vector<edge_t>& edg,
        const T inf
      ) :
      n(n), r(r), edg(edg), 
      flg(false), dst(n, inf), inf(inf)
      {
        cal();
      }
    bellman_ford (
        const int n, const int r,
        const vector<edge_t>& edg
      ) :
      bellman_ford(n, r, edg, numeric_limits<T>::max())
      {
      }
    bool has_negative_cycle () const {return flg;}
    auto& result () {return dst;}
};
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n, m, r;
  cin >> n >> m >> r;
  vector<tuple<int, int, int>> edg;
  for (int i = 0; i < m; i++) {
    int d;
    int s, t;
    cin >> s >> t >> d;
    edg.emplace_back(d, s, t);
  }
  bellman_ford<int> bf(n, r, edg);
  if (bf.has_negative_cycle()) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    auto dst = bf.result();
    for (auto const& x : dst) {
      cout << (x == bf.inf ? "INF" : to_string(x)) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3288
#include<iostream>
#include<cmath>
#include<iomanip>
#include<array>
#include<string>
#include<vector>
using namespace std;
typedef int q;
typedef double w;
int main()
{
	q a;
	cin>>a;
	if(a<1200){cout<<"ABC";}
	else if(a<2800){cout<<"ARC";}
	else{cout<<"AGC";}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
return 0;}

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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())


void solve(ll a, ll b, ll c, ll d, ll e, ll k){
    bool flag = true;
    if (e-a > k) flag = false;
    if (flag) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

int main() {
  ll a;
    scanf("%lld",&a);
    ll b;
    scanf("%lld",&b);
    ll c;
    scanf("%lld",&c);
    ll d;
    scanf("%lld",&d);
    ll e;
    scanf("%lld",&e);
    ll k;
    scanf("%lld",&k);
  solve(a, b, c, d, e, k);
  return 0;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    char c;
    cin >> c;
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    {
        cout << "vowel" << endl;
    }
    else
    {
         cout << "consonant" << endl;
    }
    return 0;
}


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

int main()
{
    string s;
    int flag=0;
    cin>>s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7') flag=1;
    if(flag) cout<<"Yes";
    else cout<<"No";
    
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    int n;
    cin>>n;
    vector<int> a(n+1,0);
    for(int i=1;i<=n;i++){
	cin>>a[i];
    }
    //bool flag = true;
    int cnt = 0;
    for(int i=1;i<=n;i++){
	if(i == a[i] ) continue;
	for(int j=1;j<=n;j++){
	    if(i == a[j] ){
		cnt++;
		//cout<<t<<endl;
		swap(a[i],a[j]);
		break;
	    }
	}
//	if( t < i ){
//	    flag = false;
//	    break;
//	}
    }

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


Measured memory_bytes: 256
#!/user/bin/env python
#pythonプログラムであることを示している

# -*- coding: utf-8 -*-
"""
このプログラムはPythonを書く際のテンプレとなっています。これをコピペしてコーディングを行なってください。
なお字下げしないこと！！
"""

__author_ = 'Maruta Yuzuha'
__version_ = '1.0.0'
__date__ = '2019/12/25'

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = input().split()
    if (s[0] == s[1]) and int(s[0]) <= 100 and int(s[0]) >= 0:
        print('Yes')
    else: 
        print('No')
    
    return 0

if __name__ == '__main__':
    #上記のifの記述によってこのスクリプトファイルが起動された時だけ実行する部分になる。
    #ちなみにスクリプトが "モジュールとして"インポートされた時には実行されない、

    #単体テスト:モジュールのdocstring(ドキュメンテーション文字列)に記載された全ての対話実行例が書かれている通りに動作するかを確認
    #python ファイル名 -v
    import doctest
    doctest.testmod()

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

Measured memory_bytes: 8428
N = gets.to_i
if N >= 1 && N <= 9
  puts N
elsif N >= 10 && N <= 99
  puts 9
elsif N >= 100 && N <= 999
  puts N - 99 + 9
elsif N >= 1_000 && N <= 9_999
  puts 9 + (999 - 100 + 1)
elsif N >= 10_000 && N <= 99_999
  puts N - 9999 + 900 + 9
elsif N == 100_000
  puts 90_909
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e17;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
template<typename T>
vector<T> cumulative_sum(vector<T> &v) {
    vector<T> sum(v.size() + 1);
    for(int i = 0; i < (int)v.size(); ++i){
        sum[i+1] = sum[i] + v[i];
    }
    return sum;
}
/*使うとき
vector<int> a(N);
auto cum = cumlative_sum(a)
とするとvector<int> cumが生成される

i番目までの仕切りの和
cum[i]: [0,i)の和（半開区間）

要素i~jの和が欲しい時
j+1 ~ i番目の仕切りまで数えればよい
int sum = cum[j+1]-cum[i]
*/
int N;
//dp[l][r]: [l, r)の区間を作るための最小値
ll dp[432][432];
vector<ll> cum;
void debug(){
    rep(i,N){
        rep(j,N){
            if(dp[i][j] == INFLL)cerr<<-1<<" ";
            else cerr<<dp[i][j]<<" ";
        }
        cerr<<endl;
    }
    cerr<<endl;
}

ll dfs(int l, int r){
    if(l == r || l == r + 1)return 0;
    if(dp[l][r] != INFLL)return dp[l][r];
    ll res = INFLL;
    ll cost = cum[r] - cum[l];
    for(int k = l+1; k < r;k++){
        chmin(res, dfs(l,k) + dfs(k,r) + cost);
    }
    dp[l][r] = res;
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    cin >> N;
    vector<ll> a(N);
    rep(i,N)cin>>a[i];
    cum = cumulative_sum(a);

    /*
    auto summ = [&](int l, int r){
        return cum[r] - cum[l];
    };
    */

    rep(i, N+1)rep(j, N+1){
        dp[i][j] = INFLL;
    }
    //長さ0, 1の場合の初期化
    rep(i,N+1){
        dp[i][i] = 0;
        dp[i][i+1] = 0;
    }

    /*
    for(int len = 2; len <= N; len++){
        for(int l = 0; l < N; l++){
            int r = l + len;
            if(r > N)continue;
            for(int k = l;k <= r;k++){
                chmin(dp[l][r], dp[l][k] + dp[k][r] + summ(l,r));            
            }
        }
    }*/
    cout << dfs(0, N) << endl;
}

Measured memory_bytes: 1664
def count(Y, M, D) :
	thr = (Y - 1) // 3
	cnt = (Y - thr - 1) * 195 + thr * 200
	if(Y % 3 == 0) :
		cnt += (M - 1) * 20 + D
	else :
		m = (M - 1) // 2
		cnt += (M - m - 1) * 20 + m * 19 + D
	print(Mil - cnt + 1)

n = int(input())

Mil = 666 * 195 + 333 * 200

for i in range(n) :
	Y, M, D = map(int, input().split())
	count(Y, M, D)
	


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

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

ll N, M;

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

    ll lin = 0, rin = 0;
    ll lhs = 0, rhs = 0;

    rep(i, M)
    {
        cin >> lin >> rin;

        if (i == 0)
        {
            lhs = lin;
            rhs = rin;
        }

        lhs = max(lhs, lin);
        rhs = min(rhs, rin);
    }

    cout << max<ll>(0, rhs - lhs + 1) << endl;

    return 0;
}


Measured memory_bytes: 256
//https://codeforces.com/blog/entry/64250?fbclid=IwAR2gUYNv6XP1qDbhkwuc_nVXFNxQ8fQrZ53dZHFCTomNUvINIBv9LIpbWCQ#comment-482534

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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

#define Make(x,p)       (x | (1<<p))
#define DeMake(x,p)     (x & ~(1<<p))
#define Check(x,p)      (x & (1<<p))
#define popcount(x)     __builtin_popcount(x)

const LL MOD=1e9+7;
const int N=3003;
LL dp[2][N];

int main(){
    int n;
    string s;
    cin >> n >> s;
    FOR(i,1,n) dp[0][i]+=dp[0][i-1]+1; //I really don't get it
    int now=0;
    FOR(i,1,n-1){
        now=1-now;
        if(s[i-1]=='>') {
            FOR(j,1,i+1) {
                dp[now][j]=(dp[now][j-1]+dp[1-now][i]-dp[1-now][j-1])%MOD;
            }
        }
        else{
            FOR(j,1,i+1){
                dp[now][j]=(dp[now][j-1]+dp[1-now][j-1])%MOD;
            }
        }
    }
    LL ans=(dp[now][n]+MOD)%MOD;
    cout << ans;
}


Measured memory_bytes: 256
import math
 
def dcos(x):
    return math.cos(math.radians(x))
 
A, B, H, M = map(int, input().split())
 
one_H = 360 / 12
one_M = 360 / 60
one_H_M = one_H / 60
 
#短針の動きのみ考える。
kakudo_H = one_H * H
#分針の動きを加える。
kakudo_H = kakudo_H + one_H_M*M
 
# if kakudo_H > 180:
#     kakudo_H = 360 - kakudo_H
 
kakudo_M = one_M * M
# if kakudo_M > 180:
#     kakudo_M = 360 - kakudo_M
 
kakudo = abs(kakudo_M - kakudo_H)

ans = A**2 + B**2 + (-2)*A*B*dcos(kakudo)
 
print(ans**0.5)

Measured memory_bytes: 9576
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] In = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int n = In[0];
            int m = In[1];
            int[] L = new int[m];
            for(int i=0; i < n; i++)
            {
                int[] In2 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                int k = In2[0];
                for(int j = 1; j <= k; j++)
                {
                    int a = In2[j];
                    a--;
                    L[a]++;
                }
            }
            int cnt = 0;
            for(int i = 0; i < m; i++)
            {
                if (L[i] == n) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 28296
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int a;
  cin >> a;
  cout << a*800 - (a/15)*200 << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int a[] = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);

		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (x <= 0) break;
			x -= a[i];
			ans++;
		}

		if (x == 0) {
			System.out.println(ans);
		} else {
			System.out.println(ans - 1);
		}

		sc.close();
	}

}


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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


lli yoko(lli h, lli w) {
    if (h <= 2 && w <= 2)
        return LLONG_MAX;
    if (h % 3 == 0) {
        return 0;
    }
    else {
        return w;
    }
}

lli yokotate(lli h, lli w) {
    // ha は h / 3 か h / 3 + 1 のいずれか
    // wb/wc は w / 2 か w / 2 + 1 のいずれか
    lli ret = LLONG_MAX;
    REPE(ha, h/3, h/3+1) {
        REPE(wb, w/2, w/2+1) {
            if (ha == 0)
                continue;

            lli hb, hc;
            lli wa, wc;
            hb = hc =  h - ha;
            wa = w;
            wc = w - wb;

            lli max_area = max({wa * ha, wb * hb, wc * hc});
            lli min_area = min({wa * ha, wb * hb, wc * hc});
            ret = min(ret, max_area - min_area);
        }
    }
    return ret;
}

int main() {
    lli h, w;
    cin2(h, w);

    lli ans1 = LLONG_MAX;
    lli ans2 = LLONG_MAX;
    lli ans3 = LLONG_MAX;
    lli ans4 = LLONG_MAX;


    // 横斬り
    ans1 = yoko(h, w);
    // 縦横斬り、横先
    ans2 = yokotate(h, w);
    // 縦斬り
    ans3 = yoko(w, h);
    // 縦横斬り、縦先
    ans4 = yokotate(w, h);

    //cout1(ans1);
    //cout1(ans2);
    //cout1(ans3);
    //cout1(ans4);
    cout << min({ans1, ans2, ans3, ans4}) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll A, B;
    cin >> A >> B;
    ll ans = -1;
    for(ll c=1;c<=10000;c++){
        // cout << ll(c * 0.08) << "," <<c * 0.1 <<endl;
        ll maybe_a = c * 8 / 100;
        if(maybe_a == A && c / 10 == B){
            ans = c;
            break;
        }
    }
    cout << ans <<endl;


}

int main(){
    Main();
}

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

int main() {
  string s;cin >> s;
  int mon=(s[5]-'0')*10+(s[6]-'0');
  if(mon<5){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#define MN 4000
#define MOD 998244353
int c[MN+5][MN+5],p[MN+5];
int cal(int n,int k,int x)
{
	int res=0,i;k-=2*x;
	for(i=0;i<=x;++i)res=(res+1LL*c[x][i]*p[i]%MOD*c[n+k-1][k+i-1])%MOD;
	return res;
}
int main()
{
	int n,k,i,j,x;
	scanf("%d%d",&k,&n);
	for(i=0;i<=MN;++i)for(c[i][0]=j=1;j<=i;++j)c[i][j]=(c[i-1][j]+c[i-1][j-1])%MOD;
	for(p[0]=i=1;i<=MN;++i)p[i]=2*p[i-1]%MOD;
	for(i=2;i<=2*k;++i)
	{
		for(x=0,j=1;j<i-j;++j)if(i-j<=k)++x;
		if(i&1)printf("%d\n",cal(n,k,x));
		else printf("%d\n",(cal(n,k-1,x)+cal(n-1,k-1,x))%MOD);
	}
}

Measured memory_bytes: 61312
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int a[12][12];
const int INF = 1001001001;
int main() {
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i,n){
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }
  int ans = INF;
  rep(s,1<<n){
    int cost = 0;
    vector<int> d(m);
    rep(i,n){
      if(s>>i&1){
      cost += c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if(d[j] < x) ok = false;
    if(ok) ans = min(ans,cost);
  }
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long 
#define sort(v) sort(v.begin(),v.end()) 
#define pb push_back
/*

ll ar[1000000+9]={0}; 
void seiv() { 
ll n=1000000,i,j; 
ar[1]=1; 
for(i=4;i<=n;i+=2)ar[i]=1; 
for(i=3;i<=n;i+=2) 
{ if(ar[i]==0) 
{ for(j=i*i;j<=n;j+=i*2)ar[j]=1; }
 }
 
 }
*/
 int main(){
ll a,b,d,e,i,j,k,c,x, y=1,l=0;
cin>>a>>b;
for(i=1;i<=a;i++)
{
        
       cin>>c>>d;
             x=c*c+d*d;
if(sqrt(x)<=b)l++;
}
cout<<l<<endl;
}

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

typedef pair<int, int> P;

int main() {

    string s,t;
    cin >> s >> t;
    bool ok = false;
    string tmp;
    rep(i,s.size()){
        tmp = s[0];
        s = s.substr(1) + tmp;
        if(s == t){
            ok = true;
            break;
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] line1 = line.split(" ");
        double n = Double.parseDouble(line1[0]);
        double d = Double.parseDouble(line1[1]);
        System.out.println((int)Math.ceil(n / (d * 2 + 1)));
    }
}


Measured memory_bytes: 22740
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
#define ll long long
#define fast_io cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
using namespace std;

int main(){
	fast_io;
	ll r,d,x;
	cin>>r>>d>>x;
	int a[11]={};
	a[0]=x;
	for(int i=1;i<=10;i++){
		a[i]=(a[i-1]*r)-d;
		cout<<a[i]<<endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    
    if ((B-A) % 2 == 0) {
        cout << "Alice" << endl;
    } else {
        cout << "Borys" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

int32_t main(){_
   
   cin>>n;

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

   multiset<int> ms;
   int ans = 0;
   for (int i = 0; i < n; ++i)
   {
      ms.insert(a[i]);
      if(a[i] <= *ms.begin()){
         ans++;
      }
   }
      
   cout<<ans;

   return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define N 100;
int main() {
	// your code goes here
	long long a, b, c, n, m, x, y;
	cin >> a >> b;
	c = 16 - min(a, b);
	if( a <= 8 && b <= 8){
		cout << "Yay!"<< endl;
	}else{
		cout << ":(" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> P;
int n,q,k,a[100000],b[100000],c[100000],x[100000],y[100000],flag[100000],ans[100000];
vector<vector<P>> edge;

void dfs(int n,int res){
  ans[n]=res;
  flag[n]=1;
  for(auto p:edge[n]){
    if(!flag[p.first]){
      dfs(p.first,res+p.second);
    }
  }
}

signed main(){
  cin >> n;
  edge.assign(n,vector<P>());
  for(int i=0;i<n-1;i++){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    edge[a[i]].push_back(P(b[i],c[i]));
    edge[b[i]].push_back(P(a[i],c[i]));
  }
  cin >> q >> k; k--;
  for(int i=0;i<q;i++){
    cin >> x[i] >> y[i];
    x[i]--; y[i]--;
  }
  dfs(k,0);
  for(int i=0;i<q;i++){
    cout << ans[x[i]]+ans[y[i]] << endl;
  }
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> a(m),b(m);
    map<int, int> mp;
    rep(i, m)
    {
        cin >> a[i] >> b[i];
        if(a[i] == 1)mp[b[i]]++;
        if(b[i] == n)mp[a[i]]++;
    }
    rep(i,n){
        if(mp[i+1] >= 2){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 11136
N, M = [int(x) for x in input().split()]
lst = [[int(x) for x in input().split()] for i in range(M)]
dict = {}
for i in range(1, N + 1):
    dict[i] = 0
for i in lst:
    for j in i:
        dict[j] += 1
for i in dict.values():
    print(i)


Measured memory_bytes: 3060