akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=1010;
int n,h,f[N],deg[N],vis[N];
int find(int x) { return f[x]==x?x:f[x]=find(f[x]); }
int a,b,c,d;
void add(int pl,int pr) {
	deg[pl]--; deg[pr]++;
	vis[pl]=vis[pr]=1;
	f[find(pl)]=find(pr);
}
int main() {
	scanf("%d%d",&n,&h);
	rep(i,0,2*h+2) f[i]=i;
	rep(i,0,n) {
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int pl=(c==0)?a:c+h+1;
		int pr=(d==0)?b+h+1:d;
		add(pl,pr);
	}
	rep(i,0,h+1) if (deg[i]>0) {
		puts("NO");
		return 0;
	}
	rep(i,h+1,2*h+2) if (deg[i]<0) {
		puts("NO");
		return 0;
	}
	rep(i,0,h+1) if (vis[i]) {
		bool val=0;
		rep(j,0,2*h+2) if (find(i)==find(j)&&deg[j]<0) val=1;
		if (!val) { puts("NO"); return 0;}
	}
	rep(i,h+1,2*h+2) if (vis[i]) {
		bool val=0;
		rep(j,0,2*h+2) if (find(i)==find(j)&&deg[j]>0) val=1;
		if (!val) { puts("NO"); return 0;}
	}
	puts("YES");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  cin>>n;
  vector<long long> a(n);
  for(int i=0;i<n;i++){
  	cin>>a[i];
  }
  sort(a.begin(),a.end());
  for(int i=2;i<n;i++){
  	for(int j=1;j<i;j++){
    	for(int k=0;k<j;k++){
        	if(a[i]==a[j]||a[j]==a[k]) continue;
            if(a[i]<a[j]+a[k]) ans++;
        }
    }
  }
  cout<<ans;
}

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

int main() {
  string s;
  cin >> s;
  int ans=0;
  int max=0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='A' | s[i]=='G' | s[i]=='C' | s[i]=='T' ){
      max++;
    }
    else{
      max=0;
    }

    if(ans<max){
      ans=max;
    }

  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())

a = N
S_list = []
if a == 0:
    S_list.append(a)
while a != 0:
    Si = a % (-2)
    a //= (-2)
    if Si == -1:
        a += 1
        Si = 1
    S_list.append(Si)


S = ''.join([str(i) for i in S_list[::-1]])
print(S)


Measured memory_bytes: 9120
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
using namespace std;
typedef long long LL;
template<typename T>inline void read(T &x){
    x=0;T w=1,ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
    x=x*w;
}
inline void File(){
    freopen("fuck.in","r",stdin);
    freopen("fuck.out","w",stdout);
}

#include<cmath>
inline bool check(LL p){
	if(sqrt(p)==(LL)sqrt(p))return 1;
	return 0;
}
int main(){
	//File();
	int q;
	read(q);
	while(q--){
		LL x,y;
		read(x);read(y);
		LL v=(LL)sqrt(x*y);
		LL ans=(LL)sqrt(x*y)*2LL-1LL;
		if(check(x*y)&&x!=y)ans--;
		if(v*(v+1)>=x*y)ans--;
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 256
/*
    2020.6.11
    Ве№И 1379
    LTC
*/
#include <bits/stdc++.h>
#define mem(f, x) memset( f, x, sizeof(f) )
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mk(x, y) make_pair(x, y)
#define fi first
#define se second
#define pk push_back
typedef long long LL;
using namespace std;
const int M = 1005;
const int N = 1005;
int m, n;
int a[N];

int main( ){
    while( scanf( "%d %d", &n, &m ) != EOF ){
        for( int i = 0; i < n; i++ )
            scanf( "%d", a+i );
        sort( a, a+n );
        int ans = 0;
        for( int i = 0; i < m; i++ )
            ans += a[i];
        printf( "%d\n", ans );
    }
    return 0;
}


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

using namespace std;

int main()
{
 string s, t;
 cin>>s;
 cin>>t;
 int m=0;
 for(int i=0; i<s.size(); i++)
 {
  if(t[i] != s[i])	m++; 
 }
  cout<<m;
  
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,t,t2;
	scanf("%d %d %d",&a,&b,&c);
	if(b>c)
	{
		t=b;
		b=c;
		c=t;
	}
	if(a>c)
	{
		t=a;
		a=c;
		c=t;
	}
	if(a>b)
	{
		t=a;
		a=b;
		b=t;
	}
	t=c*2-a-b;
	t2=t%2;
	t/=2;
	if(t2)
	{
		t+=2;
	}
	printf("%d",t);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace D_ABC167
{
    class MainClass
    {

        static int[] a;

        public static void Main(string[] args)
        {
            long[] s = Array.ConvertAll(ReadLine().Split().ToArray(), long.Parse);
            a = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int n = (int)s[0];
            int stt = a[0];
            int[] cnt = new int[n + 1];
            cnt[1]++;
            int rpt = 0;
            int sttloop = 0;
            for (int i = 2; i <= 2 * n; i++)
            {
                if (cnt[stt] >= 1)
                {
                    sttloop = cnt[stt];
                    rpt = i - cnt[stt];
                    break;
                }
                cnt[stt] += i;
                stt = a[stt - 1];
            }

            long dif = s[1];
            if (s[1] > s[0]) dif = (s[1]-sttloop) % rpt + sttloop;
            long ini = a[0];

            // WriteLine(sttloop);
            // WriteLine(rpt);
            // WriteLine(dif);

            for (long i = 1; i < dif; i++)
            {
                ini = a[ini - 1];
            }


            WriteLine(ini);


        }
    }
}


Measured memory_bytes: 45152
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
def LILI(n): return [LI() for _ in range(n)]
INF = 10 ** 18
MOD = 10 ** 9 + 7

'''MEMO:
1 or 2 が書かれている。
与えられた x, y, z について,
z が偶数なら A_x + A_y は偶数。つまり (1, 1) or (2, 2)
z が奇数なら上記は奇数。つまり (1, 2) or (2, 1)
最小何枚で確実にすべてわかるか。

結局 union-find して独立なグラフの個数を求める問題か。
'''

import collections
import itertools
import operator

class UnionFind:
    def __init__(self, elems=None):
        class KeyDict(dict):  # dict + キーがないときは dict[key] = key として key を返す。
            def __missing__(self, key):
                self[key] = key
                return key

        self.parent = KeyDict()  # キーがなければ孤立点→自身が key（parent[key]=key）
        self.rank = collections.defaultdict(int)  # 木の高さ。デフォルトでは 0。経路圧縮すると本来は rank が下がるが、その効果は無視している。
        self.size_ = collections.defaultdict(lambda: 1)  # 根に属する頂点の個数。根の値しか信用できない。

        if elems is not None:
            for elem in elems:
                _, _ = self.parent[elem], self.rank[elem]

    def find(self, x):  # あるキーの根を探す。O(α(n)). log より高速。
        if self.parent[x] == x:
            return x  # 自身が根なら自身を返す。
        else:
            self.parent[x] = self.find(self.parent[x])  # 再帰的に親を探して、すべて根に付け替える（経路圧縮）。
            return self.parent[x]

    def unite(self, x, y):  # O(α(n)). log より高速。
        x = self.find(x)  # x の根を求める。
        y = self.find(y)  # y の根を求める。
        if x == y:  # もともと同一の木なら何もしない。
            return
        if self.rank[x] < self.rank[y]:  # rank （木の高さ）の低いほうを高いほうに繋げたい。
            x, y = y, x
        self.parent[y] = x  # x の親を y にする。
        self.size_[x] += self.size_[y]
        if self.rank[x] == self.rank[y]:  # 同じ高さの木だったら片方の rank を1つ上げておく。
            self.rank[x] += 1

    def are_same(self, x, y):  # O(α(n)). log より高速。
        return self.find(x) == self.find(y)

    def size(self, x):  # O(α(n)). log より高速。
        return self.size_[self.find(x)]

    def grouper(self):
        roots = [(x, self.find(x_par)) for x, x_par in self.parent.items()]
        root = operator.itemgetter(1)
        for _, group in itertools.groupby(sorted(roots, key=root), root):
            yield [x for x, _ in group]


def main(): 
    N, M = LI()
    uf = UnionFind()
    for _ in range(M):
        X, Y, Z = LI()
        uf.unite(X, Y)
    for i in range(1, N+1):
        uf.unite(i,i)
    print(len(list(uf.grouper())))

main()

Measured memory_bytes: 121868
#include<iostream>
#include<algorithm>
int a[110],b[110];
int n;
struct Node
{   int l;
    int num;
}s[110];
bool zw(int a,int b,int c)
{  if(a+b>c) return 1;
   return 0;
}
using namespace std;
int main ()
{   cin>>n;
   for(int i=1;i<=n;i++)
   {   cin>>a[i];
       b[i]=a[i];
   }
   sort(a+1,a+1+n);
   sort(b+1,b+1+n);
   //for(int i=1;i<=n;i++) cout<<a[i]<<" "; cout<<endl;
    int m;
   m=unique(b+1,b+1+n)-(b+1);  //cout<<m<<endl;
   for(int i=1;i<=m;i++)
   {   s[i].l=b[i];
       s[i].num=0;
   }
   int j=1;
   for(int i=1;i<=n;i++)
   {   if(b[j]==a[i]) s[j].num++;
       else   {j++;s[j].num++;}
   }
   //for(int i=1;i<=m;i++)cout<<s[i].l<<" "<<s[i].num<<endl;
   int sum=0;
   for(int i=1;i<m-1;i++)
    for(int j=i+1;j<m;j++)
     for(int k=j+1;k<=m;k++)
      {  //cout<<i<<" "<<j<<" "<<k<<endl;
	  if(zw(s[i].l,s[j].l,s[k].l))  sum+=s[i].num*s[j].num*s[k].num;
      }
      cout<<sum<<endl;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int K = sc.nextInt();

		if (N % K == 0) {
			System.out.println(0);
		} else {
			System.out.println(1);
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << "\n";

    return 0;
}

Measured memory_bytes: 3548
def examB():
    N = I(); s = [S() for _ in range(N)]
    M = I(); t = [S() for _ in range(M)]
    d = defaultdict(int)
    for l in s:
        d[l] +=1
    for l in t:
        d[l] -=1
    ans = max(0,max(d.values()))
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 38256
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b);

int main()
{
  int a[5];
  scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]);
  qsort(a, 5, sizeof(int), compare_int);
  printf("%d %d %d %d %d\n", a[0], a[1], a[2], a[3], a[4]);
  return 0;
}

int compare_int(const void *a, const void *b)
{
  return *(int*)b-*(int*)a;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000'000'007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main() {
	IOS

	ll n;
	cin >> n;
	vector<ll> a(n + 1);
	vector<ll> b(n);
	for(auto& i : a){
		cin >> i;
	}

	for(auto& i : b){
		cin >> i;
	}
	ll res = 0;
	for(int i = 0; i < n; ++i){
		res += min(a[i],b[i]);
		b[i] -= min(a[i],b[i]);
		res += min(a[i + 1], b[i]);
		a[i + 1] -= min(a[i + 1], b[i]);
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

int main()
{
    char S[11];
    std::cin >> S;
    int count = 0, i = 0, max = 0;
    while(S[i] != '\0'){
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') count++;
        else count = 0;
        if(count > max) max = count;
        i++;
    }
    std::cout << max << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 109
using namespace std;
typedef long long ll;
int main(void)
{
    //freopen("in.txt","r",stdin);

    ll a;
    cin>>a;
    ll ans=0;
    for(ll i=1;i<=a;i++)
    {
        for(ll j=1;j<=a;j++)
        {
            for(ll k=1;k<=a;k++) ans+=__gcd(i,__gcd(j,k));
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int x,y;
    cin >> x >> y;
    x--;y--;
    if(y < x) swap(x,y);
    vector<int> ans(n-1);
    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
           ans[min(j-i,abs(i-x)+1+abs(j-y))-1]++; 
        }
    }
    for(int i = 0; i < n-1; i++) cout << ans[i] << endl;
    return 0;
}

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

int main(){

  long long N=0;
  long long M=0;
  cin>>N>>M;
  
  map<int,int> mp;
  rep(i,M){

    int a;
    cin>>a;
    mp[a]=1;
  }
  
  long long dp[N+1];
  rep(i,N+1){
	dp[i]=0;
  }  
 
  dp[0]=1;
  dp[1]=1;
  if(mp[1]==1)dp[1]=0;
  
  for(int i=2; i<N+1;i++){

    if(mp[i]==1)dp[i]=0;
    else {
      dp[i]= dp[i-1] + dp[i-2];
      dp[i]%=MOD;
    }
  }
  
  cout<<dp[N]<<endl;

}

Measured memory_bytes: 5760
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline T int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int N; cin >> N;

	ll cnt = 0;
	rep2(i, 1, N){
		cnt += (N-1) / i;
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

const ll DIVIDE = (1E+9)+7;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  cin >> N >> K;
  vvll a(N, vll(N));
  rep(i, 0, N){
    rep(j, 0, N){
      cin >> a[i][j];
    }
  }

  vll dp(N, 1);
  vll dp2(N);
  vector<vvll> a_mul(61, vvll(N, vll(N, 0)));

  a_mul[0] = a;
  int count = 1;
  for(ll i=2; i<=K; i*=2){
    rep(x, 0, N){
      rep(y, 0, N){
        rep(z, 0, N){
          a_mul[count][x][y] += (a_mul[count-1][x][z]*a_mul[count-1][z][y])%DIVIDE;
        }
        a_mul[count][x][y] %= DIVIDE;
      }
    }
    count++;
  }

  int tmp = -1;
  while(K>0){
    int flag = K%2;
    K/=2;
    tmp++;
    if(flag==0) continue;
    rep(i, 0, N){
      dp2[i] = 0;
      rep(j, 0, N){
        dp2[i] += dp[j]*a_mul[tmp][j][i];
        dp2[i] %= DIVIDE;
      }
    }
    dp = dp2;
  }

  ll ans = 0;
  rep(i, 0, N){
    ans += dp[i];
    ans %= DIVIDE;
  }

  cout << ans << "\n";

  return 0;
}

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

using ll = long long;

void solve(long long N, std::vector<long long> A){
    ll ans = 0;
    for(int i = 1;i < N;i++){
        if(A[i] < A[i - 1]){
            ans += A[i - 1] - A[i];
            A[i] = A[i - 1];
        }
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4860
##C
A,B = map(int,input().split())
A1 = list()
B1 = list()
for i in range(1,1250):
    if int(i*0.08) == A:
        A1.append(i)
for j in A1:
    if int(j*0.1) == B:
        B1.append(j)
if not B1:
    print(-1)
else:
    print(min(B1))

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int
#define endl '\n'

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/*template*/
template<class T>constexpr bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>constexpr bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
constexpr int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
constexpr int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
constexpr int32_t LCM(int32_t a, int32_t b){return a / GCD(a, b) * b;}
constexpr int64_t LCM(int64_t a, int64_t b){return a / GCD(a, b) * b;}

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7;
constexpr int32_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

//#define int int64_t

/*global*/



signed main()
{
	int n, m; cin >> n >> m;
	priority_queue<int> q;
	for (size_t i = 0; i < n; i++)
	{
		int a; cin >> a;
		q.push(a);
	}

	for (size_t i = 0; i < m; i++)
	{
		int large = q.top();
		q.pop();
//		large >>= 1;

		q.push(large>>1);
	}
	int64_t sum{};
	for(int i = 0; i < n; ++i)
	{
		sum += q.top();
		q.pop();
	}
	
	cout << sum << '\n';
	
}

Measured memory_bytes: 892
# 暴力即可
# 範囲指定 A=100 B=-100で20000000000とかになるしどっちも|100|程度でいいのではないか
# なんか足りんみたい（なんで？）なので4X^2<=10^9なる最大のXを求めよう
# 2X = 1000ちょい だから500くらいあればいいのか
# 1000^2なので時間的には間に合いそう
x = int(input())
for a in range(-500, 501):
    for b in range(-500, 501):
        if a**5 - b**5 == x:
            print(a, b)
            exit()
print(3 / 0)  # はい


Measured memory_bytes: 9100
N = int(input())
takoyaki_list = list(map(int,input().split()))
total = 0 
listA = []
for i in range(N):
    for j in range(N-1):
        if i == j:
            pass
        else:
            A = [i,j]
            A.sort()
            listA.append(A)
listA = list(map(list, set(map(tuple, listA))))
for i,j in listA:
    A,B = [takoyaki_list[i],takoyaki_list[j]]
    total += A * B
print(total)

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

const int MAX = 2000;
int a[MAX];

int abs(int a, int b) { return a > b ? a - b : b - a; } // 絶対値を求める

int main() {
	int N, Z, W;
	cin >> N >> Z >> W;
	for (int i = 0;i < N;i ++) cin >> a[i];
	
	int X[MAX], Y[MAX], mi, ma;
	X[N - 1] = abs(a[N - 1], W);
	X[N - 2] = abs(a[N - 1], a[N - 2]); // Xがiを取った時の最大スコアがX[i]
	Y[N - 2] = abs(a[N - 1], a[N - 2]); // Yがiを取った時の最少スコアがY[i]
	for (int i = N - 3;i >= 0;i --) {
		mi = abs(a[i], a[N - 1]);
		ma = mi;
		for (int j = i + 1;j <= N - 2;j ++) {
			mi = min(mi, Y[j]);
			ma = max(ma, X[j]);
		}
		X[i] = mi;
		Y[i] = ma;
	}
	
	int score = 0;
	for (int i = 0;i < N;i ++) score = max(score, X[i]);
	cout << score;
	return 0;
}

// サンプルが仕事しない件

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define li long long int
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define inp(t) li t;cin>>t; while(t--)
using namespace std;

void solve()
{
  char ch;
  cin>>ch;

  if(ch<='z' && ch>='a')
    cout<<'a';
  else
    cout<<'A';
}
int main()
{
    IOS;

    solve();
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define ll long long
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define deb(x) cout << #x << "=" << x << endl;
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   


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

    ll a1 = b*d;
    ll a2 = b*c;
    ll a3 = a*c;
    ll a4 = a*d;
    cout<<max({a1, a2, a3, a4})<<endl;
}

Measured memory_bytes: 3668
n, x, y = map(int, input().split())
ans = [0] * (n-1)
for i in range(1, n):
    for j in range(i+1, n+1):
        d = min(j-i, abs(x-i)+abs(j-y)+1)
        ans[d-1] += 1
print(*ans, sep='\n')

Measured memory_bytes: 3444
from sys import stdin
a = map(int,stdin.readline().split())
n = int(stdin.readline())
mul = [1,2,4,8]
n = 4*n
b = []
for i in xrange(4):
    b.append( ((8/mul[i]) *a[i], a[i], mul[i])  )
b.sort()
ans = 0
for x,y,z in b:
    co = n/z
    ans += co * y
    n-= co * z
    #print "can buy",co,"with",x,y,z,"paying",co*x,"remaingin",n
print ans

Measured memory_bytes: 2568
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, A, B;
	cin >> N >> A >> B;

	cout << min(N * A, B) << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
a=[list(input()) for _ in [0]*h ]
b=[[i[j] for i in a] for j in range(w)]
H,W=[],[]
for i in range(h):
  if a[i]==['.']*w:
    H.append(i)
for j in range(w):
  if b[j]==['.']*h:
    W.append(j)
a=[''.join([a[i][j] if not j in W else '' for j in range(w)]) if not i in H else 0 for i in range(h)]
for i in range(h):
  if type(a[i])!=int:
    print(a[i])

Measured memory_bytes: 3188
def main():
    n, m = [int(x) for x in input().rstrip().split(" ")]
    
    cards = [int(x) for x in input().rstrip().split(" ")]
    cards.sort()
    
    from collections import defaultdict
    
    c_b = defaultdict(int)
    for i in range(m):
        b, c = [int(x) for x in input().rstrip().split(" ")]
        c_b[c] += b
        
    new_cards = list(c_b.keys())
    
    new_cards.sort(reverse=True)
    
    current = 0
    for c in new_cards:
        b = c_b[c]
        
        next_current = min(current + b, n)
        #print(c, b, current, next_current)
        if cards[next_current-1] > c:
            #2文探索で丁度良い場所を探す
            for j in range(current, next_current):
                if cards[j] < c:
                    cards[j] = c
                else:
                    break
            break
        else:
            for j in range(current, next_current):
                cards[j] = c
            current = next_current 
        
        if next_current == n:
            break
    #print(cards)
    print(sum(cards))

if __name__ == '__main__':
    main()

Measured memory_bytes: 23592
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    sort(h.begin(),h.end(),greater<int>() );
    int ans = 2e9;
    rep(i,n-k+1){
        // cout <<h[i] <<" " << h[i+k-1] <<endl;
        ans = min(ans,h[i] - h[i+k-1]);
        // cout << ans <<endl;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int a, b, c, d, n, ans;
  while(scanf("%d", &n) != EOF){
    ans = 0;
    for(a = 0;a < 10;a++)
      for(b = 0;b < 10;b++)
	for(c = 0;c < 10;c++)
	  for(d = 0;d < 10;d++)
	    if(a + b + c + d == n)ans++;

    printf("%d\n", ans);
  }
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int l;
    cin >> l;
    int total;
    if (l >= 0) total = (n-1)*(2*l+n)/2;
    else if (l <= 0 && (n+l-1)>=0) total = n*(2*l+n-1)/2;
    else total = (n-1)*(2*l+n-2)/2;
    cout << total << endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

long long max_rectangle(const std::vector<long long>& hist){
  using ll=long long;
  using P=std::pair<ll,ll>;

  ll w=hist.size();
  ll ret=0;
  std::stack<P> sta;
  for(ll i=0;i<w;i++){
    ll left=i;
    while(!sta.empty()&&sta.top().first>=hist[i]){
      auto e=sta.top();sta.pop();
      left=e.second;
      if((i-e.second+1)*(e.first+1)>ret)ret=(i-e.second+1)*(e.first+1);
    }
    sta.push(P(hist[i],left));
  }
  while(!sta.empty()){
    auto e=sta.top();sta.pop();
    if((w-e.second+1)*(e.first+1)>ret)ret=(w-e.second+1)*(e.first+1);
  }
  return ret;
}

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

  ll h,w;
  std::cin>>h>>w;

  std::vector<std::vector<int>> map(h,std::vector<int>(w));

  rep(i,0,h){
    std::string s;
    std::cin>>s;
    rep(j,0,w)map[i][j]=(s[j]=='#');
  }

  std::vector<std::vector<int>> grid(h-1,std::vector<int>(w-1));
  rep(i,0,h-1){
    rep(j,0,w-1)grid[i][j]=map[i][j]^map[i][j+1]^map[i+1][j]^map[i+1][j+1];
  }

  std::vector<std::vector<ll>> sum(h,std::vector<ll>(w-1,0));
  ll ans=std::max(h,w);

  rep(i,1,h){
    rep(j,0,w-1)if(grid[i-1][j]==0)sum[i][j]=sum[i-1][j]+1;
    chmax(ans,max_rectangle(sum[i]));
  }

  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 62976
#include<bits/stdc++.h>
using namespace std;
char a[5]={'a','e','i','o','u'};
int main()
{
    char c;
    c=getchar();
    for(int i=0;i<5;i++)
    {
        if(c==a[i])
        {
            cout<<"vowel"<<endl;
            return 0;
        }
    }
    cout<<"consonant"<<endl;
}

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

int main() {
  string n;
  cin >> n;
  for (int i = 0; i < 3; i++) {
    if (n[i] == '1')
      n[i] = '9';
    else if (n[i] == '9')
      n[i] = '1';
  }
  cout << n;
  return 0;
}

Measured memory_bytes: 256
# def partial_match_table(word):
#     table = [0] * (len(word) + 1)
#     table[0] = -1
#     i, j = 0, 1

#     while j < len(word):
#         matched = word[i] == word[j]

#         if not matched and i > 0:
#             i = table[i]
#         else:
#             if matched:
#                 i += 1
#             j += 1
#             table[j] = i

#     return table


# def kmp_search(text, word):
#     table = partial_match_table(word)
#     i, p = 0, 0

#     while i < len(text) and p < len(word):
#         if text[i] == word[p]:
#             i += 1
#             p += 1
#         elif p == 0:
#             i += 1
#         else:
#             p = table[p]

#     return (-1, i - p)[p == len(word)]


def match(s, t):
    ret = 0
    assert len(s) == len(t), (s, t)
    for i in range(len(s)):
        if s[i] == t[i]:
            ret += 1
    return ret


def main():
    s = input()
    t = input()
    ret = 1001

    for i in range(len(s)-len(t)+1):
        _ret = len(t) - match(s[i:i + len(t)], t)

        if ret > _ret:
            ret = _ret

    print(ret)


    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 8988
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
#define N 500050
char w[N];
int nxt[N],n,txn[N];
bool check1(int x) {
	if(x<2) return 1;
	int t=x-nxt[x];
	return t==x||x%t>0;
}
bool check2(int x) {
	if(x>n-1) return 1;
	int t=(n-x+1)-(n-txn[x]+1);
	return t==(n-x+1)||(n-x+1)%t>0;
}
int main() {
	scanf("%s",w+1);
	n=strlen(w+1);
	if(n==1) {puts("1\n1\n"); return 0;}
	if(n==2) {
		if(w[1]==w[2]) puts("2\n1\n");
		else puts("1\n1\n");
		return 0;
	}
	int i;
	int flg=0;
	for(i=2;i<=n;i++) if(w[i]!=w[i-1]) {flg=1;break;}
	if(!flg) {printf("%d\n1\n",n); return 0;}
	nxt[1]=0;
	int j=0;
	for(i=2;i<=n;i++) {
		for(;j&&w[i]!=w[j+1];j=nxt[j]) ;
		if(w[i]==w[j+1]) j++;
		nxt[i]=j;
	}
	int t=n-nxt[n];
	if(t==n||n%t) {
		printf("1\n1\n"); return 0;
	}
	printf("%d\n",2);
	txn[n]=n+1;
	j=n+1;
	for(i=n-1;i;i--) {
		for(;j<=n&&w[i]!=w[j-1];j=txn[j]) ;
		if(w[i]==w[j-1]) j--;
		txn[i]=j;
	}
	int ans=0;
	for(i=1;i<n;i++) {
		if(check1(i)&&check2(i+1)) ans++;
	}
	printf("%d\n",ans);
}


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

int main()
{
    string S, T; cin >> S >> T;
    int A, B; cin >> A >> B;
    string U; cin >> U;
    if(U == S) cout << A-1 << " " << B << endl;
    else cout << A << " " << B-1 << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define inf 1e9
#define pi 3.1415926536
#define mod 1000000007
#define fr(i,a,b,in) for(int i=a;i<b;i+=in)
#define frn(i,a,b,dc) for(int i=a;i>=b;i-=dc)
#define test(t) int t; cin>>t; while(t--)

ll power(ll a, ll n){
	if(n==0 || a==1) return 1;
	if(n==1) return a;
	ll p=power(a,n/2);
	p=(p*p)%mod;
	if(n%2==0) return p;
	else return (p*a)%mod;
}

int main()
{
	fastio();
	ll n,temp=10;
	cin>>n;
	ll a1=power(temp,n),a2=power(temp-1,n),a3=power(temp-2,n);
	ll ans=(a1-a2+mod)%mod;
	ans=(ans-a2+mod)%mod;
	ans=(ans+a3+mod)%mod;
	if(n==1) cout<<0<<endl;
	else if(n==2) cout<<2<<endl;
	else cout<<ans<<endl;
}

Measured memory_bytes: 3608
A, B, C, D = map(int, input().split())

def gcd(x, y):
    if y == 0: return x
    return gcd(y, x%y)

def lcm(x, y):
    return x * y // gcd(x, y)

# CとDの最大公約数
E = lcm(C, D)

F = 0
F += B // C + B // D - B // E
F -= (A - 1) // C + (A - 1) // D - (A - 1) // E

print(B - A + 1 - F)

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end

ll mod=998244353;
struct Mint {
    ll val;
    Mint inv() const{
        ll tmp,a=val,b=mod,x=1,y=0;
        while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
        return Mint(x);
    }
public:
    Mint():val(0){}
    Mint(ll x):val(x>=0?x%mod:x%mod+mod){}
    int mtoi(){return this->val; }
    Mint pow(ll t){Mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
    Mint& operator+=(const Mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
    Mint& operator-=(const Mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
    Mint& operator*=(const Mint& x){val=(ll)val*x.val%mod; return *this;}
    Mint& operator/=(const Mint& x){return *this *= x.inv();}
    bool operator==(const Mint& x) const{return val == x.val;}
    bool operator!=(const Mint& x) const{return val != x.val;}
    bool operator<(const Mint& x) const{return val < x.val;}
    bool operator<=(const Mint& x) const{return val <= x.val;}
    bool operator>(const Mint& x) const{return val > x.val;}
    bool operator>=(const Mint& x) const{return val >= x.val;}
    Mint operator+(const Mint& x) const{return Mint(*this)+=x;}
    Mint operator-(const Mint& x) const{return Mint(*this)-=x;}
    Mint operator*(const Mint& x) const{return Mint(*this)*=x;}
    Mint operator/(const Mint& x) const{return Mint(*this)/=x;}
};
struct factorial {
    vector<Mint> Fact, Finv;
public:
    factorial(int maxx){
        Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*Mint(i+1);
        Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*Mint(i);
    }
    Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
    Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
    Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

int main(){
    int n,a,b; scanf("%d%d%d",&n,&a,&b);
    ll k; scanf("%lld",&k);
    Mint ans; factorial fact(300010);
    rep(i,0,n+1){
        ll r=k-1LL*a*i;
        if(r%b!=0)continue;
        ll bcnt=r/b;
        if(bcnt>n)continue;
        ans+=fact.nCr(n,i)*fact.nCr(n,bcnt);
    }
    printf("%d\n",ans.mtoi());
    return 0;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N, X;
ll P[55];
ll sum[55];
ll ans;
ll dfs(ll a, ll x){

    ll ret = 0;
    if(x<=a){
        return 0;
    }else if(x==1) ret=1;
    else{
        if(x==sum[a]){
            ret+=P[a];
        }
        else if(x==sum[a]/2+1){
            ret += 1 + P[a-1];
        }
        else if(x < sum[a]/2+1){
            ret += dfs(a-1, x-1);
        }else if(x > sum[a]/2){
            ret += dfs(a-1, x-P[a]) + P[a-1] + 1;
        }
    }
    return ret;
}
int main() {
    cin >> N >> X;
    P[0] = 1;
    sum[0]=1;
    REP(i,1,N+1){
        P[i] = 2*P[i-1]+1;
        sum[i] = 2*sum[i-1]+3;
    }
    ans += dfs(N, X);
    p(ans);
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
C = [1]*(N)
for i in range(M):
  a, b = map(int, input().split())
  if H[a-1] >= H[b-1]:
    C[b-1] = 0
  if H[b-1] >= H[a-1]:
    C[a-1] = 0
print(sum(C))

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

int main(){
    string s;
    cin >> s;
    int len = s.size();
    bool flag = false;
    int i;
    for(i = 0; i < len/2; i++){
        if(s.at(i) != s.at(len-1-i)){
            cout << "No" << endl;
            return 0;
        }
    }
    for(i = 0; i < len/4; i++){
        if(s.at(i) != s.at(len/2-1-i) || s.at(len-1-i) != s.at(len/2+1+i)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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 MOD = 1000000007;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    set<int> s;
    for (int i = a; i < min(b, a + k); i++) {
        s.insert(i);
    }
    for (int i = max(a, b - k + 1); i <= b; i++) {
        s.insert(i);
    }
    for (const int x : s) {
        cout << x << endl;
    }
}


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

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

  if (N/100 == 7) {
    cout << "Yes" << endl;
  }
  else if (N/10-N/100*10 == 7) {
    cout << "Yes" << endl;
  }
  else if (N-(N/10-N/100*10)*10-N/100*100 == 7) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

}




Measured memory_bytes: 3592
open System
// 標準入力からスペース、タブ区切りでトークン列を読み込む
let stdinTokens = seq {
    while true do
        let line =  Console.ReadLine() 
        let tokens = line.Split([|' '; '\t'|], StringSplitOptions.RemoveEmptyEntries)
        yield! tokens
}
let readn n = stdinTokens |> Seq.take n |> List.ofSeq
let readInt n = readn n |> List.map int
let [X; A; B] = readInt 3
printfn "%d" ((X - A)%B)

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    stack<char> st;
    for(int i = 0; i < n; i++){
        if(st.empty()){
            st.push(s[i]);
            continue;
        }
        if(st.top() == '('){
            if(s[i] == ')'){
                st.pop();
            }else{
                st.push(s[i]);
            }
            continue;
        }
        if(st.top() == ')'){
            st.push(s[i]);
        }
    }

    while(!st.empty()){
        char tmp = st.top();
        st.pop();
        if(tmp == '('){
            s.push_back(')');
        }else{
            s.insert(s.begin(), '(');
        }
    }

    cout << s << endl;

    return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define fin(name) auto varfin=freopen(name, "r", stdin);varfin=varfin
#define fout(name) auto varfout=freopen(name, "w", stdout);varfout=varfout
#define I(x, a) for(auto x : a)
#define F(i, l, r) for(auto i = l; i < r; ++i)
#define E(i, l, r) for(auto i = l; i <= r; ++i)
#define DF(i, l, r) for(auto i = l; i >= r; --i)
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define ret return
#define cont continue
#define brk break
#define ins insert
#define sz(a) ((int)(a).size())

typedef long long ll;
typedef unsigned long long ull;
typedef long double dbl;
typedef pair <int, int> pii;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = 998244353;
const dbl eps = (dbl)1e-8;
const int maxn = (int)2000 + 5;
const dbl pi = acos(-1);
const int MX = 2000;

ll c[2 * maxn][2 * maxn];
ll d[maxn], prevd[maxn], dp[maxn][maxn];
int n, k;

int main() {
 //   fin("t.in");
    sync;
    cin >> k >> n;
    clean(d);
    clean(dp);
    dp[0][0] = 1;
    d[0] = dp[1][0] = 1;
    E(i, 1, MX) {
	    d[i] = 2;
	    dp[1][i] = 2;
	}
	clean(c);
    E(i, 0, 2 * MX) {
    	c[i][0] = 1;
    	E(j, 1, i) {
    		c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
    		if (c[i][j] >= mod)
    			c[i][j] -= mod;
    	}
    }
    F(i, 0, MX) {
    	E(j, 0, MX) {
    		prevd[j] = d[j];
    	}
    	E(j, 0, MX) {
    		d[j + 1] += d[j];
    		if (d[j + 1] >= mod)
    			d[j + 1] -= mod;
    	}
    	E(j, 0, MX) {
    		d[j] = (prevd[j] + (d[j] - prevd[j]) * 2ll) % mod;
    		if (d[j] < 0) d[j] += mod;
    	}
    	E(j, 0, MX) {
    		dp[i + 2][j] = d[j];
    	}
    }
    E(i, 2, 2 * k) {
    	int l = 0;
    	ll cnt = 0;
    	int fl = 0;
    	E(j, 1, k) {
    		ll x = i - j;
    		if (x <= 0 || x > k)
    			++cnt;
    		else if (2 * j == i)
    			fl = 1;
    		else
    			++l;
    	}
  		l /= 2;
  		
//  		cout << l << " " << cnt << " " << fl << " ";
//  		cout << endl;
  		
    	ll ans = 0;
    	DF(j, n, 0) {
 //   		cout << l << " " << j << endl;
//    		cout << dp[l][j] << endl;
    		ll y = 0;
    		if (cnt == 0 && n - j == 0)
    			y = 1;
    		if (cnt > 0)
    			y = c[cnt + n - j - 1][n - j];

    		ans += dp[l][j] * y;
    		if (j != 0 && fl)
    			ans += dp[l][j - 1] * y;
    		ans %= mod;
    	}
    	cout << ans << "\n";
    }

    return 0;
}

Measured memory_bytes: 157312
import java.util.*;
public class Main {
    public static void main(String args []){
        Scanner sc = new Scanner (System.in);
        int N = sc.nextInt();
        String A = sc.next();
        String S = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<A.length();i++){
            char each = A.charAt(i);
            int num = S.indexOf(each);
            if(num+N<26)num+=N;
            else num=num+N-26;
            each = S.charAt(num);
            sb.append(each);
        }
        System.out.println(sb);
    }
}

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

vector<int> init_combi(int A[], const int& n)
{
  if (n == 0)
  {
    return vector<int>{0};
  }
  else
  {
    vector<int> combi_n = init_combi(A, n - 1);
    int l = combi_n.size();
    for (int i = 0; i < l; ++i)
    {
      combi_n.push_back(combi_n.at(i) + A[n - 1]);
    }
    return combi_n;
  }
}

int main()
{
  int n, A[20];
  cin >> n;
  for (int i = 0; i < n; ++i)
  {
    cin >> A[i];
  }

  vector<int> combi = init_combi(A, n);
  sort(combi.begin(), combi.end());

  int q, m;
  cin >> q;
  for (int i = 0; i < q; ++i)
  {
    cin >> m;
    if (binary_search(combi.begin(), combi.end(), m))
    {
      cout << "yes" << endl;
    }
    else
    {
      cout << "no" << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 6976
#include <bits/stdc++.h>
using namespace std;
int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,i,j,temp,M;
	cin>>n;
	int v[n][3],dp[n][3];
	for(i=0;i<n;++i)
		for(j=0;j<3;++j)
			cin>>v[i][j];

	for(i=0;i<3;++i)
		dp[0][i]=v[0][i];

	for(i=1;i<n;++i)
	{
		dp[i][0]=v[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=v[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=v[i][2]+max(dp[i-1][1],dp[i-1][0]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 2688
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	vector<vector<pair<int, int>>> a(n, vector<pair<int, int>>());
	rep(i, m) {
		int p, y;
		scanf("%d%d", &p, &y);
		p--;
		a[p].push_back({y, i});
	}
	set<pair<int, pair<int, int>>> ans;
	rep(i, n) {
		sort(a[i].begin(), a[i].end());
		int c = a[i].size();
		rep(j, c) { ans.insert({a[i][j].second, {i + 1, j + 1}}); }
	}
	for (auto s : ans) {
		int a = s.second.first, b = s.second.second;
		rep(i, 6 - (int)(log10(a) + 1)) cout << 0;
		cout << a;
		rep(i, 6 - (int)(log10(b) + 1)) cout << 0;
		cout << b << endl;
	}
	return 0;
}

Measured memory_bytes: 13184