akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
	int N; cin >> N;
	ll* a = new ll[N];
	ll s = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		s += a[i];
	}
	for (int i = 1; i < N; i++) {
		a[i] += a[i - 1];
	}
	ll m = s;
	for (int i = 0; i < N - 1; i++) {
		m = min(m, abs(s - a[i] * 2));
	}

	cout << m << endl;
	return 0;
}

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

int h,w;

int max_route(vector<vector<int>> &maze, int i, int j){
    int now = maze[i][j];
    int ans = now;
    if(i+1 < h && maze[i+1][j] > now+1){
        maze[i+1][j] = now+1;
        ans = max(ans, max_route(maze,i+1,j));
    }
    if(j+1 < w && maze[i][j+1] > now+1){
        maze[i][j+1] = now+1;
        ans = max(ans, max_route(maze,i,j+1));
    }
    if(i-1 >= 0 && maze[i-1][j] > now+1){
        maze[i-1][j] = now+1;
        ans = max(ans, max_route(maze,i-1,j));
    }
    if(j-1 >= 0 && maze[i][j-1] > now+1){
        maze[i][j-1] = now+1;
        ans = max(ans, max_route(maze,i,j-1));
    }
    return ans;
}

int main(){
    cin >> h >> w;
    vector<vector<int>> maze(h, vector<int>(w));
    vector<vector<int>> tmp(h, vector<int>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char c;
            cin >> c;
            if(c == '#'){
                maze[i][j] = -1;
            }else{
                maze[i][j] = 10000;
            }
        }
    }
    int ans = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(maze[i][j] == -1){
                continue;
            }
            tmp = maze;
            tmp[i][j] = 0;
            //ans = max(ans,max_route(tmp,i,j));
            max_route(tmp,i,j);
            int anst = 0;
            for(int a=0; a<h; a++){
                for(int b=0; b<w; b++){
                    //cout << tmp[a][b] << " ";
                    anst = max(anst,tmp[a][b]);
                }
                //cout << endl;
                ans = max(ans,anst);
            }
            //cout << endl;
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
s=input()
x=len(s)
ans=[0]*x
chk=[0,0]
f=0
for i in range(x):
    if s[i]=="R":
        chk[i%2]+=1
    if s[i]=="L":
        if i%2:
            ans[i-1]+=chk[0]
            ans[i]+=chk[1]
        else:
            ans[i]+=chk[0]
            ans[i-1]+=chk[1]

        chk=[0,0]
chk=[0,0]
for i in range(x-1,-1,-1):
    if s[i]=="L":
        chk[i%2]+=1
    if s[i]=="R":
        if i%2:
            ans[i+1]+=chk[0]
            ans[i]+=chk[1]
        else:
            ans[i]+=chk[0]
            ans[i+1]+=chk[1]
        chk=[0,0]

print(*ans)

Measured memory_bytes: 48444
package main

import (
	"fmt"
)

func main() {
	var W, H, x, y int
	fmt.Scanf("%d %d %d %d", &W, &H, &x, &y)
	var d int = 0
	S := float64(W*H) / 2.0
	if 2*x == W && 2*y == H {
		d = 1
	}
	fmt.Printf("%f %d\n", S, d)
}


Measured memory_bytes: 512
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];
    auto A = readln.split.map!(to!int).array;

    auto grundy = new int[](K+1);
    grundy[0] = 0;

    foreach (i; 1..K+1) {
        int[] mex;
        foreach (a; A) {
            if (i - a >= 0) {
                mex ~= grundy[i-a];
            }
        }
        mex = mex.sort().uniq().array;
        grundy[i] = mex.length.to!int;
        foreach (j; 0..mex.length.to!int) {
            if (j != mex[j]) {
                grundy[i] = j;
                break;
            }
        }
    }

    writeln(grundy[K] ? "First" : "Second");
}


Measured memory_bytes: 3580
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int i=0;i<N;i++) a[i]=sc.nextInt();
        Arrays.sort(a);
        int ans = a[N-1]-a[0];
        System.out.println(ans);
    }
}
 

Measured memory_bytes: 21332
#include<stdio.h>
int main(void){
  int n,a[33]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
  scanf("%d",&n);
  printf("%d",a[n-1]);
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = intRead();
        int[] a1 = SpRead(' ').Select(_ => int.Parse(_)).ToArray();
        int[] a2 = SpRead(' ').Select(_ => int.Parse(_)).ToArray();
        int Max = 0;
        for (int i = 0; i < N; i++) { Max = Math.Max(Max, (a1.Take(i + 1).Sum() + a2.Skip(i).Take(N - i).Sum())); }
        Console.WriteLine(Max);
    }

}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
 
int main(){
  int H1,H2,M1,M2,K;

  
  
  while(scanf("%d %d %d %d %d",&H1,&M1,&H2,&M2,&K)==0);
  
    int hm1=H1*60+M1;
  int hm2=H2*60+M2;
  int T=hm2-hm1;
  
  int A=T-K;
  
  printf("%d",A);
 
 return 0;
  
}

Measured memory_bytes: 1708
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<iostream>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
int main(){
	string s;
	cin >> s;
	char a = 'R';
	int ans = 0,maxans = 0;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == a)ans ++;
		else {
			maxans = max(ans , maxans);
			ans = 0;
		}
	}
	if (s == "SRR") {
		cout << 2 << endl; 
		return 0;
	}
	else {
		if (s[s.size()-1] == 'R' && maxans < 1 && ans == 1) {
			cout << 1 << endl;
		}  else if(ans == 3) {
			cout << 3 << endl;
		} else {
			cout << maxans << endl;
		}
	}
}


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

int main(){
  int a,b,c ;
  cin >> a >> b >> c ;
  for (int i = min(a,b);i>0; i--){
    if (a % i == 0 && b % i == 0) c--;
    if (c == 0){
    	cout << i << endl;
      	break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
#define rep(i,a,b) for(int i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
int main(){
  int n;  cin >> n;
  vector<ll> a(n), b(n);
  vector<pli> c(n);
  rep(i,0,n){
    cin >> a[i] >> b[i];
    c[i] = mp(a[i]+b[i], i);
  }
  sort(all(c), greater<pli>());
  ll t=0, ao=0;
  rep(i,0,n){
    int in = c[i].se;
    if(!(i%2)){
      t += a[in];
    }else{
      ao += b[in];
    }
  }
  cout << t-ao << endl;
  return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define int ull

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

  int N;
  cin>>N;
  vector<int>T(N),A(N);
  for(int i=0;i<N;i++)cin>>T[i]>>A[i];
  int t=T[0],a=A[0];
  for(int i=1;i<N;i++){
    int l=0;
    int r=ULONG_MAX/max(A[i],T[i]);
    int m;
    while(r-l>1){
      m=(r+l)/2;
      if(t<=T[i]*m&&a<=A[i]*m)r=m;
      else l=m;
    }
    t=T[i]*r;
    a=A[i]*r;
  }
  cout<<t+a<<endl;
  return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  vector<int> c(n);
  rep(i,n){
    if(a[i]==1){
      c[a[i]-1]=1;
      continue;
    }
    c[a[i]-1]=c[a[i]-2]+1;
  }
  int ans=0;
  rep(i,n) ans=max(ans,c[i]);
  cout<<n-ans<<endl;
}

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

ll gcd(ll a, ll b){//最大公約数
  if (b == 0){
    return a;
  }
  return gcd(b, a%b);
}

ll lcm(ll a, ll b){//最小公倍数
  ll c = gcd(a, b);
  return a / c * b;
}

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  a--;
  ll e = lcm(c, d);
  ll ans = ((b-(b/c)) + (b-(b/d)) - (b-(b/e))) - ((a-(a/c)) + (a-(a/d)) - (a-(a/e)));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3520
import sys
sys.setrecursionlimit(5000000)

s = input()
if len(s) == 1:
    print("1")
    exit()
cont_list = []
ini_di = s[0]
count = 1
for i in range(1, len(s)):
    if s[i] == s[i-1]:
        count += 1
        if i == len(s) - 1:
            cont_list.append(count)
    else:
        cont_list.append(count)
        count = 1
        if i == len(s) - 1:
            cont_list.append(count)


def counting(i):
    a = max(cont_list[i], cont_list[i + 1])
    b = min(cont_list[i], cont_list[i + 1])
    return (1 + a) * a / 2 + b * (b - 1) / 2


if ini_di == "<":
    count2 = 0
    if len(cont_list) % 2 == 0:
        for i in range(0, len(cont_list), 2):
            count2 += int(counting(i))
    else:
        for i in range(0, len(cont_list)-1, 2):
            count2 += int(counting(i))
        las = cont_list[len(cont_list)-1]
        count2 += int((1+las)*las/2)
    print(count2)
else:
    count2 = 0
    if len(cont_list) % 2 == 1:
        ini = cont_list[0]
        count2 += int((1+ini)*ini/2)
        for i in range(1, len(cont_list), 2):
            count2 += int(counting(i))
    else:
        ini = cont_list[0]
        count2 += int((1 + ini) * ini / 2)
        las = cont_list[len(cont_list) - 1]
        count2 += int((1 + las) * las / 2)
        for i in range(1, len(cont_list)-1, 2):
            count2 += int(counting(i))
    print(count2)


Measured memory_bytes: 6428
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <cmath>
#include <limits.h>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b){return b? gcd(b, a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int vtable1[100001] = {};
  int vtable2[100001] = {};
  int tmp;
  for(int i = 0; i < n; i++){
    cin >> tmp;
    if(i %2 ==0){
      vtable1[tmp] += 1;
    }else{
      vtable2[tmp] += 1;
    }
  }
  int table1max = 0;
  int table1second = 0;
  int table1max_i=-1;
  int table1second_i = -1;
  int table2max = 0;
  int table2second = 0;
  int table2max_i=-1;
  int table2second_i = -1;
  for(int i = 0; i < 100001; i++){
      if(vtable1[i] > table1max){
        table1second = table1max;
        table1second_i = table1max_i;
        table1max = vtable1[i];
        table1max_i = i;
      }else if (vtable1[i] > table1second){
        table1second = vtable1[i];
        table1second_i = i;
      }
      if(vtable2[i] > table2max){
        table2second = table2max;
        table2second_i = table2max_i;
        table2max = vtable2[i];
        table2max_i = i;
      }else if (vtable2[i] > table2second){
        table2second = vtable2[i];
        table2second_i = i;
      }
  }
  int ans;
  if(table1max_i != table2max_i){
    ans = (n/2) - table1max + (n/2) -table2max;
  }else{
    int ans1 = (n/2) -table1max + (n/2)-table2second;
    int ans2 = (n/2) - table1second + (n/2) -table2max;
    if(ans1 > ans2){
      ans = ans2;
    }else{
      ans = ans1;
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

class Main {
  public static void main(String args[]) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String cards;
    int m = 0;
    int h = 0;
    try {
      while (!(cards = br.readLine()).equals("-")) {
        m = Integer.parseInt(br.readLine());
        for (int i = 0; i < m; i++) {
          h = Integer.parseInt(br.readLine());
          cards = cards.substring(h, cards.length()) + cards.substring(0, h);
        }
        System.out.println(cards);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}

Measured memory_bytes: 17028
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll a[100002];
int main()
{
  ll n,ans=0,crr=1;
  scanf("%lld",&n);
  for(int i=1;i<=n;i++){
    scanf("%lld",&a[i]);
  }
  while(crr!=2&&crr!=-1){
    ll tmp=a[crr];
    a[crr]=-1;
    crr=tmp;
    ans++;
  }
  printf("%lld\n",crr==2?ans:-1);
}

Measured memory_bytes: 896
R, C, K = list(map(int, input().split()))
rcv = [list(map(int, input().split())) for _ in range(K)]

rcv.sort()
rcv.append([R, C, 0])

L = [0] * C
su = 0
n = 0
vv = 0
D = [0, 0, 0]
for i in range(K):
  r, c, v = rcv[i]
  if r != 1: break
  for j in range(3):
    if D[j] < v:
      D[j], v = v, D[j]
  L[c - 1] = sum(D)
n = i

for i in range(1, C):
  L[i] = max(L[i], L[i - 1])

for i in range(2, R + 1):
  L2 = L
  L = [0] * C
  D = [0, 0, 0]
  DP = []
  ln = 0
  for n in range(n, K):
    r, c, v = rcv[n]
    if r != i: break
    if len(DP) == 0:
      L[c - 1] = v + L2[c - 1]
      D[0] = L[c - 1]
      DP.append([L[c - 1], 0, 0])
      continue

    DP.append([0, 0, 0])
    DP[-1][0] = v + L2[c - 1]
    for k in range(3):
      DP[-1][k] = max(DP[-1][k], DP[-2][k])
      if k == 0: continue
      DP[-1][k] = max(DP[-1][k], DP[-2][k - 1] + v)
    L[c - 1] = max(DP[-1])
  L[0] = max(L[0], L2[0])
  for j in range(1, C):
    L[j] = max(L[j], L[j - 1], L2[j])

print(max(L))

    

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

int n;
ll a[200100];

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

	cin >> n;
	bool flg = true;
	REP(i, n) {
		cin >> a[i];
		if (i == 0) continue;
		if (a[i] - a[i - 1] >= 2) flg = false;
	}
	if(a[0] != 0) flg = false;
	if (!flg) {
		cout << -1 << endl;
		return 0;
	}
	ll ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (i == n - 1) ans += a[i];
		else {
			if (a[i + 1] == a[i] + 1) continue;
			ans += a[i];
		}
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b;
  cin >> a;
  cin >>b;
  
  if(a%500<=b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, l[3123];

    cin >> n;

    REP(i, n)
    cin >> l[i];

    sort(l, l + n);

    ll res = 0;

    for (int i = n - 1; i > 1; i--)
    {
        for (int j = i - 1; j > 0; j--)
        {
            int d = l[i] - l[j];

            res += j - (upper_bound(l, l + j, d) - l);
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
import fractions as frc
gc=int(c*d/frc.gcd(c,d))

c_n=b//c-(a-1)//c
d_n=b//d-(a-1)//d
gc_n=b//gc-(a-1)//gc

res=b-(a-1)-(c_n+d_n-gc_n)

print(int(res))

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

int main(){
    int a,b; cin >> a >> b;
    int ans = 0;
    for( int i = 1; i <= 3; i++ ){
        if( a != i && b != i){
            ans = i; break;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    char A[n + 1][n + 1];
    char B[m + 1][m + 1];

    int i, j, k, l;
    for(i = 0; i < n; i ++)
    {
    	for(j = 0; j < n; j ++)
    	{
    		cin >> A[i][j];
    	}
    }

    for(i = 0; i < m; i ++)
    {
    	for(j = 0; j < m; j ++)
    	{
    		cin >> B[i][j];
    	}
    }

    int flag = 0;
    for(i = 0; i < n - m + 1; i ++)
    {
    	for(j = 0; j < n - m + 1; j ++)
    	{
    		bool match = true;
    		for(k = 0; k < m; k ++)
		    {
		    	for(l = 0; l < m; l ++)
		    	{
		    		if(A[i + k][j + l] != B[k][l])
		    			match = false;
		    	}
		    }
		    if(match == true)
		    {
		    	flag = 1;
		    	break;
		    }
    	}

    	if(flag == 1)
    		break;
    }

    if(flag == 1)
    	cout << "Yes" << endl;
    else
    	cout << "No" << endl;
}

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

using namespace std;

int vet[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
	int k;

	scanf("%d", &k);
	k--;

	printf("%d\n", vet[k]);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;

int main(){
  string s,t,ans;cin >> s >> t;
  int len = s.size()-t.size()+1;
  bool ret = false;
  int idx = -1; 
  
  rep(i,len){
    bool flag = true;
    rep(j,t.size()){
      if(s[i+j] == '?' || s[i+j] == t[j]) continue;
      flag = false;
      break;
    }
    if(flag) ret = true,idx = i;
  }
  if(!ret) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  rep(i,t.size()){
    if(s[i+idx] == '?') s[i+idx] = t[i];
  }
  rep(i,s.size()){
    if(s[i] == '?') s[i] = 'a';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
N = int(input())
P = [float(p) for p in input().split()]

dp = [[0]*(N+1) for _ in range(N+1)]
#dp[i][j]:i枚コインを投げた時、j枚表が出る確率

dp[1][1] = P[0]
dp[1][0] = 1-P[0]
for i in range(2, N+1):
    dp[i][0] = dp[i-1][0]*(1-P[i-1])
    for j in range(1, i+1):
        dp[i][j] = dp[i-1][j-1]*P[i-1] + dp[i-1][j]*(1-P[i-1])
            
ans = 0
for i in range(N//2+1, N+1):
    ans += dp[N][i]
    
print(ans)

Measured memory_bytes: 263048
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    char a;cin>>a;
    if(a-'a'>=0)cout<<'a'<<endl;
    else cout<<'A'<<endl;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    int cnt = 0;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'B') cnt++;
        else ans += cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
using System;
using System.Collections.Generic;

namespace ABC105D
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');
            int N = int.Parse(input1[0]);
            int M = int.Parse(input1[1]);

            string[] input2 = Console.ReadLine().Split(' ');
            List<int> A = new List<int>();
            for (int i = 0; i < N;i++)
            {
                A.Add(int.Parse(input2[i]));
            }

            // make sum
            List<int> SUM = new List<int>();

            SUM.Add(0);
            for (int j = 0; j < N;j++){
                SUM.Add((SUM[j] + A[j]) % M);
            }


            Dictionary<int, int> map = new Dictionary<int, int>();
            long ans = 0;

            for (int k = 0; k < SUM.Count; k++){

                if(map.ContainsKey(SUM[k])){
                    ans += map[SUM[k]];
                    map[SUM[k]]++;
                }else{
                    map.Add(SUM[k], 0);
                    ans += map[SUM[k]];
                    map[SUM[k]]++;
                }

                /*
                ans += map[SUM[k]];
                map[SUM[k]]++;
                */

                }


            /*
            for (int k = 0; k < SUM.Count;k++){
                if (!map.ContainsKey(SUM[k]))
                {
                    map.Add(SUM[k], 1);
                }else{
                    map[SUM[k]]++;
                }
            }

            long ans = 0;

            foreach(KeyValuePair<int,int> pair in map){
                ans += (pair.Value * (pair.Value - 1)) / 2;
            }

            */
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 21856
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <climits>
#include <cmath>
#include <queue>
#include <ctime>
#include <set>
#include <queue>
using namespace std;

queue<char> a;
queue<char> b;
queue<char> c;

void read(string& s, int ind) {
    for (int i = 0; i < (int) s.size(); ++i) {
        if (ind == 1) {
            a.push(s[i]);
            continue;
        }
        if (ind == 2) {
            b.push(s[i]);
            continue;
        }
        if (ind == 3) {
            c.push(s[i]);
            continue;
        }
    }
}

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

    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    read(s1, 1);
    read(s2, 2);
    read(s3, 3);
    char tmp = a.front();
    a.pop();
    while(1) {
        if (tmp == 'c' && c.empty()) {
            cout << "C" << endl;
            return 0;
        }
        if (tmp == 'b' && b.empty()) {
            cout << "B" << endl;
            return 0;
        }
        if (tmp == 'a' && a.empty()) {
            cout << "A" << endl;
            return 0;
        }
        if (tmp == 'a') {
            tmp = a.front();
            a.pop();
            continue;
        }
        if (tmp == 'b') {
            tmp = b.front();
            b.pop();
            continue;
        }
        if (tmp == 'c') {
            tmp = c.front();
            c.pop();
            continue;
        }       
    }


    return 0;   
}   

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char s[20];
	scanf("%s", &s);
	int i;
	char t[20];
	for ( i = 0; i < 13; i++ ){
		if (i < 4) {
			t[i] = s[i];
		}else if ( i == 4 ) {
			t[i] = ' ';
		}else{
			t[i] = s[i-1];
		}
	}
	printf("%s\n", t);
			
	return 0;
}


Measured memory_bytes: 128
/*
cat <<EOF >mistaken-paste
*/

#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>

#define BIG 2000000007
#define VERYBIG 200000000000007LL

#define MOD 1000000007
typedef uint64_t ull;
typedef  int64_t sll;

#define N_MAX 200000
#define M_MAX 200000

typedef struct {
	int32_t a;
	int32_t b;
} hw;

typedef struct {
	sll a;
	sll b;
} hwll;

typedef struct {
	hwll a;
	hwll b;
} linell;


typedef struct {
	ull s;
	ull t;
	int32_t c;
} struct_a;

typedef struct {
	int32_t from;
	int32_t to;
	sll cost;
} struct_b;

ull n, m;
ull h, w;
ull k;
ull q;
ull vua, vub, vuc, vud, vue, vuf;
sll vsa, vsb, vsc, vsd, vse, vsf;
long double vra, vrb, vrc;
double vda, vdb, vdc;
size_t slen;
size_t tlen;
char ch, dh;

ull umax (ull x, ull y) {
	return (x > y) ? x : y;
}

char s[401];

ull dp[305][305][305];

ull solve () {
	sll i, j, ki, li;
	// ull result = 0;
	sll result = 0;
	double dresult = 0;
	// ull maybe = 0;
	sll maybe = 0;
	// ull sum = 0;
	sll sum = 0;
	sll item;
	ull *dpcell;

	n = strlen(s);
	for (j = 0; j <= n; j++) {
		for (i = 0; i + j <= n; i++) {
			for (ki = 0; ki <= k; ki++) {
				if (j == 0) {
					dp[i][j][ki] = 0;
					continue;
				}
				if (j == 1) {
					dp[i][j][ki] = 1;
					continue;
				}

				bool isaddable = (s[i] == s[i + j - 1]);
				maybe = umax(umax(dp[i][j - 1][ki], dp[i + 1][j - 1][ki]), dp[i + 1][j - 2][ki] + (isaddable ? 2 : 0));
				if (!isaddable && ki) {
					maybe = umax(maybe, dp[i + 1][j - 2][ki - 1] + 2);
				}

				dp[i][j][ki] = maybe;
				// printf("%lld/%lld/%lld: %lld\n", i, j, ki, maybe);
			}
		}
	}

	result = 0;
	for (ki = 0; ki <= k; ki++) {
		result = umax(result, dp[0][n][ki]);
	}

	printf("%lld\n", result);

	return 0;
}

int32_t main (void) {
	int32_t i, j;
	int32_t x, y;

	scanf("%s", s);
	scanf("%llu", &k);

	solve();

	return 0;
}


Measured memory_bytes: 219264
#include <stdio.h>
#include <string.h>

int n;

typedef struct {
  int connected[900];
  int dist[900];
  int cnt;
} Node;

Node nodes[900];

void addEdge(int i, int j, int d) {
  nodes[i].connected[nodes[i].cnt] = j;
  nodes[i].dist[nodes[i].cnt++] = d;

  nodes[j].connected[nodes[j].cnt] = i;
  nodes[j].dist[nodes[j].cnt++] = d;
}

int max = 0;

int dfs(int k, int from, int dist) {
  int i;
  int sum = 0;
  for (i = 0; i < nodes[k].cnt; ++i) {
    if (nodes[k].connected[i] == from) {
      continue;
    }

    int v = nodes[k].connected[i];
    int d = nodes[k].dist[i];
    if (nodes[v].cnt == 1) {
      if (max < dist) {
        max = dist;
      }

      continue;
    }

    sum += dfs(v, k, dist + d) + d;
  }

  return sum;
}

int main(void) {
  int p[900];

  while (scanf("%d", &n), n) {
    memset(nodes, 0, sizeof(nodes));

    int i;
    for (i = 1; i < n; ++i) {
      int t;
      scanf("%d", &t);
      --t;
      p[i] = t;
    }
    int rem = 0;
    for (i = 1; i < n; ++i) {
      int d;
      scanf("%d", &d);

      rem += d;
      addEdge(i, p[i], d);
    }

    int ans = 1e9;
    for (i = 0; i < n; ++i) {
      int first = 0, second = 0;

      int j;
      int sum = 0;
      for (j = 0; j < nodes[i].cnt; ++j) {
        max = 0;
        if (nodes[nodes[i].connected[j]].cnt == 1) {
          continue;
        }

        sum +=
            dfs(nodes[i].connected[j], i, nodes[i].dist[j]) + nodes[i].dist[j];

        if (max > first) {
          second = first;
          first = max;
        } else if (max > second) {
          second = max;
        }
      }

      sum = sum * 2 - first - second + rem;

      if (ans > sum) {
        ans = sum;
      }
    }

    printf("%d\n", ans);
  }
}


Measured memory_bytes: 8120
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>
#include <cassert>
using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n,k;
    string s;
    cin >> n >> k >> s;
    int sm = 0;
    rep(i,n){
        if(s[i]=='L'){
            if(i!=0&&s[i-1]=='L')sm++;
        }else{
            if(i!=n-1&&s[i+1]=='R')sm++;
        }
    }
    cout << min(n-1,sm+2*k) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<vector>
using namespace std;
int main(void){
   int h,w;
   cin >> h >> w;
   vector<string> s(h);
   for(int i = 0;i < h;i++){
         cin >> s[i];
   }
   int stone = 0;
   for(int i = 0;i < h;i++){
         for(int j = 0;j < w;j++){
               if(s[i][j] == '#')stone++;
         }
   }
   cout << ((h + w - 1 == stone) ? "Possible" : "Impossible") << endl;
}


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

int main() {
  int a, b, d, r;
  cin >> a >> b;
  d = a / b;
  r = a % b;
  double f = (double)a / (double)b;
  cout << d << " " << r << " " << fixed << setprecision(6) << f << endl;
  
  return 0;
}


Measured memory_bytes: 3292
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iterator>
#include<set>
#define rep(i,n) for(i=0;i<n;i++);
#define endl "\n"
#define ll long long
using namespace std;
int main()
{
    long long int d,i,n,m,p=0,q=0,r=0,s=0,l;

int j;
cin>>l>>r>>d;
for(i=l;i<=r;i++)
{
    if(i%d==0)
        p++;
}
cout<<p;



}

















Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

ll N;
vector<ll> x;
int main(){
  COMinit();
  cin >> N;
  x.resize(N);
  rep(i, N) cin >> x[i];
  ll ans = 1;
  ll alr = -1;
  ll sum = 0;
  rep(i, N){
    if(x[i] < alr + 2){
      ans *= sum + 1;
      ans %= MOD;
    }else{
      alr += 2;
      sum++;
    }
  }
  ans *= kai_mod(sum);
  ans %= MOD;
  cout << ans << endl;
}


Measured memory_bytes: 7296
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc =new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
 
if((a==5 && b==5 &&c==7) || (a==5 && b==7 && c==5) || (a==7 && b==5 && c==5)){
System.out.println("YES");
}else{System.out.println("NO");}
 
}}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;
typedef multiset<int> msi;

vi countsort(msi s) {
  set<int> my_set(s.begin(), s.end());
  vector<int> my_vec(my_set.begin(), my_set.end());
  sort(my_vec.begin(), my_vec.end(), 
    [&](const int &i1, const int &i2) {
        return s.count(i1) > s.count(i2);
    }
  );
  return my_vec;
}


int n;

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

  cin >> n;
  int v;
  msi s[2];
  rep(i,n) {
    cin >> v;
    s[i%2].insert(v);
  }

  vi c0 = countsort(s[0]);
  int c00 = s[0].count(c0[0]);
  int c01 = sz(c0) > 1 ? s[0].count(c0[1]) : 0;
  int v0 = c0[0];
  vi c1 = countsort(s[1]);
  int c10 = s[1].count(c1[0]);
  int c11 = sz(c1) > 1 ? s[1].count(c1[1]) : 0;
  int v1 = c1[0];
  int ans;
  if (v0==v1) {
    ans = n - max(c00+c11, c01+c10);
  } else {
    ans = n - (c00+c10);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 9984
#define ll long long
#define MOD 1000000007
#define MOD2 998244353
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll po(ll base, ll powerRaised)
{
    if (powerRaised != 0)
        return (base * po(base, powerRaised - 1));
    else
        return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll a = 0, b = 0, c = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
            a++;
        else if (s[i] == 'G')
            b++;
        else
            c++;
    }
    ll ans = a * b * c;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            if ((i + j) % 2 == 0)
            {
                ll mid = (i + j) / 2;
                if (s[i] != s[j] && s[i] != s[mid] && s[j] != s[mid])
                    ans--;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FILLINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const lint MOD = 1000000007;

void _main() {
    int N;
    cin >> N;
    cout << (N < 1000 ? "ABC" : "ABD") << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p, l, r;
};
struct Node T[MAX];
int n;

void preParse(int u){
  if (u == NIL) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if (u == NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u){
  if (u == NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(){
  int i, v, l, r, root;
  scanf("%d", &n);
  for (i = 0; i < n; i++){
    T[i].p = NIL;
  }

  for (i = 0; i < n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if (l != NIL) T[l].p = v;
    if (r != NIL) T[r].p = v;
  }

  for (i = 0; i < n; i++) if (T[i].p == NIL) root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2040
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
int k,n;
char num[15];
bool chack(char a[])
{
	int flag1 = 0, flag2 = 0, flag3 = 0;
	for (int i = 1;i <= k;i++)
	{
		if (a[i] == '3') flag1 = 1;
		if (a[i] == '5') flag2 = 1;
		if (a[i] == '7') flag3 = 1;
	}
	if (flag1 && flag2 && flag3) return true;
	else return false;
}
ll qpow(int x, int y)
{
	ll res = 1;
	for (int i = 0;i < y;i++)
	{
		res *= 1ll * x;
	}
	return res;
}
ll st[1000010],s;
char b[4] = { '\0','3','5','7' };
void dfs(int t)
{
	if (t > k)
	{
		if (chack(num))
		{
			s++;
			for (int i = 1,j=k-1;i <= k;i++,j--)
			{
				st[s] += (1ll*num[i] - '0') * qpow(10, j);
			}	
		}
		return;
	}
	for (int i = 1;i <= 3;i++)
	{
		num[t] = b[i];
		dfs(t + 1);
		num[t] = '\0';
	}
}
int main()
{
	int digt= 0;
	cin >> n;
	int tmp = n;
	while (tmp)
	{
		digt++;
		tmp /= 10;
	}
	for (k = 3;k <= digt + 1;k++)
	{
		dfs(1);
	}
	sort(st + 1, st + s + 1);
	int ans = 0;
	for (int i = 1;i <= s;i++)
	{
		if (st[i] > n)
		{
			ans = i - 1;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

using State = string::const_iterator;
class ParseError {};

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

int expr(State &);
int term(State &);
int number(State &);
int factor(State &);

int main() {
    int t;
    cin >> t;
    while(t--) {
        string s;
        cin >> s;
        State now = s.begin();
        int ans = expr(now);
        cout << ans << endl;
    }
}

int number(State &now) {
    int res = 0;
    while(isdigit(*now)) {
        res *= 10;
        res += *now - '0';
        now++;
    }
    return res;
}

int term(State &now) {
    int res = factor(now);
    while(1) {
        if(*now == '*') {
            now++;
            res *= factor(now);
        } else if(*now == '/') {
            now++;
            res /= factor(now);
        } else {
            break;
        }
    }
    return res;
}

int expr(State &now) {
    int res = term(now);
    while(1) {
        if(*now == '+') {
            now++;
            res += term(now);
        } else if(*now == '-') {
            now++;
            res -= term(now);
        } else {
            break;
        }
    }
    return res;
}

int factor(State &now) {
    if(*now == '(') {
        now++;
        int res = expr(now);
        now++;
        return res;
    } else {
        return number(now);
    }
}


Measured memory_bytes: 3168
n, a, b= map(int, input().split())

Ssum = 0
for i in range(1, n+1):
    tmp = i
    sum = 0
    while i>0 :
        sum += i%10
        i //= 10
    if a<=sum and sum<=b:
        Ssum += tmp

print(Ssum)

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <cmath>

using ldouble = long double;

void solve() {
    ldouble l;
    std::cin >> l;
    std::cout << std::fixed << std::setprecision(10)
              << std::pow(l / 3, 3) << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 512