akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

#define	HASHTABLEMAX	16777216

unsigned short hashTable[HASHTABLEMAX];

void init(void){
	unsigned int i;
	for( i=0; i<HASHTABLEMAX; i++){
		hashTable[i] = 0;
	}
}

unsigned int makehash(char *str,unsigned int length){
	unsigned int i;
	unsigned int hash;
	unsigned int code;
	
	hash = 0;
	code = 0;
	for( i=0; i<length; i++){
		switch(str[i]){
			case 'A':
				code = 0b00;
				break;
			case 'C':
				code = 0b01;
				break;
			case 'G':
				code = 0b10;
				break;
			case 'T':
				code = 0b11;
				break;
			default:
				break;
		}
		hash <<= 2;
		hash += code;
	}
	return hash;
}

void find(unsigned int hash,unsigned int length){
	unsigned short lengthBit;
	lengthBit = 1 << (length - 1);
	if(hashTable[hash] & lengthBit){
		printf("yes\n");
	}else{
		printf("no\n");
	}
}

void insert(unsigned int hash,unsigned int length){
	unsigned short lengthBit;
	lengthBit = 1 << (length - 1);
	hashTable[hash] = hashTable[hash] | lengthBit;
}

int main(void){
	unsigned int i;
	unsigned int n;
	unsigned int hash;
	unsigned int length;
	char command[7];
	char str[13];
	
	init();
	scanf("%d",&n);
	for( i=0; i<n; i++){
		scanf("%s",command);
		scanf("%s",str);
		length = strlen(str);
		hash = makehash(str,length);
		if(strcmp(command,"find") == 0){
			find(hash,length);
		}else if(strcmp(command,"insert") == 0){
			insert(hash,length);
		}else{
			;
		}
	}
}

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

using namespace std;

int main() {
	int h, w, n, x, mat[112][112];

	int l = 0, c = 0;

	scanf("%d %d", &h, &w);

	scanf("%d", &n);

	int sum = 1;
	for (int i=1; i<=n; ++i) {
		scanf("%d", &x);

		while (x--) {			
			mat[l][c] = i;

			if ((sum > 0 && c == w-1) || (sum < 0 && c == 0)) {
				++l, sum*=-1;
			}
			else {
				c+=sum;
			}
		}
	}

	for (int i=0; i<h; ++i) {
		for (int j=0; j<w; ++j) {
			printf("%d ", mat[i][j]);
		}
		puts("");
	}

	return 0;
}

Measured memory_bytes: 384
#include "iostream"
#include "string"
#include "vector"
#include "algorithm"
#include "functional"
#include "cmath"
#include "iomanip"
#include "map"

struct city_t {
    int id;
    int pref;
    int year;
    int order;

    void print_name(){
        std::cout << std::setfill('0') << std::setw(6) << pref;
        std::cout << std::setfill('0') << std::setw(6) << order;
        std::cout << std::endl;
    }
};

bool compare_city_by_year(const city_t &a, const city_t &b) {
    return a.year < b.year;
}

bool compare_city_by_id(const city_t &a, const city_t &b) {
    return a.id < b.id;
}

int main() {
    // get values from input
    int n, m;
    std::vector<city_t> cities;
    std::map<int, int> city_count_in_prefs;

    std::cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int p_i, y_i;
        std::cin >> p_i >> y_i;
        cities.push_back(city_t { i, p_i, y_i, -1 });
        city_count_in_prefs[p_i] = 0;
    }

    // main procedure
    std::sort(cities.begin(), cities.end(), compare_city_by_year);
    for (int i = 0; i < m; ++i) {
        city_count_in_prefs[cities[i].pref] += 1;
        cities[i].order = city_count_in_prefs[cities[i].pref];
    }

    std::sort(cities.begin(), cities.end(), compare_city_by_id);

    // output
    for (int i = 0; i < m; ++i) {
        cities[i].print_name();
    }
    return 0;
}

Measured memory_bytes: 7792
/*zxj*/
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);
using namespace std;
#define csh(a,n) memset(a,n,sizeof(a));
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	a=max(a,c);
	b=min(d,b);
	if(a>b){
		cout<<0<<endl;
	}
	else{
		cout<<b-a<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n,s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<mint> dp(s+1);
  dp[0] = 1;
  mint ans = 0;
  rep(_,n){
    vector<mint> temp(s+1);
    rep(i,s+1){
      temp[i] += dp[i]*2;
      if(i+a[_]<=s) temp[i+a[_]] += dp[i];
    }
    dp = temp;
    ans += dp[s];
  }
  cout << dp[s] << endl;
}


Measured memory_bytes: 3668
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String str = sc.next();
			StringBuffer ans = new StringBuffer();
			int i=0;
			//System.out.println(str.length());
			
			while(i != str.length()){
				if(str.charAt(i) == '@'){
					++i;		
					char c = str.charAt(i);
					int k = Integer.parseInt(String.valueOf(c));
					//System.out.println("k=" +k);
					++i;
					c=str.charAt(i);	
					for(int j=0; j<k; j++){
						ans.append(c);
					}
					++i;
				}
				else{
					ans.append(str.charAt(i));
					++i;
				}
			
			}
			System.out.println(ans);	
		}
	
	}
}

Measured memory_bytes: 17132
main :: IO ()
main = do
  (n:x:xs) <- (map read) . words <$> getLine
  putStrLn . show $ solve n x

solve :: Integer -> Integer -> Integer
solve n x = calcPutties (layers n) x

calcPutties :: [(Integer, Integer)] -> Integer -> Integer
calcLayers _ 0 = 0
calcPutties ((nLay, nPut):ns) x
  | nLay == x = nPut
  | nLay > x && x > (nLay `div` 2) = (snd . head $ ns) + 1 + calcPutties ns (x - (nLay `div` 2) - 1)
  | (nLay `div` 2) >= x && x > 1 = calcPutties ns (x - 1)
  | otherwise = 0

-- (layer, putty)
layers :: Integer -> [(Integer, Integer)]
layers 0 = [(1,1)]
layers n =
  let all@((prevLayer, prevPutty) : xxs) = layers (n-1)
  in (prevLayer * 2 + 3, prevPutty * 2 + 1) : all


Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n,k;
cin >> n >> k;
int ans = n+1-k;
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
while True:
    n = int(input())
    score = []
    ans = 0
    if n==0:
        break
    for i in range(n):
        score.append(int(input()))
    score.sort()
    for i in range(1,len(score)-1):
        ans+=score[i]
    print(ans//(n-2))



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

public class Main {

    public static void main(String[] args) {
        try {
            InputReader in;
            PrintWriter out;
            boolean useOutput = false;
            // if (System.getProperty("ONLINE_JUDGE") == null) useOutput = true;
            if (useOutput) {
                FileInputStream fin = new FileInputStream(new File("src/testdata.in"));
                in = new InputReader(fin);
                FileOutputStream fout = new FileOutputStream(new File("src/testData.out"));
                out = new PrintWriter(fout);
            } else {
                InputStream inputStream = System.in;
                in = new InputReader(inputStream);
                OutputStream outputStream = System.out;
                out = new PrintWriter(outputStream);
            }
            Solver solver = new Solver();
            solver.solve(in, out);
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    static class Solver {

        public void solve(InputReader cin, PrintWriter cout) {
            try {
                int n = cin.nextInt(), k = cin.nextInt();
                int cost[] = new int[n], dp[] = new int[n];
                for (int i = 0; i < n; ++i) {
                    cost[i] = cin.nextInt();
                }
                dp[0] = 0;
                for (int i = 1; i < n; ++i) {
                    dp[i] = Integer.MAX_VALUE;
                    for (int j = Math.max(0, i - k); j < i; ++j) {
                        dp[i] = Math.min(dp[i], dp[j] + Math.abs(cost[i] - cost[j]));
                    }
                }
                cout.println(dp[n - 1]);
            } catch (RuntimeException e) {
                e.printStackTrace();
                return;
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }

        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 31812
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution <int> range(1, 3);
typedef pair <int, int> pii;

const int N = 1000007;
int n, a[N], b[N], cnt[4];

int f(int x) {
    int tmp = 2, res = 0;
    while (x >= tmp) {
        res += x / tmp;
        tmp *= 2;
    }
    return res;
}

int c(int x, int y) {
    if (y > x) {
        return 0;
    }
    if (f(x) > f(y) + f(x - y)) {
        return 0;
    }
    return 1;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    cin >> n;
    char ch;
    for (int i = 1; i <= n; i++) {
        cin >> ch;
        a[i] = (ch - '0');
        a[i]--;
        cnt[a[i]]++;
    }
    if (cnt[1]) {
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (a[i] == 2) {
                a[i] = 0;
            }
            ans ^= (a[i] & c(n - 1, i - 1));
        }
        cout << ans;
    }   else {
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (a[i] == 2) {
                a[i] = 1;
            }
            ans ^= (a[i] & c(n - 1, i - 1));
        }
        if (ans) {
            cout << 2;
        }   else {
            cout << 0;
        }
    }
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  ll ans = 0;

  rep2(i, 1, N + 1){
    ll sum = 0;
    ll num = i;

    while(num > 0){
      sum += num % 10;
      num /= 10;
    }

    if((sum >= A) && (sum <= B)) ans += i;
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <iomanip>
using namespace std;

int main() {
	
	int n=0;
	double x[20],y[20],s=0;
	
	
	while(scanf("%lf,%lf",&x[n],&y[n])+1)
		++n;
	
	for(int i=0;i<n;++i){
		s += x[i]*y[(i+1)%n] - y[i]*x[(i+1)%n];
	}
	s/=2;
	
	cout<<setprecision(20)<<(s>0?s:-s)<<endl;
	return 0;
}

Measured memory_bytes: 1292
#include<cstdio>
#include<cmath>

int main(){
  int n;
  int x[100] = {};
  int y[100] = {};
  double z[100] = {};
  double p1 = 0, p2 = 0, p3 = 0, pp = 0;
  scanf("%d", &n);

  for( int i = 0; i < n; i++ ){
    scanf("%d", &x[i]);
  }

  for( int i = 0; i < n; i++ ){
    scanf("%d", &y[i]);
  }

  for( int i = 0; i < n; i++ ){
    z[i] = fabs( x[i] - y[i] );
  }

  for( int i = 0; i < n; i++ ){
    p1 += z[i];
    p2 += pow(z[i],2);
    p3 += pow(z[i],3);
    if( z[i] > pp ) pp = z[i];
  }

  printf("%f\n%f\n%f\n%f\n", p1, sqrt(p2), pow(p3, 1.0 / 3.0), pp);

  return 0;
}

Measured memory_bytes: 2952
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    scan.word::<usize>();
    let S = scan.word::<String>().chars().collect::<Vec<_>>();
    let N = S.len();

    let mut r = 0_usize;
    let mut g = 0_usize;
    let mut b = 0_usize;

    for &c in &S {
        match c {
            'R' => r += 1,
            'G' => g += 1,
            'B' => b += 1,
            _ => {}
        }
    }

    let mut count = r * g * b;

    for i in 0..N {
        for d in 0..N {
            let j = i + d;
            let k = j + d;

            if j < N && k < N && S[i] != S[j] && S[i] != S[k] && S[j] != S[k] {
                count -= 1;
            }
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 2088
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
a = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for l in range(1, k+1):
            a += gcd(i, j, l)

print(a)

Measured memory_bytes: 69768
#include <iostream>
#include <math.h>

using namespace std;
int main(){
  long int N;
  cin>>N;
  //int ans=1;
  long int ans=1;
  for (int i=0;i<N;i++){
    ans*=i+1;
    ans%=((int)pow(10.0,9)+7);
  }
  //cout<<(int)pow(10.0,9)+7<<endl;
  //cout<<"N%3"<<N%3<<endl;
  //N%=3;
  //cout<<"N%3 "<<N<<endl;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int main() {
  int a[3];
  rep(i, 3) cin >> a[i];
  sort(a, a + 3);
  cout << a[0] + a[1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 150

#define WHITE 0
#define BLACK 1

main()
{


  int n,i,j,a,b,c;
  int A[N][N];



  scanf("%d",&n);

  for(i = 1; i <= n; i++){
    scanf("%d%d",&a,&b);
    for(j = 1; j <= b; j++){
      scanf("%d",&c);
      A[a][c] = BLACK;
    }  
  }
  
  for(i = 1; i <= n; i++){
    for(j = 1; j < n; j++){
      printf("%d ",A[i][j]);
    }
    printf("%d\n",A[i][j]);
  }
  
  return 0;
}

Measured memory_bytes: 660
def bubbleSort(A):
    steps = 0
    flag = 1
    completed_idx = 0
    while flag:
        flag = 0
        for i in range(len(A) - 1, completed_idx, -1):
            if A[i - 1] > A[i]:
                A[i - 1], A[i] = A[i], A[i - 1]
                steps += 1
                flag = 1
        completed_idx += 1

    for e in A[:-1]:
        print(e, end=' ')
    print(A[-1])
    print(steps)

N = int(input())
A = [int(elem) for elem in input().split()]
bubbleSort(A)


Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define int int64_t
#define pcnt __builtin_popcount
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define vec vector<int>
#define mat vector<vector<int>> //mat データ名(縦,vec(横));
#define F first
#define S second
int INF = 1000000000000000001; //10^18+1
int MOD = 1000000007; //10^9+7
//cout << fixed << setprecision(15); (小数点以下表示)

signed main () {
  int K,siz;
  string S;
  cin >> K >> S;
  siz=S.size();
  for(int i=0;i<K;i++){
    if(i<siz)cout << S.at(i);
  }
  if(siz>K)cout << "...";
  cout << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
//#include "stdc++.h"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = max(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

void	solve()
{
	int h, w;
	cin >> h >> w;
	vector<string> v(h);
	rep(i, h) cin >> v[i];
	rep(i, h) {
		cout << v[i] << endl;
		cout << v[i] << endl;
	}
}

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	solve();
}

Measured memory_bytes: 256
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

int main() {
    int n = read();
    vector<int> vc(n);
    generate_n(vc.begin(), n, read);
    reverse(vc.begin(), vc.end());
    int mn = INT_MAX;
    for (int x : vc) {
        mn = min(mn, x);
        if (x > mn + 1) {
            return puts("No"), 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b-1); i>=(a); i--)
#define debug(x) cout << #x << " => " << x << endl
using namespace std;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define eb emplace_back
#define pb push_back
typedef vector<int> vi;

typedef long long ll;
typedef long double ld;

const int MAX_N = 7 + 100000;
///----------------------------------------------
map<int, vector<pii> > v1,v2;
map<int, set<pii> > s1,s2;
int x[MAX_N], y[MAX_N], n,D;
bool vis[MAX_N];
///----
int solve(vector<pii> &hv, int lo, int hi) {
	auto itl = lower_bound(all(hv), mp(lo,-1));
	auto itr = lower_bound(all(hv), mp(hi+1,-1));
	return itr-itl;
}
void check(set<pii> &hv, int lo, int hi, queue<int> &que) {
	auto it = hv.lower_bound(mp(lo, -1));
	while (it != hv.end() && it->fi <= hi) {
		if (!vis[it->se]) que.push(it->se);
		vis[it->se] = true;
		it = hv.erase(it);
	}
}
///----
void bfs(int st) {
	queue<int> que;
	que.push(st); vis[st]=true;
	for (; !que.empty(); ) {
		int at = que.front(); que.pop();
		auto it = s1.find(x[at]+y[at]-D); if (it != s1.end()) check(it->se, x[at]-D, x[at], que);
			 it = s1.find(x[at]+y[at]+D); if (it != s1.end()) check(it->se, x[at], x[at]+D, que);
			 it = s2.find(x[at]-y[at]-D); if (it != s2.end()) check(it->se, x[at]-D+1, x[at]-1, que);
			 it = s2.find(x[at]-y[at]+D); if (it != s2.end()) check(it->se, x[at]+1, x[at]+D-1, que);
	}
}
///----
int main() {
	
	///read
	int a,b; scanf("%d%d%d",&n,&a,&b); a--; b--;
	rep(i,0,n) {
		scanf("%d%d",x+i,y+i);
		v1[x[i]+y[i]].eb(x[i],i);
		v2[x[i]-y[i]].eb(x[i],i);
		s1[x[i]+y[i]].emplace(x[i], i);
		s2[x[i]-y[i]].emplace(x[i], i);
	}

	///prework
	for (auto it = v1.begin(); it != v1.end(); it++) sort(all(it->se));
	for (auto it = v2.begin(); it != v2.end(); it++) sort(all(it->se));
	D = abs(x[a]-x[b])+abs(y[a]-y[b]);

	///work
	memset(vis,false,sizeof(vis));
	bfs(a); bfs(b);
	ll ans=0;
	rep(i,0,n) if (vis[i]) {
		auto it = v1.find(x[i]+y[i]-D); if (it != v1.end()) ans += solve(it->se, x[i]-D, x[i]);
			 it = v1.find(x[i]+y[i]+D); if (it != v1.end()) ans += solve(it->se, x[i], x[i]+D);
			 it = v2.find(x[i]-y[i]-D); if (it != v2.end()) ans += solve(it->se, x[i]-D+1, x[i]-1);
			 it = v2.find(x[i]-y[i]+D); if (it != v2.end()) ans += solve(it->se, x[i]+1, x[i]+D-1);
	}
	printf("%lld\n",ans/2);
	
	return 0;



}


Measured memory_bytes: 45696
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A+B>=C) 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 <int> input(n);
    for(int i=0;i<n;i++)
    {
        cin>>input[i];
    }
    vector <int> dp(n);
    dp[0] = 0;
    dp[1] = abs(input[1]-input[0]);
    for(int i=2;i<n;i++)
    {
        dp[i] = min(dp[i-1]+abs(input[i]-input[i-1]),dp[i-2]+abs(input[i]-input[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

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

int main(){
	int a, b, c;
	while(cin >> a >> b >> c){
		int ret = 0;
		for(int i=0; i< c; i++){
			a *= 10;
			ret += a/b % 10;
			a %= b;
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000
using namespace std;
int N,a[2*MAXN+5];
bool seq[2*MAXN+5];
int Check(int x)
{
	for(int i=1;i<=2*N-1;i++)
		if(a[i]<=x)
			seq[i]=0;
		else
			seq[i]=1;
	if(seq[N]==seq[N-1]||seq[N]==seq[N+1])
		return seq[N];
	int l=-1,r=-1;
	int ld,rd;
	for(int i=2;i<=N;i++)
		if(seq[i]==seq[i-1])
			l=seq[i],ld=N-i+1;
	for(int i=N;i<2*N-1;i++)
		if(seq[i]==seq[i+1])
		{
			r=seq[i];
			rd=i-N+1;
			break;
		}
	if((l==0&&r==-1)||(l==-1&&r==0)||(l==0&&r==0))
		return 0;
	if((l==1&&r==0&&ld>rd)||(l==0&&r==1&&ld<rd))
		return 0;
	if(l==-1&&r==-1&&seq[1]==0)
		return 0;
	return 1;
}
int main()
{
//	freopen("mid.in","r",stdin);
//	freopen("mid.out","w",stdout);
	scanf("%d",&N);
	for(int i=1;i<=2*N-1;i++)
		scanf("%d",&a[i]);
	int L=0,R=2*N;
	while(L<R)
	{
		int mid=(L+R)/2;
		if(Check(mid)==0)
			R=mid;
		else
			L=mid+1;
	}
	printf("%d\n",R);
	return 0;
}

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


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a.at(i);
	ll dp=1000;
	
	rep(i,n-1){
      if(a.at(i) <= a.at(i+1)){
		dp = (dp/a.at(i)) * a.at(i+1)+dp%a.at(i);
      }
	}
	cout << dp << endl;
}


Measured memory_bytes: 3540
import sys

stdin = sys.stdin

sn = lambda : stdin.readline().rstrip()
an = lambda : map(int, stdin.readline().split())
ni = lambda : int(sn())

def f(n):
  return n*(n+1)//2

x = 0
y = 0

n, k = an()
a = list(an())

mod = int(1e9)+7
ans = 0

for i, ai in enumerate(a):
  for j in range(i+1, n):
    if ai > a[j]:
      x += 1
  
  for j in range(i+1):
    if ai > a[j]:
      y += 1

ans += x * f(k)
ans += y * f(k - 1)
print(ans % mod)

Measured memory_bytes: 3188
data = []
try:
    while True:
        data.append(raw_input())

except EOFError:
    pass

n = int(data[0])
if n <= 1000:
    for i in range(1, n+1):
        x, y, z = data[i].split()
        x, y, z = int(x), int(y), int(z)
        if x <= 1000 and y <= 1000 and z <= 1000:
            if (z * 0.8 == x and z * 0.6 == y
                or z * 0.8 == y and z * 0.6 == x
                or y * 0.8 == x and y * 0.6 == z
                or y * 0.8 == z and y * 0.6 == x
                or x * 0.8 == z and x * 0.6 == y
                or x * 0.8 == y and x * 0.6 == z):
                print "YES"
            else:
                print "NO"

Measured memory_bytes: 4296
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
constexpr long double eps = 1e-9;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int k, a, b;
	scanf("%d%d%d", &k, &a, &b);
	for (int i = a; i <= b; ++i) {
		if (i % k == 0) {
			puts("OK");
			return 0;
		}
	}
	puts("NG");

	Please AC;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}

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

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

int w,h;
int M[55][55];

void dfs(int y,int x)
{
    M[y][x]=0;
    REP(i,8){
        int ny=y+dy[i],nx=x+dx[i];
        if(0<=ny && ny<h && 0<=nx && nx<w && M[ny][nx]) dfs(ny,nx);
    }
}   

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

    while(cin>>w>>h,w|h)
    {
        REP(i,h) REP(j,w) cin>>M[i][j];

        int cnt=0;
        REP(i,h) REP(j,w){
            if(M[i][j]){
                cnt++;
                dfs(i,j);
            }
        }
        cout<<cnt<<endl;
    }
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    vll a(n);
    REP(i, n) a[i] = int(s[i] - '0');
    reverse(ALL(a));
    if (p == 2 || p == 5) {
        ll res = 0;
        REP(i, n) {
            if (a[i] % p == 0) res += n - i;
        }
        cout << res << endl;
        return 0;
    }
    vll v(n + 1);
    ll d = 1;
    map<ll, ll> mp;
    mp[0] = 1;
    ll res = 0;
    REP(i, n) {
        v[i + 1] = v[i] + d * a[i];
        v[i + 1] %= p;
        res += mp[v[i + 1]];
        mp[v[i + 1]]++;
        d *= 10;
        d %= p;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4244
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n;
    cin >> n;
    vector<ll> p(n);
    vector<ll> q(n);

    rep(i,n){
        cin >> p[i];
    }
    rep(i,n){
        cin >> q[i];
    }

    vector<ll> tmp(n);
    rep(i,n){
        tmp[i] = i+1;
    }

    ll count = 0;
    ll p_ans = 0;
    ll q_ans = 0;
    
    do{
        count++;
        ll p_flag = 0;
        ll q_flag = 0;
        for(ll i = 0; i < n; i++){
            //cout << tmp[i] << " ";
            if(tmp[i] == p[p_flag]){
                p_flag ++;
            }
            if(tmp[i] == q[q_flag]){
                q_flag ++;
            }
        }

        if(p_flag == n){
            p_ans = count;
        }
        if(q_flag == n){
            q_ans = count;
        }
        //cout << endl;
    }while(next_permutation(tmp.begin(), tmp.end()));

    cout << abs(p_ans - q_ans) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[5];
	cin>>s;
	int i;
	int flag=0;
	for(i=0;i<4;i++)
	{
		for(int j=i+1;j<4;j++)
		    if(s[i]==s[j])
		    {
		    	flag++;
 		    }
	}
	if(flag==2)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

struct Node
{
  int parent, l_child, r_child;
};

Node Point[26];


void Preorder(int root){
  if(root == -1) return;
  cout << " " << root;
  Preorder(Point[root].l_child);
  Preorder(Point[root].r_child);
}

void Inorder(int root){
  if(root == -1) return;
  Inorder(Point[root].l_child);
  cout << " " << root;
  Inorder(Point[root].r_child);
}

void Postorder(int root){
  if(root == -1) return;
  Postorder(Point[root].l_child);
  Postorder(Point[root].r_child);
  cout << " " << root;  
}



int main(){
  int n, node, l, r, root;
  cin >> n;
  rep(i,n) Point[i].parent = Point[i].l_child = Point[i].r_child = -1;
  rep(i,n){
    cin >> node >> l >> r;
    Point[node].l_child = l;
    Point[node].r_child = r;
    if(l != -1) Point[l].parent = node;
    if(r != -1) Point[r].parent = node;
  }
  rep(i,n) if(Point[i].parent == -1) root = i;
  //Preorder
  cout << "Preorder" << endl;
  Preorder(root);
  cout << endl;
  //Inorder
  cout << "Inorder" << endl;
  Inorder(root);
  cout << endl;
  //Postorder
  cout << "Postorder" << endl;
  Postorder(root);
  cout << endl;

return 0;
}


Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    static List<int>[] v;
    static long[] ct;
    static bool[] visited;

    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0], q = tmp[1];

	v = new List<int>[n];
	for (int i = 0; i < n; i++)
	{
	    v[i] = new List<int>();
	}

	for (int i = 0; i < n-1; i++)
	{
	    tmp = ReadIntArray();
	    int a = tmp[0], b = tmp[1];
	    v[a-1].Add(b-1);
	    v[b-1].Add(a-1);
	}

	ct = new long[n];
	for (int i = 0; i < q; i++)
	{
	    tmp = ReadIntArray();
	    int p = tmp[0], x = tmp[1];
	    ct[p-1] += x;
	}

	visited = new bool[n];
	dfs(0, 0);

	for (int i = 0; i < n-1; i++){ Write($"{ct[i]} "); }
	WriteLine(ct[n-1]);
    }

    static void dfs(int node, long x)
    {
	if (visited[node]){ return; }
	visited[node] = true;
	
	long y = ct[node] + x;
	ct[node] = y;
	foreach (int m in v[node])
	{
	    dfs(m, y);
	}
    }
}


Measured memory_bytes: 65360
while True:
    R0, W0, C, R = map(int, input().split())
    if R0 == W0 == C == R == 0:
        break
    X = 0
    while True:
        if R0 + X * R - C * W0 >= 0:
            print(X)
            break
        else:
            X += 1

Measured memory_bytes: 7628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/*Atcoder用
 * 		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int a = Integer.parseInt(tmp[0]);
		int b = Integer.parseInt(tmp[1]);
		int c = Integer.parseInt(tmp[2]);


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String get = br.readLine();
		char[] s = get.toCharArray();
		for(char c:s)System.out.println(c);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp = br.readLine().split(" ");
		for (int n = 0; n < N; n++) {
			ls.add(Integer.parseInt(tmp[n]));
		}
 */

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int N = Integer.parseInt(tmp[0]);
		int Q = Integer.parseInt(tmp[1]);
		String S = br.readLine();

		List<Integer> l = new ArrayList<Integer>();
		List<Integer> r = new ArrayList<Integer>();


		for (int n = 0; n < Q; n++) {
			tmp = br.readLine().split(" ");
			l.add(Integer.parseInt(tmp[0])-1);
			r.add(Integer.parseInt(tmp[1])-1);
		}

		List<Integer> als = new ArrayList<Integer>();

		int acCount = 0;
		boolean isA = false;
		for(int i = 0;i<N;i++){
			if(S.charAt(i) == 'A'){
				isA = true;
				als.add(acCount);
			}
			else if(S.charAt(i) == 'C' && isA){
				isA = false;
				acCount++;
				als.add(acCount);
			}else{
				isA = false;
				als.add(acCount);
			}
		}

		for(int i = 0;i<l.size();i++){
			int ans = 0;
			int nowL = l.get(i);
			int nowR = r.get(i);

			System.out.println(als.get(nowR) - als.get(nowL));
		}


	}
}

Measured memory_bytes: 65004
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;
// char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
void swap(int* a,int* b){
    int temp = *a;
    *a=*b;
    *b=temp;
}
int32_t main(){
 	fastIO;
 	int x,y,z;cin>>x>>y>>z;
 	swap(&x,&y);
 	swap(&x,&z);
 	cout<<x<<" "<<y<<" "<<z<<endl;
} 	

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          int num1 = sc.nextInt();
          int num2 = sc.nextInt();
          int num3 = sc.nextInt();
          if(num1 + num2 == num3 || num2 + num3 == num1|| num3 + num1 == num2){
            System.out.println("Yes");
          } else {
            System.out.println("No");
          }
        }
    }

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c[3][3];
    rep(i,0,3){
        rep(j,0,3){
            cin >> c[i][j];
        }
    }
    cout << c[0][0] << c[1][1] << c[2][2] << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

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


        while(true) {
        	int n = sc.nextInt();
        	if(n == 0) {
        		break;
        	}

        	int[] s = new int[n];
        	int sum = 0;
        	for(int i = 0; i < n; i++) {
        		s[i] = sc.nextInt();
        		sum += s[i];
        	}

        	double m = sum / (double) n;
        	double a = 0.0;
        	for(int i = 0; i < n; i++) {
                a += (s[i] - m)*(s[i] - m);
            }
        	a = a/(double)n;
        	System.out.println(Math.sqrt(a));
        }
    }
}


Measured memory_bytes: 31424
def main():
    n=int(input())
    s=input()
    S=[int(x) for x in list(s)]
    Pass1={S[0],S[1],S[2]}
    Pass2={S[0]*10+S[1],S[0]*10+S[2],S[1]*10+S[2]}
    Pass3={S[0]*100+S[1]*10+S[2]}
    for k in S[3:]:
        for i in Pass2:
            Pass3.add(i*10+k)
        for i in Pass1:
            Pass2.add(i*10+k)
        Pass1.add(k)
    print(len(Pass3))
    
if __name__=='__main__':
    main()

Measured memory_bytes: 42736
program majority_of_balls
  implicit none
  integer :: n, d, l, r, m, i, j
  character(1) :: f, t
  character(200) :: c = ''
  read(*,*) n
  d = 2 * n
  l = 1
  r = n + 1
  write(*,'(a)',advance='no') '?'
  do i = 1, n
    write(*,'(x,i0)',advance='no') i
  end do
  write(*,*)
  read(*,*) f
  do while (r - l > 1)
    m = (l + r) / 2
    write(*,'(a)',advance='no') '?'
    do i = 1, n
      write(*,'(x,i0)',advance='no') m + i - 1
    end do
    write(*,*)
    read(*,*) t
    if (t == f) then
      l = m
    else
      r = m
    end if
  end do
  c(1:2) = '! '
  do i = 1, d
    if (i == l) then
      t = f
    else if (i == l + n) then
      t = merge('B', 'R', f == 'R')
    else if (l < i .and. i < l + n) then
      write(*,'(a)',advance='no') '?'
      write(*,'(x,i0)',advance='no') i
      do j = 1, n - 1
        write(*,'(x,i0)',advance='no') merge(-n + l + j, n + l + j, n + l + j > d)
      end do
      write(*,*)
      read(*,*) t
    else
      write(*,'(a)',advance='no') '?'
      write(*,'(x,i0)',advance='no') i
      do j = 1, n - 1
        write(*,'(x,i0)',advance='no') l + j
      end do
      write(*,*)
      read(*,*) t
    end if
    c(i + 2:i + 2) = t
  end do
  write(*,'(a)') trim(c)
end program majority_of_balls

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int n;
char str[100100];
int shp[100100];
char ys[2];
int main(){
	ys[0]='S';
	ys[1]='W';
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	scanf("%s",str);
	int tmp,yg;
	for(int i=0;i<4;i++){
		shp[0]=ys[i&1];
		shp[1]=ys[(i>>1)&1];
		for(int j=1;j<n-1;j++){
			tmp=str[j];
			if(shp[j]=='W')
				tmp='o'+'x'-tmp;
			if(tmp=='o')
				shp[j+1]=shp[j-1];
			else
				shp[j+1]='W'+'S'-shp[j-1];
		}
		tmp=str[n-1];
		if(shp[n-1]=='W')
			tmp='o'+'x'-tmp;
		if(tmp=='o')
			yg=shp[n-2];
		else
			yg='W'+'S'-shp[n-2];
		if(yg!=shp[0])
			continue;
		tmp=str[0];
		if(shp[0]=='W')
			tmp='o'+'x'-tmp;
		if(tmp=='o')
			yg=shp[n-1];
		else
			yg='W'+'S'-shp[n-1];
		if(yg!=shp[1])
			continue;
		for(int i=0;i<n;i++)
			cout<<(char)(shp[i]);
		cout<<endl;
		return 0;
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  cout<<x2-(y2-y1)<<' '<<y2+(x2-x1)<<' '<<x1-(y2-y1)<<' '<<y1+(x2-x1)<<endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define modulo 1000000007
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;


int main() {
	int n, a, b;
	cin >> n >> a >> b;

	cout << min(a*n,b) << endl;

	return 0;
}

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

typedef long long ll;
const int maxn=300+10;
int n,x,f[maxn][maxn][maxn],ans;
char s[maxn];

void chkmax(int&a,int b){if(a<b)a=b;}

int main(){
	cin>>(s+1)>>x;
	n=strlen(s+1);
	for(int i=0;i<=n;++i)
		for(int j=n+1;i<j;--j)
			for(int k=0;k<=x;++k){
				if(i+1<j)
					chkmax(ans,f[i][j][k]+1);
				else
					chkmax(ans,f[i][j][k]);
				if(i+1<j){
					chkmax(f[i+1][j][k],f[i][j][k]);
					chkmax(f[i][j-1][k],f[i][j][k]);
				}
				if(i+1<j-1)
					if(s[i+1]==s[j-1])
						chkmax(f[i+1][j-1][k],f[i][j][k]+2);
					else if(k<x)
						chkmax(f[i+1][j-1][k+1],f[i][j][k]+2);
			}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 112512
x = list(input())

a1 = (x[0] == x[2]) and (x[1] == x[3])
a2 = (x[0] == x[1]) and (x[2] == x[3])
a3 = (x[0] == x[3]) and (x[1] == x[2])
b = len(set(x)) == 2

if b and ( a1 or a2 or a3 ):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 8916
#include <bits/stdc++.h>
using namespace std;
int n;
int a[15];
long long sdf(int x,long long s)
{
	if(x==n)return s;
	long long b=0,s1=0;
	for(int i=x;i<n;i++)
	{
		b=b*10+a[i];
		s1=s1+sdf(i+1,s+b); 
	}
	return s1;
}
int main()
{
	char c;
	c=getchar();
	while(c<=32)
	{
		c=getchar();
	}
	while(c>32)
	{
		a[n++]=c-'0';
		c=getchar();
	}
	cout<<sdf(0,0)<<'\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string str;
cin>>str;
for(int i=  0 ;i  < 3 ; i++){
 if(str[i] == '7'){
   cout<<"Yes"<<endl;
   return 0;
 }
}
cout<<"No"<<endl;
}


Measured memory_bytes: 3660
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[j]:
        if l[k]<l[i]+l[j]:
          ans+=1
print(ans)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<(k);i++)
#define mp make_pair
#define sz(a) (int)(a).size()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef long double ld;
//----head----
char str[100005];
int main()
{
	scanf("%s",str);
	int n=strlen(str);
	int ans=(str[0]==str[n-1]);
	ans^=(n%2);
	puts(ans?"First":"Second");
	return 0;
}


Measured memory_bytes: 384