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

using namespace std;

int main(void) {
  string s;
  cin >> s;
  int ans;
  string days[] = {
    "SAT","FRI","THU","WED","TUE","MON", "SUN"
  };

  for(int i = 0;i < 7;i++){
    if(s == days[i]) {
      cout << i + 1 << endl;
    }
  }

  return 0;
}


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

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

int a, b, c;

int f(int x) {
    return (a*x + b) % c;
}

void solve(int n, int x) {
    vector<int> Y(n);
    rep(i,n) cin >> Y[i];

    int p = 0;
    for(int frame=0; ; frame++) {
        if(frame > 1e4) break;
        if(x == Y[p]) p++;
        if(p == n) {
            cout << frame << "\n";
            return ;
        }
        x = f(x);
    }
    cout << -1 << "\n";
    return ;
}

int main() {
    int n, x;
    while(cin>>n>>a>>b>>c>>x && n) solve(n,x);
    return 0;
}

Measured memory_bytes: 3044
n = int(input())
a = []
for i in range(1,500):
    a.append(i*(i-1)//2)
if (n in a):
    print("Yes")
    x = a.index(n)+1 #3
    ans = [[] for _ in range(x)]
    now = 1
    l = 0
    while l<x:
        for i in range(x-l-1):
            ans[l].append(now)
            ans[l+1+i].append(now)
            now += 1
        l += 1
    print(x)
    for i in range(x):
        print(x-1,*ans[i])
        
else:
    print("No")

Measured memory_bytes: 13956
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
bool cmp(string a,string b){
    ll sa = a.size();
    ll sb = b.size();
    bool fa=true;
    rep(i,min(sa,sb)){
        if(a[i]!=b[i]) return a[i]<b[i];
    }
    return sa<sb;
}
signed main(){
    string s;
    ll k;
    cin>>s>>k;
    vector<string> s1;
    ll ss =s.size();
    rep(i,ss){
        for(ll j=0;(i+j<ss&&j<5);j++){
            s1.push_back(s.substr(i,j+1));
        }
    }
    sort(s1.begin(),s1.end(),cmp);
    unique(s1.begin(),s1.end());
    cout<<s1[k-1]<<endl;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 1005, M = 2005;
const long long mod = 1000000007ll, inf = 100000000000000ll;

struct edge {
	int u, v;
	long long dist;
	bool operator < (edge rhs) const {
		return dist < rhs.dist;
	}
} g[M];

int n, m, sz[N], fa[N];
long long val[N], res[M], mst = 0, X;
int findroot (int u) {
	return fa[u] == u ? u : findroot(fa[u]);
}

long long query (int u, int v) {
	stack<int> stk1, stk2;
	while (fa[u] != u) stk1.push(u), u = fa[u];
	while (fa[v] != v) stk2.push(v), v = fa[v];
	while (!stk1.empty() && !stk2.empty() && stk1.top() == stk2.top()) stk1.pop(), stk2.pop();
	long long ans = -inf;
	if (!stk1.empty()) ans = max(ans, val[stk1.top()]);
	if (!stk2.empty()) ans = max(ans, val[stk2.top()]);
	return ans;
}

int main () {
	scanf("%d%d", &n, &m);
	scanf("%lld", &X);
	for (int i = 1; i <= n; i++) sz[i] = 1, fa[i] = i;
	for (int i = 1; i <= m; i++) scanf("%d%d%lld", &g[i].u, &g[i].v, &g[i].dist);

	sort(g + 1, g + m + 1);
	for (int i = 1; i <= m; i++) {
		int ru = findroot(g[i].u), rv = findroot(g[i].v);
		if (ru != rv) {
			if (sz[ru] > sz[rv]) swap(ru, rv);
			fa[ru] = rv, sz[rv] += sz[ru];
			mst += (val[ru] = g[i].dist), res[i] = -inf;
		}
		else res[i] = query(g[i].u, g[i].v);
	}

	long long ans = 0ll;
	if (mst == X) {
		int cnt = 0;
		for (int i = 1; i <= m; i++) {
			if (res[i] <= -inf || res[i] == g[i].dist) cnt++;
		}

		ans = 1ll;
		for (int i = 0; i < cnt; i++) ans = ans * 2ll % mod;
		ans = (ans + mod - 2) % mod;
		for (int i = 0; i < m - cnt; i++) ans = ans * 2ll % mod;
		printf("%lld\n", ans);
	}
	else {
		int cnt1 = 0, cnt2 = 0;
		for (int i = 1; i <= m; i++) {
			if (mst + g[i].dist - res[i] == X) cnt1++;
			else if (res[i] > -inf && mst + g[i].dist - res[i] > X) cnt2++;
		}

		ans = 1ll;
		for (int i = 0; i < cnt1; i++) ans = ans * 2ll % mod;
		ans = (ans + mod - 1) % mod;
		for (int i = 0; i <= cnt2; i++) ans = ans * 2ll % mod;
		printf("%lld\n", ans);
	}
	return 0;
}

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 inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int a,b,x;cin>>a>>b>>x;
    if(a<=x && x<=a+b){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }

}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k;
int a[200005];
ll sum;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> k;
	for(int i = 1;i <= n;i++) {
		cin >> a[i];
	}
	sort(a+1,a+n+1);
	for(int i = 1;i <= n-k;i++) {
		sum += a[i];
	}
	cout << sum;
}

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.nextLine();
        String t = scanner.nextLine();
        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != t.charAt(i)) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

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

int main()
{
    int n, d;
    scanf("%d %d", &n, &d);
    int i = d+1;
    int cnt = 1;
    while(i+d < n)
    {
        cnt ++;
        i += 2*d+1;
    }

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


    return 0;
}

Measured memory_bytes: 128
// みなさん私はカーティキー・シャルマです。LNMIITで勉強しています。私は2年目で、コロナパンデミックが発
// 生しています。世界は終わりそうだ。だから私はそれを最大限に生きたいと思っています。それはつまり、コー
// ドを最大限に意味しているのです。私の好きなアニメは「キメツノヤイバ」で、私の一番の男の子はゼニツで、
// 私の一番の女の子はネズコです。私の好きな呼吸スタイルは息吹です。私の最高の悪魔の血の芸術は、
// ククシボによって使用される月の息です。ムーザンは亡くなり、今ではタンジローがポップの新しい魔王です。
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(lld i = 0; i < n; i+=1)
#define fod(i,n) for(lld i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define LEN 100005
lld dda[LEN][3];
lld vis[LEN][4];
lld rec_ (lld day, lld type, lld n)
{
	if (vis[day][type] == -1){
		if (day == n+1) vis[day][type] = 0;
		else{
			lld ans = MIN;
			for(lld i = 1; i < 4; i += 1)
			{
				if (i != type){
					ans = max(ans, rec_(day+1,i,n)+dda[day][i]);
				}
			}
			vis[day][type]  = ans;
		}
	}
	return vis[day][type];
}
int main ()
{
      FastIO
      lld n;
      cin >> n;
      for(lld i = 1; i <= n; i += 1){
      	cin >> dda[i][1] >> dda[i][2] >> dda[i][3];
      }
      memset(vis, -1, sizeof(vis));
      cout << rec_(1, 0, n);
      return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 998244353;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

ll dp[3050][3050];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, S;
    cin >> N >> S;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    dp[0][0] = 1LL;
    rep(i, N) {
      rep(j, S+1) {
        dp[i+1][j] += (2 * dp[i][j]) % mod;
        dp[i+1][j] %= mod;
        if (j + A[i] <= S) {
          dp[i+1][j+A[i]] += dp[i][j];
          dp[i+1][j+A[i]] %= mod;
        }
      }
    }
    cout << dp[N][S] << endl;
    return 0;
}

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

typedef struct sort_t{
    int X;
    int L;
}sort;
sort lr[100000];
int comp(const void *a, const void *b)
{
    sort lr1 = *((sort *)a);
    sort lr2 = *((sort *)b);
    int v1 = lr1.X + lr1.L;
    int v2 = lr2.X + lr2.L;

    if (v1 > v2) {
      return 1;
    } else if (v1 < v2) {
      return -1;
    } else {
      return 0;
    }
}

int main(void)
{
    int N, X, L;
    int cnt = 0;
    int min = -1000000000;
    int i;

    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        scanf("%d %d", &lr[i].X, &lr[i].L);
    }
    qsort(lr, N, sizeof(*lr), comp);

    for (i = 0; i < N; i++) {
        int left = lr[i].X - lr[i].L;
        int right = lr[i].X + lr[i].L;
        if (min <= left){
            cnt++;
            min = right;
        }
    }

    printf("%d", cnt);

    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  int cnt = 0;
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    if(a[i] % 2 == 1) cnt++;
  }
  if(cnt % 2 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;


long long  A, B, C, D,a[3000], c[10], d[10], now, num, N, K, M, ans;
string S, s[100];
bool h,w[10], k[100];
char cc;


int main() {
	cin >> A>>B>>C>>D;
	
	cout <<min(A,B)+min(C,D)<<endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>



using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
/*
 execution in cmd of windows: g++ p1.cpp -op1
  
  
  p1
 
 */
typedef double dd;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl <<"\n"
#define con continue
#define br break
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
ll mx=INT_MAX;
ll mi=INT_MIN;
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define all(v) v.begin(), v.end()
#define fsort(v) sort(all(v))  
#define rsort(v) sort(v.rbegin(),v.rend())
#define rev(v) reverse(all(v))
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define sumv(v,x) accumulate(v.begin(),v.end(),x);
const ll mod = 1000000007;
const ll inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const ll MOD=1e9+7;
#define io { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define cs ll t;cin>>t;while(t--)
#define cs1 ll t;t=1;while(t--)

int main()
{
   #ifndef ONLINE_JUDGE
        ifstream cin("in.in");
        ofstream cout("out.out");
    #endif
    
        io;
        //////////////////////////////////
         cs1{
             ll i,j,s=0,c,k,q=0,n,m=0,e;
             cin>>n;
             if(n==0) cout<<1;
             else cout<<0;
        }
        //////////////////////////////////
        cer;
}


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

int main(){
	int N;
	cin >> N;
	multiset<int> seta;
	int res = 0;
	for(int i = 0; i < N; i++){
		int A;
		cin >> A;
		if(seta.empty()){
			seta.insert(A);
			res++;
		}else{
			multiset<int>::iterator itr = seta.lower_bound(A);
			if(itr == seta.begin()){
				seta.insert(A);
				res++;
			}else{
				itr--;
				seta.erase(itr);
				seta.insert(A);
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4992
def binary_search(array, key)
    left = 0
    right = array.length
    while left < right
        mid = (left + right) / 2
        if array[mid] == key
            return mid
        elsif key < array[mid]
            right = mid
        else
            left = mid + 1
        end
    end
    return -1
end

line_count = gets.to_i
array = gets.split(" ").map(&:to_i)
search_count = gets.to_i
search_array = gets.split(" ").map(&:to_i)
puts search_array.count{|n| binary_search(array, n) > 0}


Measured memory_bytes: 15344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
操作の逆順を考える
 */

struct  edge{int from,to,cost;};
edge es[2010];
int d[1010];
int V,E;

void Bellman(int s){
    rep(i,V)d[i]=mod;
    d[s]=0;
    int cnt=0;
    while(true){
        bool update=false;
        rep(i,E){
            edge e=es[i];
            if(d[e.from]!=mod && chmin(d[e.to],d[e.from]+e.cost))update=true;
        }
        if(!update){
            rep(i,V){
              	if(d[i]==mod)cout << "INF" << endl;
                else cout << d[i] << endl;
            }
            break;
        }
        if(cnt>V){
          cout << "NEGATIVE CYCLE" << endl;
          break;
        }
        cnt++;
    }
}

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    cin >> V >> E;
    int r;
    cin >> r;
  	rep(i,E){
    	int x,y,z;
      	cin >> x >> y >> z;
      	es[i]={x,y,z};
    }
    Bellman(r);
    


}

/*



 */



Measured memory_bytes: 3120
#include <iostream>
using namespace std;
int main(){
  int a[3];
  bool z;
  cin >>a[0]>>a[1]>>a[2];
  z = a[0]+a[1]+a[2] > 21 ? true : false;
  if(z) cout <<"bust"<<endl;
  else cout << "win"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
using namespace std;

int H[2], N, S[2];
char A[200200], B[200200];

bool solve(int h, int s, vector<int> &a, vector<int> &b)
{
	int l = 1, r = h;
	for (int i = N - 1; i >= 0; i--){
		if (b[i] == 1) l--;
		if (b[i] == -1) r++;

		if (l < 1) l = 1;
		if (r > h) r = h;

		if (a[i] == -1) l++;
		if (a[i] == 1) r--;
		if (l > r) return true;
	}

	return !(l <= s && s <= r);
}

int main()
{
	scanf ("%d %d %d %d %d %s %s", &H[0], &H[1], &N, &S[0], &S[1], A, B);

	for (int k = 0; k < 2; k++){
		vector<int> a, b;
		if (k == 0){
			for (int i = 0; i < N; i++){
				if (A[i] == 'U') a.push_back(-1);
				else if (A[i] == 'D') a.push_back(1);
				else a.push_back(0);
				if (B[i] == 'U') b.push_back(-1);
				else if (B[i] == 'D') b.push_back(1);
				else b.push_back(0);
			}
		}
		else{
			for (int i = 0; i < N; i++){
				if (A[i] == 'L') a.push_back(-1);
				else if (A[i] == 'R') a.push_back(1);
				else a.push_back(0);
				if (B[i] == 'L') b.push_back(-1);
				else if (B[i] == 'R') b.push_back(1);
				else b.push_back(0);
			}
		}

		if (solve(H[k], S[k], a, b)){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 3548
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)));
#define Mx(a , b) ((a) > (b) ? (a) : (b))
#define Mn(a , b) ((a) < (b) ? (a) : (b))

const double EPS = 1e-10;
const int INF = 2147483647;

LL a , b;

int main(){
	scanf("%lld%lld" , &a , &b);
	if(a * b <= 0){
		printf("Zero\n");
	} else if(b < 0 && (b - a + 1) % 2 == 1){
		printf("Negative\n");
	} else {
		printf("Positive\n");
	}
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main {
 
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt() - 1;
		int b = sc.nextInt() - 1;
		int total = 0;

		if(b != 1){
			total = (b+a-1)/a;
		}
		System.out.println(total);
	}
}

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

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Point = Tuple!(double, "x", double, "y");

void main() {
    int N;
    scan(N);
    auto a = readln.split.to!(long[]);

    auto c = new int[](60);

    long ans;

    foreach (i ; 0 .. N) {
        foreach (j ; 0 .. 60) {
            if (a[i] & (1L << j)) {
                ans += (1L << j) % mod * (i - c[j]) % mod;
                ans %= mod;
                c[j]++;
            }
            else {
                ans += (1L << j) % mod * c[j] % mod;
                ans %= mod;
            }
        }
    }

    writeln(ans);
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 18480
#include <iostream>

int main(int argc, char const* argv[])
{
  int a, b, c, x;
  std::cin >> a >> b >> c >> x;

  int cnt = 0;
  for (int ai = 0; ai <= a; ++ai) {
    for (int bi = 0; bi <= b; ++bi) {
      for (int ci = 0; ci <= c; ++ci) {
        if (ai * 500 + bi * 100 + ci * 50 == x) {
          ++cnt;
        }
      }
    }
  }
  std::cout << cnt << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
int K,A,B;
  cin >> K;
  cin >> A >> B;
  

  int C =  K* ceil(1.0*A/K); 

  if(C <= B)
 {
  cout<< "OK";
 }else{
   cout<< "NG";
 }
   
}


Measured memory_bytes: 3640
N = int(input())
AB = [[0, 0]] * N
for i in range(N):
  AB[i] = [int(i) for i in input().split()]
AB.sort(key=lambda x: x[1])

res = "Yes"
time_sum = 0
for i in range(N):
  time_sum += AB[i][0]
  if time_sum > AB[i][1]:
    res = "No"
    break

print(res)


Measured memory_bytes: 41164
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
 string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>s;
  x = 10 *(s[0]-'0') + (s[1]-'0');
  y = 10 *(s[2]-'0') + (s[3] -'0');
  if((x<=12 and x>=1) and (y<=12 and y>=1) )
  cout<<"AMBIGUOUS";
else if((x<=12 and x>=1))
  cout<<"MMYY";
else if((y<=12 and y>=1))
  cout<<"YYMM";
else cout<<"NA";
}

signed main(){
   
      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 256
import math

A, B, H, M = [int(i) for i in input().split(' ')]

A_theta = 30 * H + 0.5 * M
B_theta = 6 * M

theta = abs(B_theta - A_theta)

cos = math.cos(math.radians(theta))

dist = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * cos)

print(dist)

Measured memory_bytes: 9392
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{

    int a;
    cin >> a;
    for (int i = 1; i < 10; i++)
    {
        if (a % i == 0 && a / i < 10)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;

    private string[] S;
    private int Index;
    private const char Separator = ' ';

    public Scanner(Stream source)
    {
        Index = 0;
        S = new string[0];
        Sr = new StreamReader(source);
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public decimal NextDecimal()
    {
        return decimal.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[] LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }
    public bool EndOfStream
    {
        get { return Sr.EndOfStream; }
    }
}

public class Magatro
{
    private Scanner Cin;
    private int N;
    private int[] A;

    private void Scan()
    {
        Cin = new Scanner(Console.OpenStandardInput());
        N = Cin.NextInt();
    }
    public void Solve()
    {
        Scan();
        Console.WriteLine(N * 800 - 200 * (N / 15));
    }
}

Measured memory_bytes: 11092
#include<iostream>
 
using namespace std;
 
int main()
{
  int a, b, c;
 
  cin >> a >> b >> c;
 
  if (( a < b ) && ( b < c ))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

typedef priority_queue<int, vector<int>, greater<int>> minPq;
typedef priority_queue<int> maxPq;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<int> vll;
typedef pair<ll, ll> pll;
const int INF = 1e9 + 7;
const ll INFL = 1e18 + 7;
void init() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef _DEBUG
    freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#endif
}
vector<ll> ww, vv, dp;
int N, W;
ll V = 0;

int main() {
    init();
    cin >> N >> W;
    ww.resize(N);
    vv.resize(N);
    for (int i = 0; i < N; ++i) {
        cin >> ww[i] >> vv[i];
        V += vv[i];
    }
    dp.assign(V + 1, INFL);
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = V; j>=0; --j) {
            if (j + vv[i] <= V) {
                dp[j + vv[i]] = min(dp[j + vv[i]], ww[i] + dp[j]);
            }
        }
    }

        for (int i = V; i >= 0; --i) {
            if (dp[i] <= W) {
                cout << i << endl;
                break;
            }
        }
    }


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,m;
  cin>>n>>m;
  ll l[m],r[m];
  for(ll i=0;i<m;i++)
    	cin>>l[i]>>r[i];
  sort(l,l+m);
  sort(r,r+m);
  
  if(r[0]-l[m-1]<=-1)
    cout<<0;
  else
    cout<<r[0]-l[m-1]+1;
	return 0;
}

Measured memory_bytes: 1792
n,m = map(int,input().split())
A = list(map(int,input().split()))
for i,a in enumerate(A):
    A[i] //=2
from math import gcd,ceil
def lcm(a, b):
    return a*b//gcd(a,b)
b = 1

div_two_cnt = None
for a in A:
    cnt = 0
    while a % 2 == 0:
        a //= 2
        cnt += 1
    if div_two_cnt is None:
        div_two_cnt = cnt
    elif cnt != div_two_cnt:
        print(0)
        exit()

for i in range(n):
    a = A[i]
    b = lcm(a,b)


print(ceil((m//b)/2))



Measured memory_bytes: 84584
#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,k;
    cin >>n >>k;

    int ct = 0;
    for(int i=1; i<=n; i+=2) ++ct;

    string ans = "NO";
    if(ct >= k) ans = "YES";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back      
#define F first
#define S second
#define SS stringstream
#define sqr(x) ((x)*(x))
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define CC(x) cout << (x) << endl
#define pw(x) (1ll<<(x))
#define buli(x) __builtin_popcountll(x)
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define M 1000000007
#define N 211111

#define TASK "1"

using namespace std;

int n;
int a[N];

int main(){
	#ifdef home
		freopen(TASK".in","r",stdin);	
		freopen(TASK".out","w",stdout);
	#endif		
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) if (a[i] > i && a[a[i]] == i) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
 
#n = int(input())
h,w,n = [int(i) for i in readline().split()]
ab = [[int(i)-1 for i in readline().split()] for _ in range(n)]

ans = [0]*10

#print(ab)
d = {}
for a,b in ab:
    for i in range(3):
        for j in range(3):
            if a-i < 0 or b-j < 0 or a-i >= h-2 or b-j >= w-2: continue
            if (a-i,b-j) in d:
                d[(a-i,b-j)] += 1
            else:
                d[(a-i,b-j)] = 1
        
#print(d)
for i in d.values():
    ans[i] += 1




ans[0] = (h-2)*(w-2) - sum(ans)
print(*ans)









Measured memory_bytes: 184684
#include<bits/stdc++.h>
using namespace std;
#define MAXN	200005
#define P	1000000007
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
long long fac[MAXN], inv[MAXN];
void update(long long &x, long long y) {
	x = (x + y) % P;
}
long long power(long long x, long long y) {
	if (y == 0) return 1;
	long long tmp = power(x, y / 2);
	if (y % 2 == 0) return tmp * tmp % P;
	else return tmp * tmp % P * x % P;
}
long long getc(long long x, long long y) {
	return fac[x + y] * inv[y] % P * inv[x] % P;
}
int main() {
	int n, m, a, b, N;
	read(n), read(m), read(a), read(b);
	N = n + m;
	fac[0] = 1;
	for (int i = 1; i <= N; i++)
		fac[i] = fac[i - 1] * i % P;
	inv[N] = power(fac[N], P - 2);
	for (int i = N - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1) % P;
	int x = a + 1, y = b + 1;
	long long ans = 0;
	while (x <= n && y <= m) {
		update(ans, getc(n - x, y - 1) * getc(x - 1, m - y));
		x++; y++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> p(n),a(n),b(n),c(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &p[i]);
        p[i]--;
        c[p[i]]=i+1;
        a[i]=i+1;
        b[i]=n-i;
    }

    int sum_amod=0;
    int sum_bmod=0;
    for(i=0; i<n; i++) {
        int mod = c[i]-(a[i]+sum_amod)-(b[i]-sum_bmod);
        if(mod>0) {
            sum_amod += mod;
        }
        else {
            sum_bmod -= mod;
        }
        a[i] += sum_amod;
        b[i] -= sum_bmod;
    }

    int modb=0;
    if(b[n-1]<1) modb=(1-b[n-1]);

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

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

    return 0;
}


Measured memory_bytes: 896
#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 <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int N, K;
  string out = "";
  cin >> N >> K;
  while (N > 0)
  {
    out = to_string(N % K) + out;
    N /= K;
  }
  cout << out.length() << endl;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define se second
#define pb push_back
 
 
using namespace std;
 
 
const int N =  1e3 + 123;
const int MAXN = 2e5;
const int brd = 32;
const ull inf = 1e18 + 7;



ll n, m, X[N], Y[N], pw[40], ln[N]; 
char ans[N][40];


void rec(ll id, ll x, ll y, ll ind) {
    if (ind == 0)
        return;
    if (y > x && y > -x) {
        ans[id][ind] = 'U';
        rec(id, x, y - ln[ind], ind - 1);
    } else if (y > x && y < -x) {
        ans[id][ind] = 'L';
        rec(id, x + ln[ind], y, ind - 1);
    } else if (y < x && y < -x) {
        ans[id][ind] = 'D';
        rec(id, x, y + ln[ind], ind - 1);
    } else {
        ans[id][ind] = 'R';
        rec(id, x - ln[ind], y, ind - 1);
    }
}
 
 
int main() {
    cin >> n;
    bool s1 = 0, s2 = 0;
    for (int i = 1; i <= n; i++) {
        cin >> X[i] >> Y[i];
        if ((X[i] + Y[i]) % 2 == 0)
            s1 = 1;
        else
            s2 = 1;
    }
    if (s1 && s2)
        return cout << -1, 0;
    if (s1) {
        for (int i = 1; i <= n; i++)
            X[i]--;
    }
    ll t = 1;
    for (int i = 0; i <= brd; i++) {
        ln[i + 1] = t;
        t *= 2;
    }
    m = brd + 1;
    for (int i = 1; i <= n; i++)
        rec(i, X[i], Y[i], m);
    if (s1) {
        m++;
        ln[m] = 1;
        for (int i = 1; i <= n; i++)
            ans[i][m] = 'R';
    }
    cout << m << "\n";
    for (int i = 1; i <= m; i++)
        cout << ln[i]  << " ";
    cout << "\n";
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++)
            cout << ans[i][j];
        cout << "\n";
    }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int res = 1;
  for (int i = 0; i < N; i++) {
    if (res >= K) {
      res += K*(N - i);
      break;
    }
    else res *= 2;
  }
  cout << res << endl;
}

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

class Timer {
	std::chrono::high_resolution_clock::time_point m_start;
public:
	Timer() 
	: m_start(std::chrono::high_resolution_clock::now()) {}

	~Timer() {
		auto end = std::chrono::high_resolution_clock::now();
  		auto duration_s = std::chrono::duration<double>(end - m_start).count();
  		cerr << "Completed in " << duration_s << endl;
  	}
};

template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
#ifdef LOCAL
	~debug() { cerr << endl; }
	template < class c > typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) { cerr << boolalpha << i; return *this; }
	template < class c > typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) { return *this << range(begin(i), end(i)); }
	template < class c, class b > debug & operator <<(pair < b, c > d) {
	  return * this << "(" << d.first << ", " << d.second << ")";
	}
	template < class c > debug & operator <<(rge<c> d) {
	  *this << "[";
	  for (auto it = d.b; it != d.e; ++it)
	    *this << ", " + 2 * (it == d.b) << *it;
	  return * this << "]";
	}
#else
	template < class c > debug & operator <<(const c&) { return * this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#include <iostream>

void solve() {
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

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

	for (int i = 0; i < n-1; ++i) {
		cin >> c[i];
	}
	
	{
		int sum = b[a[0] - 1];
		for (int i = 1; i < n; ++i) {
			debug() << sum;
			sum += b[a[i] - 1];
			if (a[i] == a[i-1] + 1) {
				sum += c[a[i-1] - 1];
			}
		}

	
		cout << sum << endl;
		Timer timer;
	}
}

int main() {
	FAST
	int t = 1;
	// cin >> t;

	for (int i = 0; i < t; ++i) {
		solve();
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  bool success=true;
  cin>>str;
  for(int i=0;i<str.size();i+=2){
    if(str[i]=='L'){
      success=false;
    }
  }
  for(int i=1;i<str.size();i+=2){
    if(str[i]=='R'){
      success=false;
    }
  }
  
  if(success){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return(0);
}
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

int N;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N;

	for(int i=1;i<10;i++) {
		int p = N/i;
		int r = N%i;

		if(r==0 && p<10) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;



	return 0;
}




Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
MOD = 1000000007


def main():
    N, Q, *queries = map(int, read().split())
    queries = [(q, x) for q, x in zip(*[iter(queries)] * 2)]

    N -= 2

    # N: 処理する区間の長さ

    N0 = 2 ** (N - 1).bit_length()
    data1 = [None] * (2 * N0)
    data2 = [None] * (2 * N0)
    INF = (-1, 2 ** 31 - 1)
    # 区間[l, r+1)の値をvに書き換える
    # vは(t, value)という値にする (新しい値ほどtは大きくなる)
    def update(l, r, v, data):
        L = l + N0
        R = r + N0
        while L < R:
            if R & 1:
                R -= 1
                data[R - 1] = v

            if L & 1:
                data[L - 1] = v
                L += 1
            L >>= 1
            R >>= 1

    # a_iの現在の値を取得
    def _query(k, data):
        k += N0 - 1
        s = INF
        while k >= 0:
            if data[k]:
                s = max(s, data[k])
            k = (k - 1) // 2
        return s

    # これを呼び出す
    def query(k, data):
        return _query(k, data)[1]

    update(0, N, (0, N), data1)
    update(0, N, (0, N), data2)

    min1 = min2 = N + 10
    ans = N * N

    for i, (q, x) in enumerate(queries, 1):
        x -= 2
        if q == 1:
            data = data1
            this_min = min1
        else:
            data = data2
            this_min = min2

        n = query(x, data)
        ans -= n

        if x > this_min:
            continue

        if q == 1:
            min1 = x
            update(0, n, (i, x), data2)
        else:
            min2 = x
            update(0, n, (i, x), data1)

    print(ans)
    return


if __name__ == '__main__':
    main()


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

int main() {
    int N;
    cin >> N;
    int minCnt = 1e9;

    for (int i = 0; i < N + 1; i++) {
        int cnt = 0;
        int t = i;
        while(t > 0) {
            cnt += t % 6;
            t /= 6;
        }
        t = N - i;
        while(t > 0) {
            cnt += t % 9;
            t /= 9;
        }
        if (cnt < minCnt) {
            minCnt = cnt;
        }
    }
    cout << minCnt << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

ll array_sum(vector<ll> &a,int i)
{
  if(i==a.size())
  {
    return 0;
  }
  ll s=array_sum(a,i+1);
  return a.at(i)+s;
}
int main()
{
  int n,m;
  //input N,M
  cin >> n >> m;

  vector<ll> a(n);
  vector<ll> b(m);
  vector<ll> c(m);
  // input A
  for(int i=0;i<n;i++)
  {
    cin >> a.at(i);
  }
  // input B,C
  for(int i=0;i<m;i++)
  {
    cin >> b.at(i) >> c.at(i);
  }
  sort(a.begin(),a.end());
  vector<pair<ll,ll>> p;
  for(int i=0;i<m;i++)
  {
    p.push_back(make_pair(c.at(i),b.at(i)));
  }
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  int j=0;
  int flag=0;
  for(auto t : p)
  {
    for(int l=0;l<t.second;l++)
    {
      if(j==n){
        flag=1;
        break;
      }
      else if(a.at(j)>t.first){
        flag=1;
        j++;
        break;
      }
      else{
        a.at(j)=t.first;
        j++;
      }
    }
    if(flag==1){
      break;
    }
  }
  //sum
  ll ans=array_sum(a,0);
  //output
  cout << ans << endl;


}


Measured memory_bytes: 7408
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#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 <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<long long> A(N);
	long long XOR = 0;
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		XOR ^= A.at(i);
	}

	for (int i = 0; i < N; i++) {
		long long ans = A.at(i) ^ XOR;
		cout << ans << " ";
	}
	cout << endl;
}

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

int main(){
    int X;
    int day;
    vector<string> youbi{"thu","fri","sat","sun","mon","tue","wed"};
    cin>>X;
    day=X%7;
    cout<<youbi[day]<<endl;
    return 0;
}


Measured memory_bytes: 3204
import fractions
n,X = map(int,input().split())
x_ = list(map(int,input().split()))
x_.append(X)
x_.sort()
if len(x_) == 2:
    print(x_[1]-x_[0])
else:
    a = x_[1]-x_[0]
    for i in range(1,n):
        b = x_[i+1]-x_[i]
        a = fractions.gcd(a,b)
    print(a)

Measured memory_bytes: 16296
using System;

namespace ABC044C{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var A = sr.Next<int>();
            var X = sr.Next<int>(N);

            var dp = new long[N + 1, N + 1, N * A + 1];
            for(var i = 0; i <= N; i++){
                dp[i, 0, 0] = 1;
            }

            for(var i = 0; i <= N * A; i++){
                for(var j = 1; j <= N; j++){
                    for(var k = 1; k <= N; k++){
                        if(i - X[k - 1] >= 0){
                            dp[k, j, i] = dp[k - 1, j, i] + dp[k - 1, j - 1, i - X[k - 1]];
                        } else{
                            dp[k, j, i] = dp[k - 1, j, i];
                        }
                    }
                }
            }

            var res = 0L;
            for(var i = 0; i <= N; i++){
                res += dp[N, i, i * A];
            }

            Console.WriteLine(res - 1);
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

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

int main() {
  string S,T;
  int ans = 0;

  cin >> S >> T;

  for (int i = 0; i < 3; i++) {
      if (S.at(i) == T.at(i)) {
        ans++ ;
      }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def Binary_Search(N, K, A):
	#初期化
	left = 0
	right = 10 ** 9
	ans = INF
	
	while left <= right:
		mid = (left + right) // 2
		val = 0
		if mid == 0:
			return 1
		for i in range(N):
			val += int((A[i] - 1) // mid)
		if val <= K:
			ans = min(ans, mid)
			right = mid - 1
		else:
			left = mid + 1

	return ans

#処理内容
def main():
	N, K = getlist()
	A = getlist()
	ans = Binary_Search(N, K, A)
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 29528
#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define INF 9999999

int main() {

	int n, an;
	vector<int> vec;
	int ans = INF;

	while (1) {

		cin >> n;
		if (n == 0) break;
		//??\???
		for (int i = 0; i < n; i++) {
			cin >> an;
			vec.push_back(an);
		}
		//?????????
		sort(vec.begin(), vec.end());
		//??????????°?????¨????
		for (int i = 0; i < n - 1; i++) {
			if (vec[i + 1] - vec[i] < ans) {
				ans = vec[i + 1] - vec[i];
			}
		}
		//??????
		cout << ans << endl;
		//?????????
		vec.clear();
		ans = INF;
	}
	return 0;
}

Measured memory_bytes: 3160
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
A=get_i
num=array(10**5,0)
A.each do|a|
  num[a]+=1
end
max=0
(10**5).times do|i|
    val=0
    if i.zero?
      val=num[i]+num[i+1]
    elsif i==10**5-1
      val=num[i-1]+num[i]
    else
      val=num[i-1]+num[i]+num[i+1]
    end
    max=val if max<val
end
puts max

Measured memory_bytes: 9484
#include <stdio.h>

int main()
{
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);

  if (a == b) {
    printf("%d\n", c);
  } else if (b == c) {
    printf("%d\n", a);
  } else {
    printf("%d\n", b);
  }

  return 0;
}


Measured memory_bytes: 128