akhauriyash/Code-Regression huggingface dataset:
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

signed main() {
	int n;
	cin >> n;
	int v[n];
	int c[n];
	int b[n];
	REP (i,n) {
		cin >> v[i];
	}
	REP (i,n) {
		cin >> c[i];
	}
	REP (i,n) {
		b[i] = v[i] - c[i];
	}
	sort(b,b+n);
	int ans = 0;
	for (int i = 0;i < n;i++) {
		if (b[i] > 0) {
			ans += b[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main() {
  char *line = NULL;
  size_t buffer_size = 0;
  while (getline(&line, &buffer_size, stdin) > 0) {
    double required_velocity;
    sscanf(line, "%lf", &required_velocity);
    double required_time = required_velocity / 9.8;
    double required_height = 4.9 * required_time * required_time;
    double required_floor = ceil(required_height / 5.0) + 1.0;
    printf("%.0f\n", required_floor);
  }
  free(line);

  return 0;
}

Measured memory_bytes: 1088
#include<bits/stdc++.h>
using namespace std;
int a[111111];
int cnt[111111];
int cnt2[111111];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	reverse(a,a+n);
	for(int i=0;i<n;i++){
		cnt[a[i]]++;
		cnt[a[i]+1]++;
		cnt[a[i]-1]++;
	}
	sort(cnt,cnt+a[0]+1);
	reverse(cnt,cnt+a[0]+1);
	cout<<cnt[0]<<endl;
	return 0;
}

Measured memory_bytes: 1024
while True:
	a=input().split()
	if a[1]=='?':
		break
	elif a[1]=='/':
		print(int(a[0])//int(a[2]))
	elif a[1]=='+':
		print(int(a[0])+int(a[2]))
	elif a[1]=='-':
		print(int(a[0])-int(a[2]))
	elif a[1]=='*':
		print(int(a[0])*int(a[2]))


Measured memory_bytes: 5596
import fractions
n = int(input())
lis = list(map(int,input().split()))
num = lis[0]
for i in range(n-1):
  num = (num * lis[i+1])//fractions.gcd(num,lis[i+1])
num -= 1
ans = 0
for i in range(n):
  ans += num % lis[i]
print(ans)

Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll mod=1e9+7 ;
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; }
//-------------------

int main(){
	int n,d; cin >> n >> d;
	int cnt = 0;
	while(n > 0){
		cnt += 1;
		n -= 1+2*d;
	}
	cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <iostream>
using namespace std;
 
constexpr int MAX_N = 100000;
int n;
int pw;
 
int vw[MAX_N];
int pf[MAX_N];
int vf[MAX_N];
int th[MAX_N];
 
inline double calc(double W) {
	double res = W * pw;
	for(int i = 0; i < n; ++i) {
		const double f = max(0.0, (double)(th[i] - W * vw[i]) / vf[i]);
		res += f * pf[i];
	}
	return res;
}
 
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);
 
	while(cin >> n && n) {
		cin >> pw;

		for(int i = 0; i < n; ++i) {
			cin >> vw[i] >> pf[i] >> vf[i] >> th[i];
		}
 
		double L = 0.0, R = INT_MAX;
		for(int i = 0; i < 200; ++i) {
			const double x1 = (L + L + R) / 3;
			const double x2 = (L + R + R) / 3;
 
			if(calc(x1) < calc(x2)) {
				R = x2;
			}
			else {
				L = x1;
			}
		}
 
		cout << calc(L) << endl;
	}
}

Measured memory_bytes: 2824
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int count = 0;
    
    for(int i = A; i <= B; i++){
    	int a = i / 10000;
        int b = i % 10;
        if(a != b) continue;
      	a = (i / 1000)% 10;
        b = (i / 10) % 10;
        if(a == b) count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0);
ll a;
double b;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> a >> b;
    b *= 100;
    cout << a * (ll)(b + 0.5) / 100;
    return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long A,B,C,K;
  cin >> A >> B >> C >> K;
  if (K < A){
    cout << K << endl;
  }
  else if (K<=A+B){
    cout << A << endl;
  }
  else {
    cout << A+A+B-K << endl;
  }
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
	int n;
	int *a;
	int *x;
	scanf("%d", &n);
	a = (int *)malloc(sizeof(int) * n);
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	qsort(a, n, sizeof(int), compare_int);
	int max = a[n-1];
	x = (int *)malloc(sizeof(int) * max+1);
	for(int j=1; j<max+1; j++){
		x[j] = 2;
	}
	for(int k=0; k<n; k++){
		if(x[a[k]] == 2){
			x[a[k]]--;
			int l = a[k]+a[k];
			while(l<=max){
				x[l] = 0;
				l += a[k];
			}
		}
		else if(x[a[k]] == 1){
			x[a[k]]--;
		}
	}
	int ans = 0;
	for(int i=0; i<n; i++){
		if(x[a[i]] >= 1){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 6436
import numpy as np

N, T = map(int, input().split())
cmin = 1000
index = -1
c = np.arange(N)
t = np.arange(N)

for i in range(N):
    c[i], t[i] = input().split()
    if t[i] <= T:
        if c[i] <= cmin:
            cmin = c[i]
            index = i
if index == -1:
    print("TLE")
else:
    print(c[index])


Measured memory_bytes: 18824
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define MIN(a,b) (((a)<=(b))?(a):(b))
#define MAX(a,b) (((a)>=(b))?(a):(b))
#define ll long long int
using namespace std;

int main(){
    string s;
    cin >> s;
    if(s == "Sunny")
        cout << "Cloudy" << endl;
    else if(s == "Cloudy")
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256
// Problem : C - Sum of gcd of Tuples (Easy)
// Contest : AtCoder - AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	ll ans = 0;
	RI(i, n) {
		RI(j, n) {
			RI(k, n) {
				ans += __gcd(i, __gcd(j, k));
			}
		}
	}
	cout << ans << endl;
	return 0;
}
 


Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
using namespace std;
typedef long long int lld;
typedef long double llf;
typedef pair<lld, lld> pii;


int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, A, B;
  cin >> n >> m >> A >> B;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if ((i < B && j < A) || (i >= B && j >= A)) {
        cout << "1";
      } else {
        cout << "0";
      }
    }
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 1e3 + 5;

int n, m, a, b;
int row[N], col[N];
int ans[N][N];

void solve(int r, int c)
{
  if(r < 0 || r > n || c < 0 || c > m)
    return;
  // cout << n << " " << m << " " << r << " " << c << endl;
  for(int i = 0 ; i < n ; i++){
    if(i < r)
      row[i] = a;
    else
      row[i] = m - a;
  }
  for(int i = 0 ; i < m ; i++)
    if(i < c)
      col[i] = b;
    else
      col[i] = n - b;
  // for(int i = 0 ; i < n ; i++)
  //   cout << row[i] << " ";
  // cout << endl;
  // for(int i = 0 ; i < m ; i++)
  //   cout << col[i] << " ";
  // cout << endl;
  memset(ans, 0, sizeof ans);
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < m && row[i]; j++)
      if(col[j])
        col[j]--, row[i]--, ans[i][j] = 1;
  }
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < m ; j++)
      printf("%d", ans[i][j]);
    printf("\n");
  }
  exit(0);
}

int main()
{
  cin >> n >> m >> a >> b;
  for(int r = 0 ; r <= n ; r++){
    int right = r * (m - 2 * a) + n * a - m * b;
    int left = n - 2 * b;
    // cout << right << " " << left << " " << r << endl;
    if(left == 0){
      if(right == 0)
        solve(r, 0);
    }else{
      if(right % left == 0)
        solve(r, right / left);
    }
  }
  printf("-1\n");
  return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
  int H,W; cin >> H >> W;
  vector<string> a(H);
  for(int i = 0; i < H; i++){ cin >> a[i];}
  
  vector<bool> X(H); vector<bool> Y(W);
  for(int i = 0; i < H; i++){ X[i] = false;} 
  for(int j = 0; j < W; j++){ Y[j] = false;}
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(a[i][j] == '#'){ X[i] = true; Y[j] = true;}}}
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(X[i] == true && Y[j] == true){cout << a[i][j];}}
    cout << endl;}
  
  return 0;}

Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    if N == 0:
        if A[0] == 1:
            print(1)
        else:
            print(-1)
        exit()

    if A[0] != 0:
        print(-1)
        exit()

    B = [0] * (N+1)
    B[N] = A[N]
    for i in range(N-1, -1, -1):
        B[i] = B[i+1] + A[i]
    C = [0] * (N+1)
    for i in range(N+1):
        if i == 0:
            B[0] = 1
            C[0] = 1
        else:
            if B[i] > C[i-1] * 2:
                B[i] = C[i-1] * 2
            C[i] = B[i] - A[i]
            if C[i] < 0:
                print(-1)
                exit()
    print(sum(B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 83296
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import glob

class InputGenerator(object):
    def __init__(self, input_path=None):
        if input_path != None:
            self.g = self.input_generator(input_path)
        else:
            self.g = None

    def input_generator(self, input_path):
        with open(input_path) as f:
            for line in f:
                yield line

    def get_input(self):
        if self.g == None:
            return input()
        else:
            return next(self.g)

def solve(gen):
    l = gen.get_input().rstrip()
    num_days = 0
    num_days_max = 0
    for s in l:
        if s == 'R':
            num_days += 1
        else:
            if num_days > num_days_max:
                num_days_max = num_days
            num_days = 0

    if num_days > num_days_max:
        num_days_max = num_days

    print(num_days_max)

if __name__ == '__main__':
    test_flag = len(sys.argv) > 1

    if test_flag == True:
        file_path_list = sorted(glob.glob('test/*'))
    else:
        file_path_list = [None]

    for file_path in file_path_list:
        gen = InputGenerator(file_path)
        solve(gen)


Measured memory_bytes: 9832
#include<bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define mod 1000000007LL
#define nax 200009LL
#define FOR(i,n,m) for(int i = (n); i < (m); i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) v.begin(),v.end()
#define sz(v) int(v.size())

 
typedef long long ll;
typedef vector<int> vi; 
typedef pair<int,int> ii;



int main(){
	fastio;

	int n; cin>>n;
    vector<ii> v(n);
    int x;
    REP(i,n){
        cin>>x; v[i].fst=x; v[i].snd=i+1;
    } 

    sort(all(v));

    REP(i,n){
        cout<<v[i].snd<<" ";
    }




	return 0;
}


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

#define ff first
#define ss second
using namespace std;
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

int dx[] = { -1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};



int main() {
	fastio();

	ll n; cin >> n;

	vector<vll> v;

	f(i, 0, n - 1) {
		ll a, b, c; cin >> a >> b >> c;
		v.pb({a, b, c});
	}

	ll dp[n][3];
	dp[0][0] = v[0][0];
	dp[0][1] = v[0][1];
	dp[0][2] = v[0][2];

	f(i, 1, n - 1) {
		dp[i][0] = v[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = v[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = v[i][2] + max(dp[i - 1][1], dp[i - 1][0]);
	}

	cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]);

	return 0;
}

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

int main(){
  string s,t;
  cin>>s>>t;
  int count_min=1001;
  int l1=s.length(),l2=t.length();
  for(int i=0;i<=l1-l2;i++){
    int count=0;
    for(int j=0;j<l2;j++){
      if(s[i+j]!=t[j]) count++;
    }
    count_min=min(count_min,count);
  }
  cout<<count_min<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main() {
    int a, b; cin >> a >> b;
    int A[3] = {1, 2, 3};
    for (int i = 0; i < 3; i++) {
        if (A[i] != a && A[i] != b) cout << A[i] << endl;
    }
}

Measured memory_bytes: 256
from copy import copy
from sys import stdout

digit_costs = [2,5,5,4,5,6,3,7,6]

W, _ = map(int, raw_input().strip().split(' '))

dp = [[0 for _ in xrange(9)] for _ in xrange(W + 1)]

values  = map(int, raw_input().strip().split(' '))
weights = [digit_costs[values[i] - 1] for i in xrange(len(values))]

def is_larger(a, b) : 
    a_s, b_s = sum(a), sum(b)
    if a_s != b_s : 
        if a_s > b_s : 
            return True
        return False

    for i in xrange(8, -1, -1) : 
        if a[i] > b[i] : 
            return True
        if b[i] > a[i] : 
            return False

    return False

for i in xrange(len(values)) : 
    vi = values[i]
    wi = weights[i]
    
    for w in xrange(0, W - wi + 1) : 
        if any(x for x in dp[w]) or not w :
            temp = copy(dp[w])
            temp[vi - 1] += 1
            if is_larger(temp, dp[w + wi]) :
                dp[w + wi] = temp



result = ''
for x in xrange(8, -1, -1) : 
    if dp[-1][x] : 
        result += str(x + 1) * dp[-1][x]

print result




Measured memory_bytes: 5116
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,m=0;
  cin>>n;
  if(n%2==0){
    n/=10;
    while(n>0){
      m+=n;
      n/=5;
    }
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

signed main()
{
	int k;
	int h[2], m[2];
	rep(i, 2) {
		cin >> h[i] >> m[i];
	}
	cin >> k;
	//if (h[1] < h[0]) h[1] += 24;
	int mm = 0;
	if (m[1] - m[0] >= 0) {
		mm += m[1] - m[0];
	} else {
		mm += 60 - (abs(m[1] - m[0]));
		h[0]++;
	}
	mm += max(h[1] - h[0], 0ll)*60;
	cout << mm - k << endl; 
}




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

int main() {
  int a, b,c,t;
  cin >>t;
  a = t/100;
    b =t%100/10;
    c = t%10;

  int s =0;
  
  if (a==1){
    s+=1;}
    if (b==1){
    s+=1;}
    if (c==1){
    s+=1;}
  cout<<s<<endl;
}


Measured memory_bytes: 256
using System;

namespace _20200322
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine();
            var n = input.Length;
            if (isPalindrome(input) && isPalindrome(input.Substring(0, input.Length / 2)))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
        static bool isPalindrome(string str)
        {
            for (var i = 0; i < str.Length / 2; ++i)
            {
                if (str[i] != str[str.Length - i - 1])
                {
                    return false;
                }
            }
            return true;
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void extended_euclid(ll x,ll y,ll *c,ll *a,ll *b){
  ll a0,a1,a2,b0,b1,b2,r0,r1,r2,q;r0=x;r1=y;a0=1;a1=0;b0=0;b1=1;
  while(r1>0){q=r0/r1;r2=r0%r1;a2=a0-q*a1;b2=b0-q*b1;r0=r1;r1=r2;a0=a1;a1=a2;b0=b1;b1=b2;}
  *c=r0;*a=a0;*b=b0;
}

ll get_inv(ll n, ll p){
  ll a,b,c;
  extended_euclid(n,p,&c,&a,&b);
  if(a<p) a+=p;
  return a%p;
}

ll fact[2000100],fact_inv[2000100];

void init() {
  fact[0]=1;
  REP(i,1,2000100) fact[i]=fact[i-1]*i%MAX;
  fact_inv[2000050]=get_inv(fact[2000050],MAX);
  rrep(i,2000050)fact_inv[i]=fact_inv[i+1]*(i+1)%MAX;
}

ll nCr(int N,int K){
  if(K<0||K>N)return 0;
  return fact[N]*fact_inv[K]%MAX*fact_inv[N-K]%MAX;
}

void Main() {
  init();
  ll n,m;
  cin >> n >> m;
  REP(i,1,m+1) {
    ll x=n-m;
    if(x==0) {
      if(i==1) pr(1);
      else pr(0);
      continue;
    }
    ll ans=nCr(m-1,i-1)*nCr(x-1,i-1)*2%MAX;
    ans+=nCr(m-1,i-1)*nCr(x-1,i)%MAX;
    ans+=nCr(m-1,i-1)*nCr(x-1,i-2)%MAX;
    pr(ans%MAX);
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 31488
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int inf = 1e8;
const int maxN = 2 * 1e5 + 5;
int s[maxN][22], k[22];
int N, a[maxN];

int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d", &N); for(int i = 1; i <= N; ++i) scanf("%d", &a[i]);
	for(int i = 1; i <= N; ++i) {
		for(int j = 0; j <= 20; ++j) {
			s[i][j] = s[i - 1][j] + ((a[i] >> j) & 1); 
		}
	}	
//	cout << s[3][2] << "**********" << endl;
	long long ans = 0;
	for(int i = 1; i <= N; ++i) {
		//cout << i << endl;
		int minn = inf;
		for(int j = 0; j <= 20; ++j) {
			//if(s[i][j] > 0) cout << s[i][j] << ' ' <<(1 << j)<<endl; 
			while(k[j] + 1 < i && s[k[j] + 1][j] + 1 < s[i][j]) k[j]++;
			//if(i == 3 && j == 0) cout << s[1][j] << ' ' << s[i][j] << ' ' << j << ' ' << k[j] << endl;
			if(s[i][j] > 1) minn = min(minn, i - k[j] - 1);
			else minn = min(minn, i);
		}
		//cout << i << ' ' << minn << endl;
		ans += minn;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 18176
import java.util.Scanner;
import java.util.Arrays;
import java.util.List;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		String result = "";
		if (input.substring(2,3).equals(input.substring(3,4)) && input.substring(4,5).equals(input.substring(5,6))) {
			result = "Yes";
		} else {
			result = "No";
		}
	    System.out.println(result);
	}
}


Measured memory_bytes: 35628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int a,b;
  cin >> a>>b>>n;
  for(int i=0;i<n;i++){
    if(a%2!=0){
      a--;
    }
        b += a/2;
    a -= a/2;
    swap(a,b);
  }
  if( n%2!=0){
    swap(a,b);
  }
    cout << a<<" " <<b;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
#define pii pair <int , int > 
#define pll pair < ll , ll >
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n ;
  cin >> n ;
  int arr[n] , sudo[n] ;
  for(int i = 0 ; i < n ; i++){
    cin >> arr[i] ;
    sudo[i] = arr[i] ;
  }
  sort(sudo , sudo + n) ;
  for(int i = 0 ; i < n ; i++){
    if(arr[i] == sudo[n -1] ) cout << sudo[n - 2] << '\n' ;
    else cout << sudo[n - 1] << '\n' ;
  }
}

Measured memory_bytes: 3200
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUF_SIZE 30003

#define SECRET_DIGIT 3

int get_int(void) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
#else
#error
#endif
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  int num;
  sscanf(line, "%d", &num);
  return num;
}

int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int main(void) {
    char lucky_str[BUF_SIZE];
    int digits = get_int();
    get_str(lucky_str, BUF_SIZE);
    int i, j, k;
    char secret_key[4];

    int ans = 0;

    for(i = 0; i < 10; i++) {
        for(j = 0; j < 10; j++) {
            for(k = 0; k < 10; k++) {
                // assume that i*100+j*10+k
                secret_key[0] = i+'0';
                secret_key[1] = j+'0';
                secret_key[2] = k+'0';
                secret_key[3] = '\0'; // guard
                int s = 0;
                int idx = 0;
                for(s = 0; s < digits; s++) {
                    if(lucky_str[s] == secret_key[idx]) idx++;
                    // if(idx < 3 && lucky_str[s] == secret_key[idx]) idx++;
                }
                if(idx == 3) ans++;
            }
        }
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
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 Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
bool kaibun(string s) {
	int n = s.size();
	rep(i, n / 2) {
		if (s[i] != s[n - i - 1]) return 0;
	}
	return 1;
}
int main() {
	string s;
	cin >> s;
	int n = s.size();
	string s1 = "";
	rep(i, (n - 1) / 2) {
		s1 += s[i];
	}
	string s2 = "";
	for (int i = ((n + 3) / 2) - 1; i < n; i++) {
		s2 += s[i];
	}
	if (kaibun(s) && kaibun(s1) && kaibun(s2)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n, flag = 0;
  scanf("%d", &n);
  
  int a;
  for(int i = 0;i < n;i++){
    scanf("%d", &a);
    if(a % 2 == 0 && a % 3 != 0 && a % 5 != 0){
      flag = 1;
    }
  }
  
  if(flag == 0){
    printf("APPROVED");
  }
  else{
    printf("DENIED");
  }
  
  return 0;
}

Measured memory_bytes: 128
A , B , M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = [min(a) + min(b)]
for i in range(M):
    q = list(map(int, input().split()))
    x = a[q[0]-1] + b[q[1]-1] - q[2]
    ans.append(x)
print(min(ans))

Measured memory_bytes: 18736
histo = ["" for i in range(6)]
n = int(raw_input())
for i in range(n):
    h = float(raw_input())
    if   h < 165.0: histo[0] += "*"
    elif h < 170.0: histo[1] += "*"
    elif h < 175.0: histo[2] += "*"
    elif h < 180.0: histo[3] += "*"
    elif h < 185.0: histo[4] += "*"
    else          : histo[5] += "*"

for i in range(6):
    print "%d:%-s"%(i+1,histo[i])

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n, k; cin >> n >> k;
    string s; cin >> s;

    //1の個数、0の個数を記録
    vector<int> nums;
    if (s[0] == '0') {
        nums.push_back(0);
    }

    for (int i = 0; i < s.size();) {
        int j = i;
        while (j < s.size() && s[j] == s[i]) {
            ++j;
        }

        nums.push_back(j - i);

        i = j;
    }

    if (s[s.size()-1] == '0') {
        nums.push_back(0);
    }

    vector<int> sums(nums.size()+1, 0);
    for (int i = 0; i < nums.size(); ++i) {
        sums[i+1] = sums[i] + nums[i];
    }

    int ans = 0;
    for (int left = 0; left < sums.size(); left += 2) {
        int right = left + 2 * k + 1;

        if (right >= sums.size()) {
            right = sums.size() - 1;
        }

        ans = max(ans, sums[right] - sums[left]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1272
while True:
    H, W = map(int, input().split())
    if H==W==0:
        break
    else:
        for i in range(H):
            if i==0 or i==H-1:
                print('#'*W)
            else:
                for j in range(W):
                    if j==0:
                        print('#', end='')
                    elif j==W-1:
                        print('#')
                    else:
                        print('.', end='')
    print()



Measured memory_bytes: 6992
#include <iostream>
#include <string>
#include <vector>
using namespace std;

void chmax(string &a, string b) {
    if (a == "-") a = b;
    else if (a.size() < b.size()) a = b;
    else if (a.size() == b.size()) {
        if (a < b) a = b;
    }
}

int match[10] = {2,5,5,4,5,6,3,7,6};

string dp[11000];

int main() {
   int N, M; cin >> N >> M;
  
   vector<int> A(M);
  
    for (int i = 0; i < M; ++i) cin >> A[i];  
  
    for (int i = 0; i < 11000; ++i) dp[i] = "-";  
  
    dp[0] = "" ;
    for (int i = 0; i <= N; ++i) {
        if (dp[i] == "-") continue;
      
        for (auto a : A)  chmax(dp[i+match[a-1]], dp[i] + (char)('0' + a));
    }
  
    cout << dp[N] << endl;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  // vll a(n);
  vector<double> s(n+1);
  rep(i,n){
    double a; cin>>a;
    s[i+1]=s[i]+((a+1)*a/2)/a;
  }
  double ans=0;
  rep(i,n-k+1){
    chmax(ans,s[i+k]-s[i]);
  }
  coutd(ans);
}

Measured memory_bytes: 1792
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")


a,b = MI()

if a <=5:
    print(0)
elif a >=6 and a <= 12:
    print(int(b/2))
else:
    print(b)

Measured memory_bytes: 3064
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long
#define ld long double

struct XX{
    ll la;
    ll lb;
    ll ra;
    ll rb;
    ll q;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.q) == (riRight.q)){
            return riLeft.q < riRight.q;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.q) < (riRight.q);
    }
};


//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}


int n;
//int dat[2*10000000];
//int dat2[2*10000000];
int dat[2*100];
int dat2[2*100];

void init(int n_){
    n=1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;i++){
        dat[i]=0;
        dat2[i]=0;
    }
}

void initset(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
        k=(k-1)/2;
        dat[k]=dat[k*2+1]+dat[k*2+2];
    }
}

//[a,b)の間を[l,r]区間で比較しアップデート
//引数のindexに注意
//nは固定。initで計算すみ
//update2(L[i],R[i]+1,0,0,n,D[i]);
void update2(int a,int b,int k,int l,int r,int v){//v更新値、区間は0-index
    if(r<=a || b<=l)return;
    if(a<=l && r<=b){
        dat[k]+=dat2[k];
        if(r-l>1){
            dat2[k*2+1]+=dat2[k]/2;
            dat2[k*2+1]+=dat2[k]/2;
        }
        dat2[k]=v*(r-l);
        return;
    }else{
        update2(a,b,k*2+1,l,(l+r)/2,v);
        update2(a,b,k*2+2,(l+r)/2,r,v);
        return;
    }
}

int query(int a,int b,int k,int l,int r){
    if(r<=a || b<=l)return 0;
    if(a<=l && r<=b){
        dat[k]+=dat2[k];
        if(r-l>1){
            dat2[k*2+1]+=dat2[k]/2;
            dat2[k*2+1]+=dat2[k]/2;
        }
        dat2[k]=0;
        return dat[k];
    }
    else{
        int vl=query(a,b,k*2+1,l,(l+r)/2);
        int vr=query(a,b,k*2+2,(l+r)/2,r);
        return vl+vr;
    }
}



int main(int argc, const char * argv[])
{
    //scanf("%s",S);
    //scanf("%d",&N);
    //scanf("%lld %lld",&target1,&target2);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //ifstream ifs( "1_06.txt" );//テスト用
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A,B;
    cin >> A >> B;
    if(A<=8 && B<=8){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }

    
    
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    
    return 0;
}




Measured memory_bytes: 256
N_str = input()

ln = len(N_str)
ans = 0
no_mu, move_up = int(N_str[-1]), 11 - int(N_str[-1])
for i in range(2, ln + 1):
    n = int(N_str[-i])
    no_mu, move_up = n + min(no_mu, move_up), min(11 - n + no_mu, 9 - n + move_up)
print(min(no_mu, move_up))


Measured memory_bytes: 5492
# https://atcoder.jp/contests/abc176/submissions/16164430?lang=ja
import heapq

h, w = map(int, input().split())
sh, sw = map(lambda x: int(x) - 1, input().split())
gh, gw = map(lambda x: int(x) - 1, input().split())
S = [input() for i in range(h)]

inf = 10 ** 10
D = [[inf] * w for i in range(h)]

D[sh][sw] = 0
Q = [(0, (sh, sw))]
heapq.heapify(Q)
while Q:
  _, (curr_h, curr_w) = heapq.heappop(Q)
  for di in range(-2, 3):
    for dj in range(-2, 3):
      next_h, next_w = curr_h + di, curr_w + dj
      if 0 <= next_h < h and 0 <= next_w < w and S[next_h][next_w] == ".":
        nex = int(abs(di) + abs(dj) != 1)
        if D[next_h][next_w] > D[curr_h][curr_w] + nex:
          D[next_h][next_w] = D[curr_h][curr_w] + nex
          heapq.heappush(Q, (D[next_h][next_w], (next_h, next_w)))
if D[gh][gw] >= inf:
  print(-1)
else:
  print(D[gh][gw])


Measured memory_bytes: 113344
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
using namespace std;

inline int getint()
{
	int x = 0, c = getchar();
	while (c > 47 && c < 58)
	{
		x = x * 10 + c - 48;
		c = getchar();
	}
	return x;
}

constexpr int MAX = 300000;
int res[MAX * 4];

int main()
{
	int H = getint();
	int W = getint();
	int M = getint();

	int h, w, ans;
	int mxr = 0;
	int mxc = 0;
	int ctrow = 0;
	int ctcol = 0;
	for (int i = 0; i < M; ++i)
	{
		h = getint() - 1, w = getint() - 1;
		res[i + 2 * MAX] = h, res[i + 3 * MAX] = w;
		int x = ++res[h], y = ++res[w + MAX];

		if (x == mxr) ++ctrow;
		else if (x > mxr) mxr = x, ctrow = 1;

		if (y == mxc) ++ctcol;
		else if (y > mxc) mxc = y, ctcol = 1;
	}
	ans = mxr + mxc;

	long ct = ctrow;
	ct *= ctcol;
	if (ct > M)
	{
		printf("%d\n", ans);
		return 0;
	}

	for (int i = 0; i < M; ++i) if (res[res[i + 2 * MAX]] == mxr && res[res[i + 3 * MAX] + MAX] == mxc) --ct;
	if (ct <= 0) --ans;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 6264
S = str(input())
od = ['R', 'U', 'D']
nod = ['L', 'U', 'D']

j = True
for i in range(len(S)):
    if i%2 == 0:
        if S[i] not in od:
            print("No")
            exit()
    else:
        if S[i] not in nod:
            print("No")
            exit()

print('Yes')

Measured memory_bytes: 3064
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import sys
# import numpy as np
# from scipy.special import comb
import bisect


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    A.sort()
    B.sort()
    C.sort()

    ans = 0
    for i in range(N):
        a_i = bisect.bisect_left(A, B[i])
        b_i = (N - bisect.bisect_right(C, B[i]))
        #print("a:{} b:{}".format(a_i, b_i))
        ans += a_i * b_i

    print(ans)


if __name__ == '__main__':
    main()


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

long long int faktorisasi2(long long int n){
	long long int j = 0;
	while(n%2==0){
		n/=2;
		j++;
	}
	return j;
}

int main(){
	long long int a,b,c;
	scanf("%lld %lld %lld",&a,&b,&c);
	if((a==b && b==c && a==c ) && (a%2==1 && b%2==1 && c%2==1)){
		printf("0\n"); return 0;
	}
	if(a==b && b==c && a==c ){
		printf("-1\n");return 0;
	}
	if(a%2==0 && c%2==0 && b%2==0){
		//first round
		long long int a1 = b/2+c/2;
		long long int b1 = a/2+c/2;
		long long int c1 = b/2+a/2;
//		cout<<a1<<" "<<b1<<" "<<c1<<"\n";
		if((a1==b1 && b1==c1 && a1==c1 ) && (a1%2==1 && b1%2==1 && c1%2==1)){
			printf("1\n"); return 0;
		}
		if(a1==b1 && b1==c1 && a1==c1){
			printf("-1\n");return 0;
		}
		if(a1%2==0 && c1%2==0 && b1%2==0){
			long long int slisiha1 = abs(a-a1);
			long long int slisihb1 = abs(b-b1);
			long long int slisihc1 = abs(c-c1);
			
			if(slisiha1 == 0) slisiha1 = 2e9;	
			if(slisihb1 == 0) slisihb1 = 2e9;
			if(slisihc1 == 0) slisihc1 = 2e9;
//			cout<<slisiha1<<" "<<slisihb1<<" "<<slisihc1<<"\n";
			
			long long int n = min(faktorisasi2(slisiha1),min(faktorisasi2(slisihb1),faktorisasi2(slisihc1)));
			printf("%lld\n",n+1);
			
		}else printf("1\n");
	}else printf("0\n");
	
	return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

int main(void)
{
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(),greater<int>());
  //  cout << s << " " << t << endl;
  if(s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
student = [[0]] * N
for n in range(0, N):
    student[A[n]-1] = n+1
count = N
for s in student:
    print(str(s), end="")
    count -= 1
    if count != 0:
        print(' ', end="")

Measured memory_bytes: 13812
#include <iostream>
using namespace std;
int n, W, w, v, w1, g, z, mx, d[105][305]={1};
int main() {
	int i, j, k;
	cin>>n>>W;
	for(i=1; i<=n; i++) {
		cin>>w>>v;
		if(i==1) w1=w;
		g = w-w1;
		z += g;
		for(j=i; j; j--) for(k=g; k<=z && j*w1+k<=W; k++)
		if(d[j-1][k-g]) {
			d[j][k] = max(d[j][k], d[j-1][k-g]+v);
			mx = max(mx, d[j][k]);
		}
	}
	cout<<max(mx-1, 0);
	return 0;
}

Measured memory_bytes: 384
from collections import deque

h,w=map(int, input().split())
c_h,c_w=map(int, input().split())
d_h,d_w=map(int, input().split())
map=[[-1]*w for i in range(h)]
 
for gyou in range(h):
    tmp=input()
    for retu in range(w):
        if tmp[retu]=="#":map[gyou][retu]=-2
 
genzai=deque()
wapu=deque()
genzai.append((c_h-1,c_w-1))
wapu.append((c_h-1,c_w-1))
 
map[c_h-1][c_w-1]=0
 
def idou(gyou,retu,kaisuu):
    wapu.append((gyou,retu))
    for i in (-1,1):
        if 0<=gyou+i and gyou+i<h:
            if map[gyou+i][retu]==-1:
                map[gyou+i][retu]=kaisuu
                genzai.append((gyou+i,retu))
                wapu.append((gyou+i,retu))
                
        if 0<=retu+i and retu+i<w:
            if map[gyou][retu+i]==-1:
                map[gyou][retu+i]=kaisuu
                genzai.append((gyou,retu+i))
                wapu.append((gyou,retu+i))

def idou_wapu(gyou,retu,kaisuu):
    for i in range(-2,3):
        for j in range(-2,3):
            if 0<=gyou+i and gyou+i<h and 0<=retu+j and retu+j<w:
                if map[gyou+i][retu+j]==-1:
                    map[gyou+i][retu+j]=kaisuu+1
                    genzai.append((gyou+i,retu+j))

wapu_kaisuu=0

while len(genzai)!=0:
 
    while len(genzai)>0:
        idou(genzai[0][0],genzai[0][1],wapu_kaisuu)
        genzai.popleft()
    
    while len(wapu)>0:
        idou_wapu(wapu[0][0],wapu[0][1],wapu_kaisuu)
        wapu.popleft()
    
    wapu_kaisuu+=1

    if map[d_h-1][d_w-1]!=-1:
        print(map[d_h-1][d_w-1])
        exit()


print(map[d_h-1][d_w-1])


Measured memory_bytes: 105960
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

getInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main :: IO ()
main = do
  [h, n] <- map read . words <$> getLine :: IO [Int]
  a <- getInts :: IO [Int]

  putStrLn $ if h <= sum a then "Yes" else "No"

Measured memory_bytes: 2172
#pragma GCC optimize(2)
#include<iostream>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <cstring>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <map>
#include <unordered_map>
#include <vector> 
#include <bitset>
#include <cctype>
#include <set>
#include <stack>
#include <queue>
#include <fstream>
#include <numeric>
#include <random>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN = 1000005;
const int MAXM = 20500;
const ll MOD = 1e9+7;
 
#define MP make_pair
#define INF 0x3f3f3f3f
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template <typename T> inline T min(T a, T b, T c,T d) { return min(min(a, b), min(c,d)); }
template <typename T, typename T1> inline T qpower(T x, T p, T1 mod) { T re = 1; x %= mod; while (p) { if (p & 1)re = (re * x) % mod; x = (x * x) % mod; p >>= 1; }return re; }
#define mst(X,Y) memset(X,Y,sizeof(X)) 
#define rep(i, a, n) for (int i=(a); i<=(n); i++)
#define per(i, a, n) for (int i=(a); i>=(n); i--)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) { cerr << " " << to_string(H);    debug_out(T...);}
 
const int LIM = 1000000;
int prime[MAXN];
int arr[MAXN];
int a[MAXN];
int fac[MAXN];
int cnt = 0;
void init(int n)
{
	for (int i=2;i<=n;i++)
	{
		if (!arr[i]) prime[++cnt]=i;			
		for (int j=1;j<=cnt && prime[j]*i<=n;j++)			
		{
			arr[i*prime[j]]=1;
			if (i%prime[j]==0)			
				break;					
		}
	}
}

bool pfc(int n)
{
	for (int i = 2; i <= n;i++)
	{
		if (!arr[n])
		{
			if (fac[n])
				return false;
			else 
			{
				fac[n] = 1;
				return true;
			}
		}
		if (n%i == 0)
		{
			if (fac[i])
				return false;
			else 
				fac[i] = 1;
			while (n%i != 0)
				n/=i;
		}
	}
	return true;
}

int main()
{closeSync;
#ifdef DEBUG
	//freopen("C:/Users/86159/Desktop/input.txt", "r", stdin);
	//freopen("C:/Users/86159/Desktop/output.txt", "w", stdout);
#endif
	//clock_t c1 = clock();
	init(1000002);
	int n;
	cin>>n;
 
	rep (i,1,n)
		cin>>a[i];
	bool pc = true;
	rep (i,1,n)
	{
		//debug(a[i],pfc(a[i]));
		if (!pfc(a[i]))
		{
			pc = false;
			break;
		}
	}
	if (pc)
		cout<<"pairwise coprime\n";
	else
	{
		int cd = a[1];
		rep (i,2,n)
			cd = __gcd(cd,a[i]);
		if (cd == 1)
			cout<<"setwise coprime\n";
		else 
			cout<<"not coprime\n";
	} 
	// cout<<prime[500]<<endl;
 

	//cerr << "Time:" << clock() - c1 << "ms" <<endl;
    return 0;
}

Measured memory_bytes: 12060
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

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

void print_v(vector<int> v){
    for(int i=0; i<v.size(); i++){
        cout << char(v[i]+97);
    }
    cout << endl;
}

int main()
{
    int x;
    cin >> x;
    if(x==3 || x==5 || x==7) cout << "YES";
    else cout << "NO";


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B;
    cin >>A>>B;
    if(A+B>=10) cout <<"error" <<endl;
    else cout <<A+B  << endl;



}


Measured memory_bytes: 256