akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> L(m);
    vector<int> R(m);
    rep(i,m) {
        cin >> L[i] >> R[i];
        L[i]--;
        R[i]--;
    };

    vector<int> card(n+1);
    rep(i,m){
        card[L[i]]++;
        card[R[i]+1]--;
    }
    rep(i,n) card[i+1] += card[i];
    
    int cnt=0; 
    rep(i,n) if(card[i]==m) cnt ++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	char b;
	cin >> b;

	if(b=='A') cout << 'T' << endl;
	if(b=='C') cout << 'G' << endl;
	if(b=='G') cout << 'C' << endl;
	if(b=='T') cout << 'A' << endl;
}

Measured memory_bytes: 256
n = int(input())
x = 0
y = 0

for i in range(n):
    a, b = map(int, input().split())
    if a == b:
        x += 1
        y = max(y, x)
    else:
        x = 0
        
if y >= 3:
    print('Yes')
else:
    print('No')


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

using namespace std;

const int MAXN = 3e3 + 10;

int n, T, k, m;

int a[MAXN], dp[MAXN][MAXN];

string s, t, ans = "";

const int MOD = 1e9 + 7;

bool isDone;

void dfs(int x, int y) {
    if (isDone)
        return;

    if (x == 0 || y == 0)
        if (s[x] == t[y]) {
            ans += s[x];
            isDone = 1;
            return;
        }
    
    if (x - 1 >= 0 && dp[x][y] == dp[x - 1][y])
        dfs(x - 1, y);
    else if (y - 1 >= 0 && dp[x][y] == dp[x][y - 1])
        dfs(x, y - 1);
    else if (y - 1 >= 0 && x - 1 >= 0)
        ans += s[x], dfs(x - 1, y - 1);
}

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

    if (s[0] == t[0])
        dp[0][0] = 1;
    
    bool isPos = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == t[0])
            isPos = 1;

        dp[i][0] = isPos;    
    }

    isPos = 0;
    for (int j = 0; j < m; j++) {
        if (t[j] == s[0])
            isPos = 1;

        dp[0][j] = isPos;    
    }

    for (int i = 1; i < n; i++) {
        for (int j = 1; j < m; j++) {
            if (s[i] == t[j])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    
    if (dp[n - 1][m - 1] > 0) {
        dfs(n - 1, m - 1);
        reverse(ans.begin(), ans.end());
        cout << ans;
    } else 
        cout << " ";
}


Measured memory_bytes: 38880
import math
import collections
from operator import mul
from functools import reduce
import bisect
import string


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n=int(input())
a=list(map(int,input().split()))
b=make_divisors(a[0])+make_divisors(a[1])
b=list(set(b))
y=0
for bi in b:
    c=0
    for ai in a:
        if ai%bi!=0:
            c+=1
        if c>=2:
            break
    if c<2:
        y=max(y,bi)

print(y)




Measured memory_bytes: 64112
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int A, B;
char op;
int main(int argc, const char * argv[]) {
  cin >> A >> op >> B;
  
  if (op == '+') {
    cout << A + B << endl;
  } else {
    cout << A - B << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  ll s;
  cin >> s;
  ll x1, x2, x3, y1, y2, y3;
  ll v = 1000000000;
  x1 = 0;
  y1 = 0;
  x2 = v;
  y2 = 1;
  x3 = 0;
  y3 = 0;
  // 10^9 * y3 - x3 = S
  x3 = (v - (s % v)) % v;
  y3 = (s + x3) / v;

  cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3
       << " " << endl;
}

Measured memory_bytes: 256
import sys,math
import numpy as np

#n=int(sys.stdin.readline())
n,a,b=map(int,sys.stdin.readline().split())
#a=np.array([sys.stdin.readline().split() for i in range(n)],np.int64)

p=10**9+7
to=pow(2,n,p)-1


def C(N,K):
    if N<K:
        return 0
    else:
        c=1
        d=1
        for i in range(1,K+1):
            c=c*(n-i+1)%p
            d=d*i%p
        return c*pow(d,p-2,p)%p
print((to-C(n,a)-C(n,b))%p)



Measured memory_bytes: 12488
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<tuple<ll, ll, ll>> d;
	rep(i, n)
	{
		ll a, b; cin >> a >> b;
		d.push_back({ a + b,a,b });
	}
	ll res = 0;
	sort(all(d));
	reverse(all(d));
	rep(i, n)
	{
		if (i % 2 == 0)res += get<1>(d[i]);
		else res -= get<2>(d[i]);
	}
	cout << res << endl;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int N, M, Q;
vector<int> a, b, c, d;

ll score(const vector<int> &A)
{
  ll res = 0;
  for (int i = 0; i < Q; i++)
  {
    if (A[b[i]] - A[a[i]] == c[i])
      res += d[i];
  }
  return res;
}

ll dfs(vector<int> &A)
{
  if (A.size() == N)
  {
    return score(A);
  }

  ll res = 0;
  int prev_last = (A.empty() ? 0 : A.back());
  for (int add = prev_last; add < M; add++)
  {
    A.push_back(add);
    res = max(res, dfs(A)); // 再帰呼び出ししながらスコア最高点更新
    A.pop_back();
  }
  return res;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> M >> Q;
  a.resize(Q), b.resize(Q), c.resize(Q), d.resize(Q);
  for (int i = 0; i < Q; i++)
  {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--, b[i]--;
  }
  vector<int> A;
  cout << dfs(A) << endl;
  return 0;
}


Measured memory_bytes: 3624
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	ArrayList<Integer>[] g;

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		g = new ArrayList[N];
		for (int i = 0; i < N; ++i)
			g[i] = new ArrayList<>();
		int Q = sc.nextInt();
		long[] w = new long[N];
		for (int i = 0; i < N - 1; ++i) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			g[a].add(b);
			g[b].add(a);
		}
		for (int i = 0; i < Q; ++i) {
			int p = sc.nextInt() - 1;
			int x = sc.nextInt();
			w[p] += x;
		}
		dfs(0, -1, 0, w);
		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < N; ++i) {
			pw.print(w[i] + (i == N - 1 ? "\n" : " "));
		}
		pw.close();
	}

	void dfs(int cur, int par, long pending, long[] w) {
		w[cur] += pending;
		for (int dst : g[cur]) {
			if (dst == par)
				continue;
			dfs(dst, cur, w[cur], w);
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

#define int long long
#define mod 1000000007

using namespace std;

int32_t main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    int t1,t2;
    t1 = c-a;
    t2 = d-b;

    cout << c-t2 << " " << d+t1 << " " << a-t2 << " " << b+t1 << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var x = Integer.parseInt(br.readLine());
      if (x >= 400 && x <= 599) {
        System.out.println(8);
      } else if (x >= 600 && x <= 799) {
        System.out.println(7);
      }else if (x >= 800 && x <= 999) {
        System.out.println(6);
      }else if (x >= 1000 && x <= 1199) {
        System.out.println(5);
      }else if (x >= 1200 && x <= 1399) {
        System.out.println(4);
      }else if (x >= 1400 && x <= 1599) {
        System.out.println(3);
      }else if (x >= 1600 && x <= 1799) {
        System.out.println(2);
      }else if (x >= 1800 && x <= 1999) {
        System.out.println(1);
      }
    }
  }
}


Measured memory_bytes: 32772
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int res = 0;
  for(int i = 0; i < n; i++){
    int h;
    cin >> h;
    if(h >= k) res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
#include<numeric>
//AtCoderC++.cpp

using namespace std;

int main() {
	string s;
	for (size_t i = 0; i < 3; i++) {
		cin >> s;
		cout << s[0];
	}cout << endl;
}

Measured memory_bytes: 256
///*Bismillahir Rahmanir Rahim***///
/***Stay_Home_Stay_Safe***/
///**Author Thasin Sheikh**///
#include<bits/stdc++.h>
using namespace std;
#define MAX 1e6+10
#define MOD 1000000007
#define PI 3.14159265359
#define makefast__  ios_base::sync_with_stdio(false);
using ll=long long int  ;
using dl =double;
const int N = 2e5 + 10;
ll aarray[200000+10];
ll magic[101][101];
vector<ll>primes;
bool prime[1000001];
char a[8][8],b[8][8];
ll n,m,k;
ll ans=0;
void solve()
{
    ll i,j;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            b[i][j]=a[i][j];
        }
    }
    return ;

}
void color(ll i,ll j)
{
    for(ll l=0;l<n;l++)
    {
        if(i&(1<<l))
        {
            for(ll y=0;y<m;y++)
            {
                b[l][y]='k';
            }
        }
    }
    for(ll l=0;l<m;l++)
    {
        if(j&(1<<l))
        {
            for(ll y=0;y<n;y++)
            {
                b[y][l]='k';
            }
        }
    }
    return ;
}
bool check()
{
    ll i,j,c=0;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(b[i][j]=='#')
                c++;
        }
    }
    if(c==k)
        return true ;
    else return false;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    makefast__
    string str;
    ll i,j,t;
    cin>>n>>m>>k;
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            cin>>a[i][j];
        }
    }
    for(i=0; i<(1<<n); i++)
    {
        for(j=0; j<(1<<m); j++)
        {
            solve();
            color(i,j);
            if(check())
                ans++;

        }
    }
    cout<<ans<<endl;

    return 0;
}




Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "Yes";
const string NO  = "No";

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

    int a, b;
    bool flg = false;

    cin >> a >> b;

    for (int i = 1; i <= 3; ++i) {
        if ((a * b * i) % 2 != 0) flg = true; break;
    }

    cout << (flg ? YES : NO) << endl;

    return 0;
}



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

int main()
{
  int n;
  cin >> n;
  int a;
  map<int, int> mp;
  rep(i, n){
    cin >> a;
    mp[a]++;
  }
  cout << mp.size() << endl;

  return 0;
}

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

int main(){
  int N,K,h[100000],i,ans=((long long)1<<31)-1,temp=0;
  cin>>N>>K;
  for(i=0;i<N;i++){
    cin>>h[i];
  }
  sort(h,h+N);
  for(i=0;i<N-K+1;i++){
    if(h[i+K-1]-h[i]<ans)ans=h[i+K-1]-h[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
n,x,y=map(int,input().split())

ans=[0]*n

for i in range(1,n):
    for j in range(i+1,n+1):
        d=min(abs(j-i),abs(x-i)+1+abs(j-y))
        ans[d]+=1


for i in range(1,n):
    print(ans[i])

Measured memory_bytes: 3444
from collections import Counter
a,b=[int(i) for i in input().split()]
a_yaku=[]
b_yaku=[]
for i in range(1,int(a**0.5)+1):
    if a%i==0:
        a_yaku+=[i,a//i]

for i in range(1,int(b**0.5)+1):
    if b%i==0:
        b_yaku+=[i,b//i]
yaku=a_yaku+b_yaku
koyaku=[]
cnt=dict(Counter(yaku))
for key,val in zip(cnt.keys(),cnt.values()):
    if val==2:
        koyaku+=[key]
koyaku.sort()
koyaku=koyaku[1:]
l=len(koyaku)
ans=1
for i in range(l):
    flg=True
    for j in range(l):
        if i!=j and koyaku[i]%koyaku[j]==0:
            flg=False
    if flg:
        ans+=1
print(ans)

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

int main(){
  long long N,s=0;
  int cnt;
  cin >> N;
  vector<double> a(N);
  vector<double> b(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
    if(a.at(i)<0){
      b.at(i) = -a.at(i);
      cnt ++;
    }
    else{
      b.at(i)= a.at(i);
    }
  }
  sort(b.begin(),b.end());
  for(int j=0;j<N;j++){
    s += b.at(j);
  } 
  if(cnt % 2 ==0){
    cout <<fixed << setprecision(0) << s << endl;
  }
  else
   cout << fixed << setprecision(0) <<s-2 * b.at(0) << endl;
}    

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
#define allsortg(v)sort(v.begin(),v.end(),greater<int>());
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int>a(M), b(M);
	vector<int>c;
	rep(i, M) {
		cin >> a[i] >> b[i];
		if (a[i] == 1)c.push_back(b[i]);
		if (b[i] == N)c.push_back(a[i]);
	}
	int x = c.size();
	allsort(c);
	c.erase(unique(c.begin(), c.end()), c.end());
	if (x == c.size())cout << "IMPOSSIBLE" << "\n";
	else cout << "POSSIBLE" << "\n";

	return 0;
}

Measured memory_bytes: 2936
#include<stdio.h>
int main()
{
	double max=-1.0,min=1000000000.0,temp;
	while(scanf("%lf",&temp)!=EOF)
	{
		if(temp<min)
			min=temp;
		if(temp>max)
			max=temp;
	}
	printf("%.1f\n",max-min);
	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const int MAX = 200010;
ll fac[MAX],finv[MAX],inv[MAX];

void init() {
    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;
    }
}

ll comb(ll n,ll k){
    if(n < 0 || k < 0 || n < k) return 0;
    return fac[n] * finv[n-k] % MOD * finv[k] % MOD;
}

ll pow(ll x,ll k){
    ll res = 1;
    ll y = x;
    while(k){
        if(k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,a,b,c;
    cin >> n >> a >> b >> c;
    init();
    ll res = 0;
    // i banme : iCn-1 * (A^n*B^(i-n) + B^n*A(i-n))
    for(int i = n; i <= 2*n - 1; ++i){
        // prob
        ll tmp = comb(i-1,n-1) * (pow(a,n) * pow(b,i-n)%MOD + pow(b,n) * pow(a,i-n)%MOD)%MOD;
        (tmp *= pow(a+b,2*n-1-i)) %= MOD;
        // exp
        (tmp *= i) %= MOD;
        // add
        (res += tmp) %= MOD;
    }
    // draw : 100 / (100-c)
    ll draw = 100 * pow(pow(a+b,2*n-1) * (100-c)%MOD,MOD-2)%MOD;
    cout << res*draw%MOD << endl;
    return 0;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = intRead();
        List<int> list = new List<int>();
        List<int> anslist = new List<int>();
        List<int> newlist = new List<int>();
        newlist.Add(3);
        newlist.Add(5);
        newlist.Add(7);
        int ans = 0;
        for (int i = 1; i < N.ToString().Length; i++)
        {
            foreach (int l in newlist)
            {
                list.Add(int.Parse(l.ToString() + "3"));
                list.Add(int.Parse(l.ToString() + "5"));
                list.Add(int.Parse(l.ToString() + "7"));
                anslist.Add(int.Parse(l.ToString() + "3"));
                anslist.Add(int.Parse(l.ToString() + "5"));
                anslist.Add(int.Parse(l.ToString() + "7"));
            }
            newlist = new List<int>(list);
            list = new List<int>();
        }
        anslist.Sort();
        for (int i = 0; i < anslist.Count(); i++)
        {
            if (anslist[i] <= N)
            {
                if (anslist[i].ToString().Count(c => c == '3') > 0 &&
                    anslist[i].ToString().Count(c => c == '5') > 0 &&
                    anslist[i].ToString().Count(c => c == '7') > 0) ans++;
            }
        }
        Console.WriteLine(ans);
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = strReverce(ret);
        return ret;
    }

}


Measured memory_bytes: 17884
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007



k, a, b = LI()
if k <= a:
    print(1)
else:
    if b >= a:
        print(-1)
    else:
        print(1 + ((k - a - 1) // (a - b) + 1) * 2)


Measured memory_bytes: 41584
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }
signed main() {
    int x, y;
    cin >> x >> y;
    if ((2 * y - x) % 3 != 0 || (2 * x - y) % 3 != 0) {
        cout << 0 << endl;
    } else if (2 * y - x < 0 || 2 * x - y < 0) {
        cout << 0 << endl;
    } else {
        cout << nCkmod(((2 * y - x) / 3 + (2 * x - y) / 3), (2 * x - y) / 3) << endl;
    }
}


Measured memory_bytes: 256
# coding=utf-8

def print_list(X):
    first_flag = True
    for val in X:
        if first_flag:
            print_line = str(val)
            first_flag = False
        else:
            print_line = print_line + ' ' + str(val)
    print(print_line)

def selection_sort(A, N):
    counter = 0

    for i in range(N):
        min_j = i

        for j in range(i, N):
            if A[j] < A[min_j]:
                min_j = j

        if i != min_j:
            A[i], A[min_j] = A[min_j], A[i]
            counter += 1

    print_list(A)
    print(counter)

N = int(input())
A = list(map(int, input().split()))

selection_sort(A, N)

Measured memory_bytes: 7688
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define PII pair<int,int>
#define s second
#define f first
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x)%MOD;
        }
        p = p >> 1;
        x = (x*x)%MOD;
    }
    return res;
}
vector<vector<int>> adj;
ll dp[100005][2];
// white 0, black 1
void solve(int node, int parent){
    bool hasChildren = false;
    ll mulW = 1;
    ll mulB = 1;
    for(int c: adj[node]){
        if(c != parent){
            hasChildren = true;
            solve(c, node);
            mulW *= (dp[c][1] + dp[c][0]);
            mulW %= MOD;
            mulB *= dp[c][0];
            mulB %= MOD;
        }
    }
    dp[node][0] += mulW;
    dp[node][1] += mulB;
    if(!hasChildren){
        dp[node][0] = 1;
        dp[node][1] = 1;
    }
}
int main() {
    IO;
    int n;
    cin >> n;
    adj.resize(n);
    int x, y;
    for(int i = 0; i < n-1; i++){
        cin >> x >> y;
        adj[x-1].push_back(y-1);
        adj[y-1].push_back(x-1);
    }
    solve(0, -1);
    cout << (dp[0][0]+  dp[0][1])%MOD;


    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;

    if (a > 0 && b > 0)
        cout << "Positive" << endl;
    else if (a <= 0 && b >= 0)
        cout << "Zero" << endl;
    else {
        if ((abs(min(0, b) - a) + 1) % 2 == 0) {
            cout << "Positive" << endl;
        } else {
            cout << "Negative" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
// BWOTSHEWCHB

#include <bits/stdc++.h>

using namespace std ;

#define int long long
#define pb push_back
#define in insert
#define X first
#define Y second

const int MAXN = 1e6 + 69 , MOD = 1e9 + 7 ; 

int n , k , part[MAXN] ;
vector <int> vect , pos[MAXN] ;

int32_t main() {
	ios::sync_with_stdio(false) ;
	cin.tie(0) ; cout.tie(0) ;
	cin >> n >> k ;
	if ( k == 0 ) {
		for ( int i = 0 ; i < (1 << n) ; i ++ )
			cout << i << " " << i << " " ;
		cout << "\n" ;
		return 0 ;
	}
	if ( k >= (1 << n) or (n == 1 and k == 1) )
		return cout << "-1\n" , 0 ;
	for ( int i = 1 ; i < (1 << n) ; i ++ )
		vect.pb(i ^ k) ;
	vect.pb(k) ;
	for ( int i = (1 << n) - 1 ; i >= 1 ; i -- )
		vect.pb(i ^ k) ;
	vect.pb(k) ;
	for ( auto it : vect )
		cout << it << " " ;
	cout << "\n" ;
}


Measured memory_bytes: 28528
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Map<String, Long> count = new HashMap<>(); 
        for(int i=0;i<N;i++){
            String s = scanner.next();
            List<Character> charlist = new ArrayList<>();
            for(int j=0; j<s.length(); j++){
                charlist.add(s.charAt(j));
            }
            Collections.sort(charlist);
            s = String.valueOf(Arrays.asList(charlist));
            count.computeIfPresent(s, (key, val) -> val+1);
            count.putIfAbsent(s, Long.valueOf(1));
        }
        long result = 0;
        for(long n:count.values()){
            result += n*(n-1)/2;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 102932
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,K;
    cin >> N >> K;
    ll x[N];
    rep(i,N) cin >> x[i];
    ll out = 0;
    rep(i,N-K+1){
        ll tmp = min(abs(x[i]) + abs(x[i]-x[i+K-1]),abs(x[i+K-1]) + abs(x[i]-x[i+K-1]));
        if(i==0) out = tmp;
        else out = min(out,tmp);
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 4364
import sys
#input = sys.stdin.buffer.readline
 
def main():
    H,W = map(int,input().split())
    s = [list(input()) for _ in range(H)]
    
    memo = [[-1 for _ in range(W)] for _ in range(H)]
    def ch(x,y):
        if x == H-1 and y == W-1:
            memo[x][y] = 0
        else:
            if s[x][y] == ".":
                if y == W-1:
                    if s[x+1][y] == ".":
                        memo[x][y] = memo[x+1][y] if memo[x+1][y] != -1 else ch(x+1,y)
                    else:
                        memo[x][y] = memo[x+1][y]+1 if memo[x+1][y] != -1 else ch(x+1,y)+1
                elif x == H-1:
                    if s[x][y+1] == ".":
                        memo[x][y] = memo[x][y+1] if memo[x][y+1] != -1 else ch(x,y+1)
                    else:
                        memo[x][y] = memo[x][y+1]+1 if memo[x][y+1] != -1 else ch(x,y+1)+1
                else:
                    if s[x][y] == s[x+1][y]:
                        a = memo[x+1][y] if memo[x+1][y] != -1 else ch(x+1,y)
                    else:
                        a = memo[x+1][y]+1 if memo[x+1][y] != -1 else ch(x+1,y)+1
                    if s[x][y] == s[x][y+1]:
                        b = memo[x][y+1] if memo[x][y+1] != -1 else ch(x,y+1)
                    else:
                        b = memo[x][y+1]+1 if memo[x][y+1] != -1 else ch(x,y+1)+1
                    memo[x][y] = min(a,b)
            else:
                if y == W-1:
                    memo[x][y] = memo[x+1][y] if memo[x+1][y] != -1 else ch(x+1,y)
                elif x == H-1:
                    memo[x][y] = memo[x][y+1] if memo[x][y+1] != -1 else ch(x,y+1)
                else:
                    memo[x][y] = min(memo[x][y+1],memo[x+1][y]) if (memo[x][y+1] != -1 and memo[x+1][y] != -1) else min(ch(x+1,y),ch(x,y+1))
        return memo[x][y]

    if s[0][0] == "#":
        a = 1
    else:
        a = 0
    print(a+ch(0,0))
    
if __name__ == "__main__":
    main()


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

typedef long long ll;

 
int main(){
  ll n, a, b, c;
  cin >> n >> a >> b;
  c = a - b;
  ll hi[n];
  for(int i=0; i<n; i++){
    cin >> hi[i];
  }
  ll mint=-1, maxt=1000000007;
  while(maxt-mint>1){
    ll mid = (mint+maxt)/2;
    ll tmp = 0;
    for(int i=0; i<n; i++){
      if(hi[i]-b*mid>0){
        tmp += (hi[i]-b*mid+a-b-1)/c;
      }
    }
    if(mid < tmp) mint = mid;
    else maxt = mid;
  }
  cout << maxt << endl;
  return 0;
}


Measured memory_bytes: 1152
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                long[] A = new long[N];
                
                long ans = 0;
                long q = 10*10*10*10*10*10*10*10*10+7;
                long r = 0;
                for(int i=0; i<N; i++){
                    A[i] = scan.nextLong();
                    
                    ans = ans + A[i]*r;
                    ans = ans%q;
                    
                    r += A[i];
                    r = r%q;

                }
                System.out.println(ans);
        }
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	vector<int> a, b;
	int n, m;
	cin >> n;
	a.resize(n);
	for (int& x : a) {
		cin >> x;
	}

	cin >> m;
	b.resize(m);
	for (int& x : b) {
		cin >> x;
	}

	vector<int> c;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	set_intersection(a.begin(), a.end(), b.begin(), b.end(), back_inserter(c));

	cout << (b == c ? "YES" : "NO");
}

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

using namespace std;

using int64 = long long;

bool Solve() {
  int n;
  cin >> n;
  vector<int64> xs(n);
  unordered_map<int64, int> counter;
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    counter[xs[i]]++;
  }

  if (n % 3 != 0) {
    return all_of(xs.begin(), xs.end(), [](int x) { return x == 0; });
  }

  // n % 3 == 0
  int unit = n / 3;
  vector<int64> ys;
  for (const auto& entry : counter) {
    int64 val;
    int counter;
    tie(val, counter) = entry;
    // cout << "val: " << val << " counter: " << counter << endl;
    if (counter % unit != 0) return false;
    for (int i = 0; i < counter / unit ; i++) {
      ys.push_back(val);
    }
  }
  int64 z = 0;
  for (int y : ys) {
    z ^= y;
  }
  // cout << "z: " << z << endl;
  return z == 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string solution;
  if (Solve()) solution = "Yes";
  else solution = "No";
  cout << solution << endl;
}


Measured memory_bytes: 4260
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

typedef pair<ll, ll> P;
vec d;
struct edge {
    ll to, cost;
};
vector<vector<edge>> G;
vec seen;

void dijkstra (ll s, ll V) {
    priority_queue<P, vector<P>, greater<P>> que;
    d.assign(V, inf);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;
        for (edge e : G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

ll pos = -1;
vec history;

void dfs (ll v) {
    seen[v] = 1;
    history.push_back(v);
    for (auto e : G[v]) {
        if (seen[e.to] == 2) continue;
        if (seen[e.to] == 1) {
            pos = e.to;
            return;
        }
        dfs(e.to);
        if (pos != -1) return;
    }
    history.pop_back();
    seen[v] = 2;
}

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

    ll N, M;
    cin >> N >> M;
    G.assign(N, vector<edge>());
    while (M--) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back({b, 1});
    }

    seen.assign(N, 0);
    pos = -1;

    Rep (i, N) {
        pos = -1;
        dfs(i);
        if (pos != -1) break;
    }

    if (pos == -1) {
        cout << -1 << "\n";
        return 0;
    }

    vec cycle;
    while (history.size()) {
        ll t = history.back();
        cycle.push_back(t);
        history.pop_back();
        if (t == pos) break;
    }
    reverse(cycle.begin(), cycle.end());

    while (true) {
        ll from = -1, to = -1;
        vec order(N, -1);
        Rep (i, cycle.size()) order[cycle[i]] = i;
        
        Rep (i, cycle.size()) {
            for (auto e : G[cycle[i]]) {
                if (e.to != cycle[(i+1)%cycle.size()] && order[e.to] != -1) {
                    from = i, to = order[e.to];
                }
            }
        }

        if (from == -1) break;

        vec newcycle;
        newcycle.push_back(cycle[from]);
        ll id = to;
        while (id != from) {
            newcycle.push_back(cycle[id]);
            id = (id + 1) % cycle.size();
        }
        cycle = newcycle;
    }

    cout << cycle.size() << endl;
    for (ll e : cycle) cout << e+1 << endl;

}

Measured memory_bytes: 384
a,b,c,d=map(int,input().split())
x=a//d
y=c//b
if y<x:
    print('Yes')
elif y==x:
    if c%b==0:
        print('Yes')
    else:
        if a%d==0:
            print('No')
        else:
            print('Yes')
            
elif y==x+1:
    if c%b==0:
        print('Yes')
    else:
        print('No')
            
else:
    print('No')

Measured memory_bytes: 9096
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
convict = [[] for _ in range(N)]
for i in range(N):
    a = getN()
    for j in range(a):
        x, y = getNM()
        convict[i].append([x - 1, y])
ans = 0
# 状態を生成
for bit in range(1 << N):
    flag = True
    # 人iの証言について
    for i in range(N):
        # 正直者のフラグが立っていれば
        if bit & (1 << i):
            for j in convict[i]:
                # もし正直者が行ったことに間違いがあれば
                if j[1] == 0 and bit & (1 << j[0]) > 0:
                    flag = False
                if j[1] == 1 and bit & (1 << j[0]) == 0:
                    flag = False
    if flag:
        index = str(bin(bit)).count('1')
        ans = max(ans, index)
print(ans)

Measured memory_bytes: 43884
n = int(input())
if n ==111:
    print(999)
elif n ==119:
    print(991)
elif n == 191:
    print(919)
elif n == 199:
    print(911)
elif n== 911:
    print(199)
elif n == 919:
    print(191)
elif n== 991:
    print(119)
else:
    print(111)

Measured memory_bytes: 3060
N = gets.to_i
H = gets.split(' ').map(&:to_i)
count = 0
step = 0

(N - 1).times do |idx|
	if H[idx] >= H[idx + 1]
		step += 1
	else
		step = 0
	end
	count = step if step > count
end
p count

Measured memory_bytes: 8580
n = gets.to_i
t,a = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
ans = [0,1000000]
n.times do |i|
    ans = [i,(a-t+0.006*h[i]).abs] if (a-t+0.006*h[i]).abs < ans[1]
end
puts ans[0]+1

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

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

  cout << 3 * r * r << endl;
//  vector<int> a(n);
//  rep(i,n) cin >> a[i];
//  ll x2 = 0;
//  rep(i,n) {
//    if (i%2) x2 -= a[i];
//    else x2 += a[i];
//  }
//  vector<int> ans(n);
//  ans[0] = x2/2;
//  rep(i,n-1) {
//    ans[i+1] = a[i]-ans[i];
//  }
//  rep(i,n) ans[i] *= 2;
//  rep(i,n) printf("%d%c", ans[i], i==n-1?'\n':' ');
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m;
    cin >> n >> m;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    int64_t sum = 0;
    rep(i,n) sum += a.at(i);
    int64_t popular = 0;
    rep(i,n){
        if(a.at(i) >= sum / (4.0*m)){
            popular++;
        }
    }
    if(popular>=m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int a[maxn];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    map<int,int> mp;
    rep(i,1,n){
        cin>>a[i];
    }
     int l=1,r=1;
    int ans=n+1,cur=0;
    while(l<=n&&r<=n){
        //debug(l),debug(r);
        while(r<=n&&mp.size()<k){
            if(a[r]<=k)mp[a[r]]++;
            r++;
            //debug(mp.size());
        }
        //if(mp.size()>=s)ans=min(ans,r-l);
        while(l<r&&mp.size()>=k){
            ans=min(ans,r-l);
            if(a[l]<=k){
                mp[a[l]]--;
                if(mp[a[l]]==0)mp.erase(a[l]);
            }
            l++;
            //debug(mp.size());
        }
    }
    cout<<(ans==n+1?0:ans)<<endl;

}
/* 
6 2
4 1 2 1 3 5

 */


Measured memory_bytes: 8204
<?php
list($S)=sscanf(trim(fgets(STDIN)),"%s");
$week = [ "MON","TUE","WED","THU","FRI","SAT","SUN" ];
$cnt = 10;
for($i=0;$i<7;$i++){
    $cnt++;
    if($S == $week[$i]) $cnt=0;
}
if($cnt==0) $cnt = 7;
printf($cnt);

Measured memory_bytes: 4728
#![allow(non_snake_case, dead_code)]
use std::collections::VecDeque;
use std::io::BufRead;

struct MyReader<R: BufRead> {
    __reader: R,
    queue: VecDeque<String>,
}
impl<R: BufRead> MyReader<R> {
    fn new(reader: R) -> MyReader<R> {
        MyReader {
            __reader: reader,
            queue: VecDeque::new(),
        }
    }
    fn read(&mut self) -> String {
        if self.queue.len() == 0 {
            self.__readFromStdin()
        };
        self.queue.pop_front().unwrap()
    }
    fn readN(&mut self) -> i32 {
        self.read().parse().ok().expect("failed paring")
    }
    fn readUN(&mut self) -> usize {
        self.read().parse().ok().expect("failed paring")
    }
    fn readT<T: std::str::FromStr>(&mut self) -> T {
        self.read().parse().ok().expect("failed parsing")
    }

    fn __readFromStdin(&mut self) {
        let mut s = String::new();
        self.__reader.read_line(&mut s).unwrap();
        for it in s.trim().split_whitespace() {
            self.queue.push_back(it.to_string());
        }
    }
}
//*****************************************
fn main() {
    let stdin = std::io::stdin();
    let input = stdin.lock();
    println!("{}", run(input))
}

fn run<R: BufRead>(reader: R) -> String {
    let mut myReader = MyReader::new(reader);
    let xs = vec![myReader.readT::<i64>(), myReader.readT::<i64>()];
    let ys = vec![myReader.readT::<i64>(), myReader.readT::<i64>()];
    let mut res = vec![0; 4];
    for ix in 0..=1 {
        for iy in 0..=1 {
            res[ix * 2 + iy] = xs[ix] * ys[iy];
        }
    }
    res.sort();

    (res[res.len() - 1]).to_string()
}

Measured memory_bytes: 2180
#[int(i) for i in input().split()]
#int(input())
#list(input())

N=int(input())
p=[int(i) for i in input().split()]
P=sorted(p)
cnt=0
for i in range(N):
    if p[i]!=P[i]:
        cnt+=1
    if cnt>=3:
        break
print("YES" if cnt<=2 else "NO")

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

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

    int c[3][3];
    rep(i,3) rep(j,3) cin >> c[i][j];

    int x[3], y[3];

    x[0] = 0;
    rep(i,3) y[i] = c[i][0] - x[0];
    rep(i,3) x[i] = c[0][i] - y[0];

    bool good = true;

    rep(i,3) rep(j,3) if(c[i][j] != x[j]+y[i]) good = false;

    if(good) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int DT[100001], DA[100001];
vector<int> E[100001];
void dfsT(int A, int d) {
	if (DT[A]) return;
	DT[A] = d;
	for (int to : E[A]) {
		dfsT(to, d + 1);
	}
}
void dfsA(int A, int d) {
	if (DA[A]) return;
	DA[A] = d;
	for (int to : E[A]) {
		dfsA(to, d + 1);
	}
}

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


	int N;
	cin >> N;
	int u, v;
	cin >> u >> v;
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		E[a].pb(b);
		E[b].pb(a);
	}

	dfsT(u, 1);
	dfsA(v, 1);

	int saidai = -1;
	rep1(i, N) {
		if (DT[i] < DA[i]) chmax(saidai, DA[i]);
	}

	//int kei = DT[1] + DA[1];
	//if (kei % 2) {
	//	co(saidai - 2);
	//}
	//else {
	//}
	if (saidai - 2 <= 0) co(0);
	else co(saidai - 2);

	Would you please return 0;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int temp = 0;
		for (int j = i; j < n; j++) {
			if (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T') temp++;
			else {
				ans = max(ans, temp);
				break;
			}
		}
		if (temp != 0) ans = max(ans, temp);
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main () {
    int s[20000], t[900];
    int n, q, i, j, key;
    int c = 0;

    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ) { 
        scanf("%d", &s[i]);
    }
    
    scanf("%d", &q);

    for ( i = 0; i < q; i++ ) { 
        scanf("%d", &t[i]);
    }

    for ( j = 0; j < q; j++ ) {
        i = 0;
        key = t[j];
        s[n] = key;
        while ( s[i] != key ) {
            i++;
        }

        if ( i != n ) {
            c++;
        }
    }
    
    printf("%d\n", c);

    return 0;
}


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

using namespace std;

template <typename List>
void split(const std::string &s, const std::string &delim, List &result)
{
    result.clear();

    using string = std::string;
    string::size_type pos = 0;

    while (pos != string::npos)
    {
        string::size_type p = s.find(delim, pos);

        if (p == string::npos)
        {
            result.push_back(s.substr(pos));
            break;
        }
        else
        {
            result.push_back(s.substr(pos, p - pos));
        }

        pos = p + delim.size();
    }
}

int main()
{
    int N;
    string raw;
    vector<string> splited;
    vector<int> brick;

    getline(cin, raw);
    N = stoi(raw);

    getline(cin, raw);
    split(raw, " ", splited);

    brick.assign(N, 0);
    for (int i = 0; i < N; i++)
    {
        brick[i] = stoi(splited[i]);
    }

    int dest = 1;
    int index = 0;
    int destruct = 0;
    int dirty = 0;
    while (N > 0 && index < N)
    {
        while (index < N)
        {
            if (brick[index] == dest)
            {
                dirty = 1;
                dest++;
                break;
            }
            index++;
            destruct++;
        }
        index++;
    }

    if (dirty == 0 && destruct > 0)
    {
        cout << -1 << "\n";
    }
    else
    {
        cout << destruct << "\n";
    }
}

Measured memory_bytes: 13696