akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
//#include <tuple>
#include <set>
#include <string.h>
#include <functional>

#define X first
#define Y second
#define MP make_pair
//#define MT make_tuple
#define REP(i, a, n) for(int (i) = (a); (i) < (n); ++(i))
#define FOR(i, n) REP(i, 0, n)
typedef long long ll;
using namespace std;
const int MAX = 500;

template<class T, class U>
void convert(T &t, U &u)
{
	stringstream ss;
	ss << t;
	ss >> u;
}

ll gcd(ll m, ll n)
{
	return n != 0 ? gcd(n, m % n) : m;
}

ll lcm(ll m, ll n)
{
	if ((0 == m) || (0 == n)) return 0;
	return ((m / gcd(m, n)) * n);
}

void SearchPattern(map<ll, ll>& a, ll b, ll c)
{
	ll x = 1;
	while (!a.count((b * x) % c)){
		a[(b * x) % c] = 1;
		x = (b * x) % c;
	}
}
map<ll, ll> aa, bb, cc;
int main()
{
	ll a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f && a | b | c | d | e | f){
		aa.clear(); bb.clear(); cc.clear();

		SearchPattern(aa, a, b);
		SearchPattern(bb, c, d);
		SearchPattern(cc, e, f);

		ll ans = 1;
		ll tmp = lcm(aa.size(), bb.size());
		if (tmp == 1){
			tmp = aa.size() * bb.size();
			ans = tmp;
		}
		else ans = tmp;

		tmp = lcm(cc.size(), tmp);
		if (tmp == 1) ans *= cc.size();
		else ans = tmp;

		cout << ans << endl;
 	}

	return 0;
}

Measured memory_bytes: 7196
N = int(input())
Alist = list(map(int, input().split()))
S = sum(Alist)
Xlist = [0] * N
Xlist[0] = S - 2 * sum([Alist[_] for _ in range(1, N, 2)])
print(Xlist[0], end=" ")
for i in range(1, N):
    Xlist[i] = 2*Alist[i-1] - Xlist[i-1]
    print(Xlist[i], end=" ")
print()

Measured memory_bytes: 64484
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  100012101;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
 


int main(){
   int K;
   cin>>K;
   int s[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   cout<<s[K-1]<<endl;
return 0;
}

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

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	int player[n]={};
	for (int i=0; i<q; i++){
		int a; cin >> a;
		player[a-1]++;
	}
	for (int i=0; i<n; i++){
		if (player[i]>q-k)
		cout << "Yes\n";
		else
		cout <<"No\n";
		//cout << player[i] << '\n';
		
	}
	return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
enum = enumerate
INF = 1001001001

import collections
import random

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def dist(x1,y1,x2,y2):
	return abs(x1-x2)+abs(y1-y2)

def ran():
	vRan = [chr(i+ord("a")) for i in range(26)]
	random.shuffle(vRan)
	sr = "".join(vRan)
	print(sr)
	return sr

def main():
	S = input().rstrip()
	#S = ran()###
	#vS = [input().rstrip() for _ in [0,]*N]
	N = len(S)
	oA = ord("a")
	vD = [chr(i+oA) for i in range(26)]
	#vD += [".","#"]

	for d in vD:
		if d not in S:
			print(S+d)
			return
	
	if S=="".join(vD[::-1]):
		print(-1)
		return

	vQ = []
	vR = [ord(s) for s in S]
	vQ.append(vR.pop())
	
	while vR:
		r = vR.pop()
		nowq = INF
		for q in vQ:
			if q>r:
				nowq = min(nowq,q)
		if nowq<INF:
			vR.append(nowq)
			break
		vQ.append(r)
	
	res = "".join(chr(r) for r in vR)
	print(res)
	#sT = "No Yes".split()
	#print(sT[res])
	

if __name__ == "__main__":
	main()


Measured memory_bytes: 9744
/*---> 04 April 2020 <--- > 01:23:42 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int n;
	cin>>n;
	cout<<(n/500)*1000+((n%500)/5)*5<<"\n";
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long M;
    cin >> M;
    cout << 24 + 24 - M << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstring>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long double D;

inline D dis(D x1, D y1, D x2, D y2){
  return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

const D EPS = 1e-10;

int n,m;
D x[110],y[110],v[110];
D px[110],py[110];
D t[110][110];
int match[210];
bool use[210];
vector<int> g[210];

bool dfs(int v){
  use[v] = true;
  rep(i,g[v].size()){
    int u = g[v][i], w = match[u];
    if(w<0 || !use[w] && dfs(w)){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bimatch(D lim){
  rep(i,n+m)g[i].clear();
  rep(i,n)rep(j,m){
    if(t[i][j] < lim + EPS){
      g[i].push_back(j+n);
      g[j+n].push_back(i);
    }
  }
  memset(match,-1,sizeof(match));

  int res = 0;
  rep(i,n+m){
    if(match[i]<0){
      memset(use,0,sizeof(use));
      if(dfs(i))res++;
    }
  }

  return res;
}

int main(){
  while(scanf("%d%d",&n,&m),n){
    rep(i,n)scanf("%Lf%Lf%Lf",&x[i],&y[i],&v[i]);
    rep(i,m)scanf("%Lf%Lf",&px[i],&py[i]);
    
    rep(i,n)rep(j,m){
      t[i][j] = dis(x[i],y[i],px[j],py[j])/v[i];
    }

    D l = 0, r = 1e8;
    rep(i,1000){
      D mid = (l+r)/2;
      if(bimatch(mid) == m)r = mid;
      else l = mid;
    }
    printf("%.20Lf\n",r);
  }
}

Measured memory_bytes: 1428
#include<cstdio>
#include<queue>
#include<math.h>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define fir first
#define sec second
int R[200002];
const int INF=1001001001;

vector<pair<int,int> > edge[100002];
int d[100002];
int s[100002];
int sans[200002];
int N,M,Q;
int main(){
	scanf("%d %d %d",&N,&M,&Q);
	rep(i,M){
		R[i]=INF;
		int u,v;
		scanf("%d %d",&u,&v);u--;v--;
		edge[u].pb(make_pair(v,i) );
		edge[v].pb(make_pair(u,i) );		
	}
	rep(i,Q){
			int r;
			scanf("%d",&r);r--;
			R[r]=i;
	}
	
	fill(&d[0],&d[N+1],INF);
	fill(&s[0],&s[N+1],INF);
	//dijkstra
	priority_queue< pair<int,int>, vector<pair<int,int> >, 
	greater<pair<int,int> > > q;
	q.push(make_pair(0,0) );
	while(q.size()){
		pair<int,int> p=q.top();q.pop();
		int n=p.second;int c=p.first;
		if(d[n]<c)continue;
		rep(i,edge[n].size() ){
			int to=edge[n][i].fir;
			int ro=edge[n][i].sec;
			if(c+1==d[to]){
				s[to]=max(s[to], min(s[n],R[ro]) );
				if(s[to]<min(s[n],R[ro]) )q.push( make_pair(c+1,to) );
			}else if(c+1<d[to] ){
				s[to]=min(s[n],R[ro]);
				d[to]=c+1;
				if(s[to]<min(s[n],R[ro]) )q.push( make_pair(c+1,to) );
				q.push( make_pair(c+1,to) );
			}
		}
	}
	rep(i,N){
		if(i!=0&&s[i]<Q)sans[s[i]]++;
	}
	int ans=0;
	rep(i,Q){
		ans+=sans[i];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 13520
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[111111];
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	int x = a[n - 1], z = -1;
	for(int i = 0; i < n - 1; i++) {
		if(a[i] <= x) {
			swap(a[++z], a[i]);
		}
	}
	swap(a[++z], a[n - 1]);
	for(int i = 0; i < n; i++) {
		printf(i == z ? "[%d]" : "%d", a[i]);
		printf(i + 1 == n ? "\n" : " ");
	}
}

Measured memory_bytes: 3540
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from bisect import bisect_left
setrecursionlimit(1000000)

INF = int(1e10)
MOD = int(1e9 + 7)

def input():
    return stdin.readline()[:-1]


def main():
    from builtins import int, map
    N = int(input())
    A = list(map(int, input().split()))
    ans = [0] * (N + 1)
    for a in A:
        ans[a] += 1
    for a in ans[1:]:
        print(a)

   
if __name__ == '__main__':
    main()

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

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

  int count = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == '+') {
      count++;
    }
    else
      count--;
  }

  cout << count << endl;
}


Measured memory_bytes: 256
S = gets.chomp.chars
score = 0
p_count = 0
S.reverse.each do |ch|
  g_count = S.size - p_count
  can_p = g_count - 1 >= p_count + 1
  if can_p
    score += ch == 'g' ? 1 : 0
    p_count += 1
  else
    score += ch == 'g' ? 0 : -1
  end
end
puts score


Measured memory_bytes: 10236
use std::cmp;
use std::collections::BTreeSet;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(1 << n);

    let mut top = a
        .iter()
        .enumerate()
        .map(|(i, &a)| (a, i))
        .collect::<Vec<(usize, usize)>>();

    let mut ans = vec![0; 1 << n];
    for mask in 1..(1 << n) {
        let mut set = BTreeSet::new();
        set.insert(top[mask]);
        for pos in 0..n {
            let pos_mask = 1 << pos;
            set.insert(top[mask & (!pos_mask)]);
        }

        let mut iter = set.into_iter().rev();
        top[mask] = iter.next().unwrap();
        let second = iter.next().unwrap();
        ans[mask] = cmp::max(ans[mask - 1], top[mask].0 + second.0);
        println!("{}", ans[mask]);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 15356
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include <cstdlib>
#include <stdlib.h>
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
#define MOD 1000000007
using namespace std;
using ll=long long;
int cnt,element;
int main()
{
    FasterIO
    int a,b,n,rafi,flag=0;
    cin>>n;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%n==0)
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
    {
        cout<<"OK"<<endl;
    }
    else{
        cout<<"NG"<<endl;
    }
    return 0;
}


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

//2*ra*rb < c - a - b
// 2*a*b < (c-a-b)^2

int main() {
  long double a, b, c;
  cin >> a >> b >> c;
  
  long double eps = 1e-14;
  
  if (sqrt(a) + sqrt(b) + eps < sqrt(c)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readInt()
  val p = in.readLine.split(" ").map(_.toInt)

  val ans = p./:(0, 1, 0) { (e, i) =>
    val (acc, cnt, pre) = e
    if(i == cnt && pre == 0) (acc + 1, cnt + 1, i)
    else (acc, cnt + 1, 0)
  }._1

  println(ans)
}

Measured memory_bytes: 42488
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let s = s.replace("BC", "D");
    let mut ans = 0u64;
    let mut cnt = 0u64;
    for c in s.chars() {
        if c == 'A' {
            cnt += 1;
        } else if c == 'D' {
            ans += cnt;
        } else {
            cnt = 0;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const double PI=3.1415926535897932;
using namespace std;
typedef long long ll;

int main(void){
    ll l,r,d;
    cin>>l>>r>>d;
    ll c=0;
    for(int i=l;i<=r;i++){
        if(i%d==0)c++;
    }
    cout<<c<<endl;
    
}

Measured memory_bytes: 3524
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
pair<ll,ll> a[100010];
ll cls[100010];

int main(){
	int n;ll t;
	cin>>t>>n;
	ll sum=0;cls[0]=0;
	a[0]=make_pair(-1,-1);
	for(int i=1;i<=n;i++){
		cin>>a[i].first>>a[i].second;
		sum+=a[i].second-a[i].first;
		cls[i]=sum;
	}
	ll ans=0;
	lol(i,n){
		ll to=t+a[i+1].first;
		int left=-1,right=n+1,mid;
		while(left+1<right){
			mid=(left+right)/2;
			if(a[mid].second<=to)left=mid;
			else right=mid;
		}
		ll tmp=cls[left]-cls[i];
		if(left<n)tmp+=max((ll)0,to-a[left+1].first);
		ans=max(tmp,ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5412
import sys

di = []
for i in range(5):
    a = input()
    j = len(a)
    if a != "0":
        b = a[j-1]
        if b == "0":
            c = 10
        else:
            c = int(b)
    else:
        c = int(a)
    di.append([int(a),c])

di.sort(key=lambda x:x[1],reverse=True)
w4 = 0
for i in range(4):
    w1 = di[i][1]
    w2 = di[i][0]
    if w2 == 0:
        w3 = 0
    else:
        w3 = 10 - w1 + w2
    w4 += w3
w4 += di[4][0]
print(w4)



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

int main(void) {
    int n;
    bool flag = false;
    cin >> n;
    for (int i = 0; i < n; i++) {
        char s;
        cin >> s;
        if (s == 'Y') {
            flag = true;
            break;
        }
    }
    cout << (flag ? "Four" : "Three") << endl;
}


Measured memory_bytes: 256
X, N = map(int, input().split())

if N == 0:
  print(X)
  exit()
else:
  p = list(map(int, input().split()))

ans = [X, X]

judge = [0, 0]
while judge[0] == 0 and judge[1] == 0:
  if p.count(ans[0]) == 0:
    judge[0] = 1
    print(ans[0])
    break
  elif p.count(ans[1]) == 0:
    judge[1] = 1
    print(ans[1])
    break
  else:
    ans[0] -= 1
    ans[1] += 1

Measured memory_bytes: 9216
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n = readint;
    if (n == 3 || n == 5 || n == 7)
        writeln("YES");
    else
        writeln("NO");
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[N + 1];
        int[] b = new int[N + 1];
        for (int i = 0; i < M; i++) {
            int s = sc.nextInt();
            int c = sc.nextInt();
            if (N > 1 && s == 1 && c == 0) {
                System.out.print("-1");
                return;
            }
            if (b[s] == 0) {
                a[s] = c;
                b[s]++;
            } else {
                if (a[s] != c) {
                    System.out.print("-1");
                    return;
                }
            }
        }

        if (N == 1 && b[1] == 0) {
            System.out.println("0");
            return;
        }
        for (int i = 1; i < N + 1; i++) {
            if (b[i] == 0 && i == 1) {
                a[i] = 1;
            }
            System.out.print(a[i]);
        }
    }
}


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

int gcd(int x, int y) {
  int mx = max(x, y);
  int my = min(x, y);
  return my ? gcd(my, mx % my) : mx;
}

int main(int argc, char *argv[]) {
  int x, y;
  cin >> x >> y;
  cout << gcd(x, y) << endl;
  return 0;
}


Measured memory_bytes: 3104
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

const MOD: i64 = 1_000_000_007;

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(c: [usize1]);
    let mut c = c;
    c.dedup();
    let n = c.len();
    const W: usize = 200100;
    let mut occ = vec![vec![]; W];
    let mut pos = vec![0; W];
    let mut tbl = vec![0; W];
    for i in 0..n {
        occ[c[i]].push(i);
    }
    let mut dp = vec![0; n + 1];
    let mut acc = vec![1; n + 1];
    dp[0] = 1;
    for i in 0..n {
        let c = c[i];
        let p = pos[c];
        let pre = tbl[c];
        dp[i + 1] = pre;
        tbl[c] += acc[i];
        tbl[c] %= MOD;
        acc[i + 1] = (acc[i] + dp[i + 1]) % MOD;
    }
    puts!("{}\n", acc[n]);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

h_angle=30*h+0.5*m
m_angle=6*m
sa_angle=abs(h_angle - m_angle) 


if(sa_angle > 180 ):
    sa_angle=360- sa_angle

theta=(sa_angle / 180) * math.pi
c_2=a*a +b*b -2*a*b*math.cos(theta)
c=math.sqrt(c_2)
print(c)

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

using namespace std;

int main() {

   long long r,d,x,res;
   cin>>r>>d>>x;
   int tests=10;
   res = x;
   while(tests--){
       res = r*res - d;
       cout<<res<<endl;
   }
    return 0;
}


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

int main(){
  int N,T; cin >>N>>T;
  int c_min = 1001;
  int min_n = -1;
  for(int i=0;i<N;i++){
    int c,t; cin >> c >> t;
    if(t<T+1){
      if(c<c_min){
        c_min = c;
        min_n = i+1;
      }
    }
  }
  if(min_n<0){
    cout << "TLE" << endl;
  }else{
    cout << c_min << endl;
  }
}

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

namespace _0127
{
    public class Program

    {
        public static void Main(string[] args)
        {

            char[,] letter = new char[,]
            {
                {'a','b','c','d','e'}
              , {'f','g','h','i','j'}
              , {'k','l','m','n','o'}
              , {'p','q','r','s','t'}
              , {'u','v','w','x','y'}
              , {'z','.','?','!',' '}
            };

            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) break;

                if (line.Length % 2 != 0)
                {
                    Console.WriteLine("NA");
                    continue;
                }

                string ans = "";
                bool flg = false;
                for (int i = 0 ; i < line.Length ; i += 2)
                {
                    int c1 = int.Parse(line[i].ToString());
                    int c2 = int.Parse(line[i + 1].ToString());

                    if (c1 < 1 || c1 > 6 || c2 < 1 || c2 > 5)
                    {
                        flg = true;
                        break;
                    }
                    ans += letter[c1 - 1, c2 - 1];
                }
                Console.WriteLine(flg ? "NA" : ans);
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 15952
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	string ans = "Yes";
	if (N < 30)ans = "No";
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int n, m;
    cin>>n>>m;
    if(n==1){
        cout<<m;
        return;
    }
    int mx = 0;
    for(int i = 2; i*i <= m; i++){
        if(m%i==0){
            if(m>=n*i)mx=max(mx, i);
            if(i>=n)mx=max(mx, m/i);
        }
    }   
    cout<<(mx>0?mx:1);
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3652
#include<stdio.h>
#define N 3
int ansArr[N][N]={{1,2,3},
		  {4,5,6},
		  {7,8,0}};
int tempArr[N][N];
int curMinCost=40;
void calcMinCost(int,int);
int get0Row(void);
int get0Col(void);
int isCorrect(void);
void printArr(void);//debugging
int main(void)
{
  int i,j;//counter
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      scanf("%d",&tempArr[i][j]);
  calcMinCost(0,0);
  printf("%d\n",curMinCost);
  return 0;
}
void calcMinCost(int cost,int lastMove)
{
  int row,col;
  //printArr();
  if(cost>=curMinCost) return;
  if(isCorrect()==1)
    {
      curMinCost=cost;
      return;
    }
  row=get0Row();
  col=get0Col();
  if(row!=N-1&&lastMove!=3)//slide up
    {
      tempArr[row][col]=tempArr[row+1][col];
      tempArr[row+1][col]=0;
      calcMinCost(cost+1,1);
      tempArr[row+1][col]=tempArr[row][col];
      tempArr[row][col]=0;
    }
  if(col!=N-1&&lastMove!=4)//slide left
    {
      tempArr[row][col]=tempArr[row][col+1];
      tempArr[row][col+1]=0;
      calcMinCost(cost+1,2);
      tempArr[row][col+1]=tempArr[row][col];
      tempArr[row][col]=0;
    }
  if(row!=0&&lastMove!=1)//slide down
    {
      tempArr[row][col]=tempArr[row-1][col];
      tempArr[row-1][col]=0;
      calcMinCost(cost+1,3);
      tempArr[row-1][col]=tempArr[row][col];
      tempArr[row][col]=0;
    }
  if(col!=0&&lastMove!=2)//slide right
    {
      tempArr[row][col]=tempArr[row][col-1];
      tempArr[row][col-1]=0;
      calcMinCost(cost+1,4);
      tempArr[row][col-1]=tempArr[row][col];
      tempArr[row][col]=0;
    }
}
int get0Row(void)
{
  int i,j;//counter
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      if(tempArr[i][j]==0) return i;
}
int get0Col(void)
{
  int i,j;//counter
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      if(tempArr[i][j]==0) return j;
}
int isCorrect(void)
{
  int i,j;//counter
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      if(ansArr[i][j]!=tempArr[i][j]) return 0;
  return 1;
}
void printArr(void)
{
  int i,j;//counter
  for(i=0;i<N;i++)
    {
      for(j=0;j<N;j++)
	{
	  printf("%d ",tempArr[i][j]);
	}
      printf("\n");
    }
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n, x, y;
	cin >> n >> x >> y;
	x--, y--;
	vector<vector<int>> to(n);
	rep(i,n-1) {
		to[i].push_back(i + 1);
		to[i + 1].push_back(i);
	}
	to[x].push_back(y);
	to[y].push_back(x);

	vector<int> ans(n);
	for (int i = 0; i < n; i++) {
		queue<int> q;
		vector<int> d(n, INF);
		auto update = [&] (int s, int t) {
			if (d[t] != INF) return;
			d[t] = d[s] + 1;
			q.push(t);
		};
		q.push(i);
		d[i] = 0;
		while (!q.empty()) {
			int x = q.front(); q.pop();
			for (int y: to[x]) {
				update(x, y);
			}
		}
		rep(j, n) {
			if (d[j] != INF) ans[d[j]]++;
		}
	}
	for (int i = 1; i < n; i++) cout << ans[i] / 2 << endl;
}

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

Measured memory_bytes: 3732
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int n, k;
    cin >> n >> k;
    vector<int>pn(n);
    for(int i = 0; i < n; i++){
        cin >> pn.at(i);
    }
    vector<double>Ep(n);
    double tmp;
    for(int i = 0; i < n; i++){
        tmp = (1 + pn.at(i)) / 2.0;
        Ep.at(i) = tmp;
        dump(Ep.at(i));
    }
    double ek = 0;
    for(int i = 0; i < k; i++){
        ek += Ep.at(i);
    }
    double maxek = ek;
    for(int i = k; i < n; i++){
        ek -= Ep.at(i - k);
        ek += Ep.at(i);
        maxek = max(ek, maxek);
    }
    cout << fixed << setprecision(10);
    cout << maxek << endl;
    return 0;
}



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

using namespace std;

constexpr int LIMIT = 7368791;

bool used[LIMIT+1];

int main()
{
    int m, n;
    while (cin >> m >> n, m) {
        int cnt = 0;
        memset(used, 0, sizeof(used));
        for (int i = m; cnt < n; i++) {
            if (!used[i]) {
                cnt++;
                for (int j = i; j <= LIMIT; j += i) {
                    used[j] = 1;
                }
            }
        }
        for (int i = m; ; i++) {
            if (!used[i]) {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 10224
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
#define LL long long
int n,m;
LL ans[maxn];
int a[maxn],b[maxn],fa[maxn];

int findfa(int x){return fa[x] < 0 ? x : fa[x] = findfa(fa[x]);}

int main(){
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++) scanf("%d%d",&a[i],&b[i]);
    for (int i=1;i<=n;i++) fa[i] = -1;

    ans[m] = 1LL * n * (n-1) / 2;
    for (int i=m;i>=1;i--){
        int u = a[i], v = b[i];
        int fu = findfa(u), fv = findfa(v);
        if (fu == fv) {
            ans[i-1] = ans[i];
            continue;
        }
        ans[i-1] = ans[i] - 1LL * fa[fu] * fa[fv];
        fa[fv] += fa[fu]; fa[fu] = fv;
    }
    for (int i=1;i<=m;i++) printf("%lld\n",ans[i]);
    return 0;
}


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

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

  // for (ll i=-10; i<=10; i++) {
  //   printf("2^5 - %lld^5 = %lld\n", i, (ll)(pow(2,5)-pow(i,5)));
  // }

  for (ll a=-1000; a<=1000; a++) {
    ll l = -10000;
    ll r = 10000;
    while (l+1 < r) {
      ll m = (l+r)/2;
      ll tmp = pow(a,5)-pow(m,5);
      if (tmp < x) r = m;
      else l = m;
    }
    if (pow(a,5)-pow(l,5) == x) {
      printf("%lld %lld\n", a, l);
      return 0;
    }
    if (pow(a,5)-pow(l+1,5) == x) {
      printf("%lld %lld\n", a, l+1);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 4164
#include <iostream>

using namespace std;

int main(){
  char c;

  cin >> c;

  if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
    
  return 0;
}

Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)
map = $<.map{|l|l.chomp.split(//)}

dx = [ 0, 0, 1, -1]
dy = [ 1,-1, 0,  0]

wtcount = map.flatten.count(".")

queue = []
queue.push([0, 0])
map[0][0]=1

while !queue.empty?
  q = queue.shift
  if q == [W-1, H-1] 
    p wtcount - map[H-1][W-1]
    exit
  else
    4.times do |i|
      nx = q[0] + dx[i]
      ny = q[1] + dy[i]
      if nx>=0 && nx<W && ny>=0 && ny<H && map[ny][nx]=='.'
        queue.push([nx, ny])
        map[ny][nx] = map[q[1]][q[0]] + 1
      end
    end
  end
end

p -1


Measured memory_bytes: 2300
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
x, y = map(int, input().split())
if x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38256
while True:
    n, m = map(int,input().split())
    if (n,m) == (0,0):break
    price = list(map(int, input().split()))
    price.sort()
    summ = []
    k = -1
    j = 0
    if price[0]+price[1] > m:
            print('NONE')
            continue
    while True:
        if j == n + k:break
        elif price[j] +  price[k] <= m:
            summ.append(price[j] +  price[k])
            j += 1
        else:
            k -= 1
    summ.sort()
    print(summ[-1])


Measured memory_bytes: 5640
H,W=list(map(int,input().split()))
l=[list(input()) for i in range(H)]
inf=10**9
DP=[[inf]*W for i in range(H)]
DP[0][0]=0 if l[0][0]=="." else 1
for i in range(H):
   for j in range(W):
      if i>0:
         DP[i][j]=min(DP[i][j],DP[i-1][j]+1) if l[i-1][j] == "." and l[i][j]=="#" else min(DP[i][j],DP[i-1][j])
      if j>0:
         DP[i][j]=min(DP[i][j],DP[i][j-1]+1) if l[i][j-1] == "." and l[i][j]=="#" else min(DP[i][j],DP[i][j-1])
print(DP[H-1][W-1])

Measured memory_bytes: 9392
/*
 * atcoder/abc127_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

struct Card {
  int l, r;
  bool operator<(const Card& a)const{
    return l == a.l ? r < a.r : l < a.l;
  }
};

int N, M;
vector<Card> C;

void solve() {
  cin >> N >> M;
  int l, r;
  loop(m,0,M) {
    cin >> l >> r;
    C.push_back((Card){ l, r });
  }
  sort(C.begin(), C.end());
  if (C[0].r < C[M-1].l) {
    cout << 0 << endl;
    return;
  }

  // 答え = Lの一番右側とRの一番左側にある座標数
  int rightmost_l = 0, leftmost_r = 100000;
  for (auto&& c: C) {
    chmax(rightmost_l, c.l);
    chmin(leftmost_r, c.r);
  }
  cout << leftmost_r - rightmost_l + 1 << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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; }

int main () {
  int n;
  cin >> n;
  vll a(n);
  ll s = 0;
  rep(i,n) {
    cin >> a[i];
    s += a[i];
  }
  
  ll ans = INFLL, sum = 0;
  rep(i,n) {
    sum += a[i];
    ans = min(ans, abs(sum-(s-sum)));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  vector<long long> a(N);
  vector<long long> b(N);
  vector<long long> c(M);
  vector<long long> d(M);
  for(int i = 0; i < N; i++){
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < M; i++){
    cin >> c[i] >> d[i];
  }
  vector<int> point(N);
  for(int i = 0; i < N; i++){
    long long min = 10000000000;
    for(int j = 0; j < M; j++){
      if(abs(a[i]-c[j]) + abs(b[i]-d[j]) < min){
        min = abs(a[i]-c[j]) + abs(b[i]-d[j]);
        point[i] = j+1;
      }
    }
  }
   for(int i = 0; i < N; i++){
     cout << point[i] << endl;
   }
}

Measured memory_bytes: 256
import sys
S = list(input()) 
#judge =1
if S[0] != "A":
    S.insert(0,"A")
#if S[0] =="A" and S[1] == "K" and S[2] == "I" and S[3] == "H" and S[4] !="A":
if len(S) < 4:
    print("NO")
    sys.exit()
elif S[0] =="A" and S[1] == "K" and S[2] == "I" and S[3] == "H":
    if len (S) == 4:
        S.insert(4,"A")
    elif S[4] != "A":
        S.insert(4,"A")    
else:
    print("NO")
    sys.exit()
if len(S) <6:
    print("NO")
    sys.exit()
elif S[0] =="A" and S[1] == "K" and S[2] == "I" and S[3] == "H" and S[4] =="A" and S[5] =="B":
    if len (S) == 6:
        S.insert(6,"A")
    elif S[6] != "A":
        S.insert(6,"A")
else:
    print("NO")
    sys.exit()
if len(S) < 8:
    print("NO")
    sys.exit()
elif S[0] =="A" and S[1] == "K" and S[2] == "I" and S[3] == "H" and S[4] =="A" and S[5] =="B" and S[6] == "A" and S[7] == "R":
    if len (S) == 8:
        S.insert(8,"A")
    elif S[8] != "A":
        S.insert(8,"A")
else:
    print("NO")
    sys.exit()
if   S[0] =="A" and S[1] == "K" and S[2] == "I" and S[3] == "H" and S[4] =="A" and S[5] =="B" and S[6] == "A" and S[7] == "R" and S[8] == "A" and len(S) ==9:
    print("YES")
else:
    print("NO")

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

int main()
{
    int N, M;
    cin >> N >> M;
    float A[N], num_vote = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        num_vote += A[i];
    }

    int num_selected = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] >= num_vote / (4 * M)) num_selected++;
    }

    if (num_selected >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

ll mod = 2019;

int main() {
	string s;
	cin >> s;
	ll n = s.size();
	vector<ll> ms(n + 1, 0);
	ll ten = 1;
	reverse(s.begin(), s.end());
	vector<ll> m(2019, 0);
	REP(i, n) {
		ms[i] = ms[i - 1] + ten * (s[i - 1] - '0');
		ms[i] %= mod;
		ten *= 10;
		ten %= mod;
	}
	rep(i, n + 1) {
		m[ms[i]]++;
	}
	ll ans = 0;
	rep(i, 2019) {
		ans += m[i] * (m[i] - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5172
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main ()
{
	int M,N,mo[10000],sk[10000]={};
	
	cin>>N>>M;
	
	for(int i=0;i<N;i++)
	{
		cin>>mo[i];
	}
	for(int i=0;i<M;i++)
	{
		int aa;
		cin>>aa;
		for(int q=0;q<N;q++)
		{
			if(mo[q]<=aa){sk[q]++;
			break;
			}
		}
	}
	int z=0,b=0;
	for(int i=0;i<N;i++)
	{
		if(sk[i]>b){
			b=sk[i];
			z=i;
		}
	}
	z++;
	cout<<z<<endl;
return 0;
}

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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n,k;
    cin>>n>>k;
    
    int ans=1;
    for(int i=0;i<n;i++)ans+=min(ans,k);

    cout<<ans<<endl;

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
    int N,x,num=0;
    cin >> N >> x;
    int a[N];
    bool frag= false;
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a,a+N);
    for(int i=0;i<N;i++){
        if(a[i]>x){
            frag = true;
            break;
            
        }
        x -= a[i];
        num++;
    }
    if(x>0&&frag==false){
        num--;
        if(num<0){
            num = 0;
        }
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		int[] t = new int[26];
		for (int i=0; i<S.length; i++) {
			t[S[i]-'a']++;
		}
		for (int i=0; i<t.length; i++) {
			if (t[i] > 1) {
				System.out.println("no");
				return;
			}
		}
		System.out.println("yes");
	}
}


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

using namespace std;

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

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

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

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

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

  int n, m;
  cin >> n >> m;
  vint x(n), y(n), z(n);
  rep(i, n) cin >> x[i] >> y[i] >> z[i];
  int ans = -inf;
  rep(bit, 1<<3) {
    priority_queue<int> que;
    rep(i, n) {
      int a = (bit>>0)&1 ? x[i] : -x[i];
      int b = (bit>>1)&1 ? y[i] : -y[i];
      int c = (bit>>2)&1 ? z[i] : -z[i];
      que.push(a+b+c);
    }
    int sum = 0;
    rep(i, m) {
      sum += que.top(), que.pop();
    }
    chmax(ans, sum);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall


n, m = map(int, input().split())
d = [[0 if i == j else float('inf') for i in range(n)]
     for j in range(n)]
g = [[] for _ in range(n)]
for i in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c
    g[a].append((b, c))
    g[b].append((a, c))

gf = floyd_warshall(csgraph=d)
# print(gf)

cnt = 0
for i in range(n):
    for j, cost in g[i]:
        used = False
        if i > j:
            continue
        for k in range(n):
            if gf[i][k] == cost + gf[k][j]:
                used = True
                break
        if used is False:
            cnt += 1
print(cnt)


Measured memory_bytes: 17052
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

#define double long double
const double EPS = 1e-8;

// 二次方程式を解の公式を用いて解く
// 計算量: O(sqrt()の計算量)
// 重解は1つにせず返す 1つにしたいなら変えること
// Verified:
//   https://www.urionlinejudge.com.br/judge/en/runs/code/13486899
//   http://codeforces.com/contest/233/submission/52143945
vector<double> quadraticEquation(double a, double b, double c) {
	// 1次方程式
	if (abs(a) < EPS)
		return abs(b) < EPS ? vector<double>() : vector<double>{ -c / b };
	// 判別式
	double D = b * b - 4 * a*c;
	// 解無し
	if (D < -EPS)
		return vector<double>();
	// 重解
	if (D < EPS)
		return vector<double>{-b / (2 * a), -b / (2 * a)};
	double d = sqrt(D);
	double x1 = (-b + d) / (2 * a);
	double x2 = (-b - d) / (2 * a);
	if (x1 > x2)swap(x1, x2);
	return vector<double>{x1, x2};
}

// 二分法
// 方程式の求根アルゴリズム
// f(l) < 0 かつ 0 < f(r) の場合に限る
double bisectionMethod(double l, double r, function<double(double)> f) {
	double yl = f(l), yr = f(r);
	if (yl > yr)swap(l, r);
	assert((yl - EPS) * (yr + EPS) <= 0);
	for (int i = 0; i < 200; i++) {
		double m = (l + r) / 2;
		if (f(m) > 0)
			r = m;
		else
			l = m;
	}
	return l;
}

// 三次方程式
// 二分法でまず1つの解pを求める
// (x-p)(ax^2+b'x+c) と式変形して二次方程式で残りの解を求める
// 計算量: 二分法の計算量
// Verified: https://yukicoder.me/submissions/331206
vector<double> cubicEquation(double a, double b, double c, double d) {
	if (abs(a) < EPS)
		return quadraticEquation(b, c, d);
	double p = bisectionMethod(-INF, INF, [&](double x) {return a * x*x*x + b * x*x + c * x + d; });
	// (1, b/a, c/a, d/a) を (1, -p) で割っていった結果
	double aa = 1, bb = b / a + p, cc = c / a + bb * p;
	auto ret = quadraticEquation(aa, bb, cc);
	ret.push_back(p);
	sort(ret.begin(), ret.end());
	return ret;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int t; cin >> t;
	rep(_, 0, t) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		auto r = cubicEquation(a, b, c, d);
		dump(r);
		int p = 0, m = 0;
		for (auto x : r) {
			if (abs(x) < EPS)continue;
			if (x > 0)p++;
			else m++;
		}
		cout << p << " " << m << endl;
	}
	return 0;
}


Measured memory_bytes: 3128