akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final long INF = (long)Math.pow(10, 18);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int Q = sc.nextInt();
        long[] s = new long[A + 2];
        s[0] = -INF;
        s[s.length - 1] = INF;
        for (int i = 1; i < s.length - 1; i++) {
            s[i] = sc.nextLong();
        }
        long[] t = new long[B + 2];
        t[0] = -INF;
        t[t.length - 1] = INF;
        for (int i = 1; i < t.length - 1; i++) {
            t[i] = sc.nextLong();
        }
        long[] x = new long[Q];
        for (int i = 0; i < x.length; i++) {
            x[i] = sc.nextLong();
        }
        for (int i = 0; i < x.length; i++) {
            int b = -Arrays.binarySearch(s, x[i]) - 1;
            int d = -Arrays.binarySearch(t, x[i]) - 1;
            long res = INF;
            for (int j = b - 1; j <= b; j++) {
                for (int j2 = d - 1; j2 <= d; j2++) {
                    long l1 = Math.abs(s[j] - t[j2]) + Math.abs(t[j2] - x[i]);
                    long l2 = Math.abs(s[j] - t[j2]) + Math.abs(s[j] - x[i]);
                    res = Math.min(res, Math.min(l1, l2));
                }
            }
            System.out.println(res);
        }
        sc.close();
    }
}

Measured memory_bytes: 105916
#include <bits/stdc++.h>
#define rep(it,beg,end) for(__typeof(beg) it=beg,a=end;it!=a;it+=(beg<=a?1:-1))
using namespace std;
#define ll long long
#define pb emplace_back
#define mp make_pair
inline void read(ll &n) {
	char c;n=0;ll x=1;
	while (!isdigit(c=fgetc(stdin))&&c!='-');
	if (c=='-') x=-1, c=fgetc(stdin);
	while (isdigit(c)) n=n*10+c-'0',c=fgetc(stdin);
	n*=x;
}
inline void read(int &n) {ll x;read(x);n=x;}
template <typename T1,typename T2>
inline void read(T1 &a,T2 &b) {read(a);read(b);}
template <typename T1,typename T2,typename T3>
inline void read(T1 &a,T2 &b,T3 &c) {read(a);read(b);read(c);}
template <typename T1,typename T2,typename T3,typename T4>
inline void read(T1 &a,T2 &b,T3 &c,T4 &d) {read(a);read(b);read(c);read(d);}
// -------------------- Standard Template --------------------
int n;
ll arr[100005];
int main() {
	read(n);
	rep(i,0,n) read(arr[i]);
	sort(arr,arr+n);
	ll x=0,y=0;
	rep(i,n-1,0) {
		if (!x) {
			if (i&&arr[i]==arr[i-1]) x=arr[i]; 
		}
		if (!y) {
			if (i&&arr[i]==arr[i-1]&&arr[i]!=x) y=arr[i];
		}
	}
	ll ans=x*y;
	rep(i,n-1,0) {
		if (arr[i]==arr[i-1]&&arr[i-1]==arr[i-2]&&arr[i-2]==arr[i-3]) {
			ans=max(ans,arr[i]*arr[i]);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.05.19 21:58:11
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

// ===================### Union-Findの実装 ###=================== //
const int UF_SIZE = 100010;
int cnt = 0;

int par[UF_SIZE]; // 親
int siz[UF_SIZE]; // 木の深さ

// n要素で初期化
void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        siz[i] = 1;
    }
}
// 木の根を求める
int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}
// xとyの属する集合を併合
void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)
        return;

    cnt++;
    if (siz[x] < siz[y]) {
        par[x] = y;
        siz[y] += siz[x];
    } else {
        par[y] = x;
        siz[x] += siz[y];
    }
}
// xとyが同じ集合に属するか否か
bool same(int x, int y) {
    return find(x) == find(y);
}
// xが属する集合の要素数
int size(int x) {
    return siz[find(x)];
}

bool dp[100010];

int main() {
    int n, m;
    int x, y, z;
    scanf("%d%d", &n, &m);
    rep1(i, n) dp[i] = false;

    init(n);

    rep(i, m) {
        scanf("%d%d%d", &x, &y, &z);
        unite(x, y);
    }
    printf("%d\n", n - cnt);

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 1152
N = int(input())
A = [int(i) for i in input().split()]
B = [0 for i in range(N)]
# A_1+A_2+...+A_N = B_1+B_2+...+B_N = S
# (B_i+B_(i+1))/2 = A_i -> B_i+B_(i+1) = 2*A_i
# B_1 = S-(B_2+B_3+...+B_N) = S-2*(A_2+A_4+...+A_(N-1))
# B_(i+1) = 2*A_i-B_i
B[0] = 0
for i in range(N):
    if i%2 == 0:
        B[0] += A[i]
    else:
        B[0] -= A[i]
for i in range(1, N):
    B[i] = A[i-1]*2-B[i-1]
print(' '.join(map(str, B)))

Measured memory_bytes: 19096
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int a,b,l,c;
cin>>a>>b;
    c=log10(b)+1;
    a=a*pow(10,c)+b;
    if(round(sqrt(a))==sqrt(a)) cout<<"Yes";
else cout<<"No";
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const int MAX=1e9;
const int N=105;
int a[N];
int pre[N],suf[N];
int main()
{
	int n;
	scanf("%d",&n);
	for (int u=1;u<=n;u++) scanf("%d",&a[u]);
	pre[0]=0;for (int u=1;u<=n;u++) pre[u]=pre[u-1]+a[u];
	for (int u=n;u>=1;u--) suf[u]=suf[u+1]+a[u];
	int ans=MAX;
	for (int u=1;u<n;u++)
	{
		int S1=pre[u],S2=suf[u+1];
		ans=min(ans,abs(S1-S2));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0 ; i< n ; i++){
    cin >> a.at(i);
  }
  int ans =0;
  int flag = 0;
  for(int i = 0; i< n;i++){
    ans += 1;
    if( i == n-1){
      break;
    }
    for(int j = i ; j < n ;j++){
      if( j == n-1){
        i = j +1;
        break;
      }
      if ( a.at(j) > a.at(j + 1)){
        if(flag == 0){
          flag = 1;
        }
        else if(flag == 2){
          flag = 0;
          i = j ;
          break;
        }
      }
      if (a.at(j) < a.at(j+1)){
        if(flag == 0){
          flag = 2;
        }
        else if (flag == 1){
          flag = 0;
          i = j  ;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 768
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

# ループを見つけに行けばイ


def loop(now, town):
    cnt = 0
    while True:
        #print(now)
        next = a[now]
        if town[next] == 1:
            cnt += 1
            break
        else:
            town[next] = 1
            now = next
            cnt += 1
    return cnt, next


def tp(num, now):
    for _ in range(num):
        next = a[now]
        now = next
    return next


town1 = [None] + [0] * n
town1[1] = 1
loop1, now1 = loop(1, town1)

town2 = [None] + [0] * n
town2[now1] = 1
loop2, now2 = loop(now1, town2)

if k <= loop1 + loop2:
    ans = tp(k, 1)
else:
    k -= loop1
    k %= loop2
    #print(now1,now2)
    if k == 0:
        ans = now2
    else:
        ans = tp(k, now2)

print(ans)


Measured memory_bytes: 32380
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
string str;
int pos;

int accum(int depth){
  depth++;
  int ret = 0;
  vector<int> vec;
  if(isdigit(str[pos])){
    //cout<<"LKJLKJLKJ"<<endl;
    while(isdigit(str[pos]) == true){
      //cout<<"str[pos] : "<<str[pos]-'0'<<endl;
      ret=(ret*10)+str[pos++]-'0';
    }
    
    return (ret/2)+1;
  }else{
    while(str[pos] == '['){
      pos++;
      //cout<<"pos "<<pos<<endl;
      //cout<<"depth "<<depth<<endl;
      vec.push_back(accum(depth));
      pos++;
    }
    
    ///while(str[pos++] == ']');
    sort(vec.begin(),vec.end());
    for(int i=0;i<(vec.size()/2)+1;i++){
      //cout<<"vec "<<i<<" "<<vec[i]<<endl;
      ret+=vec[i];
    }
    return ret;
  }
}

int main(){
  int n,ans;
  cin>>n;
  for(int i=0;i<n;i++){
    pos=0;
    cin>>str;
    ans = accum(-1);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1276
import heapq
n,m=map(int,input().split())

c=list(map(lambda x: int(x)*-1,input().split()))
#heapqでは最小値しか取り出せないので最大値をとるばあには－１をかけておく

heapq.heapify(c)  #リストを優先度付きキューに
for i in range(m):
    cmin=heapq.heappop(c)  #最小値の取り出し
    heapq.heappush(c,(-1)*(-cmin//2))#最小値を2で割った商をリストに追加

print(-sum(c))
    

Measured memory_bytes: 14180
import java.util.*;
public class Main  {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int x = sc.nextInt();
      int n = sc.nextInt();
      
      if (n == 0) {
         System.out.println(x);
      } else {
         int a[] = new int[n];

         for (int i = 0; i < n; i++) {
            int aa = sc.nextInt();
            a[i] = aa;
         }
            
         int b[] = new int[102];
      
         for (int j = 0; j < 102; j++) {
            b[j] = 0;
         }
      
         for (int k = 0; k < n; k++) {
            int aaa = a[k];
            b[aaa] = 1;
         }
      
         if (b[x] == 0) {
            System.out.println(x);
         } else {
            int fin = 0;
            int count = 1;
            while (fin == 0) {
               if (b[x-count] == 0) {
                  System.out.println(x-count);
                  fin++;
               } else if (fin == 0 && 101 >= x + count &&  b[x + count] == 0) {
                  System.out.println(x+count);
                  fin++;
               }
               count++;
            }
         }
      }
   }
}

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

int main(){
  int N; // even number
  cin >> N;
  vector<int > d(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> d.at(i);
  }

  // 昇順に並び替え 真ん中の後ろと前の差が答え
  sort( d.begin(), d.end() ); // 速度不足なら、mergeSortなど。
  cout << d.at(N/2) - d.at(N/2-1) << endl;

  return 0;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

const int INF = 1e9;

int main(void){

	string S, T; cin >> S >> T;
	int A, B; cin >> A >> B;
	string U; cin >> U;
	if(S == U) A--;
	else if(T == U) B--;
	cout << A << " " << B << endl;


	return 0;

}


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

int n;
std::vector<int> vec;
void func(int a, int b)
{		
	for (int i = a; i != 0; --i)
	{
		if (b >= i)
		{
			vec.push_back(i);
			if (i == a)
			{
				for (int j = 0; j != vec.size(); ++j)
				{
					std::cout << vec[j];
					if (j != vec.size() - 1)
						std::cout << " ";
				}
				std::cout << std::endl;
			}
			else
				func(a - i, i);
			vec.pop_back();
		}
	}
}

int main()
{
	while (std::cin >> n)
	{
		if (n == 0)
			break;
		func(n, n);
	}

	return 0;
}

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

typedef long long int llint;

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

  if(n == 1) {
    cout<< "Hello World" <<endl;
  } else {
    int a, b;
    cin>> a >> b;
    cout<< a + b <<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main(){

   string s;

   getline(cin, s);

   for(int i = 0; i < s.length(); i++){
      if('a' <= s[i] && s[i] <= 'z'){
         cout << (char)(s[i] - 32);
      }
      else if('A' <= s[i] && s[i] <= 'Z'){
         cout << (char)(s[i] + 32);
      }
      else{
         cout << s[i];
      }
   }

   cout << endl;

   return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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


 ll x,n,a;
 cin>>x>>n;
 for(int i=1;i<=n;i++)
 {
     cin>>a;
     mySet.insert(a);
 }
 ll ans,diff=2000000;
 for(int i=-200;i<=200;i++)
 {
     if(!mySet.count(i))
     {
         if(diff>abs(x-i))
         {
             ans=i;
             diff=abs(x-i);
         }
     }
 }
 cout<<ans<<endl;
return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++) cin >> h.at(i);

  int sum = 1;
  int max = h.at(0);
  for(int i=1;i<n;i++){
    if((max <= h.at(i)) && (h.at(i-1) <= h.at(i))){
      sum++;
      max = h.at(i);
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int LEN=100005;

struct P {
  char name[100];
  int t;
};

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
  Q[tail]=x;
  tail=(tail+1)%LEN;
}
P dequeue() {
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}
int main() {
  int n, q;
  cin>>n>>q;
  for (int i=1; i<=n; i++) {
    cin>>Q[i].name>>Q[i].t;
  }
  head=1;
  tail=n+1;
  P u;
  int elaps=0, c;
  while (head!=tail) {
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if (u.t>0) {
      enqueue(u);
    } else {
      cout<<u.name<<" "<<elaps<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 13212
# ENV[Z = 'RUBY_THREAD_VM_STACK_SIZE'] || exec( { Z => '50000000' },'ruby',$0)
# readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }
# gets.split.map(&:to_i)
#
#
n,y = gets.split.map(&:to_i)


flag = false
n_10000 = -1
n_5000 = -1
n_1000 = -1
(n+1).times do |i|
  (n-i+1).times do |j|
    point = (i)*10000 + (j)*5000 + (n - i - j)*1000
    if point == y
      n_10000 = i
      n_5000 = j
      n_1000 = n - i - j
    end
  end
end

puts "#{n_10000} #{n_5000} #{n_1000}"


Measured memory_bytes: 1788
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N;
    cin >> N;
    vector<int> X(N);
    vector<int> Y(N);
    REP(i, N) cin >> X[i] >> Y[i];

    int p = abs(X[0] + Y[0]) % 2;
    REP(i, N) {
        if (abs(X[i] + Y[i]) % 2 != p) {
            cout << -1 << endl;
            return 0;
        }
    }

    vector<int> d;
    REV(i, 30, 0) {
        d.push_back(1 << i);
    }
    if (p == 0) d.push_back(1);

    cout << d.size() << endl;
    REP(i, d.size()) {
        cout << d[i] << " ";
    }
    cout << endl;

    REP(i, N) {
        int x = 0;
        int y = 0;
        int gx = X[i];
        int gy = Y[i];

        REP(j, d.size()) {
            if (abs(x - gx) > abs(y - gy)) {
                if (x - gx > 0) {
                    x -= d[j];
                    cout << "L";
                }
                else {
                    x += d[j];
                    cout << "R";
                }
            }
            else {
                if (y - gy > 0) {
                    y -= d[j];
                    cout << "D";
                }
                else {
                    y += d[j];
                    cout << "U";
                }
            }
        }
        cout << endl;
    }

    return 0;
}


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

int main()
{
  
  #ifndef ONLINE_JUDGE
freopen("finput.txt", "r", stdin);
freopen("foutput.txt", "w", stdout);
#else
// online submission
#endif
int a,b,c;
cin>>a>>b>>c;
int k;
cin>>k;

while(b<=a)
{
	b=b*2;
	k--;
}
while(c<=b)
{
c=c*2;
k--;
}



if(k>=0)
{
	cout<<"Yes"<<endl;
}
else
{
	cout<<"No"<<endl;
}






}


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

using namespace std;
int a[2000];
vector<int> b;
void countT(vector <int> A){  
  
    int n=A.size(); 
  
    sort(A.begin(), A.end());  
  
    int count = 0; 
      
    for( int i = n-1; i >= 1; i--){ 
        int l = 0, r = i-1; 
        while( l < r){ 
            if( A[l] + A[r] > A[i]){ 
  
                // If it is possible with a[l], a[r] 
                // and a[i] then it is also possible 
                // with a[l+1]..a[r-1],a[r] and a[i] 
                count += r - l ;  
  
                //checking for more possible solutions 
                r--;   
            } 
            else 
  
                // if not possible check for  
                // higher values of arr[l] 
                l++;   
        } 
    } 
    cout<<count; 
} 
int main() {
    
    int i,j,k,n,cnt=0,sum=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
        b.push_back(a[i]);
        
    }
    countT(b);/*
    sort(b,b+n);
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            int x=a[i];
            int y=a[j];
            cout<<x<<y<<" ";
            int id=lower_bound(b,b+n,x+y)-b;
            cout<<id<<' ';
            sum+=(id-2);
            
        }
    }
    
    cout<<sum;*/
}

Measured memory_bytes: 256
sub f{$$_=my$t=pop;grep$$_?$$_&$t:f(3-$t),@$_}print$c*(2*(map{map{push@{-$_},-$a[--$|]for@a=split$"}<>;$$_||${@$_?f(1)?b:a:c}++}-<>..-1)-$c)+($a+$b)**2+$a*$a

Measured memory_bytes: 131936
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int N,ans[82],a,b,la,lb,up,deg;
string sta,stb;

int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>sta>>stb;
		la=sta.size();
		lb=stb.size();
		up=0;
		deg=1;
		for(int i=0;i<max(la,lb)+1;i++){
			if(i>=la)a='0';
			else a=sta[la-1-i];
			if(i>=lb)b='0';
			else b=stb[lb-1-i];
			if(min(a,b)>80){
				cout<<"overflow"<<endl;
				continue;
			}
			if(a+b+up>105){
				ans[i]=a+b+up-10-96;
				up=1;
			}
			else{
				ans[i]=a+b+up-96;
				up=0;
			}
			if(ans[i]!=0)deg=i+1;
		}
		if(deg>80)cout<<"overflow"<<endl;
		else{
			for(int i=0;i<deg;i++)cout<<ans[deg-1-i];
			cout<<endl;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll a,b,c; cin >> a >> b >> c;
    if(b >= a * c) cout << c << endl;
    else cout << b / a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

int main(){
    std::string S;
    std::cin >> S;
    std::vector<bool> isUsed(26, false);
    for(int i = 0; i < S.size(); i++){
        isUsed[static_cast<int>(S[i] - 'a')] = true;
    }
    for(int i = 0; i < 26; i++){
        if(!isUsed[i]){
            char out = 'a' + i;
            std::cout << out << std::endl;
            return 0;
        }
    }

    std::cout << "None" << std::endl;
    return 0;
}


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

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

  int score_t = 0, score_h = 0;
  for (int i = 0; i < n; i++) {
    string card_t, card_h;
    cin >> card_t >> card_h;

    if (card_h < card_t) score_t += 3;
    else if (card_t < card_h) score_h += 3;
    else if (card_t == card_h) {
      score_t++;
      score_h++;
    }
  }

  cout << score_t << ' ' << score_h << endl;

  return 0;
}



Measured memory_bytes: 3220
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    string s = "";
    cin >> s;
    int cnt = 1;
    bool flag = true;
    for (int i=1; i<s.size(); i++) {
        if (flag) {
            if (s.at(i) == s.at(i-1)) {
                cnt++;
                if (i == s.size()-1) {
                    cnt--;
                }
                i++;
                flag = false;
            }
            else {
                cnt++;
                flag = true;
            }
        }
        else {
            cnt++;
            flag = true;
        }
    }
    int cnt2 = 1;
    flag = false;
    for (int i=2; i<s.size(); i++) {
        if (flag) {
            if (s.at(i) == s.at(i-1)) {
                cnt2++;
                if (i == s.size()-1) {
                    cnt2--;
                }
                i++;
                flag = false;
            }
            else {
                cnt2++;
                flag = true;
            }
        }
        else {
            cnt2++;
            flag = true;
        }
    }
    cout << max(cnt, cnt2) << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	int n;
	while(scanf("%d",&n),n){
		int sum=0,ans=INT_MIN;
		rep(i,n){
			int t; scanf("%d",&t);
			sum += t;
			ans = max(ans,sum);
			if( sum<0 )sum=0;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, K; cin >> N >> K;
    vector<ll> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    ll maxV = 0;
    for (int l = 0; l <= K; l++) {
        for (int r = 0; r <= K; r++) {
            int outNum = l + r;
            if (outNum > N || outNum > K) continue;
            int rest = K - outNum;
            vector<int> hand;
            hand.insert(hand.end(), v.begin(), v.begin() + l);
            hand.insert(hand.end(), v.rbegin(), v.rbegin() + r);
            sort(hand.begin(), hand.end());
            ll tmp = 0;
            for (int i = 0; i < outNum; i++) {
                if (i < rest && hand[i] < 0) continue;
                tmp += hand[i];
            }
            maxV = max(tmp, maxV);
        }
    }
    cout << maxV << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int i;
    char a[100];
    scanf("%s",a);
    for(i=0;a[i]!='\0';i++)
    {
        if(a[i] == ',')a[i] = ' ';
        printf("%c",a[i]);
    }
    return 0;
}


Measured memory_bytes: 128
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n>>s1;
    {
       (n<3200)?cout<<"red":cout<<s1<<endl;
    }
}


Measured memory_bytes: 3656
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")

N = I()

ans = 0
for a in range(1, N+1):
    for b in range(1, N+1):
        for c in range(1, N+1):
            ans += math.gcd(math.gcd(a, b), c)

print(ans)


Measured memory_bytes: 73836
A,B,K=map(int,input().split())

C=[]
for i in range(min(K,B-A+1)):
  C.append(A+i)
for i in range(min(K,B-A+1)):
  C.append(B-i)
#print(C)

C=list(set(C))
C.sort()
#print(C)

for i in C:
  print(i)

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

int selectionSort(vector<int> &lst, int n) {
  int count_swp = 0;
  rep(i, n - 1) {
    int minj = i;
    for (int j = i; j < n; j++) {
      if (lst[j] < lst[minj]) minj = j;
    }
    if (minj != i) {
      swap(lst[minj], lst[i]);
      count_swp++;
    }
  }
  return count_swp;
}

int main() {
  int n;
  cin >> n;
  vector<int> lst_a(n, 0);
  rep(i, n) cin >> lst_a[i];

  int count_swp = selectionSort(lst_a, n);
  rep(i, n) {
    if (i > 0) cout << " ";
    cout << lst_a[i];
  }
  cout << endl;
  cout << count_swp << endl;
  return 0;
}



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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	while (cin >> N, N) {
		int res = 0;
		for (int i = 1; i <= 1000; i++) {
			for (int j = i + 1; j <= 1000; j++) {
				int sum = 0;
				for (int k = i; k <= j; k++) {
					sum += k;
				}
				res += sum == N;
			}
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char b;
  cin >> b;
  if(b == 'A'){
    cout << 'T' << endl;
  }else if(b == 'T'){
    cout << 'A' << endl;
  }else if(b == 'C'){
    cout << 'G' << endl;
  }else if(b == 'G'){
    cout << 'C' << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    ll n; cin >> n;
    n--;
    ll ans = n * (n + 1) / 2LL;
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

int main()
{
	int H, W;
	while(cin >> H >> W && H != 0 || W != 0)
	{
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}

    return 0;
}



Measured memory_bytes: 3100
import java.util.Scanner;

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

		n = sc.nextInt();

		int n1 = n / 500;
		int n2 = (n - n1*500) / 5;

			System.out.println(n1*1000 + n2*5);

	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define MAX 11
#define mk make_pair
#define INF 1<<28
string s[20];
bool vis[20][20];
int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
int n,w,h,d[MAX][MAX],c;
int dp[1<<MAX][MAX];
int rec(int s,int v){
  if(dp[s][v]>=0)return dp[s][v];
  if(s==(1<<n)-1&&v!=0)return dp[s][v]=0;
  int res=INF;
  for(int u=0;u<n;u++) 
    if(!(s>>u&1))
      res=min(res,rec(s|1<<u,u)+d[v][u]);
  return dp[s][v]=res;
}
void bfs(int x2,int y2,int k){
  r(i,20)r(j,20)vis[i][j]=0;
  queue<pair<pair<int,int>,int> > q;
  vis[x2][y2]=1;
  q.push(mk(mk(x2,y2),0));
  while(!q.empty()){
    pair<pair<int,int>,int>p=q.front();q.pop();
    int p1=p.first.first,p2=p.first.second,p3=p.second;
    r(i,4){
      int x=dx[i]+p1;
      int y=dy[i]+p2;
      if(x>=0&&x<w&&y>=0&&y<h)
        if(!vis[x][y]&&(s[y][x]!='x')){
          if(0<=s[y][x]&&s[y][x]<12)
            d[k][(int)s[y][x]]=p3+1;
          else if(k!=0&&s[y][x]=='o')
            d[k][0]=p3+1;
          q.push(mk(mk(x,y),p3+1));
          vis[x][y]=1;
        }
    }
  }
}
int main(){
  while(cin>>w>>h,w){c=1;
    int a,b;
    vector<pair<int,int> >v;
    r(i,h)cin>>s[i];
    r(j,w)r(i,h)if(s[i][j]=='*')s[i][j]=c++,v.push_back(make_pair(j,i));
  memset(dp,-1,sizeof(dp));
  n=c;
  r(i,MAX)r(j,MAX)d[i][j]=INF;
  r(j,w)r(i,h)if(s[i][j]=='o')a=j,b=i;
  bfs(a,b,0);
  r(i,c-1)bfs(v[i].first,v[i].second,i+1);
  int p=rec(1,0);
  if(p==INF)p=-1;
  cout<<p<<endl;
  }
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define nl '\n'
typedef long long ll;
typedef long double ld;
//////////////////////////////////////////////////////////////////////



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

  int n;cin>>n;
  int a[1+n] , b[1+n] , c[1+n];
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<=n;i++)cin>>b[i];
  for(int i=1;i<=n;i++)cin>>c[i];

  sort(a+1,a+1+n);
  sort(b+1,b+1+n);
  sort(c+1,c+1+n);

  a[0] = c[0] = 0 ;
  a[n+1] = c[n+1] = 1e9+7;
  ll ans = 0;
  for(int i=1;i<=n;i++){
    int lo = 0 , hi = n+1;
    while( lo < hi ) {
      int mid = (lo+hi+1)/2;
      if( a[mid] < b[i] ) lo = mid;
      else hi = mid-1;
    }
    int lx = lo;
    lo = 0 , hi = n+1;
    while( lo < hi ) {
      int mid = (lo + hi)/2;
      if( c[mid] > b[i] ) hi = mid;
      else lo = mid+1;
    }
    int rx = lo;
    ans += lx * 1ll * (n+1-rx);
  }
  cout << ans << endl;
  
  return 0;
};


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

ll modpow ( ll a, ll n ) {
    ll res = 1;
    while ( n > 0 ) {
        if ( n & 1 ) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv ( ll a ) {
    return modpow(a, mod - 2);
} 

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

    vector<ll> a(n);
    vector<ll> a_2n(n*2);
    rep(i, n) {
        cin >> a[i];
        a_2n[i] = a[i];
        a_2n[i+n] = a[i];
    }

    vector<ll> tento(n, 0);
    ll tento_sum = 0;
    rep(i, n) {
        for ( int j = i + 1; j < n; ++j ) {
            if ( a[i] > a[j] ) {
                tento[i] = ( tento[i] + 1 ) % mod;
                tento_sum = ( tento_sum + 1 ) % mod;
            }
        }
    }

//    for ( auto tmp_num : tento ) {
//        cout << tmp_num << endl;
//    }

    vector<ll> tento_diff(n, 0);
    rep(i, n) {
        ll tmp_tento_num = 0;
        for ( int j = i + 1; j < n * 2; ++j ) {
            if ( a[i] > a_2n[j] ) {
                tmp_tento_num = ( tmp_tento_num + 1 ) % mod;
            }
        }
//        cout << tmp_tento_num << endl;
        tento_diff[i] = ( tmp_tento_num - tento[i] ) % mod;
    }

//    for ( auto tmp_num : tento_diff ) {
//        cout << tmp_num << endl;
//    }

    ll ans = 0;
    ll add_num = 0;
    rep(i, n) {
        add_num = ( tento_diff[i] * k % mod * ( k - 1 ) % mod * modinv(2) + tento[i] * k % mod ) % mod;
        ans = ( ans + add_num ) % mod;
//        cout << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <unordered_map>
// #include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","r",stdin);
    string s, t;
    cin >> s >> t;
    s.pb(t[sz(t) - 1]);
    if (s == t)
    {
        cout << "Yes" << endl;
    } else
    {
        cout << "No" << endl;
    }
    // if(t.substr)
    return 0;
}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
int N=1e5+9;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,x,t,ans=0;
	cin>>n>>x>>t;
	ans=(n/x)*t;
	if(n%x) ans+=t;
	cout<<ans;
	return 0; 
	
}


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

int th(int *P,int N,int x) {
  x /= N;
  if(N == 1)return 1;
  int j = P[0];
  for(int i=1;i<N;i++) {
    if(P[i] > j)P[i]--;
    P[i-1] = P[i];
  }
  return (j-1) * x + th(P,N-1,x);
}

int main() {
  int N;
  int P[10],Q[10];
  int i,p,q,x=1;
  cin >> N;
  for(i=0;i<N;i++)cin >> P[i];
  for(i=0;i<N;i++)cin >> Q[i];
  for(i=1;i<=N;i++)x *= i;
  p=th(P,N,x);
  q=th(Q,N,x);
  if(p>q)cout << p-q << endl;
  else cout << q-p << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <limits>
#include <type_traits>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

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

	INT err1=0, err2=0;
	for (size_t i = 0; i < s.length(); i++)
	{
		if (i % 2 == 0)
		{
			if (s[i] == '0')
			{
				err1++;
			}
			else
			{
				err2++;
			}
		}
		else
		{
			if (s[i] == '1')
			{
				err1++;
			}
			else
			{
				err2++;
			}
		}
	}

	cout << min(err1, err2) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    int X, t;
    cin >> X >> t;
    if(X <= t) cout << 0 << endl;
    else cout << X - t << endl;
    return 0;
    
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::cmp::max;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let v : Vec<i64> = get_vec();
    println!("{} {}", max(0,v[0]-v[2]), max(0, v[1] - max(0, v[2]-v[0])));
}


Measured memory_bytes: 4352
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}

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

  map<ll, ll> mp = prime_factor(n);

  cout << n << ": ";
  ll mcnt = 0;
  for (auto kv : mp) {
    mcnt++;
    ll p, cnt;
    tie(p, cnt) = kv;
    rep(i, cnt) { 
      cout << p;
      if(i == cnt - 1 && mcnt == (ll)mp.size()){
        cout << endl;
      } else {
        cout << " ";
      }
    }
  }

  return 0;
}



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

int main(){
    int n; cin >> n;
    vector<char> s(n);
    rep(i,n) cin >> s[i];

    if(n%2!=0){
        cout << "No" << endl;
        return 0;
    }else{
bool j = false;
        for(int i=0;i<n/2;i++){
            if(s[i]==s[i+n/2]){
                j = true;
            }else{
                j = false;
                break;
            }
        }if(j== true){
            cout<<"Yes"<< endl;
        }else{
            cout <<"No"<< endl;
        }

    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

const Inf = 1 << 62

func main() {
	N, M := ReadInt(), ReadInt()
	S := ReadString()
	dp := make([]int, N+1)
	for i := 0; i < N; i++ {
		dp[i] = Inf
	}
	dp[N] = 0
	// dpを平方分割
	blockSize := int(math.Sqrt(float64(N + 1)))
	blockNum := (N + 1 + blockSize - 1) / blockSize
	blocks := make([]int, blockNum)
	for i := 0; i < blockNum; i++ {
		blocks[i] = Inf
	}
	blocks[N/blockSize] = 0
	for i := N - 1; i >= 0; i-- {
		if S[i] == '1' {
			continue
		}
		l := i + 1
		r := Min(i+M, N) + 1
		min := Inf
		for l < r && l%blockSize > 0 {
			min = Min(min, dp[l])
			l++
		}
		for l < r && r%blockSize > 0 {
			r--
			min = Min(min, dp[r])
		}
		for l < r {
			min = Min(min, blocks[l/blockSize])
			l += blockSize
		}
		dp[i] = min + 1
		blocks[i/blockSize] = Min(blocks[i/blockSize], dp[i])
	}

	if dp[0] >= Inf {
		fmt.Println(-1)
		return
	}

	x := 0
	rest := dp[0]
	for x < N {
		rest--
		i := 1
		for dp[x+i] != rest {
			i++
		}
		fmt.Printf("%d ", i)
		x += i
	}
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


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

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int h = int.Parse(Console.ReadLine());

            Console.WriteLine(
                (a+b) * h /2
                );
        }
    }
}

Measured memory_bytes: 11092
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
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(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	char c;
	cin >> c;

	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
import itertools
n, a, b, c = map(int, input().split())
L = [int(input()) for _ in range(n)]

ans = 10**18
for pattern in itertools.product(range(4), repeat=n):
    MP = 0
    take = [0] * 3
    for index, length in zip(pattern, L):
        if index == 3:
            continue
        if take[index] != 0:
            MP += 10
        take[index] += length

    if take[0] == 0 or take[1] == 0 or take[2] == 0:
        continue

    MP += abs(a - take[0])
    MP += abs(b - take[1])
    MP += abs(c - take[2])

    ans = min(ans, MP)

print(ans)

Measured memory_bytes: 3064