akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    int c = i;
    int ab = n - c;
    for (int j = 1; j * j <= ab; j++) {
      if(ab % j == 0){
        int x = ab / j, y = j;
        if (x == y) ans += 1;
        else ans += 2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String T = scan.next();
        char[] d = T.toCharArray();
        int len = d.length;
        for (int i = 0; i < len; i++) {
            if (d[i] == '?') {
                d[i] = 'D';
            }
        }
        System.out.println(String.valueOf(d));
    }
}


Measured memory_bytes: 41196
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long m1, d1;
  scanln(m1, d1);
  long m2, d2;
  scanln(m2, d2);
  writeln(m1 != m2 ? 1 : 0);
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (t * y < x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (t * y > x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep) ~ "\n";
  static if (__VERSION__ >= 2071) {
    readf!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "readf(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
import numpy as np

n = int(input())
a = [int(x) for x in input().split()]

m = np.zeros(max(a)+1, dtype=int)
cnt = 0

for i in a:
    m[::i] += 1
for i in a:
    if m[i] == 1:
        cnt += 1
print(cnt)

Measured memory_bytes: 51412
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    N = int(input())
    A = list(input().split())
    C = Counter(A)
    ans = 0
    for k, v in C.items():
        if v >= int(k):
            ans += v - int(k)
        else:
            ans += v
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 24516
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
ll countDivisibles(ll A, ll B, ll M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 
int main(){
	IOS;
	cout.precision(30) ;
	int n ; cin >> n ;
	vll a(n) ;for(int i = 0 ; i < n ; i++) cin >> a[i] ;
	vll gcdd(n) ;
	vll gcdg(n) ;
	gcdd[n - 1] = a[n - 1] ;
	gcdg[0] = a[0] ;
	for(int i = 1 ; i < n ; i++) gcdg[i] = __gcd(a[i] , gcdg[i - 1]) ;
	for(int i = n - 2 ; i >= 0 ; i--) gcdd[i] = __gcd(a[i] , gcdd[i + 1]) ;
	ll ans = 1 ;
	for(int i = 1 ; i < n - 1 ; i++){
		ans = max(ans , __gcd(gcdd[i + 1] , gcdg[i -1])) ;
	}
	ans = max(ans , gcdd[1]) ;
	ans = max(ans , gcdg[n - 2]) ;
	cout << ans << endl ;
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000
#define INF 100000000000000


ll gcm(ll a,ll b);
ll lcm(ll a,ll b);

int main(){
  ll n;
  cin >> n;
  vll A(n);
  ll sum = 0;
  rep(i,n){
    ll a;
    cin >> a;
    sum += a;
    if(i == 0){
      A[i] = a;
    }
    else{
      A[i] = A[i-1] + a;
    }
  }
  ll left = 0;
  ll right = 0;
  ll ans = INF;
  rep(i,n-1){
    left = A[i];
    right = sum - A[i];
    ans = min(ans,abs(left - right));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int t = sc.nextInt();
        if(x-t <= 0){
            System.out.println(0);
            return;
        }
        System.out.println(x-t);
    }
}


Measured memory_bytes: 21716
inputs = []
while str = STDIN.gets
  if str.chomp == "0 0" then break end
  inputs << str.chomp
end

def describe_rectangle(h, w)
  # puts "h = #{h}, w = #{w}"
  output = ""
  for j in 1..h do
    for i in 1..w do
      output += "#"
    end
    output += "\n"
  end
  puts output
end

# puts inputs
for num in 0..inputs.length - 1 do
  rec = inputs[num].split(" ")
  # puts "rec = #{rec}"
  describe_rectangle(rec[0].to_i, rec[1].to_i)
  puts "\n"
end

Measured memory_bytes: 13960
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n),cnt(1e6+10);
    for(auto &i:a) cin>>i;
    for(auto &i:cnt) i=0;
    
    //全体のGCDを取って2以上ならnot coprime
    int tmp = a[0];
    for(auto i:a){
        tmp = __gcd(tmp,i);
    }
    if(tmp>=2){
        cout<<"not coprime"<<endl;
        return 0;
    }

    //1を除き、同じ値があるならばsetwise coprime
    for(auto i:a){
        if(cnt[i]){
            cout<<"setwise coprime"<<endl;
            return 0;
        }
        if(i!=1){
            cnt[i]=1;
        }
    }

    //因数について、その倍数が配列中に複数存在するならsetwise coprime
    for(int i=2; i<=1e6; i++){
        int c = 0;
        for(int j=1; j*i<1e6; j++){
            c += cnt[j*i];
        }
        if(c>1){
            cout<<"setwise coprime"<<endl;
            return 0;
        }
    }
    cout<<"pairwise coprime"<<endl;
}

Measured memory_bytes: 11104
#include <stdio.h>

int main(void) {
	int n,r;
	scanf("%d",&n);
	r = n % 10;
	if(r == 2 || r == 4 || r == 5 || r == 7 || r == 9){
		printf("hon\n");
	}else if(r == 0 || r == 1 || r == 6 || r == 8){
		printf("pon\n");
	}else if(r == 3){
		printf("bon\n");
	}
	return 0;
}

Measured memory_bytes: 1620
#include<bits/stdc++.h>
#define inf 2000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef set<ll> si;
typedef multiset<ll> msi;
typedef map<ll,ll> mii;

int main()
{
    ll i,j,k;
    ll n;
    scanf("%lld",&n);
    vi vec;
    for(i=2;i*i<=n;i++){
        if(n%i==0){
            ll cnt=0;
            while(n%i==0){
                    n/=i;
                    cnt++;
            }
            vec.pb(cnt);
        }
    }
    if(n>1)
    vec.pb(1);
    ll res=0;
    for(auto v: vec){
        ll sum=0;
        for(i=1;sum+i<=v;i++){
            sum+=i;
        }
        res+=i-1;
        //printf("%lld\n",v);
    }
    printf("%lld",res);
}


Measured memory_bytes: 3796
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main(){
    double a,b,c,d,e,f,x,y;
    while(cin>>a){
        cin>>b>>c>>d>>e>>f;
        x=(c*e-b*f)/(a*e-b*d);
        y=(c*d-a*f)/(b*d-a*e);
        if(x==-0)
            x=0;
        if(y==-0)
            y=0;
        cout<<fixed<<setprecision(3)<<x<<" ";
        cout<<fixed<<setprecision(3)<<y<<endl;
    }
    return 0;
}

Measured memory_bytes: 1280
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    String s = next();

    s = s.replace("hi","");

    int lng = s.length();


    if(lng==0){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;

vp vec[MAX_N];
set<P> st;
int lm[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,n;
    cin >> h >> w >> n;
    rep(i,n){
        int u, v;
        cin >> u >> v;
        --u, --v;
        if(u >= v){
            vec[u-v].pb(P(u,v));
            st.insert(P(u,v));
        }
    }
    vec[h].pb(P(h,0));
    st.insert(P(h,0));
    rep(i,h+1){
        lm[i] = INF;
    }
    int ans = INF;
    rep(i,h+1){
        if(len(vec[i])){
            sort(all(vec[i]));
            if(i > 0){
                each(p,vec[i]){
                    if(st.find(P(p.fi-1,p.se)) == st.end()){
                        if(lm[i-1] > p.fi-1){
                            ans = cmn(ans, p.fi);
                        }
                    }
                }
            }
            lm[i] = vec[i][0].fi;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 17024
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long W, H, N;
  cin >> W >> H >> N;

  long xmin = 0, xmax = W, ymin = 0, ymax = H;

  rep (i, N) {
    long x, y, a;
    cin >> x >> y >> a;
    if (a == 1) xmin = max(xmin, x);
    if (a == 2) xmax = min(xmax, x);
    if (a == 3) ymin = max(ymin, y);
    if (a == 4) ymax = min(ymax, y);
  }

  cout << max(0l, xmax - xmin) * max(0l, ymax - ymin) << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define inf 1013161010
#define ninf -1013161010
#define mod 1000000007
#define ll long long
#define lf long double
#define in(x) scanf("%d",&x);
#define sz(x) ((int)x.size())
#define lld l64d
#define rep(i,n) for(i=0;i<n;i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define rep1(i,a,b) for(i=a;i<=b;i++)
#define rrep1(i,a,b) for(i=a;i>=b;i--)
#define stlfor(i,t) for(auto i =t.begin();i!=t.end();i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define min_pq priority_queue<pll, vector<pll>, greater<pll> >
#define vpii vector<pair<int,int> >
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define modulo %
#define moduloe %=

typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;

ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
ll add(ll a, ll b) {a+=b; while(a >= mod) a-= mod; while(a<0) a+= mod;}
ll mul(ll a, ll b) {return (a * 1LL *b % mod);}
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}

const lf pi = 2*acos(0);
const int nn = 500006;
const lf EPS = 0.000000001;

ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
void nope(int num = 0){ if(num==0) cout<<"NO"; else cout<<"-1"; exit(0); }

ll a[nn], dp[nn];
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll i,j,n,tt;
    tt=1;
    //cin>>tt;
    while(tt--)
    {
        cin>>n;
        rep(i,n)
            cin>>a[i];
        dp[0] = 0;
        dp[1] = abs(a[1] - a[0]);
        for(i=2;i<n;i++)
        {
            dp[i] = min(dp[i-1] + abs(a[i-1] - a[i]), dp[i-2] + abs(a[i-2] - a[i]));
        }
        cout<<dp[n-1]<<endl;

    }
    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int a, b;
    cin >> a >> b;
    string s = to_string(a) + to_string(b);
    int n = stoi(s);
    int x = sqrt(n);
    if (x * x == n) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<pii> task(N);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        task[i] = MP(a, b);
    }
    sort(All(task), [](pii a, pii b) {
        if(a.second == b.second) {
            return a.first > b.first;
        }
        return a.second < b.second;
    });

    int now = 0;
    rep(i, N) {
        now += task[i].first;
        if(task[i].second < now) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


char a[55][55];

int main(){FIN

    ll n;cin>>n;
    vector<double> a(n); REP(i,n) cin>>a[i];
    VSORT(a);
    double mx = a[n-1];
    double hal = a[n-1]/2;
    double base=double(mod);
    double ans=a[0];
    REP(i,n-1){
        if (abs(a[i] - hal)<base){
            ans=a[i];
            base = abs(a[i]-hal);
        }
    }
    cout<<ll(a[n-1])<<' '<<ll(ans)<<endl;
    return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,K; cin>>N>>K;
  string S; cin>>S;
  vi A,B;
  if(S[0]=='0'){
    A.pb(0);
    B.pb(0);
  }
  A.pb(0);
  rep(i,1,N){
    if(S[i]!=S[i-1]){
      B.pb(i-1);
      A.pb(i);
    }
  }
  B.pb(N-1);
  if(S[N-1]=='0'){
    A.pb(N-1);
    B.pb(N-1);
  }
  int ans=0;
  rep(i,0,A.size()-2*K){
    if(i%2==0)
      ans=max(ans,B[i+K*2]-A[i]+1);
  }
  if(ans==0) ans=N;
  cout<<ans<<endl;
  }


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


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

    int n;
    while(cin>>n){
        if(n==0) break;
        int a[n];
        double sum=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            sum+=a[i];
        }
        sum/=n;
        int ans=0;
        for(int i=0;i<n;i++){
            if(sum>=a[i]) ans++;
        }
        cout<<ans<<endl;


    }
    
}


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

#define ll long long
#define ull unsigned long long
#define first ft
#define second sc
#define pb push_back
#define mpr make_pair
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>;
#define plb pair<ll,bool>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define FORD(i,a,b) for(ll i = (a); i >= (b); i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const ll MOD = 1e9 + 7;


int main() {

	fastio;

	int n, x;
	cin >> n >> x;
	int sum = 0;
	int a;
	vector<int> v;
	int ans = 0;
	ans += n;
	while (n--)
	{
		cin >> a;
		sum += a;
		v.pb(a);
	}
	sort(all(v));

	ans += (x - sum) / v[0];
	cout << ans;

	return 0;
}


/*
				  ©Hayk⠀                                                 DONT KILL ME
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣤⣤⣤⣤⣤⣶⣦⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀                                  ⡀⣄⣤⣦⣶⣤⣤⣤⣤⣤⣠
⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⡿⠛⠉⠙⠛⠛⠛⠛⠻⢿⣿⣷⣤⡀⠀⠀⠀⠀⠀                             ⡀⣤⣷⣿⢿⠻⠛⠛⠛⠛⠙⠉⠛⡿⣿⣴⢀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⠋⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⠈⢻⣿⣿⡄⠀⠀⠀⠀                         ⠀⠀⠀⠀ ⡄⣿⣿⢻⠈⣀⣀⢀⠀⠀⠀⠀⠀⠀⠀⠋⣿⣼⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⡏⠀⠀⠀⣠⣶⣾⣿⣿⣿⠿⠿⠿⢿⣿⣿⣿⣄⠀⠀⠀                       ⠀⠀ ⠀⣄⣿⣿⣿⢿⠿⠿⠿⣿⣿⣿⣾⣶⣠⠀⠀⠀⡏⣿⣸⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⠁⠀⠀⢰⣿⣿⣯⠁⠀⠀⠀⠀⠀⠀⠀⠈⠙⢿⣷⡄⠀                           ⡄⣷⢿⠙⠈⠀⠀⠀⠀⠀⠀⠀⠁⣯⣿⣿⢰⠀⠀⠁⣿⣿⠀
⠀⠀⣀⣤⣴⣶⣶⣿⡟⠀⠀⠀⢸⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣷⠀                          ⣷⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣆⣿⣿⣿⢸⠀⠀⠀⡟⣿⣶⣶⣴⣤⣀⠀
⠀⢰⣿⡟⠋⠉⣹⣿⡇⠀⠀⠀⠘⣿⣿⣿⣿⣷⣦⣤⣤⣤⣶⣶⣶⣶⣿⣿⣿⠀                     ⠀⣿⣿⣿⣶⣶⣶⣶⣤⣤⣤⣦⣷⣿⣿⣿⣿⠘⠀⠀⠀⡇⣿⣹⠉⠋⡟⣿⢰⠀
⠀⢸⣿⡇⠀⠀⣿⣿⡇⠀⠀⠀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠀                      ⠀⠃⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠹⠀⠀⠀⠀⡇⣿⣿⠀⠀⡇⣿⢸⠀
⠀⣸⣿⡇⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠉⠻⠿⣿⣿⣿⣿⡿⠿⠿⠛⢻⣿⡇⠀⠀                        ⠀⡇⣿⢻⠛⠿⠿⡿⣿⣿⣿⣿⠿⠻⠉⠀⠀⠀⠀⠀⡇⣿⣿⠀⠀⡇⣿⣸⠀
⠀⣿⣿⠁⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣧⠀⠀                            ⠀⣧⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⣿⣿⠀⠀⠁⣿⣿⠀
⠀⣿⣿⠀⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀                            ⠀ ⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⣿⣿⠀⠀⠀⣿⣿⠀
⠀⣿⣿⠀⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀                          ⠀   ⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⣿⣿⠀⠀⠀⣿⣿⠀
⠀⢿⣿⡆⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡇⠀⠀                         ⠀⠀   ⡇⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⣿⣿⠀⠀⡆⣿⢿⠀
⠀⠸⣿⣧⡀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠃⠀⠀                         ⠀⠀  ⠃⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⣿⣿⠀⡀⣧⣿⠸⠀
⠀⠀⠛⢿⣿⣿⣿⣿⣇⠀⠀⠀⠀⠀⣰⣿⣿⣷⣶⣶⣶⣶⠶⠀⢠⣿⣿⠀⠀⠀                       ⠀⠀⠀  ⣿⣿⢠⠀⠶⣶⣶⣶⣶⣷⣿⣿⣰⠀⠀⠀⠀⠀⣇⣿⣿⣿⣿⢿⠛⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⣿⣿⡇⠀⣽⣿⡏⠁⠀⠀⢸⣿⡇⠀⠀⠀                        ⠀⠀  ⠀⡇⣿⢸⠀⠀⠁⡏⣿⣽⠀⡇⣿⣿⠀⠀⠀⠀⠀⣿⣿⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⣿⣿⡇⠀⢹⣿⡆⠀⠀⠀⣸⣿⠇⠀⠀⠀                        ⠀⠀⠀  ⠇⣿⣸⠀⠀⠀⡆⣿⢹⠀⡇⣿⣿⠀⠀⠀⠀⠀⣿⣿⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢿⣿⣦⣄⣀⣠⣴⣿⣿⠁⠀⠈⠻⣿⣿⣿⣿⡿⠏⠀⠀⠀⠀                       ⠀⠀⠀⠀ ⠏⡿⣿⣿⣿⣿⠻⠈⠀⠁⣿⣿⣴⣠⣀⣄⣦⣿⢿⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠈⠛⠻⠿⠿⠿⠿⠋⠁⠀⠀⠀⠀⠀⠀                                  ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀  ⠁⠋⠿⠿⠿⠿⠻⠛⠈⠀⠀⠀
⠀⠀⠀⠀⠀
*/

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

vector<int> comp[101];
int c=0;
stack<pair<int,int> > sst;
int cnt[101];

const int MAXN=100;
int stamp=0;//init as 0
int low[MAXN+1];
int dfn[MAXN+1];//init as 0
vector<int> edge[MAXN+1];//init clear
bool iscut[MAXN+1];//init 0
void cut(int index,int parent){
   low[index]=dfn[index]=++stamp;
   int child=0;
   //for checking the root is a cut vertex, don’t use edge.size() because of multi-edges
   for(int i=0;i<edge[index].size();i++){
      int next=edge[index][i];
      if(!dfn[next]){
      	 sst.push(make_pair(index,next));
         child++;
         cut(next,index);
         low[index]=min(low[index],low[next]);
         if(low[next]>=dfn[index]){
         	while(sst.top().first!=index){
         		comp[c].emplace_back(sst.top().second);
         		sst.pop();	
         	}
         	comp[c].emplace_back(sst.top().second);
         	sst.pop();
         	comp[c].emplace_back(index);
         	c++;
           	iscut[index]=1;
      		
      	}
      }
      else if(next!=parent)
         low[index]=min(low[index],dfn[next]);
   }
   if(parent<0&&child==1)//don’t use edge[index].size() instead of the child
      iscut[index]=0;
}


int g[101][101];
const int mod = 1e9+7;

long long int mp(long long int a,long long int b){
	a%=mod;
	long long int res=1;
	while(b){
		if(b&1)	res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}
long long int fac[1001];
long long int inv[1001];
long long int choose(int a,int b){
	return fac[a]*inv[a-b]%mod*inv[b]%mod;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	fac[0]=inv[0]=1;
	for(int i=1;i<=1000;i++)
		fac[i]=fac[i-1]*i%mod,inv[i]=mp(fac[i],mod-2);
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1,x,y;i<=m;i++){
		cin>>x>>y;
		edge[x].emplace_back(y);
		edge[y].emplace_back(x);
		g[x][y]++;
		g[y][x]++;
	}
	for(int i=1;i<=n;i++)
		if(!dfn[i])
			cut(i,-1);
	
	long long int ans=1;
	for(int i=0;i<c;i++){
		int cnt=0;
		for(int j=0;j<comp[i].size();j++)
			for(int k=j+1;k<comp[i].size();k++)
				cnt+=g[comp[i][j]][comp[i][k]];
		if(cnt<comp[i].size()){
			ans=ans*k%mod;
		}
		else if(cnt==comp[i].size()){
			long long int x=0;
			for(int j=0;j<cnt;j++){
				x=(x+mp(k,__gcd(j,cnt))*mp(cnt,mod-2))%mod;
			}
			ans=ans*x%mod;
		}
		else{
			ans=(ans*choose(cnt+k-1,k-1))%mod;
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 256
N, W = map(int, input().split())
vw = [map(int, input().split()) for _ in range(N)]
value, weight = [list(i) for i in zip(*vw)]
dp = [[0]*(W+1)]*(N+1)

dp = [[0]*(W+1) for _ in range(N+1)] 
for i in range(0,N):
    for w in range(W+1):
        #print(i,w,dp[i][w],end = ' ')
        #print("v=", value[i] ,end = ' ')
        if w >= weight[i]:
            dp[i + 1][w] = max(dp[i][w-weight[i]] + value[i] ,dp[i][w])#iの品物が入る時、weight[i]分引いたnapzacの重さのときの価値の最大値にvalue[i]を足す
        else:
            dp[i + 1][w] = dp[i][w]

dpmax = 0
for i in range(len(dp)):
    for j in range(len(dp[0])):
        if dpmax < dp[i][j]:
            dpmax = dp[i][j]
print(dpmax)            
            


Measured memory_bytes: 42184
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef pair<double, double> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 128;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const double INF = 1e35;
const int MOD = 1000000007;
double R = 1e12;
const int loop = 2500000;

vector <P> ps;
int cnt[MAX];
double nx, ny, gx, gy;

void solve(void){
    int N;
    cin >> N;
    rep(N, i) {
        double x, y;
        scanf("%lf %lf\n", &x, &y);
        ps.pb(P(x, y));
        gx += x;
        gy += y;
    }
    gx /= N;
    gy /= N;
    if (N <= 10) R /= 100;
    double theta = 0., rad = 2*PI/loop;
    rep(loop, meaningless_) {
        theta += rad;
        nx = R*cos(theta)+gx;
        ny = R*sin(theta)+gy;
        double mind = INF; int minp = -1;
        rep(N, i) {
            if (((ps[i].first-nx)*(ps[i].first-nx)+(ps[i].second-ny)*(ps[i].second-ny))<mind) {
                minp = i;
                mind = (ps[i].first-nx)*(ps[i].first-nx)+(ps[i].second-ny)*(ps[i].second-ny);
            }
        }
        cnt[minp]++;
    }
    rep(N, i) {
        printf("%.6lf\n", cnt[i]/(double)loop);
    }
}

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


Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * n / 2 + (m - 1) * m / 2;
}

Measured memory_bytes: 256
<?php

//----------------------------------------------------------------------------------
// Input
//----------------------------------------------------------------------------------
$sc = new Scanner();
$s = $sc->next();

//$h = array();
//for ($i = 0; $i < $n; $i++) {
//  $h[] = $sc->next();
//}

//  $t = array();
//  $d = array();
//  for ($i = 0; $i < $n; $i++) {
//    $t[] = $sc->next();
//    $d[] = $sc->next();
//  }



//----------------------------------------------------------------------------------
// Main
//----------------------------------------------------------------------------------

$ans = 0;

$s1 = '';
$s2 = '';
foreach (range(0, strlen($s)-1) as $i) {
  $s1 .= ($i % 2 == 0) ? '0' : '1';
  $s2 .= ($i % 2 == 1) ? '0' : '1';
}

$k1 = 0;
$k2 = 0;
foreach (range(0, strlen($s)-1) as $i) {
  if ($s1[$i] <> $s[$i]) { $k1++; }
  if ($s2[$i] <> $s[$i]) { $k2++; }
}

$ans = min($k1, $k2);



//----------------------------------------------------------------------------------
// Output
//----------------------------------------------------------------------------------
$is_large_int_ans = 0;
$is_multi_ans = 0;

if ($is_multi_ans) {
  for ($i = 0; $i < count($ans); $i++) {
    out::println($ans);
  }
} else {
  out::println($ans);
}



//----------------------------------------------------------------------------------
// Ref: https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
//----------------------------------------------------------------------------------
class Scanner {
  private $arr = array();
  private $count = 0;
  private $pointer = 0;

  private $fp = NULL;

  function __construct() {
    $folder = explode("\\", getcwd());
    if (end($folder) == 'AtCoder') {
      error_reporting(E_ERROR | E_WARNING | E_PARSE);
      $this->fp = fopen('./Input.dat' , 'r');
    } else {
      error_reporting(0);
    }
  }

  public function next() {
    if($this->pointer >= $this->count) {
      $folder = explode("\\", getcwd());
      if (end($folder) == 'AtCoder') {
        $str = trim(fgets($this->fp));
      } else {
        $str = trim(fgets(STDIN));
      }
      $this->arr = explode(' ', $str);
      $this->count = count($this->arr);
      $this->pointer = 0;
    }
    $result = $this->arr[$this->pointer];
    $this->pointer++;
    return $result;
  }
  public function hasNext() {
    return $this->pointer < $this->count;
  }
  public function nextInt() {
    return (int)$this->next();
  }
  public function nextDouble() {
    return (double)$this->next();
  }
}

class out {
  public static function println($str = "") {
    global $is_large_int_ans;
    if ($is_large_int_ans) {
      echo sprintf("%d", $str) . PHP_EOL;
    } else {
      echo $str . PHP_EOL;
    }
  }
}

?>


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

// A

void solve() {

}

int main() {
  int x;
  cin >> x;
  cout << ( x + 1 ) % 2 << endl;
  return 0;
}


Measured memory_bytes: 3620
package main

import "fmt"

var (
	n int
	m int
	vis [][]int
	s []string
	dx = [...]int {1, -1, 0, 0}
	dy = [...]int {0, 0, 1, -1}
)

type pair struct {
	x, y int
}

func newPair(x, y int) pair {
	return pair {
		x: x,
		y: y,
	}
}


func check(x, y int) bool {
	if x < 0 || y < 0 {
		return false
	}
	if x >= n || y >= m {
		return false
	}
	if s[x][y] == '#' {
		return false
	}
	if vis[x][y] != -1 {
		return false
	}
	return true
}

func bfs(sx int, sy int) int {
	ans := 0;
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			vis[i][j] = -1;
		}
	}
	vis[sx][sy] = 0;
	que := make([]pair, 0);
	que = append(que, newPair(sx, sy))
	for p := 0; p < len(que); p++ {
		x := que[p].x
		y := que[p].y
		if vis[x][y] > ans {
			ans = vis[x][y]
		}
		for dir := 0; dir < 4; dir++ {
			nx := x + dx[dir]
			ny := y + dy[dir]
			if check(nx, ny) {
				vis[nx][ny] = vis[x][y] + 1
				que = append(que, newPair(nx, ny))
			}
		}
	}
	return ans;
}

func main() {
	fmt.Scanln(&n, &m)
	s = make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scanln(&s[i])
	}
	vis = make([][]int, n)
	for i := 0; i < n; i++ {
		vis[i] = make([]int, m)
	}
	ans := 0
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if s[i][j] == '.' {
				maxDis := bfs(i, j);
				if maxDis > ans {
					ans = maxDis
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n;
string s[10001];
int as,bs,abss;
int cnt;
int main(){
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>s[i];
    for(int i=0;i<n;i++)
        for(int j=0;j<s[i].size()-1;j++)
            if(s[i][j]=='A' && s[i][j+1]=='B')
                cnt++;
    for(int i=0;i<n;i++){
        if(s[i][0]=='B' && s[i][s[i].size()-1]=='A')
            abss++;
        else if(s[i][0]=='B')
            bs++;
        else if(s[i][s[i].size()-1]=='A')
            as++;
    }
    if(as>=1 && bs>=1){
        as+=abss;
        bs+=abss;
    }
    else{
        as+=max(abss-1,0);
        bs+=max(abss-1,0);
        if(abss){
            if(as<bs)
                as++;
            else
                bs++;
        }
    }
    //cout<<as<<" "<<bs<<" "<<cnt<<endl;
    cout<<min(as,bs)+cnt<<endl;
    return 0;
}

Measured memory_bytes: 768
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int n;
    cin>>n;
    int k;
    cin>>k;
    vec a(k);
    rep(i,k) cin>>a[i];
    for(int i=0;i<(1<<n);i++){
        set<int> st;
        bool ok=true;
        for(int j=0;j<n;j++){
            if(i>>j&1){
                st.insert(j);
            }
        }
        for(int j=0;j<k;j++){
            if(!st.count(a[j])) ok=false;
        }
        if(ok){
            cout<<i<<':';
            for(auto v:st) cout<<' '<<v;
            cout<<endl;
        }
    }
}


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

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector <string> vs;

#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
//#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    int ac=0, wa=0, tle=0, re=0;
    forl(i,0,n) {
        string s;
        cin>>s;
        if(s=="AC") ac++;
        else if(s=="WA") wa++;
        else if(s=="TLE") tle++;
        else if(s=="RE") re++;
    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";
}

Measured memory_bytes: 3608
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] p = IntStream.range(0, n).map(i -> scanner.nextInt()).toArray();
			System.out.println(getResult(p, 0));
		}
	}

	/**
	 * 解説を参考に作成したメソッド
	 * 
	 * @param p     数字の配列
	 * @param start 開始インデックス
	 * @return 最小の入替え数
	 */
	private static int getResult(int[] p, int start) {
		int next = -1;
		for (int i = start; i < p.length; i++) {
			if ((i + 1) == p[i]) {
				next = i;
				break;
			}
		}
		if (next >= 0) {
			// 解説通りの条件でスワップを実施
			int result = Integer.MAX_VALUE;
			if (next == p.length - 1) {
				result = getResult(swap(p, next - 1), next - 1) + 1;
			} else {
				result = getResult(swap(p, next), next) + 1;
			}
			return result;
		}
		return 0;
	}

	/**
	 * @param p     数字の配列
	 * @param index インデックス
	 * @return 数字の配列のインデックスとインデックス＋1の要素を入替えた配列
	 */
	private static int[] swap(int[] p, int index) {
		int temp = p[index];
		p[index] = p[index + 1];
		p[index + 1] = temp;
		return p;
	}
}


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

typedef long long ll;
typedef pair<int, int> ii;

int n, a;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    bool ok = true;
    for (int i = 0; i < n; ++i) {
      cin >> a;
      if (a % 2 == 0) {
        if (a % 3 && a % 5)
          ok = false;
      }
    }
    if (ok)
      cout << "APPROVED" << endl;
    else
      cout << "DENIED" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int arr[100006];
int n,k,h[100005];
int solve(int indx){
if(indx==n-1){
    return 0;
}
if(indx>n-1){
    return 2e9;
}
if(arr[indx]!=-1){
    return arr[indx];
}
int ans=2e9;
for(int i=1;i<=k;i++){
    ans=min(ans,solve(i+indx)+abs(h[indx+i]-h[indx]));
}
arr[indx]=ans;
return ans;
}
int main()
{
memset(arr,-1,sizeof arr);
cin >> n >> k;
for(int i=0;i<n;i++){
    cin >> h[i];
}
cout << solve(0);
    return 0;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 5e3+5;


int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<pii> p(n+1);
    vector<vector<int>> cnt(10, vector<int>(10));
    fore(i,1,n) {
        int r = i%10;
        int l = i;
        while(l/10 > 0) l /= 10;
        p[i] = {l,r};
        cnt[l][r]++;
    }

    LL ans = 0;
    fore(i,1,n) {
        int l = p[i].fi;
        int r = p[i].se;
        ans += cnt[r][l];
    }

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << "\n";

signed main()
{
	//freopen("in,txt", "r",stdin);
	//freopen("out.txt" ,"w", stdout);
	
	int a, b; cin >> a >> b;
	
	for(int i = 1, j = 2; i <= 998; i++, j++)
	{
		int x = i * (i+1)/2;
		int y = j * (j+1)/2;
		if(a - x == b - y)
		{
			cout << abs(a - x) << "\n";
			return 0;
		}
	}
	
	
}

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

int main() {

  int a,b,c,d,e;
	cin >>  a >> b >> c >> d >> e;
	
	if(a==0){
	cout << 1 << endl;
	}	
	if(b==0){
	cout << 2 << endl;
	}if(c==0){
	cout << 3 << endl;
	}if(d==0){
	cout << 4 << endl;
	}if(e==0){
	cout << 5 << endl;
	}
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

ll extgcd(ll a,ll b, ll &x, ll &y){ //extended Euclidean algorithm, used for modular multiplicative inverse
    ll d = a;
    if (b != 0){
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else{
        x = 1; y = 0;
    }
    return d; //return gcd(a,b)
}

ll mod_inv(ll a, ll m = MOD){ //return inv(a) mod m, ax+my=gcd(a,m)=1, m is prime int, ax-1=mq equiv. ax-mq=1
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m; //From (possibly) negative x to positive x
}


void solve() {
    ll n;
    cin >> n;
    if (n ==1) {
        cout << 1 << endl;
        return;
    }
    map<ll, int> ma;
    ll now = 2*n;
    for (ll i = 2; i*i < now; ++i) {
        while (now % i == 0) {
            ma[i]++;
            now /= i;
        }
    }
    ll ans = LLONG_MAX;
    int sz = ma.size();
    for (int i = 0; i < (1 << sz); ++i) {
        vector<bool> memo(sz, false);
        for (int j = 0; j < sz; ++j) {
            if ((i & (1 << j)) != 0) {
                memo[j] = true;
            }
        }
        ll a = 1;
        int cnt = 0;
        for (auto elem: ma) {
            if (memo[cnt++]) {
                a *= pow(elem.first, elem.second);
            }
        }
        ll b = 2*n/a;
        ll m,n;
        ll tmp;
        tmp = extgcd(a, b, m, n);
        /* cout << a << " " << b<< endl; */
        /* cout << m << " " << n << " " << tmp << endl; */
        if (-n*b > 0) ans = min(ans, -n*b);
        tmp = extgcd(b, a, m, n);
        /* cout << a << " " << b<< endl; */
        /* cout << m << " " << n << " " << tmp << endl; */
        if (-n*a > 0) ans = min(ans, -n*a);
    }
    cout << ans << endl;
}

int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 4144
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)

signed main() {
	for (string a; cin >> a && a != ".";) {
		string b; cin >> b;
		vector<string> p, q;
		string t = "";
		for (char c : a) {
			if (c != '"')
				t += c;
			else {
				p.push_back(t);
				t.clear();
			}
		}
		p.push_back(t);
		t = "";
		for (char c : b) {
			if (c != '"')
				t += c;
			else {
				q.push_back(t);
				t.clear();
			}
		}
		q.push_back(t);
		if (p.size() != q.size()) {
			cout << "DIFFERENT" << endl;
		}
		else if (p == q) {
			cout << "IDENTICAL" << endl;
		}
		else {
			int cnt = 0;
			bool close = true;
			for (int i = 0; i < p.size(); i += 2) {
				if (p[i] != q[i])
					close = false;
			}
			for (int i = 1; i < p.size(); i += 2) {
				if (p[i] != q[i])cnt++;
			}
			if (cnt == 1 && close) {
				cout << "CLOSE" << endl;
			}
			else {
				cout << "DIFFERENT" << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define INF 1000000000000
using namespace std;

int n,k;
int stones[100001];
long long dp[100001];

long long solve(int i) {
    if (i==n) return 0;
    else if (i > n) return INF;
    int r1,r2;
    if (dp[i] == INF) {
        for (int j=1; j<=k && i+j<=n; j++) {
            dp[i] = min(dp[i], solve(i+j)+(long long)fabs(stones[i+j]-stones[i]));
        }
    }
    return dp[i];
}

int main() {
    cin >> n >> k;
    fill(dp,dp+n+1,INF);
    for (int i=1; i<=n; i++) {
        cin >> stones[i];
    }
    cout << solve(1) << endl;
    return 0;
}

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

ll n;
double dp[3005][3005];
int vis[3005][3005];
double a[3005];
double rec(int i,int num )
{
	if(i==n)
	{
		if(num==0)
			return 1.0;
		return 0;
	}
	if(vis[i][num])
		return dp[i][num];
	vis[i][num]=1;
	double & res=dp[i][num];
	res=rec(i+1,num-1)*(a[i])+rec(i+1,num)*(1-a[i]);
	return res;
}

 
int main()
{
	\
	cin>>n;
	
	for(int i=0;i<n;i++)
		cin>>a[i];
	double ans=0;
	for(int i=n;i>=n/2+1;i--)
		ans=ans+rec(0,i);
	 cout << std::fixed;
  cout << std::setprecision(9);

	cout<<ans;

	
	
	
	
 
	return 0;
}

Measured memory_bytes: 105856