akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define pb push_back
#define sp " "
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (unsigned long long a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=998244353;
int n,m,a[N],s;
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>n>>m;
	fo(i,0,n-1) cin>>a[i];
	fo(i,0,n-1) s+=a[i];
	sort(a,a+n);
	reverse(a,a+n);
	int c=0;
	fo(i,0,n-1) if (a[i]*4*m>=s) c++;
	if (c>=m) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int, int>
#define LL long long
#define mp make_pair
#define pb push_back
using namespace std;

int main() {
	#ifdef DEBUG
	freopen("text.in", "r", stdin);
	#endif
	string s, t;
	int n, m;
	cin >> s >> t;
	n = s.size();
	m = t.size();
	int ans = m;
	for (int i = 0; i + m - 1 < n; ++i) {
		int tmp = 0;
		for (int j = 0; j < m; ++j)
			tmp += s[i + j] != t[j];
		ans = min(ans, tmp);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){
    string s;cin>>s;
    reverse(s.begin(),s.end());
    s=s+'0';
    ll dp[s.size()+1][2];     //下からi桁目まで計算して繰り下がりがjのときの最小枚数
    rep(i,0,s.size()){
        dp[i][0]=inf;
        dp[i][1]=inf;
    }
    dp[0][0]=0;
    rep(i,0,s.size()-1){
        ll x=s[i]-'0';
        rep(j,0,9){
            if(j-x<0){
                dp[i+1][1]=min(dp[i+1][1],dp[i][0]+j+(10+j-x));
            }else{
                dp[i+1][0]=min(dp[i+1][0],dp[i][0]+j+(j-x));
            }
        }
        x++;
        rep(j,0,9){
            if(j-x<0){
                dp[i+1][1]=min(dp[i+1][1],dp[i][1]+j+(10+j-x));
            }else{
                dp[i+1][0]=min(dp[i+1][0],dp[i][1]+j+(j-x));
            }
        }
    }
    cout<<dp[s.size()][0]<<endl;
    
    return 0;
}



Measured memory_bytes: 17116
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			int[] h = new int[n];
			IntStream.range(0, n).forEach(i -> h[i] = scanner.nextInt());
			Arrays.sort(h);
			System.out.println(IntStream.rangeClosed(0, n - k).map(i -> h[i + k - 1] - h[i]).min().getAsInt());
		}
	}
}


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

int main(){
  int N;
  cin >> N;
  
  vector<string> s(N);
  
  for(int i = 0; i < N; i++){
  cin >> s.at(i);
  sort(s.at(i).begin(),s.at(i).end());
  }
  
  sort(s.begin(),s.end());
  
  
  long long Ans = 0;
  long long Num = 0;
  int i = 0;
  int j;
  
  while(i < N){
  	for(j = 1; j + i< N; j++){
    	if(s.at(i) == s.at(i+j)){
        	Num++;
        }else{
          break;
        }
    }
    i += j;
    for (int k = 0; k <= Num; k++){
    Ans += k;
    }
    Num = 0;
  }
  
  cout << Ans << endl;
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

constexpr ll mod=1e9+7;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    vector<ll> sum(n+1);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    reverse(a.begin(), a.end());
    for(int i=0;i<n;i++){
        sum[i+1]=sum[i]+a[i];
        sum[i+1]%=mod;
    }
    ll res=0;
    reverse(a.begin(), a.end());
    for(int i=0;i<n;i++){
        res+=a[i]*sum[n-i-1]%mod;
        res%=mod;
    }
    cout << res << endl;
}


Measured memory_bytes: 6360
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int x[4]={},y[4]={};
    while(cin>>x[0]>>x[1]>>x[2]>>x[3]>>y[0]>>y[1]>>y[2]>>y[3]){
        int h=0,b=0;
        for(int i=0;i<4;i++){
           for(int j=0;j<4;j++){
               if(x[i]==y[j]){
                   if(i==j) h++;
                   else b++;
               }
           }
        }
        cout << h << " " << b << endl; 
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int k, q;
  cin >> k >> q;
  vector<int> d(k);
  rep(i, k) {
    cin >> d[i];
  }
  vector<int> n(q), x(q), m(q);
  rep(i, q) {
    cin >> n[i] >> x[i] >> m[i];
    x[i] %= m[i];
  }

  rep(i, q) {
    vector<int> d_mod(k);
    int d_sum = 0;
    int mod0 = 0;
    rep(j, k) {
      d_mod[j] = d[j] % m[i];
      d_sum += d_mod[j];
      mod0 += (d_mod[j] == 0);
    }


    int plus = n[i] - 1;

    int sum = x[i];
    int nochange = 0;

    sum += plus / k * d_sum;
    nochange += plus / k * mod0;

    rep(j, plus % k) {
      sum += d_mod[j];
      nochange += (d_mod[j] == 0);
    }

    int exceed = sum / m[i];

    int ans = n[i] - 1 - exceed - nochange;
    cout << ans << endl;
  }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  FOR(i,0,1902000000){
    if(i%2==0){
      n*=3;
    }
    else{
      n/=3;
    }
  }
  co(3*n*n)
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int n,m;
int ph1[110000];
int ph2[110000];
int pm[110000];
struct xxx
{
	  int x;
	  int y;
	  int id;
} a[1001001];
bool cmp(xxx a,xxx b)
{
	  if(a.x==b.x)
	    return a.y<b.y;
	  else
	    return a.x<b.x;
}
int main()
{
	  cin>>n>>m;
	  for(int i=1;i<=m;i++)
	    cin>>a[i].x>>a[i].y,a[i].id=i;
	  sort(a+1,a+1+m,cmp);
	  for(int i=1;i<=m;i++)
	  {
	  	    pm[a[i].x]++;
	  	    ph1[a[i].id]=a[i].x;
	  	    ph2[a[i].id]=pm[a[i].x];
	  }
	  for(int i=1;i<=m;i++)
	  {
	  	    int x,pr=6;
	  	    x=ph1[i];
	  	    while(x)
	  	    {
	  	    	 pr--;
	  	    	 x/=10;
			}
			while(pr--)
			  printf("0");
			printf("%d",ph1[i]);
			x=ph2[i];
			pr=6;
			while(x)
			{
				 pr--;
				 x/=10; 
			}
			while(pr--)
			  printf("0");
			printf("%d\n",ph2[i]);
	  }
	  return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
typedef long long ll;
#define F(i,L,R) for (ll i = L; i < R; i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define re(x) scanf("%lld",&x)
using namespace std;


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

  ll n;
  cin>>n;
  vector<ll> val(n+1,0);

  F(i,1,101) F(j,i,101) F(k,j,101) if(i*i + j*j + k*k + i*j + j*k + k*i <= n) {
      ll comb = 6;
      if(i==j && j == k) comb = 1;
      else if(i == j || j == k || i == k) comb = 3;

      val[i*i + j*j + k*k + i*j + j*k + k*i]+= comb;
  }


  F(i,1,n+1) cout<<val[i]<<endl;

  return 0;

}


Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
 
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
signed main(){
    int N,K,X,Y;
    cin>>N>>K>>X>>Y;
 
    cout<<min(N,K)*X+max(0ll,N-K)*Y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(x) for(auto it=(x).begin();it!=(x).end();it++) 
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
 
using namespace std;

int main(){
    int n; cin>>n;
    map<string,int> mp;
    rep(i,0,n){
        string s,t;
        cin>>s>>t;
        if(s=="insert")mp[t]++;
        else if(s=="find"){
            if(mp[t]==0)cout<<"no"<<endl;
            else cout<<"yes"<<endl;
        }
        
    }
    
    
    
    return 0;
}


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

namespace AtCoder_abc121_a
{
    public class Program
    {
        public static int Solve(int[] N , int[] M)
        {
            int[] atai = new int[2];
            for (int i = 0; i <= 1; i++)
            {
                atai[i] = N[i] - M[i];
            }
            int sum = atai[0] * atai[1];

            return sum;
        }

        static void Main(string[] args)
        {
            string[] n = Console.ReadLine().Split(' ');
            int[] hen = n.Select(int.Parse).ToArray();
            int a = int.Parse(n[0]);
            int b = int.Parse(n[1]);

            string[] m = Console.ReadLine().Split(' ');
            int[] hen2 = m.Select(int.Parse).ToArray();
            int c = int.Parse(n[0]);
            int d = int.Parse(n[1]);


            Console.WriteLine(Solve(hen,hen2));
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>

int main(void){
	long int a,b,c,d;
	long long int max;
	int x,y;

	scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
	
	max = a*c > a*d ? a*c : a*d;
	max = max > b*c ? max : b*c;
	max = max > b*d ? max : b*d;

	printf("%lld\n",max);
	
	return 0;
}

Measured memory_bytes: 2104
#include<iostream>
#define MAX_N 1000000
int H, N;
int A[MAX_N];
int main(){
    int sum = 0;
    std::cin >> H >> N;
    for(int i=0; i<N; i++){
        std::cin >> A[i];
        sum += A[i];
    }
    if(sum>=H){
        std::cout << "Yes\n";
    }else{
        std::cout << "No\n";
    }
    return 0;
}

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

int main() {
    string s, s1, s2;
    int x;
    while (1) {
        cin >> s >> x;
        if (s == "-") break;
        
        for (int i = 0; i < x; i++) {
            int n;
            cin >> n;
            
            s2 = s.substr(0, n);
            s1 = s.substr(n, s.size() - n);
            s = s1 + s2;
        }
        
        cout << s << endl;
    }
}


Measured memory_bytes: 3224
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int
main(void){  
  ios_base::sync_with_stdio(false);

  string s;
  cin >> s;

  int ans = 57577;
  
  REP(i, s.size()-2){
    int a = (s[i] - 48)*100 + (s[i+1] - 48)*10 + s[i+2] - 48;
    ans = min(ans, abs(a-753));
  }

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


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> t(n), a(n);
  for (int i = 0; i < n; ++i) cin >> t[i] >> a[i];
  ll tk = 1, ao = 1;
  for (int i = 0; i < n; ++i) {
    ll res1 = (tk + a[i] - 1) / a[i];
    ll res2 = (ao + t[i] - 1) / t[i];
    tk = max(res1, res2) * a[i];
    ao = max(res1, res2) * t[i];
  }
  cout << tk + ao << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int n,m;
    while(cin>>n>>m)
    {
        int ara[n+5];
        memset(ara,0,sizeof ara);
        for(int i=0;i<m;i++)
        {
            int l,r;
            cin>>l>>r;
            ara[l]++;
            ara[r+1]--;
        }
        int cnt=0;
        for(int i=1;i<=n;i++)
        {
            ara[i]+=ara[i-1];
            if(ara[i]==m)cnt++;
        }
        pf("%d\n",cnt);
    }
    return 0;
}
 









 




























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

int main(){
	double x1, y1, x2, y2;
	scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
	printf("%.12lf\n", sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)));
}



Measured memory_bytes: 3212
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int n, k;
int a[100005];
int main(){
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	if(k == n){
		printf("1\n");
		return 0;
	}
	if((n-1)%(k-1) == 0)
		printf("%d\n",(n-1)/(k-1));
	else
		printf("%d\n", (n-1)/(k-1) + 1);
return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main(){
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	ll s1 = 0, s2 = n, l = 1, r = n - 1;
	
	for(int i = k; i <= n + 1; i++){
		while(l < i){
			s1 = (s1 + l) % mod;
			s2 = (s2 + r) % mod;
			l++, r--;
		}
		ans = (ans + s2 + mod - s1 + 1) % mod;
//		cout << ans << "\n";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		List<List<Integer>> list = new ArrayList<List<Integer>>(n);
		Set<Integer> set = new HashSet<Integer>();
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<Integer>());
			set.add(i);
		}
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			int x = Integer.parseInt(sa[0]) - 1;
			int y = Integer.parseInt(sa[1]) - 1;
			list.get(x).add(y);
			set.remove(y);
		}
		br.close();

		int[] maxs = new int[n];
		for (int i : set) {
			List<Integer> work = new ArrayList<Integer>();
			work.add(i);
			dfs(list, maxs, work);
		}

		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans = Math.max(ans, maxs[i]);
		}
		System.out.println(ans);
	}

	static int dfs(List<List<Integer>> list, int[] maxs, List<Integer> work) {
		int now = work.get(work.size() - 1);
		List<Integer> nexts = list.get(now);
		if (nexts.isEmpty()) {
			for (int i = 0; i < work.size(); i++) {
				maxs[work.get(i)] = Math.max(maxs[work.get(i)], work.size() - 1 - i);
			}
			return maxs[now];
		}
		if (nexts.size() == 1 && maxs[now] > 0) {
			for (int i = 0; i < work.size() - 1; i++) {
				maxs[work.get(i)] = Math.max(maxs[work.get(i)],
						maxs[now] + work.size() - 1 - i);
			}
			return maxs[now];
		}

		int max = 0;
		int idx = 0;
		for (int i = 0; i < nexts.size(); i++) {
			work.add(nexts.get(i));
			int ret = dfs(list, maxs, work);
			if (ret > max) {
				max = ret;
				idx = i;
			}
			work.remove(work.size() - 1);
		}
		for (int i = nexts.size() - 1; i >= 0; i--) {
			if (i != idx) {
				nexts.remove(i);
			}
		}
		return maxs[now];
	}
}


Measured memory_bytes: 75984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
ll modinv(ll a){
  ll x = 1;
  ll p = MOD - 2;
  while(p != 0){
    if (p % 2 == 1){
      x = (x * a) % MOD;
      p--;
    }
    a = (a * a) % MOD;
    p /= 2;
  }
  return x;
}

void init(vector<ll> &prd, vector<ll> &iprd){
  prd[0] = 1;
  iprd[0] = 1;
  for(int i=1; i<=2000; i++){
    prd[i] = (prd[i-1] * i) % MOD;
    iprd[i] = modinv(prd[i]);
  }
}


int main(){
  int s;
  cin >> s;
  vector<ll> prd(2001), iprd(2001);
  init(prd, iprd);

  int mx_cel = s/3;
  int part = s%3;
  ll ans = 0;
  for(int cel = mx_cel; cel > 0; cel --){
    ans =  (ans + (prd[(cel - 1 + part)] * (iprd[cel - 1] * iprd[part] % MOD)) % MOD) % MOD;
    part += 3;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3624
local mod = 1000000007
local mfl = math.floor

-- 10^9 + 7 only
-- (31623^2) % 1000000007 = 14122
local function bmul(x, y)
  local x0, y0 = x % 31623, y % 31623
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res
end

local function modinv(src)
  return modpow(src, mod - 2)
end
local n = io.read("*n")
local edge, edgetask = {}, {}
local child = {}
local childnum = {}
local asked = {}
local parent = {}
for i = 1, n do
  edge[i] = {}
  edgetask[i] = 0
  asked[i] = false
  child[i] = {}
  childnum[i] = 0
  parent[i] = 0
end
for i = 1, n - 1 do
  local p, q = io.read("*n", "*n")
  edge[p][q], edge[q][p] = true, true
  edgetask[p] = edgetask[p] + 1
  edgetask[q] = edgetask[q] + 1
end
local tasks = {1}
for i = 2, n do
  if edgetask[i] == 1 then
    table.insert(tasks, i)
  end
end
while 0 < #tasks do
  local src = tasks[#tasks]
  table.remove(tasks)
  asked[src] = true
  local all, whites = 1, 1
  for dst, _u in pairs(edge[src]) do
    if asked[dst] then
      -- child
    else
      -- parent
      parent[src] = dst
      table.insert(child[dst], src)
      childnum[dst] = childnum[dst] + 1 + childnum[src]
      edgetask[dst] = edgetask[dst] - 1
      if edgetask[dst] == 1 and dst ~= 1 then
        table.insert(tasks, dst)
      end
    end
  end
end
local p2 = {2}
for i = 2, n do
  p2[i] = (p2[i - 1] * 2) % mod
end
local totcnt = 0
for i = 1, n do
  -- print(i, table.concat(child[i], " "))
  local ccnts = {}
  local ccntsum = 0
  for j = 1, #child[i] do
    local c = child[i][j]
    ccnts[j] = 1 + childnum[c]
    ccntsum = ccntsum + ccnts[j]
  end
  if i ~= 1 then
    local rem = n - (1 + childnum[i])
    table.insert(ccnts, rem)
    ccntsum = ccntsum + ccnts[#ccnts]
  end
  if 2 <= #ccnts then
    local add = p2[ccntsum]
    for j = 1, #ccnts do
      add = bsub(add, p2[ccnts[j]])
    end
    add = badd(add, #ccnts - 1)
    -- print(i, add)
    totcnt = badd(totcnt, add)
  end
end
-- print(totcnt)
local denom = modinv(p2[n])
print(bmul(denom, totcnt))


Measured memory_bytes: 64596
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  vi B(n);
  for(auto &a:A)cin>>a;
  for(auto &b:B)cin>>b;
  vector<pair<ll,ll>>pll;
  for(int i=0;i<n;i++){pll.pb(mp(A[i],1));pll.pb(mp(B[i],2));}
  sort(ALL(pll));
  ll cnt=0;
  ll cntt=0;
  ll ans=1;
  for(int i=0;i<n*2;i++)
    if(pll[i].S==1){
      if(cntt==0)cnt++;
      else{
	ans*=cntt;
	ans%=MOD;
	cntt--;
      }
    }else{
      if(cnt == 0)cntt++;
      else{
	ans*=cnt;
	ans%=MOD;
	cnt--;
      }
    }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7792
#if 1
  #include <bits/stdc++.h>
#else
  #include "../../../../bits/stdc++.h"
#endif

using namespace std;

#define int long long

using ll = long long;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)

#define rep(i,n) for_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;
const int mod =  1000000007;

int N;
char s[2][54];


int c(int k, int p) {
  if(k>N)return 1;
  if(k==N)return 3-p;
  if(s[0][k-1]==s[0][k]) {
    if(p==0)return 6*c(k+2, 2)%mod;
    else if(p==1)return 2*c(k+2, 2)%mod;
    else return 3*c(k+2, 2)%mod;
  }else {
    return (3-p)*c(k+1, 1)%mod;
  }
}

signed main(){
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin>>N>>s[0]>>s[1];
  
  cout<<c(1, 0)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int num;
  scanf("%d",&num);
  if(num%10 == 7 || (num/10)%10 == 7 || (num/100)%10 == 7){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll H, W;
  cin >> H >> W;

  vector<vector<ll>> a(H + 1, vector<ll>(W + 1));

  vector<tuple<ll, ll, ll, ll>> op;

  REP(h, H + 1) {
    REP(w, W + 1) {
      cin >> a[h][w];
    }
  }

  for (ll h = 1; h <= H; h++) {
    for (ll w = 2; w <= W; w++) {
      if (a[h][w - 1] % 2) {
        a[h][w - 1]--;
        a[h][w]++;
        tuple<ll, ll, ll, ll> o;
        get<0>(o) = h;
        get<1>(o) = w - 1;
        get<2>(o) = h;
        get<3>(o) = w;
        op.push_back(o);
      }
    }
  }

  for (ll h = 2; h <= H; h++) {
    if (a[h - 1][W] % 2) {
      a[h - 1][W]--;
      a[h][W]++;
      tuple<ll, ll, ll, ll> o;
      get<0>(o) = h - 1;
      get<1>(o) = W;
      get<2>(o) = h;
      get<3>(o) = W;
      op.push_back(o);
    }
  }

  cout << op.size() << endl;
  FORm(it, op) {
    cout << get<0>(*it) << " " << get<1>(*it) << " " << get<2>(*it) << " " << get<3>(*it) << endl;
  }

  return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define Pi 1
#define LL long long
#define ULL unsigned long long
#define LD long double

using namespace std;

#define MAX_N 100005

int N;
int A[MAX_N];

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

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if(i == A[i]){
      swap(A[i], A[i+1]);
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
n=int(input())
l=list(map(int, input().split()))
l_res=sorted(l)
cnt=0
for i in reversed(range(n)):
    for j in range(i):
        if l[j]>l[j+1]:
            l[j],l[j+1]=l[j+1],l[j]
            cnt+=1
print(*l_res)
print(cnt)


Measured memory_bytes: 5608
#include<stdio.h>
#include<iostream>

#define FOR(i,m,n) for (long long int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define DEBUG(a) printf("%d\n", a)

int main()
{
  long long int l, r;
  scanf("%lld %lld", &l, &r);

  long long int min = 2019;
  FOR(i,l,r) {
    FOR(j,i+1,r+1) {
      int tmp = (i * j) % 2019;
      min = MIN(tmp, min);
      if (min == 0)
        break;
    }
    if (min == 0)
      break;
  }

  std::cout << min << std::endl;

  return 0;
}

Measured memory_bytes: 256
from functools import reduce
import fractions
n, x = list(map(int, input().split()))
x_li = list(map(int, input().split()))
x_li.append(x)
x_li.sort()
d = []
for i in range(n):
    d.append(x_li[i + 1] - x_li[i])


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if len(d) > 1:
    print(gcd_list(d))
else:
    print(d[0])


Measured memory_bytes: 16304
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
long long SOLVE(long long x){
	if(x==2)
	return 3;
	else return SOLVE(x/2)*2+1;
}
int main(){
	long long n;
	int fac=1;
	long long temp;
	cin>>n;
	if(n==1)
	cout<<1<<endl;
	else{
	while(pow(2,fac)<=n)fac++;
	temp=pow(2,fac-1);
	cout<<SOLVE(temp)<<endl;
}
	return 0;
}

Measured memory_bytes: 256
let () =
  let num_card =
    Array.init 3 @@ fun _ ->
      Array.init 3 @@ fun _ ->
        Scanf.scanf "%d " @@ Fun.id in
  let mark = Array.make_matrix 3 3 false in
  Scanf.scanf "%d\n" @@ fun n ->
    for i = 0 to n - 1 do
      Scanf.scanf "%d\n" @@ fun b ->
        for i = 0 to 2 do
          for j = 0 to 2 do
            if num_card.(i).(j) = b then mark.(i).(j) <- true
          done
        done
    done;
    print_endline @@
    if
      mark.(0) = [| true; true; true |] ||
      mark.(1) = [| true; true; true |] ||
      mark.(2) = [| true; true; true |] ||
      Array.init 3 (fun i -> mark.(i).(0)) = [| true; true; true |] ||
      Array.init 3 (fun i -> mark.(i).(1)) = [| true; true; true |] ||
      Array.init 3 (fun i -> mark.(i).(2)) = [| true; true; true |] ||
      Array.init 3 (fun i -> mark.(i).(i)) = [| true; true; true |] ||
      Array.init 3 (fun i -> mark.(2-i).(i)) = [| true; true; true |]
    then "Yes"
    else "No"

Measured memory_bytes: 3724
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	long long int S,sq,dif,ans=1;
	cin>>S;
	sq=sqrt(S);
	if(sq*sq!=S){
		sq++;
		dif=sq*sq-S;
		for(long long int i=sqrt(dif);i>=1;i--)if(dif%i==0){ans=i;break;}
		cout<<0<<" "<<0<<" "<<sq<<" "<<ans<<" "<<dif/ans<<" "<<sq<<endl;
	}else cout<<0<<" "<<0<<" "<<sq<<" "<<0<<" "<<0<<" "<<sq<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))

# i = 0
# def w(i):
#     # print(i)
#     if A[i] - A[i-1] == 0:
#         return 0
#     else:
#         return (A[i]-A[i-1]) / abs(A[i]-A[i-1])
# v = w(1)
# ans = 1

# i = 2
# while i < n:
#     print(i)
#     nv = w(i)
#     if nv * v < 0:
#         ans += 1
#         i += 2
#         v = 0
#         if i == n:
#             print("p")
#             ans += 1
#     else:
#         i += 1
#     if nv != 0:
#         v = nv

B = []
for i in range(1, n):
    if A[i] != A[i-1]:
        B.append(int((A[i]-A[i-1]) / abs(A[i]-A[i-1])))
# print(B)

ans = 1
t = 0
m = 0
for i in range(len(B)):
    # print(i)
    if B[i] * t < 0:
        # print("p")
        ans += 1
        t = 0
        if i == len(B):
            ans += 1
    else:
        t = B[i]

print(ans)

Measured memory_bytes: 63724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li          long
#define ll          long long
#define ull         unsigned long long
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pli         pair<li,li>
#define pll         pair<ll,ll>
#define pb          push_back
#define fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(i,k,n)   for(int i = k; i>=n; i--)
#define tc          int t;cin>>t;while(t--)
#define all(v)      v.begin(),v.end()
#define inf         INT_MAX
#define ninf        INT_MIN
#define W(x)        cout<<x<<endl
#define WW(x,y)     cout<<x<<' '<<y<<endl;
#define in(x)       cin>>x
#define vi          vector<int>
#define vll         vector<long long>
#define vpi         vector<pair<int>>
#define vpll        vector<pair<long long>>
#define vvi         vector<vector<int>>
#define vvll        vector<vector<long long>>
#define vvpi        vector<vector<pair<int,int>>>
#define vvpll       vector<vector<pair<long long>>>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
} 

template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}

void solve(){
    int x,n;
    cin>>x>>n;
    multiset<int> st;
    for(int i = 0; i<n; i++){
        int y;
        cin>>y;
        st.insert(y);
    }
    if(st.find(x) == st.end())cout<<x;
    else{
        int z = x;
        while(st.find(z) !=st.end())z++;
        int w = x;
        while(st.find(w)!=st.end())w--;
        if(z-x<x-w)cout<<z;
        else cout<<w;
    }
}

signed main(){
    fastio();
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3656
#coding:utf-8
#1_4_D
def is_carriable(w_lim, trucks, loads):
    """ Check whether w_lim(maximum carrying capacity) is possible or not """
    i = 0
    while trucks > 0:
        w = 0
        while i < len(loads):
            if w + loads[i] > w_lim:
                trucks -= 1
                break
            w += loads[i]
            i += 1
        if i == len(loads):
            return True
    return False

n, trucks = map(int, input().split())
loads = [int(input()) for i in range(n)]

left = max(loads)
right = sum(loads) + 1

while right - left > 1:
    mid = (left + right) // 2
    if is_carriable(mid, trucks, loads):
        ans = mid
        right = mid
    else:
        left = mid

if is_carriable(max(loads), trucks, loads):
    ans = max(loads)

print(ans)

Measured memory_bytes: 11668
#include<cstdio>
#include<iostream>
#include<cctype>
using namespace std;

int main(){
 char s;
 while(1){
  scanf("%c",&s);
  if(isalpha(s)){
   if(islower(s))cout<<(char)toupper(s);
   else if(isupper(s))cout<<(char)tolower(s);
  }
  else{
   cout<<s;
  }
  if(s=='\n')break;
 }
 return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <string>
#include <sstream>
#include <iomanip>
#include <functional>

using namespace std;

int main() {

    string s;
    std::cin >> s;
    int c=(int)s.find("C");
    int f=(int)s.find("F",c);
    if ((c!=-1 && f!=-1) && c<f) {
      std::cout << "Yes" << std::endl;
    }else{
      std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  int n, m ;
  int count = 0 ;
  int ans = 0 ;
  cin >> n ;
  vector<string> s(n) ;
  REP(i,n){
    cin >> s.at(i) ;
  }
  cin >> m ;
  vector<string> t(m) ;
  REP(i,m){
    cin >> t.at(i) ;
  }
  
  REP(i,n){
    FOR(j,i,n){
      if(s.at(i)==s.at(j)){
        count++ ;
      }
    }
    REP(k,m){
      if(s.at(i)==t.at(k)){
        count-- ;
      }
    }
    ans = max(count,ans) ;
    count = 0 ;
  }
  
  cout << ans <<endl ;

  return 0 ;
}




Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)
F = sys.stdin
N, M = map(int, F.readline().strip("\n").split())
Edge = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, F.readline().strip("\n").split())
    Edge[A-1].append(B-1)
    Edge[B-1].append(A-1)

Color = [0] * N


def dfs(v, c):
    Color[v] = c
    for next in Edge[v]:
        if Color[next] == c: return False
        if Color[next] == 0:
            if not dfs(next, -c): return False
    return True

Bipartite = dfs(0, 1)
if Bipartite:
    black = Color.count(1)
    print(black * (N-black) - M)
else:
    print(N * (N - 1)//2 - M)

Measured memory_bytes: 31160
#include<stdio.h>

int main(){
	
	int a,b,c,N,t,A,B,C;
	
	scanf("%d",&N);
	
	for(t=0;t<N;t++){
		
		scanf("%d %d %d",&a,&b,&c);
		
		A=a*a-b*b-c*c;
		B=b*b-c*c-a*a;
		C=c*c-a*a-b*b;
		
		if(A==0||B==0||C==0){
			
			printf("YES\n");
		}
		else printf("NO\n");
		
	}
	
	return 0;
	
}

Measured memory_bytes: 2564
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
	int a, b, c, d, n, count;

	while(cin >> n){
		count = 0;

		for(a = 0; a <= 9; a++){
			for(b = 0; b <= 9; b++){
				for(c = 0; c <= 9; c++){
					for(d = 0; d <= 9; d++){
						if((a + b + c + d ) == n){
							count++;
							break;
						}
						if((a + b + c + d) > n){
							break;
						}
					}
					if((a + b + c) > n){
						break;
					}
				}
				if((a + b) > n){
					break;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
       int a,b,c;
       scanf("%d%d",&a,&b);
       if(b/10==0){
              c=a*10+b;
       }
       else if(b/10&&b/100==0){
              c=a*100+b;
       }
       else {
              c=a*1000+b;
       }
       int d=sqrt(c);
       if(d*d==c){
              printf("Yes");
       }
       else printf("No");
       return 0;
}



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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int ans = 0;
    for (int r = 0; r * R <= N; r++) {
        for (int g = 0; r * R + g * G <= N; g++) {
            ans += (N - r * R - g * G) % B == 0;
        }
    }

    cout << ans << endl;

    return 0;
}



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

using namespace std;

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

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

const int MAX_N = 1e5 + 7;


void solve()
{
        ld n; cin >> n;
        if (pow(2, (int)(ceil(log2(n)))) == n)
        {
                cout << (ll)(pow(2, (int)(ceil(log2(n + 1)))) - 1);
        }
        else cout << (ll)(pow(2, (int)(ceil(log2(n)))) - 1);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 4208
#include <iostream>
#include <vector>
using namespace std;
using P = pair<int,int>;

P solve(string& s){
	char b0 = s[0];
	char b1 = s[1];

	if(b0 == b1)
		return P(1,2);
	for(int i = 2; i < s.length(); i++){
		if(b1 == s[i])
			return P(i,i+1);
		if(b0 == s[i])
			return P(i-1,i+1);

		b0 = b1;
		b1 = s[i];
	}

	return P(-1,-1);
}

int main(){
	string s;
	cin >> s;
	P res = solve(s);
	cout << res.first << " " << res.second << endl;
}



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

int main() {
	
	int n, m, l, count = 0;

	cin >> n;

	for (int i = 1; i <= n; i++) {
		m = i;
		l = 0;
		while (m >= 1) {
			m = m / 10;
			l++;
		}
			if(l == 1 || l == 3 || l == 5){
				count++;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
/**
*    author:  Dooloper
*    created: 24.06.2020 20:54:39
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <functional>
#include <cassert>


using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define PI 3.14159265358979323846264338327950L

int main() {
    cin.tie(0);
    int N, M, X;
    cin >> N >> M >> X;
    vector<vector<int>> A(N, vector<int>(M + 1));
    for (int i = 0; i < N; i++){
        for (int j = 0; j < M + 1; j++){
            cin >> A[i][j];
        }
    }

    int ans = 12345678;
    int all = 1 << N;

    for (int mask = 0; mask < all; mask++){
        vector<int> level(M);
        int cost = 0;
        for (int i = 0; i < N; i++){
            if((mask>>i) &1 ){
                cost += A[i][0];
                for (int j = 0; j < M; j++){
                    level[j] += A[i][j + 1];
                }
            }
        }
        bool ok = true;
        for (int j = 0; j < M; j++){
            if(level[j] < X)
                ok = false;
        }
        if(ok)
            ans = min(ans, cost);
    }
    if(ans == 12345678)
        cout << -1 << endl;
    else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  int a=0,b=0;
  REP(i,n){
    int d;
    cin >> d;
    if(d%2 == 0)
      a++;
    else
      b++;
  }
  vector <int> sum;
  ll t=1,w = 1;
  REP(i,n){
    t *= 3;
  }
  REP(i,a){
    w *= 2;
  }
  cout << t - w << endl;
  return 0;
}


Measured memory_bytes: 256
def test():
    a,b,c,x,y = map(int,input().split())
    result = float("inf")
    for i in range(x+y):
        result = min(result,2*c*i + a*max(0,x-i) + b*max(0,y-i))
    print(result)


if __name__ == "__main__":
    test()


Measured memory_bytes: 39536
import sys
n = int(input())
h = list(map(int, input().split()))

for i in range(1, n):
    if h[i] > h[i-1]:
        h[i] = h[i] - 1

for i in range(1, n):
    if h[i] < h[i-1]:
        print('No')
        sys.exit()

print('Yes')


Measured memory_bytes: 15020
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        ArrayList<Integer> arrayList = new ArrayList<Integer>();

        for(int i=0; i<n; i++){
            int p = sc.nextInt();
            arrayList.add(p);
        }


        int cnt = 0;

        for(int i=0; i<arrayList.size()-2; i++){

            int first = arrayList.get(i);
            int mid = arrayList.get(i+1);
            int last = arrayList.get(i+2);

            int max = Math.max(first, last);
            int min = Math.min(first, last);

            if(min < mid && mid < max){
                cnt++;
            }
        }

        System.out.println(cnt);

    }
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;

  int sum[n + 1];
  memset(sum, 0, sizeof(sum));
  for (int i = n - 1; i >= 0; i--) {
    sum[i] = sum[i + 1];
    if (s[i] == '.') sum[i]++;
  }

  int ans = INF;
  int cnt = 0;
  rep (i, n) {
    if (s[i] == '#') {
      ans = min(ans, cnt + sum[i]);
      cnt++;
    }
  }
  ans = min(ans, cnt);

  cout << ans << endl;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
string s;
int main() {
	cin>>s;
	if(s=="ABC"){
		cout<<"ARC";
	}else{
		cout<<"ABC"; 
	}
} 

Measured memory_bytes: 3584
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main(){
	string w;
	cin >> w;
	int count[26] = {0};

	for (int i = 0; i < w.length(); ++i){
		count[w[i]-'a']+=1;

	}

	int flag = 0;
	for (int i = 0; i < 26; ++i){
		if (count[i] %2 != 0){
			flag = 1;
			break;
		}
	}


	if (flag == 0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256