akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL a,b;
    cin >> a >> b;

    vector<string> str(98);

    for(int i = 0; i < 49; i++){
        for(int j = 0; j < 98; j++){
            str[i] += ".";
        }
    }
    for(int i = 49; i < 98; i++){
        for(int j = 0; j < 98; j++){
            str[i] += "#";
        }
    }

    a--;
    b--;

    int k = 1;
    int l = 1;

    while(b > 0){
        str[k][l] = '#';
        l += 2;
        if(l >= 98){
            l = 1;
            k += 2;
        }
        b--;
    }
    k = 50;
    l = 1;
    while(a > 0){
        str[k][l] = '.';
        l += 2;
        if(l >= 98){
            l = 1;
            k += 2;
        }
        a--;
    }

    cout << "98 98" << endl;

    for(int i = 0; i < 98; i++){
        cout << str[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  long n;
  cin >> n;
  vector<long> list(n+1,0);
  long tmp;
  long answer = 0;
  rep(i,n){
    cin >> tmp;
    if(tmp > n){
      answer++;
      continue;
    }
    list.at(tmp)++;
  }
  for(int i=1;i<=n;i++){
    tmp = list.at(i);
    if(tmp < i){
      answer += tmp;
    }else if(tmp > i){
      answer += tmp - i;
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int n,a[100];
//Dinic O(EV^2)
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<limits>
template<typename T>
struct MF{
	vector<vector<pair<pair<int,int>,T> > >G;
	vector<int>level,iter;
	MF(int n_=0):G(n_),level(n_),iter(n_){}
	void add_edge(int from,int to,T cap)
	{
		G[from].push_back(make_pair(
			make_pair(to,G[to].size()),cap
		));
		G[to].push_back(make_pair(
			make_pair(from,G[from].size()-1),0
		));
	}
	T dfs(int u,int t,T f)
	{
		if(u==t)return f;
		for(;iter[u]<G[u].size();iter[u]++)
		{
			pair<pair<int,int>,T>&e=G[u][iter[u]];
			if(e.second>0&&level[u]<level[e.first.first])
			{
				T d=dfs(e.first.first,t,min(f,e.second));
				if(d>0)
				{
					e.second-=d;
					G[e.first.first][e.first.second].second+=d;
					return d;
				}
			}
		}
		return 0;
	}
	T max_flow(int s,int t)
	{
		T ret=0;
		for(;;)
		{
			fill(level.begin(),level.end(),-1);
			queue<int>P;
			level[s]=0;
			P.push(s);
			while(!P.empty())
			{
				int u=P.front();P.pop();
				for(pair<pair<int,int>,T>&e:G[u])
				{
					if(e.second>0&&level[e.first.first]<0)
					{
						level[e.first.first]=level[u]+1;
						P.push(e.first.first);
					}
				}
			}
			if(level[t]<0)return ret;
			fill(iter.begin(),iter.end(),0);
			for(T f;(f=dfs(s,t,numeric_limits<T>::max()))>0;)ret+=f;
		}
	}
};
main()
{
	cin>>n;
	MF<long>mf(n+2);
	long ans=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>=0)ans+=a[i],mf.add_edge(i+1,n+1,a[i]);
		else mf.add_edge(0,i+1,-a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+i;j<=n;j+=i)mf.add_edge(i,j,numeric_limits<long>::max());
	}
	cout<<ans-mf.max_flow(0,n+1)<<endl;
}

Measured memory_bytes: 256
main :: IO ()
main = do
    s <- getLine :: IO String
    let y = read $ take 4 s :: Int
    let m = read $ take 2 $ drop 5 s :: Int
    let d = read $ take 2 $ drop 8 s :: Int
    putStrLn $ if y <= 2019 && m <= 4 && d <= 30 then "Heisei" else "TBD" 

Measured memory_bytes: 508
def main():
    import sys
    readline = sys.stdin.buffer.readline

    n = int(readline())
    d = list(map(int, readline().split()))

    e = sum(d)
    ans = 0
    for i in d:
        e -= i
        ans += i*e
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9072
#include <iostream>
#include <cmath>
using namespace std;
typedef long long int LLI;

bool diff_sign( LLI a, LLI b )
{
	if( a > 0 and b < 0 or a < 0 and b > 0 )
		return true;
	return false;
}

void set_starting_values( LLI & tmp, LLI & neg, LLI & pos, LLI & neg_sum, LLI & pos_sum)
{
	if( tmp < 0 ){
		neg = tmp;
		neg_sum = 0;
		pos = 1;
		pos_sum = abs(tmp) + 1;
	}else if( tmp > 0 ){
		neg = -1;
		neg_sum = abs(tmp) + 1;
		pos = tmp;
		pos_sum = 0;
	}else{
		neg = -1;
		pos = 1;
		neg_sum = 1;
		pos_sum = 1;
	}
}

void analyze_step_by_step( LLI & tmp, LLI & neg, LLI & pos, LLI & neg_sum, LLI & pos_sum, bool & neg_state, bool & pos_state)
{
	// Set the sign
	if( pos_state == true ){
		pos_state = false;
		neg_state = true;
	}else{
		pos_state = true;
		neg_state = false;
	}
		
	if( pos == -tmp ){
		pos_sum++;
		if( pos_state == true )
			pos = 1;
		else
			pos = -1;
	}else if( !diff_sign(pos,pos+tmp) ){
		pos_sum += abs(pos+tmp) + 1;
		if( pos_state == true )
			pos = 1;
		else
			pos = -1;
	}else{
		pos += tmp;
	}
	
	if( neg == -tmp ){
		neg_sum++;
		if( neg_state == true )
			neg = 1;
		else
			neg = -1;
	}else if( !diff_sign(neg,neg+tmp) ){
		neg_sum += abs(neg+tmp) + 1;
		if( neg_state == true )
			neg = 1;
		else
			neg = -1;
	}else{
		neg += tmp;
	}
		
}

int main()
{
	LLI n, tmp, pos, neg, pos_sum, neg_sum;
	bool pos_state = true, neg_state = false;
	cin >> n >> tmp;
	
	set_starting_values( tmp, neg, pos, neg_sum, pos_sum );
	
	for(int i = 1; i < n; i++)
	{
		cin >> tmp;
		analyze_step_by_step( tmp, neg, pos, neg_sum, pos_sum, neg_state, pos_state );
	}
	
	if( pos_sum > neg_sum )
		cout << neg_sum;
	else
		cout << pos_sum;
}

Measured memory_bytes: 3140
n, m = map(int, input().split())
a = {int(input()) for _ in range(m)}
dp = [0] * (n + 1)
dp[0] = 1
for i in range(1, n+1):
    dp[i] = (dp[i - 1] + dp[i - 2]) % (10 ** 9 + 7)
    if i in a: dp[i] = 0
print(dp[n])


Measured memory_bytes: 11884
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<lint,lint> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int ne[200100][25];
int a[200100],dp[200100];
int main()
{
	int n;cin>>n;rep(i,n) cin>>a[i];
	rep(i,n+10) rep(j,22) ne[i][j]=n;
	for(int i=n-2;i>=0;i--) rep(j,22){
		ne[i][j]=ne[i+1][j];
		if((a[i+1]&(1<<j))) ne[i][j]=i+1;
	}
	lint out=0;dp[n]=n;
	for(int i=n-1;i>=0;i--){
		int ma=n;
		rep(j,22){
			if((a[i]&(1<<j))) ma=min(ma,ne[i][j]);
		}
		//cout<<i<<ma<<endl;
		dp[i]=min(dp[i+1],ma);
		out+=dp[i]-i;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 21376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+10;
const ll inf = 1e9+7;
vector<int>p[maxn];
int a[maxn];
int main() {
    ios::sync_with_stdio(0);
    ll x,f=0,ans,ansp;
    cin>>x;
    for(ll i=-100;i<=10000&&!f;i++){
        for(ll j=-100;j<=10000&&!f;j++){
            if(i*i*i*i*i-j*j*j*j*j==x){
                ans = i,ansp=j;
                f=1;
                break;
            }
        }
    }
    cout<<ans<<" "<<ansp<<endl;
    return 0;
}


Measured memory_bytes: 8344
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
typedef long long ll;

int main(){
	ll n;
	string s;
	cin >> n >> s;
	
	ll r=0,g=0,b=0;
	REP(i,n){
		if(s[i]=='R') r++;
		if(s[i]=='G') g++;
		if(s[i]=='B') b++;
	}
	ll ans = r*g*b;
	
	
	
	for(int i=1; i<=n; i++){
		for(int j=i+1; j<=n; j++){
			int k = 2*j - i;
			if(k > n) break;
			if(s[i-1]!=s[j-1] && s[j-1]!=s[k-1] && s[k-1]!=s[i-1]) ans--; 
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int X = scan.nextInt();

        int cnt = 0;
        for (int i = 0; i < A + 1; i++) {
            for (int j = 0; j < B + 1; j++) {
                for (int k = 0; k < C + 1; k++) {
                    int total = 500*i+100*j+50*k;
                    if (total == X) {
                        cnt++;
                    }
                }
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 23380
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(a*b + " " + 2*(a+b));
        sc.close();
    }
}


Measured memory_bytes: 26096
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int a,b;cin>>a>>b;
  if(a<=5){
    cout<<0<<endl;
  }else if(a<=12){
    cout<<b/2<<endl;
  }else{
    cout<<b<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long x;
    cin>>x;
    for(long long i=-200;i<=200;i++)
    {
        for(long long j=-200;j<=200;j++)
        {
            if(i*i*i*i*i-j*j*j*j*j==x){cout<<i<<' '<<j<<endl; return 0;}
        }
    }
}




Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<map>
#include<cassert>
#include<algorithm>
#include<deque>
#define F first
#define S second
#define pb push_back

using namespace std;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<P> VP;
typedef vector<VP> VVP;

class Pox
{
public:
  int p;
  int ST;
  int cost;
  Pox(int p = 0,int ST = 0,int cost = 0):p(p),ST(ST),cost(cost){}
};

int main()
{
  int N,M,L,K,A,H;
  while(cin >> N >> M >> L >> K >> A >> H,(N || M || L || K || A || H))
    {
      VVP G;
      G.resize(N);
      int mincost[N][M+1];
      bool hospital[N];
      for(int i=0;i<N;i++)
	hospital[i] = false;
      for(int i=0;i<N;i++)
	for(int j=0;j<=M;j++)
	  mincost[i][j] = (1<<28);

      for(int i=0;i<L;i++)
	{
	  int num;
	  cin >> num;
	  hospital[num] = true;
	}

      for(int i=0;i<K;i++)
	{
	  int X,Y,T;
	  cin >> X >> Y >> T;
	  G[X].push_back(P(Y,T));
	  G[Y].push_back(P(X,T));
	}

      deque<Pox> deq;
      deq.pb(Pox(A,M,0));
      mincost[A][M] = 0;
      int ans = (1<<28);

      while(!deq.empty())
	{
	  Pox pox = deq.front(); deq.pop_front();
	  int p = pox.p;
	  int ST = pox.ST;
	  int cost = pox.cost;

	  if(cost >= ans)
	    continue;	 

	  if(p == H)
	    {
	      ans = min(ans,cost);
	      continue;
	    }

	  for(int i=0;i<G[p].size();i++)
	    {
	      P np = G[p][i];
	      int nST = ST - np.S;
	      
	      if(nST < 0)
		continue;	      
	      
	      if(!hospital[np.F])
		{	
		  if(mincost[np.F][nST] > cost + np.S)
		    {
		      mincost[np.F][nST] = cost + np.S;
		      deq.push_back(Pox(np.F,nST,cost+np.S));
		    }

		}
	      else
		{

		  for(int j=0;j<=M-nST;j++)
		    {
		      assert(nST+j <= M);
		      if(mincost[np.F][nST+j] > cost + np.S + j)
			{
			  mincost[np.F][nST+j] = cost + np.S + j;
			  deq.pb(Pox(np.F,nST+j,cost+np.S+j));
			}	  
		    }
		  
		}

	    }

	}
      ans == (1<<28)?cout << "Help!" << endl:cout << ans << endl;
    }
  return 0;
}

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

int main() {
  
  int h, n;
  cin >> h >> n;
 
  int ans = 0, a;
  REP(i,n) {
    cin >> a;
    ans += a;
  } 
  
  cout << ((ans >= h) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const double pi = 3.141592653589793;



int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    rep(i, N){
        cin>>A[i];
    }
    sort(ALL(A));
    ll Ans=0;
    rep(i, N){
        Ans+=A[N-1-i]*pow(-1, i);
    }
    cout<<Ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 0){
            System.out.println(1);
        }
        else if (n == 1){
            System.out.println(1);
        }
        else {
            int f = 0;
            int f1 = 1;
            int f2 = 1;
            for (int i = 2; i <= n; i++){
                f = f1 + f2;
                f2 = f1;
                f1 = f;
            }
            System.out.println(f);
        }
    }
}



Measured memory_bytes: 26308
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)


int main(){
	int h,w;
	cin>>h>>w;
	vector<string> vs(h);
	rep(i,h)cin>>vs[i];
	
	int ans = 0;
	rep(i,h){
		rep(j,w){
			if(i==0)continue;
			if(vs[i][j]!='-')continue;
			if( (j!=0 && vs[i][j-1]=='o') || (j!=w-1 && vs[i][j+1]=='o') )continue;
			
			int dy[]={-1,-1,-1,0,1,1,1,0};
			int dx[]={-1,0,1,1,1,0,-1,-1};

			bool f = true;
			rep(k,8){
				int ddy = i+dy[k];
				int ddx = j+dx[k];
				if(  ddx>=0 && ddy>=0 && ddx<w && ddy<h && vs[ddy][ddx]=='x' )f=false;
			}
			if(f)ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3168
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#define ll long long
using namespace std;
int main(){
     double W,H,x,y;
     cin >> W >> H >> x >> y;
     if(x == W/2 && y == H/2){
          cout << W*H/2.0 << " " << 1 << endl;
     }else{
          cout << W*H/2.0 << " " << 0 << endl;
     }
     return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

#define MAX 2010
int dp[4][MAX][MAX];
//RLUD

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	int K;
	cin >> S >> K;
	string RL, UD;

	fill(dp[0][0], dp[4][0], -INF);
	rep(h, 0, 4)dp[h][0][0] = 0;

	rep(i, 0, S.size()) {
		if (S[i] == 'R' || S[i] == 'L')RL += S[i];
		else UD += S[i];
	}
	dump(RL, UD);

	rep(h, 0, 2) {
		rep(i, 0, RL.size()) {
			rep(k, 0, K + 1) {
				if (RL[i] == "RLUD"[h]) {
					if (k % 2 == 0) {
						chmax(dp[h][i + 1][k], dp[h][i][k] + 1);
					}
					else {
						chmax(dp[h][i + 1][k], dp[h][i][k] - 1);
						chmax(dp[h][i + 1][k + 1], dp[h][i][k] + 1);
					}
				}
				else {
					if (k % 2 == 1) {
						chmax(dp[h][i + 1][k], dp[h][i][k] + 1);
					}
					else {
						chmax(dp[h][i + 1][k], dp[h][i][k] - 1);
						chmax(dp[h][i + 1][k + 1], dp[h][i][k] + 1);
					}
				}
			}
		}
	}

	//rep(i, 0, RL.size() + 1) {
	//	rep(k, 0, K + 1) {
	//		dump(i, k, dp[0][i][k]);
	//	}
	//}

	rep(h, 2, 4) {
		rep(i, 0, UD.size()) {
			rep(k, 0, K) {
				if (UD[i] == "RLUD"[h]) {
					if (k % 2 == 0) {
						chmax(dp[h][i + 1][k], dp[h][i][k] + 1);
					}
					else {
						chmax(dp[h][i + 1][k], dp[h][i][k] - 1);
						chmax(dp[h][i + 1][k + 1], dp[h][i][k] + 1);
					}
				}
				else {
					if (k % 2 == 1) {
						chmax(dp[h][i + 1][k], dp[h][i][k] + 1);
					}
					else {
						chmax(dp[h][i + 1][k], dp[h][i][k] - 1);
						chmax(dp[h][i + 1][k + 1], dp[h][i][k] + 1);
					}
				}
			}
		}
	}

	int ans = -INF;
	rep(j, 0, K + 1) {
		rep(k, 0, K + 1) {
			if (j + k > K)break;
			rep(a, 0, 2)rep(b, 2, 4) {
				chmax(ans, dp[a][RL.size()][j] + dp[b][UD.size()][k]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 66368
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N, M;
string s[200], t[200];
map<string, int> sm;
map<string, int> tmap;

int main() {
  cin >> N;
  rep(i, 0, N) {
    cin >> s[i];
    sm[s[i]]++;
  }
  cin >> M;
  rep(i, 0, M) {
    cin >> t[i];
    tmap[t[i]]++;
  }

  int ans = 0;
  for (auto e : sm) {
    string word = e.first;
    int score = e.second;
    score -= tmap[word];
    chmax(ans, score);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;

namespace ABC057C
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            int len = N.ToString().Length;
            long rootN = (long)Math.Sqrt(N) + 1;
            for (long i = 1; i <= rootN; i++)
            {
                if(N % i != 0) { continue; }
                long B = N / i;
                if(i>B) { break; }
                int l1 = i.ToString().Length;
                int l2 = B.ToString().Length;
                if(l1 < l2){
                    if(len > l2){
                        len = l2;
                    }
                }
                else{
                    if(len > l1){
                        len = l1;
                    }
                }
            }
            Console.WriteLine(len);
        }
    }
}


Measured memory_bytes: 13140
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
import math

n, d = map(int, input().split())
cnt = 0
for i in range(n):
    x, y = map(int, input().split())
    dis = math.sqrt(x ** 2 + y ** 2)
    if dis <= d:
        cnt += 1
print(cnt)


Measured memory_bytes: 9104
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		int n = sc.nextInt();

		int[] array = new int[n];
		int[] counts = new int[n];

		for (int i = 0; i < n; i ++) {
			array[i] = sc.nextInt();
		}

		if (array[0] != 0) {
			System.out.println(0);
			System.exit(0);
		}

		Arrays.sort(array);

		long result = 1;
		long beforeCount = 1;
		long count = 0;
		long num = 0;

		if (array[0] != 0 || array[1] == 0) {
			result = 0;
		} else {
			for (int i : array) {
				if (i != num) {
					if (i == num + 1) {
						num += 1;
						beforeCount = count;
						count = 0;
					} else {
						result = 0;
						break;
					}
				}
				count ++;

				long ibc = beforeCount % 998244353;

				result = (result * ibc % 998244353);


			}
		}

		System.out.println(result);
	}

}




Measured memory_bytes: 59980
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
  ll n;
  cin>>n;
  cout<<(n*n+n)/2;}

Measured memory_bytes: 3656
#include <stdio.h>

int judge(int W, int H, int x, int y, int r)
{
    int point_x, point_y;

    point_x = x + r;
    point_y = y + r;

    if(point_x > W) {
        return 0;
    }
    if(point_y > H) {
        return 0;
    }
    
    point_x = x - r;
    point_y = y - r;
 
    if(point_x < 0) {
        return 0;
    }
    if(point_y < 0) {
        return 0;
    }

    return 1;
}

int main(void)
{
    int W, H, x, y, r;

    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if(judge(W, H, x, y, r) == 1) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 584
#include <bits/stdtr1c++.h>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef complex<ld> pt;

int main() {
	ios::sync_with_stdio(0);
	int a, b;
	cin >> a >> b;
	cout << max(a+b, max(a-b, a*b)) << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

# 11:50-
# 50min: give up
# 15:15-15:58 done


def main():
    N, K = map(int, input().split())
    x, y = [None] * N, [None] * N
    for i in range(N):
        x[i], y[i] = map(int, input().split())
    
    points = [[i, x[i], y[i]] for i in range(N)]
    points_ysort = sorted(points, key=lambda p: p[2], reverse=True)
    points_ysort_rev = list(reversed(points_ysort))
    points_xsort = sorted(points, key=lambda p: p[1], reverse=False)
    points_xsort_rev = list(reversed(points_xsort))
    
    min_area = 4 * (10**18)
    outsides_top = []
    
    t = 0
    while t <= N-K:
        # n_inside = N - t

        top_i, top_x, top_y = points_ysort[t]

        outsides_bottom = []
        b = 0
        while b < N:
            # n_inside -= b

            bottom_i, bottom_x, bottom_y = points_ysort_rev[b]

            if bottom_i == top_i:
                break

            # outsides_left = []
            n_outsides_left = 0
            l = 0
            while l < N:
                left_i, left_x, left_y = points_xsort[l]

                if left_x > top_x:
                    break

                if left_i in outsides_top or left_i in outsides_bottom:
                    l += 1
                    continue
                
                # outsides_right = []
                n_outsides_right = 0
                r = 0
                while r < N:
                    if N - t - b - n_outsides_left - n_outsides_right < K:
                        break

                    right_i, right_x, right_y = points_xsort_rev[r]

                    if right_i == left_i:
                        break
                    
                    if right_x < top_x:
                        break
                    
                    if right_i in outsides_top or right_i in outsides_bottom:
                        r += 1
                        continue

                    area = (top_y - bottom_y) * (right_x - left_x)
                    if area < min_area:
                        min_area = area
                    
                    # outsides_right.append(right_i)
                    n_outsides_right += 1
                    r += 1
                
                # outsides_left.append(left_i)
                n_outsides_left += 1
                l += 1
            
            outsides_bottom.append(bottom_i)
            b += 1
        
        outsides_top.append(top_i)
        t += 1

    return min_area


print(main())


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,m;
  cin >> n >> m;
  vector<vector<int>> graph(n,vector<int>(0));
  int a,b;
  REP(i,m){
    cin >> a>> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  vector<int> prev(n,-1);
  
  queue<int> queue;
  prev[0] = 0;
  queue.push(0);
  int now;
  while(!queue.empty()){
    now = queue.front();
    queue.pop();
    for(auto p : graph[now]){
      if(prev[p]==-1){
        prev[p] = now;
        queue.push(p);
      }
    }
  }
  REP(i,n){
    if(prev[i]==-1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  FOR(i,1,n){
    cout << prev[i]+1 << endl;
  }
  return 0;
}

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

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

    long long n, k;
    cin >> n >> k;

    map<long long, long long> mp;
    for(long long i = 0; i < n; i++){
        long long a, b;
        cin >> a >> b;
        mp[a] += b;
    }

    long long now = 0;
    for(auto x: mp){
        now += x.second;
        if(now >= k){
            cout << x.first << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,seq=1;
    cin>>n;
    int ans=-1;
    vector<int> v;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        v.push_back(a);
    }
    for(int i=0;i<n;i++)
    {
        if(v[i]==seq)
        {
            ans=seq;
            seq++;
        }
    }
    if(seq==1) cout<<ans;
    else cout<<n-ans;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    string S;
    cin >> S;
    Yes(S[0] != S[1] && S[1] != S[2] && S[2] != S[0]);
}

Measured memory_bytes: 256
num = list(input().split() for l in range(3))
flg = 0
for i in range(0,101):
    d = int(num[0][0]) - i
    e = int(num[1][0]) - i
    f = int(num[2][0]) - i
    b = int(num[0][1]) - d
    c = int(num[0][2]) - d
    if int(num[1][1]) == b + e and int(num[1][2]) == c + e and int(num[2][1]) == b + f and int(num[2][2]) == c + f:
        flg = 1

if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define MAXX 500005
#define PI 3.14159265358979323846264338327950
#define F first
#define S second
#define ll   int
#define mod  1000000007



int main()
{
	FAST;
	ll a[5];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << (a[0] * a[1]) / 2;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    string s;
    cin >> s;
    ll  count = 0 , sum = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'W'){
            sum += (i - count);
            count++;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3744
#include <stdio.h>


int main(){

    int a,b,c,answer;

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


    answer=3;

    if(a==b&&b==c){
        answer=answer-2;
    }


    else if((a-b)*(b-c)*(c-a)==0){
        answer--;
    }

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


    return 0;

}

Measured memory_bytes: 128
bool debug=false;
#include <queue>
#include <vector>
#include <stdio.h>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
#define F first
#define S second
#define PB push_back
//#define int long long int
const int N=(int)1e5+10;
const int INF=(int)1e9+10;
struct seg_tree{
	vector<pair<int,int>> v;
	pair<int,int> better(const pair<int,int> &a,const pair<int,int> &b){return a.F<=b.F?a:b;}
	void pull(int n){v[n]=better(v[n*2+1],v[n*2+2]);}
	void init(int n,int l,int r,int a[]){
		if(l==r)v[n]=make_pair(a[l],l);
		else if(l<r){
			int mid=(l+r)>>1;
			init(n*2+1,l,mid,a);
			init(n*2+2,mid+1,r,a);
			pull(n);
		}
	}
	void fix(int n,int l,int r,int pos){
		if(l==r)v[n].F=INF;
		else if(l<r){
			int mid=(l+r)>>1;
			if(pos>mid)fix(n*2+2,mid+1,r,pos);
			else fix(n*2+1,l,mid,pos);
			pull(n);
		}
		return ;
	}
	pair<int,int> ask(int n,int l,int r,int L,int R){
	    //if(L>R)while(true);
		if(L<=l&&r<=R)return v[n];
		else if(L>r||l>R)return {INF,-1};
		else {
			int mid=(l+r)>>1;
			return better(ask(n*2+1,l,mid,L,R),ask(n*2+2,mid+1,r,L,R));
		}
	}
};
vector<pair<int,int>> v;
seg_tree sg;
int l[N],r[N],n,ans=0;
bool ok,went[N];
map<int,int> m;
void dfs(int x){
	ans++;
	went[x]=true;
	sg.fix(0,0,n-1,x);
	if(m.find(v[x].S)==m.end())m[v[x].S]=r[x];
	else m[v[x].S]=min(m[v[x].S],r[x]);
	if(debug)printf("fixed\n");
	pair<int,int> temp;
	if(debug)printf("going down\n");
	if(l[x]>0)while(true){
		temp=sg.ask(0,0,n-1,0,l[x]-1);
		if(temp.F<INF)dfs(temp.S);
		else break;
	}
	if(debug)printf("going mid\n");
	while(true){
		temp=sg.ask(0,0,n-1,l[x],r[x]);
		if(temp.F<v[x].S)dfs(temp.S);
		else break;
	}
	temp=sg.ask(0,0,n-1,l[x],r[x]);
	if(temp.F>v[x].S)ok=false;
	else if(temp.S>m[v[x].S])ok=false;
	if(debug)printf("return\n");
	return ;
}
int main(){
	int c,a[N],can=0,lpos=0,rpos=0,npos=0;
	pair<int,int> temp;
	ok=true;
	scanf("%d%d",&n,&c);
	for(int i=0;i<n;i++){
		scanf("%d%d",&temp.F,&temp.S);
		v.PB(temp);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++)a[i]=v[i].S;
	sg.v.resize(N<<2);
	sg.init(0,0,n-1,a);
	//for(int i=0;i<n;i++)sg.ask(0,0,n-1,i,i);
	for(int i=0;i<n;i++)went[i]=false;
	v.PB({INF,INF});
	for(int i=0;i<n;i++){
	    lpos=lower_bound(v.begin(),v.end(),make_pair(v[i].F-c,0))-v.begin();
	    rpos=lower_bound(v.begin(),v.end(),make_pair(v[i].F+c+1,0))-v.begin();
		l[i]=lpos;
		r[i]=rpos-1;
	}
	if(debug)printf("before dfs\n");
	while(ok){
		while(npos<n){
			if(went[npos])npos++;
			else break;
		}
		if(npos<n)can=sg.ask(0,0,n-1,l[npos],r[npos]).S;
		else break;
		dfs(can);
	}
	printf("%d\n",ans);
}



Measured memory_bytes: 25388
/*
 *Author - Abhas Jain
 *Code is inside the solve function
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back
#define mp make_pair 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
typedef long long ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)

 
using namespace std;
using namespace __gnu_pbds;
template <typename A, typename B>
string to_string(pair<A, B> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef AJ47
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
 
ll f (ll len, ll go) {
	ll ret;
	if (len % go) {
		ret = 2ll * (len / go) * go + f (go, len % go); 
	} else {
		ret = (2ll * (len / go) - 1) * go;
	}
	return ret;
}

void solve() 
{
    ll n, x;
    cin >> n >> x;
    cout << n + f(max(x, n - x), min(x, n - x)) << endl;
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

Measured memory_bytes: 256
N = int(input())
t0, x0, y0 = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    kyori = abs(x - x0) + abs(y - y0)
    time = t - t0
    if (abs(kyori - time)) % 2 == 0 and time - kyori >= 0:
        t0, x0, y0 = t, x, y
    else:
        print('No')
        exit(0)
print('Yes')


Measured memory_bytes: 9132
#include <iostream>
#include <vector>
#include <queue>
#include <string>

using namespace std;
typedef long long ll;

template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cout << x << " ";
    }
    cout << endl;
}

template<typename T>
void qprint(priority_queue<T> q) {
    while(!q.empty()) {
        cout << q.top() << " ";
        q.pop();
    }
    cout << endl;
}

int main(void) {
    int a, b;
    cin >> a >> b;
    
    cout << ((b+a-3)/(a-1)) << endl;
    
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  int c0 = 0, c1 = 0;
  for (auto s : S) {
    if (s == '0') c0++;
    if (s == '1') c1++;
  }
  cout << 2 * min(c0, c1) << '\n';
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<list>

using namespace std;

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

int main()
{
    int H,W,bomb;
    vector<string> S;

    cin >> H >> W;
    
    for (int i=0; i<H; ++i)
    {
        string str;
        cin >> str;
        S.push_back(str);
    }

    vector<vector<int> > ans(H, vector<int>(W, 0));
    for (int i=0; i<H; ++i)
    {
        for(int j=0; j<W; ++j)
        {
            for(int k=0; k<8; ++k)
            {
                int ni = i + dx[k], nj = j +dy[k];
                if(ni<0 || ni>=H || nj<0 || nj>=W) continue;
                if(S[ni][nj] == '#') ++ans[i][j];
            }
        }
    }

    for(int i=0; i<H; ++i)
    {
        for(int j=0; j<W; ++j)
        {
            if(S[i][j] == '.') cout << ans[i][j];
            else cout << '#';
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int k,x,i,s,e;
    scanf("%d%d",&k,&x);
    s=x-k+1;
    e=x+k-1;
    for(i=s;i<=e;i++)
        printf("%d ",i);
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int A, B, X;
  cin >> A >> B >> X;
  
  if (A <= X && X <= A+B) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] n = new int[4];
        for (int i = 0; i < 4; i++) {
            n[i] = sc.nextInt();
        }
        Arrays.sort(n);

        if (n[0] == 1) {
            if (n[1] == 4) {
                if (n[2] == 7) {
                    if (n[3] == 9) {
                        System.out.println("YES");
                    } else {
                        System.out.println("NO");
                    }
                } else {
                    System.out.println("NO");
                }
            } else {
                System.out.println("NO");
            }
        } else {
            System.out.println("NO");
        }
    }
}












Measured memory_bytes: 23892
using System;
using System.Linq;

class Test {
	static void Main(string[] args) {
      string S = System.Console.ReadLine();
      string T = System.Console.ReadLine();
      int cnt = 0;
      for(int i = 0; i < S.Length; i++){
        if(S[i] != T[i]){
          cnt++;
        }
      }
      Console.WriteLine(cnt);
	}
}

Measured memory_bytes: 18104
#include<bits/stdc++.h>
#define M  1000005
#define LL long long
using namespace std;

int main(){
	char s[10];
	scanf("%s",s+1);
	if(s[3]==s[4]&&s[5]==s[6])puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    string t; cin >> t;
    rep(i,t.length()-1) {
        if (t[i] != '?')
            continue;
        if (t[i+1] == 'P')
            t[i] = 'D';
        else if (t[i+1] == 'D')
            t[i] = 'D'; 
        else {
            t[i] = 'D';
            t[i+1] = 'D';
            i++;
        }
    }
    if (t[t.length()-1] == '?')
        t[t.length()-1] = 'D';
    cout << t << endl;

    return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

int a[200005];
 
int32_t main()
{
    fast;
    int n, t, ans = 0; cin >> n >> t;
    For(i, 0, n) cin >> a[i];
    ans += t;
    For(i, 1, n) {
        ans += t;
        if(a[i] < a[i-1] + t) ans -= (a[i-1] + t - a[i]);
    }
    cout << ans;

    
    
    
    return 0;
}

Measured memory_bytes: 5080
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  string S;
  cin >> S;
  vector<int> dict(26, 0);
  for (auto c : S) {
    dict[c - 'a']++;
  }
  for (int i = 0; i < 26; ++i) {
    if (dict[i] == 0) {
      cout << (char)(i + 'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("fibsubseq.in","r",stdin)
#define write()         freopen("fibsubseq.out","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long int
#define endll           printf("\n")
#define pf              printf
#define pi              acos(-1.0)
#define eps             1e-10
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())

bool Check(unsigned int  N,int pos){return (bool)(N & (1LL<<pos));}
ll  Set(unsigned int N,int pos){    return N=N | (1LL<<pos);}
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define mod  1000000007
#define mod1 1000000009
#define var    int ii,i,j,k,z=0,c=0,t,x,y,l,r,mid
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};

bool chk(int x,int pos){return (bool)(x&(1<<pos));}
int Set(int x,int pos){return x=x|(1<<pos);}
int clr(int x,int pos){return x=x&~(1<<pos);}

ll n,m,a[200005],tree[800005],b[200005];

void update(ll idx,ll b,ll e,ll pos,ll val)
{
    if(pos<b || pos>e)return ;
    if(pos==b && pos==e)
    {
        cnd=val;
        return;
    }
    update(lndp,pos,val);
    update(rndp,pos,val);
    cnd=max(lnd,rnd);
}
ll query(ll idx,ll b,ll e,ll st,ll en)
{
    if(st>e || en<b)return 0;
    if(b>=st && e<=en)
    {
        return cnd;
    }
    ll lft=query(lndp,st,en);
    ll rgt=query(rndp,st,en);
    return max(lft,rgt);
}

int main()
{
    ll var;
    sfl(n);
    for(i=0;i<n;i++)
    {
        sfl(a[i]);
    }
    for(i=0;i<n;i++)
    {
        sfl(b[i]);
    }
    for(i=0;i<n;i++)
    {
        c=query(1,0,n,0,a[i]-1);
        c+=b[i];
        z=max(z,c);
        update(1,1,n,a[i],c);
    }
    cout<<z<<endl;
}


Measured memory_bytes: 9600
import java.util.*;

public class Main {
    static int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 1;
        for (int i = 1; i <= n; i++) {
            ans *= i;
            ans %= MOD;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS


	int n;
	cin >> n;

	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		if(i%2 and x%2)ans++;
	}

	cout << ans;






    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,a[maxn],l,q;
int f[maxn][31];
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	cout.tie(0);		
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i];
    cin>>l;
    for (int i=1;i<=n;i++)
	{
        int idx=upper_bound(a+1,a+1+n,a[i]+l)-a-1;
        if(a[i]+l>=a[n]) f[i][0]=n;
        else f[i][0]=idx;
    }
    for (int j=1; j<=30; j++)
       for (int i=1;i<=n;i++)
            f[i][j]=f[f[i][j-1]][j-1];
    cin>>q;
    while(q--){
        long long u,v;
        cin>>u>>v;
        if(u>v) swap(u,v);
        long long dem;
        dem=0;
        for(int i=30;i>=0;i--)
          if(f[u][i]<v)
             {
             	dem+=(1<<i);
             	u=f[u][i];
			 }
        cout<<dem+1<<endl;
    }
}


Measured memory_bytes: 13312
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while(s.hasNext()) {
			int a = s.nextInt();
			int b = s.nextInt();
			
			int g = lcm(a,b);
			int l = gcd(a,b);
			System.out.println(l + " " + g);
		}
		
	}
	static int lcm(int a, int b) {
		for(int i = b; i <= 2000000000; i += b) {
			if(i % a == 0) {

				return i;
			}
		}
		return -1;
	}
	static int gcd(int a, int b) {
		if(b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}
}

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

vector<bool> used(1000005, false);
void dfs(int v, vector<vector<int> > &g, vector<int> &c) {
    if (used[v]) return;
    used[v] = true;
    for (int i = 0; i < g[v].size(); i++) {
        int nx = g[v][i];
        c[nx] += c[v];
        dfs(nx, g, c);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<vector<int> > g(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        // g[b].push_back(a);
    }
    vector<int> c(n, 0);
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        c[p - 1] += x;
    }
    dfs(0, g, c);
    for (int i = 0; i < n; i++) {
        cout << c[i] << " \n"[i == n - 1];
    }
    return 0;
}


Measured memory_bytes: 23552
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<string>s(N);
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < N; i++) {
		bool flag = true;
		for (int j = 0; j < N; j++) {
			for (int k = j + 1; k < N; k++) {
				if (s[j][(k + i) % N] != s[k][(j + i) % N]) {
					flag = false;
				}
			}
		}
		if (flag) {
			M += N;
		}
	}
	cout << M << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(void){
	int a,b; cin>>a>>b;
	int n=1;
	for(int i=0;i<100;i++){
		if(n>=b){
			cout<<i<<endl;
			return 0;
		}
		n=n+a-1;
	}
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
int main(void){
    // Your code here!
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 int i,ans,ans1,ans2,n;
 ans1=INT_MAX;
 ans2=INT_MIN;
 ans=0;
 cin >> n;
 int x[n],y[n];
 for(i=0;i<n;i++)
 {
  cin >> x[i] >> y[i];
  ans1=min(ans1,x[i]+y[i]);
  ans2=max(ans2,x[i]+y[i]);
 }
 ans=max(ans,abs(ans2-ans1));
 ans1=INT_MAX;
 ans2=INT_MIN;
 for(i=0;i<n;i++)
 {
  ans1=min(ans1,x[i]-y[i]);
  ans2=max(ans2,x[i]-y[i]);
 }
 ans=max(ans,abs(ans2-ans1));
 cout << ans;
 return 0;
}

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

char str[30] ;

int main ( )
{
	while ( scanf ( "%s" , str ) == 1 ) {
		for ( int i = strlen ( str ) - 1 ; i >= 0 ; i-- ) {
			putchar ( str[i] ) ;
		}
		putchar ( '\n' ) ;
	}
	return 0 ;
}

Measured memory_bytes: 936