akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }

class Solver {
  public:
    vector<string> S;
    map<char, map<ll, ll>> val;
    map<char, ll> len;
    bool out_of_range(char name, ll index) {
        return index >= len.at(name);
    }
    bool undefined(char name, ll index) {
        return not val[name].count(index);
    }
    ll get_number(int &i, string &s) {
        assert(isdigit(s[i]));
        ll res = 0;
        while(isdigit(s[i])) {
            res *= 10;
            res += (s[i++] - '0');
        }
        return res;
    }
    char get_name(int &i, string &s) {
        char name = s[i++];
        assert(('a' <= name and name <= 'z') or ('A' <= name and name <= 'Z'));
        return name;
    }
    tuple<ll, bool> get_expression(int &i, string &s) {
        auto fail = make_tuple(0, false);
        auto success = [](ll v) { return make_tuple(v, true); };
        bool ok;
        
        if(isdigit(s[i])) return success(get_number(i, s));
        char name = get_name(i, s);
        ll index; tie(index, ok) = get_bexpression(i, s);
        if(not ok) return fail;
        if(out_of_range(name, index) or undefined(name, index)) return fail;
        
        return success(val.at(name).at(index));
    }
    tuple<ll, bool> get_bexpression(int &i, string &s) {
        assert(s[i++] == '[');
        auto ret = get_expression(i, s);
        assert(s[i++] == ']');
        return ret;
    }
    
    void declaration(int &i, string &s) {
        char name = get_name(i, s);        
        assert(s[i++] == '[');
        ll num = get_number(i, s);
        assert(s[i++] == ']');
        assert(not len.count(name)); // only once
        len[name] = num;
    }

    bool assignment(int &i, string &s) {
        bool ok;
        
        char name = get_name(i, s);
        ll index; tie(index, ok) = get_bexpression(i, s);
        if(not ok) return false;        
        assert(s[i++] == '=');        
        ll right; tie(right, ok) = get_expression(i, s);
        if(not ok) return false;        

        // check
        if(out_of_range(name, index)) return false;
        val[name][index] = right;
        return true;
    }
    
    bool solve() {
        while(true) {
            string s; cin >> s;
            if(s == ".") break;
            S.push_back(s);
        }
        
        if(S.size() == 0) return false;
        rep(i, S.size()) {
            int pos = 0;
            if(S[i].find("=") == string::npos) declaration(pos, S[i]);
            else {
                bool ok = assignment(pos, S[i]);
                if(not ok) {
                    cout << i + 1 << endl;
                    return true;
                }
            }
            assert(pos == S[i].size());
        }
        cout << 0 << endl;
        return true;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(Solver().solve());
    return 0;
}

Measured memory_bytes: 3224
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2e5 + 10 , P = 1e9 + 7 , MAX = 2010 , M = MAX << 1;
int Pow(int x,int t){int r=1;for(;t;t>>=1,x=ll(x)*x%P)if(t&1)r=ll(r)*x%P;return r;}
inline void pp(int &x,int d){if((x+=d)>=P)x-=P;}
int n , a[N] , b[N] , fac[M + M] , ifac[M + M] , f[M];
vector<pii> event[M];

int way(int a,int b) {
  return ll(fac[a+b])*ifac[b]%P*ifac[a]%P;
}

int main(){
  rep(i,0,M + M) fac[i]=i?ll(fac[i-1])*i%P:1;
  rep(i,0,M + M) ifac[i]=Pow(fac[i],P-2);
  cin >> n;
  int del=0;
  rep(i,0,n) {
    cin >> a[i] >> b[i];
    pp(del,way(a[i]+a[i],b[i]+b[i]));
    event[-a[i] + MAX].pb(mp(-b[i] + MAX , 1));
    event[a[i] + MAX].pb(mp(b[i] + MAX , -1));
  }
  int ans=0;
  rep(i,0,M) {
    for(auto e : event[i]) if(e.se==1) pp(f[e.fi],1);
    rep(j,1,M) pp(f[j],f[j-1]);
    for(auto e : event[i]) if(e.se==-1) pp(ans,f[e.fi]);
  }
  pp(ans,P-del);
  ans=ll(ans)*Pow(2,P-2)%P;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7552
/*  UntilDeathDoesUsApart
    DO   NOT   GIVE   UP!
*/

#include <bits/stdc++.h>

using namespace std;

#define inc(a)           a.begin(), a.end()
#define dec(a)           a.rbegin(), a.rend()
#define Unique(n)        (n).erase(unique(all(n)), (n).end())
#define to(i, a, n)      for(int i=a; i<n; i++)
#define fr(i, a, n)      for(int i=a; i>=n; i--)
#define read(arr, l, r)  for(int i=l; i<r; cin >> arr[i++])
#define prnt(arr, l, r)  for(int i=l; i<r; cout << arr[i++] << " \n"[i==r])

typedef long long ll;
typedef long double ld;

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

    /**int arr[4];
    read(arr, 0, 4);
    sort(arr, arr+2), sort(arr+2, arr+4);*/

    int n; cin >> n;
    string s;
    set<string> st;
    to(i, 0, n) cin >> s, st.insert(s);
    cout << st.size();

    return 0;
}


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

int main() {
  string S,T;
  int A,B;
  string U;
  cin >> S>>T>>A>>B>>U;
  
    if(S==U){
       cout<<A-1<<" "<<B<<endl;
    }
    else{
      cout<<A<<" "<<B-1<<endl;
    }
  

}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define me(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=500005;
const int M=200005;
int main()
{
	int n,d;
	cin>>n>>d;
	int q=2*d+1;
	if(n%q==0)cout<<n/q<<endl;
	else cout<<n/q+1<<endl;
	
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,A,B;
    cin >>N>>A>>B;
    ll ans=0;
    rep2(i,N){
        ll now=i;
        ll sum=0;
        while(now){
            sum+=now%10;
            now/=10;
        }
        if(sum<=B && sum>=A){
            ans+=i;
        }
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string.h>
using namespace std;
struct Node{
   int key;
   Node *next,*prev;
};
Node *nil;
Node* listSearch(int key)
{
    Node* cur=nil->next;
    while(cur!=nil&&cur->key!=key)
    {
        cur=cur->next;
    }
    return cur;
}
void init()
{
    nil=(Node *)malloc(sizeof(Node));
    nil->next=nil;
    nil->prev=nil;
}
void printList()
{
    Node* cur=nil->next;
    int isf=0;

    while(1)
    {
        if(cur==nil) break;
        if(isf++>0) printf(" ");
        printf("%d",cur->key);
        cur=cur->next;
    }
    printf("\n");
}
void deleteNode(Node *t)
{
    if(t==nil) return ;
    t->prev->next=t->next;
    t->next->prev=t->prev;
    free(t);
}
void deleteFirst()
{

    deleteNode(nil->next);
}
void deleteLast()
{

    deleteNode(nil->prev);
}
void deleteKey(int key)
{
    deleteNode(listSearch(key));
}
void Insert(int key)
{
    Node *x=(Node*)malloc(sizeof(Node));
    x->key=key;

    x->next=nil->next;
    nil->next->prev=x;
    nil->next=x;
    x->prev=nil;
}
int main()
{
    int key,n,i;
    char com[20];
    scanf("%d",&n);
    init();
    for(i=0;i<n;i++)
    {
        scanf("%s",com);
        if(strcmp(com,"insert")==0)
        {
            scanf("%d",&key);
            Insert(key);

        }
        else if(strcmp(com,"deleteFirst")==0)
        {


        deleteFirst();
        }
        else if(strcmp(com,"deleteLast")==0)
        deleteLast();
        else
        {

        scanf("%d",&key);
        deleteKey(key);
        }


    }
    printList();
    return 0;
}

Measured memory_bytes: 34448
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
	int n,cnt=0;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		if(i&1&&a[i]&1) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        
        static void Solve()
        {
            string s = Console.ReadLine();

            int win = 0;
            int lose = 0;
            int rock = 0;
            int paper = 0;
            for(int i=0;i<s.Length;++i)
            {
                if(s[i] == 'g')
                {
                    if( paper < rock)
                    {
                        paper++;
                        win++;
                    }
                    else
                    {
                        rock++;
                    }
                }
                else// p
                {
                    if( paper < rock)
                    {
                        paper++;
                    }
                    else
                    {
                        rock++;
                        lose++;
                    }
                }
            }
            int ans = win - lose;
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

struct Node{
	int key;
	Node *prev,*next;
};

Node *nil;

Node* search(int key){
	Node *cur = nil->next;
	while(nil!=cur&&cur->key!=key)
		cur = cur->next;
	return cur;
}

void init(){		//初期化
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printlist(){
	Node* cur = nil->next;
	int isf=0;
	while(1){
		if(cur==nil)break;
		if(isf++>0)printf(" ");
		cout << cur->key;
		cur = cur->next;
	}
	cout << endl;
}

void deleteNode(Node *t){
	if(t==nil)return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deletefirst(){
	deleteNode(nil->next);
}

void deletelast(){
	deleteNode(nil->prev);
}

void deletex(int key){
	deleteNode(search(key));
}

void insert(int key){
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main() {
	int n,key,num,np=0,nd=0,size=0;
	char com[10];
	cin >> n;
	init();
	for(int i=0;i<n;i++){
		scanf("%s %d",com,&key);
		if(com[0]=='i'){
			insert(key);
			np++;size++;
		}
		else{
			if(com[6]=='F')deletefirst();
			else if(com[6]=='L')deletelast();
			else{ 
				deletex(key);
				nd++;
			}
			size--;
		}
	}
	printlist();
	return 0;
}


Measured memory_bytes: 34400
#include<bits/stdc++.h>
using namespace std;
vector<int>e[55];
int main(){
  //  freopen("input.txt","r",stdin);
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        e[u].push_back(v);
        e[v].push_back(u);
    }
    for(int i=1;i<=n;i++) printf("%d\n",e[i].size());
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int ans;
    for(int i=1;i<=n;i++){
        if(i==1 || i==2 || i==4 || i==8 || i==16 || i==32 || i==64){
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

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++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> a(m);
  int r = 0;
  int l = 0;
  rep(i,m) {
    cin >> a[i];
    if(a[i] < x) r++;
    else l++;
  }
  int ans = min(r, l);
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <queue>
using namespace std;
const int maxn = 1e5+10;
vector<int> g[maxn];
int ans[maxn]={1,1},cnt;
queue<int> que;
void bfs(){
    while(!que.empty()) que.pop();
    que.push(1);
    while(!que.empty()){
        int u = que.front(); que.pop();
        for(auto v:g[u])if(!ans[v])
            que.push(v),ans[v] = u,cnt++;
    }
}
int main(){
    int n,m; scanf("%d%d",&n,&m);
    for(int i = 1; i <= m; i++){
        int u,v; scanf("%d%d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    bfs();
    if(cnt==n-1){
        puts("Yes");
        for(int i = 2; i <= n; i++) printf("%d\n",ans[i]);
    }
    else puts("No");
    return 0;
}



Measured memory_bytes: 9984
import scala.io.StdIn
import scala.math._

object Main {

  // (i番目までの山の最大の高さ、i番目の山までで海が見える山の数)
  type State = Tuple2[Int, Int]

  def main(args: Array[String]): Unit = {
    val n = StdIn.readLine.toInt
    val hs = StdIn.readLine.split(" ").map(_.toInt)

    println(hs.foldLeft((0, 0): State)((state, b) => if (b >= state._1) (b, state._2 + 1) else state)._2)
  }
}

Measured memory_bytes: 25420
while True:
    h,w = [int(x) for x in 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: 7016
#include <stdio.h>
#define MARK 4
#define RANK 13
#define CHECK 1	
int main(void)
{
	int n,rank,a,i,k;
	char mark;
	int card[4]={0,0,0,0};
	char mk[4]={'S','H','C','D'};
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf(" %c %d", &mark, &rank);
		if(mark == 'S'){
			a=1;
			a <<= rank;
			card[0] += a;
		}else if(mark == 'H'){
			a=1;
			a <<= rank;
			card[1] += a;
		}else if(mark == 'C'){
			a=1;
			a <<= rank;
			card[2] += a;
		}else if(mark == 'D'){
			a=1; 
			a <<= rank;
			card[3] += a;
		}
	}
	for(i=0; i<MARK; i++){
		for(k=1; k<=RANK; k++){
			card[i] >>= 1;
			if((card[i] & CHECK) == 0){
				printf("%c %d\n", mk[i], k);
			}
		}
	}
	return 0;
}

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

int main(){
    unsigned long long x;
    unsigned long long m = 100;
    int count = 0;
    cin >> x;

    while(x > m){
        m += (m*0.01);
        count++;
        
    }

    cout << count << endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	int64_t a[n];
	for(int64_t &i:a) cin >> i;
	map<int64_t, int> m;
	for(int64_t &i:a){
		int p = 1 - m[i];
		m[i] = p;
	}
	int ans = 0;
	for(auto p:m) if(p.second) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 7296
def seki(D):
  d10 = D//10
  d1 = D%10
  if d1>1 and d10>1:
    return(d1*d10)
  else:
    return 0

M,D = map(int,input().split())
ans = 0
for i in range(1,D+1):
  if 1<=seki(i)<=M:
    ans += 1

print(ans)

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

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

const ll LINF = 1LL << 60;
const int MAX_N = 1e5;
ll h[MAX_N+10]; 
ll dp[MAX_N+10]; 

int main() {
  int N, K; cin >> N >> K;
  REP(i, N) cin>>h[i];
  REP(i, MAX_N+10) dp[i] = LINF;

  dp[0]=0;

  for(int now=0; now < N; ++now){
    for(int dist=1; dist<=K; ++dist) {
      chmin(dp[now+dist],  dp[now]+abs(h[now]-h[now+dist]));
    }
  }
  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
//#include <bits/stdc++.h>
// utility
#include <bitset>
#include <tuple>
#include <typeinfo>
// error handling
#include <cassert>
// string
#include <cctype>
#include <cstring>
#include <string>
// container
#include <array>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// algorithm
#include <algorithm>
// iterator
#include <iterator>
// math
#include <cmath>
#include <complex>
#include <numeric>
#include <random>
// i/o
#include <cstdio>
#include <iomanip>
#include <iostream>

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
typedef __int128_t Int;
#define DBG 1
#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 loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]) == typeid(INF) and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
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 (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  int D, G;
  cin >> D >> G;
  vector<int> p(D), c(D);
  rep(i, 0, D) { cin >> p[i] >> c[i]; }

  int ans = INF;
  rep(bits, 0, 1 << D) {
    int sum = 0;
    int remax = -1;
    int num = 0;
    rep(i, 0, D) {
      if (bits >> i & 1) {
        sum += (i + 1) * 100 * p[i] + c[i];
        num += p[i];
      } else {
        chmax(remax, i);
      }
    }

    if (G > sum) {
      int x = (remax+1)*100;
      int f = (G - sum + x - 1) / x;
      if (f < p[remax]) {
        chmin(ans, num + f);
      }
    } else
      chmin(ans, num);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int a, b;
    cin >> a >> b;
    vector<int> c(3);
    c[a-1]++;c[b-1]++;
    rep(i, 0, 3) {
        if(c[i] == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
}

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

using namespace std;
#define int long long 
#define inf 999999999999
#define N 2666666
int arr[N],a[N],b[N];

signed main(){
	int k,n;cin>>k>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[n+i]=k+a[i];
	} 
	int ans=inf;
	for(int i=1;i<=n;i++){
	
		ans=min(ans,abs(a[i]-a[i+n-1]));
	}//cout<<'\n';
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4352
import numpy as np
N, M, Q = map(int, input().split())
RcntL = np.zeros((N+1, N+1), int)
for _ in range(M):
    l, r = map(int, input().split())
    RcntL[r, l] += 1
pq = []
for _ in range(Q):
    pq.append(list(map(int, input().split())))

RcntL = np.cumsum(RcntL, axis=0)
RcntL = np.cumsum(RcntL, axis=1)

for p, q in pq:
    ans = RcntL[q, q] - RcntL[q, p - 1]
    print(ans)


Measured memory_bytes: 37104
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
using ll = long long;
using P = pair<int, int>;

vector<vector<int>> calcNext(const string &s){
	int n = s.size();
	vector<vector<int>> res(n + 1, vector<int>(26, n)); 
	for(int i = n - 1; i >= 0; --i){
		for(int c = 0; c < 26; ++c){
			res[i][c] = res[i + 1][c]; 
			res[i][s[i] - 'a'] = i; 
		}
	}

	return res;
}

int dp[200100];

int main(){
  string a;
  cin >> a;
  int n = a.size();

  auto next = calcNext(a);
  fill((int*)dp, (int*)dp + sizeof(dp) / sizeof(int), INF);
  dp[n] = 1;
  vector<pair<char, int>> rest(n + 1, {'a', n});
  for(int i = n - 1; i >= 0; --i){
    for(int c = 0; c < 26; ++c){
      if(next[i][c] == n){
        if(dp[i] > 1){
          dp[i] = 1;
          rest[i] = {'a' + c, n};
        }
      }
      if(next[i][c] < n){
        if(dp[next[i][c] + 1] + 1 < dp[i]){
          dp[i] = dp[next[i][c] + 1] + 1;
          rest[i] = {'a' + c, next[i][c] + 1};
        }
      }
    }
  }
  
  string ans = "";
  int idx = 0;
  while(idx < n){
    auto p = rest[idx];
    ans += p.first;
    idx = p.second;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 29316
using System;
using System.Text;


class A {
    int N;
    int maxN = 100005;
    long L;
    int Q;
    long[] x;
    int[,] l;
    public A(){
        x = new long[maxN];
        l = new int[20,maxN];
    }
    public int calc(int a, int b){
        if(a==b) return 0;
        if(b<=l[0,a]) return 1;
        for(int i=0;i<19;i++){
            int h = (int)(1<<i);
            if(l[i,a]<=b && l[i+1,a]>b){
                return h+calc(l[i,a],b);
            }
        }
        return -1;
    }
    public string F(){
        return Console.ReadLine();
    }
    public void run(){
        N = int.Parse(F());
        string[] ss = F().Split(' '); 
        for(int i=0;i<N;i++){
            x[i] = long.Parse(ss[i]);
        }
        x[N] = x[N-1]+1;
        N = N+1;
        L = long.Parse(F());
        Q = int.Parse(F());
        
        
        int p = 1;
        for(int i=0;i<N;i++){
            while(p<N && x[p]-x[i] <= L) p++;
            p--;
            l[0,i] =  p;
        }
        
        for(int k=1;k<20;k++){
            for(int i=0;i<N;i++){
                l[k,i] = l[k-1,l[k-1,i]];
            }
        }
        
        StringBuilder sb = new StringBuilder("", 12*Q);
        for(int _=0;_<Q;_++){
            ss = F().Split(' '); 
            int a = int.Parse(ss[0])-1;
            int b = int.Parse(ss[1])-1;
            if(a>b){
                int tmp = a;
                a = b;
                b = tmp;
            }
            sb.Append(calc(a,b)+"\n");
        }
        Console.WriteLine(sb.ToString());
    }
}


class Program {
    static void Main(string[] args){
        A a = new A();
        a.run();    
    }
}

Measured memory_bytes: 26544
import sys
input = sys.stdin.readline
    
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    N = int(input())
    if N == 1:
        print(0)
        return
    arr = factorization(N)
    CNT = 0
    for p, e in arr:
        CNT += 1
        for i in range(2, 100):
            if e > i:
                e -= i
                CNT += 1
            else:
                break
    print(CNT)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9460
//A - Fairness
#include<iostream>
//#include <inttypes.h>
#include<math.h>
using namespace std;
int main()
{
	long long A,B,C,K,ans;
	cin >> A >>B >>C >>K;

	if (K % 2 == 0) {
		ans = A - B;
	}
	else {
		ans = B - A;
	}
	if (ans > pow(10, 18) || ans < -pow(10, 18)) {
		cout << "Unfair" << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
static const ll mod = 1000000007;
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

ll sum_gauss(ll n){
    if(n%2==0) return (n/2)*(n+1);
    else return ((n+1)/2)*n;
}

int main(void){
    string s;
    cin >> s;
    vector< pair<char,ll> > v;
    ll tmp_counter = 1;
    for(ll i=0; i<s.length()-1; i++){
        if(s[i] != s[i+1]){
            v.push_back(make_pair(s[i], tmp_counter));
            tmp_counter = 1;
        }
        else{
            tmp_counter += 1;
        }
    }
    v.push_back(make_pair(s[s.length()-1], tmp_counter));

    ll ans = 0;
    for(ll i=0; i<v.size(); i++){
        ans += sum_gauss(v[i].second);
        if(v[i].first == '<' && v[i+1].first == '>'){
            ans -= min(v[i].second, v[i+1].second);
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 6520
package main

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

func main() {
	ans := 1
	gcd := GCD(nextInt(), nextInt())
	for i := 2; i*i <= gcd; i++ {
		if gcd%i == 0 {
			ans++
			for gcd%i == 0 {
				gcd /= i
			}
		}
	}
	if gcd > 1 {
		ans++
	}
	fmt.Println(ans)
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  char rev[256];

  rev['i'] = 'i';
  rev['w'] = 'w';

  rev['('] = ')';
  rev[')'] = '(';

  rev['{'] = '}';
  rev['}'] = '{';

  rev['['] = ']';
  rev[']'] = '[';

  string str;
  cin >> str;
  int n = str.size();
  int ans = 0;

  REP(i, (1 << n)) if(__builtin_popcount(i) > ans){
    bool ok = true;
    REP(j,n) if((i & (1 << j)) == 0 && (str[j] == 'i' || str[j] == 'w'))
      ok = false;
    if(!ok) continue;

    char buff[20] , *p = buff, *p2 = buff;
    REP(j,n) if((i & (1 << j)) != 0)
      *p++ = str[j];
    p--;

    while(p >= p2){
      if(rev[*p] != *p2){
        ok = false;
        break;
      }
      p--; p2++;
    }

    if(ok) ans = __builtin_popcount(i);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
 
signed main(){
  int a,b;
  while(scanf("%d%d",&a,&b),a||b){
      for(int c=0;c<a;c++){
	  for(int d=0;d<b;d++){
	      printf("#");
	      }
	      printf("\n");
	  }
	  printf("\n");
      }
}

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

const ll INF = 1e9;

ll N, A, B, C;
vector<ll> L;

ll min_of_four(ll p, ll q, ll r, ll s) {
  ll pq = (p < q) ? p : q;
  ll rs = (r < s) ? r : s;
  return (pq < rs) ? pq : rs;
}

ll dfs(ll current, ll a, ll b, ll c) {
  if (current == N) {
    if (a > 0 && b > 0 && c > 0) {
      return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    } else {
      return INF;
    }
  } else {
    ll ret0 = dfs(current + 1, a, b, c);
    ll ret1 = dfs(current + 1, a + L[current], b, c) + 10;
    ll ret2 = dfs(current + 1, a, b + L[current], c) + 10;
    ll ret3 = dfs(current + 1, a, b, c + L[current]) + 10;
    return min_of_four(ret0, ret1, ret2, ret3);
  }
}

void abc119c() {
  cout << dfs(0, 0, 0, 0) << '\n';
  return;
}

int main() {
  cin >> N >> A >> B >> C;
  L.resize(N);
  for (ll i = 0; i < N; i++) {
    cin >> L[i];
  }
  abc119c();
  return 0;
}

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

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

    int N, M;
    cin >> N >> M;

    vector<int> H(N);

    for(int i = 0; i < N; i++) cin >> H[i];

    vector<bool> x(N, true);

    for(int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;

        if(H[A] > H[B]) {
            x[B] = false;
        } else if(H[A] < H[B]) {
            x[A] = false;
        } else {
            x[A] = false;
            x[B] = false;
        }
    }

    int ans = 0;

    for(int i = 0; i < N; i++) {
        if(x[i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;

const int N = 200005;

int n, arr[N];
int par[N], sz[N];

inline int findRoot(int x) {
    if (par[x] == x) {
        return x;
    }
    return par[x] = findRoot(par[x]);
}

inline void mergeTree(int x, int y) {
    x = findRoot(x);
    y = findRoot(y);
    par[x] = y;
    sz[y] += sz[x];
}

int main() {
    ios :: sync_with_stdio(false);
    cin >> n;
    vector < pair < int, int > > values;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        values.push_back(make_pair(arr[i], i));
        par[i] = 0; sz[i] = 1;
    }
    sort(values.begin(), values.end());
    reverse(values.begin(), values.end());
    long long ans = 0;
    for (auto val : values) {
        int index = val.second;
        par[index] = index;
        int rightContribution = 1;
        int leftContribution = 1;
        if ((index + 1 <= n) && (par[index + 1] != 0)) {
            rightContribution += sz[findRoot(index + 1)];
            mergeTree(index, index + 1);
        }
        if ((index - 1 >= 1) && (par[index - 1] != 0)) {
            leftContribution += sz[findRoot(index - 1)];
            mergeTree(index, index - 1);
        }
        ans += ((leftContribution * 1LL * rightContribution) * val.first);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4336
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int n, a = 0, b; cin >> n;
  map<int, int> m; vector<pii> v;
  rep(i, n){
    int in; cin >> in; m[in]++;
  }
  for(pii p: m) v.push_back(p);
  b = v.size();
  rep(i, b-2){
    rep(j, b-i-1){
      rep(k, b-i-j-2){
        if(v[i].fi != v[i+j+1].fi && v[i+j+1].fi != v[i+j+k+2].fi && v[i+j+k+2].fi != v[i].fi && v[i].fi + v[i+j+1].fi > v[i+j+k+2].fi) a += v[i].se * v[i+j+1].se * v[i+j+k+2].se;
      }
    }
  }
  cout << a << endl;
  return 0;
}

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

typedef long long ll;

int n;
int t = 0;
vector<int> assigned(102, 0);
vector<int> vis(102);
vector<vector<int>> adj(102);

int visit(int u) {
	if (vis[u] != t) {vis[u] = t;}
	else return 0;
	
	for (int i = 0; i < adj[u].size(); i++) {
		if (!assigned[adj[u][i]] || visit(assigned[adj[u][i]])) { 
	      	assigned[adj[u][i]] = u; 
	      	return 1; 
		}
	}
	return 0;
}

int main() {
	ios::sync_with_stdio(0);
	
	cin >> n;
	vector<pair<int, int>> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i].first >> b[i].second;
	}
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (a[i].first < b[j].first && a[i].second < b[j].second) {
				adj[i+1].push_back(j+1);
			//	adj[j+1].push_back(i+1);
			}
		}
	}
	
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		t++;
		ans += visit(i); 
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=100005;

long long N,A[MAXN],M,K,ans[MAXN];
int P[MAXN],stk[MAXN],tp;
bool vis[MAXN];

int main()
{
	scanf("%lld",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%lld",&A[i]);
		P[i]=i;
	}
	scanf("%lld%lld",&M,&K);
	for(int i=N;i>=1;i--)
		A[i]=A[i]-A[i-1];
	for(int i=1;i<=M;i++)
	{
		int x;
		scanf("%d",&x);
		swap(P[x],P[x+1]);
	}
	for(int i=1;i<=N;i++)
		if(!vis[i])
		{
			int u=i;
			tp=0;
			while(!vis[u])
			{
				stk[++tp]=u;
				vis[u]=true;
				u=P[u];
			}
			for(int j=1;j<=tp;j++)
				ans[stk[j]]=A[stk[(K+j-1)%tp+1]];
		}
	for(int i=1;i<=N;i++)
		ans[i]+=ans[i-1];
	for(int i=1;i<=N;i++)
		printf("%lld.0\n",ans[i]);
	
	return 0;
}


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

int n;
int board[9][9];
int dxy[3][3] = { { 0, 1, 2},
		  {-1, 0, 1},
		  {-2,-1, 0} };

bool cheak(int y,int x){
  for(int i=0;i<9;i++){
    if(i != y && board[y][x] == board[i][x]) return true;
    if(i != x && board[y][x] == board[y][i]) return true;
  }
  int py = y % 3;
  int px = x % 3;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      int nx = x+dxy[px][i];
      int ny = y+dxy[py][j];
      if(nx == x && ny == y) continue;
      if(board[y][x] == board[ny][nx]) return true;
    }
  }
  return false;
}

int main(){
  cin >> n;
  while(n--){
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	cin >> board[i][j];
      }
    }
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	if(cheak(i,j)) cout << "*" << board[i][j];
	else cout << " " << board[i][j];
      }
      cout << endl;
    }
    if(n != 0) cout << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
using ll = long long;
ll N, A, B, C, D; 

int main() {
  cin >> N >> A >> B >> C >> D;
  for(int P = 0; P < N; ++P) {
    int M = N - 1 - P;
    if(P * C - M * D <= B - A && B - A <= P * D - M * C) {
      cout << "YES" << '\n';
      return 0;
    }
  }
  cout << "NO" << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 1e5 + 5;
ll n;

int main(){
	IOS
	cin >> n;
	string ans="";
	while(n){
		n--;
		ans+='a'+(n%26);
		n/=26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#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
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

int main() {
    cin>>S;
    vec ten(10, 1), two(10, 1);
    reps(i,1,10) {
        ten[i] = ten[i-1] * 10;
        two[i] = two[i-1] * 2;
    }
    N = S.size();
    ll ans = 0;
    rep(i, N){
        rep(j,N - i){
            ans += ten[j] * (S[i] - '0') * two[i + max(0LL, N - i - 2 - j)];
        }
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

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

int main() {

  string S;
  cin >> S;
  long sum = 0;
  for(int i = 0;i < (1 << (S.length() - 1));i++)
  {
    bitset<9> bit(i);
    
    int temp = 1;
    string len = S;
    for(int j = 0;j < S.length() - 1;j++)
    {
      if(bit.test(j))
      {
        sum += stol(len.substr(0,temp));
        len = len.substr(temp);
        temp = 1;
      }
      else
      {
        temp++;
      }
    }
    
    sum += stol(len);
  }
  
  cout << sum;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
 
  public struct City{
    public long num;
    public City(long n){
      num = n;
    }
 
  }
 
  public static void Main (string[] args) {
    var N = long.Parse(Console.ReadLine());
    var list = Console.ReadLine().Split(' ').Select(long.Parse);
    var ans = "";

    ans = list.Max() < list.OrderByDescending(x => x).Skip(1).Sum() ? "Yes" : "No";

    Console.WriteLine(ans);
  }

}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
const ll mod = 1e9 + 7;
const int intmax = 0x7fffffff, intmin = ~intmax;
const ll llmax = 0x7fffffffffffffffll, llmin = ~llmax;

int a[200001];
int x[200001];
int xx[200001];
int xxsum;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = n; i > 0; i--) {
    x[i] = (xx[i] % 2) != a[i];
    if (x[i]) {
      xxsum++;
      //cout << "*" << i << endl;
      auto i2 = sqrt((double)i);
      for (int j = 1; j <= i2; j++) {
        if (i % j == 0) {
          xx[j]++;
          //cout << j << " ";
          if (j != i2) {
            xx[i / j]++;
            //cout << i / j << " ";
          }
          //cout << endl;
        }
      }
    }
  }
  cout << xxsum << "\n";
  bool first = true;
  for (int i = 1; i <= n; i++) {
    if (x[i]) {
      if (!first) cout << " ";
      cout << i;
      first = false;
    }
  }
  if (xxsum || true) cout << endl;
}


Measured memory_bytes: 3200
<?php
fscanf(STDIN, "%d %d", $N, $M);
$arr = array();
for ($m=0; $m<$M; $m++){
    fscanf(STDIN, "%d %d", $s, $c);
    $arr[] = array($s, $c);
}

$ans = -1;
for ($n=0;$n<1000;$n++){
    if (strlen(strval($n)) == $N){
        $isIncluded = 0;
        foreach ($arr as $item){
            if (strval($n)[$item[0]-1] != $item[1]){
                $isIncluded = 1;
            }
        }
        if ($isIncluded == 0){
            $ans = $n;
        break;
        }
    }
}
echo $ans;

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

using namespace std;

int main()
{
    int n;
    int num[100010];
    vector<int> odd, even;
    int oddbuck[100010] = {0};
    int evenbuck[100010] = {0};
    int maxo = 0, o1, o2;
    int maxe = 0, e1, e2;
    int ans1 = 0, ans2 = 0;

    cin >> n;

    for (int i = 0; i < n; i++) cin >> num[i];

    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            odd.push_back(num[i]);
        }
        else {
            even.push_back(num[i]);
        }
    }

    for (int i = 0; i < (int)odd.size(); i++) {
        oddbuck[odd[i]]++;
        evenbuck[even[i]]++;
    }

    for (int i = 0; i < 100010; i++) {
        if (maxo < oddbuck[i]) {
            maxo = oddbuck[i];
            o1 = i;
        }
        if (maxe < evenbuck[i]) {
            maxe = evenbuck[i];
            e1 = i;
        }
    }

    oddbuck[o1] = 0;
    evenbuck[e1] = 0;
    maxo = 0;
    maxe = 0;

    for (int i = 0; i < 100010; i++) {
        if (maxo < oddbuck[i]) {
            maxo = oddbuck[i];
            o2 = i;
        }
        if (maxe < evenbuck[i]) {
            maxe = evenbuck[i];
            e2 = i;
        }
    }

    if (e1 == o1) {
        for (int i = 0; i < (int)odd.size(); i++) {
            if (odd[i] != o1) {
                ans1++;
            }
            if (even[i] != e2) {
                ans1++;
            }
            if (odd[i] != o2) {
                ans2++;
            }
            if (even[i] != e1) {
                ans2++;
            }
        }

        cout << (ans1 < ans2 ? ans1 : ans2) << endl;
    }
    else {
        for (int i = 0; i < (int)odd.size(); i++) {
            if (odd[i] != o1) {
                ans1++;
            }
            if (even[i] != e1) {
                ans1++;
            }
        }

        cout << ans1 << endl;
    }

    return (0);
}

Measured memory_bytes: 2044
#include<stdio.h>
int main(){
    int g[10]={1,2,4,8,16,32,64,128,256,512};
    int a,n;
    for(;;){
        int low[10]={0},f=0;
        if(scanf("%d",&n) == EOF){break;}
        for(a=0;a<10;a++){
            if(n%2 == 1){low[a] = 1;}
            n=n/2;
        }
        for(a=0;a<10;a++){
            if(low[a] == 1){
                if(f == 0){printf("%d",g[a]);f = 1;}
                else if(f == 1){printf(" %d",g[a]);}
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define INF 147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
//warshall_floyd
const int MAX_V=100;
int d[MAX_V][MAX_V];
int V;
void WF(){
  for(int k=1;k<=V;k++)
    for(int i=1;i<=V;i++)
      for(int j=1;j<=V;j++)
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
}
//end of warshall_floyd
int main(){
  int m;
  cin>>V>>m;
  for(int i=0;i<MAX_V;i++)
    for(int j=0;j<MAX_V;j++)
      d[i][j]=INF;
  for(int i=0;i<m;i++){
    int a,b,c,dd;
    scanf("%d,%d,%d,%d",&a,&b,&c,&dd);
    d[a][b]=c;
    d[b][a]=dd;
  }
  WF();
  int s,g,v,p;
  scanf("%d,%d,%d,%d",&s,&g,&v,&p);
  cout<<v-p-d[s][g]-d[g][s]<<endl;

  return 0;
}

Measured memory_bytes: 3192
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

class UnionFind {
public:
	vector <ll> par; // 親
	vector <ll> rank; // 木の深さ
	ll numComponents; //集合(木)の数
	void init(ll n) {
		par.resize(n);
		rank.assign(n, 1LL);
		for(ll i = 0; i < n; ++i) par[i] = i;
		numComponents = n;
	}

	ll findRoot(ll x) {
		if(par[x] == x) return x;
		else return par[x] = findRoot(par[x]);
	}

	bool unite(ll x, ll y) {
		x = findRoot(x);
		y = findRoot(y);
		if(x == y) return false;
		if(rank[x] < rank[y]) swap(x, y);
		rank[x] += rank[y];
		par[y] = x;
		numComponents--;
		return true;
	}

	bool same(ll x, ll y){
		return findRoot(x) == findRoot(y);
	}

	ll size(ll x) {
		return rank[findRoot(x)];
	}
};



int main(void){
	int n, m, k; cin >> n >> m >> k;
	UnionFind uf;
	uf.init(n);

	vint fCount(n);
	vint bCount(n);
	rep(i, m){
		int a, b; cin >> a >> b;
		a--; b--;
		fCount[a]++; fCount[b]++;
		uf.unite(a, b);
	}
	rep(i, k){
		int a, b; cin >> a >> b;
		a--; b--;
		if(uf.same(a, b)){
			bCount[a]++; bCount[b]++;
		}
	}
	rep(i, n){
		int c = 0;
		cout << uf.size(i)-fCount[i]-bCount[i]-1 << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3968
#include<stdio.h>
int main()
{
	int A,B,a,b,kazu,yakusuu=0,baisuu=0;
	while(scanf("%d %d",&A,&B)!=EOF)
	{
		a=A;
		b=B;
		yakusuu=0;
		baisuu=0;
		if(A>B)
		{
			while(1)
			{
				kazu=a%b;
				if(kazu==0)
				{
					yakusuu=b;
					break;
				}
				a=b;
				b=kazu;
			}
		}
		else
		{
			while(1)
			{
				kazu=b%a;
				if(kazu==0)
				{
					yakusuu=a;
					break;
				}
				b=a;
				a=kazu;
			}
		}
		A=A/yakusuu;
		B=B/yakusuu;
		baisuu=A*B;
		baisuu*=yakusuu;
		printf("%d %d\n",yakusuu,baisuu);
	}
	return 0;
}

Measured memory_bytes: 592