akhauriyash/Code-Regression huggingface dataset:
//written by libra9z
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <numeric>
#include <memory>
#include <functional>
#include <stdexcept>
#include <typeinfo>
#include <limits>
#include <complex>
#include <locale>
using namespace std;
#define Debug(x) cerr << #x << " = " << x << endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl;
#define Debug2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n";
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl;
#define SET(p,v) fill((__typeof(**p)*)p,(__typeof(**p)*)p+sizeof(p),v);
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
#define all(s) s.begin(),s.end()
int main() {
	int n,m,k;
	cin>>n>>m>>k;
	for (int i=0;i<n;++i) for (int j=0;j<m;++j) {
		int ans=i+j+i*(m-1-j)+j*(n-1-i);
		if (ans==k) {
			cout<<"Yes\n";
			return 0;
		}
		ans=i+j+1+i*j+(n-1-i)*(m-1-j);
		if (ans==k) {
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        const string FirstString = "Case";
        const string Sepalate = ":";
        static void Main(string[] args)
        {
            var read = "";
            var count = 0;
            while (!string.IsNullOrEmpty(read = Console.ReadLine()))
            {
                if (read != "0")
                    Console.WriteLine($"{FirstString} {++count}{Sepalate} {read}");
            }
        }
    }
}



Measured memory_bytes: 17940
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << "\n"; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " <<to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve(){
  ll h;
  cin>>h;
  ll x=(ll)log2(h)+1;
  ll sum=0,pre=1;;
  for(ll i=0;i<x;++i){
    sum+=pre;
    pre*=2;
  }
  cout<<sum;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 384
#include <map>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main(void){
	long long N, M;
	cin >> N >> M;
	vector<pair<long long , long long>> store(N);

	for(int i = 0; i < N; i++){
		cin >> store[i].first >> store[i].second;
	}
	sort(store.begin(), store.end());
	long long need = 0;
	for(int i = 0; i < N; i++){
		if(store[i].second >= M){
			need += M*store[i].first;
			break;
		}else{
			need += store[i].second * store[i].first;
			M -= store[i].second;
		}
	}
	cout << need <<endl;
	return 0;
}


Measured memory_bytes: 1792
a, b = map(str, input().split())
aa = ""
bb = ""
for i in range(int(b)):
  aa += a
for j in range(int(a)):
  bb += b
if int(a) < int(b):
  print(aa)
elif int(b) < int(a):
  print(bb)
else:
  print(aa)

Measured memory_bytes: 3060
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 0, INF = 1e9;

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

int main() {
    ll n = read<ll>();
    cout << n * (n - 1) / 2 << endl;
    return 0;
}



Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  val Array(n, x) = StdIn.readLine().split(' ').map(_.toInt)
  var min = Int.MaxValue
  val sum = (0 until n).foldLeft(0){ (acc, _) => 
    val ig = StdIn.readLine().toInt
    min = if(ig <= min) ig else min
    acc + ig
  }
  
  println(n + ((x - sum) / min))
  
}

Measured memory_bytes: 25424
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
class Program
{
    static void Main(string[] args)
    {
        int[] n = Read.Ints();
        int[] a = new int[n[1]];
 
        for (int i = 0; i < n[1]; i++)
        {
            int[] s = Read.Ints();
            if (s[0] > s[1]) { s[0] = s[1]; }
            a[i] = s[1] - s[0];
        }
        Array.Sort(a);int ans = 0;
      for(int i = 0; i < n[1] - 1; i++)
        {
            ans += a[i];
        }Console.WriteLine(ans/2);Console.ReadLine();
    }
    public static Boolean uso() { return false; }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
 
        for (int i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
 
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] Ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 9868
import bisect
N = int(input())
A_list = [int(x) for x in input().split()]
plus_list = [int(x) - (i+1) for i, x in enumerate(A_list)]
minus_list = [int(x) + (i + 1) for i, x in enumerate(A_list)]
# print(plus_list)
# print(minus_list)
dic = {}
for i, p in enumerate(plus_list):
    j = i+1
    if p in dic.keys():
        dic[p].append(j)
    else:
        dic[p] = [j]  # already sorted

ans = 0
for i, m in enumerate(minus_list[:-1]):
    j = i + 1
    if - 1 * m not in dic.keys():
        continue
    candidates = dic[-1 * m]
    # print(candidates, j)
    # print(bisect.bisect_left(candidates, j))
    ans += len(candidates) - bisect.bisect_left(candidates, j)
print(ans)


Measured memory_bytes: 125952
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int D;
ll G;
vector<ll>p, c;
int main() {
	cin >> D >> G;
	p.resize(D); c.resize(D);
	for (int i = 0; i < D; ++i) {
		cin >> p[i] >> c[i];
	}
	ll res = 1 << 29;//全完する難易度帯を2^D通り固め打ちする
	for (int bit = 0; bit < (1 << D); ++bit) {
		ll sum = 0;
		ll num = 0;
		for (int i = 0; i < D; ++i) {
			if (bit & (1 << i)) {
				sum += c[i] + p[i] * 100 * (i + 1), num += p[i];
			}
		}
		if (sum >= G)res = min(res, num);
		else {
			for (int i = D - 1; i >= 0; --i) {
				if (bit&(1 << i))continue;
				for (int j = 0; j < p[i]; ++j) {
					if (sum >= G)break;
					sum += 100 * (i + 1);
					++num;
				}
			}
			res = min(res, num);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_9_B: Maximum Heap

#include <algorithm>
#include <cstdio>

class MaxHeap {
  int n_;
  int* data_;

public:
  MaxHeap(unsigned int n) : n_(n), data_(new int[n]) { }

  ~MaxHeap() { delete[] data_; }

  int& operator[](unsigned int i) { return data_[i]; }

  void build()
  {
    for (auto i = (n_/2)-1; i >= 0; --i) {
      max_heapify(i);
    }
  }

  void print() const
  {
    for (auto i = 0; i < n_; ++i) {
      std::printf(" %d", data_[i]);
    }
    std::printf("\n");
  }
  
private:
  void max_heapify(int i)
  {
    while (i < n_/2) {
      auto c = 2*i + 1; // left
      if (c+1 < n_ && data_[c] < data_[c+1]) {
        ++c; // right
      }
      if (data_[c] < data_[i]) {
        return;
      }
      std::swap(data_[c], data_[i]);
      i = c;
    }
  }
};

int main()
{
  int h;
  std::scanf("%d", &h);
  MaxHeap mh(h);
  for (auto i = 0; i < h; ++i) {
    std::scanf("%d", &mh[i]);
  }
  mh.build();
  mh.print();
}

// eof

Measured memory_bytes: 4144
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int n; cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; ++i) {
        if(i % 3 == 0 && i % 5 == 0);
        else if(i % 3 == 0);
        else if(i % 5 == 0);
        else ans += i;
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<ll> a(3 * N);

    rep(i, 3 * N) { cin >> a[i]; }
    sort(a.begin(), a.end());
    ll ans = 0;
    for (int i = N; i < 3 * N; i += 2) {
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>

using namespace std;

int main() {
	string s;
	cin>>s;
	vector<int> list(s.size());
	int k=0;

	for(int i=0; i<s.size(); i++){
		if(s.at(i)=='A' or s.at(i)=='T' or s.at(i)=='C' or s.at(i)=='G') list.at(k)+=1;
		else k+=1;
	}
	
	int answer=0;
	for(int i=0; i<list.size(); i++){
		if(list.at(i)>=answer) answer=list.at(i);
	}
	
	cout<<answer<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
public class Main {

  public static class Node {
    int key;
    Node left;
    Node right;
    Node p;
    public Node(int key) {
      this.key = key;
      this.left = null;
      this.right = null;
      this.p = null;
    }
  }

  public static class Tree {
    Node root;
    public Tree() {
      this.root = null;
    }
  }

  public static void insert(Tree T, Node z) {
    Node y = null;
    Node x = T.root;
    while (x != null) {
      y = x;
      if (z.key < x.key)
        x = x.left;
      else
        x = x.right;
    }
    z.p = y;

    if (y == null)
      T.root = z;
    else if (z.key < y.key)
      y.left = z;
    else
      y.right = z;
  }

  public static boolean find_helper(Node x, int k) {
    if (x == null)
      return false;
    if (x.key == k)
      return true;
    if (k <= x.key)
      return find_helper(x.left, k);
    else
      return find_helper(x.right, k);
  }

  public static String find(Node x, int k) {
    if (find_helper(x, k))
      return "yes";
    return "no";
  }

  public static String print_inorder(Node x) {
    String a = "";
    if (x != null) {
      a = a + print_inorder(x.left);
      a = a + " " + x.key;
      a = a + print_inorder(x.right);
    }
    return a;
  }

  public static String print_preorder(Node x) {
    String a = "";
    if (x != null) {
      a = a + " " + x.key;
      a = a + print_preorder(x.left);
      a = a + print_preorder(x.right);
    }
    return a;
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int m = s.nextInt();
    ArrayList<String> results = new ArrayList<String>();
    Tree T = new Tree();
    for (int i = 0; i < m; i++) {
      String cmd = s.next();
      switch(cmd) {
        case "insert":
          int key = s.nextInt();
          Node x = new Node(key);
          insert(T, x);
          break;
        case "find":
          int k = s.nextInt();
          results.add(find(T.root, k));
          break;
        case "print":
          results.add(print_inorder(T.root));
          results.add(print_preorder(T.root));
          break;
        default:
          break;
      }
    }
    s.close();
    for (String result : results) {
      System.out.println(result);
    }
  }
}



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

int x , y , a[100000] , dp[100000] ; 
int main () {
	
	cin >> x >> y ; 
	
	for ( int i = 0 ; i < x ; i++ ) {
		cin >> a[i] ;
	}
	
	for ( int i = 0 ; i < x ; i++ ) 
	dp[i] = INT_MAX ;
	
	dp[0] = 0 ;
	dp[1] = abs( a[1] - a[0] ) ; 
	
	for ( int  i = 2 ; i < x ; i++ ) {
		for ( int j = i - 1 , j2 = 0 ; j >= 0 && j2 < y ; j2++ , j-- ) {
			dp[i] = min ( dp[i] , dp[j] + abs( a[i] - a[j]) ) ;
		}
	}
	cout << dp[x-1] ;
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) { if (a < b) { return b; } return a; }

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

int main() {
    ll n; cin >> n;
    ll ans = (n%1000 == 0) ? 0 : 1000 - n%1000;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;


int main()
{

	ll N;
	cin >> N;

	vector<ll> L(N);
	rep(i, N)
	{
		cin >> L[i];
	}
	ll res = 0;
	sort(L.begin(), L.end());
	for (ll i = 0; i < N; i++)
	{
		ll k = i;
		for (ll j = i + 1; j < N; j++) {
			while (k < N && L[k] < L[i] + L[j]) ++k;
			res += k - (j + 1);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

inputs = raw_input().replace("\n", "")
H, W = map(int, inputs.split(" "))

lines = np.asarray([list(raw_input().replace("\n", "")) for h in xrange(H)])

h_indexs, w_indexs = map(set, np.where(lines == "#"))

outlines = lines[list(h_indexs), :][:, list(w_indexs)]
for outline in outlines:
    print "".join(outline)

Measured memory_bytes: 19308
while True:
    try:
        w = float(input())
        if w <= 48.0:
            print('light fly')

        elif w <= 51.0:
            print('fly')

        elif w <= 54.0:
            print('bantam')

        elif w <= 57.0:
            print('feather')

        elif w <= 60.0:
            print('light')

        elif w <= 64.0:
            print('light welter')

        elif w <= 69.0:
            print('welter')

        elif w <= 75.0:
            print('light middle')

        elif w <= 81.0:
            print('middle')

        elif w <= 91.0:
            print('light heavy')

        else:
            print('heavy')

    except EOFError:
        break


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

int main(){
  	string S;
  	int K;
  	cin >> S >> K;
  	for(int i = 0; i < S.size(); i++){
    	if(('{' - S[i]) % 26 <= K){
        	K -= ('{' - S[i]) % 26;
          	S[i] = 'a';
        }
    }
  	S.back() = (S.back() - 'a' + K) % 26 + 'a';
    cout << S << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n,m;
	cin >> n >> m;
	vector <int> c(m,0);
	vector <int> s(m,0);
	for (int i = 0 ; i < m; i++) {
		cin >> c[i] >> s[i];
	}

	for(int i = 0; i< 1000;i++) {
		int x = i /10;
		int keta = 1;
		vector <int> y (1, i % 10);
		while (x) {
			y.push_back(x % 10);
			x /= 10;
			keta++;
		}

		if (keta != n) continue;
		bool flag = true;
		reverse(y.begin(), y.end());
		for (int j = 0; j < m; j++) {
			if (y[c[j]-1] != s[j]) flag =false;
		}
		if (flag) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fin(x) scanf("%lld",&x)
#define fout(x) printf("%lld\n",x)
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
#define cases int t;  scanf("%d",&t);   while(t--)
#define MOD 1000000007
#define MAXN 123456
#define read() freopen("lele.txt","r",stdin)
#define write() freopen("dede.txt","w",stdout)

using namespace std;

int main()
{
    ll ans[4];
    ans[0] = 0;
    ans[1] = 0;
    ans[2] = 0;
    ans[3] = 0;
    ll a, b;
    fin(a); fin(b);
    ans[a]++;
    ans[b]++;
    for(ll i = 1; i <= 3; i++)
    {
        if(!ans[i])
            cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    int n, q;
    std::cin >> n >> q;

    std::vector<std::vector<int>> edges(n);
    std::vector<long long> values(n, 0);

    for (int i = 0; i < n - 1; i++) {
        int a, b;
        std::cin >> a >> b;
        a--;
        b--;

        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    for (int i = 0; i < q; i++) {
        int p, x;
        std::cin >> p >> x;
        p--;

        values[p] += x;
    }

    auto dfs = [&](auto f, int idx, int parent) -> void {
        for (auto edge : edges[idx]) {
            if (edge == parent) {
                continue;
            }

            values[edge] += values[idx];
            f(f, edge, idx);
        }
    };

    dfs(dfs, 0, -1);

    for (auto value : values) {
        std::cout << value << std::endl;
    }
}


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

int main(){

  int i;
  char c;
  string s="aiueo";

  cin>>c;

  for( i=0;i<5;i++) if(s[i]==c) break;

  if(i==5) cout<<"consonant"<<endl;
  else cout<<"vowel"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>

using namespace std;

int main()
{
  array< double, 10 > distance;
  int speed1 = 0, speed2 = 0, sum = 0;
  double dis;
  char tmp;
  while ( cin >> distance[0] >> tmp >>distance[1] >> tmp >>
                distance[2] >> tmp >> distance[3] >> tmp >>
                distance[4] >> tmp >> distance[5] >> tmp >>
                distance[6] >> tmp >> distance[7] >> tmp >>
                distance[8] >> tmp >> distance[9] >> tmp >>
                speed1 >> tmp >> speed2 )
  {
        for ( int j = 0 ; j < 10 ; j++ ) sum += distance[j];
        dis = 1.0 * speed1 * sum / ( speed1 + speed2 );
        sum = 0;
        for ( int k = 0 ; k < 10 ; k++ )
        {
                sum += distance[k];
                if ( sum >= dis )
                {
                        cout << k+1 << endl;
                        break;
                }
        }
        sum = 0;
  }

  return 0;
}

Measured memory_bytes: 3192
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if( (1<=a) && (b<=1000000000) ){
			System.out.printf("%d %d %f", a/b, a%b, (double)a/b);
		}
	}
}

Measured memory_bytes: 17188
#AGC014-B Unplanned Queries
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,m = map(int,readline().split())
dic1 = defaultdict(int)
for i in range(m):
    a,b = map(int,readline().split())
    dic1[a] += 1
    dic1[b] += 1

for i in dic1.values():
    if not even(i):
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 47068
import sys
H,W = map(int,input().split())
grid = []
for i in range(H):
    grid.append([el for el in input()])
move_x = [-1,1,0,0]
move_y = [0,0,1,-1]
for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            counter = 0
            for k in range(4):
                i += move_x[k]
                j += move_y[k]
                if i < H and j < W and -1 < H and -1 < W:
                    if grid[i][j] == '#':
                        counter += 1
                i -= move_x[k]
                j -= move_y[k]
            if counter == 0:
                print('No')
                sys.exit(0)
print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
ll const mod=998244353;
//ll const mod=1e9+7;
const ll MAX=300000;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////


int main(){
    vi x(5);
    int ans=0;
    rep(i,5)cin>>x[i];
    rep(i,5){
        if(x[i]==0){
            cout<<i+1<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int a[2000000];

int main(){
	int n;
	for(int i = 0; i < 2000000; i++){
		a[i] = 1;
	}
	for(int i = 2; i < 2000000; i++){
		if(a[i]){
			for(int j = i * 2;j < 2000000; j = j + i){
					a[j] = 0;
			}
		}
	}
	scanf("%d",&n);
	while(n != 0){
		long int ans = 0;
		for(int i = 2; i < 2000000; i++){
			if(a[i]){
				ans += i;
				n--;
				if(n == 0) break;
			}
		}
		printf("%ld\n",ans);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 8840
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    int N = S.size();
    ll dp[N+1][4];
    rep(i,0,4)dp[N][i] = 0;
    dp[N][3] = 1;
    for(int i = N;i >= 1;i--){
        rep(j,0,3){
            int a = (S[i-1] == 'A' + j || S[i-1] == '?');
            int b = (S[i-1] == '?' ? 3 : 1);
            dp[i-1][j] = (dp[i][j+1] * a + dp[i][j] * b) % MOD;
        }
        dp[i-1][3] = (dp[i][3] * (S[i-1] == '?' ? 3 : 1)) % MOD;
    }
    cout << dp[0][0] << endl;
}

Measured memory_bytes: 3584
N = int(input())
A1 = [int(x) for x in input().split()]
A2 = [int(x) for x in input().split()]

S1 = []
s = 0
for a in A1:
    s += a
    S1.append(s)

S2 = []
s = 0
for a in reversed(A2):
    s += a
    S2.append(s)
S2 = list(reversed(S2))
print(max(S1[i] + S2[i] for i in range(N)))



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod = 1000000007;
int qp(int x, int n) {return !n ? 1 : 1LL * qp(1LL * x * x % mod, n >> 1) * (n & 1 ? x : 1) % mod;}
int inv(int x) {return qp(x, mod - 2);}
int fac[100010], invfac[100010];
int C(int n, int m) {
    if (n < 0 || n < m || m < 0) return 0;
    return 1LL * fac[n] * invfac[m] % mod * invfac[n - m] % mod;
}
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    fac[0] = invfac[0] = 1;
    for (int i = 1; i <= n + 5; ++ i) fac[i] = 1LL * i * fac[i - 1] % mod, invfac[i] = inv(fac[i]);
    vector <int> a(n + 1), cnt(n + 1);
    for (int i = 0; i <= n; ++ i) cin >> a[i], cnt[a[i]] ++;
    int db;
    for (int i = 1; i <= n; ++ i) if (cnt[i] == 2) db = i;
    vector <int> ps;
    for (int i = 0; i <= n; ++ i) if (a[i] == db) ps.push_back(i);
    for (int len = 1; len <= n + 1; ++ len) {
        int ans = 0;
        (ans += C(n + 1, len)) %= mod;
        ans = (ans - C(n + 1 - (ps[1] - ps[0] + 1), len - 1) + mod) % mod;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2816
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

macro_rules! input {
    (source = $s:expr; $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
#[allow(unused_imports)]
use std::cmp::*;
trait Each: Iterator {
    fn each<F>(self, mut f: F)
    where
        Self: Sized,
        F: FnMut(Self::Item),
    {
        self.fold((), move |(), item| f(item));
    }
}
impl<T: Iterator> Each for T {}

const SEPARATOR: &'static str = " ";

fn solve(source: &str) -> String {
    let mut result: Vec<String> = vec![];
    macro_rules! p {
        ([$x: expr]) => {
            $x.iter().each(|&x| p!(x))
        };
        ([$x: expr]; $s:expr)=>{
            p!($x.iter().map(|x|x.to_string()).collect::<Vec<_>>().join($s));
        };
        ($($x: expr),* $(,)*) => {
            $(result.push($x.to_string()));*
        };
    }
    //---------------------------------------------------------------//

    input! {
        source = source;
        a:u64,
        b:u64,
    }
    if a>2*b{
        p!(a-2*b);

    }else{
        p!(0);
    }

    //---------------------------------------------------------------//
    return result.join(SEPARATOR);
}
fn main() {
    let mut s;
    let source = {
        use std::io::Read;
        s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s.as_str()
    };
    println!("{}", solve(source));
}
#[test]
fn testcase() {
    assert_eq!(solve(r"12 4
"),r"4");
assert_eq!(solve(r"20 15
"),r"0");
assert_eq!(solve(r"20 30
"),r"0");
}

Measured memory_bytes: 4352
while true
  h,w = gets.split.map{|v|
    v.to_i
  }
  if h == 0 && w == 0
    break
  end
  
  print "#" * w, "\n"
  (h-2).times do
    print "#", "." * (w-2) ,"#", "\n"
  end
  print "#" * w, "\n"
  print "\n"
end


Measured memory_bytes: 6872
def main2(N,h,K):
    dp = [0] * N
    for i in range(1,N):
        dp[i] = min([dp[j] + abs(h[i] - h[j]) for j in range(max(0, i-K), i)])
    return dp[-1]

N, K = map(int, input().split())
h = list(map(int, input().split()))
print(main2(N,h,K))


Measured memory_bytes: 13980
import java.util.Scanner;

//https://procon-questions.s3.us-east-2.amazonaws.com/final/C_vietnam.html
public class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	while (true) {
	  int b = sc.nextInt();
	  if (b == 0) {
		break;
	  }
	  calculatorResult(b);
	}
  }

  public static void calculatorResult(int b) {
	int i = 1;
	int lowestFloor = 1;
	int numberOfFloors = 0;
	int sum = 0;
	while (true) {
	  if (sum == b) {
		break;
	  }
	  if (sum < b) {
		sum += i;
		numberOfFloors++;
		i++;
	  }
	  if (sum > b) {
		sum -= lowestFloor;
		lowestFloor++;
		numberOfFloors--;
	  }
	}
	System.out.println(lowestFloor + " " + numberOfFloors);
  }
}



Measured memory_bytes: 30744
#include<stdio.h>
#include<stdlib.h>
#define N 100
#define INF 1000000000

int m[N][N];
int p[N];

void matrixChainOrder(int n){
  int i,j,k,l;
  int q;
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i+l-1;
      m[i][j] = INF;
      for(k=i;k<=j-1;k++){
	q = m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	m[i][j] = min(m[i][j],q);
      }
    }
  }
}

int min(int x,int y){
  if(x>y) return y;
  else return x;
}
  


int main(){
  int n,r,c;
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&r,&c);
    p[i]=r;
    p[i+1]=c;
  }
  matrixChainOrder(n);
  printf("%d\n",m[1][n]); 
  return 0;
}

Measured memory_bytes: 636
a=list(input())
kisu=[]
gusu=[]
for i in range(len(a)):
    if i%2==0:
        kisu.append(a[i])
    else:
        gusu.append(a[i])
#print(a)
#print(kisu)
#print(gusu)
if "L" in kisu or "R" in gusu:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#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 fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x-a) < abs(x-b)) cout << "A" << endl;
    else cout << "B" << endl;
}


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

public class Main {
    static final Scanner sc = new Scanner(System.in);
    static final int MOD = (int) 1E9 + 7;
    static final int INF = Integer.MAX_VALUE;
    
    public static void main(String[] args) {
        int N = nint();
        int pow = (int) Math.pow(2, N);
        int[] S = nints(pow); 
        sortR(S);
        
        int[] a = {S[0]};
        S[0] = INF;
        
        for (int n = 1; n <= N; n++) {
            int[] b = new int[pow(2, n-1)];
            
            int is = 0;
            for (int ib = 0, ia = 0; ib < b.length; ib++, ia++) {
                while (is < pow && a[ia] <= S[is]) {
                    is++;
                }
                if (is == pow && Arrays.stream(S).anyMatch(i -> i != INF)) {
                    System.out.println("No");
                    return;
                }
                b[ib] = S[is];
                S[is] = INF;
            }
            a = merge(a, b);
            sortR(a);
        }
        System.out.println("Yes");
    }
    static void sortR(int[] a) {
        Arrays.sort(a);
        for (int l = 0, r = a.length-1;  l <= r; l++, r--) {
            int temp = a[l];
            a[l] = a[r];
            a[r] = temp;
        }
    }
    
    static int[] merge(int[] a, int[] b) {
        int[] c = new int[a.length + b.length];
        System.arraycopy(a, 0, c, 0, a.length);
        System.arraycopy(b, 0, c, a.length, b.length);
        return c;
    }
    
    public static int pow(int a, int b) {
        return (int) Math.pow(a, b);    
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0);
    }

    private static char[][] nchars2(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 93376
import sys
from functools import lru_cache


def solve(n, aaa):
    if n == 2:
        h, m = divmod(sum(aaa), 2)
        if m == 1 or h > aaa[0]:
            return -1
        return aaa[0] - h

    x = 0
    for a in aaa[2:]:
        x ^= a
    a0, a1 = aaa[:2]
    s = a0 + a1

    if s & 1 != x & 1:
        return -1

    b = 1 << 40
    MASK = (b << 1) - 1

    @lru_cache(maxsize=None)
    def dfs(p, b):
        if b == 0:
            return p
        m = (MASK ^ (b - 1)) << 1
        q = p ^ x & m
        if x & b == 0:
            if s >= p + q + 2 * b:
                if p | b <= a0:
                    return dfs(p | b, b >> 1)
                else:
                    return -1
            return dfs(p, b >> 1)
        else:
            if s < p + q + b:
                return -1
            if p | b <= a0:
                ret = dfs(p | b, b >> 1)
                if ret != -1:
                    return ret
            return dfs(p, b >> 1)

    ret = dfs(0, b)

    if ret <= 0:
        return -1
    return a0 - ret


n, *aaa = map(int, sys.stdin.buffer.read().split())
print(solve(n, aaa))


Measured memory_bytes: 9664
#include <iostream>

using namespace std;

const int NMAX = 100 + 5;

int N, W;
int w[NMAX];
int v[NMAX];

int dp[NMAX][NMAX][3 * NMAX];

void upd(int &where, int val) {
    if (val > where)
        where = val;
}

int main()
{
    cin >> N >> W;
    for (int i = 1; i <= N; ++ i)
        cin >> w[i] >> v[i];

    int quota = w[1];
    for (int i = 1; i <= N; ++ i)
        w[i] -= quota;

    for (int i = 0; i < N; ++ i)
        for (int j = 0; j <= i; ++ j)
            for (int g = 0; g <= 3 * j; ++ g) {
                upd(dp[i + 1][j][g], dp[i][j][g]);
                upd(dp[i + 1][j + 1][g + w[i + 1]], dp[i][j][g] + v[i + 1]);
            }

    int ans = 0;
    for (int j = 0; j <= N; ++ j)
        for (int g = 0; g <= 3 * j; ++ g)
            if (1LL * quota * j + g <= W)
                ans = max(ans, dp[N][j][g]);

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
int a[60],n;
int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    long double ans=a[0];
    for(int i=1;i<n;i++){
        ans=(long double)(ans+a[i])/2;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

void chmax( string &a, string b){
 if( a == "-"){ a = b;}// aが未更新だった場合
  //それ以外の場合はaとbの大小比較
  if( b.size() > a.size()){ a = b;}

  else{
    a = max( a, b);
     }
}
 
 
  
int match[] = {0,2,5,5,4,5,6,3,7,6};


string dp[10100];
//dpは入力が整数で出力がstring

int main(){
int N,M; cin >> N >> M;
  vector<char> A(M);
  for(int i = 0; i < M; i++){ cin >> A[i];}
  for(int i = 0; i < 10100; i++){ dp[i] = "-";}
  //-は未記入 テーブルを記入していく
  dp[0] = ""; 
  for(int i = 0; i < 10010; i++){
    for(int j = 0; j < M; j++){
      //配るDP
   if( !(dp[i] == "-")){
   chmax( dp[i + match[A[j] - '0']], dp[i] + A[j]); }}}
  
  cout << dp[N] << endl; return 0;}


Measured memory_bytes: 46336
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

ll a[60];
int main(){
	ll n,l,r;
	while(scanf("%lld%lld%lld",&n,&l,&r),n){
		ll ans=0;
		rep(i,0,n)scanf("%lld",a+i);
		rep(x,l,r+1){
			int flag=-1;
			rep(i,0,n)if(x%a[i]==0){
				flag=(i+1)%2;
				break;
			}
			if(flag==-1)flag=(n+1)%2;
			ans+=flag;
		}
		printf("%lld\n",ans);
	}
}



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

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double area = x / a;
  double pi = 3.141592653589793;
  cout << fixed << setprecision(10);
  double tan;
  // 水が半分以上はいってるかどうか
  if (x >= a*a*b / 2.0) {
    tan = 2*(a*b-area) / (a*a);
  }
  else {
    tan = b*b / (2*area);
  }
  cout << atan(tan) * 180 / pi << endl;
}

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

int main(){
  string n;
  cin >> n;
  for(int i=0; i<3; i++){
    if(n.at(i)=='1'){
      n.at(i)='9';
    }
    else{
      n.at(i)='1';
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
A = list(map(int, input().split()))
 
x_tmp = x
for i, Ai in enumerate(sorted(A)):
    x_tmp -= Ai
    if x_tmp == 0:
        ans = i + 1
        break
    elif x_tmp < 0:
        ans = i
        break
    else: continue
else: ans = i
 
print(ans)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N = int(input())
edge = [[] for _ in range(N+1)]
 
for _ in range(N-1):
  a,b,c = map(int,input().split())
  edge[a].append((b,c))
  edge[b].append((a,c))

Q,K = map(int,input().split())

dist = [None]*(N+1)

def set_dist(x,d):
  dist[x] = d
  for y,dd in edge[x]:
    if dist[y] is not None:
      continue
    set_dist(y,d+dd)

set_dist(K,0)

for _ in range(Q):
  x,y = map(int,input().split())
  print(dist[x] + dist[y])

Measured memory_bytes: 131756
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
//#include<cstdio>//"scanf("%lf",&(double));printf("%f",(double));"
//#include<iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include<string>//"reverse(s's it,s's it)"
//#include<functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include<cmath>//"abs" "sqrt"
//#include<numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include<algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
//#include<cassert>//"assert(cond);": error if cond doesn't hold.
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert//also use as v.is(v's it,w's it,w's it);//Be careful in topcoder
#define ps push//stack,(priority) queue,//Be careful in topcoder.
#define fr front//queue//for priority, use top().//Be careful in topcoder.
typedef long long ll;//not necessarily//Be careful in topcoder.
typedef pair<int,int> pii;//Be careful in topcoder.
//Add other types in the same way.
const ll M=1000000007;//can be changed
int mod(int a){	return (a+M)%M;	}//M can be a variable
void plmod(ll &a,ll b){	a=(a+b+M)%M;	return;	}
void mnmod(ll &a,ll b){	a=(a-b+M)%M;	return;	}
void mlmod(ll &a,ll b){	a=(a*b)%M;  	return;	}
//Caution! you may need sth larger than "+M"!
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}
//These 2 could be better in long long

#define MAX_N 200000

pii x[MAX_N];
int ind[MAX_N];

bool cmp(pii p,pii q){
	return p.fi<q.fi;
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		int z;
		scanf("%d",&z);
		x[i].fi=z;
		x[i].sc=i;
	}
	sort(x,x+n,cmp);
	for(int i=0;i<n;++i) ind[x[i].sc]=i;
	for(int i=0;i<n;++i){
		if(ind[i]<n/2) printf("%d\n",x[n/2]);
		else printf("%d\n",x[(n/2)-1]);
	}
}

Measured memory_bytes: 4480
#include<stdio.h>
int main(){
  int n,m,a[11000],b[11000],c[11000],r[11000],i,j,k,s,t;
  while(scanf("%d %d",&n,&m),n||m){
    int p[110]={0};
    for(i=s=0;i<m;i++){
      scanf("%d %d %d",&a[i],&b[i],&c[i]);
      for(j=r[i]=i;j;j--){
	if(c[r[j-1]]>c[r[j]]){
	  t=r[j-1];
	  r[j-1]=r[j];
	  r[j]=t;
	}
      }
    }
    for(i=0;i<m;i++){//printf("%d\n",c[r[i]]);
      for(j=a[r[i]]+1;p[j];j=p[j]);
      for(k=b[r[i]]+1;p[k];k=p[k]);
      if(j-k){
	p[j]=k;
	s+=c[r[i]];
      }
    }
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 620
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
char s[MAXN];

void work(){
    scanf("%s",s);
    if(s[1]=='B') printf("ARC\n");
    else printf("ABC\n");
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}








Measured memory_bytes: 3760
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=x;i++){
        for(int j=0;i+j<=x;j++){
            if(i*2+j*4==y & i+j==x){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3636
import string

offset = int(input())

H   = {}
rH  = {}

n = len(string.ascii_uppercase)
for i, c in enumerate(string.ascii_uppercase):
    H[c] = i
    rH[(i-offset+n) % n] = c

st = input().strip()
for c in st:
    print(rH[H[c]], end = '')

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

namespace ABC079
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = Console.ReadLine()
                .ToCharArray()
                .Select(s => int.Parse(s.ToString()))
                .ToArray();

            int A = arr[0];
            int B = arr[1];
            int C = arr[2];
            int D = arr[3];

            int len = arr.Length;

            for (uint bit = 0; bit < (1 << len - 1); bit++)
            {
                //Console.WriteLine(Convert.ToString(bit, toBase: 2));
                int result = 0;

                char operator1 = (((bit >> len - 2) & 1) == 1) ? '+' : '-';
                char operator2 = (((bit >> len - 3) & 1) == 1) ? '+' : '-';
                char operator3 = (((bit >> len - 4) & 1) == 1) ? '+' : '-';

                calc(ref result, A, '+');
                calc(ref result, B, operator1);
                calc(ref result, C, operator2);
                calc(ref result, D, operator3);

                if (result == 7)
                {
                    Console.WriteLine($"{A}{operator1}{B}{operator2}{C}{operator3}{D}=7");
                    return;
                }
            }
        }

        static void calc(ref int baseNum, int otherNum, char cOperator)
        {
            if (cOperator == '+')
            {
                baseNum += otherNum;
            }
            else
            {
                baseNum -= otherNum;
            }
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int n, t;
vector<int> v;

int main(void){
    
	scanf("%d %d", &n, &t);
	for(int i = 0; i < n; ++i){
	    int a, b; scanf("%d %d", &a, &b);
	    if(b <= t) v.push_back(a);
	}
	
	sort(v.begin(), v.end());
	
	if(v.size()) printf("%d\n", v.front());
	else printf("TLE\n");
	
    return 0;
}


Measured memory_bytes: 256