akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;

int main()
{
    int x, y, z, k;
    std::cin >> x >> y >> z >> k;

    std::vector<long long> a(x);
    for (int i = 0; i < x; i++) {
        std::cin >> a[i];
    }

    std::vector<long long> b(y);
    for (int i = 0; i < y; i++) {
        std::cin >> b[i];
    }

    std::vector<long long> c(z);
    for (int i = 0; i < z; i++) {
        std::cin >> c[i];
    }

    std::sort(a.begin(), a.end(), std::greater<long long>());
    std::sort(b.begin(), b.end(), std::greater<long long>());
    std::sort(c.begin(), c.end(), std::greater<long long>());

    std::priority_queue<std::tuple<long long, int, int, int>> q;

    std::vector<std::tuple<long long, int, int, int>> found;

    q.push(std::make_tuple(a[0] + b[0] + c[0], 0, 0, 0));
    found.push_back(std::make_tuple(a[0] + b[0] + c[0], 0, 0, 0));

    for (int i = 0; i < k; i++) {

        std::tuple<long long, int, int, int> top = q.top();
        found.push_back(top);
        q.pop();

        std::cout << std::get<0>(top) << std::endl;

        int idx_a = std::get<1>(top),
            idx_b = std::get<2>(top),
            idx_c = std::get<3>(top);

        if (idx_a + 1 < x) {
            std::tuple<long long, int, int, int> next_a = std::make_tuple(a[idx_a + 1] + b[idx_b] + c[idx_c], idx_a + 1, idx_b, idx_c);
            if (std::find(found.begin(), found.end(), next_a) == found.end()) {
                q.push(next_a);
                found.push_back(next_a);
            }
        }

        if (idx_b + 1 < y) {
            std::tuple<long long, int, int, int> next_b = std::make_tuple(a[idx_a] + b[idx_b + 1] + c[idx_c], idx_a, idx_b + 1, idx_c);
            if (std::find(found.begin(), found.end(), next_b) == found.end()) {
                q.push(next_b);
                found.push_back(next_b);
            }
        }

        if (idx_c + 1 < z) {
            std::tuple<long long, int, int, int> next_c = std::make_tuple(a[idx_a] + b[idx_b] + c[idx_c + 1], idx_a, idx_b, idx_c + 1);
            if (std::find(found.begin(), found.end(), next_c) == found.end()) {
                q.push(next_c);
                found.push_back(next_c);
            }
        }
    }
}


Measured memory_bytes: 1024
# B
N, M = map(int, input().split())
A = list(map(int, input().split()))

threshold = sum(A) / (4*M)
count=0
for i in range(len(A)):
    if A[i] >= threshold:
        count += 1

if count >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.Arrays;

class Solver {
    public void Solve() {
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        for (int i = 0; i < a.length - 1; i++) {
            if (a[i] == a[i + 1]) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
}


Measured memory_bytes: 87192
#include <bits/stdc++.h>
using namespace std;
struct dat{
  int T,t,f,lap;
  dat(){T=t=f=lap=0;}
  vector<dat> V;
  bool operator > (const dat &a)const{return T-t>a.T-a.t;}
};

bool onFront(const dat &a,const dat &b){return a.f==b.f&&1.0*a.t/a.T<1.0*b.t/b.T;}
bool checkJam(const dat &a,const dat &b){return onFront(a,b)&&a.T-a.t<b.T-b.t;}

int merge(vector<dat>&A,int idx){
  dat &a = A[idx];
  for(int i=0;i<idx;i++){
    dat &b = A[i];
    if(!checkJam(a,b))continue;
    a.t=0, a.lap-=a.f, a.f=!a.f;
    b.V.push_back(a);
    A.erase(A.begin()+idx);
    return 1e9;
  }
  return a.T-a.t;
}

void Push(vector<dat>&A,dat &a){
  for(int i=0;i<(int)a.V.size();i++)Push(A,a.V[i]);
  a.V.clear();
  if(a.lap) A.push_back(a);
}

int sim(vector<dat> A){
  int res=0,idx=0;
  vector<dat> tmp[2]={A};
  
  while(1){
    vector<dat> &A = tmp[idx];
    if(A.empty())break;
    sort(A.begin(),A.end(),greater<dat>());
    int mn = 1e9;
    for(int i=A.size()-1;i>=0;i--)mn=min(mn,merge(A,i));

    idx=!idx;
    vector<dat>&nA=tmp[idx];tmp[idx].clear();
    for(int i=0;i<(int)A.size();i++)
      if(A[i].t+mn<A[i].T) A[i].t+=mn,nA.push_back(A[i]);
      else A[i].t=0, A[i].lap-=A[i].f, A[i].f=!A[i].f,Push(nA,A[i]);

    res+=mn;
  }
  return res;
}

int main(){
  int n;
  while(cin>>n,n){
    vector<dat> A(n);
    for(int i=0;i<n;i++)cin>>A[i].T>>A[i].lap;
    cout<<sim(A)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3112
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	string s;
	int cnt = 0;
	for (; cin >> s;)
	{
		string t;

		t = s;
		reverse(t.begin(), t.end());

		if (s == t)
		{
			cnt++;
		}
	}

	cout << cnt << endl;
}


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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;

/*************************************************************************/

int mex(VI &vec) {
    sort(vec.begin(), vec.end());
    vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
    
    vec.pb(INF);
    FORE(i,vec) if (vec[i] != i) {
        return i;
    }
    
    assert(false);
}

int getValue(int v, VVI &g, VI &value) {
    if (value[v] == -1) {
        VI vec;
        for (int u : g[v]) {
            vec.pb(getValue(u, g, value));
        }
        
        value[v] = mex(vec);
    }
    
    return value[v];
}

/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    VI in(n);
    VVI g(n);
    
    FOR(i,0,n-1) {
        int p;
        cin >> p; p--;
        
        in[i] = p;
        g[p].pb(i);
    }
    
    int v = 0;
    FOR(_,1,n) v = in[v];
    
    VB onCycle(n, false);
    
    while (!onCycle[v]) {
        onCycle[v] = true;
        v = in[v];
    }
    
    VI value(n,-1);
    
    FOR(i,0,n-1) if (!onCycle[i]) {
        getValue(i, g, value);
    }
    
    VI valuesForV;
    
    VI see;
    for (int u : g[v]) if (!onCycle[u]) {
        see.pb(value[u]);
    }
    
    VI vec = see;
    
    int mx = mex(vec);
    valuesForV.pb(mx);
    
    vec.pb(mx);
    valuesForV.pb(mex(vec));
    
    int x;
    for (int u : g[v]) if (onCycle[u]) {
        x = u;
        break;
    }
    
    for (int valueChosen : valuesForV) {
        VI valueHere = value;
        valueHere[v] = valueChosen;
        
        VI vecHere = see;
        vecHere.pb(getValue(x, g, valueHere));
        
        if (valueChosen == mex(vecHere)) {
            cout << "POSSIBLE";
            return 0;
        }
    }
    
    cout << "IMPOSSIBLE";

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 33664
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i; i < n; i++){
    cin >> v.at(i);
  }
  
  int ans = 0;
  for(int i; i < n; i++){
    ans += v.at(i);
  }
  ans -= n;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define llabs(n) (n)<0?-(n):(n);
using namespace std;

typedef long long LL;

int main(void)
{   ios::sync_with_stdio(false);
    LL a, b, v, w, t, c, u;

    cin>>a>>v>>b>>w>>t;
    c = llabs(a-b);
    u = v-w;
    if(c==0)
        cout<<"NO\n";
    else if(u<=0)
        cout<<"NO\n";
    else if(u*t<c)
        cout<<"NO\n";
    else
        cout<<"YES\n";

    return 0;
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define R(i,n) for(int i = 0; i < (n); i++)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}

template<class T> ostream &operator<<(ostream& os, set<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.FI << "," << P.SE << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int a,b,c,d;
bool test(){
  cin >> a >> b >> c >> d;
  if(d < b || a < b)return 0;
  int pom = __gcd(b,d);
  c++;
  int min = c + ((a - c) % pom + pom) % pom - b;
  return min >= 0;
  
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int t;
  cin >> t;
  while(t--){
    if(test()){
      cout << "Yes\n";
    }else{
      cout << "No\n";
    }
  }
}




Measured memory_bytes: 256
while 1:
    n = int(input())
    if n == 0:
        break

    data = list(map(int, input().split()))

    if n == 1:
        print(2)
    elif data.count(0) + data.count(1) == n:
        print("NA")
    else:
        print(n-data.count(0)+1)



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

using namespace std;

const double PI = acos(-1);

int main() {
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double hh = double(60 * h + m) / 720 * 2 * PI;
  	double mm = double(m) / 60 * 2 * PI;
  	double dd = abs(hh - mm);
	double ans = double(a * a + b * b) - 2 * a * b * cos(dd);
	ans = sqrt(ans);
	printf("%.15f", ans);
}


Measured memory_bytes: 4128
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

string s[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

int zeller(int y, int m, int d){
    if(m <= 2){
        y--;
        m += 12;
    }
    return (y + y/4 - y/100 + y/400 + (13*m+8)/5 + d) % 7;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int a,b;
        cin >> a >> b;
        if(a == 0) break;
        cout << s[zeller(2004, a, b)] << "\n";
    }
    return 0;
}



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

int main(void){
  int arr[5];
  for(int i=0; i<5; i++){
    cin >> arr[i];
  }
  sort(arr,arr+5);
  for(int i=0; i<5; i++){
    cout << arr[4-i];
    cout << (i == 4 ? '\n' : ' ');
  }
  return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main () {
	int N;
	std::vector<int> sides(3);
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> sides[0] >> sides[1] >> sides[2];
		sort(sides.begin(),sides.end());
		if(sides[2] * sides[2] == sides[1] * sides[1] + sides[0] * sides[0]){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
inline void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
inline void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}
int f[1000000];
int main() {
	for (int i = 1; i <= 100; i ++) {
		for (int j = 1; j <= 100; j ++) {
			for (int k = 1; k <= 100; k ++) {
				f[i * i + j * j + k * k + i * j + j * k + i * k] ++; 
			}
		}
	}
	int n;
	readin(n);
	for (int i = 1; i <= n; i ++) {
		writeln(f[i], '\n');
	}
	return 0;
}




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

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll extgcd(ll a, ll b, ll &x, ll &y) { ll d; return b == 0 ? (x = 1, y = 0, a) : (d = extgcd(b, a % b, y, x), y -= a / b * x, d); }
ll modinv(ll a, ll mod = 1e9 + 7) { ll x = 0, y = 0; extgcd(a, mod, x, y); return (x + mod) % mod; }
ll modpow(ll a, ll b, ll mod = 1e9 + 7) { ll r = 1; a %= mod; while(b) { if(b & 1) r = r * a % mod; a = a * a % mod; b >>= 1; } return r; }

const int N = 250000 + 10;
const ll mod = 1e9 + 7;
vector<ll> gen{114514, 1919};
vector<map<ll, int>> Bex(gen.size());
int n;
string s;
int ms[N];
ll calc(int i, int c, ll x) {
  if(i == 0) {
    // A
    if(c <= 1) return 1;
    if(c == 2) return modinv(x, mod);
    return x;
  } else {
    if(c == 0) return 1;
    if(c == 1) return -1;
    return 0;
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> s;
  vector<vector<ll>> A(gen.size(), vector<ll>(n+2)), B = A;
  for(int i = 0; i < n; i++) {
    if(s[i] == '+') ms[i] = 0;
    else if(s[i] == '-') ms[i] = 1;
    else if(s[i] == '>') ms[i] = 2;
    else ms[i] = 3;
  }
  for(int k = 0; k < gen.size(); k++) {
    gen[k] = ((gen[k] % mod + mod) % mod);
    ll x = gen[k];
    A[k][1] = 1;
    B[k][1] = 0;
    for(int i = 0; i < n; i++) {
      A[k][i+2] = A[k][i+1] * calc(0, ms[i], x) % mod;
      B[k][i+2] = A[k][i+1] * calc(1, ms[i], x) % mod + B[k][i+1];
      B[k][i+2] = ((B[k][i+2] % mod + mod) % mod);
      Bex[k][B[k][i+2]]++;
    }
  }
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    ll mi = 1e18;
    for(int k = 0; k < gen.size(); k++) {
      ll c = A[k][i+1] * B[k][n+1] % mod;
      c += B[k][i+1];
      c %= mod;
      ll cnt = Bex[k][c];
      mi = min(mi, cnt);
      // if(cnt != mi) mi = min(mi, cnt);
      // else break;
    }
    for(int k = 0; k < gen.size(); k++) Bex[k][B[k][i+2]]--;
    ans += mi;
  }
  cout << ans << endl;
}



Measured memory_bytes: 71792
program ABC158_B
  integer(16)::A,B,N,K
  read(5,*)N,A,B
  K=N/(A+B)*A
  if(mod(N,A+B)<=A) then
     K=K+mod(N,A+B)
  else
     K=K+A
  end if
  write(6,*)K
end program ABC158_B

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

vector<lint> G[200050]; // MAX_V,隣接リスト
lint root;

lint parent[20][200050]; // logMAX_V,MAX_V
lint depth[200050];

void LCAdfs(lint v,lint p,lint d){
    parent[0][v]=p;
    depth[v]=d;
    rep(i,G[v].size()) if(G[v][i]!=p) LCAdfs(G[v][i],v,d+1);
}

void LCAinit(lint V){
    LCAdfs(root,-1,0);
    for(int k=0;k+1<20;k++){
        for(int v=0;v<V;v++){
            if(parent[k][v]<0) parent[k+1][v]=-1;
            else parent[k+1][v]=parent[k][parent[k][v]];
        }
    }
}

lint LCA(lint u,lint v){
    if(depth[u]>depth[v]) swap(u,v);
    for(int k=0;k<20;k++){
        if((depth[v]-depth[u])>>k&1) v=parent[k][v];
    }
    if(u==v) return u;
    for(int k=20-1;k>=0;k--){
        if(parent[k][u]!=parent[k][v]){
            u=parent[k][u];
            v=parent[k][v];
        }
    }
    return parent[0][u];
}

vector<int> path(int s,int t){
    int lca=LCA(s,t);
    vector<int> ps,pt;
    int now=s;
    while(true){
        if(now==lca) break;
        ps.push_back(now);
        now=parent[0][now];
    }
    now=t;
    while(true){
        pt.push_back(now);
        if(now==lca) break;
        now=parent[0][now];
    }
    reverse(pt.begin(),pt.end());
    ps.insert(ps.end(),pt.begin(),pt.end());
    return ps;
}
int fenek,snuke;
bool reach[200000];

int dfs(int now){
    if(now==snuke) return 0;
    if(reach[now]) return 0;
    reach[now]=true;
    int res=0;
    rep(i,G[now].size()) res+=dfs(G[now][i]);
    return res+1;
}


int main(void){
    int N;
    cin >> N;
    rep(i,N-1){
        int u,v;
        cin >> u >> v;
        u--,v--,
        G[u].push_back(v);
        G[v].push_back(u);
    }
    LCAinit(N);
    vector<int> p=path(0,N-1);
    fenek=p[(p.size()-1)/2],snuke=p[(p.size()+1)/2];
    int fcnt=dfs(fenek);
    int scnt=N-fcnt;
    if(fcnt>scnt) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}

Measured memory_bytes: 32948
fun main(args: Array<String>) {
    var (N,M) = readLine()!!.split(" ").map(String::toInt)
    var arr = IntArray(N,{0})
    (0..M-1).map{i->
        var (a,b) = readLine()!!.split(" ").map(String::toInt)
        arr[a-1]++
        arr[b-1]++
    }
    for(i in arr){
        println(i)
    }
}


Measured memory_bytes: 35952
main(n,x,i,j)
{
	char s[9];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&x);
		printf("Case %d:\n",i+1);
		for(j=0;j<10;j++)
		{
			x*=x;
			sprintf(s,"%08d",x);
			x=0;
			x+=(s[2]-'0')*1000+(s[3]-'0')*100+(s[4]-'0')*10+(s[5]-'0');
			printf("%d\n",x);
		}
	}
	return 0;
}

Measured memory_bytes: 616
n=gets.to_i
a=gets.split.map &:to_i
l=[x=0]+a.map{|e|x=x.gcd(e)}
r=[x=0]+a.reverse.map{|e|x=x.gcd(e)}
p (0...n).map{|i|l[i].gcd(r[n-i-1])}.max

Measured memory_bytes: 13316
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        String K = sc.next();
        if(N.equals("0")){
            if(K.equals("100")){
                System.out.println(101);
            }else{
                System.out.println(K);
            }
        }else if(N.equals("1")){
            if(K.equals("100")){
                System.out.println(10100);
            }else{
                System.out.println(K+"00");
            }
        }else{
            if(K.equals("100")){
                System.out.println(1010000);
            }else{
                System.out.println(K+"0000");
            }
        }
   }
}

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

int main(){
	int a,b,c; cin>>a>>b>>c;
	if(a==b&&b==c&&a==c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N, A, B, C, X, L[100];
  while(cin >> N >> A >> B >> C >> X , N){
    for(int i = 0 ; i < N ; i++ ) cin >> L[i];
    int cnt = 0;
    for(int i = 0 ; i < 10001 ; i++ ){
      if(L[cnt] == X) cnt++;
      if(cnt >= N){
	cout << i << endl;
	break;
      }
      X = ( A * X + B ) % C;
    }
    if(cnt < N) cout << -1 << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;
using ll = long long;

void suzuken() {
	ll n; scanf("%lld", &n); if (n == 0) exit(0);
	vector<ll> a(n); for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	sort(a.begin(), a.end());
	ll sum = 0;
	for (int i = 0; i < n; i++) sum += a[i];
	ll res = upper_bound(a.begin(), a.end(), sum / n) - a.begin();
	cout << res << "\n";

}
int main() {
	int kkt = 89;
	while (kkt) {
		suzuken();
	}
}


Measured memory_bytes: 3296
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int f(int l){
	int res = 0, cur = 1;
	while(l >= cur){
		++res;
		cur <<= 1;
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int l;
	cin >> l;
	int n = f(l);
	vector<vector<P>> g(n);
	int m = 2 * (n-1);
	rep(i,n-1){
		g[i].emplace_back(i+1, 0);
		g[i].emplace_back(i+1, (1<<i));
	}
	int cur = (1<<(n-1));
	for(int i = n-2; i >= 0; --i){
		if(cur >= l) break;
		int hoge = (1<<i);
		if(cur + hoge > l) continue;
		g[i].emplace_back(n-1, cur);
		++m;
		cur += hoge;
		if(cur >= l) break;
	}
	cout << n << " " << m << endl;
	rep(i,n){
		for(auto p : g[i]){
			cout << i+1 << " " << p.first + 1 << " " << p.second << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(void)
{
	int a,b,i,x[10];
	for(i=0;i<7;i++){
		scanf("%d%d",&a,&b);
		x[i]=a-b;
	}
	for(i=0;i<7;i++) printf("%d\n",x[i]);
	return 0;
}

Measured memory_bytes: 2732
#include <stdio.h>
int main(void){
   int m,f,r; 
   while(scanf("%d %d %d",&m,&f,&r),m+f+r!=-3){ 
   if(m==-1||f==-1) printf("F\n"); 
   else if(m+f>=80) printf("A\n"); 
   else if(m+f>=65) printf("B\n"); 
   else if(m+f>=50) printf("C\n"); 
   else if(m+f>=30){
       if(r>=50) printf("C\n"); 
       else printf("D\n"); 
   } 
   else printf("F\n");
   } 
   return 0; 
}


Measured memory_bytes: 2128
from math import gcd


MOD = 10**9 + 7

n = int(input())

cnt = {}

zero_cnt = 0
for i in range(n):
    a, b = map(int, input().split())
    if (a,b) == (0,0):
        zero_cnt += 1
        continue
    g = gcd(abs(a), abs(b))
    a //= g
    b //= g
    rotate = 0
    while not (a >= 0 and b > 0):
        a,b = -b,a
        rotate += 1
    if (a,b) not in cnt:
        cnt[(a,b)] = [0,0]

    cnt[(a,b)][rotate % 2] += 1

ans = 1
    
for key in cnt:
    A, B = cnt[key]
    ans *= 1 + pow(2, A, MOD) - 1 + pow(2, B, MOD) - 1
    ans %= MOD

ans += zero_cnt
ans -= 1
print(ans % MOD)

    

Measured memory_bytes: 133760
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int a[10005];

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

  a[0] = 1;
  rep(i,N){
    int x;
    cin >> x;
    for(int j=10004; j>=0; j--){
      if(a[j] == 1 && j+x<10005){
        a[j+x] = 1;
      }
    }
  }
  for(int j=10004; j>=0; j--){
    if(j>0 && j%10 == 0) continue;
    if(a[j] == 1){
      cout << j << endl;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef long long int ll;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
ll combination(ll n) {
	ll nck[100][100];
	nck[0][0] = 1;
	for (int i = 1; i < 1 + n; i++) {
		nck[i][0] = nck[i][i] = 1;
			for (int j = 1; j < i; j++) {
				nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
			}
	}

}
//------------------変数-----------------------//
ll n, m, a, b, k, d, c;;
typedef pair<ll, ll> P;
vector<vector<ll>> way(2001), money(2001);
ll maxa = 0, moto = 0;
ll retu[11451] = {};
queue <ll>q;
ll bitmax = 0;
//-------------------関数----------------------//

int main() {
	//cin>>a>>b>>c;
	//REP(i, n) { cin >> retu[i]; }
	string str; cin >> str;
	ll si = str.size();
	cout << str[0] << si - 2 << str[si - 1] << endl;

	return 0;
}

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

int main(){
    int A, B;
    cin>>A>>B;
    A--;
    B--;
    cout<<"100 100"<<endl;
    char mp[100][100];
    for(int y=0;y<100;y++){
        mp[y][0]='#';
        mp[y][99]='.';
    }
    for(int y=0;y<100;y++){
        for(int x=1;x<99;x++){
            mp[y][x]=(y%2?'.':'#');
        }
    }
    for(int y=1;A;y+=2){
        for(int x=2;x<=98 && A;x+=2,A--){
            mp[y][x]='#';
        }
    }
    for(int y=98;B;y-=2){
        for(int x=97;x>=1 && B;x-=2, B--){
            mp[y][x]='.';
        }
    }

    for(int y=0;y<100;y++){
        for(int x=0;x<100;x++){
            cout<<mp[y][x];
        }
        cout<<endl;
    }

    return 0;
}

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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<pair<int, bool>> pr(N);
  for (int i = 0; i < N; i++)
  {
    if (i == 0)
    {
      pr[i] = make_pair(1, true);
    }
    else
    {
      pr[i] = make_pair(1, false);
    }
  }
  for (int i = 0; i < M; i++)
  {
    int x, y;
    cin >> x >> y;
    x--, y--;
    pr[x].first--;
    pr[y].first++;
    if (pr[x].second == true)
    {
      pr[y].second = true;
    }
    if (pr[x].first == 0)
      pr[x].second = false;
  }
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (pr[i].first > 0 && pr[i].second == true)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  long long int  n;
  cin>>n;
  if(n%2==1){
    cout<<(n-1)*(n-1)/2<<endl;
    for(int i=1;i<=n-1;i++){
      for(int j=i+1;j<=n;j++){
        if(i+j!=n){cout<<i<<" "<<j<<endl;}
      }
    }
  }
  else{
    cout<<(n*(n-2)/2)<<endl;
    for(int i=1;i<=n-1;i++){
      for(int j=i+1;j<=n;j++){
        if(i+j!=n+1){cout<<i<<" "<<j<<endl;}
      }
    }
  }
  return 0;
}


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

#define ul unsigned long 
#define ull unsigned long long
#define li long long int


int main()
{
  ul n,k;
  cin >> n;
  cin >> k;

  ul ct=0;
  while (n) {
    n/=k;
    ct++;
  }

  cout << ct<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 0;
int N;
vector<string> S;

map<string, int> mp;

void solve(){
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        ans++;
    }
    cout << ans << endl;
}

int main(){
    cin >> N;

    S.resize(N);

    rep(i, N) {
        cin >> S[i];
        mp[S[i]]++;
    }

    solve();
}


Measured memory_bytes: 25112
N, M = map(int, input().split())
p = []
S = []
for i in range(M):
    pp, SS = map(str, input().split())
    p.append(pp)
    S.append(SS)

a = []
for i in range(M):
    a.append(int(p[i]))

AC = 0
P = 0

Q = []
R = []
for i in range(N):
    Q.append(0)
    R.append(0)

for i in range(M):
    index = a[i] - 1
    if Q[index] == 0 and S[i] == 'AC':
        AC = AC + 1
        Q[index] = 1
    elif Q[index] == 0 and S[i] == 'WA':
        R[a[i] - 1] = R[a[i] - 1] + 1

for i in range(N):
    if Q[i] == 0:
        P = P
    else: P = P + R[i]

print(AC, P)

Measured memory_bytes: 21272
#include <cstdio>
#include <map>
#include <set>

int main()
{
    int N, M;
    scanf("%d %d", &N, &M);

    std::set<int> countAC;
    std::map<int, int> countWA;

    for (int i = 0; i < M; ++i)
    {
        int p;
        char buff[8];
        scanf("%d %s", &p, buff);

        auto it = countAC.find(p);
        if (buff[0] == 'A')
        {
            // 正解
            if (it == countAC.cend())
            {
                // 初めて正解
                countAC.insert(p);
            }
        }
        else {
            // 不正解
            if (it == countAC.cend())
            {
                // まだ正解していない
                countWA[p]++;
            }
        }
    }

    int sum = 0;
    for (auto pair : countWA)
    {
        if (countAC.find(pair.first) == countAC.cend())
        {
            // 正解していない
            continue;
        }
        sum += pair.second;
    }

    printf("%d %d", (int)countAC.size(), sum);
}


Measured memory_bytes: 4864
#include <vector>
#include <map>
#include <algorithm>
#include <cstdio>
using namespace std;

map<int,vector<int>>H;
int f(int i){
	vector<int>a;
	for(auto &e:H[i])a.push_back(-f(e));
	sort(a.begin(),a.end());
	int r=0;
	for(int i=1;i<=a.size();i++)r=max(r,i-a[i-1]);
	return r;
}
 
int main(){
	int N,a;
	scanf("%d",&N);
	for(int i=2;i<=N;i++)scanf("%d",&a),H[a].push_back(i);
	printf("%d\n",f(1));
}

Measured memory_bytes: 22144
N = int(input())
l_a = list(map(int,input().split()))
l_b = list(map(int,input().split()))
l_c = list(map(int,input().split()))
all = sum(l_b)
for i in range (N-1):
    if l_a[i+1] - l_a[i] == 1:
        all +=l_c[l_a[i]-1]
print(all)

Measured memory_bytes: 38256
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
flag = True
for i in range(n - 1):
    if h[i + 1] >= h[i] + 1:
        h[i + 1] -= 1
    elif h[i + 1] < h[i]:
        flag = False
        break
if flag == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 15020
from collections import Counter


def cat():
    N = int(input())
    A = list(map(int, input().split()))

    # こいつらは絶対いける
    if A == [1] * N:
        return True
    if A == [N - 1] * N:
        return True

    # 数字は高々隣り合う数2種になるはず
    Aset = set(A)
    if len(Aset) == 1:
        Amax = A[0]
        cnt = N - Amax + 1
        if N <= 2 * cnt - 2:
            return True
        else:
            return False
    elif len(Aset) == 2:
        A.sort()
        Amax = A[-1]
        Amin = A[0]
        if Amin + 1 != Amax:
            return False
        lower = N - Amax + 1
        upper = 2 * lower - 2
        c = Counter(A)
        if lower <= c[Amax] <= upper:
            return True
        else:
            return False
    else:
        return False


if __name__ == "__main__":
    if cat():
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 15204
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll E = (C / gcd(C, D)) * D;
    ll x = B / C - (A + C - 1) / C + 1;
    ll y = B / D - (A + D - 1) / D + 1;
    ll z = B / E - (A + E - 1) / E + 1;
    ll res = x + y - z;
    cout << B - A + 1 - res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector<ll> x(4);
    cin >> x[0] >> x[1] >> x[2] >> x[3];
    bool a = false,b = false,c = false,d = false;
    for(int i = 0; i < 4; i++){
        if(x[i] == 1){
            a = true;
        }
        if(x[i] == 9){
            b = true;
        }
        if(x[i] == 7){
            c = true;
        }
        if(x[i] == 4){
            d = true;
        }
    }
    if(a&&b&&c&&d){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define max(a,b) ((a)<(b)?(a):(b))

int main(){
		long long q,h,s,d,n;
		scanf("%lld%lld%lld%lld%lld",&q,&h,&s,&d,&n);
		q=q*4;
		h=h*2;
		if(max(q,max(h,max(s,d/2+d%2)))==q)printf("%lld",n*q);
		else if(max(q,max(h,max(s,d/2+d%2)))==h)printf("%lld",n*h);
		else if(max(q,max(h,max(s,d/2+d%2)))==s)printf("%lld",n*s);
		else if(n>=2)printf("%lld",n/2*d+(n%2)*max(q,max(h,s)));
		else printf("%lld\n",n*max(q,max(h,s)));
		return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

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

  rep(i,s.size()) if(i%w==0)cout<<s[i];

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int N,M,L,R,ml=1,mr=100000;
  scanf("%d %d",&N,&M);
  for(int i=0;i<M;i++){
    scanf("%d %d",&L,&R);
    if(L>ml){
      ml=L;
    }
    if(R<mr){
      mr=R;
    }
  }
  if(mr-ml<0){
    printf("0\n");
  }else{
  	printf("%d\n",mr-ml+1);
  }
  return 0;
}

Measured memory_bytes: 128
function main(input) {
  var x = parseInt(input, 10);
  var saving = 100;

  var isLower = true;
  var forYear = 0;
  while (isLower) {
    forYear += 1;
    saving = Math.floor(saving * 1.01);
    if (saving >= x) isLower = false;
  }
  console.log(forYear);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29716
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    int a, b, k;
    cin >> a >> b >> k;
    if (a+k-1 < b-k+1){
        for (int i = a; i < a+k; i++) cout << i << endl;
        for (int i = b-k+1; i < b+1; i++) cout << i << endl;
    } else {
        for (int i = a; i < b+1; i++) cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
a=[]
for I in range(M):
    P,Y=map(int,input().split())
    a.append([P,Y,I])

b=sorted(a, key=lambda x: (x[0], x[1]))

prep=0
c=0
dict={}
for city in b:
  p,y,i=city
  if p==prep:
    c+=1
  else:
    c=1
  prep=p
  dict[i]='{0:06d}{1:06d}'.format(p,c)
  
for k,v in dict.items():
  print(v)

Measured memory_bytes: 39308
import java.util.*;
public class Main {
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);      
      int sx = sc.nextInt(),sy = sc.nextInt();
      int tx = sc.nextInt(),ty = sc.nextInt();
      int x = tx-sx;
      int y = ty-sy;
      StringBuilder moveList=new StringBuilder();
      for(int i=0;i<y;i++){
       moveList.append("U");
      }
      for(int i=0;i<x;i++){
        moveList.append("R");
      }
      for(int i=0;i<y;i++){
       moveList.append("D");
      }
      for(int i=0;i<x;i++){
        moveList.append("L");
      }
      moveList.append("L");
      for(int i=0;i<y+1;i++){
        moveList.append("U");
      }
      for(int i=0;i<x+1;i++){
       moveList.append("R");
      }
      moveList.append("D");
      moveList.append("R");
      for(int i=0;i<y+1;i++){
        moveList.append("D");
      }
      for(int i=0;i<x+1;i++){
       moveList.append("L");
      }
      moveList.append("U");      
      System.out.println(moveList);
    }
}


Measured memory_bytes: 20556
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

long long int d[100000];
long long int k[10000];

typedef struct
{
	long long int w;
	char flg;
}WWW;

WWW w[200000];

long long int a[100];

int main()
{
	int n = 0;
	while(1)
	{
		long long int dw;
		scanf("%lld",&dw);
		if(dw == 0)
		{
			break;
		}
		int nn,m;
		scanf("%d",&nn);
		scanf("%d",&m);
		d[0] = 0;
		for(int i = 1; i < nn; i++)
		{
			scanf("%lld",&(d[i]));
		}
		for(int i = 0; i < m; i++)
		{
			scanf("%lld",&(k[i]));
		}
		sort(d,d + nn);
		sort(k,k + m);
		int nw = 0;
		int nww = 0;
		for(int i = 0; i < nn; i++)
		{
aa:
			if(nww < m)
			{
				if(d[i] > k[nww])
				{
					w[nw].w = k[nww];
					w[nw].flg = 1;
					nw++;
					nww++;
					goto aa;
				}
			}
			w[nw].w = d[i];
			w[nw].flg = 0;
			nw++;
		}
		for(int i = nww; i < m; i++)
		{
			w[nw].w = k[i];
			w[nw].flg = 1;
			nw++;
			nww++;
		}
		long long int all = 0;
		for(int i = 0; i < nw; i++)
		{
			if(w[i].flg == 1)
			{
				long long int sho,sho2;
				for(int ii = 0; ii < nw; ii++)
				{
					if(w[(i + ii) % nw].flg == 0)
					{
						sho = (dw + w[(i + ii) % nw].w - w[i].w) % dw;
						break;
					}
				}
				for(int ii = 0; ii < nw; ii++)
				{
					if(w[(nw + i - ii) % nw].flg == 0)
					{
						sho2 = (dw + w[i].w - w[(nw + i - ii) % nw].w) % dw;
						if(sho2 < sho)
						{
							sho = sho2;
						}
						break;
					}
				}
				all = all + sho;
			}
		}
		a[n] = all;
		n++;
	}
	for(int i = 0; i < n; i++)
	{
		printf("%lld\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        // 入力
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

        double rs = 0.0;

        for (int i=0;i<n;i++) {
            double d = sc.nextDouble();
            String s = sc.next();

            if (s.equals("JPY")) {
                rs += d;
            } else {
                rs += d * 380000.0;
            }
        }

        // 出力
        System.out.println(rs);
    }
}

Measured memory_bytes: 23124
import sys
n,k=map(int,input().split())
pp = list(map(int,input().split()))
s=[0]*n
for i,p in enumerate(pp):
  if i==0:
    s[0] = (1+p)/2
  else:
    s[i] = s[i-1]+(1+p)/2
res =0
if n==k:
  print(s[n-1])
  sys.exit()
for i in range(n-k):
  if res < s[i+k] - s[i]:
    res = s[i+k]-s[i]
print(res)

Measured memory_bytes: 71792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=2010;
char ch;
int n,m,q,x1,y_1,x2,y2,ans;
int a[N][N],sum[N][N];
int l[N][N],r[N][N];
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for (int i=1; i<=n; i++){
		for (int j=1; j<=m; j++){
			cin>>ch;
			a[i][j]=ch-'0';
			sum[i][j]=a[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
			if (a[i][j]){
				if (a[i-1][j]) l[i][j]++;
				if (a[i][j-1]) r[i][j]++;
			}
			l[i][j]+=l[i-1][j]+l[i][j-1]-l[i-1][j-1];
			r[i][j]+=r[i-1][j]+r[i][j-1]-r[i-1][j-1];
		}
	}
    while (q--){
		scanf("%d%d%d%d",&x1,&y_1,&x2,&y2);
		ans=sum[x2][y2]-sum[x2][y_1-1]-sum[x1-1][y2]+sum[x1-1][y_1-1];
		ans-=l[x2][y2]+l[x1][y_1-1]-l[x2][y_1-1]-l[x1][y2];
		ans-=r[x2][y2]+r[x1-1][y_1]-r[x2][y_1]-r[x1-1][y2];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 66028
let () =
  Scanf.scanf "%s" @@ fun s ->
  let s = Array.init (String.length s) (fun i -> s.[i]) in
  Array.fold_left (fun (stk, a) c ->
    match stk, c with
    | '0'::stk, '1' | '1'::stk, '0' -> stk, a+2
    | _ -> c::stk, a) ([], 0) s
  |> snd |> Printf.printf "%d\n"

Measured memory_bytes: 6144
import java.util.*;class Main{public static void main(String[]z){int n,i,j,p;for(Scanner s=new Scanner(System.in);(n=s.nextInt())>0;){int[][]a=new int[n][n];i=j=n/2;++i;for(p=0;p++<n*n;){a[i%n][j%n]=p;if(a[++i%n][++j%n]>0){++i;--j;}}for(int[]b:a){for(int c:b)System.out.printf("%4d",c);System.out.println();}}}}

Measured memory_bytes: 12000
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string[] input = Console.ReadLine().Split();
      string s = input[0]+input[1];
      int n = int.Parse(s);
      double n_2 = Math.Pow(n, 0.5);

      if (n_2 == (int)n_2){
      	Console.WriteLine("Yes");
      }
      else{
      	Console.WriteLine("No");
      }
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int A = 0, B = 0;
  for (int i = 0; i < n; i = i + 2) {
    A += vec.at(i);
  }
  for (int i = 1; i < n; i = i + 2) {
    B += vec.at(i);
  }
  cout << A - B << endl;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    cin >> n;
    int a[n + 1], mi = INF, ans = 0;
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 1, n)
    {
        mi = min(mi, a[i]);
        if(a[i] == mi) ans++;
    }
    cout << ans;
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;


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

  int n;
  cin >> n;
  string s;
  cin >> s;
  int ret = 0;
  vector< vector<int> > check(n,vector<int>(n));
  for(int i = 0;i < n;i++){
    for(int j = i+1;j < n;j++){
      if(s[i] == s[j] && check[i][j] == 0){
        check[i][j]++;
        int cnt = 1;
        while(i+cnt < j && j+cnt < n){
          if(s[i+cnt] == s[j+cnt]){
            check[i+cnt][j+cnt]++;
            cnt++;
          }else{
            break;
          }
        }
        ret = max(ret,cnt);
      }
    }
  }
  cout << ret << endl;
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N, P;
	string S;
	cin >> N >> P >> S;

	map<int, int> m;
	ll mod = 0;
	ll c = 1;
	ll ans = 0;
	for (ll i = N - 1; i >= 0; i--) {
		if (P == 2 || P == 5) {
			if ((S[i]-'0') % P == 0) {
				ans += i + 1;
			}
		}
		else {
			mod = (mod + c * (S[i]-'0')) % P;
			c = (c * 10) % P;
			ans += m[mod];
			m[mod]++;
			if (mod == 0) ans++;
		}
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 900
a=input().strip().split(" ")

b=[int(i) for i in a]

for i in range(2):
    if(b[i]==1):
        b[i]=int(13)
    else:
        b[i]=b[i]-1

if(b[0]>b[1]):
    print("Alice")
elif(b[0]==b[1]):
    print("Draw")
else:
    print("Bob")



Measured memory_bytes: 3060
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve(){
	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c ;
}

int main(){
	#ifndef RAY
		//freopen("input.txt", "r", stdin);
	#endif
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1;
		//cin >> t;
		while(t--){
			solve();
		}
	return 0;
}	
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K = 0;
ll t;
ll ret = 0;
ll A, B;
string s;

void input() {
  IN(A);
  IN(B);
}

void solve() {
  if (A > B) {
    swap(A, B);
  }
  ret = A;
  REP(i, B-1) {
    ret *= 10;
    ret += A;
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256