akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define N 200005
#define M 1000000007
#define mod 998244353
using namespace std;


int main()
{
    __

    int a[] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;

    cin >> k;

    cout << a[k-1];

    return 0;
}


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

int main(){
	int h,w;
	while(1){
		cin >> h >> w;
		if(h == 0 and w == 0){
			return 0;
		}
		for(int i = 0; i < h; i++){
			for(int k = 0; k < w; k++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll S, M;
  cin >> S >> M;
  if(S*2>=M){
    cout << M/2 <<endl;
  }else{
    ll ans = S;
    M -= S*2;
    cout << ans +M/4<<endl;
  }
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string S;
    cin >> S;
    if(S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())


const string YES = "Yes";
const string NO = "No";
void solve(ll A, ll B, ll C){
    if(A == B && B == C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
  ll A;
    scanf("%lld",&A);
    ll B;
    scanf("%lld",&B);
    ll C;
    scanf("%lld",&C);
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int ans = 2019;
    long long l, r;
    std::cin >> l >> r;
  	r = std::min(r, l+2019);
    
    for (long long i = l; i < r; i++) {
        for (long long j = i + 1; j <= r; j++) {
          	int x = (i * j) % 2019;
            ans = std::min(ans, x);
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define ld long double
#define pii pair<ll,ll>
#define s second
#define M 1000000007
#define f first
ll x[102],y[102];

ld ang(ll y,ll x){
	ld a = atan2(y,x) * 180.0 / 3.141592653589793;
	return a;
}

int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    ll n;
    cin>>n;
    n--;
    ll ans = n*(n+1)/2;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,x,n) for(long long i=(long long)(x);i<(long long)(n);i++)
#define rep(i,x,n) for(long i=long(x);i<long(n);i++)
/*#define cin fin
#define cout fout
ifstream cin("input.in");ofstream cout("output.out");*/
int main() 
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long n,m,x,y,p=0;
    vector<pair<long,long> > v;
    cin>>n>>m;
    rep(i,0,m){
        cin>>x>>y;
        v.push_back({x,y});
    }
    sort(v.begin(),v.end());
    x=y=-1;
    bool flag=1;
    for(long i=0;i<m;i++)
    {
        if(v[i].first>=y)
        {
            p++;
            flag=0;
            x=v[i].first;
            y=v[i].second;
        }
        else{
            flag=1;
            x=max(x,v[i].first);
            y=min(y,v[i].second);
        }
        //cout<<x<<" "<<y<<"\t"<<p<<"\n";
    }
    cout<<p;
}

Measured memory_bytes: 2420
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    int bcopy = b;
    int bketa = 0;
    while(bcopy >= 1){
        bketa++;
        bcopy /= 10;
    }
    double ab = a*pow(10,bketa) + b;
    double root = sqrt(ab);
    int rootint = root;
    if(root == double(rootint)) cout << "Yes";
    else cout << "No";
    return 0;
}

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

#define MOD 1e9+7
#define ll long long int
/*
int logdayo(ll y,ll x){
	ll z=(ll)(y/x);
	ll ans=0;
	ll memo=2;
	for(memo=2;memo<=z;){
		ans++;
		memo*=2;
	}
	return ans;
}*/

int main(void){
	ll x,y;
	cin>>x>>y;
	int ans = (int)(log2l((ll)(y/x))) + 1;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector <int> a(N);
  for(int i=0;i<N;i++) cin>>a[i];
  
  for(int i=0;i<N;i++){
    if(a[i]%2 == 0){
      if(a[i]%3 != 0 && a[i]%5 != 0 ){
        cout << "DENIED"<< endl;
        return 0;
      }
    }
  }
  
  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string,string,char
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int SED(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;

	string s;
	cin >> s;

	Yes(s[2] == s[3] && s[4] == s[5]);

	please AC;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {

    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    while (input.ready()) {
      String numStr[] = input.readLine().split(" ");
      int num[] = new int[2];
      num[0] = Integer.parseInt(numStr[0]);
      num[1] = Integer.parseInt(numStr[1]);

      System.out.println(getDigitNumber(num[0] + num[1]));

      ;
    }
  }

  public static int getDigitNumber(int num) {

    int digit = 1;
    while (num / 10 >= 1) {
      num /= 10;
      digit++;
    }
    return digit;
  }
}

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

int main() {
    int64_t N,K;
    cin >> N >> K;
    int64_t cnt_i = 0;
    int64_t cnt = 0;

    for(int64_t i = K; i <= N + 1; i++){
        cnt_i = i*(2*N+1-i)/2 - i*(i-1)/2 + 1;
        if(cnt_i > 1000000007){
            cnt_i = cnt_i % 1000000007;
        }
        cnt += cnt_i;
        if(cnt > 1000000007){
            cnt = cnt % 1000000007;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3644
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/g);
var t = input[0].split(/\s/g)[1] - 0;
var l = input[1].split(/\s/g).map(function(s){return s - 0;});
var r = t;
for (var i = 1; i < l.length; i++) {
    r += Math.min(t, l[i] - l[i - 1]);
}
console.log(r);

Measured memory_bytes: 34588
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#include <numeric>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int n;
    cin >> n;
    vector<double> p(n);
    VCIN(p);

    vector<vector<double>> dp(3000, vector<double>(3000, 0.0));
    dp[1][0] = 1.0 - p[0];
    dp[1][1] = p[0];
    for(int i=2; i<=n; i++){
        for(int j=0; j<=i; j++){
            if(j==0) dp[i][j] += dp[i-1][j] * (1.0 - p[i-1]); 
            else dp[i][j] += dp[i-1][j-1] * p[i-1] + (dp[i-1][j] * (1.0 - p[i-1]));
        }
    }

    double ans = 0;
    for(int i=n/2+(n%2); i<=n; i++){
        ans += dp[n][i];
    }
    
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int main(){
  while(1){
    int N;
    cin>>N;
    if(N==0)break;
    vector<double> A(N);
    rep(i,N)cin>>A[i];
    vector<int> tr;
    rep(i,N)if(A[i]!=1.0)tr.push_back(i);
    tr.push_back(N);
    vector<double> dp(N+1,INF);
    dp[N]=0;
    for(ll i=N-1;i>=0;i--){
      ll st=lower_bound(all(tr),i+1)-tr.begin();
      ll pre=i;
      double ex=0;
      for(ll j=st;j<st+20&&j<(ll)tr.size();j++){
        ll k=tr[j];
        ex=(ex+1.0)/A[pre]+(k-pre-1);
        minch(dp[i],dp[k]+ex+1.0);
        pre=k;
      }
    }
    printf("%.10f\n", dp[0]-1.0);
  }

  return 0;
}



Measured memory_bytes: 5404
#include <bits/stdc++.h>
using namespace std;
string s ;
int main() {
    int n ;
    cin >> n ;
    cin >> s ;
    int len = s.length() ;
    for(int i = 0 ; i < len ; i++) {
        s[i] = (s[i] + n +13 ) %26 + 'A';
    }
    cout << s << endl ;
    return 0 ;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
ll n,ans;
int main()
{
	scanf("%lld",&n);
	if(n==1||n==2)
	{
		printf("0\n");
		return 0;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i)continue;
		ll d=i;
		if(n/(d-1)*d==n)ans+=d-1;
		d=n/i;
		if(n/(d-1)*d==n)ans+=d-1;
	}
	printf("%lld\n",ans+n-1);
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> G(n + 1);
    for (int i = 1; i <= m; ++i) {
        int u, v;
        cin >> u >> v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    vector<vector<int>> bad(n + 1);
    for (int i = 1; i <= k; ++i) {
        int u, v;
        cin >> u >> v;
        bad[u].emplace_back(v);
        bad[v].emplace_back(u);
    }
    vector<bool> seen(n + 1);
    vector<int> nodes;
    vector<int> ans(n + 1);
    function<void(int)> get_cc_nodes = [&](int u) {
        nodes.emplace_back(u);
        seen[u] = true;
        for (auto &v : G[u]) {
            if (!seen[v]) {
                get_cc_nodes(v);
            }
        }
    };
    for (int i = 1; i <= n; ++i) {
        if (!seen[i]) {
            get_cc_nodes(i);
            sort(nodes.begin(), nodes.end());
            for (auto &u : nodes) {
                int cc = nodes.size() - 1 - G[u].size();
                for (auto &b : bad[u]) {
                    if (binary_search(nodes.begin(), nodes.end(), b)) {
                        --cc;
                    }
                }
                ans[u] = cc;
            }
            nodes.clear();
        }
    }
    for (int i = 1; i <= n; ++i) {
        cout << ans[i] << " \n"[i == n];
    }
    return 0;
}



Measured memory_bytes: 13052
def main():
    N = int(input())
    A = []
    for n in range(N):
        A.append(int(input()))

    A_cp = sorted(A)
    max1_A = A_cp.pop(-1)
    max2_A = max(A_cp)
    for a in A:
        if a == max1_A:
            print(max2_A)
        else:
            print(max1_A)
            
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 14112
#include<cstdio>
#define N 250052
#define p 1000000007
#define q 19260817
inline int mod(int x){return x<p?x:x-p;}
char s[N];int A[q],B[N],D[N],T,a[N],b[N],c[N],d[N],i,j,n;long long C[N],z;
inline int Hash(long long x)
{
    int y=x%q;
    for(j=A[y];j;j=B[j])if(C[j]==x)return j;
    return 0;
}
inline void add(long long x)
{
    int y=Hash(x);
    !y?B[++T]=A[y=x%q],C[A[y]=T]=x,D[T]=1:D[y]++;
}
int main()
{
    scanf("%d%s",&n,s+1);
    for(*a=*c=i=1;i<=n;i++)
    if(s[i]=='+')a[i]=a[i-1],b[i]=mod(a[i-1]+b[i-1]),c[i]=c[i-1],d[i]=mod(c[i-1]+d[i-1]);
    else if(s[i]=='-')a[i]=a[i-1],b[i]=mod(p+b[i-1]-a[i-1]),c[i]=c[i-1],d[i]=mod(p+d[i-1]-c[i-1]);
    else if(s[i]=='>')a[i]=998244353ll*a[i-1]%p,b[i]=b[i-1],c[i]=499122177ll*c[i-1]%p,d[i]=d[i-1];
    else a[i]=4924091ll*a[i-1]%p,b[i]=b[i-1],c[i]=229537957ll*c[i-1]%p,d[i]=d[i-1];
    for(i=1;i<=n;i++)add(((long long)b[n]*a[i-1]+b[i-1])%p*p+((long long)d[n]*c[i-1]+d[i-1])%p),z+=D[Hash((long long)b[i]*p+d[i])];
    return 0*printf("%lld\n",z);
}

Measured memory_bytes: 83456
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<ll, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

int main(){
    fastIO;
    ll a, b;
    cin >> a >> b;
    if(a <= 0 && b >= 0){
        cout << "Zero\n";
    }
    else if(a > 0){
        cout << "Positive\n";
    }
    else{
        int res = b - a + 1;
        if(res % 2 == 0)
            cout << "Positive\n";
        else
            cout << "Negative\n";
    }
    return 0;
}


Measured memory_bytes: 256
function main(input) {
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);

    if ((a*b) % 2 === 0 ){
        console.log('Even');
    } else{
        console.log('Odd');
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
from math import factorial as fc

n, m = map(int, input().split())
if abs(n-m) == 1:
  print(fc(n)*fc(m)%(10**9+7))
elif abs(n-m) == 0:
  print(fc(n)*fc(m)*2%(10**9+7))
else:
  print(0)

Measured memory_bytes: 5188
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		int n = scanInt();
		int a[] = new int[n], b[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanInt();
		}
		for (int i = 0; i < n; i++) {
			b[i] = scanInt();
		}
		boolean inStack[] = new boolean[n];
		int stack[] = new int[n];
		int stackSize = 0;
		for (int i = 0; i < n; i++) {
			if (b[i] > b[(i + 1) % n] && b[i] > b[(i - 1 + n) % n]) {
				inStack[i] = true;
				stack[stackSize++] = i;
			}
		}
		long ans = 0;
		while (stackSize > 0) {
			int i = stack[--stackSize];
			inStack[i] = false;
			int i1 = (i + 1) % n, i2 = (i - 1 + n) % n;
			int val = b[i], diff = b[i1] + b[i2], dest = a[i];
			if (val - diff >= dest) {
				int cnt = (val - dest) / diff;
				ans += cnt;
				b[i] = val - diff * cnt;
				if (!inStack[i1] && b[i1] > b[i] && b[i1] > b[(i1 + 1) % n]) {
					inStack[i1] = true;
					stack[stackSize++] = i1;
				}
				if (!inStack[i2] && b[i2] > b[i] && b[i2] > b[(i2 - 1 + n) % n]) {
					inStack[i2] = true;
					stack[stackSize++] = i2;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			if (a[i] != b[i]) {
				out.print(-1);
				return;
			}
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int K,T,a,x;
  cin >> K >> T;
  REP(i,T){
    cin >> a;
    chmax(x,a);
  }
  
  cout << max(0,2*x-1-K) << endl;
  
  return 0;
}

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

class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;

    //-1で初期化
    //最初はすべてバラバラ
    UnionFind(int N){
        parent = vector<int>(N,-1);
    }

    //Aがどのグループに属しているか(Aの根)を調べる
    int root(int A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }

    //自分のいるグループの頂点数を調べる
    int size(int A){
        return -parent[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B) {
    //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        //既にくっついているからくっつけない
        if(A == B) return false; 

        //大きいほう(A)に小さいほう(B)をくっつける
        //大証が逆ならひっくり返す
        if(size(A) < size(B)) swap(A,B);

        //Aのサイズを更新する
        parent[A] += parent[B];
        //Bの親をAに変更する
        parent[B] = A;

        return true;
    }

    //AとBが同じグループならtrueを返す
    bool same(int A, int B){
        return root(A)==root(B);
    } 
};

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

    ll n,m;
    cin>>n>>m;
    ll k;
    vector<vector<int>> v(m);
    for(int i=0;i<n;i++){
        cin>>k;
        for(int j=0;j<k;j++){
            int a;
            cin>>a;
            a--;
            v[a].push_back(i);
        }
    }
    UnionFind uni(n);
    for(int i=0;i<m;i++){
        if(v[i].size()>1){
            int a = v[i][0];
            for(int j=1;j<v[i].size();j++){
                uni.connect(a,v[i][j]);
            }
        }
    }
    for(int i=1;i<n;i++){
        if(!uni.same(0,i)){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;



    

}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,T,A;
  cin>>N>>T>>A;
  vector<int> h(N);
  for(int i=0;i<N;i++)
    cin>>h.at(i);
  T*=1000;
  A*=1000;
  int dif=A-T+6*h.at(0),index=0;
  if(dif<0)
    dif=-dif;
  for(int i=0;i<N;i++){
    int a=A-T+6*h.at(i);
    if(a<0)
      a=-a;
    if(a<dif){
      dif=a;
      index=i;
    }
  }
  cout<<index+1<<endl;
}

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

typedef long long ll;

int N, K;
ll mod = 1e9 + 7;
ll comb[2001][20001];

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

    for(int i=0;i<=2000;i++) comb[i][0] = 1;
    comb[1][1] = 1;
    for(int i=2;i<=2000;i++){
        for(int j=1;j<=2000;j++){
            comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
            comb[i][j] %= mod;
        }
    }

    ll ans = 1;

    int R = N - K;
    for(int i=1;i<=K;i++){
        ans = comb[R+1][i] * comb[K-1][i-1];
        ans %= mod;
        cout << ans << endl;
    }
}

Measured memory_bytes: 309888
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(a)  (a).begin(),(a).end()

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

Measured memory_bytes: 256
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 2e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
	ll h, w, m;
    cin >> h >> w >> m;
    map<pair<ll,ll>,ll> maps;
   	for(ll i = 1; i <= m; i++)
   	{
        ll x,y;
        cin >> x >> y;
        maps[{x,y}] = 1;
    }
    vector<ll>row(h+1,0),col(w+1,0);
    for(auto s : maps)
    {
        row[s.first.first]++;
        col[s.first.second]++;
    }
    vector<ll>x,y;
    ll ans = 0;
    for(auto s : maps)
    {
        x.push_back(s.first.first);
        y.push_back(s.first.second);
    }
    ll a = x.size();
    ll b = y.size();
    ll ind_x,ind_y;
    ll ma_x = 0,ma_y = 0;
    for(ll i = 1; i <= h; i++)
    {
        if(row[i] > ma_x)
        {
            ma_x = row[i];
            ind_x = i;
        }
    }
    for(ll i = 1; i <= w; i++)
        ans = max(ans,col[i] + ma_x - maps[{ind_x,i}]);
    
   	for(ll i = 1; i <= w; i++)
   	{
        if(col[i] > ma_y)
        {
            ma_y = col[i];
            ind_y = i;
        }
    }
    for(ll i = 1; i <= h; i++)
        ans = max(ans,row[i] + ma_y - maps[{i,ind_y}]);
    cout << ans << "\n";
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 68844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll x, y, z, k;
	cin >> x >> y >> z >> k;
	vector<ll> a(x), b(y), c(z);
	for (ll i = 0; i < x; i++) cin >> a[i];
	for (ll i = 0; i < y; i++) cin >> b[i];
	for (ll i = 0; i < z; i++) cin >> c[i];
	sort(all(a));
	sort(all(b));
	sort(all(c));
	reverse(all(a));
	reverse(all(b));
	reverse(all(c));
	priority_queue<vector<ll>> pq;
	pq.push({a[0] + b[0] + c[0], 0, 0, 0});
	map<vector<ll>, bool> mp;
	mp[{0, 0, 0}] = true;
	ll cnt = 0;
	while (k--) {
		vector<ll> tp = pq.top();
		pq.pop();
		cout << tp[0] << endl;
		ll s = tp[1], t = tp[2], u = tp[3];
		if (s + 1 < x && !mp[{s + 1, t, u}]) {
			pq.push({a[s + 1] + b[t] + c[u], s + 1, t, u});
			mp[{s + 1, t, u}] = true;
		}
		if (t + 1 < y && !mp[{s, t + 1, u}]) {
			pq.push({a[s] + b[t + 1] + c[u], s, t + 1, u});
			mp[{s, t + 1, u}] = true;
		}
		if (u + 1 < z && !mp[{s, t, u + 1}]) {
			pq.push({a[s] + b[t] + c[u + 1], s, t, u + 1});
			mp[{s, t, u + 1}] = true;
		}
	}
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
  char ch;
  cin>>ch;
  if(ch=='A') cout<<"T\n";
  else if(ch=='T') cout<<"A\n";
  else if(ch=='G') cout<<"C\n";
  else if(ch=='C') cout<<"G\n";
  return 0;
}

Measured memory_bytes: 256
/**
       **********    ************
	  Author : Avi J Patel
	  University : DAIICT
       **********    ************
**/
#include<bits/stdc++.h>
#include<math.h>
#include<fstream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 1844674407370955161
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define min_heap priority_queue<int, vector<int>, greater<int>>
#define max_heap priority_queue<int>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define pp pair<pair<ll,ll>,pair<ll,ll>>
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> 

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    if(a.ss < b.ss) return true; 
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.ff<b.ff) return true;
	else if(a.ff==b.ff) return a.ss<b.ss;
	else return false;
} 
bool sortff_resortss(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.ff<b.ff) return true;
	else if(a.ff==b.ff) return a.ss>b.ss;
	else return false;
}
bool sortbystring(const string &a, const string &b)
{
	string c=a+b;
	string d=b+a;
	if(c>=d) return true;
	else return false;
}
class CompareDist
{
	public:
	    bool operator()(pair<int,pair<int,int>> a,pair<int,pair<int,int>> b) 
		{
	        if(a.ff<b.ff) return true;
	        else if(a.ff==b.ff) return a.ss.ff>b.ss.ff;
	        else return false;
	    }
};

ll modi(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
ll Logn(ll  n, ll r) 
{ 
    return (n > r - 1) ? 1 + Logn(n / r, r) : 0; 
} 

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modinv(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
ll ncr(ll n, ll r, ll p) 
{ 
   if (r==0) 
      return 1; 
    int n1=n;
    ll fac[n1+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modinv(fac[r], p) % p * 
            modinv(fac[n-r], p) % p) % p; 
} 
int main()
{
	FAST
	int t=1;
//	cin>>t;
	while(t--)
	{
		ld a,b;
		cin>>a>>b;
		ll ans=a*b;
		cout<<ans;
	}
	return 0;
}

















Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
typedef long long ll;
using namespace std;

//　?tc?????tc???? coderなどのパターンを考え、後ろから行く
//　と思ったけど結局全ての置換場所を試さないといけない ab?? abaa等の場合
string s, t;
string solve() {
    int n = s.length();
    int m = t.length();
 
    set<string> ans; //setは自動的に辞書順
    rrep(r, n, m) {
        int l = r - m; // n-mから０まで
        int ok = 1;
        rep(i, 0, m) if (s[l + i] != '?' and s[l + i] != t[i]) ok = 0;
        if (ok) {
            string ss;
            rep(i, 0, n) ss += s[i];
            rep(i, 0, m) ss[l + i] = t[i];
            rep(i, 0, n) if (ss[i] == '?') ss[i] = 'a';
            ans.insert(ss);
        }
    }
 
    if(ans.size() == 0) return "UNRESTORABLE";
    return *(ans.begin());
}

int main() {
    cin >> s >> t;
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	
	int m[100][100];
	int n, s, t, u, i, j;
	
	scanf("%d", &n);
	
	for ( i = 0; i < n; i++) {
		for ( j = 0; j < n; j++) {
			m[i][j] = 0;
		}
	}
	
	for ( i = 0; i < n; i++) {
		scanf("%d", &s);
		scanf("%d", &t);
		for ( j = 0; j < t; j++) {
			scanf("%d", &u);
			m[s - 1][u - 1] = 1;
		}
	}
	
	for ( i = 0; i < n; i++) {
		for ( j = 0; j < n; j++) {
			printf("%d", m[i][j]);
			if ( j < (n - 1)) {
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

void call(int n) {
    for (int i = 1; i <= n; ++i) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        } else  {
            do {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            } while (x);
        }
    }
    
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    call(n);
    return 0;
}

Measured memory_bytes: 1160
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n;
    bool ansb = true;
    int a[200000];
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    a[0]-=1;
    rep(i,n-1){
        if(a[i] != a[i+1]){
            a[i+1]-=1;
        }
    }
    rep(i,n-1){
        if(a[i]> a[i+1]){
            ansb = false;
        }
    }
    if(ansb){
        cout << "Yes"<<endl;
    }else{
        cout << "No"<<endl;
    }
}

Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		String s=scanner.next();
		int max=0;
		for(int i=0;i<s.length();i++) {
			for(int j=i+1;j<=s.length();j++) {
				String tmp=s.substring(i, j);
				boolean b=false;
				for(int x=0;x<tmp.length();x++) {
					char c=tmp.charAt(x);
					if(c=='A'||c=='C'||c=='G'||c=='T') {
						continue;
					}else {
						b=true;
						break;
					}
				}
				if(!b) {
					max=Math.max(max, tmp.length());
				}
			}
		}
		System.out.println(max);
	}
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x,k,d;
	cin>>x>>k>>d;
	long long y=abs(x);
	long long j=y/d;
	if(x==0)
	{
		if(k%2)
		cout<<d;
		else
		cout<<0;
	}
	else if(x<0)
	{
		if(j>=k)
		{
			x+=(d*k);
			cout<<abs(x);
		}
		else
		{
			x+=(d*j);
			k=k-j;
			if(k%2==0)
			{
				cout<<abs(x);
			}
			else
			cout<<abs(x+d);
		}
	}
	else if(x>0)
	{
		if(j>=k)
		{
			x-=(d*k);
			cout<<abs(x);
		}
		else
		{
			x-=(d*j);
			k=k-j;
			if(k%2==0)
			{
				cout<<abs(x);
			}
			else
			cout<<abs(x-d);
		}
	}
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#define endl  "\n"
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);
using namespace std;
int main()
{
	string s;
	cin >> s;
	int cnt=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=s[s.size()-1-i])
		{
			s[i]=s[s.size()-1-i];
			cnt++;
		}
	}
	cout << cnt;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   int n;
           string s;
           cin>>n>>s;
           int r=0,b=0;
           rep(i,0,n){
            if(s[i]=='R')r++;
             else b++;
           }
           Yes(r>b);
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
long long k, n, a[200005], sum;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k;
for (int i=0; i<n; i++) cin >> a[i];
sort (a, a+n); for (int i=0; i<n-k; i++) sum+=a[i];
cout << sum;
return 0;
}

Measured memory_bytes: 1792
n = int(input())
dic = {}
for i in range(n):
    s = str(input())
    if s in dic.keys():
        dic[s] += 1
    else:
        dic.setdefault(s,1)
max_v = max(dic.values())
ans = []
for j in dic.items():
    if j[1] == max_v:
        ans.append(j[0])
ans.sort()
for i in ans:
    print(i)


Measured memory_bytes: 35424
#include<bits/stdc++.h>
#define foru(a,b,c) for(int a=b;a<=c;++a)
#define int long long

using namespace std;

int n,w,W[101],v[101];
int a[101][100010];

main()
{
    cin >> n >> w;
    foru(i,1,n) cin >> W[i] >> v[i];
    foru(i,0,n)
    foru(j,0,100001)
    {
        a[i][j]=INT_MAX;
    }
    a[0][0]=0;
    foru(i,0,n-1)
    {
        foru(t,0,100001)
        {
            if(a[i][t]!=INT_MAX)
            {
                if(a[i][t]+W[i+1]<=w)
                {
                    a[i+1][t+v[i+1]]=min(a[i][t]+W[i+1],a[i+1][t+v[i+1]]);
                }
                a[i+1][t]=min(a[i+1][t],a[i][t]);
            }
        }
    }
    for(int i=100001;i>=0;--i)
    {
        if(a[n][i]<INT_MAX)
        {
            cout << i;
            return 0;
        }
    }
}


Measured memory_bytes: 79104
N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
cnt = 0
for i in range(N-1):
  for j in range(i+1, N):
    ds = 0
    for k in range(D):
      ds += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k])
    sqds = int(ds**0.5)
    if sqds * sqds == ds:
      cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_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(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    int a, b, c, t = 0;
    cin >> a >> b >> c;
    rep(i, a, b + 1) {
        if(c % i < 1)
            t++;
    }
    cout << t << endl;
}


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int m = sc.nextInt();

    int[] a = new int[m];
    int[] b = new int[m];
    int[] route = new int[n];

    for (int i = 0; i < m; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      route[i] = i + 1;
    }

    int cnt = 0;

    do {

      if (route[0] != 1) {
        break;
      }

      boolean acc = false;
      int i = 0;
      int j = 0;

      while (true) {

        if (((a[i] == route[j]) && (b[i] == route[j + 1])) || ((b[i] == route[j]) && (a[i] == route[j + 1]))) {
          j++;
          if (j == n - 1) {
            acc = true;
            break;
          }
          i = 0;
        } else {
          i++;
          if (i == m) {
            acc = false;
            break;
          }
        }

      }

      if (acc) {
        cnt++;
      }

    } while ((route = nextPermutation(route)) != null);

    System.out.println(cnt);

  }

  static int[] nextPermutation(int[] array) {
    int i = Integer.MAX_VALUE;
    int j = 0;
    int[] returnarray = new int[array.length];

    for (int l = array.length - 2; l >= 0; l--) {
      if (array[l] < array[l + 1]) {
        i = l;
        break;
      }
    }

    if (i == Integer.MAX_VALUE) {
      return null;
    }

    for (int l = array.length - 1; l >= 0; l--) {
      if (array[i] < array[l]) {
        j = l;
        break;
      }
    }

    int temp = array[i];
    array[i] = array[j];
    array[j] = temp;
    i++;

    for (int l = 0; l < i; l++) {
      returnarray[l] = array[l];
    }
    for (int l = 0; l < array.length - i; l++) {
      returnarray[l + i] = array[array.length - l - 1];
    }

    return returnarray;

  }

}

Measured memory_bytes: 23892
def A():
    A, B, C = map(int, input().split())
    if A == B or B == C or A == C:
        if (A+B+C) != A*3:
            print('YES')
            return
    print('NO')

def B():
    N = int(input())
    A = [int(i) for i in input().split()]
    for i in A:
        if i%2==0 and not (i%3==0 or i%5==0):
            print('DENIED')
            return
    print('APPROVED')
B()

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#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 mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  int n;
  cin >> n;
  int _max = 0, _min = 10000;
  rep(i, n) {
    int a;
    cin >> a;
    _max = max(_max, a);
    _min = min(_min, a);
  }
  cout << _max - _min << endl;

  return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let r = read_as_vec::<f64>()[0];

    println!("{}", 2.0*r*std::f64::consts::PI);
}


Measured memory_bytes: 2208
n,m = map(int,input().split())
s = [list(map(int,input().split())) for i in range(m)]
ans = 0
for i in s:
    l = list(range(n))
    for j in s:
        if i!=j:
            l=[l[j[0]-1] if l[k]==l[j[1]-1] else l[k] for k in range(n)]
    if len(set(l))!=1: ans+=1
print(ans)

Measured memory_bytes: 40048
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define vl vector
using namespace std;
int main()
{
    ll n,m,a=0,i,j;
    cin>>n;
    ll count=0;
    ll no=1;
    while(1)
    {
        count+=no;
        n/=2;
        no*=2;
        if(n==0) break;
    }
    cout<<count;
}

Measured memory_bytes: 3592
import java.util.Scanner;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.PriorityQueue;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int n = stdIn.nextInt();

        int[] a = new int[n];

        for(int i = 0;i < n;i++) {
            a[i] = stdIn.nextInt();
        }

        int[] result = new int[n];

        for(int i = 0;i < n;i++){
            result[a[i]-1] = i+1;
        }

        for(int i : result){
            System.out.println(i);
        }
    }

}

Measured memory_bytes: 57972