akhauriyash/Code-Regression huggingface dataset:
//written by NewbieChd
#include <cstdio>
#include <cctype>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    register int f = 0;
    register char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int N = 100003;
int a[N];
int main() {
    register int n = read(), i, ans = 0;
    for (i = 1; i <= n; ++i)
        a[i] = read();
    for (i = 1; i <= n; ++i)
        a[i] -= read();
    for (i = 1; i <= n; ++i)
        if (a[i] > 0)
            ans += a[i];
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int n,m;
  
  scanf("%d %d",&n,&m);
  int l[m+1];
  int r[m+1];
  
  for(int i=1;i<=m;i++){
    scanf("%d %d",&l[i],&r[i]);
  }
  
  int countl=1;
  int countr=n;
  
  for(int i=1;i<=m;i++){
    if(countl<l[i]){
      countl=l[i];
    }
  }
  for(int i=1;i<=m;i++){
    if(countr>r[i]){
      countr=r[i];
    }
  }
  
  if(countr-countl<0){
    printf("0");
  }else{
    printf("%d",countr-countl+1);
  }
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
    using namespace std;
     
    int main(){
      int N;
      cin >> N;
     
      vector<int> L(N);
     
      for(int i = 0; i < N; i++) cin >> L[i];
     
      int sum = 0;
      for(int i = 0; i < N; i++){
        sum += L[i];
      }
     
      sort(L.begin(),L.end());
     
      if(L[N - 1] < sum - L[N - 1]) cout << "Yes";
      else cout << "No";
     
      
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int ans = 100000000;
	for (int num = -100; num <= 100; num++)
	{
		int temp = 0;
		for (int i = 0; i < n; i++)
		{
			temp += (num - a[i]) * (num - a[i]);
		}
		ans = min(ans, temp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;
const ll INF = (ll)1e18;

int n, m;
int l[N], r[N], c[N];
ll de[N];
vector < int > event[N];

int main(){
  cin >> n >> m;
  for(int i = 1; i <= m; ++i){
    cin >> l[i] >> r[i] >> c[i];
    event[l[i]].push_back(i);
    event[r[i] + 1].push_back(-i);
  }
  multiset < ll > cur;
  for(int j = 1; j <= n; ++j){
    for(int i : event[j]){
      if(i < 0){
        if(de[-i] != INF)
          cur.erase(cur.find(de[-i] + c[-i]));
      }
    }
    for(int i : event[j]){
      if(i > 0){
        if(cur.empty() || l[i] == 1){
          if(l[i] == 1){
            de[i] = 0;
          } else{
            de[i] = INF;
          }
        } else{
          de[i] = *cur.begin();
        }
        if(de[i] != INF){
          cur.insert(de[i] + c[i]);
        }
      }
    }
  }
  ll ans = INF;
  for(int i = 1; i <= m; ++i){
    if(r[i] == n){
      ans = min(ans, de[i] + c[i]);
    }
  }
  if(ans == INF) ans = -1;
  cout << ans;
  return 0;
}


Measured memory_bytes: 15232
#include <cstdio>
#include <algorithm>
using namespace std;
int n,m,x;
int c[15],a[15][15],b[15],d[15],len,sum=100000000,cost;
void init(){
	int i,j;
	scanf("%d%d%d",&n,&m,&x);
	for(i=1;i<=n;i++){
		scanf("%d",&c[i]);
		for(j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	}
}
void dfs(int step){
	int i,j,k;
	if(step==len+1){
		for(k=1;k<=m;k++)d[k]=0;
		for(j=1;j<=len;j++)
			for(k=1;k<=m;k++)
				d[k]+=a[b[j]][k];
		for(k=1;k<=m;k++)
			if(d[k]<x)return;
		cost=0;
		for(j=1;j<=len;j++)cost+=c[b[j]];
		sum=min(sum,cost);
		return ;
	}
	for(i=b[step-1]+1;i<=n;i++)
		b[step]=i,dfs(step+1);
}
int main(){
	init();
	for(len=1;len<=n;len++)
		b[0]=0,dfs(1);
	if(sum==100000000)printf("-1\n");
	else printf("%d\n",sum);
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int T = sc.nextInt();
		int A = sc.nextInt();
		int[] H = new int[N];
		double[] t = new double[N];
		double[] sa = new double[N];
		double min = Math.pow(10, 6);
		int num = 10000;
		
		for(int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
			t[i] = T - H[i] * 0.006;
			sa[i] = Math.abs(A - t[i]);
			
			if(min > sa[i]) {
				num = i + 1;
				min = sa[i];
			}
		}
		
		System.out.println(num);
		
	}
}


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

int main(){
    int n,acc=0,waa=0,tlee=0,ree=0;
    cin >> n;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        if(s=="AC")acc++;
        if(s=="WA")waa++;
        if(s=="TLE")tlee++;
        if(s=="RE")ree++;
    }
    cout << "AC x " << acc << endl;
    cout << "WA x " << waa << endl;
    cout << "TLE x " << tlee << endl;
    cout << "RE x " << ree << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		vector<ll>arr(n);
		for (ll &i : arr) cin >> i;
		ll ans = 0, mn = arr[0];
		for (ll i : arr) {
			ans += max(0ll, -i + mn);
			mn = max(mn, i);
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 4760
S = input()
judge = True
if S[0] == S[1]:#AA00
  if S[1] == S[2]:#AAA0
    judge = False
  else:#AAB0
    if S[2] != S[3]:#AABC
      judge = False
    elif S[0] == S[3]:#AABA
      judge = False
else:#AB00
  if S[1] != S[2]:#ABC0 or ABA0
    if S[0] != S[2]:#ABC0
      judge = False
    else:
      if S[1] != S[3]:#ABAC
        judge = False
  else:#ABB0
    if S[0] != S[3]:#ABBC
      judge = False
if judge:
  print("Yes")
else:
  print("No")

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

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long n = 0, k = 0;
    cin >> n >> k;
    vector<int> v(n, 0);
    for(int i = 0; i < n; i++) cin >> v[i]; 
    vector<int> dp(n, 0);
    long long ans = 0;
    dp[0] = 0;
    for(int i = 1; i < n; i++) {
        long long minn = INT32_MAX;
        long long temp = 0;
        for(int j = 1; j <= k && i - j >= 0; j++) {
            temp = dp[i - j] + abs(v[i] - v[i - j]);
            if(temp < minn) minn = temp;
        }
        dp[i] = minn;
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
safe = set()

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        safe.add(a[j])

ans = 0

for i in range(n):
    if (i+1) not in safe:
        ans += 1
        
print(ans)

Measured memory_bytes: 9128
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 1e7+1;
 
typedef long long ll;
typedef long double ld;

vector<ll> dd(N);

void findDivisors(ll n) 
{ 
    for (ll i = 1; i <= n; i++) { 
        for (ll j = 1; j * i <= n; j++) 
            dd[i * j]++; 
    } 
} 
void test_case()
{
    ll n,i,j;
    cin >> n;
    ll ans = 0;
    findDivisors(n);
    f(i,1,n+1)
    {
        ans = ans + i * (dd[i]);
    }

    cout << ans << '\n';
    
}
 
int32_t main()
{
    IOS(); 
  
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 81144
ls = [[0]*1001 for i in range(10)]
ls[0][0] = 1
for i in range(101):
	for j in range(9,0,-1):
		for k in range(i,1000):
			ls[j][k] += ls[j-1][k-i] 
	

while True:
	n,s = map(int, raw_input().split())
	if n == 0: break
	print ls[n][s]

Measured memory_bytes: 4392
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {


	int a,b,c;

	cin>>a>>b>>c;

	if(c>=a&&c<=b){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}


	return 0;
}



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

int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  vector<long long> a(n+1), b(m+1);

  a.at(0) = 0;
  for (long long i = 1; i <= n; ++i) {
    long long ai;
    cin >> ai;
    a.at(i) = a.at(i-1) + ai;
  }
  b.at(0) = 0;
  for (long long i = 1; i <= m; ++i) {
    long long bi;
    cin >> bi;
    b.at(i) = b.at(i-1) + bi;
  }
  long long ans = 0;
  long long j = m;
  for (long long i = 0; i <= n; ++i) {
    while (b.at(j) + a.at(i) > k) {
      --j;
      if (j < 0) break;
    }
    if (j >= 0 && i + j > ans) ans = i + j;
    if (j < 0) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6408
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define Repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define Print(x) cout << (x) << endl 
#define Min2(a, b) ((a) < (b)) ? (a) : (b)
#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

ll N, A[100000];

long long int gcd(int k){
    ll gcd, cnt = 0;
    for(ll i = 1; i <= A[k]; i++){
        gcd = A[k] / i;
        Rep(j, 0, N){
            if(A[j] % gcd != 0) cnt++;
            if(cnt > 1) break;
        }
        if(cnt <= 1){
            return gcd;
        }
        cnt = 0;
    }
    return 1;
}

int main(){
    cin >> N;
    Rep(i, 0, N) cin >> A[i];
    sort(A, A + N, [](int x, int y) -> bool{return (x < y);});
    int m1 = gcd(0);
    int m2 = gcd(1);
    int m = (m1 > m2) ? m1 : m2;
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;

int main() {
	int N;
	int ga, sa, ba;
	int gb, sb, bb;
	cin >> N;
	cin >> ga >> sa >> ba;
	cin >> gb >> sb >> bb;
	vector<int> dpab(N+1);
	dpab[0] = 0;
	for (int n = 1; n <= N; n++)
	{
		dpab[n] = 1 + dpab[n - 1];
		if (n >= ga)
			dpab[n] = max(dpab[n], gb + dpab[n - ga]);
		if (n >= sa)
			dpab[n] = max(dpab[n], sb + dpab[n - sa]);
		if (n >= ba)
			dpab[n] = max(dpab[n], bb + dpab[n - ba]);
	}

	int nN = dpab[N];
	vector<ll> dpba(nN + 1);
	dpba[0] = 0;
	for (int n = 1; n <= nN; n++)
	{
		dpba[n] = 1 + dpba[n - 1];
		if (n >= gb)
			dpba[n] = max(dpba[n], ga + dpba[n - gb]);
		if (n >= sb)
			dpba[n] = max(dpba[n], sa + dpba[n - sb]);
		if (n >= bb)
			dpba[n] = max(dpba[n], ba + dpba[n - bb]);
	}

	cout << dpba[nN] << endl;
	return 0;
}


Measured memory_bytes: 195584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

class Program
{
    
    static void Main(string[] args)
    {
        var arr = arrInt();
        long n = arr[0];
        long d = arr[1];
        var map = mapInt((int)n);
        int num = 0;
        foreach(var ele in map)
        {
            long x = (long)ele[0];
            long y = (long)ele[1];
            double kyori = Math.Sqrt(x * x + y * y);
            if (kyori <= d) num++;
        }
        Console.WriteLine(num);

    }

    




    //入力受け取り用
    static string crS() { return Console.ReadLine(); }
    static int crI() { return int.Parse(Console.ReadLine()); }
    static int[] arrInt(){return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();}
    static long[] arrLong(){ return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray(); }
    static string[] arrStr(){return Console.ReadLine().Split(' ').ToArray();}
    static List<int[]> mapInt(int h)
    {
        List<int[]> mapInt = new List<int[]>();
        for (int i = 0; i < h; i++)
        {
            mapInt.Add(arrInt());
        }
        return mapInt;
    }

    static List<string[]> mapStr(int h)
    {
        List<string[]> mapStr = new List<string[]>();
        for (int i = 0; i < h; i++)
        {
            mapStr.Add(arrStr());
        }
        return mapStr;
    }

    static List<char[]> mapChar(int h)
    {
        List<char[]> mapChar = new List<char[]>();
        for (int i = 0; i < h; i++)
        {
            string s = crS();
            mapChar.Add(s.ToCharArray());
        }
        return mapChar;
    }

    static List<char[]> mapCharCopy(List<char[]> map)
    {
        List<char[]> copyMap = new List<char[]>();
        foreach (var arr in map)
        {
            List<char> list = new List<char>();
            foreach (var ele in arr)
            {
                list.Add(ele);
            }
            copyMap.Add(list.ToArray());
        }
        return copyMap;
    }
}

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


using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define endl "\n"

const ll maxn=5e5;

const ll maxx=1e13;
const ll mod=1000000007;
const ll mod1=998244353;

ll a[maxn];
map<ll,ll> mp;
string s[maxn];
ll l[maxn];
ll r[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
    //   freopen("GREEDY.INP", "r", stdin);
    //  freopen("GREEDY.OUT", "w", stdout);
   ll n,k,c;
    cin>> n>>k>>c;
    string s;
    cin>>s;
    s=" " +s ;
    ll cnt=0;
    ll cnt1=0;
     for (int i=1;i<=n;i++)
     {
          if (cnt==0)
          {
              if (s[i]=='x') continue ;
              else
              {
                  cnt1++;
                  cnt=c;
                  l[i]=cnt1;

              }
          }
          else
          {
              cnt--;
              if (s[i]=='o')
              {
              //    l[i]=cnt1;

              }
          }
     }

     cnt=0;
     cnt1=0;
      for (int i=n;i>=1;i--)
     {
          if (cnt==0)
          {
              if (s[i]=='x') continue ;
              else
              {
                  cnt1++;
                  cnt=c;
                  r[i]=k-cnt1+1;

              }
          }
          else
          {
              cnt--;
              if (s[i]=='o')
              {
                //  r[i]=k-cnt1;

              }
          }
     }
       for (int i=1;i<=n;i++)
     {
     //    cout <<l[i]<<" "<<r[i]<<endl;
     }
    vector<ll> ans;
     for (int i=1;i<=n;i++)
     {
         if (s[i]=='o')
         {
             if (r[i]==l[i]&&r[i]!=0)
             {
                 ans.pb(i);
             }
         }
     }
     for (auto p:ans)
     {
         cout <<p<<endl;
     }
}


Measured memory_bytes: 15560
/*** 𝕒𝕜𝕤𝕙𝕒𝕪𝕜𝕦𝕞𝕒𝕣𝟡𝟡 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    ll x,i,j;
    cin>>x;
    ll tot=100,ans=0;
    ll inc=1;
    while(tot<x)
    {
        tot+=inc;
        inc=tot/100;
        ans++;
    }
    cout<<ans;


}

int32_t main()
{
    IOS();
    
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3612
#include <limits.h>
#include <stdio.h>
#define min(x, y) ((x) < (y) ? (x) : (y))
#define abs(x) ((x) < 0 ? (-1*x) : (x))

int main()
{
  int n,k;
  scanf("%d%d",&n,&k);
  k = min((n-1), k);
  //printf("%d",k);
  int h[n],dp[n];
  int i = 0;
  while (i < n)
  {
    dp[i] = 0;
    scanf("%d",&h[i]);
    i++;
  }
  dp[0] = 0;
  dp[1] = abs((h[1]-h[0]));
  if (n == 2)
  {
    printf("%d",dp[1]);
    return (0);
  }
  //dp[2] = min(abs((h[2]-h[1]))+dp[1], abs((h[2]-h[0])+dp[0]));
  i = 1;
  int j = 0;
  int min_tmp;
  while (i < n)
  {
    j = i-1;
    min_tmp = INT_MAX;
    while (j >= 0 && j >= i - k)
    {
      if (min_tmp > abs((h[i]-h[j]))+dp[j])
        min_tmp = abs((h[i]-h[j])) + dp[j];
      dp[i] = min_tmp;
      j--;
    }
    i++;
  }
  printf("%d",dp[i-1]);
}

Measured memory_bytes: 2460
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;


public class Main {
	public static void main (String[] args) {
		  @SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
	        String[] inputNums = scan.nextLine().split(" ");
	        System.out.println(compThreeNumers(inputNums));
	    }
	    private static String compThreeNumers(String[] inputNums) {
	        ArrayList<Long> sortedNums = new ArrayList<Long>();
	        for(String inputNum :inputNums) {
	            sortedNums.add( Long.parseLong(inputNum));
	        }
	        Collections.sort(sortedNums);

	        String space = " ";
	        String resultNums = sortedNums.get(0).toString();
	        for(int i = 1; i < sortedNums.size(); i++) {
	            resultNums += space + sortedNums.get(i).toString();
	        }
	        return resultNums;
	    }
	}

Measured memory_bytes: 26124
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

struct city_data {
    int i, place, year, x;
};

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

    int N, M;
    cin >> N >> M;
    vector<city_data> c(M);
    REP(i, M) {
        cin >> c[i].place >> c[i].year;
        c[i].i = i;
    }
    sort(ALL(c), [](const city_data a, const city_data b) {
        if (a.place == b.place)
            return a.year < b.year;
        return a.place < b.place;
    });
    int cnt = 1;
    c[0].x  = 1;
    FOR(i, 1, M) {
        if (c[i - 1].place == c[i].place) {
            c[i].x = ++cnt;
        } else {
            c[i].x = 1;
            cnt    = 1;
        }
    }
    sort(ALL(c),
         [](const city_data a, const city_data b) { return a.i < b.i; });
    REP(i, M) {
        cout << setfill('0') << right << setw(6) << c[i].place;
        cout << setfill('0') << right << setw(6) << c[i].x << '\n';
    }

    return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<utility>
#include<algorithm>

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

int main (void){

    int n, p;
    string s;

    cin >> n;

     pair<string,P>a[n];

    for(int i = 0;i < n;i++){

        cin >> a[i].first >> a[i].second.first;
        a[i].second.first *= -1;
        a[i].second.second = i+1;
    }

    sort(a,a+n);

    for(int i = 0;i < n;i++)
    cout << a[i].second.second << endl;
    



    return 0;
}

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;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	string s;
    	cin>>s;
    	n=s.size();
    	ll t=1;
    	for(i=1;i<n;i++)
    	{
    		if(s[i]==s[i-1])
    			t=0;
    	}
    	if(t)
    		cout<<"Good";
    	else
    		cout<<"Bad";
    }
    return 0;
}

Measured memory_bytes: 256
import math

nums = list(map(lambda x:int(x), input().split()))
a, b, h, m = nums[0], nums[1], nums[2], nums[3]

wa = 0.5
wb = 6

tm = 60 * h + m

da = tm * wa * math.pi / 180
db = (tm % 60) * wb * math.pi / 180
diff = abs(da - db)
csq = a*a + b*b - (2 * a * b * math.cos(diff))
print("{:.20f}".format(math.sqrt(csq)))

Measured memory_bytes: 9456
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
char s[N],t[N];
int n,ans,l=1,r,last,q[N];
int main(){
	scanf("%d%s%s",&n,s+1,t+1),last=n;
	for(int i=n;i;){
		while(last&&(i<last||s[last]!=t[i])) --last;
		if(!last)	{puts("-1");return 0;}
		while(l<=r&&q[l]-r+l-1>=i)	++l;
		q[++r]=last;
		if(i!=last) ans=max(ans,r-l+1);
		while(t[i]==s[last]&&i>=last)	--i;
	}
	printf("%d\n",ans);
	return 0;
}


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

typedef long long ll;

int main() {
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		ll a, b; cin >> a >> b;

		ll r = (ll)sqrt(a * b), ans = r * 2;
		if (a != b)ans--;
		if (a * b <= r * r)ans--;
		if (a * b <= r * (r + 1))ans--;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long mod=1e9+7;
long X,Y;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long C(long a,long b)
{
	long x=1,y=1;
	for(int i=1;i<=b;i++)
	{
		x=x*(a-i+1)%mod;
		y=y*i%mod;
	}
	return x*power(y,mod-2)%mod;
}
main()
{
	cin>>X>>Y;
	if((X+Y)%3)
	{
		cout<<0<<endl;
		return 0;
	}
	long T=(X+Y)/3;
	X-=T;
	Y-=T;
	if(X<0||Y<0)
	{
		cout<<0<<endl;
		return 0;
	}
	cout<<C(T,X)<<endl;
}


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

int main(){
    int a,b,k,ans=1,cnt=0;
    cin >> a >> b >> k;
    for(int i = min(a,b);i >= 1;i --){
        if(a%i==0&&b%i==0) cnt ++;
        if(cnt==k) {ans=i;break;}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define ll long long
using namespace std;
ll d[110][100010];
bool b[110][100010];
int n;
ll m;
int main()
{
	cin >>n>>m;
	b[0][0]=1;
	for (int i=1;i<=n;i++) fill(d[i],d[i]+100001,1e9);
	for (int tr=0;tr<n;tr++)
	{
		ll x;
		int y;
		cin >>x>>y;
		for (int i=0;i<=100000-y;i++)
		{
			if (!b[tr][i]) continue;
			d[tr+1][i]=min(d[tr+1][i],d[tr][i]);
			d[tr+1][i+y]=min(d[tr+1][i+y],d[tr][i]+x);
			b[tr+1][i+y]=b[tr+1][i]=1;
			//cout <<i+y<<" "<<d[tr+1][i+y]<<" ##\n";
		}
	}
	for (int i=100000;i>=0;i--)
	{
		if (b[n][i] && d[n][i]<=m)
	    {
		    cout <<i;
		    return 0;
	    }
	}
	return 0;
}

Measured memory_bytes: 88576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Palindromic_Numbers
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] pr = Console.ReadLine().Split(' ');
            int str1 = int.Parse(pr[0]);
            int str2 = int.Parse(pr[1]);
            Palindrome(str1,str2);
        }

        private static void Palindrome(int n0,int n1)
        {
            int[] str = new int[5];
            int PCount = 0;
            for (; n0 <= n1; ++n0)
            {
                int n = n0;
                for (int m = 4;n > 0;--m)
                {
                    str[m] = n % 10;
                    n /= 10;
                }
                if (str[0] == str[4] && str[1] == str[3])
                {
                    ++PCount; 
                }
            }
            Console.WriteLine(PCount);
            return;
        }
    }
}


Measured memory_bytes: 11092
n,m=map(int,input().split())
h=list(map(int,input().split()))
good=[1 for i in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    if h[a]>h[b]:
        good[b]=0
    elif h[a]<h[b]:
        good[a]=0
    else:
        good[a]=good[b]=0
ans=0
for i in good:
    if i==1:
        ans+=1
print(ans)



Measured memory_bytes: 19904
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long LL;
LL _min(LL x, LL y) {return x < y ? x : y;}

LL a[110000];

int main() {
	int n, k; scanf("%d%d", &n, &k);
	if(k == 0) {
		printf("0\n");
		return 0;
	}
	int pos = 0;
	for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	for(int i = 1; i <= n; i++) {
		if(a[i] >= 0) {pos = i; break;}
	}
	if(pos == 0) {
		printf("%lld\n", -a[n - k + 1]);
		return 0;
	}
	LL ans = 1e16;
	for(int i = 1; i < pos; i++) {
		if(i + k - 1 <= n && a[i + k - 1] >= 0) ans = _min(ans, -a[i] * 2 + a[i + k - 1]);
	} if(pos + k - 1 <= n) ans = _min(ans, a[pos + k - 1]);
	for(int i = pos; i <= n; i++) {
		if(i - k + 1 >= 1 && a[i - k + 1] < 0) ans = _min(ans, a[i] * 2 - a[i - k + 1]);
	}
	if(a[pos] == 0 && pos - k + 1 >= 1) ans = _min(ans, -a[pos - k + 1]);
	else if(pos - k >= 1) ans = _min(ans, -a[pos - k]);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 896
/* 
 * Author: pawanmsr
 */

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

// Macro //
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>

// Global //

// Functions //

// Main //
int main(int argc, char const *argv[])
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    
    /* code */
    int r; cin >> r;
    static float pi = 3.141593;
    cout << 2 * pi * r << endl;
    return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;

    return 0;
}

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


int main(){
	int N, W; cin>>N>>W;
	int w[N+1], v[N+1]; w[0] = v[0] = 0;
	for(int i = 1; i <= N; i++) cin>>w[i]>>v[i];
	long long dp[N+1][W+1];
	for(int i = 0; i <= N; i++) dp[i][0] = 0;
	for(int i = 0; i <= W; i++) dp[0][i] = 0;
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= W; j++){
			dp[i][j] = 0;
			if(j - w[i] >= 0) dp[i][j] = dp[i-1][j-w[i]] + v[i];
			dp[i][j] = max(dp[i][j], dp[i-1][j]);
		}
	}
	cout<<dp[N][W]<<endl;
}


Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
  ll h,w;
  cin >> h >> w;
  ll ans = h*w/2;
  if(h%2==1 && w%2==1){
    ans = h*(w-1)/2 + h/2+1;
  }
  if(h == 1 || w == 1){
    ans = 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

#include<stdlib.h>


int main()

{

int a,b,c,d,e,f,g;

scanf("%d%d%d%d",&a,&b,&c,&d);


e=abs(a-c);
f=abs(a-b);
g=abs(b-c);
if((e<=d) || (f<=d && g<=d))

{

printf("Yes\n");

}


else

{

printf("No\n");

}

return 0;

}  

Measured memory_bytes: 1640
import java.util.*;

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

        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < h.length; i++) {
            h[i] = sc.nextInt();
        }
        int ans = 0;
        int t = h[0];
        for (int i = 0; i < h.length; i++) {
            if (t <= h[i]) {
                t = h[i];
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
const ll MOD = 1e9 + 7;
struct mint {
    long long x;
    mint(long long _x=0):x((_x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint modpow(long long t) const {
        if (!t) return 1;
        mint a = modpow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return modpow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    friend std::ostream& operator<<(std::ostream& os, const mint& a){
        os << a.x;
        return os;
    }
};


int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> s(2e5,0), f(2e5,0);
    vector<ll> A;
    ll cntz = 0, cntpl = 0, cntmi = 0;
    rep(i,N){
        ll a;
        cin >> a;
        A.push_back(abs(a));
        if(a == 0)cntz++;
        if(a > 0){
            s.push_back(a);
            cntpl++;
        }
        if(a < 0){
            f.push_back(abs(a));
            cntmi++;
        }
    }
    sort(all(A));
    sort(all(s), greater<>());
    sort(all(f), greater<>());
    mint ans = 1;
    if(N == K){
        rep(i,K)ans *= A[i];
        if(cntmi & 1)ans = -ans;
        cout << ans << endl;
        return 0;
    }
    // K < N;
    ll idx[] = {0,0};
    if(K&1){
        if(cntpl > 0)ans *= s[idx[0]++];
        else{
            rep(i,K)ans *= A[i];
            ans = -ans;
            cout << ans << endl;
            return 0;
        }
    }
    // 残りの偶数個を決めていく
    ll len = K / 2;
    while(len--){
        ll tmp[2];
        tmp[0] = s[idx[0]] * s[idx[0]+1];
        tmp[1] = f[idx[1]] * f[idx[1]+1];
        if(tmp[0] < tmp[1]){
            ans *= tmp[1];
            idx[1] += 2;
        }
        else{
            ans *= tmp[0];
            idx[0] += 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 13032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define fo(i,s,e) for (int i=(s); i < (e); i++)
/*卍卍卍 #define int long long 卍卍卍*/
//https://qiita.com/hamko/items/794a92c456164dcc04ad
//s<=x<tが単調非減少である
signed main () {
  int n;cin >> n;
  vector<int> v(n,0);rep(i,n) cin>>v[i];
  sort(v.begin(),v.end());
  int ans=0;
  rep(i,n-2) fo(j,i+1,n-1) ans+=lower_bound(v.begin(),v.end(),v[i]+v[j])-v.begin()-j-1;
  cout << ans << endl;
}

Measured memory_bytes: 256
//011.cpp
//Sat Aug  8 17:47:16 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

int main(){
	int n,m;
	cin >> n >> m;

	int s[m][n];
	rep(i,m)rep(j,n){
		s[i][j] = 0;
	}

	rep(i,m){
		int k;
		cin >> k;
		rep(j,k){
			int z;
			cin >> z;
			z--;
			s[i][z] = 1;
		}
	}

	vector<int> p(m);
	rep(i,m) cin >> p[i];

	int ans = 0;
	rep(i,1<<n){
		int flag = 1;
		rep(j,m){
			int count = 0;
			rep(k,n){
				if (i>>k&1 && s[j][k]==1){
					count++;
				}
			}
			if (count%2!=p[j]){
				flag = 0;
				break;
			}
		}
		if (flag){
			ans++;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    string S; long long K;
    cin >>S >>K;
    for (int i = 0; i < min((long long) S.size(), K); i++) {
        if (S[i] >= '2') {cout << S[i] << endl; return 0;}
    }
    cout << '1' << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	char a[100],b[100],c[100];
	scanf("%s %s %s",a,b,c);
	printf("%s\n",a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0]?"YES":"NO");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

int main() {
	makel(N);
	makel(M);
	printf("%lld\n", abs((N - 2)*(M - 2)));
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;

#ifdef _MSC_VER
using LONG = __int64;
using ULONG = unsigned __int64;
#else
using LONG = long long int;
using ULONG = unsigned long long int;
#endif

int main(void) {
	int N;
	cin >> N;
	vector<int> a(3 * N);
	REP(i, 3 * N) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	ULONG sum = 0;
	for (int i = 0; i < N; i++) {
		sum += a[2 * i + 1];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1408
// 2017/09/21 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int m, f, b;
	cin >> m >> f >> b;

	if(m>=b){
		cout << 0 << endl;
	}
	else if(m+f>=b){
		cout << b-m << endl;
	}
	else{
		cout << "NA" << endl;
	}

	return 0;
}

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

int BubSort1(char x[ ], int n)
{
  int i, j, temp;

  for (i = 0; i < n - 1; i++) {
    for (j = n - 1; j > i; j--) {
      if (x[j - 1] > x[j]) {
        temp = x[j];
        x[j] = x[j - 1];
        x[j - 1]= temp;
      }
    }
  }
}

int BubSort2(char x[ ], int n)
{
  int i, j, temp;

  for (i = 0; i < n - 1; i++) {
    for (j = n - 1; j > i; j--) {
      if (x[j - 1] < x[j]) {
        temp = x[j];
        x[j] = x[j - 1];
        x[j - 1]= temp;
      }
    }
  }
}

int main(){
  int i,j,n;
  char str1[9],str2[9];
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%s",str1);
    strcpy(str2,str1);
    BubSort1(str1,8);
    BubSort2(str2,8);
    printf("%d\n",atoi(str2)-atoi(str1));
  }
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
constexpr double EPS = 1e-14;

struct vec2 {
    double x, y;
    vec2 operator+(const vec2 rhs) {
        return {x + rhs.x, y + rhs.y};
    }
    vec2 operator-(const vec2 rhs) {
        return {x - rhs.x, y - rhs.y};
    }
    vec2 operator*(const double k) {
        return {x * k, y * k};
    }
    vec2 operator/(const double k) {
        return {x / k, y / k};
    }
};

void printvec2(vec2 p, int precision) {
    cout << setprecision(precision) << fixed << p.x << " " << p.y << endl;
}

double dot(vec2 a, vec2 b) {
    return a.x * b.x + a.y * b.y;
};

double norm2(vec2 a) {
    return dot(a, a);
}

struct line {
    vec2 p, l;
};

line make_line(vec2 a, vec2 b) {
    return {a, b - a};
}

double cross(vec2 a, vec2 b) {
    return a.x * b.y - a.y * b.x;
}

bool is_parallel(vec2 a, vec2 b) {
    return abs(cross(a, b)) < EPS;
}

bool is_parallel(line a, line b) {
    return is_parallel(a.l, b.l);
}

double operator/(vec2 a, vec2 b) {
    assert(is_parallel(a, b));
    return abs(b.x) < EPS ? a.y / b.y : a.x / b.x;
}

vec2 intersection(line l1, line l2) {
    assert(!is_parallel(l1, l2));
    double a = l1.p.x, b = l1.p.y, c = l1.l.x, d = l1.l.y;
    double e = l2.p.x, f = l2.p.y, g = l2.l.x, h = l2.l.y;
    double k = (h * (a - e) - g * (b - f)) / (g * d - c * h);
    return {
        a + k * c,
        b + k * d
    };
}

vec2 get_normal(vec2 p) {
    return {-p.y, p.x};
}

vec2 foot(vec2 p, line l) {
    line normal = {p, get_normal(l.l)};
    return intersection(normal, l);
}

vec2 reflect(vec2 p, line l) {
    vec2 f = foot(p, l);
    return {2 * f.x - p.x, 2 * f.y - p.y};
}

double dist(vec2 p, line l) {
    return sqrt(norm2(foot(p, l) - p));
}

int sgn(double a) {
    if (a < -EPS) return -1;
    if (a > EPS) return 1;
    return 0;
}

int main() {
    double x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;;
    vec2 p1 = {x1 - x0, y1 - y0};
    int q;
    cin >> q;
    while (q--) {
        double x2, y2;
        cin >> x2 >> y2;
        vec2 p2 = {x2 - x0, y2 - y0};
        switch (sgn(cross(p1, p2))) {
            case -1:
            cout << "CLOCKWISE" << endl;
            break;

            case 1:
            cout << "COUNTER_CLOCKWISE" << endl;
            break;

            case 0:
            double k = p2 / p1;
            if (k < -EPS) {
                cout << "ONLINE_BACK" << endl;
            } else if (k > 1 + EPS) {
                cout << "ONLINE_FRONT" << endl;
            } else {
                cout << "ON_SEGMENT" << endl;
            }
            break;
        }
    }   
}



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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e13;
int main() {
    ll n, i, j, k, d;
    cin >> n >> d;
    cout << (n + (2 * d)) / (2 * d + 1) << endl;
    return 0;
}

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

int j, y;

void t(int i, int k, string s1){
	if (i == j && k == y)
		cout << s1 << endl;
	else {
		if (i < j && (i < 4 || (i >= 4 && (k == y || k >= 4))))
			t(i + 1, k, s1 + "A");
		if (k < y && (k < 4 || (k >= 4 && (i == j || i >= 4))))
			t(i, k + 1, s1 + "B");
	}
}

int main()
{
	cin >> j >> y;

	string s;

	t(0, 0, s);

	return 0;
}



Measured memory_bytes: 3208
#include <stdio.h>
#include <math.h>

int main()
{
	double A[100];
	double d, p1, p2, p3, max;
	int n, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%lf", &A[i]);

	p1 = 0.0;
	p2 = 0.0;
	p3 = 0.0;
	max = 0.0;

	for (i = 0; i < n; i++)
	{
		scanf("%lf", &d);
		d -= A[i];
		if (d < 0) d *= -1;

		p1 += d;
		p2 += d * d;
		p3 += d * d * d;
		if (d > max) max = d;
	}

	p2 = sqrt(p2);
	p3 = pow(p3, 1.0 / 3.0);

	printf("%.5lf\n", p1);
	printf("%.5lf\n", p2);
	printf("%.5lf\n", p3);
	printf("%.5lf\n", max);	

	return 0;
}

Measured memory_bytes: 1964
#include<iostream>

using namespace std;

int solve(int k);

int main(){

int n; cin >> n;


char *str = new char[n];
cin >> str;

int count = 0;
int i=0;
int j=n-1;

while(1){
	while(str[i]!='W'){

		i++;
		if(i==n)break;
	}

	while(str[j]!='R'){
		j--;
		if(j<0)break;
	}
	
	if(i>=j)break;
	i++;
	j--;
	count++;
}



printf("%d\n",count);

delete str;
	return 0;
}



Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	    ll n;
	    cin>>n;
	    ll b[n];
	    for(ll i=1;i<n;i++)
	    	cin>>b[i];
	    ll a[n+1];
	    a[1]=b[1];
	    a[n]=b[n-1];
	    for(ll i=2;i<n;i++)
	    {
	    	a[i]=min(b[i],b[i-1]);
	    }
	    ll sum=0;
	    for(ll i=1;i<=n;i++)
	    	sum+=a[i];
	    cout<<sum;
}

Measured memory_bytes: 256
#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#define DLOG_V(var)\
  cout << "#" << __LINE__ << ":" << #var << " : " << var << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#define DLOG_V(var)
#endif
using namespace std;

constexpr auto no_value = numeric_limits<uint64_t>::max();

int solve(const string& str1, const string& str2) {
  int max_ = 0;
  vector<vector<int>> buf(str1.size(), vector<int>(str2.size(), 0));
  for (size_t j = 0; j < str2.size(); ++j) {
    for (size_t i = 0; i < str1.size(); ++i) {
      auto prev1 = j == 0 ? 0 : buf[i][j - 1];
      auto prev2 = i == 0 ? 0 : buf[i - 1][j];
      buf[i][j] = max(prev1, prev2);
      if (str1[i] == str2[j]) {
        auto p = i == 0 || j == 0 ? 0 : buf[i - 1][j - 1];
        buf[i][j] = max(buf[i][j], p + 1);
        max_ = max(max_, buf[i][j]);
      }
    }
  }
  return max_;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string str1;
    string str2;
    cin >> str1 >> str2;
    auto res = solve(str1, str2);
    cout << res << endl;
  }
}

Measured memory_bytes: 6828
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int n, k; cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int cnt=0;
    rep(i, n){
        if(h[i] >= k) cnt++;
    }
    cout << cnt;
}

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

const double PI=acos(-1.0);

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

    if(min(b, d) - max(a, c) >= 0) cout << min(b, d) - max(a, c) << endl;
    else cout << 0 << endl; 

    return 0;
}

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

int a,b;
char ans[100][100];

signed main(){
	cin>>a>>b;
	cout<<100<<" "<<100<<endl;
	a--;b--;
	for(int i=0;i<50;i++){
		for(int j=0;j<100;j++){
			if(a&&(j%2)&&(i%2)){
				ans[i][j]='.';
				a--;
			}
			else ans[i][j]='#';
			if(b&&(j%2)&&(i%2)){
				ans[99-i][j]='#';
				b--;
			}
			else ans[99-i][j]='.';
		}
	}
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			cout<<ans[i][j];
		}
		cout<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, a, b;
	cin >> n >> a >> b;
	vector<int> x(n);
	rep(i, n) cin >> x[i];
	ll ans = 0;
	rrep(i, n) {
		ll tmp = x[i] - x[i - 1];
		ans += min(b, a * tmp);
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int r;
    cin >> r;
    if(r < 1200){
        cout << "ABC";
    }else if(r < 2800){
        cout << "ARC";
    }else{
        cout << "AGC";
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int MAX = 1e5 + 10;
int p[MAX], q[MAX], r[MAX];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	for(int i = 0; i < a; i ++) cin >> p[i];
	for(int i = 0; i < b; i ++) cin >> q[i];
	for(int i = 0; i < c; i ++) cin >> r[i];
	sort(p, p + a); sort(q, q + b); sort(r, r + c);
	int i1 = a - x, i2 = b - y, i3;
	ll sum = 0;
	for(i3 = c - 1; i3 >= 0; i3 --) {
		if(r[i3] <= min(p[i1], q[i2])) break;
		if(i1 == a || i2 == b) break;
		if(r[i3] > max(p[i1], q[i2])) {
			if(p[i1] > q[i2]) i2 ++;
			else i1 ++;
			sum += r[i3];
		}
		else if(r[i3] > p[i1]) {
			i1 ++;
			sum += r[i3];
		}
		else {
			i2 ++;
			sum += r[i3];
		}
	}
	while(i3 >= 0 && i1 < a && r[i3] > p[i1]) {
		sum += r[i3];
		i3 --, i1 ++;
	}
	while(i3 >= 0 && i2 < b && r[i3] > q[i2]) {
		sum += r[i3];
		i3 --, i2 ++;
	}
	while(i1 < a) sum += p[i1 ++];
	while(i2 < b) sum += q[i2 ++];
	cout << sum;
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
   int X;
   cin >> X;
   int c, d=1;

   	 for(int b=2; b<X; b++){ 
   	    c = 1;
        int p = 0;
   	    while(c<=X)
   	    {
          if(c*b>X) break;
          c *= b;
          p++;
   	    }
        if(p>1) d = max(c,d);    
   	 }
   
     cout << d << endl;

	return 0;
}

Measured memory_bytes: 256