akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
#define PI 3.1415926535

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

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

char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}

char lower(char c){
    if('A' <= c && c <= 'Z'){
        c = c + ('a' - 'A');
    }
    return c;
}

const ll INF = 1000000000000000000;

//input
ld L;

//processing


//dpTable
int dp[100050];

int main(){
    cin >> L;
    cout << setprecision(10) << pow(L / 3,3) << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10 ;
using ll = long long ;
const ll inf = 1e18;
int  n;
ll k ;

int zero;
vector<int> a;
ll div_floor(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll div_ceil(ll a, ll b) {
	return a / b + (((a ^ b) >= 0) and a % b);
}


bool ok (ll x) {
    ll now = x >= 0 ? 1LL * zero * n + (1LL * zero * (zero - 1) / 2) : 0;
    for (int i = 0 ; i < n - 1 ; i ++ ) {
        if (a[i] < 0) {
            ll minreq ;
             if (x < 0) minreq = div_ceil(x , a[i]);
             else minreq = x / a[i];

            int l = i + 1 ,  r = n - 1 , mid , ans = -1;
            while (l <= r) {
                mid = l + r >> 1;
                if (a[mid] >= minreq) {
                    ans = mid ;
                    r = mid - 1;
                }
                else l = mid + 1;
            }
            if (ans == -1) continue;
            now += n - ans;
        }
        else if (a[i] > 0) {
            ll minreq ;
            if (x >= 0) minreq = x / a[i];
            else minreq = div_floor(  x , a[i]);
            int l = i + 1 , r = n - 1 , mid , ans = -1;
            while (l <= r) {
                mid = l + r >> 1;
                if (a[mid] <= minreq) {
                    ans = mid ;
                    l = mid + 1;
                }
                else r = mid - 1;
            }
            if (ans == -1) continue;
            now += ans - i  ;
        }
        else throw;
    }
    return now >= k;
}

int main () {
    scanf("%d %lld", &n, &k);

    for (int i = 0 ;i < n; i++) {
        int x;
        scanf("%d", &x);
        if (x == 0) zero ++;
        else a.emplace_back(x);
    }
    sort(a.begin(), a.end());
    n = (int)a.size() ;
    ll l = -inf , r = inf, ans =-inf - 2;

    while (l <= r) {
        ll mid = l + r >> 1 ;
        if (ok(mid)) {
            ans = mid;
            r = mid - 1;
        }
        else l = mid + 1;
    }
    printf("%lld\n", ans);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 1400
program ABC081B;
var
	i,n,x,r,r0: longint;
	arr: array of integer;
begin
	r:=1<<29;
	read(n);
	SetLength(arr,n);
	for i:=0 to n-1 do begin
		read(arr[i]);
	end;
	for i:=0 to n-1 do begin
		r0:=0;
		x:=arr[i];
		while x mod 2 < 1 do begin
			r0:=r0+1;
			x:=x div 2;
		end;
		if r>r0 then begin
			r:=r0;
		end;
	end;
	writeln(r);
end.


Measured memory_bytes: 128
from math import gcd


def main():
    k = int(input())

    ans = 0
    for i in range(1, k+1):
        for j in range(1, k+1):
            s = gcd(i, j)
            for h in range(1, k+1):
                ans += gcd(s, h)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){
    int n;
    cin >> n;
    map<ll,int> m;

    rep(i,0,n){
        ll a;
        cin >> a;
        m[a]++;
    }

    ll ans = 0;
    for(auto i:m){
        if(i.sd >= i.ft)ans += i.sd - i.ft;
        else ans += i.sd;
    }
    P(ans);

    
	
	return  0;
}

Measured memory_bytes: 6272
#include<iostream>
using namespace std;
int main()
{
    long long i,j,n,s=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
        s+=i;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
int main(){
  int N;
  scanf("%d",&N);
  
  int i;
  int x[N];
  for(i=1;i<=N;i++){
    scanf("%d",&x[i]);
  }
  
  int j;
  int P;
  int max=0;
  for(i=1;i<=N;i++){
    if(max<x[i])	max=x[i];
  }
  int maxHP=0;
  int HP[max];
  for(i=1;i<=max;i++){
    HP[i]=0;
    P=i;
    for(j=1;j<=N;j++){
      HP[i]=HP[i]+(x[j]-P)*(x[j]-P);
    }
    if(i>=2){
		if(maxHP<HP[i])	maxHP=HP[i];
    }
  }
  
  int minHP=maxHP;
  for(i=1;i<=max;i++){
    if(minHP>HP[i])	minHP=HP[i];
  }
  printf("%d\n",minHP);
  
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramB
    {
        static void Main()
        {
            int k = NextInt;
            var s = Line;
            if (s.Length <= k)
            {
                System.Console.WriteLine(s);
            }
            else
            {
                System.Console.WriteLine($"{string.Join("", s.Take(k))}...");
            }
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 28296
/// @file

#include <cmath>
#include <iostream>
#include <map>
#include <vector>

namespace {

bool run(std::istream& is, std::ostream& os);
}  // unnamed namespace

/// @brief エントリポイント
#ifdef _TEST
static int run()
#else
int main()
#endif
{
  try {
    if (run(std::cin, std::cout) == false) {
      std::cerr << "main funciton error.\n";
      return EXIT_FAILURE;
    }
  } catch (const std::exception& e) {
    std::cerr << "catch exception\n";
    std::cerr << e.what() << "\n";
    return EXIT_FAILURE;
  }

  return EXIT_SUCCESS;
}

namespace {

/// @brief 実行処理
bool run(std::istream& is, std::ostream& os)
{
  const double GRAD_TEMP(6E-3);

  int n;
  is >> n;

  int t;
  int a;
  is >> t >> a;

  std::vector<int> hArray(n);
  for (auto& v: hArray) is >> v;

  // 指定した気温との誤差を算出
  std::map<double, int> epsMap;
  for (std::size_t idx = 0; idx < hArray.size(); ++idx) {
    const double TEMP = static_cast<double>(t) - hArray[idx] * GRAD_TEMP;
    const double EPS = std::abs(static_cast<double>(a) - TEMP);
    epsMap[EPS] = idx;
  }

  os << epsMap.begin()->second + 1 << "\n";

  return true;
}
}  // unnamed namespace


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

int main(){
    int N;
    cin >> N;

    vector<tuple<string, int, int>> p(N);
    for(int i = 0; i < N; ++i){
        string a;
        int b;
        cin >> a >> b;
        p.at(i) = make_tuple(a, -b, i + 1); // bをマイナス! 符号を逆転させることで、降順昇順が逆転する
    }

    sort(p.begin(), p.end());

    for(tuple<string, int ,int> a: p) {
        string b;
        int c, d;
        tie(b, c, d) = a;

        cout << d << endl;
    }
}


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



int main()
{
    //freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,s=0,y;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
    	y=floor(n/i);

    	s= s + ((y*(y+1)*i)/2);
    }
    cout<<s<<endl;
    
    return 0;
}

Measured memory_bytes: 3696
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
 
//辺edge->e : 逆辺edge->path[e.to][e.rev]
struct edge{
    int to,cap,rev;
};
 
vector<vector<edge>> path;
vector<int> visited;

void add_edge(int from,int to,int cap){
    path[from].push_back((edge){to,cap,(int)path[to].size()});
    path[to].push_back((edge){from,0,(int)path[from].size()-1});
}

int dfs(int v,int t,int f){
	if (v==t)
		return f;
	visited[v]=1;
	for(edge &e:path[v]){
		if (visited[e.to]==0 && e.cap>0){
			int d=dfs(e.to,t,min(f,e.cap));
			if (d>0){
				e.cap-=d;
				path[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow=0;
	while(1){
		visited.assign(visited.size(),0);
		int f=dfs(s,t,inf);
		if (f==0){
			return flow;
		}
		flow+=f;
	}
}

int main(){
    int n,m; cin>>n>>m;
    vector<string> s(n);
    rep(i,n) cin>>s[i];
    path.assign(n*m+2,vector<edge>(0));
    visited.assign(n*m+2,false);
    rep(i,n)rep(j,m){
        if((i+j)%2){
            if(s[i][j]=='.')
            add_edge(i*m+j+1,n*m+1,1);
            continue;
        }
        if(i>0 && s[i-1][j]=='.' && s[i][j]=='.')
        add_edge(i*m+j+1,(i-1)*m+j+1,1);
        if(i<n-1 && s[i+1][j]=='.' && s[i][j]=='.')
        add_edge(i*m+j+1,(i+1)*m+j+1,1);
        if(j>0 && s[i][j-1]=='.' && s[i][j]=='.')
        add_edge(i*m+j+1,i*m+j,1);
        if(j<m-1 && s[i][j+1]=='.' && s[i][j]=='.')
        add_edge(i*m+j+1,i*m+j+2,1);

        if(s[i][j]=='.')
        add_edge(0,i*m+j+1,1);
    }
    cout<<max_flow(0,n*m+1)<<endl;
    int xi,yi;
    rep(i,n)rep(j,m){
        if((i+j)%2) continue;
        for(auto e:path[i*m+j+1]){
            if(e.to>0 && e.cap==0){
                xi=(e.to-1)/m;
                yi=(e.to-1)%m;
                if(xi-i==1 && yi-j==0){
                    s[i][j]='v';
                    s[xi][yi]='^';
                }
                if(xi-i==-1 && yi-j==0){
                    s[i][j]='^';
                    s[xi][yi]='v';
                }
                if(xi-i==0 && yi-j==1){
                    s[i][j]='>';
                    s[xi][yi]='<';
                }
                if(xi-i==0 && yi-j==-1){
                    s[i][j]='<';
                    s[xi][yi]='>';
                }
                break;
            }
        }
    }
    rep(i,n) cout<<s[i]<<endl;
}

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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int x,y;
    cin>>x>>y;
    if(y%2==1)
    {
        cout<<"No";
        return 0;
    }
    y/=2;
    if(y>=x && y<=2*x)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#define ll long long int
using namespace std;

int main(){
    int n,m,denger_id;
    vector<int> a;
    vector<ll> step;

    cin>>n>>m;
    a.resize(m+1);
    for(int i=0; i<m; i++){
        cin>>a[i];
    }
    step.resize(n+1);
    for(int i=0; i<n+1; i++){
        step[i]=0;
    }

    step[0]=1;
    denger_id=0;
    if(a[denger_id]==1){
        step[1]=0;
        denger_id++;
    }else{
        step[1]=1;
    }
    if(step.size()<2){
        cout<<step[1]<<endl;
        return 0;
    }
    for(int i=2; i<n+1; i++){
        if(i==a[denger_id]){
            if(denger_id<a.size()-1){
                denger_id++;
            }
        }else{
            step[i]=(step[i-1]+step[i-2])%1000000007;
        }
    }
    cout<<step[n]%1000000007<<endl;
    return 0;
}

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

using namespace std;
using ll=long long;

void solve() {
    ll x,y;
    cin >> x >> y;
    x = __gcd(x,y);
    ll cnt = 1;
    if (x > 1) {
        for (ll p=2;p*p<=x;p++) {
            if (x%p==0) {
                cnt++;
                while (x%p==0) {
                    x/=p;
                }
            }
        }
        if (x > 1) cnt++;
    }
    cout << cnt;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  string s;
  cin >> s;
  i64 cnt = 1;
  for(i64 i = 1;i < s.size();i++) {
    if(s[i] != s[i - 1]) cnt++;
  }
  cout << cnt - 1 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000000;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<int>L(N);
	rep(i, N)cin >> L[i];

	sort(all(L));
	int ans = 0;
	rep(b, N) {
		rep(a, b) {
			int ab = L[a] + L[b];
			int r = lower_bound(all(L), ab)-L.begin();
			int l = b + 1;

			ans += max(0, r - l);
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = []
for i in range(n):
    a.append((inn(),i))
a.sort()
cnt = 0
for i in range(0,n,2):
    cnt += a[i][1]%2
print(cnt)


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

#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

int main(){
    char arr[3];
    fastio;
    for (int i=0;i<3;i++)
        cin >> arr[i];
    if (arr[1]=='R')
        cout << "ABC";
        else cout << "ARC";


}


Measured memory_bytes: 3600
/*      Chill raho be kuch nhi rakha sadness me. 
               Author: Maskman_lucifer                   */
               
#include <bits/stdc++.h>   
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define pb push_back
#define M 1000000007
#define lc '\n'
using namespace std;
ll dp[2000][2000];
char a[2000][2000];
ll h,w;
ll solve(ll i,ll j)
{
    if(i==0 and j==0)
    {
        return 1;
    }
    if(i<0 or j<0)
    {
        return 0;
    }
    if(dp[i][j]==-1)
    {
        if(a[i][j]=='.')
        {
            dp[i][j]=((solve(i-1,j)%M)+(solve(i,j-1)%M))%M;
        }
        else
        {
            dp[i][j]=0;
        }
    }
    return dp[i][j];
}
int main()
{
    IO
    memset(dp,-1,sizeof(dp));
    cin>>h>>w;
    for(ll i=0;i<h;i++)
    {
        string s;
        cin>>s;
        for(ll j=0;j<s.length();j++)
        {
            a[i][j]=s[j];
        }
    }
    cout<<solve(h-1,w-1)<<lc;
    return 0;
}

Measured memory_bytes: 37012
import java.util.*;

public class Main {
    static Map<Integer,Integer> dp = new HashMap<>();
    static List<Integer> depos = new ArrayList<>();

    static void doDepo(int n){
        List<Integer> ans = new ArrayList();
        for(int v : depos){
            if(n == v){
                dp.put(n,1);
                return;
            }else if(n > v){
                ans.add(dp.get(n-v) + 1);
            }
        }
        int result = ans.stream().min((a, b) -> a.compareTo(b)).get();
        dp.put(n,result);
    }

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int v = sc.nextInt();

        // 引出可能金額準備
        depos.add(1);
        int d = 6;
        while(d <= v){
            depos.add(d);
            d = d * 6;
        }
        d = 9;
        while(d <= v){
            depos.add(d);
            d = d * 9;
        }
        // dp準備
        for(int i = 1; i <= v; i++){
            doDepo(i);
        }
        // 回答
        System.out.println(dp.get(v));
    }
}

Measured memory_bytes: 53024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int (i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int (i) = (int)(initial); (i) < (int)(n); ++(i))
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int (i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int (i) = (int)(initial); (i) > (int)(n); (i)--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
	vector< pair<ll, ll> > p;
	for(ll i = 2; i*i <= n; i++) {
		if ((n % i) != 0) continue;
		p.push_back(make_pair(i, 0));
		while((n % i) == 0) {
			n /= i;
			p[i].second += 1;
		}
		p.push_back(make_pair(n, 0));
	}

	if (n != 1) p.push_back(make_pair(n, 1));
	return p;
}

int main() {
	vector<int> l(9, 0);

	repeat(i, 9) {
		cin >> l[i];
	}

	bool is_exist = true;
	int max = 100;
	for(int i = 0;i < max; i++) {
		int a1 = i;
		vector<int> b={(l[0] - a1), (l[1] - a1), (l[2] - a1)};
		int a2 = l[3] - b[0];
		int a3 = l[6] - b[0];

		for(int n = 0; n < 9; n++) {
			if (n < 3) {
				if (l[n] != (a1 + b[n])) is_exist = false;
			} else if (n < 6) {
				if (l[n] != (a2 + b[n-3])) is_exist = false;
			} else if (n < 9) {
				if (l[n] != (a3 + b[n-6])) is_exist = false;
			}
		}

		if (is_exist) {
			cout << "Yes" << endl;
			return 0;
		};
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int a,s,d,f[10001],g[10001],h,j,i,k,z[3],x;
int main(void)
{
	scanf("%d %d %d",&a,&s,&d);
	for(i=0;i<d;i++)
		scanf("%d %d",&f[i],&g[i]);
	for(i=0;i<d-1;i++){
		z[0]=0;
		z[1]=0;
		h=f[i+1]-f[i];
		k=g[i+1]-g[i];
		if(h<0){
			h*=-1;
			z[0]=1;
		}
		if(k<0){
			k*=-1;
			z[1]=1;
		}
		if(z[0]==z[1]){
			if(h>k)
				x+=h;
			else x+=k;
		}
		else
			x+=h+k;
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 2704
N = int(input())
a = list(map(int, input().split()))

isApproved = True

for x in a:
    if x % 2 == 0:
        if not(x % 3 == 0 or x % 5 == 0):
            isApproved = False

if isApproved:
    print("APPROVED")
else:
    print("DENIED")


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

int main() {
  int a, b;
  string r;
  cin >> a >> b;

  r = "No";
  if (a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12)
    if (b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12) r = "Yes";
  if (a == 4 || a == 6 || a == 9 || a == 11)
    if (b == 4 || b == 6 || b == 9 || b == 11) r = "Yes";

  cout << r << endl;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()

	ans := N*800 - (N/15)*200

	out(ans)
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  int n,a[252][4]={},b,c;
  while(cin>>n,n){
    for(int i=1;i<n;i++){
      cin>>b>>c;
      for(int j=0;j<4;j++)a[i][j]=a[b][j];
      a[i][c]++;
      a[i][(c+2)%4]--;
    }
    int max[4]={};
    for(int j=1;j<n;j++){
      for(int k=0;k<4;k++){
	if(max[k]<a[j][k])max[k]=a[j][k];
      }
    }
    cout<<max[0]+max[2]+1<<" "<<max[1]+max[3]+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 2984
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b<c+d) cout<<"Right";
	else{
		if(a+b==c+d) cout<<"Balanced";
		else cout<<"Left";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int32_t main()
{
	IOS;
	int n;
	cin>>n;
	int ans=(n/11)*2;
	n%=11;
	if(n>=1 && n<=6)
		ans++;
	else if(n>=7)
		ans+=2;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<29;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n;cin>>n;
  ll a[n],b[n];
  ll suma=0,sumb=0;
  rep(i,n){cin>>a[i];suma+=a[i];};
  rep(i,n){cin>>b[i];sumb+=b[i];};
  ll num=sumb-suma;
  if(sumb<suma){cout<<"No"<<endl;return 0;};
  ll res=0,ret=0;
  rep(i,n){
    if(a[i]>b[i]){
      res+=a[i]-b[i];
      }
    else ret+=(b[i]-a[i]+1)/2;
    }
  res=max(ret,res);
  if(num>=res)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
  }


Measured memory_bytes: 384
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        int max = (int)Math.pow(10,9)+7;
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[] dp = new int[h+1];
        Arrays.fill(dp,max);
        dp[0] = 0;
        for(int i = 1; i <= n; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            for(int j = 0; j < h; j++){
                int index = Math.min(j+a,h);
                dp[index] = Math.min(dp[j]+b,dp[index]);
            }
        }
        System.out.println(dp[h]);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 23892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		
		String[] strInputList;
		int intResultDivision = 0;
		int intResultSurplus = 0;
		double dbResultDivisionv= 0;
		
		InputStreamReader isr= new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		String strINputNum = br.readLine();
		strInputList = strINputNum.split(" ");
		
		int intNumA = Integer.parseInt(strInputList[0]);
		int intNumB = Integer.parseInt(strInputList[1]);
		
		intResultDivision = intNumA / intNumB;
		intResultSurplus = intNumA % intNumB;
		dbResultDivisionv = 1.0 * intNumA / intNumB;
		
		System.out.println(intResultDivision + " " + intResultSurplus + " " + String.format("%.6f", dbResultDivisionv));
	}
}


Measured memory_bytes: 24888
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#define LL long long
#define mk make_pair
#define pb push_back
#define pii pair<int, int>
#define ArrayDebug(a, l, r) for(int i = l; i <= r; ++i) printf("%d%c", a[i], (i==r)?'\n':' ')
const int maxn = 5e5+7;
const LL mod = 998244353;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double EPS = 1e-8;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;

int n, q;
char s[maxn];
vector< set<int> > S(30);

int main()
{
    cin >> n >> s >> q;
    for(int i = 0; i < 26; ++i) S[i] = {n};
    //记录每一个字母出现在的位置
    for(int i = 0; i < n; ++i) S[s[i]-'a'].insert(i);
    while(q--) {
        int op;
        cin >> op;
        if(op == 1) {
            int pos; char c;
            cin >> pos >> c;
            pos--;
            if(s[pos] != c) S[s[pos]-'a'].erase(pos);
            s[pos] = c;
            S[c-'a'].insert(pos);
        }
        else {
            int ans = 0;
            int l, r;
            cin >> l >> r;
            l--; r--;
            for(int j = 0; j < 26; ++j) if(*S[j].lower_bound(l) <= r) ans++;
            printf("%d\n", ans);
        }
    }
    return 0;

}

Measured memory_bytes: 24192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P  = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(ALL(A));
    ll ans =0;
    rep(i, K)
    {
        ans += A[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))
int p[lim],rank[lim];

int find(int x){
	if(p[x]==x)return x;
	return p[x]=find(p[x]);
}

void unit(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	if(rank[x]<rank[y])p[x]=y;
	else{
		p[y]=x;
		if(rank[x]==rank[y])rank[x]++;
	}
}

int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	int x,y,z;
	for(int i=0;i<n;i++){
		p[i]=i;
		rank[i]=0;
	}
	for(int i=0;i<m;i++){
		scanf("%d%d%d",&x,&y,&z);
		x--;
		y--;
		unit(x,y);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(p[i]==i)ans++;
	}
	printf("%d",ans);
	return 0;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  
  string s1(a,'0'+b);
  string s2(b,'0'+a);
  
  cout<<min(s1,s2)<<endl;

return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 1; i <= b; i++) {
        if ((a*i) % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int, input().split()))
c = 0
a_sorted = sorted(a)

for i in range(n):
    x -= a_sorted[i]
    if x > 0 and i <= n-2:
        c += 1
    elif x == 0:
        c += 1
    else:
        break

print(c)


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

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    sort(a, a+3);

    int ans = a[2]*10 + a[1] + a[0];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
ns = list(list(input()) for i in range(n))
ns_set = set()
for i in range(n):
    ns_set |= set(ns[i])
from collections import defaultdict
dic = defaultdict(lambda : 50)
for i in range(n):
    for s in ns_set:
        if s in ns[i]:
            dic[s] = min(dic[s], ns[i].count(s))
        else:
            dic[s] = 0
result = ''
for key, value in sorted(dic.items(), key=lambda x: x[0]):
    result += key*value
print(result)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
}
// vector<int> fac; //precompute fac array
// fac.resize(n+1);
// fac[0] = 1; 
// for (int i=1; i<=n; i++)   fac[i] = m(m(fac[i-1])*m(i));
// int modInverse(int n){ 
// return p(n, MOD-2); 
// }  
// int nCrModPFermat(int n, int r){   
//     if(r == 0)  return 1; 
//     return m(m(m(fac[n])*m(modInverse(fac[r])))*m(modInverse(fac[n-r]))); 
// } 
signed main(){
    fast();
    int n;
    cin >> n;
    map<string, int> ma;
    vector<string> a(n);
    set<string> st;
    for(int i=0; i<n; i++){
        cin >> a[i];
        ma[a[i]]++;
    }
    int mx = -1;
    for(auto i: ma){
        mx = max(mx, i.second);
    }
    for(auto i: ma){
        if(i.second == mx)  st.ins(i.first);
    }
    for(auto i: st) cout << i << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 34816
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair <LL,LL> pLL;

const int RLEN=1<<18|1;
inline char nc() {
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
    char ch=nc(); int i=0,f=1;
    while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
    while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
    return i*f;
}

const int N=2e5+50;
vector <pLL> edge[N];
vector <pLL> f[N];
vector <pLL> tl, tr;
LL lim;
inline void inc(int x,const pLL &t) {
    if(f[x].size() && f[x].back()<=t) return;
    while(f[x].size() && f[x].back().second>=t.second) f[x].pop_back();
    f[x].push_back(t);
}
inline bool dfs(int x,int fa) {
    f[x].clear();
    if(edge[x].size()==1) {f[x].push_back(pLL(0,0)); return true;} 
    LL lc,rc,disl,disr; int fir=0;
    for(int e=edge[x].size()-1;e>=0;e--) {
        int v=edge[x][e].first; if(v==fa) continue;
        if(!dfs(v,x)) return false;
        if(!fir) fir=1, lc=v, disl=edge[x][e].second;
        else rc=v, disr=edge[x][e].second;
    }
    tl.clear(), tr.clear(); LL lim2=lim-disl-disr;
    if(lim2<0) return false; 
    for(int p1=0,p2=0;p2<f[rc].size();p2++) {
        while(p1<f[lc].size() && f[lc][p1].first+f[rc][p2].second>lim2) ++p1;
        if(p1==f[lc].size()) break;
        tl.push_back(pLL(f[rc][p2].first+disr,f[lc][p1].second+disl));
    }
    for(int p1=0,p2=0;p1<f[lc].size();p1++) {
        while(p2<f[rc].size() && f[lc][p1].second+f[rc][p2].first>lim2) ++p2;
        if(p2==f[rc].size()) break;
        tr.push_back(pLL(f[lc][p1].first+disl,f[rc][p2].second+disr));
    }
    int pl=0, pr=0;
    while(pl<tl.size() && pr<tr.size()) {
        if(tl[pl].first>tr[pr].first) inc(x,tl[pl++]);
        else inc(x,tr[pr++]);
    }
    while(pl<tl.size()) inc(x,tl[pl++]);
    while(pr<tr.size()) inc(x,tr[pr++]);
    return f[x].size()>0;
}
inline bool check(LL v) { lim=v; return dfs(1,0);}
int main() {
    int n=rd();
    for(int i=2;i<=n;i++) {
        int x=rd(), w=rd();
        edge[x].push_back(pLL(i,w));
        edge[i].push_back(pLL(x,w));
    }
    LL l=0, r=1e12, ans=0;
    while(l<=r) {
        LL mid=(l+r)>>1;
        if(check(mid)) ans=mid, r=mid-1;
        else l=mid+1;
    } cout<<ans;
}

Measured memory_bytes: 40036
import math
import collections
import itertools
import copy

def YesNo(Bool):
    if(Bool):
        print("YES")
    else:
        print("NO")
    return

def resolve():

    A,V=map(int,input().split())
    B,W=map(int,input().split())
    T=int(input())

    if(A<B and V<=W):
        print("NO")
        return

    if(A>B and V<=W):
        print("NO")
        return

    if(A<B):
        if(A+V*T >= B+W*T):
            print("YES")
        else:
            print("NO")
    else:
        if(A-V*T <= B-W*T):
            print("YES")
        else:
            print("NO")

resolve()


Measured memory_bytes: 9456
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll n;
    cin>>n;
    vector<vector<pll>> edge(n);
    for(int i=0;i<n;i++){
        ll u,k;
        cin>>u>>k;
        for(int t=0;t<k;t++){
            ll v,c;
            cin>>v>>c;
            edge[u].push_back({v,c});
        }
    }
    vector<ll> dp(n,E);
    priority_queue<pll,vector<pll>,greater<pll>> Q;
    Q.push({0,0});
    dp[0]=0;
    while(!Q.empty()){
        pll w=Q.top(); Q.pop();
        if(dp[w.S]!=w.F){continue;}
        for(auto &I:edge[w.S]){
            if(dp[I.F]>dp[w.S]+I.S){
                dp[I.F]=dp[w.S]+I.S;
                Q.push({dp[I.F],I.F});
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<i<<" "<<dp[i]<<endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 11916
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{ 
    //解答パターンがただ1通りかつ巡回置換的な場合のみ不可能
    int n;
    cin>>n;
    pair <long long int,int> a[n];
    pair <long long int,int> b[n];
    long long int sa[n];
    long long int sb[n];
    for(int i=0;i<n;i++){
        cin>>a[i].first;
        a[i].second=i;
    }
    for(int i=0;i<n;i++){
        cin>>b[i].first;
        b[i].second=i;
    }
    sort(a,a+n);
    sort(b,b+n);

    //条件を満たすパターンが存在するか。
    int flag=1;
    for(int i=0;i<n;i++){
        if(a[i].first>b[i].first){
            flag=0;
        }
    }
    if(flag==0){
        cout<<"No"<<endl;
        return 0;
    }
    //条件を満たすパターンは1通りか
    flag=1;
    for(int i=0;i<n-1;i++){
        if(a[i+1].first<=b[i].first){
            flag=0;
        }
    }
    if(flag==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    //配置は巡回的か？
    //元の配置に整理番号を振り直す。
    for(int i=0;i<n;i++){
        sa[a[i].second]=i;//元々k番目にいた奴は何番目に小さいか
    }
    //巡回作業
    int k=a[0].second;//一番小さい奴の元の番地
    int l=b[0].second;//一番小さい奴のペアの元の番地
    int o;
    for(int i=0;i<n-1;i++){
        if(k!=l){
            o=sa[l];
            l=b[o].second;
        }
        else{
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main() {
    int h,w; cin >> h >> w;
    vector<string> c(h);
    for(int i= 0; i < h; i++) cin >> c.at(i);
    for(int i = 0; i < h; i ++) {
        cout << c[i] << endl;
        cout << c[i] << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
    if(x%y==0) return y;
    else return gcd(y,x%y);
}
int main(){
    int n,a,b,z,i;scanf("%d%d%d",&n,&a,&b);queue<int> g;stack<int> h;
    if(n==2) z = gcd(a,b);
    else{
        int c;scanf("%d",&c);
        z = gcd(a,gcd(b,c));
    }
    for(i=1;i*i<=z;i++){
        if(z%i==0){
            g.push(i);
            if(i*i!=z) h.push(z/i);
        }
    }
    while(!g.empty()){
        printf("%d\n",g.front());g.pop();
    }
    while(!h.empty()){
        printf("%d\n",h.top());h.pop();
    }
}


Measured memory_bytes: 3204
package main
 
import (
    "fmt"
  	"strings"
)
 
func main() {
	var S string
    fmt.Scan(&S)
  	S=strings.Replace(S, "eraser", "", -1)
  	S=strings.Replace(S, "erase", "", -1)  
  	S=strings.Replace(S, "dreamer", "", -1)
  	S=strings.Replace(S, "dream", "", -1)  
  	if S==""{
      	fmt.Print("YES")
    }else{
      	fmt.Print("NO")
    }
}

Measured memory_bytes: 1664
N = int(input())
s = [input().split() for i in range(N)]
M = int(input())
t = [input().split() for i in range(M)]
s.sort()
t.sort()
count = 0
s_sub = []
j = 0
for i in range(M):
    for j in range(N):
        if t[i] == s[j]:
            s[j] = ["0"]
            break
for i in range(N):
    if s[i][0] != "0":
        s_sub.append(s[i][0])
ans = 0
for i in range(len(s_sub)):
    count = 0
    for j in range(len(s_sub)):
        if s_sub[i] == s_sub[j]:
            count += 1
    if ans < count:
        ans = count
print(ans)





        



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

namespace ABC166
{
    class A
    {
        static void Main(string[] args)
        {
            //var N = long.Parse(Console.ReadLine());
            //var NK = Console.ReadLine().Split().Select(long.Parse).ToArray();
            //var abcd = Enumerable.Repeat(0, (int)Q).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            var S = Console.ReadLine();
            if (S == "ABC") Console.WriteLine("ARC");
            else Console.WriteLine("ABC");
        }
    }
}


Measured memory_bytes: 25692
import sys
sys.setrecursionlimit(410000)

mod = 10 ** 9 + 7
def dfs(v, p, k):
    ret = 1
    if len(graph[v]) > k:
        return 0
    kc = k - 2
    if p == -1:
        kc = k - 1
    for vi in graph[v]:
        if vi != p:
            ret *= kc
            ret = ret % mod
            kc -= 1
    for vi in graph[v]:
        if vi != p:
            ret *= dfs(vi, v, k)
            ret = ret % mod
    return ret

n, k = map(int, input().split())
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
    
print((dfs(0, -1, k) * k) % mod)

Measured memory_bytes: 87340
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
template <typename T> 
using lim = numeric_limits<T>;
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = 1e5;
string s[N];
vector<char> tt;
int n, a, b, c;
bool ok = true;
vector<char> ans;
bool solve(int i){
    if (a < 0 || b < 0 || c < 0) return false;
    if (i == n){
        cout << "Yes\n";
        for (char c : tt){
            cout << c << "\n";
        }
        exit(0);
        //return true;
    }

    //for (int dep = 0; dep < i; dep++) cout << " ";
    //cout << tt.size() << " " << i << "\n";
    if (s[i] == "AB"){
        a++; b--;
        tt.push_back('A');
        ok |= solve(i+1);
        a--; b++;
        tt.pop_back();

        a--; b++;
        tt.push_back('B');
        ok |= solve(i+1);
        a++; b--;
        tt.pop_back();
    }
    else if (s[i] == "BC"){
        b++; c--;
        tt.push_back('B');
        ok |= solve(i+1);
        b--; c++;
        tt.pop_back();

        b--; c++;
        tt.push_back('C');
        ok |= solve(i+1);
        b++; c--;
        tt.pop_back();
    }
    else {
        a++; c--;
        tt.push_back('A');
        ok |= solve(i+1);
        a--; c++;
        tt.pop_back();

        a--; c++;
        tt.push_back('C');
        ok |= solve(i+1);
        a++; c--;
        tt.pop_back();
    }
    return ok;
}

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

    cin >> n >> a >> b >> c;
    for (int i = 0; i < n; i++){
        cin >> s[i];
    }

    solve(0);

    cout << "No\n";
}

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

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

    int st = -1;
    int ed = -1;
    for(char c='a'; c<='z'; c++){
        int s_cnt = 0;
        int d_cnt = 0;
        rep(i, s.length()){
            if(s[i]==c){
                if(st < 0) {
                    st = i;
                    s_cnt = 1;
                    d_cnt = 0;
                }
                else {
                    s_cnt++;
                    if((i-st+1) < s_cnt*2){
                        ed = i;
                        break;
                    }
                }
            }
            else {
                d_cnt++;
                if(st >= 0) {
                    if(d_cnt > s_cnt) {
                        st = -1;
                    }
                }
            }
        }
        if(st >= 0 && ed >= 0) {
            ++st; ++ed;
            break;
        }
    }
    cout << st << " " << ed << endl;

    return 0;
}


Measured memory_bytes: 512
n = int(input())
a = [int(i) for i in input().split()]
wallet = 1000
stock = 0
price = 0
for i in range(n - 1):
    if a[i] < a[i + 1]:
        price = a[i]
        buy = wallet // price
        stock += buy
        wallet -= (price * buy)
    elif a[i] > a[i + 1]:
        price = a[i]
        wallet += (price * stock)
        stock = 0
if stock != 0:
    wallet += (a[- 1] * stock)
print(wallet)

Measured memory_bytes: 9200