akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }

int main(){
    lint N, A, B;
    cin >> N >> A >> B;
    lint ans = N / (A + B) * A;
    N %= A + B;
    cout << ans + min(A, N) << endl;
}


Measured memory_bytes: 256
#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int H, W, N;
  cin >> H >> W >> N;

  int a = max(H, W);
  out((N + a - 1) / a);
}


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

using namespace std;
using ll = long long;
int main() {
	string s;
	cin >> s;
	int x = 0, y = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0')x++;
	}
	y = s.size() - x;
	cout << min(x, y) * 2 << endl;
	return 0;
}

Measured memory_bytes: 512
from copy import deepcopy
h, w, k = map(int, input().split())
C = [[c for c in input()] for _ in range(h)]


def black(G):
    tmp = 0
    for hh in range(h):
        for ww in range(w):
            if G[hh][ww] == "#":
                tmp += 1
    return tmp


def main():
    ans = 0
    for i in range(2**h):
        tmp = i
        T = deepcopy(C)
        for hh in range(h):
            if tmp % 2 == 1:
                tmp = tmp // 2
                continue
            tmp = tmp // 2
            for ww in range(w):
                T[hh][ww] = "r"
        for j in range(2**w):
            U = deepcopy(T)
            tmp2 = j
            for ww in range(w):
                if tmp2 % 2 == 1:
                    tmp2 = tmp2 // 2
                    continue
                tmp2 = tmp2 // 2
                for hh in range(h):
                    U[hh][ww] = "r"
            if black(U) == k:
                ans += 1
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 72344
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main ()
{
	int n;
	scanf("%i",&n);
	int a[n+10];
	for(int i=1;i<=n;i++)
	{
		scanf("%i",&a[i]);
	}
	int dp[n+10];
	dp[1]=0;
	dp[2]=abs(a[1]-a[2]);
	dp[3]=min(dp[2]+abs(a[2]-a[3]),abs(a[1]-a[3]));
	dp[4]=min(dp[2]+abs(a[2]-a[4]),dp[3]+abs(a[3]-a[4]));
	for(int i=4;i<=n;i++)
	{
		dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]));
	}
	printf("%i",dp[n]);
}


Measured memory_bytes: 896
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad
import Data.Char
import Data.Function
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU

main = do
  n <- getInt
  p:ps <- fmap (rsortOn snd) . replicateM n $ do
    [a, b, h] <- getIntList
    return ((a, b), h)
  putStrLn . unwords . map show . (\((x,y),h) -> [x,y,h]) $ solve p ps

solve :: ((Int, Int), Int) -> [((Int, Int), Int)] -> ((Int, Int), Int)
solve p ps = head . filter (valid ps) $ [((x, y), h)| x <- [0..100], y <- [0..100], let h = (snd p) + dist (x, y) (fst p)]
  where
    valid ps p = all (check p) ps
    check (p, h1) (q, h2)
      | h2 == 0 = dist p q >= h1
      | otherwise = dist p q == h1 - h2


dist :: (Int, Int) -> (Int, Int) -> Int
dist (x, y) (u, v) = abs (x - u) + abs (y - v)

rsortOn :: Ord b => (a -> b) -> [a] -> [a]
rsortOn f = sortBy (flip compare `on` f)

-- IO
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

getIntVec :: Int -> IO (VU.Vector Int)
getIntVec n = VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

Measured memory_bytes: 1020
//2019.5.15 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
inline int read() {
    res s=0,ch=getchar(),w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s*w;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace MAIN {
    int n;
    vector<int> a,ans;
#define pb push_back
    inline void MAIN(){
        n=read();
        for(res i=0;i<n;i++)a.pb(read()-1);
        for(res i=0;i<n;i++){
            res p=-1;
            for(res j=0;j<n-i;j++)if(a[j]==j)p=j;
            if(p==-1){puts("-1");return;}
            ans.pb(p),a.erase(a.begin()+p);
        }
        reverse(ans.begin(),ans.end());
        for(res i=0;i<n;i++)printf("%d\n",ans[i]+1);
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n, q;
  string s;
  cin >> n >> s >> q;
  vector<set<int>> st(26);
  for(int i = 0; i < n; i++) {
    st[(int)s[i] - 'a'].insert(i + 1);
  }
  vector<int> ans;
  for(int i = 0; i < q; i++) {
    int in;
    cin >> in;
    if(in == 1) {
      int ip;
      char c;
      cin >> ip >> c;
      /*
      if(c == s[ip - 1]) {
        continue;
      }
      */
      st[(int)(s[ip - 1] - 'a')].erase(ip);
      st[(int)(c - 'a')].insert(ip);
      s[ip - 1] = c;
    } else {
      int l, r;
      cin >> l >> r;
      int cnt = 0;
      for(int j = 0; j < 26; j++) {
        auto p = st[j].lower_bound(l);
        if(p != st[j].end() && *p <= r) {
          cnt++;
        }
        // cout << p << " ";
      }
      // cout << cnt << '\n';
      ans.push_back(cnt);
    }
  }
  for(auto p : ans) {
    cout << p << "\n";
  }
  return 0;
}

Measured memory_bytes: 24452
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    let (n,k,q) = {
        let xs = read_vec_i64();
        (xs[0] as usize,xs[1] as usize,xs[2] as usize)
    };
    let xs = read_vec_i64();
    let mut zs = vec![];
    let mut res = (1 as i64) << 62;
    let mut ts = vec![];
    for &y in &xs {
        ts.clear();
        zs.clear();
        for i in 0..n+1 {
            if i < n && y <= xs[i] {
                zs.push(xs[i]);
            }
            else {
                zs.sort();
                if zs.len()+1 >= k {
                    for ii in 0..zs.len()+1-k {
                        ts.push(zs[ii]);
                    }
                }
                zs.clear();
            }
        }
        ts.sort();
        if ts.len() >= q {
            res = min(res, ts[q-1] - ts[0]);
        }
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec_i64<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 4476
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 100

int pop(void);
void push(int);
int tank[N];
int top=0;

int main()
{
 char st[N];
 int a,b,r;

 while(scanf("%s",st)!=EOF)
 {
   if (st[0]=='+')
   {
    a = pop();
    b = pop();
    r = a + b;
    push(r);
   }
   else if(st[0]=='-')
   {
    a = pop();
    b = pop();
    r = b-a;
    push(r);
   }
   else if (st[0]=='*')
   {
    a = pop();
    b = pop();
    r = a*b;
    push(a*b);
   }
   else
   {
    push(atoi(st));
   }
 }
 r = pop();
 printf("%d\n",r);
 return 0;
}

void push(int in)
{
 tank[top]=in;
 top++;
}

int pop(void)
{
 top--;
 return tank[top];
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

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

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

    long long sum = 0;
    int temp;
    for (int i=1; i<=k; i++) {
        for (int j=1; j<=k; j++) {
            temp = gcd(i, j);
            for (int l=1; l<=k; l++) {
                sum += gcd(temp, l);
            }
        }
    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll a;
    cin >> a;

    cout << a + a * a + a * a * a << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>

using namespace std;



int main() {
	vector<pair<long long, int>> ab;
	long long int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ab.push_back(make_pair(a, b));
	}
	sort(ab.begin(), ab.end());
	long long int sum = 0;
	for (int i = 0; i < n; i++) {
		if (ab[i].second < m) {
			m -= ab[i].second;
			sum += ab[i].first * ab[i].second;
		}
		else {
			sum += m * ab[i].first;
			break;
		}
	}
	cout << sum << endl;

	return 0;
}



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

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  bool frag=false;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      frag=true;
    }
  }
  if(frag==true){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3636
n,h = map(int,input().split())
a = 0
b = []

for i in range(n):
    A,B = map(int,input().split())
    a = max(A,a)
    b.append(B)
    
b = sorted(b)[::-1]

for i in range(n):
    if 0 < h and a < b[i]:
        h -= b[i]
        ans = i + 1
        
    else:
        ans = i
        break
        
if 0 < h:
    ans += -(-h//a)
    
print(ans)

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

int main()
{
	int K;
	cin >> K;
	rep(i,K)
	{
		cout << "ACL";
	}
	cout << endl;
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
    int N;
    string S;
    cin >> N >> S;
    sort(S.begin(), S.end());
    vector<int> count;
    int c = 1;
    for (int i = 1; i < N; i++)
    {
        if (S[i] != S[i - 1])
        {
            count.push_back(c + 1);
            c = 1;
        }
        else
        {
            c++;
        }
    }
    count.push_back(c + 1);
    int ans = 1;
    rep(i, count.size())
    {
        ans = (ans * count[i]) % INF;
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const int MAXN = 2e5;
const int INF = 1e9 + 2;
const ld pi = acos(-1);
const ll MOD = 1e9 + 7;
const ll POW = 1e9 + 9;

ll n, l;
string s[MAXN];

bool cmp(const string &a, const string &b){
    return (a + b) < (b + a);
}

int main() {

    faster();

    cin >> n >> l;

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

    sort(s, s + n);

    for(int i = 0; i < n; ++i)
        cout << s[i];

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  map<string,int>mp;
  int n;
  cin >> n;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
  
  return 0;
}


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

using namespace std;
typedef long long int ll;
int main(){
	int n, m;
	cin>>n>>m;
	ll s[n][2], c[m][2];
	for(int i=0; i<n; i++) cin>>s[i][0]>>s[i][1];
	for(int i=0; i<m; i++) cin>>c[i][0]>>c[i][1];
	int ans[n];
	for(int i=0; i<n; i++){
		ans[i]=0;
		ll dist=abs(s[i][0]-c[0][0])+abs(s[i][1]-c[0][1]);
		for(int j=1; j<m; j++){
			ll td=abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1]);
			if(td<dist){
				ans[i]=j;
				dist=td;
			}
		}
	}
	for(int i=0; i<n; i++) cout<<ans[i]+1<<endl;
}

Measured memory_bytes: 384
#include<vector>
#include<iostream>
#include<cinttypes>
#include<algorithm>
#include<functional>
#include<queue>

using ui = std::uint32_t;
using si = std::int32_t;
using ull = std::uint64_t;



int main(){

	std::ios::sync_with_stdio( false );
	std::cin.tie( nullptr );

	ui n;
	std::cin >> n;

	std::vector< std::vector<ui> > links( n );

	for( ui i{}; i < n - 1; ++i )
	{
		ui a, b;
		std::cin >> a >> b;
		--a; --b;

		links[a].emplace_back( b );
		links[b].emplace_back( a );

	}

	std::vector<ui> cn( n );
	for( auto&e : cn )
		std::cin >> e;

	std::sort( std::begin( cn ), std::end( cn ) );//, std::greater<>{} );

	std::queue<ui> leaves{};
	for( ui i{}; i < n; ++i )
	{

		if( links[i].size() != 1 )//size==1ならそのリンクは葉へのリンク
			continue;

		leaves.emplace( i );

		//		pv[i] = cn[c_index++];
		//		++c_index;
		//		std::cout << i << " ";
	}//std::cout << "\n";


	std::vector<ui> pv( n, 0 );//1<=ci<=10^5なので0は無効値として使える.
	ui c_index = 0;
	ull ans{};
	while( !leaves.empty() )
	{
		const auto index_ = leaves.front(); leaves.pop();

		pv[index_] = cn[c_index++];

		if( c_index >= cn.size() )
			break;

		ans += pv[index_];
		for( const auto& v : links[index_] )
		{
			//			std::cout << index_ << " " << v << " " << pv[v] << " => " << ans << "\n";
			{
				auto erase = []( auto&& v, auto value )
				{
					v.erase(
						std::remove( std::begin( v ), std::end( v ), value )
						, std::end( v )
					);
				};

				erase( links[v], index_ );
				//				erase( links[index_], v );
				//				*std::find(std::begin(links[index_]),std::end(links[index_]),v) = index_;
			}

			if( links[v].size() == 1 )
				leaves.emplace( v );

		}

	}


	{
		std::cout << ans << "\n";

		std::cout << pv[0];
		for( ui i{ 1 }; i < n; ++i )
			std::cout << " " << pv[i];

		std::cout << "\n";
	}

	return 0;

}

Measured memory_bytes: 1024
num = int(input())
sort_list = list(map(int,input().split()))

cnt = 0
for i in range(num):
    for j in reversed(range(i+1,num)):
        if sort_list[j] < sort_list[j-1]:
            sort_list[j],sort_list[j-1] = sort_list[j-1],sort_list[j]
            cnt += 1

print(" ".join([str(i) for i in sort_list]))
print(cnt)



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

int a[3][3] = {0};
int aita[3][3] = {0};
int n=0;
vector<int> b;

void input(){
    int temp;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> temp;
            a[i][j] = temp;
        }
    }
    cin >> n;
    b.resize(n);
    for(int i=0;i<n;i++){
        cin >> temp;
        b[i] = temp;
    }
}

int solve(void){
    for (int k=0;k<n;k++){
        for(int i=0;i<3;i++){
            for (int j=0;j<3;j++){
                if(b[k] == a[i][j]){
                    aita[i][j] = 1;
                }
            }
        }
    }
    // //
    // for(int i=0;i<3;i++){
    //     for(int j=0;j<3;j++){
    //         cout << aita[i][j];
    //     }
    //     cout << endl;
    // }
    // //
    if(aita[0][0] == 1 && aita[1][1] == 1 && aita[2][2] == 1) return 1;
    if(aita[2][0] == 1 && aita[1][1] == 1 && aita[0][2] == 1) return 1;
    for(int i=0;i<3;i++){
        if(aita[i][0] == 1 && aita[i][1] == 1 && aita[i][2] == 1) return 1;
        if(aita[0][i] == 1 && aita[1][i] == 1 && aita[2][i] == 1) return 1;
    }
    return 0;
}

int main(){
    int ans=0;
    input();
    ans = solve();
    if(ans==1){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

bool satisfies(string &s, string &t) {
	if (s.find(t) != string::npos) {
		return true;
	}

	return false;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	string s, t;
	cin >> s >> t;

	if (satisfies(s, t)) {
		cout << s.size() << "\n";
		return 0;
	}

	for (int i = 0; i < n; ++i) {
		if (s.substr(i, n - i) == t.substr(0, n - i)) {
			cout << n + i << "\n";
			return 0;
		}
	}

	cout << 2 * n << "\n";

	return 0;

}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())

    R = [[0]*N for x in range(N)]
    for n in range(M):
        a, b = map(lambda x:int(x)-1, input().split())
        R[a][b] += 1
        R[b][a] += 1

    for n in range(N):
        print(sum(R[n]))

if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
	ll A,B,C; cin >> A >> B >> C;
	ll ans = 0;
	if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0) ans = 0;
	else ans = min(A*B,min(B*C,C*A));
	cout << ans << endl;
}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

bool solve() {
	int N; cin >> N;
	if (N == 0) return (false);
	int X[20][33], Y[20][33], P[20][33];
	int size[20];
	for (int i = 0; i < N; i++) {
		string rot;
		int l, r, f, b, d, u;
		cin >> X[i][0] >> Y[i][0];
		cin >> l >> r >> f >> b >> d >> u;
		P[i][0] = d;
		cin >> rot;
		for (int j = 0; j < rot.size(); j++) {
			int nl, nr, nf, nb, nd, nu;
			X[i][j+1] = X[i][j];
			Y[i][j+1] = Y[i][j];
			if (rot[j] == 'L') {
				tie(nl, nr, nd, nu) = tie(u, d, l, r);
				tie(l, r, d, u) = tie(nl, nr, nd, nu);
				X[i][j+1]--;
			}
			if (rot[j] == 'R') {
				tie(nl, nr, nd, nu) = tie(d, u, r, l);
				tie(l, r, d, u) = tie(nl, nr, nd, nu);
				X[i][j+1]++;
			}
			if (rot[j] == 'F') {
				tie(nb, nf, nd, nu) = tie(d, u, f, b);
				tie(b, f, d, u) = tie(nb, nf, nd, nu);
				Y[i][j+1]--;
			}
			if (rot[j] == 'B') {
				tie(nb, nf, nd, nu) = tie(u, d, b, f);
				tie(b, f, d, u) = tie(nb, nf, nd, nu);
				Y[i][j+1]++;
			}
			P[i][j+1] = d;
		}
		size[i] = rot.size() + 1;
	}
	
	vint dp(1<<N, -INF);
	dp[0] = 0;	
	for (int b = 0; b < (1<<N); b++) {
		set<Pi> st;
		for (int i = 0; i < N; i++) {
			if (!((b>>i)&1)) continue;
			for (int j = 0; j < size[i]; j++) {
				st.emplace(X[i][j], Y[i][j]);
			}
		}
		for (int i = 0; i < N; i++) {
			int point = 0;
			if ((b>>i)&1) continue;
			set<Pi> st2;
			for (int j = size[i]-1; j >= 0; j--) {	
				Pi p = Pi(X[i][j], Y[i][j]);
				if (!st.count(p)) {
					if (!st2.count(p)) {
						point += P[i][j];
						st2.insert(p);
					}
				}
			}
			chmax(dp[b | (1<<i)], dp[b] + point);
		}
	}
	cout << dp[(1<<N)-1] << endl;
	return (true);
}

int main() {
	while (solve());
	return (0);
}



Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
#define lli long long
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    n = (n*(n-1))/2;
    m = (m*(m-1))/2;
    cout<<n+m<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int k,n;
	char a[10000];
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	a[k]+=32;
	for(int i=1;i<=n;i++)cout <<a[i];
	return 0;
}

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

#define DEBUG 0

int n, questionNum;
vector<int> vec;

int getParent(int x);
void unit(int x, int y);
bool check(int x, int y);

int main() {

	cin >> n >> questionNum;



	for (int i = 0; i < n; ++i)
		vec.push_back(i);

#if DEBUG == 1
	cout << endl;
	for (int i = 0; i < n; ++i)
		cout << vec[i] << " ";
	cout << endl << endl;
#endif // 

	
	for (int i = 0; i < questionNum; ++i) {

		int com, x, y;

		cin >> com >> x >> y;
		

		switch (com) {
		case 0:
			unit(x, y);
			break;

		case 1:
			if (check(vec[x], vec[y]))
				cout << 1 << endl;
			else
				cout << 0 << endl;
			break;

		}
		
#if DEBUG == 1
		if (com == 0)
			cout << "getParent : ";
		else
			cout << "chec : ";
		cout << x << " " << y << endl;
		for (int i = 0; i < n; ++i)
			cout << i << " ";
		cout << endl;
		for (int i = 0; i < n; ++i)
			cout << vec[i] << " ";
		cout << endl << endl;

#endif

	}

	return 0;
}


int getParent(int x) {

	if (vec[x] != x) {

#if DEBUG == 1
		// cout << vec[x] << " : " << x << endl;
#endif
		vec[x] = getParent(vec[x]);
	}
	return vec[x];
}

void unit(int x, int y) {

	x = getParent(vec[x]);
	y = getParent(vec[y]);
	vec[x] = y;

}

bool check(int x, int y) {

	int x_group = getParent(x);
	int y_group = getParent(y);

	return x_group == y_group;

}


Measured memory_bytes: 3392
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=300005;
const ll D=1e18;

ll tab[N];

struct cmp1
{
	bool operator()(int a,int b)
	{
		if(tab[a]==tab[b]) return a<b;
		return tab[a]<tab[b];
	}
};


set<int, cmp1> akt;
set<int, cmp1> pz2;

 int main()
 {
	int n,i;
	scanf("%d",&n);
	ll sm1,sm2;
	sm1=0;
	sm2=0;

	for(i=1;i<=3*n;i++)
	{
		scanf("%lld",&tab[i]);
		if(i<=n) sm1+=tab[i];
	}

	for(i=n+1;i<=3*n;i++) pz2.insert(i);

	for(i=1;i<=n;i++) 
	{
		sm2+=tab[*(pz2.begin())];
		pz2.erase(pz2.begin());
		akt.insert(i);
	}

	ll wn;
	wn=-D;
	wn=max(wn,sm1-sm2);
	//printf("(%lld %lld)\n",sm1,sm2);

	for(i=n+1;i<=2*n;i++)
	{
		if(pz2.find(i)==pz2.end())
		{
			sm2-=tab[i];
			sm2+=tab[*(pz2.begin())];
			pz2.erase(pz2.begin());
		}	

		else pz2.erase(i);

		if(tab[i]>tab[*(akt.begin())])
		{
		//	printf("|%lld|\n",i);

			int l;
			l=*(akt.begin());
			
			akt.insert(i);
			akt.erase(l);

			sm1+=(tab[i]-tab[l]);
		}


		//printf("(%lld %lld)\n",sm1,sm2);
		wn=max(wn,sm1-sm2);
	}

	printf("%lld\n",wn);
	return 0;
 }


Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    int64_t H;
    cin >> H;
    int64_t M = 1;
    int count = 0;
    while(H >= M){
        M *= 2;
        count++;
    }
    int64_t ans = 1;
    int64_t W = 1;
    rep(i, 0, count - 1){
        W *= 2;
        ans += W;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main  {
	  
      public static void main(String[]args){
    	  Scanner scan = new Scanner (System.in);
          String line = scan.next();
    	  
    	  int start = line.indexOf("A");
    	  int end = line.lastIndexOf("Z");
    	  System.out.print(end-start+1);

}
}

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

int main() {
  int N, T;
  cin >> N >> T;
  int ans = 100000;
  for (int i = 0; i < N; i++) {
    int c, h;
    cin >> c >> h;
    if (h <= T) {
      ans = min(ans, c);
    }
  }
  if (ans == 100000) {
    cout << "TLE" << endl;
  }
  else {
  cout << ans << endl;
  }
}

Measured memory_bytes: 3604
#include <stdio.h>

int main()
{
	int n;
	int count[4][3][10] = {0}; /* ゼロ初期化する場合はこれでできる */


	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
	{
		int b, f, r, v;
		scanf("%d %d %d %d", &b, &f, &r, &v);
		count[b-1][f-1][r-1] += v;
	}

	for(int b = 0; b < 4; ++b)
	{
		if(b != 0)
		{
			printf("####################\n");
		}
		for(int f = 0; f < 3; ++f)
		{
			for(int r = 0; r < 10; ++r)
			{
				printf(" %d", count[b][f][r]);
			}
			printf("\n", count[b][f][9]);
		}
	}

	return 0;
}


Measured memory_bytes: 2044
#後ろから見る
N = int(input())
*B, = map(int,input().split())
ans = []
while B:
    a = max([0] + [j for i,j in enumerate(B,1) if i==j])
    if a==0:break
    B.pop(a-1)
    ans.append(a)
if B:print(-1)
else:print(*ans[::-1],sep="\n")

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

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

        P[] red = new P[n];
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            P p = new P();
            p.x = a;
            p.y = b;
            red[i] = p;
        }

        P[] blue = new P[n];
        for (int i = 0; i < n; i++) {
            int c = in.nextInt();
            int d = in.nextInt();
            P p = new P();
            p.x = c;
            p.y = d;
            blue[i] = p;
        }

        Arrays.sort(red);
        Arrays.sort(blue);

        int ans = 0;
        for (int i = 0; i < n; i++) {
            int maxY = -1;
            P cand = null;
            for (int j = 0; j < n; j++) {
                if (red[j].x < blue[i].x && red[j].y < blue[i].y && !red[j].paired) {
                    if (red[j].y > maxY) {
                        maxY = red[j].y;
                        cand = red[j];
                    }
                }
            }

            if (cand != null) {
                cand.paired = true;
                ans++;
            }
        }

        System.out.println(ans);
    }
}

class P implements Comparable<P> {
    int x;
    int y;
    boolean paired = false;

    @Override
    public int compareTo(P o) {
        return this.x - o.x;
    }
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}
// end of Template
int n,k,q,pd[100010],sum[100010];
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>k>>q;
    for(int i=1;i<=q;i++){
        int a; cin>>a;
        pd[1] --;
        pd[a] ++;
        pd[a+1] --;
    }
    for(int i=1;i<=n;i++){
        sum[i] = sum[i-1] + pd[i];
        if(k + sum[i] <= 0) cout<<"No\n";
        else cout<<"Yes\n";
    }
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, 0, n) cin >> a[i];
  int s = accumulate(a.begin(), a.end(), 0);

  int cnt = 0;
  rep(i, 0, n) {
    if (a[i] * m * 4 < s) continue;
    ++cnt;
  }

  if (cnt >= m)
    cout << "Yes";
  else
    cout << "No";

  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
int main()
{
	int n,r;cin>>n>>r;
	if(n>=10)
	cout<<r<<endl;
	else
	{
		int sum;
		sum=100*(10-n);
		cout<<r+sum<<endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 1000

int selectionSort( int *ary, int n )
{
        int i, j, minx, tmp, swp = 0;

        for ( i = 0 ; i < n ; i++ )
        {
                minx = i;
                for ( j = i ; j < n ; j++ )
                {
                        if ( ary[minx] > ary[j] )
                        {
                                minx = j;
                        }
                }

                if ( i != minx )
                {
                        tmp = ary[i];
                        ary[i] = ary[minx];
                        ary[minx] = tmp;
                        swp++;
                }
        }
        return swp;
}


int main()
{
        int n, i, swp;
        int ary[MAX];

        scanf( "%d", &n );
        for ( i = 0 ; i < n ; i++ )
        {
                scanf( "%d", &ary[i] );
        }

        swp = selectionSort( ary, n );
        for ( i = 0 ; i < n ; i++ )
        {
                if ( i != n-1 )
                {
                        fprintf( stdout, "%d ", ary[i] );
                }
                else
                {
                        fprintf( stdout, "%d\n", ary[i] );
                }
        }
        fprintf( stdout, "%d\n", swp );


        return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	string s;cin >> s;
	int n = s.size();
	auto f = [&](int start,int num){
		if(start + num > n)return (string)"hoge";
		string ret =s.substr(0,start) + s.substr(start + num,n-start - num);
		return ret;
	};
	rep(j,n){
		rep(i,n){
			if(f(i,j) == "keyence"){
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3632
N,M = map(int,input().split())
H = list(map(int,input().split()))
roads = [[]for _ in range(N+1)]
for _ in range(M):
    a,b = map(int,input().split())
    roads[a].append(b)
    roads[b].append(a)


count = 0
for i in range(1,N+1):
    h = H[i-1]
    judge = 1
    for j in roads[i]:
        if h <= H[j-1]:
            judge = 0
            break
    if judge == 1:
        count += 1

print(count)



Measured memory_bytes: 92796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    FAST
    ll n,x;
    cin>>n>>x;
    ll arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    ll sum=0,count=0;
    for(int i=0;i<n;i++){
        sum+=arr[i];
        if(sum>x)break;
        else count++;
    }
    cout<<count+1;
    return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
ans=""
ans+="U"*(ty-sy)
ans+="R"*(tx-sx)
ans+="D"*(ty-sy)
ans+="L"*(tx-sx)
ans+="L"
ans+="U"*(ty-sy+1)
ans+="R"*(tx-sx+1)
ans+="D"
ans+="R"
ans+="D"*(ty-sy+1)
ans+="L"*(tx-sx+1)
ans+="U"
print(ans)


Measured memory_bytes: 9220
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;	//using vi = vector<int>;
typedef vector<vector<int>> vvi;

#define rep(i, N) for (int i = 0; i < N; i++)

vvi memo(1000, vector<int>(1000));

int main()
{
	int n, d;
	cin >> n >> d;
	if (n % (2 * d + 1) == 0)cout << n / (2 * d + 1) << endl;
	else cout << (n / (2 * d + 1))+1 << endl;

	return 0;
}


Measured memory_bytes: 4224
/* Life is all about calculated risks.
    But man am I bad at math. */

#include <bits/stdc++.h> 
#define ll long long int
#define INF (ll)1e12
#define MOD 1000000007
#define mp make_pair

#define DEBUG(x) cerr<<"> "<< #x << ':' <<x<<endl;

using namespace std;

ll f(ll p)
{
    ll l=1,r=p;
    ll mid = (l+r)/2;
    ll ans = 1;
    while(l <= r)
    {
        mid = (l+r)/2;
        if((mid*(mid+1))/2 <= p)
        {
            ans = mid;
            l = mid+1;
        }
        else
        {
            r = mid-1;
        }
    }
    return ans;
}

ll n;
vector<pair<ll,ll>> factors;

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

    cin>>n;
    ll sq = sqrt(n);
    ll num = n;
    for(ll i=2; i<=sq; i++)
    {
        if(num % i == 0)
        {
            ll cnt = 0;
            while(num%i == 0)
            {
                num /= i;
                cnt++;
            }
            factors.push_back(mp(i,cnt));
        }
    }
    if(num != 1)
        factors.push_back(mp(num,1));
    ll ans = 0;
    for(auto it: factors)
    {
        ans += f(it.second);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3700
#coding: utf-8

while True:
    H, W = (int(i) for i in input().split())

    if H == W == 0:
        break
    
    for i in range(H):
        for j in range(W):
            if i == 0 or i == H-1 or j == 0 or j == W-1:
                print("#", end = '')
            else:
                print(".",end = '')
        print("")
    print("")
    


Measured memory_bytes: 7024
#include <bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(0) 
typedef long long int ll;
using namespace std;
const int MOD=1e9+7;
const int size=1 << 10;

ll n,m;
char a[size][size];
int main()
{
	cin >> n >> m;
	cout << 2*m-n;
}

Measured memory_bytes: 256
#include<stdio.h>
#define SIZE 100

int main(){
  int i, j, n, x, y;
  int r[SIZE+1], m[SIZE+1][SIZE+1];
  scanf("%d", &n);
  for(i=1; i<=n; i++){
    scanf("%d%d", &r[i-1], &r[i]);
  }
  for(i=0; i<=n; i++){
    m[i][i] = 0;
  }

  for(x=2; x<=n; x++){
    for(i=0; i<=n-x+1; i++){
      j = i+x-1;
      m[i][j] = (1 << 21);
      for(y=i; y<=j-1; y++) if(m[i][j] > m[i][y] + m[y+1][j] + r[i-1]*r[y]*r[j]) m[i][j] = m[i][j] = m[i][y] + m[y+1][j] + r[i-1]*r[y]*r[j];
    }
  }
  printf("%d\n", m[1][n]);

  return 0;
}



Measured memory_bytes: 2112
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        List<Boolean> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(false);
        }
        for (int i = 0; i < m; i++) {
            a.set(sc.nextInt(), true);
        }

        int costZero = 0;
        int costN = 0;
        for (int i = x; i > 0; i--) {
            if (a.get(i)) {
                costZero++;
            }
        }
        for (int i = x; i < n; i++) {
            if (a.get(i)) {
                costN++;
            }
        }
        System.out.println(Math.min(costZero, costN));
    }

}


Measured memory_bytes: 22996
N = int(input())
F = [0 for i in range(N)]
P = [0 for i in range(N)]
for i in range(N):
  F[i] = [int(x) for x in input().split()]
for i in range(N):
  P[i] = [int(x) for x in input().split()]
ans = -10 * 10 ** 9
for c in range(1, 2 ** 10):
  pat = ('0' * 9 + bin(c)[2:])[-10:]
  ans = max(sum([P[i][sum([F[i][j] * int(pat[j]) for j in range(10)])] for i in range(N)]), ans)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

//see answer
int main() {
	int N;
	long long D, A;
	cin >> N >> D >> A;
	vector<pair<long long, long long>> XH(N);
	for (int i = 0; i < N; i++) cin >> XH[i].first >> XH[i].second;
	sort(XH.begin(), XH.end());

	vector<int> End(N, N);
	int l = 0;
	for (int i = 0; i < N; i++) {
		long long x = XH[i].first;
		while (XH[l].first + 2 * D < x) {
			End[l] = i;
			l++;
		}
	}

	vector<long long> Bombs(N, 0);
	long long bomb = 0, ans = 0;
	for (int i = 0; i < N; i++) {
		bomb += Bombs[i];
		long long h = XH[i].second;
		h -= bomb;
		if (h > 0) {
			long long n = (h + A - 1) / A;
			ans += n;
			bomb += n * A;
			if (End[i] < N) Bombs[End[i]] -= n * A;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 5760