akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    int large1=0, large2=0, num1, num2;
    for(int i=0;i<n;i++){
        int j;
        cin >> j;
        if(large1 < j){
            large2 = large1;
            large1 = j;
            num2 = num1;
            num1 = i;
        }else if(large2 < j){
            large2 = j;
            num2 = i;
        }
    }
    
    for(int i=0;i<n;i++){
        if(i==num1){
            cout << large2 << endl;
        }else{
            cout << large1 << endl;
        }
    }
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    string s,t;
    cin >> s >> t;
    unordered_map<string,int> s_cnt;
    unordered_map<string,int> t_cnt;

    int n = s.size();
    rep(i,n)
    {
        string si = s.substr(i,1);
        if(s_cnt.count(si) > 0)
            s_cnt[si]++;
        else
            s_cnt[si] = 1;

        string ti = t.substr(i,1);
        if(t_cnt.count(ti) > 0)
            t_cnt[ti]++;
        else
            t_cnt[ti] = 1;

        if(t_cnt[ti] != s_cnt[si])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 776
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
N, K = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(lambda x:int(x)-1, input().split())
  graph[a] += [b]
  graph[b] += [a]

global ans
ans = K

def npr(n, r, p):
  e = 1
  for i in range(n, n-r, -1):
    e *= i
    e %= p

  return e
p=10**9+7

def dfs(u, pre):
  global ans
  child = 0
  for v in graph[u]:
    if v != pre:
      dfs(v, u)
      child += 1
  
  if u == 0:
    ans *= npr(K-1, child, p)
  else:
    ans *= npr(K-2, child, p)

  ans %= p

dfs(0, -1)
print(ans%p)


Measured memory_bytes: 87344
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
using ll = long long;
using ull = unsigned long long;
const int maxn = 100010;
int N, K;
int A[maxn];

template <unsigned Mod> struct Modular {
  using M = Modular;
  unsigned v;
  Modular(long long a = 0) : v((a %= Mod) < 0 ? a + Mod : a) {}
  M operator-() const { return M() -= *this; }
  M& operator+=(M r) { if ((v += r.v) >= Mod) v -= Mod; return *this; }
  M& operator-=(M r) { if ((v += Mod - r.v) >= Mod) v -= Mod; return *this; }
  M& operator*=(M r) { v = (uint64_t)v * r.v % Mod; return *this; }
  M& operator/=(M r) { return *this *= mdpow(r, Mod - 2); }
  friend M operator+(M l, M r) { return l += r; }
  friend M operator-(M l, M r) { return l -= r; }
  friend M operator*(M l, M r) { return l *= r; }
  friend M operator/(M l, M r) { return l /= r; }
  friend bool operator==(M l, M r) { return l.v == r.v; }
  friend M mdpow(M b, unsigned exp) {
    Modular res(1);
    while(exp) {
      if (exp & 1) {
        res *= b;
        if ((res.v += Mod) >= Mod) res.v -= Mod;
      }
      b *= b;
      exp >>= 1;
    }
    return res;
  }
};

constexpr long long mod = 1e9 + 7;
using Mint = Modular<mod>;

vector<Mint> fact, inv_fact, minv;
void prep(int n) {
  fact.resize(n + 1), inv_fact.resize(n + 1), minv.resize(n + 1);
  for (int i = 0; i <= n; ++i) fact[i] = i ? i * fact[i - 1] : 1;
  inv_fact[n] = 1 / fact[n];
  // cout << inv_fact[n].v << endl;
  for (int i = n; i; --i) inv_fact[i - 1] = i * inv_fact[i];
  for (int i = 1; i <= n; ++i) minv[i] = inv_fact[i] * fact[i - 1];
}

Mint binom(int n, int k) {
  if (k < 0 || k > n) return 0;
  return fact[n] * inv_fact[k] * inv_fact[n - k];
}

int main() {
  fastio;
  cin >> N >> K;
  prep(N);
  // rep(i, N) cout << inv_fact[i].v << endl;
  for (int i = 0; i < N; i++) { cin >> A[i]; }
  sort(A, A + N);
  Mint res(0);
  Mint choose;
  for (int i = 0; i < N; i++) {
    Mint val(A[i]);
    choose = binom(N - i - 1, K-1);
    res -= (val * choose);
  }

  for (int i = 0; i < N; i++) {
    choose = binom(i, K-1);
    Mint val(A[i]);
    res += (val * choose);
  }
  cout << res.v << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>

#define DEG2EAD 0.01745329251994329576923690768489

std::vector< std::pair<double,double> > Koch_Curve(std::pair <double,double>,std::pair <double,double>,int);
std::vector< std::pair<double,double> > Koch_Curve(std::pair <double,double>,std::pair <double,double>,int,int);

int main(int argc, char const *argv[]){
	int n;
	std::cin >> n;
	std::vector< std::pair<double,double> > ans;
	std::pair<double,double> p0,p1;
	p0 = std::make_pair(0.0,0.0);
	p1 = std::make_pair(100.0,0.0);
	ans = Koch_Curve(p0,p1,n);

	for(int i=0; i<ans.size(); i++){
		std::cout << std::fixed;
		std::cout << std::setprecision(8) << ans[i].first << " " << ans[i].second << std::endl;
	}

	return 0;
}


std::vector< std::pair<double,double> > Koch_Curve(std::pair <double,double> Ps, std::pair <double,double> Pe, int N){
	std::vector< std::pair<double,double> > ans;
	ans.push_back(Ps);
	std::vector< std::pair<double,double> > buff = Koch_Curve(Ps,Pe,N,0);
	ans.insert(ans.end(),buff.begin(),buff.end());
	ans.push_back(Pe);
	return ans;
}

std::vector< std::pair<double,double> > Koch_Curve(std::pair <double,double> Ps, std::pair <double,double> Pe, int N, int n){
	double dx = Pe.first - Ps.first;
	double dy = Pe.second - Ps.second;
	std::pair<double,double> mid_0,mid_1,top;
	std::vector< std::pair<double,double> > buff,ans;

	mid_0 = std::make_pair(Ps.first+dx*1.0/3.0,Ps.second+dy*1.0/3.0);
	mid_1 = std::make_pair(Ps.first+dx*2.0/3.0,Ps.second+dy*2.0/3.0);
	
	if(n<N){
		ans = Koch_Curve(Ps,mid_0,N,n+1);
		ans.push_back(mid_0);
		
		double angle = 60.0*DEG2EAD;
		top.first  = mid_0.first  + dx / 3.0 * cos(angle) - dy / 3.0*sin(angle);
		top.second = mid_0.second + dx / 3.0 * sin(angle) + dy / 3.0*cos(angle);

		buff = Koch_Curve(mid_0,top,N,n+1);
		ans.insert(ans.end(),buff.begin(),buff.end());
		
		ans.push_back(top);

		buff = Koch_Curve(top,mid_1,N,n+1);
		ans.insert(ans.end(),buff.begin(),buff.end());

		ans.push_back(mid_1);

		buff = Koch_Curve(mid_1,Pe,N,n+1);
		ans.insert(ans.end(),buff.begin(),buff.end());	
	}
	return ans;
}



Measured memory_bytes: 3400
#include<bits/stdc++.h>
using namespace std;
int n,m,q;
int dp[510][510];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m>>q;
	for(int i=1;i<=m;i++){
		int l,r;
		cin>>l>>r;
		dp[l][r]++;
	}
	for(int l=1;l<=n;l++){
		for(int i=0;i+l<=n;i++){
			int j=i+l;
			dp[i][j]+=(dp[i+1][j]+dp[i][j-1]-dp[i+1][j-1]);
		} 
	}
	for(int i=1;i<=q;i++){
		int l,r;
		cin>>l>>r;
		cout<<dp[l][r]<<endl;
	}
	return 0;
}


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

ll prime(ll n) {
  int res = 0;
  bool heihou = false;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0 && i < n / i) {
      res += 2;
    }
    else if (n % i == 0 && i <= n / i) {
      heihou = true;
    }
  }
  if (heihou) return res;
  else return res - 1;
}

bool search(ll n,ll k){
  while(n % k == 0){
    n = n / k;
  }
  if (n % k == 1) return true;
  else return false;
}

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  ans += prime(N - 1);
  for (ll i = 1; i <= sqrt((double)N); i++) {
    if (N % i == 0) {
      if (i != 1) {
        if (search(N,i)) ans++;
      }
      if (search(N,N/i) && i != N / i) ans++; 
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
int a,b;
	scanf("%d %d",&a,&b);
	
	if((a%3==0 && a>=3) || (b%3==0 && b>=3)){
		printf("Possible\n");
	}else if((a+b)%3==0 && ((a+b)>=3)){
		printf("Possible\n");
	}else{
		printf("Impossible\n");
	}
		
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int N;
ll A[1 << 18];
P dp[19][1 << 18];

int main() {
	cin >> N;
	for (int i = 0; i < (1 << N); i++) {
		cin >> A[i];
	}
	for (int i = 0; i < (1 << N); i++)dp[0][i].first = A[i], dp[0][i].second = -1;
	
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < (1 << N); j++) {
			dp[i][j] = dp[i - 1][j];
			if (j & (1 << (i - 1))) {
				int ar[4];
				ar[0] = dp[i][j].first, ar[1] = dp[i][j].second;
				ar[2] = dp[i - 1][j - (1 << (i - 1))].first, ar[3] = dp[i - 1][j - (1 << (i - 1))].second;
				sort(ar, ar + 4);
				dp[i][j] = make_pair(ar[3], ar[2]);
			}
		}
	}
	ll ans = 0;
	for (int i = 1; i < (1 << N); i++) {
		ans = max(ans, dp[N][i].first + dp[N][i].second);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 82944
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;


int main() {

    int N;
    cin >> N;
    map<long, int> m;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        m[A] += 1;
    }

    int result = 0;

    for (auto kv :m) {
        if (kv.second % 2 == 1) {
            result += 1;
        }
    }

    cout << result << "\n";

    return 0;

}

Measured memory_bytes: 6528
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string s;
    while (cin >> s)
    {
        int a = 0, b = 0;
        for (int i = 0; i < 3; i++)
        {
            if (s[i] == 'A')a++;
            else b++;
        }
        if (a == 3 || b == 3)cout << "No\n";
        else cout << "Yes\n";

    }
}



Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000

int parent(int i){
	return i/2;
}

int left(int i){
	return 2*i;
}

int right(int i){
	return 2*i+1;
}

int main(){
	int h,i,A[MAX+1];

	scanf("%d",&h);
	for(i = 1;i <= h;i++){
	scanf("%d",&A[i]);
	}
	
	for(i = 1;i <= h;i++){
	printf("node %d: key = %d, ",i,A[i]);
	if(parent(i) >= 1)printf("parent key = %d, ",A[parent(i)]);
	if(left(i) <= h)printf("left key = %d, ",A[left(i)]);
	if(right(i) <= h)printf("right key = %d, ",A[right(i)]);
	printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2084
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>

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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

vector <int> b, ans;

int n;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		b.PB( x );
	}
	while (true) {
		int idx = -1;
		for (int i = 0; i < sz(b); i++)
			if (b[i] == i + 1)
				idx = i;
		if (idx == -1)
			break;
		ans.PB( idx + 1 );
		b.erase(b.begin() + idx);
	}
	if (sz(ans) != n)
		return cout << "-1\n", 0;
	reverse(all(ans));
	for (auto x : ans)
		cout << x << "\n";
}


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

int main() {
	int H, W, M;
	cin >> H >> W >> M;
	vector<int> cH(H+1, 0);
	vector<int> cW(W+1, 0);
	set<pair<int, int> > Q;

	for (int i = 0; i < M; i++) {
		int h, w;
		cin >> h >> w;
		cH[h]++;
		cW[w]++;
		Q.insert(pair<int, int>(h, w));
	}


	int mHc = 0;
	for (int i = 1; i <= H; i++) {
		mHc = (mHc < cH[i] ? cH[i] : mHc);
	}
	int mWc = 0;
	for (int i = 1; i <= W; i++) {
		mWc = (mWc < cW[i] ? cW[i] : mWc);
	}
	set<int> sH;
	for (int i = 1; i <= H; i++) {
		if (mHc == cH[i]) sH.insert(i);
	}
	set<int> sW;
	for (int i = 1; i <= W; i++) {
		if(mWc == cW[i]) sW.insert(i);
	}

	int dbl = 1;
	for (auto it = sH.begin(); it != sH.end(); it++) {
		for (auto jt = sW.begin(); jt != sW.end(); jt++) {
			if (Q.find(pair<int, int>(*it, *jt)) == Q.end()) {
				dbl = 0;
				break;
			}
		}
	}
	cout << mHc + mWc - dbl << endl;
	return(0);
}


Measured memory_bytes: 47676
#include <iostream>
#include <vector>
#include <queue>
using namespace std;


int main() {

    int h, w, n;

    cin >> h >> w;
    cin >> n;

    vector<int> colors(n);

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

    queue<int> colorQ;

    for(int i = 0; i < n; ++i) 
        for(int j = 0; j < colors[i]; ++j)
            colorQ.push(i + 1);
    

    int directionW = 1;
    int w_i = 0;
    int h_i = 0;
    vector<vector<int>> tileMap(h, vector<int>(w));
    int maxCount = h * w;


    while(!colorQ.empty()) {
        
        tileMap[h_i][w_i] = colorQ.front(); colorQ.pop();

        w_i += directionW;

        if(w_i == w) {
            h_i++;
            w_i = w - 1;
            directionW = -1;
        }
        else if(w_i == -1) {
            h_i++;
            w_i = 0;
            directionW = 1;
        }

    }

    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(j)
                cout << " ";
            cout << tileMap[i][j];
        }
        cout << endl;
    }

    return 0;

}

Measured memory_bytes: 3696
import sys
import collections
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

DQ=collections.deque([(1,0)])
VS=set([1])
MP={}
N,M=LI()
RES=[0]*(N+1)

for i in range(M):
    ff,tt=LI()
    if not ff in MP: MP[ff] = []
    if not tt in MP: MP[tt] = []
    MP[ff].append(tt)
    MP[tt].append(ff)

# print("----")
while DQ:
    i, dist = DQ.popleft()
    # print(i,dist)
    if i in MP:
        for j in MP[i]:
            if not j in VS:
                VS.add(j)
                DQ.append((j, dist+1))
                RES[j] = i

# print(VS, MP)
if len(VS) < N:
    print("No")
else:
    print("Yes")
    for i in range(2, N+1):
        print(RES[i])


Measured memory_bytes: 48348
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

int n, q;
int a[114514];
int sum[114514], sum2[114514];
signed main() {
	cin >> n >> q;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	rep(i, n) {
		sum[i] += a[i]; sum2[i] += a[i];
		sum[i + 1] += sum[i]; sum2[i + 2] += sum2[i];
	}
	while (q--) {
		int x; cin >> x;
		//中心からの距離
		int ok = -1, ng = mod;
		int l_, r_;
		while (ng - ok > 1) {
			int mid = (ok + ng) / 2;
			int l = lower_bound(a, a + n, x - mid) - a;
			int r = upper_bound(a, a + n, x + mid) - a;
			if (n - (r - l) >= r) {
				ok = mid; l_ = l, r_ = r;
			}
			else {
				if (n - (r - l - 1) >= r - 1 && x - a[l] == a[r - 1] - x) {
					ok = mid; l_ = l, r_ = r - 1;
				}
				ng = mid;
			}
		}
		if (ok == -1) {
			cout << sum2[n - 1] << endl;
		}
		else if (n - (r_ - l_) > r_) {
			cout << sum[n] - sum[r_ - 1] + (l_ > 1 ? sum2[l_ - 2] : 0) << endl;
		}
		else {
			cout << sum[n] - sum[r_ - 1] + (l_ ? sum2[l_ - 1] : 0) << endl;
		}
	}
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main() {
    int n,w;
    cin>>n>>w;
    long long knap[n+10][w+10];
    long long weight[n+1],value[1+n];
    rep(i,n){
        cin>>weight[i+1]>>value[i+1];
    }
    rep(i,n+1){
        knap[i][0]=0;
    }
    rep(i,w+1){
        knap[0][i]=0;
    }
    for (int i=1;i<n+1;i++){
        for (int j=1;j<w+1;j++){
            if (j<weight[i]){
                knap[i][j]=knap[i-1][j];
            }
            else{
                knap[i][j]=max(knap[i-1][j],knap[i-1][j-weight[i]]+value[i]);
            }
        }
    }
    cout<<knap[n][w]<<endl;

    return 0;
} 

Measured memory_bytes: 80640
//بسم الله الرحمن الرحيم
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define el << endl
#define PI 3.141592653589793238
#define _test_ int t; cin >> t; while(t--)
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
ll gcd ( ll  a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }
int dx[]={0,0,+1,-1,+1,-1,-1,+1};
int dy[]={+1,-1,0,0,+1,-1,+1,-1};
///*......................*//* LET'S BEGIN (-_^) *//*............................///
const int mx= 3e5+123;
ll x,k,d;

void _case_()
{
   cin >> x >> k >> d;
   x=abs(x);
   ll r=min(k,x/d);
   k-=r;
   x-=r*d;
   if(k%2==0)
       cout << x el;
   else cout << abs(x-d) el;
}

int main()
{

    optimize();
    //_test_
      _case_();
    return 0;

}

///////////*  N A Y E M  *///////////

Measured memory_bytes: 3620
days = int(input())
total = [[int(happy) for happy in input().split()]]
for i in range(1, days):
    nums = [int(happy) for happy in input().split()]
    today = [max([total[i-1][1]+nums[0], total[i-1][2]+nums[0]]), max([total[i-1][0]+nums[1], total[i-1][2]+nums[1]]), max([total[i-1][0]+nums[2], total[i-1][1]+nums[2]])]
    total.append(today)
print(max(total[days-1]))

Measured memory_bytes: 22776
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    #r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #a = list(map(int, r.split()))
    a, b = map(int, input().split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]

    cnt = 0
    if a < b:
        print(str(a)*b)
    else:
        print(str(b)*a)

    #'Yes', 'No', 'YES', 'NO', ':(', 'Yay!'
    #res = 0
    #a, b = map(int, r.split())
    #print()

if __name__ == '__main__':
    main()



Measured memory_bytes: 38256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [N, M, X, Y] = input[0].map(Number);
  const x = input[1].map(Number);
  const y = input[2].map(Number);

  const maxX = Math.max(...x);
  const minY = Math.min(...y);

  if (maxX >= Y || minY <= X || maxX >= minY) {
    return "War";
  } else {
    return "No War";
  }
};

console.log(main(read()));


Measured memory_bytes: 29692
A = list(input())
n = int(input())

for _ in range(n):
	command = input().split(" ")
	st = int(command[1])
	en = int(command[2]) + 1

	if command[0] == "replace":
		A[st:en] = list(command[3])
	elif command[0] == "reverse":
		B = A[st:en]
		B.reverse()
		A[st:en] = B
	else:
		moji = ""
		for i in A[st:en]:
			moji += str(i)
		print(moji)



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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
const int dx[] = {0,0,1,1,1,-1,-1,-1};
const int dy[] = {1,-1,0,1,-1,0,1,-1};

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

void dfs(int ci, int cj, VVI& board, VVI& visited, int h,int w){
  visited[ci][cj] = 1;
  rep(dir,8){
    if((ci + dy[dir]) < h && (cj + dx[dir]) < w &&
       (ci + dy[dir]) >= 0 && (cj + dx[dir]) >= 0  &&
       visited[(ci + dy[dir])][(cj + dx[dir])] == 0 &&
       board[(ci + dy[dir])][(cj + dx[dir])] == 1){
      dfs((ci + dy[dir]),(cj + dx[dir]),board,visited,h,w);
    }
  }
}

bool solve(string s){
  deque<int> que;
  int n = s.size();
  rep(i,n-1){
    if(s[i] == '('){
      que.push_back(0);
    }
    else if(s[i] == ')'){
      if(que.empty()) return false;
      int x = que.back();
      que.pop_back();
      if(x == 1) return false;
    }
    else if(s[i] == '['){
      que.push_back(1);
    }
    else if(s[i] == ']'){
      if(que.empty()) return false;
      int x = que.back();
      que.pop_back();
      if(x == 0) return false;
    }
  }
  if(que.empty()) return true;
  else return false;

}
int main(){
  string s;
  while(true){
    getline(cin,s);
    if(s.size() == 1 && s[0] == '.') break;
    bool ans = solve(s);
    cout << (ans?"yes":"no") << endl;
  }
  return 0;
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
/*#include <boost/multiprecision/cpp_int.hpp> 
using boost::multiprecision::cpp_int;*/
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int              long long int
#define pb              push_back
#define mp12            make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq1             priority_queue<int>
#define pqr1            priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000000
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
// mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void fast()
{
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

}
void file(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int modInv(int a,int b,int m)
{
    int res=1;
    a=a%m;
    while(b>0){
        if(b&1){
            res=(res*a)%m;
        }
        a=(a*a)%m;
        b=b>>1;
    }
    return res;
}


int p[1000006];
vi prime;
//int mrp[1000000];
void seive(){
    for(int i=2;i<1000006;i++) {
        if(p[i]){
            prime.pb(i);
            for(int j=i*i;j<=1000006;j=j+i){
                p[j]=0;
            }
        }
    }

}
int dp[101][100005]={};
int solve(int i,int w,int wei[],int v[]){
    // if(w<0) return INT_MIN;
    if(w==0 or i==-1) return 0;

    if(dp[i][w]!=-1) return dp[i][w];
    
    if(w<wei[i]){
        
        return dp[i][w]=solve(i-1,w,wei,v);
    }        
    else{
        int op1=v[i]+solve(i-1,w-wei[i],wei,v);
         int op2=solve(i-1,w,wei,v);
         return dp[i][w]=max(op1,op2);
    }
}



int32_t main()
{
    // memset(prime,0,sizeof(prime));
    //memset(p,1,sizeof(p));   
    //seive();
    //file();
    fast();
    //int mo=1000000007;
    int n,w;
    cin>>n>>w;
    int wei[n],v[n];
    for(int i=0;i<n;i++){
        cin>>wei[i]>>v[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(n-1,w,wei,v);




    return 0;
    
    
}



Measured memory_bytes: 82524
s = input()

atgc = "ATGCF"
ans = 0
flag = 0
tmp = 0
for c in s:
    for key in atgc:
        if c == key:
            tmp += 1
            flag = 1
            break
        if key == "F":
            flag = 0
    if tmp > ans:
        ans = tmp
    if flag == 0:
        tmp = 0
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vvll vector<ll>
#define vll(a) vector<ll> a(MAXN)
#define pb push_back
#define fo(a) for(auto&a1:(a))
#define fd(a,b) for(int i=(a);i>=(b);i--)
#define fk(a,b) for(int k=(a);k<(b);k++)
#define fj(a,b) for(int j=(a);j<(b);j++)
#define f(a,b) for(ll i=(a);i<(b);i++)
#define forni(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define fdk(a,b) for(int k=(a);k>=(b);k--)
#define fdj(a,b) for(int j=(a);j>=(b);j--)
#define ri(n) scanf("%d",&(n));
#define rll(n) scanf("%lld",&(n));
#define T(t) int t;scanf("%d",&(t));while((t)--)
#define MAXN 100005
#define MAXN2 10000005
#define pll pair<ll,ll>
#define PI 3.14159265
#define mset(a) memset((a),0,sizeof((a)))
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const ll mod=1000000007;
int main()
{
    string s,t;
    cin>>s>>t;
    ll dp[s.length()+1][t.length()+1];
    mset(dp);
    f(0,s.length()+1)
    {
        fj(0,t.length()+1)
        {
            if(i==0 || j==0)
            dp[i][j]=0;
            else{
            int num=0;
            if((s[i-1]==t[j-1]))
            num++;
            dp[i][j]=max({num + dp[i-1][j-1],dp[i-1][j],dp[i][j-1]});
            }//cout<<dp[i][j]<<" ";
        }
        //cout<<"\n";
    }
    //cout<<dp[s.length()][t.length()]<<"\n";
    int i1=s.length(),j1=t.length();
    vector<char> ans;
    while(i1>0 && j1>0)
    {
        //cout<<i1<<" "<<j1<<" "<<dp[i1][j1]<<"\n";
        if(s[i1-1]==t[j1-1] && dp[i1][j1]-dp[i1-1][j1-1]==1)
        {
            ans.pb(s[i1-1]);
            i1--;
            j1--;
        }
        else if(dp[i1][j1]==dp[i1-1][j1])
        i1--;
        else if(dp[i1][j1]==dp[i1][j1-1])
        j1--;
        else
        i1--,j1--;
    }
    reverse(ans.begin(),ans.end());
    fo(ans)
    cout<<a1;
    return 0;
}


Measured memory_bytes: 74016
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
typedef long long ll;
const int maxn = 2e5 + 5;

std::priority_queue<ll> max_qq;
std::priority_queue<ll, std::vector<ll>, std::greater<ll>> min_qq;

int main (int argc, char **argv) {
  int q;
  std::cin >> q;
  
  int opt;
  ll a, b;
  ll sum_b = 0, sum_max = 0, sum_min = 0;
  for (int i=1; i <= q; i++) {
    std::cin >> opt;
    if (opt == 1) {
      std::cin >> a >> b;
      sum_b += b;
      
      if (max_qq.size() > min_qq.size()) {
        if (a >= max_qq.top()) {
          min_qq.push(a);
          sum_min += a;
        } else {
          ll tmp = max_qq.top();
          max_qq.pop();
          sum_max -= tmp;

          min_qq.push(tmp);
          sum_min += tmp;
          
          max_qq.push(a);
          sum_max += a;
        }

      } else if (max_qq.size() < min_qq.size()) {
        if (a <= min_qq.top()) {
          max_qq.push(a);
          sum_max += a;
        } else {
          int tmp = min_qq.top();
          min_qq.pop();
          sum_min -= tmp;

          max_qq.push(tmp);
          sum_max += tmp;

          min_qq.push(a);
          sum_min += a;
        }

      } else {
        if (!max_qq.empty() &&a >= max_qq.top()) {
          min_qq.push(a);
          sum_min += a;
        } else {
          max_qq.push(a);
          sum_max += a;
        }
      }
    
    } else if (opt == 2) {
      ll ans, val;
      if (max_qq.size() >= min_qq.size()) {
        ans = max_qq.top();
      } else if (max_qq.size() < min_qq.size()) {
        ans = min_qq.top();
      }
      val = sum_min - min_qq.size()*ans + max_qq.size()*ans - sum_max;
      val += sum_b;
      std::cout << ans << " " << val << std::endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4700
/*ex5_3
  kt125 */

#include<stdio.h>

int main(void){
    int height, width, //縦、横
         count; //'.'をカウントする変数
    scanf("%d %d", &height, &width);

    char board[height][width]; //与えられたマス目の配列
    for(int i=0; i < height;i++){
        for (int j=0; j < width; j++){
            scanf(" %c", &board[i][j]);
        }  
    }
  	int col_del[height], //消去する列の番号を記憶する配列
        row_del[width],  //消去する行の番号を記憶する配列
        k=0; //カウンタ変数

    for(int i=0; i < height; i++){
        for(int j=0; j < width; j++){
            if(board[i][j]== '.'){
                count++;
            }
        }
        if (count == width){ //i行が全て'.'だった場合
            row_del[k] = i; //配列の最初から順に用いるためにkを使う
            k++;
        }
        count = 0; //各行ごとにリセット
    }  
    int row_del_num = k; //消去する行の数

    k = 0; //リセット

    for(int i=0; i < width; i++){
        for(int j=0; j < height; j++){
            if(board[j][i]== '.'){
                count++;
            }
        }
        if (count == height){ //i列が全て'.'だった場合
            col_del[k] = i;
            k++;
        }
      	count = 0; //各列ごとにリセット
    } 

  	int col_del_num = k; //消去する列の数
    
    for(int i=0; i < row_del_num; i++){
        for (int j=0; j < width; j++){
            board[row_del[i]][j] = 'o'; //消去する行の文字を'o'に置き換える
        }
    }
    for(int i=0; i < col_del_num; i++){
        for (int j=0; j < height; j++){
            board[j][col_del[i]] = 'o'; //消去する列の文字を'o'に置き換える
        }
    }
  	k = 0; // リセット
  	
    char ans_row[height * width]; //答えとなるマス目の文字を一列に並べた配列
    for(int i=0; i < height; i++){
        for(int j=0; j < width; j++){
            if (board[i][j] != 'o'){ //'o'を飛ばす
                ans_row[k] = board[i][j];
              	k++;
            }
        }
    }

  	int height_ans = height - row_del_num, //答えとなる配列の縦の長さ
  		width_ans = width - col_del_num; //答えとなる配列の横の長さ

  	char ans[height_ans][width_ans];  //答えとなる配列

    for(int i=0; i < height_ans; i++){
        for(int j=0; j < width_ans;j++){
            ans[i][j] = ans_row[j + i * (width_ans)]; //一次元の配列をマス目に合うように二次元に直す
        }
    }
  
	for(int i=0; i < height_ans;i++){
        for (int j=0; j < width_ans; j++){
            printf("%c", ans[i][j]); //マス目をprint
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	m := getNextInt(scanner)
	aa := make([]int, n)
	cost := make([]int, m*2+1)
	seg := Segment{}
	seg.init(m*2 + 1)
	sum := 0
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner) - 1
		if i == 0 {
			continue
		}
		sum += (m + aa[i] - aa[i-1]) % m
		g := 0
		if aa[i-1] > aa[i] {
			g = m
		}
		if aa[i-1]+1 < aa[i]+g {
			seg.rangeadd(aa[i-1]+1, aa[i]+g, 1)
		}
	}
	for i := m*2 - 1; i >= 0; i-- {
		cost[i] = seg.get(i)
	}
	for i := 1; i < n; i++ {
		g := 0
		if aa[i-1] > aa[i] {
			g = m
		}
		if aa[i-1]+1 < aa[i]+g {
			cost[aa[i]+g] -= aa[i] + g - (aa[i-1] + 1)
		}
	}
	for i := 1; i < m*2+1; i++ {
		cost[i] += cost[i-1]
	}
	for i := 0; i < m; i++ {
		cost[i] += cost[i+m]
	}
	mm := 0
	for i := 0; i < m; i++ {
		if mm < cost[i] {
			mm = cost[i]
		}
	}
	sum -= mm

	fmt.Fprintln(writer, sum)

	writer.Flush()
}

// Segment ...
type Segment struct {
	n, h, i, chunk, inf int
	unit                []int
	bucket              [][]int
}

func (seg *Segment) init(n int) {
	seg.n = n
	seg.unit = make([]int, 1)
	seg.unit[0] = 1
	seg.bucket = make([][]int, 1)
	seg.bucket[0] = make([]int, n)

	chunk := 8
	for i := 0; n > 1; i++ {
		n = (n-1)/chunk + 1
		seg.bucket = append(seg.bucket, make([]int, n))
		seg.unit = append(seg.unit, seg.unit[i]*chunk)
	}
	seg.h = len(seg.unit)
	seg.chunk = chunk
	seg.inf = math.MaxInt32
}

func (seg *Segment) add(index, value int) {
	for i := 0; i < seg.h; i++ {
		seg.bucket[i][index/seg.unit[i]] += value
	}
}
func (seg *Segment) get(index int) int {
	value := 0
	for i := 0; i < seg.h; i++ {
		value += seg.bucket[i][index/seg.unit[i]]
	}
	return value
}

func (seg *Segment) rangeadd(l, r, value int) {
	i := 0
	for index := l; index < r; index += seg.unit[i] {
		for i < seg.h-1 && index%seg.unit[i+1] == 0 {
			i++
		}
		for i > 0 && index+seg.unit[i] >= r {
			i--
		}
		ii := index / seg.unit[i]
		seg.bucket[i][ii] += value
	}
}


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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int N;
	vector<int> A;
	cin >> N ;
	A.resize(N);

	rep(i, N) {
		cin >> A[i];
	}

	int count = 0;
	rep(i, N) {
		if (A[i] != i + 1)count++;
	}
	if (count == 2 or count == 0)print("YES");
	else print("NO");

}

Measured memory_bytes: 256
/* ITP1_3-C */
#include <iostream>

int main(void){
    /* input */
    int inputDataX = 0;
    int inputDataY = 0;
    for(;;)
    {
        /* input */
        std::cin >> inputDataX;
        std::cin >> inputDataY;
        
        /* check end */
        if((inputDataX == 0) && (inputDataY == 0))
        {
            break;
        }
        
        /* compare value & output */
        if(inputDataX <= inputDataY)
        {
            std::cout << inputDataX << " " << inputDataY << std::endl;
        }
        else
        {
            std::cout << inputDataY << " " << inputDataX << std::endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long int
#define L_T_S_k  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
using namespace std;
const int N = 1e6;
const int mod = 1e9 + 7;

int32_t main() {    
 L_T_S_k;
 int a , b , c;
 cin >> a >> b >> c;
 cout << (a + b + c >= 22 ? "bust" : "win");
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
typedef pair<P,P> PP;

int main() {
  int n,t;
  while(cin >> n >> t && n) {
    PP a[n];
    for(int i=0; i<n; i++) {
      cin >> a[i].F.F >> a[i].S.F >> a[i].S.S;
      a[i].F.S=i;
    }
    for(int m=1; m<=n; m++) {
      bool f=0;
      int b[n],c[t+1],cnt=0;
      memset(b,0,sizeof(b));
      memset(c,0,sizeof(c));
      c[0]=m;
      for(int k=0; k<t; k++) {
        for(int i=0; i<n; i++) {
          if(b[i]==-1) continue;
          if(c[k]&&b[i]<=k&&k<=b[i]+a[i].S.F) {
            if(k+a[i].F.F>t) break;
            c[k]--;
            c[k+a[i].F.F]++;
            b[i]=-1;
            cnt++;
          } else if(b[i]+a[i].S.F==k) b[i]=k+a[i].S.S;
        }
        if(cnt==n) {
          f=1;
          break;
        }
        c[k+1]+=c[k];
      }
      if(f) {
        cout << m << endl;
        break;
      }
    }
  }
  return 0;
}

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

int main() {
  char c;
  cin >> c;

  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <stdlib.h>

struct subList;

typedef struct subList {
  struct subList *next;
  int value;
} SubList;


int main() {
  int i, j, d, n, q, t, x;
  char buf[32], *p;
  buf[31]=0;
  fgets(buf, 32, stdin);
  for (n=0,p=buf; *p!=' '; n=n*10+*(p++)-'0');
  for (q=0,p++; *p!='\n'; q=q*10+*(p++)-'0');
  SubList *slp;
  SubList **L = (SubList**)malloc(sizeof(SubList**) * n);
  SubList **tail = (SubList**)malloc(sizeof(SubList**) * n);

  for (i = 0; i < n; L[i++]=tail[i]=NULL);
  for (i = 0; i < q; i++) {
    fgets(buf, 32, stdin);
    for (t=0,p=buf+2; *p>='0'; t=t*10+*(p++)-'0');
    switch (buf[0]) {
    case '0': // insert
      if (*(++p)=='-') {
	for (x=0,p++;*p>='0';p++) x = x*10+*p-'0';
	x=-x;
      } else for (x=0; *p>='0'; x=x*10+*(p++)-'0');
      if (L[t] == NULL) {
	L[t] = (SubList*)malloc(sizeof(SubList));
	tail[t] = L[t];
	L[t]->next = NULL;
	L[t]->value=x;
	break;
      }

      slp = tail[t];
      slp->next = (SubList*)malloc(sizeof(SubList));
      tail[t] = slp->next;
      slp->next->next = NULL;
      slp->next->value = x;
      break;
      
    case '1': // dump
      slp = L[t];
      if (slp!=NULL) {
	while (1) {
	  //printf("%d", slp->value);
	  j=31;
	  d=slp->value;
	  if (d>0) {
	    for (; d>0; buf[--j]='0'+d%10,d/=10);
	    fputs(buf+j, stdout);
	  } else if (d<0) {
	    for (; d<0; buf[--j]='0'-d%10,d/=10);
	    buf[--j]='-';
	    fputs(buf+j, stdout);
	  } else {
	    putc_unlocked('0', stdout);
	  }
	  if (slp->next==NULL) break;
	  slp = slp->next;
	  putc_unlocked(' ', stdout);
	}
      }
      putc_unlocked('\n', stdout);
      break;
      
    default:
      for (x=0,p++; *p>='0'; x=x*10+*(p++)-'0');
  
      if (L[x]==NULL) {
	L[x] = L[t];
      } else {
	slp = tail[x];
	slp->next = L[t];
      }
      L[t] = NULL;
      tail[x] = tail[t];
      tail[t] = NULL;
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 17244
#include<bits/stdc++.h>
using namespace std;
long long n,m,s[200000],a[200000];
int main()
{
    cin>>n;
    for(int i=2; i<=n; i++)
    {
        cin>>a[i];
        s[a[i]]++;
    }
    for(int i=1; i<=n; i++)
    {
        cout<<s[i]<<endl;
    }
}


Measured memory_bytes: 6704
/*
   Aizu Vol-1 0122: Summer of Pyonkichi
   2017.8.15 bal4u@uu
   ??±???????????¢?´¢
*/

#include <stdio.h>
#include <string.h>

#define MAX 2000
typedef struct { char x, y, k; } QUE; QUE Q[MAX + 10]; int top;
int n;
char map[10][10][10];

int move[12][2] = {
	{ -1, -2 }, {  0, -2 }, {  1, -2 },
	{  2, -1 }, {  2,  0 }, {  2,  1 },
	{  1,  2 }, {  0,  2 }, { -1,  2 },
	{ -2,  1 }, { -2,  0 }, { -2, -1 } };

int main()
{
	int px, py, x, y;
	int i, k, xx, yy, ans;

	while (1) {
		scanf("%d%d", &px, &py); if (!px && !py) break;
		scanf("%d", &n);
		memset(map, 0, sizeof(map));
		for (i = 0; i < n; i++) {
			scanf("%d%d", &x, &y);
			for (xx = x - 1; xx <= x + 1; xx++) for (yy = y - 1; yy <= y + 1; yy++) {
				if (xx >= 0 && yy >= 0 && xx <= 9 && yy <= 9) map[i][xx][yy] = 1;
			}
		}
		Q[0].x = px, Q[0].y = py, Q[0].k = 0, top = 1, ans = 0;
		while (top) {
			x = Q[--top].x, y = Q[top].y, k = Q[top].k;
//			printf("(%d,%d), step %d, top %d\n", x, y, k, top);
			for (i = 0; i < 12; i++) {
				xx = x + move[i][0], yy = y + move[i][1];
				if (xx >= 0 && yy >= 0 && xx <= 9 && yy <= 9 && map[k][xx][yy]) {
					if (k + 1 < n) Q[top].x = xx, Q[top].y = yy, Q[top].k = k + 1, top++;
					else { ans = 1; goto NEXT; }
				}
			}
		}
NEXT:	puts(ans ? "OK" : "NA");
	}
	return 0;
}

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

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)round(x))<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

bool check(const string &s1, const string &s2) {
  printf("%s\n%s\n", s1.c_str(), s2.c_str());
  fflush(stdout);

  char res_c[128];
  scanf("%s", res_c);

  string res(res_c);
  
  if (res == "T" || res == "end") {
    return true;
  } else {
    return false;
  }
}

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

  string pat1 = "..##";
  string pat2 = ".#.#";
  
  int N;
  
  scanf("%d", &N);

  bool rightFlg = true;
  string s1 = "";
  string s2 = "";

  while (s1.size() < N) {
    // 右側にくっつける
    if (rightFlg) {
      bool success = false;
      
      for (int i = 0; i < 4; i++) {
        string ts1 = s1;
        ts1 += pat1[i];
        string ts2 = s2;
        ts2 += pat2[i];

        if (check(ts1, ts2)) {
          s1 = ts1;
          s2 = ts2;
          success = true;
          break;
        }
      }
      if (success) {
        continue;
      } else {
        rightFlg = false;
      }
    }

    // 左側にくっつける
    bool success = false;
      
    for (int i = 0; i < 4; i++) {
      string ts1 = "";
      ts1 += pat1[i];
      ts1 += s1;
      string ts2 = "";
      ts2 += pat2[i];
      ts2 += s2;

      if (check(ts1, ts2)) {
        s1 = ts1;
        s2 = ts2;
        success = true;
        break;
      }
    }
    if (success) {
      continue;
    } else {
      // ありえないやつ
      while (true) {}
    }
  }
}


Measured memory_bytes: 720
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}
vector<vector<int>> dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0},{1,1},{1,-1},{-1,1},{-1,-1}};



void solve(){
    int n, m, k;
    cin >> n >> m >> k;
    vec a(n), b(m);
    int ans = 0;
    fo(i,n){
        cin >> a[i];
    }
    fo(i,m){
        cin >> b[i];
    }
    if(a[0]<=k){
        ans=1;
    }
    foo(i,1,n){
        a[i] += a[i - 1];
        if(a[i]<=k){
            ans=max(ans,i+1);
        }
    }
    if(b[0]<=k){
        ans=max(ans,(int)1);
    }
    foo(i,1,m){
        b[i] += b[i - 1];
        if(b[i]<=k){
            ans=max(ans,i+1);
        }
    }
    fo(i,n){
        if(a[i]>k){
            break;
        }
        auto it = upper_bound(b.begin(), b.end(), k - a[i]) - b.begin();
        if(it==0){
            break;
        }
        else{
            ans = max(ans, i + 1+it);
        }
    }
    cout << ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;

    while(t--){
        solve();
    }
}


Measured memory_bytes: 6376
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();

		int n = Integer.parseInt(str);

		str = scan.nextLine();
		String[] substr = str.split(" ", 0);

		BigInteger[] array = new BigInteger[10000];
		for (int i=0; i<n; i++) {
			array[i] = BigInteger.valueOf(Integer.parseInt(substr[i]));
		}

		BigInteger l = array[0];
		for (int i=1; i<n; i++) {
			l = array[i].multiply(l).divide(array[i].gcd(l));
		}
		BigInteger ans = BigInteger.ZERO;
		BigInteger mod = BigInteger.valueOf(1000000007);
		l = l.mod(mod);
		for (int i=0; i<n; i++) {
			ans = ans.add(l.multiply(array[i].modInverse(mod)));
			ans = ans.mod(mod);
		}
		System.out.println(ans);

	}

    static BigInteger gcd(BigInteger a, BigInteger b){
        return a.gcd(b);
    }
    static BigInteger lcm(BigInteger a, BigInteger b){
        return a.multiply(b).divide(gcd(a,b));
    }
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
// using namespace __gnu_pbds;
typedef long double ld;
typedef long long ll;
#define int ll
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define vi vector<int>
#define pii pair<int,int>
#define For(i,s,e) for (ll i=(s); i<(e); i++)
//#define MAX 100005
#define initialize(arr,elem) memset(arr,elem,sizeof(arr))
#define sz size
const int MOD = 1e9+7;
const int MAX_SZ = 2e5+9;
const int INF = 1e18+9;

// typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int N,k;
int dp[101][100005],arr[102];

void rand_shuff(vi &arr){
	random_device rd;
	mt19937 g(rd());
	shuffle(all(arr),g);
}


int solve(){
	For(i,1,N+1){
		For(j,0,k+1){
			if (i == 1 && j<=arr[i]) {
				dp[i][j] = 1;
				continue;
			}
			if (i==1 && j>arr[i]) break;
			int l = max((ll)0,j-arr[i]);
			int r = j;
			if (l==0) dp[i][j] = dp[i-1][r] ;
			else dp[i][j] = (dp[i-1][r] - dp[i-1][l-1] + MOD);
			dp[i][j] %= MOD;
		}
		For (j,1,k+1) {
			dp[i][j] += dp[i][j-1];
			dp[i][j] %= MOD;
		}
	}
	
	return (dp[N][k]-dp[N][k-1] + MOD)%MOD;

}

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

	cin>>N>>k;
	int res = 0;
	initialize(dp,0);
	For(i,1,N+1) cin>>arr[i];
	
	cout<<solve()<<endl;

	return 0;
}


Measured memory_bytes: 79232
import math
import numpy

A,B,H,M=map(int,input().split())

X = abs(6*M - 0.5*M - 30*H)

if X > 180:
    X = 360 - X

C = B**2 + A**2 - 2*B*A*math.cos(math.radians(X))
print(math.sqrt(C))

Measured memory_bytes: 27196