akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll ans[510][510];
int n;
int prime[20010], cnt;
int np[20010];
int main() {
    scanf("%d", &n);
    if (n == 2) return puts("4 7\n23 10"), 0;
    for (int i = 0; i <= n + 1; i++) ans[0][i] = ans[i][0] = ans[n + 1][i] = ans[i][n + 1] = 1;
    for (int i = 2; i <= 20000; i++) {
        if (!np[i]) prime[++cnt] = i;
        for (int j = 1; prime[j] * i <= 20000; j++) {
            np[i * prime[j]] = 1;
            if (i % prime[j] == 0) break;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if ((i + j) % 2 == 0) ans[i][j] = prime[(i + j) / 2] * prime[(i - j) / 2 + n + n];
        }
    }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            if ((i + j) % 2 == 1) {
                ans[i][j] = 1;
                ans[i][j] *= ans[i - 1][j] / gcd(ans[i - 1][j], ans[i][j]);
                ans[i][j] *= ans[i + 1][j] / gcd(ans[i + 1][j], ans[i][j]);
                ans[i][j] *= ans[i][j - 1] / gcd(ans[i][j - 1], ans[i][j]);
                ans[i][j] *= ans[i][j + 1] / gcd(ans[i][j + 1], ans[i][j]);
                ans[i][j]++;
            }
    for (int i = 1; i <= n; i++, puts(""))
        for (int j = 1; j <= n; j++) printf("%lld ", ans[i][j]);
}

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

using namespace std;

long long int arr[3][100001], n, dp[3][100001];

long long int score(int i, int prev){
	
	if(dp[prev][i]) return dp[prev][i];
	
	int x, y;
	if(prev == 0)
		x = 1, y = 2;
	else if(prev == 1)
		x = 0, y = 2;
	else
		x = 0, y = 1;
	
	if(i == n)
		dp[prev][i] = max(arr[x][i], arr[y][i]);
	else
		dp[prev][i] = max(arr[x][i] + score(i+1, x), arr[y][i] + score(i+1, y));
	return dp[prev][i];
	
}

int main(){
	cin >> n;
	for(int i=1;i<=n;i++)cin >> arr[0][i] >> arr[1][i] >> arr[2][i];
	for(int i = 0; i < 3; i++)
		for(int j = 0; j < n; j++)
			dp[i][j] = 0;
	
	long long int ans = 0;
	for(int k = 0; k < 3; k++){
		ans = max(ans, score(0, k));
	}	
	cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

long int M = 1e+9+7;
int main(void){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans=0;
    if(a >= k){
        ans=k;
        k=0;
    }else{
        ans=a;
        k-=a;
    }
    if(b >= k){
        k=0;
    }else{
        k-=b;
    }
    ans-=k;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
ULL solve(ULL h, ULL w) {
  if (h % 3 == 0 || w % 3 == 0)
    return 0;
  else {
    ULL mi = h * w;
    REPC(i, 1, w) {
      ULL sa = h * i;
      ULL sb = (h / 2) * (w - i);
      ULL sc = ((h + 1) / 2) * (w - i);
      ULL nmi = max({sa, sb, sc}) - min({sa, sb, sc});
      if(nmi<mi){
        mi = nmi;
      }

      sb = h * ((w - i) / 2);
      sc = h * ((w - i + 1) / 2);
      //DUMP(i,sa, sb, sc);
      nmi = max({sa, sb, sc}) - min({sa, sb, sc});
      mi = min(mi, nmi);
    }
    return mi;
  }
}

int main() {
  int h, w;
  cin >> h >> w;
  cout << min(solve(h, w), solve(w, h)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
const int N=2e5+5;
char s[N];
int ans,cnt;
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	cnt=1;
	for(int i=1;i<=len;++i)
	{
		if(s[i]==s[i+1] && cnt==1 && i+1==len) {++ans;break;}
		if(s[i]==s[i+1] && cnt==1) cnt=2,++ans;
		else if(s[i]!=s[i+1] && cnt==1) ++ans;
		else if(s[i]!=s[i+1] && cnt==2) cnt=1,++ans,++i;
		else if(s[i]==s[i+1] && cnt==2) ++i,++ans,cnt=1;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

int main(){
    int d;
    cin >> d;
    if(d == 25) cout << "Christmas" << endl;
    if(d == 24) cout << "Christmas Eve" << endl;
    if(d == 23) cout << "Christmas Eve Eve" << endl;
    if(d == 22) cout << "Christmas Eve Eve Eve" << endl; 
    return 0;
}

Measured memory_bytes: 256
s = input()
mae = int(s[:2])
ush = int(s[2:])

if 1<=mae<=12:
    if 1<=ush<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=ush<=12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	string s;
	cin >> s;
	if (s.size() % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	int cnt = 0;
	bool flag = true;
	rep(i, s.size()) {
		if (cnt % 2 == 0) {
			if (s[i] != 'h') flag = false;
		}
		else {
			if (s[i] != 'i') flag = false;
		}
		cnt++;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

B=[]
for i in range(n):
    B +=[A[i]-(i+1)]

median=median(B)
ans=0
for i in range(n):
    ans +=abs(A[i]-(median+i+1))
print(int(ans))

Measured memory_bytes: 27244
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int maxn=200111;
const int mod=1e9+7;
int qpow(int x,int y)
{
	int ret=1;
	while(y)
	{
		if(y&1)ret=(LL)ret*x%mod;
		x=(LL)x*x%mod;
		y>>=1;
	}
	return ret;
}

int bit[maxn];
void add(int x,int v)
{
	for(;x<maxn;x+=x&-x)
	{
		bit[x]+=v;
		if(bit[x]>=mod)bit[x]-=mod;
	}
}
int query(int x)
{
	int ret=0;
	for(;x;x-=x&-x)
	{
		ret+=bit[x];
		if(ret>=mod)ret-=mod;
	}
	return ret;
}
vector<pii>vs;
void roll_back()
{
	for(int i=0;i<(int)vs.size();i++)add(vs[i].ff,mod-vs[i].ss);
	vs.clear();
}

int n,inv[maxn],pre[maxn],suf[maxn];
pii p[maxn];


int main()
{
	get1(n);
	for(int i=1;i<=n;i++)
	{
		get1(p[i].ff);
		p[i].ss=i;
	}
	sort(p+1,p+n+1);
	
	for(int i=1;i<=n;i++)if(p[i].ff<i)
	{
		puts("0");
		return 0;
	}
	
	for(int i=1;i<=n;i++)inv[i]=qpow(i,mod-2);
	pre[0]=suf[n+1]=1;
	for(int i=1;i<=n;i++)pre[i]=(LL)pre[i-1]*(p[i].ff-i+1)%mod;
	for(int i=n;i>=1;i--)suf[i]=(LL)suf[i+1]*(p[i].ff-i+1)%mod;
	
	int cur=1,ans=0,cnt=0;
	for(int i=1;i<=n;i++)
	{
		int val1=query(n),val2=query(p[i].ss);val1-=val2;if(val1<0)val1+=mod;
		ans=(ans+(LL)(val2-val1+mod)*suf[i+1]%mod*cur)%mod;
		if(p[i].ff==i)
		{
			roll_back();
			cur=1;
		}
		else
		{
			int v=(LL)pre[i]*qpow(cur,mod-2)%mod;
			add(p[i].ss,v);
			vs.pb(mp(p[i].ss,v));
			cur=(LL)cur*(p[i].ff-i)%mod;
		}
	}
	if(ans&1)ans+=mod;ans>>=1;
	
	memset(bit,0,sizeof(bit));
	for(int i=1;i<=n;i++)
	{
		cnt+=i-1-query(p[i].ss);if(cnt>=mod)cnt-=mod;
		add(p[i].ss,1);
	}
	ans=(ans+(LL)pre[n]*cnt)%mod;
	printendl(ans);
	return 0;
}

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

int main(void){
  string s;
  cin >> s;
  int res = 0;
  for(int i = 1;i < (int)s.size();++i){
    if(s[i] != s[i-1])++res;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 512
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            char[] s = Console.ReadLine().ToCharArray();
            if(Judge(s))
            {
                Console.WriteLine("AC");
            }
            else
            {
                Console.WriteLine("WA");
            }

        }
        static bool Judge(char[] s)
        {
            int C_count = 0;
            int C_index = 0;
            if (s[0] != 'A')
            {
                return false;
            }
            for (int i = 2; i < s.Length - 1; i++)
            {
                if (s[i] == 'C')
                {
                    C_count += 1;
                    C_index = i;

                    if(C_count > 1)//Cが二個以上
                    {
                        return false;
                    }

                }
            }
            if(C_count != 1)
            {
                return false;
            }
            for (int i = 1;i<s.Length;i++)
            {
                if (i != C_index)
                {
                    if (Char.IsUpper(s[i]))
                    {
                        return false;
                    }
                }
            }
            return true;
        }


    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
char s[15];
string c[N];
int n,tot;
int main()
{
	scanf("%d",&n);
	tot=0;
	for(int i=0;i<n;++i){
		scanf("%s",s);
		c[i]=s;
	}
	sort(c,c+n);
	int mx=-1,num=1;
	for(int i=0;i<n;++i){
		if(c[i]==c[i+1]) num++;
		else{
			if(mx<num) mx=num;
			num=1;
		}
	}
	num=1;
	for(int i=0;i<n;++i){
		if(c[i]==c[i+1]) num++;
		else{
			if(num==mx) printf("%s\n",c[i].c_str());
			num=1;
		}
	}
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mkp make_pair
#define mod 1000000007
#define vi vector<int>
#define si set<int>
#define pi pair<int,int>
#define li list<int>
#define fi first
#define se second
#define fr(i,n) for(i = 0 ; i < n ; i++)
int main()
{
    fio
    int n,w,i,j,k;
    ll x,y;
    cin>>n>>w;
    vector<pair<int,ll> > v;
    fr(i,n)
    {
        cin>>x>>y;
        v.pb(mkp(x,y));
    }

    ll dp[n+1][w+1];
    fr(i,n+1)
    dp[i][0] = 0;
    fr(i,w+1)
    dp[0][i] = 0;
    for(i = 1 ; i <= n ; i++)
    {
        for(j = 1 ; j<= w ; j++)
        {
            if(v[i-1].fi > j)
                dp[i][j] = dp[i-1][j];

            else
                dp[i][j] = max(dp[i-1][j] ,v[i-1].se+dp[i-1][j-v[i-1].fi]);
        }

    }
/*fr(i,n+1)
{
    fr(j,w+1)
    cout<<dp[i][j]<<" ";
    cout<<endl;
}*/
    cout<<dp[n][w];

    return 0;
}


Measured memory_bytes: 79232
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const int N=100010;
int main()
{
    IO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        if(s.back()=='s') s+="es";
        else s+="s";
        cout<<s<<'\n';
    }
    return 0;
}

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

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define all(x)  x.begin(),x.end()
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
/*
think fast
think simple
*/
void mysol()
{
	int n; cin >> n;
	int a = 1000;
	while (a < n)
		a += 1000;
	cout << a - n << endl;
}

int32_t main()
{
	fast();
	// w(t)
	{
		mysol();
	}
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
using namespace std;
int main()
{
	char c;
	cin >> c;
	char check[] = {'a', 'e', 'i', 'o', 'u'};
	for(int i = 0; i < 5; i++)
	{
		if(c == check[i])
		{
			cout << "vowel" << endl;
			return 0;
		}
	}
	cout << "consonant" << endl;
	return 0;
}



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


using Graph = vector<vector<int>>;//グラフ型
void dfs(const Graph& G, int v/*根*/, vector<bool>& seen) {
	seen[v] = true;  //vを訪問済にする
	for (auto next_v : G[v]) { //訪問済にしたvとつながっている場所を順番に探す
		if (seen[next_v]) continue; //もし探索済みならスルー
		dfs(G, next_v, seen); //再帰的に探索
	}
}

void bfs(const Graph& G, queue<int>& que/*発見したが訪問はしていない*/, vector<int>& dist/*開始地点からの距離*/) {
	
	while (!que.empty()) {
		int v = que.front();//queのうち先頭のものからスタート
		que.pop();//先頭を削除

		for (int nv : G[v]) {//vとつながっている点を列挙
			if (dist[nv] != -1) continue;//発見済(=距離が格納されている)であればスルー
			dist[nv] = dist[v] + 1;//vとつながっている点に距離の情報を追加
			que.push(nv);//vとつながっている点を発見済にする
		}
	}
}

template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}


template<typename T>
bool same(T x_b, T x_e, T y_b, T y_e) {
	for (auto i = x_b, j = y_b; i != x_e && j != y_e; ++i, ++j) {
		if (*i != *j) {
			return false;
		}
	}
	return true;
}

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	cout << c <<" "<< a <<" "<< b;
}

/*
*/


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

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

int main(void){
    long long N;
    cin>>N;
    long long ans=0;
    ans=(N*(N-1))/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def maxValue(a,b,v):
	for i in range(v,-1,-1):
		for j in range(v//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i

a,b,c,d,e,f = list(map(int, input().split()))

waVa = maxValue(a*100,b*100,f)
suVa = maxValue(c,d,min(f-waVa,waVa*e//100))
maxR = 0

anw = waVa
ans = suVa

while 1:
	waVa = maxValue(a*100,b*100,waVa-1)
	suVa = maxValue(c,d,min(f-waVa,waVa*e//100))
	if waVa == 0:
		break
	if maxR<10000*suVa//(suVa+waVa):
		maxR = 10000*suVa//(suVa+waVa)
		anw = waVa
		ans = suVa

print(anw+ans,ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define mp(a, b) make_pair(a, b)
const int maxn = 1e5 + 10;
typedef long long ll;
struct Node
{
	int x, y, id;
}a[maxn];
struct Edge
{
	int u, v, w;
	Edge() {}
	Edge(const int & _u, const int & _v, const int & _w) : u(_u), v(_v), w(_w) {} 
};
int fa[maxn], n;
int getfa(int x) { return x == fa[x] ? x : fa[x] = getfa(fa[x]);}
vector<Edge> E;
bool cmpx(const Node & i, const Node & j) { return i.x < j.x;}
bool cmpy(const Node & i, const Node & j) { return i.y < j.y;}
bool cmpw(const Edge & i, const Edge & j) { return i.w < j.w;}
int kru()
{
	ll ans = 0;
	for(int i = 1; i <= n; ++i) fa[i] = i;
	for(auto e : E)
	{
		int u = e.u, v = e.v, w = e.w;
		u = getfa(u), v = getfa(v); 
		if(u == v) continue;
		ans += w;
		fa[u] = v;
	}
	return ans;
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%d%d", &a[i].x, &a[i].y);
		a[i].id = i;
	}
	sort(a + 1, a + n + 1, cmpx);
	for(int i = 2; i <= n; ++i) E.emplace_back(a[i - 1].id, a[i].id, a[i].x - a[i - 1].x);
	sort(a + 1, a + n + 1, cmpy);
	for(int i = 2; i <= n; ++i) E.emplace_back(a[i - 1].id, a[i].id, a[i].y - a[i - 1].y);
	sort(E.begin(), E.end(), cmpw);
	cout << kru() << endl;
	return 0;
}

Measured memory_bytes: 7644
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int cnt[15];

void ng() {
	cout << 0 << "\n";
	exit(0);
}

void solve() {
	int N;
	cin >> N;
	cnt[0]++;
	rep(i, 0, N) {
		int a; cin >> a;
		cnt[a]++;
	}
	vi vec;
	vec.pb(0);
	if(cnt[0] >= 2 || cnt[12] >= 2) ng();
	if(cnt[12]) vec.pb(12);
	vi left;
	rep(i, 1, 12) {
		if(cnt[i] >= 3) ng();
		else if(cnt[i] == 2) {
			vec.pb(i); vec.pb(24 - i);
		}
		else if(cnt[i] == 1) left.pb(i);
	}
	int M = sz(left);
	int res = 0;
	rep(bit, 0, 1 << M) {
		vi tmp = vec;
		rep(i, 0, M) {
			if(bit & (1 << i)) tmp.pb(left[i]);
			else tmp.pb(24 - left[i]);
		}
		int d = 24;
		sort(all(tmp));
		rep(i, 0, sz(tmp)) {
			MIN(d, (24 + tmp[(i + 1) % sz(tmp)] - tmp[i]) % 24);
		}
		// debug(tmp);
		MAX(res, d);
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

const int MAX_N = 100000, INF = 10000000000;
int li[MAX_N];
int N;

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

int main() {
	int ans = INF;
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d", &li[i]);
	for (int i = 0; i < N-1; i++) {
		if (gcd(li[i], li[i + 1]) < ans) ans = gcd(li[i], li[i + 1]);
	}

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

	return 0;
}

Measured memory_bytes: 640
from collections import deque
import sys
inputs = sys.stdin.readline
N,M = map(int,input().split())
UV = [tuple(map(lambda x:int(x)-1,inputs().split())) for i in range(M)]
S,T = map(lambda x:int(x)-1,input().split())

es = [[] for i in range(3*N)]
for u,v in UV:
    es[u].append(v+N)
    es[u+N].append(v+2*N)
    es[u+2*N].append(v)

q = deque([S])
INF = float('inf')
dist = [INF] * (3*N)
dist[S] = 0

while q:
    v = q.popleft()
    for to in es[v]:
        if dist[to] != INF: continue
        dist[to] = dist[v] + 1
        if to==T:
            print(dist[to] // 3)
            exit()
        q.append(to)
print(-1)

Measured memory_bytes: 70468
#include <stdio.h>
#include <string.h>
 
#define MAX 244140625
 
int Hash[MAX];
char str[5];
 
int getChar(char);
int getKey();
int find();
void insert();
 
int main(){
  int n;
  char com[7];
 
  scanf("%d" ,&n);
  while(n--){
    scanf("%s %s" ,com ,str);
 
    if(com[0] == 'i'){
      insert(str);
    }else{
      if(find(str)){
    puts("yes");
      }else{
    puts("no");
      }
    }
  }
 
  return 0;
}
 
int getChar(char ch){
  if(ch == 'A'){
    return 1;
  }else if(ch == 'C'){
    return 2;
  }else if(ch == 'G'){
    return 3;
  }
  return 4;
}
 
int getKey(char str[]){
  int sum = 0, p = 1, i;
 
  for(i = 0 ; i < strlen(str) ; i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
 
int find(char str[]){
  int key = getKey(str);
 
  if(Hash[key]){
    return 1;
  }
 
  return 0;
}
 
void insert(char str[]){
  Hash[getKey(str)] = 1;
}


Measured memory_bytes: 18600
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    string s , t;
    cin >> s >> t;
    if(t.size() != s.size() + 1){
        cout << "No\n";
        return 0;
    }

    for(int i = 0 ; i < s.size() ; i++){
        if(s[i] != t[i]){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define LIM 1<<17
/// TONI BO$$ was here
/// #MLC

using namespace std;
char BUF[LIM];
int poz;

inline char getChar(){
    poz++;
    if(poz>=LIM){
    	fread(BUF,LIM,1,stdin);
    	poz=0;
    }
    return BUF[poz];
}

inline int getNr(){
    int r=0, semn=1;
    char ch=getChar();
    while(isdigit(ch)==0 && ch!='-') ch=getChar();
    if(ch=='-'){
        semn=-1;
        ch=getChar();
    }
    while(isdigit(ch)!=0){
        r=r*10+semn*(ch-'0');
        ch=getChar();
    }
    return r;
}

int main()
{
    int n,x;
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    scanf("%d",&n);
    x=0;
    while(n)
    {
        if(n%10==2)
            x++;
        n/=10;
    }
    printf("%d",x);

    return 0;
}


Measured memory_bytes: 384
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    A, B = input_nums()
    if A >= 13:
        fee = B
    elif A >= 6:
        fee = B//2
    else:
        fee = 0
    print(fee)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<numeric>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
typedef long double ld;

//typedef acos(-1) PI;

#define PI acos(-1)

int main(){
	int n;
	cin>>n;
	ld ans=2*PI*n;
	printf("%.9Lf\n",ans);
	//cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdio.h>
#include <string.h>
using namespace std;

struct Graph {
    struct Edge { int i; };
    struct Vertex { int c, d, k; };
    struct VertexInfo { int i, d; };
    Graph(int n) : e(n), v(n, { 0, -1, -1 }) {}
    void add_edge(int i, int j) {
        e[i].push_back({ j });
    }
    void foo(int i0, int d0, int c, int k) {
        queue<VertexInfo> q;
        q.push({ i0, d0 });
        while (!q.empty()) {
            auto vi = q.front(); q.pop();
            int i = vi.i, d = vi.d;
            if (v[i].k == k || d <= v[i].d) continue;
            if (v[i].c == 0) v[i].c = c;
            v[i].d = d;
            v[i].k = k;
            for (Edge o : e[i]) {
                q.push({ o.i, d - 1 });
            }
        }
    }
    vector<vector<Edge>> e;
    vector<Vertex> v;
};

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

    int n, m;
    cin >> n >> m;
    Graph g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g.add_edge(a, b);
        g.add_edge(b, a);
    }
    int q;
    cin >> q;
    vector<int> v(q), d(q), c(q);
    for (int i = 0; i < q; i++) {
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }

    for (int i = q - 1; i >= 0; i--) {
        g.foo(v[i], d[i], c[i], i);
    }

    for (int i = 0; i < n; i++) {
        printf("%d\n", g.v[i].c);
    }

    return 0;
}

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

int main() {
	long long a,b,c;
	cin>>a>>b>>c;
	if(a%2==0 || b%2==0 || c%2==0) cout<<"0"<<'\n';
	else {long long mini=min(min(c*a,a*b),c*b);
	cout<<mini<<'\n';}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if (a > b)
    {
        printf("a > b");
    }
    else
    {
        if (a < b)
        {
            printf ("a < b");
        }
        else
        {
            printf ("a == b");
        }
    }
    printf("\n");
    return 0;
}


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

const int INF = 0x3f3f3f3f;
const int N = 100123;

int p[N], q[N], r[N];

int main()
{
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	rep(i, a) scanf("%d", p+i);
	rep(i, b) scanf("%d", q+i);
	Rep(i, c) scanf("%d", r+i);
	sort(p, p+a);
	sort(q, q+b);
	sort(r+1, r+c+1);
	int z = c;
	x = a - x; y = b - y;
	p[a] = INF; q[b] = INF;
	LL ans = 0;
	while(p[x] < r[z] || q[y] < r[z]) {
		if(p[x] < q[y]) ++x;
		else ++y;
		ans += r[z--];
	}
	while(x < a) ans += p[x++];
	while(y < b) ans += q[y++];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
/* Made by Takauov Yerzhan - 31/01/2020 */
#include <bits/stdc++.h>
#define enter endl
#define LL long long
#define LD long double
#define UL unsigned long long
#define Okoshka ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define F first
#define S second

using namespace std;

const LL MXN = 3e5 + 7;
const LL MOD = 1e9 + 7;
const LL INF = 1e18 + 7;

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

LL n, k, a[MXN], sum;

int main()
{
    ///Okoshka;
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    if(k >= n){
        cout << 0;
        return 0;
    }
    for(int i = k + 1; i <= n; i++){
        sum += a[i];
    }
    cout << sum;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    ll A, B, T;
    cin >> A >> B >> T;
    ll ans = 0;
    REP(i, 100) {
        ll a = (i + 1) * A;
        if (a > T)
            break;
        ans += B;

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

Measured memory_bytes: 256
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    for0(i,n) for(int i=0;i<n;i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    Sort(s) sort(s.begin(),s.end())
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long int
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
	
    int n;
    cin>>n;
    cout<<360/gcd(n,360);
    
End;
}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 2e3 + 10;
const int inf = 0x3f3f3f3f;

int n, x, y;
vector<int> adj[maxn];
int cnt[maxn];
int d[maxn][maxn];

void bfs(int x){
  queue<int> q;
  q.push(x);
  d[x][x] = 0;
  while (not q.empty()){
    int u = q.front();
    q.pop();
    for (auto v : adj[u]){
      if (d[x][v] > d[x][u] + 1) {
        q.push(v); d[x][v] = d[x][u] + 1;
      }
    }
  }
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
  cin >> n >> x >> y;
  for (int i = 1; i < n; ++i){
    adj[i].push_back(i + 1);
    adj[i + 1].push_back(i);
  }
  adj[x].push_back(y); adj[y].push_back(x);
  memset(d, 0x3f3f3f3f, sizeof d);
  for (int i = 1; i <= n; ++i){
    bfs(i);
  }
  for (int i = 1; i < n; ++i)
    for (int j = i + 1; j <= n; ++j) cnt[d[i][j]]++;
  for (int i = 1; i < n; ++i) cout << cnt[i] << '\n';
return 0;
}



Measured memory_bytes: 16128
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char **argv)
{
	int s;
	double w, h;

	while (scanf("%d,%lf,%lf", &s, &w, &h) != EOF)
	{
		if (w / (h * h) >= 25.0)
			printf("%d\n", s);
	}

	return 0;
}

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

int main() {
  int a, b;
  cin >> a >>b;
  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

int main()
{

	int n, i;
	double x[101],y[101],d;
	double Dxy,Dxy2,Dxy3,Dxyp;	
	
	cin>>n;
	
	for( i=0; i<n; i++ ) {
		cin>>x[i];
	}
	for( i=0; i<n; i++ ) {
		cin>>y[i];
	}
	
	
	Dxy=Dxy2=Dxy3=Dxyp=0;
	for( i=0; i<n; i++ ) {
		d = abs( x[i]-y[i] );
		
		Dxy += d;
		Dxy2 += pow( d, 2 );
		Dxy3 += pow( d, 3 );
		Dxyp = max( Dxyp, d );
	}
	
	cout.setf( ios::fixed );
	cout<<Dxy<<endl<<sqrt(Dxy2)<<endl<<cbrt(Dxy3)<<endl<<Dxyp<<endl;
	
	return 0;
}


Measured memory_bytes: 3424
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>

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

using namespace std;

int main()
{
	
	int n,m,ans,d;
	while(cin >> n && n)
	{
		cin >> m >> ans >> d;

		string *s = new string[d];
		rep(i,d)
		{
			cin >> s[i];
		}
		int place = m;

		rep(i,d)
		{
			if(place == 1)
			{
				if(s[i][0] == '1') place = 2;
			}
			else if(place == n)
			{
				if(s[i][n-2] == '1') place = n-1;
			}
			else
			{
				if(s[i][place-2] == '1') place -= 1;
				else if(s[i][place-1] == '1') place += 1;
			}
		}

		if(place == ans)
		{
			cout << 0 << endl;
		}
		else
		{
			int a[2];
			bool flag = true;
		
			rep(i,d)
			{
				rep(j,n-1)
				{
					if(flag)
					{
						if(s[i][j] == '0')
						{
							bool temp = true;

							if(j == 0)
							{
								if(s[i][j+1] == '1') temp = false;
							}
							else if(j == n-2)
							{
								if(s[i][n-3] == '1') temp = false;
							}
							else
							{
								if(s[i][j-1] == '1' || (s[i][j+1] == '1')) temp = false;
							}

							if(temp)
							{
								s[i][j] = '1';
								int place2 = m;

								rep(k,d)
								{
									if(place2 == 1)
									{
										if(s[k][0] == '1') place2 = 2;
									}	
									else if(place2 == n)
									{
										if(s[k][n-2] == '1') place2 = n-1;
									}
									else
									{
										if(s[k][place2-2] == '1') place2 -= 1;
										else if(s[k][place2-1] == '1') place2 += 1;
									}
								}
								if(place2 == ans)
								{
									flag = false;
									a[0] = i+1;
									a[1] = j+1;
									break;
								}
								s[i][j] = '0';
							}						
						}
					}
				}
			}
			if(flag == false)
			{
				cout << a[0] << " " << a[1] << endl;
			}
			else
			{
				cout << 1 << endl;
			}
		}
	}
	return 0;
}

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

public class Main {
    int n;
    int[] ds;
    int[] cnts = new int[13];
    boolean[] ts = new boolean[24];
    int ans = -1;
    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        ds = new int[n];
        cnts[0]++;
        for (int i = 0 ; i < n; i++) {
            ds[i] = sc.nextInt();
            cnts[ds[i]]++;
        }
    }

    private void solve() {
        ts[0] = true;
        int mx = Arrays.stream(cnts).max().getAsInt();
        if (mx >= 3 || cnts[0] >= 2) {
            System.out.println(0);
            return;
        }
        ArrayList<Integer> ls = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (cnts[ds[i]] == 2) {
                ts[ds[i] % 24] = true;
                ts[(24 - ds[i]) % 24] = true;
            }
            else {
                ls.add(ds[i]);
            }
        }
        int[] as = new int[ls.size()];
        for (int i = 0; i < as.length; i++)
            as[i] = ls.get(i);
        dfs(0, as);
        System.out.println(ans);

    }

    private void dfs(int i, int[] as) {
        if (i == as.length) {
            calc();
            return;
        }
        ts[as[i] % 24] = true;
        dfs(i+1, as);
        ts[as[i] % 24] = false;
        ts[(24 - as[i]) % 24] = true;
        dfs(i+1, as);
        ts[(24 - as[i]) % 24] = false;
    }

    private void calc() {
        int mn = 13;
        int old = 0;
        for (int i = 1; i < ts.length; i++) {
            if (!ts[i])
                continue;
            mn = Math.min(mn, i - old);
            old = i;
        }
        mn = Math.min(mn, 24 - old);
        ans = Math.max(ans, mn);
    }
}


Measured memory_bytes: 28756
#include <stdio.h>
int main(void){
  int k,n,s[100],i,min,max,sum;
  for(k = 0; k < 20; k++){
  scanf("%d", &n);
  if(n == 0) break;
  for(i = 0; i < n; i++){
      scanf("%d", &s[i]);
  }
  min = s[0];
  max = s[0];
  sum = 0;
  for(i = 0; i < n; i++){
      if(min > s[i]){
          min = s[i];
      }
      if(max < s[i]){
          max = s[i];
      }
      sum += s[i];
  }
  printf("%d\n", (sum - min - max)/(n -2));
  }
  return 0; 
}



Measured memory_bytes: 2028
N,M=map(int,input().split())
A=[]
for i in range(N):
    a=input()
    A.append(a)
B=[]
for i in range(M):
    b=input()
    B.append(b)
a=""
b=""
for i in range(M):
    b=b+B[i]
l=[]
for i in range(N):
    if (i+M)>N:
        break
    for j in range(N):
        if (j+M)>N:
            break
        c=""
        for n in range(i,i+M):
            for m in range(j,j+M):
                    c+=A[n][m]
        l.append(c)
ok=False

for i in range(len(l)):
    if b==l[i]:
        ok=True
if ok:
    print("Yes")
else:
    print("No")

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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

int main(){
	//input
	ll N; cin>>N;
	vector<ll>H(N);
	rep(i,N) cin>>H[i];

	ll mem=H[0];
	ll cnt=0,ans=0;
	rep(i,N){
		if(H[i]<=mem){
			cnt++;
			mem=H[i];
		}
		else{
			chmax(ans,cnt-1);
			mem=H[i];
			cnt=1;
		}
		//cout<<cnt<<mem<<endl;
	}
	chmax(ans,cnt-1);
	//output
	cout<<ans;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

int main(){
    double N,M,X;
    scanf("%lf", &N);

    X = ceil(N / 1.08);
    M = floor(1.08 * X);
    if(M == N){
        printf("%.0lf", X);
    }else{
        printf(":(");
    }

    return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s, p string
	fmt.Scan(&s)
	fmt.Scan(&p)
	if strings.Contains(strings.Repeat(s, 2), p){
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}


Measured memory_bytes: 1152
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    vector<int> P(N);
    vector<int> M(N);
    rep(i,N) {
        cin >> P.at(i);
    }

    int sum = 1;
    int cur = P[0];
    for (int i = 1; i < N; i++) {
        if (P[i] <= cur) {
            sum++;
            cur = P[i];
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int lli;
const lli mod = 998244353;
const int inf = 1e9;

int main(){
	int k,n;
	cin >> k >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	a.push_back(k+a[0]);
	int ans = inf;
	for(int i=0; i<n; i++){
		ans = min(ans, k-(a[i+1]-a[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import sys
readline = sys.stdin.readline

N, X = map(int, input().split())

q_array = []
s_array = []

score_needed = 0

for i in range(N):
    b, l, u = map(int, readline().split())
    q_array.append([b, l, u, b * l + (X - b) * u])
    s_array.append(b * l + (X - b) * u)
    score_needed += b * l

q_array = sorted(q_array, key=lambda x: -x[3])
s_array = sorted(s_array, key=lambda x: -x)
sum_array = []
ss = 0
for s in s_array:
    ss += s
    sum_array.append(ss)
ans_min = 0
ans_max = N * X
if score_needed == 0:
    print(0)
    exit()
while ans_max - ans_min > 1:
    ans = (ans_min + ans_max) // 2
    use_all = ans // X
    use_part = ans % X
    # print(use_all, use_part)
    score_get_max = 0
    score_tmp = 0
    if use_part == 0:
        score_get_max = sum_array[use_all - 1]
    else:
        score_get_max = 0
        score_tmp = 0
        for q in q_array:
            b, l, u, s = q
            score_tmp = 0
            if use_part <= b:
                score_tmp = use_part * l
            else:
                score_tmp = (b * l + (use_part - b) * u)
            if use_all > 0:
                if s_array[use_all - 1] <= s:
                    score_tmp += (sum_array[use_all] - s)
                else:
                    score_tmp += sum_array[use_all - 1]
            score_get_max = max(score_get_max, score_tmp)
    # print(ans, score_get_max)
    if score_get_max >= score_needed:
        ans_max = ans
    else:
        ans_min = ans

print(ans_max)


Measured memory_bytes: 80092
from sys import stdin
nii=lambda:map(int,stdin.readline().split())

def main():
  n,m=nii()

  tree=[[] for i in range(n)]
  for i in range(m):
    a,b=nii()
    a-=1
    b-=1
    tree[a].append(b)
    tree[b].append(a)

  for i in tree[0]:
    for j in tree[i]:
      if j==n-1:
        print('POSSIBLE')
        exit()
  print('IMPOSSIBLE')

if __name__=="__main__":
  main()

Measured memory_bytes: 38320
def main():
    a, b = map(int, input().split())
    count = 0
    for i in range(a, b + 1):
        data = str(i)
        data_rev = data[::-1]
        if data == data_rev:
            count += 1
        # print(data, data_rev)

    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 40428
n=int(input())
import math
count=0
a=1
b=1
c=1
for i in range(n):
    for j in range(n):
        for m in range(n):
            k=math.gcd(a,b)
            l=math.gcd(k,c)
            count+=l
            c+=1
        c=1
        b+=1
    b=1
    a+=1
print(count)

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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("lld", &x); return (x); }

int main()
{
	int n;
	char num[9];
	n = in();

	loop(i, 0, n)
	{
		scanf("%s", num);
		int maxNum = 0;
		int minNum = 0;
		sort(num, num + 8);
		loop(j, 0, 8)
		{
			minNum = minNum * 10 + (num[j] - '0');
		}
		sort(num, num + 8, greater<char>());
		loop(j, 0, 8)
		{
			maxNum = maxNum * 10 + (num[j] - '0');
		}
		printf("%d\n", maxNum - minNum);
	}
	return (0);
}

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

int main(){
    int X,Y;
    cin>>X>>Y;
    cout << X+(Y/2) << endl;
}


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

void trace(int A[], int N){
    for(int i=0;i<N;i++){
        if(i) cout << " " ;
        cout << A[i];
    }
    cout << endl;
}
void insertionSort(int A[], int N){ // N個の要素を含む0-オリジンの配列A
  for(int i=1;i<N;i++){
    int v = A[i];
    int j = i - 1;
    while (j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
  trace(A,N);
  }
} 

int main(){
    int N,A[100];
    cin >> N;
    for(int i;i<N;i++) cin >> A[i];
    
    trace(A,N);
    insertionSort(A,N);
    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

// 100で何回割り切れるかを返す
int calc(int x) {
	int ret = 0;
	while(x % 100 == 0) {
		x /= 100;
		ret++;
	}
	return ret;
}
int main() {
	int d, n; cin >> d >> n;
	int cnt = 0, x = 0;
	while(cnt < n) {
		x++;
		if(calc(x) == d) cnt++;
	}
	cout << x << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
// #define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(12);const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=2e5+5,M=998244353;
struct pt{
    int x,y,i;
    bool operator<(const pt&p)const{return x<p.x;}
}a[N];
int n;
int t[N];
int get(int i){
    int res=0;
    for(;i>=0;i=(i&(i+1))-1)res+=t[i];
    return res;
}
void add(int i,int x){for(;i<n;i|=i+1)t[i]+=x;}
int ys[N];
int res[N];
int pw[N];
void f(){
    forn(i,n)ys[i]=a[i].y;
    sort(ys,ys+n);
    sort(a,a+n);
    forn(i,n)t[i]=0;
    forn(i,n){
        int y=lower_bound(ys,ys+n,a[i].y)-ys;
        res[a[i].i]+=pw[get(y-1)];
        add(y,1);
    }
    reverse(a,a+n);
    forn(i,n)t[i]=0;
    forn(i,n){
        int y=lower_bound(ys,ys+n,a[i].y)-ys;
        res[a[i].i]+=pw[get(y-1)];
        add(y,1);
    }
}
int32_t main(){
    cin>>n;
    pw[0]=1;
    for(int i=1;i<=n;++i)pw[i]=pw[i-1]*2%M;
    forn(i,n){
        cin>>a[i].x>>a[i].y;
        a[i].i=i;
        res[i]=pw[n]-1;
    }
    sort(a,a+n);
    forn(i,n){
        res[a[i].i]-=pw[i];
        res[a[i].i]-=pw[n-i-1];
        swap(a[i].x,a[i].y);
    }
    sort(a,a+n);
    forn(i,n){
        res[a[i].i]-=pw[i];
        res[a[i].i]-=pw[n-i-1];
        swap(a[i].x,a[i].y);
    }
    f();
    forn(i,n)a[i].y*=-1;
    f();
    int ans=0;
    forn(i,n)ans+=res[i];
    ans%=M;
    ans+=M;
    ans%=M;
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 11264
#include <stdio.h>

int main()
{
    int x,y;
    scanf("%d %d ", &x, &y);
    
    for(int i = 0; i <= x; i++)
    {
        if(y == i * 2 + (x - i) * 4)
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

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

flag = True

for i in range(n):
    if a[i] % 2 == 0 and (a[i] % 3 == 0 or a[i] % 5 == 0):
        flag = True
    elif a[i] % 2 == 1:
        flag = True
    else:
        flag = False
        break
print("APPROVED" if flag else "DENIED")

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <math.h>

using namespace std;
typedef long long int ll;
ll MOD = pow(10,9) + 7;

ll solve(vector<ll>& kids,ll K)
{
    ll n = kids.size();

    vector<vector<ll>> dp(n+1,vector<ll>(K+1));
    vector<ll> rs(K+1,1);
    vector<ll> nex_rs(K+1);
    nex_rs[0] = 1;

    for (int i=0;i<=n;++i)
    {
        dp[i][0] = 1;
    }

    for (int i=1;i<=n;++i)
    {
        //cout<<"KIDS:"<<i<<endl;
        //for (auto i:rs) cout<<i<<" ";
        
        vector<ll> rs(K+1);
        rs[0] = 1;
        for (int x=1;x<=K;++x)
        {
            rs[x] = rs[x-1] + dp[i-1][x];
        }
        
        for (int can=1;can<=K;++can)
        {
            /**
            if (can < i)
            {
                nex_rs[can]  = 1;
                continue;
            }
            **/

            //cout<<endl;

            ll upto = can - kids[i-1] - 1;
            dp[i][can] = rs[can];
            
            if (upto>=0) dp[i][can] -= rs[upto];
            dp[i][can] %= MOD;
            //nex_rs[can] = (nex_rs[can-1] + dp[i][can]) % MOD;
        }

        //rs = nex_rs;
    }
    /**
    for (auto v:dp)
    {
        for (auto i:v)
        {
            cout<<i<<" ";
        }
        cout<<endl;
    }
    **/
    return dp[n][K];
}

int main()
{
    int N,K;
    cin>>N>>K;
    vector<ll> kids(N);

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

    cout<<solve(kids,K)<<endl;

    return 0;
}


Measured memory_bytes: 84592