akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
b = [0]*(10**5+1)
for i in a:
    b[i] += 1
ans = 0
for i in range(10**5-1):
    ans = max(ans, b[i]+b[i+1]+b[i+2])
print(ans)

Measured memory_bytes: 14004
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long l = sc.nextLong();
		long r = sc.nextLong();
		long div = 2019;
		if(l / div == r / div) {
			long ans = Long.MAX_VALUE;
			for(long i = l % div; i < r % div; i++) {
				for(long j = i + 1; j < r % div + 1; j++) {
					ans = Math.min(ans, (i * j) % div);
				}
			}
			System.out.println(ans);
		} else {
			System.out.println(0);
		}

	}

}


Measured memory_bytes: 21844
l = input()
dp0 = 0
dp1 = 1
MOD = 10 ** 9 + 7
for c in l:
    if c == '0':
        dp0 = dp0 * 3 % MOD
    else:
        dp0 = (dp0 * 3 + dp1) % MOD
        dp1 = dp1 * 2 % MOD
    # print(c, dp0, dp1)
print((dp0 + dp1) % MOD)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define vii vector<int,int>

using namespace std;


int main(){
    int N;
    int c[501],s[501],f[501];
    
    cin >> N;
    rep(i,N-1) cin >> c[i] >> s[i] >> f[i];
    
    rep(i,N){
        int t=0;
        Rep(j,i,N-1){
            
            if(t<s[j]) t = s[j];
            else if(t%f[j] == 0);
            else t = t+f[j]-(t%f[j]);
            
            t += c[j];
        }
        
        cout << t << endl;
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

struct Team{
public:
  int solved;
  int elapsed_time;
  int penalty;
  int id;
  Team() : solved(0),elapsed_time(0),penalty(0),id(0){}
  bool operator<(const Team& t) const{
    if(__builtin_popcount(solved) == __builtin_popcount(t.solved)){
      if((elapsed_time + penalty) == (t.elapsed_time + t.penalty)){
	return id > t.id;
      }
      else{
	return ((elapsed_time + penalty) < (t.elapsed_time + t.penalty)); 
      }
    }
    else{
      return (__builtin_popcount(solved) > __builtin_popcount(t.solved));
    }
  }
  bool operator==(const Team& t) const{
    if(__builtin_popcount(solved) == __builtin_popcount(t.solved)
       && (elapsed_time + penalty) == (t.elapsed_time + t.penalty)){
      return true;
    }
    return false;
  }
};

int main(){
  int duration;
  int total_teams;
  int total_problems;
  int total_submission_records;
  while(~scanf("%d %d %d %d",
	       &duration,
	       &total_teams,
	       &total_problems,
	       &total_submission_records)){

    if(duration == 0
       && total_teams == 0
       && total_problems == 0
       && total_submission_records == 0) break;

    Team teams[51];
    int freq[51][11];
    
    memset(freq,0,sizeof(freq));
    for(int team_idx=0;team_idx < total_teams; team_idx++){
      teams[team_idx].id = team_idx+1;
    }
    for(int submit_idx=0;submit_idx< total_submission_records; submit_idx++){
      int elapsed_time;
      int team_number;
      int problem_number;
      int judgement;
      scanf("%d %d %d %d",
	    &elapsed_time,
	    &team_number,
	    &problem_number,
	    &judgement);
      if(judgement == 0){
	teams[team_number-1].elapsed_time
	  += elapsed_time;
	teams[team_number-1].penalty
	  += freq[team_number-1][problem_number-1] * 20;
	freq[team_number-1][problem_number-1] = 0;
	teams[team_number-1].solved |= (1<<(problem_number-1));
      }
      else{
	if(!(teams[team_number-1].solved & (1<<(problem_number-1)))){
	  freq[team_number-1][problem_number-1]++;
	}
      }
    }

    sort(teams,teams+total_teams);
    for(int team_idx=0;team_idx+1 < total_teams; team_idx++){
      if(teams[team_idx] == teams[team_idx+1]){
	printf("%d=",teams[team_idx].id);
      }
      else{
	printf("%d,",teams[team_idx].id);
      }
    }
    printf("%d\n",teams[total_teams-1].id);
  }
}

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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < n; i++)

int main(){
    int a;
    cin >> a;
    if(a == 7 || a == 5 || a == 3){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int W, H,x,y,r;

	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	W -= r, H -= r;
	if (r <= x && x <= W && r <= y && y <= H) printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 2104
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
#define PI 3.14159265359
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        int n;
        cin >> n;
        unordered_map<int, int> m;
        int sum = 0;
        int a[n];
        loop(0, n) {
            cin >> a[i];
            m[a[i]]++;
            sum += a[i];
        }
        int q;
        cin >> q;
        while (q--) {
            int x, y;
            cin >> x >> y;
            sum -= (m[x] * x);
            sum += (m[x] *  y);
            m[y] = m[x] + m[y];
            m[x] = 0;
            cout << sum << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 7808
s=['A','B','C','D','E','F']

x,y=map(str,input().split())

for x_i in enumerate(x) :
    for y_i in enumerate(y) :  
        if x==x_i[1] and y==y_i[1] :
            if x_i[1]>y_i[1]:
                print ('>')
            elif  x_i[1]==y_i[1]:
                print('=')
            else:
                print('<')


        

        

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
int n, s, a[123456];
signed main() {
	cin >> n >> s;
	for (int i = 0; i < n; i++)cin >> a[i];
	int f = 0, l = 0, ans = n + 1, sum = 0;
	while (f < n) {
		while (sum < s&&l < n) {
			sum += a[l++];
		}
		if (sum < s)break;
		ans = min(ans, l - f);
		sum -= a[f++];
	}
	if (ans > n)cout << "0\n";
	else cout << ans << endl;
}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

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

    ll n;
    cin >> n;
    ll ans = n / 11, sm = ans * 11;
    ans *= 2;
    if (sm < n) {
        sm += 6;
        ans++;
    }
    if (sm < n) {
        sm += 5;
        ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
let () =
  let rec times n m k = if m > n then (k, m) else times n (m*2) (k+1) in
  Scanf.scanf "%d %d %d\n%d\n" @@ fun a b c k ->
  let (x, b') = times a b 0 in
  let (y, c') = times b' c 0 in
  Printf.printf "%s\n" (if x + y <= k then "Yes" else "No") 

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define N 300
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
int G[N][N];
int SIRO[N],idx[N];
int n,m,l,s,T;
vector<int> g;
int dijkstra(){
  vector<vector<int> >D(1<<l,vector<int>(n,T+1));   
  priority_queue<PP,vector<PP>,greater<PP> >Q;
  Q.push(PP(0,P(0,s))),D[0][s] = 0;

  int res = 0;
  while(!Q.empty()){
    PP t = Q.top();Q.pop();
    int cost = t.first;
    int bit = t.second.first;
    int pos = t.second.second;
    if(D[bit][pos]<cost)continue;
    if(pos == s)res = max(res,__builtin_popcount(bit));
    
    for(int j=0;j<l+1;j++){
      int i = g[j];
      if(i!=s&&SIRO[i]==0)continue;
      int ncost= cost+G[pos][i];
      int nbit = bit;
      if(D[nbit][i]>ncost){
	Q.push(PP(ncost,P(nbit,i)));
	D[nbit][i] = ncost;
      }
      if(i==s||bit>>idx[i]&1)continue;
      nbit|=1<<idx[i],ncost+=+SIRO[i];
      if(D[nbit][i]>ncost){
      Q.push(PP(ncost,P(nbit,i)));
      D[nbit][i] = ncost;
      }
      
      
    }
  }
  return res;
}

int main(){
  while(1){
    cin>>n>>m>>l>>s>>T;
    if(!n&&!m&&!l&&!s&&!T)return 0;
    s--;

    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++) G[i][j] = T+1;
      G[i][i] = 0;
    }
    
    for(int i=0,a,b,c;i<m;i++){
      cin>>a>>b>>c;a--,b--;
      G[a][b] = G[b][a] = c;
    }
    
    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  G[i][j] = min(G[i][j],G[i][k]+G[k][j]);
    
    memset(SIRO,0,sizeof(SIRO));
    g.resize(l);
    g.push_back(s);
    for(int i=0,j,e;i<l;i++){
      cin>>j>>e,SIRO[j-1]=e,idx[j-1] = i,g[i] = j-1;
    }

    cout<< dijkstra()<<endl;
  }
  return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;

  if (A + B >= 10)
    cout << "error" << endl;
  else
    cout << A + B << endl;
  return 0;
}

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

using namespace std;



int main(int argc, char *argv[])
{
   
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    bool valid = false;
    
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (i * j == n) {
                valid = true;
                break;
            }
        }
    }
    
    if (valid) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  vector<int64_t>B(N);
  for(int i=0;i<N;i++)
    cin>>B.at(i);
  vector<int64_t>C(N);
  for(int i=0;i<N;i++)
    C.at(i)=B.at(i)-A.at(i);
  int64_t sum=0;
  for(int i=0;i<N;i++)
    sum+=C.at(i);
  int64_t need1=0;
  for(int i=0;i<N;i++){
  if(0<C.at(i)){
  need1+=(1+C.at(i))/2;
  }
  }if(need1<=sum)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
   return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a, b, n, temp, ans1, ans2;
	cin >> a >> b >> n;
	if (n >= b) n = b - 1;
	cout <<  (a * n) / b;

}



Measured memory_bytes: 3604
import sys

while True:
    n,m = [int(i) for i in input().split()]
    if n == 0 and m == 0:
        sys.exit()
    dp = []
    ans = 0
    for i in range(n):
        dp.append([int(j) for j in input().split()])
    dp.sort(key=lambda x:x[1],reverse=True)
    for i in range(n):
        if dp[i][0] <= m:
            m -= dp[i][0]
        elif m > 0:
            ans += dp[i][1] * (dp[i][0] - m)
            m = 0
        else:
            ans += dp[i][1] * dp[i][0]
    print(ans)


Measured memory_bytes: 7064
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=2e5+5;



void solve()
{
 int n;
 cin>>n;
 int ans=fp(10,n)-(2*fp(9,n))%mod;
 if(ans<0)
  ans+=mod;

  ans+=fp(8,n);
  ans%=mod;
  cout<<ans;

}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t=1;
 //cin>>t;
 //cout<<(t^1);
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
int main(void){
    char s[201];
    scanf("%s",s);
    int len=strlen(s);
    for(int i=len-2;i;i-=2){
        if(strncmp(s,s+i/2,i/2)==0){
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	public void run(){
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			calc(n);
		}
	}
	public void calc(int n){
		int[] p = new int[1000];
		for(int i = 0; i < n; i++){
			p[i] = sc.nextInt();
		}
		int diff = 1000000;
		
		for(int i = 0; i < n; i++){
			for(int j = i+1; j < n; j++){
				int d = Math.abs(p[i]-p[j]);
				if(d < diff) diff = d;
			}
		}
		
		System.out.println(diff);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
}

Measured memory_bytes: 47948
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
const int mod=1e9+7;
#define pb push_back
#define pii pair<ll,ll>
#define pi pair<int ,int> 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,a,n) for(int i=a;i>=n;i-- )


int main()

{  
    ll n,r;
    cin>>n>>r;ll ans=r;
    if(n>=10){ans=r;}
    else
    {
        ans+=(100*(10-n));
    }
    cout<<ans;
   
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(void){
    int n, d; cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> x[i][j];
        }
    }
    int ans=0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            int dis = 0;
            for (int k = 0; k < d; k++)
            {
                dis += abs(x[i][k] - x[j][k])*abs(x[i][k] - x[j][k]);
            }
            int num=0;
            while (num*num <= dis)
            {
                if(num*num == dis){
                    ans++;
                    break;
                }
                num++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p1 = sc.nextInt();
		int p2 = sc.nextInt();
		int p3 = sc.nextInt();
		int j1 = sc.nextInt();
		int j2 = sc.nextInt();
		int p = p1, j = j1, r;

		if(p<=p2){
			if(p3<p) p = p3;
		}else if(p>p2){
			if(p2<=p3) p = p2;
			else if(p3<p2)p = p3;
		}
		if(j2<j)j = j2;
		r = p+j-50;
		System.out.println(r);
	}

}

Measured memory_bytes: 25980
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    int a, b, c, d, e, f;
    int min, max;
    int an1, an2, an3, z;
    int flag = 0;
    char str[100000];
    char str2[100000];
    char str3[100000];
    char str4[100000];
    char str5[100000];
     
    scanf("%d", &a);
     
    for (b = 0; b < a; b++) {
        scanf("%s", str);
        scanf("%s", str2);
        flag = 0;
        c = 0;
        d = strlen(str);
        e = strlen(str2);
        memset(str4, '0', 100000);
        if (d > e) {
            min = e;
            max = d;
            strcpy(str4, str);
        }
        else {
            min = d;
            max = e;
            strcpy(str4, str2);
        }
        if (min >= 81 || max >= 81) {
            flag = 1;
        }       
        d--;
        e--;
        an2 = 0;
        an3 = 0;
        for (f = min - 1; f >= 0; f--) {
            an1 = (str[d] - '0') + (str2[e] - '0') + an2;
            if (an1 >= 10) {
                str3[c] = (an1 % 10) + '0';
                an2 = an1 / 10;
            }
            else {
                str3[c] = an1 + '0';
                an2 = 0;
            }
            d--;
            e--;
            c++;
            max--;
            an3++;
        }
        max -= 1;
        while (1) {
            if (max == -1 && an2 == 0) {
                break;
            }
            if (max > -1) {
                an1 = (str4[max] - '0') + an2;
                max--;
            }
            else {
                an1 = an2;
            }
            if (an1 >= 10) {
                str3[c] = (an1 % 10) + '0';
                an2 = an1 / 10;
            }
            else {
                str3[c] = an1 + '0';
                an2 = 0;
            }
            c++;
        }
        an3--;
        str3[c] = '\0';
        z = 0;
        if (strlen(str3) >= 81) {
            flag = 1;
        }
        if (flag == 1) {
            printf("overflow\n");
        }
         
        else {
            for (f = strlen(str3) - 1; f >= 0; f--) {
                printf("%c", str3[f]);
            }
            printf("\n");
        }
        str3[0] = '\0';
    }
     
    return (0);
}

Measured memory_bytes: 704
from sys import stdin
import math
def keta(n):
    if n < 10:
        return 1
    else:
        return 1 + keta(int(n/10))
def main():
    n = int(input())

    for i in range(1, int(math.sqrt(n))+1)[::-1]:
        if (n // i) * i == n:
            print(keta(n/i))
            return


if __name__ == '__main__':
    main()

Measured memory_bytes: 38608
#include<bits/stdc++.h>
using namespace std;
int n;
double p[3000];
double dp[3000][3000];
int main(){
	dp[0][0]=1;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>p[i];
	for(int i=1;i<=n;i++)
		for(int j=0;j<i;j++){
			dp[i][j]+=dp[i-1][j]*(1-p[i]);
			dp[i][j+1]+=dp[i-1][j]*p[i];
		}
	double res=0.0;
	for(int i=n/2+1;i<=n;i++)
		res+=dp[n][i];
	printf("%.15lf",res);
	return 0;
}

Measured memory_bytes: 68864
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>  
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
const double PI=acos(-1.0);

typedef long long Int;
typedef long long LL;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <double, double> PDD;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 2100000;
const int MAX1 = 2007;
const int MAX2 = 24000000;
const int LEN = 21;
const int BASE = 1000000000;

const int MOD = 1000000007;

int a, b, c;
Int F[MAX];
Int FF[MAX];

Int Pow(Int a, Int b)
{
  Int res = 1;
  while (b)
    if (b % 2 == 0)
    {
      b /= 2;
      a = a * a % MOD;
    }
    else
    {
      -- b;
      res = res * a % MOD;
    }
  return res;
}

Int bin(int n, int k)
{
  if (k < 0 || k > n) return 0;
  return F[n] * FF[k] % MOD * FF[n-k] % MOD;
}

int main()
{
  F[0] = FF[0] = 1;
  FOR (i,1,MAX)
  {
    F[i] = F[i-1] * i % MOD;
    FF[i] = Pow(F[i], MOD-2);
  }

  cin >> a >> b >> c;

  -- a;

  Int res = Pow(3, b+c);
  Int last = 1;
    
  FOR (i,1,b+c+1)
  {
    Int d = last * i * 2;

    d -= bin(i, b+1) * F[i-1] % MOD * (b+1) % MOD;
    d = (d + MOD) % MOD;

    d -= bin(i, c+1) * F[i-1] % MOD * (c+1) % MOD;
    d = (d + MOD) % MOD;

    Int x = d * FF[i] % MOD;
    x = x * bin(i+a, a) % MOD;
    x = x * Pow(3, b+c-i);

    res = (res + x) % MOD;

    last = d;
  }


  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 33152
#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>;

int main(){
  int A, B, C, D;
  string ans;
 cin >> A >> B >> C >> D;
 while(1){
   C -= B;
   if(C <= 0){
     ans = "Yes";
     break;
   }
   A -= D;
   if(A <= 0){
     ans = "No"; 
     break;
   }
   
 }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n; cin >>n;
    cout << n/3 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
int main() {
    int a[3],n;
	cin>>n;
	for(int i=1;i<=n;i++){
	for(int j=0;j<3;j++) cin>>a[j];
    sort(a, a + 3);             
	a[0]*=a[0];
	a[1]*=a[1];
	a[2]*=a[2];
	if(a[0]+a[1]!=a[2]){
	cout<<"NO\n";
	}else{cout<<"YES\n";}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

struct BaseClass
{
	virtual string operator()( string msg ) = 0;
};

struct Func_j : public BaseClass
{
	string operator()( string msg )
	{
		rotate( DRANGE( msg, msg.size() - 1 ) );
		return msg;
	}
};

struct Func_c : public BaseClass
{
	string operator()( string msg )
	{
		rotate( DRANGE( msg, 1 ) );
		return msg;
	}
};

struct Func_e : public BaseClass
{
	string operator()( string msg )
	{
		const int L = msg.size();
		const int mid = L / 2;
		string left = msg.substr( 0, mid );
		string right = msg.substr( L % 2 ? mid + 1 : mid );
		return right + ( L % 2 ? string( 1, msg[ mid ] ) : "" ) + left;
	}
};

struct Func_a : public BaseClass
{
	string operator()( string msg )
	{
		reverse( ALL( msg ) );
		return msg;
	}
};

struct Func_p : public BaseClass
{
	string operator()( string msg )
	{
		REP( i, 0, msg.size() )
		{
			if ( isdigit( msg[i] ) )
			{
				msg[i] = ( ( msg[i] - '0' ) + 10 - 1 ) % 10 + '0';
			}
		}
		return msg;
	}
};

struct Func_m : public BaseClass
{
	string operator()( string msg )
	{
		REP( i, 0, msg.size() )
		{
			if ( isdigit( msg[i] ) )
			{
				msg[i] = ( ( msg[i] - '0' ) + 1 ) % 10 + '0';
			}
		}
		return msg;
	}
};

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

	map< char, BaseClass* > funcs;
	funcs[ 'J' ] = new Func_j();
	funcs[ 'C' ] = new Func_c();
	funcs[ 'E' ] = new Func_e();
	funcs[ 'A' ] = new Func_a();
	funcs[ 'P' ] = new Func_p();
	funcs[ 'M' ] = new Func_m();

	int n;
	cin >> n;

	REP( case_num, 0, n )
	{
		string order, message;
		cin >> order >> message;

		for ( int i = order.size() - 1; 0 <= i; i-- )
		{
			message = ( *funcs[ order[i] ] )( message );
		}

		cout << message << endl;
	}

	FOR( f, funcs )
	{
		delete f.snd;
	}

	return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d;
  string s;
  long long ans = 0;
  
  cin >> a >> b;

  ans = a*800 - (a/15)*200;
  
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>

using namespace std;

#define fo(i,n) for(int i=0; i<(int)n; i++)
#define rep(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define pii pair<int,int>

int n;
string a[11];
string b[11];
string source;
string target;
int ans;

void dfs(string s, int i, int cur) {
	if (cur>=ans) return;
	if (s==target) ans = cur;
	if (s.length()>target.length()) return;
	
	bool done = 0;
	
	for (int j=0; j<s.length(); j++) {
		if (j+a[i].length()<=s.length()) {
			bool ok = 1;
			for (int k=0; k<a[i].length(); k++) {
				if (s[j+k]!=a[i][k]) {
					ok = 0;
					break;
				}
			}
			if (ok) {
				s = s.substr(0,j) + b[i] + s.substr(j+a[i].length(),s.length()-j-a[i].length());
				j += b[i].length()-1;
				done = 1;
			}
		}
	}
	if (done) {
		for (int j=0; j<n; j++) dfs(s,j,cur+1);
	}
}

int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

	while (scanf("%d",&n) && n!=0) {
		for (int i=0; i<n; i++) {
			cin>>a[i]>>b[i];
		}
		cin>>source>>target;
		ans = 1000000;
		for (int i=0; i<n; i++) dfs(source,i,0);
		if (ans==1000000) printf("-1\n");
		else printf("%d\n",ans);
	}

    return 0;

}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
typedef vector<i64> vi;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  string s,t;
  cin >> s >> t;
  i64 a,b;
  cin >> a >> b;
  string u;
  cin >> u;

  if(s==u) a--;
  else b--;
  cout << a << " " << b << endl;

}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<int> x(n), y(n), r(n), c(n);
    for (int i = 0; i < n; i++){
      cin >> x[i] >> y[i] >> r[i] >> c[i];
      c[i]--;
    }
    vector<vector<int>> id(4);
    for (int i = 0; i < n; i++){
      id[c[i]].push_back(i);
    }
    vector<vector<bool>> intersect(n, vector<bool>(n, false));
    for (int i = 0; i < n; i++){
      for (int j = 0; j < n; j++){
        if (i < j){
          if ((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]) < (r[i] + r[j]) * (r[i] + r[j])){
            intersect[i][j] = true;
          }
        }
      }
    }
    int ans = 0;
    queue<int> Q;
    Q.push((1 << n) - 1);
    set<int> used;
    used.insert((1 << n) - 1);
    while (!Q.empty()){
      int S = Q.front();
      Q.pop();
      ans = n - __builtin_popcount(S);
      for (int i = 0; i < 4; i++){
        int sz = id[i].size();
        for (int j = 0; j < sz; j++){
          for (int k = j + 1; k < sz; k++){
            if ((S >> id[i][j] & 1) && (S >> id[i][k] & 1)){
              bool ok = true;
              for (int l = 0; l < id[i][j]; l++){
                if ((S >> l & 1) && intersect[l][id[i][j]]){
                  ok = false;
                }
              }
              for (int l = 0; l < id[i][k]; l++){
                if ((S >> l & 1) && intersect[l][id[i][k]]){
                  ok = false;
                }
              }
              if (ok){
                int next = S - (1 << id[i][j]) - (1 << id[i][k]);
                if (!used.count(next)){
                  used.insert(next);
                  Q.push(next);
                }
              }
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 51952
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	int kingaku;
	int[] goukei = new int[4];
	int n;
	
	public void syurui(){
		for (n = 0; n <= 3;n++){
			int syurui = sc.nextInt();
			int maisuu = sc.nextInt();
			switch(syurui){
			case 1: kingaku = 6000;break;
			case 2: kingaku = 4000;break;
			case 3: kingaku = 3000;break;
			case 4: kingaku = 2000;break;
			}
		goukei[n] = kingaku * maisuu;}
	}

	public void hyouji(){
		for(n = 0; n <= 3; n++){
			System.out.println(goukei[n]);
		}
	}
	public static void main(String[] args) {
		Main m = new Main();
		m.syurui();
		m.hyouji();
		}
	}

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

signed main(){

  int n,q;
  cin>>n>>q;

  vector<vector<int>> a(n);

  auto dump = [](auto const& v){
    int n = v.size();
    for(int i=0;i<n;++i){
      cout<<v[i]<<(i+1<n?" ":"");
    }
    cout<<endl;
  };

  while(q--){
    int com;
    cin>>com;
    if(com==0){
      int t,x;
      cin>>t>>x;
      a[t].push_back(x);
    }
    else if(com==1){
      int t;
      cin>>t;
      dump(a[t]);
    }
    else{
      int t;
      cin>>t;
      a[t].clear();
    }
  }

}


Measured memory_bytes: 5820
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector< pair< pair<string,int> ,int> > p(N);
  for(int i=0; i<N; i++){
    string s;
    int t;
    cin >> s >> t;
    p[i]=make_pair(make_pair(s,-t),i);
  }
  sort(p.begin(),p.end());
  for(int i=0; i<N; i++)cout<<p[i].second+1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>Pa;
const long long INF = 1ll<<62;
const int maxn = 5e5+10;
ll n,m,cnt;
map<ll,ll>Ma[maxn];//标记
vector<Pa>V[maxn];//存放pair关系
int vis[maxn];
ll dist[maxn];
struct node{
	ll dist;
	int id;
	bool operator < (const node& b) const
	{
		return dist > b.dist;
	}
};
int getid(int u,int v)//返回编号 
{
	if(Ma[u][v]==0)
		Ma[u][v]=++cnt;
	return Ma[u][v];
} 
void spfa()
{
	for(int i=0;i<=cnt;i++)
	{
		vis[i]=0;
		dist[i]=INF;
	}
	node temp;
	temp.dist=0;
	temp.id=1;
	priority_queue<node> q;
	q.push(temp);
	dist[1]=0;
	while(!q.empty())
	{
		node u=q.top();
		q.pop();
		if(vis[u.id]==1)
			continue;
		vis[u.id]=1;
		for(int i=0;i<V[u.id].size();i++)
		{
			int v=V[u.id][i].first;
			int Valu=V[u.id][i].second;
			if(dist[v] > dist[u.id]+Valu)
			{
				dist[v]=dist[u.id]+Valu;
				node Temp;
				Temp.dist=dist[v];
				Temp.id=v;
				q.push(Temp);
			}	
		}		
	}
	if(dist[n]==INF)
		cout<<"-1"<<endl;
	else
		cout<<dist[n]/2<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	while(cin>>n>>m)
	{ 
		for(int i=0;i<=n;i++)
			Ma[i].clear(); 
		for(int i=0;i<=n;i++)
			V[i].clear();
		cnt=n;//从n+1开始记录编号
		for(int i=0;i<m;i++)
		{
			int u,v,id;
			cin>>u>>v>>id;
			int uid=getid(u,id);
			int vid=getid(v,id);
			V[u].push_back(Pa(uid,1));
			V[uid].push_back(Pa(u,1));
			
			V[v].push_back(Pa(vid,1));
			V[vid].push_back(Pa(v,1));
			
			V[vid].push_back(Pa(uid,0));
			V[uid].push_back(Pa(vid,0));
		} 
		spfa();
	} 
	return 0;
}
 

Measured memory_bytes: 97520
let partition (a : int array) p r =
  let x = a.(r) in
  let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t
  in
  let rec doit i j =
    if j >= r then i
    else begin
      if a.(j) <= x then (swap (i + 1) j; doit (i + 1) (j + 1))
      else doit i (j + 1)
    end
  in
  let i = doit (p - 1) p in
  swap (i + 1) r;
  i + 1

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let k = partition a 0 (n - 1) in
  Array.iteri (fun i e ->
    if i = 0 then print_int e
    else begin
      print_string " ";
      if i = k then (print_string "["; print_int e; print_string "]")
      else print_int e
    end) a;
  print_newline ()

Measured memory_bytes: 5296
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#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 MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    vi num(3);
    rep(i,3)cin >> num[i];
    SORT(num);
    if(num[0]==num[1])
    {
        cout << num[2] << endl;
    }
    else
    {
        cout << num[0] << endl;
    }
}


Measured memory_bytes: 256
def main():
    from collections import Counter
    import sys
    input = sys.stdin.buffer.readline

    _ = int(input())
    A = [int(i) for i in input().split()]

    ans = 0
    c = Counter(A)
    B = sorted(c.keys(), reverse=True)

    for b in B:
        if c[b] == 0:
            continue
        a = (2 ** b.bit_length()) - b
        if a == b:
            cur = c[b]//2
        else:
            if a in c:
                cur = min(c[a], c[b])
            else:
                cur = 0
        ans += cur
        # c[b] -= cur
        c[a] -= cur

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a,b) push_back(make_pair(a,b))
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int N;
vector<P2> V[MC];
int s[MC];
int G;
LL ans;

void dfs(int p , int q){
	bool b = 1;
	s[q] = 1;
	for(auto u : V[q]){
		if(u.second == p) continue;
		dfs(q,u.second);
		s[q] += s[u.second];
		ans += (LL)2 * u.first * min(s[u.second],N-s[u.second]);
		if(s[u.second] * 2 >= N) b = 0;
		if(s[u.second] * 2 == N) G = -u.first;
	}
	if(b && s[q] * 2 > N) G = q;
}

int main(){
	scanf("%d" , &N);
	repp(i,1,N){
		int A,B,C;
		scanf("%d%d%d" , &A , &B , &C);
		V[A].PB(C,B);
		V[B].PB(C,A);
	}
	dfs(-1,1);
	if(G > 0){
		int z = 123456789;
		for(auto u : V[G]){
			z = min(z,u.first);
		}
		ans -= z;
	} else ans += G;
	printf("%lld\n" , ans);
	return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

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

    int lb = 1;
    int ub = N;
    REP(i, M) {
        int L, R;
        cin >> L >> R;
        lb = max(lb, L);
        ub = min(ub, R);
    }
    
    cout << max(ub-lb+1,0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=10;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int H, W, K;
char C[MAXN][MAXN], temp[MAXN][MAXN];
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> H >> W >> K;
	FOR(i,0,H-1) FOR(j,0,W-1) cin >> C[i][j];
	int ans = 0;
	FOR(bm1,0,(1<<H) - 1) FOR(bm2,0,(1<<W) - 1){
		FOR(i,0,H-1) FOR(j,0,W-1) temp[i][j] = C[i][j];
		FOR(i,0,H-1) {
			if (bm1 & (1<<i)){
				FOR(j,0,W-1) temp[i][j] = 'r';
			}
		}
		FOR(j,0,W-1) {
			if (bm2 & (1<<j)){
				FOR(i,0,H-1) temp[i][j] = 'r';
			}
		}
		int cnt = 0;
		FOR(i,0,H-1) FOR(j,0,W-1) cnt += (temp[i][j] == '#');
		if (cnt == K) {
			ans++;
		}
		
	}
	cout<<ans;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll N,Q;
    cin >> N >> Q;
    vector<vector<ll>> v(N);
    ll a,b;
    rep(i,N-1){
        cin >> a >> b;
        v[--a].push_back(--b);
        v[b].push_back(a);
    }
    vector<ll> pv(N,0),memo(N,-1);
    ll p,x;
    rep(i,Q){
        cin >> p >> x;
        pv[--p] += x;
    }
    queue<pair<ll,ll>> que;
    que.push(pair<ll,ll>(0,pv[0]));
    while(!que.empty()){
        ll u = que.front().first;
        ll s = que.front().second;
        que.pop();
        if(memo[u] != -1) continue;
        for(auto& t:v[u]){
            que.push(make_pair(t, s+pv[t]));
        }
        memo[u] = s;
    }
    rep(i,N){
        cout << memo[i] << " ";
    }
    cout << endl;
}


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

int ch_ans(string s){
  if(s == "Vacant")return 0;
  if(s == "Male")return 1;
  if(s == "Female")return -1;
  return 0;
}
int main() {
  long long n;
  cin >> n;
  int cheir[n];
  cout << 0 << endl;
  int i,ans,r,l;
  string s;
  cin >> s;
  ans=ch_ans(s);
  cheir[0]=ans;
  if(ans == 0)return 0;
  /*cout << (n-1)/2 << endl;
  cin >> s;
  ans = ch_ans(s);
  cheir[(n-1)/2]=ans;
  if(ans == 0)return 0;
  if((cheir[0]==ans && ((n-1)/2+1)%2==0) ||(cheir[0]!=ans && ((((n-1)/2+1)%2!=0) || (n-1)/2-1==0))){
    l = 0;
    r = (n-1)/2;
  }else{
    l = (n-1)/2;
    r = n-1;
  }*/
  r = n-1;
  l = 0;
  for(i=1;i<20;i++){
    int m = l+(r-l)/2;
  //  cout << l << " " << r << endl;
    if(l+1==r){
      cout << r << endl;
      cin >> s;
      if(ch_ans(s)==0)return 0;
    }
    cout << m << endl;
    cin >> s;
    ans = ch_ans(s);
    if(ans == 0)return 0;
    cheir[m] = ans;
  //  cout << cheir[m] << ans << endl;
    if(((cheir[l] == ans) && ((m-l+1)%2!=0)) || (cheir[l]!=ans && (((m-l+1)%2==0)|| m-l-1==0)))l=m;
    else r = m;
  }
  return 0;
}


Measured memory_bytes: 976
#include <stdio.h>
#include <iostream>
#define PI 3.141592653589793238

using namespace std;

int main()
{
    double r, area, circum;
    cin>>r;

    area = PI*(r*r);
    circum = 2*PI*r;

    printf("%.6lf %.6lf\n",area,circum);



    return 0;
}



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


using namespace std;





int main()
{
    long long a,b,mi=0,mm=0,c=0;
    cin>>a>>b;
    c=a;
    mi=min(b,a-b);
    mm=max(b,a-b);
    while(true)
    {
        if(mm%mi==0)
        {
            c+=(mm/mi)*2*mi;
            c-=mi;
            break;
        }
        else
        {
            c+=(mm/mi)*mi*2;

            mm=mm%mi;
            swap(mm,mi);


        }
    }

    cout<<c<<"\n";







    return 0;
}


Measured memory_bytes: 256
import math
a, b, C=map(int, input().split())
print("{0:.5f}".format((1/2)*a*b*math.sin(C*math.pi/180.0)))
print("{0:.5f}".format(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(C*math.pi/180))))
print("{0:.5f}".format(b*math.sin(C*math.pi/180.0)))

Measured memory_bytes: 7880
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using str = string;
using P = pair<intl,intl>;
#define sqrt sqrtl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b,c;
    cin >> a >> b >> c;
    vector<intl> v;
    repi(i, a, a + c){
        if(i > b)break;
        if(find(all(v),i) == v.end())v.pb(i);
    }
    repi(i, b - c + 1, b + 1){
        if(i < a)break;
        if(find(all(v),i) == v.end())v.pb(i);
    }
    for(auto i: v){
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);

int e,f;
e=a*b;
f=c*d;

if(e==f) printf("%d",e);
else
if(e<f)  printf("%d",f);
else
if(e>f)  printf("%d",e);


return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define bye return 0
#define Yes cout << "Yes" << "\n"
#define No  cout << "No" << "\n"
#define YES cout << "YES" << "\n"
#define NO cout << "NO" << "\n"
#define endl cout << "\n";
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> v;
    vector<int> v1;
    set<int> sets;
    vector<string> str;
    string s;
    int a, b, c, t, cnt=0, flag=0;
    cin >> s;
   
   if(s[0] == s[2]){
   	Yes;
   }else{
   	No;
   }
   
   bye;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LP;

LP eq(ld a1,ld b1,ld c1,ld a2,ld b2,ld c2){
  ld x,y;
  if(a2*b1==a1*b2){
    return LP(INF,INF);
  }
  x=-(b1*c2-b2*c1)/(a2*b1-a1*b2);
  y=(a1*c2-a2*c1)/(a2*b1-a1*b2);
  //cout << a1*x+b1*y+c1 << " " << a2*x+b2*y+c2 << endl;
  return LP(x,y);
}

int n;
ld x[53],y[53];

void solve(){
  cin >> n;
  rep(i,n){
    cin >> x[i] >> y[i];
  }
  ld ans=INF;
  rep(i,n){
    rep(j,n){
      rep(k,n){
        LP oc=eq(x[i]-x[j],y[i]-y[j],-(x[i]*x[i]+y[i]*y[i]-x[j]*x[j]-y[j]*y[j])/2,x[i]-x[k],y[i]-y[k],-(x[i]*x[i]+y[i]*y[i]-x[k]*x[k]-y[k]*y[k])/2);
        ld r=sqrt((x[i]-oc.first)*(x[i]-oc.first)+(y[i]-oc.second)*(y[i]-oc.second));
        bool flag=true;
        rep(p,n){
          if(sqrt((x[p]-oc.first)*(x[p]-oc.first)+(y[p]-oc.second)*(y[p]-oc.second))>r){
            flag=false;
          }
        }
        if(flag) ans=min(ans,r);
      }
    }
  }
  rep(i,n){
    rep(j,n){
      LP oc=LP((x[i]+x[j])/2,(y[i]+y[j])/2);
      ld r=sqrt((x[i]-x[j])*(x[i]-x[j])/4+(y[i]-y[j])*(y[i]-y[j])/4);
      bool flag=true;
        rep(p,n){
          if(sqrt((x[p]-oc.first)*(x[p]-oc.first)+(y[p]-oc.second)*(y[p]-oc.second))>r){
            flag=false;
          }
        }
      if(flag) ans=min(ans,r);
    }
  }
  cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 256
n,k = map(int,input().split())
s = list(input())
x = 0
y = 0
if s[0] == "L":
    y += 1
if s[n-1] == "R":
    y += 1 
for i in range(n-1):
    if s[i] == "R" and s[i+1] =="L":
        x += 1
if x >= k:
    print(n-(x-k)*2-y)
else:
    print(n-1)

Measured memory_bytes: 4024