akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.*;
import java.util.InputMismatchException;

public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = in.nextInt();
        long ans=1;

		for(int i=1; i<=n; i++) {
			ans *= i;
            ans = ans % 1000000007;
		}
		
		out.println(ans);
		out.flush();

	}

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

	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int next() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public char nextChar() {
			int c = next();
			while (isSpaceChar(c))
				c = next();
			if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) {
				return (char) c;
			}
			throw new InputMismatchException();
		}

		public String nextToken() {
			int c = next();
			while (isSpaceChar(c))
				c = next();
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = next();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public int nextInt() {
			int c = next();
			while (isSpaceChar(c))
				c = next();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = next();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c-'0';
				c = next();
			} while (!isSpaceChar(c));
			return res*sgn;
		}

		public long nextLong() {
			int c = next();
			while (isSpaceChar(c))
				c = next();
			long sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = next();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c-'0';
				c = next();
			} while (!isSpaceChar(c));
			return res*sgn;
		}

		public double nextDouble() {
			return Double.valueOf(nextToken());
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		//public interface SpaceCharFilter {
		//	public boolean isSpaceChar(int ch);
		//}
	}
	// template
	static int gcd(int n, int r) { return r == 0 ? n : gcd(r, n%r);  }
	static long gcd(long n, long r) { return r == 0 ? n : gcd(r, n%r);  }

	static <T> void swap(T[] x, int i, int j) { T t = x[i]; x[i] = x[j]; x[j] = t;  }
	static void swap(int[] x, int i, int j) { int t = x[i]; x[i] = x[j]; x[j] = t;  }
}


Measured memory_bytes: 21204
import itertools

N = int(input())
P_list = [int(e) for e in input().split()]
Q_list = [int(e) for e in input().split()]

seq = [i for i in range(1,N+1)]
all = list(itertools.permutations(seq))
all.sort()

for i in range(len(all)):
  check_target = list(all[i])
  if check_target == P_list:
    a = i
  if check_target == Q_list:
    b = i

print(abs(a-b))

Measured memory_bytes: 8052
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int n; cin>>n;
    vll a(n); rep(i,n)cin>>a[i];
    vll s(n+1); rep(i,n)s[i+1] = s[i]+a[i];

    ll ans = INF;
    ll sum = s[n];
    REP(i,n){
        ans = min(ans, abs(sum-2*s[i]));
    }
    cout<<ans<<endl; return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
int n, m;
int main() {
	cin >> n >> m;
	int L, R;
	L = 1, R = n;
	for (int i = 0; i < m; i++) {
		if (n%2==0&&i==n/4) { R--; }
		printf("%d %d\n", L, R);
		L++; R--;
	}
	return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <algorithm>
using namespace std;

using ll = long long;

#define FOR(i, m, n) for (ll i = m; i <= n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)

int gcd(int a, int b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
    ll N;
    cin >> N;
    ll X[110];
    FOR (i, 1, N) cin >> X[i];

    ll ans = 10000000;

    FOR (j, 1, 100) {
        ll S = 0;

        FOR (i, 1, N) {
            S += (X[i] - j) * (X[i] - j);
        }
        
        if (ans > S) ans = S;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 101
#define WHITE -1
#define GRAY 0
#define BLACK 1

int n,t;
int color[MAX],d[MAX],f[MAX],Adj[MAX][MAX];

dfs(){
  int i;

  for(i=0;i<n;i++) color[i]=WHITE;
  t=0;
  for(i=0;i<n;i++){
    if(color[i]==WHITE) visit(i);
  }
}

visit(int r){
  int i;

  color[r]=GRAY;
  d[r]=++t;

  for(i=0;i<n;i++){
    if(Adj[r][i]==1 && color[i]==WHITE) visit(i);
  }

  color[r]=BLACK;
  f[r]=++t;
}

int main(){
  int i,u,k,j,v;

  for(i=0;i<MAX;i++){
    for(j=0;j<MAX;j++){ 
      Adj[i][j]=0;
    }
  }

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      Adj[u-1][v-1]=1;
    }
  }

  dfs();

  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }

  return 0;
}

Measured memory_bytes: 640
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int s = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s += a[i];
    }
    sort(all(a));
    reverse(all(a));
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] >= ((ld)s/(4.0*m))) cnt++;
    }
    if (cnt >= m) cout << "Yes\n";
    else cout << "No\n";
}
/*
*/


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		char s[] = in.readString().toCharArray(); 
		int one = 0;
		int zero = 0; 
		for(int i=0; i<s.length; i++) {
			if(s[i] == '1') one++; 
			else zero++; 
		}
		System.out.println(2*Math.min(one, zero)); 
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pii>;
#define all(x) (x).begin(), (x).end()
#define pb push_back

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi id(n);
    if (n%2==0) {
        for (int l=1, r=n, i=1; l<=r; l++, r--, i++) {
            id[l-1] = id[r-1] = i;
        }
    }
    else {
        vvi pairs;
        pairs.pb(vi{n});
        for (int l=1, r=n-1; l<r; l++, r--)
            pairs.pb(vi{l, r});
        for (int i=0; i<(int)pairs.size(); i++) {
            for (int x:pairs[i]) {
                id[x-1] = i + 1;
            }
        }
    }
    vpii edges;
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            if (id[i] != id[j]) {
                edges.pb(pii(i+1, j+1));
            }
        }
    }
    vi sum(n);
    for (pii p : edges) {
        sum[p.first-1] += p.second;
        sum[p.second-1] += p.first;
    }
    assert(set<int>(all(sum)).size()==1);

    cout << edges.size() << '\n';
    for (pii p : edges) {
        cout << p.first << ' ' << p.second << '\n';
    }
}


Measured memory_bytes: 384
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 1000010
using namespace std;
struct node{
    ll a;
    ll b;
}s[1000000];
int cmd(node x , node y){
    return x.b>y.b;
}
int main()
{
	int n,h;
	cin >>n>>h;
	ll ma=0,num=0;
	for(ll i=0;i<n;i++){
        cin >>s[i].a>>s[i].b;
        ma = max(ma,s[i].a);
	}
	sort(s,s+n,cmd);
	ll sum =0;
	for(int i=0;i<n;i++){
        if(sum>=h)
            break;
        if(ma<s[i].b){
            sum+=s[i].b;
            num++;
        }
	}
    if(sum>=h)
        cout<<num<<endl;
    else {
        double k =(double)(h-sum)/(double)ma;
        num+=ceil(k);
        cout<<num<<endl;
    }
	return 0;
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

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

const int MOD = 1e9 + 7;
const int INF = INT_MAX / 2;

vector<int> bfs(int N, vector<vector<int> >& G, int s) {
	vector<int> d(N, INF); d[s] = 0;
	queue<int> q; q.push(s);
	while (q.size()) {
		int u = q.front(); q.pop();
		for (int v : G[u])
			if (d[v] > d[u] + 1) {
				d[v] = d[u] + 1;
				q.push(v);
			}
	}
	return d;
}

int main() {
	int N; cin >> N;
	vector<vector<int> > G(N);
	rep(i, N - 1) {
		int u, v; scanf("%d%d", &u, &v);
		u--, v--;
		G[u].pb(v), G[v].pb(u);
	}
	vector<int> d1 = bfs(N, G, 0);
	vector<int> d2 = bfs(N, G, N - 1);
	int n1 = 0, n2 = 0;
	rep(u, N) if (d1[u] <= d2[u]) n1++; else n2++;
	cout << (n1 > n2 ? "Fennec" : "Snuke") << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  //a_bはaをb回
  int a_b = 0;
  int b_a = 0;
  for(int i = 0; i < b; i++){
    a_b += a * pow(10,i) ;
  }
  for(int i = 0; i < a; i++){
    b_a += b * pow(10,i) ;
  }
  cout << max(a_b,b_a);
}

Measured memory_bytes: 384
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long double Ld;

using namespace std;
template <class T>
using Graph = vector<vector<T>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

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

template <typename T>
inline T Gcd(T a, T b) {
    T c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

Int Lcm(Int a, Int b) {
    if (a < b) {
        swap(a, b);
    }

    return a / Gcd(a, b) * b;
}

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

    int n, m;
    cin >> n >> m;
    set<pair<int, int>> s;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        s.insert({a, b});
    }

    m = s.size();
    Graph<int> G(n);
    vector<bool> seen(n, false);
    for (auto [a, b] : s) {
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (seen[i]) {
            continue;
        }

        int tsize = 1;
        queue<int> que;
        que.push(i);
        seen[i] = true;
        while (!que.empty()) {
            int v = que.front();
            que.pop();

            for (auto nv : G[v]) {
                if (!seen[nv]) {
                    que.push(nv);
                    seen[nv] = true;
                    tsize++;
                }
            }
        }

        chmax(ans, tsize);
    }

    cout << ans << endl;

    return 0;
}


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

int main(){

    string n;
    cin >> n;
    int s=n.size();
    int d[s];
    ll su=0;

    rep(i,s){
        d[s-i-1]=n[i]-'0';
        su+=d[s-i-1];
    }
    ll num=0;
    ll t=1;
    rep(i,s){
        num+=(t*d[i]);
        t*=10;
    }
    if(num%su==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,k; cin >> n >> k;
  vi sieve(10);
  rep(i,k){
    int d; cin >> d;
    sieve[d] = -1;
  }
  vi num;
  rep(i,10) if(sieve[i] != -1) num.push_back(i);
  queue<int> q;
  for(int a : num) if(a != 0) q.push(a);
  while(1){
    int x = q.front(); q.pop();
    if(n <= x){
      cout << x;
      return 0;
    }
    for(int a : num) q.push(10*x+a);
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {

            int n, a, b, p1, p2,  x;

            var word = Console.ReadLine().Split(' ');

			n = int.Parse(word[0]);
			a = int.Parse(word[1]);
			b = int.Parse(word[2]);

			if (a * n < b)
				x = a * n;
			else
				x = b;



			Console.WriteLine(x);

            Console.ReadKey();


        }
    }
}


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

int N, M, answer;
pair<int, int> jobs[MAXN + 3];

int main() {
    cin >> N >> M;
    for (int i = 1; i <= N; i++) {
        int a, b;
        cin >> a >> b;

        jobs[i] = {a, b};
    }

    sort(jobs + 1, jobs + N + 1);

    answer = 0;
    priority_queue<int> pq;

    int ptr = 0;
    for (int day = M; day >= 0; day--) {
        while (ptr <= N && jobs[ptr].first <= M - day) {
            pq.push(jobs[ptr].second);
            ptr += 1;
        }

        if (!pq.empty()) {
            answer += pq.top();
            pq.pop();
        }
    }

    cout << answer << endl;
}


Measured memory_bytes: 1660
import itertools
N = int(input())
S = input()
mod = 10**9 + 7
count = [1] * 26
for i in range(N):
    count[ord(S[i]) - 97] += 1
print((list(itertools.accumulate(count, lambda x, y: x * y % mod))[-1] - 1) %
      mod)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

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

Measured memory_bytes: 4060
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<ll, ll> P;
struct edge {
 ll to;
 ll cost;
 ll id;
};
vector<edge> G[100010];
 
int main() {
    ll n,m;
    std::cin >> n>>m;
    
    ll id = 0;
    
    for (int i = 0; i < m; i++) {
        ll tmpa,tmpb,tmpc;
        std::cin >> tmpa>>tmpb>>tmpc;
        tmpa--;
        tmpb--;
        G[tmpa].push_back({tmpb,tmpc,id});
        G[tmpb].push_back({tmpa,tmpc,id});
        id++;
    }
    
    ll d[101][101];
    Fill(d,1e10);
    
    // iからjまで
    for (int i = 0; i < n; i++) {
        d[i][i] = 0;
        priority_queue<P, vector<P>, greater<P> > que;
        que.push(P(0, i));
        
        while (!que.empty()) {
             P p = que.top();
             que.pop();
             ll v = p.second;
             if (d[i][v] < p.first) continue;
        	for (int j=0; j<G[v].size(); ++j) {
        	    edge e = G[v][j];
                if (d[i][e.to] > d[i][v] + e.cost) {
                    d[i][e.to] = d[i][v] + e.cost;
                    que.push(P(d[i][e.to], e.to));
                }
             }
         }

    }
    bool used[1100];
    Fill(used,false);
    ll result = 0;
    for (int i = 0; i < n; i++) {
        // for (int j = i+1; j < n; j++) {
            for (int k = 0; k < n; k++) {
                for (auto e : G[k]) {
                    // // if(k>=e.to || i==k || i == e.to)continue;
                    // std::cout << i<<" "<<k <<" "<<e.to << std::endl;
                    // std::cout << d[i][k]<<" "<<e.cost<< " "<<d[i][e.to] << std::endl;
                    // std::cout << "" << std::endl;
                    if(d[i][k]+e.cost == d[i][e.to]){
                        used[e.id] = true;
                    }
                }
            }
    }
    
    for (int i = 0; i < m; i++) {
        if(!used[i]){
            result++;
            // std::cout << i << std::endl;
        }
        
    }
    std::cout <<  result<< std::endl;
}


Measured memory_bytes: 2816
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

// template<typename T>
// void remove(std::vector<T>& vector, unsigned int index)
// {
//     vector.erase(vector.begin() + index);
// }

int main() {
    int K, N;
    cin >> N >> K;

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

    vector<int> v(N);
    for(int i=0; i<N; ++i) {
        ++v[A[i]-1];
    }

    // for(auto e :v) cout << e << " " ; cout << endl;

    sort(v.begin(), v.end(), greater<int>());

    int sum = 0;
    for (int i=0; i<K; ++i) {
        sum += v[i];
    }

    // while(v.size() > K) {
    //     // cout << v.size() << " " << K << endl;
    //     cnt += v[0];
    //     remove(v, 0);
    // }
    cout << N - sum << endl;
}

Measured memory_bytes: 1792
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

int main(void){
	int N;
	int pos;
	string s;
	cin >> N;
	cin.ignore();
	for(int i=0; i<N; ++i){
		getline(cin, s);
		while(1){
			pos = s.find("Hoshino");
			if(pos == -1) break;
			s[pos+6] = 'a';
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

class SegmentTree(object):
    def __init__(self, A, dot, unit):
        n = 1 << (len(A) - 1).bit_length()
        tree = [unit] * (2 * n)
        for i, v in enumerate(A):
            tree[i + n] = v
        for i in range(n - 1, 0, -1):
            tree[i] = dot(tree[i << 1], tree[i << 1 | 1])
        self._n = n
        self._tree = tree
        self._dot = dot
        self._unit = unit

    def __getitem__(self, i):
        return self._tree[i + self._n]

    def update(self, i, v):
        i += self._n
        self._tree[i] = v
        while i != 1:
            i >>= 1
            self._tree[i] = self._dot(self._tree[i << 1], self._tree[i << 1 | 1])

    def add(self, i, v):
        self.update(i, self[i] + v)

    def sum(self, l, r):
        l += self._n
        r += self._n
        l_val = r_val = self._unit
        while l < r:
            if l & 1:
                l_val = self._dot(l_val, self._tree[l])
                l += 1
            if r & 1:
                r -= 1
                r_val = self._dot(self._tree[r], r_val)
            l >>= 1
            r >>= 1
        return self._dot(l_val, r_val)

def resolve():
    h, w, m = map(int, input().split())
    A = [[] for _ in range(h)]
    tree = SegmentTree([0] * w, max, 0)
    for _ in range(m):
        i, j = map(int, input().split())
        i -= 1; j -= 1
        A[i].append(j)
        tree.add(j, 1)

    ans = 0
    for i in range(h):
        for j in A[i]:
            tree.add(j, -1)
        ans = max(ans, len(A[i]) + tree.sum(0, w))
        for j in A[i]:
            tree.add(j, 1)

    print(ans)
resolve()

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

using namespace std;
using ll = long long;

int main() {
  ll money = 100;
  ll X;
  cin >> X;
  ll count = 0;
  while (money < X) {
    money = money + money / 100;
    count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3608
# union-findかな
# 蟻本によればunion-findは分割できないっぽいので、ちょっと違う? 
# 時刻を巻き戻して、橋なしから橋を建設することにすれば扱える

# 橋が崩落してA+B　がAとBに分かれたら、不便度はA*B増加する

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

def find_root(x):
	if par[x] == x:
		return x
	else:
		par[x] = find_root(par[x])
		return par[x]

def unite(x, y):
	x = find_root(x)
	y = find_root(y)
	if(x == y):
		return 0

	if rank[x] < rank[y]:
		par[x] = y

		temp = size[x] * size[y]
		size[y] = size[x] + size[y]
	else:
		par[y] = x
		if (rank[x] == rank[y]):
			rank[x] += 11

		temp = size[x] * size[y]
		size[x] = size[x] + size[y]
	return temp

def is_same(x,y):
	return find_root(x) == find_root(y)

# par = [0]*n
par = list(range(n))
rank = [0]*n
size = [1]*n

edges = [list(map(int, input().split()))[0:2] for _ in range(m)]
edges = [[b[0]-1, b[1]-1] for b in edges] #1-idx -> 0-idx

for b in range(m):
	unite(edges[b][0] , edges[b][1])

# print(par)
# print(len(set(par)))

arr = [0] * n
for i in range(n):
	arr[i] = find_root(i)

print(len(set(arr)))


Measured memory_bytes: 42164
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4
0 1 2
1 2 1
1 3 3

output:
5
"""

import sys
from math import isinf
from collections import deque


def generate_adj_table(v_table, init_adj_table):
    for each in v_table:
        source, target, cost = map(int, each)
        init_adj_table[source][target] = cost
        init_adj_table[target][source] = cost

    return init_adj_table


def graph_bfs(current, v_num, adj_table):
    queue = deque()
    distance = [float('inf')] * v_num
    distance[current] = 0
    queue.appendleft(current)

    while queue:
        current = queue.popleft()
        for adj, cost in adj_table[current].items():
            if isinf(distance[adj]):
                distance[adj] = distance[current] + cost
                queue.append(adj)
    return distance


def calc_tree_diameter(v_num, adj_table):
    # init x(random node) -> bridge vertex
    init_v = 0
    distance_1 = graph_bfs(init_v, v_num, adj_table)
    d1, bridge_v = 0, 0
    for v, each in enumerate(distance_1):
        if isinf(each):
            continue
        elif d1 < each:
            d1 = each
            bridge_v = v

    # bridge vertex -> y
    distance_2 = graph_bfs(bridge_v, v_num, adj_table)
    d2 = 0
    for each in distance_2:
        if isinf(each):
            continue
        d2 = max(d2, each)

    return d2


def solve():
    _input = sys.stdin.readlines()
    v_num = int(_input[0])
    edges = map(lambda x: x.split(), _input[1:])

    init_adj_table = tuple(dict() for _ in range(v_num))
    adj_table = generate_adj_table(edges, init_adj_table)
    ans = calc_tree_diameter(v_num, adj_table)
    print(ans)
    return None


if __name__ == '__main__':
    solve()

Measured memory_bytes: 63092
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>

using namespace std;

int gcd(int a, int b){
  return b ? gcd(b, a%b) : a;
}
int main(int argc, const char * argv[]) {
  
  // input from txt （提出時にこの箇所は削除すること）
  std::ifstream in("input.txt");
  std::cin.rdbuf(in.rdbuf());
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int64_t n;
  cin >> n;
  vector<int> a(n+1);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    a[i+1] = gcd(a[i],a[i+1]);

  }
  cout << a[a.size()-1] << endl;
  return 0;
}


Measured memory_bytes: 640
def main():
    import sys
    input = sys.stdin.buffer.readline
    N,M,T,P = (int(i) for i in input().split())
    answer = []
    while not(N == M == T == P == 0):
        DC = [[int(i) for i in input().split()] for _ in range(T)]
        XY = [[int(i) for i in input().split()] for _ in range(P)]
        rec = [[0]*(32**2+1) for _ in range(32**2+1)]
        for y in range(M):
            for x in range(N):
                rec[y][x] += 1
        ori_x,ori_y = 0,0
        for d,c in DC:
            if d == 1:
                ori_x += c
                for y in range(ori_y,32**2+1):
                    for x in range(ori_x,ori_x+c):
                        # print(M,y,ori_x*2-x-1, ori_x,x)
                        rec[y][x] += rec[y][ori_x*2-x-1]
            else:
                ori_y += c
                for y in range(ori_y,ori_y+c):
                    for x in range(ori_x,32**2+1):
                        rec[y][x] += rec[ori_y*2-y-1][x]
        for px,py in XY:
            answer.append(rec[ori_y+py][ori_x+px])

        N,M,T,P = (int(i) for i in input().split())
    for a in answer:
        print(a)
if __name__ == "__main__":
    main()












Measured memory_bytes: 22240
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
cnt = 0
ans = [abs(i) for i in a]
s = sum(ans)
mm = min(ans)

for i in a:
  if i < 0:
    cnt += 1

if mm == 0 or cnt%2 == 0:
  print(s)
else:
  print(s-mm*2)

Measured memory_bytes: 14412
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<ll, ll> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}



int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("settling.in", "r", stdin);
	// freopen("settling.out", "w", stdout);

	int n;
	string s;
	cin >> n >> s;

	vector<int> r, w;

	for(int i = 0; i < n; i++){
		if(s[i] == 'W')
			w.push_back(i);
		else
			r.push_back(i);
	}

	if(w.empty() || r.empty()){
		cout << 0 << endl;
		return 0;
	}

	int p1 = 0, p2 = (int)r.size() - 1, ans = 0;
	while(p1 < w.size() && p2 >= 0 && w[p1] < r[p2]){
		ans++;
		p1++;
		p2--;
	}

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


Measured memory_bytes: 4756
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

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

const long long INF = LONG_MAX;
long long N,X,ans;
long long x[200020],cum[200020];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    ans = INF;
    cin >> N >> X;
    rep(i,N)cin >> x[i];
    rep(i,N)cum[i+1] = cum[i] + x[i];
    //cout << INF << '\n';
    for(ll k = 1;k <= N;k++){
        long long res = (k + N) * X;
        ll j = N - 1;
        ll coe = 5;
        while(j >= 0){
            if(coe == 5){
                long long d = cum[j+1] - cum[max(0ll,j - 2*k + 1)];
                if((double)coe > (double)INF / (double)d){
                    res = INF;
                }else{
                    if(d*coe > (INF - res)){
                        res = INF;
                    }else{
                        res += d * coe;
                    }
                }
                coe += 2ll;
                j -= 2*k;
                continue;
            }else{
                long long d = cum[j+1] - cum[max(0ll,j - k + 1)];
                if((double)coe > (double)INF / (double)d){
                    res = INF;
                }else{
                    if(d*coe > (INF - res)){
                        res = INF;
                    }else{
                        res += d * coe;
                    }
                }
                coe += 2ll;
                j -= k;
            }
        }
        ans = min(ans,res);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,k;
    cin>>n>>k;
    if (n%k==0)
        cout<<"0\n";
    else
        cout<<"1\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

struct SegmentTree {
private:
    ll n;
    vector<ll> node;

public:
    SegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }

    void update(ll x, ll val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }

    ll getmin(ll a, ll b, ll k=0, ll l=0, ll r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return node[k];

        ll vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    string s;
    cin >> n >> m >> s;
    SegmentTree seg(vector<ll> (n+1, INF));
    seg.update(n, 0);
    for(ll i=n-1;i>=0;i--){
    	if(s[i] == '0')seg.update(i, seg.getmin(i+1, min(i+m+1, n+1)) + 1);
    }

    if(seg.getmin(0, 1) >= INF) cout << -1 << endl;
    else{
    	ll ma = seg.getmin(0, 1);
    	vector<ll> dp(ma+1, INF);

    	for(ll i=0;i<=n;i++){
    		ll num = seg.getmin(i,i+1);
    		if(num <= ma){
    			dp[num] = min(dp[num], i);
    		}
    	}
    	for(int i=ma;i>0;i--){
    		cout << dp[i-1] - dp[i] << " ";
    	}
    	cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3392
#include <bits/stdc++.h>
const int inf=0x3f3f3f3f;
using namespace std;
template <typename T> void read(T &t) {
    t=0; char ch=getchar(); long long f=1;
    while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
    do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
long long n,a[100010],dp[100010],ans;
int main(){
	read(n);
	for(int i=0;i<n;i++){
		read(a[i]);
	}
	for(int i=n-2;i>=0;i--){
		if(a[i]>=a[i+1]){
			dp[i]=dp[i+1]+1;
		}
		ans=max(ans,dp[i]);
	}
	cout<<ans;
	return 0;
}


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

int main()
{
    int n;
    cin>>n;
    long long arr[n+1];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    //sort(arr,arr+n);
    int cnt=0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            for(int k=j+1; k<n; k++)
            {
                if(arr[i]!=arr[j]&&arr[j]!=arr[k]&&arr[k]!=arr[i])
                {
                    if(arr[i]+arr[j]>arr[k]&&arr[j]+arr[k]>arr[i]&&arr[i]+arr[k]>arr[j])
                    {
                        cnt++;
                    }
                }
            }
        }
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s, t;
	int n; 
	cin>>n>>s>>t;
	int cnt = 0;
	for(int i = 0; i < n; i++)
	{
		string a = s.substr(n - 1 - i, i + 1);
		string b = t.substr(0, i + 1);
		//cerr<<a<<' '<<b<<'\n';
		if(a == b)
		{
			cnt = i+1;
		}
	}
	cout<<2*n-cnt<<'\n';
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        // 入力処理
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int[] a = new int[n];
        int cnt = 0;
        int[] nums = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        for (int num : nums) {
            a[cnt] = num;
            cnt++;
        }

        Arrays.sort(a);
        int alice = 0;
        int bob = 0;
        boolean turnAlice = true;
        for (int i = n - 1; i >= 0; i--) {
            if (turnAlice) {
                alice+=a[i];
                turnAlice = false;
            } else {
                bob+=a[i];
                turnAlice = true;
            }
        }

        System.out.println(alice - bob);
    }
}


Measured memory_bytes: 27220
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	a,b,c,d = readline() |> split |> parseMap
	f = zeros(Int,10)
	f[a+1]+=1
	f[b+1]+=1
	f[c+1]+=1
	f[d+1]+=1
	if f[2]==1&&f[10]==1&&f[8]==1&&f[5]==1
		println("YES")
	else
		println("NO")
	end
end

main()

Measured memory_bytes: 167544
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}




int main(){
  int N;
  cin>>N;
  int p[N];
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  for(int i=0;i<N;i++){
    if(p[i]==i+1){
      sum++;
      int tmp=p[i];
      p[i]=p[i+1];
      p[i+1]=tmp;

    }
  }
  cout<<sum<<endl;







  

  



}


  
  


Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(void){
    int n,counts=0,l;
    cin >> n;
    for(int i=1;i<=n;i++){
        
        if(std::to_string(i).length()%2 != 0){
            counts += 1;
        }
        //cout << std::to_string(i).length()  << " " << i << endl;
    }
    cout << counts;
}


Measured memory_bytes: 888
// BROWNIE TK
 
#include <bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
 
#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
 
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define osetlli tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order

using namespace std;
 
/*STD fucntions*/
lli power(lli x,lli y,lli p)
{
    lli res=1;
    x=x%p;
    while(y>0)
    {
        if(y&1)
            res=(res*x)%p;
        //y must be even now
        y=y>>1; //y=y/2
        x=(x*x)%p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli modi(lli a,lli m)
{
// fermat little thm where m is prime
return power(a,m-2,m);
}
/*CODE BEGINS*/
int main()
{
 kira;
 lli n,k;
 cin>>n>>k;
 lli a[n];
 forz(i,n)cin>>a[i];
 lli dp[k+1]={0};
 dp[0]=0;
 for(auto x:a)dp[x]=1;
 for(int i=1;i<=k;i++)
 {
   for(auto x:a)
   {
     if(i>=x)
     {
       if(dp[i-x]==0)
       {dp[i]=1;
        break;}
     }
   }
 }
 //for(auto x:dp)p1(x);
 if(dp[k])cout<<"First";
 else cout<<"Second";
 return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; //10^9

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    vector<int> ans(N, 0);

    for(int i = 0; i < N; i++){
        ans.at(a.at(i)- 1) = i + 1;
    }
    
    for(int j = 0; j < N; j++){
        cout << ans.at(j) << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<stdbool.h>
bool linearSearch(int[],int,int);
int main(){
  int count,n,A[10000],m,z,i;
  count=0;
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&z);
    if(linearSearch(A,m,z))
      count++;
  }
  printf("%d\n",count);
  return 0;
}
bool linearSearch(int *A,int n,int key){
  int i=0;
  while(A[i]!=key){
    i++;
    if(i==n)
      return false;
  }
  return true;
}



Measured memory_bytes: 2048
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<lldo>&ar,lldo in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<lldo>&ar,lldo in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint n,ans=0,i;cin>>n;
	llint snuke=big;
	for(i=0;i<n;i++){
		llint a,b;cin>>a>>b;
		ans+=a;
		if(a>b){mineq(snuke,b);}
	}
	if(snuke==big){ans=0;}
	else{ans-=snuke;}
	cout<<ans<<endl;
	return 0;
}

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

using ll = long long;
constexpr ll inf = 1e18;

struct edge {
    int to;
    ll cost;
};

using edges = vector<edge>;
using graph = vector<edges>;

void add_edge(graph& g, int from, int to, ll cost) {
    g[from].push_back(edge{to, cost});
    g[to].push_back(edge{from, cost});
}

vector<ll> dijkstra(graph const& g, int s) {
    const int n = g.size();
    vector<ll> dist(n, inf);
    dist[s] = 0;
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> que;
    que.emplace(0, s);
    while(!que.empty()) {
        auto p = que.top();
        que.pop();
        int v = p.second;
        ll cur_d = p.first;
        if(cur_d > dist[v]) continue;
        for(auto& e : g[v]) {
            if(dist[e.to] > cur_d + e.cost) {
                dist[e.to] = cur_d + e.cost;
                que.emplace(dist[e.to], e.to);
            }
        }
    }
    return dist;
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    graph g1(n), g2(n);
    for(int i = 0; i < m; ++i) {
        int u, v;
        ll a, b;
        cin >> u >> v >> a >> b;
        add_edge(g1, u - 1, v - 1, a);
        add_edge(g1, v - 1, u - 1, a);
        add_edge(g2, u - 1, v - 1, b);
        add_edge(g2, v - 1, u - 1, b);
    }
    auto d1 = dijkstra(g1, s), d2 = dijkstra(g2, t);
    vector<ll> ans(n, inf);
    const ll total = 1e15;
    for(int i = n - 1; i >= 0; --i) {
        ans[i] = min(ans[i], d1[i] + d2[i]);
        if(i != n - 1) ans[i] = min(ans[i], ans[i + 1]);
    }
    for(int i = 0; i < n; ++i) {
        cout << total - ans[i] << endl;
    }
}


Measured memory_bytes: 26184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS; ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MX 100001
#define line cout << endl
int main()
{
    IOS;
    ll n;
    cin>>n;
    ll x;
    cin>>x;
    ll z=500*n;
    if(z>=x)cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}



//*
///*
////*
/////*
//////*
///////*
////////*
/////////*
//////////*
///////////*
////////////*
/////////////*
//////////////*
///////////////*
////////////////*
/////////////////*
//////////////////*
///////////////////*
////////////////////*
/////////////////////*


Measured memory_bytes: 256