akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

const int MAX_N = 1e5+10;
ll dp[MAX_N][13];

int main(){
    string s;
    cin >> s;
    dp[0][0] = 1;
    int n = s.size();
    rep(i, n) {
        rep(j, 13) {
            if(s[i] == '?') {
                rep(k, 10) {
                    (dp[i+1][(j*10+k) % 13] += dp[i][j]) %= MOD;
                }
            }
            else {
                int k = s[i] - '0';
                (dp[i+1][(j*10+k) % 13] += dp[i][j]) %= MOD;
            }
        }
    }
    cout << dp[n][5] << endl;
    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            //int a = int.Parse(Console.ReadLine());
            //int b = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            //int c = int.Parse(input[2]);

            int N = b - a;
            
            // 文字列の入力
            //string s = Console.ReadLine();
            //string aaa ="Odd";
            //if (a%2==0 ||b%2==0)
            //{
            //    aaa = "Even";
            //}
            //出力
            Console.WriteLine((N*(N+1)/2)-b);
            //Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

struct BIT {
    int N;
    int data[1024 * 1024];

    BIT() {}

    void init(int n) {
        N = 1;
        while (N < n)N *= 2;
    }

    void add(int a, int v) {
        for (int x = a; x <= N; x += x & -x)data[x] += v;
    }

    int sum(int a) {
        int res = 0;
        for (int x = a; x > 0; x -= x & -x)res += data[x];
        return res;
    }
};

int N;
int A[200200];
int S[200200];
vector<int> SS;
BIT bit;

signed main() {
    int K;
    cin >> N >> K;
    rep(i, N) {
        cin >> A[i];
        A[i] -= K;
        S[i + 1] = S[i] + A[i];
        SS.push_back(S[i + 1]);
    }
    //Σ[l,r)=S[r]-S[l]
    //各rについてS[r]>=S[l](l<r)となるlの個数を求める
    //反転数
    sort(SS.begin(), SS.end());
    SS.erase(unique(SS.begin(), SS.end()), SS.end());
    rep(i, N + 1) {
        S[i] = 1 + distance(SS.begin(), l_b(SS.begin(), SS.end(), S[i]));
    }
    int ans = 0;
    bit.init(N);
    rep(i, N + 1) {
        ans += bit.sum(S[i]);
        bit.add(S[i], 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8688
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    cin>>N;
    const int mx = (int)1e+6 + 10;
    vec a(N), num(mx, 0);
    rep(i,N){
        cin>>a[i];
        ++num[a[i]];
    }
    bool pc = true, sc = true;
    vector<bool> prime(mx, true);
    for(int i = 2; i < mx; ++i){
        if(prime[i]){
            int temp = num[i];
            for(int j = i * 2; j < mx; j += i){
                prime[j] = false;
                temp += num[j];
            }
            if(temp >= 2) pc = false;
            if(temp == N) sc = false;
        }
    }
    if(pc) {
        cout<<"pairwise coprime"<<endl;
    }else if(sc) {
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }
}

Measured memory_bytes: 19092
import sys
X, N = map(int, input().split())
p = list(map(int, input().split()))
if N == 0:
    print(X)
    sys.exit(0)

x = X
y = X
i = True
while i:
    x += 1
    i = False
    for n in range(N):
        if x == p[n]:
            i = True
i = True
while i:
    y -= 1
    i = False
    for n in range(N):
        if y == p[n]:
            i = True
p.append(X)
if len(p) == len(set(p)):
    print(X)
    sys.exit(0)
if abs(X-x) < abs(X-y):
    ans = x
else:
    ans = y
print(ans)

Measured memory_bytes: 9244
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD=1e9+7;
std::vector<int> w(42,0);

signed main() {
  int N,K;cin>>N>>K;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  for(int i=0;i<42;i++){
    for(int j=0;j<N;j++){
      w[41-i]+=v[j]%2;
      v[j]/=2;
    }
  }
  std::vector<int> q(42);
  q[0]=1;for(int i=1;i<42;i++)q[i]=q[i-1]*2;
  string s;
  while(K){
    if(K%2)s+="1";
    else s+="0";
    K/=2;
  }
  while(s.size()<42)s+="0";
  reverse(s.begin(),s.end());
  int ans=0;
  for(int i=0;i<42;i++){
    if(s[i]=='0')continue;
    int res=0;
    for(int j=0;j<i;j++){
      if(s[j]=='1')res+=(N-w[j])*q[42-j-1];
      else res+=w[j]*q[42-j-1];
    }
    res+=w[i]*q[42-i-1];
    for(int j=i+1;j<42;j++)res+=max(N-w[j],w[j])*q[42-j-1];
    ans=max(ans,res);
  }
  int res=0;
  for(int j=0;j<42;j++){
    if(s[j]=='1')res+=(N-w[j])*q[42-j-1];
    else res+=w[j]*q[42-j-1];
  }
  ans=max(ans,res);
  //for(int i=0;i<42;i++)cout<<w[i]<<" ";cout<<endl;
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#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;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  string s;
  cin >> s;
  vector<int> v(N), w(N);
  v[0] = (s[0] == 'W');
  w[N - 1] = (s[N - 1] == 'E');

  rep(i, 1, N) { v[i] = (v[i - 1] + (s[i] == 'W')); }
  rrep(i, 0, N - 1) { w[i] = (w[i + 1] + (s[i] == 'E')); }

  dump(v, w);
  int ans = min(w[0], v[N - 1]);
  rep(i, 1, N - 1) { chmin(ans, v[i - 1] + w[i + 1]); }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2964
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;

  vector<int> a(N);

  F0R(i, K) {
    int d;
    cin >> d;
    F0R(j, d) {
      int A;
      cin >> A;
      a[A-1]++;
    }
  }

  int result = 0;
  F0R(i, N) {
    if (a[i] == 0) result++;
  }
  cout << result;
}
#endif


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

int main() {
  int n;
  while( cin >> n, n ) {
    vector<long> v, t;
    int x;
    for(int i=0; i<n; i++) {
      cin >> x; v.push_back(x);
    }
    sort(v.begin(), v.end());
    partial_sum(v.begin(), v.end(), back_inserter(t));
    long sum = 0;
    for(int i=0; i<n-1; i++) sum += t[i];
    cout << sum << endl;
  }
}

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

int main() {
  
  string S;
  int N, flag, i;
  
  cin >> N;
  cin >> S;
  flag = 0;
  
  for (i = 0; i < N/2; i++){
    if(S[i] != S[N/2 + i]){
      flag = 1;
    }
  }
  if(flag == 1 or 1 == N % 2){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll N=s.size();
    ll g=0,p=0;
    ll ans=0;
    for(ll i=0;i<N;++i){
        if(p<g){
            if(s[i]=='p'){p++;}
            else {p++;ans++;}
        }
        else {
            if(s[i]=='p'){g++;ans--;}
            else {g++;}
        }
    }
    prt(ans)

    return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {    
    public static void main(String[] args){        
           
        Scanner sc = new Scanner(System.in);                 
        
        int witdh  = 0;
        int height = 0;
        int W = sc.nextInt();
        int H = sc.nextInt();
        int N = sc.nextInt();
        
        int ans = W*H;
        
        for(int i = 0;i < N;i++){
           int x1 = sc.nextInt();
           int y1 = sc.nextInt();
           int  a = sc.nextInt(); 
           switch(a){
              case 1:
                if(x1 - witdh < 0 || H - height < 0)
                    continue;
                ans -= (x1 - witdh)*(H - height);
                witdh = x1;
                break;
              case 2:
                if(W - x1 < 0 || H - height < 0)
                    continue;
                ans -= (W - x1)*(H - height);   
                W = x1;
                break;
              case 3:
                if(y1 - height < 0 || W - witdh < 0)
                    continue;
                ans -= (y1 - height)*(W -witdh);
                height = y1;
                break;
              case 4:
                if(H-y1 < 0 || W - witdh < 0)
                    continue;
                ans -= (H-y1)*(W - witdh);
                H = y1;
                break;
           }           
        }
        
        if(ans < 0){
            System.out.println(0);
        }else{
            System.out.println(ans);
        }        
       
    }            
}
        

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

N,K=map(int,input().split())
mod=10**9+7

#factorial,facotiralの逆数を事前計算.
#N=10**5あたりまで有効
#以下は2*10**5までの計算

FACT=[1]
for i in range(1,2*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**5,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]*FACT_INV[a-b]%mod
    else:
        return 0


for i in range(1,K+1):
    print(Combi((N-K)-(i-1)+i,i)*Combi((K-i)+(i-1),i-1)%mod)
    


Measured memory_bytes: 19244
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int MOD = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  string s;
  cin >> s;
  
  if (s[0] == 'S')	cout << "Cloudy";
  else if (s[0] == 'C') cout << "Rainy";
  else	cout << "Sunny";
  
}

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

P_X = [list(map(int, input().split())) for _ in range(M)]

for i in range(M):
    sum = 0
    for j in range(N):
        if j + 1 == P_X[i][0]:
            sum += P_X[i][1]
        else:
            sum += T[j]
    print(sum)


Measured memory_bytes: 3060
S = input()
lens = len(S)
dpcut = [[0 for i in range(lens)] for j in range(2)]
dpmoji = [['' for i in range(lens)] for j in range(2)]
dpcut[0][0] = 1
dpmoji[0][0] = S[0]
for i in range(1,lens):
    dpmoji[1][i] = dpmoji[0][i-1] + S[i]
    dpmoji[0][i] = S[i]
    if i == 1:
        dpcut[1][i] = 1
    if i - 2 >= 0:
        dpcut[1][i] = dpcut[0][i-2] + 1
        if dpmoji[1][i-2] != dpmoji[1][i]:
            dpcut[1][i] = max(dpcut[1][i], dpcut[1][i-2]+1)
    if i - 1 >= 1:
        dpcut[0][i] = dpcut[1][i-1] + 1
    if dpmoji[0][i] != dpmoji[0][i-1]:
        dpcut[0][i] = max(dpcut[0][i], dpcut[0][i-1] + 1)
print(max(dpcut[0][lens-1], dpcut[1][lens-1]))


Measured memory_bytes: 33632
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
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(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};


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

  sort(s.begin(), s.end(), [](int a, int b)-> bool{
			     return a > b;
			   });

  vector<mint> modinv(n+1);
  rep1(i,n) modinv[i] = (mint)1 / (mint)i;
  
  vector<vector<mint>> dp(n+1, vector<mint>(x+1));
  dp[0][x].x = 1;
  rep(i,n) {
    rep(j,x+1) {
      dp[i+1][j % s[i]] += dp[i][j] * modinv[n-i];
      dp[i+1][j]        += dp[i][j] * (mint)(n - 1 - i) * modinv[n-i];
    }
  }

  mint res;
  rep(j,x+1) res += dp[n][j]*(mint)j;
  rep1(i,n) res *= (mint)i;
  cout << res.x << "\n";
  
  
  return 0;
}


Measured memory_bytes: 158592
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        for(int i = 0 ; i < arr.length ; i++){
            arr[i] = sc.nextInt();
        }
        int dp[] = new int[n];
        dp[0] = 0;
        for(int i = 1 ; i < n ; i++){
            dp[i] = dp[i-1] + Math.abs(arr[i]-arr[i-1]);
            if(i-2 >= 0){
                dp[i] = Math.min(dp[i],dp[i-2] + Math.abs(arr[i] - arr[i-2]));
            }
        }
        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 51112
let () =
    let fact = [| 1; 1; 2; 6; 24; 120; 720; 5040 |] in
    let read_seq n =
        let order mask c =
            let rec loop m c a =
                if c = 0 then a else
                    loop (m lsr 1) (c - 1) (if m land 1 = 1 then a else a + 1)
            in
            loop mask c 0
        in
        let rec loop mask acc n =
            if n = 0 then acc else
                let c = Scanf.scanf " %d" (fun c -> c - 1) in
                let o = order mask c in
                loop (mask lor (1 lsl c)) (acc + fact.(n - 1) * o) (n - 1)
        in
        loop 0 0 n
    in
    let main () =
        let n = read_line () |> int_of_string in
        let a = read_seq n in
        let b = read_seq n in
        Printf.printf "%d\n" (abs (a - b))
    in
    main ()

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int P, Q, R;
    cin >> P >> Q >> R;

    int pt1,pt2,pt3;
    pt1 = P + Q;
    pt2 = Q + R;
    pt3 = P + R;
    int min = pt1;
    if(min > pt2){
        min = pt2;
    }
    if(min > pt3){
        min = pt3;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        cin>>b[i];
    }
    rep(i,n-1){
        cin>>c[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=b[a[i]-1];
        if(i!=0){
            if(a[i-1]+1==a[i]){
                ans+=c[a[i-1]-1];
            }
        }
    }
    cout<<ans<<endl;

}

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

int main(){
	int A, B;
	string S;
	cin >> A >> B >> S;
	
	if( S.size() != A + B + 1 ){
		cout << "No" << endl;
	}
	
	else if( S.at(A) != '-' ){
		cout << "No" << endl;
	}
	
	else{
		bool def = true;
		for( int i = 0; i < S.size(); i++ ){
			if( i != A ){
				if( S.at(i) == '-' ){
					cout << "No" << endl;
					def = false;
					break;
				}
			}
		}
		if( def ){
			cout << "Yes" << endl;
		}
	}
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial,sqrt
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n,x,t=MI()
    print(t*ceil(n/x))
    
if __name__=="__main__":
    main()



Measured memory_bytes: 65496
import math


def main():
    n = int(input())
    _n = int(math.sqrt(n))
    ret = [0] * n
    for i in range(1, _n):
        for j in range(1, _n):
            for k in range(1, _n):
                tmp = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
                if tmp <= n:
                    ret[tmp-1] += 1
                else:
                    break
    for i in range(n):
        print(ret[i])

if __name__ == "__main__":
    main()


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


int main() {
    int A, B, C, D;

    cin >> A >> B >> C >> D;
    

    if (A+B > C+D) 
        cout << "Left" << endl;
    else if (A+B == C+D)
        cout << "Balanced" << endl;
    else
        cout << "Right" << endl;
}

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

int const N = 1234567;
int a[N], id[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0; i < n; i++) id[i] = i;
  std::sort(id, id + n, [](int i, int j) {
    return a[i] < a[j];
  });
  set<int> q;
  q.insert(-1);
  q.insert(n);
  long long ans = 0;
  for (int it = 0; it < n; it++) {
    int i = id[it];
    int next = *q.lower_bound(i);
    int prev = *(--(q.lower_bound(i)));
    ans += (long long) a[i] * (next - i) * (i - prev);
    q.insert(i);
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 11136
//
//  main.cpp
//  AtCoder
//
//  Copyright © 2018年 ユーマ. All rights reserved.
//

#include <iostream>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int num[200];
    int n = 0;
    
    bool end = false;
    
    int count = 0;
    
    cin >> n;
    
    for(int i = 0; i < n ; i++){
        cin >> num[i];
    }
    
    while(1){
        
        for(int i = 0; i < n; i++){
            if(num[i] % 2 == 0){
                num[i] /= 2;
            }
            else{
                end = true;
                break;
            }
        }
        
        if(end){
            break;
        }
        
        count++;
        
    }
    
    std::cout << count << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;
const int inf = 1e9;

int main(){
	ios_base::sync_with_stdio(0);
	int a,b,n,k,T,cas=0;
	cin>>n;
	vector< vector<int> > A(n, vector<int>(3));
	for(vector<int> &x: A) {
		cin>>x[0]>>x[1]>>x[2];
	}
	vector< vector<int> > dp(n+1, vector<int>(3));
	for(int i=1;i<=n;++i) {
		dp[i][0] = A[i-1][0] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = A[i-1][1] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = A[i-1][2] + max(dp[i-1][0], dp[i-1][1]);
	}
	cout<<max(dp[n][0], max(dp[n][1], dp[n][2]))<<'\n';
	return 0;
}

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

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

    //I don't care about anybody, and fuck ratings! I'll go to google!
    int n; cin>>n;
    vector<pair<int, int>> a(n);
    for(int i = 0; i<n; i++){
        cin>>a[i].first;
        a[i].second = i+1;
    }
    sort(a.begin(), a.end());
    for(int i = 0; i<n; i++) cout<<a[i].second<<" ";
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

vector<int> G[200010];
stack<ll> col[200010];
int C[200010];
ll ans[200010];

ll seg[524288];
ll app[200010];

void raq(int s = 0, int t = 262143, ll v = 1, int k = 1, int l = 0, int r = 262143) {
	if (t < l || r < s)return;
	if (s <= l && r <= t) {
		seg[k] += v;
		return;
	}
	raq(s, t, v, k * 2, l, (l + r) / 2);
	raq(s, t, v, k * 2 + 1, (l + r) / 2 + 1, r);
}

ll gets(int x) {
	x += 262144;
	ll ans = 0;
	while (x) {
		ans += seg[x];
		x /= 2;
	}
	return ans;
}

void pini(int x, ll v) {
	raq(x, x, v - gets(x));
}

ll alc = 0;

void euler(int c, int p) {

	for (int i : G[c]) {
		if (i == p)continue;
		col[C[c]].top() = gets(C[c]);
		col[C[c]].push(0);
		pini(C[c], 0);
		raq();
		raq(C[i], C[i], -1);
		euler(i, c);
	}

	if (p == 0)return;
	ll gc = gets(C[p]);
	ans[C[p]] += gc * (gc - 1LL) / 2LL;
	col[C[p]].pop();
	pini(C[p], col[C[p]].top());
	return;
}

int main() {
	for (int i = 0;i < 200010;i++)ans[i] = app[i] = C[i] = 0;
	for (int i = 0;i < 524288;i++)seg[i] = 0;
	ll N, a, b;
	cin >> N;
	for (int i = 1;i <= N;i++) {
		cin >> C[i];
		app[C[i]]++;
	}
	for (int i = 1;i < N;i++) {
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int st = 0;
	for (int i = 1;i <= N;i++) {
		if (G[i].size() == 1)st = i;
	}
	for (int i = 1;i <= N;i++) {
		if (i == C[st])col[i].push(0);
		col[i].push(1);
	}
	raq();
	raq(C[st], C[st], -1);
	euler(st, 0);
	for (int i = 1;i <= N;i++) {
		ll gc = gets(i);
		ans[i] += gc * (gc - 1LL) / 2LL;
	}
	for (int i = 1;i <= N;i++) {
		if (app[i] == 0)cout << 0 << endl;
		else
			cout << N * (N - 1) / 2 - ans[i] + app[i] << endl;
	}
}


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

int main()
{

string a,b,c ;
cin>>a>>b>>c ;
if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
        cout << "YES" ;
    } else {
        cout << "NO" ;
    }
	return 0 ;

	}


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

double istdev(vector <int> &nums){
	int n=nums.size();
	double ave;

	int s1 = 0;
	for (int i=0; i<n; i++)
		s1 += nums[i];
	ave = (double)s1/n;

	double s2 = 0;
	for (int i=0; i<n; i++)
		s2 += pow(nums[i]-ave,2);
	return sqrt(s2/n);
}

int main(void)
{
	int n;
	while (cin >> n, n != 0){
		vector <int> s(n);
		for (int i=0; i<n; i++)
			cin >> s[i];

		cout << fixed << istdev(s) << endl;
	}
	return 0;
}

Measured memory_bytes: 1264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();

		String t = s.substring(0, n / 2);

		if ((t + t).equals(s)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}

Measured memory_bytes: 39524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int  c;
  double a, b, x;
  cin >> a >> b;
  x = (a + b) / 2;
  c = x;

  if (x == c ) {
    cout << x << endl;
  } else {
    cout << c + 1 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long int lli;
#define pb emplace_back
#define mp make_pair
#define pii pair<int,int>
#define INF 1000000000
#define fastio	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int n;
pair<int,int> arr[30];

int main(){
    fastio;
    cin>>n;
    for(int i = 0;i<n;i++)
        cin>>arr[i].first;

    for(int i = 0;i<n;i++)
        cin>>arr[i].second;

    int sum = 0;
    for(int i = 0;i<n;i++){
        if(arr[i].first - arr[i].second > 0){
            sum += arr[i].first - arr[i].second;
        }
    } 

    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner=new Scanner(System.in);
		long n = scanner.nextLong();
		long a = scanner.nextLong();  //blue
		long b = scanner.nextLong();  //red
		long count=0;
		long ans=0;
//		long m = n;
//
//		while(m > 0) {
//			m -= a+b;
//			count++;
//		}
//
//		if(n - (a+b)*(count-1) > a) {
//			ans += a;
//		}else {
//			ans += n - (a+b)*(count-1);
//		}
//		ans += a * (count-1);
//
//		System.out.println(ans);
//
//
		long m = n/(a+b);
		long l = n%(a+b);
		ans += a * m;
		if(l > a) {
			ans += a;
		}else {
			ans += l;
		}

		System.out.println(ans);

		scanner.close();

	}

}


Measured memory_bytes: 35404
n=int(input())
a,b=map(int,input().split())
c=int(input())
d=sorted([int(input()) for _ in [0]*n],reverse=True)
for i in d:
    if c/a<(c+i)/(a+b):
        c+=i
        a+=b
    else:
        break
print(c//a)


Measured memory_bytes: 5604
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


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

	string A;
	cin >> A;

	vector<int>count(26, 0);
	rep(i, A.size())count[A[i] - 'a']++;

	int ans = 1 + ((A.size() * (A.size() - 1)) / 2);
	rep(i, 26)if (count[i] >= 2)ans -= count[i] * (count[i] - 1) / 2;

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 720
// #include<bits/stdc++.h>
// using namespace std;
 
// const int N = 100, MAXI = 100001, D = 9;
 
// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 100, flag = 1;
//     cout << tc << "\n";
//     int n = 1;

//     while (tc--)
//     {
    	
//     	int n = rand()%N + 1, m = rand()%N + 1;

//     	int a[n][m];
//     	for(int i=0;i<n;i++)
//     	{
//     		for(int j=0;j<m;j++)
//     		{
//     			int flag = rand()%4;
//     			if(flag==0)
//     				a[i][j] = -1;
//     			else
//     				a[i][j] = rand()%MAXI;
//     		}
//     	}

//     	a[n-1][0] = rand()%MAXI;

//     	cout << n << " " << m << "\n";
//     	for(int i=0;i<n;i++){
//     		for(int j=0;j<m;j++)
//     			cout << a[i][j] << " ";
//     		cout << "\n";
//     	}

//     	cout << "~\n";
//     }
 
//     return 0;
// }
 
 
//  int n, a[N];

// int MEM(int ind, vector<int> &v)
// {
// 	if(ind==n)
// 	{
// 		// o(n)
// 	}

// 	int ans = 0;
// 	if(a[ind]==-1)
// 	{
// 		for(int i=0;i<n;i++)
// 		{
// 			if(i!=ind)
// 			{
// 				v[ind] = i;
// 				ans += MEM(ind+1, v);
// 				if(ans>=mod)
// 					ans %= mod;
// 			}
// 		}
// 	}
// 	else
// 		ans = MEM(ind+1, v);

// 	return ans;

// }
 
 
 
 
 
//---------------------------------------------//
 
 
 
/*
#define int long long 
#define mod (int)(1e9+7)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */ 
 
 
 
 

//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(3e17+10)
#define N 200005


// Driver code to test above functions
int32_t main()
{
   
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;

	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]==0)
		{
			cout << 0;
			return 0;
		}
	}

	double ans = 0;

	for(int i=0;i<n;i++){
		ans += log10(abs(a[i]));
	}

//	cout << ans << endl;

	if(ans>18.0)
		cout << -1;
	else
	{
		int k = 1;
		for(int i=0;i<n;i++)
			k *= a[i];

		if(k>(int)(1e18))
			cout << -1;
		else
			cout << k;
	}

    return 0;
 
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define forn(i, a, b) for (int i = a; i < b; ++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

int main() {
#ifdef LOCAL
  freopen("f.txt", "r", stdin);
// freopen("main.txt", "w", stdout);
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#define dbg(...) 18
#endif
  int n;
  cin >> n;
  int a, ans = 0, mx = 0;
  while (n--) {
    cin >> a;
    if (a >= mx) {
      ans++;
      mx = a;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3664
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


yn = 'YNeos'
ynflg = False
cnt = 0
ans = None

def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



N = intinput()
xs = list(mulinputs())


l = max(xs)
total = []
m = 10**6
for p in range(l+1):
    t, larr = 0, []
    for x in xs:
        t += abs(x-p)*abs(x-p)
    if t < m:
        m = t


# 出力
print(m)




Measured memory_bytes: 5688
import collections

N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def judge(N):
  n = 0
  cnt = 0
  while n < N:
    n += cnt+1
    if n<=N:
      cnt += 1
  return cnt


c = collections.Counter(prime_factorize(N))

ans = 0


keys = c.keys()

for i in range(len(keys)):
  ans += judge(c[list(keys)[i]])

print(ans)

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
long long n,x=1,y=1,z=1,i;
int main()
{
	cin >> n;
	for (i=1; i<=n; i++)
	x=(x*10)%1000000007;
	
	for (i=1; i<=n; i++)
	y=(y*9)%1000000007;
	
	for (i=1; i<=n; i++)
	z=(z*8)%1000000007;
	if (x-y-y+z<-1000000007)
	cout<<x-y-y+z+2*1000000007;
	else
	if (x-y-y+z<0)
	cout<<x-y-y+z+1000000007;
	else
	cout<<x-y-y+z;

}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define MAX (7368791+1)
int m,n,cnt;
bool t[MAX];

int main(){
  while(1){
    cin>>m>>n;
    if(m==0&&n==0)break;
    fill(t,t+MAX,true);
    cnt=0;
    for(int i=m;i<MAX;i++){
      if(!t[i])continue;
      if(cnt==n){
        cout<<i<<endl;
        break;
      }
      cnt++;
      for(int j=i+i;j<MAX;j+=i)t[j]=false;
    }
    
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e15;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 1e5 + 100;
const int LOG = 20;
const int mod = 1e9 + 7;
const int MX = 1e6 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;

ll dp[500][500];
ll a[MAXN];
ll pref[MAXN];
void solve() {
    int n;
    cin >> n;
    for(int i=1;i<=n;++i){
        cin >> a[i];
        pref[i] = pref[i-1] + a[i];
    }
    for(int i=1;i<=n;++i){
        dp[i][i] = 0;
    }
    for(int len = 2;len<=n;++len){
        for(int l = 1;l + len - 1 <=n;l++){
            int r = l +len - 1;
            dp[l][r] = inf_ll;
            for(int j = l;j < r;++j){
                dp[l][r] = min(dp[l][r], dp[l][j] + dp[j+1][r]);
            }
            dp[l][r]+=pref[r] - pref[l-1];
        }
    }
    cout << dp[1][n];

}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;

    while (t--)
        solve();
    dout << endl << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 1792
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    X = int(input())

    k = (400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000)
    for i in range(8):
        if k[i] <= X < k[i + 1]:
            print(8 - i)


main()


Measured memory_bytes: 9160
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include<string>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

constexpr int n = 27;
int d;
int c[27];
vector<vector<int>> sd;
vector<int> last_sche;
int a;

pair<int, int> max_minus_value_and_day(int day) {
	int ret_value = 0;
	int ret_type = 0;
	for (int i = 1; i < n; i++) {
		int tmp = c[i] * (day - last_sche[i]);
		if (tmp > ret_value) {
			ret_value = tmp;
			ret_type = i;
		}
	}
	return pair<int, int>(ret_value, ret_type);
}

int compute_minus(int day) {
	int ret = 0;
	for (int i = 1; i < n; i++) {
		ret += c[i] * (day - last_sche[i]);
	}
	return ret;
}


int main(void) {
	cin >> d;
	sd = vector<vector<int>>(d + 1, vector<int>(n));
	last_sche = vector<int>(n, 0);
	for (int i = 1; i < n; i++) {
		cin >> c[i];
	}

	for (int i = 1; i < d + 1; i++) {
		for (int j = 1; j < n; j++) {
			cin >> sd[i][j];
		}
	}

	for (int i = 1; i < d + 1; i++) {
		auto itr = max_element(sd[i].begin(), sd[i].end());
		int plus_type = distance(sd[i].begin(), itr);
		int plus = *itr;
		pair<int, int> minus_pair = max_minus_value_and_day(i);
		if (plus > minus_pair.first) {
			cout << plus_type;
			//a += plus;
			last_sche[plus_type] = i;
		}
		else {
			cout << minus_pair.second;
			//a += sd[i][minus_pair.first];
			last_sche[minus_pair.second] = i;
		}
		//a -= compute_minus(i);
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3688
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] A = new int[h][w];
		int[][] B = new int[h][w];
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				B[i][j] = sc.nextInt();
			}
		}
		boolean[][][] dp = new boolean[h+1][w+1][6400];
		dp[0][1][0] = true;
		dp[1][0][0] = true;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				for(int k = 0; k < 6400; k++) {
					if(dp[i][j+1][k] || dp[i+1][j][k]) {
						int k1 = (int)Math.abs(k + A[i][j] - B[i][j]);
						if(k1 < 6400) {
							dp[i+1][j+1][k1] = true;
						}
						int k2 = (int)Math.abs(k + B[i][j] - A[i][j]);
						if(k2 < 6400) {
							dp[i+1][j+1][k2] = true;
						}
					}
				}
			}
		}
		int min = 6400;
		for(int k = 0; k < 6400; k++) {
			if(dp[h][w][k])
				min = Integer.min(k, min);
		}
		System.out.println(min);
	}
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


Measured memory_bytes: 85304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine(n == Console.ReadLine().Split(' ')
                .Select(num => int.Parse(num))
                .Distinct().Count() ? "YES" : "NO");
        }
    }
}

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

string shuffle(string str,int a){
	string strH=str.substr(0,a);
	string strT=str.substr(a,str.size()-a);
	return strT+strH;
}

int main(){
	string str0;
	int m,h;
	while(1){
		cin >> str0;
		if(str0=="-")break;
		cin >> m;
		for(int i=0; i<m; i++){
			cin >> h;
			str0=shuffle(str0,h);
		}
		cout << str0 <<endl;
	}
	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair <int, int>;
const int N = 80 + 2;
const ll mod = 1e9 + 7;
bool f[N][N][10000];
int a[N][N], b[N][N];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			cin >> b[i][j];
		}
	}
	f[1][1][abs(a[1][1] - b[1][1])] = 1;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			for (int k = 0; k < 10000; ++k)
			{
				if (!f[i][j][k])
					continue;
				int x = a[i + 1][j], y = b[i + 1][j];
				f[i + 1][j][abs(k + x - y)] = f[i + 1][j][abs(k + y - x)] = 1;
				x = a[i][j + 1];
				y = b[i][j + 1];
				f[i][j + 1][abs(k + x - y)] = f[i][j + 1][abs(k + y - x)] = 1;
			}
		}
	}
	for (int i = 0; i < 10000; ++i)
		if (f[n][m][i])
		{
			cout << i;
			return 0;
		}
}


Measured memory_bytes: 64768
N = str(input())
s = N[-1:]
if s == '2' or s == '4' or s == '5' or s == '7' or s == '9':
  print('hon')
elif s == '0' or s == '1' or s == '6' or s == '8':
  print('pon')
elif s == '3':
  print('bon')

Measured memory_bytes: 9112
N,K=map(int,input().split())
#1 2 3...N
if N%2==0:
  L=[str(N)]*K
  L[0]=str(N//2)
  print(" ".join(L))
  exit()
#L[0]=N//2+1
#N//2のずれ？
L=[(N//2)+1]*K
for i in range(K//2):
  if L[-1]==1:
    L.pop(-1)
  elif len(L)!=K:
    L[-1]-=1
    L+=[N]*(K-len(L))
  else:
    L[-1]-=1
L=list(map(str,L))
print(" ".join(L))

Measured memory_bytes: 34340
#include <stdio.h>
#include <iomanip>
#include <time.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <queue>
#include <vector>
#define mod 1000000007
#define ll long long
#define pi acos(-1)
using namespace std;

int main(){
	ios::sync_with_stdio(0);
	ll a,b,c;
	cin>>a>>b>>c;
	for(int i = b; i <= c; i++){
		if(i%a==0){
			cout<<"OK";
			return 0;
		}
	} 
	cout<<"NG";
	
    return 0; 
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	int N;
	int A,B;
	scanf("%d %d %d",&N,&A,&B);
	int d = B - A - 1;
	if(d%2==1){
		printf("Alice\n");
	}else{
		printf("Borys\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	while(n=in()){
		n=1000-n;
		int res=0;
		res+=n/500;
		n-=n/500*500;
		res+=n/100;
		n-=n/100*100;
		res+=n/50;
		n-=n/50*50;
		res+=n/10;
		n-=n/10*10;
		res+=n/5;
		n-=n/5*5;
		res+=n;
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    List<Integer> list = new ArrayList<>();
    int sum = 0;

    for(int i = 0; i < n; i++){
        list.add(sc.nextInt());
    }

    Collections.sort(list);

    for(int i = 0; i < n-1; i++){
        sum += list.get(i);
    }

    if(sum > list.get(n-1)){
        System.out.println("Yes");
    }else{
        System.out.println("No");
    }


    








    

    
    

    


    
    


    


    
    


    
	}
}

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

int main(){
	int n;cin >> n;
	double x1, y1, r1, x2, y2, r2;
	while(n--){
		int a = 1;
		cin >>x1>>y1>>r1>>x2>>y2>>r2;
		double d = pow(y2-y1, 2)+pow(x2-x1, 2);
		d = sqrt(d);
		if(d > (r1 + r2))a = 0;
		else if(r1 > d + r2)a = 2;
		else if(r2 > d + r1)a = -2;
		cout << a << endl;
	}
	return 0; 
}

Measured memory_bytes: 3036
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {   
            string s = ReadLine();
            while (s.Length>1)
            {
                s = s.Remove(s.Length - 1, 1);
                if (s.Length % 2 == 0)
                {
                    if (Lside(s) == Rside(s))
                    {
                        WriteLine(s.Length);
                        break;
                    }
                }
            }
        }
        static string Lside(string s)
        {
            string reS = ""; 
            for (int i = 0; i < s.Length / 2; i++)
            {
                reS += s[i].ToString();
            }
            return reS;
        }

        static string Rside(string s)
        {
            string reS = "";
            for (int i = s.Length /2; i < s.Length; i++)
            {
                reS += s[i].ToString();
            }
            return reS;
        }
    }
}


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

int main(){
    int x[3000], y[3000], a, b, i, j, tmp;
    i = 0;
    for (i = 0; i < 3000; ++i){
        cin >> x[i] >> y[i];
        a = x[i];
        b = y[i];
        if (a == 0 && b == 0){
            break;
        }
    }
    for (j = 0; j < i; ++j){
        if (x[j] > y[j]){
            tmp = x[j];
            x[j] = y[j];
            y[j] = tmp;
        }
        cout << x[j] << " " << y[j] << endl;
    }
}


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

#define REP(n) for(int i = 0;i < n;i++)
using namespace std;

int main(){

    string s;
    cin >> s;
    vector<bool> a(26,false);
    for(int i = 0;i < s.length();i++){
        if(a[s[i]-'a'] == true){
            cout << "no" << endl;
            return 0;
        }else{
            a[s[i]-'a'] = true;
        }
    }
    cout << "yes" << endl;

    
   
    return 0;
}

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

using namespace std;

string s;
int cnt;

int main () {
	cin >> s;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == s[i+1]) {
			if(s[i] == '1' && s[i+1] == '1') {
				s[i+1] = '0';
			}
			else {
				s[i+1] = '1';
			}
			cnt++;
		}
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 512