akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)

using namespace std;

string S;

//上からの下げを発生させる
#define SAGE 0
//上からの下げを発生させない
#define NO 1

long long dp[1000005][2];

int main(){
	cin >> S;
	reverse(S.begin(), S.end());
	S += '0';
	long long N = S.size();

	rep(i,N+2)rep(j,2)dp[i][j] = LONG_MAX/5;

	dp[0][NO] = 0;

	rep(i, N) {
		long long num = S[i] - '0';

		//SAGEからの遷移
		rep(j, 10) {
			long long mina = num + 1;
			if(mina > j) {
				// -> SAGE
				dp[i+1][SAGE] = min(dp[i+1][SAGE], dp[i][SAGE] + j + (10 + j - mina)); 

			} else {
				// -> NO
				dp[i+1][NO] = min(dp[i+1][NO], dp[i][SAGE] + j + (j - mina)); 
			}

		}

		//NOからの遷移
		rep(j, 10) {
			long long mina = num;
			if(mina > j) {
				// -> SAGE
				dp[i+1][SAGE] = min(dp[i+1][SAGE], dp[i][NO] + j + (10 + j - mina)); 
			} else {
				// -> NO
				dp[i+1][NO] = min(dp[i+1][NO], dp[i][NO] + j + (j - mina)); 
			}
		}

	}

	cout << dp[N][NO] << endl;
}


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

int main(){
  int n;
  cin >> n;
  int nh, nt, nm;
  nh = n / 100;
  nt = (n%100) / 10;
  nm = n%10;
  
  if(nh == 1) nh = 9;
  else nh = 1;

  if(nt == 1) nt = 9;
  else nt = 1;

  if(nm == 1) nm = 9;
  else nm = 1;

  cout << nh*100 + nt*10 + nm << endl;



}


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

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


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int N=2e5+1;
int n;
ll a[N];
pair<ll,int>b[N];
vector<int>adj[N];

ll dp[N];
ll tmp[N];
const int ts=1<<19;
ll mx[ts];
void upd(int id,int l,int r,int p,int v){
	if(l==r){
		mx[id]=v;
		return;
	}
	int mid=(l+r)/2;
	if(p<=mid) upd(id*2,l,mid,p,v);
	else upd(id*2+1,mid+1,r,p,v);
	mx[id]=max(mx[id*2],mx[id*2+1]);
}
ll qry(int id,int l,int r,int ql,int qr){
	if(l>qr || r<ql) return 0;
	if(ql<=l && r<=qr) return mx[id];
	int mid=(l+r)/2;
	return max(qry(id*2,l,mid,ql,qr),qry(id*2+1,mid+1,r,ql,qr)); 
}
void dfs(int id,int p){
	if(a[id]!=1) dp[id]=qry(1,1,n,1,a[id]-1)+1;
	else dp[id]=1;
	tmp[id]=qry(1,1,n,a[id],a[id]);
	upd(1,1,n,a[id],dp[id]);
	for(auto x:adj[id]){
		if(x==p) continue;
		dfs(x,id);
	}
	upd(1,1,n,a[id],tmp[id]);
}
void dfs2(int id,int p){
	dp[id]=max(dp[id],dp[p]);
	for(auto x:adj[id]){
		if(x==p) continue;
		dfs2(x,id);
	}
}
int main(){
	ios::sync_with_stdio(false);
	ll x,y,z;cin >> x >> y >> z;
	if((y-1)/x==z/x) cout << "NG\n";
	else cout << "OK\n";
}

Measured memory_bytes: 8336
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n, a, b = 0;
		int[] page;
		boolean flag = false;
		
		while (true) {
			n = sc.nextInt();
			if (n == 0) return;
			
			StringBuilder sb = new StringBuilder();
			
			page = new int[n + 1];
			for (int i = 0; i < n; i++) {
				page[i] = sc.nextInt();
			}
			
			flag = false;
			for (int i = 0; i < n; i++) {
				a = page[i];
				flag = false;
				for (int j = i + 1; j < n; j++) {
					if (page[j] - page[j - 1] == 1) {
						flag = true;
						b = page[j];
					} else {
						break;
					}
					i++;
				}
				if (flag) {
					sb.append(a);
					sb.append("-");
					sb.append(b);
				} else {
					sb.append(a);
				}
				
				if (i < n - 1) {
					sb.append(" ");
				}
			}
			
			System.out.println(sb.toString());
		}
	}
}

Measured memory_bytes: 34824
#!/usr/bin/env python3

def binsearch(l, r, pred): # [l, r)
    assert l < r
    l -= 1
    while r - l > 1:
        m = (l + r) // 2
        if pred(m):
            r = m
        else:
            l = m
    return r

import sys
def pred(n):
    assert 1 <= n and n <= 10 ** 18
    print('?', n)
    sys.stdout.flush()
    return input() == 'Y'

def solve():
    s = ''
    s += str(binsearch(1, 9 + 1, lambda c: not pred(int(s + str(c)))) - 1)

    if s == '9':
        f = lambda k: pred(int('1' + '0' * k))
    else:
        f = lambda k: not pred(int('9' * k))
    k = 1
    while f(k):
        k += 1
        if k >= 13:
            return 1
    if k == 1:
        s = ''

    for _ in range(k - 2):
        s += str(binsearch(0, 9 + 1, lambda c: not pred(int(s + str(c)))) - 1)
    s += str(binsearch(0, 9 + 1, lambda c: pred(int(s + str(c) + '0'))))

    return int(s)

print('!', solve())


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    ll cnt = 0;
    REP(i,0,N) {
        if(A[i] > 2) {
            cnt += (A[i] - 1) / 2;
            A[i] -= (A[i] - 1) / 2 * 2;
        }
    }
    
    ll k = 0;
    while(k < N - 1) {
        while(A[k] == 0) ++k;
        while(k < N && A[k] == 2) {
            A[k] = 0;
            ++k;
            ++cnt;
        }
        while(A[k] == 0) ++k;
        while(A[k] == 1 && k < N - 1) {
            if(A[k+1] > 1) {
                A[k] = 0; --A[k+1];
                ++k;
                ++cnt;
            }
            else if(A[k+1] == 1) {
                A[k] = 0; A[k+1] = 0;
                k += 2;
                ++cnt;
            }
            else k += 2;
        }
    }
    if(A[N-1] == 2) ++cnt;
    PR(cnt);

    return 0;
}

/*



*/

Measured memory_bytes: 3968
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<cassert>
#include<sstream>
#include<complex>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<ctime>
#include<cctype>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
#define EPS 1e-10
#define equals(a,b) (fabs((a)-(b)) < EPS) 
#define all(n) (n).begin(),(n).end()
#define MOD (1000000007LL)

using namespace std;
typedef long long ll;
int N,W;

int main()
{

  cin >> N >> W;
  vector<int> w(N);
  rep(i,N)cin >> w[i];
  sort(all(w));
  
  int sum[N];
  rep(i,N)
    {
      if(i == 0)sum[i] = w[i];
      else      sum[i] = w[i] + sum[i-1];
    }

  ll dp[W+1];
  rep(i,W+1)dp[i] = 0;
  dp[0] = 1;
  ll ans = 0;

  for(int i=N-1;i>=0;i--)
    {
      if(w[i] > W)continue;

      int cost=(i-1<0?0:sum[i-1]);
      for(int j=max(0,W-(int)w[i]+1-cost);j<=W-cost;j++)
	{
	  if(dp[j] == 0)continue;
	  assert(i != N-1);
	  ans = (ans+dp[j])%MOD;
	}

      for(int j=W;j>=0;j--)
	{
	  if(dp[j] == 0)continue;
	  if(j+w[i] > W)continue;
	  dp[j+w[i]] = (dp[j+w[i]]+dp[j]) % MOD;
	}
      /*
      if(i == 0)continue;
      int cost = (i-2<0?0:sum[i-2]);
      for(int j=max(0,W-(int)w[i-1]+1-cost);j<=W-cost;j++)
	{
	  ans = (ans+dp[j])%MOD;
	}
      */
    }

  //ans = (ans+dp[W])%MOD;

  if(ans == 0)ans = 1;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1280
n,a,b = map(int, input().split())


ans = 0

for i in range(n+1):
    n10000 = int(i/10000)
    n1000 =int(i/1000)-n10000*10
    n100 =int(i/100)-n1000*10-n10000*100
    n10 = int(i/10)-n100*10-n1000*100-n10000*1000
    n1 = int(i)-n10*10-n100*100-n1000*1000-n10000*10000
    s = n10000+n1000+n100+n10+n1
    if a<= s <= b:
        ans += i
print(ans)        

Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
	string str;
	cin >> str;
	int k;
	cin >> k;
	int n = str.length();
	VS strs;
	REP(i, n) {
		REP(j, k) {
			strs.push_back(str.substr(i, j + 1));
		}
	}
	sort(strs.begin(), strs.end());
	std::unique(strs.begin(), strs.end());
	cout << strs[k-1] << endl;
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,k,a[200005],pos=1;
map<ll,ll>viz;
int32_t main(){
CODE_START;
cin>>n>>k;
for(ll i=1;i<=n;i++)
{
    cin>>a[i];
    viz[i]=-1;
}
viz[1]=0;
ll val=1;
for(ll i=0;i<k;i++)
{
    pos=a[pos];
    if(viz[pos]!=-1){
        break;
    }
    val++;
    viz[pos]=val-1;
    if(i==k-1){
        cout<<pos<<endl;
        return 0;
    }
}
//cout<<pos<<' '<<val<<' '<<viz[pos]<<endl;
k=k-max(0LL,viz[pos]);
//cout<<k<<' ';
ll x=k/(val-viz[pos]);
//cout<<x<<' ';
k=k-x*(val-viz[pos]);
//cout<<k<<' ';
for(ll i=0;i<k;i++)

{
    pos=a[pos];
}
cout<<pos<<endl;
}


Measured memory_bytes: 17716
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

void printbin(u64 x)
{
    if (x / 2ULL > 0ULL)
    {
        printbin(x / 2ULL);
    }

    cout << (x % 2ULL);
}

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

    s64 N;
    cin >> N;

    u64 ans = 0;
    int cnt = 0;
    do
    {
        if (abs(N) % 2ULL)
        {
            ans |= ((u64)1 << cnt);
            if (cnt & 1)
            {
                N += (s64)1;
            }
            else
            {
                N -= (s64)1;
            }
        }
        N /= (s64)2;
        ++cnt;
    } while (N != 0);

    printbin(ans);
    cout << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9


int main() {
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		int tmp; cin >> tmp;
		ans += (tmp - 1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int n, m, l;
	cin >> n >> m >> l;

	vector< vector<int> > A(n, vector<int>(m, 0));
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			cin >> skipws >> A[i][j];

	vector< vector<int> > B(l, vector<int>(m, 0));
	for (int i = 0; i < m; ++i)
		for (int j = 0; j < l; ++j)
			cin >> skipws >> B[j][i];

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < l; ++j)
		{
			// For integer.
			// int sum = inner_product(A[i].begin(), A[i].end(), B[j].begin(), 0);

			// For 64bit integer.
			int64_t sum = 0;
			for (int k = 0; k < m; ++k)
				sum += A[i][k] * B[j][k];

			cout << sum << (j != l - 1 ? " " : "\n");
		}

	return 0;
}

Measured memory_bytes: 3168
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    long long X, Y, i=0;

    cin >> X >> Y;

    while(X <= Y){
        X *= 2;
        i++;
    }

    cout << i << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  string s;
  cin >> s;

  bool ans = true;
  rep (i, s.size ())
  {
    if (i % 2 == 0)
    {
      if (s [i] == 'R' || s [i] == 'U' || s [i] == 'D');
      else ans = false;
    }
    else
    {
      if (s [i] == 'L' || s [i] == 'U' || s [i] == 'D');
      else ans = false;

    }
  }
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;



int top(int n){
    int t = n%10;
    while(n>0){
        n /= 10;
        if(n>0) t = n%10;
    }
    return t;
}
int main(){
    int n;
    cin >> n;
    int table[9][9];
    rep(i,9)rep(j,9) table[i][j] = 0;
    for(int i = 1;i<=n;i++){
        int x,y;
        x = top(i);
        y = i%10;
        --x;--y;
        //cout << x <<" " << y<< endl;
        if(x == -1 || y == -1) continue;
        table[x][y]++;
    }

    // rep(i,9)rep(j,9){
    //     cout << "i " <<i<<" j "<<j<<endl;
    //     cout << table[i][j]<<endl;
    // }
    //cout << table[0][0] << endl;
    ll ans = 0;
    rep(i,9)rep(j,9){
        if(i==j) ans += table[i][j]*table[i][j];
        else  ans += table[i][j]*table[j][i];
    }

    cout << ans << endl;
 }

Measured memory_bytes: 3652
from collections import Counter
n = int(input())
d = list(map(int, input().split()))

if d[0] != 0:
    print(0)
    exit()

cnt = Counter(d)

if cnt[0] != 1:
    print(0)
    exit()

ans = 1
for i in d:
    if i != 0:
        ans = (ans * cnt[i-1]) % 998244353
print(ans)


Measured memory_bytes: 19936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }

const long long MOD = 1000000007;

void solve(long long N, long long M, std::vector<long long> a){
	vector<ll> dp(N+1);
	dp[0] = 1;
	REP(now, N) {
		FOR(next, now+1, min(N+1, now+3)) {
			if (a[next]) {
				dp[next] += dp[now];
				dp[next] %= MOD;
			}
		}
	}
	cout << dp[N] << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(N+1, true);
    for(int i = 0 ; i < M ; i++){
		ll n;
        scanf("%lld",&n);
		a[n] = false;
    }
    solve(N, M, std::move(a));
    return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  double t, x;
  cin >> t >> x;

  cout << t / x << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
 
int main() {
	int n,i,now,sum;
	cin>>n;
	int a[100000];
	int b[100000];
	memset(b,0,sizeof(int)*100000);
	
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	
	for(i=0;i<n;i++){
		b[a[i]-1]++;
	}
	
	int same=0;
	sum=0;
	for(i=0;i<100000;i++){
		if(b[i]>1){sum+=b[i];
		sum--;
		}
	}
	
	int ans=(sum+1)/2;
	ans=n-ans*2;
	cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define printArr(harry, tam) range(tam) cout << harry[i] << " \n"[i == tam -1];
#define range(n) for(int i = 0; i < n; i++)
#define maxn 100000
#define mod 1000000007
#define md(x) ((((x) % mod) + mod) % mod)
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define EPS 1e-9
#define INF INT_MAX
#define INFd 1e9

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;

//Trace dinamico
template<typename T>
void trace(T a) { cout << a << "\n"; }
template<typename T, typename... Args>
void trace(T a, Args... args) { cout << a << " "; trace(args...); }

//DP debug
int recNum = 0;
void prTabs() { range(recNum) cout << "    "; }
template<typename... Args>
void recInit(Args... args) { prTabs(); trace("rec(", args..., ")"); recNum++; }
template<typename T>
void recEnd(T a) { prTabs(); trace("->", a); recNum--;}
int n, m, a, b, c;

int main(){
	sc("%d %d %d", &a, &b, &c);
	if (a== b && b == c) {
		pr("Yes\n");
	} else {
		pr("No\n");
	}
	
 	return 0;
}


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

int lim = 1e6;
vector< int > fact(lim + 1, 1);

void factors() {
  fact[0] = 0, fact[1] = 1;
  for (int i = 2; i <= lim; i++) {
    for (int j = 1; i * j <= lim; j++) {
      fact[i * j] += 1;
    }
  }
}

int main() {
  int n;
  cin >> n;
  int sum = 0;
  factors();
  for (int i = 1; i < n; i++) {
    sum += fact[n - i];
  }
  cout << sum;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    ll ans = 0;
    set<ll> factors{N - 1};
    if(N == 1) {
        cout << 0 << endl;
    } else {
        for(ll i = 2;i * i <= N;i++) {
            if(N % i == 0) {
                factors.insert(i - 1);
                ll temp = N / i;
                if(N % temp == 0) factors.insert(temp - 1);
            }
        }
        iter(i, factors) {
            if(N / i == N % i) ans += i;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3912
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();


        System.out.println(H*W-( h*W+H*w-h*w));


    }

}


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


int main(void){
    int n,a,b;
    cin >> n >> a >> b;
    //scanf("%d %d %d",&n,&a,&b);

    int sum=0;
    for(int i=1;i<n+1;i++){
        int tmp=i;
        int d=0;
        while(i>=10){
            d += i%10;
            i /=10;
        }
        d += i;
        if(a<=d && d<=b) sum += tmp;
        i = tmp;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    //数列Aの個数
    let mut n = String::new();

    io::stdin()
        .read_line(&mut n)
        .expect("Failed to read line");

    let n: i32 = n.trim().parse().expect("Please type a number!");

    let mut sum_c : i32 = 0;
    let mut line = String::new();

    let mut cnt = 1;

    io::stdin()
        .read_line(&mut line).unwrap();
        line.trim_end().to_owned(); // 改行コードが末尾にくっついてくるので削る

        let mut ws = line.split_whitespace(); // 空白区切りの単語に分解する
    let mut b0: i32 = ws.next().unwrap().parse().unwrap(); // イテレータから値を取り出して整数に

    sum_c += b0;
    if n <= 2 {
        println!("{}", sum_c * 2);
        return;
    }

    while cnt < n - 1 {
        //let mut b1 = String::new();

        let b1: i32 = ws.next().unwrap().parse().unwrap(); // イテレータから値を取り出して整数に

        sum_c += min(b0, b1);
        b0 = b1;
        cnt += 1;

    }
                    sum_c += b0;

                    println!("{}", sum_c);
    }

    ///小さい方の値を返す
    fn min(x: i32, y: i32) -> i32{
        if x < y{
            return x;
        }
        return y;
    }


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

void call(int n){
	for (int i=1; i<=n; i++) {
		int x = i;

		if ( x % 3 == 0 ){
			cout << " " << i;
		} else if ( x % 10 == 3 ){
			cout << " " << i;
		} else {
			while (1) { 
				x /= 10;
				if (x) {
					if ( x % 10 == 3 ){
						cout << " " << i;
						break;
					}
				} else {
					break;
				}
			}
		}
	
	}
	cout << endl;
}

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	call (n);
	return 0;
}


Measured memory_bytes: 1164
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()


def solve():
    tc, xc, yc = 0, 0, 0
    for i in range(N):
        t, x, y = inm()
        d = abs(xc - x) + abs(yc - y)
        if d > (t - tc):
            return False
        if ((t - tc) - d) % 2 == 1:
            return False
        tc, xc, yc = t, x, y

    return True


print("Yes" if solve() else "No")


Measured memory_bytes: 9168
MOD = 10**9+7
def comb(n, k):
  res = 1
  for i in range(k):
    res *= n-i
    res %= MOD
    res *= pow(i+1, MOD-2, MOD)
  return res

n, a, b = map(int, input().split())
ans = pow(2, n, MOD) - comb(n, a) - comb(n, b) - 1
ans %= MOD
print(ans)

Measured memory_bytes: 41196
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let (n, m) = {
        let mut ws = s.split_whitespace(); // 空白区切りの単語に分解する
        let n: i64 = ws.next().unwrap().parse().unwrap(); // イテレータから値を取り出して整数に
        let m: i64 = ws.next().unwrap().parse().unwrap();
        (n, m)
    };
    println!("{}", n * (n - 1) / 2 + m * (m - 1) / 2)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,W;

  cin >> W >> a >> b ;

  int c=a+W,d=b+W;

  if(c<b) cout << b-c << endl;

  else if(d<a) cout << a-d << endl;

  else cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<map>
#include<set>
#define ll long long
//#define double long double
using namespace std;
#define PI  3.1415926535898 
#define eqs 1e-6
const long long max_ = 3000 + 7;
const int mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1e18;
int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') {
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * f;
}
int min(int a, int b) {
	return a < b ? a : b;
}
int max(int a, int b) {
	return a > b ? a : b;
}
int main() {
	int t = read();
	int flag = 1;
	while (t--)
	{
		int n = read();
		if (n % 2 == 0) {
			if (!(n % 3 == 0 || n % 5 == 0)) {
				flag = 0; break;
			}
		}
	}
	if (flag) {
		cout << "APPROVED";
	}
	else {
		cout << "DENIED";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <numeric>

using std::cin;
using std::cout;
using std::endl;
using std::string;;

template<typename iterator>
size_t maxIndex(iterator beginIt, iterator endIt) {
  return std::distance(beginIt, *std::max_element(beginIt, endIt));
}

template<typename iterator>
size_t minIndex(iterator beginIt, iterator endIt) {
  return std::distance(beginIt, *std::min_element(beginIt, endIt));
}

template<typename iterator>
int sum(iterator beginIt, iterator endIt) {
  return std::accumulate(beginIt, endIt, 0);
}

std::string lower(std::string src) {
  std::string dst = src;
  std::transform(src.begin(), src.end(), dst.begin(), tolower);
  return dst;
}

std::string upper(std::string src) {
  std::string dst = src;
  std::transform(src.begin(), src.end(), dst.begin(), toupper);
  return dst;
}


int main(void) {
  int num = 0;
  int max = 0;
  int min = 1000000000;
  int N;

  int A[100];
  
  cin >> N;

  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    min = std::min(min, A[i]);
    max = std::max(max, A[i]);
  }

  cout << abs(max - min) << endl;
  
  // cout << num << endl;
  return 0;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
using namespace std;
#define N (1000000000+7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
ll A(ll x){
    if(x>=0)return x;
    else return -x;
}
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

ll c[27];
ll s[400][27];
ll last[400][27];
ll score[27];

int main(void){
	int D;
	cin>>D;
	for(int i=1;i<=26;i++)cin>>c[i];
	for(int i=1;i<=D;i++){
		for(int j=1;j<=26;j++){
			cin>>s[i][j];
		}
	}
	vector<ll>mx(D+1,0);
	for(int d=1;d<=D;d++){
		ll S = 0;
		for(int i=1;i<=26;i++){
			if(S<s[d][i]){
				mx[d]=i;
				S = s[d][i];
			}
		}
	}
	ll ans=0;
	random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> rand26(1,26),randday(1,D);
	for(ll d=1;d<=D;d++){
		for(int i=1;i<=26;i++){
            last[d][i]=last[d-1][i];
            if(i==mx[d])last[d][mx[d]]=d;
        }
		ans+=s[d][mx[d]];
		for(ll j=1;j<=26;j++){
            ans-=c[j]*(d-last[d][j]);
		}
	}
	for(ll qu=0;qu<8;qu++){
		ll d = randday(mt);
		ll q = rand26(mt);
		ll tmp = ans;
		ans+=s[d][q]-s[d][mx[d]];
        ll old1 = last[d][mx[d]];
        ll new1 = last[d-1][mx[d]];
        ll old2 = last[d][q];
        ll new2 = d;
        for(ll i=d;i<=D;i++){
            tmp+=c[mx[d]]*(i-last[i][mx[d]]);
            if(last[i][mx[d]]==old1)last[i][mx[d]]=new1;
            tmp-=c[mx[d]]*(i-last[i][mx[d]]);
        }
        for(ll i=d;i<=D;i++){
            tmp+=c[q]*(i-last[i][q]);
            if(last[i][q]==old2)last[i][q]=new2;
            tmp-=c[q]*(i-last[i][q]);
        }
		if(ans<tmp){
			ans = tmp;
			mx[d]=q;
		} 
		else{
			for(ll i=d;i<=D;i++){
				if(last[i][mx[d]]==new1)last[i][mx[d]]=old1;
			}
			for(ll i=d;i<=D;i++){
				if(last[i][q]==new2)last[i][q]=old2;
			}
		}
	}
	for(int i=1;i<=D;i++)cout<<mx[i]<<endl;
    return 0;
}

Measured memory_bytes: 3800
using System;
using System.Linq;

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string s=Console.ReadLine();
    int N=s.Length;
    int ans=Math.Abs(int.Parse(s.Substring(0,3)));
    for(int i=0;i<N-2;i++){
      int tmp=int.Parse(s.Substring(i,3));
     // Console.WriteLine(tmp);
      if((Math.Abs(753-tmp))<(Math.Abs(753-ans))){
        ans=tmp;
      }
     // Console.WriteLine(ans);
    }
      Console.WriteLine(Math.Abs(753-ans));
    }
    
  }

}

Measured memory_bytes: 27288
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

struct Edge{
        int to;
        LL cost;
};
bool operator < (const Edge &e,const Edge &f){	return e.cost>f.cost;	};	//INVERSE!!
typedef vector<vector<Edge>> Graph;

void addEdge(Graph &g,int from,int to,LL cost){
    g[from].push_back((Edge){to,cost});
}

int dijkstra(const Graph &G, vector<LL> &dist, int s,int g)
{
    dist = vector<LL>(G.size(),LLMAX/2);
    priority_queue<Edge> que;
    que.push(Edge{s,0});
    while(!que.empty()){
        Edge e=que.top();
        que.pop();
        if(e.cost<=dist[e.to]){
            dist[e.to]=e.cost;
            for(int i=0;i<(int)G[e.to].size();i++){
                if(e.cost+G[e.to][i].cost < dist[G[e.to][i].to]){
                    dist[G[e.to][i].to] = e.cost+G[e.to][i].cost;
                    que.push(Edge{G[e.to][i].to,e.cost+G[e.to][i].cost});
                }
            }
        }
    }
    return dist[g];
}

int main(void){
    int N,M,S,T;
    GI(N);GI(M);GI(S);GI(T);
    S--;T--;
    Graph Yen(N),Snuke(N);
    REP(i,M){
        int U,V;
        LL A,B;
        GI(U);GI(V);GLL(A);GLL(B);
        U--;V--;
        addEdge(Yen,U,V,A);
        addEdge(Yen,V,U,A);
        addEdge(Snuke,U,V,B);
        addEdge(Snuke,V,U,B);
    }
    vector<LL> yDist,sDist;
    dijkstra(Yen,yDist,S,T);
    dijkstra(Snuke,sDist,T,S);
    vector<LL> ans(N);
    for(int i=N-1;0<=i;i--){
        LL r=yDist[i] + sDist[i];
        r = 1e15-r;
        if(i<N-1)
            r=max(r,ans[i+1]);
        ans[i]=r;
    }
    REP(i,N)
        printf("%lld\n",ans[i]);
    return 0;
}


Measured memory_bytes: 19012
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    ll a;
    cin>>a;
    if(a>=30)cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#include <vector>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define MININF -1e18L
using namespace std;
typedef long long ll;
typedef pair<int, int> intint;

int main(void)
{
    int n, m, c;
    cin >> n >> m >> c;

    vector<int> b(m);
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }   

    int ans = 0;
    for (int i = 0; i < n; i++) {
        vector<int> a(m);
        int tmp = 0;
        for (int j = 0; j < m; j++) {
            int a;
            cin >> a;
            tmp += a * b[j];
        }
        tmp += c;
        if(tmp > 0) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
import scala.io.Source.stdin

object Main extends App {
  println {
    stdin.getLines.map{ s=>
      s.foldLeft(List(0)){ (x,y) =>
        if(y.asDigit>=10 || y.asDigit < 0)
          {if(x.head>0) 0::x else x }
        else (x.head*10+y.asDigit)::x.tail
      }.sum
    }.sum
  }
}

Measured memory_bytes: 43848
def main():
    N, M = map(int, input().split())
    X = [int(a) for a in input().split()]

    if N >= M:
        print(0)
    else:
        X.sort()
        dlist = list()
        for i in range(M-1):
            d = abs(X[i] - X[i+1])
            dlist.append(d)
        dlist.sort()
        print(sum(dlist[:len(dlist) - (N-1)]))
if __name__ == "__main__":
    main()

Measured memory_bytes: 13960
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const int MOD = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int MAX = 200070;

int a[MAX];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    LL a,b;
    cin >> a >> b;
    LL ans = LINF;
    FOR(i, 1, a) {
        LL s1 = i * b;
        LL s2 = (a - i) / 2 * b;
        LL s3 = a * b - s1 - s2;
        LL s = min(min(s1, s2), s3);
        LL S = max(max(s1, s2), s3);
        ans = min(ans, S - s);
        
        s2 = b / 2 * (a - i);
        s3 = a * b - s1 - s2;
        s = min(min(s1, s2), s3);
        S = max(max(s1, s2), s3);
        ans = min(ans, S - s);

        
        
    }
    swap(a, b);
    FOR(i, 1, a) {
        LL s1 = i * b;
        LL s2 = (a - i) / 2 * b;
        LL s3 = a * b - s1 - s2;
        LL s = min(min(s1, s2), s3);
        LL S = max(max(s1, s2), s3);
        ans = min(ans, S - s);
        
        s2 = b / 2 * (a - i);
        s3 = a * b - s1 - s2;
        s = min(min(s1, s2), s3);
        S = max(max(s1, s2), s3);
        ans = min(ans, S - s);
        
        
        
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
use std::collections::HashSet;

fn main() {
    let wa1 = read_line_as_value::<u8>();
    let wa2 = read_line_as_value::<u8>();
    // println!("{} {}", wa1, wa2);
    let mut set: HashSet<u8> = [1, 2, 3].iter().cloned().collect();
    set.remove(&wa1);
    set.remove(&wa2);
    println!("{}", set.iter().next().unwrap())
}

fn read_line_as_value<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().parse() {
        Ok(val) => val,
        _ => panic!("error while parsing input: {}", input)
    }
}

Measured memory_bytes: 2156
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

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

  int d = x / 100;
  int r = x % 100;
  if (r <= d * 5) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto __VA_ARGS__:(c))
using namespace std;
typedef long long ll;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int H,W,K;
	cin>>H>>W>>K;
	vector<vector<int>> a(H,vector<int>(W));
	rep(i,0,H) {
		string s;
		cin>>s;
		rep(j,0,W) a[i][j]=s[j]-'0';
	}

	auto check=[&](int mask) {
		int h=__builtin_popcount(mask)+1;
		vector<vector<int>> b(h,vector<int>(W));
		rep(j,0,W) {
			int k=0;
			rep(i,0,H) {
				b[k][j]+=a[i][j];
				if (b[k][j]>K) return (int)1e9;
				if (mask>>i&1) k++;
			}
		}

		int res=h-1;
		vector<int> s(h);
		rep(j,0,W) {
			bool br=false;
			rep(i,0,h) {
				s[i]+=b[i][j];
				if (s[i]>K) br=true;
			}
			if (br) {
				res++;
				rep(i,0,h) s[i]=b[i][j];
			}
		}
		return res;
	};

	int res=H+W;
	rep(mask,0,1<<(H-1)) {
		res=min(res,check(mask));
	}
	cout<<res<<'\n';
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, a: "List[int]"):
    counter = 0
    nx = 0
    r = []
    for i in range(N):
        counter += 1
        r.append(a[nx])
        if a[nx] - 1 == 1:
            break
        nx = a[nx] - 1
    if counter < N and 2 in r:
        print(counter)
    else:
        print(-1)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10068
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll a,b,c;cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0){
        cout<<0<<endl;
        return 0;
    }
    ll res=3e18;
    ll buf=a*b;
    chmin(res,buf);
    buf=a*c;
    chmin(res,buf);
    buf=b*c;
    chmin(res,buf);
    cout<<res<<endl;
}

Measured memory_bytes: 3620
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

k = inp()
if k%2 == 0 or k%5 == 0:
    print(-1)
    quit()
now = 0
for i in range(k+10000):
    now += pow(10,i+1,k)*7
    # print(now)
    now %= k
    if now == 0:
        print(i+1)
        quit()
print(-1)


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

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  
  cout << *max_element(v.begin(),v.end()) - *min_element(v.begin(),v.end()) << endl;

}

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

int main() {
  int64_t k, a, b;
  std::cin >> k >> a >> b;

  int64_t k_c = 0, bis = 1;
  if (a + 1 < b) {
    k_c = std::min(a - 1, k);
    bis += k_c;

    if (2 <= k - k_c) {
      int64_t times = (k - k_c) / 2;
      bis += (b - a) * times;
      k_c += 2 * times;
    }

    if (k - k_c == 1) {
      bis += 1;
      k_c += 1;
    }

    std::cout << bis << std::endl;
  } else {
    std::cout << k + 1 << std::endl;
  }
  return 0;
}

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

int main()
{
  int h, w;
  cin >> h >> w;

  deque<string> rows;

  set<int> colIdxSet;

  for (int i = 0; i < h; i++)
  {
    string s;
    cin >> s;
    if (s.find('#') != string::npos)
    {
      for (int j = 0; j < s.size(); j++)
      {
        if (s[j] == '#')
        {
          colIdxSet.insert(j);
        }
      }
      rows.push_back(s);
    }
  }

  for (int i = 0; i < rows.size(); i++)
  {
    string row = rows[i];

    for (int j = 0; j < row.size(); j++)
    {
      if (colIdxSet.find(j) != colIdxSet.end())
      {
        cout << row[j];
      }
    }
    cout << endl;
  }

  return 0;
}


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

using namespace std;
int twosFound;
int main()
{
    int n;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        int x;
        scanf("%d",&x);
        while(x % 2 == 0)
            twosFound++,x /= 2;
    }
    cout << twosFound;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    int a, b;
    cin >> a >> b;
    if (a == 1) a = 14;
    if (b == 1) b = 14;
    if (a == b) cout << "Draw" << endl;
    else if (a > b) cout << "Alice" << endl;
    else cout << "Bob" << endl;
    return 0;
}

Measured memory_bytes: 256
typedef char Bool;
#define true 39
#define false 0 
typedef long long int64;
typedef unsigned long long uint64;
typedef int int32;
typedef unsigned int uint32;
typedef unsigned char byte;
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int n;
	int* a;
	int* b;

	scanf("%d", &n);

	a = (int*)malloc(n * sizeof(int));
	b = (int*)malloc(n * sizeof(int));

	for (int i = 0; i != n; i++)
	{
		scanf("%d", &a[i]);
	}

	b[0] = 0;

	for (int i = 1; i != n; i++)
	{
		if (a[i] <= b[i - 1] + a[i - 1])
		{
			b[i] = (b[i - 1] + a[i - 1]) - a[i];
		}
		else
		{
			b[i] = 0;
		}
	}

	uint64 c = 0;

	for (int i = 0; i != n; i++)
	{
		c += b[i];
	}

	printf("%llu", c);

	return 0;
}

Measured memory_bytes: 3240
// C.

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(int argc, char *argv[]) {
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	for (int i = 0; i < m; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	vector<int> dists;
	for (int i = 1; i < m; ++i) {
		dists.push_back(a[i] - a[i - 1]);
	}
	sort(dists.rbegin(), dists.rend());
 	long long ans = accumulate(dists.begin() + min(m - 1, n - 1), dists.end(), 0LL);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1276
extern crate core;

use std::io::{self, Read};
use std::collections::HashSet;

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
    ($line:expr,$name:ident,$t:tt) => {
        let $name=value!($line,$t);
    };
    }

    macro_rules! values_def {
    ($lines:expr,$n:expr,$name:ident,$t:tt) => {
        let $name={
        let mut vec=Vec::new();
        for i in 0..$n{
            let mut next=$lines.next().unwrap().split_whitespace();
            vec.push(value!(next,$t));
        }
        vec
        };
    };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize m:usize x:usize)(list:[usize]));
    let set = list.into_iter().collect::<HashSet<_>>();
    let a = {
        let mut res = 0;
        for i in 0..x {
            if set.contains(&i) {
                res += 1;
            }
        }
        res
    };

    let b = {
        let mut res = 0;
        for i in x..n {
            if set.contains(&i) {
                res += 1;
            }
        }
        res
    };
    std::cmp::min(a, b).to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "5 3 3\n1 2 4" => "1",
    test2: "7 3 2\n4 5 6" => "0",
    test3: "10 7 5\n1 2 3 4 6 8 9" => "3",
}


Measured memory_bytes: 4352