akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

int A,B;

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

	cin >> A >> B;

	cout << 100 << " " << 100 << endl;

	int cnt = 0;
	for (int i = 0;i < 50;i++){
		for (int j = 0;j < 100;j++){
			if(i%2 == 0 && j%2 == 0 && cnt < A-1){
				cout << ".";
				cnt++;
			}
			else cout << "#";
		}
		cout << endl;
	}

	cnt = 0;
	for (int i = 0;i < 50;i++){
		for (int j = 0;j < 100;j++){
			if(i%2 == 1 && j%2 == 0 && cnt < B-1){
				cout << "#";
				cnt++;
			}
			else cout << ".";
		}
		cout << endl;
	}


	return 0;

}


Measured memory_bytes: 256
a,b = map(int, input().split())
mafs = 0 
if a < 1 and b >=0:
  print("Zero")
elif a > 0 and b > 0:
  print("Positive")
elif a < 0 and b < 0:
    if (abs(a) - abs(b) + 1) % 2 == 0: print("Positive")
    else: print("Negative")

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

int main() {
  int n,m,ans=0;
  cin>>n>>m;
  ans+=n*(n-1)/2;
  ans+=m*(m-1)/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n){
	return (ceil(log2(n)) == floor(log2(n)));
}
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}

int main(){
	int a,b;scanf("%d%d",&a,&b);
	double ret=0;
	for(int i=1;i<=a;i++){
		double tmp=1.0/a;
		int now=i;
		while(now<b){
			now*=2;
			tmp *= 0.5;
		}
		ret+=tmp;
	}
	printf("%.12f\n",ret);
}









Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define pf pop_front
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=100005;
const ll inf=1e9+7;
ll dp[maxn];
vector<ll> g[maxn];
ll in[maxn];
ll n,m;
int main()
{
    while(cin>>n>>m)
    {
        memset(dp,0,sizeof(dp));
        rep(i,m)
        {
            ll a,b;
            cin>>a>>b;
            g[a].pb(b);
            //out[a]++;
            in[b]++;
        }
        queue<ll> q;
        rep1(i,n)
        {
            if(in[i]==0)
            {
                q.push(i);
                dp[i]=0;
            }
        }
        while(!q.empty())
        {
            ll v=q.front();
            q.pop();
            for(auto i:g[v])
            {
                in[i]--;
                dp[i]=max(dp[i],dp[v]+1);
                if(!in[i]) q.push(i);
            }
        }
        ll ans=0;
        rep1(i,n) ans=max(ans,dp[i]);
        cout<<ans<<"\n";
    }
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

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

int main()
{
    cout << fixed << setprecision(15);
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<ll> A(X);
    vector<ll> B(Y);
    vector<ll> C(Z);

    REP(i, X){
        cin >> A[i];
    }
    REP(i, Y){
        cin >> B[i];
    }
    REP(i, Z){
        cin >> C[i];
    }

    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    vector<ll> E(min(X, K)*min(Y, K));

    REP(i, min(X, K)){
        REP(j, min(Y, K)){
            E.push_back(A[i] + B[j]);
        }
    }

    sort(E.begin(), E.end(), greater<ll>());

    vector<ll> F(min(min(X, K)*min(Y, K), K)*min(Z, K));
    REP(i, min(min(X, K)*min(Y, K), K)){
        REP(j, min(Z, K)){
            F.push_back(E[i] + C[j]);
        }
    }

    sort(F.begin(), F.end(), greater<ll>());

    REP(i,K){
        cout << F[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 64760
var
        min,d,n,i,j,t:longint;
        a:array[1..200000] of longint;
begin
        read(n);
        for i:=1 to n do read(a[i]);
        min:=a[1];
        for i:=2 to n do if min>a[i] then min:=a[i];
        i:=1;
        t:=1;
        if min<>i then begin write(-1); exit; end else
        while j<>n do
        begin
                for j:=1 to n do
                        if a[j]<>i then begin inc(d); a[j]:=-1; end
                        else if a[j]=i then inc(i);
        end;
        if d>=0 then write(d) else write(-1);
end.



Measured memory_bytes: 896
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
int main(){
  int n,sum=0,i;
  cin>>n;
  vector<int>a(n+1);
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int k=n/2;
  cout<<a[k+1]-a[k];
  //cout<<sum;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a),i##_end_=(b);i<i##_end_;i++)
#define MEMSET(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define SZ(a) ((int)a.size())
using namespace std;
const int M=100005;

vector<int> E[M];
int SG[M];
int n,ans;

int dfs(int u,int fa){
    int v,res=0;
    FOR(i,0,SZ(E[u])) if((v=E[u][i])^fa) res^=dfs(v,u)+1;
    return res;
}
 
int main(){
    scanf("%d",&n);
    FOR(i,1,n){
        int u,v;
        scanf("%d %d",&u,&v);
        u--;v--;
        E[u].pb(v);
        E[v].pb(u);
    }
    
    ans=dfs(0,-1);
    printf("%s",ans?"Alice":"Bob");
    return 0;
}

Measured memory_bytes: 10368
fun main(args: Array<String>) {
    var (N,K)  = (0..1).map{ readLine()!!.toInt()}
    var X = readLine()!!.split(" ").map(String::toInt)
    var sum = 0
    X.map{x->
        
        if(K - x <= x) sum += 2*(K-x)
        else sum += 2*x
    }
    println(sum)
}

Measured memory_bytes: 35984
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;
int dp[2][3000];

void solve() {
    string s;
    cin >> s;
    int ans = 0;
    for (auto i:s) {
        int x = i - '0';
        rep(j, 0, 2019)dp[1][(j * 10 + x) % 2019] += dp[0][j];
        ++dp[1][x];
        rep(j, 0, 2019) {
            dp[0][j] = dp[1][j];
            dp[1][j] = 0;
        }
        ans += dp[0][0];
    }
    cout << ans;
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 3736
n = int(input())
x = input()
val = int(x, 2)

cnt1 = x.count("1")
p_cnt = cnt1 + 1
m_cnt = cnt1 - 1
p_amari = val % (cnt1 + 1)
if cnt1 - 1 != 0:
    m_amari = val % (cnt1 - 1)
else:
    m_amari = 0


for i in range(n):
    ans = 0
    if x[i] == "0":
        # pになる
        amari = p_amari + pow(2, n - i - 1, p_cnt)
        amari %= p_cnt
        ans += 1
    elif x[i] == "1":
        # mになる
        if cnt1 - 1 == 0:
            print(0)
            continue
        amari = m_amari - pow(2, n - i - 1, m_cnt)
        amari %= m_cnt
        ans += 1
    while amari != 0:
        amari %= bin(amari).count("1")
        ans += 1
    print(ans)

Measured memory_bytes: 80380
import java.util.Scanner;

public class Main {

    private static Node root = null;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            String command = scanner.next();
            switch (command) {
                case "insert":
                    insert(scanner.nextInt());
                    break;
                case "find":
                    System.out.println(find(root, scanner.nextInt()) ? "yes" : "no");
                    break;
                case "print":
                    print();
                    break;
            }
        }
    }

    private static void insert(int id) {
        if (root == null) {
            root = new Node(id, null);
            return;
        }
        Node current = root;
        Node parent = null;
        while (current != null) {
            parent = current;
            if (id < current.id) {
                current = parent.left;
            } else  {
                current = parent.right;
            }
        }
        Node newNode = new Node(id, parent);
        if (id < parent.id) {
            parent.left = newNode;
        } else {
            parent.right = newNode;
        }
    }

    private static boolean find(Node node, int id) {
        if (node == null) return false;
        if (node.id == id) return true;
        if (node.id < id) return find(node.right, id);
        return find(node.left, id);
    }

    private static void print() {
        printInOrder(root);
        System.out.print("\n");
        printPreorder(root);
        System.out.print("\n");
    }

    private static void printPreorder(Node node) {
        if (node == null) return;
        System.out.print(" " + node.id);
        printPreorder(node.left);
        printPreorder(node.right);
    }

    private static void printInOrder(Node node) {
        if (node == null) return;
        printInOrder(node.left);
        System.out.print(" " + node.id);
        printInOrder(node.right);
    }


    private static class Node {
        int id;
        Node parent;
        Node left = null;
        Node right = null;

        Node(int id, Node parent) {
            this.id = id;
            this.parent = parent;
        }
    }
}




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

using namespace std;

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

class CommonIO {
public:
    CommonIO() {
        std::cin.tie(0);
        std::ios::sync_with_stdio(false);
    }
    ~CommonIO() {}

    template <class T>
    void scan(T &v) {
        std::cin >> v;
    }
    template <class T, class... Rest>
    void scan(T &v, Rest&... rest) {
        scan(v);
        scan(rest...);
    }

    template <class T>
    void print(T v) {
        std::cout << v;
    }
    template <class T>
    void print(std::vector<T> &v) {
        if (v.size() == 0) return;
        print(*v.begin());
        for (auto it = ++v.begin(); it != v.end(); ++it) {
            print(' ');
            print(*it);
        }
    }
    template <class T>
    void print(std::vector< std::vector<T> > &grid) {
        if (grid.size() == 0) return;
        print(*grid.begin());
        for (auto it = ++grid.begin(); it != grid.end(); ++it) {
            print('\n');
            print(*it);
        }
    }
    template <class T, class... Rest>
    void print(T v, Rest... rest) {
        print(v);
        print(' ');
        print(rest...);
    }

    template <class T>
    void printl(T v) {
        print(v);
        std::cout << '\n';
    }
    template <class T, class... Rest>
    void printl(T v, Rest... rest) {
        print(v);
        print(' ');
        printl(rest...);
    }
} io;

ll N, K;  // 人数、修行回数
vector<ll> A, F;  // 消化コスト、食べにくさ

bool judge(ll ans) {
    ll k = K;
    REP(i, N) {
        ll time = A[i] * F[i];
        if (time <= ans) continue;

        k -= (time - ans + F[i] - 1) / F[i];
        if (k < 0) return false;
    }
    return true;
}

ll search(ll min, ll max) {
    if (min == max) return min;

    ll middle = (min + max)/2;
    return judge(middle) ? search(min, middle) : search(middle + 1, max);
}

int main() {
    io.scan(N, K);
    A.resize(N); F.resize(N);
    REP(i, N) io.scan(A[i]);
    REP(i, N) io.scan(F[i]);
    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<ll>());

    io.printl(search(0, LONG_LONG_MAX));
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
signed main(void){
    int n,t; cin>>n>>t;
    vector <int> a(n); 
    rep(i,n) cin>>a[i];
    vector <int> right(n); 
    vector <int> left(n); 
    priority_queue <int> q;
    int big=-1;
    for(int i=n-1;i>=0;i--){
        q.push(a[i]);
        big = max(q.top() - a[i], big);
    }
    int ans = 0;
    map <int,int> ma;
    rep(i,n){
        ma[a[i]]++;
        if(ma[a[i]-big]) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 15860
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            var filePath = Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                $"{Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location)}.in");
            Console.SetIn(new StreamReader(filePath));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var counter = new Counter(Enumerable.Range(0, N).Select(elem => Console.ReadLine()).ToList());
            Console.WriteLine($"AC x {counter["AC"]}");
            Console.WriteLine($"WA x {counter["WA"]}");
            Console.WriteLine($"TLE x {counter["TLE"]}");
            Console.WriteLine($"RE x {counter["RE"]}");
        }
    }

    class Counter
    {
        private Dictionary<string, int> dic;

        public Counter(List<string> l)
        {
            dic = l.GroupBy(elem => elem).Select(elem => new { Result = elem.Key, Count = elem.Count() }).ToDictionary(elem => elem.Result, elem => elem.Count);
        }

        public int this[string result]
        {
            get
            {
                int count;
                return this.dic.TryGetValue(result, out count) ? count : 0;
            }
        }
    }
}


Measured memory_bytes: 25700
from fractions import gcd

K = int(input())

ans = 0
L = [0]*(K+1)
for a in range(1,K+1):
    for b in range(1,K+1):
        L[gcd(a,b)] += 1


for a in range(1,K+1):
    if L[a] == 0:
        continue
    for c in range(1,K+1):
        ans += L[a]*gcd(a,c)

print(ans)

Measured memory_bytes: 76076
//In The Name Of God
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 1e5 + 5, Mod = 1e9 + 7, P = 727, Lg = 17, TOF = 1900;

int A[N], Dp[105][N], Ps[105][N];
int32_t main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      int n, k; cin >> n >> k;
      for(int i = 1; i <= n; i++)
            cin >> A[i];
      Dp[0][0] = Ps[0][0] = 1;
      for(int i = 1; i < N; i++)
            Ps[0][i] = Ps[0][i - 1];
      for(int i = 1; i <= n; i++){
            for(int j = 0; j <= k; j++){
                  Dp[i][j] = Ps[i - 1][j];
                  if(j > A[i])
                        Dp[i][j] = (Dp[i][j] - Ps[i - 1][j - A[i] - 1] + Mod) % Mod;
                  if(j)
                        Ps[i][j] = (Ps[i][j - 1] + Dp[i][j]) % Mod;
                  else
                        Ps[i][j] = Dp[i][j];
            }
      }
      cout << Dp[n][k];
      return 0;
}



Measured memory_bytes: 160000
#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>;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n + 1), b(n);
    rep(i, n + 1) cin >> a[i];
    rep(i, n) cin >> b[i];
    ;
    ll ans = 0;
    rep(i, n) {
        if(b[i] > a[i]) {
            b[i] -= a[i];
            ans += a[i];
            if(b[i] >= a[i + 1]) {
                ans += a[i + 1];
                a[i + 1] = 0;
            } else {
                a[i + 1] -= b[i];
                ans += b[i];
            }
        } else {
            ans += b[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4784
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	
	cout << n/3 << '\n';
	return 0;
	
	
}


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

#define ll long long

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s = "";

	ll N;

	cin >> N;

	while (N--) {

		s = char('a' + N % 26) + s;
		N /= 26;
	}
	
	cout << s << endl;
	return 0;
}

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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> d(N);
    map<ll,ll> mp;
    for(int i=0;i<N;i++){
        cin >> A[i];
        ll diff = A[i]-i;
        mp[diff]++;
        // cerr << mp[diff] << endl;
        d[i] = diff;
    }
    ll ans =0;
    for(int i=0;i<N;i++){
        ll diff = -2*i -d[i];
        // cerr << diff << endl;
        ans += mp[diff];
    }
    cout << ans << endl;

  


    return 0;
}

Measured memory_bytes: 28972
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid ,int right){
  int n1 = mid - left;
  int n2 = right - mid;
  for(int i = 0;i < n1;i++){
    L[i] = A[left + i];
  }
  for(int i = 0;i < n2;i++){
    R[i] = A[mid + i];
  }
  L[n1] = R[n2] = SENTINEL;
  int i = 0,j = 0;
  for(int k = left; k< right;k++){
    cnt++;
    if(L[i] <= R[j]){
      A[k] = L[i++];

    }
    else{
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right){
  if(left + 1 < right){
    int mid = (left + right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}
int main(){
  int A[MAX],n,i;
  cnt = 0;
  scanf("%d",&n);
  for(i = 0;i < n; i++){
    scanf("%d", &A[i]);
  }
  mergeSort(A,n,0,n);
  for(i = 0;i < n;i++){
    if(i == 0){printf("%d",A[i]);}
    else{
      printf(" %d",A[i]);

    }

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



Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    rep(i, S.length()-1) {
        if (S[i] == 'A' && S[i+1] == 'C') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

cnt = 0
for i in range(N):
    minj = i
    for j in range(i,N):
        if A[j] < A[minj]:
            minj = j
    if minj != i:
        tmp = A[minj]
        A[minj] = A[i]
        A[i] = tmp
        cnt += 1

print(" ".join([str(s) for s in A]))
print(cnt)


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

int main(){
    int a;
    int b;
    int x;
    cin >> a;
    cin >> b;
    if(1 <= a && a <= 9 && 1 <= b && b <= 9){
        x = a * b;
    }
    else{
        x = -1;
    }
    cout << x <<endl;
    return 0;
}



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

int main(){
  int n;
  cin>>n;
  if(n%2==1){
    cout<<0<<endl;
    return 0;
  }
  int arr[n];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  sort(arr ,arr+n);
  
  cout<<arr[n/2]-arr[n/2-1]<<endl;
  
    return 0;
}

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

int main() {
    int K, S;
    cin >> K >> S;
    int count = 0;
    for (int i = 0; i < K + 1; i++) {
        for (int j = 0; j < K + 1; j++) {
            if (0 <= S - (i + j) && S - (i + j) <= K) {
                count++;
            }
        }
    }
    cout << count << endl;
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define ss second
#define ff first 


int main(){
    int n;
    cin >> n;
    vector<pair<int, pii> > a(n);
    for(int i=0; i<n; ++i){
        a[i].first = i;
        cin >> a[i].second.first >> a[i].second.second;
    }

    double ans=0;
    int xx = 0;
    do{
        double tempsum = 0;
        for(int i=1; i<n; ++i){
            tempsum += sqrt((a[i].ss.ff - a[i-1].ss.ff)*(a[i].ss.ff - a[i-1].ss.ff) + (a[i].ss.ss - a[i-1].ss.ss)*(a[i].ss.ss - a[i-1].ss.ss));
        }
        ans+=tempsum;
        ++xx;
    }while(next_permutation(a.begin(), a.end()));

    printf("%.6f", ans/xx);
}


Measured memory_bytes: 3820
import std.stdio, std.math, std.conv, std.string;

bool is_prime(int n)
{
    auto t = sqrt(n.to!double);

    for (int i = 2; i <= t; ++i) {
        if (n % i == 0) return false;
    }

    return true;
}

void main()
{
    auto N = readln.chomp.to!int;
    int cnt;
    foreach (_; 0..N) {
        if (is_prime(readln.chomp.to!int)) ++cnt;
    }
    writeln(cnt);
}


Measured memory_bytes: 2472
a = []
a = gets.chomp.split("").map(&:to_i)
n = gets.chomp.to_i
#p a[0].class
#p n
t = 0
cnt = 1
for i in 0..a.length-1
    if a[i] != 1 
        t = i
        cnt = a[i]
        break
    end
end
if t >= n
    puts 1
    #exit
else
    puts cnt
end

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;
typedef vector<bool> VB;
typedef vector< VB > VVB;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

const LL MOD = 1000000007;

template<typename T>
void dump(T a, int n) { for (int i = 0; i < n; i++) cout << a[i] << (i == n - 1 ? '\n' : ' '); }

template<typename T>
void dump(T a) { dump<T>(a, a.size()); }

const int dx[] = {0, 1, 1, 0, -1, -1};
const int dy[] = {1, 1, 0, -1, -1, 0};
const int D = 6;
const int offset = 150;
const int N = 300;

int main(void) {
	int T, M;
	while(cin >> T >> M, T || M) {
		VVI area(N, VI(N, -1));
		VVB wall(N, VB(N, false));
		PII S;
		for (int i = 0; i < M; i++) {
			PII p;
			cin >> p.X >> p.Y;
			wall[p.Y + offset][p.X + offset] = true;
		}
		cin >> S.X >> S.Y;
		S.X += offset;
		S.Y += offset;

		// bfs
		queue<PII> q;
		q.push(S);
		area[S.Y][S.X] = T;
		while (q.size()) {
			PII p = q.front();
			q.pop();
			int t = area[p.Y][p.X] - 1;

			if (t == -1) { // walk end
				break;
			}

			for (int i = 0; i < D; i++) {
				PII n(p);
				n.X += dx[i];
				n.Y += dy[i];
				
				if (!wall[n.Y][n.X] && t > area[n.Y][n.X]) {
					q.push(n);
					area[n.Y][n.X] = t;
				}
			}
		}

		// count walked area
		int ans = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				int x = area[i][j];
				ans += x >= 0;
			}
		}

		cout << ans << endl;
	}

	return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    if(a == 1 & b == 2 || a == 2 & b == 1) {
        cout << 3 << endl;
    } else if(a == 2 & b == 3 || a == 3 & b == 2) {
        cout << 1 << endl;
    } else if(a == 1 & b == 3 || a == 3 & b == 1) {
        cout << 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<cstdlib>
#include<cmath>
#define range(i,a,b) for(int i = (a); i <= (b); i++)
#define rrange(i,a,b) for(int i = (a); i >= (b); i--)
#define rep(i,b) for(int i = 1; i <= (b); i++)
#define rrep(i,b) for(int i = (b); i >= 1; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long ll;
const int N=1e5+11;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001LL;
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; }
ll h,w,ans=LLINF,t1,t2,maxn,minn,s1,s2,s3;
ll read(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
void calc(ll x,ll y,ll z){
	maxn=-LLINF;minn=LLINF;
	maxn=max(x,max(y,z));
	minn=min(x,min(y,z));
	ans=min(maxn-minn,ans);
}
void solve(int h,int w){
	t1=h/3;t2=w/2;
	s1=t1*w;s2=(h-t1)*t2;s3=(h-t1)*(w-t2);
	calc(s1,s2,s3);
	t1=h/3+1;t2=w/2;
	s1=t1*w;s2=(h-t1)*t2;s3=(h-t1)*(w-t2);
	calc(s1,s2,s3);
	t1=h/3;t2=(h-t1)/2;
	s1=t1*w;s2=t2*w;s3=(h-t1-t2)*w;
	calc(s1,s2,s3);
	t1=h/3+1;t2=(h-t1)/2;
	s1=t1*w;s2=t2*w;s3=(h-t1-t2)*w;
	calc(s1,s2,s3);
}
int main(){
//	freopen("ex.in","r",stdin);
	h=read();w=read();
	solve(h,w);solve(w,h);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


string s, t, u;

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

	int N; cin >> N;
	int ans;
	if(N%2 == 0) ans = (N / 2) - 1;
	else ans = (N-1) / 2;
	cout << ans << endl;



	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

		for(int i = 1;;i++){
			int x = sc.nextInt();
			if(x!=0){
			System.out.printf("Case %d: %d\n",i,x);
			}else{
				break;
			}
		}
	}
}

Measured memory_bytes: 65356
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int n, i, j, cnt=0, save=0, connect=0;//connect=0初回  ３連続でない 7連続である
    
   
    scanf("%d",&n);
    int s[n][2];
    
    for(i=0; i<n; i++)
        for(j=0; j<2; j++)
            scanf("%d", &(s[i][j]) );
    
//    printf("%d", n);
//    printf("\n");
//    for (i = 0; i < n; i++) {
//        for (j = 0; j < 2; j++) {
//            printf("%d ", s[i][j]);
//        }
//        printf("\n");
//    }
    
    for(i = 0; i < n; i++){
        if(s[i][0]==s[i][1]){
            if(connect==0||connect==7){
                cnt++;
            }else{
                cnt=1;
            }
            connect=7;
        }else{
           
            if(cnt>save){
                save = cnt;
            }
        
            connect=3;
        }
    }
    if(save>cnt){
        cnt=save;
    }
//    printf("zorome = %d\n", cnt);
    if(cnt>2){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;



int main(){
    int n,m; cin>>n>>m;
    vector<pear> jobs(n);
    rep(i,n){
        cin>>jobs[i].first>>jobs[i].second;
    }
    sort(jobs.begin(),jobs.end());
    ll ans = 0; priority_queue<int> pq;
    int i = 0;
    for(int j = 1; j <= m; j++){
            while(jobs[i].first<=j&&i<n){
                pq.push(jobs[i].second); i++;
            }
        if(!pq.empty()){
            ans += pq.top(); pq.pop();
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1660
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

//ll mod = 1000000007;
ll mod = 998244353;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}



int main() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double ath = h * M_PI / 6, bth = m * M_PI / 30;
	ath += M_PI * m / 360;
	double ans = sqrt((a*cos(ath) - b * cos(bth))*(a*cos(ath) - b * cos(bth)) + (a*sin(ath) - b * sin(bth))*(a*sin(ath) - b * sin(bth)));
	printf("%.15f\n", ans);
	return 0;
}

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

ll pow(ll x, ll n, int mod) {
  ll ans = 1;
  while(n != 0){
      if(n&1) ans = ans*x % mod;
      x = x*x % mod;
      n = n >> 1;
  }
  return ans;
}

ll nCr(int n, int r, int mod) {
  ll res = 1;
  for(int i = 1; i <= r; i++) {
    res = res * (n-i+1) % mod * pow(i, mod-2, mod) % mod;
  }
  return res;
}

int main() {
  int mod = 1000000007;
  int n,a,b;
  cin >> n >> a >> b;
  ll temp = pow(2, n, mod) - 1 - nCr(n, a, mod) - nCr(n, b, mod);
  temp %= mod;
  temp += mod;
  temp %= mod;
  cout << temp << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n,k;
  cin >> n >> k;
  ll p,r,s;
  cin >> r >> s >> p;
  string t;
  cin >> t;
  vector<int> mod(k,0);
  ll ans = 0;

  rep(i,t.size()){
    if (t[i] == 'r'){
      if (mod[i%k] == 1){
        mod[i%k] = 0;
        continue;
      }
      else{
        ans += p;
      }
      mod[i%k] = 1;
    }
    else if (t[i] == 's'){
      if (mod[i%k] == 2){
        mod[i%k] = 0;
        continue;
      }
      else{
        ans += r;
      }
      mod[i%k] = 2;
    }
    else if (t[i] == 'p'){
      if (mod[i%k] == 3){
        mod[i%k] = 0;
        continue;
      }
      else ans += s;
      mod[i%k] = 3;
    }
    //cout << i << ":" << ans << endl;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3708
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn gcd(a: i64, b: i64) -> i64 { if b == 0 { a } else { gcd(b, a % b) } }
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: i64 = sc.cin();
    let a: Vec<i64> = sc.vec(n);
    let q: Vec<i64> = a.iter().map(|x| x/2).collect();
    let mut g = 1;
    for &x in q.iter() {
        g = g*x/gcd(g, x);
    }
    for &x in q.iter() {
        let y = g / x;
        if y % 2 == 0 {
            put!(0);
            return;
        }
    }
    let mut ans = 0;
    let mut h = g;
    while h <= m {
        ans += 1;
        h += 2 * g;
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 12324
x = int(input())
yokin = 100
# for i in range(1, 10000000000):
#     yokin = int(1.01 * yokin) 
#     if (yokin >= x):
#         print(i)
#         exit()

count = 0
while yokin < x:
    yokin += yokin // 100
    count += 1

print(count)

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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

int main() {
  string S;
  getline(cin, S);
  
  vector<int> alpha(26, 0);
  while (S.size() > 0) {
    int d = 0;
    for (int i = 0; i < S.size(); i++) {
      d = S[i] - 'a';
      if (0 <= d && d < 26) alpha[d]++;
      d = S[i] - 'A';
      if (0 <= d && d < 26) alpha[d]++;
    }
    getline(cin, S);
  }

  char c;
  for (int i = 0; i < 26; i++) {
    c = 'a' + i;
    cout << c << " : " << alpha[i] << BR;
  }

  return 0;
}


Measured memory_bytes: 3168
// After contest. O(N*M) dp.
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 2002;
const int mo = 1e9 + 7;

int n, m, s[maxn], t[maxn], f[maxn][maxn];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;

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

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

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j) {
			if (s[i] == t[j])
				f[i+1][j+1] = (f[i][j+1] + f[i+1][j] + 1) % mo;
			else
				f[i+1][j+1] = ((f[i][j+1] + f[i+1][j]) % mo - f[i][j] + mo) % mo;
		}

	cout << (f[n][m] + 1) % mo << endl;

	return 0;
}

Measured memory_bytes: 15872
/// https://github.com/hatoo/competitive-rust-snippets
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules !get {([$t:ty]) => {{let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.split_whitespace().map(|t| t.parse::<$t>() .unwrap () ) .collect ::<Vec <_ >>() } } ;([$t :ty ] ;$n :expr ) =>{(0 ..$n ) .map (|_ |get !([$t ] ) ) .collect ::<Vec <_ >>() } ;($t :ty ) =>{{let mut line :String =String ::new () ;stdin () .read_line (&mut line ) .unwrap () ;line .trim () .parse ::<$t >() .unwrap () } } ;($($t :ty ) ,*) =>{{let mut line :String =String ::new () ;stdin () .read_line (&mut line ) .unwrap () ;let mut iter =line .split_whitespace () ;($(iter .next () .unwrap () .parse ::<$t >() .unwrap () ,) *) } } ;($t :ty ;$n :expr ) =>{(0 ..$n ) .map (|_ |get !($t ) ) .collect ::<Vec <_ >>() } ;($($t :ty ) ,*;$n :expr ) =>{(0 ..$n ) .map (|_ |get !($($t ) ,*) ) .collect ::<Vec <_ >>() } ;}
#[allow(unused_macros)]
macro_rules !debug {($($a :expr ) ,*) =>{eprintln !(concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) ;} }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let (n, l) = get!(u8, u8);
    let mut S:Vec<String> = get!(String; n);
    S.sort();
    for s in &S {
        print!("{}", s);
    }
    println!("");
}

Measured memory_bytes: 8572
#include<stdio.h>
#define N 1000000

int main(){
  int A[N];
  int n,i,center;

  scanf("%d",&n);
  
  for(i = 0; i < n; i ++){
    scanf("%d",&A[i]);
  }
  center = Partition(A, 0,n-1);
  for(i = 0; i < center; i ++){
    printf("%d ",A[i]);
  }
  printf("[%d] ",A[center]);

  for(i = center+1; i < n-1; i ++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);
    return 0; 
}

 int Partition(int A[], int p, int r){
   int x,i,j,k;
   
   x = A[r];
   i = p-1;
   for(j = p; j <= r-1; j ++){
     if (A[j] <= x){
       i = i+1;
       k = A[i]; 
       A[i] = A[j] ;
       A[j] = k;
     }
   }
   k = A[i+1];
   A[i + 1] = A[r];
   A[r] = k;
   return i+1;
 }

Measured memory_bytes: 2904
#include<iostream>
#include<algorithm>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a<b)?a:b)
using namespace std;
namespace fio {
	streambuf* in = cin.rdbuf();
	char bb[1000000], * s = bb, * t = bb;
#define gc() (s==t&&(t=(s=bb)+in->sgetn(bb,1000000),s==t)?EOF:*s++)
	inline int read() {
		int x = 0;
		char ch = gc();
		while (ch < 48)ch = gc();
		while (ch >= 48)x = x * 10 + ch - 48, ch = gc();
		return x;
	}
}using fio::read;
int n, m;
int arr[15][15];
int dp[305][305];
int main() {
	n = read(), m = read();
	for (int i = 1; i <= n; i++)for (int u = 1; u <= m; u++)arr[i][u] = read();
	for (int i = 0; i <= 100; i++)for (int u = 0; u <= 100; u++)for (int x = 1; x <= n; x++)for (int y = 1; y <= m; y++)dp[i][u] = max(dp[i][u], arr[x][y] - i * x - u * y);
	for (int x = 0; x <= n; x++)for (int y = 0, now = 0x7fffffff; y <= m; now = 0x7fffffff, y++) {
		for (int i = 0; i <= 100; i++)for (int u = 0; u <= 100; u++)
			now = min(now, dp[i][u] + i * x + u * y);
		if (now != arr[x][y])cout << "Impossible", exit(0);
	}
	puts("Possible"), puts("202 10401");
	for (int i = 1; i <= 201; i++)if (i != 101)cout << i << ' ' << i + 1 << ' ' << (i <= 100 ? 'X' : 'Y') << endl;
	for (int i = 0; i <= 100; i++)for (int u = 0; u <= 100; u++)printf("%d %d %d\n", i + 1, 202 - u, dp[i][u]);
	cout << 1 << ' ' << 202;
}

Measured memory_bytes: 512
#!/usr/bin/env python

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
INF = float("inf")

def main():
    N = int(input())
    for i in range(1,10):
        for j in range(1,10):
            if i*j == N:
                print("Yes")
                exit()
    print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9172
#include <algorithm>
#include <iostream>
int main(int argc, char *argv[]) {
  int N, X;
  std::cin >> N >> X;
  int sum = 0, min = X;
  for (int i = 0; i < N; ++i) {
    int m;
    std::cin >> m;
    min = std::min(m, min);
    sum += m;
  }

  int res = (X - sum) / min + N;
  std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using T = tuple<ll,ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N,x=1000,y=0;
  cin >> N;
  vector<ll> A(N);
  rep(i,N){
    cin >> A.at(i);
    if(i>0){
      if(A.at(i-1)>A.at(i)){
        x+=y*A.at(i-1);
        y=0;
      }else{
        if(x/A.at(i-1)>=1){
          y+=x/A.at(i-1);
          x-=(x/A.at(i-1))*A.at(i-1);
        }
      }
    }
    if(i==N-1){
      x+=y*A.at(i);
    }
  }
  cout << x << endl;
}
      

Measured memory_bytes: 3624
// Sakhiya07 - Yagnik Sakhiya

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

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>

#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 20005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
ll dp[N];
void solve()
{
    ll h,n;
    cin >> h >> n;
    pll p[n];
    for(ll i=0;i<N;i++)   dp[i] = 1e15;
    for(ll i=0;i<n;i++)    cin >> p[i].ff >> p[i].ss;
    dp[0] = 0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=p[i].ff;j<N;j++)
        {
            dp[j] = min(dp[j],dp[j-p[i].ff]+p[i].ss);
        }
    }
    ll ans = *min_element(dp+h,dp+N);
    cout<<ans;
}

int main()
{
    FAST;
    ll t = 1;
  //  cin >> t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)
#define SWAP(x,y) 		((x!=y)&&(x^=y,y^=x,x^=y))

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

int main(int argc, char* argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N,M;
	LL ans;

	cin >> N;

	vector<LL> T(N);

	for(int i=0;i<N;i++){
		cin >> T[i];
	}

	cin >> M;

	vector<LL> P(M);
	vector<LL> X(M);

	for(int i=0;i<M;i++){
		cin >> P[i] >> X[i];
	}


	for(int j=0;j<M;j++){

		ans = 0;
		for(int i=0;i<N;i++){
			if(i==P[j]-1){
				ans+=X[j];
			}else{
				ans+=T[i];
			}
		}

		cout << ans << endl;

	}
	return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
result = 0
nums = {}
n.times{
    |i|
    a = gets.chomp.to_i
    if( nums[a]==1 )
        result -= 1
        nums[a] = 0
    else
        result += 1
        nums[a] = 1
    end
}
puts result

Measured memory_bytes: 8188
N, K = [int(item) for item in input().split()]
candles = [int(item) for item in input().split()]
ans = []
for i in range(N-K+1):
  l, r = i, i+K-1
  ans.append(abs(candles[l]) + abs(candles[l] - candles[r]))
  ans.append(abs(candles[r]) + abs(candles[r] - candles[l]))
ans.sort()
print(ans[0])

Measured memory_bytes: 14224
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

char X, Y;

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

  if (X == Y) {
    cout << "=" << endl;
  } else if (X < Y) {
    cout << "<" << endl;
  } else {
    cout << ">" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
cnt = 0

def insert_sort(g):

    global cnt

    i = g

    for _ in range(n):
        
        v = nums[i]

        j = i - g

        while j >= 0 and nums[j] > v:

            nums[j + g] = nums[j]
            
            j -= g

            cnt += 1
        
        nums[j + g] = v

        i += 1

        if i >= n:

            break


def shell_sort():

    i = 0

    for _ in range(m):

        insert_sort(g[i])

        i += 1

n = int(input())

nums = []

for _ in range(n):

    nums.append(int(input()))

g = []

g_val = n

for _ in range(n):

    g_val = g_val // 2

    g.append(g_val)

    if g_val == 1:

        break

m = len(g)

shell_sort()

print(m)

g_cnt = 0

s = ''

for _ in range(m):

    s += str(g[g_cnt]) + ' '

    g_cnt += 1

print(s.rstrip())

print(cnt)

nums_cnt = 0

for _ in range(n):

    print(nums[nums_cnt])

    nums_cnt += 1



Measured memory_bytes: 45524
#include<stdio.h>

int A[500000],count=0;

void Merge(int l,int m,int r){

int n1=m-l,n2=r-m,i,j,k;
int L[n1],R[n2];
for(i=0;i<n1;i++){
L[i]=A[l+i];
}
for(i=0;i<n2;i++){
R[i]=A[m+i];
}
L[n1]=1000000001;
R[n2]=1000000001;
for(i=0,j=0,k=l;k<r;k++){
if(L[i]<=R[j]){
A[k]=L[i];
i++;
}
else {
A[k]=R[j];
j++;
}
count++;
}

}

void Merge_Sort(int l,int r){
int m;
if(l+1<r){
m=(l+r)/2;
Merge_Sort(l,m);
Merge_Sort(m,r);
Merge(l,m,r);
}
}

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

Merge_Sort(0,n);
for(i=0;i<n;i++){
printf("%d",A[i]);
if(i!=n-1)printf(" ");
}
printf("\n%d\n",count);

return 0;
}

Measured memory_bytes: 4508
import math
N_str = input()
num = len(N_str)
N = int(N_str)
result = 0
for i in range(1, num):
  if i % 2 != 0:
    result += int(math.pow(10,i))-1 - int(math.pow(10,i-1)) + 1
if num % 2 !=0:
  result += N - int(math.pow(10,num-1)) + 1
  
print(result)

Measured memory_bytes: 3064