akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int x, y, ans;
int a[210];

int main()
{
	a[1] = 300000, a[2] = 200000, a[3] = 100000;
	cin >> x >> y;
	ans = a[x] + a[y];
	if(x == 1 && y == 1) ans += 400000;
	cout << ans << endl;
	return 0;
}

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

using namespace std;
const int INF = 100000;

int main(){
    while(true){
        int maxi;cin >> maxi;
        if(maxi == 0) break;
        int n;cin >> n;
        n+=2;
        vector<int> d(n);
        for(int i=1;i<=n-2;i++){
            cin >> d[i];
        }
        vector<vector<int>> graph(n,vector<int>(n,INF));
        for(int i=0;i<n;i++){
            for(int s=1;s<=maxi;s++){
                int g = i+s;
                g = min(g,n-1);
                g = max(g,0);
                g += d[g];
                g = min(g,n-1);
                g = max(g,0);
                graph[i][g] = 1;
            }
        }
        // read graph.
        for(int i=0;i<n;i++){
            graph[i][i] = 0;
        }
        for(int k=0;k<n;k++){
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    graph[i][j] = min(graph[i][j],graph[i][k]+graph[k][j]);
                }
            }
        }
        bool ret = true;
        for(int t=0;t<n;t++){
            if(graph[0][t] < INF and graph[t][n-1] >= INF){
                ret = false;
            }
        }
        cout << (ret?"OK":"NG") << endl;
    }
    return 0;
}

Measured memory_bytes: 1336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll acc[2004] = {0};
    rep(i, n) acc[a[i]]++;
    rep(i, 2003) acc[i + 1] += acc[i];
    ll sum = 0;
    rep(i, n) rep3(j, i + 1, n) {
        int s = a[i] + a[j]; // 未満
        int t = abs(a[i] - a[j]); // より大きい
        ll tmp = acc[s - 1] - acc[t];
        if (t < a[i]) tmp--;
        if (t < a[j]) tmp--;
        sum += max(0LL, tmp);
    }
    cout << sum / 3 << endl;
}




Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n,a,b,min={0},i;
      
    scanf("%d",&n);
  
    a=sqrt(n);
  
    for(i=0;i<=a;i++){
        b=i*i;
        if(min>=b) min=b;
    }  
  
    printf("%d\n",b);
  
    return 0;
}  

Measured memory_bytes: 128
using System;
					
public class Program
{
	public static void Main()
	{
		//°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸Kobato Love°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸
		int a,c;
		string b;
		a = int.Parse(Console.ReadLine()); 
		b = Console.ReadLine(); 
		c = int.Parse(Console.ReadLine()); 
		
		string res = "";

		for(int i = 0; i < b.Length; i++)
		{
			if(b[i] == b[c-1])
			{
				res += b[i];
			}
			else
			{
				res += '*';
			}
		}
		Console.WriteLine(res);
		
	}
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main()
{
    ll a,b;
    cin>>a>>b;
    ll g = __gcd(a,b);
    auto di = divisor(g);
    sort(all(di));
    vector<ll> ans;
    ans.push_back(1);
    for (int i = 0; i < di.size(); i++)
    {
        ll now = di[i];
        bool ok = true;
        for (int j = 0; j < ans.size(); j++)
        {
            if(__gcd(now,ans[j])==1) continue;
            else
            {
                ok=false;
                break;
            }
        }
        if(ok)
        {
            ans.push_back(now);
        }        
    }
    
    cout<<ans.size()-1<<endl;
    return 0;
}

Measured memory_bytes: 384
// By Atul Rathore

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

#define ll long long int
#define f(n) for(int i=0;i<n;i++)
#define p(x) cout<<x<<endl;
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007


int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;
	int n, k;
	cin >> n >> k;
	int a[n] = {};
	while (k--)
	{
		int x;
		cin >> x;
		for (int i = 0; i < x; i++)
		{
			int y;
			cin >> y;
			a[y - 1] = 1;
		}
	}
	int ans = 0;
	f(n)
	{
		if (a[i] == 0)ans++;
	}
	cout << ans;





}


Measured memory_bytes: 3648
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#include<cmath>
#include<stack>
#include<deque>
#include<queue>
#include<vector>
#include<string>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mkp(a,b) make_pair(a,b)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=200010,mod=1e9+7;
ll a[N],s[N];
int n;
int main()
{
    //IO;
    cin>>n;
    for(int i=1;i<=n;i++) 
    {
        cin>>a[i];
        s[i]=s[i-1]+a[i];
    }
    ll res=0;
    for(int i=1;i<=n;i++)
        res=(res+(s[n]-s[i])%mod*a[i]%mod)%mod;
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 6716
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int a, b;

int main() {
	cin >> a >> b;
	
	if(mo(a - b, 2) == 0) {
		cout << (a + b) / 2 << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 768
def dfs(s, n, visited):
    all_visited = True
    for i in range(n):
        if not visited[i]: all_visited = False
    if all_visited: return 1

    ret = 0
    for i in range(n):
        if not graph[s][i]: continue
        if visited[i]: continue
        visited[i] = True
        ret += dfs(i, n, visited)
        visited[i] = False

    return ret


n, m = map(int, input().split())

graph = [[False for i in range(n)] for j in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    graph[a-1][b-1] = graph[b-1][a-1] = True

visited = [False for i in range(n)]
visited[0] = True

print(dfs(0, n, visited))

Measured memory_bytes: 3064
# めちゃよかったのでほぼそのまま　https://atcoder.jp/contests/abc116/submissions/4060186?lang=ja
import heapq
import sys
input = sys.stdin.readline

def main():
	[N,K]=[int(x) for x in input().split()]
	td=[[int(x) for x in input().split()] for _ in range(N)]
	td.sort(key=lambda x:x[1],reverse=True)
	
	# 貪欲にとる.
	keep = []  # 各種類のsushiでおいしさ最大のものを保存
	exchange = []  # 取り替える用 (種類がかぶっているものが入る). priority queue
	types = set() # keepに入っているsushiの種類
	for i in range(K):
	    [t, d] = td[i]
	    if t not in types:
	        keep.append(d)
	        types.add(t)
	    else:
	        heapq.heappush(exchange, d)
	 
	basic_point_1 = sum(keep)
	basic_point_2 = sum(exchange)
	types_bonus = len(types)
	ans = basic_point_1 + basic_point_2 + types_bonus**2
	 
	# 種類が増えるようにおいしさ最大のものから交換していく.
	for i in range(K, N):
	    if len(exchange) == 0:  # 取り替えると種類が減るので終了.
	        break
	    [t, d] = td[i]
	    if t in types:
	        continue
	    types.add(t)
	    basic_point_1 += d
	    basic_point_2 -= heapq.heappop(exchange) # おいしさ最小のものと交換.
	    types_bonus += 1
	    ans = max(ans, basic_point_1 + basic_point_2 + types_bonus**2)
	print(ans)
        
if __name__ == "__main__":
  main()
    


Measured memory_bytes: 69084
/*
    Created by Rahul Goel.
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/*******************************************************************************/
using namespace std;
using namespace __gnu_pbds;
template < typename T >
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*******************************************************************************/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
ll mod_sum() { return 0LL; }
template < typename T, typename... Args >
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%MOD + MOD)%MOD; }
/*******************************************************************************/
ll mod_prod() { return 1LL; }
template< typename T, typename... Args >
T mod_prod(T a, Args... args) { return (a * mod_prod(args...))%MOD; }
/*******************************************************************************/
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
/*******************************************************************************/
//.-.. . -. -.- .- .. ... .-.. --- ...- .
/*
    Code begins after this.
*/

ll solve() {
    ll n;
    cin >> n;

    vi sieve(n + 5);

    for (ll i = 2; i < (ll)sieve.size(); i++) {
        if (sieve[i] == 0) {
            sieve[i] = i;
            for (ll j = i * i; j < (ll) sieve.size(); j += i) {
                if (sieve[j] == 0) {
                    sieve[j] = i;
                }
            }
        }
    }

    ll ans = 1;
    for (ll i = 2; i < n; i++) {
        ll num = i;
        ll temp = 1;
        while (num > 1) {
            ll cnt = 0;
            ll fac = sieve[num];
            while (num % fac == 0) {
                num /= fac;
                cnt++;
            }
            temp *= (cnt + 1);
        }
        ans += temp;
    }

    cout << ans << endl;

    return 0;
}

signed main() {
    fastio;

    ll t = 1;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 11060
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N; cin >> N;
	vector<int> h(N);
	bool zero = true;
	rep(i, N) {
		cin >> h[i];
		if (h[i] != 0)zero = false;
	}
	if (zero) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 0;
	bool ok = true;
	while (true) {
		int i;
		ok = true;
		for (i = 0; i < N; ++i)if (h[i] != 0)break;
		for (int j = i; i < N; ++i) {
			if (h[i] == 0)break;
			if (h[i] > 0)--h[i];
		}
		++ans;
		for (i = 0; i < N; ++i) if (h[i] != 0)ok = false;
		if (ok) {
			cout << ans << endl;
			cin >> N;
			return 0;
		}
	}
}

Measured memory_bytes: 256
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }

//37447563117764
i64 dfs(i64 cur,i64 n )
{
  if(cur>n)return 0;
i64 last=cur%10;
i64 ans=1;
if(last!=0)
ans+=dfs(cur*10+last-1,n);
if(last!=9)
ans+=dfs(cur*10+last+1,n);
ans+=dfs(cur*10+last,n);

return ans;

}
i64 check (i64 n)
{

  i64 sum=0;
  for(int i=1;i<=9;i++)
  sum+=dfs(1LL*i,n);

  return sum;

}

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

    // ifstream fin(".in");
    // ofstream fout(".in");
int k;
cin>>k;
i64 lo=0,hi=1e10,ans;
while(lo<=hi)
{
  i64  mid=(lo+hi)/2;
if(check(mid)>=k)
{
  ans=mid;
  hi=mid-1;
}
else
lo=mid+1;

}

  cout<<ans;


    return 0;
  }


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <math.h>
#include <numeric>

using namespace std;

typedef long long ll;
typedef long double ld;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

class UnionFind
{
public:
    explicit UnionFind(int N)
    {
        m_par.reserve(N);
        for (int n = 0; n < N; ++n) {
            m_par.push_back(n);
        }
    }
    int Root(int n)
    {
        if (n == m_par[n]) return n;
        return m_par[n] = Root(m_par[n]);
    }
    void Unite(int n, int m)
    {
        if (Root(n) == Root(m)) return;
        m_par[Root(n)] = Root(m);
    }
    bool Same(int n, int m)
    {
        return Root(n) == Root(m);
    }
private:
    vector<int> m_par;
};

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<pair<int, int> > viiCod(N);
    for (int n = 0; n < N; ++n) {
        int a, b;
        cin >> a >> b;
        viiCod[n] = {a, b};
    }
    
    set<pair<int, pair<int, int>>> Edges;
    
    vector<int> viIndex(N);
    iota(viIndex.begin(), viIndex.end(), 0);
    sort(viIndex.begin(), viIndex.end(), [&](int l, int r){ return viiCod[l].first < viiCod[r].first; });
    for (int n = 0; n < N-1; ++n) {
        int i = viIndex[n];
        int j = viIndex[n+1];
        Edges.insert({viiCod[j].first - viiCod[i].first, {i, j}});
    }
    
    iota(viIndex.begin(), viIndex.end(), 0);
    sort(viIndex.begin(), viIndex.end(), [&](int l, int r){ return viiCod[l].second < viiCod[r].second; });
    for (int n = 0; n < N-1; ++n) {
        int i = viIndex[n];
        int j = viIndex[n+1];
        Edges.insert({viiCod[j].second - viiCod[i].second, {i, j}});
    }
    
    ll ret = 0;
    UnionFind UF(N);
    for (auto tmp : Edges) {
        int i = tmp.second.first;
        int j = tmp.second.second;
        
        if (!UF.Same(i, j)) {
            ret += tmp.first;
            UF.Unite(i, j);
        }
    }
    cout << ret << endl;

    return 0;
}


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

int main(){
  string s;
  int n,m;
  
  cin>>s;
  n=-1;
  m=-1;
  
  for(int i=0;i<3;i++)
  {
    if(s.at(i)=='A')
      m=1;
    else
      n=1;
  }
  if(n*m==1)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

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

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;



int main() {

	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	int dx = tx - sx;
	int dy = ty - sy;

	cout << string(dy, 'U') << string(dx, 'R');	
	cout << string(dy, 'D') << string(dx, 'L');
	cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
	cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U' << endl;

	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

LL n,a[20][20],dp[70000],val[70000];

int main()
{
	cin>>n;
	rep(i,n) rep(j,n) cin>>a[i][j];
	rep(i,1<<n)
	{
		rep(j,n)
		{
			if((i&(1<<j))==0) continue;
			for(int k=j+1;k<n;k++)
			{
				if((i&(1<<k))==0) continue;
				val[i]+=a[j][k];
			}
		}
	}
	rep(i,69995) dp[i]=-1e18;
	dp[0]=0;
	rep(i,1<<n)
	{
		int mask=((1<<n)-1)^i;
		for(int k=mask;k>0;k=(k-1)&mask) dp[i|k]=max(dp[i|k],dp[i]+val[k]);
	}
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}

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

int main(){
  vector<int> alph(26,0);
  string w;

  cin >> w;

  for(int i = 0; i < w.size(); i++){
    alph[w[i] - 'a'] ++;
  }

  for(int i = 0; i < 26; i++){
    if(alph[i] % 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())
A = list(map(int,input().split()))
is_ball = [-1]*(N+1)
for i in range(N,-1,-1):
  is_ball[i] = A[i-1]
  divisors = make_divisors(i)
  if A[i-1] == 1:
    for div in divisors:
      A[div-1] ^= 1
      
b=[]

for i in range(1,N+1):
  if is_ball[i] == 1:
    b.append(i)
    
print(len(b))
print(" ".join(map(str,b)))
    
    


Measured memory_bytes: 81128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    int x,y;        //xが匹、yが本
    cin >> x >> y;

    
    int ans;
    for(int i=0;i<=50;i++){
        ans=2*i+4*(x-i);
        if(ans==y){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    cout << n*800 - (n/15)*200 << endl;
    return 0;
}


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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  vector<int> cnt(1000);
  for (char c : s) {
    ++cnt[c];
  }
  if (cnt['N'] && !cnt['S'] || cnt['S'] && !cnt['N'] || cnt['E'] && !cnt['W'] || cnt['W'] && !cnt['E']) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
N, D, A = map(int, input().split())
XH = [tuple(map(int, input().split())) for _ in range(N)]
XH.sort()


ans = 0
bomb_effect = 0
bomb_i = 0
bombs = []
for x, h in XH:
    while (bomb_i < len(bombs)) and (x > bombs[bomb_i][0]):
        bomb_effect -= bombs[bomb_i][1] * A
        bomb_i += 1

    tairyoku = h - bomb_effect
    if tairyoku > 0:
        new_bomb = -((-tairyoku) // A)
        ans += new_bomb
        bombs.append((x + 2 * D + 0.5, new_bomb))
        bomb_effect += new_bomb * A

print(ans)


Measured memory_bytes: 56948
import math
A,B,H,M= list(map(int, input().split(' ')))
print(math.sqrt(A**2+B**2-2*A*B*math.cos((M*6-(H*30+M*0.5))*3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977/180)))

Measured memory_bytes: 9500
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b;
  cin >> a >> b;

   cout << (a - 1) * (b - 1) << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                vector<int> x(3);
                x[0] = a[i];
                x[1] = a[j];
                x[2] = a[k];
                sort(ALL(x));
                if(x[2] == x[1])continue;
                if(x[1] == x[2])continue;
                if(x[0] == x[1])continue;
                if(x[2] < x[1] + x[0])ans++;
            }
        }
    }
    cout << ans << endl;
}

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

std::vector<std::string> ans;

void rec(std::string str, char max_c, int n) {
	if (str.size() == n) {
		ans.push_back(str);
		return;
	}
	for (char c = 'a'; c <= max_c + 1; ++c) {
		str.push_back(c);
		if (c == max_c + 1) rec(str, max_c + 1, n);
		else rec(str, max_c, n);
		str.pop_back();
	}
}

int main(void) {
	int n;
	std::cin >> n;

	rec("a", 'a', n);

	for (int i = 0; i < ans.size(); ++i) std::cout << ans[i] << std::endl;
	return 0;
}


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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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 H, W;
vector<vector<char>> a(1010, vector<char>(1010));
vector<vector<ll>> dp(1010, vector<ll>(1010, 0));

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

    cin >> H >> W;

    REP(i, H) {
        string line; cin >> line;
        REP(j, W) {
            a.at(i).at(j) = line.at(j);
        }
    }

    dp[0][0] = 1;

    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {
            if (y < 0 || H <= y || x < 0 || W <= x) {
                continue;
            }
    
            if (a[y][x] == '#') continue;

            if (y >= 1 && a[y - 1][x] == '.') {
                dp[y][x] = dp[y - 1][x];
                dp[y][x] %= mod;
            }
            if (x >= 1 && a[y][x - 1] == '.') {
                dp[y][x] = dp[y][x - 1];
                dp[y][x] %= mod;
            }

            if (y >= 1 && a[y - 1][x] == '.') {
                if (x >= 1 && a[y][x - 1] == '.') {
                    dp[y][x] = dp[y - 1][x] + dp[y][x - 1];
                    dp[y][x] %= mod;
                }
            }            
        }
    }

    cout << dp[H - 1] [W - 1] << endl;
    
    return 0;
}

Measured memory_bytes: 9344
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  list_ = list(map(int, input().split()))

  diff = 0
  while True:
    if x-diff not in list_:
      print(x-diff)
      break
    if x+diff not in list_:
      print(x+diff)
      break
    diff+=1

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

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  double h, th;
  if(2 * x > a * a * b){
    h = (2 * b) - (double(2 * x)/(a * a));
    th = h / a;
  }else{
    h = double((2 * x)) / (a * b);
    th = b / h;
  }
  double Do;
  Do = (atan(th) * 360)/(2 * 3.14159265358979);
  cout << setprecision(10) << Do;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<utility>
using namespace std;
int N;
pair<int,int>A[2<<17];
int cnt[60];
const int off=13;
main()
{
	cin>>N;
	long ans=0;
	for(int i=0;i<N;i++)
	{
		string S;cin>>S;
		long a=0;
		int b=0;
		bool under=false;
		for(int j=0;j<S.size();j++)
		{
			if(S[j]=='.')
			{
				under=true;
				continue;
			}
			a=a*10+S[j]-'0';
			if(under)b++;
		}
		A[i]=make_pair(-b,-b);
		while(a%2==0)
		{
			A[i].first++;
			a/=2;
		}
		while(a%5==0)
		{
			A[i].second++;
			a/=5;
		}
		if(A[i].first>=0&&A[i].second>=0)ans--;
	}
	sort(A,A+N);
	int j=N-1;
	for(int i=0;i<N;i++)
	{
		while(j>=0&&A[i].first+A[j].first>=0)
		{
			cnt[A[j].second+off]++;
			j--;
		}
		for(int k=0;k<60;k++)
		{
			if(A[i].second+k-off>=0)ans+=cnt[k];
		}
	}
	cout<<ans/2<<endl;
}


Measured memory_bytes: 5156
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    vector<bool>v(10,true);
    int n,k;cin>>n>>k;
    rep(i,k){
        int hoge; cin>>hoge;v[hoge]=false;
    }
    for(int m=n;;m++){
        string t=to_string(m);
        bool flag=true;
        rep(i,t.size())if(!v[t[i]-'0'])flag=false;
        if(flag){
            cout<<m<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#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 show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#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)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

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

   int ans = 0;
   rep(i,n-2) {
     if (s.substr(i,3) == "ABC") ans++;
   }

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

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

int main() {

	bool f[100001];
	int c[100002];
 	int Q;
  	int l[100005], r[100005];

	// Sieve of Eratosthenes
	for(int i=2;i<=100000;i++){
		if(!f[i]){
			for(int j=i+i;j<=100000;j+=i){
				f[j] = true;
            }
        }
	}

	// judge wheter i is a 2017-like-number or not
	for(int i=3; i<=100000;i+=2){
		if(!f[i]&&!f[(i+1)/2])
			c[i]++;
	}

	// c[i] is the number of 2017-like-numbers from 1 to i
	for(int i=3; i<=100000;i++){
		c[i] += c[i-1];
	}
  
  cin >> Q;
  for(int i=0;i<Q;i++){
    cin >> l[i] >> r[i];
  }
  for(int i=0;i<Q;i++){
    cout << c[r[i]] - c[l[i]-1] << endl;
  }
  	
}


Measured memory_bytes: 1920
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, res = 0;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  while(true) {
    REP(i,n) {
      if(a[i] % 2 != 0) { cout << res << endl; return 0; }
      a[i] /= 2;
    }
    res++;
  }
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
Ans = []
d = 0
cnt = 0
while cnt < 2:
  c = (A[d:d+4]).count(A[d])
  for j in range(c//2):
    Ans.append(A[d])
  cnt += c//2
  d += c
  if d == N:
    Ans.append(0)
    Ans.append(0)
    cnt +=2
print(Ans[0]*Ans[1])

Measured memory_bytes: 14252
#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()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll ans=0;
	
	int n; cin >> n;
	vector<int> a(n); rep(i,n) cin >> a[i];
	
	ll c=0;
	int j=1;
	
	rep(i,n){
		if(a[i]==j) j++;
		else c++;
	}
	
	if(j==1) c=-1;
	
	
	cout << c << "\n";
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long N,t=5,ans=0;
	cin >> N;

	if (N%2==0)
	{
		N /= 2;
		for (size_t i = 0; i < 25; i++)
		{
			//cout << t<<endl << N / t<<endl;
			ans += (N / t);
			t *= 5;
		}
		cout << ans;
	}
	else
	{
		cout <<0;
	}
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int n, x, cnt, i, j;

	while (1) {
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0) break;

		cnt = 0;
		for (i = n; i > 0; i--) {
			for (j = (i-1); j>0; j--) {
				if ((((x - i) - j) < j) && (((x - i) - j))>0) {
					cnt++;
				}
			}
		}
		printf("%d\n", cnt);
	}

	return 0;
}


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

#define ll long long

using namespace std;

int main() {
	string s; cin >> s;
	int cnt = 0;
	for (char c : s) {
		int k = c - '0';
		cnt = (cnt + k) % 9;
	}
	if (cnt == 0) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s;
    cin >> s;

    ll k;
    cin >> k;

    rep(i, min((ll)s.size(), k)) {
        if (s[i] != '1') {
            put(s[i]);
            return 0;
        }
    }
    put(1);

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

ll Sil(ll n)
{
    if (n == 0)
        return 1;
    ll w = 1;
    for (ll i = 1; i <= n; ++i)
        w = (w * i) % MOD;
    return w;
}

ll Pot(ll p, ll w)
{
    if (w == 0)
        return 1;
    if (w % 2 == 0)
    {
        ll pol = Pot(p, w / 2);
        return pol * pol % MOD;
    }
    return Pot(p, w - 1) * p % MOD;
}

ll Inv(ll n)
{
    return Pot(n, MOD - 2);
}

ll C(ll n, ll k)
{
    if (n == k || k == 0)
        return 1;
    return Sil(n) * (Inv(Sil(n - k)) * Inv(Sil(k)) % MOD) % MOD;
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n, m, k;
    cin >> n >> m >> k;
    ll odp = 0;
    for (ll d = 1; d < m; ++d)
    {
        ll il = (n * n) % MOD;
        il = (il * (m - d)) % MOD;
        odp = (odp + il * d) % MOD;
    }
    for (ll d = 1; d < n; ++d)
    {
        ll il = (m * m) % MOD;
        il = (il * (n - d)) % MOD;
        odp = (odp + il * d) % MOD;
    }
    odp = (odp * C(n * m - 2, k - 2)) % MOD;
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,i,j,min,ans=0;
    cin>>n;
    vector<int> v(n);
    for(i=0;i<n;i++){
        cin>>v[i];
    }
    for(i=0;i<n;i++){
        min=i;
        for(j=i;j<n;j++){
            if(v[j]<v[min]){
                min=j;
            }
        }
        if(v[i]!=v[min]){
            swap(v[i],v[min]);
            ans++;
        }
    }
    for(i=0;i<v.size();i++){
        cout<<v[i]<<((i<v.size()-1)?' ':'\n');
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main{
	public Main(){
		int a = 0, b = 0, o = 0, ab = 0;
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String[] str = (sc.nextLine()).split(",");
			
			if(str[1].equals("A")){
				a++;
			} else if(str[1].equals("B")){
				b++;
			} else if(str[1].equals("O")){
				o++;
			} else {
				ab++;
			}
		}
		
		System.out.println(a);
		System.out.println(b);
		System.out.println(ab);
		System.out.println(o);
	}
	
	public static void main(String[] args){
		Main test = new Main();
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {
	public  static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = A - B * 2;
		if(C <= 0 ) {
			C = 0;
		}
		
		System.out.println(C);
	}
}

Measured memory_bytes: 23892
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

struct event {
	int t, x, f;
	event() {}
	event(int t, int x, int f) : t(t), x(x), f(f) {}
	bool operator<(const event &rhs) const {
		if (t != rhs.t)
			return t < rhs.t;
		return f < rhs.f;
	}
};
int N, M, K, T, Q;
int main() {
	cin >> N >> Q;
	vector< event > E(N * 2);
	rep(i, N) {
		int S, T, X;
		cin >> S >> T >> X;
		E[i * 2] = event(S - X, X, 1);
		E[i * 2 + 1] = event(T - X, X, -1);
	}
	sort(E.begin(), E.end());
	vector< int > D(Q);
	rep(i, Q) cin >> D[i];
	int di = 0;
	set< int > s;
	for (int i = 0; i < N * 2; i++) {
		event e = E[i];
		int t = e.t;

		while (di < Q && D[di] < t) {
			di++;
			if (s.empty()) {
				cout << -1 << endl;
			} else
				cout << (*(s.begin())) << endl;
		}
		if (di >= Q)
			break;
		if (e.f > 0)
			s.insert(e.x);
		else
			s.erase(e.x);
	}
	while (di++ < Q)
		cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(b/a<=c) printf("%d\n",b/a);
    else printf("%d\n",c);
}


Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $a = explode(" ", trim(fgets(STDIN)));
  $b = explode(" ", trim(fgets(STDIN)));

  $ans = 0;
  $nokori_mon = $a[$n];
  for ($i=$n-1; $i>=0; $i--) {
    // i+1の街
    if($nokori_mon < $b[$i]){
      $ans += $nokori_mon;
      $power = $b[$i]-$nokori_mon;
    }else{
      $ans += $b[$i];
      $power = 0;
    }
    // iの街
    if($a[$i] < $power){
      $ans += $a[$i];
      $nokori_mon = 0;
    }else{
      $ans += $power;
      $nokori_mon = $a[$i] - $power;
    }
  }
  echo $ans;

Measured memory_bytes: 20980
h, w, m = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(m)]

c = [0 for _ in range(h)]
r = [0 for _ in range(w)]
bakuset = {}
for i, j in hw:
    # print(i, j)
    c[i-1] += 1
    r[j-1] += 1
    if not str(i-1) + "+" + str(j-1) in bakuset:
        bakuset[str(i-1) + "+" + str(j-1)] = 0
    # print(bakuset, i-1, j-1)
    bakuset[str(i-1) + "+" + str(j-1)] += 1

ans = max(c) + max(r)

mc = max(c)
mr = max(r)
cc = []
rr = []

for i in range(h):
    if c[i] == mc:
        cc.append(i)

for i in range(w):
    if r[i] == mr:
        rr.append(i)

flag = 10**10

for i in cc:
    for j in rr:
        if not str(i) + "+" + str(j) in bakuset:
            flag = 0
            break
        flag = min(flag, bakuset[str(i) + "+" + str(j)])
    if not flag:
        break

if flag:
    ans -= flag

print(ans)

Measured memory_bytes: 210780
# -*- coding: utf-8 -*-
def fact(x):
    f = 1
    for i in range(1,x+1):
        f *= i
        f %= 10**9+7
    return f             

n,m = map(int, raw_input().split())
mod = 10**9+7
if(n==m):
    print((2*(fact(n))**2)%mod)
elif(abs(n-m)==1):
    tmp = fact(min(n,m))
    print(max(n,m)*(tmp**2)%mod)
else:
    print(0)

Measured memory_bytes: 5764
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val h = (1..n).map { sc.nextInt() }
    val t = Array(n) { mutableListOf<Int>()}
    repeat(m) {
        val a = sc.nextInt() - 1
        val b = sc.nextInt() - 1
        t[a].add(b)
        t[b].add(a)
    }
    println((0 until n).count {
        var isCount = true
        for (to in t[it]) {
            val toH = h[to]
            if (toH >= h[it]) {
                isCount = false
                break
            }
        }
        isCount
    })
}

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

int main(){
	ll l, r;
	cin >> l >> r;

	r = min(r, l+2018);
	int ans = 2018;
	for(ll i = l; i <= r; i++){
		for(ll j = i+1; j<= r; j++){
			int mod = i*j%2019;
			ans = min(ans, mod);
		}
	}
	cout << ans << endl;
	return 0;
}

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

ll to_ll(string str){
  stringstream ss;
  ll res;
  ss << str;
  ss >> res;
  return res;
}

ll solve(int n){
  if(s[n+1] != '['){
    int end = n;
    while(s[end] != ']')++end;
    return (to_ll(s.substr(n+1,end-n-1)))/2 + 1;
  }else{
    int b = 0,p = n+1;
    vector< ll > v;
    while(b >= 0){
      if(b == 0 && s[p] == '['){
	ll tmp = solve(p);
	v.push_back(tmp);
      }
      if(s[p] == '[')++b;
      else if(s[p] == ']')--b;
      ++p;
    }
    int size = (int)v.size();
    sort(v.begin(),v.end());
    ll res = 0;
    for(int i = 0;i < (size+1)/2;++i){
      res += v[i];
    }
    return res;
  }
}

int main(void){
  int n;
  cin >> n;
  for(int i = 0;i < n;++i){
    cin >> s;
    cout << solve(0) << endl;
  }
  return 0;
}

Measured memory_bytes: 3292
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 110;

string code;
int n;

int main() {
    cin>>n;
    cin>>code;

    int cntb = 0, cntr = 0;
    for(int i=0;i<code.length();i++) {
        if(code[i] == 'B') cntb++;
        else cntr++;
    }

    if(cntr > cntb) {
        cout<<"Yes\n";
    }
    else {
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX=100;
int main(void)
{
	int N,x;
		cin >> N >> x;
	int a[MAX+1],i;
	for(i=1;i<=N;i++)
		cin >> a[i];
	sort(a+1,a+N+1);
	int ans=0;
	
	for(i=1;i<=N;i++)
	{
		if(x<a[i])
			break;
		x-=a[i];
		ans=i;
	}
	if(ans==N && x>0)
		cout << N-1 << endl;
	else
		cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

bool connected[11][11] = { 0, };
int n, m, k;
int odd[11];

int rec(int cur, int sheet[11])
{
	int i, j;
	int bulb[11];
	int res = 1;
	int sol;

	if (cur == n + 1)
	{
		for (i = 1; i <= m; i++)
		{
			bulb[i] = !odd[i];
		}

		for (i = 1; i <= n; i++)
		{
			if (sheet[i])
			{
				for (j = 1; j <= m; j++)
				{
					if (connected[i][j])
					{
						bulb[j] = !bulb[j];
					}
				}
			}
		}

		for (i = 1; i <= m; i++)
		{
			res = res&&bulb[i];
		}

		return res;
	}

	sheet[cur] = 0;
	sol = rec(cur + 1, sheet);
	sheet[cur] = 1;
	return sol + rec(cur + 1, sheet);
}

int main()
{
	int i, j;
	int input;
	int sheet[11];

	scanf("%d %d", &n, &m);

	for (i = 0; i < m; i++)
	{
		scanf("%d", &k);

		for (j = 0; j < k; j++)
		{
			scanf("%d", &input);

			connected[input][i + 1] = true;
		}
	}

	for (i = 0; i < m; i++)
	{
		scanf("%d", &odd[i + 1]);
	}

	printf("%d\n", rec(1, sheet));

	return 0;
}

Measured memory_bytes: 128
n,d,a = gets.split.map(&:to_i)
monsters = n.times.map{ gets.split.map(&:to_i) } 

monsters.map!{ |xh| xh[1] = (xh[1]+a-1)/a; xh }.sort_by!{ |x,h| x }

deq = []
acc_damage = 0
ans = 0
monsters.each do |x,h|
  
  while deq.size > 0 && deq[0][0] < x do
    acc_damage -= deq[0][1]
    deq.shift
  end
  
  need = h - acc_damage
  need = 0 if need < 0
  
  if need > 0
    acc_damage += need
    ans += need
    deq.push( [x + d*2, need] )
  end
end

puts ans

Measured memory_bytes: 22520