akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

#include <array>
template<typename T>
class RollingHash {
    constexpr static int N = 3;
    array<ll, N> MOD;
    array<ll, N> Base;
    vector<ll> hash[N], pw[N];

public:
    RollingHash(T &s) {
        MOD = {{1000000007, 1000000009, 1234567891}};
        Base = {{1007, 1009, 1013}};
        int n = static_cast<int>(s.size());
        REP(i, 0, N) {
            hash[i].resize(n + 1, 0);
            pw[i].resize(n + 1, 1);
            REP(j, 0, n) {
                hash[i][j + 1] = (hash[i][j] * Base[i] + s[j]) % MOD[i];
                pw[i][j + 1] = (pw[i][j] * Base[i]) % MOD[i];
            }
        }
    }
    array<ll, N> getHash(int l, int r) {
        array<ll, N> res;
        REP(i, 0, N) {
            res[i] = (((hash[i][r] - pw[i][r - l] * hash[i][l]) % MOD[i]) + MOD[i]) % MOD[i];
        }
        return res;
    }
};

#include <set>
using D = array<ll, 3>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    RollingHash<string> rh(s);
    int ans = 0;
    int l = 0, r = n;
    while (l <= r) {
        int i = (l + r) / 2;
        set<D> st;
        bool update = false;
        REP(j, 0, n - i + 1) {
            if (j - i >= 0) {
                st.insert(rh.getHash(j - i, j));
            }

            if (st.count(rh.getHash(j, j + i))) {
                chmax(ans, i);
                update = true;
                break;
            }
        }
        if (update) {
            l = i + 1;
        }else {
            r = i - 1;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
//abc171_b.cpp
//Sun Jun 21 20:54:59 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,k;
	cin >> n >> k;

	int p[n];
	for (int i=0;i<n;i++){
		cin >> p[i];
	}

	sort(p,p+n);

	int ans = 0;
	for (int i=0;i<k;i++){
		ans += p[i];
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3628
N = int(input())
a = [int(input()) for _ in range(N)]
count = 0
i = 1
x = 0
osita = [0]*(N+1)
for b in range(N+1):
    osita[b] = i
    i = a[i-1]
    
if 2 in osita:
    print(osita.index(2))
else:
    print(-1)

Measured memory_bytes: 7852
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
int n,cnt;
ll a[15];
void dfs(int index,ll m){
    if (index==n){
        if (!(m&1))cnt++;
        return;
    }
    dfs(index+1,m*a[index+1]);
    dfs(index+1,m*(a[index+1]+1));
    dfs(index+1,m*(a[index+1]-1));
}
int main(){
    read(n);
    for (int i=1;i<=n;i++) read(a[i]);
    cnt=0;
    dfs(1,a[1]);
    dfs(1,a[1]+1);
    dfs(1,a[1]-1);
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int H,W;
    cin >> H >> W;
    bool box[110][110];
    int ans[110][110];
    for(int i=0;i<110;i++){
        for(int j=0;j<110;j++){
            box[i][j]=true;
            ans[i][j]=9999;
        }
    }
    ans[1][1]=0;
    //black = false;
    //white = true;
    string str;
    string black = "#";
    string white = ".";

    for(int i=0;i<H;i++){
        cin >> str;
        for(int j=0;j<W;j++){
            if(str.compare(j,1,black)==0){
                box[i+1][j+1]=false;
            }else{
                box[i+1][j+1]=true;
            }
        }
    }
    for(int j=2;j<=W;j++){
        if(box[1][j-1]==box[1][j]){
            ans[1][j]=ans[1][j-1];
        }else{
            ans[1][j]=ans[1][j-1]+1;
        }
    }
    int right;
    int down;
    for(int i=2;i<=H;i++){
        if(box[i-1][1]==box[i][1]){
            ans[i][1]=ans[i-1][1];
        }else{
            ans[i][1]=ans[i-1][1]+1;
        }
        for(int j=2;j<=W;j++){
            if(box[i-1][j]==box[i][j]){
                down = ans[i-1][j];
            }else{
                down = ans[i-1][j] + 1;
            }
            if(box[i][j-1]==box[i][j]){
                right = ans[i][j-1];
            }else{
                right = ans[i][j-1] + 1;
            }
            ans[i][j] = min(down,right);
        }
    }

    int answer = ans[H][W];
    if(answer%2==1){
        answer ++;
        answer /= 2;
    }else{
        answer /= 2;
        if(box[1][1]==false){
            answer ++;
        }
    }

    cout << answer << endl;
    return 0;


}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;

int bitCount(int bits) {
    int cnt = 0;
    for(int mask = 1; mask != 0; mask<<=1) {
        if( (bits & mask) != 0 )
            ++cnt;
    }
    return cnt;
}

int main(){
  int n,m; cin>>n>>m;
  vector<int> k(m);
  vector<int> p(m);
  vector<int> s(m);
  rep(i,m){
    cin>>k[i];
    int bit=0;
    rep(j,k[i]){
      int ss; cin>>ss;
      bit|=(1<<ss-1);
    }
    s[i]=bit;
  }
  rep(i,m) cin>>p[i];
  // rep(i,m) cout<<bitset<8>(s[i])<<endl;

  int ans=0;
  for(int bit=0;bit<(1<<n);bit++){
    // cout<<bitset<8>(bit)<<endl;
    bool chek=1;
    rep(i,m){
      int a=bit&s[i];
      a=bitCount(a);
      if(a%2!=p[i]){
        chek=0;
        break;
      }
    }
    if(chek)
    ans++;
  }

    cout<<ans<<endl;

    return 0;
  }


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,K;
map<int,int> s;
Int dp[110][200000];
Int X[200000];
Int sumdp[200000];

int main(void) {
    cin>>N>>K;
    dp[0][0] = 1;
    Int sq = sqrt(N);

    for(int i = 0;i < sq;i++) {
        X[i] = 1;
    }
    for(int i = 0;i < sq;i++) {
        int p = sq - i;
        X[i+sq] = N / p - N / (p+1);
    }
    if(sq*(sq+1) > N)
        X[sq]--;
    sq *= 2;
    for(int i = 0;i < K;i++) {
        sumdp[0] = dp[i][0];
        for(int j = 1;j < sq;j++) {
            sumdp[j] = (sumdp[j-1] + dp[i][j]) % MOD;
        }
        reverse(sumdp,sumdp+sq);
        for(int j = 0;j < sq;j++) {
            dp[i+1][j] = (sumdp[j] * X[j]) % MOD;
        }
    }
    Int ans = 0;
    for(int j = 0;j < sq;j++) {
        ans = (ans + dp[K][j]) % MOD;
    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 161024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
using namespace std;

int main() {
  int n;
  bool flag=false;
  cin >> n;
  for(int y=0;4*y<=n;y++) {
    if((n-4*y)%7 == 0) {
      flag=true;
      break;
    }

  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            out.println(N - K + 1);
        }

    }
}



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

using namespace std;

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

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

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

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

#define MAX_N 2000

int N, K;
vector<int> graph[MAX_N];

int dp[MAX_N];
void dfs(int u, int p, int d) {
  dp[u] = d;
  for(int& v : graph[u]) {
    if(v != p) dfs(v, u, d+1);
  }
}

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

  cin >> N >> K;
  vector<Pi> es;
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
    es.emplace_back(a, b);
  }

  if(K == 1) {
    cout << N-2 << endl;
    return 0;
  }

  int ans = inf;
  rep(i, N) {
    memset(dp, -1, sizeof(dp));
    dfs(i, -1, 0);
    int cnt = 0;
    rep(j, N) {
      if(dp[j] > K/2) cnt++;
    }
    chmin(ans, cnt);
  }
  for(Pi p : es) {
    memset(dp, -1, sizeof(dp));
    dfs(p.first, p.second, 0);
    dfs(p.second, p.first, 0);
    int cnt = 0;
    rep(i, N) {
      if(dp[i] > (K-1)/2) cnt++;
    }
    chmin(ans, cnt);
  }
  cout << ans << endl;

  return 0;
}


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

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

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

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

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

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

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

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

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

int N, M, K, T, Q;

void dfs(vector< vector< int > > &G, vector< bool > &used, int x) {
	used[x] = true;
	rep(i, G[x].size()) {
		int j = G[x][i];
		if (!used[j])
			dfs(G, used, j);
	}
}

signed main() {
	cin >> N >> K;
	vector< int > P(N);
	vector< vector< int > > G(N - K + 1);
	rep(i, N) cin >> P[i];
	vector< int > D(N - 1);
	rep(i, N - 1) D[i] = P[i + 1] - P[i];
	int last = -1, firsti = -1;
	for (int i = 1; i < N; i++) {
		if (D[i - 1] < 0)
			last = i - 1;
		if (i - K >= last) {
			if (firsti < 0) {
				firsti = i;
			} else {
				G[firsti - K + 1].push_back(i - K + 1);
				G[i - K + 1].push_back(firsti - K + 1);
			}
		}
	}
	set< int > s;
	rep(i, K) s.insert(P[i]);
	int ans = 0;
	for (int i = K; i < N; i++) {
		//cout << *(s.begin()) << " " << *(s.rbegin()) << endl;
		if ((*(s.begin()) == P[i - K] && *(s.rbegin()) < P[i])) {
			G[i - K + 1].push_back(i - K);
			G[i - K].push_back(i - K + 1);
		}
		s.erase(P[i - K]);
		s.insert(P[i]);
	}
	vector< bool > used(N - K + 1, false);
	rep(i, N - K + 1) {
		if (!used[i]) {
			dfs(G, used, i);
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  int p;
  for(char c:S) if(c=='p') p++;
  cout << S.size()/2-p <<endl;
  return 0;
}

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

#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 ALL(obj) (obj).begin, (obj).end()
#define INF 1e9
typedef long long ll;

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> s;
    REP(i,M){
         cin >> k[i];
         vector<int> ss(k[i]);
         REP(j,k[i]){
             cin >> ss[j];
             ss[j]--;
         }
         s.push_back(ss);
    }

    vector<int> p(M);
    REP(i,M) cin >> p[i];

    int ans = 0;

    for (int bit=0; bit<(1<<N); bit++){
        bool flag = true;

        for (int i=0; i<M; i++){
            int count=0;
            for (int j=0; j<k[i]; j++){
                if((bit>>s[i][j]) & 1){
                    count++;
                }
            }
            if (count%2 != p[i]){
                flag = false;
            }
        }

        if(flag){
            ans++;
        }
    }

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


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int l = s.length();        
        boolean ans = true;
        
        for(int i=0; i<l; i++){  
            if(s.indexOf(s.charAt(i),i+1)!=t.indexOf(t.charAt(i),i+1)){
                ans = false;
                break;
            }
        }

        System.out.println(ans?"Yes":"No");
    }
}

Measured memory_bytes: 28568
from sys import stdin
# stdin = open("testdata.txt", "r")

def input():
	return stdin.readline().strip()

from collections import defaultdict

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

penalties = defaultdict(int)
p_count = 0

answered = dict()

for _ in range(m):
	q, ans = input().split()
	if int(q) not in answered:
		if ans=='AC':
			p_count += penalties[int(q)]
			answered[int(q)] = 1
		else:
			penalties[int(q)] += 1
print(len(answered), p_count)

Measured memory_bytes: 60764
#include <iostream>
using namespace std;
long long a[1005],b[1005];
int main()
{
	long long n;
	cin >> n; 
	for(long long i = 1;i <= n;i++)
	{
		cin >> a[i] >> b[i];
	}
	a[0] = 1;
	b[0] = 1;
	long long sum = 0;
	long long x = 1;
	for(long long i = 0;i < n;i++)
	{
		if(a[i]>a[i+1]||b[i] > b[i+1])
		{
			long long c,d;
			c = a[i]/a[i+1];
			d = b[i]/b[i+1];
			if(a[i]%a[i+1])
			{
				c++;
			}
			if(b[i]%b[i+1])
			{
				d++;
			}
			a[i+1]*=max(c,d);
			b[i+1]*=max(c,d); 
		}
	}
	sum = a[n]+b[n];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  int n, m;
  readf("%s %s\n", &n, &m);
  auto d = new int[](n+2);
  foreach (_; 0..m) {
    int l, r;
    readf("%s %s\n", &l, &r);
    d[l]++;
    d[r+1]--;
  }

  int res, c;
  foreach (i; 1..n+1) {
    c += d[i];
    if (c == m) {
      res++;
    }
  }
  res.writeln;
}


Measured memory_bytes: 636
h, w = map(int, input().split())
str_array = [input() for i in range(h)]
count = [0 for i in range(26)]
for i in range(h):
    for j in range(w):
        count[ord(str_array[i][j]) - ord('a')] += 1

flag = True
count_odd = 0
count_two = 0
if h == 1 and w == 1:
    # 必ずよい
    pass
elif h == 1 or w == 1:
    # 奇数が1種類のみあればいい
    for i in range(26):
        if count[i] % 2 != 0:
            count_odd += 1
            if count_odd > 1:
                flag = False
elif h % 2 == 0 and w % 2 == 0:
    # 全て4の倍数であればよい
    for i in range(26):
        if count[i] % 4 != 0:
            flag = False
elif h % 2 != 0 and w % 2 != 0:
    for i in range(26):
        if count[i] % 2 != 0:
            count_odd += 1
            if count_odd > 1:
                flag = False
        elif count[i] % 4 != 0:
            count_two += 2
            if count_two > h + w - 2:
                flag = False
elif h % 2 != 0:
    for i in range(26):
        if count[i] % 2 != 0:
            flag = False
        elif count[i] % 4 != 0:
            count_two += 2
            if count_two > w:
                flag = False
elif w % 2 != 0:
    for i in range(26):
        if count[i] % 2 != 0:
            flag = False
        elif count[i] % 4 != 0:
            count_two += 2
            if count_two > h:
                flag = False

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38512
#include <iostream>
#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;

double dp1[1024][1024];
double dp[1024];

int main(){
  const int n = getInt();
  const int m = getInt();

  for(int i = 1; i <= n; i++){
    double s = 0.0;
    for(int j = 1; j <= min(i, m); j++){
      s += dp1[i][j - 1];
      dp1[i][j] = (1.0 - s) * 1 / (i - j + 1);
    }
  }

  dp[0] = 1.0;
  for(int i = 0; i < n; i++){
    for(int j = 1; i + j <= n && j <= m; j++){
      dp[i + j] += dp[i] * dp1[n - i][j];
    }
  }

  printf("%.10f\n", dp[n]);

  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{

    int n;
    cin >> n;

    int t = n % 10;

    if (t == 3)
    {
        cout << "bon" << '\n';
    }
    else if (t == 0 or t == 1 or t == 6 or t == 8)
    {
        cout << "pon" << '\n';
    }
    else
    {
        cout << "hon" << '\n';
    }
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b;

int main(){
  cin >> a >> b;
  if(a%2==1&&b%2==1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main(){
	int N;
	cin >> N;
	long long A[N];
	vector<long long> L, R;
	for(long long i=0;i<N;i++){
		cin >> A[i];
		L.push_back(i - A[i]);
		R.push_back(i + A[i]);
	}
	L.push_back(1000000001);
	R.push_back(1000000002);
	sort(L.begin(), L.end());
	sort(R.begin(), R.end());
	long long i = 0, j = 0;
	long long ans = 0;
	while(i < N && j < N){
		if(L[i] < R[j])i++;
		else if(L[i] == R[j]){
			long long it = i, jt = j;
			while(L[it] == L[it+1])it++;
			while(R[jt] == R[jt+1])jt++;
			ans += (it - i + 1) * (jt - j + 1);
			i = it + 1;
			j = jt + 1;
		}
		else j++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 8144
s=input()
result=""
count=0
l=len(s)
if s[0]!="A":
  result="WA"
elif ord(s[1:2])<97 or ord(s[l-1])<97:
  result="WA"
for i in s[2:l-1]:
  if ord(i)<97:
    count+=1
  if ord(i)<97 and i!="C":
    result="WA"
    break
  if count>1:
    result="WA"
    break
if count==0:
  result="WA"
if result!="WA":
  result="AC"
print(result)

Measured memory_bytes: 3064
A, B, C, X, Y = map(int, input().split())

ans1 = X*A+Y*B
if(X > Y):
    ans2 = min(C*Y*2+A*(X-Y), C*X*2)
elif(Y > X):
    ans2 = min(C*X*2+B*(Y-X), C*Y*2)
else:
    ans2 = C*2*X
print(min(ans1, ans2))

Measured memory_bytes: 3064
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;


signed main() {
  ios::sync_with_stdio(false);
  int x, y;
  cin >> x >> y;
  combination table(x+y);
  if ((x + y) % 3 != 0 || abs(x-y) > (x+y) / 3) {
    cout << 0 << endl;
    return 0;
  }
  cout << table.C((x+y) / 3, (x+y) / 6 - abs(x-y) / 2) << endl;
  return 0;
}

Measured memory_bytes: 31488
#include<stdio.h>
int main()
{
	int A, B,ans=0;
	scanf("%d %d", &A, &B);

	if (A -B>0)
	{
		ans= A*2 - 1;
	}
	else
	{
		if (A - B < 0)
		{
			ans = B * 2 - 1;
		}
	
		else
		{
			if (A = B)
			{
				ans = B * 2;
			}
			
		}
	}
	printf("%d", ans);
	
	return 0;
}


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

int A, B;

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

	cin >> A >> B;
	for (int X = 1; X < 10000; X++) {
		int a = (X * 0.08);
		int b = (X * 0.1);
		if (A == a && B == b) {
			cout << X;
			return 0;
		}
	}
	cout << -1;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
// #include<vor>
using namespace std;
typedef long long int ll;
#define pb push_back
ll mod = 1e9+7;

ll powm(ll a , ll b , ll mod)
{
  ll res = 1;
  while(b)
  {
    if(b & 1)
    res = (res *a)%mod;
    a = (a*a)%mod;
    b>>1;
  }
  return res;
}
ll gcd(ll a , ll b);
ll power(ll x , ll y , ll m);

ll modInverse(ll a , ll m)
{
  ll g = gcd(a,m);
  if(g != 1)
  return 1;
  else
  return power(a,m-2,m);

}

ll power(ll x , ll y , ll m)
{
  if(y == 0)
  return 1;
  ll p = power(x , y/2 , m)%m;
  p = (p*p)%m;

  return (y%2 == 0) ? p : (x *p) % m;
}

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

void solve()
{
  ll a,b,c;
  cin>>a>>b>>c;
  cout<<c<<" "<<a<<" "<<b<<"\n";
}

int main()
{
  // int tc;
  // cin>>tc;
  // while(tc--)
  // {
    solve();
  // }
}


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

int main() {
    int a;
    cin >> a;
    int b[a],i=0,l;
    while(cin>>l){
        b[i] = l;
        i++;
    }

    int c = 0, d=0;

    for (int i = 0 ; i < a ; i++ ){
      d += pow((b[i] - 1), 2);
    }
    
    for (int n=1 ; n<= 100 ; n++){
      for (int i = 0 ; i < a ; i++ ){
        c += pow((b[i] - n), 2);
      }
      if (d >= c){
        d = c;
      }
      c=0;
    }


    cout << d << endl;
 
    return 0;
}

Measured memory_bytes: 256
h1, m1, h2, m2, k = map(int, input().split())

if m1 <= m2:
    h = h2 - h1
    m = m2 - m1
else:
    h = h2 - h1 - 1
    m = m2 - m1 + 60

m += 60 * h

print(m - k)


Measured memory_bytes: 9048
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  cin >> n;
  cout << 180 * (n - 2) << endl;
  return 0;
}


Measured memory_bytes: 256
module Main where
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as B8
import Data.Maybe (fromJust)

main = do
  n <- readLn :: IO Int
  as <- map (fst . fromJust . B8.readInt) . B8.words <$> BS.getLine
  print $ solve as n
  return ()

solve :: [Int] -> Int -> Int
solve as n = min (calcSum as (k `div` n)) (calcSum as (k `div` n + 1))
  where
    k = sum as

calcSum :: [Int] -> Int -> Int
calcSum xs n = sum $ map (\x -> (x - n)*(x-n)) xs


Measured memory_bytes: 508
from collections import Counter

arr_b = []
N = int(input())
for i in range(N):
    arr_b.append(str(input()))
arr_r = []
N = int(input())
for i in range(N):
    arr_r.append(str(input()))

c_b = Counter(arr_b)
c_r = Counter(arr_r)

res = 0
for k_b in c_b.keys():
    if k_b in c_r :
        if res < c_b[k_b] - c_r[k_b]:
            res = c_b[k_b] - c_r[k_b]
    else:
        if res < c_b[k_b]:
            res = c_b[k_b]

print(res)


Measured memory_bytes: 3316
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int a,j=1;
  scanf("%d",&a);
  FOR(3)j*=a;
  PRN(j);
  return 0;
}


Measured memory_bytes: 128
n, k = map(int, input().split())

p = list(map(int, input().split()))

def kitaiti(num):
    result = (num+1)*num/(num*2)
    return result
r = [kitaiti(p[i]) for i in range(n)]

result = [sum(r[:k])]
for i in range(k, n):
    result.append(result[-1]-r[i-k]+r[i])
print(max(result))

Measured memory_bytes: 24804
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  string s;
  cin>>s;
  int ans=10000;
  int n=s.size();
  rep(i,n-2){
    int sub=stoi(s.substr(i,3));
    int diff=abs(753-sub);
    if(diff<ans)ans=diff;
  }
  cout(ans);
  return 0;
}

Measured memory_bytes: 125568
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
using namespace std;
const int inf = 1e9;

vector<bool> used;
vector<string> op;
vector<vector<int> > adj;
int minmax(int cur, int depth, int val, int x, int y){
	int ret = (depth%2==0)? -inf: inf;
	for(int i=0; i<(int)adj[cur].size(); i++){
		int next = adj[cur][i];
		if(used[next]) continue;
		
		int xy = (op[next][4] == 'X')? x: y;
		int nval;
		if(op[next][3]=='&') nval = val & xy;
		if(op[next][3]=='|') nval = val | xy;
		if(op[next][3]=='^') nval = val ^ xy;
		
		used[cur] = true;
		if(depth%2==0){
			ret = max(ret, minmax(next, depth+1, nval, x, y));
		}else{
			ret = min(ret, minmax(next, depth+1, nval, x, y));
		}
		used[cur] = false;
	}
	if(ret==inf || ret==-inf) ret = val;
	return ret;
}
	
int main(){
	int n,m;
	cin >> n >> m;
	op.resize(n);
	adj.resize(n);
	for(int i=1; i<n; i++) cin >> op[i];
	for(int i=0; i<n-1; i++){
		int u,v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	
	used = vector<bool>(n, false);
	map<pair<int, int>, int> opt;
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			if(i==j) continue;
			int k = 3-i-j;
			int x = 1<<i | 1<<k;
			int y = 1<<j | 1<<k;
			opt[make_pair(x, y)] = minmax(0, 0, 0, x, y);
		}
	}
	
	for(int i=0; i<m; i++){
		int x,y;
		cin >> x >> y;
		vector<pair<int,int> > mxy(3);
		mxy[0].first = x -(x&y);
		mxy[1].first = y -(x&y);
		mxy[2].first = x&y;
		for(int j=0; j<3; j++) mxy[j].second = j;
		sort(mxy.begin(), mxy.end());
		
		int nx=0, ny=0;
		for(int j=0; j<3; j++){
			if(mxy[j].second == 0) nx |= 1<<j;
			if(mxy[j].second == 1) ny |= 1<<j;
			if(mxy[j].second == 2){
				nx |= 1<<j;
				ny |= 1<<j;
			}
		}
		int ret = opt[make_pair(nx, ny)];
		
		int ans = 0;
		for(int j=0; j<3; j++){
			if((ret&(1<<j)) != 0) ans |= mxy[j].first;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 26472
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

// 二つの値の最小値を求める関数
Int Min(const Int a, const Int b) {
    if (a <= b) {
        return a;
    } else {
        return b;
    }
}

int main(void) {
    Int n;
    cin >> n;
    vector<Int> x(n);
    for (Int i = 0; i < n; ++i) {
        Int temp;
        cin >> temp;
        x[i] = temp - 1;
    }
    const Int X_MAX = 100;
    Int min_sum = LLONG_MAX;
    for (Int i = 0; i < X_MAX; ++i) {
        Int sum = 0;
        for (Int j = 0; j < n; ++j) {
            sum += ((x[j] - i) * (x[j] - i));
        }
        min_sum = Min(min_sum, sum);
    }
    cout << min_sum << endl;
    return 0;
}



Measured memory_bytes: 3620
import math
n,h = map(int,input().split())
ab = [input() for i in [0]*n]
amax = max([int(x.split()[0]) for x in ab])
b = sorted([int(x.split()[1]) for x in ab if int(x.split()[1])>amax])
if sum(b) < h:
    print(math.ceil((h-sum(b))/amax)+len(b))
else:
    b.reverse()
    for i in range(len(b)):
        h -= b[i]
        if h <=0:
            print(i+1)
            break

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N); 
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  
  int ans = 0;
  int i = 0;
  while(i<N){
    int x = vec.at(i);
    int cnt = 1;
    if(cnt + i == N){
      i++;
    }
    while(cnt + i < N){
      if(x == vec.at(i+cnt)){
        cnt++;
      }
      else{
        i += cnt;
        break;
      }
      if(i + cnt == N){
        i += cnt;
        break;
      }
    }
    if(cnt > x){
      ans += cnt - x;
    }
    else if(cnt < x){
      ans += cnt;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto S = RD!string;

	writeln(S[0] == S[1] && S[1] == S[2] ? "No" : "Yes");
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)
	sho := x / 500
	var oldresult int = 0
	var amari int
	var yen50 int
	var result int
	for i := 0; i < sho+1; i++ {
		amari = x - sho*500
		yen50 = amari / 5
		result = i*1000 + yen50*5
		if result > oldresult {
			oldresult = result
		}
		if result < oldresult {
			break
		}
	}
	fmt.Println(oldresult)
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    A = [a-1 for a in A]
    manzoku = 0
    for i in range(N):
        manzoku += B[A[i]]
        if i < N-1 and A[i+1] == A[i] + 1:
            manzoku += C[A[i]]
    print(manzoku)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N - 1)]  # type: "List[int]"
    solve(N, A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    X = Scanner.int()
    for k in range(1, 1000):
        if k * X % 360 == 0:
            print(k)
            return


def main():
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10720
#include <iostream>
#include "bits/stdc++.h"

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a;i>0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

int main() {
    ll n, m, Q;
    cin >> n >> m >> Q;
    VE l(m), r(m), p(Q), q(Q);
    VVE x(n + 1, vector<ll>(n + 1, 0));
    REP(i, m){
        cin >> l[i] >> r[i];
        x[l[i]][r[i]]++;
    }
    VVE c(n + 2, vector<ll>(n + 2, 0));
    rep(i, 1, n + 1)rep(j, 1, n + 1) {
        c[i][j] = c[i][j - 1] + x[i][j];
    }
    REP(i, Q) cin >> p[i] >> q[i];
    REP(i, Q){
        ll ans = 0;
        rep(j, p[i], q[i] + 1){
            ans += c[j][q[i]] - c[j][p[i] - 1];
        }
        print(ans);
    }
    jkl;
}






Measured memory_bytes: 9600
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL x, y; cin >> x >> y;

	int ret = 0;

	while (x <= y) {
		x *= 2;
		ret++;
	}

	cout << ret << endl;
	return 0;
}

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

int main()
{
    ll k, n;
    cin >> k >> n;
    ll a[1000000];
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    ll ans = 0;
    ll diff = 0;
    for (ll i = 0; i < n - 1; i++)
    {
        diff = max(diff, a[i + 1] - a[i]);
    }
    diff = max(diff, abs(a[n - 1] - (a[0] + k)));
    cout << k - diff;
}

Measured memory_bytes: 3584
N, K = map(int, input().split())
sweet = [0]*N
for i in range(K):
    num = int(input())
    people = [int(i) for i in input().split()]
    for p in people:
        sweet[p-1] += 1

count = 0
for i in range(N):
    if sweet[i] == 0:
        count += 1
print(count)

Measured memory_bytes: 9184
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        
        if ( a == b && b == c) {
            System.out.println("No");
        } else if ( a != b && b != c && a != c ) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
        
    }
} 

Measured memory_bytes: 21204
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();

	int n;

	ll ans = 1;

	scanf("%d",&n);

	for(int i=0;i<n;i++){
		ll x;
		scanf("%lld",&x);
		ans =ans/__gcd(ans,x)*x;
	}

	printf("%lld\n",ans );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, a;
  cin >> N;
  vector<int> S(N),T(N);
  for (int i = 0; i < N; i++) {
      cin >> S.at(i);
  }
  T = S;
  sort(T.begin(), T.end());
  a = T.at(N - 1);
  if (a == T.at(N - 2)) {
    for (int i = 0; i < N; i++) {
        cout << a << endl;
    }
  }
  else {
    for (int i = 0; i < N; i++) {
        if (S.at(i) == a){
            cout << T.at(N - 2) << endl;
        }
        else {
            cout << a << endl;
        }
    }
  }
}

Measured memory_bytes: 3200