akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstring>
#include <iomanip>
using namespace std;

#define LL -1
#define BB -2

int main(){
  while (true) {
    int N, T, L, B;
    cin >> N >> T >> L >> B;
    if (N == 0 && T == 0 && L == 0 && B == 0) break;
    double dp[N+1][T+1][2];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    int field[N+1];
    memset(field, 0, sizeof(field));
    for (int i = 0; i < L; i++) {
      int p;
      cin >> p;
      field[p] = LL;
    }
    for (int i = 0; i < B; i++) {
      int p;
      cin >> p;
      field[p] = BB;
    }
    double ans = 0;
    for (int i = 1; i <= T; i++) {
      for (int j = 0; j < N; j++) {
        if (field[j] == BB) {
          continue;
        }
        if (field[j] == LL) dp[j][i][1] += dp[j][i-1][0];
        for (int k = 1; k <= 6; k++) {
          int np = j+k;
          if (np > N) np = N-(np-N);
          if (field[j] == LL) {
            if (field[np] == BB) {
              dp[0][i][0] += dp[j][i-1][1]/6;
            }else {
              if (np == N) ans += dp[j][i-1][1]/6;
              dp[np][i][0] += dp[j][i-1][1]/6;
            }
          }else {
            if (field[np] == BB) {
              dp[0][i][0] += dp[j][i-1][0]/6;
            }else {
              if (np == N) ans += dp[j][i-1][0]/6;
              dp[np][i][0] += dp[j][i-1][0]/6;
            }
          }
        }
      }
    }
    cout << fixed << setprecision(20)
         << ans << endl;//dp[N][T][0]+dp[N][T][1] << endl;
  }
}

Measured memory_bytes: 1396
open Hashtbl
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let k = n / 3
let h = create 100000
let c = Array.iter (fun a -> replace h a @@ if mem h a then find h a + 1 else 1) a_s; length h
let f2 z m = mem h 0 && find h 0 = z && fold (fun a c b -> if a <> 0 && c = m then true else b) h false
let g a b c = a lxor b = c || b lxor c = a || c lxor a = b
let f3 () = if c = 2 then f2 k (2 * k) else
  if c = 3 then
    let (b, acc) = fold (fun a c (b, acc) -> if not b then (b, acc) else (c = k, a :: acc)) h (true, []) in
    let acc = Array.of_list acc in
    b && g acc.(0) acc.(1) acc.(2)
  else false
let b = if c = 1 then mem h 0 else n mod 3 = 0 && f3 ()
let _ = print_endline @@ if b then "Yes" else "No"

Measured memory_bytes: 6528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct res{int num; char s[11]; int p;} res;

int com(const void *a, const void *b){
    res *r1 = (res *)a;
    res *r2 = (res *)b;
    if(strcmp(r1->s, r2->s) == 0){return r2->p - r1->p;}
    return strcmp(r1->s, r2->s);
}

int main(void){
    int n, i;
    scanf("%d", &n);
    res r[n];
    for(i = 0; i < n; ++i){
        scanf("%s %d", r[i].s, &r[i].p);
        r[i].num = i+1;
    }
    qsort(r, n, sizeof(res), com);
    for(i = 0; i < n; ++i){
        printf("%d\n", r[i].num);
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
using namespace std;
#define ll long long 
#define il inline
const int maxn=1000010;
int a[maxn],n,tot[maxn];
int prime[maxn],notprime[maxn];
int d[maxn];
int prime_tot;
il int read(){
    int x=0,f=1; char ch=getchar();
    while (ch<'0'||ch>'9') ch=getchar();
    while (ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+ch-'0'; ch=getchar();
    }
    return x*f;
}
int gcd(int x,int y){
    return (!y)?x:gcd(y,x%y);
}
void linear_seive(){
    notprime[1]=1; d[1]=1;
    for (int i=2;i<=1000000;++i){
        if (!notprime[i]){
            prime[++prime_tot]=i; d[i]=i;
        }
        for (int j=1;j<=prime_tot&&i*prime[j]<=1000000;++j){
            notprime[i*prime[j]]=1;
            d[i*prime[j]]=prime[j];
            if (!(i%prime[j])){
                break;
            }
        }
    }
}
int main(){
    //int timer=clock();
    //freopen("in.txt","r",stdin);
    linear_seive();
    //cout<<"linear_seive:"<<clock()-timer<<endl;
    n=read();
    bool ok=true;
    for (int i=1;i<=n;++i){
        a[i]=read();
    }
    sort(a+1,a+1+n); 
    int ttmp=1; while (a[ttmp]==1) ++ttmp;
    if (n-ttmp+1>prime_tot) ok=false;
    //cout<<"read:"<<clock()-timer<<endl;
    for (int i=1;i<=n;++i){
        if (!ok) break;
        int s=a[i],tmp;
        while (s!=d[s]){
            tot[s]++; tot[d[s]]++;
            if (tot[s]>1||tot[d[s]]>1){
                ok=false; break;
            }else{
                tmp=d[s];
                while (s%tmp==0) s/=tmp;
            }
        }
        if (s!=1){
            ++tot[s];
            if (tot[s]>1) ok=false;
        }
    }
    //cout<<"check ok1:"<<clock()-timer<<endl;
    if (ok){
        printf("pairwise coprime");
        exit(0);
    }
    int gd=a[1];
    for (int i=2;i<=n;++i){
        gd=gcd(gd,a[i]);
        if (gd==1) break;
    }
    //cout<<"check ok2:"<<clock()-timer<<endl;
    if (gd==1) printf("setwise coprime");
    else printf("not coprime");
}

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

int main() {
    int n;
    long h, w;
    cin >> n >> h >> w;
    long ans = 0;
    rep(i, n) {
        long a, b;
        cin >> a >> b;
        if (a >= h && b >= w) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def solve():
  M, D = map(int, input().split())
  ans = 0
  for i in range(12,D+1):
    a,b = int(str(i)[0]),int(str(i)[1])
    if a>1 and b>1:
      if a*b<=M:
        ans += 1
  return ans
print(solve())

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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
//typedef pair<int,int> P;

#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define rrep(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,n) rep(i,0,n)
#define RREP(i,n) rrep(i,n,0)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

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

  int ans = 0;
  int a,b,c,n;
  cin >> a >> b >> c >> n;
  for (int i = 0; i * a <= n; i++) {
    int left = n - i * a;
    for (int j = 0; j * b <= left; j++) {
      int lleft = left - j * b;
      if (lleft % c != 0) continue;
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int K, X;
	scanf("%d%d", &K, &X);
	for (int i = 1; i <= 2*K - 1; i++) {
		printf("%d ", X - K + i);
	}
	return 0;
}


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

//    int n=132;
//    bitset<16>binar(n);
//    int a = bitset<16>(binar).to_ulong();
//    cout<<a;

#define int long long
#define pb push_back
#define rep(i,a,b) for ( int i = a; i < b; i++)
#define all(c) (c).begin(),(c).end()

using namespace std;

signed main()
{
   int n,m;
   cin>>n>>m;
   vector<int> a(n);
   rep(i,0,n){
   	cin>>a[i];
   }
   int l,r;
   vector<int> ans(n,1);
   rep(i,0,m){
   	cin>>l>>r;
   	l--;
   	r--;
   	if(a[l]>=a[r])
   	{
   		ans[r]=0;
	   }
	   if(a[l]<=a[r]){
	   		ans[l]=0;
	   }
   }
   int val= accumulate(all(ans),0);
   cout<<val;
   
   
}
        
        
    

    





Measured memory_bytes: 4760
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
#define MAX 510000
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(b<a){a=b;return 1;}return 0;}
using namespace std;

void trace(int A[],int N){
    int i;
    for(int i=0; i<N; ++i){
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

void insertionSort(int A[],int N){
    int j,i,v;
    for(int i=1; i<N; ++i){
        v=A[i];
        j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}

int main(){
    int N,i,j;
    int A[100];
    
    scanf("%d",&N);
    for(int i=0; i<N; ++i) scanf("%d",&A[i]);
    
    trace(A,N);
    insertionSort(A,N);
    
    return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>

using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> v1(n + 1, 0);
    vector<int> v2(n + 1, 0);
    if(n == 1){
        cout << 0;
        return 0;
    }
    for(int i = 0; i < n + 1; i++){
        if(i == 0){
            v1[i] = 0;
            v2[n] = 0;
        }else{
            if(s[i - 1] == '#'){
                v1[i] = v1[i - 1] + 1;
            }else{
                v1[i] = v1[i - 1];
            }
            if(s[n - i] == '.'){
                v2[n - i] = v2[n - i + 1] + 1;
            }else{
                v2[n - i] = v2[n - i + 1];
            }
        }
    }
    vector<int> v3(n + 1);
    for(int i = 0; i < n + 1; i++){
        v3[i] = v1[i] + v2[i];
    }
    sort(v3.begin(), v3.end());
    cout << v3[0];
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main()
{
	int n, x, y;
	
	scanf("%d%d%d", &n, &x, &y);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a, a + n);
	int l = 0, r = a[n - 1] / y + 1;
	x = x - y;
	while (l <= r) {
		int m = (l + r) >> 1;
		long long s = 0;
		for (int i = 0; i < n; i++) {
			if (m * y < a[i]) {
				s += (a[i] - m * y) / x;
				if ((a[i] - m * y) % x) {
					s++;
				}
			}
		}
		if (s <= m) {
			r = m - 1;
		} else {
			l = m + 1;
		}
	}
	printf("%d\n", l);
}

Measured memory_bytes: 640
#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  lint max = std::numeric_limits<lint>::max() / 25;
  auto make_p = [&] (lint base) {
    std::vector<lint> p={1};
    while (true) {
      lint x = p.back() * base;
      if (max < x) break;
      p.emplace_back(x);
    }
    return p;
  };
  auto p2 = make_p(2);
  auto p5 = make_p(5);
  // debug(p2,p5);

  auto g = [&] (auto&& g, lint X) -> lint {
    if (X < 2) return 0;
    auto ub = std::upper_bound(all(p2),X);
    assert(ub != p2.begin());
    lint P = *std::prev(ub);
    lint x = P - 1;
    lint y = g(g, X - P);
    lint ans = x + y;
    return ans;
  };
  auto h = [&] (auto&& h, lint X) -> lint {
    if (X < 5) return 0;
    auto ub = std::upper_bound(all(p5),X);
    assert(ub != p5.begin());
    lint P = *std::prev(ub);
    lint x = P - 1;
    assert(x % 4 == 0);
    x /= 4;
    lint y = h(h, X - P);
    lint ans = x + y;
    return ans;
  };

  // rep(i,0,20) {
  //   debug(i,g(g,i));
  // }
  // rep(i,0,30) {
  //   debug(i,h(h,i));
  // }
  lint X; std::cin >> X;
  lint ans = -1;
  if (X % 2 == 1) {
    ans = 0;
  } else {
    lint x = g(g, X);
    lint y = h(h, X / 2);
    debug(x,y);
    ans = std::min(x,y);
  }
  std::cout << ans << std::endl;
  return 0;
}

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


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

    std::vector<int> X;
    for(int i=0; i<N; i++){
        int buf;
        std::cin >> buf;
        X.push_back(buf);
    }

    int res=1145141919;
    for(int p=1; p<101; p++){
        int sum=0;
        for(int i=0; i<N; i++){
            sum = sum + (X[i] - p)*(X[i] - p);
        }
        res = std::min(res, sum);
    }

    std::cout << res << '\n';

    return 0;
}


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

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

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

    ll ans = 1;
    rep(i, N) {
        ll t;
        cin >> t;
        ans = lcm(ans, t);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
dp = [[0]*3 for _ in range(n+1)]
for i in range(n):
    a, b, c = map(int, input().split())
    dp[i+1][0] = max(dp[i][1], dp[i][2])+a
    dp[i+1][1] = max(dp[i][0], dp[i][2])+b
    dp[i+1][2] = max(dp[i][0], dp[i][1])+c
print(max(dp[-1]))

Measured memory_bytes: 22764
#include <bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
using ll = long long;
using ull = unsigned long long;
using namespace std;
ll mod = 1e9 + 7;

int main(){

  int A, B ,C; cin >> A >> B >> C;
  if(A + B + C >= 22)cout << "bust" << endl;
  else cout << "win" << endl;

}

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

using namespace std;

int main(){
    int a,b,c,d;

    cin>>a>>b>>c>>d;

    //if(a-c>2*d){
    if(abs(a-c)<=d||abs(a-b)<=d&&abs(b-c)<=d){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   string s;
   cin >> s;
   int ans;
   if(s=="SUN"){
      ans = 7;
   }
   if(s=="MON"){
      ans = 6;
   }
   if(s=="TUE"){
      ans = 5;
   }
   if(s=="WED") ans = 4;
   if(s=="THU") ans = 3;
   if(s=="FRI") ans = 2;
   if(s=="SAT") ans = 1;
   cout << ans << '\n';
   return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double EPS = 1e-7;
const long long mod = 1e9 + 7;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define dist(a,b) ( pow(a.X - b.X, 2) + pow( a.Y - b.Y, 2 ) )
typedef tuple <int, int, int> line;
typedef complex <double> point;
typedef vector <point> polygon;
int h, w, ans[1005][1005];
char grid[1005][1005];
int main()
{
    Hello
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0 ; j < w; j++)
        {
            cin >> grid[i][j];
        }
    }
    ans[0][0] = 1;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if ( grid[i][j] == '#' )
                continue;
            if (i)
            {
                ans[i][j] += (ans[i - 1][j]) % mod;
            }
            if (j)
            {
                ans[i][j] += (ans[i][j - 1]) % mod;
            }
            ans[i][j] %= mod;
        }
    }
    cout << ans[h - 1][w - 1];
    return 0;
}



Measured memory_bytes: 5120
import Data.Array
import Data.List
import Control.Applicative

prime n = f 2 [] $ listArray (2, n) [2..]
  where
   f i ps _
     | i > n = ps
   f i ps lpf = do
     let ps' = if (lpf ! i) == i then ps++[i] else ps
     let nlpf = takeWhile (\p -> (p * i <= n) && (p <= (lpf ! i))) ps'
     let lpf' = lpf // map (\p-> (p * i, p)) nlpf
     f (succ i) ps' lpf'

main = do
  n <- read <$> getLine :: IO Int
  --let n = 4
  putStrLn $ intercalate " " $ map show $ take n $ filter (\i -> i `mod` 5 == 1) $ prime 3000


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

int main() {
    int n, x, d = 0, cnt = 0;
    cin >> n >> x;
    vector<int> L(n);
    rep(i, n) cin >> L[i];
    int ans;

    cnt += 1;
    rep(i, n) {
        if(d + L[i] > x)
            break;
        d += L[i];
        cnt += 1;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	string s; cin >> s; 
	int n = s.size();
	bool flag = true;
	for( int i = 0; i < n; ++i ){
		if( s[i] != s[n-i-1] ) flag = false;
	}
	for( int i = 0; i < (n-1)/2; ++i ){
		if( s[i] != s[(n-1)/2-i-1] ) flag = false;
	}
	for( int i = (n+1)/2; i < n; ++i ){
		if( s[i] != s[n-i-1+(n+1)/2] ) flag = false;
	}
	if( flag ) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

vector<ll> divisor(ll n){
	vector<ll> res;
	for(ll i = 1; i*i <= n; i++){
		if(n%i == 0){
			res.push_back(i);
			if(i != n/i) res.push_back(n/i);
		}
	}
	return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    set<ll> st;
    map<ll, int> mp;
    int one = 0;
    rep(i,n){
        cin >> a[i];
        st.insert(a[i]);
        mp[a[i]]++;
        if(a[i] == 1) ++one;
    }
    if(one == 1){
        cout << 1 << endl;
        return 0;
    }
    if(one > 1){
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    rep(i,n){
        bool ok = true;
        for(auto p : divisor(a[i])){
            if(p == a[i]){
                if(mp[a[i]] == 1) continue;
                else{
                    ok = false;
                    break;
                }
            }
            if(st.find(p) != st.end()){
                ok = false;
                break;
            }
        }
        if(ok) ++ans;
    }
    cout << ans << endl;
	return 0;
}

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

bool judge(string s) {
  int N = s.size();
  bool ans = true;
  for (int i = 0; i < N; ++i) {
    if (s[i] != s[N - i - 1]) ans = false;
  }
  return ans;
}

int main() {
  string S;
  cin >> S;
  int N = S.size();
  
  string a = "";
  for (int i = 0; i < (N - 1) / 2; ++i) a += S[i];
  string b = "";
  for (int i = (N + 3) / 2 - 1; i < N; ++i) b += S[i];
  
  if (judge(S) && judge(a) && judge(b)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;

ll lcm(int x, int y)
{
  return 1ll * x / __gcd(x, y) * y;
}

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if (fopen("A.INP", "r")){
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  }
  int n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  ll L = lcm(n, m);
  int x = L / n, y = L / m, z = __gcd(n, m);
  for (int i = 0; i < z; ++i){
    if (s[i * y] != t[i * x]){
      cout << -1;
      return 0;
    }
  }
  cout << L;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a + b == c || b + c == a || c + a == b) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


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

using namespace std;

typedef long long ll;

int main(){

	string s, t;
	
	cin >> s >> t;
	bool flag = s == t;
	for(int i=0; i<s.size(); i++){
		s = s.substr(1) + s.substr(0, 1);
		if(s == t) flag = true;
	}
	if(flag) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> p(n), x(n), q(n);
    vector<vector<int>> g(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].emplace_back(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    bool ok = true;
    function<void(int)> dfs = [&](int v) {
        if (g[v].empty()) {
            return;
        }
        vector<int> t(x[v] + 1, 1e9);
        t[0] = 0;
        for (int to : g[v]) {
            vector<int> nt(x[v] + 1, 1e9);
            dfs(to);
            for (int i = 0; i <= x[v]; i++) {
                if (i + x[to] <= x[v]) nt[i + x[to]] = min(nt[i + x[to]], q[to] + t[i]);
                if (i + q[to] <= x[v]) nt[i + q[to]] = min(nt[i + q[to]], x[to] + t[i]);
            }
            t = nt;
        }
        int mn = 1e9;
        debug(v, t);
        for (int i = 0; i <= x[v]; i++) {
            mn = min(mn, t[i]);
        }
        if (mn == 1e9) {
            puts("IMPOSSIBLE");
            exit(0);
        }
        q[v] = mn;
    };
    dfs(0);
    puts("POSSIBLE");
    return 0;
}

Measured memory_bytes: 11072
import java.util.*;

public class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        while(n-->0){
            String s = sc.next();
            int ans = 0;
            while(s.length()>=2){
                ans = 1-ans;
                int sum = (int)(s.charAt(0)-'0') + (int)(s.charAt(1)-'0');
                if(s.length()>=3) s = sum + s.substring(2,s.length());
                else s = Integer.toString(sum);
            }

            if(ans==0) System.out.println("Audrey wins.");
            else System.out.println("Fabre wins.");
        }
    }

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

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
using namespace std;
const int INF=1e17+5;
const int maxn=1e5+5;
int n,m,a[maxn],b[maxn],ans,sum;
vector<int>T[maxn];
int32_t main()
{
    IOS;
    int x,y;
    cin>>n>>x>>y;
    cout<<min(n*x,y);
    return 0;
}

Measured memory_bytes: 2560
str=input()
n=int(input())
cnt=0
for i in range(n):
    command=list(input().split())
    a=int(command[1])
    b=int(command[2])
    if command[0]=="replace":
        str=str[:a]+command[3]+str[b+1:]
    elif command[0]=="reverse":
        str=str[:a]+str[a:b+1][::-1]+str[b+1:]         
    else:
        print(str[a:b+1])


Measured memory_bytes: 5608
/*
 It's better to sleep happy and tired rather than disappointed and frustrated
 There's only 1 thing that's impossible and that is defeating a man who doesn't give up
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;

const int inf=0x3f3f3f3f;
int n ,k, ans , sum , a , b ,arr[mx5],dp[mx5];
string str;

 
int main() {
	ios::sync_with_stdio(false);
	//int t;cin>>t;while(t--)
	{
		cin>>n>>k;
		fo(i,n)cin>>arr[i];
		for(int i=n-2 ; i>=0 ; i--)
		{
			int t=inf;
			Fo(j,1,k+1)
			{
				if(i+j<n)
				{
					t=min(t,dp[i+j]+abs(arr[i]-arr[i+j]));
				}
			}
			dp[i]=t;
		}
		cout<<dp[0];
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

    int cnt = 0;
    for(int i = 1; i <= n; i++) {
        int x = (n-1)/i;
        if(1 <= x) {
            cnt += x;
        }
    }

    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3648
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ll ans = 0;
    FOR(i, 1, N+1) {
        ll lo = i;
        ll hi = (N / i) * i;
        ll cnt = hi / i - lo / i + 1;
        ans += (cnt * (lo + hi)) / 2;
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


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

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

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

    int c = 1;
    int d = 0;

    for (int i = 0; i < n; i++)
    {
        d += l[i];
        if (d <= x) c++;
    }

    cout << c << endl;
}

Measured memory_bytes: 256
n = gets.to_i
A, B = gets.chomp.split.map(&:to_i)
ps = gets.chomp.split.map(&:to_i)

no_one = ps.select { |a| a <= A }
no_two = ps.select { |a| a >= A + 1 && a <= B }
no_three = ps.select { |a| a >= B + 1 }

puts [no_one.size, no_two.size, no_three.size].min

Measured memory_bytes: 1788
import collections

N = int(input())
edges = [[None] * N for _ in range(N)]
for i in range(N):
    num_prop = int(input())
    for j in range(num_prop):
        x, y = map(int, input().split())
        edges[i][x-1] = y


def check(hs, us):
    for h in hs:
        for h2 in hs:
            if edges[h][h2] == 0:
                return False
        for u in us:
            if edges[h][u] == 1:
                return False
    return True


def search():
    maxv = 0
    maxhs = None
    maxus = None
    for i in range(1 << N):
        hs = []
        us = []
        for j in range(N):
            if (i >> j) & 1 == 1:
                hs.append(j)
            else:
                us.append(j)
        if check(hs, us):
            if maxv < len(hs):
                maxv = len(hs)
                maxhs = hs
                maxus = us
    return maxv  #, [x+1 for x in maxhs], [x+1 for x in maxus]

print(search())


Measured memory_bytes: 42332
import sys

def partition(A, p, r):
    x = A[r - 1]
    i = p - 1
    for j in range(p, r - 1):
        if A[j] <= x:
            i += 1
            tmp = A[j]
            A[j] = A[i]
            A[i] = tmp
    tmp = x
    A[r - 1] = A[i + 1]
    A[i + 1] = '[{}]'.format(tmp)

n = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

partition(A, 0, n)

print(*A)

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

int main(){
  string s;
  bool used[26] = {};
  cin >> s;
  if (s.size() < 26) {
    for (int i = 0; i < s.size(); ++i) {
      used[s[i] - 'a'] = true;
    }
    for (int i = 0; i < 26; ++i) {
      if ( !used[i] ) {
        cout << s << (char)('a' + i) << endl;
        return 0;
      }
    }
  } else {
    for (int i = 24; i >= 0; --i) {
        if (s[i] < s[i + 1]) {
            char c = s[i + 1];
            for (int j = i + 1; j < 26; ++j) {
                if (s[j] > s[i]) c = min(c, s[j]);
            }
            cout << s.substr(0, i) << c << endl;
            return 0;
        }
    }
    cout << -1 << endl;
  }
  return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n;
  cin>>n;
  n = n%10;
  if(n==2||n==4||n==5||n==7||n==9)puts("hon");
  else if(n==0||n==1||n==6||n==8)puts("pon");
  else puts("bon");

}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    ################
    class UnionFind():
        """
        parents : 親要素(findしない場合は根ではないことの注意)，根の場合は"-(要素数）"
        find(x):要素xの属するグループの根を返す
        size(x):要素xの属するグループの要素数を返す
        same(x,y):x,yが同じグループに属しているか返す
        members(x):要素xが属するグループに属する要素をリストで返す
        roots:全ての根の要素を返す
        group_count():グループの数を返す
        all_group_members():{根要素：[そのグループに含まれる要素のリスト]}の辞書を返す
        """
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            #根を探す&つなぎかえる
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.parents[x] > self.parents[y]:
                x, y = y, x

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
################


    mod=10**9+7
    N=I()
    X=[0]*N
    Y=[0]*N
    for i in range(N):
        X[i],Y[i]=MI()
    
    ans=N
    
    for ii in range(N):
        for jj in range(N):
            p=X[ii]-X[jj]
            q=Y[ii]-Y[jj]
            uf=UnionFind(N)
    
            for j in range(N):
                for k in range(N):
                    if X[k]-X[j]==p and Y[k]-Y[j]==q:
                        uf.union(j,k)
            temp=uf.group_count()
            ans=min(ans,temp)
    print(ans)
        
        

main()


Measured memory_bytes: 69872
#include<list>
#include<iostream>
#include<string>
int main(void) {
	int n;
	std::cin >> n;
	std::list<int> List;
	std::string CommandInput;
	int KeyInput;
	for (int i = 0; i < n; ++i) {		
		std::cin >> CommandInput;		
		if (CommandInput == "insert") {
			std::cin >>  KeyInput;
			List.push_front(KeyInput);
		}
		else if (CommandInput == "delete") {
			std::cin >> KeyInput;
			for (std::list<int>::iterator itr = List.begin(); itr != List.end(); ++itr) {
				if (*itr == KeyInput) {
					itr = List.erase(itr);
					break;
				}
			}
		}
		else if (CommandInput == "deleteFirst") {
			List.pop_front();
		}
		else if (CommandInput == "deleteLast") {
			List.pop_back();
		}
	}
	std::list<int>::iterator enditr = List.end();
	enditr--;		
	for (std::list<int>::iterator itr = List.begin(); itr != List.end(); ++itr) {
		if (itr != enditr) {
			std::cout << *itr << " ";
		}
		else {
			std::cout << *itr << std::endl;
		}
			}
	//system("pause");
	return 0;
}

Measured memory_bytes: 34380
#include<iostream>
#include<iomanip>
using namespace std ;
using ll = long long ;

int main(){
	double w,h,x,y ;
	cin >> w >> h >> x >> y ;
	cout << fixed << setprecision(10) << w*h/2.0 ;
	if(w==x*2.0&&h==y*2.0) cout << " 1" << endl ;
	else cout << " 0" << endl ;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
al = list(list(input()) for _ in range(h))
row = [0]*w
col = [0]*h

for i in range(h):
    for j in range(w):
        if al[i][j] == '#':
            col[i] += 1
            row[j] += 1
ans = []
w_len = len(row) - row.count(0)
for i in range(h):
    tmp = ''
    if col[i] != 0:
        for j in range(w):
            if row[j] != 0:
                tmp += al[i][j]
        ans.append(tmp)

for a in ans:
    print(*a, sep='')

Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define z 1000000007
#define sh 100000
int main()
{

	
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	ll n,k,i,j;
	cin>>n>>k;
	ll ar[n+1];
	ll pre[n+1];
	for(i=1;i<=n;i++)
	{
		cin>>ar[i];
		pre[i]=ar[i];
	}	
	for(i=2;i<=n;i++)
		pre[i]+=pre[i-1];
	ll dp[n+1][k+1];
	ll dp1[n+1][k+1];
	memset(dp,0,sizeof(dp));
	memset(dp1,0,sizeof(dp1));
	for(i=0;i<=min(ar[1],k);i++)
	{
		dp[1][i]=1;
		dp1[1][i]=dp[1][i];
	}	
	for(i=1;i<=n;i++)
	{
		dp[i][0]=1;
		dp1[i][0]=dp[i][0];
	}	
	

	for(j=2;j<=n;j++)
	{
		for(i=1;i<=k;i++)
			dp1[j-1][i]=(dp1[j-1][i-1]+dp1[j-1][i])%z;
		for(i=1;i<=k;i++)
		{
			int ind=i-ar[j]-1;
			if(ind<0)
				dp[j][i]=dp1[j-1][i];
			else
			dp[j][i]=(dp1[j-1][i]-dp1[j-1][ind]+z)%z;
			dp1[j][i]=dp[j][i];
			// cout<<i<<" "<<j<<" "<<dp[j][i]<<endl;
		}
	}
	cout<<dp[n][k];
	

}

Measured memory_bytes: 158080
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
ll counter[30];
int main(){
	ll n,ans=0;
	cin>>n;
	string str;
	cin>>str;
	for(int i=0;i<n;i++){
		ll tmp=1;
		for(int j=0;j<='z'-'a';j++){
			if(str[i]!='a'+j){
				tmp *= counter[j]+1;
				tmp%=mod;
			}
		}
		ans += tmp;
		ans %= mod;
		counter[ str[i]-'a' ]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int N,M,R;cin >> N >> M >> R;
    vector<int> r(R);
    for(int i=0; i<R; i++) cin >> r[i];
    vector<vector<ll>> d(N+1,vector<ll>(N+1,LINF));
    for(int i=0; i<M; i++){
        int a,b,c;cin >> a >> b >> c;
        d[a][b]=c;
        d[b][a]=c;
    }
    for(int i=1; i<=N; i++) d[i][i]=0;
    for(int k=1; k<=N; k++){
        for(int i=1; i<=N; i++){
            for(int j=1; j<=N; j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    ll ans=LINF;
    sort(r.begin(),r.end());
    do{
        ll cost=0;
        for(int i=0; i<R-1; i++){
            cost+=d[r[i]][r[i+1]];
        }
        ans=min(ans,cost);
    } while(next_permutation(r.begin(),r.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, K, S, i, ans=0; cin >> N >> K >> S;
for(i=0; i<K; i++){ cout << S << " "; }
if(S<=2){ for(i=K; i<N; i++){ cout << S+1 << " "; } }
else{ for(i=K; i<N; i++){ cout << S-1 << " "; } }
}

Measured memory_bytes: 1280
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int k = sc.nextInt();
		// スペース区切りの整数の入力
		int x = sc.nextInt();

		if ( k*500 >= x ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		// 出力
	}
}

Measured memory_bytes: 23764
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
void solve(){
	int n;
	cin>>n;
	vi a(n+1);
	rep(i,1,n+1){
		cin>>a[i];
	}
	vector<ll> dp(n+1,0);
	dp[1] = 0;
	vector<ll> prefix(n+1);
	prefix[1] = a[1];
	for(int i=3;i<=n;i+=2){
		prefix[i] = prefix[i-2]+a[i];
	}
	for(int i=2;i<=n;i++){
		if(i&1){
			dp[i]=max(dp[i-1],dp[i-2]+a[i]);
		}else{
			dp[i] = a[i] + dp[i-2];
			dp[i] = max(dp[i],prefix[i-1]);
		}
	}
	cout<<dp[n];
}
int main(){
    solve();
}


Measured memory_bytes: 7968
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
	int n;
	std::cin >> n;
	
	if(n % 2) std::cout << 2 * n << std::endl;
	else std::cout << n << std::endl;
	
	return 0;
}

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

int main()
{
	int a[10];

	for(int i=0;i<=3;i++){
		scanf("%1d",&a[i]);
	}

	if(a[1] == a[2] && a[1] == a[0]){
			printf("Yes\n");
	}
	else if(a[1] == a[2] && a[2] == a[3])
	{
			printf("Yes\n");
	}
	else
		printf("No\n");
}

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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 1e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;


signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int n;
   cin >> n;
   multiset <int> s;
   for (int i = 0; i < 3 * n; i++) {
      int x;
      cin >> x;
      s.insert(x);
   }
   int sum = 0;
   while (s.size()) {
      int k = *s.rbegin();
      s.erase(s.find(k));
      k = *s.rbegin();
      sum+= k, s.erase(s.find(k));
      k = *s.begin();
      s.erase(s.find(k));
   }
   cout << sum;
}

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

#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
int powmod(int a,int l, int md){a%=md; int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
int invmod(int a, int md){return powmod(a,md-2,md);}
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector< ii > vii;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return (((a%md)*(b%md))%md+md)%md;}
int addmod(int a, int b, int md) {return ((a%md+b%md)%md+md)%md;}
int submod(int a, int b, int md) {return (((a%md-b%md)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


signed main(void)
{
	IOS;
	int n; cin>>n;
	vi a(n);
	for(int i =0 ; i < n; i++)
		cin>>a[i];
	sort(all(a), greater<int>());
	multiset<ii> s;
	s.insert({a[0],a[0]});
	int ans=0;
	for(int i = 1; i < n; i++) {
		auto it = s.end();
		it--;
		ii p = *it;
		s.erase(it);
		ans += p.ff;
		s.insert({a[i], p.ff});
		s.insert({a[i], p.ss});
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 17188
n, m = map(int, input().split())
l = []
r = []
for i in range(m):
    L, R = map(int, input().split())
    l.append(L)
    r.append(R)
L1 = max(l)
R1 = min(r)
if R1 >= L1:
    print(R1 - L1 + 1)
else:
    print(0)

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

const int MOD=(int)1e9+7;
int h,w;
int dp[1005];
char a[1005];

int main(){
scanf("%d%d",&h,&w);
dp[0]=1;
for (int i=0;i<h;i++){
  scanf("%s",&a);
  for (int j=0;j<w;j++){
    if (a[j]=='#'){
      dp[j]=0;
    } else if (j!=0){
      dp[j]=(dp[j]+dp[j-1]) % MOD;
    }
  }
}
printf("%d\n",dp[w-1]);
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
  int a,b;
    cin>>a>>b;
    for(int i=0;i<=1000;i++){
        int a1 = i*0.08;
        int a2 = i*0.1;
        if(a1==a&&a2==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;


return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int int_vector_find(std::vector<int> vec,int num) {
	auto itr = std::find(vec.begin(), vec.end(), num);
	int index = std::distance(vec.begin(), itr);

	if (index != vec.size()) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {
	int n, m, x, y;
	std::cin >> n >> m >> x >> y;

	std::vector<int> a;
	std::vector<int> b;

	for (int i = 0; i < n; ++i) {
		int t;
		std::cin >> t;
		a.push_back(t);
	}

	for (int i = 0; i < m; ++i) {
		int t;
		std::cin >> t;
		b.push_back(t);
	}

	std::sort(a.begin(), a.end());
	std::sort(b.begin(), b.end());

	if (a[a.size()-1]>=y) {
		std::cout << "War" << std::endl;
		return 0;
	}
	if (b[0] <= x) {
		std::cout << "War" << std::endl;
		return 0;
	}
	if (b[0]-a[a.size()-1]>0) {
		std::cout << "No War" << std::endl;
	}
	else {
		std::cout << "War" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys

def solve(A):
    nc = 1
    while nc < len(A) and A[nc] == A[0]:
        nc += 1
    if nc > 2:
        return False
    for i in xrange(1, len(A)):
        if A[i] - A[i-1] > 1:
            return False
    c = 2
    prev = -1
    for j in xrange(nc, len(A)):
        if A[j] == prev:
            c += 1
        else:
            if c < 2:
                return False
            prev = A[j]
            c = 1
    if c < 2:
        return False
    if nc == 1:
        return A[0] * 2 == A[-1]
    else:
        return A[0] * 2 - 1 == A[-1]

sys.stdin.readline()
A = map(int, sys.stdin.readline().split())
A.sort()
print "Possible" if solve(A) else "Impossible"


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	ll a, b, k;
	cin >> a >> b >> k;

	if (k >= a + b)
	{
		cout << "0 0\n";
		return 0;
	}

	ll g = min(k, a);
	k -= g;
	a -= g;

	g = min(k, b);
	b -= g;

	cout << a << " " << b << "\n";

	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N, H;
    cin >> N >> H;
    vector<ll> a(N), b(N);
    rep(i, N) cin >> a[i] >> b[i];

    sort(ALL(a), greater<ll>());
    sort(ALL(b), greater<ll>());

    ll ans = 0;
    rep(i, N) {
        if (b[i] <= a[0]) break;

        H -= b[i];
        ans++;
        if (H <= 0) {
            cout << ans << endl;
            return 0;
        }
    }

    ans += ceil((double)H / (double)a[0]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4764
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,m=101,s=0,t,i,res;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> t;
    s+=t;
    if(t%10!=0)
      m=min(m,t);
  }
  res=s;
  if(s%10==0){
    res=s-m;
    if(m>100)
      res=0;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3616