akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>
#include <unordered_set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)<(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}
/*
小数の桁数を指定する
	cout << setprecision(8)<< mp[0]-mx << endl;
*/

int main()
{
	ll i,j,k,a,b;//,ans=0;
	char c;
	ll N,M,T, X,Y;
	vector<ll> way[100100];
	queue<ll> q;
	int tm[100010] = {0};
	int ans[100010] = {0};
	int cur;
	cin>>N>>M>>T;
	--M;--T;
	for(i=0;i<N-1;++i)
	{
		cin>>j>>k;
		way[j-1].push_back(k-1);
		way[k-1].push_back(j-1);
	}
	for(i=0;i<N;++i)
	{
		tm[i] = -1;
		ans[i] = -1;
	}
	tm[T] = 0;
	q.push(T);
	while(!q.empty())
	{
		cur = q.front();
		q.pop();
		for(i=0;i<way[cur].size();++i)
		{
			if(tm[way[cur][i]] == -1)
			{
				tm[way[cur][i]] = tm[cur]+1;
				q.push(way[cur][i]);
			}
		}
	}
	// 各地点までの時間
	ans[M] = 0;
	q.push(M);
	while(!q.empty())
	{
		cur = q.front();
		q.pop();
		for(i=0;i<way[cur].size();++i)
		{
			X = way[cur][i];
			if(ans[X] == -1)
			{
				ans[X] = ans[cur]+1;
				if(ans[X] < tm[X])
					q.push(X);
			}
		}
	}
	int m_ans = 0;
	for(i=0;i<N;++i)
	{
		if (ans[i] <= tm[i] && ans[i] != -1)
		{
			ans[i] = tm[i]-1;
			if(m_ans < ans[i])
				m_ans = ans[i];
		}
	}
	cout << m_ans << endl;
	return 0;
}




















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

using namespace std;

#ifdef LOCAL_DEFINE
  #include "../../library/DEBUG.hpp"
#else
  #define debug(...) 0
#endif

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> arr(3 * n);
  vector<long long> L(3 * n, 0);
  vector<long long> R(3 * n, 0);
  priority_queue<long long> pq2;
  priority_queue<long long, vector<long long>, greater<long long>> pq1;
  long long sl = 0, sr = 0;
  for (int i = 0; i < 3 * n; i++) {
    cin >> arr[i];
    if (i < n) {
      sl += arr[i];
      L[i] = sl;
      pq1.push(arr[i]);
    }
  }
  for (int i = 3 * n - 1; i >= 2 * n; i--) {
    sr += arr[i];
    pq2.push(arr[i]);
    R[i] = sr;
  }
  for (int i = n; i <= 2 * n - 1; i++) {
    pq1.push(arr[i]);
    long long val = pq1.top();
    pq1.pop();
    sl = sl + arr[i] - val;
    L[i] = sl;
  }
  for (int i = 2 * n - 1; i >= n; i--) {
    pq2.push(arr[i]);
    long long val = pq2.top();
    pq2.pop();
    sr = sr + arr[i] - val;
    R[i] = sr;
  }
  long long ans = LLONG_MIN;
  for (int i = n - 1; i < 2 * n; i++) {
    ans = max(ans, L[i] - R[i + 1]);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 12620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

int dfs(int d,int a,int b,int c,int A,int B,int C,vector<int>l){
    if (d==0){
        if(a==A || b==B || c==C){
            return pow(10,7);
        }else{
            return abs(a)+abs(b)+abs(c)-30;
        }
    }
    int ret0=dfs(d-1,a,b,c,A,B,C,l);
    int ret1=dfs(d-1,a-l[d],b,c,A,B,C,l)+10;
    int ret2=dfs(d-1,a,b-l[d],c,A,B,C,l)+10;
    int ret3=dfs(d-1,a,b,c-l[d],A,B,C,l)+10;
    return min(min(ret0,ret1),min(ret2,ret3));
}

int main(){
    int n,A,B,C;
    cin>>n>>A>>B>>C;
    vector<int> l(n+1);
    l[0]=0;
    FOR(i,1,n+1){
        cin>>l[i];
    }
    cout<<dfs(n,A,B,C,A,B,C,l)<<endl;
}


Measured memory_bytes: 256
n,W=map(int,raw_input().split())
wv=[map(int,raw_input().split()) for _ in xrange(n)]
diff=[]
for i in xrange(n):
    diff.append(wv[i][0]-wv[0][0])
dp=[[[0]*301 for _ in xrange(n+1)] for _ in xrange(n+1)]
for i in xrange(n):
    w,v=wv[i]
    for j in xrange(i+1):
        for k in xrange(301):
            if k-diff[i]<0:
                dp[i+1][j+1][k]=dp[i][j+1][k]
            else:
                dp[i+1][j+1][k]=max(dp[i][j+1][k],dp[i][j][k-diff[i]]+v)
ans=0
for j in xrange(n+1):
    for k in xrange(301):
        if j*wv[0][0]+k<=W:
            ans=max(ans,dp[n][j][k])
print ans

Measured memory_bytes: 58012
#include<bits/stdc++.h>//¼ÇÒä»¯ËÑË÷,ÂÊÏÈ¼ÇÂ¼
using namespace std;
const int max_n=20005;
int dp[max_n];
int ans=0x3f3f3f3f;
int a[max_n];
int b[max_n];
int maxa;
int main()
{
	int h,n;cin>>h>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
		maxa=max(maxa,a[i]);
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=h;j++)//ÏÂ±ê´Ó0Ã¶¾Ùµ½h
		{
			dp[j+a[i]]=min(dp[j+a[i]],dp[j]+b[i]);
		}
	}
	for(int i=h;i<=h+maxa;i++)
	{
		ans=min(ans,dp[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
open System
open System.Collections.Generic

[<AutoOpen>]
module FastIO =
    let reader = new IO.StreamReader(new IO.BufferedStream(Console.OpenStandardInput()))
    let inline read f = reader.ReadLine() |> f
    let inline reada f = reader.ReadLine().Split() |> Array.map f
    let inline readChars() = read string |> Seq.toArray
    let inline readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let inline write (s: string) = writer.Write s
    let inline writeln (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> writeln

    let inline ioDispose() =
        reader.Dispose()
        writer.Dispose()

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

// -----------------------------------------------------------------------------------------------------
let main() =
    let n = read int
    let st = SortedDictionary<string, int>(StringComparer.OrdinalIgnoreCase)
    for i in 0 .. n - 1 do
        let s = read string
        if st.ContainsKey(s) then st.[s] <- st.[s] + 1 else st.Add(s, 1)
    let cnt = Seq.maxBy (fun (kv: KeyValuePair<string, int>) -> kv.Value) st
    for kv in st do
        if cnt.Value = kv.Value then puts kv.Key
    ()
// -----------------------------------------------------------------------------------------------------
main()
ioDispose()


Measured memory_bytes: 40544
n = int(input())
a = list(map(int, input().split()))

ave = sum(a)
for i in range(n):
    a[i] = a[i] * n

diff = float("inf")
for i in range(n):
    if abs(a[i] - ave) < diff:
        ans = i
        diff = abs(a[i] - ave)
print(ans)

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

bool p[1000000];

void prime(){
  memset(p,true,sizeof(p));
  p[0] = false;
  p[1] = false;
  for(ll i = 2; i * i < 1000000; i++){
    if(p[i]== false) continue;
    ll x = 2;
    while(i*x < 1000000){
      p[i*x] = false;
      x++;
    } 
  }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  prime();
  ll x;
  cin >> x;
  rep(i,1000000){
    if(p[i] && x <= i) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


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


int main(void) {
	long long I, O, T, J, L, S, Z;
	cin >> I >> O >> T >> J >> L >> S >> Z;

	long long ans = O;
	int n = I%2 + J%2 + L%2;
	if (n>=2 && I>0 && J>0 && L>0) {
		ans+=3;
		I--, J--, L--;
	}
	ans = ans + I/2*2 + J/2*2 + L/2*2;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import sys

n = input()

for t in range(n):
    ls = raw_input()
    ls = [map(int, list(raw_input())) for x in range(8)]

    sx, sy = input(), input()

    dx = [1,0,-1,0] + [2,0,-2,0] + [3,0,-3,0]
    dy = [0,1,0,-1] + [0,2,0,-2] + [0,3,0,-3]

    def isin(x, y): return 0 <= x < 8 and 0 <= y < 8

    class state:
        def __init__(self, x, y):
            self.x = x
            self.y = y

    stack = [state(sx-1, sy-1)]
    while len(stack):
        s = stack.pop()
        ls[s.y][s.x] = 0
        for i in range(len(dx)):
            xx = s.x + dx[i]
            yy = s.y + dy[i]
            if isin(xx, yy) and ls[yy][xx] == 1:
                stack.append(state(xx, yy))

    print "Data {}:".format(t+1)
    for raw in ls:
        for col in raw:
            sys.stdout.write(str(col))
        sys.stdout.write('\n')

Measured memory_bytes: 4344
import math
a,b = map(int, input().split())

def xorcalc(x):
	if x %2 == 0:
		y = x//2
		if y %2 == 0:
			return x
		else:
			return x+1
	else:
		y = math.ceil(x/2)
		if y%2 == 0:
			return 0
		else:
			return 1
ans = xorcalc(b) ^ xorcalc(a-1)
print (ans)

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

int digts (int n) {
    int sum =0;
    while (n>0) {
      int dig  = n%10;
      sum = sum + dig;
      n = n/10;
    }
    return sum;
  }
int main () {
  int N, A, B; cin >>N >> A >>B;
  int res = 0;
  
  for ( int i=0; i<=N; i++) {
    int ans = digts(i);
    if ( ans >= A && ans <= B) res += i;
  }
  cout << res << endl;
}

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

int main(){
    int N;
    cin >> N;
    int ans = 0;
    rep(i,N){
        int x;
        cin >> x;
        rep(j,30){
            if (x % 2 != 0){
                break;
            }
            else{
                x /= 2;
                ans++;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int i;
  int a;
  int b;
  int change;
  int x = 0;
  int y = 0;
  int z = 0;

  while(1){
    scanf("%d", &a);
    scanf("%d", &b);
    if(a == 0){
      if(b == 0){
        break;
      }
    }

    change = b - a;

    while(change >= 1000){
      change = change - 1000;
      z++;
    }
    while(change >= 500){
      change = change - 500;
      y++;
    }
    while(change >= 100){
      change = change - 100;
      x++;
    }


    printf("%d %d %d\n", x, y, z);
    x = 0;
    y = 0;
    z = 0;
    change = 0;


  }

  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <malloc.h>
int main()
{
#ifdef LOCAL
    freopen("input.txt","r", stdin);
    freopen("output.txt","w",stdout);
#endif // LOCAL
    int n=0,can[105],num,i;
    while(~scanf("%d",&num))
    {
        if(n==0)
            can[n++]=num;
        else
        {
            for(i=0;i<n;i++)
                if(num==can[i])
                    break;
            if(i==n)
                can[n++]=num;
        }
    }
    printf("%d",n);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A[100000];
	rep(i, N) A[i] = getint();
	sort(A, A + N);

	ll S = A[0];
	int kotae = 1;
	rep1(i, N - 1) {
		if (S * 2 < A[i]) kotae = 1;
		else kotae++;
		S += A[i];
	}
	co(kotae);


	Would you please return 0;
}

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

struct Node{
  int p;
  int l;
  int r;
};

struct Node T[MAX];
int n;

void preparse(int);   /* 先行順巡回 */
void inparse(int);    /* 中間順巡回 */
void postparse(int);  /* 後行順巡回 */

int main(){
  
  int i, v, l, r, root;

  scanf("%d", &n);

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

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

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

  printf("Preorder\n");
  preparse(root);
  printf("\nInorder\n");
  inparse(root);
  printf("\nPostorder\n");
  postparse(root);
  printf("\n");

  return 0;
}

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

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

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

Measured memory_bytes: 620
#include <stdio.h>

int main(void){
    int N,X,m[100];
    int i,j,sum_m,diff,tmp,cnt;
    scanf("%d",&N);
    scanf("%d",&X);
    for(i=0;i<N;i++)
    {
        scanf("%d",&m[i]);
    }
    sum_m=0;
    for(i=0;i<N;i++)
    {
        sum_m+=m[i];
    }
    for (i=0; i<N; i++) {
        for (j=i+1; j<N; j++) {
            if (m[i] > m[j]) {
                tmp =  m[i];
                m[i] = m[j];
                m[j] = tmp;
            }
        }
    }
    diff=X-sum_m;
    cnt=N;

    while(diff-m[0]>=0)
    {
            diff-=m[0];
            cnt+=1;
    }

    printf("%d",cnt);
 /*   printf("%d\n",sum_m);
    for(i=0;i<N;i++)
    {
        printf("%d",m[i]);
    }*/
    return 0;
}

Measured memory_bytes: 128
import bisect

n, m = map(int, input().split())
cities = [[] for _ in range(n)]
ans = [None] * m
idxMap = {}

for i in range(m):
    p, y = map(int, input().split())
    # bisect.insort_left(cities[p-1], y)
    cities[p-1].append(y)
    idxMap[y] = i

    # ans.append(str(p).zfill(6) + str(idx+1).zfill(6))
    # py.append(list(map(int, input().split())))

for i in range(n):
    cities[i].sort()

# print('cities:', cities)

for i in range(n):
    for j in range(len(cities[i])):
        year = cities[i][j]
        idx = idxMap[year]
        ans[idx] = str(i+1).zfill(6) + str(j+1).zfill(6)

# print(cities)
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 83360
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    int N;
    cin >> N;
    vector<LL> A(N,0);
    REP(i,N)cin>>A[i];

    LL ans = 0;
    LL pre_val = A[0];
    FOR(i,1,N){
        LL val = A[i];
        if(val < pre_val){
            ans += (pre_val-val);
        }else{
            pre_val = val;
        }
    }

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

Measured memory_bytes: 4832
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_int_tuple() -> (i32, i32) {
    let v: Vec<i32> = read_vec();
    (v[0], v[1])
}

fn main() {
    let (N, M) = read_int_tuple();
    if N >= M {
        println!("0");
        return;
    }
    let N = N as usize;
    let M = M as usize;
    let mut X: Vec<i32> = read_vec();
    X.sort();
    let mut dist = vec![0; M-1];
    for i in 0..M-1 {
        dist[i] = X[i+1] - X[i];
    }
    dist.sort();
    let ans: i32 = dist[..M-N].iter().sum();
    println!("{}", ans);
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  string s, t;
  cin >> s >> t;
  string ans = s;
  bool ok = false;
  for(int i = s.length() - 1; i >= 0; --i)
  {
    bool in = true;
    for(int j = t.length() - 1; j >= 0; --j)
    {
      if (i + j >= s.length())
      {
        in = false;
        break;
      }
      in &= (s[i + j] == t[j] || s[i + j] == '?');
    }
    if (in)
    {
      for(int j = 0; j < t.length(); ++j)
      {
        ans[i + j] = t[j];
      }
      ok = true;
      break;
    }
  }
  for(int i = 0; i < ans.length(); ++i)
  {
    if (ans[i] == '?') ans[i] = 'a';
  }
  cout << (ok ? ans : "UNRESTORABLE");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var n int
var lis = make([]int, 0, 30000)
var r = regexp.MustCompile(`[357]{1,10}`)

func dfs(s int) {
	if s == 0 {
		dfs(10*s + 3)
		dfs(10*s + 5)
		dfs(10*s + 7)
	}
	if r.MatchString(fmt.Sprintf("%d", s)) {
		if s < 1000000000 && s <= n {
			lis = append(lis, s)
			dfs(10*s + 3)
			dfs(10*s + 5)
			dfs(10*s + 7)
		}
	}
}

func main() {
	n = nextInt()
	dfs(0)

	var re int
	for _, item := range lis {
		str := strconv.Itoa(item)
		m := map[rune]int{}
		for _, item := range str {
			m[item]++
		}

		if len(m) >= 3 {
			re++
		}
	}

	fmt.Println(re)
}


Measured memory_bytes: 5376
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d})<<"\n";
}


Measured memory_bytes: 3668
#include <stdio.h>

int main(){
  int a,b;
  int c[3] = {1,2,3};
  int r = 0;
  int count = 0;
  scanf("%d %d",&a,&b);
  c[a-1] = 0;
  c[b-1] = 0;
  while(r <= 0){
    r += c[count];
    count++;
  }
  printf("%d",r);
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        int N = NextInt();
        int M = NextInt();
        int C = NextInt();
        int[] B = LineInt();
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int[] A = LineInt();
            int sum = 0;
            for (int j = 0; j < M; j++) sum += A[j] * B[j];
            if (sum + C > 0) ans++;
        }
        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

Measured memory_bytes: 13396
#include<stdio.h>
int a[300000];
int n;
int main(void){
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    if(n==1){
        printf("%d\n",a[0]);
        return 0;
    }
    for(i=n-1;i>=0;i-=2){
        printf("%d ",a[i]);
    }
    if(n%2==0){
        i=0;
    }else{
        i=1;
    }
    for(;i<n-2;i+=2){
        printf("%d ",a[i]);
    }
    printf("%d\n",a[i]);
    return 0;
}



Measured memory_bytes: 2816
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cmath>
#include <utility>
#include <map>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    int n, maxx = 0;
    cin >> n;
    map <string, int> a;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        a[s]++;
        if (a[s] > maxx)
            maxx = a[s];

    }
    for (auto it = a.begin(); it != a.end(); it++)
    {
        int t = it->second;
        if (t == maxx)
            cout << it->first << endl;
    }
    //cin.close();
    //cout.close();
    return 0;
}

Measured memory_bytes: 23808
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main() {

  string s[3];
  cin>>s[0]>>s[1]>>s[2];

  cout<<"A"<<s[1][0]<<"C"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

ll modfact(ll n){
    ll ret=1;
    while(n){
        ret*=n;
        ret%=mod;
        n--;
    }
    return ret;
}

int main(){
    ll n,m;cin>>n>>m;
    if(abs(n-m)>=2){
        cout<<0<<endl;
        return 0;
    }

    ll num = (modfact(n) * modfact(m));
    if (abs(n - m) == 1){
        cout<<num%mod<<endl;
    }else {
        cout<<(2*num)%mod<<endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include<algorithm>
#include<cstdio>
#include<functional>
#include<iostream>
#include<cfloat>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<time.h>
#include<vector>
using namespace std;
int main()
{
	int a[110],x,b;
	cin >> x;
	b=x;
	for (int i=0;i<x;i++)
	{
		cin >> a[i];
		for (int j=0;j<i;j++)
		{
			if (a[i]==a[j])
			{
				b--;
				break;
			}
		}
	}
	cout << b << endl;
	system("pause");
	return 0;
}


Measured memory_bytes: 504
def contain_nil?(matrix)
    matrix.each do |array|
        array.each {|e| return true if e == nil }
    end
    return false
end

def contain_one_nil?(array)
    count = 0
    index = nil
    array.each_with_index do |e, i|
        if e == nil
            count += 1 if e == nil
            index = i
        end
    end
    index if count == 1
end

def solveArray(array)
    sum = array.last * 2
    array.each do |e|
        sum -= e if e != nil
    end
    sum
end

def solve(pp, ss, matrix)
    while contain_nil?(matrix) do
        flag = false
        # row
        (0..(pp-1)).each do |i|
            array = matrix[i]
            index = contain_one_nil?(array)
            if index
                array[index] = solveArray(array)
                flag = true
                break
            end
        end
        
        # column
        (0..(ss-1)).each do |i|
            array = []
            matrix.each {|e| array << e[i]}
            index = contain_one_nil?(array)
            if index
                matrix[index][i] = solveArray(array)
                flag = true
                break
            end
        end
        
        # not solve
        return unless flag
    end
end

first_flg = true
while true do
    pp, ss = gets.split(' ').map(&:to_i)
    break if pp == 0 && ss == nil
    
    if first_flg
        first_flg = false
    else
        puts
    end
    
    base_matrix = []
    matrix = []
    (pp+1).times do
        array = gets.split(' ').map do |e|
            if e == '?'
                nil
            else
                e.to_i
            end
        end
        matrix << array
        base_matrix << array.dup
    end
    solve(pp, ss, matrix)
    if contain_nil?(matrix)
        puts 'NO'
    else
        base_matrix.each_with_index do |array, i|
            array.each_with_index do |e, j|
                puts matrix[i][j] if e == nil
            end
        end
    end
    gets
end

Measured memory_bytes: 7248
// ※※※ 解答不能 ※※※
// tonyu0氏.
// https://atcoder.jp/contests/abc150/submissions/9407718
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(LL i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(LL i = a; i >= b; i--)
LL n, m, a[100010];
LL gcd(LL a, LL b) {return b == 0 ? a : gcd(b, a % b);}
LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}

int main(){
    scanf("%lld %lld", &n, &m);
    rep(i, n) scanf("%lld", &a[i]);
    LL l = 1;
    rep(i, n){
        l = lcm(l, a[i] >> 1);
        if(l > m){
            puts("0");
            return 0;
        }
    }
    rep(i, n){
        if(l / (a[i] >> 1) % 2 == 0){
            puts("0");
            return 0;
        }
    }
    printf("%lld\n", (m / l + 1) / 2);
    return 0;
}

Measured memory_bytes: 1024
def main():
	n,k = map(str,input().split())
	# n = int(input())
	# s = str(input())
	# h = list(map(int,input().split()))
	# l = [list(map(int, input().split())) for _ in range(n)]
	# s = list(s)

	print(k+n)
	


if __name__ == '__main__':
	main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ans = 0, mxH = 0;
  for (int i = 0; i < N; i++) {
    int H;
    cin >> H;
    ans += mxH <= H;
    mxH = max(mxH, H);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main()
{
	char s[3];
	int i,j,m=0,n=0;
	for(i=0;i<3;i++)
	{
		cin>>s[i];
		if(s[i]=='A')
		m++;
		else
		n++;
	}
	if(m>0&n>0)
	cout<<"Yes";
	else
	cout<<"No";
	
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, a, b, k = list(map(int, readline().split()))
    M = 998244353

    h = (n + 1) // 2
    l = h + 1
    com = [0] * l
    com[0] = 1

    for i in range(1, l):
        t = com[i - 1] * (n + 1 - i)
        t *= pow(i, M - 2, M)
        t %= M
        com[i] = t

    ans = 0
    rng = min(k // a + 1, n + 1)

    for x in range(rng):
        res = k - a * x
        if res % b == 0:
            y = res // b
            if y > n:
                continue
            if x > h:
                x = n - x
            if y > h:
                y = n - y
            add = com[x] * com[y]
            ans += add
            ans %= M

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 55384
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  double m[2][2],ans[2],rev[2][2];
  while(cin >>m[0][0]>>m[0][1]>>ans[0]>>m[1][0]>>m[1][1]>>ans[1]){
    double det = m[0][0]*m[1][1]-m[0][1]*m[1][0];
    rev[0][0] = m[1][1]/det;
    rev[0][1] = -m[0][1]/det;
    rev[1][0] = -m[1][0]/det;
    rev[1][1] = m[0][0]/det;
    double x = ans[0]*rev[0][0]+ans[1]*rev[0][1];
    double y = ans[0]*rev[1][0]+ans[1]*rev[1][1];
    printf("%.3lf %.3lf\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < n; ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};

auto at(int bs, int i)
{
  return (bs >> i) & 1;
}

template <typename T>
auto make_vector(size_t sz, T t) {
  return std::vector<T>(sz, t);
}
template <size_t N, typename T, typename U, std::enable_if_t<
  N == 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t sz, U u) {
  return make_vector(sz, T(u));
}
template <size_t N, typename T, std::enable_if_t<
  N == 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t sz) {
  return std::vector<T>(sz);
}
template <size_t N, typename T, typename... Args, std::enable_if_t<
  N != 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t a, Args... args) {
  return make_vector(a, make_higher_vector<N - 1, T>(args...));
}
template <typename T, typename Size_t>
auto& at(T& t, Size_t i) {
  return t.at(i);
}
template <typename T, typename Size_t, typename... Args>
auto& at(T& t, Size_t i, Args... args) {
  return at(t.at(i), args...);
}

int main()
{
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  auto bsm = 1 << n;
  auto a = make_higher_vector<2, lint>(n, n);
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      std::cin >> at(a, i, j);
    }
  }
  auto whole = std::vector<lint>(bsm, 0);
  auto ans   = std::vector<lint>(bsm, 0);
  for (int bs = 0; bs < bsm; bs++)
  {
    auto& ret = ans.at(bs);
    for (int i = 0; i < n; i++)
    {
      if (!at(bs, i)) continue;
      for (int j = i + 1; j < n; j++)
      {
        if (!at(bs, j)) continue;
        ret += at(a, i, j);
      }
    }
    whole.at(bs) = ret;
    for (int cs = bs; cs > 0; cs--)
    {
      cs &= bs;
      if (cs == 0) break;
      assert((bs & cs) == cs);
      auto ds = bs ^ cs;
      cmx(ret, whole.at(cs) + ans.at(ds));
      if (cs == 0) break;
    }
  }
  std::cout << ans.at(bsm - 1) << std::endl;
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//const int mod = 1e9+7;
int r;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    quickread();
    cin >> r;
    cout << (1999-r) / 200 + 1 << endl;
    return 0;
}


Measured memory_bytes: 3688
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

class Main {
    static Scanner sc = new Scanner();

    public static void main(final String[] args) throws IOException {
        int n = sc.nextInt();
        int m = sc.nextInt();
        PriorityQueue pq = new PriorityQueue<>(Collections.reverseOrder());

        for (int i = 0; i < n; i++) {
            pq.add(sc.nextInt());
        }
        for (int i = 0; i < m; i++) {
            int first = (int) pq.poll();
            first = first/2;
            pq.add(first);
        }
        long  ans = 0;
        for (int i = 0; i < n; i++) {
          ans += (int)pq.poll();
        }
        System.out.println(ans);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
        String next() throws IOException {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
            return tokenizer.nextToken();
        }
        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 46232
#include <stdio.h>

int parent(int i){ return i / 2;}
int left(int i){ return 2 * i;}
int right(int i){ return 2 * i + 1;}

int main(){
  int h[512], size, n, i;

  scanf("%d", &size);
  for(i = 1; i <= size; ++i){
    scanf("%d", h + i);
  }

  for(i = 1; i <= size; ++i){
    printf("node %d: key = %d, ", i, h[i]);
    if(parent(i)) printf("parent key = %d, ", h[parent(i)]);
    if(left(i) <= size) printf("left key = %d, ", h[left(i)]);
    if(right(i) <= size) printf("right key = %d, ", h[right(i)]);
    puts("");
  }
  return 0;
}

Measured memory_bytes: 612
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(Solve(nk));
        /*for (int i = 1; i < 100; i++)
        {
            for (int j = 0; j < i; j++)
            {
                long res = Solve(new int[] { i, j });
                long res2 = Solve2(new int[] { i, j });
                if(res != res2)
                {
                    Console.WriteLine($"{i} {j} {res} {res2}");
                }
            }
        }*/
    }
    static long Solve2(int[] nk)
    {
        long res = 0;
        for (int i = 1; i <= nk[0]; i++)
        {
            for (int j = 1; j <= nk[0]; j++)
            {
                if ((i % j) >= nk[1])
                {
                    res++;
                    //Console.WriteLine($"{i}{j}");
                }
            }
        }
        return res;
    }
    static long Solve(int[] nk)
    {
        //bはk+1以上。
        //aはb*n+k以上
        long res = 0;
        for (int b = nk[1] + 1; b <= nk[0]; b++)
        {
            int diff = b - nk[1];
            //完全なセクション
            int add = diff * (nk[0] / b);
            //ラストセクション
            if (nk[1] == 0)
            {
                add += Math.Max(0, (nk[0] % b - nk[1]));
            }
            else
            {
                add += Math.Max(0, (nk[0] % b - nk[1] + 1));
            }
            res += add;
        }
        return res;
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
const int INF = (1<<29); 
using namespace std;
int V, d[15][15],dp[1 << 15][15];
int rec(int S, int v) {
	if (dp[S][v] >= 0)return dp[S][v];
	if (S == (1 << V) - 1 && v == 0)return dp[S][v] = 0;
	int res = INF;
	rep(u, V) {
		if (!(S >> u & 1))res = min(res, rec(S | 1 << u, u) + d[v][u]);
	}
	return dp[S][v] = res;
}
int main() {
	int E; cin >> V >>E;
	memset(d, 0x3f, sizeof(d));
	memset(dp, -1, sizeof(dp));
	rep(i, E) {
		int s, t, c; cin >> s >> t >>c;
		d[s][t] = c;
	}
	int ans = rec(0, 0);
	printf("%d\n", ans == INF ? -1 : ans);
}


Measured memory_bytes: 5140
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> s;
  map<int,int> t;
  for(int i=0; i<M; i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    if(a == 0){
      s.push_back(b);
    }
    if(b == N-1){
      t[a]++;
    }
  }
  for(auto m: s){
    if(t.count(m)){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


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

int main(){
  int N,value[50],cost[50],total=0;
  cin>>N;
  for(int i=0;i<N;i++)cin>>value[i];
  for(int i=0;i<N;i++)cin>>cost[i];
  for(int i=0;i<N;i++)if(value[i]>cost[i])total+=value[i]-cost[i];

  cout<<total;
}


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

using namespace std;
using lint = long long;

int main() {
    lint N, P;
    cin >> N >> P;

    for (lint i = pow(P, (double) 1 / N) + 1; i >= 1; --i) {
        if (P % (lint) pow(i, N) == 0) {
            cout << i << endl;
            return 0;
        }
    }
}


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

int h, w, n, c[10000];

int main() {
	cin >> h >> w >> n;
	for (int i = 0, j = 0, a; i < n; i++) {
		cin >> a;
		while (a--)
			c[j++] = i + 1;
	}

	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cout << c[w * i + (i & 1 ? w - 1 - j : j)]
					<< (j < w - 1 ? " " : "\n");
}


Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int X[100];
	rep(i, N) cin >> X[i];

	int saishou = 1e9;
	rep1(i, 100) {
		int tmp = 0;
		rep(j, N) {
			tmp += (X[j] - i) * (X[j] - i);
		}
		chmin(saishou, tmp);
	}
	co(saishou);


	Would you please return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#include <bits/stdc++.h>

#define int long long
#define double long double 

using namespace std;

const int INF = 1e+18;
const int MAXN = 100000;
const int LOGN = 20;
const int mod = 1e9+7;



signed main() {
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    int dp[n + 1][3];
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;
    for (int i = 1; i <= n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        dp[i][0] = a + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c + max(dp[i-1][1], dp[i-1][0]);
    }
    
    cout << max({dp[n][0], dp[n][1], dp[n][2]});
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	deque<int> b;
	for(int i = 0; i < n; ++i){
		if(i % 2 == 0){
			b.push_back(a[i]);
		}else{
			b.push_front(a[i]);
		}
	}
	if(n % 2 == 1){ reverse(b.begin(), b.end()); }
	for(int x : b){
		cout << x << " ";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 4348
#define _CRT_SECURE_NO_DEPRECATE  
#define _CRT_NONSTDC_NO_DEPRECATE

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cctype>
#include <numeric>
#include <cstring>
#include <bitset>
#include <complex>
#include <complex>

using namespace std;

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){
    //os << "{ ";
    for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); ++it)
        os << "" << *it << "" << (it + 1 == v.end() ? "" : " ");
    //os << " }";
    return os;
}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(ull i=(a); i<(ull)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair
string const resstr[] = { "Impossible", "Possible", "No", "Yes" };

int main(){
    char a, b, c;
    bool pos[] = { 1, 0, 0 };
    while (cin >> a >> c >> b){
        swap(pos[a - 'A'], pos[b - 'A']);
    }
    rep(i, 3){
        if (pos[i]){
            cout << (char)('A' + i) << endl;
            break;
        }
    }
}

Measured memory_bytes: 1180
def slove():
    import sys
    input = sys.stdin.readline
    abc = list(map(int, input().rstrip('\n').split()))
    abc.sort()
    if sum(abc[:2]) == abc[-1] or abc[0] == sum(abc[1:]):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include<iostream>

using namespace std;

int main(){
	int N, S;

	cin >> N;

	S = 0;

	int N_copy = N;

	while(N_copy){
		S += N_copy%10;
		N_copy = N_copy/10;
	}

	if(!(N%S))	cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 256
N = int(input())

current = [0, 0]
time  = 0
is_valid = True

for _ in range(N):
    t, x, y = map(int, input().split())
    distance = t - time - (abs(current[0] - x) + abs(current[1] - y))
    if distance < 0 or distance % 2 != 0:
        is_valid = False
        break
    else:
        current = [x, y]
        time = t

if is_valid:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

ll N;
string s;

bool solve(string ans) {
    for (ll i = 1; i <= N; i++) {
        string pre = ans.substr(i-1, 2);
        if (s[i] == 'o') {
            if (pre == "SS" || pre == "WW") ans += 'S';
            else ans += 'W';
        } else {
            if (pre == "WS" || pre == "SW") ans += 'S';
            else ans += 'W';
        }
    }

    if (ans[N] == ans[0] && ans[N+1] == ans[1]) {
        cout << ans.substr(0, N) << "\n";
        return true;
    } else return false;
}

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

    cin >> N >> s;
    s += s[0];

    if (solve("SS")) return 0;
    if (solve("SW")) return 0;
    if (solve("WS")) return 0;
    if (solve("WW")) return 0;

    cout << -1 << "\n";
}

Measured memory_bytes: 768
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)*}
    };
}

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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        v: [i32; n]
    }
    println!("{}", v.iter().map(|i| i.trailing_zeros()).min().unwrap());
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

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

		int [] list = new int [3] ;

		for (int i = 0; i < 3; i++) {
			list[i] = scan.nextInt() ;
		}

		int result = 101 ;

		for(int j = 0;j < 3; j++) {
			if (list[j] < result ) {
				result = list[j] ;
			}
		}

		for(int j = 0;j < 3; j++) {
			if (list[j] == result ) {
				list[j] = 101;
				break;
			}
		}
		int result2 = 101 ;

		for(int j = 0;j < 3; j++) {
			if (list[j] < result2 ) {
				result2 = list[j] ;
			}
		}

		for(int j = 0;j < 3; j++) {
			if (list[j] == result2 ) {
				list[j] = 101;
				break;
			}
		}

		System.out.println(result + result2);
	}
}

Measured memory_bytes: 23892
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println(a59_(sc.next(),sc.next(),sc.next()));
    }

    static String a59_(String s, String s1, String s2) {
        s = s.substring(0, 1).toUpperCase();
        s1 = s1.substring(0, 1).toUpperCase();
        s2 = s2.substring(0, 1).toUpperCase();
        return s + s1 + s2;
    }
}


Measured memory_bytes: 20948