akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    string s;
    cin >> s;
    
    int year = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
    
    int month = (s[5] - '0') * 10 + (s[6] - '0');
    
    int day = (s[8] - '0') * 10 + (s[9] - '0');
    
    //cout << year << " " << month << " " << day << "\n";
    
    bool later = true;
    
    if(year > 2019)
    {
        later = false;
    }
    
    if(year == 2019 && month > 4)
    {
        later = false;
    }
    
    if(year == 2019 && month == 4 && day > 30)
    {
        later = false;
    }
    
    if(later)
    {
        cout << "Heisei";
    }
    else
    {
        cout << "TBD";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in", "r", stdin);freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out", "w", stdout);
    
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		char[] s=nextString().toCharArray();
		Arrays.sort(s);

		if(s[0]=='a'&&s[1]=='b'&&s[2]=='c')
			System.out.println("Yes");
		else
			System.out.println("No");

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22484
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

int main(){
    char c[3];
    int a[2] = {0};
    cin >> c;
    int flag= 0;
    int tmp = c[0]-'A';
    for(int i = 1; i< 3; i++){
        if((c[i]-'A')!=tmp) flag=1;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n; cin>>n; n--;
    vll A(n+1), B(n);
    rep(i, n) cin>>B[i];
    A[0] = B[0];
    A[n] = B[n-1];
    for(int i=1; i<n; i++){
        A[i] = min(B[i-1], B[i]);
    }
    ll ans=0;
    rep(i, n+1) ans += A[i];
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<list>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int MAX=100005;
const int inf=1e9;
vi G[MAX];
int N;
bool visited[MAX];
typedef pair<int,int> P;
int prenum[MAX],parent[MAX],lowest[MAX],timer;
vector<P> bridge;
void dfs(int current,int prev)
{
  prenum[current]=lowest[current]=timer;
  timer++;

  visited[current]=true;
  int next;
  for(int i=0;i<G[current].size();i++)
  {
    next=G[current][i];
    if(!visited[next])
    {
      parent[next]=current;
      dfs(next,current);
      lowest[current]=min(lowest[current],lowest[next]);
      if(prenum[current]<lowest[next]) bridge.push_back(P(min(current,next),max(current,next)));
    }
    else if(next!=prev)
    {
      lowest[current]=min(lowest[current],prenum[next]);
    }
  }
}

void bridge_points()
{
  timer=1;
  dfs(0,-1);
  sort(bridge.begin(),bridge.end());
  for(int i=0;i<bridge.size();i++)
  {
    cout << bridge[i].first << ' ' << bridge[i].second << endl;
  }
}

int main(void)
{
  int m;
  cin >> N >> m;
  memset(visited,false,sizeof(visited));
  for(int i=0;i<m;i++)
  {
    int s,t;
    cin >> s>> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  bridge_points();
}



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

const int MAXN = 200020;

int n, k, cnt, ql, qr;
char s[MAXN];
bool rev, q[MAXN << 2];

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	scanf( "%d%d%s", &n, &k, s + 1 );
	for( int i = 1 ; i <= n ; i++ ) q[ i ] = s[ i ] - 'A';
	ql = 1, qr = n + 1;
	for( cnt = 1 ; cnt <= ( n << 1 ) && cnt <= k ; cnt++ )
	{
		if( q[ ql ] ^ rev ) ql++, q[ qr++ ] = rev ^= 1;
		else q[ ql ] ^= 1;
	}
	cnt--;
	if( k - cnt & 1 )
		if( q[ ql ] ^ rev ) ql++, q[ qr++ ] = rev ^= 1;
		else q[ ql ] ^= 1;
	for( int i = ql ; i < qr ; i++ ) putchar( 'A' + ( q[ i ] ^ rev ) );
	return putchar( 10 ), 0;
}


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

Measured memory_bytes: 1024
n,k=(int(i) for i in input().split())
l=[1 for i in range(1,n+1)]
for i in range(k):
  d=input()
  l1=[int(j) for j in input().split()]
  for j in l1:
      l[j-1]=0
c=0
for i in l:
  if(i>0):
    c+=1
print(c)

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

long long f(long long a)
{
    if (a == 0)
    {
        return 0;
    }
    bitset<60> b(a);
    return 1 + f(a % b.count());
}

int main()
{
    size_t N;
    string X;
    cin >> N >> X;

    size_t count = 0;
    for (char x : X)
    {
        if (x == '1')
        {
            count++;
        }
    }

    reverse(X.begin(), X.end());
    long long digit_minus = 1;
    long long minus = 0;
    vector<long long> m;

    long long digit_plus = 1;
    long long plus = 0;
    vector<long long> p;

    for (char x : X)
    {
        if (x == '1')
        {
            minus += digit_minus;
            plus += digit_plus;
        }

        m.push_back(digit_minus);
        p.push_back(digit_plus);

        if (count > 1)
        {
            minus %= count - 1;
        }
        digit_minus *= 2;
        if (count > 1)
        {
            digit_minus %= count - 1;
        }

        plus %= count + 1;
        digit_plus *= 2;
        digit_plus %= count + 1;
    }

    vector<long long> ans(N, 0);
    for (size_t i = 0; i < N; i++)
    {
        long long a;
        if (X[i] == '1')
        {
            a = minus;
            a -= m[i];
            a += count - 1;
            a += count - 1;
            if (count > 1)
            {
                a %= count - 1;
            }
        }
        else
        {
            a = plus;
            a += p[i];
            a %= count + 1;
        }
        if (count == 1 && X[i] == '1')
        {
            ans[i] = 0;
        }
        else
        {
            ans[i] = 1 + f(a);
        }
    }
    reverse(ans.begin(), ans.end());
    for (long long a : ans)
    {
        cout << a << endl;
    }
}


Measured memory_bytes: 8412
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,m;
    while(cin>>n>>m,n||m){
        vector<int> a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int ans=-1;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(m>=a[i]+a[j])ans=max(ans,a[i]+a[j]);
            }
        }
        if(ans==-1)cout<<"NONE"<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    set<int> st;

    rep(i, m) {
        int a;
        cin >> a;
        st.insert(a);
    }

    ll dp[100010] = {};
    dp[0] = 1;

    rep(i, 100005) {
        if (st.count(i)) continue;
        if (!st.count(i + 1)) dp[i + 1] += dp[i];
        if (!st.count(i + 2)) dp[i + 2] += dp[i];
        dp[i + 1] %= MOD, dp[i + 2] %= MOD;
    }
    cout << dp[n] << endl;
    return 0;
}



Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll n;
  cin>>n;

  vector<ll> w(n);

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

  ll tmp=1000000;

  ll s1=0;
  ll s2=0;

  rep(i,n){
    s2+=w[i];
  }

  rep(i,n){
    s1+=w[i];
    s2-=w[i];
    tmp=min(tmp,abs(s1-s2));

  }

  cout << tmp << endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll r;
  cin >> r;

  if (r < 1200)
    cout << "ABC" << endl;
  else if (r < 2800)
    cout << "ARC" << endl;
  else
    cout << "AGC" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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; }

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

const ll INF = 1LL << 60;

int main(){
  string s; cin >> s;
  int n = s.size();

  vi ans(n,0);

  int i = 0;
  while(i < n){
    int cr = 0;
    while(s[i] == 'R'){
      cr++;
      i++;
    }
    int index_r = i-1;
    int index_l = i;

    int cl = 0;
    while(s[i] == 'L'){
      cl++;
      i++;
    }
    int c = cr + cl;
    if(c%2 == 0){
      ans[index_r] = c/2;
      ans[index_l] = c/2;
    }
    else if(cr%2 == 1){
      ans[index_r] = c/2 + 1;
      ans[index_l] = c/2;
    }
    else if(cr%2 == 0){
      ans[index_r] = c/2;
      ans[index_l] = c/2 + 1;
    }
  }

  rep(i, n) std::cout << ans[i] << '\n';
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
   long double a,b,x;cin>>a>>b>>x;
   long double cur=1.0*x/a;
   cout.precision(10);
   if(cur*2==b*a)cout<<45.0<<endl;
   else if(cur*2<b*a){
       cout<<atan(b*b/cur/2.0)*180.0/M_PI;
   }
   else if(cur>=b*a)cout<<0<<endl;
   else {
       cur=b*a-cur;
       cout<<atan(2.0*cur/a/a)*180/M_PI;
   }
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>

using lli = long long int;
int inf = 1000000007;
using namespace std;

int N, M;
int u, v;
int S, T;

int main()
{
	cin >> N >> M;
	vector<vector<int>> G(3 * N + 1);
	vector<int> cost(3 * N + 1, -3);
	for (int i = 0; i < M; i++) {
		cin >> u >> v;
		G[u].push_back(v + N);
		G[u + N].push_back(v + 2 * N);
		G[u + 2 * N].push_back(v);
	}
	cin >> S >> T;
	queue<int> q;
	q.push(S);
	cost[S] = 0;
	while (q.size() != 0) {
		int now = q.front();
		q.pop();
		for (auto e : G[now]) {
			int nx = cost[now] + 1;
			if (cost[e] == -3) {
				cost[e] = nx;
				q.push(e);
			}
		}
	}
	cout << cost[T] / 3 << endl;
	return 0;
}

Measured memory_bytes: 17792
import std.stdio, std.conv, std.array, std.algorithm, std.string, std.math;

void main() {
    uint count = to!uint(readln().chomp);
    for (uint i = 0; i < count; ++i) {
        double[] t = map!(to!double)(readln().chomp.split).array;
        double[] a = [t[0]-t[2], t[1]-t[3]];
        double[] b = [t[4]-t[6], t[5]-t[7]];
        if (is_zero(outer_product2(a, b))) {
            writeln("YES");
        } else {
            writeln("NO");   
        }
    }
}

bool is_zero(double x) {
    if (abs(x) < 1.0e-10) {
        return true;
    } else {
        return false;
    }
}

double outer_product2(double[] a, double[] b) {
    return a[0]*b[1] - a[1]*b[0];
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define F for(int i = 0; i < n; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
 {  
    FIO
    int n; cin>>n;
  cout<<48-n;
    
    return 0;
}



Measured memory_bytes: 3572
#include"iostream"
using namespace std;
template<class elem>
class linkstack {
private:struct node {
	elem data;
	node* next;
	node(const elem& x, node* n = NULL) :data(x), next(n) {}
	node() :next(NULL) {}
	~node() {}
};
		node* top;
public:linkstack() { top = NULL; }
	   ~linkstack();
	   bool isempty()const { return top == NULL; }
	   void push(const elem& x) { top = new node(x, top); }
	   elem pop() { elem t = top->data; node* p = top; top = top->next; delete p; return t; }
	   elem front()const { return top->data; }
};
template<class elem>
linkstack<elem>::~linkstack()
{
	node* p;
	while (top != NULL)
	{
		p = top;
		top = top->next;
		delete p;
	}
}
int main()
{
	linkstack<int>op;
	char a[1000];
	cin.getline(a, 1000);
	int i, j,k,op1,op2;
	i = 0;
	while(1)
	{
		if (a[i] >= '0' && a[i] <= '9')
		{
			k = 0;
			while (a[i] != ' ')
			{
				k = 10 * k + a[i] - '0';
				++i;
			}
			op.push(k);
		}
		else if(a[i]=='+')
		{
			op2 = op.pop();
			op1 = op.pop();
			op.push(op1 + op2);
			++i;
		}
		else if(a[i]=='-')
		{
			op2 = op.pop();
			op1 = op.pop();
			op.push(op1 - op2);
			++i;
		}
		else if (a[i] == '*')
		{
			op2 = op.pop();
			op1 = op.pop();
			op.push(op1 * op2);
			++i;
		}
		else if (a[i] == '/')
		{
			op2 = op.pop();
			op1 = op.pop();
			op.push(op1 / op2);
			++i;
		}
		if (a[i] == '\0')break;
		++i;
	}
	cout << op.pop() << endl;
	return 0;
}


Measured memory_bytes: 3104
// Author: Jashan Bansal
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second	
#define mp make_pair
#define int long long
#define ll long long
#define pii pair<int,int>
#define all(arr) arr.begin(), arr.end()
#define sz(arr) ((long long)arr.size())
// const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
#define log1(x) cout << x << '\n'
#define log2(x,y) cout << x << " " << y <<'\n'
#define log3(x,y,z) cout << x <<" " << y <<" " << z << '\n'
#define logarr(arr,n) for(int __=0; __ < n; __++)	cout << arr[__] << " "; cout << '\n'

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}


void solve(){
	int n, k; cin >> n >> k;
	vi arr(n);
	for(auto &x: arr) cin >> x;

	vi dp(n+1,INT_MAX);
	dp[1] = 0;
	for(int i=2; i<=n; i++){
		for(int j=1; j<=k; j++){
			if(i-j >= 1)
				dp[i] = min(dp[i], dp[i-j] + abs(arr[i-1] - arr[i-1-j]));
		}
	}
	
	cout << dp[n] << "\n";
}
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	// cin>>t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    public string Proc(List<Tuple<int,int>> tasks )
    {

        var tasks2 = tasks.OrderBy(x => x.Item2).ToList();
        int sum = 0;
        foreach (var it in tasks2)
        {
            sum += it.Item1;
            if (sum > it.Item2) return "No";
        }

        return "Yes";
    }
}

class Program
{
    static string[] GetVals(string splitChar)
    {
        var src = Console.ReadLine();
        return src.Split(new string[] { splitChar }, StringSplitOptions.None);
    }

    static string[] GetVals(char splitChar)
    {
        var src = Console.ReadLine();
        return src.Split(splitChar);
    }

    static string GetVal()
    {
        return Console.ReadLine();
    }

    static void Write(object o)
    {
        Console.WriteLine(String.Format("{0}", o));
    }

    static int ParseI(string val) { return int.Parse(val); }
    static double ParseD(string val) { return double.Parse(val); }

    static void Main(string[] args)
    {
        var n = ParseI(GetVal());
        var lst = new List<Tuple<int, int>>();
        for (int i = 0; i < n; i++)
        {
            var s = GetVals(' ');
            lst.Add(new Tuple<int, int>(ParseI(s[0]), ParseI(s[1])));
        }

        Write(new Solution().Proc(lst));
    }
}

Measured memory_bytes: 33060
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define INF INT_MAX
#define MAX_X 30
#define MAX_Y 30

int cost[4];
int w, h;

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

struct P {
    int cost, x, y, way;
    bool operator >(const P& p) const {
        if (cost != p.cost) return cost > p.cost;
        return y < p.y;
    }
};

int main() {
    while (cin >> w >> h, w|h) {
        vector<vi> field(h, vi(w));
        REP(iy, h) REP(ix, w) {
            cin >> field[iy][ix];
        }
        REP(i, 4) {
            cin >> cost[i];
        }

        vector<vector<vi>> costs(4, vector<vi>(h, vi(w, INF)));
        costs[2][0][0] = 0; // right

        priority_queue<P, vector<P>, greater<P>> que;
        que.push((P){0, 0, 0, 2});
        while (!que.empty()) {
            P p = que.top(); que.pop();
            if (p.x == w - 1 && p.y == h - 1) {
                cout << p.cost << endl;
                break;
            }

            int way = (p.way + field[p.y][p.x]) % 4;
            int sx = p.x + dx[way];
            int sy = p.y + dy[way];

            if (0 <= sx && sx < w && 0 <= sy && sy < h) {
                if (field[p.y][p.x] != 4) {
                    if (costs[way][sy][sx] > p.cost) {
                        costs[way][sy][sx] = p.cost;
                        que.push((P){p.cost, sx, sy, way});
                    }
                }
            }

            REP(d, 4) {
                way = (p.way + d) % 4;
                sx = p.x + dx[way];
                sy = p.y + dy[way];

                if (0 <= sx && sx < w && 0 <= sy && sy < h) {
                    if (costs[way][sy][sx] > p.cost + cost[d]) {
                        costs[way][sy][sx] = p.cost + cost[d];
                        que.push((P){p.cost + cost[d], sx, sy, way});
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 1364
"use strict";
const main = arg => {
  let N = arg.split("\n")[0]*1;
  let A = arg.split("\n")[1].split(" ").map(x=> x*1);
  let count = 1;
  let isAsc = false;
  let isDes = false;
  for(let i = 1; i < N; i++){
    // 昇順
    if(A[i] < A[i-1] ){
      isAsc = true;
    //　降順
    } else if(A[i] > A[i-1]){   
      isDes = true;
    // 同じ値の時
    } else {
    }
    // 判定（昇順かつ降順なら列は続かないのでリセット）
    if(isAsc && isDes){
      isAsc = isDes = false;
      count++;
    }
    
  }
  
  console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 17484
#include <iostream>
#include <algorithm>
#include <queue>
#include <list>
#include <string>
using namespace std;

int main()
{
    int A,B,sum = 0;
    cin >> A >> B;
    if(A > B){
        sum += A;
        A--;
    }else{
        sum += B;
        B--;
    }
        if(A > B){
        sum += A;
        A--;
    }else{
        sum += B;
        B--;
    }
    cout << sum;
}

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

int MAX_N = 10000;
ll R, S, P;

char hand(char t){
  if(t=='r'){
    return 'p';
  } else if(t=='s') {
    return 'r';
  } else {
    return 's';
  }
}

int main() {
  ll N, K; cin >> N >> K;
  cin >> R >> S >> P;
  string T; cin >> T;

  for(int i=0; i<N; i++){
    T[i]=hand(T[i]);
    if(i>=K && T[i]==T[i-K]){
        T[i]=' ';
    }
  }
  ll ans=0;
  for(int i=0; i<N; i++){
    if(T[i]=='r'){
      ans += R;
    } else if(T[i]=='s') {
      ans += S;
    } else if(T[i]=='p'){
      ans += P;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

#define M 100
#define NUMBER '0'

void push(double);
double pop(void);
int getop(char []);

int main(){
  int x;
  double y;
  char str[M];

  while((x = getop(str)) != EOF){
    switch (x){
    case NUMBER:
      push(atof(str));
      break;
    case '+':
      push(pop() + pop());
      break;
    case '-':
      y = pop();
      push(pop() - y);
      break;
    case '*':
      push(pop() * pop());
      break;
    case '\n':
      printf("%.8g\n", pop());
      break;
    default:
      printf("エラー\n");
      break;
    }   
  }
  return 0;
}

int sp = 0;
double val[M];

void push(double x){
  if (sp < M)
    val[sp++] = x;
  else
    printf("エラー（オーバーフロー）\n");
}

double pop(void){
  if (sp > 0)
    return val[--sp];
  else {
    printf("エラー（アンダーフロー）\n");
    return 0.0;
  }
}

int getch(void);
void ungetch(int);

int getop(char str[]){
  int i, c;

  while ((str[0]= c = getch()) == ' ' || c == '\t')
    
  str[1] = '\0';
  if (!isdigit(c) && c != '.')
    return c;
  i = 0;
  if (isdigit(c)) 
    while (isdigit(str[++i] = c = getch()))
      ;
  if (c == '.')
    while (isdigit(str[++i] = c = getch()))
      ;
  str[i] = '\0';
  if (c != EOF)
    ungetch(c);
  return NUMBER;
}

int getch(void) {
char buf[M];
int bufp =0;
  return (bufp > 0) ? buf[--bufp] : getchar();
}

void ungetch(int c){
char buf[M];
int bufp =0;
  if (bufp >= M)
    printf("ungetch: too many characters\n");
  else
    buf[bufp++] = c;
}

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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define tc ll t; cin >> t; while (t--)2 2
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define sz(c) (ll) c.size()
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

bool is_palin(string s) {
	string t = s;
	reverse(all(t));
	return (s == t) ? 1 : 0;
}

string palin(string s) {
	string t;
	ll n = sz(s);
	t = s;
	if(!is_palin(t)) return "No";

	t = s.substr(0,(n-1)/2);
	if(!is_palin(t)) return "No";

	t = s.substr((n+3)/2,n - 1 - ((n+3)/2));
	if(!is_palin(t)) return "No";

	return "Yes";

}

int main() {
    godspeed;
 	string s; cin >> s;
 	cout << palin(s);
}

Measured memory_bytes: 3612
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
 ll x; cin>>x;
  for(ll i=x;x<=100000;i++){
  if(IsPrime(i)){
  cout<<i<<endl;
    return 0;
  }
  }



}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	int b1 = 0, b2 = 0, b4 = 0;
	REP(i, n) {
		ll a;
		cin >> a;
		if (a % 4 == 0) {
			b4++;
		}
		else if (a % 2 == 0) {
			b2++;
		}
		else if (a % 2 == 1){
			b1++;
		}
	}
	bool f = false;
	if (b2 == 0) {
		if (b1 <= b4 + 1) {
			f = true;
		}
	}
	else {
		if (b1 <= b4) {
			f = true;
		}
	}
	if (f) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
cw = [input() for i in range(H)]

ans = 0
# 行の塗り方
for rows in range(2**H):
        # 列の塗り方
    for cols in range(2**W):

        # それぞれの塗り方について、残る黒色を数える
        black = 0

        # 全てのマスを調べる
        for i in range(H):
            for j in range(W):
                # 赤で塗られない、かつ、黒色の場合
                if ((rows >> i) & 1) == 0 and ((cols >> j) & 1) == 0 and cw[i][j] == '#':
                    black += 1

        # 残る黒色の数がちょうどK個の場合
        if black == K:
            ans += 1

print(ans)

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

int main(){

    long long N;
    cin >> N;

    vector<long long> dp(N + 10); dp[0] = 0;
    for(int i = 1; i <= N; i++){
        long long min = 1e12;
        if(i - 1 >= 0) min = std::min(min, 1 + dp[i - 1]);
        for(int j = 1; j < 10000; j++){
            if(i - pow(6, j) >= 0) min = std::min(min, 1 + dp[i - pow(6, j)]);
            else break;
        }
        for(int j = 1; j < 10000; j++){
            if(i - pow(9, j) >= 0) min = std::min(min, 1 + dp[i - pow(9, j)]);
            else break;
        }
        dp[i] = min;
    }

    cout << dp[N] << endl;

    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename T>
std::tuple<T, T, T> extgcd(T a, T b){
    T s1 = 1, t1 = 0, s2 = 0, t2 = 1;
    while(b != 0){
        std::tie(s1, t1, s2, t2) = std::make_tuple(s2, t2, s1 - (a / b) * s2, t1 - (a / b) * t2);
        std::tie(a, b) = std::make_tuple(b, a % b);
    }
    return std::make_tuple(s1, t1, a);
}

template <typename T>
T mod_inverse(T a, T mod){
    T b;
    std::tie(b, std::ignore, std::ignore) = extgcd(a, mod);
    if(b < 0){b += mod;}
    return b;
}

int p;
int a[3100];
int s[3100][3100];
int poly[3100], tmp[3100];

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

  std::cin >> p;

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

  s[0][0] = 1;

  for(int n=0;n<p;++n){
      for(int k=1;k<=n;++k){
          s[n+1][k] = (n * s[n][k] + s[n][k-1]) % p;
      }
      s[n+1][n+1] = 1;
  }

  for(int i=0;i<p;++i){
      if(a[i] > 0){
          int r = s[p][p], y = 0;

          for(int j=p-1;j>=0;--j){
              tmp[j] = r;

              y = (y * i + r) % p;
              r = (s[p][j] + i * r) % p;
          }

          int iy = mod_inverse(y, p);

          for(int j=p-1;j>=0;--j){
              poly[j] += tmp[j] * iy % p;
              if(poly[j] >= p){
                  poly[j] -= p;
              }
          }
      }
  }

  for(int i=0;i<p;++i){
      std::cout << poly[i] << " \n"[i + 1 == p];
  }
}


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

signed main() {
    int n;
    cin >> n;

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

    int m;
    cin >> m;
    vector<int> q(m);
    rep(i,m) cin >> q[i];

    vector<int> v;
    for(int i = 0; i < (1 << n); i++){
        int sum = 0;
        for(int j = 0; j < n; j++){
            if(1 & (i >> j)) sum += a[j];
        }
        v.push_back(sum);
    }
    sort(v.begin(),v.end());
    for(int i = 0; i < m; i++){
        if(binary_search(v.begin(),v.end(), q[i])){
            cout << "yes" << endl;
        } else cout << "no" << endl;
    }

}



Measured memory_bytes: 11084
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>


using namespace std;

int main() {

	int N, K, R, S, P;
	string T;
	cin >> N >> K;
	cin >> R >> S >> P;
	cin >> T;
	vector<int> v(N,0);
	int64_t total = 0;
	for (int i = 0; i < T.length(); i++) {

		if (i - K >= 0) {
			if (T[i] == T[i - K] && v[i - K] == 1)continue;
		}

		if (T[i] == 'r')total += P;
		else if (T[i] == 's')total += R;
		else total += S;
		v[i] = 1;
		//cout << total<<endl;
	}

	cout << total;
	return 0;


}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define modulo 1000000007
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
int main(){
	fast_io;
	int n;
	cin>>n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    int ans=0;
    for (int i = 1; i < n-1; i++)
    {
        if((a[i]>a[i-1] && a[i]<a[i+1]) || (a[i]>a[i+1] && a[i]<a[i-1]))
            ans++;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn main() {
    let x: i32 = read();
    let a: i32 = read();
    let b: i32 = read();
    println!("{}", (x - a) % b);
}


Measured memory_bytes: 4352
n,m = map(int,input().split())
a = list(map(int,input().split()))

imos = [0] * (2*m+2)
ans = 0
for i in range(n-1):
    a0 = a[i]-1
    a1 = a[i+1]-1
    dif = (a1-a0)%m
    ans += dif
    if(dif>=2):
        imos[a0+2] += 1
        imos[a0+dif+1] -= dif
        imos[a0+dif+2] += dif-1

# print(imos)

for i in range(1,2*m+2):
    imos[i] += imos[i-1]
# print(imos)

for i in range(1,2*m+2):
    imos[i] += imos[i-1]
# print(imos)

for i in range(m):
    imos[i] += imos[i+m]

ans -= max(imos[:m])
print(ans)

Measured memory_bytes: 86512
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  int a_i = 0;
  int a_j = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    if (a_i < a[i])
      a_i = a[i];
  }
  int mid = a_i / 2;
  for (int i = 0; i < n; i++)
  {
    int d1 = mid < a_j ? a_j - mid : mid - a_j;
    int d2 = mid < a[i] ? a[i] - mid : mid - a[i];
    if (d1 > d2)
      a_j = a[i];
  }
  cout << a_i << " " << a_j << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

const int INF = 1 << 29;

int main(){
    int n;
    int h[100001] = {};

    cin >> n;

    for(int i = 0; i < n; i++) cin >> h[i];

    int dp[100001];    
    for(int i = 0; i < n; i++) dp[i] = INF;

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

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
 
int main() {
  int x, y;
 
  while(true) {
    cin >> x >> y;
 
    if(!x && !y) {
      break;
    }
 
    for (int i = 0; i < x; ++i) {
      for (int j = 0; j < y; ++j) {
        if(!i || !j || i == x - 1 || j == y - 1) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3084
#include<iostream>

using namespace std;
int main()
{
    int a, b, max;
    cin >> a >> b;
    max = a + b;
    if(max < a-b){
        max = a-b;
    }
    if(max < a*b){
        max = a*b;
    }
    cout << max << endl;
    return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}


template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

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




template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    vll x(n);

    ll t = INF;

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

    for(int l = 0; l < n-k+1; ++l){
        int r = l+k-1;
        t = min(t, min(abs(x[l])+abs(x[r]-x[l]), abs(x[r])+abs(x[r]-x[l])));
    }

    ppp(t);

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] e = new int[n+1];
    for(int i=1;i<=n;i++){
      int t=i;
      for(int j=2;j<=t;j++){
        while(t%j==0){
          e[j]++;
          t/=j;
        }
      }
    }
    int cnt2 = 0;
    int cnt4 = 0;
    int cnt14 = 0;
    int cnt24 = 0;
    int cnt74 = 0;
    int ans = 0;
    for(int i=2;i<=n;i++){
      if(e[i]>=2)cnt2++;
      if(e[i]>=4)cnt4++;
      if(e[i]>=14)cnt14++;
      if(e[i]>=24)cnt24++;
      if(e[i]>=74)cnt74++;
    }
    ans=cnt74+cnt24*(cnt2-1)+cnt14*(cnt4-1)+cnt4*(cnt4-1)*(cnt2-2)/2;
    System.out.println(ans);
  }
}

Measured memory_bytes: 27072
#include <bits/stdc++.h>
using namespace std;
bool rec(int x){
	if(x<=1){
          return false;
}
     for(int i=2;i<=sqrt(x);i++)
     if(x%i==0){
	return false;
}
	return true;

}
int main(){
	int a;
	cin>>a;
	int s=a;
	while(!rec(s)){
		s++;
	}
	cout<<s;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int dp[21][50001];
int n,m;
int c[21];
int solve(int a,int b);
int main(){
  memset(dp,-1,sizeof(dp));
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> c[i];
  }
  cout << solve(0,n) << endl;
}
int solve(int a,int b){
  if(dp[a][b] != -1)return dp[a][b];
  if(b == 0)return dp[a][b] = 0;
  else if(a == m)return dp[a][b] = 100000;
  else if(b < c[a])return dp[a][b] = solve(a+1,b);
  else return dp[a][b] = min(solve(a+1,b),min(solve(a,b-c[a])+1,solve(a+1,b-c[a])+1));
  
}

Measured memory_bytes: 8392
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let b = read_vec::<usize>();
    let mut a = vec![0; n];
    if n == 2 {
        println!("{}", b[0] * 2);
        return;
    }

    a[0] = b[0];
    for i in 1..n - 1 {
        a[i] = min(b[i], b[i - 1]);
    }
    a[n - 1] = b[n - 2];

    debug!(a);
    println!("{}", a.iter().sum::<usize>());
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main() {
  long long n,k;
  cin>>n>>k;
  vector<long long>a(n);
  for(long long i=0;i<n;i++){
    cin>>a.at(i);
  }
  vector<int>ord(n+1,-1);
  vector<int>s;
  int v=1;
  while(ord.at(v)==-1){
    ord.at(v)=s.size();
    s.push_back(v);
    v=a.at(v-1);
  }
  int c=s.size()-ord.at(v);
  int l=ord.at(v);
  if(k<ord.at(v)){
    cout<<s.at(k)<< endl;
  }
 else{
    cout<<s.at(l+(k-l)%c)<< endl;
  }
}


Measured memory_bytes: 6668
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

///////////////////////////////////////////////////////////////////////////


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

	ll N;
	cin >> N;

	cout << 3 * N * N << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
void init(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main()
{
  init();
  int h, w; cin >> h >> w;
  vecstr g(h); REP(i, h) cin >> g[i];
  vector<vecll> dp(h + 1, vecll(w + 1, 0));
  dp[1][1] = 1;
  REP(i,h){
    REP(j,w){
      if(i == 0&&j == 0){dp[i + 1][j + 1] = 1;continue;}
      if(g[i][j] == '#'){dp[i + 1][j + 1] = 0;continue;}
      dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1];
      dp[i + 1][j + 1] %= MOD;
      // cout << dp[i + 1][j + 1] << endl;
    }
  }
  cout << dp[h][w] << endl;
}


Measured memory_bytes: 9216
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i <= (int)b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 100010;
struct Edge { int to, nxt, col, dis; } edge[maxn * 2];
struct Data { 
    int num, col, val;
    Data() {}
    Data(int a, int b, int c) { num = a, col = b, val = c; }
};
vector < Data > ans[maxn];
struct Query { int num, ans; } query[maxn];
int n, q, tot, head[maxn], par[maxn][18], dis[maxn][18], dep[maxn], sum[maxn], cnt[maxn];
void add(int u, int v, int c, int d) {
    edge[++tot].to = v, edge[tot].nxt = head[u], edge[tot].col = c, edge[tot].dis = d, head[u] = tot;
}
void dfs1(int u, int fa) {
    dep[u] = dep[fa] + 1;
    for(int i = head[u]; i; i = edge[i].nxt) if(edge[i].to != fa) {
        int v = edge[i].to;
        par[v][0] = u, dis[v][0] = edge[i].dis;
        dfs1(v, u);
    }
}
int LCA(int u, int v) {
    if(dep[u] < dep[v]) swap(u, v);
    for(int i = 17; i >= 0; i --)
        if(dep[u] - dep[v] >= (1 << i)) u = par[u][i];
    if(u == v) return u;
    for(int i = 17; i >= 0; i --)
        if(par[u][i] != par[v][i]) u = par[u][i], v = par[v][i];
    return par[u][0];
}
void dfs2(int u, int fa) {
    for(int i = head[u]; i; i = edge[i].nxt) if(edge[i].to != fa) {
        int v = edge[i].to;
        sum[edge[i].col] += edge[i].dis;
        cnt[edge[i].col] ++;
        dfs2(v, u);
        sum[edge[i].col] -= edge[i].dis;
        cnt[edge[i].col] --;
    }
    for(int i = 0; i < ans[u].size(); i++) {
        if(ans[u][i].num < 0) query[-ans[u][i].num].ans -= 2 * (cnt[ans[u][i].col] * ans[u][i].val - sum[ans[u][i].col]);
            else query[ans[u][i].num].ans += cnt[ans[u][i].col] * ans[u][i].val - sum[ans[u][i].col];
    }
}
int main()
{
    read(n), read(q);
    rep(i, 1, n - 1) {
        int u, v, c, d;
        read(u), read(v), read(c), read(d);
        add(u, v, c, d);
        add(v, u, c, d);
    }
    dfs1(1, 0);
    rep(j, 1, 17) rep(i, 1, n) par[i][j] = par[par[i][j - 1]][j - 1], dis[i][j] = dis[i][j - 1] + dis[par[i][j - 1]][j - 1];
    rep(i, 1, q) {
        query[i].num = i;
        int x, y, u, v;
        read(x), read(y), read(u), read(v);;
        int lca = LCA(u, v);
        query[i].ans = dis[u][17] + dis[v][17] - 2 * dis[lca][17];
        ans[lca].push_back(Data(-i, x, y));
        ans[u].push_back(Data(i, x, y));
        ans[v].push_back(Data(i, x, y));
    }
    dfs2(1, 0);
    rep(i, 1, q) printf("%d\n", query[i].ans);
    return 0;
}

Measured memory_bytes: 31800