akhauriyash/Code-Regression huggingface dataset:
def gs() STDIN.gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
 
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end


n,m = gsmi

k = 0
(1..(Math.sqrt(m).to_i)).each do |i|
	if m%i==0 && (i>=n || m/i>=n)
		if i>=n && m/i>=n
			k = max(k,m/i)
		else
			k = max(k,i)
		end
	end
end

puts k

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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations
typedef long long lint;
lint T1, T2, A1, A2, B1, B2;

// solve
int main(){

    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    A1 -= B1;
    A2 -= B2;
    if(A1 > 0){
        A1 = -A1;
        A2 = -A2;
    }

    lint S1 = T1 * A1, S2 = T2 * A2;

    if(S1 + S2 == 0){
        cout << "infinity\n";
        return 0;
    }

    if(S1 + S2 < 0){
        cout << "0\n";
        return 0;
    }

    if(S1 + S2 > 0){
        lint t = (-S1) % (S1 + S2);
        cout << (-S1) / (S1 + S2) * 2 + (t == 0 ? 0 : 1) << '\n';
        return 0;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string a; cin>>a;
	char b,c; cin>>b>>c;
	a.push_back(b);
	a.push_back(c);
	if(to_ll(a)%4==0) cout<<"YES";
	else cout<<"NO";
	
	return 0;
}

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  rep(j, n){
    double x[4], y[4];
    rep(i, 4){
      cin >> x[i] >> y[i];
    }
    if(abs((x[1] - x[0]) * (y[3] - y[2]) - (x[3] - x[2]) * (y[1] - y[0])) < EPS){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
	return 0;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;
typedef struct p{
    lint s, a, b, c;
    p(lint s_, lint a_, lint b_, lint c_){
        s = s_; a = a_; b = b_; c = c_;
    }
}p;

int main(){
    int x, y, z, k; cin >> x >> y >> z >> k;
    vector<lint> a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    sort(a.begin(), a.end(), greater<lint>());
    sort(b.begin(), b.end(), greater<lint>());
    sort(c.begin(), c.end(), greater<lint>());
    auto cp = [](const p &u, const p &v){return u.s < v.s;};
    priority_queue<p, vector<p>, decltype(cp)> que(cp);
    map<string, int> used;
    que.push(p(a[0]+b[0]+c[0], 0, 0, 0));
    used["0#0#0"]++;
    rep(i, k){
        p np = que.top(); que.pop();
        cout << np.s << endl;
        if(np.a+1 < x && !used[to_string(np.a+1)+"#"+to_string(np.b)+"#"+to_string(np.c)]){
            que.push(p(a[np.a+1]+b[np.b]+c[np.c], np.a+1, np.b, np.c));
            used[to_string(np.a+1)+"#"+to_string(np.b)+"#"+to_string(np.c)]++;
        }
        if(np.b+1 < y && !used[to_string(np.a)+"#"+to_string(np.b+1)+"#"+to_string(np.c)]){
            que.push(p(a[np.a]+b[np.b+1]+c[np.c], np.a, np.b+1, np.c));
            used[to_string(np.a)+"#"+to_string(np.b+1)+"#"+to_string(np.c)]++;
        }
        if(np.c+1 < z && !used[to_string(np.a)+"#"+to_string(np.b)+"#"+to_string(np.c+1)]){
            que.push(p(a[np.a]+b[np.b]+c[np.c+1], np.a, np.b, np.c+1));
            used[to_string(np.a)+"#"+to_string(np.b)+"#"+to_string(np.c+1)]++;
        }
    }
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  rep(i, N) {
    sum += i+1;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,K; cin>>N>>K;
    cout<<(N-1+K-2)/(K-1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n;
    cin >>n;
    vector<int> a(n),b(n);
    rep(i,n) cin >>a[i];
    rep(i,n) cin >>b[i];

    vector<int> ct_b(n+1);
    rep(i,n) ++ct_b[b[i]];

    bool ok = true;
    vector<int> c(n),d(n);
    rep(i,n){
        if(ct_b[a[i]] == 0){
            ok = false;
            c[i] = 1;
            d[i] = 2;
        }
        else c[i] = d[i] = 1;
    }


    if(ok) cout << "Yes" << endl;
    else{
        cout << "No" << endl;
        rep(i,n) cout << c[i] << " \n"[i==n-1];
        rep(i,n) cout << d[i] << " \n"[i==n-1];
    }
    return 0;
}



Measured memory_bytes: 4688
N = input()
H = [int(N[0]), int(N[1]), int(N[2]), int(N[3])]
A = H[0]
B = H[1]
C = H[2]
D = H[3]
# A = N[0], B = N[1], C = N[2], D = N[3]
# a = N[0], b = N[1], c = N[2], d = N[3]
# A = int(a), B = int(b), C = int(c), D = int(d)
c1 = {'op1':'+', 'op2':'+', 'op3':'+'}
c2 = {'op1':'+', 'op2':'+', 'op3':'-'}
c3 = {'op1':'+', 'op2':'-', 'op3':'+'}
c4 = {'op1':'+', 'op2':'-', 'op3':'-'}
c5 = {'op1':'-', 'op2':'+', 'op3':'+'}
c6 = {'op1':'-', 'op2':'+', 'op3':'-'}
c7 = {'op1':'-', 'op2':'-', 'op3':'+'}
c8 = {'op1':'-', 'op2':'+', 'op3':'+'}

if A+B+C+D == 7:
    print(str(A) + c1['op1'] + str(B) + c1['op2'] + str(C) + c1['op3'] + str(D) + '=7')
elif A+B+C-D == 7:
    print(str(A) + c2['op1'] + str(B) + c2['op2'] + str(C) + c2['op3'] + str(D) + '=7')
elif A+B-C+D == 7:
    print(str(A) + c3['op1'] + str(B) + c3['op2'] + str(C) + c3['op3'] + str(D) + '=7')
elif A+B-C-D == 7:
    print(str(A) + c4['op1'] + str(B) + c4['op2'] + str(C) + c4['op3'] + str(D) + '=7')
elif A-B+C+D == 7:
    print(str(A) + c5['op1'] + str(B) + c5['op2'] + str(C) + c5['op3'] + str(D) + '=7')
elif A-B+C-D == 7:
    print(str(A) + c6['op1'] + str(B) + c6['op2'] + str(C) + c6['op3'] + str(D) + '=7')
elif A-B-C+D == 7:
    print(str(A) + c7['op1'] + str(B) + c7['op2'] + str(C) + c7['op3'] + str(D) + '=7')
elif A-B-C-D == 7:
    print(str(A) + c8['op1'] + str(B) + c8['op2'] + str(C) + c8['op3'] + str(D) + '=7')


Measured memory_bytes: 3192
from collections import deque
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n
s = input()
t = input()
class RollingHash:
    def __init__(self, s, base, MOD):
        self.s = s
        self.l = l = len(s)
        self.base = base
        self.MOD = MOD
        self.h = h = [0]*(l + 1)
        for i in range(l):
            h[i+1] = (h[i] * base + ord(s[i])) % MOD
    def get(self, l, r):
        MOD = self.MOD
        return ((self.h[r] - self.h[l]*pow(self.base, r-l, MOD) + MOD)) % MOD
base = 3
g = gcd(len(s), len(t))
s = s * ((len(t) + len(s) - 1)//len(s))
MOD = 1004535809
rh0 = RollingHash(s, base, MOD)
rh1 = RollingHash(t, base, MOD)
N = len(s)
M = len(t)
B = rh1.get(0, M)
R = [0]*N
r = 0
for i in range(N-M+1):
    if rh0.get(i, i+M) == B:
        R[i] = r = 1
for i in range(N-M+1, N):
    if (rh0.get(i, N)*pow(base, M-(N-i), MOD) + rh0.get(0, M-(N-i))) % MOD == B:
        R[i] = r = 1
if not r:
    print(0)
    exit(0)
D = [0]*N
que = deque()
for i in range(N):
    if R[i] and R[(i+M)%N] == 0:
        que.append(i)
        D[i] = 1
if not que:
    print(-1)
    exit(0)
while que:
    v = que.popleft()
    if R[v-M]:
        que.append((v-M)% N)
        D[v-M] = D[v] + 1
print(max(D))

Measured memory_bytes: 83528
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    int N;cin>>N;
    cout<<ceil(N/2.0)<<endl;
}






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

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

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

    while(1){
        sort(begin(A), end(A));

        int x = *begin(A);
        auto it = begin(A)+1;
        while (it != end(A)){
            *it %= x;
            if (*it == 0) {
                it = A.erase(it);
            } else {
                ++it;
            }
        }

        A.erase(unique(begin(A), end(A)), end(A));
        
        if(A.size() == 1){
            break;
        }
    }

    cout << A[0] << endl;
}

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

void print_A(int A[],int n){
	for (int i = 0 ;i<n;i++) {
		if (i!=n-1 )printf("%d ",A[i]);
		else printf("%d",A[i]);
	}
	printf("\n");
	return ;
}

int selectionsort(int A[],int n ){
	int count = 0;
	for(int i =0;i<n-1;i++){
		int y=i;
		for(int j=i;j<n;j++) if(A[j]<A[y]) y=j;
		if(A[y]<A[i]) {
			swap(A[i],A[y]);
			count++;
		}
	}
	return count;
}

int main (){
	int n,A[110];
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	int a=selectionsort(A,n);
	print_A(A,n);
	printf("%d\n",a);
	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;

  vector<string> S(H);
  for (int i = 0; i < H; i++)
  {
    cin >> S.at(i);
  }
  
  for (int i = 0; i < H + 2; i++)
  {
    if (1 <= i && i <= H)
    {
      cout << "#" << S.at(i - 1) << "#";
    }
    else
    {
      for (int i = 0; i < W + 2; i++)
      {
        cout << '#';
      }
    }
    cout << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
string u,v;
int main(){
        int n;
        while(~getI(n)){
                double ans=0;
                FE(i,1,n) if(i%2) ans++;
                ans/=n;
                printf("%.10lf\n",ans);
        }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
// #include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define RFOR(i, j, k) for(int i=j ; i>=k ; i--)
#define REP(i, j) FOR(i, 0, j)
#define RREP(i, j) RFOR(i, j, 0)
#define PI 3.1415926535897932384626433832795
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    int N; cin >> N;
    vi a(N), b(100001, 0);
    REP(i, N) {
        cin >> a[i];
        b[a[i]]++;
    }

    ll x = 0;
    REP(i, b.size()) {
        if (b[i] > 1) x += b[i]-1;
    }

    ll ans = (x + 1) / 2;

    cout << N - ans * 2 << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
 
int main(){
 
  int n, t, count, i, j;
  int num[10000];
 
  scanf("%d",&n);
 
  for(i=0; i < n; i++){
    scanf("%d",&num[i]);
  }
  count = n;
 
  for (i = 0; i < n; i++){
    if (num[i] == 2) {
    }
    else if(num[i] % 2 == 0){
      count--; 
    }
    else{
      t = sqrt(num[i]);
      for(j=3; j<=t; j=j+2){
        if(num[i] % j == 0){
          count--;  
          break;  
        }
      }  
    }
  }
 
  printf("%d\n",count);
 
  return 0;
}

Measured memory_bytes: 1820
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,l;
    cin>>n>>l;
    vector<string>m(n);
    for(i=0;i<n;i++)
    {
        cin>>m[i];
    }
    sort(m.begin(),m.end());
    for(i=0;i<n;i++)
    {
        cout<<m[i];
    }
    cout<<endl;
    return 0;
}




Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

class Solver {
};

int main() {
	while (true) {
		int b;
		cin >> b;
		if (b == 0)break;

		int a = 0;
		int x = 0;
		for (int i = 1; i * i - i < 2 * b; i++) {
			if ((2 * b - i * i + i) % (2 * i) > 0)continue;

			a = (2 * b - i * i + i) / (2 * i);
			x = i;
		}

		cout << a << ' ' << x<<endl;
	}
}


Measured memory_bytes: 3068
// 2020-09-20 20:01:38
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
#include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
using namespace atcoder;

// clang-format on
int op(int a, int b) { return max(a, b); }
int e() { return -1; }
int f_;
bool f(int a) { return a < f_; }
void answer() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  segtree<int, op, e> st(a);
  rep(qi, q) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      st.set(x - 1, y);
    } else if (t == 2) {
      cout << st.prod(x - 1, y) << '\n';
    } else {
      f_ = y;
      cout << st.max_right<f>(x - 1) + 1 << '\n';
    }
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 6080
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

#define FOR(i,n) for(ll i=0;i<n;i++) 
#define RFOR(i,n) for(ll i=n-1;i>=0;--i)
#define COUT(str) cout << str << endl

#define MAX_N 100ll //"long long","int"かを変えること!!!!

//入力
int a,b,c ;

int main() {

	cin >> a >> b >> c;

	if (a <= c&&c <= b) COUT("Yes");
	else COUT("No");

	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
to = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    to[a - 1] += [b - 1]
    to[b - 1] += [a - 1]
print(sum(to[j] == [] or h[j] > max(h[i] for i in to[j]) for j in range(n)))

Measured memory_bytes: 29480
# -*- coding: utf-8 -*-
N,M = list(map(int,input().split()))

l = [list(map(int,input().split())) for _ in range(N)]
l = sorted(l, key=lambda x:x[0])
a_cnt = 0
b_cnt = 0
for a,b in l:
    if b <= M:
        b_cnt += b
        M -= b
        a_cnt += a*b
    elif b > M and M > 0:
        b_cnt += M
        a_cnt += a*M
        break
    else:
        break
print(a_cnt)


Measured memory_bytes: 29796
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, k = LI()
A = LI()
now = 0
D = {0:-1}
for i in range(min(k, n)):
    now = A[now] - 1
    if now in D:
        break
    D[now] = i

if k < n:
    print(now + 1)
    exit()

k -= (i + 1)
b = now
c = k % (i - D[now])
for j in range(c):
    b = A[b] - 1

print(b + 1)








Measured memory_bytes: 113268
s=input()

a=[1,0,0,0]

for i in range(len(s)):
    c=s[i]
    if c=="A":
        a[1]+=a[0]
    elif c=="B":
        a[2]+=a[1]
    elif c=="C":
        a[3]+=a[2]
    else:
        a=[ a[0]*3 ] + [ a[j+1]*3+a[j] for j in range(3) ]

    a=[a[i]%1000000007 for i in range(4)]

print(a[3])

Measured memory_bytes: 3188
#include <stdio.h>
 
#define MAX 1000000
int prime[MAX];

int main(void) {
  int n, i, j,c;
  for (i = 2; i < 1001; ++i)
      for (j = 2 * i; j < MAX; j += i)
        prime[j] = 1; 
  while (scanf("%d", &n) != EOF) {
	c = 0;
    for (i = 2; i <= n; i++)
		if(prime[i] != 1)
			++c; 
    printf("%d\n", c);
  } 
  return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
    int n, x; cin >> n >> x;
    vector<ll> a(n);
    ll ans = 0;
    for(int i = 0; i < n; i++)cin >> a[i];
    for(int i = 1; i < n; i++){
        if(a[i-1] + a[i] > x){
            int c = a[i-1] + a[i] - x;
            if(a[i] > c){
                a[i] -= c;
            }
            else{
                a[i] = 0;
            }
            ans += c;
        }
    }
    cout << ans << endl;



    return 0;
}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    String s = scanner.next();
    int red = 0;
    int blue = 0;
    int n = s.length();
    for(int i = 0; i < n; i++){
      if(s.charAt(i) == '0'){
        red++;
      }else{
        blue++;
      }
    }
    System.out.println(Math.min(red, blue) * 2);
  }
}


Measured memory_bytes: 24396
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
   int a[7] = {1,3,5,7,8,10,12};
   int b[4] = {4,6,9,11};
   int c[1] = {2};
   int x,y;cin>>x>>y;
   int f,g;
   rep(i,7){if(a[i]==x)f = 1;if(a[i]==y)g = 1;}
   rep(i,4){if(b[i]==x)f = 2;if(b[i]==y)g = 2;}
   if(x==2)f = 3;
   if(y==2)g = 3;
   cout<<(f==g?"Yes":"No");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) {
		cin >> A[i];
	}
	SORTR(A);
	ll res = A[0];
	FOR(i, 1, (N - 1) / 2 + 1) {
		res += 2 * A[i];
	}
	if (N % 2) {
		res -= A[(N - 1) / 2];
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ll long long
#define CL(a,b) memset(a,b,sizeof a)
#define pb push_back
#define fi first
#define sc second
#define pi pair<int,int>
#define pii pair<int,pair<int,int>>
const int N=1e5+7;
int vis[N],t[N];
int main()
{
    int n,m;
    cin>>n>>m;
    int x;
    char s[10];
    int ac=0,pt=0;
    for(int i=1; i<=m; i++)
    {
        scanf("%d%s",&x,s);
        if(!vis[x])
        {
            if(s[0]=='A')
            {

                vis[x]=1;
                ac++;
                pt+=t[x];
            }
            else
                t[x]++;
        }
    }
    printf("%d %d",ac,pt);
    return 0;
}



Measured memory_bytes: 1024
using System;

public class Hello{
    public static void Main(){
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            
            if(a < b && b < c){
                Console.WriteLine("Yes");
            }
             else{
                Console.WriteLine("No");
        }
    }
}



Measured memory_bytes: 17988
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int N;
    cin >> N;
    vector<int> p(N+1);
    vector<int> pos(N+1);
    vector<int> a(N+1),b(N+1);
    REP(i,1,N+1){
        cin >> p[i];
        pos[p[i]] = i;
    }

    REP(i,1,N+1){
        a[i] = i * N;
        b[i] = (N + 1 - i) * N;
    }

    REP(i,1,N+1){
        a[p[i]] += i;
    }

    REP(i,1,N+1){
        cout << a[i];
        if(i != N) cout << " ";
    }
    cout << endl;
    REP(i,1,N+1){
        cout << b[i];
        if(i != N) cout << " ";
    }
    cout << endl;

    REP(i,1,N){
        if(!(a[p[i]] + b[p[i]] < a[p[i+1]] + b[p[i+1]] )){
            printf("------ bad case -----\n");
            printf("i = %d\n",i);
            printf("a[i] = %d,b[i] = %d\n",a[p[i]] , b[p[i]]);
            printf("[i] = %d,b[i] = %d\n",a[p[i+1]] , b[p[i+1]]);
            cout << endl;
        }
    }





    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>
int main(void){
    int len,i;
    char str[100];
    scanf("%s",str);
    len=strlen(str);
    for(i=len-1;i>=0;i--){
        printf("%c",str[i]);
    }
    printf("\n");
    
    
    
}



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


using namespace std;

#define ll long long

int main(){
   ios::sync_with_stdio(false);
   cin.tie(0);
   int a,b,c,x;
   cin >> a >> b >> c >> x;
   //int c1=a*500,c2=b*100,c3=c*50;
   int ans=0;
   for(int i=0;i<=a;i++) {
	   for(int j=0;j<=b;j++) {
		   for(int k=0;k<=c;k++) {
				ans+=i*500+j*100+k*50==x;
		   }
	   }
   }
   cout << ans;
   return 0;
}




Measured memory_bytes: 3620
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    a = s.count("-")
    b = s.count("+")
    print(b-a)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 39024
import java.util.Scanner;

/**
 * TITLE : I miss you...
 * URL : https://atcoder.jp/contests/abc154/tasks/abc154_b
 */
public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        System.out.println(S.replaceAll("[a-z]", "x"));
        sc.close();
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n;
    cin >> n;
    if (n>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
// 区間加算クエリ
template <typename F,typename T>
struct DST{
  T identity;
  F merge;
  int size;
  vector<T> dat,delay;
  
  DST(F f,T id):merge(f),identity(id){}

  void eval(int k,int l,int r){
    if(delay[k] != 0){
      dat[k] += delay[k];
      if(k<size-1){
	delay[2*k+1] += delay[k]/2;
	delay[2*k+2] += delay[k]/2;	
      }
      delay[k]=0;
    }
  }

  void init(int n){
    size = 1;
    while(size<=n) size *= 2;
    dat.resize(size*2-1,identity);
    delay.resize(size*2-1,0);    
  }

  void build(vector<T> vec){
    rep(i,vec.size()) dat[size-1+i] = vec[i];
    dfs(0);
  }

  T dfs(int k){
    if(k>=size-1) return dat[k];
    else return dat[k] = merge(dfs(2*k+1),dfs(2*k+2));
  }

  void update(int a,int b,T x,int k,int l,int r){
    eval(k,l,r);

    if(r<=a||b<=l) return ;
    if(a<=l&&r<=b){
      delay[k] += (r-l)*x;
      eval(k,l,r);
    }
    else{
      update(a,b,x,2*k+1,l,(l+r)/2);
      update(a,b,x,2*k+2,(l+r)/2,r);
      dat[k] = merge(dat[2*k+1],dat[2*k+2]);
    }
  }

  T query(int a,int b,int k,int l,int r){
    eval(k,l,r);
    if(r<=a||b<=l) return identity;

    if(a<=l&&r<=b) return dat[k];
    else return merge(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
  }

  void all_eval(){
    rep(i,2*size-1){
      eval(i,0,0);
    }
  }

  T get(int k){ return dat[size-1+k];}
  
  void show(){
    int index = 0;
    int num = 1;
    while(index<size){
      rep(i,num){
	if(dat[i+index]==identity) cout << "e ";
	else cout << dat[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
    index = 0;
    num = 1;
    while(index<size){
      rep(i,num){
	cout << delay[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
  }
  

  
};
int main()
{
  int n,q;cin >> n >> q;
  vector<ll> c(q),s(q),t(q),x(q);
  rep(i,q){
    cin >> c[i];
    if(c[i]==0) cin >> s[i] >> t[i] >> x[i];
    else cin >> x[i];
  }

  auto f = [&](ll a,ll b){ return a+b;};
  ll id = 0;
  DST<decltype(f),ll> dst(f,id);
  dst.init(n);
  rep(i,q){
    if(c[i]==0) dst.update(s[i],t[i]+1,x[i],0,0,dst.size);
    else cout << dst.query(x[i],x[i]+1,0,0,dst.size) << "\n";
  }
  
  return 0;
}



Measured memory_bytes: 9972
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    string yes = "YES", no = "NO";
    string s;
    cin >> s;
    string t = "AKIHABARA";
    int idx = 0;
    rep(i, t.size()) {
        if(idx >= s.size()) {
            if(i+1 == t.size()) {
                cout << yes << endl;
            }
            else {
                cout << no << endl;
            }
            return 0;
        }
        if(t[i] == 'A') {
            if(s[idx] == 'A') idx++;
            else {
                
            }
        }
        else {
            if(t[i] == s[idx]) idx++;
            else {
                cout << no << endl;
                return 0;
            }
        }
    }
    if(idx == s.size()) {
        cout << yes << endl;
    }
    else cout << no << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-01-01 16:45:09
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

constexpr int64 INF = 1e18;

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

  int n; int64 x; cin >> n >> x;
  vector<int64> a(n); cin >> a;

  vector<vector<int64>> dp(n, vector<int64>(n, INF));
  // dp[i][j] : 位置 i にいるスライムを j 回動かしたときの a[i] の min

  for (int i = 0; i < n; ++i) {
    for (int move = 0; move < n; ++move) {
      int pos = (i + move) % n;
      dp[i][move] = min(dp[i][(move + n - 1) % n], a[pos]);
    }
  }

  int64 ans = INF;

  for (int move = 0; move < n; ++move) {
    int64 sum = 0;
    for (int j = 0; j < n; ++j) {
      sum += dp[j][move];
    }
    sum += move * static_cast<int64>(x);
    ans = min(ans, sum);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 31616
#include <iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    long long sum = 0;
    for(int i = 1 ; i <= n ;i++){
        if(i%3!=0 && i%5!=0)
            sum += i;
    }
    cout<<sum;
}


Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int a, b, ans = 0, k = 0, n;

int main()
{
	cin >> n;
	while (n--)
	{
		cin >> a >> b;
		if (k < a)
		{
			k = a;
			ans = a + b;
		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
#define ARR(...) vector<int>({__VA_ARGS__})
#define ARS(...) vector<string>({__VA_ARGS__})
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> base;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __DJKIM613
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

const int MAXN = 2e5 + 10;

ll N, K;
ll A[MAXN], B[MAXN];

bool f(ll val){
    ll xxx = 0;
    for(int i = 0 ; i < N ; i++){
        if(A[i] * B[i] <= val) continue;
        xxx += (A[i] - val / B[i]);
        if(xxx > K) return false;
    }
    return true;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    cin >> N >> K;
    for(int i = 0 ; i < N ; i++) cin >> A[i];
    for(int i = 0 ; i < N ; i++) cin >> B[i];

    sort(A, A + N);
    sort(B, B + N, greater<ll>());

    ll l = 0, r = 1e12;
    while(l < r){
        ll mid = (l + r) / 2;
        if(f(mid)) r = mid;
        else l = mid + 1;
    }

    cout << l << '\n';
    return 0;
}

Measured memory_bytes: 3328
a,b,c=map(int,input().split())
x=list(map(int,input().split()))
ans=0
for _ in range(a):
  y=list(map(int,input().split()))
  t=[x[i]*y[i] for i in range(b)]
  if sum(t)+c>0:
    ans+=1
print(ans)

Measured memory_bytes: 3060
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# a^n
def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod

# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

inf = 10**18
mod = 10**9+7

s = input()
ss = []
ind = 0
while ind < len(s)-1:
    if s[ind] == 'B' and s[ind+1] == 'C':
        ss.append('D')
        ind+=2
    else:
        ss.append(s[ind])
        ind+=1
if ind == len(s)-1:
    ss.append(s[ind])
ind = 0
A = 0
ans = 0
while ind < len(ss):
    if ss[ind] == 'A':
        A+=1
    elif ss[ind] == 'D':
        ans+=A
    else:
        A = 0
    ind+=1
print(ans)

Measured memory_bytes: 98768
#include <cstdio>
#include <algorithm>

typedef long long LL;
int Mod;
const int MN = 105, MK = 105;

int Binom[MN][MN], Pow[MK][MN];
int N, M, K;
int f[2][MN][MN];

int main() {
	scanf("%d%d%d%d", &N, &M, &K, &Mod);
	for (int i = 0; i <= std::max(N, M); ++i) {
		Binom[i][0] = 1;
		for (int j = 1; j <= i; ++j)
			Binom[i][j] = (Binom[i - 1][j - 1] + Binom[i - 1][j]) % Mod;
	}
	for (int i = 0; i <= K; ++i) {
		Pow[i][0] = 1;
		for (int j = 1; j <= std::max(N, M); ++j)
			Pow[i][j] = (LL)Pow[i][j - 1] * i % Mod;
	}
	int o = 0;
	f[0][0][0] = 1;
#define Z0(x) for (int i = 0; i <= N; ++i) for (int j = 0; j <= M; ++j) f[x][i][j] = 0;
	for (int t = 1; t <= K; ++t) {
		Z0(o ^ 1);
		for (int i = 0; i <= N; ++i) for (int j = 0; j <= M; ++j) if (f[o][i][j]) {
			int x = f[o][i][j], y = (LL)Pow[K - t + 1][j] * Pow[t][M - j] % Mod;
			for (int a = 0; i + a <= N; ++a, x = (LL)x * y % Mod)
				f[o ^ 1][i + a][j] = (f[o ^ 1][i + a][j] + (LL)Binom[N - i][a] * x) % Mod;
		} o ^= 1;
		Z0(o ^ 1);
		for (int i = 0; i <= N; ++i) for (int j = 0; j <= M; ++j) if (f[o][i][j]) {
			int x = f[o][i][j], y = (LL)Pow[K - t + 1][i] * Pow[t][N - i] % Mod;
			for (int b = 0; j + b <= M; ++b, x = (LL)x * y % Mod)
				f[o ^ 1][i][j + b] = (f[o ^ 1][i][j + b] + (LL)Binom[M - j][b] * x) % Mod;
		} o ^= 1;
		Z0(o ^ 1);
		for (int i = 0; i <= N; ++i) for (int j = 0; j <= M; ++j) if (f[o][i][j]) {
			int x = f[o][i][j], y = (LL)(Mod - Pow[K - t][j]) * Pow[t][M - j] % Mod;
			for (int c = 0; i + c <= N; ++c, x = (LL)x * y % Mod)
				f[o ^ 1][i + c][j] = (f[o ^ 1][i + c][j] + (LL)Binom[N - i][c] * x) % Mod;
		} o ^= 1;
		Z0(o ^ 1);
		for (int i = 0; i <= N; ++i) for (int j = 0; j <= M; ++j) if (f[o][i][j]) {
			int x = f[o][i][j], y = (LL)(Mod - Pow[K - t][i]) * Pow[t][N - i] % Mod;
			for (int d = 0; j + d <= M; ++d, x = (LL)x * y % Mod)
				f[o ^ 1][i][j + d] = (f[o ^ 1][i][j + d] + (LL)Binom[M - j][d] * x) % Mod;
		} o ^= 1;
	}
	printf("%d\n", f[o][N][M]);
	return 0;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> cnt(N);
    vector<int> flag(N);
    for (int i = 0; i < N; i++) {
        cnt[i] = 1;
    }
    flag[0] = 1;
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        if (flag[x] == 1) {
            flag[y] = 1;
        }
        if (cnt[x] == 1) {
            flag[x] = 0;
        }
        cnt[x]--, cnt[y]++;
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (flag[i]) ans++;
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	string s;
  int n;
  cin>>n;
  cin>>s;
  int len=s.length();
  if(len<=n)cout<<s<<endl;
  else {
    for(int i=0;i<n;i++)
    {cout<<s[i];}
    cout<<"..."<<endl;
        }
  
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed << setprecision(10);
    LL s, w;
    cin >> s >> w;
    string ret = (s > w)? "safe" : "unsafe";

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

Measured memory_bytes: 3652
n, m = map(int, input().split())
s=[]
c=[]
num=[]
for i in range(m):
  S, C = map(int, input().split())
  s.append(S)
  c.append(C)

for i in range(10**(n+1)):
  String=str(i)
  if len(String) == n and all([String[s[j]-1] == str(c[j]) for j in range(m)]):
    print(str(i))
    exit()
print('-1')

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
typedef long long ll;
ll mod_pow(ll, ll, ll);
ll mod_fact(ll, ll);
ll mod_inv(ll, ll);
//
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<bool>> map(h + 2, vector<bool>(w + 2));
  for(int i = 0; i < h; i++){
    string s;
    cin >> s;
    for(int j = 0; j < w; j++){
      if(s[j] == '.'){
        map[i + 1][j + 1] = true;
      }
    }
  }
  int white = 0;
  for(int i = 0; i < h + 2; i++){
    for(int j = 0; j < w + 2; j++){
        if(map[i][j]) white++;
    }
  }
  vector<vector<int>> dis(h + 2, vector<int>(w + 2));
  queue<pair<int, int>> que;
  que.push(make_pair(1, 1));
  while(!que.empty()){
      auto p = que.front();
      int x = p.first;
      int y = p.second;
      que.pop();
      for(int i = 0; i < 4; i++){
          int cx = x + dx[i];
          int cy = y + dy[i];
          if(!map[cx][cy] || dis[cx][cy] || (cx == 1 && cy == 1)){
              continue;
          }
          que.push(make_pair(cx, cy));
          dis[cx][cy] = dis[x][y] + 1;
       }
  }
  if(dis[h][w] == 0) cout << -1;
  else cout << white - (dis[h][w] + 1);
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()

class BIT(object):
    def __init__(self,A,dot=lambda x,y:x+y,e=0,inv=None):
        n=len(A)
        self.__n=n; self.__dot=dot; self.__e=e; self.__inv=inv; self.__node=['$']+A
        for i in range(1,n+1):
            j=i+(i&-i)
            if(j<=n): self.__node[j]=dot(self.__node[i],self.__node[j])

    def add(self,i,w=1):
        i+=1
        while(i<=self.__n):
            self.__node[i]=self.__dot(self.__node[i],w)
            i+=i&-i

    def sum(self,i):
        res=self.__e
        while(i>0):
            res=self.__dot(res,self.__node[i])
            i-=i&-i
        return res

    def range_sum(self,l,r):
        assert(self.__inv)
        return self.__inv(self.sum(r),self.sum(l))

def resolve():
    n,k=map(int,input().split())
    A=[int(input())-k for i in range(n)]
    S=[0]*(n+1)
    for i in range(n):
        S[i+1]=S[i]+A[i]

    # S[i] の転倒数を考えれば良く、そのために座圧する
    D={s:i for i,s in enumerate(sorted(set(S)))}
    for i in range(n+1):
        S[i]=D[S[i]]

    ans=0
    bit=BIT([0]*(max(S)+1))
    for s in S:
        ans+=bit.sum(s+1)
        bit.add(s)

    print(ans)
resolve()

Measured memory_bytes: 84660
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i, _ := range a {
		fmt.Scan(&a[i])
	}

	ma := make(map[int]int)
	for _, v := range a {
		ma[v]++
	}
	if len(ma) == len(a) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 14336