akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef int64_t  ll;

int main () {
  int x, y;
  cin >> x >> y;
  bool flag = false;
  //鶴の数を決める
  //1 4 で エラー出た
  //よくわからんないから逆verをいれた
  for(int i = 0; i < x; ++i) {
    if (y == ((x - i) * 2 + i * 4)) {
      flag = true;
    }
    if (y == ((x - i) * 4 + i * 2)) {
      flag = true;
    }

  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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


int main(){

int N,K;
cin >> N >> K;

vector<int> list(N);

for(int i =0; i<N; i++) cin >>list.at(i);

sort(list.begin(),list.end(),greater<int>());

int ans = 0;

for (int i = 0; i<K; i++){
    ans += list.at(i);
}

cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long c = Long.parseLong(sc.next());

        // 主処理
        boolean judge = (0 < c - a - b) && (4 * a * b < (c - a - b) * (c - a - b));
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
        sc.close();
    }
}


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



int main() {
   int n, m;
   cin >> n >> m;
   vector<int> h(n);
   for (int i=0; i<n; i++) {
      cin >> h[i];
   }
   vector<int> a(m), b(m);
   for (int i=0; i<m; i++) {
      cin >> a[i] >> b[i];
   }
   int ans = n;
   vector<int> temp(n,0);
   for (int i=0; i<m; i++) {
      if ((h[a[i]-1] <= h[b[i]-1]) && (temp[a[i]-1] == 0)) {
         ans = ans - 1;
         temp[a[i]-1] = 1;
      }
      if ((h[b[i]-1] <= h[a[i]-1]) && (temp[b[i]-1] == 0)) {
         ans = ans - 1;
         temp[b[i]-1] = 1;
      }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 4772
#include <algorithm>
#include <bitset>
#include <climits>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;

const ll modulo = 1e9 + 7;

ll fast_exp(ll x, ll y) {
  if (y == 0) return 1;
  ll half = fast_exp(x, y / 2);
  ll res = half * half % modulo;
  if (y % 2 == 1) res = res * x % modulo;
  return res;
}

class Solution {
  vector<ll> fac, rev;

  ll C(int n, int k) {
    if (k > n) return 0;
    ll ans = fac[n] * rev[n - k] % modulo;
    ans = ans * rev[k] % modulo;
    return ans;
  }

 public:
  void solve() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    if (k == 1) {
      cout << 0;
      return;
    }

    fac = vector<ll>(n + 1);
    rev = vector<ll>(n + 1);
    fac[0] = 1;
    for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % modulo;
    for (int i = 0; i <= n; ++i) rev[i] = fast_exp(fac[i], modulo - 2);

    sort(a.begin(), a.end());
    ll lo = 0, hi = 0;
    for (int i = 0; i < n; ++i) {
      ll l = C(n - i - 1, k - 1) * a[i] % modulo;
      ll h = C(i, k - 1) * a[i] % modulo;
      lo = (lo + l) % modulo;
      hi = (hi + h) % modulo;
    }

    ll ans = (hi - lo) % modulo;
    ans = (ans + modulo) % modulo;

    cout << ans;
  }
};

int main() {
  Solution solution = Solution();
  solution.solve();
}

Measured memory_bytes: 2560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            long ans = 0;

            for (int i = 1; i <= n; i++) {
                long tmp = n / i;
                ans += tmp * (2 * i + (tmp - 1) * i) / 2;
            }

            // 出力
            out.println(ans);

        }

    }
}



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

int main() {
    string s; cin >> s;
    string ans;
    ans.push_back(s[0]);
    ans += to_string(s.size()-2);
    ans.push_back(s[s.size()-1]);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
#include <algorithm>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;

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

int main(){
    ll n, k; cin >> n >> k;
    cout << min(n%k, k - (n%k)) << endl;
    return 0;
}


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

struct DisjointSet {
public:
    vector<int> rank, p;
    DisjointSet() {};
    DisjointSet(int n) {
        rank.resize(n, 0);
        p.resize(n, 0);
        for (int i = 0; i < n; i++) makeSet(i);
    }
    void makeSet(int i) {
        p[i] = i; //representative
        rank[i] = 0; //height
    }
    void unite(int x, int y) {
        link(findSet(x), findSet(y) );
    }
    bool same(int x, int y) {
        if (findSet(x) == findSet(y) ) return true;
        else return false;
    }
    int findSet(int x) {
        if (x != p[x]) p[x] = findSet(p[x]); //root's parent is itself
        return p[x];
    }
    void link(int fx, int fy) {
        if (rank[fx] > rank[fy]) { //y is lower
            p[fy] = fx;
        } else {
            p[fx] = fy;
            if (rank[fx] == rank[fy]) rank[fy]++;
        }
    }
};
int main() {
    int n, q;
    cin >> n >> q;
    int com, x, y;
    DisjointSet ds = DisjointSet(n);
    for (int i = 0; i < q; i++) {
        cin >> com >> x >> y;
        if ( com == 0) {
            ds.unite(x, y);
        } else {
            if (ds.same(x, y) ) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
constexpr ll MOD = ll(1e9) + 7;

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

	string s, t;
	for(int i = 0; i < b; ++i) {
		s += (char)('0' + a);
	}
	
	for(int i = 0; i < a; ++i) {
		t += (char)('0' + b);
	}
	
	if( s <= t ) cout << s << endl;
	else cout << t << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>

using namespace std;

int main()
{
    // 整数の入力
    long long N,K,i;
    cin >> K;
    N = 50;
    cout << N << endl;
    long long base = K/50;
    long long amari = K % 50;
    for (i= 0; i< N;i++){
        if (i != 0){
            cout << " ";
        }
        if (i < amari){
            cout << N - i + base;
        }else{
            cout << N - i + base - 1;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int ask(vector < int >& v) {
    cout << "? ";
    for (int p : v) cout << p << " ";
    cout << endl;
    string s;
    cin >> s;
    return s == "Red";
}
int ans[205];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    vector < int > v(n);
    iota(v.begin(), v.end(), 1);
    int f = ask(v);
    int l = 0;
    int r = n;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        vector < int > nv = v;
        for (int i = 1; i <= mid; i++) {
            nv[i - 1] = n + i;
        }
        if (ask(nv) != f) r = mid;
        else l = mid;
    }
    for (int i = 1; i <= l; i++) {
        v[i - 1] = n + i;
    }
    // del r, add n + r
    vector < bool > used(2 * n + 1);
    for (int c : v) used[c] = true;
    for (int i = 1; i <= 2 * n; i++) {
        if (!used[i]) {
            v[r - 1] = i;
            if (ask(v)) {
                ans[i] = 1;
            }
            else {
                ans[i] = 0;
            }
        }
    }
    for (int i = 1; i <= l; i++) {
        v[i - 1] = i;
    }
    for (int i = r; i <= n; i++) {
        v[i - 1] = n + i;
    }
    used.assign(used.size(), false);
    for (int c : v) used[c] = true;
    for (int i = 1; i <= 2 * n; i++) {
        if (!used[i]) {
            v[r - 1] = i;
            if (ask(v)) {
                ans[i] = 1;
            }
            else {
                ans[i] = 0;
            }
        }
    }
    cout << "! ";
    for (int i = 1; i <= 2 * n; i++) {
        if (ans[i]) {
            cout << "R";
        }
        else {
            cout << "B";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 724
#include<iostream>
#include<map>
using namespace std;
int main(){
	int k;
	cin>>k;
	int num=7,cnt=1,flag=0;
	map<long long ,int> mp;
	while(num!=0){
		while(num<k){
			num=num*10+7;
			cnt++;
		}
		if(mp[num]==1){
			flag=1;
			break;
		}
		else mp[num]=1;
		if(num%k==0)break;
		num=num%k;
	}
	if(flag==1)cout<<"-1"<<endl;
	else cout<<cnt<<endl;
	return 0;
}

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

int main() {
  int64_t x, n;
  cin >> x >> n;

  set<int64_t> p;
  rep(i, n) {
    int val;
    cin >> val;
    p.insert(val);
  }

  int ans;
  int low = x;
  int high = x;
  while (true) {
    if (!p.count(low)) {
      ans = low;
      break;
    } else if (!p.count(high)) {
      ans = high;
      break;
    }
    low--;
    high++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 1000000007;
const lli e3 = 1 << 13;
const lli INF = 1ll << 62;

lli n;
graph g;
lli ling[e5];
lli vis[e5];
lli a,b;
lli mem[e5];

lli ling_search(lli x){
  if(vis[x] && ling[x] >= 0){
    ling[x] = 1;
    return ling[x];
  }
  vis[x] = 1;
  for(auto y : g[x]){
    if(ling_search(y.first) > 0){
      ling[x] = 1;
      return ling[x];
    }
  }
  ling[x] = -1;
  return ling[x];
}

lli dfs(lli x){
  unordered_set<lli> s;
  for(auto y : g[x]){
    if(y.second == 0) continue;
    s.insert(dfs(y.first));
  }
  for(lli i = 0;i <= g[x].size();i++){
    if(s.count(i) == 0) return mem[x] = i;
  }
  cerr << "error" << endl;
  return -1;
}

lli dfs2(lli x){
  unordered_set<lli> s;
  for(auto y : g[x]){
    if(y.second == 0) continue;
    s.insert(dfs2(y.first));
  }
  if(x != a){
    for(lli i = 0;i <= g[x].size();i++){
      if(s.count(i) == 0) return mem[x] = i;
    }
  }else{
    lli i = 0;
    for(i = 0;i <= g[x].size()+1;i++){
      if(s.count(i) == 0) break;
    }
    i++;
    for(;i <= g[x].size()+1;i++){
      if(s.count(i) == 0) return mem[x] = i;
    }
  }
  cerr << "error" << endl;
  return -1;
}

int main(){
  cin >> n;
  for(lli i = 1;i <= n;i++){
    lli p;
    cin >> p;
    g[p][i] = 1;
    g[0][i] = 1;
  }
  ling_search(0);
  for(lli i = 1;i <= n;i++){
    if(ling[i] == 1){
      a = i;
      for(auto y : g[i]){
        if(ling[y.first] == 1){
          b = y.first;
          break;
        }
      }
      break;
    }
  }
  g[a][b] = 0;
  fill(mem,mem+n+1,0);
  dfs(b);
  if(mem[a] != mem[b]){
    cerr << 1 << endl;
    cout << "POSSIBLE" << endl;
    return 0;
  }
  lli hoge = mem[a];
  fill(mem,mem+n+1,0);
  dfs2(b);
  if(mem[b] == hoge){

    cout << "POSSIBLE" << endl;
    return 0;
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 64016
#include <cstdio>
#include <vector>
#include <algorithm>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

constexpr int mod = 1e9+7;
int main() {
    int n; scanf("%d", &n);
    vector<int> a(n), b(n); repeat (i,n) scanf("%d%d", &a[i], &b[i]);
    int max_a = *whole(max_element, a);
    int max_b = *whole(max_element, b);
    vector<vector<int> > choose = vectors(2*max_a+1, 2*max_b+1, int());
    choose[0][0] = 1;
    vector<vector<int> > dp = vectors(2*max_a+1, 2*max_b+1, int());
    repeat (i,n) {
        dp[max_a-a[i]][max_b-b[i]] += 1;
    }
    repeat (y,2*max_a+1) {
        repeat (x,2*max_b+1) {
            choose[y][x] %= mod;
            dp[y][x] %= mod;
            if (y+1 < 2*max_a+1) choose[y+1][x] += choose[y][x];
            if (x+1 < 2*max_b+1) choose[y][x+1] += choose[y][x];
            if (y+1 < 2*max_a+1) dp[y+1][x] += dp[y][x];
            if (x+1 < 2*max_b+1) dp[y][x+1] += dp[y][x];
        }
    }
    ll result = 0;
    repeat (i,n) {
        result += dp[max_a+a[i]][max_b+b[i]];
        result -= choose[2*a[i]][2*b[i]];
    }
    result %= mod;
    result *= (mod+1)/2;
    result %= mod;
    if (result < 0) result += mod;
    printf("%lld\n", result);
    return 0;
}


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

int main(){
  while(1){
  int x,y,s,mo,mo1,mo2,max=0;
  cin>>x>>y>>s;
  if(x+y+s==0) break;
  for(int i=1;i<s-1;i++){
    for(int j=1;j<=s-1;j++){
      mo1=i*(100+x)/100;
      mo2=j*(100+x)/100;
      if(mo1+mo2==s){
	mo1=i*(100+y)/100;
	mo2=j*(100+y)/100;
	mo=mo1+mo2;
	if(max<mo) max=mo;
      }
    }
  }
  cout<<max<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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; }
const long long INF = 1LL<<60;

int main(){
    int N;cin >> N;
    for(int i=0;i<N;i++){
        int a;cin >> a;
        if(a&1) continue;
        if(a%3==0) continue;
        if(a%5==0) continue;
        cout << "DENIED" << endl;
        return 0;
    }
    cout << "APPROVED" << endl;
}

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

int main() {
  int N, M;
  long long workNum = 0;
  cin >> N >> M;
  for (int i = 0; i < M; i++){
    int l;
    cin >> l;
    workNum+=l;
  }
  cout << (N < workNum ? -1 : N - workNum) << endl;
  return 0;
}

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

using ll = long long;

int main() {

    ll a, b, c;

    cin >> a >> b >> c;

    ll aa = a * a;
    ll bb = b * b;
    ll cc = c * c;

    ll left = a + b - c;

    if(left >= 0) {
        cout << "No";
        return 0;
    }

    ll x = aa + bb + cc + 2*a*b - 2*b*c - 2*c*a;


    if(x > 4*a*b)
        cout << "Yes";
    else
        cout << "No";
    
    cout << endl;

    return 0;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int n;
    string s;
    int k;
    cin>>n>>s>>k;
    for(int i=0;i<n;i++){
        if(s[i]!=s[k-1]){
            cout<<'*';
        }else{
            cout<<s[i];
        }
    }
    cout<<endl;
    
}


Measured memory_bytes: 3612
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
 
ll f(ll b, ll n) {
	if (n < b) return n;
	return f(b, n / b) + n % b;
}
 
int main() {
	ll n, s;
	cin >> n >> s;
 
	for (ll b = 2; b * b <= n; b++) {
		if (f(b, n) == s) {
			cout << b << endl;
			return 0;
		}
	}
 
	ll ans = n == s ? (s + 1) : -1;
	for (ll x = 1; x * x <= n - s; x++) {
		if ((n - s) % x != 0) continue;
 
		ll b = (n - s) / x + 1,
		   y = s - x;
 
		if (1 <= x and x < b and 0 <= y and y < b) {
			ans = ans < 0 ? b : min(ans, b);
		}
	}
 
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  let
    unsafeBinaryMinInt :: (Int -> Bool) -> (Int, Int) -> Int
    unsafeBinaryMinInt p = check
      where
        check :: (Int, Int) -> Int
        check ij@(i, _) | p i       = i
                        | otherwise = search ij
        search :: (Int, Int) -> Int
        search = snd . until ((==) <$> succ . fst <*> snd) halve
          where
            halve :: (Int, Int) -> (Int, Int)
            halve (i, j) | p m       = (i, m)
                         | otherwise = (m, j)
              where
                m = (i + j) `div` 2
  [_, k] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  as <- map (subtract 1 . unsafeTextToInt) . T.words <$> T.getLine :: IO [Int]
  let
    p :: Int -> Bool
    p i = (<= k) . sum . map (`div` i) $ as
  print $  unsafeBinaryMinInt p (1, 10 ^ 9)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 18836
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int n;cin>>n;
    vii v(n);
    
    for(int i=1;i<=n;i++){
        int in;cin>>in;
        v[i-1]={in,i};
    }
    sort(all(v));
    for(pii i:v){
        cout<<i.second<<" ";
    }
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>
#include<cmath>
#include<queue>

typedef long long ll;
using namespace std;
#define mod 10007
#define rep(i,n) for(ll i=0;i<n;i++)

int main(void){
  string s;
  cin >> s;
  string ans="Yes";
  int cnt['d'];
  for(int i=0;i<int('d');i++){
    cnt[i]=0;
  }


  for(char x:s){
    if(x!='a' && x!='b' && x!='c'){
      ans="No";
    }else{
      cnt[int(x)]++;
      if(cnt[int(x)]>=2){
        ans="No";
      }
    }
  }
  cout << ans << endl;
  return 0;

}


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

string print(string s, int a, int b){
	return s.substr(a, b - a + 1);
}

string reverse(string s, int a, int b){
	string news = s;
	for (int i = 0; i < b - a + 1; i++){
		news[b - i] = s[a + i];
	}
	return news;
}

string replace(string s, int a, int b, string p){
	return s.replace(a, b - a + 1, p);
}

int main()
{
	string str, command;
	int q;
	cin >> str;
	cin >> q;
	for (int i = 0; i < q; i++){
		cin >> command;
		int a, b;
		cin >> a >> b;
		string p;
		if (command == "print"){
			cout << print(str, a, b) << endl;
		}
		else if (command == "reverse"){
			str = reverse(str, a, b);
		}
		else if (command == "replace"){
			cin >> p;
			str = replace(str, a, b, p);
		}
	}
	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
signed main(){
  queue<int>a[10000];
  int b,c,d;
  int q,w;
  cin>>q>>w;
  for(int i=0;i<w;i++){
    cin>>b>>c;
    if(b==0) cin>>d,a[c].push(d);
    if(b==1) if(!a[c].empty()) cout<<a[c].front()<<"\n";
    if(b==2) if(!a[c].empty()) a[c].pop();
  }
}



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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> a;
    rep(i, n)
    {
        int c;
        cin >> c;
        a.push_back(make_pair(c, i));
    }
    SORT(a);
    rep(i, n)
    {
        cout << a[i].second + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 1780
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k,l;
  int a[100][100],b[50][50],m,n;

  while(cin>>n>>m&&n+m){
    for(i=0;i<n;i++)
      for(j=0;j<n;j++)
	cin>>a[j][i];
    for(i=0;i<m;i++)
      for(j=0;j<m;j++)
	cin>>b[j][i];
    for(i=0;i<n-m+1;i++){
      for(j=0;j<n-m+1;j++){
	for(k=0;k<m;k++){
	  for(l=0;l<m;l++){
	    if(b[l][k]!=-1&&
	       b[l][k]!=a[j+l][i+k])
	      break;
	  }
	  if(l!=m)
	    break;
	}
	if(k==m){
	  for(k=0;b[k][0]==-1;k++);
	  cout<<j+k+1<<" "<<i+1<<endl;;
	  break;
	}
	for(k=0;k<m;k++){
	  for(l=0;l<m;l++){
	    if(b[m-k-1][l]!=-1&&
	       b[m-k-1][l]!=a[j+l][i+k])
	      break;
	  }
	  if(l!=m)
	    break;
	}
	if(k==m){
	  for(k=0;b[m-1][k]==-1;k++);
	  cout<<j+k+1<<" "<<i+1<<endl;
	  break;
	}
	for(k=0;k<m;k++){
	  for(l=0;l<m;l++){
	    if(b[m-l-1][m-k-1]!=-1&&
	       b[m-l-1][m-k-1]!=a[j+l][i+k])
	      break;
	  }
	  if(l!=m)
	    break;
	}
	if(k==m){
	  for(k=0;b[m-k-1][m-1]==-1;k++);
	  cout<<j+k+1<<" "<<i+1<<endl;
	  break;
	}
	for(k=0;k<m;k++){
	  for(l=0;l<m;l++){
	    if(b[k][m-l-1]!=-1&&
	       b[k][m-l-1]!=a[j+l][i+k])
	      break;
	  }
	  if(l!=m)
	    break;
	}
	if(k==m){
	  for(k=0;b[0][m-k-1]==-1;k++);
	  cout<<j+k+1<<" "<<i+1<<endl;
	  break;
	}
      }
      if(j!=n-m+1)
	break;
    }
    if(i==n-m+1)
      cout<<"NA"<<endl;
  }
  return 0;
}

Measured memory_bytes: 928
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

vector<int> D;
void solve(){
	
	int N;
	cin>>N;
	
	for(int i=6;i<=N;i=i*6){
		D.push_back( i );
	}
	for(int i=9;i<=N;i=i*9){
		D.push_back( i );
	}
	sort(D.begin(),D.end());
	int size = D.size();

	vector<int> dp(N+1,INF);
	dp[0] = 0;
	for(int i=0;i<=N;++i){
		if(dp[i] < INF ){
			for(int j=0;j<size;++j){
				int ter = i + D[j];
				if(ter > N ){
					break;
				}
				dp[ter] = min(dp[ter],dp[i]+1);
			}
		}
	}
	int ans = INF;
	for(int i=0;i<=N;++i){
		if(dp[i]==INF ){
			continue;
		}
		int res = dp[i] + N-i;
		ans = min(ans,res);
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

/*RE→解説後
ソートしないならmap<int,pair<int,int>> なんて使わなくてよい
costの計算は累積和を求めるときでよい
累積和もD飛ばしで和をとるだけでいい
解法を単純にしよう
追記：x,yは1～h*W(90000)のあたいが書かれている座標
*/
int main() {
  int h,w,d;
  cin>>h>>w>>d;
  int x[90009],y[90009];
  rep(i,h) rep(j,w){
    int a;
    cin>>a;
    a--;
    x[a]=i;
    y[a]=j;
  }
  int sums[90009];
  for(int i=d;i<h*w;++i)
    sums[i]=sums[i-d]+abs(x[i]-x[i-d])+abs(y[i]-y[i-d]);
  
  int q;
  cin>>q;
  rep(i,q){
    int l,r;
    cin>>l>>r;
    cout<<sums[r-1]-sums[l-1]<<endl;
  }
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include<stack>
#include<string>
#include<algorithm> 
#include <set>
#include<list>
#include <bit>
#include <bitset>
#include <cstdint>
#include <initializer_list>
typedef long long int ll;
using namespace std;
const int MOD = 1000000007;


int main() {
	string str,temp; cin >> str;
	ll num=0;
	for (int i = 0; i < str.length(); i++) {
		temp = str[i];
		num += atoi(temp.c_str());
	}
	if (num % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3268
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



string n;

int main(){
  ll H,W;
  cin >> H >> W;
  if(H == 1 || W == 1) cout << 1 << endl;
  else if(H*W%2==0) cout << H*W/2 << endl;
  else cout << H*W/2 + 1 << endl;
  
 
  return 0;
}


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

int main() {
	int N, num, count, sum = 0, ans = 10000000;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> num;
		count = 0;
		while (true)
		{

			if (num % 2 == 0)
			{
				count++;
				num = num >> 1;
			}
			else
			{
				break;
			}

		}
		ans = min(ans, count);
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n, tmp, num=0;
    cin >> n;
    vector<int> A;
    vector<long long> sticks;
    for (int i = 0; i < n; i++){
        cin >> tmp;
        A.push_back(tmp);
    }
    sort(A.begin(), A.end(), greater<int>());
    
    for (int i = 1; i < n; i++){
        if (A[i] == A[i-1]){
            sticks.push_back(A[i]);
            i++;
            num++;
        }
    }
    if (num < 2){
        cout << 0 << endl;
    }else{
     cout << sticks[0] * sticks[1] << endl;   
    }
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

int N,M;
int A[114514],B[114514];
int S[114514]={};
vector<int> G[114514];
vector<PP> CD;
bool visited[114514]={};
bool added[114514]={};
int parent[114514]={};
int dist[114514]={};
map<PP,int> Mp;

void dfs1(int p){
    visited[p]=true;
    REP(i,G[p].size()){
        if(visited[G[p][i]]==false){
            parent[G[p][i]]=p;
            dist[G[p][i]]=dist[p]+1;
            dfs1(G[p][i]);
            Mp[{p,G[p][i]}]=1;
            S[p]++;
        }
    }
}

void dfs2(int p){
    REP(i,G[p].size()){
        if(parent[G[p][i]]==p){
            dfs2(G[p][i]);
        }
    }
    if(S[p]%2==1){
        int q=parent[p];
        Mp[{q,p}]--;
        Mp[{p,q}]++;
        S[q]--;
        S[p]++;
    }
}


signed main(void){
    cin >> N >> M;
    REP(i,M){
        cin >> A[i] >> B[i];
        A[i]--;B[i]--;
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    if(M%2==1)GOODBYE;
    
    dfs1(0);
    REP(i,M){
        if(Mp[{A[i],B[i]}]+Mp[{B[i],A[i]}]==0){
            if(dist[A[i]]<=dist[B[i]]){
                Mp[{A[i],B[i]}]=1;
                S[A[i]]++;
            }else{
                Mp[{B[i],A[i]}]=1;
                S[B[i]]++;
            }
        }
    }
    dfs2(0);
    
    //REP(i,M){cout << A[i]+1 MM B[i]+1 MM Mp[{A[i],B[i]}]<<","<<Mp[{B[i],A[i]}] << endl;}cout << endl;
    //REP(i,M){cout << i+1 MM S[i] << endl;}cout << endl;
    //REP(i,M){cout << i+1 MM dist[i] << endl;}cout << endl;
    
    REP(i,M){
        if(Mp[{A[i],B[i]}]==1){
            cout << A[i]+1 MM B[i]+1 << endl;
        }
        if(Mp[{B[i],A[i]}]==1){
            cout << B[i]+1 MM A[i]+1 << endl;
        }
    }
    
    
    return 0;
}



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

int main() {
  int HPt, ATKt, HPa, ATKa;
  cin >> HPt >> ATKt >> HPa >> ATKa;
  for(int i; ; i++){
    HPa-=ATKt;
    if(HPa<=0) {
      cout << "Yes" << endl;
      break;
    }
    HPt-=ATKa;
    if(HPt<=0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void check_all_paths (string & ss);
void check_simple (string & ss);

int main () {
    // paper (p) <= rock (g)
    string s;
    cin >> s;

    // check_all_paths(s);

    check_simple(s);

    return 0;
}

void check_simple (string & s) {
    int max_p = s.size()/2;
    int act_p = 0;
    for(int i = 0; i < s.size(); i++) {
        if (s[i] == 'p') act_p++;
    }
    cout << max_p - act_p << endl;
}


struct ss {
    bool g, p;
    int score;
};

void check_all_paths (string & s) {
    int gs = 0, ps = 0, i = 0, n=s.size();

    vector<ss> v(n);
    int score=0, max_score=-999999999;

    /*
      g 
     */
    while (i>=0) {
        if ( i == n ) {
            if (score > max_score)
                max_score=score;

//             cout << s << endl;
//             for(int x=0; x<n;x++) {
//                 cout << (v[x].p ? 'p' : 'g');
//             }
//             cout << " : " << gs << " - " << ps;
//             cout << endl;
//             for(int x=0; x<n;x++) {
//                 cout << (v[x].score < 0
//                          ? 'L' : (v[x].score == 0 ? 'D' : 'W'));
//             }

//             cout << " score = " << score
//                  << " (" << max_score << ")" << endl;

            i--;
        }

        char c = s[i];

        if (v[i].g == false) {
            gs++;
            if ( c == 'p' ) {
                score -= 1;
                v[i].score = -1;
            }
            v[i].g = true;
            i++;
            continue;
        } else if (v[i].p == false) {
            gs--;
            if (gs > ps) { // p 
                ps++;
                if ( c == 'g' ) {
                    score += 1;
                    v[i].score = +1;
                }
                v[i].p = true;
                i++;
                continue;
            }
        }        

        // both g & p tried
        if (v[i].p) ps--;
        v[i].g = v[i].p = false;
        score -= v[i].score;
        v[i].score = 0;
        i--;
        score -= v[i].score;
        v[i].score = 0;

    }

    cout << max_score << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
ll N,a,b,c,d;
unordered_map<ll,ll>s;
ll calc(ll x){
	ll ans=100000000000000;
	if(log(x)+log(d)<log(ans))ans=x*d;
	if(x<=1)return ans;
	if(s[x])return s[x];
	int g=x%2;
	ans=min(ans,calc((x-g)/2)+g*d+a);
	if(g&1)
	ans=min(ans,calc((x-g)/2+1)+(2-g)*d+a);
	
	g=x%3;
	if(g<=1)
	ans=min(ans,calc((x-g)/3)+g*d+b);
	else
	ans=min(ans,calc((x-g)/3+1)+(3-g)*d+b);
	
	g=x%5;
	if(g<=2)
	ans=min(ans,calc((x-g)/5)+g*d+c);
	else 
	ans=min(ans,calc((x-g)/5+1)+(5-g)*d+c);
	return s[x]=ans;
}
int main(){
	int t;cin>>t;
	for(int i=1;i<=t;i++){
		cin>>N>>a>>b>>c>>d;
		s.clear();
		cout<<calc(N)<<endl;
	}
    return 0;
}








Measured memory_bytes: 4284
# 初期入力
import sys
input = sys.stdin.readline
N,M = (int(i) for i in input().split())
ans_L =[]
ans_R =[]
for i in range(M):
    L,R = (int(x) for x in input().split())
    ans_L.append(L)
    ans_R.append(R)
#
ans =0
max_L =max(ans_L)
min_R =min(ans_R)
if max_L > min_R:
    ans =0
else:
    ans =min_R -max_L +1
print(ans)

Measured memory_bytes: 16852
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll x,y;
  cin >> x >> y;
  ll a,b;
  a = y - x * 2;
  b = x * 4;
  if(a < 0 || a % 2 == 1 || b < y)cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3620
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 2e3 + 5;
int n,k;

int mod = 1e9+7;
struct modular {
    int value;
    modular(long long v = 0) { value = v % mod; if (value < 0) value += mod;}
    modular(long long a, long long b) : value(0){ *this += a; *this /= b;}
    modular& operator+=(modular const& b) {value += b.value; if (value >= mod) value -= mod; return *this;}
    modular& operator-=(modular const& b) {value -= b.value; if (value < 0) value += mod;return *this;}
    modular& operator*=(modular const& b) {value = (long long)value * b.value % mod;return *this;}
    //其他函数调用mexp(modular(10),3);
    friend modular mexp(modular a, long long e) {
        modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
        return res;
    }
    friend modular inverse(modular a) { return mexp(a, mod - 2); }
    modular& operator/=(modular const& b) { return *this *= inverse(b); }
    friend modular operator+(modular a, modular const b) { return a += b; }
    friend modular operator-(modular a, modular const b) { return a -= b; }
    friend modular operator-(modular const a) { return 0 - a; }
    friend modular operator*(modular a, modular const b) { return a *= b; }
    //除法只有在mod是素数可用;
    friend modular operator/(modular a, modular const b) { return a /= b; }
    friend ostream& operator<<(ostream& os, modular const& a) {return os << a.value;}
    friend istream& operator>>(istream& is, modular & a){long long value; is >> value;a.value = 0; a += value;  return is;}
    friend bool operator==(modular const& a, modular const& b) {return a.value == b.value;}
    friend bool operator!=(modular const& a, modular const& b) {return a.value != b.value;}
};


modular comb[N][N];
void init_comb(){
    for(int i = 0; i<N; i++){
        comb[i][i]=1;
        comb[i][0]=1;
        for(int j = 1; j<i; j++){
            comb[i][j] = comb[i-1][j]+comb[i-1][j-1];
        }
    }
}

modular get_comb(int x, int y){
    if(y>x)return 0;
    if(x==-1)return 1;
    else return comb[x][y];
}


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>k;
    
    init_comb();
    
    for (int i = 1; i <= k; i++){
        modular ans = 0;
        ans += get_comb(k-1,i-1) * get_comb(n-k-1,i-1)*2 + get_comb(k-1,i-1) * get_comb(n-k-1,i-2) +get_comb(k-1,i-1) *get_comb(n-k-1,i);
        cout<<ans<<endl;
    }
    
    
    
    
    return 0;
}



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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  
  int n;
  cin >> n;
  
  unordered_map<int, int> count;
  
  int a;
  for(int i=0;i<n;i++){
    cin >> a;
    count[a]++;
  }
  
  int countToBeRemoved = 0;
  for(auto p:count){
    if(p.first<p.second){
      countToBeRemoved += p.second-p.first;
    }
    else if(p.first>p.second){
      countToBeRemoved += p.second;
    }
  }
  cout << countToBeRemoved << endl; 
  return 0;
}



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

int main(void) {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<long long> p(A), q(B), r(C);
  for (int i = 0; i < A; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < B; i++) {
    cin >> q[i];
  }
  for (int i = 0; i < C; i++) {
    cin >> r[i];
  }
  sort(p.begin(), p.end(), greater<long long>());
  sort(q.begin(), q.end(), greater<long long>());
  sort(r.begin(), r.end(), greater<long long>());
  priority_queue<long long> pq;
  for (int i = 0; i < X; i++) {
    pq.push(p[i]);
  }
  for (int i = 0; i < Y; i++) {
    pq.push(q[i]);
  }
  for (int i = 0; i < min(X + Y, C); i++) {
    pq.push(r[i]);
  }
  long long ans = 0;
  for (int i = 0; i < X + Y; i++) {
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8816
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	string arr[4] = { "AC","WA","TLE","RE" };
	int count[4] = { 0,0,0,0 };
	for (int i = 0; i < N; i++) {
		string number;
		cin >> number;
		for (int j = 0; j < 4; j++) {
			if (number == arr[j]) {
				count[j]++;
			}
		}
	}
	for (int i = 0; i < 4; i++) {
		cout << arr[i] << " x " << count[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n, i, a, b;
    double ans=0;
    vector <double> v;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    for(i=0;i<n-1;i++){
        v[i+1]=(v[i]+v[i+1])/2.0;
    }
    cout << v[i] <<endl;

    return 0;
}

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

int main() {
    int N, M, X;
    cin >> N >> M >> X;

    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    for(int i=0;i<N;i++){
        cin >> C[i];
        for(int j=0;j<M;j++){
            cin >> A[i][j];
        }
    }

    int ans = -1;
    for(int bit=0;bit<(1 << N);bit++){
        vector<int> s(M, X);
        int cost_sum = 0;
        for(int i=0;i<N;i++){
            if((bit>>i)&1){
                cost_sum += C[i];
                for(int j=0;j<M;j++){
                    s[j] -= A[i][j];
                }
            }
        }
        bool ok = true;
        for(int j=0;j<M;j++){
            if(s[j] > 0){
                ok = false;
                break;
            }
        }
        if(ok){
            if(ans == -1){
                ans = cost_sum;
            }else{
                ans = min(ans, cost_sum);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	
	Scanner sc;
	
	class Point{
		public double x,y;
		
		public String toString(){
			return "("+x+","+y+")";
		}
		
		public Point(double x,double y){
			this.x=x;
			this.y=y;
		}
	}
	
	double getTheta(Point p,Point p0){
		double theta=Math.acos((p.x-p0.x)/Math.hypot(p.x-p0.x,p.y-p0.y));
		if(p.y<p0.y)theta=Math.PI*2-theta;
		return theta;
	}
	
	int solve(Point[] points){
		Point start=points[0];
		for(Point v:points){
			if(v.y<start.y)start=v;
		}
		Point p0=start;
		int n=0;
		double prev=0;
		do{
			double min=Math.PI*3;
			Point next=p0;
			for(Point p: points){
				double theta=getTheta(p,p0);
				if(theta>=prev&&theta<min){
					min=theta;
					next=p;
				}
			}
			p0=next;
			prev=min;
			++n;
		}while(p0!=start);
		return points.length-n;
	}
	
	double nd(){
		return sc.nextDouble();
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	void io(){
		sc=new Scanner(System.in);
		sc.useDelimiter(",|"+System.getProperty("line.separator"));
		
		int n;
		Point[] points;
		while((n=ni())!=0){
			points=new Point[n];
			for(int i=0;i<n;++i){
				points[i]=new Point(nd(),nd());
			}
			System.out.println(solve(points));
		}
		sc.close();
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
	}
}

Measured memory_bytes: 19172
#![allow(dead_code)]

use std::io;
fn main() {
    solve_d();
}

fn solve_d() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let s = s.trim().to_string();
    let s = s.clone() + s.as_str();

    let mut p = String::new();
    io::stdin().read_line(&mut p).unwrap();
    let p = p.trim().to_string();

    let mut ans = "No";
    for i in 0..(s.len() - p.len()) {
        let mut m = 0;
        for j in 0..p.len() {
            let sc = s.chars().nth(i + j).unwrap();
            let pc = p.chars().nth(j).unwrap();
            if sc == pc {
                m += 1;
            }
        }
        if m == p.len() {
            ans = "Yes";
        }
    }
    println!("{}", ans);
}




Measured memory_bytes: 5024
#include <bits/stdc++.h>
#include <regex>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(5)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 1145141919;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator > (const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

P d[4] = { P(1, 1), P(-1, -1), P(-1, 1), P(1, -1) };
P r[2] = { P(1, 1), P(-1, -1) };
int main()
{
	int n; 
	while (cin >> n,n)
	{
		vector<vector<P>> v(n+1);
		REP(j, n+1)
		{
			int m; cin >> m;
			int x, y; cin >> x >> y;
			REP(i, m - 1)
			{
				int a, b;
				cin >> a >> b;
				v[j].push_back(P(a - x, b - y));
				x = a; y = b;
			}
		}

		FOR(i, 1, n + 1)
		{
			if (v[i].size() != v[0].size()) continue;
			bool f;
			REP(j, 4)
			{
				REP(k, 2)
				{

					f = true;
					REP(l, v[i].size())
					{
						int tx, ty;
						tx = v[i][l].first*d[j].first;
						ty = v[i][l].second*d[j].second;
						if (j > 1) swap(tx, ty);
						int ux = v[0][(k ? v[0].size() - l - 1 : l)].first * r[k].first;
						int uy = v[0][(k ? v[0].size() - l - 1 : l)].second * r[k].second;
						if (!(tx == ux&&ty == uy)) f = false;
					}
					if (f) goto end;

				}
			}

		end:;
			if (f) cout << i << endl;
		}
		puts("+++++");
	}
	return 0;
}

Measured memory_bytes: 1212
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SZ(x) ((int)(x).size())
typedef long long ll;

using namespace std;

int main(){
  int P,Q,R;
  cin >> P >> Q >> R;
  cout << min({P+Q,Q+R,R+P}) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String[] line = sc.nextLine().split(" ");
		sc.close();

		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);

		if(isValid(a) && isValid(b)) {
			if (isEven(a, b)) {
				System.out.println("Even");
			} else {
				System.out.println("Odd");
			}
		}
	}

	private static boolean isEven(int a, int b) {

		if ((a * b) % 2 == 0) {
			return true;
		} else {
			return false;
		}
	}

	private static boolean isValid(int num) {
		if (num >= 1 && num <= 10000) {
			return true;
		} else {
			return false;
		}
	}

}


Measured memory_bytes: 21460