akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
#define MAX 10000
#define NIL -1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<double, double> doup;


int main(void) {
    ll N;
    cin >> N;
    ll i, j;
    ll s, t;
    for(i=1; i<=3500; i++) {
        for(j=1; j<=3500; j++) {
            s=N*i*j;
            t=4*i*j-N*(i+j);
            if(t>0 && s%t==0) {
                cout << s/t << " " << i << " " << j << endl;
                return 0;
            }
        }
    }
    
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    vl A(N); REP(i, N) cin >> A[i];
    vl prev(N);
    stack<PL> st;
    st.push({-1,0});
    REP(i, N){
        while (st.top().ss >= A[i]) {
            st.pop();
        }
        prev[i] = st.top().ff;
        st.push({i, A[i]});
    }
    while(!st.empty()) st.pop();
    
    vl post(N);
    st.push({N,0});
    for (ll i = N-1; i >= 0; i--) {
        while(st.top().ss >= A[i]){
            st.pop();
        }
        post[i] = st.top().ff;
        st.push({i, A[i]});
    }
    
    ll ans = 0;
    REP(i, N)
        ans += A[i] * (post[i] - i) * (i - prev[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B,K;
    cin >> A >> B >> K;
    if(A+B<=K) cout << 0 << " " << 0 << endl;
    else if(K>A) cout << 0 << " " << B-(K-A) << endl;
    else cout << A-K << " " << B << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF 100100100

int main(void)
{
    int n, k, h[100100];
    scanf("%d%d", &n, &k);
    rep(i, n)
        scanf("%d", &h[i]);

    int dp[100100] = {0};
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++)
    {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        for (int j = 2; j <= k; j++)
            if (i - j >= 0)
                dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
    }

    printf("%d\n", dp[n - 1]);
    return 0;
}

Measured memory_bytes: 896
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
int main(){
  ll i,j=0,N,M,ans=0,f=1;
  cin>>N;
  vec a(N),b(N);
  rep(i,N){
    cin>>a[i];
    ans-=a[i];
  }
  rep(i,N){
    cin>>b[i];
    ans+=b[i];
    if(b[i]>a[i])j+=(b[i]-a[i]+1)/2;
  }
  if(j<=ans){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def eratosthenes(n):
    p = []
    t = [True] * n

    for i in range(2, int(math.ceil(math.sqrt(n)))):
        if t[i]:
            p.append(i)
            for j in range(2*i, n, i):
                t[j] = False

    for j in range(i+1, n):
        if t[j]:
            p.append(j)

    return p


# error_print(len(P))

@mt
def slv(N, A):
    P = eratosthenes(10**6+1)
    P = set(P)
    # random.shuffle(A)

    for a in A:
        u = set()
        if a in P:
            P.remove(a)
            a = 1

        for p in P:
            if a % p == 0:
                u.add(p)
            while a % p == 0:
                a //= p
            if a == 1:
                break

        if a != 1:
            break
        P -= u
    else:
        return 'pairwise coprime'

    g = 0
    for a in A:
        g = math.gcd(a, g)
    return 'setwise coprime' if g == 1 else 'not coprime'


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))

    # P = eratosthenes(10**6+1)
    # N = len(P)
    # A = P[::-1]

    # error_print(N)
    # print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 204512
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, X;
    cin >> N >> X;
    vector<ll> L(N);
    for (ll i = 0; i < N; i++) {
        cin >> L[i];
    }

    ll D = 0;
    ll ans = 1;
    for (ll i = 0; i < N; i++) {
        if ((D += L[i]) <= X) {
            ans++;
        } else {
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

min, max = map(int, input().split())

for i in range(M-1):
    l, r = map(int, input().split())
    if min < l:
        min = l
    if max > r:
        max = r



lis = [i for i in range(min, max+1)]
print(len(lis))





Measured memory_bytes: 7092
#include <bits/stdc++.h>
#define ll long long
#define str string
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define pq priority_queue
using namespace std;
int main () {
	ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	scanf("%lld", &a);
	b = a / 11 * 2;
	c = a / 11 * 11;
	if (a - c > 0 && a - c <= 6) b++;
	else if (a - c > 6) b += 2;
	printf("%lld\n", b);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, s[10], i, j, k=0, g=0, h=0;
    scanf("%d",&n);
    s[0] = n/1000;
    s[1] = n/100%10;
    s[2] = n/10%10;
    s[3] = n%10;
    for (i=0;i<4;i++)
    {
        for (j=(i+1);j<4;j++)
        {
            if (s[i] == s[j])
            {
                k++;
            }
        }
    }
    for (i=0;i<3;i++)
    {
        for (j=(i+1);j<3;j++)
        {
            if (s[i] == s[j])
            {
                g++;
            }
        }
    }
    for (i=1;i<4;i++)
    {
        for (j=(i+1);j<4;j++)
        {
            if (s[i] == s[j])
            {
                h++;
            }
        }
    }
    if (k==4 || g==3 || h==3)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

bool is(char c)
{
    return c == 'A' or c == 'C' or c=='G' or c=='T';
}

int main()
{
    string S;
    cin >> S;
    ll max = -1;
    ll len = S.size();
    rep(i, 0, len) {
        ll cnt = 0;
        rep(j, i, len) {
            if (is(S[j])) {
                ++cnt;
            } else {
                break;
            }
        }
        if (cnt > max) {
            max = cnt;
        }
    }
    cout << max << endl;
}

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

typedef long long ll;
const ll INF = 1e10;

int main(int argc, char* argv[])
{
  ll N;
  std::cin >> N;
  std::vector< std::vector<ll> > vopen(N, std::vector<ll>(10, 0LL));
  for (ll y = 0; y < N; y++) {
    for (ll x = 0; x < 10; x++) {
      std::cin >> vopen[y][x];
    }
  }
  std::vector< std::vector<ll> > vp(N, std::vector<ll>(11, 0LL));
  for (ll y = 0; y < N; y++) {
    for (ll x = 0; x < 11; x++) {
      std::cin >> vp[y][x];
    }
  }

  ll ans = -INF;
  for (ll S = 1; S < std::pow(2, 10); S++) {
    ll state = S;
    ll opened[10];
    ll i = 0;
    std::fill(opened, opened + 10, 0LL);
    while (state > 0) {
      opened[i] = state % 2;
      state /= 2;
      i++;
    }
    ll benefit = 0LL;
    for (ll y = 0; y < N; y++) {
      ll cnt = 0;
      for (ll x = 0; x < 10; x++) {
	if ((vopen[y][x] & opened[x]) == 1) {
	  cnt++;
	}
      }
      benefit += vp[y][cnt];
    }
    ans = std::max(ans, benefit);
  }

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


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}
 
ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
string s;
cin >> s;
deque<char> ss;
rep(i,s.size()) {
    ss.pb(s[i]);
}
int q;
cin >> q;
int t,f;
char c;
bool flg = true;
int cnt=0;
rep(i,q) {
    cin >> t;
    if (t==1) {
        if (flg == true) {
            flg=false;
        } else {
            flg =true;
        }
        cnt++;
    }
    if (t==2) {
        cin >> f >> c;
        if (flg==false) {
            if (f==1) {
                ss.push_back(c);
            }
            if (f==2) {
                ss.push_front(c);
            }
        } else {
            if (f==1) {
                ss.push_front(c);
            } else {
                ss.push_back(c);
            }
        }
    }
}
string res;
for(auto a:ss) {
    res += a;
}
if (cnt%2==1) {
    reverse(all(res));
}
ct(res);


}

Measured memory_bytes: 1368
import scala.io.StdIn.{readLine,readInt}
/**
  * AOJ
  */

object Main {

  def main(args: Array[String]): Unit = {

    val dice1 = read
    val dice2 = read

    println(if(find(dice1,dice2)){"Yes"}else{"No"})
  }

  def find(dice1:Array[Int],dice2:Array[Int]) : Boolean = {
    for(i <- createDiceArray(dice1,"WNNNW"); j <- createDiceArray(i,"HHH")){
      if(diceMatch(j,dice2)){return true}
    }
    return false
  }

  def createDiceArray(dice:Array[Int],commands:String) : List[Array[Int]] = {
    var dices = List(dice)
    for(cmd <- commands.toCharArray){
      dices :+= getNextStatus(cmd,dices.last)
    }
    dices
  }

  def read() : Array[Int] = {readLine().split(" ").map(_.toInt)}

  def diceMatch(dice1:Array[Int],dice2:Array[Int]):Boolean = (dice1 zip dice2).forall(x => x._1 == x._2)

  def getNextStatus(cmd:Char,dice:Array[Int]): Array[Int] = {
    cmd match {
      case 'N' => Array(dice(1), dice(5), dice(2), dice(3), dice(0), dice(4))
      case 'W' => Array(dice(2), dice(1), dice(5), dice(0), dice(4), dice(3))
      case 'H' => Array(dice(0), dice(2), dice(4), dice(1), dice(3), dice(5))
    }
  }
}

Measured memory_bytes: 44228
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi t(n),a(n);
    rep(i,n)cin>>t[i];
    rep(i,n)cin>>a[i];
    vi y(n);
    y[0]=t[0];
    Rep(i,1,n){
        if(t[i]!=t[i-1])y[i]=t[i];
    }
    if(y[n-1]!=0&&y[n-1]!=a[n-1]){
        cout<<0<<endl;
        return;
    }
    y[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--){
        if(a[i]!=a[i+1]){
            if(y[i]!=0&&y[i]!=a[i]||y[i]==0&&a[i]>t[i]){
                cout<<0<<endl;
                return;
            }
            y[i]=a[i];
        }
    }
    int ans=1;
    rep(i,n){
        // cout<<y[i]<<" ";
        if(y[i]==0)ans=ans*min(t[i],a[i])%mod;
    }
    // cout<<endl;
    cout<<ans<<endl;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, bool> PAIR;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

const int MAX_N = 1e5;
PAIR box[MAX_N];

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

    rep(i, N) box[i] = PAIR(1, i == 0);

    rep(i, M) {
        int X, Y;
        cin >> X >> Y;
        X--, Y--;

        box[Y] = PAIR(box[Y].first + 1, box[Y].second | box[X].second);
        box[X].first--;
        box[X] = PAIR(box[X].first, box[X].first && box[X].second);
    }

    int ans = 0;
    rep(i, N) ans += box[i].second;
    cout << ans << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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;

int main(){
    Init();
    ll n; cin >> n;
    
    // 0とn+1が終点（0）
    vi a(n+2, 0);
    vi b(n+2, 0);
    // 予定変更がない場合の移動費
    ll sum = 0;

    // a1~anを入力するとともに、各iとi-1の移動費を計算
    for(ll i=1; i<=n; i++){
        cin >> a[i];
        b[i] = abs(a[i-1]-a[i]);
        sum += b[i];
    }
    b[n+1] = abs(a[n]-a[n+1]);
    sum += b[n+1];
    
    // i番目の場所に訪れない場合をそれぞれ出力
    for(ll i=1; i<=n; i++) cout << sum - b[i] - b[i+1] + abs(a[i-1]-a[i+1]) << endl;
    return 0;
}

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

using namespace std;

int main() {
  int D, N;
  cin >> D >> N;
  if (N == 100) N = 101;
  if (D == 0) cout << N << endl;
  else if (D == 1) cout << N * 100 << endl;
  else cout << N * 100 * 100 << endl;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	N--;
	cout << N * (N + 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

N = iin()
abc = [iln() for _ in range(N)]

dp = [[0 for _ in range(3)] for _ in range(N+1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k: continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j]+abc[i][k])

print(max(dp[N]))


Measured memory_bytes: 100180
import numpy as np
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans_list = [v[i]-c[i] for i in range(n)]
ans = 0
for i in range(n):
    if ans_list[i] > 0:
        ans += ans_list[i]
print(ans)

Measured memory_bytes: 21272
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main(){
    ll n;
    cin>>n;
    double v[55];
    rep(i,0,n)cin>>v[i];
    sort(v,v+n);
    double ans=0;
    rep(i,0,n-1){ans=(v[i]+v[i+1])/2;v[i+1]=ans;}
    printf("%.12lf",ans);
}

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 int long long
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;
int _x[] = {0, 0, -1, 1, -1, 1, -1, 1};
int _y[] = { -1, 1, 0, 0, 1, -1, -1, 1};

void solve() {
	int n;
    cin >> n;
    int ans = 0;
    for(int i=1; i<=n; ++i){
        int a = log2(i)/log2(10);
        if((a+1) % 2 == 1)
            ans++;
    }
    cout << ans << "\n";
}

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


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int main() {
    int X;
    cin >> X;
    int ans = 1;
    for(int b = 2; b <= 31; b++) {
        int p = 2;
        while(pow(b,p)<=X) {
            ans = max(ans, (int)pow(b,p));
            p++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main()
{
	int hM[10], I, K, temp;

	for(I = 0; I < 10; I = I + 1)
		scanf("%d", &hM[I]);

	for(I = 0; I < 9; I = I + 1)
		for(K = 0; K < 9 - I; K = K + 1)
			if(hM[K] < hM[K + 1])
			{
				temp = hM[K];
				hM[K] = hM[K + 1];
				hM[K + 1] = temp;
			}

	for(I = 0; I < 3; I = I + 1)
		printf("%d\n", hM[I]);

	return 0;
}



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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for(int x = 0; x <= k; x++) {
    for(int y = 0; y <= k; y++) {
      int z = s - x -y;
      if(0 <= z && z <= k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
index = 1
s =  $stdin.gets.chomp
q =  $stdin.gets.chomp
a = Array.new()
a.push s
is_reverse = false
while line = $stdin.gets
  t, f, c = line.chomp.split.map{|a| a}
  if t == '1' then
    is_reverse = !is_reverse
  else
    if f == '1' then
      if is_reverse then
        a.push c
      else
        a.unshift c
      end
    else
      if is_reverse then
        a.unshift c
      else
        a.push c
      end
    end
  end
end
s = a.join
s.reverse! if is_reverse
puts s

Measured memory_bytes: 17148
def partition(hoge):
    x = hoge[-1]
    i = -1
    for j in range(len(hoge)):
        if hoge[j] <= x:
            i += 1
            tmp = hoge[i]
            hoge[i] = hoge[j]
            hoge[j] = tmp
    """        
    tmp = hoge[i+1]
    hoge[i+1] = hoge[-1]
    hoge[-1] = tmp
    """
    return i
    
if __name__ == '__main__':
    _ = input()
    hoge = [int(x) for x in input().split()]
    part = partition(hoge)
    ans = list()
    for num, elem in enumerate(hoge):
        if num == part:
            ans.append('[{}]'.format(elem))
        else:
            ans.append(str(elem))
    print (' '.join(ans))


Measured memory_bytes: 16600
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

//素数ならtrue
bool prime[55560];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  memset(prime, true, sizeof(prime));
  prime[0] = prime[1] = false;
  for (int i = 2; i * i <= 55560; i++) {
    if (prime[i]) {
      for (int j = 2 * i; j <= 55560; j += i) {
        prime[j] = false;
      }
    }
  }

  VI v;
  FOR(i, 1, 55556) {
    if(prime[i] && i%5 == 1) {
      v.PB(i);
    }
  }
  
  int n;
  cin >> n;
  REP(i, n) {
    cout << v[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3

import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n, m = read_list(int)
    heights = read_list(int)
    roads = [None] * m
    for i in range(m):
        roads[i] = tuple(read_list(int))

    is_good = [True] * n
    for (src, dst) in roads:
        src -= 1
        dst -= 1
        if heights[src] <= heights[dst]:
            is_good[src] = False
        if heights[src] >= heights[dst]:
            is_good[dst] = False
    print(len([i + 1 for i in range(n) if is_good[i]]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 30380
#include <stdio.h>
#include <string.h>

int main()
{
	char s[100010];
	int i, c;

	scanf("%s", s);

	i = 0;
	while(s[i]){
		if(s[i] == 'd'){
			if(s[i+1] == 'r'&& s[i+2] == 'e' && s[i+3] == 'a' && s[i+4] == 'm') i = i+5;
			else break;
		}
		else if(s[i] == 'e'){
			if(s[i+1] == 'r' && s[i+2] == 'a' && s[i+3] == 's' && s[i+4] == 'e'){
				i = i+5;
			}
			else{
				if(s[i-1] == 'm' && s[i+1] == 'r') i = i + 2;
				else break;
			}
		}
		else{
			if(s[i] == 'r' && s[i-1] == 'e') i = i + 1;
			else break;
		}
	}

	if(s[i]) printf("NO");
	else printf("YES");

return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
  while(1){
    int n;
    scanf("%d", &n);
    if(n == 0) break;
    int points[n];
    for ( int i = 0; i < n; i++ ){
      scanf( "%d", &points[i] );
    }
    int sum = 0;
    for (int i = 0; i < n ; i++ ){
      sum += points[i];
    }
    double avg;
    avg = 1.0*sum / n;
    double devpoints[n];
    for (int i = 0; i < n; i++ ){
      devpoints[i] = (points[i] - avg)*(points[i] - avg);
    }
    double a2 = 0.0;
    for ( int i = 0; i < n; i++ ){
      a2 += devpoints[i];
    }
    double a;
    a = sqrt(a2/n);


    printf("%lf\n", a);
  }
  return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
inline int newline() { putchar('\n'); return 0; }

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

    int x[n];
    rep2(i, n) cin(x[i]);

    ll result = LLONG_MAX;
    erep3(i, 1, 100) {
        ll sum = 0;
        rep2(j, n) {
            sum += pow((x[j] - i), 2);
        }
        if (sum < result) result = sum;
    }

    print(result);
    return 0;
}

Measured memory_bytes: 256
import sys
import math
in1 = sys.stdin.readlines()
"""
in1 = ['8','7 5 1 1 7 3 5 3']
in1 = ['7','6 4 0 2 4 0 2']
in1 = ['5','2 4 4 0 2']
"""
p = 10 ** 9 + 7
N = int(in1[0])
A_N = list(map(int, in1[1].split()))
A_N.sort()

ckA = []
if N % 2 == 1:
    ckA.append(0)
    oddFlag = 1
else:
    oddFlag = 0

for idx1 in range(1 + oddFlag, N, 2):
    ckA.append(idx1)
    ckA.append(idx1)

if ckA != A_N:
    print(0)
else:
    print((2 ** ((N - oddFlag) // 2)) % p)


Measured memory_bytes: 13996
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;



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

    string test[] = { "SW", "WS", "SS", "WW" };
    bool ok = false;

    FOR(k, 0, 4) {
        bool dame = false;
        string workstr(n, '.');
        string t = test[k];
        copy(t.begin(), t.end(), workstr.begin());

        FOR(i, 1, n) {
            char c = s[i];
            int idx1 = (i - 1 + n) % n;
            int idx2 = (i + 1) % n;
            bool bl = (c == 'o') ^ (workstr[i] == 'S');
            char forward;
            if (bl)
                forward = (workstr[i - 1] == 'S' ? 'W' : 'S');
            else
                forward = workstr[i - 1];

            if (workstr[idx2] != '.'&&workstr[idx2] != forward) {
                dame = true;
                break;
            }
            workstr[idx2] = forward;
        }
        if ((workstr[0] == 'S') ^ (s[0] == 'o') ^ (workstr[n - 1] != workstr[1])) {
            dame = true;
        }

        if (!dame) {
            cout << workstr << endl;
            ok = true;
            break;
        }
    }

    if (!ok)
        cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int A=0,B=0,C=0;
  cin >> A >> B >> C;
  cout << ( A==B?C:A==C?B:A ) << endl;

  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> a.at(i);
    }
    int m=abs(a.at(0))+abs(a.at(N-1));
    for(int i=1;i<N;i++){
        m+=abs(a.at(i)-a.at(i-1));
    }
    for(int i=0;i<N;i++){
        int o_r,n_r;
        if(i==0){
            o_r=abs(a.at(0))+abs(a.at(0)-a.at(1));
            n_r=abs(a.at(1));
        }
        else if(i==N-1){
            o_r=abs(a.at(N-1))+abs(a.at(N-1)-a.at(N-2));
            n_r=abs(a.at(N-2));
        }
        else{
            o_r=abs(a.at(i+1)-a.at(i))+abs(a.at(i)-a.at(i-1));
            n_r=abs(a.at(i+1)-a.at(i-1));
        }
        cout << m+n_r-o_r << endl;
    }
}

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LONG_LONG_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;

int main(){
    int n,k;
    cin >> n >> k;
    ll ans  = 1;
    for(int i = 0; i < n; i++) {
        if(i == 0) {
            ans *= k;
            continue;
        }
        ans *= (k-1);
    }
    cout << ans << endl;
}

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

int main() {
  int A, B, C; cin >> A >> B >> C;
  if (max(max(A, B), C) % 2 == (A + B + C) % 2) cout << (3 * max(max(A, B), C) - A - B - C) / 2 << endl;
  else cout << 1 + (3 * max(max(A, B), C) - A - B - C + 2) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int n,a[N],x[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  for(int i=1;i<=n;i++) {
    cin >> a[i];
    x[a[i]]++;
    x[a[i]+1]++;
    if(a[i])x[a[i]-1]++;
  }
  cout<<*max_element(x,x+100001);
  return 0;
}

Measured memory_bytes: 4256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, a, b) for(ll (i)=(a);(i)<=(b);i++)
#define rFOR(i, a, b) for(ll (i)=(b);(i)>=(a);i--)
#define REP(i, n) for(ll i=0;i<n;i++)
using namespace std;

int main() {
  int a,b;
  cin>>a>>b;
  if (b>=0&&a<=0){
    cout<<"Zero"<<endl;
  }else if(a<0&&b<0&&(abs(a)-abs(b)+1)%2==1){
    cout<<"Negative";
  }else {
    cout<<"Positive";
  }
}


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

int main() {
  int N;
  cin >> N;
  
  map<string, int> dict;
  
  vector<string> S(N);
  for (; N > 0; N--) {
    string S;
    cin >> S;
    dict[S]++;    
    //cout << S << " " << dict[S] << endl;
  } 
  
    //for (const auto& [key, value] : dict) {
  int max_value = 0;
  for (auto iter = dict.begin(); iter != dict.end(); ++iter) {
    string key = iter->first;
    int value = iter->second;
    if (max_value < value) {
      max_value = value;
    }
    //cout << key << " => " << value << "\n";    
  }
  for (auto iter = dict.begin(); iter != dict.end(); ++iter) {
    string key = iter->first;
    int value = iter->second;
    if (value == max_value) {
      cout << key << endl;
    }
  }
  // cout << S.at(i) << endl;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Y;
  cin >> N >> Y;
 
  //1000->i 5000->j 10000->N-i-j
  int judge=-1;
  
  for(int i=0;i<=N;i++) {
    for(int j=0;j<=N;j++) {
      if(i+j>N) continue;
 
      if(1000*i+5000*j+10000*(N-i-j)==Y) {
	cout << N-i-j << " " << j << " " << i << endl;
	judge=1;
	break;
      }
    }
    if(judge==1) break;
  }
 
  if(judge==-1) {
    cout << -1 << " " << -1 << " " << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n, m, a, b;
  cin >> n >> m >> a >> b;
  
  int mx = a;
  int mn = b;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    mx = max(mx, a);
  }
  for (int j = 0; j < m; ++j) {
    int b;
    cin >> b;
    mn = min(mn, b);
  }
  cout << (mx < mn ? "No War" : "War") << endl;
  return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
H=list()
for i in range(N):
  hn=int(input())
  H.append(hn)
H.sort()
X=list()
for i in range(N-K+1):
  Xn=H[i+K-1]-H[i]
  X.append(Xn)
print(min(X))

Measured memory_bytes: 11288
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
 
ll dp[55][55];
 
long long nCr[51][51];
 
void init_nCr(){
  memset(nCr, 0, sizeof(nCr));
 
  nCr[0][0] = 1;
 
  for(int i = 1; i <= 50; i++){
    for(int j = 0; j <= 50; j++){
      nCr[i][j] += nCr[i - 1][j];
      if(j - 1 >= 0){
        nCr[i][j] += nCr[i - 1][j - 1];
      }
    }
  }
}
 
int main(){
	init_nCr();
	ll n,a,b;
	cin>>n>>a>>b;
	vector<ll> v;
	rep(i,0,n){
		ll c;
		cin>>c;
		v.pb(c);
	}
	clr(dp,0);
	rep(i,1,v.sz+1){
		rep(j,0,v.sz){
			dp[i][j] = max(dp[i][j],dp[i-1][j]);
			dp[i][j+1] = max(dp[i][j+1],dp[i-1][j] + v[i-1]);
		}
	}
	ll mxa = 0;
	ll mxb = 1;
	rep(i,a,b+1){
		if(dp[v.sz][i]*mxb>=mxa*i){
			mxa = dp[v.sz][i];
			mxb = i;
		}
	}
	printf("%20.20f\n", 1.*mxa/mxb);
	sort(all(v));
	reverse(all(v));
	ll ans = 0;
	set<ll> se;
	vector<ll> v1;
	rep(i,0,a){
		se.insert(v[i]);
		v1.pb(v[i]);
	}
	sort(all(v1));
	if(v[0]==1&&se.sz==1){
		rep(i,a,b+1){
			ans += nCr[n][i];
		}
		printf("%lld\n", ans);
		return 0;
	}
	map<ll,ll> ma1;
	rep(i,0,v1.sz){
		ma1[v1[i]]++;
	}
	map<ll,ll> ma2;
	rep(i,0,v.sz){
		ma2[v[i]]++;
	}
	set<ll> se2;
	rep(i,0,v1.sz){
		se2.insert(v1[i]);
	}
	vector<ll> v2(all(se2));
	if(v2.sz==1){
		ll t = 0;
		rep(i,a,b+1){
			t += nCr[ma2[v[0]]][i];
		}
		cout << t << endl;
		return 0;
	}
	ans = 1;
	rep(i,0,v2.sz){
		ans *= nCr[ma2[v2[i]]][ma1[v2[i]]];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: i32
    }

    let mut res: i64 = 0;
    for i in 1..n+1 {
        if !(i % 3 == 0 || i % 5 == 0) {
            res += i as i64;
        }
    }
    println!("{}", res);
}


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

int main(){
    int n;
    cin>>n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ans=0;
    for(auto& p:mp){
        int s=p.second;
        ans+=(ll)s*(s-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define MOD (1000000007)
#define rep(i,k) for(int i=0;i<k;++i)
#define cmp3(i,j,k,p,q,r) (i==p&&j==q&&k==r)
enum AGC{A,G,C};
int main(){
  #define int long
  int n,res=0;
  cin>>n;
  static int dp[101][4][4][4];
  rep(i,4)rep(j,4)rep(k,4) dp[3][i][j][k]=1;
  dp[3][A][G][C] = dp[3][A][C][G] = dp[3][G][A][C] = 0;
  for(int i=4;i<=n;++i){
    rep(c_4,4)rep(c_3,4)rep(c_2,4)rep(c_1,4){
      if(cmp3(c_3,c_2,c_1,A,G,C))continue;
      if(cmp3(c_3,c_2,c_1,A,C,G))continue;
      if(cmp3(c_3,c_2,c_1,G,A,C))continue;
      if(cmp3(c_4,c_2,c_1,A,G,C))continue;
      if(cmp3(c_4,c_3,c_1,A,G,C))continue;
      dp[i][c_3][c_2][c_1]+=dp[i-1][c_4][c_3][c_2]%MOD;
    }
  }
  rep(i,4)rep(j,4)rep(k,4)res+=dp[n][i][j][k]%MOD;
  cout<<res%MOD;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int i,j;
    int h,w;cin>>h>>w;
    char arr[h][w];
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin>>arr[i][j];
        }
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cout<<arr[i][j];
        }

        cout<<"\n";
        for(j=0;j<w;j++){
            cout<<arr[i][j];
        }
        cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<cmath>
#define ll long long
using namespace std;
#define rep2(i,a,n) for(int i=a;i<=n;i++)
int main(void){
    // Your code here!
  int n;
  cin>>n;
  vector<int> vec(n,0);
  
  for(int i=0;i<n;i++){
      cin>>vec[i];
  }
  
  
 ll sum=0;
  for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
          sum+=vec[i]*vec[j];
      }
  }
  cout<<sum;
}


Measured memory_bytes: 3188
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

s = ins()
t = ins()
h = {}
g = {}
for i in range(len(s)):
    if s[i] not in h:
        if t[i] not in g:
            h[s[i]] = t[i]
            g[t[i]] = s[i]
        else:
            print('No')
            exit()
    elif h[s[i]] != t[i]:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 41804