akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
int sg[100001];
int n,p,q;
bool in[100001];
vector<int>c[100001];
vector<int>adj[100001];
void build(int id){
	in[id]=true;
	for(int i=0; i<adj[id].size() ;i++){
		int cur=adj[id][i];
		if(in[cur]) continue;
		c[id].push_back(cur);
		build(cur);
	}
}
void cal(int id){
	for(int i=0; i<c[id].size() ;i++){
		cal(c[id][i]);
		sg[id]^=(sg[c[id][i]]+1);
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1; i<n ;i++){
		cin >> p >> q;
		adj[p].push_back(q);
		adj[q].push_back(p);
	}
	build(1);
	cal(1);
	if(sg[1]==0) cout << "Bob\n";
	else cout << "Alice\n";
}

Measured memory_bytes: 17920
import java.util.*;
class Main{
	Scanner sc=new Scanner(System.in);
	void aa(){
		while(true){
			int h=sc.nextInt();
			int w=sc.nextInt();
			if(h==0&&w==0)break;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(i==0||i==h-1||j==0||j==w-1)System.out.print("#");
					else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
	public static void main(String[]arg){
		new Main().aa();
	}
}

Measured memory_bytes: 24636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    int k;
    ll l, r;
    ll ans = 0;
    vector<ll> vl[n + 2], vr[n + 2];
    rep(i, n) {
        cin >> k >> l >> r;
        if (l > r) {
            ans += r;
            vl[k].emplace_back(l - r);
        } else {
            ans += l;
            vr[k + 1].emplace_back(r - l);
        }
    }
    priority_queue<int, vector<int>, greater<int>> que;
    for (int i = 1; i <= n; i++) {
        for (ll x : vl[i]) {
            que.emplace(x);
        }
        while ((int)que.size() > i) {
            que.pop();
        }
    }
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }
    for (int i = n; i > 0; i--) {
        for (ll x : vr[i]) {
            que.emplace(x);
        }
        while ((int)que.size() > n - i + 1) {
            que.pop();
        }
    }
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}

signed main() {
    int number_of_testcases;
    cin >> number_of_testcases;
    while (number_of_testcases--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 18044
use proconio::marker::*;
use proconio::*;
use std::cmp::*;

pub trait MoOperator {
    type Query;
    type Answer;
    fn size(&self) -> usize;
    fn init(&mut self);
    fn insert(&mut self, v: usize);
    fn delete(&mut self, v: usize);
    fn answer(&mut self, q: Self::Query) -> Self::Answer;
}

struct State {
    c: Vec<usize>,
    cnt: Vec<u32>,
    ans: usize,
}

impl MoOperator for State {
    type Query = ();
    type Answer = usize;
    fn size(&self) -> usize {
        self.c.len()
    }
    fn init(&mut self) {
        for c in self.cnt.iter_mut() {
            *c = 0;
        }
        self.ans = 0;
    }
    fn insert(&mut self, x: usize) {
        let c = &mut self.cnt[self.c[x]];
        if *c == 0 {
            self.ans += 1;
        }
        *c += 1;
    }
    fn delete(&mut self, x: usize) {
        let c = &mut self.cnt[self.c[x]];
        if *c == 1 {
            self.ans -= 1;
        }
        *c -= 1;
    }
    fn answer(&mut self, _q: Self::Query) -> usize {
        self.ans
    }
}

#[fastout]
fn run() {
    input! {
        n: usize,
        q: usize,
        c: [Usize1; n],
        ask: [(Usize1, usize); q],
    }
    let mut query: Vec<_> = ask.into_iter().map(|(l, r)| (l, r, ())).collect();
    let mut answer = vec![0; q];
    let mut state = State {
        c: c,
        cnt: vec![0; n],
        ans: 0,
    };
    let size = n;
    let batch = (size as f64 / (query.len() as f64).sqrt()).ceil() as usize;
    let mut q = vec![];
    std::mem::swap(&mut q, &mut query);
    let mut query = (0..(size / batch + 1)).map(|_| vec![]).collect::<Vec<_>>();
    for (i, (l, r, op)) in q.into_iter().enumerate() {
        query[l / batch].push((r, l, i, op));
    }
    state.init();
    let mut x = 0;
    let mut y = 0;
    for (i, mut query) in query.into_iter().enumerate() {
        query.sort_unstable_by_key(|p| p.0);
        if i & 1 == 1 {
            query.reverse();
        }
        for (r, l, k, op) in query.into_iter() {
            for v in (min(x, l)..x).rev() {
                state.insert(v);
                x = l;
            }
            for v in min(y, r)..r {
                state.insert(v);
                y = r;
            }
            for v in min(x, l)..l {
                state.delete(v);
                x = l;
            }
            for v in (min(y, r)..y).rev() {
                state.delete(v);
                y = r;
            }
            answer[k] = state.answer(op);
        }
    }
    for a in answer {
        println!("{}", a);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 41628
def examA():
    N = I()
    X = [LI()for _ in range(N)]
    l = 0; r = inf
    while(r-l>_ep):
        now = (l+r)/2
        x_l = -inf; x_r = inf
        y_l = -inf; y_r = inf
        for x,y,c in X:
            move = now / c
            x_l = max(x_l,x-move)
            x_r = min(x_r,x+move)
            y_l = max(y_l,y-move)
            y_r = min(y_r,y+move)
        if x_l+_ep<x_r and y_l+_ep<y_r:
            r = now
        else:
            l = now
    ans = r
    print(ans)
    return

def examB():
    N = I()
    C = LI()
    C.sort()
    base = pow(2,2*N-1,mod)
    inv = pow(2,mod-2,mod)
    ans = 0
    for i in range(N):
        cur = C[i]*base*(1+(N-1-i)*inv)
        ans += cur
        ans %= mod
    print(ans)
    return

def examC():
    N = I()
    Ag,As,Ab = LI()
    Bg,Bs,Bb = LI()
    dp = [i for i in range(N+1)]
    for i in range(N):
        dp[i+1] = max(dp[i],dp[i+1])
        if i+Ag<=N:
            dp[i+Ag] = max(dp[i+Ag],dp[i]+Bg)
        if i+As<=N:
            dp[i+As] = max(dp[i+As],dp[i]+Bs)
        if i+Ab<=N:
            dp[i+Ab] = max(dp[i+Ab],dp[i]+Bb)
    ne_N = dp[-1]
    #print(dp)
    dp2 = [i for i in range(ne_N+1)]
    for i in range(ne_N):
        dp2[i+1] = max(dp2[i],dp2[i+1])
        if i+Bg<=ne_N:
            dp2[i+Bg] = max(dp2[i+Bg],dp2[i]+Ag)
        if i+Bs<=ne_N:
            dp2[i+Bs] = max(dp2[i+Bs],dp2[i]+As)
        if i+Bb<=ne_N:
            dp2[i+Bb] = max(dp2[i+Bb],dp2[i]+Ab)
    ans = dp2[-1]
    print(ans)
    return


import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-4)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 424888
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    ll d;
    cin>>N>>M>>d;
    long double ans = (M - 1);
    if(d == 0){
        cout<<fixed<<setprecision(10)<<ans / N<<endl;
    }else{
        ll g = N * 2 - min(d * 2, N);
        cout<<fixed<<setprecision(10)<<(ans * g) / (N * N)<<endl;
    }
}

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

int users; 
int friendships;
int blockships; 
int u1, u2;
int comp[100100];
int componentSize[100100];
int friendCandidates[100100]; 
bool visited[100100]; 
vector<int> fList[100100]; 
vector<int> bList[100100];

void dfs(int vertexID, int componentID) {
    if (visited[vertexID])
        return; 
    visited[vertexID] = true;
    comp[vertexID] = componentID;
    componentSize[componentID]++;   
    for (int f : fList[vertexID]) {
        dfs(f, componentID); 
    }
}
int main() {
    scanf("%d %d %d", &users, &friendships, &blockships); 

    for (int i = 0; i < friendships; i++) {
        scanf("%d %d", &u1, &u2); 
        fList[u1].push_back(u2);
        fList[u2].push_back(u1);
    }

    for (int i = 0; i < blockships; i++) {
        scanf("%d %d", &u1, &u2); 
        bList[u1].push_back(u2);
        bList[u2].push_back(u1);
    }

    int numOfComponents = 0; 

    for (int i = 1; i <= users; i++) {
        if (!visited[i]) {
            dfs(i, ++numOfComponents); 
        }
    }

    for (int i = 1; i <= users; i++) {
        int totalCandidates = componentSize[comp[i]] - 1; 
        int notCandidates = fList[i].size();
        for (int enemy : bList[i]) {
            if (comp[enemy] == comp[i]) 
                notCandidates++; 
        } 
        totalCandidates -= notCandidates; 
        totalCandidates = max(totalCandidates, 0); 
        friendCandidates[i] = totalCandidates; 
    }

    for (int i = 1; i <= users; i++) {
        printf("%d ", friendCandidates[i]); 
    }

    printf("\n");
}

Measured memory_bytes: 12800
while 1:
    H, W = map(int, input().split())

    if H == 0 and W == 0:
        break

    for i in range(H):
        for j in range(W):
            if (i+j)%2 == 0:
                print("#", end = "")
            else:
                print(".", end = "")
        print("")
    print("")

Measured memory_bytes: 9000
from collections import Counter

H, W = map(int, input().split())
cntr = Counter()
[cntr.update(Counter(input())) for _ in range(H)]

if H % 2 and W % 2:
    has_one = False
    twos = 0
    for v in cntr.values():
        if v % 2:
            if has_one:
                print("No")
                exit()
            else:
                has_one = True
                twos += 2 if v == 3 else 0
        else:
            twos += v % 4
    print("Yes") if twos // 2 <= H // 2 + W // 2 and has_one else print("No")
elif H % 2 or W % 2:
    if H % 2:
        H, W = W, H
    twos = 0
    for v in cntr.values():
        if v % 2:
            print("No")
            exit()
        else:
            twos += v % 4
    print("Yes") if twos <= H else print("No")
else:
    print("Yes") if all(v % 4 == 0 for v in cntr.values()) else print("No")


Measured memory_bytes: 9480
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long  t,r=1,r1=0,r2=0,k=0,a,b,c=0,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    vector<tuple<string,int,
           int>>mp;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1="ACL";
    //,s2,s3,s4;
    cin>>n;
    l(i,0,n)


{


cout<<s1;

}
cout<<endl;
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<string.h>
int main()
{
  char s1[27]="abcdefghijklmnopqrstwxyz";
  char s[100000];
  int i,j,l,l1,c1=0,d1;
  gets(s);
  l=strlen(s);
  l1=strlen(s1);
  for(i=0;i<l1;i++){
        d1=0;
        for(j=0;j<l;j++){
            if(s1[i]==s[j]){
                    c1++;
                    break;
            }
     if(s1[i]!=s[j]){
        d1++;

    }
        }
         if(d1==l){
        printf("%c",s1[i]);
        break;
    }
    if(c1==l1){
        printf("None");
    }

  }
return 0;
}



Measured memory_bytes: 256
/**Bismillahir Rahmanir Rahim**/


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

#define pb push_back
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define clr(v) v.clear()
vector<ll>v;
pair<ll,ll>p;
map<ll,ll>mp;
set<ll>st;
deque<ll>dq;
priority_queue<ll>pq;
#define f(i,b) for(i=0;i<b;i++)
#define f1(i,b) for(i=1;i<=b;i++)
#define fr(i,b)for(i=b-1;i>=0;i--)
ll mn=INT_MAX,mx=INT_MIN;
ll n,m,tc,i,j,tmp,sum,cn,ans,res,pos,flag,l,x,k,dif;

string s,str;


ll a[200007],b[200007];
int main()
{

   io;
ll a,b,c,d;
cin>>a;
cout<<48-a<<endl;
return 0;
}





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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) {
    cin>>A[i];
  }

  vector<ll> t(N, 0);
  vector<ll> base(N);
  rep(i,N) {
    base[i] = i - A[i];
    // printf("A[%d]=%d base[%d]=%d\n", i, A[i], i, base[i]);

    // base[i] 短調増加で、0<= base <= N-1 ならOK
    if (i>0 && base[i-1] > base[i]) {
      cout << -1 << endl;
      return 0;
    }

    if (base[i] < 0 || base[i] >= N) {
      cout << -1 << endl;
      return 0;
    }
    t[base[i]] = max(t[base[i]], i-base[i]);
  }
  ll ans = accumulate(t.begin(), t.end(), 0LL);
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod (ll)1000000007
#define fast std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define input int t;cin>>t;while(t--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define f(i, a, b) for (int i = (a); i < (b); i++)
#define fr(i, a, b) for (int i = (a); i >= (b); i--)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define all(x) x.begin(), x.end()
#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
int i,j,k;
int main()
{
	int n;
	cin>>n;
	ll a[n];
	ll h[n+1]={0};
	set<ll> s;
	f(i,0,n)
	{
		cin>>a[i];
		h[a[i]]++;
		s.insert(a[i]);
	}
	ll cnt=0;
	for(auto i:s)
	{
		cnt+=(h[i]*(h[i]-1))/2;
	}
	ll ans;
	f(i,0,n)
	{
		ans=cnt-(h[a[i]]-1);
		cout<<ans<<"\n";
	}
	
	
}


Measured memory_bytes: 10624
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val MOD = 1000000007
    val s = readLine()!!.reversed()
    // dp[i][j]: 入力の右からi番目まででj余る
    val dp = Array(s.length + 1) { LongArray(13) }
    dp[0][0] = 1
    var ten = 1
    for (i in s.indices) {
        if (s[i] == '?') {
            for (j in 0..9) {
                val num = (j * ten) % 13
                for (k in 0 until 13) {
                    dp[i + 1][(k + num) % 13] = (dp[i + 1][(k + num) % 13] + dp[i][k]) % MOD
                }
            }
        } else {
            val num = ((s[i] - '0') * ten) % 13
            for (j in 0 until 13) {
                dp[i + 1][(j + num) % 13] = (dp[i + 1][(j + num) % 13] + dp[i][j]) % MOD
            }
        }

        ten = (ten * 10) % 13
    }
    println(dp[s.length][5])
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 50632
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	cin >> s;

	set<char> ss;
	for (auto ch : s) ss.insert(ch);

	if (ss.size() == 26) cout << "None\n";
	else {
		for (char ch = 'a'; ch <= 'z'; ch++) {
			if (ss.find(ch) == ss.end()) {
				cout << ch << "\n";
				break;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); ++i)
#define per(i,a,b) for (int i=(a); i>=(b); --i)
using namespace std;

const int maxn = 400005;
int f[maxn][20], g[maxn][20], pre[1<<19], suf[1<<19];
int x[maxn], ans[maxn], d[20], n, m, v;

int main() {
	scanf("%d%d", &n, &v); d[0] = v;
	while (v) d[++m] = v/2, v /= 2;
	rep (i, 1, n) scanf("%d", &x[i]);
	rep (i, 1, n) rep (j, 0, m)
		if (i >= 2 && x[i] - x[i-1] <= d[j]) f[i][j] = f[i-1][j];
		else f[i][j] = i;
	per (i, n, 1) rep (j, 0, m)
		if (i <= n-1 && x[i+1] - x[i] <= d[j]) g[i][j] = g[i+1][j];
		else g[i][j] = i;
	memset(pre, 0xc0, sizeof pre);
	memset(suf, 0x3f, sizeof suf);
	pre[0] = 0; suf[0] = n+1;
	int ALL = (1<<m)-1;
	rep (i, 0, ALL) rep (j, 0, m-1) if (!(i>>j&1)) {
		if (pre[i] == n) pre[i|1<<j] = n;
		else pre[i|1<<j] = max(pre[i|1<<j], g[pre[i]+1][j+1]);
		if (suf[i] == 1) suf[i|1<<j] = 1;
		else suf[i|1<<j] = min(suf[i|1<<j], f[suf[i]-1][j+1]);
	}
	int l = 1, r, tot = 0, flag;
	while (l <= n) {
		r = l; if (tot++ > m) break;
		while (r + 1 <= n && x[r+1] - x[r] <= d[0]) r++;
		flag = 0;
		rep (i, 0, ALL)
			if (pre[i] >= l-1 && suf[(~i)&ALL] <= r+1) {
				flag = 1; break;
			}
		rep (i, l, r) ans[i] = flag;
		l = r + 1;
	}
	rep (i, 1, n) puts(ans[i] ? "Possible" : "Impossible");
	return 0;
}

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

typedef long long ll;
vector<int>prime;
const int N = 1e6;
const ll mod = 1e9+7;
int arr[10010],cnt[N+100];
int mark[N+100];
void sieve()
{
	for(int i=2;i<=N;i++){
		if(!mark[i]){
			prime.push_back(i);
			mark[i] = i;
		}
		for(auto it:prime)
		{
			if(it*i>N)break;
			mark[it*i] = it;
			if(i%it==0)break;
		}
	}
}
ll bigmod(ll a,ll b)
{
	if(b==0)return 1;
	ll x = bigmod(a,b/2);
	x = (x*x)%mod;
	if(b%2)x = (x*a)%mod;
	return x;
}
int main()
{
	sieve();
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&arr[i]);
	}
	for(int i=1;i<=n;i++)
	{
		int tmp = arr[i];
		vector<int>v;
		while(mark[tmp])
		{
			v.push_back(mark[tmp]);
			tmp/=mark[tmp];
		}
		int sz = v.size();
		for(int j=0;j<sz;)
		{
			int k;
			for(k=j+1;k<sz&&v[k]==v[j];k++);
			cnt[v[j]] = max(cnt[v[j]],k-j);
			j = k;
		}
	}
	ll lcm = 1;
	for(int i=2;i<=N;i++){
		lcm = (lcm*bigmod(i,cnt[i]))%mod;
	}
	ll ans = 0;
	for(int i=1;i<=n;i++){
		ll t1 = bigmod(arr[i],mod-2)%mod;
		ll ins = (lcm*t1)%mod;
		ans = (ans+ins)%mod;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 7544
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrt sqrtl
#define int intl
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 1; i <= k; i++){
        a *= i;
    }
    return a;
}
signed main(){
    intl n;
    cin >> n;
    intl a[n];
    cin(i,a);
    map <int,int> m;
    rep(i,n){
        m[a[i]]++;
    }
    intl cnt = 0;
    for(auto i :m){
        cnt += (i.second * (i.second - 1))/2;
    }
    rep(i,n){
        cnt -= m[a[i]]*(m[a[i]]-1)/2;
        cnt += (m[a[i]]-1)*(m[a[i]]-2)/2;
        cout << cnt << endl;
        cnt += m[a[i]]*(m[a[i]]-1)/2;
        cnt -= (m[a[i]]-1)*(m[a[i]]-2)/2;
    }
    return 0;
}

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

int main(){
	int N, total;
	while (cin >> N) {
		for (int i = 0; i < 10; i++) {
			if (N & 1) {
				total = 1 << i;
				cout << total;
				if (N >> 1) {
					cout << ' ';
				}
			}
			N >>= 1;
		}
		cout << endl;
	}
}

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

long long int niche(long long int a, long long int m) {
  long long int w = a, n = 1;
  while (w % m != 1) {
    n++;
    w = (w % m) * a;
  }
  return n;
}

long long int gcd(long long int a, long long int b) {
  return (b == 0) ? a:gcd(b, a % b);
}

long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}

long long int lcm(long long int a, long long int b, long long int c) {
  return lcm( lcm(a, b), c);
}

int main() {
  long long int a1, m1, a2, m2, a3, m3;

  while (cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3) {
    if (a1 * m1 * a2 * m2 * a3 * m3 == 0)
      break;

    cout << lcm(niche(a1, m1), niche(a2, m2), niche(a3, m3)) << endl;
  }
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
using llong = long long;

llong n;
llong a[15];
llong x[15][15];
llong y[15][15];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (int j = 0; j < a[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }

    llong ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        bitset<16> b(i);

        bool f = true;
        for (int j = 0; j < n; j++) {
            if (!b[j]) continue;

            for (int k = 0; k < a[j]; k++) {
                if (b[x[j][k] - 1] != y[j][k]) f = false;
            }
        }

        if (f) {
            ans = max<llong>(ans, b.count());
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define INF 10000000000000000LL
#define ll  long long 
const int inf =INT_MAX;
const int MAX=3e5+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=1e6+9;
const int MAX_A=71;
const int LN=20;
using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size();
    while(n--){
        rotate(s.rbegin(), s.rbegin()+1, s.rend());
        if(s == t){
            cout << "Yes" << "\n";
            return 0;
        }
    }
    cout << "No" << "\n";
    return 0;
}

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

int main(){
    long long i,n,max=0,ans=0;
    cin >> n;
    vector<long long> a(n);
    map<long long,long long>Map;
    for(i=0;i<n;i++){
        cin >> a.at(i);
        Map[a.at(i)]++;
        if(i==0)max=a.at(i);
        if(max<a.at(i))max=a.at(i);
    }
    for(i=0;i<n;i++){
        if(Map[a.at(i)]<a.at(i)){
            ans += Map[a.at(i)];
        }
        else if(Map[a.at(i)]==a.at(i)){
            continue;
        }
        else {
            ans += Map[a.at(i)]-a.at(i);
        }
        Map[a.at(i)]=0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
const int INF=1e9;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m;cin>>n>>m;
    vector<vector<int> > adj(n);
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    vector<int> distance(n,INF),processed(n),ans(n,0);
    priority_queue<pair<int,int> > q;
    distance[0]=0;
    q.push({0,0});
    while(!q.empty()){
        int a=q.top().second;q.pop();
        if(processed[a])continue;
        processed[a]=1;
        for(auto u:adj[a]){
            if(ans[u]==0)ans[u]=a+1;
            if(distance[a]+1<distance[u]){
                distance[u]=distance[a]+1;
                q.push({-distance[u],u});
            }
        }
    }
    ans[0]=0;
    for(int i:distance)if(i==INF){cout<<"No";return 0;}
    cout<<"Yes"<<endl;
    for(int i:ans)if(i!=0) cout<<i<<endl;
}

Measured memory_bytes: 11644
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(),(x).end()

using namespace std;

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


template<typename T>
void dump(T *arr, int h, int w){
	rep(i,h){
		rep(j,w) cout << arr[i][j] << "\t";
		cout << "\n";
	}
}

template<typename T>
void dump(T *arr, int a){
	rep(i,a) cout << arr[i] << "\t";
	cout << "\n";
}

template<typename T>
void dump(vector<T> arr, int a){
	rep(i,a) cout << arr[i] << "\t";
	cout << "\n";
}

const int INF = 1e9;
const int MOD = 1e9+7;

bool compare(P a, P b){
	if(a.second != b.second) return a.second > b.second;
	else	return a.first > b.first;
}


int digits(ll num){
	ll d=0;
	while(num >= 1){
		num/= 10;
		d++;
	}
	return d;
}

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

	int k,n;
	cin >> n >> k;

	vector<double> p(n);
	rep(i, n){
		cin >> p[i];
		p[i] = (p[i]+1)/2;
	}

	double sum=0;
	rep(i, k){
		sum+=p[i];
	}
	double ans=sum;
	for(int i=1; i+k-1<n; i++){
		sum = sum -p[i-1] + p[i+k-1];
//		cout << "  " << sum << "\n";
		ans = max(ans, sum);
	}
//	dump(p, n);
	cout << fixed << ans << "\n";

	return 0;
}


Measured memory_bytes: 1792
until(n,m=gets.split.map(&:to_i))==[0,0]do
r,p,a=[],[],[]
n.times{r.unshift(gets.gsub("?",".").split)}
m.times{p<<gets.split}
p.each{|p|r.each{|r|if p[0]=~/#{r[1]}/&&p[1]=~/#{r[2]}/
a<<p*" "if r[0]=~/p/
break
end}}
puts a.size,a
end

Measured memory_bytes: 9508
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

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

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

	lint n, in[2], ans = 0;
	cin >> n;
	rep(i, n) {
		cin >> in[0] >> in[1];
		ans += in[1] - in[0] + 1;
	}
	co(ans);
	gc();
}

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

int main(){
  char X,Y;cin >> X >> Y;
  if(X<Y){
    cout << "<" << endl;
  }else if(X>Y){
    cout << ">" << endl;
  }else{
    cout << "=" << endl;
  }
}

Measured memory_bytes: 256
def check(l, r):
    th = 1 + (r - l + 1) // 2 
    for i in range(26):
        if cnt[i] >= th:
            return True
    return False

s = input()
n = len(s)
si = [0] * n
for i in range(n):
    si[i] = ord(s[i]) - 97

l, r = 0, 1
cnt = [0]*26
for i in range(2):
    cnt[si[i]] += 1
while l < n-1 and r < n:
    if check(l, r):
        print(l+1, r+1)
        exit()
    elif max(cnt) == 1 + (r - l + 1) // 2 or r-l == 1:
        r += 1
        if r < n:
            cnt[si[r]] += 1
    else:
        cnt[si[l]] -= 1
        l += 1     
print(-1, -1)

Measured memory_bytes: 9888
a,b,c,d = [int(x) for x in input().split()]
MOD = 998244353
dp = [[0 for i in range(d+10)] for j in range(c+10)]

for i in range(a,c+1):
    for j in range(b,d+1):
        # print(str(i) +'  '+str(j))
        if i == a and j == b:
            dp[i][j] = 1
            continue
        dp[i][j] = dp[i-1][j]*j + dp[i][j-1]*i - dp[i-1][j-1]*(i-1)*(j-1)
        dp[i][j] %= MOD
print(dp[c][d])

Measured memory_bytes: 152980
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;

int main(){
	int n;
	int ans=0;
	int a[100];
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			ans+=a[i]*a[j];
		}
	}
	cout<<ans<<"\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
using ldb = long double;
using pa = pair < int, int >;
using vec = vector < int >;
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;
#define pb push_back
#define all(c) c.begin(),c.end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define F  first
#define S  second
#define f(i,x,n) for(int i=x;i<n;i++) 
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 5e5 + 10;
const double PI = acos(-1);
const int LINF = LLONG_MAX;
// 
int32_t main() {
    fast();
    int a[3][3];
    f(i,0,3){
          f(j,0,3){
              	cin >> a[i][j];   
          }
    }
    int b[3][3];
    f(i,0,3){
           f(j,0,3){
                  b[i][j]=0;
           }
    }
    int n;
    cin >> n;
    f(i,0,n){
          int x;
          cin >> x;
          f(j,0,3){
          	int f=0;
             f(k,0,3){
              		if(a[j][k]==x and b[j][k]==0) {
              			b[j][k]=1;
              			f=1;
              			break;
              		}         
              
              }
              if(f){
              	break;
              }    

          }
    }
   	f(i,0,3){
   		int c=0,c1=0;
   		f(j,0,3){
   		       if(b[i][j]==1){
   		       		c++;
   		       }
   		}
   		if(c==3){
   			cout<<"Yes\n";
   			return 0;
   		}
   		c=0;
   		f(j,0,3){
   		       if(b[j][i]==1){
   		       	c++;
   		       }
   		}
   		if(c==3){
   			cout<<"Yes\n";
   			return 0;
   		}
   	}
   	int c=0;
   	f(i,0,3){
   	       f(j,0,3){
   	              if(i==j and b[i][j]==1){
   	              	c++;
   	              }
   	       }
   	}
   	if(c==3){
   		cout<<"Yes\n";
   		return 0;
   	}
   	if(b[0][2]+b[1][1]+b[2][0]==3){
   		cout<<"Yes\n";
   		return 0;
   	}
   	cout<<"No\n";

    return 0;
}



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

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

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

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

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

using i64=int64_t;

void solve(){
    int N,K;
    cin >> N >> K;

    vector<int> A(N);
    vector<i64> B(N);
    rep(i,0,N) cin >> A[i] >> B[i];

    auto f=[&](int x){
        i64 sum=0;
        rep(i,0,N) if((A[i]|x)==x) sum+=B[i];
        return sum;
    };

    i64 ans=f(K);
    rep(i,0,30){
        if(!((K>>i)&1)) continue;
        ans=max(ans,f(((K^(1<<i))|((1<<i)-1))));
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
#define MOD 1000000007
using namespace std;
int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> h(n);
    rep(i,0,n){
        cin>>h[i];
    }
    sort(h.begin(),h.end(),greater<ll>());
    ll ans=0;
    rep(i,k,n)ans+=h[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int INF=100000000;
	int n,m; cin>>n>>m;
	int dp[50010]; rep(i,50010) dp[i]=INF;
	dp[0]=0;
	int c[m]; rep(i,m) cin>>c[i];
	rep(i,n+1){
		rep(j,m){
			int tmp=INF;
			if(i-c[j]>=0) tmp=dp[i-c[j]]+1;
			dp[i]=min(tmp,dp[i]);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}



Measured memory_bytes: 3304
sx,sy,tx,ty = map(int, raw_input().split())
dx = tx-sx
dy = ty-sy
PATH = 'U'*dy + 'R'*dx + 'D'*dy + 'L'*dx
PATH += 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D'
PATH += 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'
print PATH

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

ll N, K;
set<ll> num = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
ll mini = numeric_limits<ll>::max();

void dfs(ll current) {
    if(N <= current) {
        mini = min(mini, current);
        return;
    }
    iter(i, num) {
        if(i == 0 && current == 0) continue;
        ll temp;
        temp = 10 * current;
        temp += i;
        dfs(temp);
    }
}

int main(void) {
    cin >> N >> K;
    rep(i, K) {
        ll temp;
        cin >> temp;
        num.erase(temp);
    }
    dfs(0);
    cout << mini << endl;
    return 0;
}


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

int main(){
	 int n,cont=0;
	 cin >> n;
	 char c;
	 for(int i = 0;i<n;i++){
	 	cin >> c;
	 	if(cont >= 0 and c == '('){
	 	
	 		cont++;
	 		dq.push_back('(');
	 		
	 	}else if(cont and c == ')'){
	 	
	 		cont--;
	 		dq.push_back(')');
	 		
	 	}else if(cont == 0 and c == ')'){
	 		cont = 0;
	 		dq.push_front('(');
	 		dq.push_back(')');
	 	}else
	 		cout<<"oi";
	 }
	 while(cont--){
	 	dq.push_back(')');
	 }
	 
	 for(auto it: dq)
	 	cout<<it;

}

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

using namespace std;

int main() {
   int n;
   cin >> n;
   int mx;
   int i=1;
   int co=0;
   int h;
   while(i<=n){
       cin >> h;
       if(i==1){
           mx=h;
           co=co+1;
       }
    else if(mx<=h){
           mx=h;
           co=co+1;
       }
       i=i+1;
   }
   cout << co << endl;
   return 0;
}

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

int main(void){
  int N;
  cin >> N;  
  vector<int>button(N);
  for( int i=0; i<N; ++i){
    int input_button;
    cin >> input_button;
    input_button--;
    button.at(i)=input_button;
  }
  
  int blink_button=0;		//最初に光ってるのはボタン1
  int push_num=0;			//ボタンを押した回数
  for(;;){
    if(blink_button == 1){
      cout << push_num << endl;
      break;
    }
    if(push_num >= N){
      cout << -1 << endl;
      break;
    }
    push_num++;
    blink_button = button[blink_button];
  }
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> v(n,0);
  for(int i=1;i<=k;i++){
    int d;
    cin>>d;
    for(int j=1;j<=d;j++){
      int a;
      cin>>a;
      v[a-1]=1;
    }
  }
  int ans=0;
  for(auto &i:v){
    if(i==0){
      ans+=1;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}
 
 
int main() {
    ll n,k,h;
    cin >> n >> k;
    vector<ll> H;
    rep(i,n) {
        cin >> h;
        H.pb(h);
    }
    sort(all(H), std::greater<ll>());
    ll t = 0;
    rep(i,H.size()) {
        if (i > k-1) {
            t += H[i];
        }
    }
    cout << t << "\n";

}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    double t,a;
    cin>>t>>a;
    double h,p;
    int ans=1;
    cin>>h;
    p=(double)abs(t-h*0.006-a);
    for (int i=2;i<=n;i++) {
        cin>>h;
        if ((double)abs(t-0.006*h-a)<p) {
            p = (double)abs(t-0.006*h-a);
            ans = i;
        }
    }
    cout<<ans;
}


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

int main()
{
    double a, b, C;
    cin >> a >> b >> C;
    double r = C * M_PI / 180;

    cout << fixed << setprecision(8)
        << a * b * sin(r) / 2 << endl
        << a + b + sqrt(a * a + b * b - 2 * a * b * cos(r)) << endl
        << b * sin(r) << endl;

    return 0;
}


Measured memory_bytes: 3512
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  long a[n],b[n],c[n];
  for(int i = 0;i<n;i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  long dp[3][n+5];
  dp[0][1] = a[0];
  dp[1][1] = b[0];
  dp[2][1] = c[0];
  for(int i = 2;i<=n;i++){
    dp[0][i] = max(dp[1][i-1],dp[2][i-1])+a[i-1];
    dp[1][i] = max(dp[0][i-1],dp[2][i-1])+b[i-1];
    dp[2][i] = max(dp[0][i-1],dp[1][i-1])+c[i-1];
  }
  cout << max(dp[0][n],max(dp[1][n],dp[2][n])) << endl;
}


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

int main() {
  int N, ans;
  cin >> N;
  ans = 0;
  for(int i=0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	double s,m;
	
	while( scanf("%lf",&s) != EOF ){
		scanf("%lf",&m);
		
		while(1){
			if(s<35.50 && m<71.00){
				printf("AAA\n");
				break;
			}
			else if(s<37.50 && m<77.00){
				printf("AA\n");
				break;
			}
			else if(s<40.00 && m<83.00){
				printf("A\n");
				break;
			}
			else if(s<43.00 && m<89.00){
				printf("B\n");
				break;
			}
			else if(s<50.00 && m<105.00){
				printf("C\n");
				break;
			}
			else if(s<55.00 && m<116.00){
				printf("D\n");
				break;
			}
			else if(s<70.00 && m<148.00){
				printf("E\n");
				break;
			}
			else if(s>=70.00 || m>=148.00){
				printf("NA\n");
				break;
			}
		}
	}
	
return 0;
}

Measured memory_bytes: 608
let [| N; K |] = stdin.ReadLine().Split() |> Array.map int

let h =
    [| for i in [ 0..N - 1 ] do
        yield (stdin.ReadLine() |> int) |]
    |> Array.sort

[| 0..N - K |]
|> Array.map (fun i -> h.[i + K - 1] - h.[i])
|> Array.min
|> stdout.WriteLine


Measured memory_bytes: 39012
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const uLL base=26;
uLL power[23];

int n,m,ord[23],pos[23];
char s[23][23];

uLL hsx[23],hsy[23];
bool use[23];
void dfs(int x)
{
	if(x==n+1)
	{
		for(int i=1;i<=m;i++)hsx[i]=hsy[i]=use[i]=0;
		for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)
		{
			hsx[j]+=power[pos[i]]*(s[i][j]-'a');
			hsy[j]+=power[n-pos[i]+1]*(s[i][j]-'a');
		}
		int match=0;
		for(int i=1;i<=m;i++)if(!use[i])
		{
			for(int j=1;j<=m;j++)if(!use[j]&&i!=j&&hsx[i]==hsy[j])
			{
				use[i]=use[j]=1;
				match++;
				break;
			}
		}
		if(match!=m/2)return;
		if(m%2==1)
		{
			for(int i=1;i<=m;i++)if(!use[i]&&hsx[i]!=hsy[i])
				return;
		}
		puts("YES");
		exit(0);
	}
	for(int i=1;i<=n;i++)if(!pos[i])
	{
		pos[i]=ord[x];
		dfs(x+1);
		pos[i]=0;
		if(n-x&1)break;
	}
	
}
int main()
{
	power[0]=1;
	for(int i=1;i<23;i++)power[i]=power[i-1]*base;
	
	get2(n,m);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	int tn=0;
	if(n%2)ord[++tn]=n/2+1;
	for(int i=1;i<=n/2;i++)
	{
		ord[++tn]=i;
		ord[++tn]=n-i+1;
	}
	dfs(1);
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdbool.h>

#define MAX 1000000

int main(void)
{
    int i, j;

    bool isPrime[MAX];
    isPrime[0] = isPrime[1] = false;
    isPrime[2] = true;
    for (i = 4; i < MAX; i += 2) {
        isPrime[i] = false;
    }

    int prime_list[MAX];
    prime_list[0] = 2;
    int prime_cnt = 1;

    for (i = 3; i < MAX; i += 2) {
        isPrime[i] = true;
        for (j = 0; j < prime_cnt && prime_list[j] <= sqrt(i); j++) {
            if (i % prime_list[j] == 0) {
                isPrime[i] = false;
                break;
            }
        }
        if (isPrime[i] == true) {
            prime_list[prime_cnt] = i;
            prime_cnt++;
        }
    }

    int n;
    while (scanf("%d", &n) != EOF) {
        int cnt = 0;
        for (i = 2; i <= n; i++) {
            if (isPrime[i] == true) {
                cnt++;
            }
        }
        printf("%d\n", cnt);
    }

    return 0;
}

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

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 P(p) cout<<(p)<<endl
#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 n,m,a,b,c,d[100005] = {};
string s,t;

int main(){
    cin >> a >> b;
    P((a+b)%24);
	
	return  0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int w,n;
    int W[30],a,b;
    
cin>>w>>n;
    for(int i=1;i<=30;i++){
       W[i]=i;
    }
       for(int i=1;i<=n;i++){
        (cin>>a).ignore()>>b;
swap(W[a],W[b]);
    } 
        for(int i=1;i<=w;i++){
    cout<<W[i]<<endl;
        }
}

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

int main(){
	int sum = 0;
	string a;
	cin >> a;
	for(int i = 0;i<a.size();i++){
		if(a[i]=='x'){
			sum += 1;
		}
		else{
			sum += 0;
		}
	}
	if(sum>7){
		cout << "NO";
	}
	else{
		cout << "YES";
	}
	return 0;
} 

Measured memory_bytes: 256