akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>

const long long int INF = 6000000000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

typedef pair<int,int> P;

struct edge{
  int to;
  int cost;
};

int V,E;
long long d[200][200];


int main(){

  cin >> V >> E;
  for( int i = 0; i < V; ++i){
    for( int j = 0; j < V; ++j){
      d[i][j] = INF;
    }
  }

  for( int i = 0; i < V; ++i){
    d[i][i] = 0;
  }

  for( int i = 0; i < E; ++i){
    int a,b,c;
    cin >> a >> b >> c;
    d[a][b] = c;
  }

  for( int k = 0; k < V; ++k){
    for( int i = 0; i < V; ++i){
      for( int j = 0; j < V; ++j){
        d[i][j] = min( d[i][j], d[i][k]+d[k][j]);
      }
    }
  }

  bool f = false;
  for( int i = 0; i < V; ++i){
    if( d[i][i] < 0 ){
      f = true;
    }
  }

  if(f){
    cout << "NEGATIVE CYCLE" << endl;
  }else{
    for( int i = 0; i < V; ++i){
      for( int j = 0; j < V; ++j){
        if(j) cout << " ";
        if( d[i][j]  >= 3000000000 ){
          cout << "INF";
        }else{
          cout << d[i][j];
        }
      }
      cout << endl;
    }
  }

}

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

int main() {
  int x, rank = 8;

  cin >> x;

  for (int i = 400; i < 2000; i += 200) {
    if (x >= i && x < i + 200) {
      cout << rank;
      break;
    }
    rank--;
  }

  return 0;
}

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

int main () {
    int h,m,s;
    cin >> s;
    
    h = s / 3600; s %= 3600;
    m = s / 60; s %= 60;
        
    cout << h << ":" << m << ":" << s << endl;
   
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
int main(){
  int a1,a2,a3,a4;
  int b1,b2,b3,b4;
  cin >> a1 >> a2 >> a3 >> a4 >> b1 >> b2 >> b3 >> b4;

  int suma = a1 + a2 + a3 + a4;
  int sumb = b1 + b2 + b3 + b4;

  if (suma >= sumb)
     cout << suma << endl;
  else 
     cout << sumb << endl;
  
  return 0;
}


Measured memory_bytes: 3092
N = int(input())
A = list(map(int,input().split()))
num_list = [0]*(2*(10**5)+10)       
  
for i in A:
  num_list[i] += 1

sum_all = 0
for i in range(2*(10**5)+10):
  n = num_list[i]          
  sum_all += n*(n-1)//2 
  
for i in A:  
  n = num_list[i]          
  ans = sum_all - n*(n-1)//2 + (n-1)*(n-2)//2
  print(ans)

Measured memory_bytes: 26268
def bb
    n = gets.chomp.to_i
    l = gets.chomp.split(/\s/).map{|x| x.to_i}.sort
    m = l[-1]
    n = l[0..-2].inject(0) {|r,x| r + x}

    puts m < n ? 'Yes' : 'No'
end

bb

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N;
map<ll, ll> cnt;
string ans = "YES";
int main(){
	cin >> N;
	REP(i,0,N){
		ll a;
		cin >> a;
		if(cnt[a] > 0){
			ans = "NO";
			break;
		}
		cnt[a] = 1;
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pii pair<ll,ll>
using namespace std;
#define N 100007
#define pb push_back;
vector<ll> g[N];
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    ll n;
    cin>>n;
    map<string,ll> mp;
    while(n--)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}

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

using namespace std;
#define pb push_back
#define db(x) cerr << #x << " = " << x << endl;
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define vi vector<int>
#define vll vector<ll>
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<pii>
#define ll long long
#define ull unsigned long long
typedef long double ld;

#define MAXN 1123

#define MOD 1000000007

int n, m;
int grid[MAXN][MAXN];
int vis[MAXN][MAXN];
ll dp[MAXN][MAXN];

ll solve(int i, int j)
{
    if (i == n - 1 && j == m - 1)
        return 1;

    if (vis[i][j])
        return dp[i][j];
    vis[i][j] = 1;

    if (!grid[i][j]) return 0;

    return dp[i][j] = (solve(i + 1, j) + solve(i, j + 1)) % MOD;
}

int main()
{
    scanf("%d%d\n", &n, &m);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            char c;
            scanf("%c", &c);
            grid[i][j] = c == '.';
        }
        scanf("\n");
    }

    printf("%lld\n", solve(0, 0));
    
}

Measured memory_bytes: 19456
//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W


#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#include <string>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector 

bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;	
}

//   example:-

//   sort(vec.begin(),vec.end(),compare);
ll arr[100000];
ll temp=0;
ll dp[100000000];
ll frog(ll *arr, ll a, ll tp){
	if(tp==1) return 0;
	if(tp==2) return abs(arr[tp-1]-arr[tp]);
	if(dp[tp]!=-1) return dp[tp];
	dp[tp]=min(abs(arr[tp-2]-arr[tp])+frog(arr,a,tp-2),abs(arr[tp-1]-arr[tp])+frog(arr,a,tp-1));
	return dp[tp];
	}

int main() {
	fast;
	memset(dp,-1,sizeof dp);
	read(a)
	loop(j,1,a+1){
		read(f)
		arr[j]=f;
	}
	temp=a;
	cout<<frog(arr,a,temp);	
	return 0;
}


Measured memory_bytes: 790144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  ll N,K; cin >> N >> K;
  vector<int> A(N); rep(i,N) cin >> A[i];
  rep(i,N) A[i]--;
  vector<int> chk(N, -1);
  int cnt = 0;
  chk[0] = cnt;
  int pre = 0;
  int now;
  int d;
  int mo;
  while(1){
    cnt++;
    now = A[pre];
    if(chk[now]!=-1){
      d = cnt-chk[now];
      mo = chk[now];
      break;
    }
    else{
      chk[now] = cnt;
      pre = now;
    }
  }
  if(mo>K){
    int pos = 0;
    rep(i,K){
      pos = A[pos];
    }
    cout << pos+1 << endl;
    return 0;
  }
  else{
    K -= mo;
    K %= d;
    rep(i,N){
      if(chk[i]-mo == K){
        cout << i+1 << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4844
import heapq

H,W = map(int,input().split())
edges = [{}for _ in range(10)]
for i in range(10):
    l = list(map(int,input().split()))
    for j in range(10):
        if j != i:
            edges[j][i] = l[j]
costDic = {}
que = [(0,1)]
heapq.heapify(que)
while que:
    cost,now = heapq.heappop(que)
    if now not in costDic:
        costDic[now] = cost
        for nx,c in edges[now].items():
            if nx not in costDic:
                heapq.heappush(que,(cost+c,nx))

ans = 0
for i in range(H):
    wall = list(map(int,input().split()))
    for j in range(W):
        n = wall[j]
        if n != -1:
            ans += costDic[n]

print(ans)


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

def lcs(a, b):
	return a * b // gcd(a,b)

def gcd(a, b):
	if a % b == 0:
		return b
	else:
		return gcd(b, a%b)

def f(a, b, c):
	leftc = a + (c - a % c) % c
	if leftc > b:
		s = 0
	else:
		rightc = b - b % c
		s = (rightc - leftc) // c + 1
	return s

def F(x, c, d):
	res = x
	res -= x // c
	res -= x // d
	res += x // lcs(c, d)
	return res

# a~bまで→　F(b) - F(a-1)と考える（定積分のイメージ）
def main():
	a, b, c, d = map(int, input().strip().split())
	print(F(b, c, d) - F(a-1, c, d))
	# s = f(a, b, c)
	# t = f(a, b, d)
	# u = f(a, b, lcs(c, d))
	# # print(n,s, t, u)
	# print(n - (s + t - u))

if __name__ == '__main__':
	main()


Measured memory_bytes: 38256
! 2019.10.27
!
      program answer
      implicit none
      integer :: a,b,x
      double precision :: a_d,b_d,x_d
      double precision :: theta
      double precision :: pi
      intrinsic datan,dble,dabs
!
      pi = 3.14159265358979323846264338327950
      read(*,*) a,b,x
      a_d = dble(a)
      b_d = dble(b)
      x_d = dble(x)
      if(a_d*b_d/2.0 < x_d/a_d) then
        theta = datan(2.0d0*(a_d*b_d)/a_d**2.0d0-2.0d0*(x_d/a_d)/a_d**2.0d0)/pi*180.0d0
        if(dabs(theta - 45.0d0) < 0.00001) then
          theta = 45.0d0
        end if
      else
        theta = datan((a_d*b_d**2.0d0)/(2.0d0*x_d))/pi*180.0d0
      end if
      write(*,*) theta
      end program answer


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int N, K, h[10000005];

int main() {

	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%d", &h[i]);
	}

	int ans = 0;

	for (int i = 0; i < N; i ++) {
		if (h[i] >= K) {
			ans++;
		}
	}

	printf("%d", ans);



}






Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

string L = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string A = " ',-.?" + L;
string B = "101 000000 000011 10010001 010001 000001 100101 10011010 "
	"0101 0001 110 01001 10011011 010000 0111 10011000 "
	"0110 00100 10011001 10011110 00101 111 10011111 1000 "
	"00110 00111 10011100 10011101 000010 10010010 10010011 10010000";
string C = L + " .,-'?";
int bin2dec(string s){
	int x=0,i;
	for (i=0;i<s.size();i++){
		x *= 2;
		if (s[i] =='1')x++;
	}
	return x;
}
int main(){
	vector<string>x(32);
	stringstream ss(B);
	string s,s1,s0;
	int i,n,p;
	for (i = 0; i < 32; i++){
		ss >> s;
		x[i]=s;
	}
	while(getline(cin,s)){
		n = s.size();
		s1 = "";
		for (i = 0; i < n; i++){
			s1+=x[A.find(s[i])];
		}
		n = s1.size()%5;
		if (n!= 0)s1 += string(5 - n,'0');
		n = s1.size();
		s = "";
		for (i = 0; i < n; i += 5){
			p= bin2dec(s1.substr(i, 5));
			s += C[p];
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1212
N, M = map(int, input().split(' '))
penalty = [0] * N
actually = [False] * N
for i in range(M):
    ptmp, stmp = input().split(' ')
    pi = int(ptmp)-1
    if actually[pi] == False:
        if stmp == 'WA':
            penalty[pi] += 1
        else:
            actually[pi] = True

sum_penalty = 0
sum_correct = 0
for i in range(N):
    if actually[i] == True:
        sum_correct += 1
        sum_penalty += penalty[i]
print(sum_correct, sum_penalty)

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

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

    bool can = true;
    for (int i = 0; i < s.size() ; i++) {
        if (s[i] != s[s.size() - i - 1]) {
            can = false;
            //cout << "one" << endl;
            //cout << i << " " << s.size() << endl;
            break;
        }
    }

    int sed = (s.size() - 1) / 2;
    for (int i = 0; i < (s.size() - 1) / 2; i++) {
        if (s[i] != s[sed - i - 1]) {
            can = false;
            //cout << "tuee" << endl;
            break;
        }
    }

    for (int i = (s.size() + 3); i < s.size(); i++) {
        if (s[i] != s[s.size() - i]) {
            can = false;
            //cout << "htree" << endl;
            break;
        }
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    //cout << s.size() << endl;
    //cout << s[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl
#define all(v) v.begin(), v.end()
#define rsort(v) sort(v.rbegin(), v.rend())
const int MN = 200001;
const int INF = 1e9+1;
int N;
int res;
vector<int> a(MN);
vector<int> edge[MN];
vector<int> ans(MN,0);
vector<int> dp(MN,INF);
stack<int> st[MN];


void dfs(int n,int p) {
  auto it = lower_bound(all(dp),a[n]);
  if (*it == INF)
    res++;
  int id = (it-dp.begin());
  st[id].push(dp[id]);
  dp[id] = a[n];
  ans[n] = res;
  for (int e : edge[n]) {
    if (e == p)
      continue;
    dfs(e,n);
  }
  dp[id] = st[id].top();
  st[id].pop();
  if (st[id].empty())
    res--;
  return ;
}

int main() {
  cin >> N;
  rep(i,N) cin >> a[i];
  rep(i,N-1) {
    int u,v;
    cin >> u >> v;
    u--; v--;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  dfs(0,-1);
  rep(i,N) {
    print(ans[i]);
  }
  return 0;
}

Measured memory_bytes: 165868
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

void CountingSort(vector<int> ary1, vector<int>& ary2, int k) {
	int n = ary1.size();
	vector<int> ary3(k);

	for (int i = 0; i < k; i++) ary3[i] = 0;

	for (int i = 0; i < n; i++) ary3[ary1[i]]++;

	for (int i = 1; i < k; i++) ary3[i] = ary3[i] + ary3[i - 1];

	for (int i = n - 1; i >= 0; i--) {
		ary2[ary3[ary1[i]] - 1] = ary1[i];
		ary3[ary1[i]]--;
	}
	return;
}


int main() {

	int n = 0, max = 0, isf = 0;
	cin >> n;
	vector<int> ary1(n);
	vector<int> ary2(n);

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

	CountingSort(ary1, ary2, max + 1);
	string p;
	for (int i = 0;i < n;i++) {
		if (isf++) p += " ";
		p += to_string(ary2[i]);
	}

	cout << p << endl;
	return 0;
}



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

int main()
{
	int i,a,b,c=-1;
	while(cin >> a >> b, a||b)
	{
		if(c!=-1) cout << endl;
		for(c=0,i=a; i<=b; i++)
		{
			if( (i%4==0 && i%100!=0) || (i%400==0) )
			{
				c++;
				cout << i << endl;
			}
		}

		if(!c) cout << "NA" << endl;
	}
}

Measured memory_bytes: 0
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         int N = int.Parse(ReadLine());
         int[] A = ReadLine().Split(' ').Select(int.Parse).ToArray();
         int cnt = 0;
         for(int i = 0; i < N; i+=2){
             if(A[i] % 2 != 0) cnt++;
         }
         WriteLine(cnt);
      }
   }
}

Measured memory_bytes: 28300
import bisect
import sys
input=sys.stdin.readline
from collections import deque
N=int(input())

cnt=0
L=[]
for i in range(N):
    n=int(input())
    L.append(n)
#print(L)
Q=[-1,10**10]
Q=deque()
#Q.appendleft(10**10)
#print(Q)
for i in range(N):
    if bisect.bisect_left(Q,L[i])==0:
        Q.appendleft(L[i])
    #elif bisect.bisect_left(Q,L[i])==len(Q)-1:
        #Q.insert(len(Q)-1,L[i])
    else:
        Q[bisect.bisect_left(Q,L[i])-1]=L[i]
#print(Q)
print(len(Q))

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


class Solution:
    def main(self):
        a, b = input().split()
        a = int(a)
        b1,b2 = b.split(".")

        ans = a * int(b1)
        c = ((a * int(b2[0]) * 10) + (a * int(b2[1])) )// 100

        print(ans + c)

# Run main
if __name__ == '__main__':
    Solution().main()

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W;
    cin >> H >> W;
    vector<vector<ll>> coinMap(H + 1, vector<ll>(W + 1));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> coinMap.at(i + 1).at(j + 1);
        }
    }
    vector<tuple<ll, ll, ll, ll>> answers;
    for (int i = 1; i <= H; i++)
    {
        if (i % 2)
        {
            for (int j = 1; j < W; j++)
            {
                if (coinMap.at(i).at(j) % 2)
                {
                    answers.emplace_back(i, j, i, j + 1);
                    coinMap.at(i).at(j)--;
                    coinMap.at(i).at(j + 1)++;
                }
            }
            if (i < H && coinMap.at(i).at(W) % 2)
            {
                answers.emplace_back(i, W, i + 1, W);
                coinMap.at(i).at(W)--;
                coinMap.at(i + 1).at(W)++;
            }
        }
        else
        {
            for (int j = W; j > 1; j--)
            {
                if (coinMap.at(i).at(j) % 2)
                {
                    answers.emplace_back(i, j, i, j - 1);
                    coinMap.at(i).at(j)--;
                    coinMap.at(i).at(j - 1)++;
                }
            }
            if (i < H && coinMap.at(i).at(1) % 2)
            {
                answers.emplace_back(i, 1, i + 1, 1);
                coinMap.at(i).at(1)--;
                coinMap.at(i + 1).at(1)++;
            }
        }
    }
    cout << answers.size() << endl;
    for (auto move : answers)
    {
        ll i, j, idash, jdash;
        tie(i, j, idash, jdash) = move;
        cout << i << " " << j << " " << idash << " " << jdash << "\n";
    }
    cout << endl;
    return 0;
}


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

bool check(int a, int b , int c){
	return ( a*a == ( b*b + c*c ) )? true : false ;
}

int main(){
	int n, a, b, c;

	cin >> n;
	for(int i=0 ; i<n ; i++){
		cin >> a >> b >> c;
		if( check(a,b,c) || check(b,c,a) || check(c,a,b) ){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    int As,Al,Bs,Bl;
    cin >> As>>Al;
    cin>>Bs>>Bl;
    int Max=min(Al,Bl);
    int Min=max(As,Bs);
    cout << max(0, Max-Min) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    short W, H;
    short x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if(x - r < 0 || x + r > W || y - r < 0 || y + r > H)
    {
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }
}


Measured memory_bytes: 2684
n=gets.strip.to_i
hh=gets.strip.split.map(&:to_i)

pre = hh.first-1

(1...n).each do |i|
  if pre > hh[i]
    puts 'No'
    exit
  end

  if pre <= hh[i]-1
    pre = hh[i]-1
  elsif pre <= hh[i]
    pre = hh[i]
  end

end

puts 'Yes'


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

int main() {
	int n;
	cin >> n;
	vector<int> vec(n);

	for (int i = 0; i < n; i++)
		cin >> vec.at(i);

	int count = 0;
	for (int i = 1; i < n - 1; i++) {
		if ((vec.at(i) - vec.at(i - 1)) * (vec.at(i + 1) - vec.at(i)) >= 0)
			count++;
	}

	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
int n,m;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>m;
	if(n>=10)
	cout<<m;
	else
	cout<<m+100*(10-n);
	return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

use std::cmp;

fn find_max(x: &Vec<i32>) -> i32 {
    let mut max: i32 = x[0];
    let mut x_iter = x.iter();
    while let Some(i) = x_iter.next() {
        max = cmp::max(*i, max);
    }
    return max
}

fn main() {
    let mut time: Vec<i32> = Vec::new();
    for _i in 0..5 {
        let tmp: i32 = read();
        time.push(tmp);
    }

    let remnant: Vec<i32> = time.clone().into_iter().map(|x| (10-x%10)%10).collect();
    let remove: i32 = find_max(&remnant);

    let time_calc: Vec<i32> = time.clone().into_iter().map(|x| x+(10-x%10)%10).collect();

    let ans: i32 = time_calc.iter().sum();

    println!("{}", ans - remove);
}


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

int main(){
	string s;
	cin>>s;
	if(s=="ABC")cout<<"ARC";
	else cout<<"ABC";

	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main() {
    int n,satisfaction;
    satisfaction = 0;
    scanf("%d",&n);
    //printf("%d\n",n);
    int a[22],b[22],c[22];

    //SCANNING
    for (int i=0; i < n; ++i){
        scanf("%d", &a[i]);
        --a[i];
        //printf("%d ", a[i]);
    }
    //printf("\n");
    for (int i=0; i < n; ++i){
        scanf("%d", &b[i]);
        //printf("%d ", b[i] );
    }
    //printf("\n");
    for (int i=0; i < n-1; ++i){
        scanf("%d", &c[i]);
        //printf("%d ", c[i]);
    }
    //printf("\n");

    //RUNNING THE BUFFET
    for (int i=0; i < n; ++i){
        if (i != n-1) {
            if ((a[i+1] - a[i]) == 1) {
                satisfaction = satisfaction + b[a[i]] + c[a[i]];
            } else {
                satisfaction = satisfaction + b[a[i]];
            }
        } else {
            satisfaction = satisfaction + b[a[i]];
        }
    }
    printf("%d\n", satisfaction);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t;cin>>t;
    map<string,ll>mp;
    ll cnt=0;
    while(t--){
        string s;cin>>s;
        if(mp[s]==0){cnt++;mp[s]++;}
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 19200
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n,d;
int f[11][11],ans;
int main()
{
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=d;j++)
		{
			cin>>f[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{		
		for(int j=i+1;j<=n;j++)
		{
			int tmp=0;
			for(int k=1;k<=d;k++)
			{
				tmp+=pow(f[i][k]-f[j][k],2);
			}			
			int tmp2=sqrt(tmp);
			tmp2*=tmp2;
			if(tmp2==tmp)
			{
				ans++;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#import<cstdio>
int n,c[510],s[510],f[510],i,a,j;main(){for(scanf("%d",&n);~scanf("%d%d%d",c+j++,s+j,f+j););for(f[j-1]=1;i<n;a=!printf("%d\n",a))for(j=i++;j<n;)a=(a<s[j]?s[j]:(~-a/f[j]+1)*f[j])+c[j++];}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	char s[6];
	scanf("%s", s);
	if(s[0]=='S')
	printf("Cloudy\n");
	if(s[0]=='C')
	printf("Rainy\n");
	if(s[0]=='R')
	printf("Sunny\n");
	
	return 0;
}

Measured memory_bytes: 128
import numpy as np
def factorial(n):
  if (n==1):
    return 1
  return n*factorial(n-1)

n = int(input())
x = []
y = []
for i in range(n):
  x_, y_ = list(map(int, input().split()))
  x.append(x_)
  y.append(y_)
val = 0
for i in range(n):
  for j in range(i+1, n):
    val += np.sqrt((x[i] - x[j])**2 + (y[i] - y[j])**2)

ans = val/factorial(n) * factorial(n-1) * 2
print(ans)

Measured memory_bytes: 26892
#include<bits/stdc++.h>
using namespace std;
 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX (1000*1000*1000+7)
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >

int32_t main()
{
    fast;
    int n,m,x,y,val,ans=0;
    std::vector<pii> v;
    cin>>n>>m;
    rep(i,n)
    {
        cin>>x>>y;
        v.pb({x,y});
    }
    sort(all(v));
    int i=0;
    while(m)
    {
        val=min(m,v[i].ss);
        ans+=(val*v[i].ff);
        i++;
        m-=val;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 2420
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int h, w; cin >> h >> w;
  vector<string> a(h); REP(i, h) cin >> a[i];
  REP(i, w+2) cout << '#';
  cout << '\n';
  REP(i, h) cout << '#' << a[i] << "#\n";
  REP(i, w+2) cout << '#';
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;





int main(void) {
  string s;
  cin >> s;
  ll i, j;
  ll N=(ll)s.size();
  ll dp[MAX][5]={};
  
  dp[0][0]=1;
  for(i=0; i<N; i++) {
    for(j=0; j<4; j++) {
      if(s[i]=='?')
        dp[i+1][j]=dp[i][j]*3%MOD;
      else
        dp[i+1][j]=dp[i][j];
    }
    
    ll c=s[i];
    if(c=='A') {
      moC(dp[i+1][1], +, dp[i][0]);
    }else if(c=='B') {
      moC(dp[i+1][2], +, dp[i][1]);
    }else if(c=='C') {
      moC(dp[i+1][3], +, dp[i][2]);
    }else if(c=='?') {
      for(j=0; j<3; j++) {
        moC(dp[i+1][j+1], +, dp[i][j]);
      }
    }
    
  }
  
  pt(dp[N][3]);
  
}






Measured memory_bytes: 4380
n = int(input())
csf = [list(map(int,input().split())) for _ in range(n-1)]

for i in range(n):
    ans = 0
    for c,s,f in csf[i:]:
        if ans < s:
            ans = s+c
        else:
            ans = -(-ans // f) * f + c
    print(ans)


Measured memory_bytes: 3188
package main

import (
	"fmt"
)

func main() {
	var a int
	fmt.Scan(&a)
	fmt.Println(a + a*a + a*a*a)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1768
n = int(input())
str_list = input().split()

list = [int(k) for k in str_list]

list.sort(reverse=True)

result = 1

if(0 in list):
  print('0')
  exit()

for i in range(n):
  result = result * list[i]
  if(result > 1000000000000000000):
    print('-1')
    exit()

print(result)
  


Measured memory_bytes: 22048
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int dp[200010][3];
int A[200010];
int N; 
int calc(int x, int k, int choice) {
    if (x >= N) return -INF2;
    else if ((x == N - 1 || x == N - 2) && choice == N/2 - 1) return A[x];
    if(dp[x][k] != -INF2) return dp[x][k];
    if(k == 0)
        return dp[x][k] = A[x] + calc(x + 2, k, choice + 1);
    else if(k == 1)
        return dp[x][k] = A[x] + max(calc(x + 2, k, choice + 1), calc(x + 3, k - 1, choice + 1)); 
    else
        return dp[x][k] = A[x] + max({calc(x + 2, k, choice + 1), calc(x + 3, k - 1, choice + 1), calc(x + 4, k - 2, choice + 1)});
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    
    rep(i, N) cin >> A[i];
    int K = 1;
    if (N % 2 == 1) K++;
    rep(i, 200010) rep(j, 3) dp[i][j] = -INF2;
    if (K == 1)
        cout << max({calc(0, K, 0), calc(1, K - 1, 0)}) << endl;
    else
        cout << max({calc(0, K, 0), calc(1, K - 1, 0), calc(2, K - 2, 0)}) << endl;
    return 0;
}


Measured memory_bytes: 19260
import java.io.*;
import java.util.*;

public class Main {
    public static long ciel(long x,long y){
        long res=x/y;
        if(x%y!=0)res++;
        return res;
    }
    public static boolean check(String str){
        if(str.equals(".")||str.equals(",")||str.equals("!")||str.equals("?"))return true;
        return false;
    }
    public static long gcd(long u,long v){
        if(v==0)return u;
        return gcd(v, u%v);
    }
    static int n,m,mod= (int) (1e9+7);
    static long memo[][];
    static long inf= (long) 1e18;
    static int[]cost,weight;
    public static long dp(int i,int rem){
        if(rem<0)return -1*inf;
        if(i==n)return 0;
     if(memo[i][rem]!=-1)return memo[i][rem];
     return memo[i][rem]=Math.max(dp(i+1, rem),cost[i]+ dp(i+1,rem-weight[i]));
    }
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        n=sc.nextInt();
        int w=sc.nextInt();
        weight=new int[n];
        cost=new int[n];
    for(int i=0;i<n;i++){
        weight[i]=sc.nextInt();
        cost[i]=sc.nextInt();
    }
        memo=new long[n][w+1];
        for(long []x:memo)Arrays.fill(x, -1);
        pw.println(dp(0, w));
        pw.close();
    }

  public static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException, IOException {
            return br.ready();
        }

    }
}


Measured memory_bytes: 125140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            System.out.println(new Main().run(sc));
        }
    }

    public String run(Scanner sc) {
        int a = Integer.parseInt(sc.nextLine());
        return String.valueOf(a + a*a + a*a*a);
    }
}


Measured memory_bytes: 35548
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
using namespace std;
const int N=1e5+11,mod=1e9+7;
int n,m;
char s[N];
int sum[N];
int main(){
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	rep(i,1,n-1)
		if(s[i]=='A'&&s[i+1]=='C')
			++sum[i];
	rep(i,1,n)
		sum[i]+=sum[i-1];
	for(;m--;){
		int l,r;
		scanf("%d%d",&l,&r);
		--r;
		printf("%d\n",sum[r]-sum[l-1]);
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <math.h>
using namespace std;

int main(){
    int s;
    cin >> s;
    int s1 = s/100;
    int s2 = s%100;

    if(s1>0 && s1<13){
        if(s2>0 && s2<13){
            cout << "AMBIGUOUS";
        }else{
            cout << "MMYY";
        }
    }else if(s2>0 && s2<13){
            cout << "YYMM";
    }else{
        cout << "NA";
    }
    return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
Ts = [A, B, C, D, E]
Ts.sort(key=lambda T: (T-1)%10)
#print(Ts)
def c(T):
  return (T+9)//10*10
r = Ts[0]
r += c(Ts[1])
r += c(Ts[2])
r += c(Ts[3])
r += c(Ts[4])
print(r)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define H ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
using namespace std;
const ll  mod = 998244353;

int n;
vector <int> period[10];
ll p[100][11];
bool vis[10][2000];
ll mem[10][2000];

ll dp(int idx, int msk, vector<int> v){
    if (idx >= 10){
        if (msk == 0){
            return LONG_LONG_MIN;
        }
        ll cnt = 0;
        for (int i = 0; i < n; i++){
            cnt += p[i][v[i]];
        }
        return cnt;
    }

    ll &ret = mem[idx][msk];
    if (vis[idx][msk]) return ret;
    vis[idx][msk] = 1;
    ret = dp(idx + 1, msk, v);
    int nmsk = (msk | (1 << idx));
    for (int i = 0; i < period[idx].size(); i++){
        v[period[idx][i]]++;
    }
    return ret = max(ret, dp(idx + 1, nmsk, v));
}

int main()
{
    H

    cin >> n;
    vector<int> v(n, 0);
    int x;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < 10; j++){
            cin >> x;
            if (x){
                period[j].push_back(i);
            }
        }
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= 10; j++){
            cin >> p[i][j];
        }
    }
    cout << dp(0, 0, v);
    return 0 ;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define ld double
using namespace std;

const int maxn = 1e6+5, maxq = 10005;


int main()
{
	int n, x,d = 0,l;
	cin >> n >> x;
	for (int i = 1; i <= n; i++)
	{
		cin >> l;
		d += l;
		if (d > x)
		{
			cout << i;
			return 0;
		}
	}
	cout << n + 1;
}

Measured memory_bytes: 256
N = int(input())
S = input()

left = 0
right = S[1:].count('E')

cnt = [left+right]

for i in range(1,len(S)):
    if S[i-1] == 'W':
        left += 1
    
    if S[i] == 'E':
        right -= 1
        
    cnt.append(left+right)

print(min(cnt))

Measured memory_bytes: 15564
n, k, q = map(lambda x: int(x), input().split())
points = [int(k) - int(q)] * n
for _ in range(q):
    a = int(input())
    points[a - 1] += 1
for point in points:
    if point <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 6596
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long H, W, N;
  scanln(H);
  scanln(W);
  scanln(N);
  if (H > W) {
    swap(H, W);
  }
  writeln(N.ceil(W));
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep) ~ "\n";
  static if (__VERSION__ >= 2071) {
    readf!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "readf(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
def main():
    s = [input() for i in range(3)]
    
    player = 0
    while True:
        if len(s[player]) == 0:
            break
        
        sp = s[player]
        s[player] = sp[1:]
        player = ord(sp[0]) - ord("a")
        
    print(chr(player+ord("A")))
    
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.util.*;


public class Main {

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

        int N = sc.nextInt();
        int[] P = new int[N];

        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        }
        int ans = 0;
        int max = N+1;
        for (int i = 0; i < N; i++) {
            if(max>= P[i]){
                ans++;
                max = P[i];
            }


        }
        System.out.println(ans);
    }

}






Measured memory_bytes: 90764
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
using namespace std;

int INF = 1e9 + 7;

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

char s[110];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> s[i];

	int aru = 0, sum = 0, ans = 0;
	for (int i = 1; i < n; i++) {
		set<char> x, y;
		for (int j = 1; j <= i; j++) {
			x.insert(s[j]);
		}
		for (int j = i + 1; j <= n; j++) {
			y.insert(s[j]);
		}
		for (auto j : x) {
			for (auto k : y) {
				if (j == k) aru = 1;
			}
			sum += aru;
			aru = 0;
		}
		ans = max(ans, sum);
		sum = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
N,M,C = map(int,input().split())
B = np.array(list(map(int,input().split())))
A = []
for i in range(N):
    A.append(np.array(list(map(int,input().split()))))
count = 0
for i in range(N):
    if sum(list(A[i]*B))+C > 0:
        count += 1
print(count)

Measured memory_bytes: 12500
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int a[21];
int used[21];
int flag = 0;
int sum = 0;
int m;
int n;
void dfs(int depth){
    if(depth >= n) {
        if(sum == m){
            flag = 1;
        }
        return ;
    }
    for(int i = 0; i < 2; i++){
        if(used[depth] == 0){
            used[depth] = 1;
            sum += a[depth] * i;
            dfs(depth+1);
            used[depth] = 0;
            sum -= a[depth] * i;
        }
    }
}
int main(){
    scanf("%d", &n);
    int k;
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    scanf("%d", &k);
    for(int i = 0; i < k; i++){
        for(int j = 0; j < 21; j++) used[j] = 0;
        flag = 0;
        sum = 0;
        scanf("%d", &m);
        dfs(0);
        if(flag) {
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int h,w,K;
  cin >> h >> w >> K;
  vvi item(h,vi(w,-INF));
  rep(i,K) {
    int r,c,va;
    cin >> r >> c >> va;
    r--;c--;
    item[r][c]=va;
  }
  vv(ll) dp(w,vl(3,0));
  rep(i,h) {
    vv(ll) dp2(w,vl(3,0));
    rep(j,w) {
      rep(k,3) {
        chmax(dp2[j][k],dp[j][k]);
        if(j>0) {
          chmax(dp2[j][k],dp2[j-1][k]);
        }
      }
      if(item[i][j]<0) {
        continue;
      }
      ll va=item[i][j];
      chmax(dp2[j][0],va);
      rep(k,3) {
        chmax(dp2[j][0],va+dp[j][k]);
      }
      if(j>0) {
        rep(k,2) {
          chmax(dp2[j][k+1],va+dp2[j-1][k]);
        }
      }
      
    }
    dp = dp2;
  }
  ll ans = 0;
  rep(i,3) {
    chmax(ans,dp[w-1][i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 39128
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int T = sc.nextInt();

		int c[] = new int[n];
		int t[] = new int[n];
		int min = 10000;

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

		for (int i = 0;i<n ;i++ ) {
			if (t[i]<=T) {
				 min = Math.min(min,c[i]);
			}
		}

		if (min == 10000) {
			System.out.println("TLE");
		}else{
			System.out.println(min);
		}

	}
}


Measured memory_bytes: 23124
#a, b, k = map(int, input().split( ))
import math

 
n = int(input())
a = list(map(int,input().split()))

left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    left[i + 1] = (math.gcd(left[i],a[i]))
    right[n - i - 1] = (math.gcd(right[n - i],a[n - 1 - i]))
#print(left, right)

ans = 0
for i in range(n):
  ans = max(ans, math.gcd(left[i],right[i+1]))
print(ans)

Measured memory_bytes: 20624
#include<stdio.h>
#define MAX(a, b) ((a < b) ? b : a)

int main(void) {
  int A, B, C, D;
  scanf("%d %d %d %d", &A, &B, &C, &D);
  int X = MAX(A*B, C*D);
  printf("%d\n", X);
  return 0;
}


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

int H,W;
int dx[4] = {-1,-1,0,0},dy[4] = {-1,0,-1,0};
char F[1010][1010],JOI[3] = {'J','O','I'};
char S[2][2];
bool good[1010][1010] = {};
int ok(int x,int y){
	if(x<1 || H<=x || y<1 || W<=y) return 0;
	if(F[x][y]==S[0][0] && F[x+1][y]==S[1][0] && F[x][y+1]==S[0][1] && F[x+1][y+1]==S[1][1]) return 1;
	else return 0;
}
int main(){
	cin >> H >> W;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin >> F[i][j];
		}
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			cin >> S[i][j];
		}
	}
	int ans = 0,sum = 0;
	for(int i=1;i<H;i++){
		for(int j=1;j<W;j++){
			sum += ok(i,j);
			good[i][j] = ok(i,j);
		}
	}
	ans = sum;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			char c = F[i][j];
			for(int k=0;k<3;k++){
				int cnt = 0;
				if(JOI[k]==c) continue;
				F[i][j] = JOI[k];
				for(int l=0;l<4;l++){
					int nx = i+dx[l],ny = j+dy[l];
					if(ok(nx,ny)) cnt++;
					else if(good[nx][ny]) cnt--;
				}
				ans = max(ans,sum+cnt);
			}
			F[i][j] = c;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 5072