akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());
            int ans = c - (a - b);
            if (ans <= 0) ans = 0;

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21844
# coding: utf-8
import numpy as np


def solve(*args: str) -> str:
    a, b, h, m = map(int, args[0].split())

    ax = a*np.sin(np.pi*(h+(m/60))/6)
    ay = a*np.cos(np.pi*(h+(m/60))/6)

    bx = b*np.sin(np.pi*m/30)
    by = b*np.cos(np.pi*m/30)

    return str(np.sqrt(pow(bx-ax, 2) + pow(by-ay, 2)))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 27192
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)

string a,b;

int main(){
    while(1){
        cin>>a;
        if(a == ".") return 0;
        cin >> b;
        if(a == b) { cout << "IDENTICAL" << endl; continue;}
        vector<string>x[2],y[2];
        string xx = "";
        bool in = 0;
        for(int i=0;i<=a.size();i++){
            if(i==a.size()||a[i] == '"'){
                if(!in) x[0].push_back(xx);
                else y[0].push_back(xx);
                in ^= 1;
                xx = "";
            }
            else xx.push_back(a[i]);
        }
        xx = ""; in = 0;
        for(int i=0;i<=b.size();i++){
            if(i==b.size() || b[i] == '"'){
                if(!in) x[1].push_back(xx);
                else y[1].push_back(xx);
                in ^= 1;
                xx = "";
            }
            else xx.push_back(b[i]);
            }
        //cout << y[0][0] << " " << y[1][0] << endl;
        if(x[0] != x[1]) cout << "DIFFERENT" << endl;
        else if(y[0].size() != y[1].size()) cout << "DIFFERENT" << endl;
        else{
            int c = 0;
            for(int i=0;i<y[0].size();i++) c += (y[0][i] != y[1][i]);
            if(c == 1) cout << "CLOSE" << endl;
            else cout <<"DIFFERENT" << endl;
        }
    }
}



Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

const ll INF=2e18;

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

  int N;
  ll K;
  cin>>N>>K;
  vector<int> P(N);
  rep(i,N) cin>>P[i];
  vector<ll> C(N);
  rep(i,N) cin>>C[i];

  rep(i,N) P[i]--;
  
  ll ans=-INF;
  for(int st=0;st<N;st++){
    vector<int> v;
    int now=st;
    while(P[now]!=st){
      now=P[now];
      v.push_back(now);
    }
    v.push_back(st);
    int V=v.size();
    ll sum=0;
    rep(i,v.size()) sum+=C[v[i]];

    if(sum<=0){
      ll res=0;
      for(int i=0;i<V&&i<K;i++){
        res+=C[v[i]];
        chmax(ans,res);
      }
    }else{
      int rest=K%V;
      ll res=sum*(K/V);
      if(res>0) chmax(ans,res);
      rep(i,rest){
        res+=C[v[i]];
        chmax(ans,res);
      }

      if(K/V>0){
        ll res=sum*((K/V)-1);
        rep(i,V){
          res+=C[v[i]];
          chmax(ans,res);
        }
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3760
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
   int a, b, c;
   cin >> a >> b >> c;
   cout << a * b / 2;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<tuple<int, int, int>> p(N);
  for (int i=0; i<N; i++) {
  int t, x, y;
  cin >> t >> x >> y;
  p.at(i) = make_tuple(t, x, y);
  }
  
  int count = 0;
  for (tuple<int, int, int> tup : p) {
    int t, x, y;
    int a, b, c;
    tie(t, x, y) = tup;
    count++;
    
    if (count == 1) {
      if (t < x+y) {
        cout << "No" << endl;
        goto SKIP;
      }
      else {
        a=t, b=x, c=y;
      }
    }
    
    else { 
      if (x-b >= 0 && y-c >= 0) {
        if (t-a < x-b + y-c) {
          cout << "No" << endl;
          goto SKIP;
        }
        else if (t-a >= x-b + y-c && (t-a-x-b+y-c)%2 != 0) {
          cout << "No" << endl;
          goto SKIP;
        }
        else a=t, b=x, c=y;
      }
      
      if (x-b >= 0 && y-c < 0) {
        if (t-a < x-b + c-y) {
          cout << "No" << endl;
          goto SKIP;
        }
        else if (t-a >= x-b + c-y && (t-a-x-b+c-y)%2 != 0) {
          cout << "No" << endl;
          goto SKIP;
        }
        else a=t, b=x, c=y;
      }
      
      if (x-b < 0 && y-c < 0) {
        if (t-a < b-x + c-y) {
          cout << "No" << endl;
          goto SKIP;
        }
        else if (t-a >= b-x + c-y && (t-a-b-x+c-y)%2 != 0) {
          cout << "No" << endl;
          goto SKIP;
        }
        else a=t, b=x, c=y;
      }
    } 
  }
 
  cout << "Yes" << endl;
  
  SKIP:
  return 0;
}

Measured memory_bytes: 4204
N, K = list(map(int, input().split()))

if K == 0:
    result = N * N
else:
    result = 0
    for b in range(max(K + 1, 2), N + 1):
        div = N // b
        result += div * (b - K)
        result += max(N + 1 - (b * div + K), 0)

print(result)


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

static const int N = 100;
static const int WHITE = 0;
static const int GRAY  = 1;
static const int BLACK = 2;

int n,M[N][N];
int color[N],d[N],f[N],tt;
int nt[N];

int next(int u){
    for(int v=nt[u];v<n;v++){
        nt[u] = v+1;
        if(M[u][v])
            return v;
    }
    return -1;
}

void dfs_visit(int r){
    for(int i=0;i<N;i++) nt[i] = 0;

    stack<int> s;
    s.push(r);
    color[r] = GRAY;
    d[r] = ++tt;

    while(!s.empty()){
        int u = s.top();
        int v = next(u);
        if(v != -1){
            if(color[v] == WHITE){
                color[v] = GRAY;
                d[v] = ++tt;
                s.push(v);
            }
        }else{
            s.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}

void dfs(){
    for(int i=0;i<n;i++){
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;

    for(int u=0;u<n;u++){
        if(color[u] == WHITE)
            dfs_visit(u);
    }
    for(int i=0;i<n;i++){
        cout << i+1 << ' ' << d[i] << ' ' << f[i] << endl;
    }
}

int main(){
    int u,k,v;

    cin >> n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            M[i][j] = 0;

    for(int i=0;i<n;i++){
        cin >> u >> k;
        u--;

        for(int j=0;j<k;j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    dfs();
}



Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    long long int h,w;
    std::cin >> h >>w;
    long long int sa,sb,sc;
    long long int ans=h*w;
    long long int smax,smin;
    for (int i = 1; i < h; i++) {
        sa=i*w;
        
        //横分割
        int p=w/2;
        sb=(h-i)*p;
        sc=(h-i)*(w-p);
        if(sa!=0 && sb!=0 && sc!=0){
            smax=max(max(sa,sb),sc);
            smin=min(min(sa,sb),sc);
            ans=min(ans,smax-smin);
        }
        //縦分割
        p=(h-i)/2;
        sb=(h-i-p)*w;
        sc=p*w;
        if(sa!=0 && sb!=0 && sc!=0){
            smax=max(max(sa,sb),sc);
            smin=min(min(sa,sb),sc);
            ans=min(ans,smax-smin);
        }
    }
    for (int i = 1; i < w; i++) {
        sa=i*h;
        //縦分割
        int p=h/2;
        sb=(w-i)*p;
        sc=(w-i)*(h-p);
        if(sa!=0 && sb!=0 && sc!=0){
            smax=max(max(sa,sb),sc);
            smin=min(min(sa,sb),sc);
            ans=min(ans,smax-smin);
        }
        
        //横分割
        p=(w-i)/2;
        sb=(w-i-p)*h;
        sc=p*h;
        if(sa!=0 && sb!=0 && sc!=0){
            smax=max(max(sa,sb),sc);
            smin=min(min(sa,sb),sc);
            ans=min(ans,smax-smin);
        }
    }
    
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int res = 0, a, b, c, x;
    cin >> a >> b >> c >> x;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (500 * i + 100 * j + 50 * k == x) res++;
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#define FOR(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
int N;
int main(void) {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] == 5 && a[1] == 5 && a[2] == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	H := sc.NextInt()

	l := 1
	for i := 0; l*2 <= H; i++ {
		l *= 2
	}
	fmt.Println(l*2 - 1)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  vector<int> ans(N);
  rep(i, N - 1)
  {
    int A;
    cin >> A;
    ans[A - 1]++;
  }
  printlnVector(ans);
  return 0;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int nmax=1000010;
ll fac[nmax],finv[nmax],inv[nmax];
 
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<nmax;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll com(int n,int k){
  if(n<k||n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
 
int main(){
  COMinit();
  ll n,k;cin >> n >> k;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll mx=0,mi;
  for(int i=0;i<n;i++){
    mx+=(com(i,k-1)*a[i])%mod;
    mi+=(com(n-1-i,k-1)*a[i])%mod;
    mx%=mod;
    mi%=mod;
  }
  cout << (mx+mod-mi)%mod << endl;
}

Measured memory_bytes: 24448
# 21:04-                                                                                                                                                                                                    

from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

perms = list(permutations(range(1, N+1)))

perm2key = {perms[i]:i for i in range(len(perms))}

print(abs(perm2key[Q]-perm2key[P]))




Measured memory_bytes: 16472
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define pb push_back
#define mp make_pair
typedef pair<int,int> ii;
const double pi=3.141592653589793238462643383279;
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	if(s=="ABC")
	{
		cout<<"ARC"<<endl;
	}
	else
	cout<<"ABC"<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using Graph = vector<vector<int>>;
using P = pair<int,int>;
using ll =long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,m;
    cin >> n >> m;
    vector<tuple<int,int,int>> in(m);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        in[i] = make_tuple(a,b,i);
    }
    sort(in.begin(),in.end());
    vector<ll> ans(m);
    int t = 1;
    int pre = 0;
    rep(i,m){
        int a,b,c;
        tie(a,b,c) = in[i];
        if(pre==a){
            t++;
            ans[c] = (ll)a*1000000 + t;
        }else{
            t = 1;
            ans[c] = (ll)a*1000000 + t;
            pre = a;
        }
    }
    for(auto tmp : ans){
        cout << setfill('0') << right << setw(12) << tmp << endl;
    }
}

Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

bool check(LL a,LL b){
    double x = 0;
    LL tmp = a;
    while(tmp > 0){
        x += (double)(tmp%10);
        tmp /= 10;
    }
    x = (double)(a/x);
    double y = 0;
    tmp = b;
    while(tmp > 0){
        y += (double)(tmp%10);
        tmp /= 10;
    }
    y = (double)(b/y);
    return x > y;
}

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

    LL n;
    cin >> n;
    LL k = 1;
    LL pre = 0;
    while(n > 0){
        LL t = 1;
        for(LL i = k; i < 10*k && n > 0; i += t){
            while(pre >= i){
                i += t;
            }
            if(check(i,i+t)){
                t *= 10;
                i = k - 1;   
            }else{
                cout << i << endl;
                n--;
                pre = i;
            }
        }
        k *= 10;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}

template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}

template<typename T> void sort(vector<T>& v) {sort(v.begin(), v.end());}

int main() {
  int s;
  cin >> s;
  set<int> st;
  for (int i = 1; ; ++i) {
    if (st.count(s)) {
      cout << i << endl;
      return 0;
    }
    st.emplace(s);
    if (s % 2) s = 3 * s + 1;
    else s /= 2;
  }
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,s,e) for(int (i)=(s);(i)<(e);i++)
#define endl "\n"

typedef long long ll;

void use_cio(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
//----------------------------------------//
int n;
int L[210];

int main(){
	use_cio();
	cin >> n;
	rep(i,2*n) cin >> L[i];
	sort(L, L+2*n);
	ll ans = 0;
	for(int i = 0 ; i < 2*n;i+=2) ans += L[i];
	cout << ans;
}

Measured memory_bytes: 256
N=int(input())
A=[list(map(int,input().split())) for _ in range(N)]
wait=[[float("inf")]*N for _ in range(N)]
for i in range(N):
  wait[A[i][0]-1][i]=0
L=[list(range(N)),[]]
finish=[0]*N

day=0
ind=0
while L[ind]:
  battle=False
  day+=1
  for player in L[ind]:
    if finish[player]>=N-1:
      continue
    enemy=A[player][finish[player]]-1
    if wait[player][enemy]<day and wait[enemy][player]<day:
      battle=True
      #print("day{},{}vs{}".format(day,player+1,enemy+1))
      finish[player]+=1
      finish[enemy]+=1
      if finish[player]<N-1:
        wait[A[player][finish[player]]-1][player]=day
      if finish[enemy]<N-1:
        wait[A[enemy][finish[enemy]]-1][enemy]=day
      L[(ind+1)%2].append(player)
      L[(ind+1)%2].append(enemy)
  L[ind]=[]   
  ind=(ind+1)%2
  if not battle:
    day-=1
    break
if min(finish)<N-1:
  print(-1)
else:
  print(day)
       
      
  




Measured memory_bytes: 93084
// D - Xor Sum 4
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(ll i=(s);i<(e);++i)
#define MOD 1000000007
 
ll O[60];
 
int main(){
	ll ans=0, N; cin>>N;
	rp(i,0,N){ ll j,a; scanf("%lld",&a); for(j=0; a; a>>=1) O[j++]+=a&1; }
	rp(i, 0, 60) ans = (ans + (O[i]*(N-O[i]) % MOD) * ((1LL<<i) % MOD)) % MOD;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
import heapq

N, K = list(map(int, input().split()))
td = []
td_ = []
group = set()
total = 0

for i in range(N):
    t, d = list(map(int, input().split()))
    heapq.heappush(td, (-d, t))

for i in range(K):
    d, t = heapq.heappop(td)
    total -= d
    if t not in group:
        group.add(t)
    else:
        heapq.heappush(td_, -d)

ans = len(group)**2 + total

while td and td_:
    d, t = heapq.heappop(td)

    if t not in group:
        group.add(t)
        d_ = heapq.heappop(td_)
        total = total - d_ - d
        ans = max(ans, len(group)**2 + total)
print(ans)

Measured memory_bytes: 19256
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

ans = 0
n = inp()
a = inpl()
d = defaultdict(int)

for key in a:
    d[key] += 1
    d[key+1] += 1
    d[key-1] += 1
for i in d:
    ans = max(ans, d[i]) 
print(ans)

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

using namespace std ;

int main ()
{
    long long n , a , b ;
    cin >> n >> a >> b ;
    long long ans = n / ( a + b )  ; // we find the number of complete sequences of red and blue balls in "n" ;
    ans *= a ; // we find the number of red balls in the complete sequences we found earlier ;
    long long x = n % ( a + b ) ;  // we find the number of the remaining balls
    ans += min( a , x ) ; // // we add the number of the rest of red balls to the answer
    cout << ans ;
    return 0 ;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,cnst=12800*2,i,j,f[81][81],g[81][81],sm,jm1,jm2;
bool dp[81][81][51201];
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b;
    for(i=1; i<=a; i++){
        for(j=1; j<=b; j++) cin>>f[i][j];
    }
    for(i=1; i<=a; i++){
        for(j=1; j<=b; j++) cin>>g[i][j];
    }
    dp[1][0][0+cnst]=1;
    dp[0][1][0+cnst]=1;
    for(i=1; i<=a; i++){
        for(j=1; j<=b; j++){
            jm1=f[i][j]-g[i][j];
            for(sm=-cnst; sm<=cnst; sm++){
                if(sm+jm1>=-cnst&&sm+jm1<=cnst){
                    if(dp[i][j-1][sm+cnst]==1||dp[i-1][j][sm+cnst]==1){
                        dp[i][j][sm+jm1+cnst]=1;
                    }
                }
                jm1=-jm1;
                if(sm+jm1>=-cnst&&sm+jm1<=cnst){
                    if(dp[i][j-1][sm+cnst]==1||dp[i-1][j][sm+cnst]==1){
                        dp[i][j][sm+jm1+cnst]=1;
                    }
                }
                jm1=-jm1;
            }
        }
    }
    for(i=0; i<=cnst; i++){
        if(dp[a][b][i+cnst]==1||dp[a][b][-i+cnst]==1){
            cout<<i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 326144
#include <iostream>
 
using namespace std;
 
int main() {
    int l, r;
    cin >> l >> r;
    int min=2019;
    for(int i=l; i<r; i++) {
        for(int j=i+1; j<=r; j++) {
            if(min>(i%2019)*(j%2019)%2019) {
                min=(i%2019)*(j%2019)%2019;
            }
            if(min==0) {
                cout << min << endl;
                return 0;
            }
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(),i.end()
#define debug(i) std::cout << i << "\n"



const int INF = 100000000;
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	if (y == 0)
		return 1;
    if(y%2){
        return (x*pow_mod(x,y-1,mod))%mod;
    }else{
        return pow_mod(x*x,y/2,mod);
    }
}

int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!

  ll n,k,sum=0;
  std::cin>>n>>k;
  std::vector<ll> a(n),div;

  rep(i,0,n){
    std::cin>>a[i];
    sum+=a[i];
  }

  for(int i=1;i*i<=sum;i++){
    if(sum%i==0){
      div.push_back(i);
      if(i*i!=sum)div.push_back(sum/i);
    }
  }

  ll ans=1;

  std::sort(all(div),std::greater<ll>());

  rep(i,0,div.size()){
    std::vector<ll> b(n);
    bool flag=false;

    ll sumb=0;
    rep(j,0,n){
      b[j]=(a[j]/div[i])*div[i]-a[j];
      sumb-=b[j];
    }

    sumb/=div[i];
    std::sort(all(b));
    rep(j,0,sumb){
      b[j]+=div[i];
    }

    ll temp=0;
    rep(j,0,n){
      if(b[j]>=0)temp+=b[j];
    }
    if(temp<=k)flag=true;

    if(flag){
      ans=div[i];
      break;
    }
  }

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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    int a,b;
    cin >> a >> b;
    if(a <= 0 && b >= 0) cout << "Zero" << endl;
    else if(a > 0) cout << "Positive" << endl;
    else{
        if((b-a+1) %2 == 0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    string s;
    cin>>s;
    if(s[0]==s[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    

    solve();


    return 0;
}


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


int main(){
  int N,M,L,R;
  cin>>N>>M;
  L=1;
  R=N;
  for(int i = 0;i<M;i++){
    int l,r;
    cin>>l>>r;
    L=max(l,L);
    R=min(r,R);
    if(R-L<0){
      cout<<0<<endl;
      return 0;
    }
  }
  int ans = R-L+1;

  cout<<ans<<endl;
}


Measured memory_bytes: 256
//100分小学生代码。
#include<iostream>
#include <cmath>
using namespace std;
int beishu(int cifang,int shu)//就是不喜欢用pow函数。
{
    long long int sum=1;
    for (int i=1;i<=cifang;i++)
        sum*=shu;
    return sum;
}
int weishu(int x)
{
    int num=0;
    while (x)
    {
        num++;
        x/=10;
    }
    return num;
}
int main()
{
    int a,b;
    cin>>a>>b;
    long long int s;
    s=a*beishu(weishu(b),10);//位值原理。
    s+=b;
    int g=sqrt(s);
    if (g*g==s)//判断是否为平方数。
        cout<<"Yes\n";//要换行。
    else
        cout<<"No\n";//要换行。
    return 0;//完美100AC的结束了。
} 

Measured memory_bytes: 256
//
// Created on 2019-02-09.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    ll N;
    string S;
    cin >> N >> S;

    vector<ll> bl(N+2); bl[0] = 0;
    vector<ll> wh(N+2); wh[0] = 0;

    REP(i,N){
        bl[i+1] = S[i]=='#' ? bl[i]+1 : bl[i];
        wh[i+1] = S[i]=='.' ? wh[i]+1 : wh[i];
    }

    bl[N+1] = bl[N];
    wh[N+1] = wh[N];

//    REP(i,N+2){
//        cout << bl[i] << " ";
//    } cout << endl;
//
//    REP(i,N+2){
//        cout << wh[i] << " ";
//    } cout << endl;

    ll ans = N;
    REP(i,N+1){
        ll l = i-wh[i];
        ll r = (N-i) - (bl[N]-bl[i]);
        //cout << "l: " << i << "-" << wh[i] << " r: " << (N-i) << "-(" << bl[N] << "-" << bl[i] << ")" << endl;
        ans = min(l+r, ans);
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 3732
#include <stdio.h>

int main(void){
	int a,b;
	char op;
	
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op=='+') printf("%d\n",a+b);
		if(op=='-') printf("%d\n",a-b);
		if(op=='*') printf("%d\n",a*b);
		if(op=='/') printf("%d\n",a/b);
		if(op=='?') break;
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

const int MAX = 1000000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    COMinit();

    int x,y; cin >> x >> y;

    if((x+y)%3!=0){
        cout << 0 << endl;
        return 0;
    }

    if((2*x-y)%3!=0 || (2*y-x)%3!=0){
        cout << 0 << endl;
        return 0;        
    }

    int m,n;
    m = (2*x-y)/3;
    n = (2*y-x)/3;

    //cout << m << " " << n << endl;


    cout << COM(m+n, m) << endl;

    return 0;
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N, K; cin >> N >> K;
	
	vector<int> cnt(N+1, 0);
	REP(i,N){
		int a; cin >> a;
		cnt[a]++;
	}

	SORT(cnt);

	int sum = 0;
	REP(i,K){
		sum += cnt[N-i];
	}

	int ans = N - sum;
	cout << ans << endl;



	return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n){
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> t(n+10);
  vector<int> x(n+10);
  vector<int> y(n+10);
  rep(i,n) cin >> t[i] >> x[i] >> y[i];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  int a,b;
  rep(i,n){
    a = t[i] - t[i-1];
    b = abs((x[i] + y[i]) - (x[i-1] + y[i-1]));
    if(a >= b && a%2 == b%2){
      continue;
    }
    else{
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 1408
X,Y = map(int,input().split())
ans = 0
if X == 3:
    ans += 100000
if X == 2:
    ans += 200000
if X == 1:
    ans += 300000
if Y == 3:
    ans += 100000
if Y == 2:
    ans += 200000
if Y == 1:
    ans += 300000
if X == 1 and Y == 1:
    ans += 400000
print(ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

n = int(input())
w = list(map(int, input().split()))

minl = 0
maxl = 0
mins = 100
for i in range(len(w)):
    for j in range(len(w)):
        if i > j:
     
            minl = minl + w[j]
        else:
        
            maxl = maxl + w[j]
    mins = min(mins, abs(minl-maxl))
    minl = 0
    maxl = 0

print(mins)



Measured memory_bytes: 3060
import collections
import heapq
def main():

    N, M = map(int, input().split())
    graph = collections.defaultdict(dict)
    for _ in range(M):
        a, b, c = map(int, input().split())
        graph[a-1][b-1] = -c

    dist = [float('inf') for _ in range(N)]
    dist[0] = 0
    for _ in range(N-1):
        for a in graph:
            for b in graph[a]:
                dist[b] = min(dist[b], dist[a]+graph[a][b])
    ans = dist[N-1]

    negative = [False for _ in range(N)]
    for _ in range(N):
        for a in graph:
            if dist[a] != float('inf'):
                for b in graph[a]:
                    if dist[b] > dist[a] + graph[a][b]:
                        dist[b] = dist[a] + graph[a][b]
                        negative[b] = True
                    if negative[a] == True:
                        negative[b] = True
    if negative[N-1]:
        return 'inf'
    else:
        return -ans

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 52440
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());

            var set = new HashSet<int>();
            set.Add(A);
            set.Add(B);

            for (var i = 1; i <= 3; i++)
            {
                if (!set.Contains(i))
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
const ll MINF = LLONG_MIN;
const int INT_INF = INT_MAX;

int main()
{
    string s;
    cin >> s;
    if (s == "Sunny")
        cout << "Cloudy" << endl;
    else if (s == "Cloudy")
        cout << "Rainy" << endl;
    else if (s == "Rainy")
        cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}

bool prime[10000001];
void SieveOfEratosthenes(int n) 
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    int a,b, k;
    cin >> a >> b >> k;
    int ans = 1;
    for(int i=__gcd(a,b);i>=1;i--){
        if(a%i==0 && b%i==0){k--;ans = i;}
        if(k==0){break;}
    }
    cout << ans;



}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int n, w; cin >> n >> w;
    if(n == 0 && w == 0) break;
    map<int, int> m;
    int ma = 0, d = 0;;
    REP(i, n) {
      int tmp; cin >> tmp;
      m[tmp/w]++;
      ma = max(ma, tmp/w);
      d =  max(d, m[tmp/w]);
    }

    double ans = 0.01;


    REP(i, ma+1) {
      ans += ((double)(ma-i)/(ma)) * ((double)m[i]/d);
    }

    cout << ans << endl;
  }

}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "YES" : "NO");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  string A, B, C;
  cin >> A >> B >> C;
  bool is_ok = false;
  if (A.back() == B.front() && B.back() == C.front())
    is_ok = true;
  printYesNo(is_ok);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);


  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  /* your code */
  for(i=0;i<n;i++)scanf("%d",&A[i+1]);

  for(i=0;i<=VMAX;i++) C[i]=0;

  for(i=0;i<n;i++) C[A[i+1]]++;

  for(i=1;i<=VMAX;i++) C[i]=C[i]+C[i-1];

  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");



  return 0;
}



Measured memory_bytes: 9632
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
const int MOD = 1e9+7;
 
int main() {
	int N;
  	cin >> N;
  	int ans;
  	if(N>=64) ans = 64;
  	else if(N>=32) ans =32;
  	else if(N>=16) ans =16;
  	else if(N>=8) ans =8;
  	else if(N>=4) ans =4;
  	  else if(N>=2) ans =2;
  else ans =1;
      cout << ans << endl;
}

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

using namespace std;

int n, m, p[100005], ans[100005];
vector<pair<int, int> > v[100005];
int ta;

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++)
    {
        scanf("%d%d", p + i, &ta);
        v[p[i]].emplace_back(ta, i);
    }
    for (int i = 1; i <= n; i++)
    {
        sort(v[i].begin(), v[i].end());
        for (int j = 0; j < v[i].size(); j++)
            ans[v[i][j].second] = j + 1;
    }
    for (int i = 0; i < m; i++)
        printf("%06d%06d\n", p[i], ans[i]);
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin>>n;

  vll a(n);
  REP(i,n)cin>>a[i];
  vpl b(n);
  REP(i,n){
    b[i].FI=a[i];
    b[i].SE=i;
  }

  sort(ALL(b),greater<pll>());
  map<pll,ll> m;

  REP(i,n){
    map<pll,ll> next;

    for(ll l=0; l<=i+1; l++){
      ll res=0;
      ll r=n-1-(i+1)+l;

      if(0<=l-1)
        res=max(res,m[pll(l-1,r)]+b[i].FI*abs(l-1-b[i].SE));
      if(r+1<=n-1)
        res=max(res,m[pll(l,r+1)]+b[i].FI*abs(b[i].SE-(r+1)));

      next[pll(l,r)]=res;
    }

    swap(m,next);
  }


  ll ans=0;
  for(auto p:m)ans=max(ans,p.SE);

  cout<<ans<<endl;
}



Measured memory_bytes: 3960
import math
import itertools


n = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

min_num = []
cnt = 0
a = 0
b = 0

for i in range(1, n+1):
    min_num.append(i)

for v in itertools.permutations(min_num, n):
    cnt += 1
    if list(v) == P:
        a = cnt
    if list(v) == Q:
        b = cnt

print(abs(a-b))


Measured memory_bytes: 73924
import sys

sys.setrecursionlimit(100000)

def f(a):
  global R,G,B,N,ans,Rm,Gm,Bm

  for b in range(N-R*a+1):
    cmod=(N-R*a-G*b)%B
    c=(N-R*a-G*b)//B
    if cmod==0 and  c>=0:
      ans+=1
    elif c<0:
      break

  if a>0:
    f(a-1)


R,G,B,N=list(map(int,input().split(" ")))

ans=0

f(N//R+1)

print(ans)

Measured memory_bytes: 42588
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,i,j;
    int A[100];
    int minj;
    int m=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
        
    }
    for(i=0;i<n;i++){
        minj=i;
        int tmp;
        for(j=i;j<n;j++){
            if(A[j]<A[minj]){
                minj=j;
            }
        }
        
            if(i!=minj){
              
            tmp=A[i];
            A[i]=A[minj];
            A[minj]=tmp;
            m++;
            
                    }
        
    }
    for(i=0;i<n-1;i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[n-1]);
    printf("%d\n",m);
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, t, x, h, res = 0;
    double mx = -INF;
    cin>>n>>t;
    rep(i, n){
        cin>>x>>h;
        chmax(mx, h / double(x));
    }
    cout<<mx*t<<endl;
}



Measured memory_bytes: 3272
#include <stdio.h>
using namespace std;

int main()
{
  char s[6];
  scanf("%s", s);
  if (s[2] == s[3] && s[4] == s[5])
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

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

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,X,D;cin>>N>>X>>D;
    ll ans=0;
    
    if(X==0&&D==0){
        cout<<1<<endl;
        return 0;
    }
    
    for(ll i=0;i<=N;i++){
        ans+=i*(N-i)+1;
    }
    
    if(X<0&&D<0){
        X*=-1;
        D*=-1;
    }
    
    if(X>=0&&D>=0){
        ll g=gcd(X,D);
        X/=g;
        D/=g;
        
        if(D>N){
            cout<<ans<<endl;
            return 0;
        }
        ll diff=X;
        
        for(ll i=0;i+D<=N;i++){
            ll la=i*(i-1)/2,lb=i*(2*N-i-1)/2;
            ll ra=(i+D)*(i+D-1)/2+diff,rb=(i+D)*(2*N-(i+D)-1)/2+diff;
            
            ll a=min(lb,rb)-max(la,ra)+1;
            ans-=max(a,0LL);
        }
        
        cout<<ans<<endl;
    }else{
        ll g=gcd(abs(X),abs(D));
        X/=g;
        D/=g;
        
        if(D<0){
            D*=-1;
            X*=-1;
        }
        
        if(D>N){
            cout<<ans<<endl;
            return 0;
        }
        
        ll diff=X;
        
        for(ll i=0;i+D<=N;i++){
            ll la=i*(i-1)/2,lb=i*(2*N-i-1)/2;
            ll ra=(i+D)*(i+D-1)/2+diff,rb=(i+D)*(2*N-(i+D)-1)/2+diff;
            
            ll a=min(lb,rb)-max(la,ra)+1;
            ans-=max(a,0LL);
        }
        
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 256
using System;
using System.Linq;

class PG{
    public static void Main(string[] args){
        Console.WriteLine(Gcd(Console.ReadLine().Split(' ').Select(int.Parse).ToArray()));
        
    }
    public static int Gcd(int[] nums){
        int a= nums[0];
        int b=nums[1];
        while(true){
            if(a>b){
                if(b==0){
                    return a;
                }
                a=a%b;
            }else if(b>a){
                if(a==0){
                    return b;
                }
                b=b%a;
            }else{
                return a;
            }
        }
    }
}


Measured memory_bytes: 18372