akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		final int N = sc.nextInt();
		int[] x = new int[N+1];
		int[] y = new int[N+1];

		for (int i = 1; i < N + 1; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		double d = 0;
		for (int i = 1; i < N; i++) {
			for (int j = i + 1; j < N + 1; j++)
				d = d + Math.sqrt(Math.pow((double) x[i] - x[j], 2) + Math.pow((double) y[i] - y[j], 2));
		}

		System.out.println(d * 2 / N);

	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 22612
#include<iostream>
#include<math.h>
using namespace std;
int main() {
	int a, b, sum=0, mn=10000;
	cin >> a >> b;
	for (int i = b; i < a + b; i++) {
		sum += i;
		if (abs(mn) > abs(i))mn = i;
	}
	cout << sum - mn << '\n';
}

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

int main(){
  int n,k;
  int ans;
  cin >> n >> k;

    for(int i=0;i<n;i++){
      if(i==0){
        ans=k;
      }else{
        ans *= (k-1);
      }
   }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define mod 1000000007
#define pb push_back
 
typedef long long ll;

using namespace std;

int main(){
  map<char,int> cnt,temp;
  int n;
  for(char c='a'; c<='z'; c++){
    cnt[c]=0;
    temp[c]=0;
  }
  cin >> n ;
  string s,ans="";
  rep(i,n){
    cin >> s;
    if(i==0){
     rep(j,s.size())  cnt[s[j]]++;
    }else{
      for(char c='a'; c<='z'; c++)  temp[c]=0;
      rep(j,s.size()) temp[s[j]]++;
      for(char c='a'; c<='z'; c++){
        cnt[c]=min(cnt[c],temp[c]);
      }
    }
  }
  for(char c='a'; c<='z'; c++){
    if(cnt[c]>0){
      rep(i,cnt[c]) ans.push_back(c);
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define range 524289
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<ll, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;



int main(int argc, char const *argv[])
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.txt", "r", stdin);
 //    	freopen("output.txt", "w", stdout);
 //    	freopen("error.txt", "w", stderr);
	// #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;



    map<string, ll> mp;
    for(int i = 0;i<n;i++){
    	string s;
    	cin>>s;
    	sort(s.begin(), s.end());
    	if(mp.find(s)!=mp.end()){
    		mp[s]++;
    	}
    	else{
    		mp[s] = 1;
    	}
    }
    ll sum = 0;
    for (auto u : mp){
    	sum += (u.se*(u.se-1))/2;

    }
    cout<<sum<<endl;

    return 0;
}



Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
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 (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
    vector<char> c(n);
    rep(i,n) cin >> c[i];
    int cntR = 0, cntW = 0;
    rep(i,n) {
        if (c[i]=='R') cntR++;
        else cntW++;
    }
    int ans = cntR;
    rep(i,cntR) {
        if (c[i]=='R') ans--;
    }
    cout << ans << "\n";
	return 0;
}


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

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

pii d[8] = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int h, w;
  while (cin >> h >> w, h) {
    vector<string> s(h);
    for (int i = 0; i < h; i++) {
      cin >> s[i];
    }

    map<string, int> cnt;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        for (int k = 0; k < 8; k++) {
          pii now = {i, j};
          string t = "";
          do {
            t += s[now.first][now.second];
            cnt[t]++;
            now.first += d[k].first, now.second += d[k].second;
            if (now.first < 0) now.first = h - 1;
            else if (now.first >= h) now.first = 0;
            if (now.second < 0) now.second = w - 1;
            else if (now.second >= w) now.second = 0;
          } while (now != pii(i, j));
        }
      }
    }

    int szMax = 1;
    string ans = "0";
    for (auto& i : cnt) {
      if (i.second == 1) continue;
      if (i.first.size() > szMax) {
        ans = i.first;
        szMax = ans.size();
      }
    }
    cout << ans << endl;
  }

  return 0;
}


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

using LL = long long int;
using uLL = unsigned long long int;
using uint = unsigned int;
using ld = long double;


int main(){
	cin.tie(NULL);
	ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    ld x = ld(n)/3;
    cout << fixed << setprecision(10) << x*x*x << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

#define REP(i, n) for(int i = 0;i < n;i++)

using namespace std;

const int INF = 100000000;

int main(){
  int n,m;
  cin >> n >> m;

  vector< vector<int> > like(n,vector<int>(0));
  vector<int> food(m,0);

  REP(i,n){
    int k;
    cin >> k;
    int l;
    int count=0;
    while(cin >> l){
      like[i].push_back(l);
      count++;
      if (count == k) {
        break;
      }
    }
  }

  REP(i,n){
    int size = like[i].size();
    REP(j,size){
      food[like[i][j] - 1]++;
    }
  }

  int ans = 0;
  REP(i,m){
    if (food[i] == n) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
long long x,y,l;
int main()
{
    getline(cin,s);
    l=s.size();
    x=-1;
    y=-1;
    for(int i=0;i<l;i++)
    {
    	if(s[i]=='C') 
    	{
    		x=i;
    		break;
    	}
    }
    for(int i=0;i<l;i++)
    {
    	if(s[i]=='F') 
    	{
    		y=i;
    	}
    }    
    if(x!=-1 && y!=-1 && x<y) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
LR=[list(map(int,input().split())) for _ in range(M)]

ans_left,ans_right=LR[0][0],LR[0][1]

for lr in LR:
    left,right=lr[0],lr[1]
    if ans_left<left:
        ans_left=left
    if ans_right>right:
        ans_right=right

ans=ans_right-ans_left+1
if ans<=0:
    ans=0
print(ans)


Measured memory_bytes: 27332
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int sum=0;
    rep(i,n*(n-1)/2){
      int t;
      cin>>t;
      sum+=t;
    }
    cout<<sum/(n-1)<<endl;
  }
}

Measured memory_bytes: 3092
import sys
f=lambda:map(int,sys.stdin.readline().split())
n,m=f()
la=sorted(f())
ll=sorted([list(f()) for _ in range(m)],key=lambda k:-k[1])
ls=[]
t=0
for b,c in ll:
  if t+b>n:
    ls+=[c]*(n-t)
    t=n
    break
  ls+=[c]*b
  t+=b
ls.sort(reverse=1)
a=0
for i in range(n):
  if i<t: a+=max(la[i],ls[i])
  else: a+=la[i]
print(a)

Measured memory_bytes: 36856
#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;

int n;
int dp[2][101];
int ca[2][101];

int pick(int x, int y){
  if (x==1 && y == n-1) return ca[x][y];

  if (dp[x][y] != -1)return dp[x][y];

  if (x != 1)dp[x][y]=pick(x+1, y);
  if (y+1 < n)dp[x][y] = max(dp[x][y], pick(x, y+1));
  dp[x][y] += ca[x][y];
  return dp[x][y];
}

int main(int argc, char const *argv[]) {
  cin >> n;
  for (int i=0; i < n; i++) {
    dp[0][i] = -1;
    dp[1][i] = -1;
    cin >> ca[0][i];
  }

  for (int i=0; i < n; i++) {
    cin >> ca[1][i];
  }

  printf("%d\n", pick(0, 0));
  return 0;
}


Measured memory_bytes: 256
x,y = map(int, input().split())

ans = abs(abs(x)-abs(y))
if x > y and abs(x) != abs(y) and x*y > 0:
	ans+=2
elif x*y < 0 or (x>y and x==0) or (x>y and y==0):
	ans+=1

print(ans)


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  string s;
  Solver(LL n) : n(n){};

  void solve() {
    cin >> s;
    set<int> S1, S2, S3;
    for (int i = 0; i < n; ++i) {
      int d = s[i] - '0';
      for (auto x : S2) {
        S3.insert(x * 10 + d);
      }
      for (auto x : S1) {
        S2.insert(x * 10 + d);
      }
      S1.insert(d);
    }
    cout << S3.size() << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 384
import * as fs from "fs"

// 配列を作成して指定された値で初期化する
const createArray = <T>(length: number, initialValue: T): T[] => {
  const ary = []
  for (let i = 0; i < length; i++) {
    ary.push(initialValue)
  }
  return ary
}

// 配列の初期化などで使える、整数値の上限（これ同士を足してもオーバーフローしない）
const NUMBER_MAX = Math.floor(Number.MAX_SAFE_INTEGER / 2)

const process = (n: number, k: number, h: number[]): string => {
  // コストの配列を作る
  const ary = createArray(n, NUMBER_MAX)
  ary[0] = 0

  for (let i = 0; i < n; i++) {
    for (let j = 1; j <= k; j++) {
      if (i + j >= n) {
        break
      }

      const costJ = ary[i] + Math.abs(h[i] - h[i + j])
      if (ary[i + j] > costJ) {
        ary[i + j] = costJ
      }
    }
  }

  return ary[n - 1] + ""
}

const Main = (input: string): string => {
  const aa: string[][] = input.split("\n").map((e) => e.split(" "))
  const na0: number[] = aa[0].map((e) => parseInt(e))
  const na1: number[] = aa[1].map((e) => parseInt(e))
  const [n, k] = na0

  const res = process(n, k, na1) + ""
  console.log(res)
  return res
}
 Main(fs.readFileSync("/dev/stdin", "utf8"))


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

int a[2000000];
int b[2000000];
int main(){
	int n;cin>>n;
	rep(i,n)scanf("%1d",&a[i]);
	set<int>se;
	rep(i,n-1){
		b[i]=abs(a[i]-a[i+1]);
		se.insert(b[i]);
	}
	n--;
	bool flag=false;
	if(se.count(1)){
		rep(i,n)b[i]%=2;
	}
	else{
		flag=true;
		rep(i,n)b[i]/=2;
	}
	int ans=0;
	rep(i,n){
		if(n-1==(i|(n-1-i)))ans^=b[i];
	}
	if(flag)ans*=2;
	cout<<ans<<endl;
}

Measured memory_bytes: 10496
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        if(a+b+c >= 22){
            System.out.println("bust");
        }else{
            System.out.println("win");
        }
        
    }
}



Measured memory_bytes: 22868
//E - Red Scarf


#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vi arr(n);
	int val =0;
	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i];
		val ^= arr[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cout<<(val^arr[i])<<endl;
	}
	return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<int> rec(n, 0);
  for (int x = 1; x < 100; x++) {
    for (int y = 1; y < 100; y++) {
      for (int z = 1; z < 100; z++) {
        int a = x*x + y*y + z*z + x*y + y*z + z*x;
        if (a <= n) rec[a-1]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << rec[i] << endl;
  }
}


Measured memory_bytes: 3576
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;
    vector<int> color(N);
    REP(i, N) color[i] = S[i] - '0';

    int state = 1, continuous = 0, begin = 0;
    vector<int> white, black, white_begin, white_end;
    // if(color[0] == 0) black.push_back(0);
    REP(i, N) {
        if(state != color[i]) {
            if(state == 0) {
                white.push_back(continuous);
                white_begin.push_back(begin);
                white_end.push_back(i);
            } else {
                black.push_back(continuous);
            }
            state = color[i];
            continuous = 1;
            begin = i + 1;
        } else {
            continuous++;
        }
    }

    if(color[N-1] == 0) {
        white.push_back(continuous);
        black.push_back(0);
    }
    else black.push_back(continuous);


    if(white.size() == 0) {
        cout << black[0] << endl;
        return 0;
    }

    // REP(i, black.size()) {
    //     cerr << "black[" << i << "] = " << black[i] << endl;
    // }
    
    // REP(i, white.size()) {
    //     cerr << "white[" << i << "] = " << white[i] << endl;
    // }

    int ans = 0;
    REP(black_begin, black.size()) {
        int tmp = black[black_begin];
        FOR(white_idx, black_begin, min(black_begin + K, int(white.size())) - 1) {
            tmp += white[white_idx] + black[white_idx+1];
            // cerr << "black_begin = " << black_begin << " tmp = " << tmp << endl;
        }
        if(tmp > ans) ans = tmp;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1876
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    char a;
    scanf("%c",&a);
    if((a>= 'a') && (a<='z')){
        printf("a");
        return 0;
    }
    printf("A");
    return 0;
}

Measured memory_bytes: 1596
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>

int main(void){
	
	int n, i, num;
	double ave = 0, sub;
	int a[101];
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
		ave += a[i];
	}
	
	ave /= n;
	
	num = 0;
	sub = fabs(a[0]-ave);
	
	for(i = 1; i < n; i++){
		if(fabs(a[i]-ave) < sub){
			num = i;
			sub = fabs(a[i]-ave);
		}
	}
	
	printf("%d\n", num);
	
	return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

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

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

int main()
{
    IO;

    ll N; cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];

    sort(all(A));
    reverse(all(A));

    ll ans = 0;

    if (N % 2 == 0) {
        rep(i, N / 2) {
            ans += 2 * A[i];
        }
        cout << ans - A[0] << endl;
    }
    else {
        rep(i, (N+1) / 2) {
            ans += 2 * A[i];
        }
        cout << ans - A[0] - A[(N - 1) / 2] << endl;
    }

}

Measured memory_bytes: 4464
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	cout.precision(10);
	double r;
	cin >> r;
	double ans = r * 2.0 * M_PI;
	cout << ans << endl;
	return 0;
}


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

int main() {
	double a, b, c, d;
	cin >> a >> b >> c >> d;
	for(int i = 0;; i++) {
		if(a <= 0) {
			cout << "No";
			break;
		}
		if(c <= 0) {
			cout << "Yes";
			break;
		}
		c -= b;
		if(a <= 0) {
			cout << "No";
			break;
		}
		if(c <= 0) {
			cout << "Yes";
			break;
		}
		a -= d;
		if(a <= 0) {
			cout << "No";
			break;
		}
		if(c <= 0) {
			cout << "Yes";
			break;
		}
	}
}

Measured memory_bytes: 3748
N, W = list(map(int, input().split()))
v = [0 for i in range(N)]
w = [0 for i in range(N)]
for i in range(N):
    v[i], w[i] = list(map(int, input().split()))
dp = [[-1 for j in range(W + 1)] for i in range(N + 1)]

def rec(i, j):
    if dp[i][j] != -1:
        return dp[i][j]
    if i == N:
        res = 0
    elif j < w[i]:
        res = rec(i + 1, j)
    else:
        res = max(rec(i + 1, j),rec(i + 1, j - w[i]) + v[i])
    dp[i][j] = res
    return res

print(str(rec(0, W)))

Measured memory_bytes: 26128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll n;
  cin>>n;
  string s;
  cin>>s;

  ll right[n+1][27]={};
  for(int i=0;i<n;i++){
    right[i][s[i]-'a']++;
  }
  for(int i=n-1;i>=0;i--){
    for(int j=0;j<26;j++){
      right[i][j]+=right[i+1][j];
    }
  }

  ll ans=0;
  for(int i=0;i<n;i++){
    ll res=1;
    for(int j=0;j<26;j++){
      if(s[i]-'a'==j) continue;
      res=res*(right[i+1][j]+1);
      res%=MOD;
    }
    ans=(ans+res)%MOD;
  }
  cout<<(ans+MOD)%MOD<<endl;

  return 0;
}


Measured memory_bytes: 22140
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val k = in.readLine().toInt
    val Array(a, b) = in.readLine().split("\\s+").map(_.toInt)

    out.println(
      if (Math.ceil(1.0 * a / k) <= Math.floor(1.0 * b / k)) {
        "OK"
      } else {
        "NG"
      }
    )

    out.flush()
  }
}


Measured memory_bytes: 54628
n = int(input())
s = [str(input()) for i in range(n)]
m = int(input())
t = [str(input()) for i in range(m)]
used = []
for i in range(n):
    if s[i] not in used:
        used.append(str(s[i]))
for j in range(m):
    if t[j] not in used:
        used.append(str(t[j]))

ans = [0]*len(used)
for i in range(len(used)):
    for j in range(n):
        if s[j] == used[i]:
            ans[used.index(used[i])] += 1

for i in range(len(used)):
    for j in range(m):
        if t[j] == used[i]:
            ans[used.index(used[i])] -= 1
if max(ans) >= 0:
    print(max(ans))
else:
    print(0)

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

int desc(const void* a, const void *b) {
	long long *A = (long long*)a;
	long long *B = (long long*)b;
	if (*A > *B) return -1;
	if (*A < *B) return 1;
	return 0;
}

int main()
{
	int i, j, X, Y, Z, XY, T, cnt = 0;
	long long K, *A, *B, *C, *AB, *S;

	scanf("%d %d %d %lld", &X, &Y, &Z, &K);
	A = (long long*)malloc(sizeof(long long)*X);
	B = (long long*)malloc(sizeof(long long)*Y);
	C = (long long*)malloc(sizeof(long long)*Z);

	XY = X * Y;
	AB = (long long*)malloc(sizeof(long long)*XY);
	S = (long long*)malloc(sizeof(long long)*K*Z);

	for (i = 0; i < X; i++) {
		scanf("%lld", &A[i]);
	}
	for (i = 0; i < Y; i++) {
		scanf("%lld", &B[i]);
	}
	for (i = 0; i < Z; i++) {
		scanf("%lld", &C[i]);
	}

	for (i = 0; i < X; i++)
		for (j = 0; j < Y; j++) {
			AB[cnt++] = A[i] + B[j];
		}
	qsort(AB, XY, sizeof(long long), desc);

	T = (XY <= K) ? XY : K;
	for (i = 0; i < T; i++) 
		for (j = 0; j < Z; j++) {
			S[i*Z + j] = AB[i] + C[j];
		}
	qsort(S, K * Z, sizeof(long long), desc);
	for (i = 0; i < K; i++) {
		printf("%lld\n", S[i]);
	}

	return 0;
}


Measured memory_bytes: 54920
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> g(n);
	if (n % 2 == 0) {
		for (int i = 0; i < n / 2; ++i) {
			g[i] = i;
			g[n - i - 1] = i;
		}
	}
	else {
		for (int i = 0; i < n / 2; ++i) {
			g[i] = i;
			g[n - i - 2] = i;
		}
		g[n - 1] = n / 2;
	}
	vector<pair<int, int> > e;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			if (g[i] != g[j]) {
				e.push_back(make_pair(i, j));
			}
		}
	}
	cout << e.size() << endl;
	for (pair<int, int> i : e) {
		cout << i.first + 1 << ' ' << i.second + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200001)
#define MOD (1000000007)

ll d[MAXN];
int main(void)
{
    ll n;
    scanf("%ld",&n);
    for(int i=0;i<n;i++) scanf("%ld",&d[i]);

    ll ans = 0;
    for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) ans += d[i]*d[j];
    
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  cout << n * n * n << '\n';
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

# input
n = int(input())
a = list(map(int, input().split()))

d = {}
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1 

# output
for i in range(1, n+1):
    if i in d.keys():
        print(d[i])
    else:
        print(0)


Measured memory_bytes: 33528
import java.util.Scanner;

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

    int K = scanner.nextInt();
    long sum = 0;
    for (int a = 1; a <= K; a++) {
      for (int b = 1; b <= K; b++) {
        long d = gcd(a, b);
        for (int c = 1; c <= K; c++) {
          sum += gcd(d, c);
        }
      }
    }
    System.out.println(sum);
  }

  static long gcd(long i, long j) {
    if (i > j) return gcd(j, i);
    while (i > 0) {
      long r = j % i;
      j = i;
      i = r;
    }
    return j;
  }
}


Measured memory_bytes: 27368
n = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
switch = 1
ans = []

for i in range(n-1):
    if switch == 1:
        if A[i] == A[i+1]:
            ans.append(A[i])
            switch = 0
    else: 
        switch = 1

if len(ans)>=2:
    print(ans[0]*ans[1])
else:
    print(0)

Measured memory_bytes: 15020
#include<bits/stdc++.h>
#define EPS (1e-8)
#define N 100005
using namespace std;
struct data{
  int vw,pf,vf,th;
};
int n,pw;
data d[N];
double ans;

double check(double f){
  double res=f*pw;
  for(int i=0;i<n;i++){
    if(d[i].th-d[i].vw*f<=0)continue;
    res+=(d[i].th-d[i].vw*f)/d[i].vf*d[i].pf;
  }
  ans=min(ans,res);
  return res;
}

void bynary_search(){
  double l=0,r=105;
  check(0);
  while(l+EPS<r){
    double m=(l+r)/2;
    if(check(m)>check(m+EPS))l=m+EPS;
    else r=m;
  }
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    cin>>pw;
    for(int i=0;i<n;i++)
      scanf("%d%d%d%d",&d[i].vw,&d[i].pf,&d[i].vf,&d[i].th);
    ans=(1e9);
    bynary_search();
    printf("%.8f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    ll n,k; cin >> n >> k;

    ll ans = 1;

    for (int i = 0; i < n; ++i) {
        if (ans * 2 > ans + k)ans += k;
        else ans *= 2;
    }
    print(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    cout<<h2*60+m2-h1*60-m1-k;
}


Measured memory_bytes: 3640
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,k;
char t[max_n];
vector<int> v[max_n];
int w[3];
int get(char c){
    if(c=='r')return 0;
    if(c=='s')return 1;
    return 2;
}
ll solve(vector<int> v){
    if(v.size()==0)return 0;
    ll res=0;
    for(int i=0;i<v.size();i++){
        int j=i;
        while(j<v.size()&&v[j]==v[i])j++;
        res+=1ll*(j-i+1)/2*w[(v[i]+2)%3];
        i=j-1;
    }
    return res;
}
int main(){
    scanf("%d%d",&n,&k);
    for(int i=0;i<3;i++)scanf("%d",w+i);
    scanf(" %s",t);
    for(int i=0;i<n;i++)v[i%k].push_back(get(t[i]));
    ll ans=0;
    for(int i=0;i<k;i++){
        ans+=solve(v[i]);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <map>
#include <algorithm>
#include <fstream>
using namespace std;
map<int,int> ap;
int a[2*100*1000+5],del[2*100*1000+5];
int n,x,i,j,pp,ok,p;
int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("data.in","r",stdin);
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(p=30;p>=1;p--)
    {
        j=n;
        for(i=1;i<=n;i++)
      {
          while(j>0&&((1<<p)-a[j]<a[i]||del[j]==1))
            j--;
          if(del[j]==0&&j>0&&(1<<p)==a[j]+a[i]&&del[i]==0&&i!=j)
          {
              pp++;
              del[j]=del[i]=1;
          }
      }
    }
    cout<<pp;
    return 0;
}


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

int main() {
  int n,a,res=1;
  cin >> n >> a;
  for(int i=0;i<n;i++){
    if(res<a){
      res*=2;
    }else{
      res+=a;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

int h, w;
std :: string a[10015];
long long dp[1005][1005]{};
long long mod = 1000000007;

long long rec(int r, int c) {
    if(r >= h || c >= w) return 0;
    if(a[r][c] == '#') return 0;
    if(dp[r][c] > -1) return dp[r][c] % mod;
    dp[r][c] = rec(r + 1, c) + rec(r, c + 1);
    return dp[r][c] % mod;
}

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

    std :: cin >> h >> w;

    memset(dp, -1, sizeof(dp));

    for(int i = 0 ; i < h ; i++) std :: cin >> a[i];

    dp[h - 1][w - 1] = 1;
    std :: cout << rec(0, 0) << '\n';
}

Measured memory_bytes: 12884
import java.io.PrintWriter;
import java.util.*;

public class Main {
	static class SegmentTree {
		int N;
		int[] v;
		public SegmentTree(int M) {
			N=1;
			while(M>N) {
				N<<=1;
			}
			v = new int[N*2];
		}
		public void add(int l, int r, int x) {
			add(l, r, 0, N, x, 1);
		}
		public void add(int l, int r, int a, int b, int x, int idx) {
			if(r<=a || b<=l) {
				;
			} else if(l<=a && b<=r) {
				v[idx] += x;
			} else {
				int mid = (a+b)/2;
				add(l, r, a, mid, x, idx*2);
				add(l, r, mid, b, x, idx*2+1);
			}
		}
		
		public int get(int p) {
			p += N;
			int ans = 0;
			while(p>=1) {
				ans += v[p];
				p>>=1;
			}
			return ans;
		}
		
	}
	
	static class Segment {
		int l,r;
		int length;
		public Segment(int l, int r) {
			this.l = l;
			this.r = r;
			length = r-l+1;
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		int N = sc.nextInt();
		int M = sc.nextInt();
		Segment[] segments = new Segment[N];
		for(int i=0; i<N; i++)
			segments[i] = new Segment(sc.nextInt(), sc.nextInt());

		Arrays.sort(segments, new Comparator<Segment>() {
			public int compare(Segment s1, Segment s2) {
				return Integer.compare(s1.length, s2.length);
			}
		});
		
		SegmentTree st = new SegmentTree(M+1);
		
		int idx = 0;
		for(int i=1; i<=M; i++) {
			while(idx<N && segments[idx].length<i) {
				st.add(segments[idx].l, segments[idx].r+1, 1);
				idx++;
			}
			int ans = N-idx;
			for(int j=i; j<=M; j+=i)
				ans += st.get(j);
			pw.println(ans);
		}
		
		sc.close();
		pw.close();
	}
}


Measured memory_bytes: 148980
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef pair<int,lld> pil;
typedef pair<lld,int> pli;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};
int vis[222222],sz[222222];
int find(int x){
	if(x!=vis[x]) return vis[x] = find(vis[x]);
	return x;
}
int main(void){
	for(int e=0;e<222222;e++) {
		vis[e] = e;
		sz[e] = 1;
	}
	int n,m;
	scanf("%d%d",&n,&m);
	for(int e=0;e<m;e++){
		int a,b;
		scanf("%d%d",&a,&b);
		a = find(a);
		b = find(b);
		if(a!=b){
			vis[b] = a;
			sz[a] += sz[b];
			sz[b] = 0;
		}
	}
	int mm =0 ;
	for(int e=1;e<=n;e++) mm = max(mm,sz[e]);
	printf("%d\n",mm);
	return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 85;

int dp[N][N][16000];
int a[N][N], b[N][N];
int n, m;
int ans;

void go(int x, int y, int diff) {
  if(x == n and y == m)  {
    ans = min(ans, abs(diff + (a[x][y] - b[x][y])));
    ans = min(ans, abs(diff - (a[x][y] - b[x][y])));
    return;
  }
  if(x > n + 1 or y > m + 1) return;
  if(dp[x][y][diff] != -1) return;
  dp[x][y][diff] = 1;
  int ans = 0;
  go(x + 1, y, abs(diff + (a[x][y] - b[x][y])));
  go(x + 1, y, abs(diff - (a[x][y] - b[x][y])));
  go(x, y + 1, abs(diff + (a[x][y] - b[x][y])));
  go(x, y + 1, abs(diff - (a[x][y] - b[x][y])));
}

int main() {
  memset(dp, -1, sizeof dp);
  cin >> n >> m;
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= m; j++) {
      cin >> b[i][j];
    }
  }
  ans = 1e9;
  go(1, 1, 0);
  cout << ans << '\n';
}

Measured memory_bytes: 451840
#include <iostream>
#include <string>

int main(){
  int K = 0, len;
  std::string str;
  
  std::cin>>K;
  std::cin>>str;
  
  len = str.length();
  
  if(len > K){
    str.replace(K, len - K, "...");
  }
  
  std::cout<<str;
  
  return 0;
}

Measured memory_bytes: 3636
n = int(input())
x = list(map(int, input().split()))

y = sorted(x)
mid1 = y[(n + 1) // 2]
mid2 = y[(n - 1) // 2]

for i in range(n):
    if mid1 == mid2:
        ans = mid1
    elif x[i] >= mid1:
        ans = mid2
    elif x[i] <= mid2:
        ans = mid1

    print(ans)


Measured memory_bytes: 26772
#include <stdio.h>

int const M = 998244353;
int i, n, x, c[7 << 14];

int pow(int a, int b) {
  long long r = 1;
  for(; b; b >>= 1) {
    if(b & 1)
      r = r * a % M;
    a = (long long)a * a % M;
  }
  return r;
}  

int main() {
  scanf("%d%d", &n, &x);
  int r = 0;
  if(x == 0) {
    for(i = 1; i < n; c[x]++, i++) scanf("%d", &x);
    if(c[0] == 0) {
      c[0] = r = 1;
      for(i = 1; c[i]; i++) {
        n -= c[i];
        r = (long long) r * pow(c[i - 1], c[i]) % M;
      }
    }
  }
  printf("%d\n", n > 1 ? 0 : r);
  return 0;
}


Measured memory_bytes: 512
def Solve(c,s):
    if s:
        if max(c)>4:return False
        for i in range(9):
            if c[i]>=2:
                cc=c[:]
                cc[i]-=2
                if Solve(cc,False):return True
    else:
        check=0
        for i in range(4):check+=c.count(3*i)
        if check==9:return True
        else:
            for i in range(7):
                if c[i]>=1:
                    cc=c[:]
                    isneg=False
                    for j in range(3):
                        cc[i+j]-=1
                        if cc[i+j]<0:
                            isneg=True
                            break
                    if isneg==False and Solve(cc,False):return True
_in=""
while True:
    ans=[]
    try:_in=input()
    except EOFError:break
    for i in range(9):
        l=(_in+str(i+1))[::1]
        count=[l.count(str(j+1))for j in range(9)]
        if Solve(count,True):ans.append(str(i+1))
    print(0 if len(ans)==0 else " ".join(ans))

Measured memory_bytes: 7472
#include<stdio.h>

int main(void){
	int n, a, b, c, d;
	int count = 0;

	while(scanf("%d", &n) != EOF){
		if(n <= 36){
			for(a = 0; a <= 9; a++){
				for(b = 0; b <= 9; b++){
					for(c = 0; c <= 9; c++){
						for(d = 0; d <= 9; d++){
							if((a+b+c+d) == n){
								count++;
							}
						}
					}
				}
			}
			printf("%d\n", count);
			count = 0;
		}else{
			printf("0\n");
		}
	}

	return 0;
}

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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,i,j,k;
    cin>>n;
    for(i=1;i<=9;i++)
    {
        if(n%i==0 && n/i<=9)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;

}


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

int main(){

  int n,a = 0,b = 0,o = 0,ab = 0;
  string str;
  char s;

  while(cin >> n >> s >> str){

    if(str == "A") a++;
    else if(str == "B") b++;
    else if(str == "O") o++;
    else if(str == "AB") ab++;

  }

  cout << a << endl << b << endl << ab << endl << o << endl;

}

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

const ll MX = 1e18;

int main(void){
  	int n;
  	cin >> n;
  	bool flg = false;
  	ll ans = 1;
  	rep(i, n){
    	ll a;
      	cin >> a;
        if(a == 0){
        	cout << 0;
          	return 0;
        }
      	if(flg || MX/ans < a){
        	flg = true;
        }
      	ans *= a;
    }
  	if(flg) cout << -1;
  	else cout << ans;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int H, W;
ll ans, black, white;
string S[400];
bool used[400][400];

void dfs(int h, int w, char c) {
    if (h < 0 || H <= h || w < 0 || W <= w || used[h][w] || S[h][w] == c) return;
    used[h][w] = true;
    if (S[h][w] == '.') white++;
    else black++;

    char next = '#';
    if (c == '#') next = '.';
    int dh[4] = {0, 1, 0, -1}, dw[4] = {1, 0, -1, 0};
    REP(i, 4) dfs(h + dh[i], w + dw[i], next);
}

void check(int h, int w) {
    if (S[h][w] == '.') return;
    black = 0, white = 0;
    dfs(h, w, '.');
    ans += black * white;
}

int main() {
    cin >> H >> W;
    REP(i, H) cin >> S[i];
    REP(i, H) REP(j, W) check(i, j);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15616
#include<iostream>
using namespace std;
int main(){
  int n,cou=0;
  cin>>n;
  long long a=1,b=1,c=1;
  for(int i=1;i<n;i++){
    for(int j=1;i*j<n;j++){
      if(i*j<=n)
        cou++;
    }
  }
  cout<<cou<<endl;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_029
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            var tt = new int[30] {2, 4, 8, 16, 32, 64, 128, 256, 512,
1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288,
1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912,
1073741824};
            int n = ReadInt();
            int[] array = ReadInts();
            Array.Sort(array);
            var dict = new Dictionary<int, int>();
            for(int i =0; i < n; i++)
            {
                if (!dict.ContainsKey(array[i])) dict.Add(array[i], 0);
                dict[array[i]]++;
            }
            int res = 0;
            for (int j = tt.Length - 1; j >= 0; j--)
            {
                for (int i = 0; i < n; i++)
                {
                    if (!dict.ContainsKey(array[i])) continue;

                    int v = tt[j] - array[i];
                    if (v == 0) continue;

                    if (array[i] == v)
                    {
                        if (dict[v] >= 2)
                        {
                            res++;
                            if (dict[v] == 2) dict.Remove(v);
                            else dict[v] -= 2;
                        }
                    }
                    else if (dict.ContainsKey(v))
                    {
                        res++;
                        if (dict[v] == 1) dict.Remove(v);
                        else dict[v]--;
                        if (dict[array[i]] == 1) dict.Remove(array[i]);
                        else dict[array[i]]--;
                    }
                }
            }
            Console.WriteLine(res);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 36128
n = int(input())
p = list(map(int,input().split()))

cnt = 0
for i in range(n-2):
    tmp = p[i:i+3]
    ma = max(tmp)
    mi = min(tmp)
    if(tmp[1] != ma and tmp[1] != mi):
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#[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 solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        v: [(String, i64); n],
    }
    let mut list = (0..n)
    .map(|i| (v[i].0.clone(), -v[i].1, i))
    .collect::<Vec<_>>();
    list.sort();
    for (_, _, i) in list.into_iter(){
        puts!("{}\n",i+1);
    }
    // let ans = if x<a {0} else {10};
    // puts!("{}\n", ans);
}

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