akhauriyash/Code-Regression huggingface dataset:
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
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) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    int n;
    std::cin >> n;
    std::map<int, i64> mp;
    for(int i = -1000; i < 1000; i++) {
        mp[i] = std::pow((i64)i, 5);
    }
    for(auto &x : mp) {
        for(auto &y : mp) {
            if(x.second - y.second == n) {
                std::cout << x.first << " " << y.first << std::endl;
                return;
            }
        }
    }
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 4196
import java.util.*;

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

    int n = sc.nextInt();

    int a = n/4;
    int b = n/7;
    boolean flag = false;

    for(int i=0; i<=a; i++){
      for(int j=0; j<=b; j++){
        if(4*i+7*j==n){
          flag = true;
          break;
        }
      }
    }

    if(flag){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21972
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

x = int(input())
ans = 1
if x < 1800:
    ans = 2
if x < 1600:
    ans = 3
if x < 1400:
    ans = 4
if x < 1200:
    ans = 5
if x < 1000:
    ans = 6
if x < 800:
    ans = 7
if x < 600:
    ans = 8
print(ans)

Measured memory_bytes: 10420
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [(1+p)/2 for p in P]

cumsum = [0]*(N+1)
for i in range(1, N+1):
    cumsum[i] = cumsum[i-1] + P[i-1]
ans = 0
for i in range(N-K+1):
    if ans < cumsum[i+K]-cumsum[i]:
        ans = cumsum[i+K]-cumsum[i]
print(ans)

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

int main() {
	string S;
	cin >> S;
	int a = 0;
	for (char& i : S) {
		if (i == 'o') ++a;
	}
	if (a - S.size() + 15 < 8) cout << "NO";
	else cout << "YES";
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
dp = [-1]*N


def dfs(n):
    global dp
    if dp[n] > 0:
        return dp[n]

    ma = 0
    for b in G[n]:
        ma = max(ma, dfs(b) + 1)
    dp[n] = ma
    return ma


def main():
    global dp
    for i in range(N):
        dp[i] = dfs(i)
    print(max(dp))


if __name__ == '__main__':
    main()


Measured memory_bytes: 129244
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < W; i++) printf("#");
		printf("\n");

		for(int i = 1; i < H-1; i++){
			printf("#");
			for(int j = 1; j < W-1; j++) printf(".");
			printf("#\n");
		}

		if(H > 1){
			for(int i = 0; i < W; i++) printf("#");
			printf("\n");
		}
		printf("\n");
	}
}

Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
   

    cin.tie(0);
    ios::sync_with_stdio(false);
   
    
    int a,b,c; cin >> a >> b >> c;
    if(a==b) cout << c << endl;
    else if(b==c) cout << a << endl;
    else cout << b << endl;
    
    
    
}


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

int main(){
  int n;
  cin >> n;
  map <int, int> a;
  for(int i = 0; i < n; i++){
    int number;
    cin >> number;
    if(a.count(number)){
      a.at(number) = a.at(number) + 1;
    }else{
      a[number] = 0;
    }
  }

  

  cout << a.size() << endl;
}


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

using namespace std;

int p, q, n, m;
vector<int> vec;
int il(int k) {
    int c = 0;
    while(k) {
        c++;
        k/=2;
    }
    return c-1;
}

int ans[150000];
void solve() {
    int i, j, t = 0;
    for (i=0;i<n;i++) {
        if (t<m) {
            if (!t) {
                ans[1] = vec[t];
            }
            else {
                if (i%2) ans[1<<i]=vec[t];
                else ans[1<<i]=ans[(1<<i)+1]=vec[t];
                for (j=(1<<i)+(i%2?1:2);j<(1<<(i+1));j++) ans[j] = vec[((t+1)^1)-1];
            }
            t++;
        }
        else {
            for (j=(1<<i);j<(1<<(i+1));j++) ans[j] = vec[t];
            t++;
        }
    }
}

int cur;
void dfs(int p) {
    if (p>=(1<<n)) return;
    dfs(p*2);
    cur^=(1<<ans[p]);
    printf("%d ",cur);
    dfs(p*2+1);
}

int pcnt(int n) {
    int c=0;
    while(n) {
        c+=n%2;
        n/=2;
    }
    return c;
}
int main() {
    int i;

    scanf("%d%d%d",&n,&p,&q);
    if (pcnt(p^q)%2==0) {
        printf("NO\n");
        return 0;
    }
    for (i=(p^q);i;i&=i-1) {
        vec.push_back(il(i&-i));
        m++;
    }
    for (i=(((1<<n)-1)^(p^q));i;i&=i-1) {
        vec.push_back(il(i&-i));
    }
    solve();
    printf("YES\n%d ",p);
    cur=p;
    dfs(1);
    printf("\n");

    return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int n;
    cin >> n;

    ll a[n];
    rep(0, n) cin >> a[i];

    ll max_diff = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i != j) {
                max_diff = max(max_diff, abs(a[i] - a[j]));
            }
        }
    }

    cout << max_diff << endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 256
import itertools


def main():
    n, m, q = [int(x) for x in input().split()]
    li = [tuple(map(int, input().split())) for _ in range(q)]

    arrays = itertools.combinations_with_replacement(range(m), n)

    def gen():
        for array in arrays:
            total = 0
            for a, b, c, d in li:
                if array[b - 1] - array[a - 1] == c:
                    total += d
            yield total

    return max(gen())


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

using namespace std;

struct edge
{
  int to;
  ll cost;
};

int main()
{
  int n;
  cin >> n;
  vector<edge> graph[100001];
  int result[100001] = {};

  REP(i, n - 1)
  {
    int u, v, w;
    cin >> u >> v >> w;
    edge e = {v, w};
    edge ei = {u, w};
    graph[u].push_back(e);
    graph[v].push_back(ei);
  }

  result[1] = -1;
  queue<int> q;
  q.push(1);
  while (!q.empty())
  {
    int i = q.front();
    q.pop();
    for (int j = 0; j < graph[i].size(); j++)
    {
      if (result[graph[i][j].to] != 0)
        continue;
      if (graph[i][j].cost % 2 == 0)
      {
        result[graph[i][j].to] = result[i];
      }
      else
      {
        result[graph[i][j].to] = result[i] * -1;
      }

      q.push(graph[i][j].to);
    }
  }

  FOR(i, 1, n + 1)
  {
    if (result[i] == 1)
    {
      cout << 1 << endl;
    }
    else
    {
      cout << 0 << endl;
    }
  }
}


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

int main(){
  ll a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(v<=w) cout<<"NO";
  else {
    if((v-w)*t>=abs(a-b)) cout<<"YES";
    else cout<<"NO";
  }
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<vector>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
#define INF 998244353
int h,w;
char s[30][30];
bool used[30][30];
int d[440][440];
int ans;
struct point
{
	int l,r,d;
}p0;
queue<point> que;
/*int getp(int x,int y)
{
	return (x-1)*w+y;
}
void add_edge(int u,int v)
{
	int x=getp(u,v);
	int y;
	if(u!=1&&s[u-1][v]=='.')
	{
		y=getp(u-1,v);
		d[x][y]=1;
	}
	if(u!=h&&s[u+1][v]=='.')
	{
		y=getp(u+1,v);
		d[x][y]=1;
	}
	if(v!=1&&s[u][v-1]=='.')
	{
		y=getp(u,v-1);
		d[x][y]=1;
	}
	if(v!=w&&s[u][v+1]=='.')
	{
		y=getp(u,v+1);
		d[x][y]=1;
	}
} */
void bfs(int x,int y)
{
	p0.l=x,p0.r=y,p0.d=0;
	que.push(p0);
	d[x][y]=0;
	while(!que.empty())
	{
		point p1=que.front();
		que.pop();
		used[p1.l][p1.r]=true;
		int a=p1.l;
		int b=p1.r;
	    if(a!=1)
	    {
		    if(s[a-1][b]=='.'&&!used[a-1][b])
		    {
			    p0.l=a-1,p0.r=b,p0.d=d[a][b]+1;
			    d[a-1][b]=min(d[a-1][b],d[a][b]+1);
			    used[a-1][b]=true; 
			    que.push(p0);
		    }
	    }
	    if(a!=h)
	    {
		    if(s[a+1][b]=='.'&&!used[a+1][b])
		    {
			    p0.l=a+1,p0.r=b,p0.d=d[a][b]+1;
			    d[a+1][b]=min(d[a+1][b],d[a][b]+1);
			    used[a+1][b]=true; 
			    que.push(p0);
		    }
	    }
	    if(b!=1)
	    {
		    if(s[a][b-1]=='.'&&!used[a][b-1])
		    {
			    p0.l=a,p0.r=b-1,p0.d=d[a][b]+1;
			    d[a][b-1]=min(d[a][b-1],d[a][b]+1);
			    used[a][b-1]=true; 
			    que.push(p0);
		    }
	    }
	    if(b!=w)
	    {
		    if(s[a][b+1]=='.'&&!used[a][b+1])
		    {
			    p0.l=a,p0.r=b+1,p0.d=d[a][b]+1;
			    d[a][b+1]=min(d[a][b+1],d[a][b]+1);
			    used[a][b+1]=true; 
			    que.push(p0);
		    }
	    }
	}
	return ;
}
int main()
{
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
	    for(int j=1;j<=w;j++)
		{
			cin>>s[i][j];
		}	
	}
	/*for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			
		}
	}*/
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			for(int l=1;l<=h;l++)
			{
				for(int r=1;r<=w;r++)
				{
					d[l][r]=998244353;
					used[l][r]=false;
				}
			}
			if(s[i][j]=='.')
			bfs(i,j);
			for(int l=1;l<=h;l++)
			{
				for(int r=1;r<=w;r++)
				{
					if(used[l][r])
					{
						ans=max(ans,d[l][r]);
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n,m=[int(i) for i in raw_input().split()]
l=[i for i in range(n)]
r=[0 for i in range(n)]
def find(x):
    if l[x]==x:
        return l[x]
    return find(l[x])
for i in range(m):
    u,v=[int(j)-1 for j in raw_input().split()]
    px=find(u)
    py=find(v)
    if r[px]<r[py]:
            l[u]=py
            l[v]=py
            l[px]=py
    elif r[px]==r[py]:
            l[u]=px
            l[v]=px
            l[py]=px
            r[px]+=1
    else:
            l[u]=px
            l[v]=px
            l[py]=px
d={}
for i in l:
    d[find(i)]=d.get(find(i),0)+1
print max(d.values())


Measured memory_bytes: 109892
from copy import *
n=int(input())
arr=list(map(int,input().split()))
arr1=[]
arr2=[]
for i in range(1,100001):
	arr1.append([0,i])
	arr2.append([0,i])

for i in range(0,n,2):
	arr1[arr[i]-1][0]+=1
#arr1.sort()
#print(arr1[-1])
for i in range(1,n,2):
	arr2[arr[i]-1][0]+=1
arr1.sort(reverse=True)
arr2.sort(reverse=True)
#print(arr1[-1],arr2[-1])
if(arr1[0][1]==arr2[0][1]):
	print(min(n-arr1[0][0]-arr2[1][0],n-arr1[1][0]-arr2[0][0]))	
else:
	print(n-arr1[0][0]-arr2[0][0])


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

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N, ll M, ll X, vector<ll> A) {
  sort(ALL(A));
  ll d = lower_bound(ALL(A),X) - A.begin();
  cout << min(d,M-d) << endl;
}

int main() {
  ll N;
  cin >> N;
  ll M;
  cin >> M;
  ll X;
  cin >> X;
  vector<ll> A(M);
  for (int i = 0; i < M; i++) {
    cin >> A[i];
  }
  solve(N, M, X, move(A));
  return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int n;
  cin >> n;
  vi a(n);
  cin >> a;
  vi move(n + 1);
  loop(i, 1, n) move[i] = (a[i - 1] < a[i]) - (a[i - 1] > a[i]);
  int f = 0, minL = 0, maxR = 0, pre = move[1];
  loop(i, 1, n) {
    if (move[i] == 0) continue;
    if (move[i] != pre) {
      if (move[i] < 0) cmax(f, maxR);
      if (move[i] > 0) cmin(f, minL);
    }
    f += move[i];
    pre = move[i];
    cmax(maxR, f);
    cmin(minL, f);
  }
  cout << maxR - minL + 1 << endl;
}



Measured memory_bytes: 4332
x=[list(map(str,input().split())) for _ in range(3)]
N=int(input())
B=[input() for _ in range(N)]
flag=0
for i in range(3):
  for j in range(3):
    if x[i][j] in B:
      x[i][j]=True

for p in range(3):
  if x[p].count(True)==3:
    flag=1
lis=[]
lis2=[]
for a in range(3):
  for b in range(3):
    lis2.append(x[b][a])
  else:
    lis.append(lis2)
    lis2=[]

for q in range(3):
  if lis[q].count(True)==3:
    flag=1
if x[0][0]==True and x[1][1]==True and x[2][2]==True:
  flag=1
elif  x[0][2]==True and x[1][1]==True and x[2][0]==True:
  flag=1
if flag==1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline LL ri() {LL x; scanf("%lld", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/


char s[1000][1000];
int n;

//string col(int c) {
  //string r(n);
  //rep(i, n) r[i] = s[i][c];
  //return r;
//}

//string row(int c) {
  //string r(n);
  //rep(i, n) r[i] = s[c][i];
  //return r;
//}

//void apply(int r, const string& x) {
  //rep(i, n) s[r][i] = x[i];
//}

const int inf = 1e6;
int main() {
  cin >> n;
  rep(i, n) scanf("%s", s[i]);

  vector<set<int>> v(n);

  int allw = 1;
  rep(i, n) rep(j, n) if (s[i][j] == '#') allw = 0;
  if (allw) {
    cout << -1 << endl;
    return 0;
  }

  rep(i, n) rep(j, n) if (s[i][j] == '.') v[j].insert(i);
  int res = inf;
  rep(i, n) {
    int flag = 0, ans = 0;
    rep(k, n) if (s[k][i] == '#') {
      flag = 1;
      break;
    }
    if (!flag) {
      ans ++;
    }
    rep(j, n) {
      if (s[i][j] == '#') ans += v[j].size() > 0;
      else ans += 2;
    }
    smin(res, ans);
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 12416
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	int cnt4 = 0;
	int cnt2 = 0;
	int tmp = 0;
	rep(i, n) {
		if (a[i] % 4 == 0) {
			cnt4++;
		}
		else if (a[i] % 2 == 0) {
			cnt2++;
		}
		else {
			tmp++;
		}
	}
	if (cnt2 != 0) {
		if (tmp <= cnt4) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		if (tmp <= cnt4 + 1) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
L = list(map(int,input().split()))

ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        if a==b:
            continue
        for k in range(j+1,N):
            #print(i,j,k)
            c = L[k]
            if a==c or b==c:
                continue
            if (a+b)>c and (b+c)>a and (c+a)>b:
                #print(i,j,k)
                ans += 1

print(ans)

Measured memory_bytes: 9184
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r=sc.nextInt();
		if(r >= 2800) System.out.println("AGC");
		else if(r >= 1200) System.out.println("ARC");
		else System.out.println("ABC");
	}
}

Measured memory_bytes: 23764
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//---------------------------------------------------------------------------
bool color[200001];
//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b,c;cin>>a>>b>>c;
    if(a==b&&b==c){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------

/*
ll n;cin>>n;
vector<ll>a(n);
for(ll i=0;i<n;i++)
    cin>>a[i];
 
ll n;cin>>s;
string s;cin>>s;

ll n,m;cin>>n>>m;
vector<ll>a(n),b(m);
for(ll i=0;i<n;i++){
    cin>>a[i];
}
for(ll i=0;i<m;i++){
    cin>>b[i];
}

ll n;cin>>n;
vector<Pll>xy;
for(ll i=0;i<n;i++){
    ll x,y;cin>>x>>y;
    xy.pb({x,y});
}
*/


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
    stack<char> sc;
    string s;
    cin>>s;
    FOR(i, 0, s.length()){
        if(s[i]!='B') sc.push(s[i]);
        else if(!sc.empty()) sc.pop();
    }
    string ans;
    while(!sc.empty()){
        ans.push_back(sc.top());
        sc.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 256
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
const [xn, _p] = input.split('\n');
const [x, n] = xn.split(' ').map((s) => s >> 0);
const p = new Set(
  _p
    .split(' ')
    .filter((s) => s)
    .map((s) => s >> 0)
);

// console.log(x, n);
// console.log(p);

for (let diff = 0; diff < 100; diff++) {
  // 下方向を見る
  const down = x - diff;
  if (!p.has(down)) {
    console.log(down);
    break;
  }

  // 上方向を見る
  const up = x + diff;
  if (!p.has(up)) {
    console.log(up);
    break;
  }
}


Measured memory_bytes: 29644
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
#my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())


#your code here!
def resolve():
    N,K=pin()
    sita=0
    ue=N
    #方針
    ans=0
    for k in range(1,N+2):
        if k>=K:ans=(ans+(ue-sita+1))%1000000007
        sita+=k;ue+=N-k
    print(ans)
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 2"""
        output = """10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """200000 200001"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """141421 35623"""
        output = """220280457"""
        self.assertIO(input, output)


if __name__ == "__main__":
    #unittest.main()

    #I wrote my code above!

    resolve()#and submit 2 atcoder!



Measured memory_bytes: 16372
#include <iostream>
#include <string>

using namespace std;

const char *FIRST[] = {
	"w", "", "k", "s", "t",
	"n", "h", "m", "y", "r"
};
const char *SECOND = "aiueo";

int main(){
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i += 2){
		int n = s[i] - '0', m = 0;
		switch(s[i + 1]){
			case 'L': m = 1; break;
			case 'U': m = 2; break;
			case 'R': m = 3; break;
			case 'D': m = 4; break;
		}
		if(n == 0 && m == 2){
			cout << "nn";
		}else{
			cout << FIRST[n] << SECOND[m];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
const int maxn = 5e5+5;
int n, m;
struct Tree {
    int ls, rs, val; 
}tre[maxn*50];
int idx = 0, root[maxn];
int build(int l, int r) {
    int nod = ++idx;
    tre[nod].val = 0;
    if (l == r) return nod;
    int mid = (l + r) >> 1;
    tre[nod].ls = build(l, mid);
    tre[nod].rs = build(mid+1, r);
    return nod;
}

int update(int pre, int l, int r, int pos, int v) {
    int nod = ++idx;
    tre[nod] = tre[pre]; tre[nod].val += v;
    if (l == r) return nod;
    int mid = (l + r) >> 1;
    if (pos <= mid) tre[nod].ls = update(tre[pre].ls, l, mid, pos, v);
    else tre[nod].rs = update(tre[pre].rs, mid+1, r, pos, v);
    return nod;
}

int query(int id, int l, int r, int pos) {
    if (l == r) return tre[id].val;
    int mid = (l + r) >> 1;
    if (pos <= mid) {
        return tre[tre[id].rs].val + query(tre[id].ls, l, mid, pos);
    }
    else return query(tre[id].rs, mid+1, r, pos);
}

int a[maxn], vis[maxn];
void solve() {
    scanf("%d%d", &n,&m);
    for (int i = 1 ; i <= n ; i ++) {
        scanf("%d", a+i);
    }
    root[0] = build(1, n);    
    for (int i = 1 ; i <= n ; i ++) {
        if (!vis[a[i]])
            root[i] = update(root[i-1], 1, n, i, 1);
        else {
            int t = update(root[i-1], 1, n, vis[a[i]], -1);
            root[i] = update(t, 1, n, i, 1);
        }
        vis[a[i]] = i;
    }
    while (m--) {
        int l, r; scanf("%d%d", &l, &r);
        int tmp = query(root[r], 1, n, l);
        printf("%d\n", tmp);
    }
}

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


Measured memory_bytes: 252948
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int count=0;
  int Max=0;
  vector<int> Mochi(N);
  
  for(int i=0;i<N;i++)
    cin>>Mochi.at(i);
  
  sort(Mochi.begin(),Mochi.end());
  
  for(int i=0;i<N;i++){
    if(Mochi.at(i)>Max){
      count++;
      Max=Mochi.at(i);
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b,s=0;
    scanf("%d",&a);
    while(a>=5)
    {
        if(a>=500)
            {
                b=a/500;
                a=a%500;
                b=b*1000;
            }
        else
        {
            b=a/5;
            a=a%5;
            b=b*5;
        }
        s=s+b;
    }
    printf("%d",s);
    return 0;
}


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

using static Input;
using static Util;
class Program
{
    static string A;
    static string B;
    static void INPUT()
    {
        A = NextString();
        B = NextString();
    }
    static void OUTPUT()
    {
        var ans = 0;
        for(var idx = 0; idx < 3; idx++)
        {
            ans +=
                B.ElementAtOrDefault(idx) ==
                A.ElementAtOrDefault(idx) ?
                1 : 0;
        }
        Console.WriteLine(ans);
    }

    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
#else
        INPUT();
#endif
        OUTPUT();
    }

    static void TESTINPUT()
    {
        A = "ABC";
        B = "ABX";
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 11348
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;
 
const long long MOD = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;
 
#define itn int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
/////////////////////////
int visit[100010];
int main(void){
   int n;cin >> n;
   vector<vector<int>> G(n,vector<int>(0));
   rep(i,n-1){
      int a,b;cin >> a >> b;
      G[--a].pb(--b);
      G[b].pb(a);
   }
   ll sum = 0LL;
   vector<int> c(n);rep(i,n){cin >> c[i];sum+=c[i];}
   sort(all(c)); reverse(all(c));
   sum -=c[0];
   
   vector<int> ans(n);
   ans[0] = c[0];
   int j = 0;
   
   queue<int> q;
   q.push(0);
   visit[0] = 1;
   while(!q.empty()){
      int x = q.front();q.pop();
      visit[x] = 1;
      int m = G[x].size();
      rep(i,m){
         int y = G[x][i];
         if(visit[y] == 0){
            ans[y] = c[++j];
            q.push(y);
         }
      }
   }
   cout << sum << endl;
   rep(i,n) cout << ans[i] << " ";
   cout << endl;
}

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

int main(){

	vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

	int k;
	cin>>k;

	cout<<a[k-1]<<"\n";
	return 0;
}

Measured memory_bytes: 256
x=int(input())
import math
def is_prime(n):
    if n==1:
        return False
    for divisor in range(2,int(math.sqrt(n))+1):
        if n%divisor == 0:
            return False
    return True

k=0
while True:
    if is_prime(x+k):
        print(x+k)
        break
    else:
        k += 1

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void push(int* , int);

int pop(int*);

int top=0;

int main(){
  
  int i,time=0,y,x,in;
  int num[200];
  char s[200];

  while(scanf("%s",s)!=EOF){

    if(s[0]=='+'){
      y=pop(num);
      x=pop(num);
      in=x+y;
      push(num,in);
    }
    else if(s[0]=='-'){
      y=pop(num);
      x=pop(num);
      in=x-y;
      push(num,in);
    }
    else if(s[0]=='*'){
      y=pop(num);
      x=pop(num);
      in=x*y;
      push(num,in);
    }
    else{
      in=atoi(s);
      push(num,in);

    }
  }
  printf("%d\n",num[1]);


    
  return 0;
}


void push(int* A, int x){

  top++;
  A[top]=x;
}


int pop(int* A){

    top=top-1;
    return A[top+1];
 
}

Measured memory_bytes: 548
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long N;
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	long long u = N;
	int flag = 0;

	while(u > 0){
		if((u % 10) == 7){
			flag = 1;
			break;
		}
		u /= 10;
	}
	if(flag){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
const int inf=1145141919ll;
const int mod=1000000007ll;
const int dd[]={0,-1,0,1,0};
using namespace std;
int n,m,k;
int p[2222222];
signed main(){
	int i,j;
	cin>>n;
	int u=0,v=0;
	for(i=0;i<n;i++){
		cin>>p[i];
		if(p[i]%2)
			u++;
		if(p[i]%4==0)
			v++;
	}
	if((n%2&&u-1<=v)||(n%2==0&&u<=v))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 1024
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91
#include <utility>

template <class F> class fix_point : private F {
public:
  explicit constexpr fix_point(F &&f) : F(std::forward<F>(f)) {}

  template <class... Args>
  constexpr decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};

template <class F> constexpr decltype(auto) make_fix(F &&f) noexcept {
  return fix_point<F>(std::forward<F>(f));
}
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <utility>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const std::string s = scan<std::string>();
  u32 ans = 0;
  if (s == "SUN") {
    ans = 7;
  } else if (s == "MON") {
    ans = 6;
  } else if (s == "TUE") {
    ans = 5;
  } else if (s == "WED") {
    ans = 4;
  } else if (s == "THU") {
    ans = 3;
  } else if (s == "FRI") {
    ans = 2;
  } else if (s == "SAT") {
    ans = 1;
  } else {
    assert(false);
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


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

ans = 0
for i in range(n-1):
    if i+1 == p[i]:
        tmp = p[i]
        p[i] = p[i+1]
        p[i+1] = tmp
        ans += 1

if n == p[n-1]:
    tmp = p[n-1]
    p[n-1] = p[n-2]
    p[n-2] = tmp
    ans += 1

print(ans)

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

int main(){
  int N;
  cin >> N;
  
  vector<int> rate(9, 0);
  int kind = 0;
  for (int i = 0; i < N; i++){
    int a;
    cin >> a;
    a /= 400;
    
    if (a < 8){
      if (rate.at(a) == 0){
        kind++;
      }
      
      rate.at(a)++;
    }
    else{
      rate.at(8)++;
    }
  }
  
  int kindmin, kindmax;
  kindmin = max(kind, 1);
  kindmax = kind + rate.at(8);
  
  cout << kindmin << ' ' << kindmax << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define int long long
#define MAX 1000000000000000000LL
int inf=100000000000007;
using namespace std;
string alph="abcdefghijklmnopqrstuvwxyz";

signed main(){
    int n; cin>>n;
    priority_queue<int> q;
    int a;
    for(int i=0; i<n; i++){
        cin>>a;
        q.push(a);
    }
    int s;
    int ans=0;
    int key[2]={};
    while(!q.empty()){
        s=q.top();q.pop();
        if(s==q.top()&&!q.empty()){
            key[ans]=s;
            ans++;
            q.pop();
        }
        if(ans==2){
            break;
        }
        if(q.empty()){
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<key[0]*key[1]<<endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
    ll N,A,B; cin>>N>>A>>B;
    if(A%2==B%2) cout<<(B-A)/2<<endl;
    else cout<<min(A+(B-A-1)/2, (N-B+1)+(B-A-1)/2)<<endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 150000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int X;
int primes[MAX_N];
bool is_prime[MAX_N + 1];

int init() {
  int p = 0;
  for (int i = 0; i <= MAX_N; i++) is_prime[i] = true;
  is_prime[0] = false, is_prime[1] = false;
  for (int i = 2; i <= MAX_N; i++) {
    if (is_prime[i]) {
      primes[p++] = i;
      for (int j = i * 2; j <= MAX_N; j += i) is_prime[j] = false;
    }
  }
  return p;
}

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

  int p = init();

  if (is_prime[X]) {
    cout << X << endl;
    return 0;
  }

  int idx = 0;
  while (primes[idx] <= X) {
    idx++;
  }
  cout << primes[idx] << endl;

  return 0;
}


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

bool ng[10];

int main() {
	int N, K;
	cin >> N >> K;
	for(int i = 0; i < K; i++) {
		int a;
		cin >> a;
		ng[a] = true;
	}

	for(int i = N;; i++) {
		int tmp = i;
		bool flg = true;
		while(tmp) {
			if(ng[tmp % 10])
				flg = false;
			tmp /= 10;
		}
		if(flg) {
			cout << i << endl;
			break;
		}
	}
}



Measured memory_bytes: 256
/* 144b */
#include<stdio.h>
int main(void){
  int n,i,a;
  scanf("%d",&n);
  a=0;
  for(i=1;i<10;i++){
    if(n%i==0&&n/i<10){
      a++;
      break;
    }
  }
  if(a>0){
  printf("Yes\n");
  }
  if(a==0){
  printf("No\n");
  }
  return 0;
}


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

int main()
{
    vector<int> v;
    for (int i = 0; i < 3; i++)
    {
        int n;
        cin >> n;
        v.push_back(n);
    }
    sort(v.begin(), v.end());
    if (v[0] + v[1] == v[2])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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


#define ll unsigned long long
#define FASTIO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

const ll maxn = 2e5+5;
const int MOD = 1e9+7;


//https://codeforces.com/blog/entry/67679


int main(){
	
	int n;cin >> n;
	n *= 2;
	vector<int> input(n);
	for(int &x:input) cin >> x;
	sort(input.begin(),input.end());
	ll ans = 0;
	for(int i=n-2;i>=0;i -= 2){
		ans += input[i];
	}
	cout << ans;
}

Measured memory_bytes: 256
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main()
{
    IOS
    int n;
    string s;
    cin>>n>>s;
    int ct=0;
    for(int i=0;i<s.length()-2;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
            ct++;
    }
    cout<<ct;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
 int a[1000],n,i,j,d=0;
 scanf("%d",&n);
 for(i=0;i<n;i++)
  scanf("%d",&a[i]);
 for (i = 0;i<n;i++)
 {   
     for (j = n-1;j>= i+1;j--)
     {
        if (a[j] < a[j-1])
        {
          int temp=a[j];
          a[j]=a[j-1];
          a[j-1]=temp;
          d++;
        }
     }
 }
  printf("%d",a[0]);
  for(i=1;i<n;i++)
  {
   printf(" %d",a[i]);
  }
 printf("\n%d\n",d);
 return 0;
}

Measured memory_bytes: 604
# A
N, A, B = map(int, input().split())

# regular
min_ = A*(N-1) + B
max_ = A + B * (N-1)

res = max_ - min_ + 1

# irregular
if res < 0:
    res = 0
if N == 1 and A != B:
    res = 0
print(res)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    System.out.println(Integer.toString(n, k).length());
  }
}

Measured memory_bytes: 21076
#include <iostream>
#include <vector>
using namespace std;

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

  vector<int> v(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int diff = v[i] - c[i];
    if (diff > 0) {
      sum += diff;
    }
  }
  cout << sum;
}


Measured memory_bytes: 256
from collections import deque
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

d = dict()
for point in xy:
    d[str(point)] = 1


if N == 1:
    print(1)
    exit()

ans = N
que = deque()

for i in range(N):
    for j in range(i+1, N):
        p = xy[i][0] - xy[j][0]
        q = xy[i][1] - xy[j][1]

        ans_tmp = N

        for point in xy:
            add = [point[0] + p, point[1] + q]
            # sub = [point[0] - p, point[1] - q]
            if d.get(str(add)) == 1:
                ans_tmp -= 1
                d[str(add)] -= 1
                que.append(str(add))
            # if d.get(str(sub)) == 1:
            #     ans -= 1
            #     d[str(sub)] -= 1
        
        ans = min(ans, ans_tmp)
        
        while len(que):
            key = que.pop()
            d[key] += 1
        


print(ans)




Measured memory_bytes: 9412