akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

int b[1000];
signed main(){
  int n;cin>>n;
  rep(i,n-1)cin>>b[i];
  int ans=0;
  rep(i,n){
    if(i==0)ans+=b[0];
    else if(i==n-1)ans+=b[n-2];
    else ans+=min(b[i-1],b[i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n = int(input())
A = []
M = [[-1 for _ in range(n)] for _ in range(n)]
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        M[i][j] = cnt
        M[j][i] = cnt
        cnt += 1
ans = 0
nodes = []
adjacent_list = [[] for i in range(n*(n-1)//2)]
for i in range(n):
    tmp = list(map(int, input().split()))
    pre = tmp[0] - 1
    for j in tmp[1:]:
        adjacent_list[M[i][pre]].append(M[i][j-1])
        pre = j - 1
#まず、閉路検
seen = defaultdict(lambda: False)
visited = defaultdict(lambda: False)
def check(node):
    if visited[node]:
        return
    seen[node] = True
    for i in adjacent_list[node]:
        if seen[i] and (not visited[i]):
            print(-1)
            exit()
        check(i)
    visited[node] = True
def dfs_path(node):
    if not adjacent_list[node]:
        return 1
    if finish[node]:
        return finish[node]
    tmp = 0
    for i in adjacent_list[node]:
        tmp = max(tmp, dfs_path(i) + 1)
    finish[node] = tmp
    return finish[node]
finished = set()
finish = [0 for i in range(n*(n-1)//2)]
for i in range(n*(n-1)//2):
    check(i)
    dfs_path(i)
print(max(max(finish), 1))


Measured memory_bytes: 283856
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e5 + 5;
const ll mod = 998244353;
const double PI = acos(-1.0);

int n, m;
int val[maxn];

void solve()
{
	int i, j, k;
	sa(n), sa(m);

	vector<int>odd;
	vector<int>even;
	repp(i, 1, m)
	{
		sa(val[i]);
		if (val[i] & 1)
		{
			odd.push_back(val[i]);
		}
		else
		{
			even.push_back(val[i]);
		}
	}
	if (n == 1)
	{
		printf("1\n");
		printf("1\n");
		printf("1\n");
	}
	else
	{
		int od_sz = odd.size();
		int ev_sz = even.size();

		if (od_sz > 2)
		{
			puts("Impossible");
		}
		else
		{
			if (od_sz == 0)
			{
				rep(i, 0, ev_sz - 1)
				{
					printf("%d ", even[i]);
				}
				printf("%d\n", even[ev_sz - 1]);

				printf("%d\n", ev_sz + 1);
				printf("1 ");
				rep(i, 0, ev_sz - 1)
				{
					printf("%d ", even[i]);
				}
				printf("%d\n", even[ev_sz - 1] - 1);
			}
			else if (od_sz == 1)
			{
				if (ev_sz == 0)
				{
					printf("%d\n", odd[0]);
					printf("2\n");

					printf("%d %d\n", odd[0] - 1, 1);
				}
				else
				{
					printf("%d ", odd[0]);
					rep(i, 0, ev_sz - 1)
					{
						printf("%d ", even[i]);
					}
					printf("%d\n", even[ev_sz - 1]);
					printf("%d\n", m);

					printf("%d ", odd[0] + 1);
					rep(i, 0, ev_sz - 1)
					{
						printf("%d ", even[i]);
					}
					printf("%d\n", even[ev_sz - 1] - 1);
				}
			}
			else if (od_sz == 2)
			{
				if (ev_sz == 0)
				{
					if (odd[0] == 1 && odd[1] == 1)
					{
						printf("1 1\n");
						printf("1\n");
						printf("2\n");
					}
					else
					{
						sort(odd.begin(), odd.end());
						printf("%d %d\n", odd[0], odd[1]);
						printf("2\n");
						printf("%d %d\n", odd[0] + 1, odd[1] - 1);
					}
				}
				else
				{
					printf("%d ", odd[0]);
					rep(i, 0, ev_sz)
					{
						printf("%d ", even[i]);
					}
					printf("%d\n", odd[1]);

					vector<int>r;
					r.push_back(odd[0] + 1);
					rep(i, 0, ev_sz)
					{
						r.push_back(even[i]);
					}
					if (odd[1] - 1)
					{
						r.push_back(odd[1] - 1);
					}
					printf("%d\n", r.size());
					int sz = r.size();
					rep(i, 0, sz)
					{
						if (i == sz-1)
						{
							printf("%d\n", r[i]);
						}
						else
						{
							printf("%d ", r[i]);
						}
					}
				}
			}
		}
	}
}

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if (n == 0 && m == 0)
				break;
			int[][] pc = new int[n][1440];
			int[] pctime = new int[n];
			for (int i = 0; i < n; i++) {
				pctime[i] = 0;
				for (int j = 0; j < 1440; j++)
					pc[i][j] = 0;
			}
			int r = sc.nextInt();
			for (int i = 0; i < r; i++) {
				int t = sc.nextInt();
				int ni = sc.nextInt();
				int mi = sc.nextInt();
				int s = sc.nextInt();
				if (s == 1)
					pctime[ni - 1] = t;
				if (s == 0) {
					for (int j = pctime[ni - 1]; j < t; j++)
						pc[ni - 1][j] = mi;
				}
			}
			int q = sc.nextInt();
			for(int i=0;i<q;i++){
				int ts = sc.nextInt();
				int te = sc.nextInt();
				int mi = sc.nextInt();
				int result=0;
				for(int j=ts;j<te;j++)
					for(int k=0;k<n;k++)
						if(pc[k][j]==mi){
							result++;
							break;
						}
				System.out.println(result);
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 65004
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n;
  int t;
  int a;
  int h;
  cin>>n;
  cin>>t>>a;
  double min=1000000000,ans;
  for(int i=0;i<n;i++){
    cin>>h;
    double temp=t-h*0.006;
    if(abs(temp-a)<min){
      min=abs(temp-a);
      ans=i+1;
    }
  }

  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

from heapq import heappush, heappop
inf = float('inf')
# (始点,隣接リスト)
def dijkstra(start,ad):
    dist = [inf]*len(ad)
    dist[start] = 0
    pq = [(start,0)]
    while pq:
        v = heappop(pq)[0]
        for nv,nw in ad[v]:
            if dist[nv] > dist[v] + nw:
                dist[nv] = dist[v] + nw
                heappush(pq,(nv,dist[nv]))
    return dist

N = int(input())

ad = [[] for _ in range(N)]

for _ in range(N-1):
    u,v,w = map(int,input().split())
    u -= 1; v -= 1
    ad[u].append((v,w))
    ad[v].append((u,w))

dist = dijkstra(0,ad)

for d in dist:
    if d % 2 == 0:
        print(0)
    else:
        print(1)

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

int c[105][105];
int main() {
	int n;
	cin >> n;
	REP(i, n) REP(j, n) cin >> c[i][j];
	
	long long int ret = 0;
	REP(i, n) FOR(j, i+1, n) {
		ret += min(c[i][j], c[j][i]);
	}
	cout << ret << endl;
}

Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
typedef long long ll;

using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int ans;
  if (b / a > c) cout << c << endl;
  else {
    b -= b % a;
    cout << b / a << endl;
  }

}


Measured memory_bytes: 256
import sys
N = int(input())
S = [int(input()) for _ in range(N)]
t = sum(S)
if t % 10 != 0:
    print(t)
    sys.exit()

res = 0
for s in S:
    if (t - s) % 10 != 0:
        res = max(res, t - s)
print(res)


Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
int ar[200009];
int main()
{
    int n,i,x=1,cnt=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
        if(ar[i]==x)
        {
            cnt++;
            x++;
        }
    }
    if(cnt)
    {
        printf("%d\n",n-cnt);
    }
    else
        printf("-1\n");
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void) {
	int a,b,c;
	cin >> a >> b >> c;

	if(a == b){
		cout << c << endl;
	}else if(a == c){
		cout << b << endl;
	}else{
		cout << a << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>

int main() {
	int n, k; std::cin >> n >> k;
	std::vector<long long int> health(n); for (auto& h : health) std::cin >> h;
	if (n <= k) {
		std::cout << 0 << std::endl; return 0;
	}
	std::sort(health.begin(), health.end());
	const auto count = std::accumulate(health.begin(), std::next(health.begin(), n - k), 0LL);
	std::cout << count << '\n';
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
	int a = 0, b = 0, c = 0, d = 0;
	scanf("%d %d %d", &a, &b, &c);
	if (a > b){
		d = a;
		a = b;
		b = d;
	}
	if (b > c){
		d = b;
		b = c;
		c = d;
	}
	if (a > b){
		d = a;
		a = b;
		b = d;
	}
	printf("%d %d %d\n", a, b, c);

}

Measured memory_bytes: 2692
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define min(a, b) ( (a) < (b) ? (a) : (b) )
#define max(a, b) ( (a) > (b) ? (a) : (b) )
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (n); (i) += (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;
typedef vector <int> vi;

template <class T>
const bool is_impar(T x) {return (bool) (x & 1);}

int n, rez = 0;
string s;
char a[105], b[105];

int common_letters(char a[], char b[]) {
    bitset <30> viza, vizb;
    int rez = 0;
    for (int i = 0; a[i]; i++)
        viza[a[i] - 'a'] = true;
    for (int i = 0; b[i]; i++)
        vizb[b[i] - 'a'] = true;
    FOR (i, 0, 29, 1)
        rez += (viza[i] == vizb[i] && viza[i] == true);
    return rez;
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> s;
    FOR(i, 1, n - 1, 1) {
        memset(a, 0, sizeof a);
        memset(b, 0, sizeof b);
        FOR (i1, 0, i, 1)
            a[i1] = s[i1];
        FOR (i1, i, n, 1)
            b[i1 - i] = s[i1];
        rez = max(rez, common_letters(a, b));
    }
    cout << rez;
}


Measured memory_bytes: 256
from collections import deque

n,m=map(int,input().split())
step=list(range(2,n+1))
broken=[]
for i in range(m):
    broken+=[int(input())]
mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
if m==0:
    dp[1]=1
elif not broken[0]==1:
    dp[1]=1
b=deque(broken)
if len(broken) != 0:
    bad_one = b.popleft()
    if bad_one==1 and len(b) != 0:
        bad_one=b.popleft()
else:
    bad_one = -1
for i in step:
    if i != bad_one:
        dp[i]=(dp[i-1]+dp[i-2])%mod
    elif i == bad_one and len(b) != 0:
        bad_one = b.popleft()
print(dp[n])

Measured memory_bytes: 53848
#include<stdio.h>
int main()
{
    int i,j,n,s,minj,count=0;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    for(i=0;i<n-1;i++){
        minj = i;
    for(j=i;j<=n-1;j++){
      if(A[j]<A[minj]) minj = j;
    }
    if(minj != i){
      s = A[i];
      A[i] = A[minj];
      A[minj] = s;
      count++;
    }
  }
  for(i=0;i<n-1;i++) printf("%d ",A[i]);
    printf("%d\n%d\n",A[n-1],count);
  return 0;
}


Measured memory_bytes: 2088
import sys
sys.setrecursionlimit(300000)
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
adj = [[] for _ in range(n)]
for _ in range(n-1):
	a, b = map(int, input().split())
	adj[a-1].append(b-1)
	adj[b-1].append(a-1)

vis = [-1 for _ in range(n)]
def dfs(start):
	s = [start]
	while s:
		l = s.pop()
		for c in adj[l]:
			if vis[c] < 0:
				s.append(c)
				vis[c] = vis[l] + 1
	return

vis[0] = 0
dfs(0)

dia = -1
dia_ind = -1
for i in range(n):
	if vis[i] > dia:
		dia = vis[i]
		dia_ind = i

vis = [-1 for _ in range(n)]
vis[dia_ind] = 0
dfs(dia_ind)

dia = -1
dia_ind = -1
for i in range(n):
	if vis[i] > dia:
		dia = vis[i]
		dia_ind = i

if dia%3 == 1:
	print("Second")
else:
	print("First")

Measured memory_bytes: 48864
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
T inf(){
	return numeric_limits<T>::has_infinity?numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

const string YES = "Yes";
const string NO = "No";
Int N;
Int A;
Int B;
Int C;
Int D;
string S;

void solve(){
	bool flag = false;
	if(D<C){
		for(int i = B - 1;i <= D - 1;i++){
			if(S[i]=='.' and S[i+1]=='.' and S[i+2]=='.'){
				flag = true;
			}
		}
	}else{
		flag = true;
	}
	if(!flag){
		cout<<NO<<endl;
		return;
	}
	bool valid = true;
	for(int i = A;i <= B - 1;i++){
		if(S[i]=='#' and S[i+1]=='#')valid = false;
	}
	for(int i = C;i <= D - 1;i++){
		if(S[i]=='#' and S[i+1]=='#')valid = false;
	}
	if(valid){
		cout<<YES<<endl;
	}else{
		cout<<NO<<endl;
	}
}

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

	cin >> N;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;
	cin >> S;
	A--;B--;C--;D--;
	solve();
	return 0;
}

//}}}



Measured memory_bytes: 592
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
ll attack(ll H){
	if(H==1)
		return 1;
	return attack(H/2)*2+1;
}
signed main(){

	ll H;
	cin>>H;
	cout<<attack(H)<<endl;

	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<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define seq vector
signed main(){
    
    int K,S,count =0;
    cin >> K >> S;

    vector<int> nums(3*K+1,0);

    for(int i=0 ; i<=K;i++){
        nums[i]+=1;
        nums[i+K+1]-=1;
    }
    for(int i=1; i<=3*K;i++){
        nums[i]+=nums[i-1];
    }
    for(int X=0; X <= K;X++){
        if ( S-X<0){
            break;
        }
        count += nums[S-X];
        //cout << X << " " << S-X << " " << nums[S-X] << endl; 
    }
    /*for(auto i : nums){
        cout << i <<" ";
    }
    cout << endl;*/
    cout << count << endl;
}

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

using namespace std;


class Solution{

public:
    pair<int, int> unbalanced(const string& s){

        for(int i = 0; i + 1 < s.size(); i ++)
            if(s[i] == s[i + 1]) return {i + 1, i + 2};

        for(int i = 0; i + 2 < s.size(); i ++)
            if(s[i] == s[i + 2]) return {i + 1, i + 3};

        return {-1, -1};
    }
};

int main() {

    string s;
    cin >> s;

    pair<int, int> res = Solution().unbalanced(s);
    printf("%d %d\n", res.first, res.second);

    return 0;
}


Measured memory_bytes: 3372
#include <stdio.h>

int main(){
    double w;
      
    while(scanf("%lf", &w) != EOF)
        if     (w <= 48.0) printf("light fly\n");
        else if(w <= 51.0) printf("fly\n");
        else if(w <= 54.0) printf("bantam\n");
        else if(w <= 57.0) printf("feather\n");
        else if(w <= 60.0) printf("light\n");
        else if(w <= 64.0) printf("light welter\n");
        else if(w <= 69.0) printf("welter\n");
        else if(w <= 75.0) printf("light middle\n");
        else if(w <= 81.0) printf("middle\n");
        else if(w <= 91.0) printf("light heavy\n");
        else               printf("heavy\n");
 
    return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	int k;
	cin >> k;

	int n = (k+3)/4 * 2;
	vector<vi> mat(n, vi(n));
	
	rep(i,0,n) rep(j,0,n){
		int res = (i+j)%n + (i%2 ? n : 0) + 1;
		if(res > k) res -= n;
		res = max(res, 1);
		res = min(res, k);
		mat[i][j] = res;
	}
	
	cout << n << endl;
	trav(v, mat){
		trav(x, v) cout << x << ' ';
		cout << endl;
	}
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}
template <class T>
void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
const int INF = 1001001001;

int main() {
    int N;
    cin >> N;
    vector<int> R(N);
    rep(i, N) cin >> R[i];
    int cost = -1001001001;
    int minv = INF;
    int maxv = -INF;
    rep(i, N-1) {
        minv = min(R[i], minv);
        maxv = max(R[i+1]-minv, maxv);
    }
    print(maxv);
    return 0;
}


Measured memory_bytes: 3604
n,k = map(int,input().split())
m = [0]*n
v = [0]*n
dp = [[0] * (k+1) for i in range(n)]
for i in range(n):
    m[i],v[i] = map(int,input().split())

for j in range(k+1):
    dp[0][j] = v[0] if j >= m[0] else 0

for i in range(1,n):
    for j in range(k+1):
        if j >= m[i]:
            dp[i][j] = max(dp[i-1][j-m[i]]+v[i],dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]
#print(dp)
print(dp[i][j])

Measured memory_bytes: 148360
#include <bits/stdc++.h>
using namespace std;
typedef long l;
l h,w,n,i;
l k(l a,l b){for(i=0;i<a;i++)n=min(n,max(i*b,(b/2+(b%2==0?0:1))*(a-i))-min(i*b,(b/2)*(a-i)));}
int main(){cin>>h>>w,n=h%3==0||w%3==0?0:min(h,w),k(h,w),k(w,h),cout<<n;}


Measured memory_bytes: 256
using System;

namespace noteCsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(char.Parse(" "));
            int[] result = new int[3];
            result[0] = int.Parse(input[0]);
            result[1] = int.Parse(input[1]);
            result[2] = int.Parse(input[2]);
            for(int i = 0; i < 2; i++)
            {
                for(int cycle = 0; cycle < 2; cycle++)
                {
                    if (result[cycle] > result[cycle + 1])
                    {
                        int temp = result[cycle];
                        result[cycle] = result[cycle + 1];
                        result[cycle + 1] = temp;
                    }
                }
            }
            Console.WriteLine(result[0] + " " + result[1] + " " + result[2]);
        }
    }
}



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

int main(){
	int a[3][3],chk[3][3],i,j,k,n,ans=0;
	for(i = 0; i < 3; i++){
		for(j = 0; j < 3; j++){
			cin >> a[i][j];
		}
	}
	cin >> n;
	int b[n];
	for(i = 0; i < n; i++){
		cin >> b[i];
	}
	for(i = 0; i < 3; i++){
		for(j = 0; j < 3; j++){
			chk[i][j] = 0;
		}
	}

	for(k = 0; k < n; k++){
		for(i = 0; i < 3; i++){
			for(j = 0; j < 3; j++){
				if(a[i][j] == b[k]){
					chk[i][j] = 1;
					break;
				}
			}
		}
	}

	for(i = 0; i < 3; i++){
		if((chk[i][0] == 1)&&(chk[i][1] == 1)&&(chk[i][2] == 1)){
			ans = 1;
			break;
		}
	}
	if(ans == 0){
		for(i = 0; i < 3; i++){
			if((chk[0][i] == 1)&&(chk[1][i] == 1)&&(chk[2][i] == 1)){
				ans = 1;
				break;
			}
		}
	}
	if(ans == 0){
		if((chk[0][0] == 1)&&(chk[1][1] == 1)&&(chk[2][2] == 1)){
			ans = 1;
		}
		else if((chk[0][2] == 1)&&(chk[1][1] == 1)&&(chk[2][0] == 1)){
			ans = 1;
		}
	}

	if(ans == 1){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int k,x,i,j;
    scanf("%d %d",&k,&x);
    int a[2*k-1];
    j = x + 1 - k;
for(i=1;i<=2*k-1;i++){
a[i] = j + i;
printf("%d ",a[i]-1);
}
return 0;
}

Measured memory_bytes: 128
def isPrime(num):
    if num == 2 or num == 3:
        return True
    elif num % 2 == 0:
        return False

    p = 3
    sqrt_num = int(num ** 0.5)
    while True:
        if num % p == 0:
            return False

        if sqrt_num >= p:
            p += 2
        else:
            return True


n = int(input())
input_num = [int(input()) for _ in range(n)]

print(len(list(filter(lambda x: isPrime(x), input_num))))


Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a;
	vector<int> cnt;
	a.resize(n);
	cnt.resize(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		while(a[i] % 2 == 0) {
			a[i] /= 2;
			++cnt[i];
		}
	}
	for(int i = 0; i < n; ++i) {
		if(cnt[i] != cnt[0]) {
			cout << 0 << '\n';
			return 0;
		}
	}
	long long v = 1;
	for(int i = 0; i < cnt[0] - 1; ++i) {
		v = v * 2;
	}
	for(auto x : a) {
		v = v * x / __gcd(v, 1LL * x);	
		if(v > m) {
			cout << 0 << '\n';
			return 0;
		}
	}
	int ans = (m / v + 1) / 2;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1024
import numpy as np
from itertools import permutations
from math import hypot

n = int(input())

li = []
for _ in range(n):
    i, j = map(int, input().split())
    li.append(np.array([i, j]))

li2 = permutations(li)

re = []
for a in li2:
    dis = 0 
    for (x1,y1),(x2,y2) in zip(a,a[1:]):
        dis += hypot(x1-x2, y1-y2)
    re.append(dis)

print(np.average(re))

Measured memory_bytes: 13772
N, M = map(int, input().split())
dep = []
ter = []
for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        dep.append(b)
    elif b == 1:
        dep.append(a)
    elif a == N:
        ter.append(b)
    elif b == N:
        ter.append(a)
print('POSSIBLE' if len(set(dep) & set(ter)) != 0 else 'IMPOSSIBLE')


Measured memory_bytes: 21816
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
//change null_type here for map/set
typedef tree<int,null_type,less<int>,rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;
typedef long long int  ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define F first
#define S second

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    x*=sgn; return ~c;
}
///START HERE
///indexed_set pbd;
//pbd.insert()
//auto x = pbd.find_by_order(2);
//int od=pbd.order_of_key(7)
///rope<int> rp;
//rp.push_back()
//RandomAccess like vector
//mutable_begin, mutable_end()

int main(){
    ///read()+printf
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //fast;
    double d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }



    return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;
cin >> n >> k;
vector <int> price(n);
for(int i=0;i<n;i++){
cin >> price.at(i);
}
sort(price.begin(),price.end());
int output =0;
for(int i=0;i<k;i++){
output += price.at(i);
}

cout << output <<endl;
  
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,d; cin>>n>>d;
    cout<<(n+d*2)/(d*2+1)<<endl;;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	    Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		double r = scan.nextDouble();

		String S = String.format("%.5f", r*r*Math.PI);
		String l = String.format("%.5f", 2*Math.PI*r);

		System.out.println(sb.append(S).append(" ").append(l));

	}

}

Measured memory_bytes: 28312
use std::cmp::*;
use std::io::*;
fn lower_bound<T: PartialOrd>(x: T, a: &Vec<T>) -> usize {
    let mut l: usize = 0;
    let mut r: usize = a.len();
    while r != l {
        let mid = (l + r) >> 1;
        if a[mid] < x {
            l = mid + 1;
        } else {
            r = mid;
        }
    }
    l
}
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let a: usize = itr.next().unwrap().parse().unwrap();
    let b: usize = itr.next().unwrap().parse().unwrap();
    let q: usize = itr.next().unwrap().parse().unwrap();
    let mut s: Vec<i64> = Vec::new();
    let mut t: Vec<i64> = Vec::new();
    s.push(-(1i64 << 60));
    t.push(-(1i64 << 60));
    for _ in 0..a {
        let c: i64 = itr.next().unwrap().parse().unwrap();
        s.push(c);
    }
    for _ in 0..b {
        let d: i64 = itr.next().unwrap().parse().unwrap();
        t.push(d);
    }
    s.push(1i64 << 60);
    t.push(1i64 << 60);

    let mut out = Vec::new();

    for _ in 0..q {
        let x: i64 = itr.next().unwrap().parse().unwrap();
        let p1 = lower_bound(x, &s);
        let p2 = lower_bound(x, &t);
        let ls = s[p1 - 1];
        let rs = s[p1];
        let lt = t[p2 - 1];
        let rt = t[p2];

        let mut ans = 1i64 << 60;
        ans = min(ans, x - min(ls, lt));
        ans = min(ans, max(rs, rt) - x);
        ans = min(ans, min(rt - x, x - ls) * 2 + max(rt - x, x - ls));
        ans = min(ans, min(rs - x, x - lt) * 2 + max(rs - x, x - lt));
        writeln!(out, "{}", ans).ok();
    }
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 13304
# https://abc097.contest.atcoder.jp/tasks/abc097_a
a, b, c, d = gets.chomp.split.map(&:to_i)

def a2b2c?(a, b, c, d)
  (a - b).abs <= d && (b - c).abs <= d
end

def a2c?(a, c, d)
  (a - c).abs <= d
end

if a2b2c?(a, b, c, d) || a2c?(a, c, d)
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

int main(){
    ll a; 
    int b1, b2;
    scanf("%lld %d.%d", &a, &b1, &b2);
    ll ans = a*(b1*100+b2);
    ans /= 100;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3776
package main

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

func main() {
  stdin := bufio.NewScanner(os.Stdin)
  stdin.Scan()
  text := stdin.Text()
  
  r, _ := strconv.Atoi(text)
  
  result := 3 * r * r
  fmt.Println(result)
}

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

int main(){
    int n;
    cin>>n;
    vector<int> h(n+1,0),dp(n+1,0);
    for(int i=1;i<=n;i++)
        cin>>h[i];
    dp[0] = inf;
    dp[1] = 0;
    for(int i=2;i<=n;i++){
        int opt1 = abs(h[i]-h[i-1]) + dp[i-1];
        int opt2 = abs(h[i]-h[i-2]) + dp[i-2];
        dp[i] = min(opt1, opt2);
    }
    cout<<dp[n]<<endl;
    return 0;
}



Measured memory_bytes: 4060
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] array = new int[n * n];
		int[] ref = new int[n * n];
		for (int i = 0; i < n; ++i) {
			x[i] = sc.nextInt();
			array[x[i] - 1] = i + 1;
			ref[x[i] - 1] = i + 1;
		}

		int pos = 0;
		for (int i = 0; i < n * n; ++i) {
			if (ref[i] > 0) {
				int cnt = 0;
				while (cnt < array[i] - 1) {
					if (array[pos] == 0) {
						array[pos] = array[i];
						++cnt;
					}
					++pos;
				}
			}
		}
		pos = n * n - 1;
		for (int i = n * n - 1; i >= 0; --i) {
			if (ref[i] > 0) {
				int cnt = 0;
				while (cnt < n - array[i]) {
					if (array[pos] == 0) {
						array[pos] = array[i];
						++cnt;
					}
					--pos;
				}
			}
		}

		for (int i = 0; i < n * n; ++i) {
			if (ref[i] > 0) {
				int cnt = 0;
				for (int j = 0; j < i; ++j) {
					if (array[j] == ref[i]) {
						++cnt;
					}
				}
				if (cnt != ref[i] - 1) {
					System.out.println("No");
					return;
				}
				for (int j = i + 1; j < n * n; ++j) {
					if (array[j] == ref[i]) {
						++cnt;
					}
				}
				if (cnt != n - 1) {
					System.out.println("No");
					return;
				}
			}
		}
		StringBuilder sb = new StringBuilder();
		System.out.println("Yes");
		for (int i = 0; i < n * n; ++i) {
			sb.append(array[i] + (i == n * n - 1 ? "\n" : " "));
		}
		System.out.println(sb.toString());

	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 34640
S = input()
tf = []
for s in S:
    if s in "ACGT":
        tf.append(True)
    else:
        tf.append(False)

ans = 0
temp = 0
for res in tf:
    if res:
        temp += 1
    else:
        temp = 0
    ans = max(ans, temp)
print(ans)

Measured memory_bytes: 61812
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	string s;
	cin >> s;
	if (s[0] == 'S') cout << "Cloudy" << endl;
	if (s[0] == 'C') cout << "Rainy" << endl;
	if (s[0] == 'R') cout << "Sunny" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
int main()
{
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for(int i = 0; i < n-2; i++){
    if(s.substr(i, 3) == "ABC"){
      ans++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int N,M,tmp,max=-1;
	cin >> N >> M;
	for(int i=1; i*i<=M; i++){
		if(M % i == 0){
			tmp = M/i;
			if(max < i && M/i >=N) max = i;
			if(max < tmp && M/tmp >= N) max = tmp;
		}
	}
	cout << max << endl;
	
	return 0;
}


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

using namespace std;

int main() {
	int a;
	cin >> a;
	int sum = 0;
	int i = a;
	while(i > 0) {
		sum+=(i%10);
		i/=10;
	}
	if ( a % sum == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x) 
{
    while (x->left != NIL) x = x->left;
    return x;
}

Node * find(Node *u, int k)
{
    while (u != NIL && k != u->key) {
        if (k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node * treeSuccessor(Node *x)
{
    if (x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while (y != NIL && x == y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z) 
{
    Node *y;
    Node *x;

    if (z->left == NIL || z->right == NIL) {
        y = z;
    } else {
        y = treeSuccessor(z);
    }

    if (y->left != NIL) {
        x = y->left;
    } else {
        x = y->right;
    }

    if (x != NIL) {
        x->parent = y->parent;
    }

    if (y->parent == NIL) {
        root = x;
    } else {
        if (y == y->parent->left) {
            y->parent->left = x;
        } else {
            y->parent->right = x;
        }
    }
    
    if (y != z) {
        z->key = y->key;
    }

    free(y);
}

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void preorder(Node *u)
{
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

void inorder(Node *u)
{
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

int main(int argc, char const *argv[])
{
    int n, i, x;    
    string com;

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        cin >> com;
        if (com[0] == 'f') {
            scanf("%d", &x);
            Node *t = find(root, x);
            if (t != NIL) printf("yes\n");
            else printf("no\n");
        } else if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if (com == "delete") {
            scanf("%d", &x);
            treeDelete(find(root, x));
        }
    }

    return 0;
}



Measured memory_bytes: 22084
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

A_dp = [0] * (N + 1)
B_dp = [0] * (M + 1)

for i in range(1,N+1):
  if i == 1:
    A_dp[i] += A[i-1]
    continue
  A_dp[i] += A_dp[i-1] + A[i-1]
  
for j in range(1,M+1):
  if j == 1:
    B_dp[j] += B[j-1]
    continue
  B_dp[j] += B_dp[j-1] + B[j-1]
  
cnt = 0
j = M

for i in range(N+1):
  if A_dp[i] > K:
    continue
  while A_dp[i] + B_dp[j] > K:
    j -= 1
  cnt = max(cnt, i+j)
  
print(cnt)

Measured memory_bytes: 48684
#include <bits/stdc++.h>
using namespace std;
#define N 5
#define M 105
int n,a[N][N],x[M],y[M];bool ans,vs[N][N];
int main()
{
	for(int i=1;i<=3;++i) for(int j=1;j<=3;++j)
		scanf("%d",&a[i][j]),x[a[i][j]]=i,y[a[i][j]]=j;
	scanf("%d",&n);
	for(int i=1,t;i<=n;++i) scanf("%d",&t),vs[x[t]][y[t]]=1;
	for(int i=1;i<=3;++i) if(vs[i][1] && vs[i][2] && vs[i][3]) ans=1;
	for(int i=1;i<=3;++i) if(vs[1][i] && vs[2][i] && vs[3][i]) ans=1;
	if(vs[1][1] && vs[2][2] && vs[3][3]) ans=1;
	if(vs[1][3] && vs[2][2] && vs[3][1]) ans=1;puts(ans?"Yes":"No");
	return 0; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = max(x, y);
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
//const int INF = 1 << 30;//10^9
const ll INF = INFL;
//ll MOD = 1000000007;
ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

//デバッグ
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll get_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

//約数の列挙O(√n)
vector<ll> divisor(ll n){
    vector<ll> res(0);
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n/i) res.push_back(n/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

//素因数列挙
vector<ll> MakePrimeList(ll x) {
    vector<ll> res;
    for(ll k=2; k*k<=x; k++) {
        if(x % k == 0) {
            res.pb(k);
            while(x % k == 0) x /= k;
        }
    }
    if(x > 1) res.push_back(x);
    return res;
}


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}


int main(){
  string S;
  cin >> S;
  ll w;
  cin >> w;
  rep(i, S.size()){
    if((i) % w == 0) cout << S[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#define MAx 100

struct Sort{char suit;int value; };
int main()
{
  struct Sort a[101],b[101];
  int n,i,j,k,mini,m,sum=0; 
  char mo;
  scanf("%d%c",&n,&mo);

  for(i=0;i<n;i++){ 
    if(i<n)break;
  }
  
  for(i=0;i<n;i++){ 
    scanf("%c%d%c",&a[i].suit,&a[i].value,&mo);
  }
  for(i=0;i<n+1;i++){
    b[i]=a[i];
  }
  
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(a[j].value<a[j-1].value){
	m=a[j].value;
	a[j].value=a[j-1].value;
 	a[j-1].value=m;
	mo=a[j].suit;
        a[j].suit=a[j-1].suit;
        a[j-1].suit=mo;
      }
    }
  }  
  for(i=0;i<n-1;i++){
    mini=i; 
    m=b[i].value;
    for(j=i;j<n;j++){
      if(b[j].value<m){
	m=b[j].value;
	mini=j;
      }
    }
    if(m!=b[i].value){
      k=b[i].value;
      b[i].value=b[mini].value;
      b[mini].value=k;
      mo=b[i].suit;
      b[i].suit=b[mini].suit;
      b[mini].suit=mo;
    }
  }

  for(i=0;i<n;i++){
    if(a[i].suit==b[i].suit && a[i].value==b[i].value){
    sum++;
    }
  }
  for(i=0;i<n-1;i++){
    printf("%c%d ",a[i].suit,a[i].value);
  }
  printf("%c%d",a[i].suit,a[i].value);
  printf("\nStable\n");

  for(i=0;i<n-1;i++){
    printf("%c%d ",b[i].suit,b[i].value);
  }
  printf("%c%d",b[i].suit,b[i].value);
  if(sum==n){
    printf("\n");
    printf("Stable\n");}
  
  else {
    printf("\n");
    printf("Not stable\n");
  }

  return 0;
}



Measured memory_bytes: 2088
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        int v = sc.NextInt();
        int b = sc.NextInt();
        int w = sc.NextInt();
        int t = sc.NextInt();

        if (v > w)
        {
            long dist = Math.Abs(a - b);
            long diff = v - w;

            // dist / diff <= t
            // dist <= t * diff
            Console.WriteLine(dist <= t * diff ? "YES" : "NO");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27544
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
int main(){
  int N;
  cin >> N;
  int ans = 0;
  rep(i,N){
    rep(j,N){
      int gcdij;
      gcdij = gcd(i,j);
      rep(k,N){
        ans += gcd(gcdij,k);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
L,R = map(int,(input().split()))

A = []

ans = 2019

if (R-L) >= 2018:
    print(0)
else:
    for i in range(L,R+1):
        A.append(i % 2019)
    a = min(A)
    b = max(A)
    for j in range(a+1,b+1):
            for k in range(a,j):
                ans = min(ans,(j*k)%2019)
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    string N;
    cin >> N;
    rep(i, 3){
        if(N[i] == '7') {cout << "Yes" << endl; return 0;}
    }
    cout << "No" << endl;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back

int main() {
  char a; cin>>a;
  if(isupper(a)) cout<<'A'<<endl;
  else cout<<'a'<<endl;
}


Measured memory_bytes: 3596
fun main(array: Array<String>) {
    val (n, m, x) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() }
    var min0 = 0
    var minN = 0
    repeat(m) {
        if(a[it] < x) {
            min0++
        }
        else if(a[it] > x) {
            minN++
        }
    }
    if(min0 >= minN) {
        print(minN)
    }
    else {
        print(min0)
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

struct UnionFind{
  vector<ll> v;
  multiset<ll> st[101010];
  UnionFind(int n) : v(n, -1){}
  void init(){ for(int i = 0;i < v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    for(ll w : st[y]){
      st[x].insert(w);
    }
    st[y].clear();
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};

ll n,m;
ll res;
bool used[101010];

int main(){
	cin>>n>>m;
  ll need=(n-1-m)*2;
  if(need==0){
    cout<<0<<endl;
    return 0;
  }
  UnionFind uf(n);
  rep(i,n){
    ll a;
    cin>>a;
    uf.st[i].clear();
    uf.st[i].insert(a);
  }
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    uf.unite(a,b);
  }
  vector<ll> ws;
  rep(i,n){
    ll f=uf.find(i);
    if(used[f])continue;
    used[f]=true;
    res+=*uf.st[f].begin();
    need--;
    if(need==0){
      cout<<res<<endl;
      return 0;
    }
    uf.st[f].erase(uf.st[f].begin());
    for(ll w : uf.st[f]){
      ws.push_back(w);
    }
  }
  sort(all(ws));
  if(ws.size()<need){
    cout<<"Impossible"<<endl;
  }else{
    rep(i,need)res+=ws[i];
    cout<<res<<endl;
  }
	return 0;
}


Measured memory_bytes: 11896