akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
vector<int> a[N];

int DFS(int u) {
  vector<int> d;
  for (auto& v : a[u]) {
    d.push_back(DFS(v));
  }
  if (d.empty()) return 0;
  sort(d.begin(), d.end());
  int ret = 0;
  for (int k = 0; k < d.size(); ++k) {
    ret = max(ret, d[k] + (int)d.size() - 1 - k);
  }
  return ret + 1;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int j;
    scanf("%d", &j);
    --j;
    a[j].push_back(i);
  }
  printf("%d\n", DFS(0));
  return 0;
}


Measured memory_bytes: 13568
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

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

        // mは「最小公倍数-1」そのときのf(m)はa[i]-1の合計なので、mを求める必要なし
        int ans = 0;
        for (int i = 0; i < N; i++) {
            ans += a[i] - 1;
        }

        out.println(ans);
    }
}

Measured memory_bytes: 27600
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <string>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;

const ll mod = 1000000007;
const ll INF = 1000000000000;

ll N;
string s[100010], t[100010];
ll ch[100010][26];
vector<ll> vec[100010];

int main()
{
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> s[i];
		for (int j = 0; j < 10; j++)
		{
			vec[i].push_back((ll)(s[i][j] - 'a'));
		}
		sort(vec[i].begin(), vec[i].end());
		for (int j = 0; j < 10; j++)
		{
			t[i] += (char)(vec[i][j] + 'a');
		}
	}

	sort(t, t + N);

	ll cnt = 0, ans = 0;

	for (int i = 1; i < N; i++)
	{
		if (t[i] == t[i - 1])
		{
			cnt++;
		}
		else
		{
			ans += cnt * (cnt + 1) / 2;
			cnt = 0;
		}
	}

	cout << ans + (cnt + 1) * cnt / 2 << endl;

	int www;
	cin >> www;
}

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

int main()
{
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  int i, j;
  for(i = 0; i < m; i++)
  {
    cin >> b.at(i);
  }
  vector<vector<int>> a(n, vector<int>(m));
  for(i = 0; i < n; i++)
  {
    for(j = 0; j < m; j++)
    {
      cin >> a.at(i).at(j);
    }
  }
  int check;
  int ans = 0;
  for(i = 0; i < n; i++)
  {
    check = 0;
    for(j = 0; j < m; j++)
    {
      check += a.at(i).at(j)*b.at(j);
    }
    if(check+c > 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
  Scanner sc;

  class Pair {
    int f;
    int s;

    Pair(int f, int s) {
      this.f = f;
      this.s = s;
    }
  }

  void run() {
    for ( ;; ) {
      int n = ni();
      int m = ni();
      if ( ( n | m ) == 0 ) {
        break;
      }

      Pair[] list = new Pair[n];
      for ( int i = 0; i < n; ++i ) {
        int d = ni();
        int p = ni();
        list[ i ] = new Pair( d, p );
      }

      Arrays.sort( list, new Comparator<Pair>() {
        @Override
        public int compare(Pair o1, Pair o2) {
          return o2.s - o1.s;
        }
      } );

      int sum = 0;
      for ( Pair p : list ) {
        int pay = Math.min( m, p.f );
        sum += ( p.f - pay ) * p.s;
        m -= pay;
      }

      System.out.println( sum );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = (a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (a); i <= (long long)(n); i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

int main(void)
{
    ll n, k;
    cin >> n >> k;

    if(n%k == 0) {
        cout << 0 << endl;
    } else {
        cout <<  min(n % k, abs(n%k-k))<< endl;
    }

    return 0;
}
/** atcoder **/


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

#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define pb push_back
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline void                             in(T &p){cin>>p;}
template<class T1,class T2>inline void                   in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void          in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T>inline void                             ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
template<class T>inline void                             outs(T p){for_each(all(p),out<decltype(p[0])>);}
long N,K,len=1,i,M,ans=1,L,A;
string S;
vector<long>v,s;
inline void solve(void){
  in(N,K,S);
  up(i,1,N-1){
    if(S[i]==S[i-1])len++;
    else{
      v.pb(len);
      len=1;
    }
  }
  v.pb(len);
  M=v.size();
  s.resize(M+1);
  for(i=0;i<M;i++)s[i+1]=s[i]+v[i];
  A=S[0]=='1'?0:1;
  L=2*K+1;
  for(i=A;i+L<=M;i+=2)chmax(ans,s[i+L]-s[i]);
  L=1;
  for(i=A;i+L<=M;i+=2)chmax(ans,s[i+L]-s[i]);
  if(S[0]=='0')chmax(ans,s[min(K*2,M)]-s[0]);
  if(S[N-1]=='0')chmax(ans,s[M]-s[max(M-K*2,0L)]);
  out(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 2116
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include<cmath>
#include<functional>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int ans;
    if(n%x == 0)ans = (n/x)*t;
    else    ans = (n / x + 1) * t;
    cout << ans << endl;
    
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  string S;
  cin >> S;
  ll w{}, sum{};
  rep(i, 0, S.size()){
    if(S[i] == 'W'){
      sum += i - w;
      w++;
    }
  }
  cout << sum << rt;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

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

  string s;
  cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s << endl;

  return 0;
};


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int num[3],ans = 0;cin >> num[0] >> num[1] >> num[2];
  sort(num,num+3);
  ans = num[2]-num[1]+(num[1]-num[0])/2;
  if((num[1]-num[0])%2) ans += 2;
  cout << ans << endl;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	vvi dp(n + 1, vi(m + 1, 0));
	vvi prev(n + 1, vi(m + 1, -INF));
	REP(i, n)REP(j, m) {
		if (s[i] == t[j]) {
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
			prev[i + 1][j + 1] = 3;
		}
		else {
			if (dp[i][j + 1] < dp[i + 1][j]) {
				dp[i + 1][j + 1] = dp[i + 1][j];
				prev[i + 1][j + 1] = 2;
			}
			else {
				dp[i + 1][j + 1] = dp[i][j + 1];
				prev[i + 1][j + 1] = 1;
			}
		}
	}
	int i = n, j = m;
	string ret;
	while (i > 0 && j > 0) {
		if (prev[i][j] == 3) {
			ret.push_back(s[i - 1]);
			i--; j--;
		}
		else if (prev[i][j] == 2) {
			j--;
		}
		else {
			i--;
		}
	}
	reverse(ALL(ret));
	cout << ret << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<ll> a(n),b(n);
  for(int i=0;i<n;++i){
    cin >> a[i];
    b[i]=(a[i]-(i+1));
  }
  sort(b.begin(),b.end());

  ll b1=b[n/2];
  ll b2=b[(n+1)/2];
  ll cal1=0;
  ll cal2=0;
  for(int i=0;i<n;++i){
    cal1+=abs(b1-b[i]);
    cal2+=abs(b2-b[i]);
  }

  ll ans=min(cal1,cal2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6368
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
 
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 

int main()
{
    string s;
    cin>>s;
    ll n=s.length();
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='?')
        {
            s[i]='D';
        }
    }
    cout<<s<<endl;
}
    


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w,m,x,y;cin>>h>>w>>m;
  lvector hvec(h+1),wvec(w+1);
  map<P,ll> mp;
  rep(i,m) {
    cin>>x>>y;
    mp[P(x,y)]++;
    hvec[x]++,wvec[y]++;
  }
  ll hpos=max_element(ALL(hvec))-hvec.begin(),ans=0;
  rep(wpos,w+1) {
    ll tmp=hvec[hpos]+wvec[wpos]-mp[P(hpos,wpos)];
    ans=max(ans,tmp);
  }
  ll wp=max_element(ALL(wvec))-wvec.begin();
  rep(hp,h+1) {
    ll tmp=hvec[hp]+wvec[wp]-mp[P(hp,wp)];
    ans=max(ans,tmp);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 64172
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        int sum = 0;
        int max = 0;
        int tmp = 0;
        for(int i = 0;i<3;i++) {
        	tmp = scanner.nextInt();
        	if(max < tmp) {
        		max = tmp;
        	}
        	sum += tmp;
        }
        System.out.println(sum-max);


    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

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

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

int R[101], C[101];
int dp[101][101];

int f(int l, int r) {
	dump(l, r);
	if (dp[l][r] != INF)return dp[l][r];
	if (l >= r - 1)return 0;
	rep(m, l + 1, r) {
		chmin(dp[l][r], f(l, m) + f(m, r) + R[l] * R[m] * C[r - 1]);
	}
	return dp[l][r];
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	rep(i, 0, n)cin >> R[i] >> C[i];
	memset(dp, 0x3f, sizeof(dp));
	cout << f(0, n) << endl;
	return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <cstdlib>

using namespace std;

struct list {
	int data;
	struct list* next;
};

list* make_list(int n, list* p) {
	list* z = (list*)malloc(sizeof(list));
	z->data = n;
	z->next = p;
	return z;
}

int main() {
	int n, k, m;
	while (cin >> n >> k >> m) {
		if (n == 0 && k == 0 && m == 0) {
			break;
		}
		list* z = make_list(n, NULL);
		list** p = &z;
		for (int i = n-1; i >= 1; i--) {
			z = make_list(i, z);
		}
		while ((*p)->next != NULL) {
			p = &((*p)->next);
		}
		if (m != 1) {
			(*p)->next = z;
		} else {
			(*p)->next = z->next;
			z = z->next;
		}
		if (m != 1) {
			p = &z;
			for (int i = 0; i < m-2; i++) {
				p = &((*p)->next);
			}
			(*p)->next = ((*p)->next)->next;
		}
		while (((*p)->next)->data != (*p)->data) {
			for (int i = 0; i < k-1; i++) {
				p = &((*p)->next);
			}
			(*p)->next = ((*p)->next)->next;
		}
		cout << (*p)->data << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
  ll N;
  cin >> N;
  ll n = N % 10;
  if(n==2 || n==4 || n == 5|| n == 7 || n==9) cout <<"hon";
  else if(n==3) cout << "bon" << endl;
  else cout << "pon";
}

Measured memory_bytes: 3632
D,N = map(int,input().split())
#%%
ans = 0
cur = 0
for i in range(1,(100**D)*N*10):
    a = i
    t = 0
    while a%100==0 and a>0:
        a//=100
        t+=1
    if t==D:
        cur += 1
    if cur == N:
        ans = i
        break
print(ans)
        
    

Measured memory_bytes: 40944
//#include "atcoder/all"
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
// using namespace atcoder;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll ans = max(A * C, A * D);
  ans = max(ans, B * D);
  ans = max(ans, B * C);

  if (A <= 0 && B >= 0)
    ans = max(ans, 0LL);
  if (C <= 0 && D >= 0)
    ans = max(ans, 0LL);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define fort(i,n) for (int i = 1; i <= n; i++)
#define ll long long
#define pi pair<int,int>
#define sz size()
#define er erase
#define fr first
#define sc second
using namespace std;

int n,a[15];

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    fort(i,9)
    {
        a[i]=111*i;
        if (n<=a[i]&&n>a[i-1])
        {
            cout << a[i];
            break;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<int(n);i++)
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    ll Max=0;
    ll Min=1e9;
    rep(i, n)  cin >> a[i];

    rep(i, n){
        Max=max(Max, a[i]);
        Min=min(Min, a[i]);
    }
    cout << Max-Min << endl;
    return 0;
}

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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int a, b;
	cin >> a >> b;	
	cout << max(0, a - 2 * b) << '\n'; 	
	return 0;
}

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

int main() {
  int A = 0, B = 0, N = 0;
  cin >> N >> A >> B;
  
  if(N * A > B) {
    cout << B << endl;
  }else if(N * A < B) {
    cout << N * A << endl;
  }else{
    cout << B << endl;
  }
}


Measured memory_bytes: 3596
//package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        int x, y, z;
        int ans;

        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        y = sc.nextInt();
        z = sc.nextInt();

        /*x = Integer.parseInt(a);
        y = Integer.parseInt(b);
        z = Integer.parseInt(c);*/
        sc.close();

        ans = (x - z) / (y + z);
        System.out.println(ans);
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int dp[1<<16],w_sum[1<<16],top=0;
int fl[10001],k;
int w[16],ind=0;
int n,m,W;

int main(){
    cin >> n >> m >> W;
    m -= 1;

    memset(fl,0, sizeof(fl));
    memset(w_sum, 0, sizeof(w_sum));
    fill((int *)dp, (int *)dp+(1<<16), 1<<29);
    
    for(int i=0;i<n;i++){
        cin >> k;
        for(int j=0;j<k;j++){
            cin >> w[ind];
            fl[i] |= (1 << ind);
            ind++;
            top = i;
        }
    }

    if(fl[0] == (1 << ind) - 1){
        cout << 0 << endl;
        return 0;
    }

    for(int i=0;i<(1 << ind);i++){
        for(int j=0;j<ind;j++){
            if(i&(1<<j)){
                w_sum[i] += w[j];
            }
        }
    }
    
    dp[0] = 0;
    for(int i=0;i<(1<<ind);i++){
        for(int j=i;j!=0;--j&=i){
            if(w_sum[j] <= W){
                dp[i] = min(dp[i], dp[i^j]+1);
            }
        }
    }

    int ret = abs(top - m);
    for(int i=top;i>0;i--){
        ret += 2 * dp[fl[i]] -1;
        fl[i-1] |= fl[i];
    }
    cout << ret << endl;
}

Measured memory_bytes: 1724
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
#define vel vector<long long>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
long long p = 998244353;
vel kai(4001, 1);
vel ink(4001, 1);
vel uni(vel &list) {
	if (list.size() == 0) { return list; }
	sort(list.begin(), list.end());
	vel ql(1, list[0]);
	rep(i, list.size() - 1) {
		if (list[i] != list[i + 1]) { ql.push_back(list[i + 1]); }
	}
	return ql;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 4000) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 4001) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
signed main() {
	make_kai();
	vel rui(40001, 1);
	rep(i, 4000) { rui[i + 1] = (rui[i] * 2) % p; }
	int n, k; cin >> k >> n;
	vel ans(2 * k - 1, 0);
	for (int i = 2; i <= k + 1; i++) {
		int qans = 0;
		int pair = (i - 1) / 2;
		int ex = k - i + 1;
		rep(j, min(pair, n) + 1) {
			int can_use = n - j;
			int can_pal = j + ex;
			if (can_pal != 0) {
				int pl = com(can_use + can_pal - 1, can_pal - 1)*com(pair, j); pl %= p;
				pl *= rui[j]; pl %= p;
				qans += pl; qans %= p;
			}
		}
		if (i % 2 == 0) {
			n--;
			rep(j, min(pair, n) + 1) {
				int can_use = n - j;
				int can_pal = j + ex;
				if (can_pal != 0) {
					int pl = com(can_use + can_pal - 1, can_pal - 1)*com(pair, j); pl %= p;
					pl *= rui[j]; pl %= p;
					qans += pl; qans %= p;
				}
			}
			n++;
		}
		ans[i - 2] = qans;
		ans[2 * k - i] = qans;
	}
	rep(i, 2 * k - 1) { cout << ans[i] << endl; }
	return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<ll> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


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

	string k; int d;
	cin >>k >>d;
	
	int n=sz(k); 
	vector<vector<ll> > p(d+2, vector<ll>(2));    
	p[0][0]=1;
	rep(i, n){
		vector<vector<ll> > np(d+2, vector<ll>(2));    
		
		rep(j, d) rep(s, 10){
			int mj = (j + s) % d;
			
			if(s < k[i] -'0') (np[mj][1] += p[j][0]) %=mod;
			else if(s== k[i] -'0') (np[mj][0] += p[j][0])%=mod;
			(np[mj][1] += p[j][1])%=mod;
			
			
		}
		swap(np, p);
	//for(auto x :p) printf("%d:%d, ",x[0], x[1]); puts("");
	}
	ll ans = (p[0][0] + p[0][1] -1 + mod) %mod;
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <queue>
#include <utility>

using namespace std;

int N,M;
const int MAXN=1e5+10;

vector<int> graph[MAXN];
bool visited[MAXN];
int ans[MAXN];

void BFS(){
    queue<int> q;
    q.push(1);
    visited[1]=true;
    while(!q.empty()){
        int cur=q.front();
        q.pop();
        // printf("cur=%d\n",cur);
        
        // visited[cur]=true;

        for(auto adj:graph[cur]){
            if (visited[adj]) continue;
            visited[adj]=true;
            q.push(adj);
            ans[adj]=cur;
        }

    }
}

int main(){
    scanf("%d%d",&N,&M);
    for(int i=0;i<M;i++){
        int s,e;
        scanf("%d%d",&s,&e);
        graph[s].push_back(e);
        graph[e].push_back(s);
    }

    BFS();

    puts("Yes");
    for(int i=2;i<=N;i++) printf("%d\n",ans[i]);

    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  long long H[N];
  long long maxl[N];
  int A[M], B[M];
  
  for (int i = 0; i < N; i++) {
    cin >> H[i];
    // iから一本で行ける展望台の最高の高さ
    maxl[i] = 0;
  }
  
  for (int i = 0; i < M; i++)
    cin >> A[i] >> B[i];

  for (int i = 0; i < M; i++) {
    maxl[A[i]-1] = max(maxl[A[i]-1], H[B[i]-1]);
    maxl[B[i]-1] = max(maxl[B[i]-1], H[A[i]-1]);
  }

  int ans = 0;
  // 道が繋がってなければmaxl[i] = 0から条件は問題ない
  for (int i = 0; i < N; i++) {
    if (maxl[i] < H[i])
      ans++;
  }

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


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

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

    int na = (C+B-1) / B;
    int nb = (A+D-1) / D;

	
    cout << ((na <= nb) ? "Yes" : "No") << endl; 
    
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"


template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef cc_hash_table<int, int, hash<int > > ht;


#define int long long 
#define  st first
#define  nd second

const int M = 1000000007;
const int  maxn = 100001;
const int  inf =  1e16;


void solve(){
  int a,b,c,d; 
  cin >> a >> b >> c >> d ; 

  cout << max( a*c,max(a*d,max(b*d,b*c)));
  

}
int32_t main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int te ; 
 // cin >> te ;
  te = 1; 
  while(te--){
    solve();
  }
  
  }

  
  

Measured memory_bytes: 3648
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

type greaterHeap []int

func (h greaterHeap) Len() int            { return len(h) }
func (h greaterHeap) Less(i, j int) bool  { return h[i] < h[j] }
func (h greaterHeap) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *greaterHeap) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *greaterHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

type lessHeap []int

func (h lessHeap) Len() int            { return len(h) }
func (h lessHeap) Less(i, j int) bool  { return h[i] > h[j] }
func (h lessHeap) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *lessHeap) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *lessHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	N := nextInt()
	as := make([]int, 3*N)
	for i := 0; i < 3*N; i++ {
		as[i] = nextInt()
	}

	ks := make([]int, N+1)

	g := &greaterHeap{}
	var total int
	for i := 0; i < N; i++ {
		heap.Push(g, as[i])
		total += as[i]
	}
	ks[0] = total
	for i := N; i < 2*N; i++ {
		heap.Push(g, as[i])
		total += as[i]
		total -= heap.Pop(g).(int)
		ks[i-N+1] = total
	}

	l := &lessHeap{}
	total = 0
	for i := 3*N - 1; i > 2*N-1; i-- {
		heap.Push(l, as[i])
		total += as[i]
	}
	ks[N] -= total
	for i := 2*N - 1; i > N-1; i-- {
		heap.Push(l, as[i])
		total += as[i]
		total -= heap.Pop(l).(int)
		ks[i-N] -= total
	}

	ans := math.MinInt64
	for _, v := range ks {
		ans = max(ans, v)
	}
	fmt.Println(ans)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;
    for (ll i=2; i*i<=n; ++i) {
        while (n%i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) res[n]++;
    return res;
}

ll mod = 1e9+7;
ll ma = 1e5 * 2;

struct ModComb {
    vector<long long> fact, rfact;
    long long max, mod;
    ModComb(long long ma, long long mod) :fact(ma, 0), rfact(ma, 0), max(ma), mod(mod) {
        fact[0] = 1;
        for (long long i=1; i<max; ++i) {
            fact[i] = fact[i-1]*i;
            fact[i] %= mod;
        }
        rfact[max-1] = mod_inverse(fact[max-1], mod);
        for (long long i=max-2; i>=0; --i) {
            rfact[i] = rfact[i+1]*(i+1);
            rfact[i] %= mod;
        }
    }
    long long mod_pow(long long x, long long n, long long mod) {
        long long a = 1LL;
        while (n) {
            if (n%2) a = ((a%mod)*(x%mod))%mod;
            x = ((x%mod)*(x%mod))%mod;
            n /= 2LL;
        }
        return a;
    }

    long long mod_inverse(long long a, long long m) {
        return mod_pow(a, m-2, m);
    }

    long long operator()(long long n, long long r) {
        if (n < r) return 0;
        return (((fact[n] * rfact[r]) % mod) * rfact[n - r]) % mod;
    }
};


int main() {
    ll N, M;
    cin >> N >> M;
    ModComb c(ma, mod);
    map<ll, ll> p = prime_factor(M);
    ll ans = 1;
    for (auto t : p) {
        ll tmp = c(N+t.second-1, t.second);
        ans = (ans * tmp) % mod;
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, m;
    cin >> n >> m;
    int a, sum = 0;
    rep(i, 0, m){
        cin >> a;
        sum += a;
    }
    if(n - sum < 0) cout << -1 << endl;
    else cout << n - sum<< endl;
}


Measured memory_bytes: 3624
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef unsigned int uint;
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

const int MX = 200005;

int A[MX];
int N;

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", A+i);
	ll ans = 0;
	int r = 1, cur = 0;
	for(int i = 1; i <= N; i++){
		while((cur&A[r]) == 0 && r <= N) cur ^= A[r++];
		ans += r - i;
		cur ^= A[i];
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>
#include <cmath>


using namespace std;



int main() {
	int n;
	double x[100], y[100];
	double D1 = 0;
	double D2 = 0;
	double D3 = 0;
	double sum2 = 0;
	double sum3 = 0;
	double max = 0;
	cin >> n;
	for (int i = 0; i < n;  i++) {
		cin >> x[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> y[i];
	}
	for (int i = 0; i < n; i++) {
		D1 += abs(x[i] - y[i]);
		if (max < abs(x[i] - y[i])) {
			max = abs(x[i] - y[i]);
		}
		sum2 += abs(x[i] - y[i]) * abs(x[i] - y[i]);
		sum3 += abs(x[i] - y[i]) * abs(x[i] - y[i]) * abs(x[i] - y[i]);
	}
	D2 = sqrt(sum2);
	D3 = pow(sum3, 1.0/3.0);

	cout << fixed << D1 << endl;
	cout << fixed << D2 << endl;
	cout << fixed << D3 << endl;
	cout << fixed << max << endl;
}


Measured memory_bytes: 3472
import sys
from collections import Counter
sys.setrecursionlimit(10**6)

def main():
    input = sys.stdin.readline
    MOD = 998244353
    N = int(input())
    D = list(map(int, input().split()))

    c = Counter(D)

    if D[0] != 0 or c[0] != 1:
        return 0
    
    ans = 1
    m = max(D)
    for i in range(2, m+1):
        ans *= pow(c[i-1], c[i], MOD)
        ans %= MOD

    return ans

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

Measured memory_bytes: 19864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	char a;
	cin >> a;
	if(a-'a'<0)
		cout << 'A' << endl;
	else
		cout << 'a' << endl;
	return 0;
}



Measured memory_bytes: 3592
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        int n=(int)'A';
        for(int i=0;i<26;i++){
            if(s.replaceAll(Character.toString((char)(n+i)), "").length()!=2&&s.replaceAll(Character.toString((char)(n+i)), "").length()!=4){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }

}

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

int main() {
    int n;
    cin >> n;
    cout << 0 << endl;
    vector<string> ans(n);
    cin >> ans[0];
    if(ans[0] == "Vacant") return 0;
    cout << n-1 << endl;
    cin >> ans[n-1];
    if(ans[n-1] == "Vacant") return 0;

    int right = n-1;
    int left = 0;
    while(right-left > 1) {
        int mid = (right+left) / 2;
        cout << mid << endl;
        cin >> ans[mid];
        if(ans[mid] == "Vacant") return 0;
        else {
            if(((right-mid) % 2 == 0) && (ans[mid] != ans[right])) {
                left = mid;
            }else if(((right-mid) % 2 == 1) && (ans[mid] == ans[right])) {
                left = mid;
            }else if(((mid-left) % 2 == 0) && (ans[mid] != ans[left])) {
                right = mid;
            }else if(((mid-left) % 2 == 1) && (ans[mid] == ans[left])) {
                right = mid;
            }
        }
    }
}

Measured memory_bytes: 1620
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7



int main(){
  int x;
  cin >> x;
  string ans;
  if(x >= 1000){
    ans = "ABD";
  }else{
    ans = "ABC";
  }
  print(ans);
}

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

const int INF = 1001001001;

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

	int min_val = INF;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int p;
		cin >> p;

		if (min_val >= p) {
			min_val = p;
			ans++;
		}
	}

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

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

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

int N;
int U[100010];
int V[100010];
int W[100010];

class UnionFindTree{
private:
  // indexの数の親ノード(ある集合の親を見つけたいときはここを直接参照せず、findを使う)
  vector<int> par;
  // indexを根とする木のランク
  vector<int> rank;
  // 集合のサイズ
  vector<int> cnts;
  // 木の最大値
  int treeSize;
public:
  UnionFindTree(int initTreeSize = 1000){
    // 引数で与えられた値を最大格納数とするUnionFindTreeの作成
    treeSize = initTreeSize;
    init(initTreeSize);
  }
  void init(int sz){
    par.clear(),rank.clear(),cnts.clear();
    treeSize=sz;
    for(int i = 0; i < sz; i++){
      par.push_back(i);
      rank.push_back(0);
      cnts.push_back(1);
    }
  }
  // 与えられた数が格納されている木のルートを探索
  int find(int x){  
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
  }
  // 和集合をとる。ただしここでは各集合の親の付け替えは起こらない
  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y)return;
    if(rank[x] < rank[y]){
      par[x] = y;
      cnts[y]+=cnts[x];
    }
    else{
      par[y] = x;
      cnts[x]+=cnts[y];
      if(rank[y] == rank[x])rank[x]++;
    }
  }
  // xの属する集合のサイズ
  int getCnt(int x){
    return cnts[find(x)];
  }
  bool same(int x,int y){
    return find(x) == find(y);
  }
    
};
set<int> G[100010];
UnionFindTree uft(100010);
bool used[100010];
int cols[100010];

void dfs(int pos, int col){
    used[pos] = true;
    cols[pos] = col;
    for(int to : G[pos]){
        if(used[to]) continue;
        dfs(to, col ^ 1);
    }
}

int main(){


    cin >> N;
    for(int i = 0; i < N - 1; i++){
        cin >> U[i] >> V[i] >> W[i];
        U[i]--;
        V[i]--;
        if(W[i] % 2 == 0){
            uft.unite(U[i], V[i]);
        }
    }
    int start = -1;
    for(int i = 0; i < N; i++){
        int u = uft.find(U[i]);
        int v = uft.find(V[i]);
        if(u != v){
            G[u].insert(v);
            G[v].insert(u);
        }
        start = u;
    }
    dfs(start, 0);
    for(int i = 0; i < N; i++){
        cout << cols[uft.find(i)] << endl;
    }
    

    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>C(N-1),S(N-1),F(N-1);
  for(int i=0;i<N-1;i++)cin>>C[i]>>S[i]>>F[i];
  vector<vector<int>>dp(N,vector<int>(N,0));
  for(int j=0;j<N;j++)dp[j][0]=0;

  for(int j=0;j<N-1;j++){
    for(int i=1;i+j<N;i++){
      dp[j][i]=dp[j][i-1];
      if(dp[j][i]<S[i-1+j])dp[j][i]=S[i-1+j];
      while(dp[j][i]%F[i-1+j])dp[j][i]++;
      dp[j][i]+=C[i-1+j];
    }
  }

  for(int j=0;j<N;j++)cout<<dp[j][N-1-j]<<endl;
  return 0;
}


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

int parity(int n){
  if(n*n*n*n%10 == 1)
    return 1;
  else
    return 0;
}

int power(int x, int y){
  int64_t n = 1ll;
  for(int i = 0; i < y; i++)
    n *= x;
  return n;
}
int digit(int x, int y){
  return x%power(10,y+1)/power(10,y);
}

int main(){
  int n;
  cin >> n;
  cout << n*(n+1)/2 << endl;
}

Measured memory_bytes: 256