akhauriyash/Code-Regression huggingface dataset:
n = int(input())
output = []
a_list = list(map(int,input().split()))

a_sorted = sorted(a_list)
min = a_sorted[0]
output.append(min)
max = a_sorted[n-1]
output.append(max)
sum = sum(a_sorted)
output.append(sum)
print(output[0], output[1], output[2])



Measured memory_bytes: 6592
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int NumStr(const string &str)
{
	int n = str.size();
	int sum = 0;
	for(int i=0; i<n; i++){
		if(str[i] == 'A')sum += 1;
		else if(str[i] == 'C')sum += 2;
		else if(str[i] == 'G')sum += 3;
		else if(str[i] == 'T')sum += 4;
		sum *= 4;
	}
	return sum;
}

void InsertFlag(vector<bool> &flag, const string &str)
{
	int num_str = NumStr(str);
	flag[num_str] = true;
}
void FindFlag(vector<bool> &flag, const string &str)
{
	int num_str = NumStr(str);
	if(flag[num_str] == true)cout << "yes" << endl;
	else if(flag[num_str] == false)cout << "no" << endl;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<bool> flag;
	flag.resize(16777216);
	
	for(int i=0; i<n; i++){
		string command, str;
		cin >> command >> str;
		if(command == "insert")InsertFlag(flag, str);
		else if(command == "find")FindFlag(flag, str);
	}
}

Measured memory_bytes: 3116
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  while(true){
    const int n = getInt();
    const int m = getInt();

    if(n + m == 0) break;

    vector<int> l(n);
    vector<int> ans(n + m - 1);

    REP(i,n) l[i] = getInt();

    REP(i, 1 << m) if(__builtin_popcount(i) == l[0]){
      REP(j,m) ans[j] = ((i & (1 << j)) == 0 ? 0 : 1);
      int now = l[0];
      bool ok = true;

      for(int j = 1; j < n; j++){
        now -= ans[j - 1];
        const int next = l[j] - now;
        if(next == 0){
          ans[j + m - 1] = 0;
        }else if(next == 1){
          ans[j + m - 1] = 1;
        }else{
          ok = false;
          break;
        }
        now += next;
      }

      if(!ok) continue;

      REP(j,n + m - 1) printf("%d", ans[j]);
      puts("");
      goto nextloop;
    }

    puts("Goofy");

  nextloop:;
  }
  return 0;
}

Measured memory_bytes: 1056
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
ll read(){
  ll a;
  cin>>a;
  return a;
}
int main(){
  vector<ll> one,two,three,kans,ans;
  ll x,y,z,k;
  cin>>x>>y>>z>>k;
  for(int i=0;i<x;i++) one.push_back(read());
  for(int i=0;i<y;i++) two.push_back(read());
  for(int i=0;i<z;i++) three.push_back(read());
  for(int i=0;i<x;i++){
    for(int j=0;j<y;j++) kans.push_back(one[i]+two[j]);
  }
  sort(kans.begin(),kans.end(),greater<ll>());
  for(int i=0;i<min((ll)kans.size(),k);i++){
    for(int j=0;j<z;j++) ans.push_back(kans[i]+three[j]);
  }
  sort(ans.begin(),ans.end(),greater<ll>());
  for(int i=0;i<k;i++) cout<<ans[i]<<endl;
}


Measured memory_bytes: 43000
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 配列数取得
	int liACnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &liACnt);

	// 交換回数取得
	int liCnt = 0;
	int liSame = 0;
	for (i = 1; i <= liACnt; i++) {
		int liVal;
#ifdef D_TEST
		fscanf(szpFpT, "%d", &liVal);
#else
		fscanf(stdin, "%d", &liVal);
#endif

		// 一致チェック
		if (i == liVal) {			// 一致
			if (liSame == 0) {			// １回目
				liSame++;
			}
			else {						// ２回目
				liCnt++;					// 交換
				liSame = 0;
			}
		}
		else {						// 不一致
			if (liSame == 1) {			// 前回一致あり
				liCnt++;					// 交換
				liSame = 0;
			}
		}
	}
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	if (liSame == 1) {			// 前回一致あり
		liCnt++;					// 交換
		liSame = 0;
	}

	// 結果セット
	sprintf(lc1Out, "%d\n", liCnt);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
  

int task = 1;
const int mxN = 2e5 + 1;
const ll mod=1000000007;

const ll modi = 998244353; 



void solve(){
  int n;
  cin >> n;
  set<string> s;
  for(int i =0;i<n;i++){
    string a;
    cin >> a;
    s.insert(a);
  }
  cout << s.size() << endl;
}
 
 
int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output1.txt","w",stdout);
    #endif
    // int t;cin >> t;while(t--)
        // cout << "Case #" << task << ": " ;
        solve();
        // task++;
    // }

}

Measured memory_bytes: 19148
#include <bits/stdc++.h>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
using namespace std;

signed main(){
	fast;
	int a, b, c, k;
	cin>>a>>b>>c>>k;
	
	int sm=0;
	
	if(a<=k){
		sm+=a;
		k=k-a;
	}
	
	else{
		sm=k;
		k=0;
	}
	
	if(b<=k){
		k=k-b;
	}
	else{
		k=0;
	}
	
	if(k>0){
		sm=sm-k;
	}
	
	cout<<sm;
    return 0; 
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d;
  cin>>d;
  vector<int> c(26);
  for(int i=0;i<26;i++)
    cin>>c.at(i);
  vector<vector<int>> s(d,vector<int>(26));
  for(int i=0;i<d;i++)
    for(int j=0;j<26;j++)
      cin>>s.at(i).at(j);
  vector<int> l(26,0);
  for(int i=1;i<=d;i++){
    vector<int> x(26,0);
    int m=0;
    for(int j=0;j<26;j++){
      int64_t p=s.at(i-1).at(j);
      for(int k=0;k<26;k++)
        p-=c.at(k)*(k==j?0:i-l.at(k));
      x.at(j)=p;
      if(x.at(j)>x.at(m))
        m=j;
    }
    cout<<m+1<<endl;
    l.at(m)=i;
  }
}

Measured memory_bytes: 3680
N,K=map(int,input().split())
listA=[0]*10**5
for z in range(N):
    a,b=map(int,input().split())
    listA[a-1]+=b
count=0
y=0
while count<=10**5-1:
    y+=listA[count]
    if y>=K:
        print(count+1)
        break
    else:
        count+=1


Measured memory_bytes: 5740
Q = int(input())
isPrime = [True] * 100001
for p in range(2, 100001):
    if isPrime[p]:
       for i in range(p * p, 100001, p):
           isPrime[i] = False
isPrime[1],isPrime[2] = False,True

like_2017 = [0] * 100002
for i in range(1,100001):
    if isPrime[i] and isPrime[(i+1)//2]:
        like_2017[i] = like_2017[i-1] + 1
    else:
        like_2017[i] = like_2017[i-1]
        
for i in range(Q):
    l,r = map(int,input().split())
    print(like_2017[r] - like_2017[l-1])
    


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

int main() {
  int A, B, C,D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B ;
  R = C + D ;
  if (L > R){
    cout << "Left" << endl;
  }
  else if ( L < R){
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        x: i64,
        t: i64,
    }
    println!("{}", max(0,x-t));
}


Measured memory_bytes: 2132
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    println!("{}", s.chars().skip_while(|&c| c == 'W').enumerate()
        .fold((0, 0), |(n, mut state), (i, c)|
              if c == 'B' { (n, state) }
              else {
                  state += i - n;
                  (n + 1, state)
              }
        ).1
    )
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxn = 400005;

int ehead[maxn],ecnt;
struct edge {
	int u,v,next;
}edg[maxn<<1];
void add(int u,int v) {
	edg[++ecnt]=(edge){u,v,ehead[u]};
	ehead[u]=ecnt;
	edg[++ecnt]=(edge){v,u,ehead[v]};
	ehead[v]=ecnt;
}
char s[maxn];int n,low[maxn],high[maxn];LL ans;
int fa[maxn],f[maxn],g[maxn],stk[maxn],top,pos[maxn],idx;
int pre[maxn],suf[maxn],lowf[maxn],d[maxn];

void upd(int &x,int y) {x<y?x=y:0;}
void dnd(int &x,int y) {x>y?x=y:0;}
void dfs(int u) {
	low[u]=lowf[u]=1<<29;pos[++idx]=u;
	if (s[u]=='1') low[u]=lowf[u]=0;
	for (int v,j=ehead[u];j;j=edg[j].next)
	if ((v=edg[j].v)!=fa[u]) {
		fa[v]=u;dfs(v);f[u]=max(f[u],f[v]+1);
		low[u]=min(low[u],max(low[v]-1,f[v]+1));
	}
}
void solve(int u) {
	int mx1=0,mx2=0,cur;top=0;
	g[u]>mx1?(mx2=mx1,mx1=g[u]):(g[u]>mx2?mx2=g[u]:0);
	for (int v,j=ehead[u];j;j=edg[j].next)
		if ((v=edg[j].v)!=fa[u]) stk[++top]=v;
	
	pre[0]=suf[top+1]=g[u];
	for (int i=1;i<=top;i++) pre[i]=max(pre[i-1],f[stk[i]]+1);
	for (int i=top;i>=1;i--) suf[i]=max(suf[i+1],f[stk[i]]+1);
	for (int i=1;i<=top;i++) d[i]=max(pre[i-1],suf[i+1]);
	cur=lowf[u];
	for (int i=1;i<=top;i++) {
		int v=stk[i],res=f[v]+1,dis=d[i];
		int w=max(f[v]+1,low[v]-1);
		res>mx1?(mx2=mx1,mx1=res):(res>mx2?mx2=res:0);
		upd(g[v],dis+1);
		dnd(lowf[v],max(cur-1,dis+1));
		dnd(cur,w);
	}
	
	cur=lowf[u];
	for (int i=top;i>=1;i--) {
		int v=stk[i],dis=d[i];
		int w=max(f[v]+1,low[v]-1);
		dnd(lowf[v],max(cur-1,dis+1));
		dnd(cur,w);
	}
	low[u]=min(low[u],lowf[u]);
	high[u]=min(mx1-1,mx2+1);
}
int main()
{
	#ifdef Amberframe
		freopen("agc008f.in","r",stdin);
		freopen("agc008f.out","w",stdout);
	#endif
	scanf("%d",&n);
	for (int u,v,i=1;i<n;i++)
		scanf("%d %d",&u,&v),add(u,v);
	scanf("%s",s+1);dfs(1);
	for (int i=1;i<=n;i++) solve(pos[i]);
	for (int i=1;i<=n;i++)
		ans+=max(0,high[i]-low[i]+1);
	printf("%lld",ans+1);
	return 0;
}

Measured memory_bytes: 29184
import sys
sys.setrecursionlimit(pow(10, 6))

d, g = map(int, input().split())
pc = []
for _ in range(d):
  pc.append(tuple(map(int, input().split())))

def dfs(i, ll):
  if i != d:
    solve = dfs(i+1, ll + [1])
    nsolve = dfs(i+1, ll + [0])
    return min(solve, nsolve)
  else:
    total = sum((100 * (j + 1) * p + c) * l for j, ((p, c), l) in enumerate(zip(pc, ll)))
    if total >= g:
      return sum(p * l for (p, _), l in zip(pc, ll))
    else:
      rem = g - total
      remc = pow(10, 6)
      for j, ((p, c), l) in reversed(tuple(enumerate(zip(pc, ll)))):
        if l == 0:
          if rem > 100 * (j + 1) * (p - 1):
            break
          else:
            remc = rem // (100 * (j + 1)) + (1 if rem % (100 * (j + 1)) else 0)
            break
      return sum(p * l for (p, _), l in zip(pc, ll)) + remc

print(dfs(0, []))


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

typedef long long ll;

using namespace std;

string s;
ll a[200005], cnt, ans;

int main()
{
    cin >> s;
    int now = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'A') a[++now] = 1;
        else if (s[i] == 'B' && s[i + 1] == 'C')
        {
            a[++now] = 2;
            i++;
        }
        else
        {
            cnt = 0;
            for (int j = 1; j <= now; j++)
            {
                if (a[j] == 2) ans += cnt;
                else cnt++;
            }
            now = 0;
        }
    }
    cnt = 0;
    for (int j = 1; j <= now; j++)
    {
        if (a[j] == 2) ans += cnt;
        else cnt++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2180
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        aa: [i64; n],
    }
    let mut x = 0;
    let mut ans = 1 << 32;
    let sum: i64 = aa.iter().sum();
    for i in 0..n-1 {
        x += aa[i];
        ans = min(ans, (sum-2*x).abs() as i64);
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
// abc129_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  ll sum = 0, right, left, ans = inf, now;
  cin>>n;
  vector<int> w(n);
  rep(i, n) {
    cin >> w.at(i);
    sum += w.at(i);
  }
  right = sum, left = 0;

  rep(i, n) {
    now = abs(right - left);
    ans = min(ans, now);
    right -= w.at(i);
    left += w.at(i);
  }

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


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <cstdio>
using namespace std;
int main()
{
    char s[110];
    scanf("%s",s);
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
         printf("Yes\n");
    else
         printf("No\n");
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

        ////if (str == "keyence") {
        //    System.out.println(str.substring(0,3));
        //    System.out.println(str.substring(8,str.length()));
        //    //System.out.println(str);
        ////}

        for (int i = 0; i <= str.length(); i++) {
            for (int j = i; j <= str.length(); j++) {
                //System.out.println(str.substring(0, i) + str.substring(j, str.length()));
                if ((str.substring(0, i) + str.substring(j, str.length())).equals("keyence")) {
                    System.out.println("YES");
                    System.exit(0);
                }
            }
        }
        System.out.println("NO");
    }
}


Measured memory_bytes: 23892
// Problem : B - ... (Triple Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<a": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int k;
        cin >> k;
        string s;
        cin >> s;
        int n=s.size();
        if(n<=k){
        	cout << s << '\n';
        }
        else{
        	string x=s.substr(0,k);
        	x+="...";
        	cout << x;
        }
        
        
        
        
        

}

Measured memory_bytes: 3652
n, W = map(int, input().split())
w, v = [[0]*n for i in range(2)]
for i in range(n):
  v[i], w[i] = map(int, input().split())

dp = [[0] * (W+1) for i in range(n+1)]


for i in range(n):
  for j in range(W+1):
        if j>=w[i]:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i], dp[i+1][j-w[i]]+v[i])
        else:
            dp[i+1][j] = dp[i][j]

print(max(dp[n]))


Measured memory_bytes: 15684
#include <iostream>
#include <utility>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1000000007;

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll res = max(a * c, a * d);
    res = max(res, b * c);
    res = max(res, b * d);
    cout << res << endl;
}


Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll dp[100005];

int main()
{jizz
	ll n,w,a,b;
	cin >> n >> w;
	while(n--)
	{
		cin >> a >> b;
		for(int i=w;i>a;--i)
			if(dp[i-a])
				dp[i]=max(dp[i],dp[i-a]+b);
		dp[a]=max(dp[a],b);
	}
	cout << *max_element(dp,dp+w+1) << "\n";
}

Measured memory_bytes: 1024
//WA
#include <stdio.h>

#define N 100001

//UnionFind木(葉より根の方が値が小さい)
typedef struct UnionFindTree{
  int parent;
  int size;
} uft;

uft t[N];

void init(int n) {
  for (int i=0; i<n; i++) {
    t[i].parent = i;
    t[i].size = 1;
  }
}

int root(int a) {
  if (t[a].parent == a) return a;
  else return root(t[a].parent);
}

void unite(int a, int b) {
  int ra=root(a), rb=root(b);
  if (ra == rb) return ;
  if (ra < rb) {
    t[rb].parent = ra;
    t[ra].size += t[rb].size;
  } else {
    t[ra].parent = rb;
    t[rb].size += t[ra].size;
  }
}

int main() {
  long n, m;
  scanf("%ld%ld", &n, &m);
  int a[m], b[m]; long ans[m+1];
  ans[m] = n*(n-1)/2;
  for (int i=0; i<m; i++) scanf("%d%d", a+i, b+i);
  init(n);
  for (int i=m-1; i>=0; i--) {
    int ra=root(a[i]-1), rb=root(b[i]-1);
    if (ra==rb) ans[i] = ans[i+1];
    else {
      ans[i] = ans[i+1]-(t[ra].size*t[rb].size);
      unite(ra, rb);
    }
  }
  for (int i=0; i<m; i++) printf("%ld\n", ans[i+1]);
  return 0;
}


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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  int x, k, d; cin >> x >> k >> d;
  x = abs(x);
  if(k <= x / d) {
    cout << x - (k * d) << endl;
    return 0;
  }
  if(d > x) {
    if(k % 2) {
      cout << d - x << endl;
    } else {
      cout << x << endl;
    }
    return 0;
  }
  int neccesarry_k = x / d;
  if(neccesarry_k % 2 == k % 2) {
    cout << x % d;
  } else {
    cout << d - (x % d);
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3632
#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<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

//gcd(0,x)=gcd(x,0)=x, gcd(0,0)=0
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

signed main(){

    int A, B; cin >> A >> B;
    int g = gcd(A, B);
    
    int ans = 1;
    FOR(i, 2, 1000001){
        int c = 0;
        while(g % i == 0){
            c++;
            g /= i;
        }
        if(c) ans++;
    }
    if(g > 1) ans++;
    Out(ans);

    return 0;
}


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

int main(){
    char a,b;
    cin>>a>>b;
    if(a==b){
        cout<<"H"<<endl;
    }
    else{
        cout<<"D"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3608
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


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

    if (B % A == 0) {
        cout << A + B << endl;
    }
    else {
        cout << B-A << endl;
    }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);

int n;
static const int INF = 1e9+7;
static const int MAX = 10;
struct edge{int to, cost;};
vector< vector<edge>> G(MAX);
int d[MAX][MAX];
void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d[s], d[s] + n, INF);
    d[s][s] = 0;
    que.push(P(0, s));

    while (!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[s][v] < p.first) continue;
        for (const auto e : G[v]){
            if (d[s][e.to] > d[s][v] + e.cost){
                d[s][e.to] = d[s][v] + e.cost;
                que.push(P(d[s][e.to], e.to));
            }
        }
    }
}
int main(){
    n = 10;
    int h, w, x;
    sc(h) sc(w)
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            sc(x)
            G[i].push_back((edge){j, x});
        }
    }
    int wall[h][w], ans = 0;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++) sc(wall[i][j])
    }
    for (int i = 0; i < n; i++) dijkstra(i);
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (wall[i][j] != -1) ans += d[wall[i][j]][1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////
int N, Q;
vector<vector<int>>G;
vector<int>res;
int r[200100];
bool visited[200100];
ll ans[200100];
ll score[200100];
void dfs(int a) {
	for (auto i : G[a]) {
		if (!visited[i]) {
			visited[i] = true;
			ans[i] = ans[a] + score[i];
			dfs(i);
		}
	}
	return;
}

int main() {
	cin >> N >> Q;
	G.resize(N);
	for (int i = 0; i <= N; ++i) {
		visited[i] = false;
		score[i] = 0;
	}
	visited[0] = true;
	r[0] = 0;
	for (int i = 0; i < N - 1; ++i) {
		int a, b; cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for (int i = 0; i < Q; ++i) {
		int p, x;
		cin >> p >> x;
		--p;
		score[p] += x;
	}
	ans[0] = score[0];
	dfs(0);
	for (int i = 0; i < N; ++i) {
		cout << ans[i] << " ";
	}
	return 0;
}


Measured memory_bytes: 23680
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int X=sc.nextInt();
        int d=X-A;
        if(0<=d&&d<=B){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}




Measured memory_bytes: 19924
#include<bits/stdc++.h>
int main()
{
	char a[3];
	int x,i;
	scanf("%s",a);
	for(i=0;i<3;i++)
	{
		if(a[i]=='o')
		{
			x+=100;
		}
	}
	printf("%d",x+700);
	return 0;
} 

Measured memory_bytes: 256
n = int(input())
d, x = map(int, input().split())
a = [int(input()) for i in range(n)]
choco = x
for i in a:
    iter = 0
    date = 1
    while date <= d:
        choco += 1
        iter += 1
        date = iter * i + 1
print(choco)


Measured memory_bytes: 2940
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd(mut a: i64, mut b: i64) -> i64 {
    while b != 0 {
        let r = a % b;
        a = b; b = r;
    }
    a
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        a: i64, b: i64, c: i64, d: i64,
    }
    let a = a - 1;
    let l = c / gcd(c, d) * d;
    let mut tot = 0;
    tot += b / c + b / d - b / l;
    tot -= a / c + a / d - a / l;
    puts!("{}\n", b - a - tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
package main
import (
        "fmt"
        "strings"
        "strconv"
)
func main() {
        var in string
        fmt.Scan(&in)
        abcd := strings.Split(in, "")
        for bits:=0; bits<(1<<uint64(4)); bits++ {
                r := 0
                res := make([]string, 4)
                for i:=0; i<4; i++ {
                        v, _ := strconv.Atoi(abcd[i])
                        if (bits>>uint64(i))&1 == 1 {
                                r += v
                                res[i]="+"
                        } else {
                                r -= v
                                res[i]="-"
                        }
                }
                if r == 7 {
                        fmt.Printf("%s%s%s%s%s%s%s=7\n", abcd[0], res[1], abcd[1], res[2], abcd[2], res[3], abcd[3])
                        break
                }
        }
}

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

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int a, b, X;
  bool find = false;
  cin >> X;
  for (a = 1; a <= 120 && !find; a++)
    for (b = -120; b <= 120 && !find; b++)
      if (a * a * a * a * a - b * b * b * b * b == X){
	cout << a << ' ' << b << '\n';
	find = true;
      }
  return 0;
}


Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

"""
https://note.nkmk.me/python-union-find/
素集合データ構造

:parameter
union(x, y): 2つの集合を一つに併合する
find(x): xがどの集合に属しているかを判定する
size(x): 要素xが属するグループのサイズ（要素数）を返す
same(x, y): 要素x, yが同じグループに属するかどうかを返す
members(x): 要素xが属するグループに属する要素をリストで返す
roots(): 全ての根の要素をリストで返す
group_count(): グループの数を返す
all_group_members(): 辞書を返す。　key = ルート要素, value = そのグループに含まれる要素のリスト
__str__(): print()での表示用。ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す
"""
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def all_group_count(self):
        return [self.size(r) for r in self.roots()]

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def solve():
    N, M = MI()
    E = []
    for i in range(M):
        a, b = MI1()
        E.append((a, b))

    ans = 0
    for a, b in E:
        uf = UnionFind(N)
        for v1, v2 in E:
            if (v1, v2) == (a, b):
                continue
            uf.union(v1, v2)
        # print(uf.group_count())
        if uf.group_count() > 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    solve()



Measured memory_bytes: 9264
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
set<string>s;
vector<string>v;
map<string,int>mp;
int main(void){
	int n;
	cin>>n;
	REP(i,n){
		string ss;
		cin>>ss;
		s.insert(ss);
		mp[ss]++;
	}
	while(!s.empty()){
		v.pb(*s.begin());
		s.erase(s.begin());
	}
	int maxn=-1;
	REP(i,v.size()){
		maxn=max(maxn,mp[v[i]]);
	}
	REP(i,v.size()){
		if(mp[v[i]]==maxn){
			cout<<v[i]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 36980
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map(String::toInt).toMutableList()
    aList.add(0, 0)
    aList.add(0, 0)
    val bukaNum = IntArray(n + 1)
    for(a in aList)bukaNum[a]++
    for (i in 1..n) {
        println(bukaNum[i])
    }
}

Measured memory_bytes: 70524
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
using vi = vector<int>; using vvi = vector<vi>;
const ll MOD = 1e9+7; ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0}; vi d4y = {0, 1, 0, -1};
//---------------------------------------

int main(){
    int x; cin>>x;
    vector<bool> box(2000003);

    for(int i=2; i<=x; i++){
        for(int j=2; i*j<=2000000; j++){
            box[i*j]=true;
        }
    }

    for(int i=x; i<=2000000; i++){
        if(box[i]==false){
            cout<<i<<endl;
            break;
        }
    }

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N;
  cin >> N;
  string S;
  cin >> S;

  vector<vector<bool>> dp(1001, vector<bool>(4, false));
  dp.at(0).at(0) = true;
  for (ll i = 0; i < N; i++)
  {
    ll x = myctoi(S.at(i));
    for (ll j = 1000; j >= 0; j--)
    {
      for (ll k = 2; k >= 0; k--)
      {
        if (!dp.at(j).at(k))
          continue;
        dp.at(j * 10 + x).at(k + 1) = true;
        //cerr << j << " " << k << endl;
      }
    }
  }

  ll ans = 0;
  for (ll i = 0; i < 1001; i++)
  {
    if (dp.at(i).at(3))
    {
      //cerr << i << endl;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  
  ll sum = 0LL;
  ll change1 = 0LL;
  ll change2 = 0LL;
  
  //初めが正の場合
  rep(i,n){
    sum += a[i];
    if(i%2==0){ //iが偶数の時。(正になる必要がある)
      if(sum <= 0){
        change1 += 1 - sum;
        sum = 1;
      }
    }else{
      if(sum >= 0){ //iが奇数の時。（負になる必要がある）
        change1 += sum + 1;
        sum = -1;
      }
    }
  }
  sum = 0;
  
  //初めが負の場合
  rep(i,n){
    sum += a[i];
    if(i%2==0){ //iが偶数の時。(負になる必要がある)
      if(sum >= 0){
        change2 += 1 + sum;
        sum = -1;
      }
    }else{
      if(sum <= 0){ //iが奇数の時。（正になる必要がある）
        change2 += 1 - sum;
        sum = 1;
      }
    }
  }  
  
  
  cout << min(change1,change2);

  return 0;
}

Measured memory_bytes: 1024
<?php
fscanf(STDIN, "%d", $N);
$j = rev($N);
$k = calc($j);
if ($N !== $k) {
    echo ':(';
} else {
    echo $j;
}

function calc($x) {
    return intval($x * 1.08);
}
function rev($x) {
    return ceil($x / 1.08);
}


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

int main(){
	int N, k = 1;
	cin >> N;
	if(!N){
		cout << 0 << endl;
		return 0;
	}
	vector<int> v;
	while(1){
		if(N % (1ll<<k) == 0){
			v.push_back(0);
		}else{
			v.push_back(1);
			if((k-1)%2 == 0){
				N -= (1ll<<k-1);
			}else{
				N += (1ll<<k-1);
			}
		}
		k++;
		if(N == 0){
			break;
		}
	}
	for(int i=0; i<v.size(); i++){
		cout << v[v.size()-i-1];
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1e9 + 7;

ll N, A[100000], B[100000], MIN[100000], aa[100000], bb[100000];
lP a[100000], b[100000];
priority_queue<lP, vector<lP>, greater<lP>>q;

int main(){
	cin >> N;
	for (int i = 0; i != N; ++i) {
		cin >> A[i];
		a[i] = mkp(A[i], i);
		MIN[i] = llmax;
	}
	for (int i = 0; i != N; ++i) {
		cin >> B[i];
		b[i] = mkp(B[i], i);
	}
	sort(a, a + N);
	sort(b, b + N);
	for (int i = 0; i != N; ++i) {
		aa[a[i].second] = i;
		bb[b[i].second] = i;
	}
	MIN[0] = 0;
	q.push(mkp(0, 0));
	while (!q.empty()) {
		int qf = q.top().first, qs = q.top().second;
		q.pop();
		if (qf == MIN[qs]) {
			for (int i = aa[qs] - 1; i != -1; --i) {
				if (qf + a[aa[qs]].first - a[i].first < MIN[a[i].second]) {
					MIN[a[i].second] = qf + a[aa[qs]].first - a[i].first;
					q.push(mkp(qf + a[aa[qs]].first - a[i].first, a[i].second));
				}
				else
					break;
			}
			for (int i = aa[qs] + 1; i != N; ++i) {
				if (qf + a[i].first - a[aa[qs]].first < MIN[a[i].second]) {
					MIN[a[i].second] = qf + a[i].first - a[aa[qs]].first;
					q.push(mkp(qf + a[i].first - a[aa[qs]].first, a[i].second));
				}
				else
					break;
			}
			for (int i = bb[qs] - 1; i != -1; --i) {
				if (qf + b[bb[qs]].first - b[i].first < MIN[b[i].second]) {
					MIN[b[i].second] = qf + b[bb[qs]].first - b[i].first;
					q.push(mkp(qf + b[bb[qs]].first - b[i].first, b[i].second));
				}
				else
					break;
			}
			for (int i = bb[qs] + 1; i != N; ++i) {
				if (qf + b[i].first - b[bb[qs]].first < MIN[b[i].second]) {
					MIN[b[i].second] = qf + b[i].first - b[bb[qs]].first;
					q.push(mkp(qf + b[i].first - b[bb[qs]].first, b[i].second));
				}
				else
					break;
			}
		}
	}
	for (int i = 0; i != N; ++i) {
		cout << MIN[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 18244
#include<stdio.h>
#include<stdlib.h>
void merge(int*,int,int,int);
void mergeSort(int*,int,int);
int cnt=0;
int main(){
  int l,m,r,n,i;
  int *A;
  scanf("%d",&n);
  A=(int *)malloc(n *sizeof(int));
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  l=0;
  r=n;
  mergeSort(A,l,r);
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d",A[i]);
    else printf("%d ",A[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  free(A);
  return 0;
}
void merge(int A[],int l,int m,int r){
  int n1=m-l;
  int n2=r-m;
  int L[n1],R[n2];
  int i;
  for(i=0;i<n1;i++)L[i]=A[l+i];
  for(i=0;i<n2;i++)R[i]=A[m+i];
  L[n1]=2000000000;
  R[n2]=2000000000;
  i=0;
  int j=0;
  for(int k=l;k<r;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i+=1;
      cnt++;
    }
    else {
      A[k]=R[j];
      j+=1;
      cnt++;
    }
  }
}
void mergeSort(int A[],int l,int r){
  if(l+1<r){
    int m=(l+r)/2;
    mergeSort(A,l,m);
    mergeSort(A,m,r);
    merge(A,l,m,r);
  }
}



Measured memory_bytes: 5184
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
#define int long long
	int n;
	cin >> n;
	vector<pair<int, int>> wow;
	vector<int> vertexs;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		vertexs.push_back(a);
		vertexs.push_back(b);
		wow.push_back(make_pair(a, b));
	}
	sort(vertexs.begin(), vertexs.end());
	long long ans = LONG_INF;
	priority_queue<pair<long long, long long>> kouho;
	REP(i, n) {
		kouho.push(make_pair(max(wow[i].first, wow[i].second), min(wow[i].first, wow[i].second)));
	}
	while (true) {
		pair<long long, long long> now = kouho.top();
		kouho.pop();
		if (now.first <= now.second) {
			pair<long long, long long> pee;
			while (kouho.empty() == false) {
				pee = kouho.top();
				kouho.pop();
			}
			ans = (vertexs[2 * n - 1] - vertexs[0]) * (now.first - pee.first);
			break;
		}else{
			kouho.push(make_pair(now.second, now.first));
		}
	}
	long long a = 0, b = LONG_INF, c = 0, d = LONG_INF;
	for (int q = 0;q < n;++q) {
		if (wow[q].first > wow[q].second) swap(wow[q].first, wow[q].second);
		a = max(a, wow[q].first);
		b = min(b, wow[q].first);
		c = max(c, wow[q].second);
		d = min(d, wow[q].second);
	}
	if (n < 16) {
		for (int i = 0;i < (1 << n);++i) {
			long long a = 0, b = LONG_INF, c = 0, d = LONG_INF;
			long long tere = i;
			for (int q = 0;q < n;++q) {
				if (tere % 2 == 1) {
					a = max(a, wow[q].second);
					b = min(b, wow[q].second);
					c = max(c, wow[q].first);
					d = min(d, wow[q].first);
				}
				else {
					a = max(a, wow[q].first);
					b = min(b, wow[q].first);
					c = max(c, wow[q].second);
					d = min(d, wow[q].second);
				}
				tere /= 2;
			}
			ans = min(ans, (d - c)*(b - a));
		}
	}
	cout << min(ans, (d - c)*(b - a)) << endl;
	return 0;
}

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

int main(void){
    char s[201],t[201];
    int n,i,h;
    
    while(1){
        scanf("%s",s);
        if(strcmp(s,"-") == 0) break;
        scanf("%d",&n);
        for(i = 0; i < n; i++){
            scanf("%d",&h);
            strcpy(t,s+h);
            strncat(t,s,h);
            strcpy(s,t);
        }
        printf("%s\n",s);
    }
}

Measured memory_bytes: 1796