akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  string line;
  while(getline(cin,line)) {
    string str;
    FOR(it,line)
      if (isalpha(*it))
        str += toupper(*it);
    set<string> res;
    set<string> ignore;
    for (int len = str.size(); len >= 3; --len) {
      for (int pos = 0; pos < str.size()-len+1; ++pos) {
        string s = str.substr(pos, len);
        if (ignore.count(s)) continue;
        string t = s;
        reverse(ALL(t));
        if (s == t) {
          res.insert(s);
          for (int i=0; i<(len-1)/2; ++i) {
            ignore.insert(s.substr(i, len-i*2));
          }
        }
      }
    }
    bool f = 0;
    FOR (it, res) {
      if (f) cout << " ";
      else f = 1;
      cout << *it;
    }
    cout << endl;
  }
}

Measured memory_bytes: 0
#!ruby -apl
a,b,c,d,e,f,p,q=$F.map &:to_f
a-=p
b-=q
c-=p
d-=q
e-=p
f-=q
x=c*f-d*e
$_=x*a*d>x*b*c&&x*a*f<x*b*e ?:YES: :NO

Measured memory_bytes: 6112
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; 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);
    int A[3];
    rep(i, 3) cin >> A[i];
    int ans = 0;
    while(!(A[0] == A[1] && A[1] == A[2])) {
        sort(A, A+3);
        if (A[2] - A[0] > 1 || A[1] == A[2]) {
            A[0] += 2;
        } else {
            A[0]++;
            A[1]++;
        }
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*
    handle - pruvi007
    questionName - 
    Contest - 
    Topic - 
    Platform - 
*/
#include<bits/stdc++.h>
using namespace std;
#define ll          long long int
#define fast         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INF          1e18
#define MOD          1000000007
#define Vi           vector<ll> 
#define Vs           vector<string>
#define VI           vector<vector<ll> >
#define PII          pair<ll,ll> 
#define PSI          pair<string,ll>
#define PB           push_back


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

int main()
{
    fast;
    int n;
    cin >> n;
    double k;
    cin >> k;
    int c = 0;
    for(int i=0;i<n;i++)
    {
        ll x,y;
        cin >> x >> y;
        double d = sqrt(x*x + y*y);
        if( d<=k )
            c++;
    }
    cout << c << '\n';
}

Measured memory_bytes: 3776
#include<stdio.h>

int n;
int A[20];

int solve (int i,int m){

  if(m==0)
    return -1;
  
  if(i >= n)
    return -2;

  if(solve(i+1,m)==-1) return -1;
  else if(solve(i+1,m-A[i])==-1)return -1;
  else return -2;
  
}
  
int main()
{
  int i,q;
  
  scanf("%d",&n);
  for(i = 0;i<n;i++)
    scanf("%d",&A[i]);

  
  scanf("%d",&q);

  int B[q];
  
  for(i = 0;i<q;i++)
    scanf("%d",&B[i]);


  for(i = 0;i<q;i++){
    if(solve(0,B[i])==-1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}
    



Measured memory_bytes: 2048
S = input()
n_length = len(S)
result = 0
for i in range(2**(n_length-1)):
    a = bin(i)[2:].zfill(10)
    tmp = 0
    now = ''
    for n in range(len(S)):
        now = S[-n-1] + now
        if a[-n-1] == '1':
            tmp += int(now)
            now = ''
    tmp += int(now) 
    result += tmp
print(result)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    string s;
    cin >> s;
    int res = 0;
    for (auto ss : s) {
        res += ss - '0';
    }
    if (res % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3720
from functools import reduce
n, a, b = map(int, input().split())
mod = 10**9 + 7

def comb(N, A, MOD):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    return num * pow(den, MOD - 2, MOD) % MOD

print((pow(2, n, mod) - 1 - comb(n, a, mod) - comb(n, b, mod))%mod)

Measured memory_bytes: 9588
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <bitset>
#include <queue>

using namespace std;
using ll = long long;

const ll MOD = 1e6 + 3;

ll binpow(ll a, ll p) {
    p %= MOD - 1;
    ll res = 1;
    while (p) {
        if (p & 1) {
            (res *= a) %= MOD;
        }
        (a *= a) %= MOD;
        p >>= 1;
    }
    return res;
}

ll f[MOD];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    f[0] = 1;
    for (int i = 1; i < MOD; i++) {
        f[i] = f[i - 1] * i % MOD;
    }
    int q;
    cin >> q;
    while (q--) {
        ll x, d, n;
        cin >> x >> d >> n;
        if (x == 0) {
            cout << "0\n";
            continue;
        }
        if (d == 0) {
            cout << binpow(x, n) << '\n';
            continue;
        }
        ll p = binpow(d, MOD - 2);
        ll ans = binpow(d, n);
        x = x * p % MOD;
        // x (x + 1) (x + 2) ... (x + n - 1)
        if (x + n - 1 >= MOD) {
            cout << "0\n";
            continue;
        }
        cout << ans * f[x + n - 1] % MOD * binpow(f[x - 1], MOD - 2) % MOD << '\n';
    }
    return 0;
}

Measured memory_bytes: 8704
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

std::vector<int64_t> get_divisor(int64_t n)
{
    std::vector<int64_t> ret;
    for (int64_t i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i != n / i)
            {
                ret.push_back(n / i);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main()
{
    int64_t n;
    cin >> n;

    int64_t sum = 0;

    auto divisors = get_divisor(n);

    for (auto div : divisors)
    {
        const auto m = n / div - 1;
        // m * div + div = n if (n % div == 0)
        if (m > div)
        {
            sum += m;
        }
        cerr << m << endl;
    }
    cout << sum << endl;
}


Measured memory_bytes: 384
#include <cstdio>
static const int MAXF = 3004;

int a, b, c, d, e, f;
bool mzu[MAXF] = { false };
bool suc[MAXF] = { false };

int main()
{
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);

    for (int i = 0; i * a <= f; ++i)
        for (int j = 0; i * a + j * b <= f; ++j)
            mzu[i * a + j * b] = true;
    for (int i = 0; i * c <= f; ++i)
        for (int j = 0; i * c + j * d <= f; ++j)
            suc[i * c + j * d] = true;

    double ans = -1;
    int ans_mzu = -1, ans_suc = -1;
    for (int i = 1; i <= f; ++i) if (mzu[i])
        for (int j = 0; i * 100 + j <= f && j <= e * i; ++j) if (suc[j]) {
            double perc = 100.0 * j / (i * 100 + j);
            if (perc > ans) {
                ans = perc;
                ans_mzu = i * 100;
                ans_suc = j;
            }
        }

    printf("%d %d\n", ans_mzu + ans_suc, ans_suc);
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const long long MOD = 4294967291LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long mult_mod(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;

    long double out = 0;

    for(int i = 0; i < n; ++i){
        long double a; cin >> a;
        out += 1 / a;
    }

    cout << setprecision(6) << fixed << (1 / out);

    return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n;
    cin >>n;
    cout<<n*800-(n/15)*200<<endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC125_C
{
    class Program
    {
        static int GCD(int a, int b)
        {
            return (b == 0) ? a: GCD(b, a % b);
        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] numArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int[] l = new int[n];
            int[] r = new int[n];

            for (int i = 0; i < n - 1; i++)
            {
                l[i + 1] = GCD(l[i], numArray[i]);
            }

            for (int i = n - 1; 0 < i; i--)
            {
                r[i - 1] = GCD(r[i], numArray[i]);
            }

            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                ans = Math.Max(ans, GCD(l[i], r[i]));
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 26972
from operator import itemgetter

N, H = map(int, raw_input().split())
attackCount = 0

swords = []
for _ in xrange(N):
    swords.append(map(int, raw_input().split()))
swords.sort(key=itemgetter(0), reverse=True)
niceWeapon = swords[0]

subWeapons = [x for x in swords if x[1] > niceWeapon[0]]
subWeapons.sort(key=itemgetter(1), reverse=True)

practicalHP = H

while practicalHP > 0 and subWeapons:
    throwWeapon = subWeapons.pop(0)
    attackCount += 1
    practicalHP -= throwWeapon[1]

if practicalHP > 0:
    attackCount += (practicalHP / niceWeapon[0])
    if practicalHP % niceWeapon[0]:
        attackCount += 1

print attackCount


Measured memory_bytes: 22608
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<long long > A(N);
  std::vector<long long > sum(N);// i番目までの和
  for (int i=0; i<N; i++){
    scanf("%lld", &A[i]);
  }
  std::sort(A.begin(), A.end());
  sum[0]=A[0];
  for (int i=0; i<N-1; i++){
    sum[i+1] = sum[i]+A[i+1];
  }
  std::vector<bool > can(N, false);
  for (int i=0; i<N-1; i++){
    if (sum[i]*2>=A[i+1]){
      can[i]=true;
    } else {
      can[i]=false;
    }
  }
  can[N-1]=true;
  int ans = 0;
  int index = N-1;
  while(index>=0){
    if (can[index]){
      ans++;
    } else {
      break;
    }
    index--;
  }
  printf("%d\n", ans);
  return 0;
}


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

int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<=0&&b>=0)puts("Zero");
	else if(a>=0&&b>=0)puts("Positive");
	else if((b-a+1)&1)puts("Negative");
	else puts("Positive");
	return 0;
}

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

int main()
{
  int h,w;
  cin>>h>>w;
  vector<vector<int> >a(h);
  vector<vector<int> >vis(h);
  for(int i=0;i<h;i++)
  {
    a[i].resize(w);
    vis[i].resize(w);
    for(int j=0;j<w;j++)cin>>a[i][j];
  }
  vector< pair<int,int> >from;
  vector< pair<int,int> >to;
  
  for(int i=0;i<h;i++)
  {
    for(int j=0;j<w;j++)
    {
      if(a[i][j]%2==1)
      {
        if(i!=0 && a[i-1][j]%2!=0)
        {
          a[i][j]--;
          a[i-1][j]++;
          from.push_back({i,j});
          to.push_back({i-1,j});
        }
        else if(j!=0 && a[i][j-1]%2!=0)
        {
          a[i][j]--;
          a[i][j-1]++;
          from.push_back({i,j});
          to.push_back({i,j-1});
        }
        else if(i!=h-1 && a[i+1][j]%2!=0)
        {
          a[i][j]--;
          a[i+1][j]++;
          from.push_back({i,j});
          to.push_back({i+1,j});
        }
        else if(j!=w-1 && a[i][j+1]%2!=0)
        {
          a[i][j]--;
          a[i][j+1]++;
          from.push_back({i,j});
          to.push_back({i,j+1});
        }
        else 
        {
          if(j!=w-1)
          {
            a[i][j]--;
          	a[i][j+1]++;
          	from.push_back({i,j});
          	to.push_back({i,j+1});
          }
          else if(i!=h-1)
          {
            a[i][j]--;
          	a[i+1][j]++;
          	from.push_back({i,j});
          	to.push_back({i+1,j});
          }
        }
      }
    }
  }
  for(int i=0;i<h;i++)
  {
    for(int j=0;j<w;j++)
    {
      if(a[i][j]%2==0)
      {
        vector<pair<int,int> >t;
        if(i!=0 && a[i-1][j]%2!=0)
        {
          t.push_back({i-1,j});
        }
        
        if(j!=0 && a[i][j-1]%2!=0)
        {          
          t.push_back({i,j-1});
        }
        
        if(i!=h-1 && a[i+1][j]%2!=0)
        {       
       		t.push_back({i+1,j});      
        }
        
        if(j!=w-1 && a[i][j+1]%2!=0)
        {       
          t.push_back({i,j+1});  
        }
        if(t.size()>=2)
        {
          a[t[0].first][t[0].second]--;
          from.push_back(t[0]);
          to.push_back({i,j});
          
          a[t[1].first][t[1].second]--;
          from.push_back(t[1]);
          to.push_back({i,j});
        }
        if(t.size()==4)
        {
          a[t[2].first][t[2].second]--;
          from.push_back(t[2]);
          to.push_back({i,j});
          
          a[t[3].first][t[3].second]--;
          from.push_back(t[3]);
          to.push_back({i,j});
        }
    }
  }
 }
  cout<<from.size()<<endl;
  for(int i=0;i<from.size();i++)
  {
    cout<<from[i].first+1<<" "<<from[i].second+1<<" "<<to[i].first+1<<" "<<to[i].second+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 7176
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int N, L;
string S[105];

int main(void)
{
	cin >> N >> L;
	for(int i = 0; i < N; i++){
		cin >> S[i];
	}
	sort(S, S+N);
	
	for(int i = 0; i < N; i++){
		cout << S[i];
	}
	cout << endl;
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	if (s.size() == 2) cout << s << endl;
	else {
		for (int i = 2; i >= 0; i--) cout << s[i];
		cout << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

ll n, x;
ll a[100000];

int main(){
    cin >> n >> x;
    REP(i, n) cin >> a[i];

    ll c = 0;
    REP(i, n-1){
        ll tmp = a[i] + a[i+1];
        if(tmp >= x){
            if(a[i+1] >= tmp-x){
                a[i+1] -= (tmp-x);
            } else {
                a[i] -= (tmp-x-a[i+1]);
                a[i+1] = 0;
            }
            c += tmp-x;
        }
    }
    cout << c << endl;
}


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

int main()
{
    int n, k, y, x;

    cin >> n >> k >> x >> y;

    int ans = 0;
    if(n<=k) {
        ans = n * x;
    }
    else {
        ans = k * x;
        ans += (n-k)*y;
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int n, d[110];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }

  set<int> values;
  for (int i = 0; i < n; i++) {
    values.insert(d[i]);
  }

  cout << values.size() << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int n;
long long a[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	if(n==1)
	{
		printf("0");
		return 0;
	}
	if(n==3)
	{
		long long ans=max(a[3]-2*a[1]+a[2],2*a[3]-a[1]-a[2]);
		printf("%lld\n",ans);
		return 0;
	}
	if(n%2==0)
	{
		long long ans=0;
		int m=n/2;
		for(int i=1;i<=m;i++)
			ans+=a[i+m]-a[i];
		ans*=2;
		ans-=a[m+1]-a[m];
		printf("%lld\n",ans);
		return 0;
	}
	else
	{
		long long s1,s2;
		long long ans=0;
		long long ans1=0,ans2=0;
		int m;
		
		m=(n+1)/2;
		s1=0,s2=0;
		for(int i=1;i<=m;i++)
			s1+=a[i];
		for(int i=m+1;i<=n;i++)
			s2+=a[i];
		ans1=(2*s2-2*s1)+(a[m]+a[m-1]);
		
		m=n/2;
		s1=0,s2=0;
		for(int i=1;i<=m;i++)
			s1+=a[i];
		for(int i=m+1;i<=n;i++)
			s2+=a[i];
		ans2=(2*s2-2*s1)-(a[m+1]+a[m+2]);
		printf("%lld\n",max(ans1,ans2));
		return 0;
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <set>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n, h, w;
    cin >> n >> h >> w;
    vector<int> v(n);
    REP(i,n){
        v[i] = i * w;
    }
    int tmp;
    REP(i,n){
        cin >> tmp;
        v[i] += (tmp) * ((i & 1) ? -1 : 1);
    }
    set<int> st;
    REP(i,n){
        st.insert(v[i]);
        //cout << v[i] << endl;
    }
    vector<int> sv(st.size());
    int loop=0;
    for(auto x:st){
        sv[loop] = x;
        loop++;
    }
    /*
    REP(i,st.size()){
        cout << sv[i] << endl;
    }*/
    int result = sv[0];
    FOR(i,1,sv.size()){
        result += (sv[i] - sv[i - 1] - w) * (sv[i] - sv[i - 1] - w > 0);
        //cout << result << endl;
    }
    result += (w*(n-1)-sv[sv.size() - 1]) * (w*(n-1)-sv[sv.size() - 1]>0);
    cout << result * h << endl;

    return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int digit(int n) {
	int ans = 0;
	while (n) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
signed main() {
	int n;
	cin >> n;
	int ans = inf;
	REP(i, n) {
		ans = min(ans, digit(i) + digit(n - i));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<fstream>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;

int n;

void init()
{
    cin>>n;
}

void work()
{
    cout<<10-n/100;
    n-=100*(n/100);
    cout<<10-n/10;
    n-=10*(n/10);
    cout<<10-n;
}


int main()
{
    init();
    work();
    return 0;
}



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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

typedef struct {
	TLong a;	// rate
	TLong b;	// point
} score;

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

int gcd(int a,int b){
	if(!(a % b)) return b;
	return gcd(b,a % b);
}

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const void *p,const void *q){
    return ((score *)p)->a - ((score*)q)->a;
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	nongetpop(array,&(*size));
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[]){
	int n;
	score *sc;
	scanf("%d",&n);
	sc = (score *)malloc(sizeof(score) * n);
	for (int i = 0; i < n; ++i)	scanf(" %d%d",&sc[i].a,&sc[i].b);
	qsort(sc,n,sizeof(score),comp);
	printf("%d\n", (sc[n - 1].a + sc[n - 1].b));
	return 0;
}


Measured memory_bytes: 3324
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = (sc.next());
         if(Character.isUpperCase(n.charAt(0))) {
        	 System.out.println("A");
         }else {
        	 System.out.println("a");
         }

    }
}

Measured memory_bytes: 35748
use proconio::*;
use std::cmp::max;

fn main() {
    input! {
        n: usize,
        m: usize,
        k: i64,
        mut a: [i64; n],
        mut b: [i64; m],
    };
    a.push(1 << 40);

    let mut acc = b.iter().sum::<i64>();
    let mut j = m;
    let mut ans = 0;

    for i in 0..a.len() {
        while acc > k && j > 0 {
            j -= 1;
            acc -= b[j];
        }

        if acc > k {
            break;
        }

        ans = max(ans, j + i);
        if i == n {
            break;
        }
        acc += a[i];
    }

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


Measured memory_bytes: 9568
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, X;
  cin >> N >> X;
  vec s(N);
  for (int i = 0; i < N; i++) cin >> s[i];

  sort(ALL(s));
  reverse(ALL(s));

  static int dp[210][101010];
  m0(dp);

  dp[0][X] = 1;
  for (int i = 0; i < N; i++) {
    for (int x = 0; x <= X; x++) {
      dp[i + 1][x] += dp[i][x] * (N - i - 1) % MOD;
      dp[i + 1][x] %= MOD;
      dp[i + 1][x % s[i]] += dp[i][x] % MOD;
      dp[i + 1][x % s[i]] %= MOD;
    }
  }

  int ans = 0;
  for (int i = 0; i <= X; i++) {
    ans += i * dp[N][i];
    ans %= MOD;
  }

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


Measured memory_bytes: 166016
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

struct prcs
{
	string name;
	int time;
	int endTime;
};

int main() {

	int n, q;
	cin >> n >> q;

	int ttl = 0;
	vector<prcs> pary;
	queue<prcs>  que;


	for (int i = 0; i < n; i++) {
		prcs pr;
		cin >> pr.name >> pr.time;
		que.push(pr);
	}


	while (!que.empty()) {
		prcs pr = que.front();
		que.pop();

		if (pr.time > q) {
			pr.time -= q;
			que.push(pr);
			ttl += q;
		}
		else {
			ttl += pr.time;
			pr.endTime = ttl ;
			pary.push_back(pr);
		}
	}


	for (int i = 0;i < n;i++) {
		prcs pp = pary[i];
		cout << pp.name << " " << pp.endTime << endl;
	}

	return 0;
}



Measured memory_bytes: 7080
#include <iostream>
#include <algorithm>
using namespace std;
int n,a[210],ans;
int main()
{
	cin>>n;
	for(int i=0;i<2*n;i++) cin>>a[i];
	sort(a,a+2*n);
	for(int i=0;i<2*n;i+=2) ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  string S,T;
  cin >> S;
  cin >> T;
  int count = 0;
  for(int i=0;i<3;i++){
    if(S[i]==T[i]){
      count ++;
    }
  }
  cout << count << endl;
  return 0;
}

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

int main(){
  int N;
  int t[110000],x[110000],y[110000];

  cin >> N;
  t[0] = x[0] = y[0] = 0;
  for(int i=0;i<N;i++) cin >> t[i+1] >> x[i+1] >> y[i+1];

  bool can = true;

  for(int i=0;i<N;i++){
    int dt = t[i+1] - t[i];
    int dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
    if(dt < dist) can = false;
    if(dt%2 != dist%2) can = false;
  }

  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int q = sc.nextInt();
    // 素数かどうかを表す
    int[] prime = new int[100001];
    for(int i = 2; i < 100001; i++) {
      int f = 1;
      for(int j = 2; j * j <= i; j++) {
        if((i % j) == 0) {
          f = 0;
          break;
        }
      }
      prime[i] = f;
    }
    // i以下の似た数の個数を表す
    int[] like = new int[100001];
    for(int i = 2; i < 100001; i++) {
      like[i] = like[i - 1];
      if(((i % 2) == 1) && (prime[i] == 1) && (prime[(i + 1) / 2] == 1)) like[i]++;
    }
    for(int i = 0; i < q; i++) {
      int l = sc.nextInt();
      int r = sc.nextInt();
      System.out.println(like[r] - like[l - 1]);
    }
  }
}

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

int main()
{
   ll n,m,ans=0;
   cin>>n>>m;
   ll a[m];
   for(int i=0;i<m;i++){
       cin>>a[i];
       ans+=a[i];
   }
   if(n<ans)
       cout<<"-1";
   else
       cout<<n-ans;
}



Measured memory_bytes: 3672
N, K = map(int, input().split())
Dlist = list(map(int, input().split()))
    
alist = list(set([0,1,2,3,4,5,6,7,8,9]) - set(Dlist))
if sum(x==0 for x in alist) == 0:
    b = min(alist)
else:
    b = min(list(set(alist)-set([0])))
strN = str(N)
c = ""
ans = ""
flag = True
for i in range(len(strN)):
    iN = int(strN[i])
    if sum(x>=iN for x in alist) == 0:
        ans = str(b) + str(min(alist))*len(strN)
        flag = False
        break
    elif sum(x==iN for x in alist) == 0:
        ans = c + str(min([a for a in alist if a>iN])) + str(min(alist))*(len(strN)-1-i)
        flag = False
        break
    else:
        c = c + str(iN)

if flag:
    print(N)
else:
    print(int(ans))

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

int main(void) {
  int N;
  while (cin >> N, N) {
    vector<string> words(N);
    for (int i = 0; i < N; i++) {
      cin >> words[i];
    }

    int tanku_size[] = {5, 7, 5, 7, 7};
    for (int i = 0; i < N; i++) {
      int tanku_pos = 0;
      int letter_size = 0;
      for (int j = i; j < N; j++) {
        letter_size += words[j].size();
        if (letter_size > tanku_size[tanku_pos]) break;
        if (letter_size == tanku_size[tanku_pos]) {
          tanku_pos++;
          letter_size = 0;
        }
      }
      if (tanku_pos == 5) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
  return 0;
}

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

#define sync {ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define ll long long int
#define mod 1000000007

string s;

void solve()
{
    cin>>s;
    
    int n = int(s.length());
    
    if(s[n-1]=='s')
        s+="es";
    else
        s+='s';
    
    cout<<s;
}

int main()
{
    sync;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}







Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
#define setbit(s, i) (s|=(1LL<<(i)))
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "C"
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    ll x, y;
    read(x);
    read(y);
    int ans=0;
    while(x<=y){
        ans++;
        x*=2;
    }
    write(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  
  auto fin=[](){
    cout<<-1<<endl;
    exit(0);
  };
  
  reverse(a.begin(),a.end());
  if(a[0]!=2) fin();
  
  Int c=2,d=2;
  for(Int i=0;i<n-1;i++){
    if(c*2<=a[i+1]) fin();
    
    c=(c+a[i+1]-1)/a[i+1]*a[i+1];
    d=(d+a[i]-1)/a[i+1]*a[i+1];
  }
  
  d+=a.back()-1;
  if(c>=d) fin();
  
  cout<<c<<" "<<d<<endl;
  return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  double ans = 0;
  for (int i = 0; i < N; ++i) {
    double x;
    string u;
    cin >> x;
    cin >> u;
    if (u == "JPY") {
      ans += x;
    } else {
      ans += x * 380000;
    }
  }
  cout << fixed << ans << endl;
  return 0;
}


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

int main() {
	int a, b, c;
	int arr[3]={};
	for (int i=0;i<3; i++){
		cin>> arr[i];
	}
	sort(arr, arr+3);
	if (arr[0]==5 and arr[1]==5 and arr[2]==7){
		cout << "YES" << endl;
	}
	else cout <<"NO"<< endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int l,r,d; cin>>l>>r>>d;
	int ct=0;
	for (int i=l; i<=r; i++)
		if (i%d==0) ct++;	
	cout<<ct<<endl;
	return 0;
}


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

const string M_INF="-";

int n,m,cost[]={0,2,5,5,4,5,6,3,7,6};
string dp[10010];

void chmax(string &s, string t){
  if(s.size()<t.size())s=t;
  if(s.size()==t.size())if(s<t)s=t;
}

int main(){
  cin>>n>>m;
  vector<int>a(m);
  rep(i,m)cin>>a[i];
  
  rep(i,10010)dp[i]=M_INF;
  dp[0]="";
  for(int i=0; i<=n; ++i){
    if(dp[i]==M_INF)continue;
    rep(j,m){
      chmax(dp[i+cost[a[j]]],dp[i]+char(a[j]+'0'));
    }
  }
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 54776
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;

 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()




//s.reserve(32768); //updated !
//s.max_load_factor(0.25);


string s[10];
string str[10];

int main(){
 
    

    int h,w,k;
    cin>>h>>w>>k;

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

    int ans2=0;

    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){

            for(int m=0;m<h;m++){
                for(int n=0;n<w;n++){
                    str[m][n]=s[m][n];
                }
            }

            int ans=0;

            for(int m=0;m<h;m++){
                for(int n=0;n<w;n++){
                    if((i&(1<<m)) || (j&(1<<n))){
                        str[m][n]='@';
                    }

                    if(str[m][n]=='#')ans++;
                }
                
            }

            if(ans==k)ans2++;
            
            

            
        }
    }

    cout<<ans2<<"\n";
    
    


    



    
    
    




    

}
    

    






    
    

    
 
    
 

 
 
    
 
 


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x%mod;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res%mod;
}
const int MAXN = 1e5+5;
int n,val[MAXN],rk[MAXN];
inl bool cmp(int x,int y){return rk[x]<rk[y];}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	for(ri i=1;i<=n;++i) read(rk[i]),val[i]=i;
	sort(val+1,val+1+n,cmp);
	for(ri i=1;i<=n;++i) printf("%d ",val[i]);
	return 0;
}

Measured memory_bytes: 1536
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	static boolean xFlg, yFlg, swap;
	static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long k = sc.nextInt();
		long x = sc.nextInt();
		long y = sc.nextInt();
		sc.close();

		if (x < 0) {
			x *= -1;
			xFlg = true;
		}
		if (y < 0) {
			y *= -1;
			yFlg = true;
		}
		if (x > y) {
			long t = x;
			x = y;
			y = t;
			swap = true;
		}
		long z = x + y;
		if (k % 2 == 0 && z % 2 == 1) {
			System.out.println(-1);
			return;
		}

		long ans = 1;
		if (z != k) {
			ans = (z + k - 1) / k;
			if (ans == 1) {
				ans = 2;
			}
			if (k * ans % 2 != z % 2) {
				ans++;
			}
		}
		pw.println(ans);

		if (ans == 3 && z < k && z % 2 == 1) {
			long x1 = k - y;
			print(x1, y);
			long x2 = (x + x1) / 2;
			print(x2, y + k - (x1 - x2));
			print(x, y);
		} else {
			long total = k * ans;
			long over = (total - z) / 2;
			long sum = 0;
			long x2 = 0;
			long y2 = 0;
			while (sum < total) {
				sum += k;
				if (sum <= x + over) {
					x2 = sum;
					y2 = 0;
				} else if (sum <= x + over + y) {
					x2 = x + over;
					y2 = sum - x2;
				} else {
					x2 = x;
					y2 = y;
				}
				print(x2, y2);
			}
		}
		pw.flush();
	}

	static void print(long x, long y) {
		if (swap) {
			long t = x;
			x = y;
			y = t;
		}
		if (yFlg) {
			y *= -1;
		}
		if (xFlg) {
			x *= -1;
		}
		pw.println(x + " " + y);
	}
}


Measured memory_bytes: 39612
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    VI x(n);
    VI y(n);
    rep(i,n) cin >> x[i] >> y[i];
    double ans = 0;
    rep(i,n-1) FOR(j,i+1,n) ans += sqrt(pow(x[i] - x[j],2) +pow(y[i] - y[j],2));
    ans = ans * 2/n;
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
H, W, K = list(map(int, input().split()))
s = []
for i in range(H):
    row = input()
    s.append(row)

ans = 0
for i in range(1 << H):
    for j in range(1 << W):
        cnt = 0
        for hi in range(H):
            for wi in range(W):
                if i >> hi & 1:
                    continue
                if j >> wi & 1:
                    continue
                if s[hi][wi] == '#':
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)


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

class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		long v1=0,v2=0;
		for(int i=0;i<b;++i)v1=v1*10+a;
		for(int i=0;i<a;++i)v2=v2*10+b;
		String[] ans= {String.valueOf(v1),String.valueOf(v2)};
		Arrays.sort(ans);
		System.out.println(ans[0]);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 21076
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;
int cnt[27];
char buf[111];
int vis[111][111];
int cnt2[27];
int main() {
	scanf("%d%d", &n, &m);
	REP(i,n) {
		scanf("%s", buf);
		REP(j, m) cnt[buf[j]-'a']++;
	}
	vector<int> slots;
	REP(i, n) REP(j, m) {
		if(!vis[i][j]) {
			int C = 0;
			for(int ii = i, q = 0; q < 2; ii = n-ii-1,q++ ) {
				for(int jj = j,w=0; w<2; jj = m-jj-1, w++ ) {
					if(!vis[ii][jj])
						C++;
					vis[ii][jj] = 1;
				//	printf("i=%d,j=%d, ii=%d, jj=%d\n", i, j, ii, jj);
				}
			}
			cnt2[C]++;
		}
	}
	for(int k = 4; k >= 1; k--) {
		for(int j=  0; j < 26; j++) {
			while(cnt[j] >= k && cnt2[k] > 0) {
				cnt2[k]--;
				cnt[j] -= k;
			}
		}
		if(cnt2[k] != 0) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
H, W = [int(a) for a in input().split()]
S = [None] * H
for i in range(H):
    S[i] = input()

L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]

ans = 0

for i in range(H):
    for j in range(W):
        # Uを求める
        if S[i][j] == '#':  pass  # Uは0で初期化されている
        elif i == 0:        U[i][j] = 1
        else:               U[i][j] = U[i - 1][j] + 1

        # Lを求める
        if S[i][j] == '#':  pass
        elif j == 0:  L[i][j] = 1
        else:       L[i][j] = L[i][j - 1] + 1

        # Dを求める
        if S[H - 1 - i][j] == '#':  pass
        elif i == 0:    D[H - 1 - i][j] = 1
        else:           D[H - 1 - i][j] = D[H - i][j] + 1

        # Rを求める
        if S[i][W - 1 - j] == '#':  pass
        elif j == 0:    R[i][W - 1 - j] = 1
        else:           R[i][W - 1 - j] = R[i][W - j] + 1

for i in range(H):
    for j in range(W):
        ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

print(ans)


Measured memory_bytes: 184708
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_W = 20;
const int MAX_H = 20;
const int MAX_BITS = 1 << MAX_W;

/* typedef */

/* global variables */

int n, h, w;
int rs[MAX_H][MAX_W], dp[2][MAX_BITS];

/* subroutines */

/* main */

int main() {
  cin >> n;

  for (int cn = 1; cn <= n; cn++) {
    cin >> w >> h;
    for (int y = 0; y < h; y++)
      for (int x = 0; x < w; x++) cin >> rs[y][x];

    memset(dp, 0, sizeof(dp));

    int prv = 0, cur = 1;
    int wbits = (1 << w) - 1, bw = 1 << (w - 1);

    for (int y = 0; y < h; y++)
      for (int x = 0; x < w; x++) {
	memset(dp[cur], 0, sizeof(int) * (wbits + 1));

	for (int bits = 0; bits <= wbits; bits++) {
	  int cbits = (bits << 1) & wbits;

	  if (dp[cur][cbits] < dp[prv][bits])
	    dp[cur][cbits] = dp[prv][bits];

	  if ((y == 0 || ! (bits & bw)) && (x == 0 || ! (bits & 1))) {
	    int ndp = dp[prv][bits] + rs[y][x];
	    if (dp[cur][cbits | 1] < ndp)
	      dp[cur][cbits | 1] = ndp;
	  }
	}

	prv ^= 1;
	cur ^= 1;
      }

    int max_dp = 0;
    for (int bits = 0; bits <= wbits; bits++)
      if (max_dp < dp[prv][bits]) max_dp = dp[prv][bits];

    printf("Case %d: %d\n", cn, max_dp);
  }

  return 0;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define FOR(i, n, m) for(int i = n; i < (int)m; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define pb push_back
using namespace std;
using ll = std::int_fast64_t;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll inf = 1000000000;
constexpr ll mod = 1000000007;
constexpr long double eps = 1e-15;
template<typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2> p) {
	os << to_string(p.first) << " " << to_string(p.second);
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	REP(i, v.size()) {
		if(i) os << " ";
		os << to_string(v[i]);
	}
	return os;
}

/*
template<typename T>
struct Treap {
	double drand() { // random number in [0, 1]
		static random_device rd;
		static mt19937 mt(rd());
		return (unsigned)mt() / (double)numeric_limits<unsigned>::max();
	}
	T v;
	double p;
	int cnt;
	Treap* lch;
	Treap* rch;
	Treap(T v) : v(v), p(drand()), cnt(1), lch(NULL), rch(NULL) { }
	Treap* update() {
		this->size = size(this->lch) + size(this->rch) + 1;
		return this;
	}
	static int size(Treap* t) {
		if(!t) return 0;
		else return t->cnt;
	}
	static Treap* merge(Treap* l, Treap* r) {
		if(!l || !r) {
			if(!l) return r;
			else return l;
		}
		if(l->p >= r->p) {
			l->rch = merge(l->rch, r);
			return l->update();
		} else {
			r->lch = merge(r->lch, l);
			return r->update();
		}
	}
	static pair<Treap*, Treap*> split(Treap* t, int k) {
		// split [0, k) and [k, n)
		if(k == 0) return {NULL, t};
		if(!(t->l)) {
			auto tmp = split(t->r, k - 1);
			t->r = tmp.first;
			return {t->update(), tmp.second};
		} else if(!(t->r)) {
			auto tmp = split(t->r, k - 1);
			t->r = tmp.first;
			return {t->update(), tmp.second};
		} else {

		}
	}
	Treap* insert() {
	}
	Treap* erase() {
	}
	T operator[](int k) {
	}
};
*/

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x, p;
	cin >> x >> p;
	ld ans = 0;
	if(x % 2) {
		ans += 1;
		ans += p / (ld)100 * (100 / (ld)p * ((x - 1) / 2))
		       + (100 - p) / (ld)100 * (100 / (ld)p * ((x + 1) / 2));
	} else {
		ans = 100 / (ld)p * (x / 2);
	}
	cout << fixed << setprecision(39) << ans << endl;
	return 0;
}
// ---------------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n,a[123456],b[123455];
bool PP(int i,int j){
    return a[i]<a[j];
}
int main(){
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=i;
    }
    sort(b+1,b+1+n,PP);
    for (int i=1;i<=n;i++)
    cout<<b[i]<<" ";
    return 0;
}

Measured memory_bytes: 1664