akhauriyash/Code-Regression huggingface dataset:
import math

isprime = [True for _ in range(55559)]
isprime[0]=False
isprime[1]=False
for i in range(2,55559):
    if isprime[i]:
        for j in range(2,55558//i+1):
            isprime[i*j] =False

n=int(input())
res = []
for i in range(55559):
    if isprime[i] and i % 5 == 1:
        res.append(i)
print(" ".join(map(str,res[:n])))


Measured memory_bytes: 3608
Q=int(input())
E=10**(-10)
from math import floor
def f(x):
  if min(abs(int(x)-x),abs(int(x)+1-x))<E:
    return int(x-1)
  else:
    return int(x)
  
for i in range(Q):
  a,b=map(int,input().split())
  n=a*b
  if f(n**(1/2))<a and f(n**(1/2))<b:
    if f(n**(1/2))*(f(n**(1/2))+1)<n:
      print(2*f(n**(1/2)))
    else:
      print(2*f(n**(1/2))-1)
  else:
    if f(n**(1/2))*(f(n**(1/2))+1)<n:
      print(2*f(n**(1/2))-1)
    else:
      print(2*f(n**(1/2))-2)
  

Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n, x, tmp;
    sc(n) sc(x)
    int A[n];
    REP(i, n) sc(A[i])
    ll ans = 0;
    REP(i, n){
        if (i == 0){
            if (x < A[i]){
                ans += A[i] - x;
                A[i] -= A[i] - x;
            }
            continue;
        }else{
            if (x < A[i] + A[i - 1]){
                ans += A[i] + A[i - 1] - x;
                A[i] -= A[i] + A[i - 1] - x;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int N;
	string s;
	cin >> N >> s;
	vector<int> b(N);
	for (b[0] = 0; b[0] < 2; b[0]++) {
		for (b[1] = 0; b[1] < 2; b[1]++) {
			for (int i = 2; i < N; i++) {
				b[i] = (s[i - 1] != 'o') ^ (b[i - 1] ^ b[i - 2]);
			}
			if ((b[N - 2] ^ b[N - 1] ^ b[0]) != (s[N - 1] != 'o')) continue;
			if ((b[N - 1] ^ b[0] ^ b[1]) != (s[0] != 'o')) continue;
			for (int i = 0; i < N; i++) {
				printf("%c", "SW"[b[i]]);
			}
			puts("");
			return 0;
		}
	}
	puts("-1");
	return 0;
}


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

class Program
{
    static void Main()
    {
        int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a = arr[0];
        int b = arr[1];
        if (a < b)
        {
            Console.WriteLine("a < b");
        }
        else if (a > b)
        {
            Console.WriteLine("a > b");
        }
        else
        {
            Console.WriteLine("a == b");
        }
    }
}


Measured memory_bytes: 20236
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n, len;
vector <int> v;

int main() {
	cin >> n;
	while (n--) {
		cin >> len;
		v.push_back(len);
	}
	sort(v.begin(), v.end());
	long long int m1 = 0;
	long long int m2 = 0;
	for(int i = 0; i < v.size() - 1; ++i) {
		if(v[i] == v[i + 1]) {
			if(v[i] > m1 || v[i] > m2) {
				if(m1 < m2) {
					m1 = v[i];
				}
				else {
					m2 = v[i];
				}
			}
			i += 1;
		}
	}
	cout << m1 * m2 << endl;
}

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

//#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

signed main() {
    int n, a[3];
    cin >> n >> a[0] >> a[1] >> a[2];
    
    int limit = 1;
    rep(i,n) limit *= 4;
    
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    
    int make[4], times[4];
    
    int ans = INT_MAX;
    rep(i,limit){
        rep(j,4){
            make[j] = 0;
            times[j] = -1;
        }
        int k = i;
        rep(j,n){
            int idx = k % 4;
            times[idx]++;
            make[idx] += l[j];
            k /= 4;
        }
        if(times[0] == -1 || times[1] == -1 || times[2] == -1){
            continue;
        }
        int t = 0;
        rep(i,3){
            t += times[i] * 10;
            t += abs(a[i] - make[i]);
        }
        ans = min(t, ans);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3544
n = int(input())
s = input()

r = len([i for i in s if i == "R"])
g = len([i for i in s if i == "G"])
b = len(s)- r-g

res = r *g * b
count = 0
between = 1
isLoop = True
while isLoop:
    for start in range(between):
        tg = s[start::between]
        if start == 0 and len(tg) < 3:
            isLoop = False
            break
        res -= tg.count("RGB") \
        + tg.count("RBG") \
        + tg.count("GRB") \
        + tg.count("GBR") \
        + tg.count("BRG") \
        + tg.count("BGR") 
    between += 1

print(res)

Measured memory_bytes: 9164
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int a, b, c;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b >> c;

  int p, q, r;
  p = a + b;
  q = b + c;
  r = c + a;

  int ans = min({p, q, r});

  cout << ans << endl;
}


Measured memory_bytes: 256
main(m,d){for(;scanf("%d%d",&m,&d)*m;printf("%sday\n","Wednes\0Thurs\0 Fri\0   Satur\0 Sun\0   Mon\0   Tues"+((m>2)*2+((m+9)%12*13+47)/5+d)%7*7));}

Measured memory_bytes: 596
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define REP(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int
main(int argc, char *argv[])
{
  char s[1000001];
  int N, A, B;
  scanf("%d %d %d", &N, &A, &B);
  scanf("%s", s);

  int x = 0; int y = 0;
  for(int i = 0; i < N; i++){
    if(s[i] == 'a'){
      if(x < A + B){
	printf("Yes\n");
	x++;
      }
      else printf("No\n");
    }
    if(s[i] == 'b'){
      if(x < A + B && y < B){
	printf("Yes\n");
	x++; y++;
      }
      else printf("No\n");
    }
    if(s[i] == 'c') printf("No\n");
  }
  return 0;
}


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

using namespace std;
#define FOR(i,s,e) for (int i=(s); i<(e); i++)
#define FOE(i,s,e) for (int i=(s); i<=(e); i++)
#define FOD(i,s,e) for (int i=(s); i>=(e); i--)
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define LL long long
#define ULL unsigned long long
#define pi acos(-1.0)
LL max(LL a,LL b){if (a>b){return a;} else {return b;}}
LL min(LL a,LL b){if (a<b){return a;} else {return b;}}

#define eps 1e-6

#define K 300001
int n, a[K];

int main(){
    scanf("%d", &n);
    FOE(i, 1, n) scanf("%d", &a[i]);
    
    int ret = 0;
    FOE(i, 1, n) if (a[a[i]] == i) ret++;
    
    cout << ret / 2 << endl;
    return 0;
}

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

int main(void)
{
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++)
  {
    if(i % 2 == 0)
    {
      if(!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'))
      {
        cout << "No" << endl;
        return (0);
      }
    }
    if(i % 2 == 1)
    {
      if(!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'))
      {
        cout << "No" << endl;
        return (0);
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
const int mod = 1e9+7;
ll dp[100005];
void test_case(){
	int n , m; cin >> n >> m;
	set<int> hash;
	dp[0] = 1;
	dp[1] = 1;
	for(int i = 0 ; i < m ; i++){
		int x; cin >> x;
		if(x==1)
			dp[1] = 0;
		if(x==0)
			dp[0] = 0;
		hash.insert(x);
	}
	for(int i = 2 ; i <= n ; i++){
		if(hash.find(i) != hash.end())
			dp[i] = 0;
		else
			dp[i] = (dp[i-1]+dp[i-2])%mod;
	}
	cout<<dp[n]<<"\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


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

int main(){
  string S, T;
    cin >> S >> T;
 
    //答えansを仮置きする。
    //これが十分に大きくないと不正解となるので、
    //この値なら絶対に正しい答えが出る、という値を仮置きすること
    int ans = T.size();
 
    //Sの何文字目から調べるかを全探索する
    for (int start = 0; start <= S.size() - T.size(); start++)
    {
        int diff = 0;
        for (int i = 0; i < T.size(); i++)
        {
            if (T[i] != S[start + i]) {
                diff++;
            }
        }
        ans = min(ans, diff);
    }
 
    cout << ans << endl;

}


Measured memory_bytes: 3612
from collections import defaultdict
N, M, Q = map(int, input().split())
T = []
for i in range(M):
    L, R = map(int, input().split())
    T.append([L, R, 0])
for i in range(Q):
    L, R = map(int, input().split())
    T.append([L, R, 1, i])

Ans = [0]*Q
d = defaultdict(int)
T = sorted(T, key=lambda x: (x[1], x[2]))
for i in range(len(T)):
    result = 0
    if T[i][2] == 0:
        d[T[i][0]] += 1
    else:
        for j in range(T[i][0], T[i][1]+1):
            result += d[j]
        Ans[T[i][3]] = result

for i in Ans:
    print(i)

Measured memory_bytes: 145548
// ini template jangan diedit
#include <bits/stdc++.h>
#include <math.h>
//macros goblok


#define forian(i,a,n) for(ll i=a;i<=n;i++)
#define pb push_back
#define popb pop_back
#define ll long long
#define Faqih using
#define itu namespace
#define Ganteng_Titik std; 
Faqih itu Ganteng_Titik
//int N; int a=0;
//int arr[110];
const double pi = 3.14159265359;
void test_case()
{
	double a,b,h,m;
	double c;
	cin >> a >> b >> h >> m;
	double dif_angle,sudut_jam,sudut_menit;
	double (sudut_jam = double (h*30)+(double(m/2)));
	double (sudut_menit = double (m*6));
	double (dif_angle = abs(sudut_jam - sudut_menit));
//	printf("%.20f\n", dif_angle);
	// Mencari Sisi Ketiga dari Jarum Jam
	c = sqrt((a*a) +(b*b) - (2*a*b*cos(pi*dif_angle/180)));
	printf("%.20f\n", c);
}

int main() // Main Program for At Coder
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
return 0;
}


Measured memory_bytes: 4228
#include"bits/stdc++.h"
using namespace std;

void Main() {
  long long X, Y;
  cin >> X >> Y;
  if (abs(X - Y) <= 1) cout << "Brown" << endl;
  else cout << "Alice" << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 256
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    int s,w;
    scanf("%d%d",&s,&w);
    if (s <= w) printf("unsafe\n");
    else printf("safe\n");
    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <iomanip>
using ll = long long;
using namespace std;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r) { return l.second < r.second; }
bool greaterPair(const ipair& l, const ipair& r) { return l.second > r.second; }

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define irep(i, n) for (int i = 0; i <= (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rirep(i, n) for (int i = n; i >= 0; --i)
int factorical(int n) {
	int sum = 1;
	for (int i = 1; i <= n; ++i)
	{
		sum *= i;
	}
	return sum;
}

vector<int> divisors(int n) {
	vector<int> res;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}
vector<ll> divisors_ll(ll n) {
	vector<ll> res;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}


void printVector(const vector<int>& vec) {
	for (int value : vec) {
		cout << value << " ";
	}
	cout << endl;
}

bool pal(string s) {
	int n = s.length() / 2;
			rep(i, n) {
			if (s[i] != s[s.length() - 1 - i]) return false;
		}
			return true;
}

int euclidean_gcd(int a, int b) {
	if (a < b) return euclidean_gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

vector <string> vec_sort_and_del(vector<string> s) {
	std::sort(s.begin(), s.end());
	s.erase(std::unique(s.begin(), s.end()), s.end());
	return s;
}

int GetDigit(int num) {
	int digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

int main() {
	int s, w;
	string ans = "safe";
	cin >> s >> w;
	if (w >= s) ans = "unsafe";
	cout << ans;

	return 0;
}




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

string direction[4]={"AC","WA","TLE","RE"};

int main()
{
    map<string,int>mmap;
    int n;
    string s;
    cin >> n;
    while(n--)
    {
        cin >> s;
        mmap[s]++;
    }
    for(int i=0;i<4;i++)
    {
        cout << direction[i] << " x " << mmap[direction[i]] << endl;
    }
}


Measured memory_bytes: 3644
n,x=map(int,input().split())
a=list(map(int,input().split()))
count=0
for i in range(n-1):
    if a[i]+a[i+1]>x:
        if a[i]>x:
            count+=a[i]-x
            a[i]=x
        count+=a[i]+a[i+1]-x
        a[i+1]=x-a[i]
print(count)

Measured memory_bytes: 14544
#include <iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
int l[10];
int v[2];
double m;
double pos;
int ans;
while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v[0],&v[1])!=EOF){
m=0;
for(int i=0;i<10;i++){
m+=l[i];
}
pos=(m*v[0])/double(v[0]+v[1]);
for(int i=0;i<10;i++){
pos-=l[i];
if(!(pos>0)){
ans=i+1;
break;
}
}
cout<<ans<<endl;
}
return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define print(x) cout << to_string(x) << '\n'
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)
 
long long INF = 1LL<<60;
long long MOD = 998244353;

string to_string(char &c) {string x(1, c); return x;}
string to_string(const char s[]) {return (string)s;}
string to_string(string &s) {return s;}
string to_string(vb &v) {string res; for (const bool &x : v) res += to_string(x) + ' '; return res;}
template <class C> string to_string(C &v) {string res; for (auto &x : v) res += to_string(x) + ' '; return res;}
template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
ostream &operator<<(ostream &os, vb &v) {
    bool first = true;
    os << '[';
    for (const bool &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
template <class C> ostream &operator<<(ostream &os, C &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
string bin_string(int x) {
    const int d = 32;
    string res(d, ' ');
    REP(i, 0, d) res[d-1-i] = '0'+(x>>i & 1LL);
    return res;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int n, k, s;
    cin >> n >> k >> s;
    vi res(n, 1);
    if (s-n+k>1) {
        for (int i=0; i<n; i+=n-k+1) res[i] = s-n+k;
    } else {
        res.assign(n, 1e9);
        REP(i, 0, s+k-1) res[i] = 1;
    }
    print(res);
}


Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll gcd(ll a,ll b) {return  b ? gcd(b,a%b) : a;}
const long long INF = 1LL << 60;
const int mod = 1000000007;
const double PI = acos(-1.0);
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main () {
     ll A,B;
     cin >> A>>B;
     ll d = gcd(A,B);
     vector<ll> a;
     ll dd = d;
     for(ll i = 2;i*i<=d;++i){
          if(dd%i==0){
               a.push_back(i);
               dd/=i;
               while(dd%i==0&&dd>1){
                    dd/=i;
               }
          }
     }
     if(dd!=1) a.push_back(dd);
     cout << 1+a.size() <<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#define int long long
using namespace std;
 
signed main(){
    int n;
    int max=0;
    int min=0;
    cin>> n;
    int N=3*n;
    int a[N];
 
    priority_queue<int> PQ1;
    priority_queue<int, vector<int>, greater<int> >PQ2;
 
    int max_arr[n+1]={0};
    int min_arr[n+1]={0};
    
    for(int i=0;i<3*n;i++){
        cin>>a[i];
        
    }
 
    for(int i=0;i<n;i++){
        max+=a[i];
        min+=a[i+2*n];
    }
 
    // cout<<max<<" "<<min<<endl;
 
    max_arr[0]=max;
    
    for(int i=0;i<n;i++){
        PQ2.push(a[i]);
    }
 
    for(int i=n;i<2*n;i++){
        PQ2.push(a[i]);
        max+=a[i];
        max-=PQ2.top();
        PQ2.pop();
        max_arr[i-n+1]=max;
 
    }
 
    // for(int i=0;i<n+1;i++){
    //     cout<<max_arr[i]<<" ";
    // }
 
    min_arr[n]=min;
    for(int i=2*n;i<3*n;i++){
        PQ1.push(a[i]);
    }
    for(int i=3*n;i>2*n;i--){
        // cout<<i-n-1<<endl;
        PQ1.push(a[i-n-1]);
        min+=a[i-n-1];
        min-=PQ1.top();
 
        // cout<<PQ1.top()<<endl;
        PQ1.pop();
        min_arr[(i-2*n)-1]=min;
    }
    // cout<<count<<endl;
 
 
    // for(int i=0;i<n+1;i++){
    //     cout<<min_arr[i]<<" ";
    // }
 
 
    // for(int i=0;i<n+1;i++){
    //     max[i]=
    // }
 
    int ans= max_arr[0] - min_arr[0];
    for(int i=0;i<=n;i++){
        /*if(ans<max_arr[i]-min_arr[i]){
            ans=max_arr[i]-min_arr[i];
        }*/
        ans=std::max(ans, max_arr[i] - min_arr[i]);
    }
    cout<<ans<<endl;
 
}

Measured memory_bytes: 6516
n=int(input())
s1=input()
s2=input()
ans=1
if s1[0]==s2[0]:
  p=3
  ans*=3
else:
  p=1
  ans*=6
for i in range(1,n):
  if p==1:
    p=2
  elif p==2:
    if s1[i]==s2[i]:
      p=3
    else:
      ans*=3
      p=1
  else:
    if s1[i]==s2[i]:
      ans*=2
      p=3
    else:
      ans*=2
      p=1
print(ans%(10**9+7))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


bool limit_order(
	const pair <int, int> &a,
	const pair <int, int> &b)
{
	if (a.second < b.second) return true;
	return false;
}

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

	vector <pair<int, int>> task(N);
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		task[i] = make_pair(a, b);
	}
	// 締め切りが近い順に並べる
	sort(task.begin(), task.end(), limit_order);

	long long time = 0;
	for (int i = 0; i < N; i++) {
		time += task[i].first;
		if (time <= task[i].second) continue;
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1792
///created: 11/Jul/2019 21:35:52

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
const int modulo = 1e9 + 7;

#ifdef LOCAL_DEBUG_NTV1612
template<class __Ty>
string to_string(__Ty a) {
	string res = "[ ";
	bool f = true;
	for (auto &p : a) { res += (f ? string("") : string(", ")) + to_string(p); f = false;	}
	return res + " ]";
}
void _debug() { fprintf(stderr, "\n"); }
template<typename __Ty_head, typename... __Ty_tail>
void _debug(__Ty_head head, __Ty_tail... tail) { fprintf(stderr, "%s ", to_string(head).c_str()); _debug(tail...); }
#define debug(...) fprintf(stderr, "DEBUG [%s]: ", #__VA_ARGS__), _debug(__VA_ARGS__)
#else
#define debug(...) 0
#endif

template<class __Ty> bool mini(__Ty& a, __Ty b) { return a > b ? ((a = b) | 1) : (0); }
template<class __Ty> bool maxi(__Ty& a, __Ty b) { return a < b ? ((a = b) | 1) : (0); }
template<class __Ty> __Ty add(__Ty a, __Ty b) { return (a + b) % (__Ty(modulo)); }
template<class __Ty> __Ty sub(__Ty a, __Ty b) { __Ty m(modulo); return ((a - b) % m + m) % m; }

const int N = 1e5 + 10;
int a[N], n, bit[2 * N], b[N];

void update(int m, int v) {
	m += N;
	for (int i = m; i < 2 * N; i += i & -i)
		bit[i] += v;
}

int get(int m) {
	m += N;
	int res = 0;
	for (int i = m; i > 0; i -= i & -i)
		res += bit[i];
	return res;
}

ll count_pair(int x) {
	ll res = 0;
	memset(bit, 0, sizeof bit);
	memset(b, 0, sizeof b);
	update(0, 1);
	for (int i = 1; i <= n; ++i) {
		if (a[i] >= x) b[i] = +1;
		else b[i] = -1;
		b[i] += b[i - 1];
		res += get(b[i]);
		update(b[i], 1);
	}
	return res;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	ll sz = 1LL * n * (n + 1) / 2;
	int l = 1, r = 1e9, ans = -1;
	while (l <= r) {
		int mid = (l + r) / 2;
		if (count_pair(mid) >= (sz + 1) / 2) {
			ans = mid;
			l = mid + 1;
		}
		else r = mid - 1;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CPeaks {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, M;
        cin >> N >> M;
        vector<int> H(N);
        REP(i, N) cin >> H[i];

        vector<bool> good(N, true);
        REP(i, M) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            if (H[a] >= H[b]) {
                good[b] = false;
            }
            if (H[a] <= H[b]) {
                good[a] = false;
            }
        }

        int res = 0;
        REP(i, N) {
            if (good[i]) res++;
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CPeaks solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3996
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <cctype>
#include <fstream>

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000			 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979
#define MAXI 7500000

//.size()はunsigned int　0-1をするとオーバーフローする

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

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

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


int main(void)
{
	int a, b, c;
	int time;
	int now = 0;
	int res = -1;

	cin >> a >> b >> c;

	FOR(t,0,60){
		time = 60 * t + c;
		now = 0;
		while (1)
		{
			if (now + a >= time)
			{
				res = time;
				break;
			}
			now += a + b;
			if(now>=time){
				break;
			}
		}
		if(res!=-1){
			break;
		}
	}
	cout << res << endl;
}



Measured memory_bytes: 3108
n = int(input())
a_array = [int(x) for x in input().split()]
b_array = [int(x) for x in input().split()]

plus = 0
minus = 0
plus_array = []
minus_cnt = 0
for i, j in zip(a_array, b_array):
    if j <= i:
        plus += i - j
        plus_array.append(abs(j - i))
    else:
        minus += j - i
        minus_cnt += 1
    # print(minus, plus)

plus_array = sorted(plus_array, reverse=True)
plus_res = 0
if plus < minus:
    print(-1)
elif minus == 0:
    print(0)
else:
    for i in range(len(plus_array)):
        minus -= plus_array[i]
        plus_res += 1
        if minus < 0:
            print(plus_res + minus_cnt)
            exit()


Measured memory_bytes: 18356
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int P[100000 + 10];
vector<pi> edge; //fiが終点 seが始点
set<int> l_to_r[100000 + 10];
set<int> r_to_l[100000 + 10];

signed main(void) {
    int N, M;
    cin >> N >> M;

    set<int> S;
    REP(i, 1, N) S.insert(i);
    rep(i, N-1+M) {
        int A, B;
        cin >> A >> B;
        edge.pb(mp(B, A));
        l_to_r[A].insert(B);
        r_to_l[B].insert(A);
        if (S.count(B)) S.erase(B);
    }
    int root = *(S.begin());
    // cout << root << endl;
    stack<int> T;
    T.push(root);
    // int removed_num = 0;

    while(T.size() > 0) {
        int top = T.top();
        T.pop();
        for (auto e : l_to_r[top]) {
            if (r_to_l[e].size() == 1) {
                P[e] = top;
                T.push(e);
            } else {
                r_to_l[e].erase(top);
                // removed_num++;
            }
        }
    }

    // REP(i, 1, N) {
    //     printf("l_to_r[%lld]の中身:\n", i);
    //     for (auto e : l_to_r[i]) cout << e << endl;
    //     printf("r_to_l[%lld]の中身:\n", i);
    //     for (auto e : r_to_l[i]) cout << e << endl;
    //     printf("P[%lld] = %lld\n", i, P[i]);
    // }
    
    REP(i, 1, N) {
        if (P[i] == i) cout << 0 << endl;
        else cout << P[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 23408
#include <bits/stdc++.h>
using namespace std;
void fst()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
}
int mod = 1e9 + 7;
int binpow(int a, int b)
{
    int res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res = res * a;
            res %= mod;
        }
        a = a * a;
        a %= mod;
        b >>= 1;
        b %= mod;
    }
    return res;
}
#define Darr(x)           \
    cerr << #x << " = ";  \
    for (auto i : x)      \
        cerr << i << " "; \
    cerr << "\n";

#define all(a) a.begin(), a.end()
#define pb push_back
#define deb(x) cerr << #x << "=" << x << " ";
#define int long long
#define R(n) for (int i = 0; i < n; i++)
#define Rj(n) for (int j = 0; j < n; j++)
#define F(i, a, n) for (int i = a; i <= n; i++)
#define MN(x, y) x = min(x, y);
#define MX(x, y) x = max(x, y);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

int n, k, tc, y, u, v;

int32_t main()
{
    fst();
    //freopen("input.txt","r",stdin);
    cin >> n;
    cin >> k;
    vi a(n);
    R(n) cin >> a[i];
    int pref = 1;
    R(k)
    pref *= a[i];
    F(i, k, n - 1)
    {
        //deb(pref)
        if (a[i] > (a[i - k]))
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    // Darr(a);
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
string s;
bool cf=false,fc=false;
int main()
{
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(!cf&&s[i]=='C')
		{
			cf=true;
		}
		if(cf&&!fc&&s[i]=='F')
		{
			fc=true;
		}
		if(fc&&cf)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
Author:Jenil Mehta
Not yet serious but trying to be serious :)
Coding is lub
*/
 
#include <iostream>
#include <sstream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
typedef long long int ll;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
using namespace std;
ll a[1002];
ll b[1002];
int dp[3000 + 5][3000 + 5];
 
int main() {
   /*
   Jab Bhi Koi Ladaki Dekhun Meraa Dil Divaanaa Bole
Ole Ole Ole, Ole Ole Ole
Gaao Taraanaa Yaaraa Jhum Jhum Ke Haule Haule
Ole Ole Ole, Ole Ole Ole
Mujhako Lubhaati Hai Javaaniya Masti Lutaati Zidagaani Yahaan
Maane Na Kahanaa Paagal Mast Pavan Saa Dil Ye Dole
Ole Ole Ole, Ole Ole Ole
Ole Ole Ole, Ole Ole Ole
Jab Bhi Koi Ladaki Dekhun Meraa Dil Divaanaa Bole
Ole Ole Ole, Ole Ole Ole
Gaao Taraanaa Yaaraa Jhum Jhum Ke Haule Haule
Ole Ole Ole, Ole Ole Ole
   */
    string s;
    cin>>s;
    int f=0;
    ll n=s.length();
    ll x=(n-1)/2;
    for(ll i=0;i<n;i++)
    {
        if(s[i]!=s[n-1-i])
        f=1;
    }
    int j=(s.length()+3)/2-1;
    int i=0;
    for(;j<s.length()&&i<s.length();j++,i++)
    {
        if(s[j]!=s[s.length()-1-i])
        {
            f=1;
        }
    }
    if(f)
    cout<<"No";
    else
    cout<<"Yes";
}

Measured memory_bytes: 256
from itertools import permutations

n, m = map(int, input().split())
g = {i: set() for i in range(1, n+1)}

for _ in range(m):
    a, b = map(int, input().split())
    g[a].add(b)
    g[b].add(a)

res = 0
visited = {1}
def dfs(v):
    global res
    global visited
    if len(visited) == n:
        res += 1
        return
    for i in g[v] - visited:
        visited.add(i)
        dfs(i)
        visited.remove(i)

dfs(1)

print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long

using namespace std;

ll n ;
int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    map<ll,ll> ma;
    ll sq = sqrt(n);
    for (ll i = 2;i<=sq;i++)
    {
        if (n % i == 0)
        {
            while(n % i == 0)
            {
                ma[i]++;
                n /= i;
            }
        }
    }
    if (n > 1)ma[n]++;
    ll ans = 0;
    for (auto p : ma)
    {
        ll s = p.second;
        ll o = 1;
        while(s >= o)
        {
            ans++;
            s -= o;
            o++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
  int n,k,r,s,p;
  int points = 0;
  std::string t;
  std::cin >> n >> k;
  std::cin >> r >> s >> p;
  std::cin >> t;
  for (int i = 0; i < n - k; i++) {
    if (t[i] == t[i + k]) t[i + k] = 'j';
  }
  //std::cout << t << '\n';
  for (int i = 0; i < n; i++) {
    if (t[i] == 's') points += r;
    else if (t[i] == 'p') points += s;
    else if (t[i] == 'r') points += p;

  }
  std::cout << points << '\n';
  return 0;
}


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

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

  int ans=0, now=1;
  for(int i=0; i<n; ++i){
    if(a[i]==now){++ans; ++now;}
  }

  if(ans==0)cout<<-1<<endl;
  else cout<<n-ans<<endl;

}

Measured memory_bytes: 1024
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] atoz = new int[26];
   
        do {
            String s = sc.nextLine();
            for (char c : s.toCharArray()){
                if ((c < 'A' || 'Z' < c) && (c < 'a' || 'z' < c)) continue;
                atoz[Character.toLowerCase(c)- 'a']++;
            }
        } while (sc.hasNext());
   
        for (char c = 'a'; c <= 'z'; c++){
            System.out.println(c + " : " + atoz[c - 'a']);
        }
    }
}



Measured memory_bytes: 26216
L,R = map(int,input().split())
r = 2019
if R//2019 != L//2019:
    print(0)
else:
    Rmod = R%2019
    Lmod = L%2019
    for i in range(Lmod,Rmod+1):
        for j in range(i+1,Rmod+1):
            r = min(r,(i*j)%2019)
    print(r)


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


int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m);
  vector<int> ans(n+1);
  for(int i=0;i<m;++i){
    cin >> a[i] >> b[i];
  }
  for(int i=0;i<m;++i){
    ans[a[i]]++;
    ans[b[i]]++;
  }
  for(int i=1;i<=n;++i){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
const int maxn = 100000+5;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

int n;
int a[maxn];
int pre[maxn];
int suf[maxn];

int main(){
    //freopen("input.txt", "r", stdin);
    fastio();

    cin >> n;
    for(int i = 0; i < n; ++i)
        cin>>a[i];
    pre[0] = a[0];
    for(int i = 1; i < n; ++i)
        pre[i] = __gcd(a[i], pre[i-1]);
    suf[n-1]= a[n-1];
    for(int i = n-2; i >= 0; --i)
        suf[i] = __gcd(a[i], suf[i+1]);
    int ans = 0;
    for(int i = 0; i< n; ++i)
        ans = max(ans, __gcd(pre[i-1], suf[i+1]));
    cout<< ans<<endl;

    return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#define FUP(i,x,y) for(int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(int i=(x);i>=(y);i--)
#define MAXN 510
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define ll long long
#define db double
using namespace std;
int read(){
    int w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
struct node{
	int pos,data;
}b[MAXN];
bool cmp(node p,node q)
{
	return p.pos<q.pos;
}
int n,x[MAXN];
int a[MAXN*MAXN],need[MAXN*MAXN],now[MAXN*MAXN];
int num[MAXN*2],used[MAXN*2],cnt=1;
int main(){
	n=read();
	FUP(i,1,n)
	{
		x[i]=b[i].pos=read();
		b[i].data=i;
		a[x[i]]=i;
		need[x[i]]=i-1;
	}
	sort(b+1,b+n+1,cmp);
	FUP(i,1,n) num[i]=b[i].pos,used[i]=b[i].data-1;
	FUP(i,n+1,2*n) num[i]=b[i-n].pos,used[i]=n-1-used[i-n];
	FUP(i,1,n*n)
	{
		if(a[i])
		{
			if(need[i]!=now[i])
			{
				puts("No");
				return 0;
			}
		}
		else
		{
			while(used[cnt]==0) cnt++;
			used[cnt]--;
			a[i]=a[num[cnt]];
			now[num[cnt]]++;
		}
	}
	puts("Yes");
	FUP(i,1,n*n) printf("%d ",a[i]);
    return 0;
}

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

const int maxn = 220000;

int a[maxn];
long long s[maxn];
pair<long long, long long> lft[maxn], rgt[maxn];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for(int i = 0; i < n; ++ i) cin >> a[i];
	for(int i = 0; i < n; ++ i) s[i] = i == 0 ? a[i] : s[i - 1] + a[i];
	for(int i = 1; i < n; ++ i) {
		int pos = lower_bound(s, s + i, s[i] / 2) - s;
		if(pos < i) lft[i] = make_pair(s[pos], s[i] - s[pos]);
		else lft[i] = make_pair(s[pos - 1], s[i] - s[pos - 1]);
		if(pos && pos < i && abs(s[pos] - (s[i] - s[pos])) > abs(s[pos - 1] - (s[i] - s[pos - 1]))) {
			lft[i] = make_pair(s[pos - 1], s[i] - s[pos - 1]);
		}
	}
	reverse(a, a + n);
	for(int i = 0; i < n; ++ i) s[i] = i == 0 ? a[i] : s[i - 1] + a[i];
	for(int i = 1; i < n; ++ i) {
		int pos = lower_bound(s, s + i, s[i] / 2) - s;
		if(pos < i) rgt[i] = make_pair(s[pos], s[i] - s[pos]);
		else rgt[i] = make_pair(s[pos - 1], s[i] - s[pos - 1]);
		if(pos && pos < i && abs(s[pos] - (s[i] - s[pos])) > abs(s[pos - 1] - (s[i] - s[pos - 1]))) {
			rgt[i] = make_pair(s[pos - 1], s[i] - s[pos - 1]);
		}
	}
	reverse(rgt, rgt + n);
	long long ans = -1;
	for(int i = 1; i < n - 2; ++ i) {
		s[0] = lft[i].first;
		s[1] = lft[i].second;
		s[2] = rgt[i + 1].first;
		s[3] = rgt[i + 1].second;
		sort(s, s + 4);
		if(ans == -1 || ans > s[3] - s[0]) ans = s[3] - s[0];
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;

int main(){
    int N,W;cin >> N >> W;
    vector<LL> w(N),v(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    vector<vector<LL>> dp(N+1,vector<LL> (W+1,0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < W; j++) {
            if(dp[i][j]==0&&j!=0) continue;
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            if(j+w[i]<=W) dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
        }
    }
    LL ans=0;
    for (int i = 0; i <= W; i++) {
        ans=max(ans,dp[N][i]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 80256
/*
	*	Created By: 'Present_Sir'
	*	Created On: Friday 21 August 2020 11:13:15 AM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
#define ld long double
#define pi 3.1415926536 
using namespace std;


void solve(){
    long double a,b,h,m;
    cin>>a>>b>>h>>m;
    long double convert = pi/180;
    long double ans = 0;

    long double angle1 = h*30.0+m*0.5;
    long double angle2 = m*6.0;
    long double angle = abs(angle1-angle2);   
    angle = min(angle,360-angle);
    //cout<<angle1<<" "<<angle2<<" "<<angle<<endl;
    ans = (ld)a*a +(ld)b*b - (ld)2*a*b*cos((ld)(angle*convert));
    ans = (ld)sqrt((ld)ans);
    cout<<setprecision(9)<<fixed<<ans<<endl;
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 4160
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  if(n%1000!=0)
  {
      cout<<ceil(n/1000.0)*1000 - n <<'\n';
  }
  else
    cout<<0<<'\n';
  return 0;
}


Measured memory_bytes: 3900
import java.util.*
import java.math.*

fun main(args: Array<String>) {
    var (N,X) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toInt()
//    val S = readLine()!!.toInt()
    val L = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    var sum = 0
    var ans = 1
    for (l in L) {
        sum += l
        if (sum > X) break
        ans++
    }


    println(ans)
}


Measured memory_bytes: 37928
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
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; }

signed main(){
  int k,a,b;
  cin >> k >> a >> b;
  bool judge = false;
  for(int i = a;i <= b;i++){
    if(i % k == 0) judge = true;
  }
  if(judge) cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int x, sum;cin >> x;
	ll s = floor(sqrt(x * 2)) - 1;
	for (int i = s; i <= x;i++) {
		if (i * (i + 1) / 2 >= x) {
			cout << i << endl;
			return 0;
		}
	}
}

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

int main() {
  long int n,a,b;  cin >> n >> a >> b;
  long int h = n/(a+b);
  long int k = n%(a+b);
  if(k>=a) cout << a*h + a << endl;
  else if(k<a) cout << a*h + k << endl;
  
  return 0;
}




Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n=int(input())
alps=[chr(ord("a")+x) for x in range(26)]
def dfs(s,mx):
    if len(s)==n:
        print(s)
    else:
        for i in range(mx+1):
            if (i==mx):
                dfs(s+alps[i],mx+1)
            else:
                dfs(s+alps[i],mx)
                
                
dfs("",0)


Measured memory_bytes: 4412
#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	if (n < 1200) {
		cout << "ABC" << endl;
	} else if(n < 2800) {
		cout << "ARC" << endl;
	} else {
		cout << "AGC" << endl;
	}
	return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\n" << (#x) << " = " << (x) << "\n"
using namespace std;
ll N, W, w[100], v[100];

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> N >> W;
	for(int j = 0; j < N; ++j){
		cin >> w[j] >> v[j];
	}

	ll dp[N + 1][W + 1];
	for(int i = 0; i <= N; ++i){
		for(int j = 0; j <= W; ++j){
			if(i == 0 || j == 0){
				dp[i][j] = 0;
				continue;
			}
			if(j >= w[i - 1]){
				dp[i][j] = max(dp[i - 1][j], v[i - 1] + dp[i - 1][j - w[i - 1]]);
			}
			else{
				dp[i][j] = dp[i - 1][j];
			}
		}
	}

	cout << dp[N][W];
	return 0;
}

Measured memory_bytes: 82492
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

string dic[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main(){
  string s;
  cin >> s;
  int id;
  rep(i,7){
    if(s == dic[i]){
      id = i;
      break;
    }
  }
  cout << 7 - id << endl;
}


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

using namespace std;
map<int,int> mp,ind;
typedef long long ll;
int imos[400010] = {};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i,n,d,a;
    cin >> n >> d >> a;
    for(i=0;i<n;i++){
        int x,h; cin >> x >> h;
        mp[x] += h; mp[x + 2*d + 1] += 0;
    }
    int now = 0;
    for(auto x:mp){
        ind[x.first] = now; now++;
    }
    ll ans = 0; int dm = 0;
    for(auto x:mp){
        dm += imos[ind[x.first]];
        if(x.second<=dm) continue;
        int t = (x.second - dm + a - 1)/a;
        ans += t; dm += a*t;
        imos[ind[x.first + 2*d + 1]] -= a*t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 39296
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdint.h>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
    int a, b;
    cin>>a>>b;
    int ans = -1;
    if(a < 10 && b < 10) ans = a * b;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0594?year=2014

#include <bits/stdc++.h>

using namespace std;

int dist(int x1, int y1, int x2, int y2) {
    int dx = x2 - x1;
    int dy = y2 - y1;
    
    if ((dx > 0 and dy > 0) or (dx < 0 and dy < 0)) {
        return max(abs(dx), abs(dy));
    } else {
        return abs(dx) + abs(dy);
    }
}

int main() {
    int w, h, n;
    cin >> w >> h >> n;

    int xst, yst;
    cin >> xst >> yst;

    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }

    int xen, yen;
    int ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        cin >> xen >> yen;
        ans += dist(xst, yst, xen, yen);
        xst = xen, yst = yen;
    }

    cout << ans << endl;
    return 0;
}

/*
 * 右上または左下に移動する場合を考える。
 * 「右1，上1」を「右斜め上1」に変換できる。
 * 右，上，右斜め上に各x,y,z回動くことを(x,y,z)であらわすと
 * (1,1,0)->(0,0,1)のような変換ができる。
 * 一般には
 * (x,y,0)->(max(x,y)-min(x,y),0,min(x,y))
 * のようになるので，この場合の移動回数は
 * (max(x,y)-min(x,y))+min(x,y)=max(x,y)
 * 他の場合はx+yのような移動回数になる。
 *
 */


Measured memory_bytes: 3072
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
ate = a[0]
ans += b[ate-1]
for i in range(1,n):
    eat = a[i]
    ans += b[eat-1]
    if ate + 1 == eat:
        ans += c[ate-1]
    ate = eat
print(ans)


Measured memory_bytes: 9204