akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

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

int main() {
  ll N,M;
  string S,T;
  cin >> N >> M >> S >> T;
  int n=N,m=M;
  if(n<m) swap(n,m);
  ll g=gcd(n,m);
  bool flag=true;
  rep(i,g) flag&=(S[i*N/g]==T[i*M/g]);
  if(flag) cout << N*M/g << endl;
  else cout << -1 << endl;
}

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

int main() {
  int arr[5];
  for(int i=0;i<5;i++){
    cin>>arr[i];
  }
  sort(arr,arr+5);
  bool a=true;
  for(int i=0;i<5;i++){
    if(arr[i]!=i){
    	cout<<i<<endl;
    	a=false;
    	break;
    }
  }
  if(a)cout<<5<<endl;
}

Measured memory_bytes: 3156
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#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=601000;
char s[N];
int dp[N][30],r[N],q,x,y,n,go[N][21];
int main() {
	scanf("%s",s+1);
	n=strlen(s+1);
	rep(j,0,27) dp[n+1][j]=-1; dp[n+1][26]=n+1;
	per(i,1,n+1) {
		int w=s[i]-'a';
		dp[i][w]=i+1;
		rep(j,w+1,27) if (dp[i][j-1]!=-1) {
			dp[i][j]=dp[dp[i][j-1]][j-1];
		} else dp[i][j]=-1;
		rep(j,0,w) if (dp[i][26]!=-1) dp[i][j]=dp[dp[i][26]][j];
			else dp[i][j]=-1;
	}
	rep(i,1,n+2) if (dp[i][26]!=-1) go[i][0]=dp[i][26]; else go[i][0]=i;
	rep(j,1,21) rep(i,1,n+2) go[i][j]=go[go[i][j-1]][j-1];
	scanf("%d",&q);
	rep(i,0,q) {
		scanf("%d%d",&x,&y);
		per(j,0,21) if (go[x][j]<=y+1) x=go[x][j];
		puts(x==y+1?"Yes":"No");
	}
}


Measured memory_bytes: 105472
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<cstdio>
#include<algorithm>
#define LL long long
#define INF 1ll<<60
using namespace std;
const int N=2e5+100;
const int M=4e5+100;
const int mod=1e9+7;
int head[N],Next[M],ver[M],tot;
void add(int x,int y) {
    ver[++tot]=y;
    Next[tot]=head[x];
    head[x]=tot;
}

int vis[N];

int main() {
	int n,m;
    while(cin>>n>> m) {
        tot=1;
        
        memset(head,0,sizeof(head));
        memset(Next,0,sizeof(Next));
        memset(ver,0,sizeof(ver));
		memset(vis,0,sizeof(vis));
		
		for(int i=1;i<=m;i++){
			
			int x,y;
			cin >> x >> y;
			add(x,y);
			add(y,x);
		}
		
		for(int i=head[1];i;i=Next[i]){
			int y=ver[i];
			vis[y]++;
		}
		for(int i=head[n];i;i=Next[i]){
			int y=ver[i];
			vis[y]++;
		}
		int flag=0;
		for(int i=1;i<=n;i++){
			if(vis[i]>=2){
				flag=1;
				break;
			}
		}
		if(flag)cout<<"POSSIBLE"<<endl;
		else cout<<"IMPOSSIBLE"<<endl;
        
    }
    return 0;

}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,x,y;
vector<int> e1[N],e2[N];
int fa[N],dep[N],ance[18][N];
void dfs(int x){
    for (int i=0;i<e2[x].size();i++){
        int v=e2[x][i];
        if (fa[v]) continue;
        fa[v]=x;
        dep[v]=dep[x]+1;
        dfs(v);
    }
}
void init(){
    fa[1]=1;dfs(1);
    for (int i=1;i<=n;i++) ance[0][i]=fa[i];
    for (int i=1;i<18;i++)
    for (int j=1;j<=n;j++)
        ance[i][j]=ance[i-1][ance[i-1][j]];
}
int go(int x,int k){
    for (int i=0;i<18;i++)
    if (k>>i&1) x=ance[i][x];
    return x;
}
int lca(int x,int y){
    if (dep[x]<dep[y]) swap(x,y);
    x=go(x,dep[x]-dep[y]);
    for (int i=17;i>=0;i--)
    if (ance[i][x]!=ance[i][y]) x=ance[i][x],y=ance[i][y];
    return x!=y?fa[x]:x;
}
int dist(int x,int y){
    return dep[x]+dep[y]-2*dep[lca(x,y)];
}
int move(int x,int y){
    int LCA=lca(x,y);
    return y!=LCA?fa[y]:go(x,dep[x]-dep[y]-1);
}
void dfs(int x,int y,int fa){
    if (x==y) return;
    for (int i=0;i<e1[x].size();i++){
        int v=e1[x][i];
        if (v==fa) continue;
        if (dist(x,v)>2) puts("-1"),exit(0);
        if (v!=y) dfs(v,move(v,y),x);
    }
}
int ans;
void calc(int x,int y,int fa,int times){
    ans=max(ans,times+dist(x,y));
    if (x==y) return;
    for (int i=0;i<e1[x].size();i++){
        int v=e1[x][i];
        if (v==fa||v==y) continue;
        calc(v,move(v,y),x,times+1);
    }
}
int main()
{
    scanf("%d%d%d",&n,&x,&y);
    for (int i=1;i<n;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        e1[a].push_back(b);
        e1[b].push_back(a);
    }
    for (int i=1;i<n;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        e2[a].push_back(b);
        e2[b].push_back(a);
    }
    init();
    dfs(x,y,0);
    calc(x,y,0,0);
    printf("%d\n",ans*2);
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;

long long MOD = 10000000000 + 7;

bool compare(plli x, plli y){
  return x.first > y.first;
}

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;
  vector<plli> v(N);

  for(int i = 0; i < N; i++){
    ll tmp;
    cin >> tmp;
    v.at(i) = make_pair(tmp, i);
  }

  sort(v.begin(), v.end(), compare);

  // cerr << v[0].first << " " << v[0].second << endl;

  vector<vector<ll>> dp(N+1, vector<ll>(N+1, 0)); 
  // dp[i][j] : 左にi個、右にj個入れたときの最大
  for(int k = 1; k <= N; k++){
    // dp[i][j]: i+j = k を走査する
    for(int i = 0; i <= k; i++){
      int j = k - i;
      if(i-1>=0) dp[i][j] = max(dp[i][j], dp[i-1][j] + v[k-1].first * abs(v[k-1].second - i + 1) );
      if(j-1>=0) dp[i][j] = max(dp[i][j], dp[i][j-1] + v[k-1].first * abs(N-j - v[k-1].second));
    }
  }
  ll ans = 0;
  for(int i = 0; i <= N; i++){
    ans = max(ans, dp.at(i).at(N-i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 34684
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
--import Data.Array
import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

set :: Int -> [[Int]] -> [[Int]]
set n [] = []
set n (d:ds) = let len = length d in let t = replicate (div (n - len) 2) 0 in (t ++ d ++ t) : set (n-1) ds

f :: [[Int]] -> Int
f [[r]] = r
f (u:v:vs) = f $ zipWith (+) (binMap max u) v : vs

main = do
  ds <- map (map readInt . wordsBy (==',')) . lines <$> getContents
  print $ f $ set (length ds) ds


Measured memory_bytes: 5712
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int X=sc.nextInt();
		if(X==7||X==5||X==3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		pw.close();
	}

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

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

Measured memory_bytes: 21076
N, Q = map(int, input().split())
s = input()

t = []
d = []
for i in range(Q):
    t_i, d_i = input().split()
    t.append(t_i)
    d.append(d_i)


def calc_group(n):
    for i in range(Q):
        if s[n] == t[i]:
            if d[i] == 'L':
                n -= 1
                if n == -1:
                    return -1  # deleted at the left side
            elif d[i] == 'R':
                n += 1
                if n == N:
                    return 1  # deleted at the right side
    return 0


l = -1
r = N
n = (l + r) // 2
while l != n:
    if calc_group(n) == -1:
        l = n
    else:
        r = n
    n = (l + r) // 2
l_max = l

l = -1
r = N
n = (l + r) // 2
while l != n:
    if calc_group(n) == 1:
        r = n
    else:
        l = n
    n = (l + r) // 2
r_min = r

count = r_min - l_max - 1
print(count)

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

int main() {
  int n; cin >> n;
  vector<int> w(n);
  rep(i,n) {
    cin >> w[i];
  }
  int ans = 10000;
  rep(i,n-1) {
    int s_a = 0, s_b = 0;
    rep(j,n) {
      if (j <= i) s_a += w[j];
      else s_b += w[j];
    }
    ans = min(abs(s_a - s_b), ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
List = [list(input().split()) for i in range(N)]
ANS=List
for j in range(N):
    List[j][1]=int(List[j][1])
RList=sorted(List,reverse=True, key=lambda x: x[1])
RList.sort(key=lambda x: x[0])
for i in range(N):
    print((ANS.index(RList[i]))+1)

Measured memory_bytes: 3064
N = int(input())
T ,A = map(int, input().split())
Hs = list(map(int, input().split()))
p = 0
dtmin = abs(A-(T -Hs[0]*0.006))
for i in range(N):
    h = Hs[i]
    dt= abs(A-(T -0.006*h))
    if dt < dtmin:
        dtmin = dt
        p = i
print(p+1)


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

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

template <class Monoid>
struct SegTree {
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid UNITY;
  int size;
  vector<Monoid> dat;

  SegTree(int n, const Func f, const Monoid &unity)
      : F(f), UNITY(unity), size(n), dat(2 * n, unity) {}

  // Sets i-th value (0-indexed) to x for initial setup.
  // build() must be called after set() calls.
  void set(int i, const Monoid &x) { dat[size + i] = x; }
  void build() {
    for (int k = size - 1; k > 0; --k) {
      dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  // Sets i-th value (0-indexed) to x.
  void update(int i, const Monoid &x) {
    int k = size + i;
    dat[k] = x;
    while (k > 1) {
      k >>= 1;
      dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  // Queries by [l,r) range (0-indexed, open interval).
  Monoid fold(int l, int r) {
    l += size;
    r += size;
    Monoid vleft = UNITY, vright = UNITY;
    for (; l < r; l >>= 1, r >>= 1) {
      if (l & 1) vleft = F(vleft, dat[l++]);
      if (r & 1) vright = F(dat[--r], vright);
    }
    return F(vleft, vright);
  }

  // Queries by a single index (0-indexed).
  Monoid operator[](int i) { return dat[size + i]; }

  /* debug */
  void print() {
    for (int i = 0; i < size; ++i) {
      cout << (*this)[i];
      if (i != size - 1) cout << ",";
    }
    cout << endl;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  string S;
  cin >> S;
  int Q;
  cin >> Q;

  vector<SegTree<int>> st;
  REP(i, 26) {
    st.emplace_back(
        N + 10, [](int x, int y) { return x + y; }, 0);
  }
  REP(i, N) { st[S[i] - 'a'].set(i, 1); }
  REP(i, 26) { st[i].build(); }

  REP(q, Q) {
    int typ;
    cin >> typ;
    if (typ == 1) {
      int iq;
      char cq;
      cin >> iq >> cq;
      iq--;
      int from = S[iq] - 'a';
      int x = st[from].fold(iq, iq + 1);
      st[from].update(iq, x - 1);
      int to = cq - 'a';
      int y = st[to].fold(iq, iq + 1);
      st[to].update(iq, y + 1);
      S[iq] = cq;
    } else {
      assert(typ == 2);
      int l, r;
      cin >> l >> r;
      l--;
      int cnt = 0;
      REP(i, 26) {
        if (st[i].fold(l, r) > 0) ++cnt;
      }
      cout << cnt << '\n';
    }
  }
}


Measured memory_bytes: 136472
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
#include<math.h>
//#include<string.h>
//#include<time.h>
#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define h 1000//division number
int main() {
	int n, ans, i, j, k, cnt;
	double x[100], y[100], cx, cy;
	for (; ~fscanf(stdin, "%d", &n), n; P(d, ans)) {
		ans = 0;
		for (i = 0; i < n; i++) fscanf(stdin, "%lf%*c%lf", x + i, y + i);
		for (i = 0; i < n; i++) {
			for (j = 0; j < h; j++) {
				cx = x[i] + cos(2 * pi*j / h);
				cy = y[i] + sin(2 * pi*j / h);
				for (k = cnt = 0; k < n; k++)
					if ((cx - x[k])*(cx - x[k]) + (cy - y[k])*(cy - y[k]) < 1.0 + 1e-7)cnt++;
				if (cnt > ans) ans = cnt;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 648
#[allow(unused)]
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    println!("{}", (n - 1) / 2);
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <numeric>
#include <ctime>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <map>

using namespace std;
typedef long long int lint;

#define INF 10000000
#define MAX 100

int solve(int n)
{
	int m;
	int cost[MAX][MAX];		// cost[i][j] は 辺ijのコスト
	int mincost[MAX];		// 集合Xからの辺の最小コスト
	bool used[MAX];			// 頂点iがXに含まれているか

	for(int i = 0; i < n; i++){
		mincost[i] = INF;
		used[i] = false;
		for(int j = 0; j < n; j++){
			cost[i][j] = INF;
		}
	}

	cin >> m;

	for(int k = 0; k < m; k++){
		int i, j, c;
		scanf("%d,%d,%d", &i, &j, &c);
		cost[i][j] = cost[j][i] = (c / 100) - 1;
	}

	mincost[0] = 0;
	int res = 0;

	while(1){
		int v = -1;
		for(int u = 0; u < n; u++){
			if(!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
		}

		if(v == -1) break;
		used[v] = true;
		res += mincost[v];

		for(int u = 0; u < n; u++){
			mincost[u] = min(mincost[u], cost[v][u]);
		}
	}

	return res;
}

int main()
{
	while(1){
		int n;
		scanf("%d", &n);
		if(n == 0) break;
		cout << solve(n) << endl;
	}

	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
long long a[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    long long d;
    cin>>d;
    a[0]=1;
    for(int i=1;i<=20;i++)
    	a[i]=a[i-1]*10;
    long long ans=0;
    for(int i=2;i<=20;i++)
    {
    	int k=i/2;
    	for(long long state=0;state<1<<k;state++)
    	{
    		long long cha,chan=d;
    		if(i%2==1)
    			cha=10;
    		else
    			cha=1;
    		for(int j=0;j<k;j++)
    		{
    			long long x=abs(chan)%10;
    			if(chan<0)
    			{
    				x=10-x;
    				x%=10;
				}
				if(state>>j&1)
				{
					long long sym=10-x;
					if(j==0)
						sym--;
					cha*=sym;
					chan+=x*a[i-2*j-1];
					chan-=x;
				}
				else
				{
					long long sym=x;
					if(j==0)
						sym--;
					if(sym<0)
					{
						cha=0;
						break;
					}
					cha*=sym;
					chan-=(10-x)*a[i-2*j-1];
					chan+=(10-x);
				}
				chan/=10;
			}
			if(chan==0)
				ans+=cha;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3544
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
	char o[51], e[51];
	int i=0;
	cin>>o>>e;
	while(o[i]!='\0'){
		putchar(o[i]);
		if(e[i]!='\0') putchar(e[i]);
		i++;
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 256
s = list(input())
ans = 'AC'
if s[0] != 'A':
    ans = 'WA'
c_idx = None
for i, v in enumerate(list(s)):
    if i >= 2 and i <= len(s)-2:
        if v == 'C':
            if c_idx is None:
                c_idx = i
            else:
                ans = 'WA'
if c_idx is None:
    ans = 'WA'
else:
    s[0] = 'a'
    s[c_idx] = 'c'
    if [ i.lower() for i in s ] != s:
        ans = 'WA'
print(ans)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 1e8;
const int mod = 1e9 + 7;
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);

  int  n;
  cin >>  n;
  vector<int>v(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  int sum = 0;
  for(int i=0;i<n;i++){
    sum += v[i];
  }
  int small = 0  , big = 0;
  int mid = sum/2;

  for(int i=0;i<n;i++){
     if(small + v[i] <= mid){
       small += v[i];
     }
     else break;
  }

  for(int i=0;i<n;i++){
    big += v[i];
    if(big >= (mid+1))break;
  }

  int x = abs((sum - small) - small);
  int y = (abs(big - (sum - big)));

  cout << min(x,y) << '\n';


}

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

//https://atcoder.jp/contests/agc037/tasks/agc037_c

const int nm = 2e5;
int n, a[nm], b[nm];
ll ans = 0;

priority_queue<pair<int, int>> q;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i];
	for (int i = 0; i < n; ++i) {
		if (b[i] < a[i]) {
			cout << -1 << endl;
			return 0;
		}
		if (b[i] != a[i])
			q.emplace(b[i], i);
	}
	while (!q.empty()) {
		int i = q.top().second;
		q.pop();

		int t = (b[i] - a[i]) / (b[(i + n - 1) % n] + b[(i + 1) % n]);
		if (!t) {
			cout << -1 << endl;
			return 0;
		}
		ans += t;
		b[i] -= (b[(i + n - 1) % n] + b[(i + 1) % n]) * t;

		if (b[i] != a[i])
			q.emplace(b[i], i);
	}
	cout << ans << endl;
}


Measured memory_bytes: 6904
H = int(input())
 
# 体力がHのモンスター1体に勝つために必要な攻撃回数をf(H)とする
# すると、f(H)は以下の漸化式に従って求まる
# f(H)=2*f(floor(H/2)+1) (H>1)
# f(H)=1 (H=1)
 
def attack_num(x):
  if x == 1: return 1
  else: return 2*attack_num(x // 2) + 1
  
print(attack_num(H))

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define ri register int 
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	// no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} 
using io :: gi;
using io :: putc;
using io :: print;
const int N=2e3+5;
#define bit bitset<N>
struct node{
	int tot,head[N],nxt[N<<1],adj[N<<1],top[N],sz[N],f[N],dep[N],son[N];
	bit p[N],q[N];
	inline void addedge(ri x,ri y){
		nxt[++tot]=head[x];
		adj[head[x]=tot]=y;
	}
	inline void dfs(ri x){
		sz[x]=1;
		p[x][x]=q[x][x]=1;
		for(ri y,i=head[x];i;i=nxt[i])
			if((y=adj[i])!=f[x])
				p[y]=p[x],
				f[y]=x,
				dep[y]=dep[x]+1,
				dfs(y),
				q[x]|=q[y],
				sz[x]+=sz[y],
				son[x]=sz[y]>sz[son[x]]?y:son[x];
	}
	inline void dfs2(ri x,ri tp){
		top[x]=tp;
		if(son[x])
			dfs2(son[x],tp);
		for(ri y,i=head[x];i;i=nxt[i])
			if((y=adj[i])!=f[x]&&y!=son[x])
				dfs2(y,y);
	}
	inline int lca(ri x,ri y){
		while(top[x]^top[y])
			if(dep[top[x]]>dep[top[y]])
				x=f[top[x]];
			else
				y=f[top[y]];
		return dep[x]<dep[y]?x:y; 
	}
	inline int sec(ri x,ri y){ // lca(x,y) = x
		while(top[x]^top[y]){
			if(f[top[y]]==x) return top[y];
			y=f[top[y]];
		}
		return son[x];
	}
	inline bit S(ri a,ri b){
		ri x=lca(a,b);
		bit ans=p[a]^p[b];
		ans[x]=1;
		if(x!=b)
			ans|=q[b];
		else
			ans|=~q[sec(b,a)];
		if(x!=a)
			ans|=q[a];
		else
			ans|=~q[sec(a,b)]; 
		return ans;
	}
}t;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair 
pii qu[N*N];
bit nG[N];
int main(){
	ri n,m,i,x,y,l,r;
	l=1;r=0;
	gi(n);gi(m);
	for(i=1;i^n;++i)
		gi(x),gi(y),
		t.addedge(x,y),
		t.addedge(y,x);
	t.dfs(1);
	t.dfs2(1,1);
	while(m--)
		gi(x),gi(y),
		nG[x][y]=nG[y][x]=1,
		qu[++r]=mp(x,y);
	while(l<=r){
		x=qu[l].fi;
		y=qu[l].se;
		++l;
		bit now=(nG[x]^nG[y])&t.S(x,y);
		now[x]=now[y]=0;
		for(i=now._Find_first();i!=now.size();i=now._Find_next(i))
			if(!nG[x][i])
				nG[x][i]=nG[i][x]=1,
				qu[++r]=mp(x,i);
			else
				nG[y][i]=nG[i][y]=1,
				qu[++r]=mp(y,i);
	}
	printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 23040
function f()
    N, K = parse.(Int, split(readline()))
    A = parse.(Int, split(readline()))
    c = zeros(N)
    for a in A
        c[a] += 1
    end
    sort!(c)
    m = 0
    for i in c
        m += (i != 0)
    end
    ans = 0
    for i in c
        m -= (i != 0)
        ans += i
        if m <= K
            break
        end
    end
        
    println(Int(ans))
end
f()

Measured memory_bytes: 206744
#include<bits/stdc++.h>
    using namespace std;
    const int INF=10;
    int a,b,c,d,e,_a,_b,_c,_d,_e,mini=0;
    bool __a=true,__b=true,__c=true,__d=true,__e=true;
    int main() {
    	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    	_a=a%10;_b=b%10;_c=c%10;_d=d%10;_e=e%10;
    	if(_a==0) _a=INF;
    	if(_b==0) _b=INF;
    	if(_c==0) _c=INF;
    	if(_d==0) _d=INF;
    	if(_e==0) _e=INF;
    	mini=min(min(_a,_b),min(min(_c,_d),_e));
    	printf("%d",a+b+c+d+e+50-_a-_b-_c-_d-_e+mini-10);
    	return 0;
    }

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
    	var cnt = 0;
    	var w = Console.ReadLine().ToLower();
    	while(true) {
    		var s = Console.ReadLine();
    		
    		if(s == "END_OF_TEXT")	break;
    	
    		foreach(var t in s.ToLower().Split(' ')) {
    			if(w == t)	cnt++;
    		}
    	}
    	Console.WriteLine(cnt);
    }
}

Measured memory_bytes: 9036
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int solve(string x, string y, int xlen, int ylen) {
    vector<vector<int>> dp(xlen + 1, vector<int>(ylen + 1, 0));
    for (int i = 1; i < xlen + 1; i++) {
        for (int j = 1; j < ylen + 1; j++) {
            if (x[i - 1] == y[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else {
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
            }
        }
    }
    return dp[xlen][ylen];
}

int main() {

    int n;
    string x, y;

    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> x >> y;

        cout << solve(x, y, x.length(), y.length()) << endl;

    }
    
    return 0;
}


Measured memory_bytes: 6808
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define fi first
#define se second
#define pb push_back
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
#define L(i,u) for (int i=head[u]; i!=0; i=edge[i].nxt)
#define abs(a) ((a)>0 ? (a) : -(a))
#define INF 0x3f3f3f3f
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
typedef long long ll;
typedef long double ld;
const int N = 133333;
ll n,l;

inline void read(ll &x) {
	x=0; char c=getchar(); int f=1;
	while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=10*x+c-'0'; c=getchar();} x*=f;
}
/*bool sg(int gou, int cha) { //(¿ÉÏÈÊÖ£¬²»¿É)
	if (gou&1) return 1;
	return cha&1;
}
inline int f(ll n) { //dep=nµÄÂú¶þ²æÊ÷ÄÜ·ñÏÈÊÖ 
	if (n==1||n==3||n==4) return 0;
	return 1;
}*/
inline ll f(ll n) {
	return n&-n;
}
int ch[N][2],size,dep[N];
inline void insert(char *s, int len) {
	int now=0;
	rep(i,1,len) {
		int c=s[i]-'0';
		if (!ch[now][c]) {ch[now][c]=++size; dep[size]=i;}
		now=ch[now][c];
	}
}
ll s[N],len;
int main() { //freopen("1.in","r",stdin);
	read(n); read(l);
	char st[N];
	rep(i,1,n) {
		scanf("%s",st+1); int l=strlen(st+1);
		insert(st,l);
	}
	rep(i,0,size) if (((ch[i][0]>0)^(ch[i][1]>0))&&l>dep[i]) s[++len]=l-dep[i];
//	printf("%d %d %d\n",len,s[1],s[2]);
/*	int gou=0,cha=0;
	rep(i,1,len)
		if (f(s[i])) gou++; else cha++;
	bool flag=sg(gou,cha);*/
	ll SG=0; rep(i,1,len) SG^=f(s[i]); 
//	printf("%lld %lld\n",s[1],f(s[1]));
	if (SG) puts("Alice"); else puts("Bob");
	/*f[1]=0; f[2]=1;
	rep(i,3,100) {
		int gou=0,cha=0;
		per(j,i-1,1) {
			if (f[j]) gou++; else cha++;
			f[i]|=!sg(gou,cha);
		}
		printf("%d:%d\n",i,f[i]);
	}*/
	return 0;
}

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

using namespace std;


int main(void){
    // Your code here!
    int n;
    cin >> n;
    vector<int> a(9);
    for(int i=0; i<9; i++) a[i] = 0;
    
    for(int i=0; i<n; i++) {
        int tmp;
        cin >> tmp;
        if(tmp >= 3200) a[0]++;
        else if(tmp >= 2800) a[1]++;
        else if(tmp >= 2400) a[2]++;
        else if(tmp >= 2000) a[3]++;
        else if(tmp >= 1600) a[4]++;
        else if(tmp >= 1200) a[5]++;
        else if(tmp >= 800) a[6]++;
        else if(tmp >= 400) a[7]++;
        else a[8]++;
    }
    int color = 0;
    for(int i=1; i<9; i++) 
        if(a[i]>0) color++;
    cout << (color!=0 ? color : 1) << " " << color+a[0] << endl;
    return 0;
}


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


int main() {
string A;
cin >> A;
int cou = 0;
for(int i = 0;i < 3;i++) {
    if(A.at(i) == 'o') {
        cou++;
    } 
}

cout << cou * 100 + 700 << endl;

return 0;
}
 

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

using namespace std;
set<string> Set;
int main()
{
    int n;
    string t,s;
    cin >> n;
    cin >> s;
    t=s;
    Set.insert(s);
    for (int i=1;i<n;i++)
    {
        cin >> s;
        if (Set.count(s)||t.back()!=s.front())
        {
            cout << "No" << endl;
            return 0;
        }
        Set.insert(s);
        t=s;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#define MOD 1000000007 
#define MOD2 998244353
#include <vector>
#include <iostream>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n-1,-1)

int main() {
	ll power[2501];
	power[0] = 1;
	REP(i, 2500) power[i + 1] = (power[i] * 26) % MOD;

	ll power2[2501];
	power2[0] = 1;
	REP(i, 2500) power2[i + 1] = (power2[i] * 26) % MOD2;

	int n;
	cin >> n;
	char s[5001];
	cin >> s;

	vll hash_list;
	ll ha=0;
	hash_list.push_back(0);
	REP(i, n) {
		ha *= 26;
		ha += s[i] - 'a';
		ha %= MOD;
		hash_list.push_back(ha);
	}

	vll hash_list2;
	ll ha2 = 0;
	hash_list2.push_back(0);
	REP(i, n) {
		ha2 *= 26;
		ha2 += s[i] - 'a';
		ha2 %= MOD2;
		hash_list2.push_back(ha2);
	}

	RFOR(j, n/2, 0) {
		unordered_map<ll, int> ma;
		REP(i, n - j + 1) {
			ll x = (hash_list[i]*power[j])%MOD;
			x = (hash_list[i + j]+MOD-x)%MOD;
			if (ma.find(x) == ma.end()) ma[x] = i;
			else if (i >= ma[x] + j) {
				ll xx = (hash_list2[i]*power2[j])%MOD2;
				xx = (hash_list2[i + j]+MOD2-xx)%MOD2;
				ll xxx = (hash_list2[ma[x]]*power2[j])%MOD2;
				xxx = (hash_list2[ma[x] + j]+MOD2-xxx)%MOD2;
				if(xx==xxx){
					cout << j;
					return 0;
				}
			}
		}
	}
	cout << "0";
	return 0;
}

Measured memory_bytes: 700
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0) 
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int inf = ~0u >> 1;
int main() {
    IO;
    int n;
    cin >> n;
    if (n % 10 == 7 || n / 10 % 10 == 7 || n / 100 == 7) {
        cout << "Yes" << endl;
    } 
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3576
N = int(input())
S = input()

assignable = False

for k in range(4):
    res = [None for _ in range(N)]
    res[0] = k % 2
    res[-1] = k // 2
    for i in range(N - 2):
        if S[i] == 'o':
            if res[i] == 0:
                res[i + 1] = res[i - 1]
            else:
                res[i + 1] = 1 - res[i - 1]
        else:
            if res[i] == 0:
                res[i + 1] = 1 - res[i - 1]
            else:
                res[i + 1] = res[i - 1]
    if S[-2] == 'o':
        if res[-2] == 0:
            if res[-1] != res[-3]:
                continue
        else:
            if res[-1] != 1 - res[-3]:
                continue
    else:
        if res[-2] == 0:
            if res[-1] != 1 - res[-3]:
                continue
        else:
            if res[-1] != res[-3]:
                continue
    if S[-1] == 'o':
        if res[-1] == 0:
            if res[0] == res[-2]:
                assignable = True
        else:
            if res[0] == 1 - res[-2]:
                assignable = True
    else:
        if res[-1] == 0:
            if res[0] == 1 - res[-2]:
                assignable = True
        else:
            if res[0] == res[-2]:
                assignable = True
    if assignable:
        for i in range(N):
            if res[i]:
                print('W', end='')
            else:
                print('S', end='')
        break
else:
    print(-1)

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

string str[45];
int A[45][45];
int N;
ll DP[45][45][45][45][2];

/*
DP[a][b][c][d][0] = # ways to connect points in [a , b] U [c , d] into a tree
and there is exactly one connetion from [a , b] to [c , d].
DP[a][b][c][d][1] = # ways to connect points in [a , b] U [c , d] into a forest.

DP[a][b][c][d][0] = DP[a][p - 1][p + 1][b][1] * DP[c][q - 1][q + 1][d] * [A[p][q] == 1]
// enumerate the line connecting [a , b] and [c , d]
// the remaining connections must be from [a , b] to [c , d]
// [a , p - 1] U [p + 1 , b] and [c , q - 1] U [q + 1 , d] must form forests (or a tree)

DP[a][b][c][d][1] = DP[a][p][q][d][0] * DP[p + 1][b][c][q - 1][1]
// forests is must have at least one tree, so we enumerate the range where we get a tree

*/

ll solve(int a , int b , int c , int d , int x){
  if(x == 0){
    if(a > b || c > d)return 0;
  }
  else{
    if((a > b) && (c > d))return 1;
    if((a > b) ^ (c > d))return 0;
  }
  ll& ret = DP[a][b][c][d][x];
  if(~ret)return ret;
  ret = 0;
  if(x == 0){
    for(int p = a; p <= b; ++p){
      for(int q = c; q <= d; ++q){
        if(A[p][q]){
          ret += solve(a , p - 1 , p + 1 , b , 1) * solve(c , q - 1 , q + 1 , d , 1);
        }
      }
    }
  }
  else{
    for(int p = a; p <= b; ++p){
      for(int q = c; q <= d; ++q){
        ret += solve(a , p , q , d , 0) * solve(p + 1 , b , c , q - 1 , 1);
      }
    }
  }
  return ret;
}

int main(){
  cin >> N;
  for(int i = 1; i <= 2 * N; ++i){
    cin >> str[i];
  }
  for(int i = 1; i <= 2 * N; ++i){
    for(int j = 0; j < 2 * N; ++j){
      A[i][j + 1] = str[i][j] == '1';
    }
  }
  memset(DP , -1 , sizeof(DP));
  ll ret = 0;
  for(int i = 2; i <= 2 * N; ++i){
    if(A[1][i]){
      ret += solve(2 , i - 1 , i + 1 , 2 * N , 1);
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 64384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)   for(signed i=0; i<n; i++)
#define FOR(i, k, n)    for(signed i=k; i<n; i++)
#define yn(b)   cout << ((b)?"Yes":"No") << endl
#define YN(b)   cout << ((b)?"YES":"No") << endl
#define pr(r)   cout << r << endl
#define min(x,y)    (x<y)?x:y
#define max(x,y)    (x>y)?x:y
#define ll  long long
int main(void){
    int A, B, C;
    cin >> A >> B >> C;
    int r=B/A;
    if(C >= r) pr(r);
    else pr(C);
}

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



 bool is_prime(int x){
 	if(x<=1)return false;
   for(int i=2;i*i<=x;i++)
     if(x%i==0) return false;
   return true;
 }
  
  signed main(){
  	int x;
    cin>>x;
    
    int p=x;
    while(!is_prime(p)) p++;
    
    cout<<p<<endl;
    
    return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
 
#define endl '\n'
#define FAST                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;

int main() {
int n,m;
cin>>n>>m;
map<int,set<int>>mm;
for(int i=0;i<m;i++)
{
    int a,b;
    cin>>a>>b;
    mm[a].insert(b);
}
if(n==1 && m==1 && (mm.begin())->first==1 && *((mm.begin())->second.begin())==0)
return cout<<0,0;
else if(n==1 && m==0)
return  cout<<0,0;
for(auto i=mm.begin();i!=mm.end();i++)
{
    set<int>v=i->second;
    if(v.size()>1 || (*v.begin()==0 && i->first==1))
    return cout<<-1,0;
}
int arr[n+1];
memset(arr,0,sizeof arr);
for(auto i=mm.begin();i!=mm.end();i++)
{
    set<int>v=i->second;
arr[i->first]=*v.begin();
    
}
if(arr[1]==0)
arr[1]=1;
for(int i=1;i<=n;i++)
{
  cout<<arr[i];
}
cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
 
const int maxn = 2e5 + 20;
 
int n;
string s, t;
int ans = 0, ss = s.size(), tt = t.size(), boz;

bool cmp (string s, string t)
{
	string v1, v2;
	for ( ; v1.size() <= 1000000; ) v1 += s;
	for ( ; v2.size() <= 1000000; ) v2 += t;
	return v1 > v2;
}
	
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> s >> t;
	ss = s.size(), tt = t.size();
	if (cmp (s, t))
		swap (s, t), swap (ss, tt);
 
	for (int i = 0; i * ss <= n; i++)
		if ( (n - i * ss) % tt == 0)
			ans = i, boz = (boz == -1 ? i : boz);
	string res1, res2;
	
	for (int i = 0; i < ans; i++)
		cout << s;	
	n -= ss * ans;
	for (int i = 0; i * tt < n; i++)
		cout << t;
	cout << endl;
	return 0;
}

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

int main() {
  int n;	cin >> n;
  string s;	cin >> s;
  
  int ans=0;
  for(int i=0;i<n-2;i++){
    if(s.substr(i,3)=="ABC")	ans++;
  }
  cout << ans; 
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	ll n;
	cin >> n;
	ll ans = 0, now = 0;
	for (ll i = 0; i < n; i++)
	{
		ll a;
		cin >> a;
		if (now > a)
			ans += now - a;
		now = max(now, a);
	}
	cout << ans << endl;
}



Measured memory_bytes: 3632
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
    int n;  cin >> n;
    string *w = new string[n];
    map<string,int> m;

    for (int i = 0; i < n; i++) {
        cin >> w[i];
        m[w[i]]++;
    }
    
    bool can = true;
    for (int i = 0; i < n-1; i++) {
        if (w[i][w[i].length()-1] != w[i+1][0] || m[w[i]] > 1 || m[w[i]] > 1)   
            can = false;
    }

    if (can)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<algorithm> // sort,reverse,min,lower_bound
using namespace std;
#define df 0
typedef long int li;

li wid(li l,li r){
  if(l>r)return 0;
  return r-l+1;
}
int main(){
  if(df) printf("*debug mode*\n");

  int n; cin >>n;
  set<pair<li,li>> temp;
  li max_w=0;
  for(int i=0;i<n;i++){
    li l,r; cin >>l >>r;
    temp.insert(make_pair(l,r));
    if(r-l+1>max_w)max_w=r-l+1;
  }
  if(df){
    printf("temp\n");
    for(const pair<li,li>& x: temp){
      printf("%d %d\n",x.first,x.second);
    }
  }
  vector<pair<li,li>> s;
  while(not temp.empty()){
    pair<li,li> x=*(temp.rbegin());
    temp.erase(x);
    s.push_back(x);
    auto y=temp.rbegin();
    while(y!=temp.rend() and (*y).second>=x.second){
      temp.erase(*y);
      y=temp.rbegin();
    }
    if(y==temp.rend())break;
  }
  if(df){
    printf("s\n");
    for(const pair<li,li>& x: s){
      printf("%d %d\n",x.first,x.second);
    }
  }
  if(s.size()==1){
    pair<li,li> x=*(s.begin());
    cout << x.second-x.first+1+max_w;
    return 0;
  }
  reverse(s.begin(),s.end());
  li len=s.size(), xr=s[0].second, yl=s[len-1].first,ans=wid(yl,xr)+max_w;
  for(int i=0;i<len-1;i++){
    li xl=s[i].first, yr=s[i+1].second;
    li temp=wid(xl,xr)+wid(yl,yr);
    if(temp>ans)ans=temp;
  }
  printf("%ld",ans);
}

/// confirm df==0 ///


Measured memory_bytes: 8696
import java.util.*;

class Main {
    static int N;
    static char[][] A;
    static int M;
    static char[][] B;

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

        A = new char[N][N];
        for (int i = 0; i < N; i++)
            A[i] = sc.next().toCharArray();
        B = new char[M][M];
        for (int i = 0; i < M; i++)
            B[i] = sc.next().toCharArray();

        for (int ii = 0; ii <= N - M; ii++) {
            for (int jj = 0; jj <= N - M; jj++) {
                if (match(ii, jj)) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }

    public static boolean match(int ii, int jj) {
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < M; j++) {
                if (A[i + ii][j + jj] != B[i][j])
                    return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 21972
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = input[0];
  const A = input[1].trim().split(' ').map(Number);

  let ret = 'APPROVED';
  for(let i=0; i<N; i++){
    let tmp = A[i];
    let flg = true;
    if(tmp % 2 === 0 && tmp % 3 === 0){
      flg = false;
    };

    if(tmp % 2 === 0 && tmp % 5 === 0){
      flg = false;
    }

    if(tmp % 2 === 0 && flg){
      ret = 'DENIED';
    }
  };


  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////


int main(){
  ini(A,B,C,D,E,F);
  vi w(3010 , 0) , s(3010 , 0);
  for(int i = 0; i * A <= 30; i++){
    for(int j = 0 ; i * A + j * B <= 30; j++){
      w[100 * (i * A + j * B)] = 1;
    }
  }

  for(int i = 0 ; i * C <= 3000; i++){
    for(int j = 0 ; i * C + j * D <= 3000 ; j++){
      s[i * C + j * D] = 1;
    }
  }
  int W = A * 100 , S = 0;
  for(int i = 1; i <= 3000; i++){
    for(int j = 0; j <= 3000 ; j++){
      if(w[i] == 0) continue;
      if(s[j] == 0) continue;
      if(i + j > F) continue;
      //trc(i , j);
      if(j * 100 > i * E) continue;
      //trc(i , j);
      if( S * (i + j) < j * (W + S) ){
        W = i , S = j;
      }
    }
  }
  out(W + S, S);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5;
int a[maxn+5],b[maxn+5];
inline int Read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
	int n,h;
	n=Read();h=Read();
	for(int i=1;i<=n;i++){
		a[i]=Read();b[i]=Read();
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	int ans=0;
	for(int i=n;i>=1;i--){
		if(h>0&&b[i]>a[n]){
			h-= b[i];
			ans++;
		}
		if(h<=0){
			cout<<ans<<endl;
			return 0;
		}
	}
	printf("%d\n",ans+h/a[n]+(h%a[n]!=0));
	return 0;
}

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

int main(void) {
    int64_t A,B,H,M;
    cin >> A >> B >> H >> M;

    double a,b;
    b = ((double)M * M_PI)/ (double)30;
    a = (((double)H + ((double)M/60))*M_PI) / (double)6;

    a -= M_PI/2;
    b -= M_PI/2;
//printf("a:%lf b:%lf a:%lf b:%lf\n", a,b, cos(a), cos(b)); 

    // ベクトルC = A - B の大きさが答え
    double cx,cy;
    cx = ((double)A * cos(a)) - ((double)B * cos(b));
    cy = ((double)A * sin(a)) - ((double)B * sin(b));
//printf("a:%lf b:%lf\n", a*180.0/M_PI, b *180.0/M_PI);
//printf("cosa:%lf sina:%lf cosb:%lf sinb:%lf\n", cos(a), sin(a), cos(b), sin(b));
    cout << setprecision(12) << sqrt((cx*cx)+(cy*cy)) << "\n";
    return 0;
}


Measured memory_bytes: 4128
while True:
    a, op, b = input().split()
    a, b = int(a), int(b)

    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    elif op == '?':
        break

Measured memory_bytes: 7696