akhauriyash/Code-Regression huggingface dataset:
class Dice

  def initialize( given_ary )
    @ary = given_ary
  end

  def topface( val )
    4.times do
      self.roll( "E" )
      if self.top == val
        return
      end
    end
    3.times do
      self.roll( "N" )
      if self.top == val
        return
      end
    end
  end

  def frontface( val )
    4.times do
      tmp = @ary[1]
      @ary[1] = @ary[2]
      @ary[2] = @ary[4]
      @ary[4] = @ary[3]
      @ary[3] = tmp
      if @ary[1] == val
        return
      end
    end
  end

  def checkall( givendice )
    4.times do
      self.roll( "E" )
      4.times do
        tmp = @ary[1]
        @ary[1] = @ary[2]
        @ary[2] = @ary[4]
        @ary[4] = @ary[3]
        @ary[3] = tmp
        if identical( givendice )
          return true
        end
      end
    end
    3.times do
      self.roll( "N" )
      4.times do
        tmp = @ary[1]
        @ary[1] = @ary[2]
        @ary[2] = @ary[4]
        @ary[4] = @ary[3]
        @ary[3] = tmp
        if identical( givendice )
          return true
        end
      end
    end
    return false
  end

  def roll( direction )
    case direction.downcase
    when "e"
      tmp = @ary[0]
      @ary[0] = @ary[3]
      @ary[3] = @ary[5]
      @ary[5] = @ary[2]
      @ary[2] = tmp
    when "w"
      tmp = @ary[0]
      @ary[0] = @ary[2]
      @ary[2] = @ary[5]
      @ary[5] = @ary[3]
      @ary[3] = tmp
    when "s"
      tmp = @ary[0]
      @ary[0] = @ary[4]
      @ary[4] = @ary[5]
      @ary[5] = @ary[1]
      @ary[1] = tmp
    when "n"
      tmp = @ary[0]
      @ary[0] = @ary[1]
      @ary[1] = @ary[5]
      @ary[5] = @ary[4]
      @ary[4] = tmp
    end
  end

  def top
    @ary[ 0 ]
  end

  def front
    @ary[ 5 ]
  end

  def right
    @ary[ 2 ]
  end

  def vals
    @ary
  end

  def compare( givendice )
    4.times do
      self.roll( "E" )
      if identical( givendice )
        return true
      end
    end
    3.times do
      self.roll( "N" )
      if identical( givendice )
        return true
      end
      4.times do
      self.roll( "E" )
      if identical( givendice )
        return true
      end
    end

    end
    false

  end

  def identical( givendice )
    @ary.zip( givendice.vals ).map{ | x, y | ( x - y ).abs }.inject(:+) == 0
  end

end

dices = Array.new()
gets.to_i.times do
  dices << Dice.new( gets.split.map(&:to_i) )
end
result = ""
dices.each do | outer |
  dices.each do | inner |
    if outer === inner
      next
    end
    if outer.checkall( inner )
      puts "No"
      exit
    end
  end
end
puts "Yes"

Measured memory_bytes: 8908
#include <cstdio>
#include <algorithm>
using namespace std;

int m,k;

int main()
{
    scanf("%d%d",&m,&k);
    if (!k)
    {
        for (int i=0;i<(1<<m);i++)
        {
            printf("%d %d ",i,i);
        }
    }
    else if (m==1 && k==1)
    {
        printf("-1");
    }
    else if (k<(1<<m))
    {
        printf("%d ",k);
        for (int i=0;i<(1<<m);i++)
        {
            if (i==k) continue;
            printf("%d ",i);
        }
        printf("%d ",k);
        for (int i=(1<<m)-1;i>=0;i--)
        {
            if (i==k) continue;
            printf("%d ",i);
        }
    }
    else
    {
        printf("-1");
    }
    getchar(); getchar();
    return 0;
}

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

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

    auto counts = vector<int>(N);
    for (auto i = 0; i < N; i++)
    {
        int x; cin >> x;
        counts[x]++;
    }

    auto ways = 1;
    if (N % 2 == 0)
    {
        for (auto i = 1; i < N; i += 2)
            if (counts[i] != 2) ways = 0;
            else ways = (2 * ways) % int(1e9+7);
    }
    else
    {
        ways = counts[0] == 1;
        for (auto i = 2; i < N; i += 2)
            if (counts[i] != 2) ways = 0;
            else ways = (2 * ways) % int(1e9+7);
    }

    cout << ways << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

const int M=10000;

int main(){
	int N;
	cin>>N;
	vector<lli> v(N+2,0);
	for(int i=0;i<N;i++) cin>>v[i];
	
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	
	
	lli a,b;
	for(int i=0;i<N+1;i++){
		if(v[i]==v[i+1]){
			a=v[i];
			v[i]=0;
			v[i+1]=-1;
			i=N+1;
			}
	}
		for(int i=0;i<N+1;i++){
		if(v[i]==v[i+1]){
			b=v[i];
			v[i]=0;
			v[i+1]=-1;
			i=N+1;
			}
	}
	cout<<a*b;
}

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

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

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

  ll n; cin >> n;
  vector<ll> a(n+1), b(n);
  rep(i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];

  ll ans = 0;
  rep(i, n) {
    if(a[i] >= b[i]) {
      ans += b[i];
    } else {
      // 余力がある場合
      b[i] -= a[i];
      ans += a[i];
      // この時点の b[i] は余力
      // a[i+1] を倒す
      if(a[i+1] >= b[i]) {
        ans += b[i];
        a[i+1] -= b[i];
      } else {
        ans += a[i+1];
        a[i+1] = 0;
      }
    }
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
    int A, B; cin >> A >> B;
    cout << A * B << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

    vector<vector<int>> abc( 100010, vector<int>( 3 ) );
    for ( int i = 0; i < N; ++i ) cin >> abc[ i ][ 0 ] >> abc[ i ][ 1 ] >> abc[ i ][ 2 ];

    vector<vector<long long>> dp( 100010, vector<long long>( 3, 0 ) );
    for ( int i = 0; i < N; ++i )
    {
        for ( int j = 0; j < 3; ++j )
        {
            for ( int k = 0; k < 3; ++k )
            {
                if ( k == j ) continue;
                dp[ i + 1 ][ k ] = max( dp[ i + 1 ][ k ], dp[ i ][ j ] + abc[ i ][ k ] );
            }
        }
    }

    long long result = 0;
    for ( int i = 0; i < 3; ++i ) result = max( result, dp[ N ][ i ] );

    cout << result << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
    ll n;
    cin >> n;
    vector <ll> v(n);
    rep(i, n) cin >> v.at(i);
    rep(i, n) {
        if (i < n-1) {
            cout << v.at(n-1-i) << ' ';
        } else {
            cout << v.at(n-1-i) << endl;
        }
    }
}


Measured memory_bytes: 3020
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <iomanip>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
int main() {
	int n;
	cin >> n;
	vector<int> a;
	for (int i = 0;i < n;++i) {
		int hoge;
		cin >> hoge;
		a.push_back(hoge);
	}
	long long ans = 10000000000;
	for (int i = -100;i <= 100;++i) {
		long long now_ans = 0;
		for (int q = 0;q < n;++q) {
			now_ans += abs(a[q] - i)*abs(a[q] - i);
		}
		ans = min(ans, now_ans);
	}
	cout << ans << endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, M, Q;
int A[55], B[55], C[55], D[55];
int T[11];
int ans;

void dfs(int d, int par)
{
	if (d == N)
	{
		int res = 0;
		rep(i, 0, Q)
		{
			if (T[B[i]] - T[A[i]] == C[i])res += D[i];
		}
		chmax(ans, res);
		return;
	}
	rep(i, par, M + 1)
	{
		T[d] = i;
		dfs(d + 1, i);
	}
}

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

	cin >> N >> M >> Q;

	rep(i, 0, Q)
	{
		cin >> A[i] >> B[i] >> C[i] >> D[i];
		A[i]--, B[i]--;
	}

	dfs(0, 1);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3640
// AOJ GRL_4_A Path/Cycle - Cycle Detection for a Directed Graph
// 2018.4.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_V 102
int V;   // 頂点数
int to[MAX_V][MAX_V], hi[MAX_V];
int q[MAX_V], top, end;
int count[MAX_V];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int topological_sort()
{
    int i, j, k, f;

//  for (i = 0; i < V; i++) for (j = 0; j < hi[i]; j++) count[to[i][j]]++;

    top = end = 0;
	f = 0;
    for (i = 0; i < V; i++) if (!count[i]) q[end++] = i;
    while (top < end) {
		i = q[top++];
        f++;
        for (j = 0; j < hi[i]; j++) {
            k = to[i][j];
            if (--count[k] == 0) q[end++] = k;
        }
    }
	return f == V;
}

int main()
{
	int E, s, t;

	V = in(), E = in();
	while (E--) {
		s = in(), t = in();
		to[s][hi[s]++] = t;
		count[t]++;
	}

	puts(topological_sort()? "0": "1");
	return 0;
}


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

using namespace std;

bool exists(int x, int n, string s) {
    if (x * 2 > n) return false;

    unordered_map <string, set <int> > ssm;
    set <int> epy {};
    string ss;

    for (int i = 0; i < n - x + 1; i++) {
        ss = s.substr(i, x);
        if (ssm.find(ss) == ssm.end()) {
            ssm[ss] = epy;
        }
        ssm[ss].insert(i);
    }
    set <int> si;
    for (auto itr = ssm.begin(); itr != ssm.end(); itr++) {
        si = itr->second;
        if (*si.rbegin() - *si.begin() >= x) return true;
    }

    return false;
}

int main(void) {
    int n, mi, md, ma;
    string s;
    cin >> n;
    cin >> s;

    mi = 0;  // Exist
    ma = 2501;  // Not exist
    for (int i = 0; i < 100; i++) {
        md = mi + (ma - mi) / 2;
        if (exists(md, n, s)) {
            mi = md;
        } else {
            ma = md;
        }
    }
    cout << mi << endl;

    return 0;
}


Measured memory_bytes: 6756
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

ll mod_pow(ll x, ll p, ll M = MOD) {
  ll a = 1;
  while (p) {
    if (p % 2)
      a = a*x%M;
    x = x*x%M;
    p /= 2;
  }
  return a;
}

ll mod_inverse(ll a, ll M = MOD) {
  return mod_pow(a, M - 2, M);
}


signed main() {
  fio();
  int n, h, d;
  cin >> n >> h >> d;
  vl fact(n + 1);
  fact[0] = 1;
  rep1 (i, n) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  ll f = 0;
  rep1 (i, n) f = (f + fact[i]) % MOD;

  vl dp(h + 1);
  dp[0] = fact[n] * mod_inverse(f) % MOD;
  queue<ll> qu;
  qu.push(dp[0]);
  ll sum = dp[0];
  for (int i = 1; i <= h; i++) {
    (dp[i] += sum * f) %= MOD;
    (sum += dp[i]) %= MOD;
    qu.push(dp[i]);
    if (qu.size() > d) {
      (sum -= qu.front()) %= MOD;
      qu.pop();
    }
  }
  cout << (dp[h] + MOD) % MOD << endl;
}


Measured memory_bytes: 24080
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const ll inf=1e18;
int main(){
	ll n,x;
	cin>>n>>x;
	vi in(n);
	rep(i,n)cin>>in[i];
	ll out=inf;
	vi tmp=in;
	rep(q,n){
		ll sum=x*q;
		rep(i,n)tmp[i]=min(tmp[i],in[(i-q+n)%n]);
		rep(i,n)sum+=tmp[i];
		out=min(out,sum);
	}
	cout<<out<<endl;
}

Measured memory_bytes: 384
n = int(input())
t = input()
k = [1]
z = 0
s = t[0]
for i in range(1,n):
    if(t[i-1]==t[i]):
        z+=1
    else:
        z=0
    if(z==0):
        k.append(1)
    else:
        z=0

print(len(k))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,l;
  int s=0;
  int ans=0;
  int ansabs=999999;
  cin >> n >> l;


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

  for(auto z : v)
  {
    int buf=s-z;
    int bufabs=z;
    if(bufabs<0)
      bufabs=-bufabs;

    if(ansabs>bufabs){
      ans=buf;
      ansabs=bufabs;
    }
  }
  cout << ans << endl;
  return 0;

}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

#define int int64_t
//int a[N+2];

int32_t  main(){
  IOS;
  int n;cin>>n;
  int ans=0;
  if(n==1){cout<<"0\n";return 0;}
  for(int i=2;i*i<=n;++i){
    if(n%i==0){
      if(n/i!=i){
        //different divisor 
        {//for i
          
          int j=i-1;
          //cout<<j<<" j\n";
          if((n/j)==(n%j))ans+=j; 
        }
        {//i=n/i 
          int j=n/i;
          j--;
         // cout<<j<<" j\n";
          if((n/j)==(n%j))ans+=j;
        }

      }else{
        //same divisor
        int j=i-1;
       // cout<<j<<" j\n";
        if((n/j)==(n%j))ans+=j;
      }
    }
  }
  if((n/(n-1))==(n%(n-1)))ans+=n-1;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		stdin.readLine();
		long cnt = Arrays.stream(stdin.readLine().split(" ")).sorted().distinct().count();
		String ans = cnt == 3 ? "Three" : "Four";
		System.out.println(ans);
	}

}

Measured memory_bytes: 26196
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solveD();
	}

    private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Z = sc.nextInt();
		int W = sc.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		int ans1 = Math.abs(a[N-1] - W);
		int ans2 = ans1;
		if (N > 1) {
			ans2 = Math.abs(a[N - 1] - a[N - 2]);
		}
		System.out.println(ans1 > ans2 ? ans1 : ans2);
	}
}

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


using namespace std;


int main()
{
	string str, tmp_str;
	int n, h;

	while(1){
		cin >> str;
		if(str == "-")
			break;

		cin >> n;
		for(int i = 0; i < n; i++){
			cin >> h;
			tmp_str = str.substr(h);
			tmp_str += str.substr(0, h);
			str = tmp_str;
		}

		cout << str << endl;
	}

	return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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 input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll x,y; cin>>x>>y;
    for (int i = 0; i <= x; ++i) {
        if (2*i + 4*(x-i) == y) {
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 3604
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,m;
	cin>>n>>m;
	int ans=0;
	if(n>=2)
	{
		ans+=n*(n-1)/2;
	}
	if(m>=2)
	{
		ans+=m*(m-1)/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int N, T;
  cin >> N >> T;
  vector<int> c(N), t(N);
  for(int i=0;i<N;i++){
    cin >> c[i] >> t[i];
  }
  int cost = 1001;
  for(int i=0;i<N;i++){
    if(t[i] <= T) cost = min(cost, c[i]);
  }
  if(cost > 1000) cout << "TLE" << endl;
  else cout << cost << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <bitset>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

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;
}



signed main() {
    int N, K; cin >> N >> K;
    vector<int> plus, minus;
    rep(i, N) {
        int x; cin >> x;
        if (x < 0) minus.push_back(-x);
        else plus.push_back(x);
    }
    sort(all(minus));
    sort(all(plus));
    int ans = INF_INT;
    rrep(i, K) {
        if (minus.size() > i && plus.size() > K - i - 2) {
            chmin(ans, plus[K - i - 2] * 2 + minus[i]);
            chmin(ans, plus[K - i - 2] + minus[i] * 2);
           // cout << plus[K - i - 2] << " " << minus[i] << endl;
        }
    }
    if (plus.size() >= K) chmin(ans, plus[K - 1]);
    if (minus.size() >= K) chmin(ans, minus[K - 1]);
    cout << ans << endl;
}


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

int main() {
  long long Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  N *= 4;
  long long count = 0;
  if (D < 2 * S && D < 4 * H && D < 8 * Q){
    count += (N / 8) * D;
    N %= 8;
  }
  if (S < 2 * H && S < 4 * Q){
    count += (N / 4) * S;
    N %= 4;
  }
  if (H < 2 * Q){
    count += (N / 2) * H;
    N %= 2;
  }
  count += N * Q;
  
  cout << count << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

#define int long long
	int N,K;
	cin >> N >> K;
	pair<int,int> ab[100000];
	for(int i=0; i<N; i++){
		int a,b;
		cin >> a >> b;
		ab[i] = MP(a,b);
	}
	sort(ab,ab+N);
	int sum = 0;
	for(int i=0; i<N; i++){
		sum += ab[i].second;
		if(sum >= K){
			cout << ab[i].first << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,C,s[N],t[N],c[N],qz[N],f[N];
signed main()
{
    n=read(), C=read();
    for(ri int i=1;i<=n;i++) s[i]=read(), t[i]=read(), c[i]=read();
    for(ri int i=1;i<=C;i++)
    {
        memset(qz,0,sizeof(qz));
        for(ri int j=1;j<=n;j++) if(i==c[j]) qz[s[j]]++, qz[t[j]+1]--;
        for(ri int j=1;j<=100000;j++) qz[j]+=qz[j-1];
        for(ri int j=1;j<=100000;j++) if(qz[j]>0) f[j]++;
    }
    int res=0;
    for(ri int i=1;i<=100000;i++) res=max(res,f[i]);
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 8400
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
lli MOD = 1000000007;
int main()
{
    set<int> s;
    int a;
    int n;
    cin >> n;
    rep(i, n)
    {
        cin >> a;
        s.insert(a);
    };
    cout << (s.size() % 2 ? s.size() : s.size() - 1) << endl;
}


Measured memory_bytes: 4992
using System;

namespace AtCoderConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = new string[3];
            int[,] matrix = new int[3, 3];

            // 標準入力から1行ずつ取得
            for (int i = 0; i < 3; i++) {
                input[i] = Console.ReadLine();
            }

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    matrix[i, j] = int.Parse(input[i].Split(' ')[j]);
                }
            }

            int[] a = new int[3];
            int[] b = new int[3];
            // a0を0として考える
            a[0] = 0;
            b[0] = matrix[0, 0];
            b[1] = matrix[0, 1];
            b[2] = matrix[0, 2];
            a[1] = matrix[1, 0] - b[0];
            a[2] = matrix[2, 0] - b[0];

            if(b[0] + a[0] == matrix[0, 0] && b[0] + a[1] == matrix[1, 0] && b[0] + a[2] == matrix[2, 0] &&
               b[1] + a[0] == matrix[0, 1] && b[1] + a[1] == matrix[1, 1] && b[1] + a[2] == matrix[2, 1] &&
               b[2] + a[0] == matrix[0, 2] && b[2] + a[1] == matrix[1, 2] && b[2] + a[2] == matrix[2, 2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
//#define i_7 998244353
ll i_7;
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
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;
}


void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////

#define N 3000
ll n;
string s;
vector<ll>v[N];

ll kaz[N];
ll dp[N];//min
ll ep[N];//max
void init(){
    memset(kaz,0,sizeof(kaz));
    memset(dp,0,sizeof(dp));
    memset(ep,0,sizeof(ep));
}
void dfs(ll id,ll par){
    if(s[id]=='1'){
        kaz[id]++;
    }
    ll sum=0;
    for(auto x:v[id]){
        if(x==par)continue;
        dfs(x,id);
        kaz[id]+=kaz[x];
        ep[id]+=ep[x]+kaz[x];
        sum+=(ep[x]+kaz[x]);
    }
    dp[id]=ep[id];
    bool f=true;
    
    for(auto x:v[id]){
        if(x==par)continue;
        if(sum-(ep[x]+kaz[x])<(dp[x]+kaz[x])){
            f=false;
            chmin(dp[id],dp[x]+ep[x]+2*kaz[x]-sum);
        }
    }
    if(f){
        dp[id]=ep[id]%2;
    }
}

int main(){fastio
    cin>>n>>s;
    rep(i_,1,n-1){
        ll a,b;cin>>a>>b;
        a--;b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    ll ans=inf;
    rep(i,0,n-1){
        init();
        dfs(i,-1);
        
        if(dp[i]==0){
            chmin(ans,ep[i]/2);
            //cout<<i<<":"<<ep[i]<<endl;
        }
        /*
        if(i==5)rep(j,0,n-1){
            cout<<j<<":"<<dp[j]<<" "<<ep[j]<<endl;
        }*/
    }
    if(ans==inf)ans=-1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int A1,A2,A3;
    scanf("%d %d %d",&A1,&A2,&A3);\
    int A4=A1+A2+A3;
    if(A4>=22)
        printf("bust\n");
    else
    printf("win\n");
    return 0;

}




Measured memory_bytes: 128
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int n;
    cin >> n;
    int a[2][100] = {0};
    vector<int> sum(100);

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

    for (int i = 0; i < n; i++){
        int s = 0;
        for (int k = 0; k <= i; k++){
            s += a[0][k];
        }
        for (int k = i; k < n; k++){
            s += a[1][k];
        }
        sum[i] = s;
    }

    cout << *max_element(all(sum)) << endl;



}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 303;
const int K = 1000000;
int cnt[N], b[N];
int used[K];
bitset < 200005 > bs1[N], bs2[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int k;
    cin >> k;
    vector < int > a;
    int x = 1;
    a.pb(1);
    used[1]++;
    while(1){
        x = x * 10 % k;
        if (x == 0){
            cout << 1;
            return 0;
        }
        if (used[x] == 2) break;
        used[x]++;
        a.pb(x);
    }
    for (auto i: a){
        if (used[i] == 2)
        bs2[1][i] = 1;
        bs1[1][i] = 1;
    }
    for (int i = 2; i <= 100; i++){
        if (i == 2)
        for (int j = 0; j < k; j++){
            if (bs1[1][j]){
                bs2[i] |= (bs2[i - 1] << j);
            }
        } else
        for (int j = 0; j < k; j++){
            if (bs2[1][j]){
                bs2[i] |= (bs2[i - 1] << j);
            }
        }
        for (int j = k; j <= k + k; j++){
            if (bs2[i][j]) bs2[i][j - k] = 1;
        }
        if (bs2[i][0]){
            cout << i;
            return 0;
        }
    }
}


Measured memory_bytes: 5744
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    int a[100];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    p(abs(a[0]-a[n-1]))
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a,b,c,x,r=0;
  scanf("%d%d%d%d",&a,&b,&c,&x);
  int i,j,k;
  for(i=0;i<=a;++i){
    for(j=0;j<=b;++j){
      for(k=0;k<=c;++k){
        r=500*i+100*j+50*k==x?r+1:r;
      }
    }
  }
  printf("%d\n",r);
  return 0;
}

Measured memory_bytes: 128
def main():
    n, x, mod = map(int, input().split())
    a = x
    val = set()
    val_arr = []
    idx = {}
    rep = []
    init = []
    for i in range(n):
        if a in val:
           rep = val_arr[idx[a]:]
           init = val_arr[:idx[a]]
           break
        else:
            idx[a] = i
            val.add(a)
            val_arr.append(a)
            a = a ** 2 % mod
    if len(rep) > 0:
        ans = sum(init)
        ans += sum(rep) * ((n - len(init)) // len(rep))
        ans += sum(rep[:(n - len(init)) % len(rep)])
    else:
        ans = sum(val_arr)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 86008
K = int(input())
numbers = set([])
q = set(list(map(str, [1, 2, 3, 4, 5, 6, 7, 8, 9])))
# print(f'{q=}')

while len(numbers) <= 100000:  # 10**8:
    # print('test')
    qq = set([])
    for i in q:
        # print(f'{i=}')
        if len(i) == 1:
            if i == '0':
                n = i + '0'
                qq.add(n)
                n = i + '1'
                qq.add(n)
            elif i == '9':
                n = i + '9'
                qq.add(n)
                n = i + '8'
                qq.add(n)
            else:
                v = int(i)
                n = i + str(v - 1)
                qq.add(n)
                n = i + str(v)
                qq.add(n)
                n = i + str(v + 1)
                qq.add(n)
        else:
            if i[-1] == '0':
                n = i + '0'
                qq.add(n)
                n = i + '1'
                qq.add(n)
            elif i[-1] == '9':
                n = i + '9'
                qq.add(n)
                n = i + '8'
                qq.add(n)
            else:
                v = int(i[-1])
                n = i + str(v - 1)
                qq.add(n)
                n = i + str(v)
                qq.add(n)
                n = i + str(v + 1)
                qq.add(n)
    # print(f'{qq=}')
    numbers |= q
    # print(f'{numbers=}')
    # print(f'{len(numbers)=}')
    q = qq

numbers = sorted(map(int, numbers))
# print(f'{numbers[:30]=}')
ans = numbers[K - 1]
print(ans)


Measured memory_bytes: 78776
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long long
#define ll long long

int main()
{
  ul n,k;
  int l[50];
  cin>>n>>k;
  for (size_t i = 0; i < n; i++)
  {
    cin>>l[i];
  }
  sort(l,l+n);
  ul ct=0;
  for (size_t i=n-k;i<n;i++) {
    ct+=l[i];
  }
  cout<<ct<<endl;

  return 0;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, m, a, b, f[210000];
int main(void){
    // Your code here!
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        if (a == 1) f[b]++;
        if (b == n) f[a]++;
    }
    for (int i = 2; i < n; i++) {
        if (f[i] == 2) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 1024
n=int(input())
xlr=[[] for _ in range(n)]

for i in range(n):
    xx,ll = map(int,input().split())
    xlr[i] = [xx,ll,xx-ll,xx+ll]
    
xlr.sort(key = lambda x:x[3])

ans=1
right=xlr[0][-1]
for i in range(1,n):
    if right <= xlr[i][2]:
        ans+=1
        right=xlr[i][-1]

print(ans)

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    vector<int> data(3);
    REP(i, 3) cin >> data[i];
    sort(data.begin(), data.end());

    string left = to_string(data[2]) + to_string(data[1]);
    
    int ans = stoi(left) + data[0];
    cout << ans << endl;
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; void solve(); int main(){cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(10); solve();}
using ll=int_fast64_t; using ld=long double; using pll=pair<ll,ll>; using pld=pair<ld,ld>;
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
template<class T> void vecout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n; cin>>n;
  ll N=1<<n;
  ll INF=1001001001;
  vector<ll> s(N);
  rep(i,N) cin>>s[i];
  sort(s.rbegin(),s.rend());
  vector<ll> p,q;
  // initialize
  p.push_back(s[0]);
  s[0]=INF;
  rep(i,n){
    sort(p.rbegin(),p.rend());
    q=p;
    auto it=s.begin();
    for(auto itq=q.begin();itq!=q.end();++itq){
      while(it!=s.end()){
        if(*itq<=*it){
          ++it;
        } else {
          p.push_back(*it);
          *it=INF;
          ++it;
          break;
        }
      }
    }
  }
  cout<<(p.size()==N?"Yes":"No")<<"\n";
}


Measured memory_bytes: 5612
implicit none
integer:: n,i,j,a,count
integer,allocatable:: d(:)
 
read(*,*) n
allocate(d(n))
read(*,*) d
 
do i=1,n-1
do j=i+1,n
if(d(i)>d(j))then
a=d(j)
d(j)=d(i)
d(i)=a
endif
end do
end do
 
 
count=1
do i=1,n-1
if(d(i)<d(i+1))then
count=count+1
endif
end do

write(*,*) count
 
end

Measured memory_bytes: 2828
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int gcd(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v;
	u = v;
	v = r;
  }
  return u;
}

int main(){
	int a,b;
	double x;
	while(scanf("%d",&a)!=EOF){
		cin>>b;
	cout<<gcd(a,b)<<" ";
	x=(double)a*b;
	//cout<<x<<endl;
	if(a<b){
		int tmp = a;
		a = b;
		b = tmp;
	}
	printf("%0.0f\n",x/(double)gcd(a,b));
	}
    return 0;
}

Measured memory_bytes: 1300
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<random>
#include<algorithm>
#define ll long long
using namespace std;
ll a[4];
int main()
{
    for (int i=0; i<3; ++i)
        cin>>a[i];
    sort(a,a+3);
    cout<<(a[0]*a[1])/2<<endl;
    return 0;
}


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

using namespace std;

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

  if(N == 1)
    cout << "1" << endl;

  else if(2 <= N && N <= 3)
    cout << "2" << endl;

  else if(4 <= N && N <= 7)
    cout << "4" << endl;

  else if(8 <= N && N <= 15)
    cout << "8" << endl;

  else if(16 <= N && N <= 31)
    cout << "16" << endl;

  else if(32 <= N && N <= 63)
    cout << "32" << endl;

  else
    cout << "64" << endl;
}
 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int n; cin >> n;
  int sum = 0;
  for(int i = 1; i <= n; i++){
    if(i <= 9) sum++;
    else if(i >= 100 && i <= 999) sum++;
    else if(i >= 10000 && i <= 99999) sum++;
  }
  cout << sum << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

import sys
input = sys.stdin.readline

def main():
    num = int(input())

    link = defaultdict(set)
    weight = defaultdict(int)
    for i in range(num - 1):
        a, b, c = map(int, input().split())
        link[a].add(b)
        link[b].add(a)
        weight[(min(a, b), max(a, b))] = c

    q_num, k = map(int, input().split())

    dist_data = [-1 for i in range(num + 1)]
    dist_data[k] = 0
    now_check = set()
    next_check = set()
    now_check.add(k)

    while len(now_check) > 0:
        for ele in now_check:
            now_dist = dist_data[ele]
            for now_ele in link[ele]:
                if dist_data[now_ele] != -1:
                    continue
                next_check.add(now_ele)
                dist_data[now_ele] = now_dist + weight[(min(now_ele, ele), max(now_ele, ele))]
        now_check = next_check
        next_check = set()

    for i in range(q_num):
        a, b = map(int, input().split())
        print(dist_data[a] + dist_data[b])



if __name__ == '__main__':
    main()



Measured memory_bytes: 65432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int K;

int main(void){
    
    scanf("%d", &K);
    int a = K / 2, b = K - a;
    printf("%d\n", a * b);
    
    return 0;
}

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

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int ans =700;
	vector <char> a(3);
	for (int i =0 ; i<3;i++) {
		cin >> a[i];
		if (a[i] == 'o') ans += 100;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}
vector<bool> isPrime(1000010, true);
void init() {
    isPrime[0] = isPrime[1] = false;
    repp(i,2,1000010) {
        if(isPrime[i]) {
            for (int j = i*2; j < 100010; j += i) isPrime[j] = false;
        }
    }
}

int main() {
    int X; cin >> X;
    init();
    while(true) {
        if(isPrime[X]) {
            cout << X << endl;
            return 0;
        } else {
            ++X;
        }
    }
}


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

int main(){
    string s;
    cin >> s;
    bool ac = true;
    if(s[0] != 'A')ac = false;
    int cnt = 0;
    for(int i = 2;i < s.size()-1;i++){
        if(s[i] == 'C')cnt++;
    }
    if(cnt != 1)ac = false;
    rep(i,s.size()){
        if(s[i] != 'A' && s[i] != 'C'){
            if(s[i]<'a' || s[i]>'z')ac = false;
        }
    }
    if(ac)cout << "AC" << endl;
    else cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << (((a+b)%2)?((a+b)/2+1):((a+b)/2)) << endl;
}

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

int main(void) {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << sqrt(pow(x1-x2, 2) + pow(y1-y2, 2)) << endl;
    return 0;
}

Measured memory_bytes: 3212