akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
#include <sstream>
#include <vector>
#include <stdio.h>
#define ll              long long
#define fr(i,j,p)       for(int i=j; i<p ;i++)
#define frr(i,j,p)      for(int i=j; i>=p ;i--)
#define PI              3.14159265358979323846
#define print(m)        std::cout << std::fixed << std::setprecision(11) << m <<endl;
#define mkp             make_pair
#define pb              push_back
#define M               32
#define lbindex(a,x)    (int)(lower_bound(a.begin(), a.end(),x)-a.begin());
#define upindex(a,x)    (int)(upper_bound(a.begin(), a.end(),x)-a.begin());
#define all(a)          (a).begin(),(a).end()
#define mem(b,a,n)      memset(b,a,sizeof(b[0])*n);
#define meme(b,a,n,m)   memset(b,a,sizeof(b[0][0])*n*m);
#define ff              first
#define ss              second
#define endl            '\n'

//ll md=1000000007;
//ll mdd=998244353;

using namespace std;

typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);  cout.tie(NULL);
    int n;  cin>>n;
    ll a[n];
    fr(i,0,n)   cin>>a[i];
    sort(a,a+n);
    ll ans=a[n-1];
    int i=n-2,j=n-2;
    while(i>0)
    {
        ans+=a[j];  i--;
        if(i==0)    break;
        ans+=a[j];  i--;    j--;
    }
    cout<<ans;
    return 0;

}


Measured memory_bytes: 5212
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

zero = [0] * N
for i in range(N) :
  if A[i] == 0 :
    zero[i] += 1
for i in range(1, N) :
  zero[i] += zero[i - 1]
    
for i in range(K, N) :
  if A[i] > A[i - K] and zero[i] == zero[i - K] :
    print('Yes')
  else :
    print('No')

Measured memory_bytes: 94128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
#define double long double
typedef pair<double, string> P;

bool solve(){
	int n;
	string name;
	int p, a, b, c, d, e, f, s, m;
	P data[50];
	
	cin >> n;
	if( n == 0 ) return false;
	for( int i = 0; i < n; i++ ){
		char buf[25];
		name = buf;
		cin >> name >> p >> a >> b >> c >> d >> e >> f >> s >> m;
		double income = s * f * m - p;
		double timer = a + b + c + m * (d + e);
		double effect = income / timer;
		data[i].first = -effect;	//Swap Order Technic.
		data[i].second = name;
	}
	sort(data, data + n);
	
	for( int i = 0; i < n; i++ ){
		cout << data[i].second << endl;
	}
}

int main(){
	while(1){
		if( !solve() )
			break;
		else
			cout << "#" << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

const int MOD = 1000000007;

using namespace std;

int main(){

    long long count = 0,i,n;
    cin >> n;
    long long a[n+1],b[n];
    for(i=0;i<n+1;i++){
        cin >> a[i];
    }
    for(i=0;i<n;i++){
        cin >> b[i];
    }
    for(i=0;i<n;i++){
        if(a[i]>0){
           if(a[i]<b[i]){
                b[i] -= a[i];
                count += a[i];
            }else{
                count += b[i];
                b[i] -= a[i];
            }
        }
        if(b[i]>0){
            if(a[i+1]<b[i]){
                count += a[i+1];
                a[i+1] = 0;
            }else{
                a[i+1] -= b[i];
                count += b[i];
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0; i<n; i++){
			int out=0;
			int score=0;
			boolean[] runner=new boolean[3];
			for(; out<3;){
				String s=sc.next();
				if(s.equals("HIT")){
					if(runner[2])
						score++;
					runner[2]=runner[1];
					runner[1]=runner[0];
					runner[0]=true;
				}else if(s.equals("HOMERUN")){
					for(int j=0; j<3; j++){
						if(runner[j])
							score++;
						runner[j]=false;
					}
					score++;
				}else{
					out++;
				}
			}
			println(score+"");

		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

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

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> N(10, vector<int>(10));
    if(n < 10){
        cout << n << endl;
    }else{
        ll ans = 0;
        string num;
        int s, e;
        rep(i, 1, n + 1){
            num = to_string(i);
            if(num.size() == 1){
                N[(int)num[0] - (int)'0'][(int)num[0] - (int)'0']++;
            }else{
                N[(int)num[0] - (int)'0'][(int)num[num.size() - 1] - (int)'0']++;
            }

        }
        rep(i, 1, 10){
            rep(j, 1, 10){
                ans += N[i][j] * N[j][i];
            }
        }
        cout << ans << endl;
    }

}


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

ll v[3000];
ll dp[3000][3000][2];

ll f(int a, int b, int t) {
	if (a == b) return !t * v[a];
	if (dp[a][b][t]) return dp[a][b][t];

	ll r = 0;
	if (t == 0) r = max(f(a+1, b, 1) + v[a], f(a, b-1, 1) + v[b]);
	else r = min(f(a+1, b, 0), f(a, b-1, 0));

	dp[a][b][t] = r;
	return r;
}

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

	int n;
	cin >> n;

	for (int i = 0; i < n; ++i) cin >> v[i];
	ll s = 0;
	for (int i = 0; i < n; ++i) s += v[i];
	cout << 2 * f(0, n-1, 0) - s << '\n';
}


Measured memory_bytes: 139776
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class AAtCoderBeginnerContest999 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] arr = in.next().toCharArray();
            char[] res = new char[arr.length];
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] == '1') {
                    res[i] = '9';
                } else if (arr[i] == '9') {
                    res[i] = '1';
                } else {
                    res[i] = arr[i];
                }
            }
            for (char c : res) {
                out.print(c);
            }
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public void close() {
        }

    }
}



Measured memory_bytes: 21204
A= input()
if len(A)== 1:
	print(A)
	exit()
length=len(A)
B = "9" * (length-1)
A=int(A)
C=A-int(B)
B=str(int(C/10**(length-1)))+B
B=int(B)
B=list(str(B))
B=list(map(int,B))
print(sum(B))

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

def solve():
    import sys
    import math

    A, B, H, M = list(map(int, sys.stdin.readline().split()))

    h_speed = 360 / (12*60)
    m_speed = 360 / 60

    m = H*60 + M

    h_angle = h_speed * m
    m_angle = m_speed * m % 360
    angle = abs(h_angle - m_angle) if abs(h_angle-m_angle) <= 180 else 360 - abs(h_angle-m_angle)

    if angle == 0:
        print(abs(A-B))
        return
    elif angle == 180:
        print(A+B)
        return

    # 余弦定理
    C = (B**2 + A**2 - 2*A*B*math.cos(math.radians(angle)))**(1/2)
    print(C)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
long long mem[2][1010], a[2][100010], n;

long long dp(int x, int y){
    if(mem[x][y]!=-1)
    return mem[x][y];
long long res=a[x][y];
if(x==0){
    res=max(res, a[x][y]+dp(x+1, y));
}
if(y<n-1){
    res=max(res, a[x][y]+dp(x, y+1));
}
mem[x][y]=res;
return res;
}

int main(){
    int x;
    while(cin>>n){
        for(int i=0; i<2; ++i){
            for(int j=0; j<n; ++j){
                cin>>a[i][j];
            }
        }
        memset(mem, -1, sizeof mem);
        long long ans=dp(0, 0);
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;


size_t solve(const vector<uint64_t>& heights, const size_t k)
{
    size_t min_height = UINT64_MAX;

    for(size_t i = 0; i < heights.size(); i++)
    {
        size_t j = i + (k - 1);
        if (j >= heights.size()) {
            break;
        }
        size_t diff = heights[j] - heights[i];
        min_height = min(min_height, diff);
    }

    return min_height;
}

void test_max_case()
{
    size_t n = pow(10, 5);
    size_t k = n / 2;
    vector<uint64_t> heights(n, UINT64_MAX);
    for(size_t i = 0; i < n; i++)
    {
        heights[i] = i + 1;
    }
    sort(heights.begin(), heights.end());

    size_t answer = solve(heights, k);
    cout << answer << endl;
}

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

    size_t n, k = UINT64_MAX;
    cin >> n >> k;
    assert(2 <= n && n <= pow(10, 5));
    assert(2 <= k && k <= n);

    vector<uint64_t> heights(n, UINT64_MAX);
    for(size_t i = 0; i < n; i++)
    {
        uint64_t height = 0;
        cin >> height;
        assert(1 <= height && height <= pow(10, 9));
        heights[i] = height;
    }
    sort(heights.begin(), heights.end());

    size_t answer = solve(heights, k);

    cout << answer << endl;

    // test_max_case();

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
const int INF = 1001001001;
int V, E,r;
struct edge{int u,v,cost;};
vector<edge> A;
vector<int> d;

int main() {
    cin >> V >> E >> r;
    A.resize(E);
    d.resize(V);
    for(int i=0; i<E; i++) {
        int s,t,w;
        cin >> s >> t >> w;
        struct edge temp = {s,t,w};
        A[i] = temp;
    }

    for(int i=0; i<V; i++) d[i] = INF;
    d[r] = 0;

    for(int i=0; i<V-1; i++) {
        for(int j=0; j<E; j++) {
            struct edge e = A[j];
            if(d[e.u] == INF) continue;
            d[e.v] = min(d[e.v], d[e.u] + e.cost);
        }
    }

    for(int i=0; i<E; i++) {
        struct edge e = A[i];
        if(d[e.u] != INF && d[e.v] > d[e.u] + e.cost) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }

    for(int i=0; i<V; i++) {
        if(d[i] == INF) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
    return 0;
}


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

    #define ll long long
    #define pb push_back
    #define mod 1000000007

    int main() {

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

      string s,t;
      cin>>s>>t;
      ll i,ans=0;
      for(i=0;i<3;i++){
        if(s[i]==t[i])ans++;
      }
      cout<<ans;


      return 0;
      
      }

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(void) {
	int a,b,c,d,x;

	cin >> a >> b >> c >> d;

	x = max(a*b, c*d);

	cout << x << endl;

	return 0;
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

void solve() {
  int n;
  cin >> n;
  map<int, int> cnt;
  rep(i, n) {
    int a;
    cin >> a;
    cnt[a] += 1;
  }
  vi32 flag(1000001, 1);
  vi32 target;
  for (auto p : cnt) {
    if (p.second > 1) {
      flag[p.first] = 0;
    }
    target.push_back(p.first);
  }
  int ans = 0;
  for (auto x : target) {
    if (flag[x]) {
      ans += 1;
    }
    for (int i = x; i <= 1000000; i += x) {
      flag[i] = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 17480
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print(""); 
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

map<ll, ll> prime_fact(ll n) {
	map<ll, ll> ret;
	rep2(i, 2, sqrt(n)){
		while (n % i == 0){
			ret[i]++;
			n /= i;
		}
	}
	if(n != 1) ret[n]++;
	return ret;
}

void Main(){
 
	ll A, B;
	cin >> A >> B;
	
	map<ll, ll> ma = prime_fact(A);
	ll ans = 1;
	for(auto itr = ma.begin(); itr != ma.end(); itr++){
		ll key = itr -> first;
		ans += (B % key == 0);
	}
	print(ans);
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Main();
	return 0;
	
}





Measured memory_bytes: 3680
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	int w, h;
	int r;
	bool pow[40001];
	bool outputed;

	for (int i = 1;i <= 200;i++) {
		pow[i*i] = true;
	}

	while (true) {
		scanf("%d%d", &h, &w);
		if (w == 0 && h == 0)break;

		r = w*w + h*h;
		outputed = false;
		for (int R = r;;R++) {
			for (int a = 1;a*a < R / 2;a++) {
				if (pow[R - a*a] && (R > r || a > h)) {
					printf("%d %d\n", a, (int)sqrt(R - a*a));
					outputed = true;
					break;
				}
			}
			if (outputed)break;
		}
	}

	return 0;
}

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

using namespace std;
typedef long long ll;

ll calc(ll x) {
	return x*(x+1)/2;
}

int main() {
	int n;
	cin >> n;
	vector<ll> num(n+1);
	for (int i = 1; i <= n; i++) {
		ll a;
		cin >> a;
		num[i]=a;
	}
	int i = 1, j = 1;
	ll x = num[1];
	ll s = num[1];
	ll ans = 0;
	while (i <= n) {
		while (j < n && (num[j+1]^x)==(num[j+1]+s)) {
			j++;
			x^=num[j];
			s+=num[j];
		}
		ans+=calc(j-i+1);
		if (j == n) break;

		j++;
		x^=num[j];
		s+=num[j];

		while (x!=s) {
			x^=num[i];
			s-=num[i];
			i++;
		}

		if (i < j) {
			ans-=calc(j-1-i+1);
		}

	}
	cout << ans << "\n";
}


Measured memory_bytes: 4820
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
   int h,w,k;cin>>h>>w>>k;
   char c[h][w];
   for(int i = 0;i<h;i++){
    string a;cin>>a;
    for(int j = 0;j<w;j++){
     c[i][j] = a[j];
    }
   }
   int n = h+w;
   char cc [h][w];
   int g = 0;
   for (int bit = 0; bit < (1<<n); ++bit) {
        vector<int> S;
        for(int i = 0;i<h;i++)for(int j = 0;j<w;j++) cc[i][j] = c[i][j];
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }

        
        for (int i = 0; i < (int)S.size(); ++i) {
            if(S[i] <= h-1){
            	for(int j= 0;j<w;j++) cc[S[i]][j] = '1';
            }
            else{
            	for(int k = 0;k<h;k++) cc[k][S[i]-h] = '1';
            }
        }
        int kuro = 0;
        for(int i = 0;i<h;i++){
        	for(int j = 0;j<w;j++){
            	if(cc[i][j] == '#') kuro+=1;
            }
        }
        if(kuro == k) {
          g+=1;
        }
    }
    cout<<g;
}

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

int main(void) {
    int A,B,H,M; cin >> A >> B >> H >> M;
    long double ang_short = H*30+0.5*M;
    long double ang_long = M*6;
    long double ang_tri;
    if(ang_short>=ang_long)  ang_tri = ang_short-ang_long;
    else ang_tri = ang_long-ang_short;
    if(ang_tri>180) ang_tri=360-ang_tri;
    //cout << ang_tri << endl;
    //cout << cos(ang_tri) << endl;
    long double ans = A*A + B*B - 2*A*B*cos(ang_tri*PI/180);
    ans = sqrtl(ans);
    printf("%20.20LF\n",ans);
}

Measured memory_bytes: 4100
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		
		if (a < b&&b < c){
			System.out.println("Yes");
			}
		else {
			System.out.println("No");
		}
	}
}

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


int main() 
{ 
	int n;
	cin>>n;
	vector<int> v;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		v.push_back(x);
	}
	int count=0,max1=0;
	for(int i=0;i<n-1;i++){
		if(v[i+1]<=v[i]){
		count++;
		//	cout<<i<<","<<i+1<<"  ";
		}
		else{
		//	cout<<"\n";
			max1=max(max1,count);
			count=0;
			//i--;
		}
		//cout<<i<<","<<count<<","<<max1<<"  ";
	}
	max1=max(max1,count);
	cout<<max1;
	return 0; 
} 


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
    int N; cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    // 累積和と連想配列
    vector<long long> s(N+1, 0);
    map<long long, long long> nums;
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];
    for (int i = 0; i < N+1; ++i) nums[s[i]]++;

    // 集計処理
    long long res = 0;
    for (auto it : nums) {
        long long num = it.second; // it.first が it.second 個ある
        res += num * (num - 1) / 2;
    }
    cout << res << endl;
} 

Measured memory_bytes: 15872
from heapq import heappop,heappush,heapify
n=int(input())
a=list(map(int,input().split()))
left=[0]*n
lst=a[:n]
s=sum(lst)
heapify(lst)
for i in range(n):
    heappush(lst,a[n+i])
    x=heappop(lst)
    if i==0:
        left[0]=s+a[n]-x
    else:
        left[i]=left[i-1]+a[n+i]-x
left=[s]+left
right=[0]*n
lst=[]
for i in range(2*n,3*n):
    lst.append(-a[i])
s=-sum(lst)
heapify(lst)
for i in range(n):
    heappush(lst,-a[2*n-1-i])
    x=-heappop(lst)
    if i==0:
        right[n-1]=s+a[2*n-1]-x
    else:
        right[n-1-i]=right[n-i]+a[2*n-1-i]-x
right+=[s]
ans=-float("inf")
for i in range(n+1):
    ans=max(ans,left[i]-right[i])
print(ans)

Measured memory_bytes: 37212
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    const char White = '.';
    const char Black = '#';

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var h = int.Parse(spl[0]);
        var w = int.Parse(spl[1]);
        var ss = new char[h][];
        for(int i = 0; i<h; i++) {
            ss[i] = input.ReadLine().ToCharArray();
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (ss[i][j] == Black) continue;
                var x = 0;
                for (var ii = i - 1; ii <= i + 1; ii++) {
                    for (var jj = j - 1; jj <= j + 1; jj++) {
                        if (0 <= ii && ii < h && 0 <= jj && jj < w) {
                            x += ss[ii][jj] == Black ? 1 : 0;
                        }
                    }
                }
                ss[i][j] = (char)('0' + x);
            }
        }

        StringBuilder sb = new StringBuilder();
        foreach(var rec in ss) {
            sb.Append(rec);
            sb.AppendLine();
        }

        return sb;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11220
// ALDS1_12_B: Single Shortest Path I
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1000000
#define NIL -1
using graph = std::vector<std::vector<int>>;
bool debug = false;

graph adjacency_matrix;
std::vector<bool> node_stat;
std::vector<int> next_node, minimum_cost;

void dijkstra(int vertex) {
    if (debug) std::cout << "dijkstra(" << vertex << ")\n";
    node_stat.at(vertex) = false;

    for (int i=0; i<adjacency_matrix.at(vertex).size(); i++) {
        int next_vertex = i, edge_weight = adjacency_matrix.at(vertex).at(next_vertex);
        if (edge_weight != -1) {
            int cost_to_next = minimum_cost.at(vertex) + edge_weight;
            if (cost_to_next < minimum_cost.at(next_vertex)) {
                if (debug) std::cout << vertex << " -> " << next_vertex << ": " << cost_to_next << "\n";
                minimum_cost.at(next_vertex) = cost_to_next;
                next_node.at(vertex) = next_vertex;
            }
        }
    }

    int min_weight = INF, next_vertex = NIL;
    for (int i=0; i<minimum_cost.size(); i++) {
        if (minimum_cost.at(i) < min_weight) {
            if (node_stat.at(i)) {
                if (debug) std::cout << "i = " << i << "\n";
                min_weight = minimum_cost.at(i);
                next_vertex = i;
            }   
        }
    }
    if (debug) std::cout << "min_weight = " << min_weight << ", next_vertex = " << next_vertex << "\n";
    if (next_vertex == NIL) {
        return;
    }
    dijkstra(next_vertex);
}

void init() {
    node_stat.assign(node_stat.size(), true);
    next_node.assign(next_node.size(), NIL);
    minimum_cost.assign(minimum_cost.size(), INF);
    minimum_cost.at(0) = 0;
}

int main() {
    int total_node_num; std::cin >> total_node_num;
    
    adjacency_matrix.resize(total_node_num);
    for (int i=0; i<adjacency_matrix.size(); i++) adjacency_matrix.at(i).assign(total_node_num, NIL);
    node_stat.resize(total_node_num);
    next_node.resize(total_node_num);
    minimum_cost.resize(total_node_num);
    
    for (int i=0; i<total_node_num; i++) {
        int vertex_num; std::cin >> vertex_num;
        int outdegree; std::cin >> outdegree;
        for (int j=0; j<outdegree; j++) {
            int next_vertex; std::cin >> next_vertex;
            std::cin >> adjacency_matrix.at(vertex_num).at(next_vertex);
        }
    }
    init();
    dijkstra(0);
    for (int i=0; i<minimum_cost.size(); i++) {
        std::cout << i << " " << minimum_cost.at(i) << "\n";
    }
}



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

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

	return 0;
}

Measured memory_bytes: 3756
a,b,c = map(int,input().split())
r = 0
if a == b == c:
  if a%2 == 1:
    print(r)
    exit()
  else:
    print(-1)
    exit()

while True:
  if a%2 == 1 or b%2 == 1 or c%2 == 1:
    break
  r += 1
  aa = (b+c)//2
  bb = (a+c)//2
  cc = (a+b)//2
  a,b,c = aa,bb,cc

print(r)

Measured memory_bytes: 9120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC147A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b, c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            if (a+b+c>=22)
                Console.Write("bust");
            else
                Console.WriteLine("win");
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#define ll long long 
#define lowbit(x) (x)&(-x)
using namespace std;

const int maxn = 3e5 + 100;
int a[maxn];
// dp[i] is the length of the squence that end with i 

	struct node
	{
		int L; int R;
		int pmax; 
	};
	node tree[maxn << 2];

	void push_up(int x)
	{
		tree[x].pmax = max(tree[x << 1].pmax, tree[x << 1 | 1].pmax);
	}
	void init(int L, int R, int x)
	{
		tree[x].L = L; tree[x].R = R;
		if (tree[x].L == tree[x].R)
		{
			tree[x].pmax = 0;
			return;
		}
		int mid = (L + R) >> 1;
		init(L, mid, x << 1); init(mid + 1, R, x << 1 | 1);
		push_up(x);
	}

	//给l，r区间加上K
	void update(int l, int r, int x, ll K)
	{
		if (l <= tree[x].L && tree[x].R <= r)
		{
			tree[x].pmax = K;
			return;
		}
		int mid = (tree[x].L + tree[x].R) >> 1;
		if (l <= mid) update(l, r, x << 1, K);
		if (mid < r) update(l, r, x << 1 | 1, K);
		push_up(x);
	}

	int query(int l, int r, int x)
	{
		if (l <= tree[x].L && tree[x].R <= r) return tree[x].pmax;
		int mid = (tree[x].L + tree[x].R) >> 1;
		int ans1 = 0; int ans2 = 0;
		if (l <= mid) ans1 = query(l, r, x << 1);
		if (mid < r) ans2 = query(l, r, x << 1 | 1);
		push_up(x);
		return max(ans1, ans2);
	}

int main()
{
	ios::sync_with_stdio(false);
	int N; int K; cin >> N >> K;
	int pmin = 1e9; int pmax = -1;
	for (int i = 1; i <= N; i++)
	{
		cin >> a[i];
		pmin = min(pmin, a[i]);
		pmax = max(pmax, a[i]);
	}

	init(1, pmax, 1);
	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		int L = max(a[i] - K, pmin); int R = min(a[i] + K, pmax);
		int len = query(L, R, 1);
		int last = query(a[i], a[i], 1);
		update(a[i], a[i], 1, max(last, len + 1));
		ans = max(ans, max(last, len + 1));
	}

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

Measured memory_bytes: 17096
#include <iostream>
#include <array>
#include <vector>

using std::cout;
using std::endl;

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

    while (data_num--) {
        std::array<int, 10> balls;
        for (auto i = 0; i < 10; i++) {
            std::cin >> balls.at(i);
        }

        std::vector<int> b(1, 0), c(1, 0);
        b.push_back(balls.at(0));

        for (auto i = 1; i < 10; i++) {
            int b_end = b.at(b.size() - 1);
            int c_end = c.at(c.size() - 1);
            int ball = balls.at(i);

            if (b_end > ball && c_end > ball) {
                cout << "NO" << endl;
                break;
            } else if (b_end < ball && c_end > ball) {
                b.push_back(ball);
            } else if (b_end > ball && c_end < ball) {
                c.push_back(ball);
            } else {
                if (b_end > c_end) {
                    b.push_back(ball);
                } else {
                    c.push_back(ball);
                }
            }

            if (i == 9) {
                cout << "YES" << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1252
N,M = gets.split.map(&:to_i)
x = []

# 市番号, 年, 県
M.times do |i|
  p,y = gets.split.map(&:to_i)
  x << [i,y,p]
end

# 県を第1, 年を第2でソート
x = x.sort_by do |item|
  [item[2], item[1]]
end

pref = -1
b = 0
h = {}
M.times do |i|
  # 県が変わった場合
  if pref != x[i][2]
    pref = x[i][2]
    b = 1 # カウンタリセット
  end
  s = format('%06d', x[i][2]) # 認識番号前半
  s << format('%06d', b) # 認識番号後半
  b += 1
  h[x[i][0]] = s # 市の番号でハッシュに格納
end

# 市の番号順に出力
M.times do |i|
  puts h[i]
end

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

int main() {
  long long N;
  cin >> N;
  vector<long long> v(N);
  for (long long i = 0; i < N; i++) {
    cin >> v.at(i);
  }
  
  vector<long long> vec = v;
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(),vec.end());
  long long m1 = vec.at(0);
  long long m2 = vec.at(1);

  for (long long i = 0; i < N; i++) {
    if (v.at(i) == m1) {
      //cout << v.at(i) << endl;
      cout << m2 << endl;
    }
    else {
      //cout << v.at(i) << endl;
      cout << m1 << endl;
    }
  }
  
  
}



Measured memory_bytes: 4736
#include<stdio.h>

int main(){
    int a,val=0,b=10;
    scanf("%d", &a);
    for(;;){
        if(a/b == 0){
            val+= a-(val*10);
            break;
        }    
        val += a/b;
        b*=10;
    }
    if(a%val==0)
        printf("Yes\n");
    else
        printf("No\n");
        
    return 0;    

}


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

int main()
{
  int n, t;
  cin >> n >> t;
  int ans = 10000;
  int cost, time;
  for(int i = 0; i < n; i++) {
    cin >> cost >> time;
    if(time <= t)
      ans = min(ans, cost);
  }
  if(ans == 10000) {
    cout << "TLE" << endl;
  }else{
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int INF = 1 << 30;

void chmin(int &a, int b){
  if(a > b) a = b;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  
  sort(h.begin(),h.end());
  
  int ans = INF;
  
  for (int i = k-1; i < n; i++){
    chmin(ans, h[i] - h[i-(k-1)]);
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef vector <int> VI;

VI string_to_vi( string number )
{
	VI converted( number.size() );
	for ( int i = 0; i < number.size(); i++ ) converted[i] = (int)( number[i] - '0' );
	return converted;
}

VI add( VI left, VI right )
{
	VI result;
	reverse( left.begin(), left.end() );
	reverse( right.begin(), right.end() );
	VI::iterator it_left = left.begin();
	VI::iterator it_right = right.begin();

	int carry = 0;
	while ( it_left != left.end() || it_right != right.end() )
	{
		int l = 0, r = 0;
		if ( it_left != left.end() ) l = *it_left;
		if ( it_right != right.end() ) r = *it_right;

		result.push_back( ( l + r + carry ) % 10 );
		carry = ( l + r + carry >= 10 ) ? 1 : 0;

		if ( it_left != left.end() ) it_left ++;
		if ( it_right != right.end() ) it_right ++;
	}
	if ( carry ) result.push_back( 1 );

	reverse( result.begin(), result.end() );
	return result;
}

void print_number( VI& number )
{
	for ( VI::iterator it = number.begin(); it != number.end(); it++ ) cout << *it;
	cout << endl;
}

int main( void )
{
	int n; cin >> n;
	for ( int i = 0; i < n; i++ )
	{
		string input_a, input_b;
		cin >> input_a >> input_b;

		VI a = string_to_vi( input_a );
		VI b = string_to_vi( input_b );
		VI c = add( a, b );

		if ( c.size() > 80 ) cout << "overflow" << endl;
		else print_number( c );

	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
vector<int>S;

int main()
{
	int N,res=0;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int t;
		cin>>t;
		S.push_back(t);
	}
	sort(S.begin(),S.end());
	for(int i=0;i<=100000;i++)
	{
		int cnt=lower_bound(S.begin(),S.end(),i)-S.begin();
		if(cnt==N/2)res++;
	}
	cout<<res<<endl;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n;
    cin >> n;
    if(n%2 != 0){
        cout << 0 << endl;
        return 0;
    }
    long long ans = 0, div = 10;
    while(n > 0){
        ans += n / div;
        n /= 5;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>

#define INF 1000000000;
#define MOD 1000000007;
typedef long long ll;
using namespace std;

int main()
{
    int a, b, c, d; cin >> a >> b >> c >> d;
    string ans = "No";
    int ac = abs(a-c);
    int ab = abs(a - b);
    int bc = abs(b - c);
    if (ac <= d || (ab <= d && bc <= d)) {
        ans = "Yes";
    }
    cout << ans << endl;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int ans = -1;
  for(int i = 1; i <= 1000; i++) {
    int e = i * 0.08;
    int t = i * 0.1;
    if (e == A && t == B) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
  long N;
  vector<long> abcde(5);
  cin >> N;
  for(int i=0; i<5; i++) cin >> abcde[i];
  
  vector<long>::iterator minIt = min_element(abcde.begin(), abcde.end());
  size_t minIndex = distance(abcde.begin(), minIt);
  
  cout << 4+(long)ceil((long double)N/(*minIt)) << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
const int N = 3e3 + 3;
const int mod = 1e9 + 7;
int n , m;
int ans;
int dp[N][2][N];
int solve(int r , int b , int pos){
	if(pos > m){
		return 1;
	}
	if(dp[r][n - r - b][pos] != -1){
		return dp[r][n - r - b][pos];
	}
	int res = 0;
	if(r >= 1){
		res += solve(r - 1 , b + 1 , pos + 1);
		res += solve(r , b , pos + 1);
		res -= (res >= mod) * mod;
	}
	if(b >= 1){
		res += solve(r + 1 , b - 1 , pos + 1);
		res -= (res >= mod) * mod;
		res += solve(r , b , pos + 1);
		res -= (res >= mod) * mod;;
	}
	return dp[r][n - r - b][pos] = res;
}
int main(){
	scanf("%d %d" , &n , &m);
	ans = 0;
	memset(dp , -1 , sizeof(dp));
	for(int r = 0 ; r <= n ; ++r){
		ans += solve(r , n - r , 1);
		ans -= (ans >= mod) * mod;
		if(r){
			ans -= solve(r - 1 , n - r , 1);
		}
		ans += (ans < 0) * mod;
	}
	printf("%d\n" , ans);
}

Measured memory_bytes: 71040
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
char S[200000+2];
char T[200000+2];
int main(){
  int i;
  int res = 0;
  N = rd(S);
  rd(T);
  for(i=(0);i<(N);i++){
    if(S[i] != T[i]){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int N;
// char S[2d5+2], T[2d5+2];
// {
//   int res = 0;
//   rd(S@N, T);
//   rep(i,N) if(S[i] != T[i]) res++;
//   wt(res);
// }


Measured memory_bytes: 4404
import sys
def S(): return sys.stdin.readline().rstrip()

N,M = map(int,S().split())
AB = []
C = []
for _ in range(M):
    AB.append(tuple(int(i) for i in S().split()))
    C.append(sum(1<<(int(i)-1) for i in S().split()))

dp = [float('inf')]*(1<<N)
dp[0] = 0

for i in range(1<<N):
    for j in range(M):
        a,b = AB[j]
        c = C[j]
        dp[i|c] = min(dp[i|c],dp[i]+a)

if dp[-1] == float('inf'):
    print(-1)
else:
    print(dp[-1])

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

int main(){
  string s;
  cin>>s;
  int count=0,ans=0;
  s+='S';
  for(int i=0;i<4;i++){
    if(s[i]=='R'){
      count++;
    }
    else{
      ans=max(ans,count);
      count=0;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int[] a) {
    auto mt = new long[a.length];

    long lo = 0;
    long hi = a[0];
    while (lo <= hi) {
        long m = (lo + hi) / 2; // 山 1 の雨の量

        mt[0] = m * 2;
        for (int i = 1; i < a.length; i++) {
            // 山 i の雨の量を求める
            long p = 2 * a[i-1] - mt[i-1];
            mt[i] = p;
        }

        long x = (mt[0] + mt[$-1]) / 2;
        if (x == a[$-1]) {
            writeln(mt.map!(text).join(" "));
            break;
        }
        else if (x > a[$-1]) {
            hi = m - 1;
        }
        else {
            lo = m + 1;
        }
    }
}

void main() {
    int n; scan(n);
    auto a = readints;
    calc(a);
}


Measured memory_bytes: 6600
def myAnswer(A:int,B:int,C:int,X:int,Y:int) -> int:
   ans = 0
   both = C * 2
   AB=A+B
   while X!=0 or Y!=0:
      if(X>=1 and Y >=1):
         ans += min(AB,both)
         X-=1
         Y-=1
      elif(X>=1 and Y == 0):
         ans += min(both,A)
         X -= 1
      else:
         ans += min(both,B)
         Y -= 1
   return ans


def modelAnswer():
   tmp=1
def main():
   A,B,C,X,Y=map(int,input().split())
   print(myAnswer(A,B,C,X,Y))
if __name__ == '__main__':
   main()

Measured memory_bytes: 38896
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include<sstream>
#include <vector>
#include<queue>
#include <set>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;

int N, M;


 
bool visited[100005];
queue<int> q;
vector<int> v[100005];
int32_t  main() {

	IOS;

	

	cin >> N >> M;
	 
	bool flag = false;
	for (int i = 0; i < M; i++) {

		int r1, r2;

		cin >> r1 >> r2;

		v[r1].push_back(r2);

		v[r2].push_back(r1);

		if (r1 == 1 || r2 == 1)
			flag = true;

	}

	if (!flag) {
		cout << "No" << endl;
	}
	else {

		vector<int> ans(N+1);

		q.push(1);


		while (q.size()) {

			int tmp = q.front();
			q.pop();

			if (!visited[tmp]) {

				visited[tmp] = true;

				for (int i : v[tmp]) {

					q.push(i);
					if (ans[i] == 0) {
						ans[i] = tmp;
					}

				}

			}

		}
		cout << "Yes" << endl;

		for (int i = 2; i <= N; i++) {

			cout << ans[i] << endl;
		}

	}

 

}


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

int main(){
    vector<bool> prm(1e6,true);
    prm[0] = prm[1] = 0;
    for(int i=2; i<=1e3; i++){
        if(prm[i]){
            for(int j=2; i*j<1e6; j++){
                prm[i*j] = false;
            }
        }
    }
    
    while(1){
        int a,d,n;
        cin >> a >> d >>n;
        if(a==0) break;
        
        int cnt=0;
        for(int i=0; a+i*d<1e6 ; i++){
            if(prm[a+i*d]) cnt++;
            if(cnt == n){
                cout << a+i*d << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3124
"use strict";
const Main = (input) => {
	let xs = input.trim().split('').sort();
    //console.log(xs);
    let ans ='';
    for(let i =0; i < xs.length; i++){
      if(xs[i]==xs[i+1]){
      ans="no";
      break;
      }else{
      ans="yes";  
      }
    }
     console.log(ans);
  }
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
N, M = map(int, input().split())
S = input()
T = input()
s = len(S)
t = len(T)


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


st = gcd(s, t)
good = s * t // st

if S[::s // st] == T[::t // st]:
    print(good)
else:
    print(-1)

Measured memory_bytes: 3316
import java.util.*;
import java.io.*;

class Main {
  public static void main(String[] args) throws Exception{
    try (Scanner sc = new Scanner(System.in)){
      int N = sc.nextInt();
      int T = sc.nextInt();
      int cost = 1200;
      for (int i = 0; i < N; i++) {
        int c = sc.nextInt();
        int t = sc.nextInt();
        if (t <= T && cost > c) {
          cost = c;
        }
      }
      if (cost == 1200) {
        System.out.println("TLE");
      } else {
        System.out.println(cost);
      }
    }
  }
}


Measured memory_bytes: 23892
a = list(map(int, input().split()))
y = [list(input()) for i in range(a[0])]
for d in range(a[0]):
    for s in range(a[1]):
        if y[d][s] == ".":
            y[d][s] = "0"
for i in range(a[0]):
    for j in range(a[1]):
        if y[i][j] == "#":
            for k in range(3):
                for l in range(3):
                    if a[0] - 1 >= i - 1 + k >= 0 and a[1] - 1 >= j - 1 + l >= 0:
                        if y[i - 1 + k][j - 1 + l] == "0":
                            y[i - 1 + k][j - 1 + l] = 1
                        elif y[i - 1 + k][j - 1 + l] == "#":
                            pass
                        else:
                            y[i - 1 + k][j - 1 + l] += 1
for b in range(a[0]):
     y[b] = [str(f) for f in y[b]]
     print(''.join(y[b]))


Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)

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

    int A[N];
    REP(i, N) {
        scanf("%d", &A[i]);
    }

    sort(A, A + N);

    int cnt = 0;
    REP(i, N) {
        if (A[i] == A[i + 1]) {
            i++;
        } else {
            cnt++;
        }
    }

    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 512
import numpy as np

a = int(input())

if(a >= 400 and a < 600):
  out = 8
elif(a >= 600 and a < 800):
  out = 7
elif(a >= 800 and a < 1000):
  out = 6
elif(a >= 1000 and a < 1200):
  out = 5
elif(a >= 1200 and a < 1400):
  out = 4
elif(a >= 1400 and a < 1600):
  out = 3
elif(a >= 1600 and a < 1800):
  out = 2
elif(a >= 1800 and a < 2000):
  out = 1
print(out)

Measured memory_bytes: 27148
#17D8104010B 宮本拓輝 再提出10/31 Prolem D AOJ0655 Japan Sinks python3


import sys


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

if max(A)==0:
  print(0)
  sys.exit()

A.insert(0,0)
A.append(0)

top_valley=[] #[i][0]に標高,[i][1]は1なら頂点,0なら谷
up_down=True #登りならTrue,下りならfalse

for i in range(1,len(A)-1):
  #頂点
  if up_down==True:
    if A[i]>A[i+1]:
      top_valley.append([A[i],1])
      up_down=False
  #谷
  elif up_down==False:
    if A[i]<A[i+1]:
      top_valley.append([A[i],0])
      up_down=True


top_valley.sort()


cnt=1
max_cnt=1
for i in range(len(top_valley)-1):
  if top_valley[i][1]==1:
    cnt-=1
  elif top_valley[i][1]==0:
    cnt+=1

  if top_valley[i][0]<top_valley[i+1][0]:
    max_cnt=max(max_cnt,cnt)

print(max_cnt)

"""
6
3 2 3 0 2 0
2
"""


Measured memory_bytes: 16684