akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 2e5+5;

int n, x;

ll arr[maxn];

int main()
{
	scanf("%d %d", &n, &x);
	for(int i = 1; i<= n; i++) scanf("%lld", arr+i);
	for(int i = 1; i<= n; i++) arr[i] += arr[i-1];
	ll best = 4e18;
	for(int k = 1; k<= n; k++)
	{
		ll base = 1LL*(k+n)*x;
		int rounds = (n+k-1)/k;
		for(int r = 1; r<= rounds; r++)
		{
			int st = (r-1)*k+1;
			int ed = k*r;
			int val = r==1?5:(2*r+1);
			st = n+1-st;
			ed = max(1, n+1-ed);
			// printf("%d %d\n", ed, st);
			base += 1LL*(arr[st]-arr[ed-1])*val;
			if(base> best) break;
		}
		// printf("%d %lld\n", k, base);
		best = min(best, base);
	}
	printf("%lld\n", best);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main() {
    
string a,s,c;
cin >> a >> s >> c;
char x = s.at(0);
cout << 'A' << x << 'C'<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll w;
    cin >> n >> w;
    vector<ll> a(n), b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    map<ll, ll> dp[2];
    dp[0][0] = 0;
    for(int i = 0; i < n; i++) {
        for(const auto &p : dp[i & 1]) {
            ll j = p.first;
            chmax(dp[(i + 1) & 1][j], p.second);
            if(j + a[i] <= w) {
                chmax(dp[(i + 1) & 1][j + a[i]], dp[i & 1][j] + b[i]);
            }
        }
        dp[i & 1].clear();
    }
    ll ans = -LLINF;
    for(const auto &p : dp[n & 1]) {
        if(p.first <= w) {
            chmax(ans, p.second);
        }
    }
    print(ans);
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#define int long long
using namespace std;

string ans = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
signed main() {
	string a, b; cin >> a >> b;
	if (a.length() < b.length()) {
		puts("UNRESTORABLE");
		return 0;
	}
	for (int i = 0; i <= a.length() - b.length(); i++) {
		string c = a;
		bool OK = true;
		for (int j = 0; j < b.length(); j++) {
			if (a[i + j] != '?'&&a[i + j] != b[j]) {
				OK = false;
			}
		}
		if (OK) {
			for (int j = 0; j < b.length(); j++) {
				if (a[i + j] == '?') {
					a[i+j] = b[j];
				}
			}
			for (int j = 0; j < a.length(); j++) {
				if (a[j] == '?')a[j] = 'a';
			}
			ans = min(ans, a);
		}
		a = c;
	}
	if(ans.length()>50)puts("UNRESTORABLE");
	else cout << ans << endl;
}

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

using namespace std;

string s, t;
map<char, char>m;
map<char, char>m2;

int main()
{
    while(cin >> s >> t)
    {
        m.clear();
        m2.clear();
        for(int i = 0; i < s.size(); i++)
        {
            if(m.count(s[i]) && m[s[i]] != t[i])
            {
                cout << "No" << endl;
                break;
            }
            if(m2.count(t[i]) && m2[t[i]] != s[i])
            {
                cout << "No" << endl;
                break;
            }
            m[s[i]] = t[i];
            m2[t[i]] = s[i];
            if(i + 1 == s.size())
                cout << "Yes" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 776
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

W,H,x,y = IL()

if x==W/2 and y==H/2:
  print(W*H/2,1)
else:
  print(W*H/2,0)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<queue>
#include<ctime>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,x,y,sum,vis[1000005];
priority_queue<pair<int,long long>/**/> pq;
int main()
{
	cin>>n;
	x=n;
	while (x)
	{
		m+=x%10;
		x/=10;
	}
	pq.push(make_pair(-1,1));
	while ((!pq.empty()))
	{
		x=pq.top().second;
		y=-pq.top().first;
		pq.pop();
		if (vis[x]) continue;
		vis[x]=1;
		if (y>=m)
		{
			cout<<m;
			return 0;
		}
		if (!(x%n))
		{
			cout<<y;
			return 0;
		}
		for (i=0;i<=9;i++)
		{
			if (!vis[(x*10+i)%n]) pq.push(make_pair(-y-i,(x*10+i)%n));
		}
	}
	cout<<m;
	return 0;
}

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

ll num[101010];

int main() {
    int N;
    cin >> N;
    vector<ll> H(N);
    rep(i, N) cin >> H[i];

    rep(i, N-1) {
        if (H[i] >= H[i+1]) {
            num[i] = 1;
        }
    }

    ll ma = 0;
    for (int i=1; i<=N; ++i) {
        if (num[i-1] != 0 and num[i] != 0) {
            num[i] += num[i-1];
            ma = max(ma, num[i]);
        }
    }

    cout << ma << endl;
}


Measured memory_bytes: 1792
N = int(input())
S = input()

# 条件1だけを満たす組み合わせの数
ans = S.count('R') * S.count('G') * S.count('B')

# 条件2を満たさないものを、条件1でカウントしたものから減算
for l in range(N): # left
  for r in range(l+1, N): # right
    c = (r - l) // 2 + l # center
    if c - l == r - c: # 条件2を満たさない
      if len(set([S[l], S[c], S[r]])) == 3: # 条件1を満たす
        ans -= 1

print(ans)

Measured memory_bytes: 68156
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	// your code goes here
	ll n,m,t;
	cin>>n>>m>>t;
	vector <ll> a(n),b(m);
	for(ll i=0;i<n;i++)
	{
	    cin>>a[i];
	    if(i)
	    {
	        a[i]+=a[i-1];
	    }
	}
	for(ll i=0;i<m;i++)
	{
	    cin>>b[i];
	    if(i)
	    {
	        b[i]+=b[i-1];
	    }
	}
	ll out=0;
	for(ll i=0;i<n;i++)
	{
	    ll rem=t-a[i];
	    if(rem<0)
	    {
	        break;
	    }
	    auto it=upper_bound(b.begin(),b.end(),rem);
	    ll j=it-b.begin();
	    
	    out=max(out,i+j+1);
	}
	for(ll i=0;i<m;i++)
	{
	    ll rem=t-b[i];
	    if(rem<0)
	    {
	        break;
	    }
	    auto it=upper_bound(a.begin(),a.end(),rem);
	    ll j=it-a.begin();
	    out=max(out,i+j+1);
	}
	cout<<out;
}


Measured memory_bytes: 6424
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=3e2+10,mod=1e9+7;
vector<int> a;
long double dp[N][N][N];
int n;
long double solve(int ones,int twos,int threes){
    if(ones<0 || twos<0 || threes<0)return 0.0;
    if(ones==0 && twos==0 && threes==0)return 0.0;
    long double&ret=dp[ones][twos][threes];
    if(ret == ret)return ret;
    long double all=ones+twos+threes;
    ret = n/all;
    ret += 1.0*solve(ones-1,twos,threes)*ones/all;
    ret += 1.0*solve(ones+1,twos-1,threes)*twos/all;
    ret += 1.0*solve(ones,twos+1,threes-1)*threes/all;
    return ret;
}

int main()
{
    FASTIO
    int ones=0,twos=0,threes=0;
    cin >> n;
    a.resize(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        ones += (a[i]==1);
        twos += (a[i]==2);
        threes += (a[i]==3);
    }
    memset(dp,-1,sizeof dp);
    cout << setprecision(12) << solve(ones,twos,threes) << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 465792
#include<iostream>
using namespace std;
int main(void){
    int m,f,r;
    while(cin>>m>>f>>r && m!=-1||f!=-1||r!=-1){
        if(m==-1||f==-1){
            cout<<"F"<<endl;
        }else if(m+f>=80){
            cout<<"A"<<endl;
        }else if(m+f>=65){
            cout<<"B"<<endl;
        }else if(m+f>=50){
            cout<<"C"<<endl;
        }else if(m+f>=30){
            if(r>=50) cout<<"C"<<endl;
            else cout<<"D"<<endl;
        }else{
            cout<<"F"<<endl;
        }
    }
    
}


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

int main() {
	int n, m, x; cin >> n >> m >> x;
	vector<int>a(m); for(int i = 0; i < m; i++)cin >> a[i];
	int ans = 0;
	ans = min((upper_bound(a.begin(), a.end(), x - 1) - lower_bound(a.begin(), a.end(), 0)),
		(upper_bound(a.begin(), a.end(), n) - lower_bound(a.begin(), a.end(), x)));
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n,k,x,y;
    int a=0;
    cin >> n >> k >> x >> y;
    for(int i = 1; i <= n; i++) {
        if(i <= k) a += x;
        else a += y;
    }
    cout << a << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll dp[(1<<18)+5][51];
int main(){
for(int i=0;i<=(1<<18);i++)for(int j=0;j<=50;j++)dp[i][j]=inf;
int n;
cin>>n;
V<int> a(n),b(n);
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++)cin>>b[i];
dp[0][0]=0;
for(int bit=0;bit<(1<<n);bit++){
  int cnt=0;
  for(int j=0;j<n;j++)if(bit&(1<<j))cnt++;
  V<P> d;
  int t=cnt;
   for(int j=0;j<n;j++)if(!(bit&(1<<j)))d.emplace_back(j,t++);
   for(int i=0;i<=50;i++){
     if(dp[bit][i]>=inf)continue;
     for(int j=0;j<d.size();j++){
       P now=d[j];
       int num;
       if(abs(now.fi-cnt)%2==0)num=a[now.fi];
       else num=b[now.fi];
       if(num>=i)chmin(dp[bit|(1<<now.fi)][num],dp[bit][i]+(now.se-cnt));
  }
  }
  }
  ll ans=inf;
  for(int i=0;i<=50;i++)chmin(ans,dp[(1<<n)-1][i]);
  if(ans>=inf)cout<<-1<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 104832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1e18;

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  if((c+b-1)/b<=(a+d-1)/d) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <stack>

using namespace std;
typedef long long ll;

#define _SI(arr) (sizeof(arr)/sizeof(arr[0])

int main() {
	ll N;
	cin >> N;
	vector<ll> d;

	for (ll i = 0; i < N; i++)
	{
		ll temp;
		cin >> temp;

		if (!binary_search(d.begin(), d.end(), temp)) {
			d.push_back(temp);
			sort(d.begin(), d.end());
		}
	}

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

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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b, c; cin >> a >> b >> c;

  int mx = b / a;
  cout << min(mx, c) << endl;

  return (0);
}


Measured memory_bytes: 3652
<?php
fscanf(STDIN, "%s", $s);
$totalToppingMoney = 0;

//トッピングの値段算出
for($i = 0; $i < 3; $i++){
	if($s[$i] == 'o'){
		$totalToppingMoney += 100;
	}
}

//ラーメンの値段出力
echo (700 + $totalToppingMoney);

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

int a[10][10101];

int main()
{
  int r, c;

  while (cin >> r >> c, r){

    for (int i = 0; i < r; i++){
      for (int j = 0; j < c; j++){
        cin >> a[i][j];
      }
    }

    int maxv = -1;
    for (int bit = 0; bit < (1 << r); bit++){
      int ans = 0;
      for (int j = 0; j < c; j++){
        int cnt = 0;
        for (int i = 0; i < r; i++){
          cnt += (a[i][j] + ((bit >> i) & 1)) % 2;
        }
        ans += max(cnt, r - cnt);
      }

      maxv = max(maxv, ans);
    }

    cout << maxv << endl;
  }
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}


void solve(){
  int N;
  cin >> N;
  int A[200000+5];
  rep(i, N-1){
    int a;
    cin >> a;
    A[i] = a-1;
  }

  int count[200000+5] = {};
  RREP(i, 1, N){
    count[A[i]] += 1;
  }

  rep(i, N){
    cout << count[i] << endl;
  }
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 5148
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("inputh.txt", "r", stdin);
    freopen("outputh.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
   // cin>>test;
    while(test--)
    {

        ll n;
        cin>>n;
        vi v(n);
        fo(i,n)
            cin>>v[i];
        sort(v.begin(),v.end(),comp<ll>);
        ll sum=v[0];
        ll i=1;
        for(;i<=(n-2)/2;i++)
        {
            sum+=2*(v[i]);
        }
        if(isodd(n))
            sum+=v[i];
        cout<<sum;
//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not





Measured memory_bytes: 4784
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 +7
ans = 0

S = [0]*N

for i in range(1,N):
    S[i] = (A[N-i]+S[i-1])%mod

for j in range(1,N):
    ans += (S[j]*A[N-1-j])%mod
    ans = ans%mod

print(ans%mod)

Measured memory_bytes: 94292
#include "bits/stdc++.h"
using namespace std;
#define debug(var) cout << #var << ": " << var << endl;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
using ll = long long;
using ull = unsigned long long;
using vvint = vector<vector<int>>;
constexpr ll mod = 1e9 + 7;

int main() {

  int A, B; cin >> A >> B;
  cout << max(A + B, max(A - B, A * B));

  return 0;
}

Measured memory_bytes: 764
s = []
t = []
x = []

N = int(input())
for n in range(N):
    s.append(input())

M = int(input())
for n in range(M):
    t.append(input())

for n in range(N):
    S = s.count(s[- n])
    T = t.count(s[- n])
    x.append(S - T)

for n in range(M):
    S = s.count(t[- n])
    T = t.count(t[- n])
    x.append(S - T)

if max(x) > 0:
    print(max(x))
else:
    print(0)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;


/*vectorの要素を全部確認するやつだよ。


for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}


*/


/*for文でx,yを上下左右確認するやつだよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}
*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}


*/

/*2重for文書くのめんどくなった時用だよ。

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

	}
}

*/




ll s[100010], t[100010], x[100010];

int main(void) {

	ll a, b, q; cin >> a >> b >> q;

	for (int i = 1; i <= a; i++) {
		cin >> s[i];
	}
	for (int i = 1; i <= b; i++) {
		cin >> t[i];
	}
	for (int i = 1; i <= q; i++) {
		cin >> x[i];
	}

	s[0] = -1 * (pow(10, 15));
	s[a + 1] = pow(10, 15);
	s[a + 2] = pow(10, 15);

	t[0] = -1 * (pow(10, 15));
	t[b + 1] = pow(10, 15);
	t[b + 2] = pow(10, 15);

	for (int i = 1; i <= q; i++) {
		ll ans = pow(10, 15);

		int itrs = lower_bound(s, s + a + 3, x[i]) - s;
		int itrt = lower_bound(t, t + b + 3, x[i]) - t;

		//cout << itrs << " " << itrt << endl;
		//デバッグを消しなさいwwwwww

		ans = min(ans, llabs(s[itrs] - x[i]) + llabs(s[itrs] - t[itrt]));
		ans = min(ans, llabs(s[itrs] - x[i]) + llabs(s[itrs] - t[itrt+1]));
		ans = min(ans, llabs(s[itrs] - x[i]) + llabs(s[itrs] - t[itrt-1]));

		ans = min(ans, llabs(t[itrt] - x[i]) + llabs(t[itrt] - s[itrs]));
		ans = min(ans, llabs(t[itrt] - x[i]) + llabs(t[itrt] - s[itrs-1]));
		ans = min(ans, llabs(t[itrt] - x[i]) + llabs(t[itrt] - s[itrs+1]));

		ans = min(ans, llabs(s[itrs-1] - x[i]) + llabs(s[itrs-1] - t[itrt]));
		ans = min(ans, llabs(s[itrs - 1] - x[i]) + llabs(s[itrs - 1] - t[itrt+1]));
		ans = min(ans, llabs(s[itrs - 1] - x[i]) + llabs(s[itrs - 1] - t[itrt-1]));

		ans = min(ans, llabs(t[itrt - 1] - x[i]) + llabs(t[itrt - 1] - s[itrs]));
		ans = min(ans, llabs(t[itrt - 1] - x[i]) + llabs(t[itrt - 1] - s[itrs+1]));
		ans = min(ans, llabs(t[itrt - 1] - x[i]) + llabs(t[itrt - 1] - s[itrs-1]));



		cout << ans << endl;
	}




}

Measured memory_bytes: 3712
n=int(input())
a=list(map(int, input().split()))
count=[0]*(n+1)
for i in range (n):
    count[a[i]]+=1
m=0
for i in range (1,n+1):
    m+=count[i]*(count[i]-1)//2
for i in range (n):
   print(m-(count[a[i]]-1))

Measured memory_bytes: 81740
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int countR=0, countB=0;
    
    for(int i=0;i<100;i++){
        if(s[i]=='R') countR++;
        if(s[i]=='B') countB++;
    }
    if(countR>countB){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


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

using namespace std;

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

template <typename T>
int sz(T &x) {
  return (int)(x.size());
}

int power(int x, int y, int mod) {
  if (y == 0) {
    return 1;
  }
  int z = power(x, y >> 1, mod);
  z = z * 1ll * z % mod;
  if (y & 1) {
    z = z * 1ll * x % mod;
  }
  return z;
}

const int mod = 998244353;
const int inf = 1'000'000'007;

vector<int> p;

int find9(int x) {
  return p[x] == x ? x : p[x] = find9(p[x]);
}

void merge9(int x, int y) {
  x = find9(x);
  y = find9(y);
  if (x == y) {
    return;
  }
  p[x] = y;
}

void solve() {
  int n, k;
  ll m;
  cin >> n >> m >> k;

  p.clear(), p.resize(n), iota(p.begin(), p.end(), 0);
  vector<int> a(k), b(k), c(k);
  for (int i = 0; i < k; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    if (c[i] == 0) {
      merge9(a[i], b[i]);
    }
  }

  for (int i = 0; i < k; ++i) {
    if (c[i] == 1) {
      if (m == n - 1) {
        cout << "No\n";
        return;
      }
      if (find9(a[i]) == find9(b[i])) {
        cout << "No\n";
        return;
      }
    }
  }

  set<int> s;
  for (int i = 0; i < n; ++i) {
    s.insert(find9(i));
  }

  ll ans = n - 1;
  int cc = sz(s);

  ans += (cc * 1ll * (cc - 1) / 2) - (cc - 1);


  if (ans < m) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }
}

int main() {
  #ifndef LOCAL58
    // don't forget to remove if interactive
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
  #endif

  int t;
  t = 1;
  while (t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 9516
#include<stdio.h>

int main(){
    int S, h, m, s;
    scanf("%d", &S);

    h = S/3600;
    m = (S - h*3600)/60;
    s = (S-h*3600-m*60);
    printf("%d:%d:%d\n", h,m,s);
    return 0;
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n-1) {
        if(s[i] == s[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    rep(i,n-2) {
        if(s[i] == s[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#define REP(i, n, N) for(ll i=(n); i < N; i++)
#define p(s) cout << (s) << endl
#define p2(a, b) cout << (a) << ' ' << (b) << endl
using namespace std;
typedef long long ll;



int main() {
    int n;
    string s,s1,s2,s1_reverse,s2_reverse;
    set<string> st;
    cin >> n;
    REP(i,0,n){
        st.clear();
        cin >> s;
        REP(j,0, s.size()-1){
            s1 = s.substr(0,j+1);
            s2 = s.substr(j+1,s.size()-j);
            s1_reverse = s1;
            s2_reverse = s2;
            reverse(s1_reverse.begin(),s1_reverse.end());
            reverse(s2_reverse.begin(),s2_reverse.end());
            st.insert(s1+s2);
            st.insert(s2+s1);
            st.insert(s1_reverse+s2);
            st.insert(s2+s1_reverse);
            st.insert(s1+s2_reverse);
            st.insert(s2_reverse+s1);
            st.insert(s1_reverse+s2_reverse);
            st.insert(s2_reverse+s1_reverse);
        }
        p(st.size());
    }


    return 0;
}


Measured memory_bytes: 3272
#include <iostream>
#include <queue>
#include <string>
#include <cstring>
using namespace std;
int w, h, n;
string b[16];
int sx[3], sy[3], gx[3], gy[3];
short v[1 << 24];
short dist[3][16][16];

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

struct S {
	int x[3], y[3];
	float h;
	bool operator < (const S& s) const { return h > s.h; }
};

float calcH(S& s) {
	float ret = 0;
	for(int i = 0; i < n; i++) {
		ret = max(ret, (float)dist[i][s.y[i]][s.x[i]]);
	}
	return ret;
}


int conv(S s) {
	int ret = 0;
	for(int i = 0; i < n; i++) {
		ret = ret * 16 + s.x[i];
	}
	for(int i = 0; i < n; i++) {
		ret = ret * 16 + s.y[i];
	}
	return ret;
}

bool check(S s) {
	for(int i = 0; i < n; i++) {
		if(s.x[i] != gx[i] || s.y[i] != gy[i]) return false;
	}
	return true;
}

bool in(int x, int y) {
	return 0 <= x && x < w && 0 <= y && y < h;
}

bool valid(S s, S ps) {
	for(int i = 0; i < n; i++) {
		if(!in(s.x[i], s.y[i])) return false;
		if(b[s.y[i]][s.x[i]] == '#') return false;
	}
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			if(s.x[i] == s.x[j] && s.y[i] == s.y[j]) return false;
			if(ps.x[j] == s.x[i] && ps.y[j] == s.y[i] &&
				ps.x[i] == s.x[j] && ps.y[i] == s.y[j]) return false;
		}
	}
	return true;
}

void makeNS(int i, S s, S& ps, vector<S>& res) {
	if(i == n) {
		if(valid(s, ps)) res.push_back(s);
		return;
	}
	for(int k = 0; k < 5; k++) {
		S ns = s;
		ns.x[i] += dx[k];
		ns.y[i] += dy[k];
		makeNS(i + 1, ns, ps, res);
	}
}

int main() {
	while(cin >> w >> h >> n, w | h | n) {
		cin.ignore();
		S s;
		for(int i = 0; i < h; i++) {
			getline(cin, b[i]);
			for(int j = 0; j < w; j++) {
				if(b[i][j] == 'a') s.x[0] = j, s.y[0] = i;
				if(b[i][j] == 'b') s.x[1] = j, s.y[1] = i;
				if(b[i][j] == 'c') s.x[2] = j, s.y[2] = i;
				if(b[i][j] == 'A') gx[0] = j, gy[0] = i;
				if(b[i][j] == 'B') gx[1] = j, gy[1] = i;
				if(b[i][j] == 'C') gx[2] = j, gy[2] = i;
				if(b[i][j] == 'a' || b[i][j] == 'b' || b[i][j] == 'c') b[i][j] = ' ';
			}
		}

		memset(dist, -1, sizeof dist);
		for(int l = 0; l < n; l++) {
			for(int i = 0; i < h; i++) {
				for(int j = 0; j < w; j++) {
					if(b[i][j] == '#') continue;
					queue<pair<int, int>> q;
					q.push(make_pair(gx[l], gy[l]));
					dist[l][gy[l]][gx[l]] = 0;
					while(q.size()) {
						int x = q.front().first, y = q.front().second;
						q.pop();
						for(int k = 1; k < 5; k++) {
							int nx = x + dx[k], ny = y + dy[k];
							if(b[ny][nx] == '#') continue;
							if(dist[l][ny][nx] != -1) continue;
							dist[l][ny][nx] = dist[l][y][x] + 1;
							q.push(make_pair(nx, ny));
						}
					}
				}
			}
		}

		memset(v, -1, sizeof v);

		priority_queue<S> q;
		s.h = calcH(s);
		q.push(s);
		v[conv(s)] = 0;
		int ans = -1;
		while(q.size()) {
			s = q.top();
			q.pop();
			int d = v[conv(s)];

			if(check(s)) {
				ans = d;
				break;
			}

			vector<S> NS;
			makeNS(0, s, s, NS);
			for(S ns : NS) {
				int X = conv(ns);
				if(v[X] != -1 && v[X] <= d + 1) continue;
				v[X] = d + 1;
				ns.h = calcH(ns) + d + 1;
				q.push(ns);
			}
		}

		cout << ans << endl;
	}

}

Measured memory_bytes: 37316
s = str(input())
dic = {}
dic.setdefault('a',0)
dic.setdefault('b',0)
dic.setdefault('c',0)
    
for i in range(len(s)):
    dic.setdefault(s[i],0)
    dic[s[i]] += 1

if dic['a']==1 and dic['b']==1 and dic['c']==1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 8924
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)

bool debug=true;

/*    *************************************
	  * Written in New Computer           *
	  * The following code belongs to     *
	  * XiaoGeNintendo of HellHoleStudios *
	  *************************************
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

ll n,t,e;
ll dp[100005];
ll x[100005];
int main(int argc,char* argv[]){
	qi;
	cin>>n>>e>>t;
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	
	//dp[i]=min{dp[j]+max{t,2*(x[i]-x[j])}}
	//dp[i]=min{dp[j]+2*(x[i]-x[j])} or dp[i]=min{dp[j]+t} <-easy
	//dp[i]=2*x[i]+min{dp[j]-2*x[j])} 
	ll last=0,mn=-2*x[0];
	for(int i=0;i<n;i++){
		if(2*(x[i]-x[0])<=t){
			dp[i]=t;
			continue;
		}
	
		while(2*(x[i]-x[last+1])>t){
			mn=min(mn,dp[last]-2*x[last+1]);
			last++;
		}
		
		dp[i]=min(mn+2*x[i],dp[last]+t);
	}
	
	cout<<dp[n-1]+e<<endl;
	return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
	long long r, D, x;
	
	scanf("%lld %lld %lld", &r, &D, &x);

	for (int i = 0; i < 10; ++i)
	{
		x = r*x - D;
		printf("%lld\n", x);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int g=0,n;
    cin >> n ;
    for(long long int i=1;i<=n;i++){
        if(i*i>g && i*i<=n){
            g=i*i;
        }
    }
    cout << g << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
ll N;
ll ans=0;
vec d;
const ll MAXN=1000010;
bool arrived[MAXN];

void Solve(ll i){
    if(arrived[d[i]]) return;
    if(i==N-1) ans++;
    else if(d[i]!=d[i+1]) ans++;
   // cout<<"arrived"<<endl;
    for(ll j=1; j*d[i]<MAXN; j++) arrived[d[i]*j]=true;
    return;
}
int main(){
    cin>>N;
    rep(i,N){
        ll x; cin>>x;
        d.pb(x);
    }
    sort(ALL(d));
    
    rep(i,N) Solve(i);
    cout<<ans<<endl;

}

Measured memory_bytes: 5776
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef tuple<double,int,int> T;
void exec()
{
	double dist[1<<8][30]={0};
	double ts[8];
	double table[30][30]={0};
	int n,m,p,a,b;
	cin >> n >> m >> p >> a >> b;
	a--;b--;
	if(n==0)exit(0);
	for(int i=0;i<n;i++){
		cin >> ts[i];
	}
	for(int i=0;i<p;i++){
		int x,y,z;
		cin >> x >> y >> z;
		x--;y--;
		table[x][y]=z;
		table[y][x]=z;
	}
	double M=1e10;
	fill(dist[0],dist[0]+(1<<8)*30,M);
	priority_queue<T, vector<T>, greater<T> > pq;
	pq.push(T(0,0,a));
	dist[0][a]=0;
	double ret=M;
	int c=0;
	while(pq.size())
	{
		c++;
		T t=pq.top();
		double d=get<0>(t);
		int u=get<1>(t);
		int p=get<2>(t);
		pq.pop();
		if(dist[u][p]<d)
		{
			continue;
		}
		for(int i=0;i<n;i++){
			int v=u|(1<<i);
			if(u==v)continue;
			for(int q=0;q<m;q++){
				if(table[p][q]==0)continue;
				double d2=d+table[p][q]/ts[i];
				if(d2<dist[v][q])
				{
					pq.push(T(d2,v,q));
					dist[v][q]=d2;
					if(q==b){
						ret=min(ret,d2);
					}
				}
			}
		}
	}
	//cout << c;
	if(ret==M){
		cout << "Impossible" << endl;
	}
	else
	{
		cout << ret << endl;
	}
}
int main() {
	cout << setprecision(20);
	while(1)exec();
}

Measured memory_bytes: 2804
#include<stdio.h>
int main(void)
{
	int a,b;
	b=1,a=1;
	while(a+b>0){
		scanf("%d%d",&a,&b);
		if(a+b>0){
			if(a>b){
				printf("%d %d\n",b,a);
			}else{
		printf("%d %d\n",a,b);
		}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int c[10][10];
int w,h;
int sx,sy;
bool done[10][10];
int nh;
int solve(int x,int y,int nd){
	int res=0;
	int i,j;
	for(i=x+1;i<w;i++){
		if(nd==nh&&i==sx&&y==sy)return 1;
		if(done[i][y]&&c[i][y]==1){
			done[i][y]=false;
			res+=solve(i,y,nd+1);
			done[i][y]=true;
			break;
		}
	}
	for(i=x-1;i>=0;i--){
		if(nd==nh&&i==sx&&y==sy)return 1;
		if(done[i][y]&&c[i][y]==1){
			done[i][y]=false;
			res+=solve(i,y,nd+1);
			done[i][y]=true;
			break;
		}
	}
	for(i=y+1;i<h;i++){
		if(nd==nh&&x==sx&&i==sy)return 1;
		if(done[x][i]&&c[x][i]==1){
			done[x][i]=false;
			res+=solve(x,i,nd+1);
			done[x][i]=true;
			break;
		}
	}for(i=y-1;i>=0;i--){
		if(nd==nh&&x==sx&&i==sy)return 1;
		if(done[x][i]&&c[x][i]==1){
			done[x][i]=false;
			res+=solve(x,i,nd+1);
			done[x][i]=true;
			break;
		}
	}
	return res;
}		

int main(){
	int i,j;
	while(1){
	nh=0;
	scanf("%d %d",&w,&h);
		if(w==0)return 0;
	for(i=0;i<w;i++)for(j=0;j<h;j++)done[i][j]=true;
	for(i=0;i<h;i++)for(j=0;j<w;j++){
		scanf("%d",&c[j][i]);
		if(c[j][i]==1)nh++;
		if(c[j][i]==2){sx=j;sy=i;}
	}
	int ans=solve(sx,sy,0);
	printf("%d\n",ans);
	}
}

Measured memory_bytes: 1024
def actual(a, b, k):
    M = max(a, b)

    common_divisors = []

    for i in range(1, M + 1):
        if (a % i == 0) and (b % i == 0):
            common_divisors.append(i)

    return common_divisors[-k]

a, b, k = map(int, input().split())
print(actual(a, b, k))

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  string S, T; cin >> S >> T;
  map<char, int> sm, tm;
  vector<int> sv, tv;
  rep(i, S.size()) {
    sm[S[i]]++;
  }
  rep(i, T.size()) {
    tm[T[i]]++;
  }
  for (auto e: sm) {
    sv.push_back(e.second);
  }
  for (auto e: tm) {
    tv.push_back(e.second);
  }
  sort(all(sv));
  sort(all(tv));
  if (sv == tv) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 776
N = gets.to_i
S = gets.chomp.chars
dp = Array.new(N + 1, 0)
S.each_index.group_by{|i| S[i] }.each do |k, v|
  s, t = v.minmax
  dp[s + 1] += 1
  dp[t + 1] -= 1
end
(1 .. N).each do |i|
  dp[i] += dp[i - 1]
end
puts dp.max

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

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;

    bool flg = true;
    if(s.length()+1 != t.length()) flg = false;
    if(s != t.substr(0, s.length())) flg = false;

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(){
	int N, M, i;
	if(scanf("%d%d", &N, &M));
	for(i=N; i<=M/10; i++){
		if(M%i==0){
			printf("%d\n", M/i);
			return 0;
		}
	}
	if(M%20==0 && M/19>=N){printf("19\n");return 0;}
	if(M%19==0 && M/19>=N){printf("19\n");return 0;}
	if(M%18==0 && M/18>=N){printf("18\n");return 0;}
	if(M%17==0 && M/17>=N){printf("17\n");return 0;}
	if(M%16==0 && M/16>=N){printf("16\n");return 0;}
	if(M%15==0 && M/15>=N){printf("15\n");return 0;}
	if(M%14==0 && M/14>=N){printf("14\n");return 0;}
	if(M%13==0 && M/13>=N){printf("13\n");return 0;}
	if(M%12==0 && M/12>=N){printf("12\n");return 0;}
	if(M%11==0 && M/11>=N){printf("11\n");return 0;}
	if(M%10==0 && M/10>=N){printf("10\n");return 0;}
	if(M%9==0 && M/9>=N){printf("9\n");return 0;}
	if(M%8==0 && M/8>=N){printf("8\n");return 0;}
	if(M%7==0 && M/7>=N){printf("7\n");return 0;}
	if(M%6==0 && M/6>=N){printf("6\n");return 0;}
	if(M%5==0 && M/5>=N){printf("5\n");return 0;}
	if(M%4==0 && M/4>=N){printf("4\n");return 0;}
	if(M%3==0 && M/3>=N){printf("3\n");return 0;}
	if(M%2==0 && M/2>=N){printf("2\n");return 0;}
	printf("1\n");
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int numH = scan.nextInt();
		int numW = scan.nextInt();

		char[][] charBef = new char[numH + 2][numW + 2];
		char[][] charAft = new char[numH][numW];

		for (int j = 0; j <= numW+1; j++) {
			charBef[0][j] = '.';
			charBef[numH + 1][j] = '.';
		}

		for (int i = 1; i <= numH; i++) {
			StringBuilder strSB = new StringBuilder();
			strSB.append(".");
			strSB.append(scan.next());
			strSB.append(".");
			charBef[i] = strSB.toString().toCharArray();
		}

		for (int i = 0; i < numH; i++) {
			for (int j = 0; j < numW; j++) {

				int count = 0;

				if (charBef[i + 1][j + 1] == '.') {
					if (charBef[i][j] == '#') {
						count++;
					}
					if (charBef[i + 1][j] == '#') {
						count++;
					}
					if (charBef[i + 2][j] == '#') {
						count++;
					}
					if (charBef[i][j + 1] == '#') {
						count++;
					}
					if (charBef[i + 2][j + 1] == '#') {
						count++;
					}
					if (charBef[i][j + 2] == '#') {
						count++;
					}
					if (charBef[i + 1][j + 2] == '#') {
						count++;
					}
					if (charBef[i + 2][j + 2] == '#') {
						count++;
					}
					charAft[i][j] = (char) (count + '0');
				} else {
					charAft[i][j] = '#';
				}
			}
		}

		for (int i = 0; i < numH; i++) {
			for (int j = 0; j < numW; j++) {
				System.out.print(charAft[i][j]);
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 23764
#include<stdio.h>

int main(void){
    int n,x;
    int count=0;
    scanf("%d",&n);
    int A[n];
    for(int i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    for(int i=1;i<n;i++){
        for(int j=i;j>0;j--){
            if(A[j]<A[j-1]){
                x=A[j];
                A[j]=A[j-1];
                A[j-1]=x;
                count++;
            }
        }
    }
    
    for(int i=0;i<n;i++){
        printf("%d",A[i]);
        if(i<n-1){
            printf(" ");
        }
    }
    printf("\n%d\n",count);
    
    return 0;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  string s;
  cin >> s;
  ll cnt = 0;
  rep(i, s.size()/2){
    if(s.at(i) != s.at(s.size()-i-1))
      cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n;
	cin >> n;
	cout << n * n * n;
}


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

int main()
{
    std::string abcd;
    std::cin >> abcd;

    int a = abcd[0] - '0';
    int b = abcd[1] - '0';
    int c = abcd[2] - '0';
    int d = abcd[3] - '0';

    std::string eq="";
    for (int bit=0; bit < (1<<3); bit++){
        int sum=a;
        eq=abcd[0];
        for(int i=0; i<3; i++){
            if (bit & (1<<i)){
                // +
                sum += abcd[i+1] - '0';
                eq+='+';
                eq+= abcd[i+1];
            } else {
                sum -= abcd[i+1] - '0';
                eq+='-';
                eq+= abcd[i+1];
            }
        }
        if (sum == 7){
            break;
        }
    }

    std::cout << eq << "=7" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;


int main(){
   double n,k;
   cin>>n>>k;
   double ans=0;
   for(double i=1;i<=n;i++){
      double m=0;
      double tmp=i*pow(2,m);
      while(tmp<k){
         tmp*=2;
         m++;
      }
      ans+=1/n/pow(2,m);
   }
   cout<<std::setprecision(15)<<ans<<endl;
}

   


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	unordered_map<string,int>m;
	for(int i=0;i<n;++i){
		string s; cin>>s;
		++m[s];
	}
	vector<string>v={"AC"s,"WA"s,"TLE"s,"RE"s};
	for(auto&&i:v){
		cout<<i<<" x "s<<m[i]<<"\n"s;
	}
}


Measured memory_bytes: 3668
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#define ll long long
using namespace std;

int main(){
    int X,Y;
    cin>>X>>Y;
    for(int i=0;i<=X;i++){
        if(2*i+4*(X-i)==Y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3640
a, b, c, d = map(int, input().split())
m = abs(a-b)
n = abs(b-c)
l = abs(a-c)
if l > 2 * d:
    print("No")
elif l <= d:
    print("Yes")
else:
    if m <= d and n <= d:
        print("Yes")
    else:
        print("No")


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
#define all(x) x.begin(), x.end()

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

    string S, T; cin >> S >> T;
    T.pop_back();
    if(S == T) cout << "Yes" << endl;
    else cout << "No" << endl;    

    return 0;
}



Measured memory_bytes: 3612