akhauriyash/Code-Regression huggingface dataset:
import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def iif(n): return [int(input()) for _ in range(n)]
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    mod = 1000000007
    
    X = ii()

    if 400 <= X < 600:
        print(8)
    elif 600 <= X < 800:
        print(7)
    elif 800 <= X < 1000:
        print(6)
    elif 1000 <= X < 1200:
        print(5)
    elif 1200 <= X < 1400:
        print(4)
    elif 1400 <= X < 1600:
        print(3)
    elif 1600 <= X < 1800:
        print(2)
    elif 1800 <= X < 2000:
        print(1)
    
    return

main()


Measured memory_bytes: 9236
#include <iostream>
#include <string>
using namespace std;
int main() {
  string T, P;
  int p = 0;
  cin >> T >> P;
  while(p < int(T.length() - P.length() + 1)) {
	if(p == (int)T.find(P,p)) {
	  cout << (int)T.find(P, p) << endl;
	}
	p++;
  }
  return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<ll> v1, v2;
	ll n,m,k;
	cin>>n>>m>>k;
	for(ll i=0; i<n; ++i){
		ll x; cin>>x;
		v1.push_back(x);
	}
	for(ll i=0; i<m; ++i){
		ll y; cin>>y;
		v2.push_back(y);
	}
	vector<ll> pre(n+1,0);
	vector<ll> pre2(m+1,0);
	for(int i=1; i<=n; ++i){
		pre[i] = pre[i-1];
		pre[i] += v1[i-1];
	}
	for(int i=1; i<=m; ++i){
		pre2[i] = pre2[i-1];
		pre2[i] += v2[i-1];
	}

	int ans = 0;
	for(int i=0; i<=n; ++i){
		if( pre[i] > k ){ break; }
		ans = max(ans, i);
		ll left = k - pre[i];
		auto get = prev(upper_bound(pre2.begin(), pre2.end(), left));
		if( (*get) > left ){ continue; }
		int dist = distance(pre2.begin(), get);
		ans = max(ans, i + dist);
	}
	for(int i=0; i<=m; ++i){
		if( pre2[i] > k ){ break; }
		ans = max(ans, i);
		ll left = k - pre2[i];
		auto get = prev(upper_bound(pre.begin(), pre.end(), left));
		if( (*get) > left ){ continue; }
		int dist = distance(pre.begin(), get);
		ans = max(ans, i + dist);
	}
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 9516
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) << endl ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }


int main(){
	ll a,b,c,d,e ;
	cin >> a >> b >> c >> d >> e ;
	ll m = 60*c+d-60*a-b ;
	cout << m-e << endl ;
}




Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include<algorithm>
#define ll long long
#define pb push_back
#define popb pop_back
#define ull unsigned long long 
#define beg begin
#define MAXN 1000000007
#define mp make_pair
#define pii pair<int,int>
#define piii pair<int,pii>
using namespace std;


int main(void) {
     ios::sync_with_stdio(0);
     int n ;
     cin >> n ;
     cout << (n/2) * (n-n/2) ; 
     
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,W;cin>>n>>W;
	vector<int> v(n);
	vector<int> w(n);
	for(int i = 0; i < n; i++) {
		cin>>v[i]>>w[i];
	}
	vector<vector<int>> dp(n+1,vector<int>(W + 1,0));
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= W; j++) {
			dp[i][j] = max(dp[i - 1][j],dp[i][j]);
			if (j - w[i - 1] >= 0){
				dp[i][j] = max(dp[i - 1][j],dp[i - 1][j - w[i - 1]] + v[i - 1]);
			}
		}
	}
	cout << dp[n][W] << endl;

	return 0;
}


Measured memory_bytes: 6836
s=input()

n=10000000
for i in range(26):
    lis=[-1]
    for c in range(len(s)):
        if s[c]==chr(ord("a")+i):
            lis.append(c)
    if len(lis)>1:
        ni=0
        for j in range(len(lis)-1):
            ni=max(ni,lis[j+1]-lis[j]-1)
        ni=max(ni,len(s)-1-lis[len(lis)-1])
        n=min(n,ni)

print(n)

Measured memory_bytes: 38512
import sys
input = sys.stdin.readline
from collections import defaultdict, deque

(n, m), h, g = map(int, input().split()), list(map(int, input().split())), defaultdict(list)
for i in range(m): a, b = map(int, input().split()); g[a-1].append(b-1); g[b-1].append(a-1)
good = [True for i in range(n)]
for i in range(n):
    for j in g[i]:
        if h[j] >= h[i]: good[i] = False
print(good.count(True))

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

int main()
{
	int r, c, x;
	cin >> r >> c;

	int table[r+1][c+1];
	int sum = 0, sum_row[r], sum_col[c];

	for (int i = 0; i < r; ++i)
	{
		for (int j = 0; j < c; ++j)
			sum_col[j] = 0;
		sum_row[i] = 0;
	}
		
	for (int i = 0; i < r; ++i)
		for (int j = 0; j < c; ++j)
		{
			cin >> x;
			table[i][j] = x;
			sum += x;
			sum_row[i] += x;
			sum_col[j] += x;
		}

	for (int i = 0; i < r; ++i)
	{
		for (int j = 0; j < c; ++j)
			cout << table[i][j] << " ";
		cout << sum_row[i] << endl;
	}

	for (int i = 0; i < c; ++i)
		cout << sum_col[i] << " ";
	cout << sum << endl;

	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;


void print(ll a, ll b){
    cout << a << " " << b << endl;
}

void Main(){
    ll x;
    cin >> x;
    
    // xの約数のうち小さいほうを列挙
    vll d;
    for(ll i = 1; i*i <= x; i++){
        if(x%i == 0) d.pb(i);        
    }
    
    ll a;
    ll b;

    for(auto i : d){
        // cout << i << endl;
        a = i;
        b = 0;
        while(a*a*a*a*a - b*b*b*b*b <= x){
            // print(a,b);
            a = b + i;
            if(a*a*a*a*a - b*b*b*b*b == x) {
                print(a,b);
                return;
            }
            a++; b++;
        }        
    } 

    for(auto i : d){
        // cout << i << endl;
        a = i;
        b = 0;
        while(a >= b){
            // print(a,b);
            if(a*a*a*a*a + b*b*b*b*b == x) {
                print(a,-b);
                return;
            }
            a--; b++;
        }        
    } 
    cout << "no" << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>  

int main(void){    

int a,b,c,i;    

int count;    

scanf("%d %d %d\n", &a, &b, &c);    

for(i=a,count=0;i<=b;i++){        

if(c%i==0)count++;    

}    

printf("%d\n", count);        

return 0;

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
using namespace std;
template <class T> void rd(T &x){
  x = 0; int f = 1; char ch = getchar();
  while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
  while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  x *= f;
}

typedef long long ll;
const ll inf = 1e16;
const int maxn = 1e3 + 5;
int n, sp, tp;
ll ans;

namespace dinic{
  int cur[maxn], dis[maxn];

  struct edge{ int v, nxt; ll f; }; vector <edge> e; int head[maxn];

  void adde(int u, int v, ll f){
	e.push_back((edge){v, head[u], f}); head[u] = e.size() - 1;
	e.push_back((edge){u, head[v], 0}); head[v] = e.size() - 1;
  }

  bool bfs(){
	memset(dis, -1, sizeof(dis)); dis[sp] = 0;
	queue <int> q; q.push(sp);
	while(!q.empty()){
	  int u = q.front(); q.pop();
	  for(int i = head[u]; ~i; i = e[i].nxt){
		int v = e[i].v;
		if(dis[v] == -1 && e[i].f){
		  dis[v] = dis[u] + 1;
		  q.push(v);
		}
	  }
	}
	return dis[tp] != -1;
  }

  ll dfs(int u, ll minv){
	if(u == tp || minv == 0) return minv;
	ll used = 0;
	for(int &i = cur[u]; ~i; i = e[i].nxt){
	  int v = e[i].v;
	  if(dis[v] == dis[u] + 1 && e[i].f){
		ll f = dfs(v, min(e[i].f, minv));
		e[i].f -= f; e[i ^ 1].f += f;
		used += f; minv -= f;
		if(!minv) return used;
	  }
	}
	if(!used) dis[u] = -1;
	return used;
  }

  void extend(){
	while(bfs()){
	  rep(i, sp, tp) cur[i] = head[i];
	  ans -= dfs(sp, inf);
	}
  }

  void init(){
	memset(head, -1, sizeof(head));
  }
}

int main(){
  dinic :: init();
  rd(n);
  sp = 0;
  tp = n + 1;
  rep(i, 1, n){
	int x; rd(x);
	ans += x;
	if(x > 0) dinic :: adde(i, tp, x);
	else if(x < 0) dinic :: adde(sp, i, -x), ans += -x;
  }
  rep(i, 1, n){
	rep(j, 2, n / i){
	  dinic :: adde(i, i * j, inf);
	}
  }
  dinic :: extend();
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;

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

    int n;
    priority_queue<float, vector<float>, greater<float>> v;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        float x;
        cin >> x;
        v.push(x);
    }

    while (v.size() != 1) {
        float x = v.top();
        v.pop();
        float y = v.top();
        v.pop();

        v.push((x+y) / 2);
    }

    cout << v.top();
}


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

int main(){
    string s;
    int w;
    cin >> s >> w;
    string res = "";
    for(int i = 0; i < s.size(); i++){
        if(i % w == 0) res += s[i];
    }
    cout << res << endl;
    return 0;
}

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

#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))
double co[30][3];
int main(){
    int n,m;
    cin>>n>>m;
    rep(i,n){
        rep(j,3){
            cin>>co[i][j];
        }
    }
    double ans=0;
    rep(i,1<<n){
        if(__builtin_popcount(i)!=m) continue;
        double tmp=0;
        rep(j,n){
            if((1<<j)&i)
            rep(k,n){
                if((1<<k)&i){
                    rep(l,3){
                        tmp+=pow(abs(co[j][l]-co[k][l]),2);
                    }
                }
            }
        }
        // cout<<tmp<<endl;
        ans=max(ans,tmp);
    }
    cout<<fixed<<setprecision(10)<<ans/2<<endl;
}

Measured memory_bytes: 1300
N = int(input())
A = list(map(int, input().split()))
B = [(A[i]-(i+1)) for i in range(N)]

if N == 1:
  print(0)
  exit()
B = sorted(B, reverse=True)
cs = B[:]
for i in range(N-1):
  cs[i+1] += cs[i]

ans = float('inf')
tmp = 0
for b in B:
  tmp += abs(b)
ans = min(ans, tmp)

for i in range(1, N):
  b = B[i]
  left = b*(i)-cs[i-1]
  right = -1*(b*(N-i-1)-(cs[-1]-cs[i]))
  ans = min(ans, abs(left)+abs(right))
print(ans)

Measured memory_bytes: 32328
N,Y=map(int,input().split())
a=0
b=0
c=0
for i in range(0,N+1):
    for j in range(0,N-i+1):
        if 10000*i+5000*j+1000*(N-i-j)==Y:
            a=i
            b=j
            c=N-i-j
            break
if a==0 and b==0 and c==0:
    print(-1,-1,-1)
else:
    print(a,b,c)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

//typedef pair<int, int> P;

const int MAX_V = 2020;
const int MAX_LOG_V = 12;
vector<int> G[MAX_V];
int root;

int parent[MAX_LOG_V][MAX_V];
int depth[MAX_V];

void dfs(int v, int p, int d) {
	parent[0][v] = p;
	depth[v] = d;
	for (int i = 0; i < G[v].size(); i++) {
		if (G[v][i] != p)dfs(G[v][i], v, d + 1);
	}
}

void init(int V) {
	dfs(root, -1, 0);
	for (int k = 0; k + 1 < MAX_LOG_V; k++) {
		for (int v = 0; v < V; v++) {
			if (parent[k][v] < 0)parent[k + 1][v] = -1;
			else parent[k + 1][v] = parent[k][parent[k][v]];
		}
	}
}

int lca(int u, int v) {
	if (depth[u] > depth[v]) {
		swap(u, v);
	}
	for (int k = 0; k < MAX_LOG_V; k++) {
		if ((depth[v] - depth[u]) >> k & 1) {
			v = parent[k][v];
		}
	}
	if (u == v)return u;
	for (int k = MAX_LOG_V - 1; k >= 0; k--) {
		if (parent[k][u] != parent[k][v]) {
			u = parent[k][u];
			v = parent[k][v];
		}
	}
	return parent[0][u];
}
int dist(int a, int b) {
	int par = lca(a, b);
	return depth[a] + depth[b] - 2 * depth[par];
}


int N, K;
int A[100010], B[100010];
signed main() {
	cin >> N >> K;
	
	REP(i, N-1) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
		G[A[i]].pb(B[i]);
		G[B[i]].pb(A[i]);
	}
	root = 0;
	init(N);
	int ans = INF;
	if (K % 2 == 0) {
		REP(i, N) {
			int res = 0;
			REP(j, N) {
				if (j == i)continue;
				if (dist(i, j) > K / 2)res++;
			}
			ans = min(ans, res);
		}
	}
	else {
		REP(i, N - 1) {
			int res = 0;
			int l = A[i], r = B[i];
			REP(j, N) {
				if (j == l || j == r)continue;
				int d = min(dist(l, j), dist(r, j));
				if (d > (K - 1) / 2)res++;
			}
			ans = min(ans, res);
		}
	}
	print(ans);
	/*while (true) {
		int x, y; cin >> x >> y;
		pe(depth[x]); print(depth[y]);
		print(lca(x, y));
	}*/
}


Measured memory_bytes: 768
N=int(input())
H=list(map(int,input().split()))
s=0
t=0
for i in range(N-1):
  if H[i]>=H[i+1]:
    s+=1
  else:
    t=max(s,t)
    s=0
t=max(s,t)
print(t)
  

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n, m;

struct _edge {
    int x, i;
    _edge(int x, int i) : x(x), i(i) {}
};

vector<_edge> edge[200001];
int ps[200001];
int deg[200001];
int used[500000];
int ans[100001];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    int rt;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        if (x < 0) ++x, rt = i;
        else {
            edge[x].emplace_back(i, m);
            edge[i].emplace_back(x, m);
            ++m;
        }
        ++deg[i];
        ++deg[x];
    }
    for (int i = n + 1; i <= n + n; ++i) {
        int x;
        cin >> x;
        x += n;
        if (x < n) x = 0;
        else {
            edge[x].emplace_back(i, m);
            edge[i].emplace_back(x, m);
            ++m;
        }
        ++deg[i];
        ++deg[x];
    }

    for (int i = 1; i <= n; ++i) {
        if ((deg[i] ^ deg[i + n]) & 1) {
            printf("IMPOSSIBLE\n");
            return 0;
        }
        for (int j = 2 | (deg[i] & 1); j--; ) {
            edge[i].emplace_back(i + n, m);
            edge[i + n].emplace_back(i, m);
            ++m;
        }
    }

    for (int it = 0; it <= n + n; ++it) {
        int t = it ? it : rt;
        while (ps[t] < edge[t].size()) {
            int x = t;
            while (1) {
                bool b = 1;
                for (int &i = ps[x]; i < edge[x].size(); ++i) {
                    int p = edge[x][i].x;
                    int j = edge[x][i].i;
                    if (used[j]) continue;
                    b = 0;
                    used[j] = 1;
                    if (x <= n && p > n) ++ans[x];
                    if (x > n && p <= n) --ans[p];
                    x = p;
                    ++i;
                    break;
                }
                if (b) break;
            }
        }
    }
    printf("POSSIBLE\n");
    for (int i = 1; i <= n; ++i) {
        printf("%d%c", ans[i], "\n "[i < n]);
    }
    return 0;
}


Measured memory_bytes: 22144
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int R = scanner.nextInt();
        int S = scanner.nextInt();
        int P = scanner.nextInt();
        String T = scanner.next();
        char[] chars = T.toCharArray();
        char c, cc;

        long ans = 0;
        for (int i = 0; i < N; i++) {
            cc = chars[i];
            if (0 <= i - K) {
                c = chars[i - K];
                if(c == cc) {
                    chars[i] = 'x';
                    continue;
                }
            }
            if(cc == 'r') {
                ans += P;
            } else if (cc == 's') {
                ans += R;
            } else {
                ans += S;
            }
        }
//        System.out.println(chars);
        System.out.println(ans);
    }
}

Measured memory_bytes: 28500
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    vector <long long> v;
    map<string, int> n;
    double a,b,c,d=0,e=0,i,f=0,g=0,j,k=1,l=0,r=0,z,m,h,p;
    string y,t,s,x;
    double q,u;
    cin>>s;
    for(i=0;i<s.size();i++){
        if(s[i]=='?'){
            s[i]='D';
        }
    }
    cout<<s;
}

Measured memory_bytes: 3756
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
int N, M, K, H, W, L, R;



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

	cin >> N >> K;
	vector<long long int>v(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> v[i];
		v[i] += v[i - 1];
	}
	vector<long long int>box;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j <= N; j++) {
			box.push_back(v[j] - v[i]);
		}
	}
	long long int num = 0;
	for (int i = 50; i >= 0; i--) {
		num += 1LL << i;
		int cnt = 0;
		for (auto j : box) {
			if ((num&j)==num) cnt++;
		}
		if (cnt < K) num -= 1LL << i;
	}
	cout << num << endl;
}


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

using R = long double;
const R EPS = 1e-10;
int sgn(const R &x) {return (x > EPS) - (x < -EPS);}
using P = complex<R>;
const P O = P(0, 0);
using L = struct {P s, t;};
using VP = vector<P>;

auto & operator >>(istream& is, P &p) {R x, y; is >> x >> y; p =P(x,y); return is;}

inline R dot(P o, P a, P b) {return real(conj(a - o) * (b - o));}
inline R det(P o, P a, P b) {return imag(conj(a - o) * (b - o));}
inline int sdot(P o, P a, P b) {return sgn(dot(o, a, b));}
inline int sdet(P o, P a, P b) {return sgn(det(o, a, b));}

bool parallel(L a,L b){return sdet(O,a.t-a.s,b.t-b.s)==0;}

bool iss(L a, L b) {
	int sa = sdet(a.s, a.t, b.s) * sdet(a.s, a.t, b.t);
	int sb = sdet(b.s, b.t, a.s) * sdet(b.s, b.t, a.t);
	return max(sa, sb) < 0;
}

P cross(L a, L b) {
	R u = det(a.s, b.s, b.t) / det(O, a.t - a.s, b.t - b.s);
	return (1 - u) * a.s + u * a.t;
}

bool in_polygon(const VP &pol, const P &p) {
	const int n = pol.size();
	int res = 0;
	rep(i, n) {
		P a = pol[i], b = pol[(i + 1) % n];
		bool f = sgn(imag(p - a)) >= 0, s = sgn(imag(p - b)) < 0;
		if (sgn(imag(b - a))*sdet(a, b, p) == 1 and f == s) res += 2 * f - 1;
	}
	return res > 0;
}

int main(void) {
	int n, m;
	cin >> n >> m;
	VP pol[20];

	rep(i, n) {
		int l;
		cin >> l;
		pol[i] = VP(l);
		rep(j, l) cin >> pol[i][j];
	}

	VP cand(m);
	rep(i, m) cin >> cand[i];

	vector<L> lines;
	rep(i, m) rep(j, n) for (auto &p : pol[j]) lines.push_back(L{cand[i], p});

	const int k = lines.size();

	vector<P> points;
	rep(j, k)rep(i, k) if(!parallel(lines[i],lines[j])) points.push_back(cross(lines[i], lines[j]));

	vector<L> obj;
	rep(i, n) {
		const int l = pol[i].size();
		rep(j, l) obj.push_back(L{pol[i][j], pol[i][(j + 1) % l]});
	}

	int ans = 0;
	for (auto &tar : points) {
		rep(i, n) if (in_polygon(pol[i], tar)) continue;

		int cur = 0;

		rep(i, m) {
			L seg = L{tar, cand[i]};
			bool ok = true;
			for (auto &seg2 : obj) if (iss(seg, seg2)) ok = false;
			if (ok) cur++;
		}

		ans = max(ans, cur);
	}

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

Measured memory_bytes: 4020
K = int(input())
X, Y = map(int,input().split())

if K%2 == 0 and (X+Y)%2:
    print(-1)
    exit(0)

def next(x,y):
    if x < 0:
        dx, dy = next(-x, y)
        return -dx, dy
    if y < 0:
        dx, dy = next(x, -y)
        return dx, -dy
    if x < y:
        dx, dy = next(y, x)
        return dy, dx
    if x + y == K:
        return x, y
    if x + y <= K * 2 and (x + y) % 2 == 0:
        return (x + y)//2, (x + y)//2 - K
    return K, 0

x, y = 0,0
ans = list()
while x != X or y != Y:
    dx, dy = next(X - x, Y - y)
    x += dx; y += dy
    ans.append((x, y))

print(len(ans))
for x, y in ans:
  print(x, y)


Measured memory_bytes: 32664
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    string S;
    cin >> S;
    for (int i = 0; i < S.length(); i++) {
        S[i] = (S[i] + N - 'A') % 26 + 'A';
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
string s;
int p, q, r;
int pos;
int get_val(int x, int y, char op)
{
    int res;
    if(op == '*') res = min(x, y);
    else res = max(x, y);
    return res;
}
int Solve()
{
    char op = '#';;
    if(s[pos] == '(') 
    {
        pos++;
        int A = Solve();
        char op = s[pos];
        pos++;
        int B = Solve();
        pos++;
        return get_val(A, B, op);
    }
    else if(s[pos] == ')') return 0;
    else if(s[pos] == '-')
    {
        pos++;
        return 2 - Solve();
    }
    else
    {
        int num;
        if(s[pos] == 'P') num = p;
        else if(s[pos] == 'Q') num = q;
        else if(s[pos] == 'R') num = r;
        else num = s[pos] - '0';
        pos++;
        return num;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> s)
    {
        if(s == ".") break;
        int ans = 0;
        for(p = 0; p < 3; p++)
        {
            for(q = 0; q < 3; q++)
            {
                for(r = 0; r < 3; r++) 
                {
                    pos = 0;
                    if(Solve() == 2) ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}




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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}


long long X[1000100];

void solve(long long N) {
    for(int i = 1 ; i <= 1000000 ; i++){
        for(int j = 1 ; j * i <= 1000000 ; j++){
            X[i*j]++;
        }
    }

    long long ans = 0;
    for(int i = 1 ; i <= 1000000 ; i++){
        if( N >= i ) {
            ans += X[N - i];
        }
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 11468
#include <bits/stdc++.h>
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll GCD(ll a, ll b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

ll LCM(ll a, ll b)
{
    return a * b / GCD(a, b);
}

vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll 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()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    ll sum = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    auto kouho = divisor(sum);
    ll ans = 0;
    for (auto p : kouho)
    {
        vector<ll> r(n);
        ll t = 0;
        for (ll i = 0; i < n; i++)
        {
            r[i] = (a[i] % p);
            t += r[i];
        }
        sort(ALL(r));
        ll c = 0;
        for (ll i = 0; i < n - (t / p); i++)
        {
            c += r[i];
        }
        if (c <= k)
        {
            chmax(ans, p);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
  long a, b;
  cin >> a >> b;
  int k;
  cin >> k;
  
  for (int i = 0; i < k; ++i) {
    if (a & 1) --a;
    b += a / 2;
    a /= 2;
    swap(a, b);
  }
  
  if (k & 1) swap(a, b);
  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
N = int(input())
S = set()
prev = None
flag = 1
for _ in range(N):
    W = input()
    if W in S or (prev is not None and prev[-1] != W[0]):
        flag = 0
    prev = W
    S.add(W)
if flag:
    print("Yes")
else:
    print("No")


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

int main(){
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    for(auto &a: A)
        cin >> a;
    
    int ans = X;
    for(int i=0; i<N; i++)
        ans += (D-1)/A[i] + 1;
    
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

typedef pair<int,int> pii;

#define MAX_H 1510
#define MAX_W 1510

int H,W;
int mat[MAX_H][MAX_W];

int maximum_rectangle(){
  int res = 0,h[MAX_W] = {0};
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      h[j] = (mat[i][j] == 0 ? h[j] + 1 : 0);
    }
    stack<pii> st;
    st.push(pii(0,W));
    for(int j = 0 ; j <= W ; j++){
      int k = j;
      while(h[j] < st.top().first){
        k = st.top().second;
        res = max(res,st.top().first*(j-k));
        st.pop();
      }
      if(st.top().first < h[j]){
        st.push(pii(h[j],k));
      }
    }
  }
  return res;
}

int main(){
  cin >> H >> W;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cin >> mat[i][j];
    }
  }
  cout << maximum_rectangle() << endl;
  return 0;
}

Measured memory_bytes: 9464
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
   
using namespace std;
   
string str[2];
int s, n, t, m, lt, rt, t_w, t_t;
double p;
   
int conv(string s){
  string data[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};  
  for(int i=0;i<7;i++) if(s == data[i]) return i;
  if(s == "All") return -1;
}
   
int check(int s_w, int s_t){
  int cnt = 0;
  for(int k=0;k<m;k++){
    int f_w = s_w;
    int f_t = s_t + s;
    if(f_t >= 24 * 60){
      f_t -= 24 * 60;
      f_w = (f_w + 1) % 7;
    }
    bool f = false;
    if(t_w == -1 || (t_w == s_w && t_w == f_w)){
      if(t_t == 0){
        if(0 <= s_t && s_t < 24 * 60 && 0 <= f_t && f_t < 24 * 60) f = true;
      }
      if(t_t == 1){
        if(6 * 60 <= s_t && s_t < 18 * 60 && 6 * 60 <= f_t && f_t < 18 * 60) f = true;
      }
      if(t_t == 2){
        if(((18 * 60 <= s_t && s_t < 24 * 60) || (0 <= s_t && s_t < 6 * 60))
           && ((18 * 60 <= f_t && f_t < 24 * 60) || (0 <= f_t && f_t < 6 * 60))) f = true;
      }
    }
    if(f) cnt++;
    s_t += t;
    if(s_t >= 24 * 60){
      s_t -= 24 * 60;
      s_w = (s_w + 1) % 7;
    }
  }
  return cnt;
}
   
main(){
  while(cin >> s >> n >> t >> str[0] >> str[1] >> p >> m && (s|n|t|m) && str[0] != "None" && str[1] != "None"){
    t_w = conv(str[0]);
    if(str[1] == "All") t_t = 0;
    if(str[1] == "Day") t_t = 1;
    if(str[1] == "Night") t_t = 2;
    double ans = 0.0;
    for(int i=0;i<7;i++){
      for(int j=0;j<24*60;j++){
        int cnt = check(i, j);
        ans = max(ans, 1.0 - pow((p - 1.0) / p, n * cnt));
      }
    }
    printf("%.10f\n", ans);
  }
}

Measured memory_bytes: 1296
s = gets.chomp
f = true
s.size.times{|i|
  if (i%2==0 && s[i]!="h") || (i%2==1 && s[i]!="i")
    f = false
    break
  end
}

puts (s.size%2==0 && f)? "Yes" : "No"


Measured memory_bytes: 1788
package main

import (
	"fmt"
)

func main() {
	var (
		fhy, hy, fy, sum, count int
	)
	fmt.Scan(&fhy, &hy, &fy, &sum)
	for i := 0; i < fhy+1; i++ {
		for j := 0; j < hy+1; j++ {
			for k := 0; k < fy+1; k++ {
				if i*500+j*100+k*50 == sum {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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


	cin >> N;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	int box = 0;
	for (auto i : v)box ^= i;
	if (box) {
		cout << "No\n";
		return 0;
	}
	map<int, int>m;
	for (auto i : v)m[i]++;
	if (m.size() == 1) {
		if (v[0]) {
			cout << "No\n";
			return 0;
		}
		cout << "Yes\n";
		return 0;
	}
	if (m.size() > 3) {
		cout << "No\n";
		return 0;
	}
	if (m.size() == 3) {
		vector<int>a;
		for (auto i : m) {
			a.push_back(i.first);
			if (i.second * 3 != N) {
				cout << "No\n";
				return 0;
			}
		}
		if (a[0] ^ a[1] == a[2]) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
		return 0;
	}
	vector<int>a;
	for (auto i : m) {
		a.push_back(i.first);
		if ((i.second * 3) % N) {
			cout << "No\n";
			return 0;
		}
	}
	if (m[a[0]] > m[a[1]]) {
		if (a[1]) {
			cout << "No\n";
			return 0;
		}
	}
	else {
		if (a[0]) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 640
def combnk_mod(n, k, p):
    # pが素数かつaとpが互いに素であるとき
    # フェルマーの小定理より以下が成り立つ.
    # 1 / a = a ** (p - 2) (mod p)
    # これを使って (1 / k!) mod p を計算する.

    if  2 * k > n:
        k = n - k
    x = 1 # 分母にあたる数 1 / n! mod p
    y = 1 # 分子にあたる数. n! / (n - k)! mod p
    for i in range(1, k + 1):
        x *= pow(i, p - 2, p)
        y *= n - i + 1
        x %= p
        y %= p
    return (x * y) % p

MOD = 10 ** 9 + 7
x, y = map(int, input().split())
m = 2 * x - y
n = 2 * y - x
if m < 0 or n < 0:
    ans = 0
elif m % 3 > 0 or n % 3 > 0:
    ans = 0
else:
    m = m // 3
    n = n // 3
    ans = combnk_mod(m + n, min(m, n), MOD)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n;
	vector<int> a;
	cin >> n;
	if(n == 0)break;
	REP(i,n) {
	    int temp;
	    cin >> temp;
	    a.PB(temp);
	}
	int oha = 32;
	int i = 0;
	while(oha > 0){
	    oha -= (oha-1)%5;
	    if(oha > 0)
		cout << oha << endl;
	    oha -= a[i%n];
	    i++;
	    if(oha > 0)
		cout << oha << endl;
	}
	cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int a, b, c, d;
    scanf("%d%d%d%d",&a, &b, &c, &d);
    printf("%s\n", (abs(c-a) <= d) || ((abs(b-a) <= d) && (abs(c-b) <= d)) ? "Yes" : "No");
    return 0; 
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
using namespace std;

int H,W;
const int MAX_H = 111;
int c[MAX_H][MAX_H];

int N;
const int MAX_N = 10010;
int a[MAX_N];



int main(){
	scanf("%d%d",&H,&W);
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
	}

	for(int i=0,k=0;i<H;i++){
		int s = i%2 ? W-1 : 0;
		int e = i%2 ? -1 : W;
		int sgn = i%2 ? -1 : 1;
		for(int j=s;j!=e;j+=sgn){
			c[i][j] = k+1;
			a[k]--;
			if(a[k]==0)k++;
		}
	}

	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			printf("%d ",c[i][j]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

const int mod = 1000000007;

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

  string s;
  cin >> s;

  int n = s.length();
  int k;

  cin >> k;

  rep(i, n) {
    if(s[i] == 'a') continue;
    int cnt = 26-(s[i]-'a');
    if(cnt <= k) {
      s[i] = 'a';
      k -= cnt;
    }
  }

  s[n-1] = (s[n-1] - 'a' + k) % 26 + 'a';

  cout << s << endl;
}


Measured memory_bytes: 888
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    double ans = 0;
    rep(i, n){
        double x;
        cin >> x;
        ans += 1.0 / x;
    }
    cout << fixed << setprecision(10) << 1.0 / ans << endl;

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/



/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n,k,q; cin >>n>>k>>q;
    
    vi ok(n+1);
    rep2(i,1, q+1){
        int p;
        cin >> p;
        ok[p]++;
    }
    rep2(i,1,n+1){
        cout << (q -ok[i] < k ? "Yes": "No") <<endl;
    }   
}


Measured memory_bytes: 1024
n = int(input())
a = [int(input()) for _ in range(n)]
a1 = sorted(a)
if a1[n-1]==a1[n-2]:
  flag = True ## true = have repeat
  maxone = a1[n-1]
else:
  flag = False ## false = no repeat
  maxone = a1[n-1]
  maxtwo = a1[n-2]
for i in range(n):
  if a[i]==maxone and flag==True: print(maxone)
  elif a[i]==maxone and flag==False: print(maxtwo)
  elif a[i]!=maxone: print(maxone)


Measured memory_bytes: 14112
#include <cstdio>
int abs(int x) {
    return x > 0 ? x : -x;
}
int n, x[102], y[102], l[102], stdPoint, ansx, ansy, h;
bool check(){
    for(int i=1;i<=n;i++){
        int t=h-abs(ansx-x[i])-abs(ansy-y[i]);
        if(t<0)t=0;
        if(l[i]!=t)return false;
    }
    return true;
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d%d%d", &x[i], &y[i], &l[i]);
        if (l[i])
            stdPoint = i;
    }
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            ansx = i, ansy = j;
            h = l[stdPoint] + abs(x[stdPoint] - i) + abs(y[stdPoint] - j);
            if (check()){
                printf("%d %d %d\n",ansx,ansy,h);
                return 0;
            }
        }
    }
    return 0;
}

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

int main(void){
    ll n;
    cin >> n;
    vector<ll>box(n+1);
    vector<ll>ans(n+1);
    for(int i=1;i<=n;i++){
        cin >> box[i];
    }

    for(int i=n;1<=i;i--){
        ll sum = 0, k = 1,j = i;
        while(j*k<=n){
            sum += ans[j*k];
            k++;
        }
        if(sum%2 != box[i]){
            ans[i] = 1;
        }else{
            ans[i] = 0;
        }
    }

    // for(int j=1;j<=n;j++){
    //     cout << ans[j] <<' ';
    // }
    // cout << endl;

    ll cnt = accumulate(ans.begin(),ans.end(),0);
    cout << cnt << endl;
    bool flag = false;
    for(int i=1;i<=n;i++){
        if(ans[i]==1){
            if(flag){
                cout << ' ';
            }
            flag = true;
            cout << i;
        }
    }
    cout << endl;
    return 0;
}

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

//typedef
//------------------------------------------
typedef int64_t LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define EACH(i,c) for(decltype((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) whole(sort, c)
#define RSORT(c) rwhole(sort, c)

//constant
//--------------------------------------------
constexpr double EPS = 1e-10;
constexpr double PI  = M_PI;
constexpr int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}
template<class T,class U> void chmin(T&a,U b){if(b<a)a=b;}
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;}

//main code

int main(int argc, char *argv[])
{
	LL n;
	cin >> n;
	VL p(n);
	cin >> p;
	int m = p[0];
	int ans = 1;
	for (int i = 1; i < n; i++) {
		if (p[i] < m) {
			m = p[i];
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
  char ha[1<<21],k[256];
int main(int argc,char *argv[]){
  int flg;
  int val,s,t;
  char c;
  k['T'] = 1;
  k['G'] = 2;
  k['C'] = 3;
  k['A'] = 4;
    
  scanf("%d", &val);
  getchar();
  while (val--) {
    s = 0;
    t = 1;
    flg = ( c = getchar() ) == 'i';
    while ( ( c = getchar() ) != ' ' );
    while ( ( c = k[getchar()] ) != 0 ) {
      s += c * t;
      t *= 4;
    }
    if (flg) ha[s] = 1; else puts( ha[s] ? "yes" : "no" );
  }
  return 0;
}

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

using namespace std;

#define MAX 110
typedef pair<char,int> P;

bool check(int ant[MAX],int L){
  for(int i = 0 ; i < L ; i++){
    if(ant[i] != 0) return false;
  }
  return true;
}

int main(){
  int N,L,p;
  char d;
  while(cin >> N >> L, N){
    int ant[MAX]={0};
    vector<int> tunnel[MAX],id[MAX];
    L--;
    for(int i = 0 ; i < N ; i++){
      cin >> d >> p;
      ant[p-1]++;
      id[p-1].push_back(i+1);
      tunnel[p-1].push_back((d == 'L' ? 1 : 2));
    }
    int t = 0,last;
    while(!check(ant,L)){
      vector<int> next[MAX],nid[MAX];
      last = -1;
      for(int i = 0 ; i < L ; i++){
        next[i].clear();
        nid[i].clear();
        if(ant[i] && last == -1){
          last = id[i][0];
        }
      }
      for(int i = 0 ; i < L ; i++){
        while(tunnel[i].size()){
          if(tunnel[i][0] == 1){
            tunnel[i].erase(tunnel[i].begin());
            if(i-1 >= 0){
              next[i-1].push_back(1);
              nid[i-1].push_back(id[i][0]);
              id[i].erase(id[i].begin());
            }
          }else if(tunnel[i][0] == 2){
            tunnel[i].erase(tunnel[i].begin());
            if(i+1 < L){
              next[i+1].push_back(2);
              nid[i+1].push_back(id[i][0]);
              id[i].erase(id[i].begin());
            }
          }
        }
      }
      for(int i = 0 ; i < L ; i++){
        tunnel[i] = next[i];
        id[i] = nid[i];
        if(tunnel[i].size() == 2){
          swap(tunnel[i][0],tunnel[i][1]);
        }
        ant[i] = tunnel[i].size();
      }
      t++;
    }
    cout << t << " " << last << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
import copy

N, M = map(int, input().split())
c = [0]
c += list(map(int, input().split()))
memo = [N] * (N+1)
flag = [False] * (N+1)
flag[0] = True
memo[0] = 0

for i in range(1, N+1):
    if not flag[i]:
        flag[i] = True
        for j in range(1, M+1):
            if i >= c[j]:
                memo[i] = min(memo[i], memo[i-c[j]] + 1)

print(memo[N])



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

int main()
{
    ll ans = 1;
    ll mx = 1e18;
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            cout << '0' << endl;
            return 0;
        }
    }
    rep(i, n)
    {
        if (mx / ans < a[i])
        {
            cout << "-1" << endl;
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4004
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, a;
   set<int> s;
   string ans = "YES";
   cin >> n;
   FOR(i, 0, n)
   {
      cin >> a;
      s.insert(a);
   }
   if(s.size() < n)
      ans = "NO";
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 9600
#include <cstdio>
#include <algorithm>
using namespace std;
int n,m,x;
int c[15],a[15][15],b[15],d[15],len,sum=100000000,cost;
void init(){//数据读取
	int i,j;
	scanf("%d%d%d",&n,&m,&x);
	for(i=1;i<=n;i++){
		scanf("%d",&c[i]);
		for(j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	}
}
void dfs(int step){
	int i,j,k;
	if(step==len+1){//深搜结束条件
		for(k=1;k<=m;k++)d[k]=0;//d[k]表示被选择的书店，在k列位置上的和
		for(j=1;j<=len;j++)
			for(k=1;k<=m;k++)
				d[k]+=a[b[j]][k];//计算被选择的书店，在k列位置上的和
		for(k=1;k<=m;k++)
			if(d[k]<x)return;//不满足条件
		cost=0;
		for(j=1;j<=len;j++)cost+=c[b[j]];//计算花费
		sum=min(sum,cost);//找最小值
		return ;
	}
	for(i=b[step-1]+1;i<=n;i++)//找组合情况，就让后查找的位置越来越大，请注意i=b[step-1]+1
		b[step]=i,dfs(step+1);
}
int main(){
	init();
	for(len=1;len<=n;len++)//len界定选择的书店的数量
		b[0]=0,dfs(1);
	if(sum==100000000)printf("-1\n");//没找到
	else printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 3200