akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	long long left = 1, right = 1;
	for(int i = 0; i < N; ++i)
	{
		long long ll = left, lr = right;
		int T, A;
		long long t, a;
		cin >> T >> A;
		long long mult = max(left/T, right/A);
		t = (mult)*T, a = (mult)*A;
		while(t < left || a < right)
		{
			t += T, a += A;
		}
		left = t, right = a;

		
		//cout << left << " " << right << endl;
	}
	cout << left + right << endl;

	return 0;
}

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

int main(){
    int N, K, sum = 0;
    cin >> N >> K;
    int l[N];
    for(int i = 0; i < N; i++){
        cin >> l[i];
    }
    sort(l, l + N, greater<int>());

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M,S,T;
vector<int> G[100010];
int A[100010],B[100010];
int d[100010][3];

signed main(){
	cin>>N>>M;
	REP(i,100010)REP(j,3){
		d[i][j]=INF;
	}
	REP(i,M){
		cin>>A[i]>>B[i];
		A[i]--,B[i]--;
		G[A[i]].push_back(B[i]);
	}
	cin>>S>>T;
	S--,T--;
	d[S][0]=0;
	queue<P> Q;
	Q.push({S,0});
	while(Q.size()){
		P p=Q.front();Q.pop();
		int s=p.first,t=p.second;
		REP(i,G[s].size()){
			int nt=(t+1)%3;
			int e=G[s][i];
			if(d[e][nt]==INF){
				d[e][nt]=d[s][t]+1;
				Q.push({e,nt});
			}
		}
	}
	if(d[T][0]==INF){
		cout<<-1<<endl;
	}
	else{
		cout<<d[T][0]/3<<endl;
	}
	return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>

int main(void){
  int i  = 0;
  int num = 5;
  int x[num];
  int ans = 0;

  for(i=0;i<num;i++){
    scanf("%d", &x[i]);
    fflush(stdin);
    if(x[i]==0){
      ans = i+1;
    }
  }

  printf("%d\n", ans);
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll H, W;
    ll a, b;
    cin >> H >> W;
    rep(h, H) {
        rep(w, W) {
            string temp;
            cin >> temp;
            if(temp == "snuke") {
                a = h;
                b = w;
            }
        }
    }
    cout << (char)(b + 'A') << a + 1 << endl;
    return 0;
}


Measured memory_bytes: 3580
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int K = sc.nextInt();
    String s_ = sc.next();

    sc.close();
    
    String[] S = s_.split("");

    for (int i = 0; i < S.length; i++) {
      if (i == K - 1) {
        if (S[i].equals("A")) {
          S[i] = "a";
        }
        if (S[i].equals("B")) {
          S[i] = "b";
        }
        if (S[i].equals("C")) {
          S[i] = "c";
        }
      }
    }

    for (int i = 0; i < S.length; i++) {
      System.out.print(S[i]);
    }

    System.out.println("");

  }

}

Measured memory_bytes: 23764
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];
    long[] b = new long[n];
    for(int i = 0;i < n;i++){
      a[i]=sc.nextLong();
      b[i]=sc.nextLong();
    }
    long cnt = 0;
    for(int i = n-1;i >= 0;i--){
      if((a[i]+cnt)%b[i]!=0)cnt+=b[i]-(a[i]+cnt)%b[i];
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 66740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<bool> dp(k + 1, true);
    dp[0] = false;
    reps(i, 1, k + 1) {
        bool res = false;
        rep(j, n) {
            if (i < a[j]) continue;
            if (!dp[i - a[j]]) {
                res = true;
                break;
            }
        }
        dp[i] = res;
    }
    if (dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int num = 1, i = 0;

	while(num != 0)
	{
		scanf("%d", &num);

		i++;

		if(num != 0)
		{
			printf("Case %d: %d\n", i, num);
		}
		
	}

	return 0;
}

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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	double d;cin>>d;

	printf("%0.10lf",2*d*3.141592653589793238462643383279502884197169399375105820974944);
}




Measured memory_bytes: 3744
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
using namespace std;
typedef long long ll;

int n;
string s;
const int NMOD=2;
ll MOD[] = {999727999, 1070777777};
ll P[] = {1777771, 1231247};
map<vector<ll>,ll> m1, m2;
vector<ll> f(int l, int r, int mask, int b){
    vector<ll> hs(NMOD);
    vector<ll> ps(NMOD,1);
    for(int i=0, x=l; x<r; x++, i++)if(mask&(1<<i)){
        fore(y,0,NMOD)ps[y]=(ps[y]*P[b])%MOD[y];
        fore(y,0,NMOD)
            hs[y] = (hs[y]+ps[y]*(1LL*s[x]))%MOD[y];
    }
    ps=vector<ll>(NMOD,1);
    for(int i=n-1, x=r-1; x>=l; x--, i--)if(!(mask&(1<<i))){
        fore(y,0,NMOD)ps[y]=(ps[y]*P[1-b])%MOD[y];
        fore(y,0,NMOD)
            hs[y] = (hs[y]+ps[y]*(1LL*s[x]))%MOD[y];
    }
    return hs;
}

int main(){FIN;
    cin >> n >> s;
    fore(x,0,1<<n){
        m1[f(0,n,x,0)]++;
        m2[f(n,2*n,x,1)]++;
    }
    ll ans = 0;
    for(auto p:m1)ans+=p.snd*m2[p.fst];
    
    cout << ans << "\n";
}


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

int main(){
  int n;
  cin >> n;
  multiset<int> ms;
  for(int i = 0;i < n;i++){
    int a;
    cin >> a;
    auto it = ms.lower_bound(a);
    if(it == begin(ms)){
      ms.insert(a);
    }
    else{
      it = prev(it);
      ms.erase(it);
      ms.insert(a);
    }
  }
  cout << ms.size() << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define int long long
using namespace std;

constexpr int MOD = 1e9 + 7;

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

  multiset<int> st;

  int ans = 1;
  for (int i = 0; i < N; i++) {
    if (A[i] != 0 && st.count(A[i] - 1) == 0) {
      cout << 0 << endl;
      return 0;
    }

    if (A[i] == 0) {
      ans *= (3 - st.count(0));
      ans %= MOD;
    } else {
      ans *= (st.count(A[i] - 1) - st.count(A[i]));
      ans %= MOD;
    }

    st.insert(A[i]);

    if (st.count(A[i]) > 3) {
      cout << 0 << endl;
      return 0;
    }
  }

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

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
long long a,b,n;
long long check(long long x)
{
	return a*x/b-a*(x/b);
}
int main()
{
	cin>>a>>b>>n;
	long long l=0,r=n,ans=0;
	while(r-l>=1000000)
	{
		long long lmid=l+(r-l)/3,rmid=r-(r-l)/3;
		if(check(lmid)<=check(rmid))
			l=lmid;
		else
			r=rmid;
	}
	while(l<=r&&l<=n)
	{
		ans=max(ans,check(l));
		l++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
using namespace std;

int main() {
    int N, Q; cin >> N >> Q;
	string S; cin >> S;
	vector<pair<int, int>> lr(Q);
	for (int i = 0; i < Q; i++){
		int l, r; cin >> l >> r;
		lr[i].first = l - 1;
		lr[i].second = r - 1;
	}

	vector<int> left(N+1), right(N+1);
	left[0] = 0;
	for(int i = 1; i < N; i++){
		left[i] = left[i-1] + (S[i-1] == 'A' && S[i] == 'C');
	}

	for (int i = 0; i < Q; i++){
		cout << left[lr[i].second] - left[lr[i].first] << endl;
	}

}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
signed main(){
    int N; cin >> N;
    vector<int>dp(N + 1, INF);
    dp[0] = 0;
    for(int i =0; i <= N; ++i){
        if(dp[i] == INF) continue;
        int cal = 6;
        while(cal + i < dp.size()){cmin(dp[i + cal], dp[i] + 1); cal *= 6;}
        cal = 9;
        while(cal + i < dp.size()){cmin(dp[i + cal], dp[i] + 1); cal *= 9;}
    }
    int ans = INF;
    for(int i = 0; i <= N; ++i)cmin(ans, dp[i] + N - i);
    cout << ans << endl;
}


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

using namespace std;

struct Dish
{
  long long A, B;
};

int main()
{
  int N;
  cin >> N;
  vector<Dish> dish(N);
  for (int i = 0; i < N; i++)
    cin >> dish[i].A >> dish[i].B;
  sort(dish.begin(), dish.end(), [](const Dish &l, const Dish &r) { return (l.A + l.B > r.A + r.B); });
  long long ans = 0;
  for (int i = 0; i < N; i++)
    if (i % 2 == 0)
      ans += dish[i].A;
    else
      ans -= dish[i].B;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, x, ans = 1, sum;
signed main() {
	cin >> n >> x;
	rep(i, n) {
		int a; cin >> a;
		sum += a;
		if (sum <= x)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
st=[]

while True:
  try:
    n=input()
    if n=="":
      break
    st += n.lower()
  except:
    break
   
char = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(char)):
  print(char[i],":",st.count(char[i]))    



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

using namespace std;

typedef long long ll;

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

	string s;
	cin >> s;

	if(s == "AAA" || s == "BBB"){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}

}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int H1, M1, H2, M2, K; cin >> H1 >> M1 >> H2 >> M2 >> K;
	cout << (H2*60+M2)-(H1*60+M1)-K << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll ans1=(a*n)/b-a*(n/b),ans2=(a*(b-1))/b-a*((b-1)/n);
    cout<<max(ans1,ans2);
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end());
#define REVERSE(v)  reverse(v.begin(), v.end());
typedef long long ll;
using namespace std;

int main() {
  int N; cin>>N;
  string ans="No";
  while(N>=4) {
    if(N%4==0) ans="Yes";
    if(N%7==0) ans="Yes";
    N -= 4;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String args[]) throws IOException{
               BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));	
	String[] lo = reader.readLine().split(" ");
	int X = Integer.parseInt(lo[0]);
	int N = Integer.parseInt(lo[1]);
	String p = reader.readLine();
	int[] list = !p.equals("")?Arrays.stream(p.split(" ")).mapToInt(Integer::parseInt).toArray():new int[0];
	HashSet<Integer> hs = new HashSet<>();
	for(int i = 0;i<N;i++) hs.add(list[i]);
	int t = 0;
	while(true){
		if(!hs.contains(X-t)){
			System.out.println((X-t));
			return;
		}
		else if(!hs.contains(X+t)){
			System.out.println((X+t));
			return;	
		}
		t++;	
	}
	}
}


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

int main(){
	int n,k,q;
  cin >> n >> k >> q;
  int a[n],b[q];
  rep(i,n)
    a[i]=k-q;
  rep(i,q){
    cin >> b[i];
   	a[b[i]-1]++;
  }
 
    
  rep(i,n)
  {
    if(a[i]>0)
      cout << "Yes"<<endl;
    else
      cout << "No"<<endl;
  }
  return 0;
}
  
  
  
  
    


Measured memory_bytes: 1408
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	s;

	cin >> n >> m;
	if (n==m) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;

	}
	return 0;
}


Measured memory_bytes: 256
import itertools
L = [''.join(i) for i in itertools.product('0123', repeat=3)]
l = len(L)

mod = 10**9+7

AGC = '021'
ACG = '012'
GAC = '201'
nc3 = set([AGC, ACG, GAC])

AGGC = '0221'
AGTC = '0231'
ATGC = '0321'
nc4 = set([AGGC, AGTC, ATGC])

n = int(input())
dp = [[0]*l for _ in range(n+1)]
for i in L:
  if i in nc3: continue
  dp[3][int(i, 4)] = 1

for i in range(3, n):
  for jl in L:
    for k in "0123":
      nxt = jl[1:] + k
      if nxt in nc3: continue
      if jl+k in nc4: continue
      dp[i+1][int(nxt, 4)] += dp[i][int(jl, 4)]
print(sum(dp[n])%mod)

Measured memory_bytes: 9280
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	int N;
	ll A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	for (int i = 0; i < N; ++i) {
		ll R= A + i * D-(N - 1 - i)*C;
		ll L = A + i * C - (N - 1 - i)*D;
		if (L <= B && B <= R) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 5100000;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;


//UF木
struct UnionFind {
private:
	vector<int> par, ran, sz;
public:
	UnionFind(int n) {
		par.resize(n, 0);
		ran.resize(n, 0);
		sz.resize(n, 1);
		rep(i, n) {
			par[i] = i;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y)return;
		if (ran[x] < ran[y]) {
			par[x] = y; sz[y] += sz[x];
		}
		else {
			par[y] = x; sz[x] += sz[y];
			if (ran[x] == ran[y])ran[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int num(int x) { return sz[find(x)]; }
};

ll n, m;
Vl ans;
int a[100005], b[100005];

int main() {

	cin >> n >> m;

	UnionFind uf(n);

	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}

	ll cnt = n * (n - 1) / 2;

	rep(i, m) {
		ans.pb(cnt);
		ll A = a[m - i - 1], B = b[m - i - 1];
		if (uf.same(A, B))continue;
		ll sa = uf.num(A), sb = uf.num(B);
		cnt -= sa * sb;
		uf.unite(A, B);
	}

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

	rep(i, ans.size()) {
		cout << ans[i] << endl;
	}

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 131075 + 300;
const ll inf = 2e18, mod = 1e9 + 7;

int n;
pair<pair<int, ll>, pair<int, ll> > p[maxn];
vector<pair<ll, ll> > S[maxn], A, B;

void merge(int ind)
{
	int a = 0, b = 0;
	while (a < A.size() || b < B.size())
	{
		if (a < A.size() && b < B.size())
		{
			if (A[a] == B[b])
			{
				a++;
				continue;
			}
			if (A[a] < B[b])
			{
				if (!S[ind].empty() && (A[a].ff >= S[ind].back().ff && A[a].ss >= S[ind].back().ss))
					a++;
				else
					S[ind].pb(A[a++]);
			}
			else
			{
				if (!S[ind].empty() && (B[b].ff >= S[ind].back().ff && B[b].ss >= S[ind].back().ss))
					b++;
				else
					S[ind].pb(B[b++]);
			}
		}
		else if (a < A.size())
		{
			if (!S[ind].empty() && (A[a].ff >= S[ind].back().ff && A[a].ss >= S[ind].back().ss))
				a++;
			else
				S[ind].pb(A[a++]);
		}
		else
		{
			if (!S[ind].empty() && (B[b].ff >= S[ind].back().ff && B[b].ss >= S[ind].back().ss))
				b++;
			else
				S[ind].pb(B[b++]);
		}
	}
}

void dfs(int u, ll V)
{
	if (p[u].ff.ff == -1)
		S[u].pb(mp(0, 0));
	else
	{
		int a = p[u].ff.ff, b = p[u].ss.ff;
		ll now = p[u].ff.ss + p[u].ss.ss;

		dfs(a, V);
		dfs(b, V);

		A.clear();
		B.clear();

		int pos = 0;
		for (int i = 0; i < S[a].size(); i++)
		{
			while (pos < S[b].size() && S[a][i].ss + S[b][pos].ff + now <= V)
				pos++;
			if (pos)
			{
				if (!A.empty() && (S[a][i].ff + p[u].ff.ss <= A.back().ff && S[b][pos - 1].ss + p[u].ss.ss <= A.back().ss))
					A.popb();
				A.pb(mp(S[a][i].ff + p[u].ff.ss, S[b][pos - 1].ss + p[u].ss.ss));
			}
		}

		pos = 0;
		for (int i = 0; i < S[b].size(); i++)
		{
			while (pos < S[a].size() && S[b][i].ss + S[a][pos].ff + now <= V)
				pos++;
			if (pos)
			{
				if (!B.empty() && (S[b][i].ff + p[u].ss.ss <= B.back().ff && S[a][pos - 1].ss + p[u].ff.ss <= B.back().ss))
					B.popb();
				B.pb(mp(S[b][i].ff + p[u].ss.ss, S[a][pos - 1].ss + p[u].ff.ss));
			}
		}

		merge(u);
	}
}

bool check(ll V)
{
	for (int i = 0; i < n; i++)
		S[i].clear();
	dfs(0, V);
	return !S[0].empty();
}

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

	fill(p, p + maxn, mp(mp(-1, -1), mp(-1, -1)));

	cin >> n;
	for (int i = 1; i < n; i++)
	{
		int u;
		ll w;
		cin >> u >> w;
		u--;
		if (p[u].ff.ff == -1)
			p[u].ff = mp(i, w);
		else
			p[u].ss = mp(i, w);
	}

	/*cerr << check(15) << endl;
	cerr << "___________" << endl;
	for (int i = 0; i < n; i++)
	{
		cerr << '#' << i << endl;
		for (auto j : S[i])
			cerr << '_' << j.ff << ' ' << j.ss;
		cerr << endl;
	}*/

	ll l = -1, r = inf - 10, mid;
	while (r - l > 1)
	{
		mid = (l + r) / 2;
		if (check(mid))
			r = mid;
		else
			l = mid;
	}

	cout << r << endl;
}



Measured memory_bytes: 31076
/*input
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5
*/

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

const int MAX_N = 200101;
int B[MAX_N];
int C[MAX_N];

int main() {
    int N, A[MAX_N];
    cin >> N;
    rep(i, N) cin >> A[i];
    rep(i, N) {
        B[i] = -A[i]+i;
        C[i] = A[i]+i;
    }
    sort(C, C+N);
    ll ans = 0;
    rep(i, N) {
        ans += upper_bound(C, C+N, B[i])-lower_bound(C, C+N, B[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5944
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   string a,b;
   cin >> a >> b;

   int i=0;
   if(a.size()>b.size()) {
      cout << "GREATER" << endl;
   }else if(a.size()<b.size()){
      cout << "LESS" << endl;
   }else{
      while(1){
         if(a[i] > b[i]) {
            cout << "GREATER" << endl;break;
         }
         else if(a[i] < b[i]) {
            cout << "LESS" << endl;break;
         }
         else{
            if(i==a.size()-1){
               cout << "EQUAL" << endl;
               break;
            }
            i++;
         }
      }
   }

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
unsigned long long int a,b,c,d,e,f;
cin>>a>>b>>c>>d;
if((a*b)==(c*d)){
    cout<<(a*b)<<endl;
}
else{
    e=a*b;
    f=c*d;
    if(e>f){
        cout<<e<<endl;
    }
    else{
        cout<<f<<endl;
    }
}
return 0;
}


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

ll choose2(ll n) { return n * (n - 1) / 2; }

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  map<string, ll> freq;
  rep(i, n) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
    freq[s[i]]++;
  }
  ll ans = 0;
  for (auto p : freq) {
    if (p.second < 2) continue;
    ans += choose2(p.second);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll ans = 0;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i % 3 && i % 5) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
map<int,int> mp;
int main() 
{
	int n;
	cin >> n;
	int x;
	for(int i = 1; i <= n; i++)
	{
		cin >> x;
		mp[x]++;
		if(mp[x] != 1)
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int n,x;

int main(void){
    cin >> n >> x;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int res = 0;
    REP(i,n-1){
        if(x>=a[i]){
            res++;
            x -= a[i];
        }else{
            break;
        }
    }
    if(a[n-1]==x){
        res++;
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  sort(A.begin(), A.end());
  A.push_back(inf);
  
  int ans = 0;
  int bef = A.at(0);
  int written = 1;
  for (int i = 1; i < N + 1; i++)
  {
    if (bef == A.at(i)) written = 1 - written;
    else {ans += written; written = 1;}
    //cout << written << " ";
    bef = A.at(i);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<deque>
#include<cstring>
#include<climits>
#include<cassert>
#include<cctype>

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

using namespace std;

bool ma[100000];
int main() {
  map<int,int> mp;
  rep(i,9) rep(j,9) {
    mp[j+i*9] = (int)mp.size();
    cout << i+1 << 'x' << j+1 << '=' << (i+1)*(j+1) << endl;
  }
  
  return 0;
}

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

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

    int curr = 1;
    int ans = 0;

    for (int i = 1; i <= N; ++i) {
        int a;
        cin >> a;
        if (a == curr) {
            ++curr;
        }
        else {
            ++ans;
        }
    }

    cout << (ans == N ? -1 : ans) << endl;

    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  unordered_map<int, int> mp;
  for (int i = 0; i < n; ++i)
  {
    int a;
    cin >> a;
    mp[a]++;
  }
  int cnt = 0;
  for (auto &e : mp)
  {
    if (e.second % 2 == 1)
      cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 4388
#include <stdio.h>
#include <string.h>

int main(void){

    char S[100];
    int flag = 0;
    int N = 0;
    int j = 0;

    scanf("%s", S);

    N = strlen(S) - 1;


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

        if (S[i] != S[N - i]){
            flag = 1;
        }

        if ((N - 1) / 2 >= i){
            if (S[i] != S[(N - 1) / 2 - i]){
                flag = 1;
            }
        }

        if ((N + 3) / 2 <= i){
            if (S[i] != S[N - j]){
                flag = 1;
            }
            j++;
        }
    }
    if (flag == 0){
        printf("Yes\n");
    } else {
        printf("No\n");  
    }

    return 0;
}

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

int vectormax(vector<int> vec){
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    return vec.at(0);
}

int main(){
    int L,R;
    cin>>L>>R;

    int modL,modR;
    modL=L%2019;
    modR=R%2019;

    int n;
    n=modR-modL+1;
    int nct;
    nct=n*(n-1)/2;
    

    if (R-L>2018){
        cout<<0<<endl;
    }
    else if(modL>=modR){
        cout<<0<<endl;
    }
    else{
        vector<int> mod(n);
        for(int i=0;i<n;i++){
            mod.at(i)=modL+i;
        }

       // vector<int> answer(nct);
       int ans;
       ans=2019;
        //int count;
        //count=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                //answer.at(count)=(mod.at(i)*mod.at(j))%2019;
                ans=min(ans,(mod.at(i)*mod.at(j))%2019);
               // count++;
            }
        }
        //cout<<vectormax(answer)<<endl;
        cout<<ans<<endl;
        //cout<<count<<endl;
    }

}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.Map.Entry;

public class Main{
	
	public static void main(String[] args) throws IOException{
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		Scanner in = new Scanner(System.in);
		
		String s = in.next();
		int K = in.nextInt();
		TreeSet<String> ts = new TreeSet<>((s1,s2)->s1.compareTo(s2));
		
		for(int i = 1; i <= K; i++){
			for(int j = 0; j + i - 1 <= s.length() - 1; j++){
				String ss = s.substring(j, j + i);
				//System.out.print(ss + " ");
				ts.add(ss);
			}
		}
		
		//for(String ss : ts) System.out.print(ss + " ");
		//System.out.println();
		for(int i = 0; i < K - 1; i++){
			ts.pollFirst();
		}
		System.out.println(ts.pollFirst());
	}
}


Measured memory_bytes: 30884
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <tuple>
#include <utility>
#include <vector>

#define llong long long

using namespace std;
const int IINF = 2147483647;
const llong LLINF = 9223372036854775807;

vector<llong> DJK(int n, int s, vector<vector<pair<int, llong>>> &E)
{
    vector<pair<llong, bool>> V(n);
    for (int i = 0; i < n; i++)
        V[i] = make_pair(-1, false);
    V[s].first = 0;
    priority_queue<pair<llong, int>> Q;
    Q.push(make_pair(-V[s].first, s));
    while (!Q.empty())
    {
        int m = Q.top().second;
        Q.pop();
        if (V[m].second)
            continue;
        V[m].second = true;
        for (pair<int, llong> p : E[m])
        {
            int pd = p.first;
            llong plen = p.second;
            if (V[pd].first < 0)
                V[pd].first = LLINF;
            if (V[m].first + plen < V[pd].first)
            {
                V[pd].first = V[m].first + plen;
                Q.push(make_pair(-V[pd].first, pd));
            }
        }
    }
    vector<llong> ret(n);
    for (int i = 0; i < n; i++)
        ret[i] = V[i].first;
    return ret;
}

int main(){
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  vector<vector<pair<int, llong>>>uva(n), uvb(n);
  for(int i=0; i<m; i++){
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    uva[u-1].push_back(make_pair(v-1, a));
    uva[v-1].push_back(make_pair(u-1, a));
    uvb[u-1].push_back(make_pair(v-1, b));
    uvb[v-1].push_back(make_pair(u-1, b));
  }
  vector<llong>ca=DJK(n, s-1, uva), cb=DJK(n, t-1, uvb), c(n);
  for(int i=0; i<n; i++)c[i]=ca[i]+cb[i];
  llong mc=c[n-1];
  vector<llong>ret(n);
  for(int i=n-1; i>=0; i--){
    mc = min(mc, c[i]);
    ret[i]=1000000000000000-mc;
  }
  for(int i=0; i<n; i++)cout << ret[i] << endl;
  return 0;
}


Measured memory_bytes: 20540
n, m, q = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]
query = [list(map(int, input().split())) for _ in range(q)]

trains = [[0 for _ in range(n+1)] for _ in range(n+1)]

for i in range(m):
    l, r = lr[i]
    trains[l][r] += 1

for i in range(n+1):
    for j in range(n):
        trains[i][j+1] += trains[i][j]

for j in range(n+1):
    for i in range(n):
        trains[i+1][j] += trains[i][j]

for i in range(q):
    p, q = query[i]
    print(trains[q][q]-trains[p-1][q]-trains[q][p-1]+trains[p-1][p-1])

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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var x = inputLongArray[0];
            var n = inputLongArray[1];
            var pp = Console.ReadLine();

            string result = string.Empty;
            if (n == 0)
            {
                result = x.ToString();
            }
            else
            {
                var p = pp.Split(' ').Select(i => int.Parse(i)).ToArray();

                var tmp = Enumerable.Range(0, 102);
                var ans = new Dictionary<int, int>();

                foreach (var item in tmp)
                {
                    if (p.Contains(item)) continue;
                    ans.Add(item, Math.Abs(item - x));
                }
                result = ans.Where(r => r.Value == ans.Values.Min()).First().Key.ToString();
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28528
#include<bits/stdc++.h>
#define N 3
using namespace std;
typedef unsigned long long ull;
bool im[1010][1010],pa[110][110];
int w,h,p,ans;
vector<ull> used;

void ppp(){
 ull a=0;
 ull roll[1001][1001]={};
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)a=a*N+pa[i][j];
 for(int i=0;i<used.size();i++)
   if(used[i]==a)return;
 used.push_back(a);
 for(int j=0;j<h;j++){
   ull b=0,g=1;
   for(int i=0;i<p;i++)b=b*N+im[j][i],g*=N;
   roll[j][p-1]=b;
   for(int i=p;i<w;i++)
     roll[j][i]=b=b*N+im[j][i]-im[j][i-p]*g;
 }
 for(int j=p-1;j<w;j++){
   ull b=0,g=1,n=1;
   for(int i=0;i<p;i++)n*=N;
   for(int i=0;i<p;i++)b=b*n+roll[i][j],g*=n;
   if(b==a)ans++;
   for(int i=p;i<h;i++){
     b=b*n+roll[i][j]-roll[i-p][j]*g; 
     if(b==a)ans++;
   }
 }
}

void ch(){
 bool npa[110][110];
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)npa[i][j]=pa[j][p-i-1];
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)pa[i][j]=npa[i][j];
}

void ch1(){
 for(int i=0;i<p;i++)
   for(int j=0;j<p/2;j++)swap(pa[i][j],pa[i][p-j-1]);
}

int main(){
 int D[256];
 for(int i='A';i<='Z';i++)D[i]=i-'A';
 for(int i='a';i<='z';i++)D[i]=i-'a'+26;
 for(int i='0';i<='9';i++)D[i]=i-'0'+52;
 D['+']=62,D['/']=63;
 while(cin>>w>>h>>p,w){
   string s;
   used.clear();
   for(int i=0;i<h;i++){
     cin>>s;
     for(int j=0;j<s.size();j++){
       int t=D[s[j]],a=6;
	while(a--)im[i][j*6+a]=t%2,t/=2;
     }
   }
   for(int i=0;i<p;i++){
     cin>>s;
     for(int j=0;j<s.size();j++){
       int t=D[s[j]],a=6;
	while(a--)pa[i][j*6+a]=t%2,t/=2;
     }
   }
   ans=0;
    for(int i=0;i<4;i++){
     ppp();
     ch1();
     ppp();
     ch1();
     ch();
   }
   cout<<ans<<endl;
 }
 return 0;
}

Measured memory_bytes: 11920
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t,n;
    t = 1;
    for(int i=0;i<t;i++)
    {
        cin>>n;
        ll sum = 0;
        for(int i=1;i<=n;i++)
        {
            for(int j=i;j<=n;j+=i)
            {
                sum+=j;
            }
        }
        cout<<sum<<"\n";
    }
    return 0;
}

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

#define NMAX 50000

using namespace std;

//ifstream fin("f.in");
//ofstream fout("f.out");

int dieFaces, score;
double chanceOfWin;

int main()
{
    cin >> dieFaces >> score;
    for(int i = 1; i <= dieFaces; ++i)
    {
        int value = i;
        int power = 1;
        while(value < score)
        {
            value = value * 2;
            power = power * 2;
        }
        chanceOfWin += (1 / (double)dieFaces) * (1 / (double)power);
    }
    printf("%.12lf\n", chanceOfWin);
    return 0;
}


Measured memory_bytes: 256
class Sieve:
    """区間[2,n]の値を素因数分解する"""

    def __init__(self, n=1):
        primes = []
        f = [0] * (n + 1)
        f[0] = f[1] = -1
        for i in range(2, n + 1):  # 素数を探す
            if f[i]:
                continue
            primes.append(i)
            f[i] = i  # 素数には自身を代入
            for j in range(i * i, n + 1, i):  # 合成数に素因数を書き込む
                if not f[j]:
                    f[j] = i  # 最小の素因数を代入
        self.primes = primes
        self.f = f

    def is_prime(self, x) -> bool:  # 素数判定
        return self.f[x] == x

    def factor_list(self, x) -> list:  # 素因数分解の昇順リスト, [2,2,3,5,...]
        res = []
        while x != 1:
            res.append(self.f[x])
            x //= self.f[x]
        return res

    def factor(self, x) -> list:  # 素因数分解の頻度リスト, [[2,x],[3,y],[5,z],...]
        fl = self.factor_list(x)
        if not fl:
            return []
        res = [[fl[0], 0]]
        for p in fl:
            if res[-1][0] == p:
                res[-1][1] += 1
            else:
                res.append([p, 1])
        return res


def main():
    N = int(input())
    *A, = map(int, input().split())

    B = [0] * (10 ** 6 + 1)
    for x in A:
        B[x] += 1

    setwise = False

    sv = Sieve(10 ** 6)
    for p in sv.primes:
        e = p
        cnt = 0
        while e <= 10 ** 6:
            if B[e]:
                cnt += B[e]
            e += p
        if cnt == N:
            print('not coprime')
            return
        elif cnt > 1:
            setwise = True

    print('setwise coprime' if setwise else 'pairwise coprime')


if __name__ == '__main__':
    main()


Measured memory_bytes: 223944
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		String S = sc.next();

		sc.close();

		StringBuffer ans = new StringBuffer();

		for (char c : S.toCharArray()) {
			int x = c - 'A';
			x += N;
			x %= 26;
			ans.append((char) (x + 'A'));
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 22228
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;
long long mod=1000000033;
int p[1100];
long long q[1100];
long long hb[114514];
int sz=0;
int n;
long long pow(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		b/=2;
		a=a*a%mod;
	}
	return ret;
}
long long calc(long long x){
	long long now=0;
	for(int i=0;i<n;i++){
		now=(now+pow(x,p[i])*((mod+q[i])%mod))%mod;
	}
	return now;
}
long long ABS(long long a){return max(a,-a);}
long long np[1100];
long long nq[1100];
int v[1100];
int ns;
int main(){
	int a;scanf("%d",&a);
	n=a;
	for(int i=0;i<a;i++){
		scanf("%d%lld",p+i,q+i);
	}
	for(int i=0;i<a;i++){
		if(v[i])continue;
		long long tmp=0;
		for(int j=0;j<a;j++){
			if(p[i]==p[j]){
				tmp+=q[j];
				v[j]=1;
			}
		}
		if(tmp){
			np[ns]=p[i];
			nq[ns]=tmp;
			ns++;
		}
	}
	for(int i=0;i<ns;i++){
		p[i]=np[i];
		q[i]=nq[i];
	}
	a=ns;
	n=ns;
	long long deg=0;
	for(int i=0;i<a;i++)deg=max(deg,(long long)p[i]);
	long long dm=999999999999LL;
	for(int i=0;i<a;i++)dm=min(dm,(long long)p[i]);
	if(deg<=1){
		long long A=0;
		long long B=0;
		for(int i=0;i<a;i++){
			if(p[i]==1)A+=q[i];
			else B+=q[i];
		}
		if(A<0){
			A=-A;B=-B;
		}
		if(A==0){
			if(B==0)printf("Yes 1\n");
			else printf("No\n");
		}else{
			printf("No\n");
		}
		return 0;
	}
	long long t=0;
	for(int i=0;i<a;i++)if(p[i]==dm)t+=q[i];
	long long m=t;
	t=ABS(t);
	long long ret=99999999999999999LL;
	for(int i=1;(long long)i*i*i<=t;i++){
		if(t%i==0){
			if((t/i)%i==0){
				hb[sz++]=i;
			}
			long long s=t/i;
			long long u=(long long)(sqrt(s)+0.00001);
			if(u*u==s)hb[sz++]=u;
		}
	}
	std::sort(hb,hb+sz);
	for(int i=0;i<sz;i++){
	//	printf("%lld\n",hb[i]);
		if(calc(hb[i])==0LL){
			printf("Yes %lld\n",hb[i]);return 0;
		}
	}
	printf("No\n");
}

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

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		int Div = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) Div++;
		}
		if (Div == 8 && i % 2 != 0) ans++; 
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <array>
const int MOD=1e9+7;
using namespace std;
typedef long long ll;
vector<int> vi;
int n,m;
int x[100005],y[100005];
ll ans=0,xsum=0,ysum=0;

int main(int argc,char const* argv[])
{
  cin >> n >> m;
  for(int i=1;i<=n;i++)
    {
      cin >> x[i];
    }
  for(int i=1;i<=m;i++)
    {
      cin >> y[i];
    }
  for(int k=1;k<=n;k++)
    {
      xsum+=(ll)(2*k-n-1)*x[k];
      xsum%=MOD;
    }
  for(int k=1;k<=m;k++)
    {
      ysum+=(ll)(2*k-m-1)*y[k];
      ysum%=MOD;
    }
  ans=(xsum*ysum)%MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a;
	int b;
	int c;
	int d;
	int e;
	cin >> a >> b >> c >> d;
	if (a*b > c*d) {
		cout << a * b << "\n";
	}
	else if (a*b < c*d) {
		cout << c * d << "\n";
	}
	else if (a*b == c * d) {
		cout << a * b << "\n";
	}
	cin >> e;
}

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

string to_bit(string s){
	string ret = "";
	for(int i = 0;i < 8;i++){
		int t;
		if(s[i] <= '9' && s[i] >= '0') t = s[i] - '0';
		else t = s[i] - 'a' + 10;
		for(int j = 0;j < 4;j++){
			if(t >> (3 - j) & 1) ret += to_string(1);
			else ret += to_string(0);
		}
	}
	return ret;
}

int main(){
	int q;
	cin >> q;
	for(int i = 0;i < q;i++){
		long double ans = 0.0;
		string s;
		cin >> s;
		s = to_bit(s);
		if(s[0] == '1') cout << "-";
		for(int j = 1;j < 25;j++){
			ans *= 2.0;
			if(s[j] == '1') ans += 1.0;
		}
		long double add = 0.5;
		for(int j = 25;j < 32;j++){
			if(s[j] == '1') ans += add;
			add /= 2.0;
		}
		cout << (int)ans << ".";
		do{
			ans -= (int)ans;
			ans *= 10.0;
			cout << (int)ans;
		}while((ans - (int)ans) > 1e-9);
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3264