akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
bool func(ll n){
    if(n%2==0)return 0;
    ll cnt=0;
    for(ll i=1;i<=n;i++)if(n%i==0)cnt++;
    return cnt==8;
}
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll n,ans=0;cin>>n;
    for(ll i=1;i<=n;i++)ans+=func(i);
    cout<<ans;
}





Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
#define rep(i,n,k) for(int i=n;i<k;i++)
#define int long long
#define P make_pair
#define F first
#define S second
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s;
    cin>>n>>m;
    vector<int> v;
    rep(i,0,n){
        cin>>q;
        v.push_back(q);
    }
    sort(v.begin(),v.end());
    
    rep(i,0,n-m){
        ans+=v[i];
    }
    cout<<ans<<endl;
}

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

int ans=1<<30;
int D;
int g;
vector<bool>d(12);
vector<int>p(12);
vector<int>c(12);

void cal(void){
  int sum=0;
  int ans2=0;
  for(int i=0;i<D;i++){
    if(d.at(i)){
      sum+=c.at(i);
      sum+=(i+1)*100*p.at(i);
      ans2+=p.at(i);
    }
  }
  for(int i=D-1;i>=0;i--){
    if(d.at(i)!=true){
      for(int j=1;j<=p.at(i);j++){
        if(sum>=g){
          break;
        }
        sum+=(i+1)*100;
        ans2++;
      }
    }
  }
  ans =min(ans,ans2);
}

void dfs(int v){
  if(v ==D){
    cal();
    return;
  }
  d.at(v)=0;dfs(v+1);
  d.at(v)=1;dfs(v+1);
}

int main() { 
  cin >>D>>g;
  for(int i=0;i<D;i++){
    cin >>p.at(i)>>c.at(i);
  }
  dfs(0);
  cout <<ans;
}

Measured memory_bytes: 256
using System;

namespace A_CirclePond
{
    class Program
    {
        static void Main(string[] args)
        {
            var hankei = int.Parse(Console.ReadLine().Split(' ')[0]);
            double ensyu = hankei * 2 * 3.14;
            decimal ensyudesi = Convert.ToDecimal(ensyu);

            Console.WriteLine(ensyudesi.ToString());
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 18164
import scala.io.StdIn

object Main extends App {
  val abc = StdIn.readLine().split(" ")
  abc match {
    case Array(a, b, c)
      if (a.takeRight(1) == b.take(1) &&
          b.takeRight(1) == c.take(1) ) => println("YES")
    case _ => println("NO")
  }
}

Measured memory_bytes: 27088
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<set>
#include<vector>
using namespace std;
#define PI acos(-1.0)
#define pppp cout<<endl;
#define EPS 1e-8
#define LL long long
#define ULL unsigned long long     //1844674407370955161
#define INT_INF 0x3f3f3f3f      //1061109567
#define LL_INF 0x3f3f3f3f3f3f3f3f //4557430888798830399
// ios::sync_with_stdio(false);
// 那么cin, 就不能跟C的 scanf，sscanf, getchar, fgets之类的一起使用了。
const int dr[]= {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[]= {-1, 1, 0, 0, -1, 1, -1, 1};
int read()//输入外挂
{
    int ret=0, flag=0;
    char ch;
    if((ch=getchar())=='-')
        flag=1;
    else if(ch>='0'&&ch<='9')
        ret = ch - '0';
    while((ch=getchar())>='0'&&ch<='9')
        ret=ret*10+(ch-'0');
    return flag ? -ret : ret;
}
const LL MOD=1000000007;
LL fac[1000005];
void getFac() //构造阶乘
{
    fac[0]=1;
    for(int i=1; i<=1000000; i++)
    {
        fac[i]=fac[i-1]*i%MOD;
    }
}
LL quickPowMod(LL a,LL b,LL mod) //快速幂
{
    LL res=1;
    while(b)
    {
        if(b&1)
            res=res*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return res;
}
LL getC(LL n,LL m,LL mod) //获取C(n,m)%mod
{
    if(m>n)
        return 0;
    return fac[n]*(quickPowMod(fac[m]*fac[n-m]%mod,mod-2,mod))%mod;
}
LL Lucas(LL n,LL m,LL mod) //卢卡斯定理
{
    if(m==0)
        return 1;
    return getC(n%mod,m%mod,mod)*Lucas(n/mod,m/mod,mod)%mod;
}
int main()
{
    getFac();
    LL mod=1000000007;
    LL h,w,a,b;
    cin>>h>>w>>a>>b;
    LL ans=0;
    for(LL i=b+1;i<=w;++i)
        ans=(ans%mod+Lucas(h-a+i-2,i-1,mod)*Lucas(w-i+a-1,w-i,mod)%mod)%mod;
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 8064
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

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

    int N;cin >> N;
    vector<int> time(N-1),start(N-1),interval(N-1);
    for(int i = 0;i<N-1;i++) cin >> time.at(i) >> start.at(i) >> interval.at(i);
    
    for(int i = 0;i<N;i++){
        if(i == N-1){
            cout << 0 << endl;
            break;
        }
        int now = 0;
        for(int j = i;j<N-1;j++){
            if(now < start.at(j)) now = start.at(j);
            else if(now%interval.at(j) != 0){
                now += interval.at(j)-(now%interval.at(j));
            }
            now += time.at(j);
        }
       cout << now << endl;
    }
}


Measured memory_bytes: 3660
BIG_NUM = 2000000000

while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if i == 0 or i == H-1 or k == 0 or k == W-1:
                print("#",end = "")
            else:
                print(".",end = "")
        print()

    print() #データセットの区切り



Measured memory_bytes: 7004
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;


int main(){
  ll n, k;
  cin >> n >> k;
  ll x = n % k;
  ll ans = min(x, abs(x-k));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int isPrime(int);

int main(){
  int num[10000];
  int n, i;
  int x =0;

  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    scanf("%d", &num[i]);

    x += isPrime(num[i]);
  }
  printf("%d\n", x);

  return 0;
}
  

  
int isPrime(int num){
  int i;
  
  if (num <= 1) return 0;
  if (num % 2 == 0 && num > 2) return 0;
  for(i = 3; i <= sqrt(num); i += 2){
    if (num % i == 0)return 0;
  }
  return 1;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vi a(N);
    cin >> a;
    vi s(N, 0);
    s[0] = a[0];
    REP(i, N - 1) s[i + 1] = s[i] + a[i + 1];

    int ans = INF;
    REPF(i, 1, N - 2) {
        auto L = lower_bound(ALL(s), ceil(s[i] / 2.0));
        auto R = lower_bound(ALL(s), ceil(s[i] + (s[N - 1] - s[i]) / 2.0));
        auto M = begin(s) + i;

        auto update = [&](vi::iterator l, vi::iterator m, vi::iterator r) {
            if (r == end(s)) return;
            int P = *l;
            int Q = *m - P;
            int R = *r - *m;
            int S = s[N - 1] - *r;
            dump(i, P, Q, R, S);
            if (P > 0 && Q > 0 && R > 0 && S > 0)
                chmin(ans, abs(max({P, Q, R, S}) - min({P, Q, R, S})));
        };

        update(L, M, R);
        update(L, M, prev(R));
        if (L != begin(s)) {
            update(prev(L), M, R);
            update(prev(L), M, prev(R));
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N;
    cin >> N;
    int B[N];
    rep(i, N-1) cin >> B[i];
    int sum = B[0];
    for(int i = 1; i < N; i++){
        if(i == N-1){
            sum += B[N-2];
            break;
        }
        sum += min(B[i-1], B[i]);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    int s = n%60;
    int h = n/3600;
    int m = (n-h*3600)/60;
    System.out.println(h+":"+m+":"+s);
  }
}

Measured memory_bytes: 24152
#include<iostream>
using namespace std;
#define ceil(u, d) ((u) / (d) + ((u) % (d) == 0 ? 0 : 1))
#define max(a, b) ((a) > (b) ? (a) : (b))

int main()
{
    int n;
    long long t_ratio, a_ratio, t = 1, a = 1, n_min;
    cin >> n;
    for(int i = 0; i < n; i++){
        scanf("%lld%lld", &t_ratio, &a_ratio);
        n_min = max(ceil(t, t_ratio), ceil(a, a_ratio));
        t = n_min * t_ratio;
        a = n_min * a_ratio;
    }
    cout << t + a << endl;
    return 0;
}

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

int main(){
  
  string A,B,C; cin >> A >> B >> C;
  
  if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0]){
    cout << "YES" << endl;
  }
  
  else{
    cout << "NO" << endl;
  }
  
  return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  vector<int> dp(n, int(2e9));
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);

  for (int i = 2; i < n; i++) {
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[n - 1] << '\n';
  return 0;
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	tuple<int, int,int> pairs[101000];
	for (int i = 0; i < m; i++)
	{
		int p, y;
		cin >> p >> y;
		pairs[i] = make_tuple(y, p, i);
	}
	sort(pairs, pairs + m);
map<int, int> k;
	pair<int, int> pa[101000];
	for (int i = 0; i < m; i++)
	{
		int x = get<1>(pairs[i]);
		int f = get<2>(pairs[i]);
		k[x]++;
		pa[f] = make_pair(x, k[x]);
	}
	for (int i = 0; i < m; i++)
	{
		cout << setfill('0');
		cout << setw(6) << pa[i].first << setw(6) << pa[i].second << endl;


	}
}

Measured memory_bytes: 8192
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int INF = 2e6;
ll MOD = 1e9 + 7;
 
int main(){
    int n, m; 
    cin >> n >> m;
    vector<ll> a(n);
    vector<pair<ll,int>> b(m);

    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i].second >> b[i].first;

    sort(a.begin(),a.end());

    priority_queue<pair<ll,int>> que;
    for(int i = 0;i < m;i++) {
            que.push(b[i]);
    }
    int k = 0;
    bool ok = false;
    while(que.size()){
        pair<ll,int> f = que.top();
        que.pop();
        ll p = f.first;
        int q = f.second;
        for(int i = 0; i < q;i++){
            if(a[k] < p){
                a[k] = p;
                k++;
            }else{
                ok = true;
                break;
            }
        }
        if(ok) break; 
    }
    ll ans = 0;
    rep(i,n) ans += a[i];
    cout << ans << endl;
}



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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    string s;
    cin >> s;
    vector<char> v;
    ll n = s.length();
    rep(i, n) {
        if (s[i] == '0') {
            v.push_back('0');
        } else if (s[i] == '1') {
            v.push_back('1');
        } else {
            if (v.size() != 0) {
                v.pop_back();
            }
        }
    }

    rep(i, v.size()) { cout << v[i]; }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next(), t = sc.next();
        long min_different = Long.MAX_VALUE;
        for (int i = 0; i < s.length(); i++) {
            long diff = 0;
            if (i + t.length() > s.length())
                break;
            for (int j = 0; j < t.length(); j++) {
                if (s.charAt(i + j) != t.charAt(j))
                    diff++;
            }
            min_different = Math.min(min_different, diff);
        }

        sc.close();
        System.out.println(min_different);
    }
}


Measured memory_bytes: 35880
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

vector<pair<char, int>> RunLengthEncoding(string data) {
    int n = data.size();
    vector<pair<char, int>> ret;
    char c = data[0];
    int num = 1;
    for(int i=1; i<n; i++) {
        if(data[i] == c) {
            num++;
        }else{
            ret.push_back({c, num});
            c = data[i];
            num = 1;
        }
    }
    ret.push_back({c, num});
    return ret;
}

int main() {
  string s; cin >> s;
  long long k; cin >> k;

  auto x = RunLengthEncoding(s);
  long long cnt = 0;
  int l = x.size();
  if (l == 1) {
    long long a = x[0].second*k / 2;
    cout << a << endl;
    return 0;
  }
  for(int i=0; i<l; i++) {
    cnt += x[i].second / 2;
  }
  long long d = 0;
  if (x[0].first == x[l-1].first) {
    d = x[0].second / 2 + x[l-1].second / 2;
    d -= (x[0].second + x[l-1].second) / 2;
    d *= (k-1);
  }
  cout << k * cnt - d << endl;
 
  return 0;
}

// EOF

Measured memory_bytes: 3608
import math
N, D = map(int, input().split())
points = []
count = 0
for i in range(N):
    points.append(list(map(int,input().split())))
for j in range(len(points)-1):
    for k in range(j+1,len(points)):
        sum = 0
        for l in range(D):
            sum += abs(points[j][l] - points[k][l])**2
        if math.sqrt(sum).is_integer():
            count += 1
print(count)



Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,M = MI()
X = LI()
Y = LI()
mod = 10**9+7

r = sum((i*(N-i)*(X[i]-X[i-1])) % mod for i in range(1,N))
r %= mod

ans = 0
for i in range(1,M):
    ans += r*i*(M-i)*(Y[i]-Y[i-1]) % mod
    ans %= mod

print(ans)


Measured memory_bytes: 90904
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<int, pair<int,int>> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;

int a[5];
int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
        if (a[i] == 0) cout << i + 1;
    }
}

Measured memory_bytes: 3188
n = raw_input()                                                
l = map(int, raw_input().split())                              
n = raw_input()                                                
                                                               
sum = 0                                                        
for i in map(int, raw_input().split()):                        
    if i in l:                                                 
        sum += 1                                               
                                                               
print sum

Measured memory_bytes: 6776
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,m;
  cin>>n>>m;
  cout<<(n*(n-1))/2+(m*(m-1))/2;
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[52],b[52];
map<pair<ll,ll>,ll>c;
int main() {
	ll n;
	ll ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j){
				continue;
			}
			ll nowx=a[i]-a[j];
			ll nowy=b[i]-b[j];
			pair<ll,ll> now=make_pair(nowx,nowy);
			c[now]++;
			ans=max(c[now],ans);
		}
	}
	cout << n-ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n, d, x;
  cin >> n >> d >> x;
  int ans = 0;
  REP(i, n){
    int a;
    cin >> a;
    ans += (d-1)/a + 1;
  }
  ans += x;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
string s;
int main(){
    cin>>s;
    int ans=0;
    int k=0;
    int j=s.size()-1;
    while(k<j){
    //cout<<k<<" "<<j<<endl;
       if(s[k]=='x'&&s[j]=='x'){
          k++;
          j--;
          continue;
       }
       if(s[k]=='x'&&s[j]!='x'){
         k++;
         ans++;
         continue;
       }
       if(s[k]!='x'&&s[j]=='x'){
         j--;
         ans++;
         continue;
       }
       if(s[k]!='x'&&s[j]!='x'){
          if(s[k]==s[j]){
             k++;
             j--;
             continue;
          }else{
             cout<<-1<<endl;
             return 0;
          }
       }
    }
    cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 512
n, a, b = map(int, input().split())

m = 10 ** 9 + 7

def comb(n, r, m):
  ans = 1
  for i in range(r):
    #ans = ans * (n-i) * pow(i+1, m-2, m) % m
    ans *= (n-i) * pow(i+1, m-2, m) % m
    ans %= m
    # *= で書いてしまうとans自体にmod計算されないので
    # 大きな数が発生して遅くなる．
    # ans %= mを追加すれば早い？
    
  return ans
  
print((pow(2,n,m)-1-comb(n,a,m)-comb(n,b,m))%m)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if(n % 2)
    {
        cout << b[n/2] - a[n/2] + 1 << endl;
    }
    else
    {
        int r = n/2;
        int l = r - 1;
        ll x = a[l] + a[r];
        ll y = b[l] + b[r];
        cout << y - x + 1 << endl;
    }
}


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

typedef long long ll;
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl '\n'
const int N = 2e5 + 5;
using namespace std;
int a[N];
unordered_map<int, int> M;

int main() {
    IO;
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        M[a[i]]++;

    }
    // sort(a, a + n);
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        int ok = 1;
        for (int j = 1; j * j <= a[i]; ++j) {
            if (a[i] % j == 0) {
                if (j == a[i] && M[j] >= 2 || j != a[i] && M[j] >= 1 || a[i] / j == a[i] && M[a[i] / j] >= 2 ||
                    a[i] / j != a[i] && M[a[i] / j] >= 1) {
                    ok = 0;
                    break;
                }
            }
        }
        if (ok) cnt++;
    }
    cout << cnt << endl;

}

Measured memory_bytes: 32340
#include <iostream>
#include <set>
#include <vector>
#include <iomanip>
#include <deque>


#include <algorithm>

#include <cfenv>
#include <cmath>
typedef long long int ll;

using namespace std;
#include <string>

int main()
{


     deque<char> S;

     string s;
     ll Q;

     bool riv_flag =0;


     

     cin >> s;
     for(char c: s){

         S.push_back(c);


         
     }

     cin >>Q;







     for(ll i=0;i<Q;i++){


         ll T;


         cin >> T;

         if(T ==1 ){


             if(riv_flag ==0){

                 riv_flag =1;
             }
             else{

                 riv_flag =0;
             }
         }
         else{


             ll F;
             char C;

             cin >> F >> C;

             if(!riv_flag){


                 if(F ==1){

                     S.push_front(C);
                 }
                 else{

                     S.push_back(C);
                 }


             }
             else{


                 if(F ==1){

                     S.push_back(C);
                 }
                 else{

                     S.push_front(C);
                 }


                 
             }
         }


         
     }

      string ans;


         for(char c:S){


             ans += c;


         }


     if(!riv_flag ){


        


         cout << ans << endl;
     }
     else{


         reverse(ans.begin(),ans.end());

         cout << ans << endl;
     }

    


    
    return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll cnt=(a-1)/d+1;
	Yn(c<=(cnt)*b);
}


Measured memory_bytes: 3648
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let a: Vec<usize> = (0..n).map(|_| input()).collect();

    let mut v: Vec<bool> = vec![false; n + 1];
    let mut i = 1;
    let mut ok = true;
    let mut ans = 0;
    while i != 2 {
        if v[i] {
            ok = false;
            break;
        }
        ans += 1;
        v[i] = true;
        i = a[i - 1];
    }

    println!("{}", if ok { ans } else { -1 });
}


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

int main(){
  
  int a, b, c, k;
  
  cin >> a >> b >> c >> k;
  
  cout << a + b + c + max(a, max(b, c)) * (pow(2, k) - 1) << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    int w,x=0;
    string s;
    cin >> s >> w;
    while(x*w<s.size()){
        cout << s[x*w];
        x++;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
using namespace std;

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int a,b,c;
	int sum=0;
	int keta_check=0;
	
	cin  >> a;
	syc(a,1,100000);
	
	for(int i=a;i>0;i--){
		b=i;
		while(1){
			c=b/10;
			keta_check++;
			if(c<=0)break;
			b=c;
		}
		if(keta_check%2 == 1){
			sum++;
		}
		keta_check = 0;
	}
	cout << sum << endl;
	return 0;	
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    char s[2];
    
    scanf("%c", s);
    
    if (s[0]=='a'||s[0]=='i'||s[0]=='u'||s[0]=='e'||s[0]=='o') {
        printf("vowel");
    } else {
        printf("consonant");
    }
    
    
    return 0;
}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int ans = min(b/a, c);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll md=(1e+9) +7;
int a[100];
ll dp[101][100001]={0};
int main(){
    int n;
    int k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<=k;i++){
        dp[0][i]=i+1;
        if(i>a[0]){dp[0][i]=a[0]+1;}
        dp[0][i]%=md;
    }
    for(int i=1;i<n;i++){
        dp[i][0]=1;
        for(int j=1;j<=k;j++){
            dp[i][j]=dp[i][j-1];
            dp[i][j]+=dp[i-1][j];
            if(j>a[i]){dp[i][j]-=dp[i-1][j-a[i]-1];}
            dp[i][j]%=md;
        }
    }
    cout<<(((dp[n-1][k]-dp[n-1][k-1])+md)%md);
    return 0;

}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1005

struct Point{
	double x,y;
};

int N;
double dist_table[NUM][NUM],dp[NUM][NUM];
Point point[NUM];


double calc_dist(Point A,Point B){

	return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}

int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){

		scanf("%lf %lf",&point[i].x,&point[i].y);
	}

	for(int i = 0; i < N-1; i++){
		for(int k = i+1; k < N; k++){

			dist_table[i][k] = calc_dist(point[i],point[k]);
			dist_table[k][i] = dist_table[i][k];
		}
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){

			dp[i][k] = 0;
		}
	}

	for(int to = 1; to <= N-1; to++){
		for(int from = 0; from < to; from++){

			if(from == 0 && to == 1){

				dp[from][to] = dist_table[from][to];

			}else if(from < to-1){

				dp[from][to] = dp[from][to-1]+dist_table[to-1][to];

			}else{

				dp[from][to] = BIG_NUM;

				for(int k = 0; k < from; k++){

					dp[from][to] = min(dp[from][to],dp[k][from]+dist_table[k][to]);
				}
			}
		}
	}

	double ans = BIG_NUM;

	for(int i = 0; i <= N-2; i++){

		ans = min(ans,dp[i][N-1]+dist_table[i][N-1]);
	}

	printf("%.10lf\n",ans);

	return 0;
}




Measured memory_bytes: 18960
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;
    vector<ll> x(n), y(n);
    REP(i, n) cin >> x[i] >> y[i];

    vector<ll> r(n);
    iota(ALL_OF(r), 0LL);
    ld s = 0;
    ll k = 0;
    do {
        REP(_i, n-1) {
            ll i = r[_i];
            ll j = r[_i+1];
            s += hypotl(x[i] - x[j], y[i] - y[j]);
        }
        k++;
    } while (next_permutation(ALL_OF(r)));
    cout << fixed << setprecision(30) << s / k << endl;
    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MD = 1e9 + 7;
map<pair<ll, ll>, int> ma;
int quick_pow(int x, int y) {
    int ans = 1;
    while(y) {
        if(y & 1) ans = 1LL * ans * x % MD;
        y >>= 1;
        x = 1LL * x * x % MD;
    }
    return ans;
}
int main() {
    int n, s = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        ll a, b;
        scanf("%lld%lld", &a, &b);
        ll d = __gcd(a, b);
        if(d == 0) {
            s++;
            continue;
        }
        a /= d, b /= d;
        if(a < 0) a = -a, b = -b;
        ma[{a, b}]++;
    }
    ll ans = 1;
    for(auto it : ma) {
        if(it.second == 0) continue;
        ll a = it.first.first, b = it.first.second;
        ll d = quick_pow(2, ma[{a, b}]);
        b = -b;
        if(b < 0) a = -a, b = -b;
        if(ma.count({b, a})) {
            d = (d + quick_pow(2, ma[{b, a}]) - 1) % MD;
            ma[{b, a}] = 0;
        }
        ans = ans * d % MD;
    }
    ans = (ans - 1 + s + MD) % MD;
    printf("%lld\n", ans);
    return 0;
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    int n;
    cin >> n;

    vector<int> a(n);

    rep(i, n) cin >> a[i];

    int ans = 0;

    rep(i, n){
        if(i % 2 == 0 && a[i] % 2 == 1) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " <<  y << " " << z;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    sub = 0
    ans = 0
    mod = pow(10, 9)+7
    for i in range(n):
        ans = (ans + sub*a[i])%mod
        sub += a[i]
    
    print(ans)
    
    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 31300
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h,n = LI()
a = LI()
if sum(a) >= h:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 52316
import java.util.Set;
import java.io.*;
import java.util.*;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.HashSet;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner();
        try (final FastWriter writer = new FastWriter()) {
            int N = scanner.nextInt();
            Set<Long> s = new HashSet<>();
            for (int i = 0; i < N; i++) {
                long j = scanner.nextLong();
                if (s.contains(j)) {
                    writer.println("NO");
                    return;
                }
                s.add(j);
            }
            writer.println("YES");
        }
    }
}

class FastScanner {
    private final BufferedReader br;
    private StringTokenizer st;

    public FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (final IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (final IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}

class FastWriter extends PrintWriter {
    public FastWriter() {
        super(new BufferedOutputStream(System.out));
    }

    public static void main(final String[] args) {
        try (final FastWriter w = new FastWriter()) {
            w.println(32);
        }
    }
}



Measured memory_bytes: 59328
object Main extends App {
	val k = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	
	val y = k(1)
	val z = k(2)

	var per = 0;
	var size = k(0) - z

	while(size >= 0){
		per = per + 1;
		size = size - y - z;
	}

	println(per - 1)

}

Measured memory_bytes: 27188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  vector<bool> a(n + 1, true);
  while (m--) {
    int aa; cin >> aa;
    a[aa] = false;
  }
  vector<long long> dp(n + 1, 0);
  dp[0] = 1;
  REP(i, n) {
    if (a[i + 1]) (dp[i + 1] += dp[i]) %= MOD;
    if (i + 2 <= n && a[i + 2]) (dp[i + 2] += dp[i]) %= MOD;
  }
  cout << dp[n] << '\n';
  return 0;
}


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

const ll MOD  = 1000000007;
const ll MAX = 1000009;
ll fac[MAX], finv[MAX], inv[MAX];  //階乗、階乗の逆元、逆元

void nCk_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1]            = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i]  = fac[i - 1] * i % MOD;
        inv[i]  = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCk(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int X, Y;
    cin >> X >> Y;
    int xyDiff = abs(X - Y);
    int n      = (X + Y) / 3;

    nCk_init();
    if ((X + Y) % 3 == 0 && xyDiff <= n) {
        cout << nCk(n, n*2 - X) << endl;
    }
    else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 23680
N = int(input())
a = list(map(int,input().split()))

count = []
n_count = 0
now_num = 1

for i in range(N):
  if a[i] == now_num:
    n_count += 1
    now_num += 1
else:
  if n_count != 0:
    count.append(i - (n_count - 1) + N - (i + 1))
    
if count:
  print(min(count))
else:
  print(-1)
  

Measured memory_bytes: 26012
N = int(input())
mochi=[]
making_mochi=[]
for i in range(N): #入力値をリストに格納
    mochi.append(int(input()))
mochi.sort()

if N==1:
    print(1)
    
else:
    making_mochi.append(mochi[0])
    for i in range(1,N):
        if mochi[i]!=max(making_mochi):
            making_mochi.append(mochi[i])
    print(len(making_mochi))

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li I, O, T, J, L, S, Z;

int main() {
    cin >> I >> O >> T >> J >> L >> S >> Z;

    li res2 = (I / 2) * 4 + (J / 2) * 4 + (L / 2) * 4;
    li res1 = [&] {
        li tmp = 0;
        if (min(I, min(J, L)) > 0) {
            tmp += 6;
            I--;
            J--;
            L--;
        }
        tmp += (I / 2) * 4 + (J / 2) * 4 + (L / 2) * 4;
        return tmp;
    }();
    li res = max(res1, res2);
    res += O * 2;

    cout << res / 2 << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, MOD;
vector<int> adj[100100];
long long down[100100];
void dfs1 (int x, int p) {
	down[x] = 1;
	adj[x].erase(remove(adj[x].begin(), adj[x].end(), p), adj[x].end());
	for (auto i: adj[x]) {
		dfs1(i, x);
		down[x] = (down[x]*(down[i]+1))%MOD;
	}
}
long long up[100100];
long long pre[100100], suf[100100];
void dfs2 (int x, int p) {
	pre[0] = suf[adj[x].size()] = 1;
	for (int i=0; i<adj[x].size(); i++) {
		pre[i+1] = (pre[i]*(down[adj[x][i]]+1))%MOD;
	}
	for (int i=adj[x].size(); i>0; i--) {
		suf[i-1] = (suf[i]*(down[adj[x][i-1]]+1))%MOD;
	}
	for (int i=0; i<adj[x].size(); i++) {
		up[adj[x][i]] = ((up[x]*((pre[i]*suf[i+1])%MOD))+1)%MOD;
	}
	for (auto i: adj[x]) {
		dfs2(i, x);
	}
}
int main () {
	cin >> n >> MOD;
	int ai, bi;
	for (int i=0; i<n-1; i++) {
		cin >> ai >> bi;
		ai--; bi--;
		adj[ai].push_back(bi);
		adj[bi].push_back(ai);
	}
	dfs1(0, -1);
	up[0] = 1;
	dfs2(0, -1);
	for (int i=0; i<n; i++) cout << (up[i]*down[i])%MOD << endl;
}

Measured memory_bytes: 14900
import sys
input = sys.stdin.readline
from itertools import accumulate


N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
info = [list(map(int,input().split())) for _ in range(M)]

info = sorted(info, key=lambda x:-x[1])

calc = [0]
for B, C in info:
    if len(calc) + B <= N+1:
        calc +=[C]*B
    else:
        calc += [C]*(N+1-len(calc))

calc += [0]*(N+1-len(calc))
calc = list(accumulate(calc))

cs = [0] + list(accumulate(A))
ans = 0
# i:いくつ変換するか
for i in range(N+1):
    res = cs[N] - cs[i] + calc[i]
    ans = max(ans,res)

print(ans)

Measured memory_bytes: 41836