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

#define ff first
#define ss second
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)

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

using namespace std;

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

	ll n; cin >> n;

	cout << n*(n - 1) / 2;

	return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> lo(N);
  for ( int i = 0; i < N ; i++) cin >> lo.at(i);
  
  sort(lo.begin(), lo.end());
  reverse(lo.begin(), lo.end());
  
  int ans = 0;
  for ( int i = 0; i < K ; i++) ans += lo.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
class UnionFind {
private:
	unsigned size_; std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
int n, m, q, a[400000], b[400000], c[400000], dist[5000], D[5000][5000];
vector<pair<int, int>>vec; vector<pair<int, int>>x[5000];
void query(int r1) {
	fill(dist + 1, dist + n + 1, 1299999999);
	queue<int>Q; Q.push(r1); dist[r1] = 0;
	while (!Q.empty()) {
		int a1 = Q.front(); Q.pop();
		for (int i = 0; i < x[a1].size(); i++) {
			if (dist[x[a1][i].first] == 1299999999) {
				dist[x[a1][i].first] = max(dist[a1], x[a1][i].second);
				Q.push(x[a1][i].first);
			}
		}
	}
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i] >> c[i]; vec.push_back(make_pair(c[i], i));
	}
	sort(vec.begin(), vec.end());
	UnionFind UF(n + 1); long long sum = 0;
	for (int i = 0; i < vec.size(); i++) {
		int to = vec[i].second;
		if (UF.same(a[to], b[to]) == false) {
			UF.unite(a[to], b[to]); sum += c[to];
			x[a[to]].push_back(make_pair(b[to], c[to]));
			x[b[to]].push_back(make_pair(a[to], c[to]));
		}
	}
	for (int i = 1; i <= n; i++) {
		query(i); for (int j = 1; j <= n; j++)D[i][j] = dist[j];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		int p1, p2; cin >> p1 >> p2;
		cout << sum - D[p1][p2] << endl;
	}
	return 0;
}

Measured memory_bytes: 87660
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int o = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
			}
		Arrays.sort(a);
		int p1 = o;
		int p2 = m;
		for(int i = n-1; i >= 0; i--){
			if(p1 / p2 <= (p1 + a[i]) / (p2 + l)){
				p1 = p1 + a[i];
				p2 = p2 + l;
				}
			}
		System.out.println(p1/p2);
		}
	}

Measured memory_bytes: 18244
s = input()

if 0 < int(s[:2]) < 13 :
    if 0 < int(s[2:]) < 13 :
        print('AMBIGUOUS')
    else :
        print('MMYY')
else :
    if 0 < int(s[2:]) < 13:
        print('YYMM')
    else :
        print('NA')

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

int main(){
  ll a;
  long double b;
  std::cin >> a>>b;
  std::cout <<(ll)(a*b) << '\n';


  return 0;
}


Measured memory_bytes: 3728
public class Main {

  private static void solve() {
    char[] s = ns();

    int ret = 0;
    for (char c : s) {
      ret += c - '0';
      ret %= 9;
    }
    System.err.println(ret);
    System.out.println(ret == 0 ? "Yes" : "No");
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

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

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

int main() {
  string s;
  cin >> s;
  int cnt=700;
  if(s.at(0)=='o') cnt+=100;
  if(s.at(1)=='o') cnt+=100;
  if(s.at(2)=='o') cnt+=100;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};



int main() {
    int r,c,sx,sy;
    cin >> r >> c;

    // 盤面入力受取と初期スタート地点探し
    vector<string> p(r);
    rep(i,r) {
      cin >> p[i];
    }

    // BFS のためのデータ構造
    vector<vector<int>> dist(r,vector<int>(c)); 
    queue<pair<int,int>> que; 
 
int ans=0;

 rep(k,r){
   rep(l,c){
     if(p[k][l]=='.'){
       sx=k;
       sy=l;  
  
  
    // 全マスを「未訪問」に初期化
    rep(i,r){
      rep(j,c){
        dist[i][j]=-1; 
      }
    }

    // 初期条件 ((sx,sy) を初期ノードとする)
    dist[sx][sy] = 0;
    pair<int,int> q=mp(sx,sy);
    que.push(q); // (sx,sy) を入れる

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        pair<int,int> v = que.front(); // キューから先頭頂点を取り出す
        que.pop();
      
        //vの上下左右をすべて調べる
        rep(i,4) {
          int nh = v.fi + dx[i];
          int nw = v.se + dy[i];

          // 場外アウトしたり、移動先が壁の場合はスルー
          if (nh < 0 || nh >= r || nw < 0 || nw >= c) continue;
          if (p[nh][nw] == '#') continue;
          
          if (dist[nh][nw] != -1) continue; // すでに発見済みのマスは探索しない

          // 新たなマスについて距離情報を更新してキューに追加する
          dist[nh][nw] = dist[v.fi][v.se] + 1;
          pair<int,int> r=mp(nh,nw);
          que.push(r);
        }
    }

    // (sx,sy)からの最長距離と場所を求める
    rep(i,r){
      rep(j,c){
        ans=max(ans,dist[i][j]);
      }
    }
  
  }
 }
}
     

cout << ans << endl;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vvl dp(n+1,vl(n+1,0));
    vector<pll> a(n);
    rep(i,n){cin>>a[i].fs;a[i].sc=i;}
    sort(rall(a));
    rep(i,n){
        rep(j,i+1){
            chmax(dp[i+1][j], dp[i][j] + abs(a[i].sc-(n-i+j-1))*a[i].fs);
            chmax(dp[i+1][j+1], dp[i][j] + abs(a[i].sc-j)*a[i].fs);
            // puta(i+1,j,dp[i+1][j]);
            // puta(i+1,j+1,dp[i+1][j+1]);
        }
    }
    puta(max(dp[n]));
    return 0;
}

Measured memory_bytes: 34600
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;

int main() {
  int k;
  cin>>k;
  
  ll sum=0;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        sum += gcd(i,gcd(j,l));
      }
    }
  }
  
  cout << sum << endl;
  
  return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

template <i64 p>
class fp {
    public:
    i64 x;
    fp() : x(0) {}
    fp(i64 x_) : x((x_ % p + p) % p) {}
    fp operator+() const { return fp(x); }
    fp operator-() const { return fp(-x); }
    fp& operator+=(const fp& y) {
        x += y.x;
        if (x >= p) x -= p;
        return *this;
    }
    fp& operator-=(const fp& y) { return *this += -y; }
    fp& operator*=(const fp& y) {
        x = x * y.x % p;
        return *this;
    }
    fp& operator/=(const fp& y) { return *this *= fp(inverse(y.x)); }
    fp operator+(const fp& y) const { return fp(x) += y; }
    fp operator-(const fp& y) const { return fp(x) -= y; }
    fp operator*(const fp& y) const { return fp(x) *= y; }
    fp operator/(const fp& y) const { return fp(x) /= y; }
    bool operator==(const fp& y) const { return x == y.x; }
    bool operator!=(const fp& y) const { return !(*this == y); }
    i64 extgcd(i64 a, i64 b, i64& x, i64& y) {
        i64 d = a;
        if (b != 0) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
    i64 inverse(i64 a) {
        i64 x, y;
        extgcd(a, p, x, y);
        return (x % p + p) % p;
    }
};

template <i64 p>
i64 abs(const fp<p>& x) { return x.x; }

template <i64 p>
istream& operator>>(istream& is, fp<p>& x) {
    is >> x.x;
    return is;
}

template <i64 p>
ostream& operator<<(ostream& os, const fp<p>& x) {
    os << x.x;
    return os;
}

template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "[";
    for (const auto& v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename A, typename T, size_t size>
void fill(A (&ary)[size], const T& val) {
    fill((T*)ary, (T*)(ary + size), val);
}

constexpr int inf = 1.01e9;
constexpr i64 inf64 = 4.01e18;
constexpr long double eps = 1e-9;

// double(64bit浮動小数)のn分探索のループ回数の上限(2分探索なら50でも十分かもしれない). long double(80ビットの x87 浮動小数点型?)だと, 2分探索であってもこれだと足りないケースがある気がするので, もうちょっと余裕を持たせた方が良さそう.
constexpr i64 max_loop = 100;

void solve() {
    //constexpr i64 mod = 1'000'000'007;
    i64 A,B,N;
    cin >> A >> B >> N;

    i64 i=min(B-1,N);
    cout << (A*i)/B-A*(i/B);
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 3616
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
mod = 10 ** 9 + 7

class SegmentTree:
    """Segment Tree (Point Update & Range Query)

    Query
        1. update(i, val): update i-th value to val
        2. query(low, high): find f(value) in [low, high)

    Complexity
        time complexity: O(log n)
        space complexity: O(n)
    """

    def __init__(self, N, f, default):
        self.N = 1 << (N-1).bit_length()
        self.default = default
        self.f = f
        self.segtree = [self.default] * ((self.N << 1) - 1)

    @classmethod
    def create_from_array(cls, arr, f, default):
        N = len(arr)
        self = cls(N, f, default)
        for i in range(N):
            self.segtree[self.N - 1 + i] = arr[i]

        for i in reversed(range(self.N - 1)):
            self.segtree[i] = self.f(
                self.segtree[(i << 1) + 1], self.segtree[(i << 1) + 2])
        return self

    def update(self, i, val):
        i += self.N - 1
        self.segtree[i] = val
        while i > 0:
            i = (i - 1) >> 1
            self.segtree[i] = self.f(
                self.segtree[(i << 1)+1], self.segtree[(i << 1)+2])

    def query(self, low, high):
        # query [l, r)
        low, high = low + self.N, high + self.N
        ret = self.default
        while low < high:
            if low & 1:
                ret = self.f(ret, self.segtree[low-1])
                low += 1
            if high & 1:
                high -= 1
                ret = self.f(ret, self.segtree[high-1])
            low, high = low >> 1, high >> 1
        return ret

n, q = MAP()
rmq = SegmentTree(n, min, (1<<31)-1)

for _ in range(q):
	c, x, y = MAP()
	if c == 0:  # update
		rmq.update(x, y)
	else:  # find
		print(rmq.query(x, y+1))



Measured memory_bytes: 10996
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int n; cin >> n;
    vi a(n), b(n);
    FOR(i, 0, n - 1) cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (n & 1)
        cout << b[n / 2] - a[n / 2] + 1 << endl;
    else {
        cout << b[n / 2] + b[n / 2 - 1] - a[n / 2] - a[n / 2 - 1] + 1 << endl;
    }
}

Measured memory_bytes: 4700
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define fastii ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
int main()
{
fastii;
    ll x,n;
    cin>>x>>n;
    ll arr[n];
    map<ll,ll>m;
    f(i,n)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    sort(arr,arr+n);
    ll c1,c2;
    if(m[x]==0)
        cout<<x;
    else
    {
        ll y=x;
        while(m[y]!=0)
        {
            y--;
        }
        c1=y;
        y=x;
        while(m[y]!=0)
        {
            y++;
        }
        c2=y;
        if(abs(c1-x)<=abs(c2-x))
        {
            cout<<c1;
        }
        else
        {
            cout<<c2;
        }
    }
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <list>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string S, answer = "";
    bool flag = false;
    cin >> S;
    for (int i = 0; i < S.size(); ++i) {
        if (i - 1 >= 0 && S[i - 1] == 'A' && S[i] == 'C') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int lcs(char X[], char Y[]) {
  
  int i, j, s = strlen(X), t = strlen(Y);
  int common[s + 1][t + 1];
  
  for(i = 0; i <= s; i++)
    common[i][0] = 0;
  for(j = 0; j <= t; j++)
    common[0][j] = 0;
    
  for(i = 1; i <= s; i++){
    for(j = 1; j <= t; j++){
      
      if(X[i-1] == Y[j-1])
        common[i][j] = common[i-1][j-1] + 1;
      else if(common[i-1][j] >= common[i][j-1])
        common[i][j] = common[i-1][j];
      else
        common[i][j] = common[i][j-1];
    }
  }
  return common[s][t];
}
   
int main() {
  
  int n, i, j;
  char X[1000], Y[1000];
  
  scanf("%d", &n);
  for (i = 0; i < n; i++){
    scanf("%s %s", X, Y);
    printf("%d\n", lcs(X, Y));
  }
  return 0;
}

Measured memory_bytes: 5652
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		HashSet<Long> list = new HashSet<Long>();

		for(int i = 0;i < n;i++) {
			list.add(scan.nextLong());
		}

		if(n != list.size()) {
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}
	}
}

Measured memory_bytes: 75744
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] arr = reader.readLine().split(" ");
        double H = Double.parseDouble(arr[0]);
        int A = Integer.parseInt(arr[1]);
        System.out.println((int) Math.ceil(H / A));
    }
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n) {
        if(a[a[i] - 1] == i + 1) ans++;
    }
    cout << ans / 2 << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,k,i,j;
int dp[200001],h[200001];
int main(){
    cin>>n>>k;
    for(i=1;i<=n;i++)cin>>h[i];
    for(i=1;i<=200001;i++)dp[i]=1e9;
    dp[1]=0;
    for(i=2;i<=n;i++){
        for(j=1;j<=k;j++){
            if(j < i)dp[i]=min(dp[i],(dp[i-j]+abs(h[i]-h[i-j])));
        } 
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N, M;

struct Edge {
  int to, d;
};

vector<vector<Edge>> G;
vector<int> skip, visited;

bool findContradiction(int i, int d, map<int, int> &ds) {
  if(ds.find(i) != ds.end()) return ds[i] != d;

  visited[i] = 1;
  ds[i] = d;
  bool res = false;
  for(auto &e: G[i]) {
    res |= findContradiction(e.to, d + e.d, ds);
  }
  return res;
}

bool contradictory() {
  bool res = false;
  rep(i,N) {
    if(skip[i]) continue;
    map<int, int> ds;
    res |= findContradiction(i, 0, ds);
  }
  return res || any_of(all(visited), [](int v){ return v == 0; });
}

int main () {
  cin >> N >> M;
  G.resize(N);
  visited.resize(N, 0);
  skip.resize(N, 0);

  rep(i,M) {
    int L, R, D;
    cin >> L >> R >> D;
    L--, R--;
    G[L].push_back(Edge{R, D});
    skip[R] = true;
  }

  cout << (contradictory() ? "No" : "Yes") << endl;

  return 0;
}


Measured memory_bytes: 20608
# https://atcoder.jp/contests/abc162/tasks/abc162_d

N = int(input())
S = input()


def colors(target, a, b):
    for i in range(N):
        for j in range(i + 1, N):
            if S[i] == a and S[j] == b:
                target[i] += 1


rg = [0 for _ in range(N)]
colors(rg, 'R', 'G')
gr = [0 for _ in range(N)]
colors(gr, 'G', 'R')

gb = [0 for _ in range(N)]
colors(gb, 'G', 'B')
bg = [0 for _ in range(N)]
colors(bg, 'B', 'G')

rb = [0 for _ in range(N)]
colors(rb, 'R', 'B')
br = [0 for _ in range(N)]
colors(br, 'B', 'R')

ans = 0
for i in range(N):
    if S[i] == 'B':
        for j in range(i + 1, N):
            ans += rg[j]
            ans += gr[j]

            k = j + j - i
            if k >= N:
                continue
            if S[i] == 'B' and S[j] == 'R' and S[k] == 'G':
                ans -= 1
            if S[i] == 'B' and S[j] == 'G' and S[k] == 'R':
                ans -= 1

    if S[i] == 'R':
        for j in range(i + 1, N):
            ans += gb[j]
            ans += bg[j]

            k = j + j - i
            if k >= N:
                continue
            if S[i] == 'R' and S[j] == 'G' and S[k] == 'B':
                ans -= 1
            if S[i] == 'R' and S[j] == 'B' and S[k] == 'G':
                ans -= 1

    if S[i] == 'G':
        for j in range(i + 1, N):
            ans += rb[j]
            ans += br[j]

            k = j + j - i
            if k >= N:
                continue
            if S[i] == 'G' and S[j] == 'R' and S[k] == 'B':
                ans -= 1
            if S[i] == 'G' and S[j] == 'B' and S[k] == 'R':
                ans -= 1

print(ans)


Measured memory_bytes: 69684
#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)

using namespace std;

int D, G;
int p[15], c[15];

void showBit(int num)
{
  REP(i, D) {
    if ((num >> i) & 1) cout << '1';
    else cout << '0';
  }
}

int dfs(int d, int used)
{
  if (d == D) {
    int score = 0;
    int ret = 0;
    REP(i, D) {
      if ((used >> i) & 1) {
        score += 100*(i+1)*p[i] + c[i];
        ret += p[i];
      }
    }
    if (score >= G) return ret;

    int k = D - 1;
    while ((used >> k) & 1) k--;
    REP(i, p[k]) {
      score += 100*(k+1);
      ret++;
      if (score >= G) return ret;
    }
    return 1100000000;
  }
  return min(dfs(d + 1, used | (1 << d)), dfs(d + 1, used));
}

int main()
{
  cin >> D >> G;
  REP(i, D) cin >> p[i] >> c[i];

  cout << dfs(0, 0) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;

static const int INF=100000;
typedef long long ll;
typedef pair<int,int> P;

int main(){
   int n;
   cin >> n;
   int w[n];
   for(int i=0;i<n;i++){
       cin >> w[i];
   }
   int ans=INF;
   for(int t=0;t<n-1;t++){
       int s1=0;
       int s2=0;
       for(int i=0;i<=t;i++){
           s1+=w[i];
       }
       for(int j=n-1;j>t;j--){
           s2+=w[j];
       }
       ans=min(ans,abs(s2-s1));
   }
   cout << ans << endl;
}


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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 1e6;

ll po(ll a, ll b, ll M){
    ll res = 1;
    a %= M;
    while(b){
        if(b & 1) res = res * a % M;
        a = a * a % M;
        b >>= 1LL;
    }
    return res;
}
ll mul(ll a, ll b, ll M){
    return ((a % M) * (b % M)) % M;
}
ll sub(ll a, ll b, ll M){
    return ((a % M) - (b % M) + M) % M;
}
bool check(int p, ll yo){
    ll x = mul(7, sub(po(10, p, yo), 1, yo), yo);
    return x;
}

void tc(){
    int k;
    cin >> k;
    if(k % 2 == 0){
        cout << -1;
        return;
    }
    ll yo = 9 * k;
    int ans = 0;
    for(int i = 1; i <= N; i++){
        if(check(i, yo) == 0){
            cout << i;
            return;
        }
    }
    cout << -1;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) tc();
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define OUT(s) cout << s << "\n";

long N;
using namespace std;
// https://atcoder.jp/contests/abc162/tasks
void Main()
{
    long a = 0;
    REP(i, N) {
        if (0 != ((i+1) % 3) && 0 != ((i+1) % 5)) {
            a += (i+1);
        }
    }
    OUT(a);
}

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

Measured memory_bytes: 3612
//2020 2.16 選択ソート

#include <stdio.h>
#define MAX 100

int main()
{
    int A[MAX];
    int i,j;
    int a,min,temp,temp2,flag=0,cnt=0;

    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&A[i]);
    }
    
    for(i=0;i<a;i++)
    {
        min = A[i];
    for(j=i+1;j<a;j++)
    {
        if(min>A[j]) {min = A[j]; temp = j; flag=1;}
    }

    if(flag==1)
    {
    temp2 = A[i];
    A[i] = min;
    A[temp] = temp2;
    cnt++;
    flag=0;
    }
    
    }
    for(i=0;i<a;i++)
    {
        if(i==0) printf("%d",A[i]);
        else printf(" %d",A[i]);
    }
    printf("\n%d\n",cnt);
    return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string S;
	cin >> S;
	int cnt = 0;
	rep(i, 3) {
		if (S[i] == 'o') {
			cnt++;
		}
	}
	cout << 700 + 100 * cnt << endl;
}

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

typedef long long ll;

#define f first
#define s second
#define pb push_back

using namespace std;

int main(void){
    ll N;
    cin >> N;
    --N;
    ll ans = (N*(N+1))/2;
    cout << ans<<"\n";

    return 0;
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
const int mxn = 2e5;
int n;
ll ans;
vi adj[mxn];

void dfs(int u = 0, int p = -1)
{
	for (int v : adj[u])
		if (v != p)
			dfs(v, u);
	if (u)
	{
		if (p < u)
			ans += (ll)(u - p) * (n - u);
		else
			ans += (ll)(u + 1) * (p - u);
	}
	else
	{
		ans += n;
	}
}

int main()
{
	fast;
	cin >> n;
	FOR(n - 1)
	{
		int u, v;
		cin >> u >> v, --u, --v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfs();
	cout << ans;
}

Measured memory_bytes: 23904
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(N), B(N);

	for (int i = 0;i < N;i++) {
		cin >> A[i] >> B[i];
	}

	vector<pair<int, int>> AB(N);

	for (int i = 0;i < N;i++) {
		AB[i] = make_pair(A[i], B[i]);
	}
	sort(AB.begin(), AB.end());

	long long ans = 0;
	for (int i = 0;i < N;i++) {
		int buy = min(M, AB[i].second);
		ans += (long long)buy * AB[i].first;
		M -= buy;

	}


	cout << ans << endl;

}

Measured memory_bytes: 1792
public class Main {
    public static void main (String args[]) {
        long[] L = new long[87];
        L[0] = 2;
        L[1] = 1;
        for (int i = 2; i < 87; i++) {
            L[i] = L[i-1] + L[i-2];
        }
        java.util.Scanner sc = new java.util.Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(L[N]);
    }
}

Measured memory_bytes: 23508
// J4180449 三宅亮輔
// 問題名
// - Disjoint Set
// 問題URL
// - https://onlinejudge.u-aizu.ac.jp/problems/DSL_1_A
// 所要時間
// - 30分
// 学んだこと
//  Union Find木の実装方法
//  蟻本を読んでroot関数にparの値を追加することが有効であると理解した。
//  アッカーマン関数の逆関数のオーダーになることがわかった。

#include <bits/stdc++.h>
using namespace std;

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

vector<P> v;
int n, q;

int par[100];

int root(int a) {
    if(a == par[a])
        return a;
    return par[a] = root(par[a]);
}

bool same(int a, int b) { return root(a) == root(b); }

void unite(int a, int b) {
    a = root(a);
    b = root(b);
    par[a] = b;
}

int main() {
    int ans = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
        par[i] = i;

    for(int i = 0; i < n * n; i++) {
        int a;
        cin >> a;
        v.push_back(P(a, i));
    }
    sort(v.begin(), v.end());

    for(int i = 0; i < n * n; i++) {
        if(v[i].first != -1) {
            int x = v[i].second % n;
            int y = v[i].second / n;
            if(!same(x, y)) {
                unite(x, y);
                ans += v[i].first;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){
    int n,sum=0;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<int> l(20,0);
    rep(i,n) {
        cin >> l[i];
    }
    sort(l.begin(),l.end(),greater<int>());
    rep(i,n-1)  {
        sum += l[i+1];
    }
    if(l[0] < sum) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import collections

n = int(input())
# 複数行標準入力
S = []
for _ in range(n):
    S.append(input())  # S += [input()] とも書ける

c = collections.Counter(S)
m = c.most_common()[0][1]
ans = []
for _c in c.items():
    if _c[1] == m:
        ans.append(_c[0])

for _ans in sorted(ans):
    print(_ans)


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int W, H;
int Ky, Kx, My, Mx;
char mas[16][64];
bool used[4][16][64][4][16][64];

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

bool in(int i, int j) {
  return 0<=i&&i<H&&0<=j&&j<W;
}
bool wall(int y, int x) {
  return in(y, x) && mas[y][x] == '#';
}
bool nowall(int y, int x) {
  return in(y, x) && mas[y][x] != '#';
}

bool master, kitchen;
void dfs(int Fd, int Fy, int Fx, int Bd, int By, int Bx, bool isone) {
  if(kitchen) return;
  if(isone && master) return;
  if(used[Fd][Fy][Fx][Bd][By][Bx]) return;
  used[Fd][Fy][Fx][Bd][By][Bx] = true;

  int nFy = Fy+dy[Fd], nFx = Fx+dx[Fd];
  while(nowall(nFy, nFx)) {
    nFy += dy[Fd], nFx += dx[Fd];
  }
  nFy -= dy[Fd], nFx -= dx[Fd];
  if(isone) {
    if(nFy == My && nFx == Mx) {
      master = true;
      return;
    }
    dfs((Fd+1)%4, nFy, nFx, 0, 0, 0, true);
    dfs((Fd+3)%4, nFy, nFx, 0, 0, 0, true);
    return;
  }

  if(!wall(By+dy[(Bd+2)%4], Bx+dx[(Bd+2)%4])) return;
  int nBy = By, nBx = Bx;
  while(nowall(nBy, nBx)) {
    rep(i, 2) {
      dfs((Fd+2*i+1)%4, nFy, nFx, (Bd+2*i+1)%4, nBy, nBx, false);
      if(kitchen) return;
    }
    nBy += dy[Bd], nBx += dx[Bd];
  }
  nBy -= dy[Bd], nBx -= dx[Bd];
  if(nFy == My && nFx == Mx && nBy == My && nBx == Mx &&
     nowall(nBy+dy[(Bd+2)%4], nBx+dx[(Bd+2)%4])) {
    kitchen = true;
    return;
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> W >> H, W || H) {
    rep(i, H) rep(j, W) {
      cin >> mas[i][j];
      if(mas[i][j] == 'K') Ky = i, Kx = j;
      else if(mas[i][j] == 'M') My = i, Mx = j;
    }
    kitchen = master = false;
    rep(i, 4) {
      int y = Ky+dy[i], x = Kx+dx[i];
      if(nowall(y, x)) {
	memset(used, false, sizeof(used));
	rep(j, 4) dfs(i, Ky, Kx, j, Ky, Kx, false);
	memset(used, false, sizeof(used));
	dfs(i, Ky, Kx, 0, 0, 0, true);
	break;
      }
    }
    if(kitchen) cout << "He can accomplish his mission." << endl;
    else if(master) cout << "He cannot return to the kitchen." << endl;
    else cout << "He cannot bring tea to his master." << endl;
  }

  return 0;
}



Measured memory_bytes: 20544
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define  N  (200'005)
#define MOD (1000000000ll + 7ll)
#define OO (1050000000)
#define OOL (1100000000000000000)

//global
vector<int> adj[N];

int dfs(int u,int p,int d){
	if(d == 0) return 1;
	int ans = 1;
	for(auto v:adj[u]){
		if(v != p) ans += dfs(v,u,d-1);
	}
	return ans;
}

int main(){
	//fold
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	//endfold
	int n,k;
	cin >> n >> k;
	rep(i,0,n-1){
		int u,v;
		cin >> u >> v;
		u--; v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int ans = 0;
	if(k&1){
		rep(u,0,n){
			for(auto v:adj[u]){
				ans = max(ans,dfs(u,v,(k-1)/2)+dfs(v,u,(k-1)/2));
			}
		}
	}else{
		rep(u,0,n){
			ans = max(ans,dfs(u,-1,k/2));
		}
	}
	cout << n-ans;
	return 0;
}

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

int main(){
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<int> s;
    s.push_back(a[0]);


    for(int i = 1; i < n; i++){
        vector<int>::iterator it;
        it = lower_bound(s.begin(), s.end(), a[i]);
        int ind = distance(s.begin(), it);
        if(ind >= s.size() && s[ind] < a[i]) s.push_back(a[i]);
        else s[ind] = a[i];
    }
    cout << s.size() << endl;
    return 0;
}   


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

typedef long long ll;
using namespace std;

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

	string s; cin >> s;

	for (int i = 0;i < s.size();i++){
		cout << (char)((s[i]-'A'+23)%26+'A');
	}

	cout << endl;

	return 0;

}



Measured memory_bytes: 3168
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		op := sc.Text()
		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())
		if op == "?" {
			break
		}
		ans := 0
		switch op[0] {
		case '+':
			ans = a + b
		case '-':
			ans = a - b
		case '*':
			ans = a * b
		case '/':
			ans = a / b
		}
		fmt.Println(ans)
	}
}



Measured memory_bytes: 1108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(int N, int x, long[] A)
        {
            long sum = 0;
            for (int i = 0; i + 1 < N; ++i)
            {
                if (A[i] + A[i + 1] > x)
                {
                    long a = Math.Min(A[i] + A[i + 1] - x, A[i + 1]);
                    A[i + 1] -= a;
                    sum += a;
                }
                if (A[i] > x)
                {
                    long a = A[i] - x;
                    A[i] -= a;
                    sum += a;
                }
            }
            return sum;
        }
        static void Main(string[] args)
        {
            int[] v = ReadInts();
            long[] A = ReadLongs();
            Console.WriteLine(Solve(v[0], v[1], A));
        }
    }
}


Measured memory_bytes: 23388
a, b, h, m = map(int, input().split())

import math


x = 2 * math.pi * (h + m / 60) / 12
y = 2 * math.pi * m / 60

t = abs(x - y)
# print(x / 2 / math.pi * 360)
# print(y / 2 / math.pi * 360)
# print(t / 2 / math.pi * 360)
# print(a ** 2 + b ** 2 - 2 * a * b * math.cos(t))
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(t)))


Measured memory_bytes: 9432
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
#define int         int64_t

using namespace std;

typedef pair<int, int> pii;
const int N = 102;
const int logN = 17;

pii p[N], cur, res;
int n;

pii operator+(const pii& x, const pii& y) {
    return mp(x.fi + y.fi, x.se + y.se);
}

pii Max(const pii& x, const pii& y) {
    if(x.fi * x.fi + x.se * x.se > y.fi * y.fi + y.se * y.se) return x;
    return y;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> p[i].fi >> p[i].se;
    sort(p + 1, p + n + 1, [](const pii& x, const pii& y) {
            return atan2(x.fi, x.se) < atan2(y.fi, y.se);
         });
    for(int i = 1; i <= n; ++i) {
        cur = p[i]; res = Max(res, cur);
        for(int j = i % n + 1; j != i; j = j % n + 1) {
            cur = cur + p[j];
            res = Max(res, cur);
        }
    }
    cout << fixed << setprecision(16);
    cout << sqrt((long double)(res.fi * res.fi + res.se * res.se));
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<int> t(n);
    int st = 0;
    REP(i,n){
        cin >> t[i];
        st += t[i];
    }
    int m;
    cin >> m;
    vector<int> p(m);
    vector<int> x(m);
    REP(i,m){
        cin >> p[i] >> x[i];
    }
    REP(i,m){
        int res = st-t[p[i]-1]+x[i];
        put(res);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<stack>
#include<cstdio>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
int main()
{
	int n,a[1<<18];
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	int aa=-1e9,dd=1e9;
	for(;;)
	{
		int bb=aa+(dd-aa)/3,cc=dd-(dd-aa)/3;
		long sa=0,sb=0,sc=0,sd=0;
		for(int i=1;i<=n;i++)
		{
			sa+=abs(a[i]-aa-i);
			sb+=abs(a[i]-bb-i);
			sc+=abs(a[i]-cc-i);
			sd+=abs(a[i]-dd-i);
		}
		if(sb<sc)dd=cc;
		else aa=bb;
		if(dd-aa<10)break;
	}
	long s,ans=1e15;
	for(;aa<=dd;aa++)
	{
		s=0;
		for(int i=1;i<=n;i++)
		{
			s+=abs(a[i]-aa-i);
		}
		ans=min(ans,s);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024