akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-


def main():
    from itertools import accumulate

    n, m = map(int, input().split())
    imos = [0 for _ in range(n + 1)]

    for i in range(m):
        li, ri = map(int, input().split())
        imos[li - 1] += 1
        imos[ri] += -1

    count = 0

    for i in list(accumulate(imos)):
        if i >= m:
            count += 1

    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8104
/*--------------------------------
  Author: The Ace Bee
  Blog: www.cnblogs.com/zsbzsb
  This code is made by The Ace Bee
--------------------------------*/
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <map>
#define rg register
using namespace std;
template < typename T > inline void read(T& s) {
	s = 0; int f = 0; char c = getchar();
	while (!isdigit(c)) f |= (c == '-'), c = getchar();
	while (isdigit(c)) s = s * 10 + (c ^ 48), c = getchar();
	s = f ? -s : s;
}

typedef long long LL;
typedef pair < int, int > pii;
const int _ = 100010;

int n, m, k; LL ans[11];
map < pii, int > _map;
struct node{ int x, y; }a[_];

inline bool cmp(const node& n, const node& m)
{ return n.x == m.x ? n.y < m.y : n.x < m.x; }

int main() {
	read(n), read(m), read(k);
	for (rg int i = 1; i <= k; ++i)
		read(a[i].x), read(a[i].y);
	
	ans[0] = max(0ll, 1ll * (n - 2) * (m - 2));
	
	sort(a + 1, a + k + 1, cmp);
	/*
	for (rg int i = 1; i <= k; ++i)
		printf("%d %d\n", a[i].x, a[i].y);
//	*/
	pii p;
	for (rg int i = 1; i <= k; ++i)
		for (rg int x = max(1, a[i].x - 2); x <= min(n - 2, a[i].x); ++x)
			for (rg int y = max(1, a[i].y - 2); y <= min(a[i].y, m - 2); ++y)
				p = make_pair(x, y), --ans[_map[p]], ++_map[p], ++ans[_map[p]];
	
	for (rg int j = 0; j < 10; ++j) printf("%lld\n", ans[j]);
	
	return 0;
}


Measured memory_bytes: 57216
W, H, x, y, r = map(int, input().split())

delta = [[r, 0], [-r, 0], [0, r], [0, -r]]

for dx, dy in delta:
    if 0 <= x + dx <= W and 0 <= y + dy <= H:
        pass
    else:
        print('No')
        exit(0)

print('Yes')


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define rep(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define drep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define MAGICLINE ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define se second
#define fs first
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, int> PLI;
typedef priority_queue<int> PQI;
typedef priority_queue<LL> PQL;
typedef priority_queue<PLI,
                       vector<PLI>,
                       greater<PLI> > dijQ;

const int MN = 100002;
bool T[MN];
vector<int> inp;

int main(){
  MAGICLINE;
  int n, k; scanf("%d %d", &n, &k);
  rep(i, 0, n){
    int a; scanf("%d", &a);
    inp.pb(a);
  }
  rep(i, 1, k+1){
    bool a = true;
    rep(j, 0, n){
      if(i - inp[j] < 0) continue;
      a &= T[i - inp[j]];
    }
    T[i] = (a ^ 1);
  }

  if(!T[k]) return !printf("Second\n");
  else return !printf("First\n");
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int sx,sy,tx,ty;
  cin >> sx>>sy>>tx>>ty;
  int dx=tx-sx;
  int dy=ty-sy;
  for(int i=0;i<dy;i++){
    cout << "U";
  }
  for(int i=0;i<dx;i++){
    cout << "R";
  }
  for(int i=0;i<dy;i++){
    cout << "D";
  }
  for(int i=0;i<dx;i++){
    cout << "L";
  }
  cout << "L";
  for(int i=0;i<dy+1;i++){
    cout <<"U";
  }
  for(int i=0;i<dx+1;i++){
    cout << "R";
  }
  cout << "D";
  cout << "R";
  for(int i=0;i<dy+1;i++){
    cout << "D";
  }
  for(int i=0;i<dx+1;i++){
    cout << "L";
  }
  cout <<"U";
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
lst = [input() for i in range(n)]

count = Counter(lst)
m = max(count.values())

ans = []
for k, v in count.items():
  if v == m:
    ans.append(k)

ans.sort()

for i in range(len(ans)):
  print(ans[i])

Measured memory_bytes: 100668
#include <iostream>
using namespace std;
int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int a_b = a*x + b*y;
  int c_a_b = (y > x) ? (y-x)*b + x*c*2 : (x-y)*a + y*c*2;
  int c_o = (x > y) ? x*c*2 : y*c*2;
  cout << min(min(a_b, c_a_b), c_o) << endl;
}
    

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
	static int n;
	static int X;
	static int[] x;

	static void Main(){
		string[] input = Console.ReadLine().Split();
		n = int.Parse(input[0]);
		X = int.Parse(input[1]);
		x = Console.ReadLine().Split().Select(int.Parse).ToArray();

		if (n == 1){
			Console.WriteLine(Abs(X - x[0]));
			return;
		}

		int min = Min(x.Min(),X);
		List<int> dis = new List<int>();
		foreach (var xi in x) if (xi != min) dis.Add(xi - min);
		if (X != min) dis.Add(X - min);

		Console.WriteLine(GCD(dis.ToArray()));
	}

	public static int GCD(int a, int b) //最大公約数の計算
    {
        return a > b ? GcdRecursive(a, b) : GcdRecursive(b, a);
    }

    private static int GcdRecursive(int a, int b)
    {
        return b == 0 ? a : GcdRecursive(b, a % b);
    }

    public static int GCD(params int[] nums) //最大公約数の計算
    {
        int n = nums.Length;
        int ans = GCD(nums[0], nums[1]);
        for (int i = 2; i < n; i++)
            ans = GCD(ans, nums[i]);
        return ans;
    }
}

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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

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

struct edge {
    ll to, cost;
};

int main() {
    ll dist[limit];
    ll n;
    cin >> n;

    vector<edge> E[n + 1];

    rep(i, n - 1) {
        ll a, b, c;
        cin >> a >> b >> c;
        E[a].push_back({b, c});
        E[b].push_back({a, c});
    }

    ll q, k;
    cin >> q >> k;

    dist[k] = 0;
    bool used[n + 1] = {};
    used[k] = true;

    queue<ll> que;
    que.push(k);

    while (!que.empty()) {
        ll q = que.front();
        for (auto e : E[q]) {
            if (!used[e.to]) {
                used[e.to] = true;
                dist[e.to] = dist[q] + e.cost;
                que.push(e.to);
            }
        }
        que.pop();
    }

    rep(i, q) {
        ll x, y;
        cin >> x >> y;
        cout << dist[x] + dist[y] << endl;
    }

    return 0;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int[] x=new int[3];
		x[0]=sc.nextInt();
		x[1]=sc.nextInt();
		x[2]=sc.nextInt();
		Arrays.sort(x);
		if(x[0]==x[1]&&x[1]!=x[2]||x[1]==x[2]&&x[1]!=x[0])
			pw.println("Yes");
		else
			pw.println("No");
		pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}

Measured memory_bytes: 22740
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<bitset>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int inf=10000007;
int x[20][20];

int main(){
  int n;cin>>n;
  vector<int> a(n);
rep(i,20){
  rep(j,20)x[i][j]=inf;
}
int bufx,bufy;
rep(i,n){
  cin>>a[i];
  rep(j,a[i]){
    cin>>bufx>>bufy;
    x[i][bufx]=bufy;
  }
}
int max=0;
for(int bit=0;bit<(1<<n);++bit){
  vector<int> buf(n+1,inf);
  bool memo=true;
  int num=0;
  for(int i=0;i<n;i++){
    if(bit &(1<<i)){
      num++;
      rep1(j,n){
        if(buf[j]!=inf&&x[i][j]!=inf){
          if(buf[j]!=x[i][j]){
            memo=false;
            goto next;
          }
        }
          if(x[i][j]==1){
            if(!(bit &(1<<j-1))){
            memo=false;
            goto next;
            }
          }
          if(x[i][j]==0){
            if((bit &(1<<j-1))){
            memo=false;
            goto next;
            }
          }
        if(x[i][j]!=inf)buf[j]=x[i][j];
      }
    }
  }
  if(memo){
    if(max<num)max=num;
  }
  next:;
}
cout<<max<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
 
  int d[6],i,blank;
  char ENSW[100];
 
  for(i = 0; i < 6; i++){
 
    scanf("%d",&d[i]);
 
  }
 
  scanf("%s",ENSW);
   
  for(i = 0; ENSW[i] != '\0'; i++){
 
    if(ENSW[i] == 'N'){
 
      blank=d[0];
      d[0]=d[1];
      d[1]=d[5];
      d[5]=d[4];
      d[4]=blank;
 
    }
 
    if(ENSW[i] == 'E'){
 
      blank=d[0];
      d[0]=d[3];
      d[3]=d[5];
      d[5]=d[2];
      d[2]=blank;
 
    }
 
    if(ENSW[i] == 'S'){
 
      blank=d[0];
      d[0]=d[4];
      d[4]=d[5];
      d[5]=d[1];
      d[1]=blank;
 
    }
 
    if(ENSW[i] == 'W'){
 
      blank=d[0];
      d[0]=d[2];
      d[2]=d[5];
      d[5]=d[3];
      d[3]=blank;
 
    }
 
  }
   
  printf("%d\n",d[0]);
 
  return 0;
 
}


Measured memory_bytes: 2140
#include<iostream>

using namespace std;

int main(){
	
	int num;
	int res = 0;
	cin >> num;
	for(int a=1;a<=num;a++){
		for(int b=1;b<=num;b++){
			for(int c=1;c<=num;c++){
				res++;
			}
		}
	}
	
	cout << res;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<long long >size;
    UnionFind(int N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
            par[i] = i;
            size[i]=1;
        } 
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        size[ry]+=size[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    void zero(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
        }
        return;
    }
    bool all_same(int n){
        int g=root(0);
        rep2(i,n-1){
            if(root(i)!=g){
                return false;
            }
        }
        return true;
    }
    long long  get_size(int x){
        int rx=root(x);
        return size[rx];
    }
};
long long cnt(long long a){
    return (a*(a-1))/2;
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>>bridge(m);
    UnionFind uf(n);

    rep(i,m){
    int a,b;
    cin>>a>>b;
    a--,b--;
    //uf.unite(a,b);
    bridge[i]=make_pair(a,b);
    }
    long long ans[m+1];
    long long now=cnt(n);
    ans[m]=now;

    for(int i=m-1;i>-1;i--){
        int a=bridge[i].first;
        int b=bridge[i].second;
            if(uf.same(a,b)){
            ans[i]=ans[i+1];
            //uf.unite(a,b);
            continue;
            }
        //cout<<uf.get_size(a)<<" "<<uf.get_size(b)<<" ";
        ans[i]=ans[i+1]-uf.get_size(a)*uf.get_size(b);
        //cout<<ans[i]<<"\n";
        uf.unite(a,b);
        
    }
    rep2(i,m)cout<<ans[i]<<"\n";
    
    return 0;

}
/*


*/


Measured memory_bytes: 4096
use std::io;
use std::str::FromStr;

static MOD: u64 = 1_000_000_007;

fn input_tuple() -> (u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn binary_power(x: u64, n: u64) -> u64 {
    if n == 0 {
      return 1;
    }
    if n % 2 == 0 {
      return (binary_power(x, n / 2) % MOD).pow(2) % MOD;
    } else {
      return binary_power(x, n - 1) % MOD * x % MOD;
    }
}
  
fn inverse_mod(n: u64) -> u64 {
    binary_power(n, MOD-2)
}  

fn combination(n: u64, mut m: u64) -> u64 {
    if n < m {
        return 0;
    }
    
    if m > n - m {
        m = n - m
    }

    let mut ret = 1u64;
    for i in 0..m {
        ret %= MOD;
        ret *= n - i;        
    }
    ret %= MOD;

    let mut div = 1u64;
    for i in 1..(m+1) {
        div %= MOD;
        div *= i;
    }
    div %= MOD;

    // println!("{}, {}", ret, div);
    ret * inverse_mod(div) % MOD
}

fn main() {
    let (n, a, b) = input_tuple();
    let mut sum = binary_power(2, n) - 1;
    sum += MOD - combination(n, a);
    sum %= MOD;
    sum += MOD - combination(n, b);
    sum %= MOD;
    println!("{}", sum % MOD);
}


Measured memory_bytes: 4352
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

#define HONEST 'H'
#define LIAR 'D'

int main(void)
{
	int W, a, b;
	cin >> W >> a >> b;

	if(a > b)
		swap(a, b);

	int ret = b - (a+W);
	ret = max(0, ret);

	cout << ret << endl;

	return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong N;
  vector<string> S;
  map<string, int> m;

  cin >> N;
  S.resize(N);
  for (auto &in: S) {
    cin >> in;
    ++m[in];
  }

  map<int, set<string>> ans;
  for (auto &res: m) {
    ans[res.second].insert(res.first);
  }

    for (auto &out: (--ans.end())->second) {
      cout << out << endl;
    }

  return 0;
}

Measured memory_bytes: 36096
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf")] * N
dp[0] = 0


for i in range(N):
    for j in range(1, K + 1):
        if i + j >= N:
            break
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))

print(dp[-1])

Measured memory_bytes: 85640
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int a[5000][5000],dp[5000][5000];
const int  N=1000000007;
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    char x;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            cin>>x;
            if(x=='.')
            {
                a[i][j]=0;
            }
            if(x=='#')
            {
                a[i][j]=1;
            }
        }
    }
    dp[1][1]=1;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {

            if(i==1 &&j==1)
            {
                continue;
            }
            if(a[i][j]==1)
            {
                dp[i][j]=0;
            }
            else
            {
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                dp[i][j]=dp[i][j]%N;
            }
        }
    }
    cout<<dp[n][m]<<endl;
    return 0;
}


Measured memory_bytes: 80768
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意
int main(){
  long a; cin>>a;
  
  //string s; cin>>s;
  cout<<(a>=30?"Yes":"No") <<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

template<typename T>
struct LazySegmentTree{
    vector<T> data;
    vector<T> lazy;
    int sz;

    LazySegmentTree(int n){
        sz = 1;
        while(sz < n)   sz <<= 1;
        data.assign(sz << 1, 0LL);
        lazy.assign(sz << 1, 0LL);
    }

    void set(int k, T x) { data[sz + k] = x; }
    void build(){
        for(int k = sz - 1; k >= 0; --k){
            data[k] = data[k << 1] + data[k << 1 | 1];
        }
    }

    void propagate(int k, int len){
        if(lazy[k] == 0)    return;
        data[k] += lazy[k] * len;
        if(k < sz){
            lazy[k << 1] += lazy[k];
            lazy[k << 1 | 1] += lazy[k];
        }
        lazy[k] = 0;
        return;
    }

    T update(int a, int b, const T& x, int k = 1, int l = 0, int r = -1){
        if(r == -1) r = sz;
        propagate(k, r - l);
        if(b <= l || r <= a)    return data[k];
        else if(a <= l && r <= b){
            lazy[k] += x;
            propagate(k, r - l);
            return data[k];
        }
        else{
            return data[k] = update(a, b, x, k << 1, l, (l + r) >> 1) + update(a, b, x, k << 1 | 1, (l + r) >> 1, r);
        }
    }

    T query(int a, int b, int k = 1, int l = 0, int r = -1){
        if(r == -1) r = sz;
        propagate(k, r - l);
        if(b <= l || r <= a)    return 0;
        else if(a <= l && r <= b)   return data[k];
        else{
            return query(a, b, k << 1, l, (l + r) >> 1) + query(a, b, k << 1 | 1, (l + r) >> 1, r);
        }
    }

    T operator[](const int& k){
        return query(k, k + 1);
    }
};

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

    int n, q;
    cin >> n >> q;
    LazySegmentTree<ll> seg(n);
    for(int i = 0; i < q; ++i){
        int com;
        cin >> com;
        if(!com){
            int s, t, x;
            cin >> s >> t >> x;
            --s;
            seg.update(s, t, x);
        }
        else{
            int i;
            cin >> i;
            --i;
            cout << seg[i] << '\n';
        }
    }
}


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

int main(){
  long long n;  
  cin >> n;
  vector<long long> a(n);
  vector<long long> b(n); 
  long long p=0;
  
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    a.at(i)--; 
  }
  for(int i=0;i<n;i++){
    b.at(a.at(i))++;
  }
  for(int i=0;i<n;i++){
    p += b.at(i) * (b.at(i) - 1) / 2;
  }
  vector<long long> ans(n);  
  for(int i=0;i<n;i++){
    ans.at(i) = p - b.at(a.at(i)) + 1;
    cout << ans.at(i) << endl;
  }
}

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

#define int long long

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999

using namespace std;

int32_t main(){
    int n;
    string s;
    cin >> n >> s;

    vector<int> v(n, 0);
    int cnt=0;
    REP(i, n){
        v[i]+=cnt;
        if(s[i]=='E'){
            cnt++;
        }
    }
    cnt=0;
    REP(i, n){
        v[n-i-1]+=cnt;
        if(s[n-i-1]=='W'){
            cnt++;
        }
    }

    int m=-1;
    REP(i, n){
        m=max(m, v[i]);
    }

    cout << n-m-1 << endl;
}

Measured memory_bytes: 3076
#include<stdio.h>
#define MAX 25
#define NIL -1
struct Node_struct{int p,l,r,sib;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];
int deg[MAX];
int H[MAX];

void print(int u){
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",u,T[u].p,T[u].sib,deg[u],D[u],H[u]);

  if(D[u]==0)printf("root");
  else if(T[u].l==NIL && T[u].r==NIL)printf("leaf");
  else printf("internal node");
  
  printf("\n");
  
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].r!=NIL)calcDepth(T[u].r,p+1);
  if(T[u].l!=NIL)calcDepth(T[u].l,p+1);
}

void calcHeight(int u){
  if(T[u].l==NIL && T[u].r==NIL){H[u]=0;return;}

  if(T[u].l!=NIL)calcHeight(T[u].l);
  if(T[u].r!=NIL)calcHeight(T[u].r);
  
  if(H[T[u].l]<H[T[u].r])H[u]=H[T[u].r]+1;
  else H[u]=H[T[u].l]+1;
  return;
}

int main(){
  int i,j;
  int n;
  int id,child;
  int root=NIL;
  scanf("%d", &n);
  for(i=0;i<n;i++)T[i].p=T[i].l=T[i].r=T[i].sib=NIL;
  
  for(i=0; i<n; i++){
    scanf("%d", &id);
    for(j=0;j<2;j++){ //子を入力する (input children)
      scanf("%d", &child);
      if(child!=NIL)deg[id]++;
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else T[id].r = child; //左の兄弟に繋げる (connect to left sibling)
      if(deg[id]==2)T[T[id].l].sib=child,T[T[id].r].sib=T[id].l;
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
  
  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  calcHeight(root);

  //出力 (output)
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 2108
def prob_B():
    N, D = map(int, input().split())

    count = 0

    try:
        while True:
            X, Y = map(int, input().split())

            if (X**2 + Y**2) <= D**2:
                count += 1

    except EOFError:

        print(count)


def main():
    prob_B()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int x,y;
  cin>>x>>y;
  for (int i = 0; i <= x; ++i)
  {
    if(i*2+(x-i)*4==y)
    {
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n, uni=0;
	cin >> n;
	map<int, int> t;
	rep(i,n){
		int a; cin >> a;
		if(a>=1 && a<=399) t[1]++;
		else if(a>=400 && a<=799) t[2]++;
		else if(a>=800 && a<=1199) t[3]++;
		else if(a>=1200 && a<=1599) t[4]++;
		else if(a>=1600 && a<=1999) t[5]++;
		else if(a>=2000 && a<=2399) t[6]++;
		else if(a>=2400 && a<=2799) t[7]++;
		else if(a>=2800 && a<=3199) t[8]++;
		else uni++;
	}
	int ans=0, m, b;
	for(auto x : t){
		if(x.second > 0) ans++;
	}
	if(ans == 0) m = 1;
	else m = ans;
	b = ans+uni;
	cout << m << " " << b << endl;
	return 0;
}

Measured memory_bytes: 3552
import java.math.*;
import java.util.*;


public class Main {

    public static void main(String args[]){
        Scanner scan =new Scanner(System.in);
        HashSet<String> items =new HashSet<String>();
        int N =scan.nextInt();
        int i=0;
        while(N-->0) {
            String s=scan.next();
        if(items.contains(s)){
            continue;
        }
        else {
            items.add(s);
            i++;
        }
        }
        System.out.println(i);
    }

}


Measured memory_bytes: 77268
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    if (s.size()<=n)cout << s;
    else 
    {
        for (int i=0;i<n;i++)
        {
            cout << s[i];
        }
        cout << "...";
    }
    
    return 0;
}


Measured memory_bytes: 3616
/*================================================================
Love China, Love YALI, Love OI!
*   
*   File Name：C.cpp
*   Author：YaliKiWi
*   Date：2019年09月15日
*   Discribe：
*
================================================================*/


#include<bits/stdc++.h>
using namespace std;
#define fo(i,s,e) for(register int i=s;i<=e;i++)
#define max_(x,y) ((x)>(y)?(x):(y))
#define min_(x,y) ((x)<(y)?(x):(y))
#define dd double
#define ull unsigned long long
#define ll long long
#define maxn 100000+10
int a[maxn],n,k,q;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>k>>q;
	fo(i,1,q){
		int x;
		cin>>x;
		a[x]++;
	}
	fo(i,1,n){
		if(q-a[i]<k){
			cout<<"Yes"<<endl;
		}
		else {
			cout<<"No"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<vector<int>> game(N, vector<int>(N - 1));
  for (int i = 0; i < N; i++) {
    for (auto &v : game[i]) {
      cin >> v;
      v--;  // i -> i-1
    }
    reverse(game[i].begin(), game[i].end());
  }

  vector<pair<int, int>> que;
  auto check = [&](int i) {
    if (game[i].size() == 0) return;
    int j = game[i].back();
    if (game[j].size() == 0) return;
    if (game[j].back() == i) {
      pair<int, int> p(i, j);
      if (p.second < p.first) swap(p.first, p.second);
      que.push_back(p);
    }
  };

  for (int i = 0; i < N; i++) {
    check(i);
  }

  int day = 0;
  while (que.size() > 0) {
    day++;
    sort(que.begin(), que.end());
    que.erase(unique(que.begin(), que.end()), que.end());
    vector<pair<int, int>> prevQ;
    swap(prevQ, que);
    for (auto &p : prevQ) {
      int i = p.first, j = p.second;
      game[i].pop_back();
      game[j].pop_back();
    }
    for (auto &p : prevQ) {
      int i = p.first, j = p.second;
      check(i);
      check(j);
    }
  }
  for (int i = 0; i < N; i++) {
    if (game[i].size() != 0) {
      puts("-1");
      return 0;
    }
  }
  cout << day << endl;
  return 0;
}


Measured memory_bytes: 4224
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

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

//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;
//	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	shuffle(permutation.begin(), permutation.end(), rng);



int main () {
	scanf("%d%d", &n, &m);
	cout << n * (n-1)/2ll + m * (m-1)/2ll << '\n';
	return Accepted;
}

// B...a

Measured memory_bytes: 18688
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int c[100005] = {};

    rep(i, n)
    {
        cin >> a[i];
        c[a[i]]++;
    }

    // int min = *min_element(a.begin(), a.end());
    // int max = *max_element(a.begin(), a.end());
    int cnt;
    int ans = 1;
    for (int x = 1; x < 100000; x++)
    {
        cnt = c[x - 1] + c[x] + c[x + 1];
        if (cnt > ans)
        {
            ans = cnt;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define tp(a, b, c) make_tuple(a, b, c)
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//
//-------------------関数----------------------//
int main() {
  ll cnt = 0;
  char a;
  REP(i, 3) {
    cin >> a;
    cnt += a - '0';
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f(int n)
{
    if(n % 2 == 0)
    {
       return n / 2;
    }
    else
    {
        return 3 * n + 1;
    }
}
int main()
{
    int s; cin >> s;
    vector<int> a(1000000);
    int i = 0;
    a.at(i) = s;
    int m = 0;
    while(m == 0)
    {
        a.at(i+1) = f(a.at(i));
        i++;
        for(int j = 0; j < i; j++)
        {
            if(a.at(i) == a.at(j))
            {
                m = i + 1;
                break;
            }
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 4096
arr = []
n = gets.to_i
n.times do
  input = gets.to_i
  arr << input
end
max = -2000000000000000
minv = arr[0]
(arr.length - 1).times do |i|
  i += 1
  max = arr[i] - minv if(arr[i] - minv > max)
  minv = arr[i] if(arr[i] < minv)
end
p max


Measured memory_bytes: 8548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    cout << (isupper(c)? 'A':'a') << "\n";
}

Measured memory_bytes: 3632
#include <iostream>
//#include <array>
#include <algorithm>
#include <vector>

int main() {
  unsigned int n;
  unsigned int k;
  std::cin >> n >> k;
  std::vector<int> counter(n, 0);
  for (unsigned int i = 0; i < n; i++) {
    unsigned int ai;
    std::cin >> ai;
    counter[ai - 1]++;
  }
  std::sort(counter.begin(), counter.end());

  //要素の中の0の数(j)を調べる
  unsigned int j = 0;
  for (unsigned int i = 0; i < n; i++) {
    if (counter[i] == 0) {
      j++;
    } else {
      break;
    }
  }

  //前から順番に消していく
  int result = 0;
  while (n - j > k) {
    result += counter[j];
    counter[j] = 0;
    j++;
  }
  std::cout << result << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
const ll MOD = 1000000007;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  ll tmp = (k * (k - 1) / 2) % MOD;
  for(int i = 0; i < n; i++){
    int f = 0, b = 0;
    for(int j = 0; j < i; j++){
        if(a[i] > a[j]) f++;
    }
    for(int j = i + 1; j < n; j++){
        if(a[i] > a[j]) b++;
    }
    ans = (ans + (b * k) + ((b + f) * tmp)) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func debug(a ...interface{}) {
	if os.Getenv("ONLINE_JUDGE") == "false" {
		fmt.Fprintln(os.Stderr, a...)
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1001), 1001001)

	n, k := scanInt(), scanInt()
	a := scanInts(n)
	ma := 0
	for i := 0; i < n; i++ {
		ma = max(ma, a[i])
	}

	sg := newSegmentTree(ma+1+k, 0, func(a, b node) node {
		if a > b {
			return a
		}
		return b
	})

	ans := 0
	for i := 0; i < n; i++ {
		l := max(a[i]-k, 0)
		r := min(a[i]+k, ma) + 1
		b := sg.query(l, r)
		sg.update(a[i], b+1)
		ans = max(ans, int(b)+1)
	}
	fmt.Fprintln(wr, ans)
}

type node int

type op func(a, b node) node
type segmentTree struct {
	d  []node
	n  int
	sz int
	e  node
	f  op
}

func newSegmentTree(n int, e node, f op) *segmentTree {
	sz := 1
	for sz < n {
		sz <<= 1
	}
	s := segmentTree{make([]node, 2*sz), n, sz, e, f}
	for i := 0; i < 2*sz; i++ {
		s.d[i] = e
	}
	return &s
}

func (s *segmentTree) set(i int, a node) {
	s.d[i+s.sz] = a
}

func (s *segmentTree) build() {
	for i := s.sz - 1; i > 0; i-- {
		s.d[i] = s.f(s.d[2*i], s.d[2*i+1])
	}
}

func (s *segmentTree) get(i int) node {
	return s.d[i+s.sz]
}

func (s *segmentTree) update(i int, a node) {
	i += s.sz
	s.d[i] = a
	for i >>= 1; i > 0; i >>= 1 {
		s.d[i] = s.f(s.d[2*i], s.d[2*i+1])
	}
}

func (s *segmentTree) query(l, r int) node {
	vl, vr := s.e, s.e
	l += s.sz
	r += s.sz
	for l < r {
		if l&1 == 1 {
			vl = s.f(vl, s.d[l])
			l++
		}
		if r&1 == 1 {
			r--
			vr = s.f(s.d[r], vr)
		}
		l >>= 1
		r >>= 1
	}
	return s.f(vl, vr)
}

func (s *segmentTree) maxRight(l int, f func(v node) bool) int {
	if l == s.n {
		return s.n
	}
	v := s.e
	l += s.sz

	for {
		for l&1 == 0 {
			l >>= 1
		}
		if !f(s.f(v, s.d[l])) {
			for l < s.sz {
				l <<= 1
				if f(s.f(v, s.d[l])) {
					v = s.f(v, s.d[l])
					l++
				}
			}
			return l - s.sz
		}
		v = s.f(v, s.d[l])
		l++
		if l&-l == l {
			break
		}
	}

	return s.n
}

func (s *segmentTree) minLeft(r int, f func(v node) bool) int {
	if r == 0 {
		return 0
	}
	v := s.e
	r += s.sz

	for {
		r--
		for r > 1 && r&1 == 1 {
			r >>= 1
		}
		if !f(s.f(v, s.d[r])) {
			for r < s.sz {
				r = r<<1 + 1
				if f(s.f(v, s.d[r])) {
					v = s.f(v, s.d[r])
					r--
				}
			}
			return r + 1 - s.sz
		}
		v = s.f(v, s.d[r])
		if r&-r == r {
			break
		}
	}

	return 0
}


Measured memory_bytes: 22904
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    for(ll i=1;i<=8;++i){
        if(X>=(10-i)*200&&X<(11-i)*200){
            prt(i);
            return 0;
        }
    }

    return 0;
}



Measured memory_bytes: 3648
s=input()+" "
box,add=[],[]
ans=[0]*(len(s)-1)
count,word=0,"R"
for i in range(len(s)):
    if s[i]==word:
        count +=1
    else:
        add.append(i)
        box.append(count)
        count=1
        word=s[i]
        
RL=[]
for i in range(0,len(box),2):
    R=0
    A,B=box[i],box[i+1]
    R +=(A+1)//2+B//2
    L=(A+B)-R
    RL.append((R,L))

j=0
for i in range(0,len(add),2):
    ans[add[i]-1],ans[add[i]]=RL[j][0],RL[j][1]
    j +=1

print(*ans)

Measured memory_bytes: 14620
program prob79
    implicit none
    integer :: a,b,ans
    read(*,*) a,b

    if(a >= b)then
        ans = a
        a = a - 1
    else
        ans = b
        b = b - 1
    end if
    ans = ans + max(a,b)
    write(*,*) ans

    stop
contains
end program prob79

Measured memory_bytes: 2776
def main():
    n,q=map(int,input().split())
    from collections import deque,defaultdict
    dic=defaultdict(list)
    for i in range(n-1):
        x,y=map(int,input().split())
        dic[x-1].append(y-1)
        dic[y-1].append(x-1)
    cnt=[0]*n
    for i in range(q):
        x,y=map(int,input().split())
        cnt[x-1]+=y
    
    d=deque()
    d.append(0)
    completed=[False]*n
    while d:
        now=d.popleft()
        completed[now]=True
        for x in dic[now]:
            if completed[x]==False:
                cnt[x]+=cnt[now]
                d.append(x)
    print(*cnt)

if __name__=="__main__":
    main()

Measured memory_bytes: 73204
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

int num_truck(const vector<int>& w, int P){
    int num = 1;
    int p = P;
    for (int i = 0; i < w.size(); i++) {
        if (w[i] > P) return -1; //??????????????´???
        if (p >= w[i]) {
            p -= w[i];
            continue;
        }
        num++;
        p = P - w[i];
    }
    return num;
}
int calc_P(const vector<int>& w, int k, int min, int max){
// cout << min << " " << max << endl;
    if (min > max) return min;
    int mid = (min + max) / 2;
    int num = num_truck(w, mid);
    if (num > k) return calc_P(w, k, mid + 1, max);
    if (num < k) return calc_P(w, k, min, mid - 1);
    if (num == num_truck(w, mid - 1)) return calc_P(w, k, min, mid - 1);
    return mid;
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> w(n);
    for (auto& i : w) cin >> i;
    int min_p = *max_element(w.begin(), w.end());
    int max_p = accumulate(w.begin(), w.end(), 0);
    cout << calc_P(w, k, min_p, max_p) << endl;
    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
 
using namespace std;
 
int V,E,L;
 
int const INF = 1<<28;
 
struct Edge {
  int src, dst, dist, ene;
};
 
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
Graph G;
 
struct State {
  int money, attacked, pos;
  bool operator < ( const State& s ) const {
    return attacked > s.attacked;
  }
};
 
 
int dijkstra(int st) {
   
  int dist[110][110]; // [node][money]
   
  fill(dist[0], dist[0]+110*110, INF);
  dist[st][L] = 0;
   
  priority_queue<State> pq;
  pq.push((State){L, 0, st});
  while(!pq.empty()) {
    const State stt = pq.top(); pq.pop();
    if(stt.attacked>dist[stt.pos][stt.money])continue;
 
    for(int i=0; i<G[stt.pos].size(); i++) {
      int next = G[stt.pos][i].dst;
      int nmoney = stt.money-G[stt.pos][i].dist;
       
      if(nmoney < 0) continue;
      if(dist[next][nmoney] > stt.attacked) {
	dist[next][nmoney] = stt.attacked;
	pq.push((State){nmoney, stt.attacked, next});
      }
    }
 
    for(int i=0; i<G[stt.pos].size(); i++) {
      int next = G[stt.pos][i].dst;
      int nattacked = stt.attacked + G[stt.pos][i].ene;
      if(dist[next][stt.money] > nattacked) {
	dist[next][stt.money] = nattacked;
	pq.push((State){stt.money, nattacked, next});
      }
    }
  }
   
  int mn = INF;
  for(int i=0; i<=L; i++) {
    mn = min(mn, dist[V-1][i]);
  }
   
  return mn;
}
 
int main(){
   
  while(cin >> V >> E >> L && (V|E|L)) {
    G.resize(V);
    for(int i=0; i<V; i++) {
      G[i].clear();
    }
    for(int i=0; i<E; i++) {
      int a, b, d, e;
      cin >> a >> b >> d >> e; a--, b--;
      G[a].push_back((Edge){a, b, d, e});
      G[b].push_back((Edge){b, a, d, e});
    }
     
    cout << dijkstra(0) << endl;
  }
  return 0;
}

Measured memory_bytes: 1800
N = int(input())
A = []
for i in range(N):
	tem_data = input().split()
	A.append([tem_data[0] , int(tem_data[1]) , i+1])
A = sorted(A , key = lambda x: (x[0] , -x[1]))
for name , score  , number in A:
	print(number)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>u,w;
set<LL>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n;
    l=0;
    for(i=0; i<n; i++)
    {
          cin>>o;
          if(o<400)
          {
              v.IN(1);
          }
          else if(o<800)
          {
               v.IN(2);
          }
          else if(o<1200)
          {
              v.IN(3);
          }
          else if(o<1600)
          {
              v.IN(4);
          }
          else if(o<2000)
          {
              v.IN(5);
          }
          else if(o<2400)
          {
              v.IN(6);
          }
          else if(o<2800)
          {
              v.IN(7);
          }
          else if(o<3200)
          {
              v.IN(8);
          }
          else
          {
              l++;
          }
    }
    if(l==n)
    {
        cout<<1<<" "<<l<<endl;
    }
    else{cout<<v.SZ<<" "<<v.SZ+l<<endl;}

    return 0;

}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	int N, A;
	cin >> N >> A;
	vi x(N);
	int X = A;
	REP(i, N) {
		cin >> x[i];
		X = max(X, x[i]);
	}

	vector<vvl> dp(N+1, vvl(N+1, vl(N*X+1, 0)));
	dp[0][0][0] = 1;
	FOR(i, 1, N) {
		FOR(j, 0, N) {
			FOR(k, 0, N*X) {
				if (k < x[i-1]) {
					dp[i][j][k] = dp[i-1][j][k];
				}
				else if(j >= 1) {
					dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]];
				}
			}
		}
	}

	ll ans = 0;
	FOR(i, 1, N) {
		ans += dp[N][i][i*A];
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int x;
  cin >> x;
  if (x<1200) {
    cout << "ABC" << endl;
  }
  else {
    cout << "ARC" << endl;
  }
}


Measured memory_bytes: 3592
#include <stdio.h>
int main(){
    int n, m,i;
    long long int x,y,z;
    long long int sum[4001];
    int q, a[4000];
    while(1){
        scanf("%d ", &n);
        if(n==0) break; 
        m=0;
        q=0;
        for(i=1;i<4001;i++){
            sum[i]=0;
        }
        while(n--){
            scanf("%lld %lld %lld ", &x, &y, &z);
            sum[x] += y *z;
            a[q] = x;
            q++;
        }        
        for(i=0;i<q;i++)
            if(1000000 <= sum[a[i]]){
                printf("%d\n", a[i]);
                m = 1;
                sum[a[i]] = 0;
            }
            if(m==0) printf("NA\n");
    }
    return 0;
} 

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

const int N = 1e5 + 5;
const ll Mx = 1e10;

int prime[N], b[N], totnum = 0, tot = 0;
ll dprime[N];

ll Pow(ll x) {
	return 1ll * x * x * x;
}

void Pre() {
	for (int i = 2; i <= 2200; ++ i) {
		if (! b[i]) prime[++ totnum] = i;
		for (int j = 1; j <= totnum && i * prime[j] <= 2200; ++ j) {
			b[prime[j] * i] = 1;
			if (i % prime[j] == 0) break;
		}
	}
	tot = 0;
	for (int i = 1; i <= totnum; ++ i) {
		ll val = Pow(prime[i]);
		if (val > Mx) break;
		dprime[++ tot] = val;
	}
}

int n; ll a[N];
map <ll, int> Mp;

inline ll f(ll x) {
	ll res = 1ll;
	for (int i = 1; i <= totnum; ++ i) {
		if (prime[i] > x) break;
		int t = 0;
		while (x % prime[i] == 0) x /= prime[i], ++ t;
		if (t == 1) res *= prime[i] * prime[i];
		else if (t == 2) res *= prime[i];
	}
	if (x == 1) return res;
	ll sqr = sqrt(x);
	if (sqr * sqr == x) return res * sqr;
	else if (res * x * x <= Mx) return res * x * x;
	else return -1;
}

int main(void) {
	Pre(); Mp.clear();
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) scanf("%lld", &a[i]);
	bool ok = false;
	for (int i = 1; i <= n; ++ i) {
		for (int j = 1; j <= tot && dprime[j] <= a[i]; ++ j) {
			while (a[i] % dprime[j] == 0) a[i] /= dprime[j];
		}
		if (a[i] == 1) ok = true; else ++ Mp[a[i]];
	}
	
	
//	for (int i = 1; i <= n; ++ i) printf("%d ", a[i]); puts("");
	sort(a + 1, a + 1 + n);
	int i = 1; while (a[i] == 1 && i <= n) ++ i;
	
	ll ans = 0;
	for (int last; (last = i) <= n; ++ i) {
		while (a[i] == a[i + 1]) ++ i;
		ll tar = f(a[i]);
		if (tar == -1) ans += i - last + 1;
		else if (tar < a[i] && (* lower_bound(a + 1, a + 1 + n, tar)) == tar) continue;
		else ans += max(i - last + 1, Mp[tar]);
//		printf("tar = %lld ans = %lld\n", tar, ans);
	}
	printf("%d\n", ans + ok);
	return 0;
}

Measured memory_bytes: 11264