akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int V, E;
int u[1010], v[1010], c[1010];
struct edge { int to, cap, rev; };
vector<edge>G[110];
bool used[110];
void add_edge(int from, int to, int cap) {
	G[from].push_back(edge{ to,cap,(int)G[to].size() });
	G[to].push_back(edge{ from,0,(int)G[from].size() - 1 });
}
int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < G[v].size(); ++i) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, INF);
		if(f == 0)return flow;
		flow += f;
	}
}
int main() {
	cin >> V >> E;
	REP(i, E) {
		cin >> u[i] >> v[i] >> c[i];
		add_edge(u[i], v[i], c[i]);
	}
	cout << max_flow(0, V - 1) << endl;
	return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
inline int read()
{
    int x=0,t=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-') t=-1,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return x*t;
}
int n;
struct Node
{
	int t;
	int cnt;
}f[100005];
inline bool cmp(Node p,Node q)
{
	return p.cnt<q.cnt;
}
int main ()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		f[i].t=i;
		f[i].cnt=read();
	}
	sort(f+1,f+n+1,cmp);
	for(int i=1;i<=n;i++)
		printf("%d ",f[i].t);
	printf("\n");
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n;
    cin >> n;
    map<string,ll> mp;
    rep(i,n){
        string s;
        cin >> s;
        sort(all(s));
        mp[s]++;
    }
    ll ans = 0;
    for(auto s:mp){
        ans += s.second * (s.second-1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11376
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String text = sc.nextLine();

		String ansText = text.replace("apple", "Peach").replace("peach", "apple");
		ansText = ansText.replace("Peach", "peach");

		System.out.println(ansText);
	}

}

Measured memory_bytes: 25708
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int N;
long long h[100010];
long long dp[100010];

// iまでの最小の行き方を返す
long long rec(int i)
{
  if (dp[i] < INF)
  {
    return dp[i];
  }
  if (i == 0)
  {
    return 0;
  }
  long long res = INF;
  if (i == 1)
  {
    res = rec(i - 1) + abs(h[i] - h[i - 1]);
  }
  else
  {
    res = min(rec(i - 1) + abs(h[i] - h[i - 1]), rec(i - 2) + abs(h[i] - h[i - 2]));
  }
  dp[i] = res;
  return res;
}

int main()
{
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i)
    cin >> h[i];
  for (int i = 0; i < 100010; ++i)
    dp[i] = INF;
  cout << rec(N - 1) << endl;
  return 0;
}

Measured memory_bytes: 3328
import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;

void main() {
  int[] abc = readln.chomp.split.to!(int[]);
  if(abc[0]!=abc[1]&&abc[1]==abc[2] ||
     abc[0]!=abc[1]&&abc[0]==abc[2] ||
     abc[0]==abc[1]&&abc[1]!=abc[2]) writeln("Yes");
  else writeln("No");
}



Measured memory_bytes: 256
//06, 10, 2018, 09:42:45 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, m;

    scanf("%d %d", &n, &m);

    int r = -1;

    for(int i = 1 ; i * i <= m ; i++){
        if(m % i == 0){
            int a = m / i;
            
            if(m / a >= n){
                r = max(r, a);
            }

            if(m / i >= n){
                r = max(r, i);
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
int main()
{
int N=0;
 
std::cin >> N; 
 
long long int sum=1;
 
for(int i=1;i<N+1;i++)
{
sum*=i;
sum = sum % 1000000007;
}
 
std::cout << sum << std::endl;
 
return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
S = input()
CNTR = 0
CNTG = 0
CNTB = 0
for i in range(N):
    if S[i] == 'R':
        CNTR += 1
    if S[i] == 'G':
        CNTG += 1
    if S[i] == 'B':
        CNTB += 1
CONB = CNTR * CNTG * CNTB
CNT = 0
for i in range(N):
    for j in range(i,N):
        if S[j] != S[i]:
            k = j + (j-i)
            if k > N-1:
                continue
            if S[k] != S[i] and S[k] != S[j]:
                CNT += 1
print(CONB - CNT)

Measured memory_bytes: 9224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			int x, y;
			do {
				String[] list = br.readLine().split(" ");
				x = Integer.parseInt(list[0]);
				y = Integer.parseInt(list[1]);
				if (x == 0 && y == 0) {
					break;
				} else {
					if (x > y) {
						System.out.println(y + " " + x);
					} else {
						System.out.println(x + " " + y);
					}
				}
			} while (true);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24336
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a;
    vector<int> p;
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a;
        p.push_back(a);
    }
    sort(p.begin(), p.end());
    for(int j = 0; j < n; j++){
        if(j == n-1){
            sum += p[j]/2;
        }else{
            sum += p[j];
        }
    }
    cout << int(sum) << endl;
}


Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= putStrLn . solve 

solve :: [Int] -> String
solve = check . sort
    where
        check [1, 4, 7, 9] = "YES"
        check _ = "NO"

readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
	Q[tail]=x;
	tail=(tail+1)%LEN;
}

P dequeue(){
	P x=Q[head];
	head=(head+1)%LEN;
	return x;
}

int min(int a, int b){return a<b ? a:b;}

int main(){
	int elaps=0,c;
	int i, q;
	P u;
	scanf("%d %d",&n, &q);
	
	for(i=1; i<=n; i++){
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].t);
	}
	head=1; tail=n+1;
	
	while(head != tail){
		u=dequeue();
		c=min(q, u.t);
		u.t-=c;
		elaps+=c;
		if(u.t>0) enqueue(u);
		else{
			printf("%s %d\n",u.name, elaps);
		}
	}
	
	return 0;
}

Measured memory_bytes: 10756
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  ll A, B, C;
  while (cin >> A >> B >> C) {
    int res;
    if (A == B && A == C) {
      if (A % 2 == 0) {
        res = -1;
      } else {
        res = 0;
      }
    } else {
      for (int i = 0;; i++) {
        if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
          res = i;
          break;
        }
        ll a = (B + C) / 2;
        ll b = (A + C) / 2;
        ll c = (A + B) / 2;
        A = a;
        B = b;
        C = c;
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))

a += [0]
counter = 0

for i in range(N-1):
    flow = a[i] + a[i+1] - x
    if flow > 0:
        counter += flow
        a[i+1] = max(a[i+1]-flow, 0)

print(counter)


Measured memory_bytes: 14152
import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate, permutations
import sys
import bisect

sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

N, M, Q = mii()

ans = 0

ABCD = []
for i in range(Q):
    a, b, c, d = mii()
    ABCD.append([a-1, b-1, c, d])

def calc(arr):
    ret = 0
    for a, b, c, d in ABCD:
        if arr[b] - arr[a] == c:
            ret += d
    return ret

def dfs(length, n, arr):
    global ans
    if length == N:
        ans = max(ans, calc(arr))
        return
    for i in range(n, M+1):
        arr.append(i)
        dfs(length+1, i, arr)
        arr.pop(-1)


dfs(0, 1, [])

print(ans)

Measured memory_bytes: 9516
#include <iostream>

using namespace std; 

int N, M, K[50], A[50][50];

int C[50];

int main(void) {

	cin >> N >> M;

	for (int i = 1; i <= N; i++) {
		cin >> K[i];
		for (int j = 1; j <= K[i]; j++) {
			cin >> A[i][j];
		}
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= K[i]; j++) {
			C[A[i][j]]++;
		}
	}


	int ans = 0;

	for (int i = 1; i <= 30; i++) {
		if (C[i] == N) { ans++; }
	}

	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

long long a,b,c,k;

int main(){
  cin>>a>>b>>c>>k;
  if(k%2){
    cout<<(b-a)<<endl;
  } else {
    cout<<(a-b)<<endl;
  }
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n;
string s;
bool check[1000000 + 6];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    n = s.length();
    int ans = 0;
    rep(i, n) {
        if (check[i]) continue;
        int cnt_J = 0;
        int cnt_O = 0;
        int cnt_I = 0;
        rep2(j, i, n) {
            if(check[j]) continue;
            if (s[j] != 'J') break;
            cnt_J++;
            check[j] = true;
        }
        rep2(j, i, n) {
            if (check[j]) continue;
            if (s[j] != 'O') break;
            cnt_O++;
            check[j] = true;
        }
        rep2(j, i, n) {
            if (check[j]) continue;
            if (s[j] != 'I') break;
            cnt_I++;
            check[j] = true;
        }
        if (cnt_J >= cnt_O && cnt_I >= cnt_O) ans = max(ans, cnt_O);
    }
    cout << ans << endl;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n, m;
int s[10], c[10];
int num[10];
void solve() {
    cin >> n >> m;
    rep(i, m) cin >> s[i] >> c[i];

    bool ok = true;
    rep(i, n) num[i] = -1;
    rep(i, m) { if (num[s[i] - 1] != -1 && num[s[i] - 1] != c[i]) ok = false; num[s[i] - 1] = c[i]; }

    if (num[0] == -1) {
        if (n != 1)num[0] = 1; else num[0] = 0;
    }
    if (!ok || n != 1 && num[0] == 0) { cout << -1 << endn; return; }
    rep(i, n) if (num[i] == -1) cout << 0; else cout << num[i];
    cout << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const int mod=1e9+7;
const vi emp;
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

class Graph{
	private:
	int V;
	vvi List;
	public:
	Graph(int v){
		V=v;
		List=vvi(v);
	}
	void add_edge(int s,int t){
		List[s].push_back(t);
		List[t].push_back(s);
	}
	string solve(){
		vb used(V);
		queue<int> q;
		q.push(0);
		used[0]=1;
		while(!q.empty()){
			int v=q.front();
			q.pop();
			for(int i=0;i<List[v].size();i++){
				int u=List[v][i];
				if(!used[u]){
					used[u]=1;
					q.push(u);
				}
			}
		}
		for(int i=0;i<V;i++) if(!used[i]) return "NO";
		return "YES";
	}
};

int n,m;

int main(){
	cin>>n>>m;
	Graph g(n);
	vvi a(m);
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		for(int j=0;j<k;j++){
			int l;
			cin>>l;
			a[l-1].push_back(i);
		}
	}
	for(int i=0;i<m;i++) for(int j=1;j<a[i].size();j++){
		g.add_edge(a[i][j],a[i][j-1]);
	}
	cout<<g.solve()<<endl;
}

Measured memory_bytes: 8440
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {

  auto a=in.Array(3);
  sort(all(a));
  reverse(all(a));

  cout << (a[0]*10+a[1]+a[2]) << endl;

}


Measured memory_bytes: 256
#include <stdio.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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STRS(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define MED(a,b,c) ((a)<(b)?(a)>(c)?(a):(b)<(c)?(b):(c):(a)>(c)?(b)<(c)?(c):(b):(a))
#define RNG(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RNG3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXI(a,b) {if((a)<(b))(a)=(b);}
#define MINI(a,b) {if((a)>(b))(a)=(b);}
#define BEGINFOR(a,b,c,d,e,f,g,h,i) a;goto i##_6;i##_2:c;goto i##_6;i##_3:h;goto i##_7;i##_4:d;goto i##_8;i##_5:f;goto i##_8;i##_6:if(b)goto i##_4;else goto i##_9;i##_7:if(g)goto i##_5;else goto i##_1;i##_8:if(e)goto i##_2;else goto i##_3;i##_9:
#define CONTINUE(i) goto i##_3
#define BREAK(i) goto i##_1
#define ENDFOR(i) goto i##_3;i##_1:

int main(){
	char ch[6];
	fgets(ch, 5, stdin);
	if((ch[0] == ch[1] || ch[2] == ch[3]) && ch[1] == ch[2]) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

template<class T>
void show_1d_vector(const vector<T> &v){
    for(auto v1: v) {
        cout << v1 << " ";
    }
    cout << endl;
}


vector<ll> argsort(const vector<ll> &v) {
      vector<ll> index(v.size());
      iota(index.begin(), index.end(), 0);
      sort(index.begin(), index.end(),[&v](size_t i1, size_t i2) { return v[i1] < v[i2]; });
      return index;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    vector<ll> a2 = a;
    vector<ll> b2 = b;
    sort(all(a2));
    sort(all(b2));

    for(int i = 0; i < n; i++){
        if(a2[i]>b2[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = 0; i < n-1; i++){
        if(b2[i]>=a2[i+1]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    /*
    map<ll,ll> mp;
    map<ll,ll> mp_rev;
    for(int i = 0; i < n; i++){
        mp[a2[i]] = b2[i];
        mp_rev[b2[i]] = a2[i];
    }

    if(mp.size() != n){
        cout << "Yes" << endl;
        return 0;
    }
    for(int i = 0; i < n; i++){
        if(mp[a[i]] == b[i]){
            cout << "Yes" << endl;
            return 0;
        }
    }*/
    vector<ll> arga = argsort(a);
    vector<ll> argb = argsort(b);
    vector<ll> argb2(n);
    for(int i = 0; i < n; i++){
        argb2[arga[i]] = argb[i];
    }
    vector<bool> used(n,false);
    ll cnt = 0;
    ll next = 0;
    while(!used[next]){
        used[next] = true;
        next = argb2[next];
        cnt++;
    }
    if(cnt == n){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }


    return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-indexか1-indexでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-index昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-index昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-index降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-index降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int H, W, h, w; cin >> H >> W>>h>>w;
    cout << (H-h)*(W-w) << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int A, P;
  cin >> A >> P;

  int ans = (3 * A + P) / 2;
  cout << ans << endl;
  return 0;
}



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


int main()
{
    /*A
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    */
    /*B
    ll x;
    cin>>x;
    ll count1 = x/500;
    x=x-500*count1;
    ll count2 = x/5;
    cout<<count1*1000+count2*5<<endl;
    */

    int k,n;
    cin>>k>>n;
    vector <int> a(n);
    int maxd=0;
    ll start=0;
    rep(i,n)
    {
        cin>>a[i];
        if(i>=2)
        {
            if(maxd<a[i]-a[i-1])
            {
                start = i;
                maxd = a[i]-a[i-1];
            }
            
        }
        if(i==n-1)
        {
            if(maxd<k-a[n-1]+a[0])
            {
                start = 0;
                maxd = k-a[n-1]+a[0];
            }
        }
    }
   
    cout<<k-maxd<<endl;

   
    return 0;

}

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

using namespace std;

#define intt long long 
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int a[N];

int main() {

	FAST;

	string a, b;
	int n, m;
	cin >> a >> b;
	cin >> n >> m;
	string c;
	cin >> c;
	if (c == a) n --;
	else m --;
	cout << n << ' ' << m << '\n';
	return 0;
}

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

int main() {
    int64_t N, K;
    cin >> N >> K;
    while (true) {
        if (N > K) {
            N -= (int64_t)(N / K) * K;
        } else {
            if (N < K - N) {
                break;
            }
            N = K - N;
        }
    }

    cout << N << endl;
    return 0;
}


Measured memory_bytes: 256
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compare(const void *a, const void *b)
{
    return strcmp((const char *)a, (const char *)b);
}

int main(void)
{
    intmax_t N;
    char S[(int)2e5][11];
    intmax_t ans = 0;

    scanf("%jd", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%s", &S[i][0]);
    }

    qsort(S, N, sizeof(S[0]), compare);

    ans = 1;
    for (size_t i = 1; i < N; i++) {
        if (strcmp(S[i], S[i - 1]) != 0)
            ans++;
    }

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

    return 0;
}


Measured memory_bytes: 6096
import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if((a*b)%2==0)
            System.out.println("Even");
        else
            System.out.println("Odd");      
    }
}

Measured memory_bytes: 21844
n,k,*a=map(int,open(0).read().split())
v=[-1]*n
t=c=0
while v[t]<0: v[t]=c; c+=1; t=a[t]-1
l=v[t]
c-=l
print(v.index(min(k,l+(k-l)%c))+1)

Measured memory_bytes: 31776
#include <iostream>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == ',')
      cout << " ";
    else
      cout << s[i];
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 384
import math

a, b, h, m = map(int, input().split())

short = h/12+(m/60*1/12)
long = m/60

diff = abs(long-short)
ans = diff*360

if ans > 180:
    ans = 360-ans

total = a**2 + b**2 - 2*a*b*math.cos(math.radians(ans))
print(total**(1/2))


Measured memory_bytes: 9504
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll inf = 1e18;
ll mod=1e9+7;
//LLONG_MIN

ll a,b,c;

int main(void){
	cin>>a>>b>>c;
	if(c*a<=b){
		cout<<c<<endl;
	}else{
		cout<<b/a<<endl;
	}
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    vector<char> s(3);
    for (int i=0;i<3;i++){
        cin >> s.at(i);
    }
    
    int count = 0;
    for (int i=0;i<3;i++){
        if(s.at(i) == '1'){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3632
// include headers{{{
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*}}}*/
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;


long long min(long long a, long long b) {
    if (a < b) return a;
    else return b;
}


int main() {
    long long a, b, q; cin >> a >> b >> q;
    long long x, ans, candidate;
    long long s1, s2, t1, t2;
    long long inf = 1001001001001001;
    vector<long long> s(a+2); rep(i, a) cin >> s[i+1];
    vector<long long> t(b+2); rep(i, b) cin >> t[i+1];

    s[0] = -inf; s.back() = inf;
    t[0] = -inf; t.back() = inf;

    rep (i, q) {
        ans = inf;

        cin >> x;
        int s_right_idx = lower_bound(s.begin(), s.end(), x) - s.begin();
        int t_right_idx = lower_bound(t.begin(), t.end(), x) - t.begin();

        s1 = s[s_right_idx];
        s2 = s[s_right_idx-1];
        t1 = t[t_right_idx];
        t2 = t[t_right_idx-1];

        for (auto s: {s1, s2}) {
            for (auto t: {t1, t2}) {
                // 1. x -> s, s -> t
                // 2. x -> t, t -> s
                candidate = min(abs(s-x) + abs(t-s), abs(t-x) + abs(s-t));
                ans = min(ans, candidate);
            }
        }
        cout << ans << endl;
    }

    return 0;
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	ll rem;
	int k;cin>>k;
	if(k&1){
		ll t=1;
		rem=7%k;
		while(rem){
			rem*=10;
			rem+=7;
			rem%=k;
			t++;
			if(t>k){
				db(-1);return 0;
			}
		}
		db(t);
	}
	else db(-1);
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 3576
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (1 << 29)

using namespace std;

int main()
{
	int N, M;

	scanf("%d", &N);
	scanf("%d", &M);

	vector<int> P(N);
	vector<int> C(M);
	vector<int> E(M);

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &P[i]);
	}

	for (int i = 0; i < M; i++)
	{
		scanf("%d", &C[i]);
		scanf("%d", &E[i]);
	}

	vector<vector<int> > dp(M + 1, vector<int>(N + 1, INF)); dp[0][0] = 0;

	for (int i = 1; i <= M; i++)
	{
		for (int j = 0; j <= N; j++)
		{
			dp[i][j] = min(dp[i - 1][j], dp[i - 1][max(0, j - C[i - 1])] + E[i - 1]);
		}
	}

	sort(P.begin(), P.end(), greater<int>());

	vector<int> S(N + 1); S[0] = 0;

	for (int i = 1; i <= N; i++)
	{
		S[i] = S[i - 1] + P[i - 1];
	}

	int ret = 0;

	for (int i = 0; i <= N; i++)
	{
		ret = max(ret, S[i] - dp[M][i]);
	}
	
	printf("%d\n", ret);

	return 0;
}

Measured memory_bytes: 22652
using System;
using System.Collections.Generic;
using System.Linq;

public class S
{

    private const long DP_INIT_MINUS1 = -1;
    private const double DP_INIT_DOUBLE_MINUS1 = -1.0;
	private const long MOD = 1000000007;


    //s
    private const int FIRST_WIN = 1;
    private const int SECOND_WIN = 0;

    private static long[,] dp;
    private static long[] cSum;
	
	private static List<int>[] tree; 
    private static int[] count = new int[250000];
    private static int[] adder = new int[250000];
    private static bool[] past = new bool[250000];


    public static void Main()
	{
		/*
        var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = input[0];
        var M = input[1];
        */

        var input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        var N = input[0];
        var K = input[1];
        solver(N,K);
        //solver(N,Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse));
    }

    public static void solver(int N, int K){

        /*
            ABC 138 D "Ki"
            都度加算は現実的じゃない。
            また木であることから、根から見たときに各ノードを通過するのは確実に1度きり。
            再帰でDFSチックな動作が実現できそう。私はDFSとか書いたことないけど。

            追：after_contestだけ落ちた。解説いわく、ノード番号がa<bのときbはaの子がなんちゃら・・・
            まあフィーリングで意味は分かってるからいいとして、その制約は本来無いから・・・
            まあフィーリングで意味は分かってるからいいとして、なぜ引っかかる

            こたえ：これは有向グラフで、a<bのときaが親であることに依存している。
            解決策：・・・？？？？
            よくわからないので適当にかきました

        
         */


        int[] input;
		tree = new List<int>[N+1];
        
		for(int i = 1; i <= N; i++){
			tree[i] = new List<int>();
            past[i] = false;
		}
        for(int i = 1; i < N; i++){
            input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            tree[input[0]].Add(input[1]);
            tree[input[1]].Add(input[0]);
        }

        for(int i = 0; i < K; i++){
            input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            adder[input[0]] += input[1];
        }

        dfsAdd(1,0);
        
        Console.Write(count[1]);
        for(int i = 2; i <= N; i++){
            Console.Write(" " + count[i]);
        }




    }

    public static void dfsAdd(int node, int currentAdd){
        past[node] = true;
        currentAdd += adder[node];
        count[node] += currentAdd;
        foreach(var tgt in tree[node]){
            if(past[tgt] == false)
                dfsAdd(tgt, currentAdd);
        }


    }

}

Measured memory_bytes: 64356
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

int count, index, d[110][110];
vector <int> v;

inline void update_index() {
    if (++count >= v[index])
        count = 0,
        ++index;
}

int main()
{
    int n, m, N;
    cin >> n >> m >> N;
    for (int x, i = 0; i < N; ++i)
        cin >> x,
        v.push_back(x);
    for (int i = 0; i < n; ++i)
        for (int j = (i % 2 == 0 ? 0 : m - 1); j >= 0 && j < m; j = (i % 2 == 0 ? j + 1 : j - 1)) {
            d[i][j] = index + 1;
            update_index();
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j)
            cout << d[i][j] << " ";
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 384
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <string.h>

int N, A;

int main() {
	scanf("%d", &N);
	scanf("%d", &A);
	printf("%d\n", N * N - A);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include<cstdio>
#include<iomanip>

using namespace std;

int main()
{
    
    double n;
    int k;
    
    cin >> n>>k;
    
    double ans=0.0000000000;
    for(int i=1;i<n+1;i++){
        double ians=1.0000000000;
        int now=i;
        while(1){
            if(now<k){
                ians*=0.5;
                now *= 2;
            }
            else break;
        }
        ans += ians;
    }
    
    
    cout <<setprecision(11)<< ans/n;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <map>

using ll = long long;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 200000;
int v[1 + nmax];
bool valid(int n) {
  if(0 < v[1])
    return 0;
  for(int i = 2; i <= n; i++) 
    if(v[i - 1] + 1 < v[i])
      return 0;
  return 1;
}
int frec[1 + nmax];

int main() {
  int n;
  std::cin >> n;
  for(int i = 1;i <= n; i++)
    std::cin >> v[i];
  if(valid(n) == 0)
    std::cout << -1;
  else {
    ll result = 0;
    for(int i = n; 1 <= i; i--) {
      if(frec[i - v[i]] == 0) {
        result += v[i];
        frec[i - v[i]] = 1;
      }
    }
    std::cout << result;
  }
  return 0;
}


Measured memory_bytes: 5164
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;

int main(void){
  ll n, k, i;
  ll sum = 0;

  cin >> n >> k;

  ll right, left;
  right = (k-1) * k / 2;
  left = (n+n-k+1) * k / 2;

  for(i=k;i<=n+1;i++){
    sum += (left-right+1);
    sum %= MOD;

    right += i;
    right %= MOD;
    left += (n-i);
    left %= MOD;
  }

  if(sum<0) sum += MOD;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3632
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sun Dec  2 21:04:54 2018
//
package main

import (
	"fmt"
	"strconv"
)

var n int

func is753(num string) bool {
	var has7, has5, has3 bool

	for i := range num {
		switch num[i] {
		case '7':
			has7 = true
		case '5':
			has5 = true
		case '3':
			has3 = true
		}
	}

	return has7 && has5 && has3
}

func num753(n int, arr []string) []string {
	if n == 0 {
		return arr
	}

	var ret []string
	for i := range arr {
		ret = append(ret, arr[i]+"7", arr[i]+"5", arr[i]+"3")
	}

	return append(arr, num753(n-1, ret)...)
}

func main() {
	fmt.Scan(&n)
	l := len(strconv.Itoa(n))

	arr := num753(l-1, []string{"7", "5", "3"})

	ans := 0
	for i := range arr {
		num, _ := strconv.Atoi(arr[i])
		if num <= n && is753(arr[i]) {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6656
import numpy as np
N,K,Q= map(int,input().split())
human=np.array([K-Q]*N)
ok=[0]*N
for i in range(Q):
    ok[int(input())-1] +=1
ok_np=np.array(ok)
suv= human+ok_np
for i in suv:
    if i>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 18108
N = int(input())
ans = 0
a = 0
b = 0
ba = 0
for _ in range(N):
    S = input()
    ans += S.count('AB')
    if S[0] == 'B' and S[-1] == 'A':
        ba += 1
    if S[0] != 'B' and S[-1] == 'A':
        a += 1
    if S[0] == 'B' and S[-1] != 'A':
        b += 1

if ba == 0:
    print(ans + min(a, b))
else:
    if a + b == 0:
        print(ans + ba - 1)
    else:
        print(ans + ba + min(a, b))


Measured memory_bytes: 44264
#include<bits/stdc++.h>
#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 REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=21,M=(1<<21)+5;
int trans[M][2],n,aim,len,best;
char st[M];
vi f[N];

void dfs(int k,int now){
	int sum=0;
	for(int i=1;i<f[k].size();i++)
		sum+=f[k][i];
	if(sum>=aim){
		if(k>len||k==len&&now<best)
			len=k,best=now;
	}
	if(k==n)return;
	REP(t,2){
		fill(f[k+1].begin(),f[k+1].end(),0);
		REP(i,f[k].size())
			if(f[k][i])f[k+1][trans[i][t]]+=f[k][i];
		dfs(k+1,(now<<1)|t);
	}
}

int main(){
	read(n),read(aim);
	rep(k,0,n){
		f[k].resize(1<<(n-k+1));
	}
	REP(i,1<<(n+1)){
		int s=i,k=n+1;
		while(k&&!(s>>k&1))k--;
		for(k--;k>=0;k--){
			if(!trans[i][(s>>k)&1])
				trans[i][(s>>k)&1]=(s&((1<<k)-1))|(1<<k);
		}
	}
	rep(k,0,n){
		scanf("%s",st);
		REP(i,1<<k)
			if(st[i]=='1')
				f[0][i|(1<<k)]=1;
	}
	dfs(0,1);
	per(i,len-1,0)
		putchar('0'+(best>>i&1));
	return puts(""),0;
}

Measured memory_bytes: 34048
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int num,a,cnt,b,even;
  	cin >> num;
    a = num;
  	unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    //cin >> a;
    cnt=0;
  	even=digit/2;
    //cout << even << endl;
  	for(int i=0;i<even;i++){
        b = pow(100, i);
      	//cout << cnt << endl;
        cnt+=9*b;
      }
  	//cout << cnt << endl;
    if(digit%2==1){
        b = pow(10, digit-1);
        cnt+=a-b;
    }
  	b=pow(10, digit-1);
    if(a == b && digit%2==1){
        cout << cnt+1 << endl;
    }else if(a == b && digit%2==1){
      	cout << cnt << endl;
    }else if(digit%2==0){
        cout << cnt << endl;
    }else{
      	cout << cnt+1 << endl;
    }
    //cout << cnt+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) { cout << ", "; first = false; }
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n);
  for (lli i=0; i<n; ++i) cin >> v[i];
}

int main() {
  lli n, k;
  cin >> n >> k;
  cout << (n-k+1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAX 100
#define WHITE 0
#define BLACK 1
#define GRAY  2
#define INFNTY 10000000

int i, j, n ,M[MAX][MAX];

void dijkstra()
{ 
	int u2, v2, minv;
	int d[MAX], color[MAX];
	
	for (i = 0; i < n; i++) {
		d[i] = INFNTY;
		color[i] = WHITE;
	}
	
	d[0] = 0;
	color[0] = GRAY;
	
	while (1) {
		minv = INFNTY;
		u2 = -1;
		for (i = 0; i < n; i++) { 
			if (minv > d[i] && color[i] != BLACK) {
				u2 = i;
				minv = d[i];
			}
		}
		if (u2 == -1) {
			break;
		}
		color[u2] = BLACK;
		for (v2 = 0; v2 < n; v2++) {
			if (color[v2] != BLACK && M[u2][v2] != INFNTY) {
				if (d[v2] > d[u2] + M[u2][v2]) {
					d[v2] = d[u2] + M[u2][v2];
					color[v2] = GRAY;
				}
			}
		}
	}
	
	for (i = 0; i< n; i++) {
		printf("%d ",i);
		if (d[i] == INFNTY) {
			d[i] = - 1;
			printf("\n",d[i]);
		}
		else {
			printf("%d\n",d[i]);
		}
	}
}



int main() 
{
	int u, k, v, c;
	
	scanf("%d",&n);
	
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			M[i][j] = INFNTY;
		}
	}
	
	for (i = 0; i < n; i++) {
		scanf("%d %d",&u, &k);
		for (j = 0; j < k; j++) {
			scanf("%d %d",&v, &c);
			M[u][v] = c;
		}
	}
		
	dijkstra();
		
    return 0;
}


Measured memory_bytes: 2064
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int d, n;
    cin >> d >> n;
    
    int t = pow(100, d);
    
    if (n == 100) n = 101;
    cout << t * n << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>

using namespace std;

int main() {
  int N = 3;
  vector<vector<int>> C(N, vector<int>(N));
  for (int i = 0; i < N; ++i) {
    copy_n(istream_iterator<int>(cin), N, C[i].begin());
  }
  for (int i = 1; i < N; ++i) {
    for (int j = 1; j < N; ++j) {
      if ((C[0][j] - C[0][j - 1]) !=
          (C[i][j] - C[i][j - 1])) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

#define debug1(x)		  cout<<x<<endl
#define debug2(x,y)       cout<<x<<"   "<<y<<endl
#define debug3(x,y,z)     cout<<x<<"   "<<y<<"   "<<z<<endl
#define debug4(x,y,z,xy)  cout<<x<<"   "<<y<<"   "<<z<<"   "<<xy<<endl

#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pl(x) printf("%lld\n",x)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define MAX 1000000
#define mod 1000000007

int main(){
    ll x,n,i,a,b,c,j,k,ans=0;
    cin>>a>>b>>c;
    cin>>x;

    for(i=0;i<=a;i++){
        for(j=0;j<=b;j++){
            for(k=0;k<=c;k++){
                ll tot=i*500+j*100+k*50;
                if(tot==x){
                    ans++;
                }
            }
        }
    }

    pl(ans);
}


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

using namespace std;

int main() {
    int d;

    int n;
    cin >> n;

    set<int> S;
    for (int i = 0; i < n; i++) {
        scanf("%d", &d);
        S.insert(d);
    }

    int q;
    cin >> q;
    set<int> T;
    for (int i = 0; i < q; i++) {
        scanf("%d", &d);
        T.insert(d);
    }

    int C = 0;
    for (auto Si : S) {
        for (auto Ti : T) {
            if (Si == Ti) {
                C++;
            }
        }
    }

    cout << C << endl;

    return 0;
}

Measured memory_bytes: 3200