akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll a,b,c;
cin>>a>>b>>c;
ll sum=0;
for(int i=0;i<1000010;i++){
    sum=b*i;
    if((sum+c)%a==0){
        cout<<"YES"<<endl;
        break;
    }
    if(i==1000000){
        cout<<"NO"<<endl;
        break;
    }
}

}










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

ll dp[2005][2005];
ll mod = 1e9 + 7;

int main() {
    ll S; cin >> S;
    for (int i = 3; i <= S; i++){
        dp[1][i] = 1;
    }

    vector<ll> a(2005);
    for (int i = 1; i <= 700; i++){
        for (int m = 0; m < 2005; m++){
            a[m] = 0;
        }
        a[0] = dp[i-1][0];
        for (int m = 1; m < 2005; m++){
            a[m] = a[m-1] + dp[i-1][m];
            a[m] %= mod;
        }

        for (int j = i; j <= S; j++){
            if(j < 3)continue;
            dp[i][j] += a[j-3];
            dp[i][j] %= mod;
        }
    }

    ll ans = 0;
    for (int i = 1; i < 700; i++){
        ans += dp[i][S];
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14248
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int a, b, c, d; readV(a, b, c, d);
  writeln((a-c).abs <= d || (a-b).abs <= d && (b-c).abs <= d ? "Yes" : "No");
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(stdR.readLine());
        String[] S = new String[N];
        int[] t = new int[N];
        for(int i = 0 ; i < N ; i++) {
            String[] tmp = stdR.readLine().split(" ");
            S[i] = tmp[0];
            t[i] = Integer.parseInt(tmp[1]);
        }
        int sum = 0;
        boolean sleeped = false;
        String sleeps = stdR.readLine();
        for(int i = 0 ; i < N ; i++) {
            if(sleeped)sum += t[i];
            if(sleeps.equals(S[i]))sleeped = true;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 22356
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] A = new int[n];
		for (int i = 0; i < n; i++) {
			A[i] = sc.nextInt();
		}
		for(int i = 0; i < n/2; i++) {
			int tmp = A[i];
			A[i] = A[n-i-1];
			A[n-i-1] = tmp;
		}
		System.out.printf("%d", A[0]);
		for(int i = 1; i < n; i++) {
			System.out.printf(" %d", A[i]);
		}
		System.out.println();
	}
}	


Measured memory_bytes: 26368
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();
        
        if (a >= 3200 ) {
            System.out.println(s);
        }
        else {
            System.out.println("red");
        }
    
    }
}


Measured memory_bytes: 23636
N,M=map(int,input().split())
L=[0]*M
R=[0]*M
max=N
min=1
for kai in range(M):
    L[kai],R[kai]=map(int,input().split())

for tan in range(M):
    if(L[tan]>min):
        min=L[tan]
    if(R[tan]<max):
        max=R[tan]
    if(L[tan]>max):
        kotae=0
        break
    if(R[tan]<min):
        kotae=0
        break
    kotae=max-min+1
print(kotae)

Measured memory_bytes: 10868
import itertools
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
m = a + b + c
ok = []
tg = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
n = int(input())
bng = []
for _ in range(n):
    bng.append(int(input()))
for i in range(9):
    if m[i] in bng:
        ok.append(i)
ok = sorted(ok)
ans = itertools.permutations(ok, 3)
flag = 0
for i in ans:
    if list(i) in tg:
        flag += 1
if flag > 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
h, n = (int(x) for x in input().split())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
dp = [0] * (h + max(a for a, _ in ab))
for i in range(1, h + 1):
    dp[i] = min(dp[i - a] + b for a, b in ab)
print(dp[h])

Measured memory_bytes: 3540
def root(x):
  if table[x]==x:
    return x
  else:
    table[x]=root(table[x])
    return table[x]
def unite(x,y):
  x=root(x)
  y=root(y)
  if x!=y:
    if rank[x]<rank[y]:
      x,y=y,x
    rank[x]+=rank[y]
    table[y]=x
def same(x,y):
  return root(x)==root(y)
def size(x):
  return rank[root(x)]
(n,m),_,*e=[map(int,t.split())for t in open(0).readlines()]
*table,=range(n)
rank=[1]*n
a=[n*~-n//2]
for x,y in e[::-1]:
  x,y=x-1,y-1
  t=a[-1]
  if not same(x,y):
    t-=size(x)*size(y)
  a.append(t)
  unite(x,y)
print(*a[::-1],sep='\n')

Measured memory_bytes: 55916
def resolve():
	d, g = map(int, input().split())
	ps = []
	cs = []
	ans = 100**6
	for _ in range(d):
		p, c = map(int, input().split())
		ps.append(p)
		cs.append(c)
	for i in range(d-1, -1, -1):
		total = 0
		solved = 0
		for _ in range(ps[i]):
			if total >= g and ans > solved:
				ans = solved
			total += 100 * (i + 1)
			solved += 1
		total += cs[i]
		if total >= g and ans > solved:
			ans = solved
			break
		for j in range(1 << d):
			done = False
			t_solved = solved
			t_total = total
			for k in range(d-1, -1, -1):
				if (j >> k) & 1:
					if i == k:
						continue
					if done:
						break
					for _ in range(ps[k]):
						if done:
							break
						if t_total >= g and ans > t_solved:
							ans = t_solved
							done = True
							continue
						t_total += 100 * (k+1)
						t_solved += 1
					t_total += cs[k]
					if t_total >= g and ans > t_solved:
						ans = t_solved
	print(ans)
resolve()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N;
	cin >> N;
	N %= 10;
	string ans;
	switch (N)
	{
	case 0:
	case 1:
	case 6:
	case 8:
		ans = "pon";
		break;
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		ans = "hon";
		break;
	case 3:
		ans = "bon";
		break;
	}

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

Measured memory_bytes: 3628
#include<stdio.h>

int main(){
	long long K;
	scanf("%lld",&K);
	long long a[50];
	for(int i=0;i<50;i++)a[i]=K/50+i;
	K%=50;
	for(int i=0;i<K;i++){
		for(int j=0;j<50;j++){
			if(j==i)a[j]+=50;
			else a[j]--;
		}
	}
	printf("50\n");
	for(int i=0;i<49;i++)printf("%lld ",a[i]);
	printf("%lld\n",a[49]);
	return 0;
}

Measured memory_bytes: 128
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*16
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	vector<int> tmp;
	REP(i, 4) {
		int a;
		cin >> a;
		tmp.push_back(a);
	}
	sort(tmp.begin(), tmp.end());
	if (tmp[0] == 1 && tmp[1] == 4 && tmp[2] == 7 && tmp[3] == 9) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val num     = scala.io.StdIn.readInt
    val factors = scala.io.StdIn.readLine.split(" ")
    var sum = 0

    factors.foreach({ i=>
      sum += countDivisibleBy2(i.toInt)
    })
    println(sum)
  }

  def countDivisibleBy2(input: Int): Int = {
    var num = input
    var count = 0
    while(num%2 == 0) {
      num   =  num/2
      count += 1
    }

    return count
  }
}

Measured memory_bytes: 31032
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    map<ll,ll> sec;
    ll counter = 0;
    for(ll i = 0; i<n; i++){
        ll a; cin >> a;
        auto it = sec.find(i-a);
        if(it != sec.end()) counter += (it->second);
        sec[i+a]++;
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 16060
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
long long train[20][20] = {};
long long cost[20] = {};
int main() {
#define int long long
	int h, w;
	cin >> h >> w;
	REP(i, 10) {
		REP(q, 10) {
			cin >> train[i][q];
		}
	}
	for (int i = 0;i <= 9;++i) {
		int valuing[20] = {};
		int visited[20] = {};
		for (int q = 0;q < 20;++q) {
			valuing[q] = LONG_INF;
		}
		valuing[i] = 0;
		priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> next;
		next.push(make_pair(0, i));
		while (next.empty() == false) {
			pair<int, int> now = next.top();
			next.pop();
			if (visited[now.second] == 0) {
				visited[now.second] = 1;
				for (int q = 0;q <= 9;++q) {
					if (valuing[q] > now.first + train[now.second][q]) {
						valuing[q] = now.first + train[now.second][q];
						next.push(make_pair(now.first + train[now.second][q], q));
					}
				}
			}
		}
		cost[i] = valuing[1];
	}
	long long ans = 0;
	for (int i = 0;i < h;++i) {
		for (int q = 0;q < w;++q) {
			int a;
			cin >> a;
			if (a != -1) {
				ans += cost[a];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, int> PLDI;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
const int INF = (1e9);
const LL MOD = 1e9+7;
const double PI=atan2(0,-1);


int main()
{
    int h,w;
    cin>>h>>w;
    string s;
    int x,y;
    REP(j,h)
    REP(i,w)
    {
        cin>>s;
        if(s=="snuke")
        {
            x=i;
            y=j;
        }
    }
    cout<<(char)(x+'A')<<y+1<<endl;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
nflag = -1
count = 0
sum = 0
for i in range(N):
    sum += h[i]
while True:
    if sum == 0:
        print(count)
        break
    nflag = -1
    for i in range(N):
        if h[i] != 0 and nflag == -1:
            nflag = i
            if i == N - 1:
                h[i] -= 1
                sum -= 1
                count += 1
                break
        elif h[i] == 0 and nflag != -1:
            for j in range(nflag, i):
                h[j] -= 1
            sum -= i - nflag
            count += 1
            break
        elif i == N - 1 and nflag != -1:
            for j in range(nflag, i + 1):
                h[j] -= 1
            sum -= i - nflag + 1
            count += 1
            break

Measured memory_bytes: 3064
def main():
    s = input().rstrip()
    a, b = len(s), -1
    for i in range(len(s)):
        if s[i] == "C":
            a = i
            break
    for i in reversed(range(len(s))):
        if s[i] == "F":
            b = i
            break
    if a < b:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    string s;
    cin>>s;
    if(s[0]!=s[1] || s[1]!=s[2]){
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3652
/*    
                                                                             
	1. Practice makes a man perfect.
	2. Let go of the past.
	3. Without pain, without sacrifice, we would have nothing.
	4. Great things never come from comfort zones.
	5. Turn your wounds into wisdom.
	6. No pain ... no palm, no throne, no glory,no cross, no crown.
	7. You never know how strong you are until being strong is your only choice.
	8. Smooth seas do not make skillful sailors.
	9. I am not what happened to me, I am what I choose to become.
	10. No matter how fail life pushes you down, No matter how much you hurt,You can always bounce back.
		
		
	--> This lines keep me motivated.		

	Author:- Gaurang_Kothiya
	
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define bits(n) __builtin_popcountll(n)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846

const int inf= 1e9 +1;
const int inf64= 1e18 -1;
const int MOD= 1e9 +7;


 
void Solve()
{	
	int n,k;
	cin>>n>>k;
	m(char,bool) vis;
	f(i,1,k)
	{
		int x;
		cin>>x;
		vis[x+'0']=true;	
	}	
	while(true)
	{
		string s=to_string(n);
		bool f=true;
		fe(x,s)
		{
			if(vis[x]) f=false;
		}
		if(f)
		{
			cout<<n;
			return;
		}
		n++;
	}
}
 
signed main() 
{
	speed		

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    /*
    int a, b, c ;
    cin >> a >> b >> c ;
    //*/

    //*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    //*/
    
    /*
    if( a == 3 || a == 5 || a == 7 ){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    //*/
    
    cout << vec.at(0) * vec.at(1) / 2 << endl;

    return 0; 
}


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

int main() {
  int a;
  cin>>a;
  
  if(a<105){
    cout<<"0"<<endl;
  }
  else if(a<135){
    cout<<"1"<<endl;
  }
  else if(a<165){
    cout<<"2"<<endl;
  }
  else if(a<189){
    cout<<"3"<<endl;
  }
  else if(a<195){
    cout<<"4"<<endl;
  }
  else{
    cout<<"5"<<endl;
  }
}


Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a,b;
  while(cin>>a&&a){
    for(i=0;i<9;i++){
      cin>>b;
      a-=b;
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            const int N = 100;
            int[,] dp = new int[N + 1, N + 1];
            int[] p = new int[N + 1];

            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            p[0] = int.Parse(input[0]);
            p[1] = int.Parse(input[1]);

            for (int i = 2; i <= n; i++)
            {
                input = Console.ReadLine().Split(' ');
                p[i] = int.Parse(input[1]);
            }

            for (int l = 2; l <= n; l++)
            {
                for (int i = 1; i <= n - l + 1; i++)
                {
                    int j = i + l - 1;
                    dp[i, j] = int.MaxValue;

                    for (int k = i; k <= j - 1; k++)
                    {
                        dp[i, j] = Math.Min(
                            dp[i, j],
                            dp[i, k] + dp[k + 1, j] + p[i - 1] * p[k] * p[j]);
                    }
                }
            }
            Console.WriteLine(dp[1, n]);
        }
    }
}

Measured memory_bytes: 9244
#include<stdio.h>
#define N 25

struct Node{
  int p;
  int l;
  int r;
};
  
struct Node A[N];
int n,B[N],C[N];

  
int rec(int x,int y){
  B[x] = y;
  if(A[x].r != -1) rec(A[x].r,y+1);
  if(A[x].l != -1) rec(A[x].l,y + 1);
}

int Getb(int x){
  if(A[x].p== -1) return -1;
  if(A[A[x].p].l!=x&&A[A[x].p].l!=-1)
    return A[A[x].p].l;
  if(A[A[x].p].r!=x&&A[A[x].p].r!=-1)
    return A[A[x].p].r;
  return -1;
}

int Geth(int x){
  int a=0,b=0;
  if(A[x].l != -1) a=Geth(A[x].l)+1;
  if(A[x].r != -1) b=Geth(A[x].r)+1;
  return C[x]=(a>b ? a : b);
}

  
  

int main(){
  int i,j,d,v,c,l,r,n,op;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    A[i].p = A[i].l = A[i].r = -1;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&d,&op);
    A[v].l = d;
    A[v].r = op;
    if(d != -1) A[d].p=v;
    if(op != -1) A[op].p=v;
  }
  for(i=0;i<n;i++){
    if(A[i].p == -1) r=i;
  }

  rec(r,0);
  

  for(i=0;i<n;i++){
    int deg=0;
    if(A[i].l!=-1) deg++;
      if(A[i].r!=-1) deg++;
    
    Geth(i);
 
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,A[i].p,Getb(i),deg,B[i],C[i]);
    if(A[i].p == -1) printf("root\n");
    else if(A[i].l == -1 && A[i].r == -1 ) printf("leaf\n");
    else printf("internal node\n");

  }
  return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef int ll;
typedef long long int li;
const ll MAXN=2e5+51,MOD=1e9+7;
ll cnt,offset=3000,res;
ll x[MAXN],y[MAXN],fact[MAXN>>4],finv[MAXN>>4],dp[MAXN>>5][MAXN>>5];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
}
inline ll qpow(ll base,ll exponent)
{
	ll res=1;
	while(exponent)
	{
		if(exponent&1)
		{
			res=(li)res*base%MOD;
		}
		base=(li)base*base%MOD,exponent>>=1;
	}
	return res;
}
inline void setup(ll cnt)
{
	fact[0]=fact[1]=finv[0]=1;
	for(register int i=2;i<=cnt;i++)
	{
		fact[i]=(li)fact[i-1]*i%MOD;
	}
	finv[cnt]=qpow(fact[cnt],MOD-2);
	for(register int i=cnt-1;i;i--)
	{
		finv[i]=(li)finv[i+1]*(i+1)%MOD;
	}
}
inline ll calc(ll p)
{
	return (li)fact[(x[p]+y[p])<<1]*finv[x[p]<<1]%MOD*finv[y[p]<<1]%MOD;
}
int main()
{
	setup(8000),cnt=read();
	for(register int i=0;i<cnt;i++)
	{
		dp[offset-(x[i]=read())][offset-(y[i]=read())]++;
	}
	for(register int i=1;i<=(offset<<1);i++)
	{
		for(register int j=1;j<=(offset<<1);j++)
		{
			dp[i][j]=(dp[i][j]+(dp[i-1][j]+dp[i][j-1])%MOD)%MOD;
		}
	}
	for(register int i=0;i<cnt;i++)
	{
		res=(res+dp[offset+x[i]][offset+y[i]])%MOD;
		res=(res-calc(i)+MOD)%MOD;
	}
	printf("%d\n",res&1?(res+MOD)>>1:res>>1);
}


Measured memory_bytes: 150400
#include <iostream>
#include <vector>
#include <climits>
using namespace std;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<int> p(n), c(n);
  for (int i = 0; i < n; i++)
    scanf("%d", &p[i]);
  for (int i = 0; i < n; i++)
    scanf("%d", &c[i]);

  long long ans = LLONG_MIN;
  for (int i = 0; i < n; i++) {
    vector<int> t(n, -1);
    vector<long long> s;
    int now = i, a;
    for (int j = 0; j < n; j++) {
      t[now] = j;
      now = p[now] - 1;
      s.push_back((s.empty() ? 0 : s.back()) + c[now]);
      if (t[now] != -1) {
        a = j + 1;
        break;
      }
    }

    if (s.back() > 0) {
      for (int i = k - a + 1; i <= k; i++)
        if (i > 0) {
          long long v = (i / a) * s.back();
          if (i % a > 0) v += s[i % a - 1];
          ans = max(ans, v);
        }
    }
    else {
      for (int i = 0; i < s.size(); i++)
        ans = max(ans, s[i]);
    }
  }

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

  return 0;
}

Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;
ll n;
string s;
vector<ll> a;

int main(){
  cin >> n;
  a.resize(n,0);
  for(int i=0;i<n;i++) cin >> a.at(i);
  sort(a.begin(),a.end());
  ll i = 0;
  bool ng = 0;
  if(n%2 == 0){
    if(a.at(i) != 1) ng = 1;
    i++;
    if(a.at(i) != 1) ng = 1;
  }else{
    if(a.at(i) != 0 ) ng = 1;
  }
  if(ng){
    cout << 0 << endl;
    return 0;
  }
  i++;
  ll count = 1;
  while(i<=(n-1)){
    if(!( (a.at(i) == (a.at(0) + (2*count)) ) && (a.at(i+1) == (a.at(0) + (2*count))) )){
      ng = 1; break;
    }
    count++;
    i += 2;
  }
  if(ng){
    cout << 0 << endl;
    return 0;
  }  
  ll nn = n/2;
  ll ans = 1;
  while(nn--){
    ans = ans * 2 % mod;
  }
  cout << ans << endl;
  return 0;
}

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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    int n,k,sum=0;
    cin>>n>>k;
    int A[n+1];
    for(int i=0; i<n; i++)
        cin>>A[i];
    sort(A,A+n);
    for(int i=0; i<k; i++)
    {
        sum+=A[i];
    }
    cout<<sum<<nl;
    return 0;
}



Measured memory_bytes: 3648
from collections import deque
n = int(input())
target_list = deque()
for ni in range(n):
    cmd = input().split()
    if cmd[0] == "deleteFirst":
        target_list.popleft()
    elif cmd[0] == "deleteLast":
        target_list.pop()
    elif cmd[0] == "insert":
        target_list.appendleft(cmd[1])
    elif cmd[0] == "delete":
        try:
            target_list.remove(cmd[1])
        except ValueError:
            pass
print(*target_list)


Measured memory_bytes: 69736
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int a[100005];

int main()
{
    NO_TLE
    int n,sum=0;
    cin>>n;
    rer(i,1,n)
    {
        cin>>a[i];
        sum+=abs(a[i]-a[i-1]);
    }
    rer(i,1,n)
    {
        cout<<sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])+abs(a[n])<<endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
#define REP3(i,s,n) for(int i=s;i<n;i++)
using namespace std;

int main() {
    int N;
    cin >> N;
    int a[N];
    REP(i,N){
        cin >> a[i];
    }
    vector<int> v;
    vector<int>::iterator it;
    v.reserve(N);

    REP(i,N){
        if(i==0 || a[i] > *(v.end()-1))
            v.push_back(a[i]);
        else {
            it = lower_bound(v.begin(), v.end(), a[i]);
            *it = a[i];
        }
    }
    cout << v.size() << '\n';
}

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

using namespace std;

int main() {
    long double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << setprecision(20) <<  sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int ans = 0;

    for (int i = 1; i < n + 1; i++) {
        if (to_string(i).length() % 2 == 1) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    while(n){
        ++ans;
        n/=k;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
X = [-1] * 20
ans = 0
ma = -1
for i in range(N):
    for j in range(20):
        if A[i] & (1<<j):
            ma = max(ma, X[j])
            X[j] = i
    ans += i - ma
print(ans)


Measured memory_bytes: 23560
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string X,Y;
  cin>>X>>Y;
  int i,j;
  i=X[0];
  j=Y[0];
  if(i>j)
    {
      cout<<">"<<endl;
    }
   if(i==j)
    {
      cout<<"="<<endl;
	}
   if(i<j)
   {
    cout<<"<"<<endl;
  }
  return 0;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0, loop##i=(int)(n); i < loop##i; ++i)
#define FORE(x, y) for (auto &x : y)
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)(x).size())
template <class T, class U>
bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template <class T, class U>
bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }

constexpr int MOD = 1'000'000'007;
signed main() {
	int N, M;
	cin >> N >> M;
	vector<int> p(N, -1);
	vector<vector<int>> ch(N);
	REP(i, M) {
		int s, d;
		cin >> s >> d;
		s--, d--;
		p[s] = d;
		ch[d].push_back(s);
	}

	vector<bool> on_cycle(N);
	{
		vector<int> label(N, -1);
		REP(i, N) {
			if (label[i] == -1) {
				int cur = i, prv = -1;
				while (cur != -1) {
					if (on_cycle[cur]) break;
					if (label[cur] != -1 && label[cur] < i) break;
					if (label[cur] == i) {
						// cycle
						int endpoint = cur;
						cur = p[cur];
						while (cur != endpoint) {
							on_cycle[cur] = true;
							cur = p[cur];
						}
						on_cycle[endpoint] = true;
						break;
					}
					label[cur] = i;
					prv = cur;
					cur = p[cur];
				}
				if (cur == -1) {
					on_cycle[prv] = true;  // root
				}
			}
		}
	}
	
	vector<bool> vis(N, false);
	auto dfs = [&](auto f, int v) -> int {
		int ret = 1;
		FORE(w, ch[v]) {
			if (on_cycle[w]) continue;
			ret *= f(f, w);
			ret %= MOD;
		}
		ret++;
		return ret;
	};
	int ans = 1;
	REP(i, N) {
		if (!vis[i] && on_cycle[i]) {
			int tmp = 1;
			int cur = i;
			while (cur != -1) {
				vis[cur] = true;
				FORE(w, ch[cur]) {
					if (on_cycle[w]) continue;
					tmp *= dfs(dfs, w);
					tmp %= MOD;
				}
				cur = p[cur];
				if (cur == i) break;
			}
			tmp++;
			ans *= tmp;
			ans %= MOD;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3216
import sys

n=int(input())
a=list(map(int,input().split()))
a.reverse()
res=True
for i in range(1, n):
  if a[i-1]+1<a[i]:
    res&=False
  if a[i-1]+1==a[i]:
    a[i]-=1
print("Yes" if res else "No")

Measured memory_bytes: 63856
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#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;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

int dev_sum(int x)
{
    int sum = 0;
    REPD(i, 5)
    {
        int den = pow(10, i);
        int q = x / den;
        if (q > 0)
        {
            sum += q;
            x -= den * q;
        }
    }

    return sum;
}

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N, A, B;
    cin >> N >> A >> B;

    ll ans = 0, sum = 0;
    REP(i, N + 1)
    {
        sum = dev_sum(i);
        if (sum >= A && sum <= B)
        {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
#define mp make_pair
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcd(int a,int b){return a*b / gcd(a,b);}
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  string s;
  cin >> s;
  string res = "";
  rep(i,0,(int)s.length())res += 'x';
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  string tmp;
  vector<vector<int>> S(N,vector<int>(N));

  rep(i,N){
    cin >> tmp;
    rep(j,N){
      if(tmp[j]=='1'){
        S[i][j]=1;
      }
      else S[i][j]=0;
    }
  }

  int ans = -1;
  rep(s,N){
    vector<int> gr(N,-1);
    queue<int> q;
    q.push(s);
    gr[s] = 1;
    bool flag = true;
    while(!q.empty() && flag){
      int now = q.front(); q.pop();
      rep(j,N){
        if(S[now][j] == 1){
          if(gr[j] == -1) {
            gr[j] = gr[now]+1;
            q.push(j);
          }
          else if(abs(gr[j] - gr[now])!=1){
            flag = false;
            break;
          }
        }
      }
    }

    if(flag)for(auto x:gr) ans = max(ans,x);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
  string s;
  cin >> s;
  int cnt=0;
  int n=s.length();
  for(int i=0;i<n;i++){
    if(s[i]=='1'){
      cnt++;
    }
  }
  cout << min(cnt,n-cnt)*2 << endl;
}


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

ll dfs(ll x){
    multiset<ll> tmp;
    if(!edges[x].size()){
        return 0;
    }
    for (auto e : edges[x]) {
        tmp.insert(dfs(e));
    }
    ll ans = 0;
    ll ind = edges[x].size()-1;
    for (auto e : tmp) {
        ans = max(ans,e+ind);
        ind--;
    }

    return 1+ans;
}

int main() {
    std::cin >> n;
    edges.resize(n);
    
    for (int i = 0; i < n-1; i++) {
        ll a;
        std::cin >> a;
        edges[a-1].push_back(i+1);
    }
    std::cout << dfs(0) << std::endl;
}


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

int H, W;
bool R[510][510];
bool B[510][510];

int main() {
  cin >> H >> W;
  for (int i=0; i<H; i++) {
    R[0][i] = true;
    B[W-1][i] = true;
  }
  for (int y=0; y<H; y+=2) {
    for (int x=1; x<W-1; x++) {
      R[x][y] = true;
    }
    for (int x=1; x<W; x++) {
      B[x][y+1] = true;
    }
  }

  for (int y=0; y<H; y++) {
    for (int x=0; x<W; x++) {
      char c;
      cin >> c;
      if (c == '#') {
        R[x][y] = true;
        B[x][y] = true;
      }
    }
  }

  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cout << (R[j][i]?'#':'.');
    }
    cout << "\n";
  }
  cout << "\n";
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cout << (B[j][i]?'#':'.');
    }
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 1280
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n
x1 y1 h1
...
xn yn hn

n 100
x,y 100
h 10^9

out:
cx cy H
 */
int n,x[100],y[100],h[100];

int main(){
  cin>>n;
  int k;
  REP(i,n){
    cin>>x[i]>>y[i]>>h[i];
    if(h[i]>0) k=i;
  }

  LOG("k=%d\n",k);

  int cx=0,cy=0,H;
  for(cx=0; cx<=100; cx++){
    for(cy=0; cy<=100; cy++){
      H = abs(x[k]-cx) + abs(y[k]-cy) + h[k];
      //LOG("cx=%d, cy=%d, H=%d\n", cx, cy, H);
      bool f=true;
      REP(i,n){
        f = f && (h[i] == max(H-abs(x[i]-cx)-abs(y[i]-cy),0));
      }
      if(f){
        printf("%d %d %d\n", cx, cy, H);
        return 0;
      }
    }
  }

  LOG("hoge; cx=%d\n",cx);

  return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/04  Problem: ABC 098 B / Link: http://abc098.contest.atcoder.jp/tasks/abc098_b  ----- */


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

	LL N; 
	cin >> N;
	string s; cin >> s;
	int ans = 0;
	FOR(i, 1, N) {
		string a = s.substr(0, i);
		string b = s.substr(i);
		bitset<26>Ba,Bb;
		for (auto c : a) {
			Ba[c - 'a'] = 1;
		}
		for (auto c : b) {
			Bb[c - 'a'] = 1;
		}
		ans = max(ans, (int)(Ba&Bb).count());
	}
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main()
{
	int i,j,n, d, x, a[100],choco=0;

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

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

	printf("%d\n", choco+x);

		return 0;
}

Measured memory_bytes: 128
H, W, K = map(int, input().split())
table = []
for i in range(H):
    table.append(str(input()))
outer = 2**H
inner = 2**W
gyouketa  = '0'+str(H)+'b'
retuketa  = '0'+str(W)+'b'
count = 0
ans = 0
for i in range(outer):
    for j in range(inner):
        gyou = format(i, gyouketa)
        retu = format(j, retuketa)
        for h in range(H):
            if gyou[h] == '0':
                for w in range(W):
                    if retu[w] == '0' and table[h][w] == '#':
                        count += 1
        if count == K:
            ans += 1
        count = 0
print(ans)

Measured memory_bytes: 9224
K = int(input())
N = 50
A = [i for i in range(N)]
q, r = divmod(K, N)
for i in range(N): A[i] += q
for i in range(r):
    for j in range(N):
        if j == i: A[j] += N
        else: A[j] -= 1
print(N)
print(*A)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

vector<int> ob[200200];

int H,W,N;

int main()
{
	scanf ("%d %d %d",&H,&W,&N);
	for (int i=0;i<N;i++){
		int x,y; scanf ("%d %d",&x,&y);
		ob[x].push_back(y);
	}

	int dis = 1;
	for (int i=2;i<=H;i++) if (!ob[i].empty()){
		sort(ob[i].begin(),ob[i].end());
		if (ob[i][0] <= i-dis){
			printf ("%d\n",i-1);
			return 0;
		}
		if (ob[i][0] == i-dis+1) dis++;
	}
	printf ("%d\n",H);

	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    double n,m,d;
    cin >> n >> m >> d;
    if(d == 0)printf("%.9f",1 / n * (m - 1));
    else printf("%.9f",2 * (n - d) / (n * n) * (m - 1));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define endl "\n"
#define ll long long
#define N ((int)(3e5 + 5))
#define MOD ((int)(1e9 + 7))


using namespace std;


/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/

int arr[5][5];


int main()
{
    fastio;
    for(int i = 1 ; i<=3 ; i++){
        for(int j = 1 ; j<=3 ; j++) cin>>arr[i][j];
    }
    for(int i = 2 ; i<=3 ; i++){
        for(int j = 2 ; j<4 ; j++){
            if(arr[i][j] - arr[i][j-1] != arr[1][j] - arr[1][j-1]){
                cout<<"No\n";
                return 0;
            }
        }
    }
    cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 3612