akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll N=1000000007;
//ll power(ll a,ll b,ll mod)
//{
//    ll result=1;
//    while(b>0)
//    {
//        if(b%2==1)
//            result=(result*a)%mod;
//        a=(a*a)%mod;
//        b=b/2;
//    }
//    return result;
//}
//ll d,x,y;
//void extendedEuclid(ll a,ll b)
//{
//    if(b==0)
//    {
//        d=a; x=1; y=0;
//    }
//    else
//    {
//        extendedEuclid(b,a%b);
//        ll temp=x; x=y; y=temp-(a/b)*y;
//    }
//}
//ll modInverse(ll a,ll m)
//{
//    extendedEuclid(a,m);
//    return (x%m+m)%m;
//}
//ll lcm(ll a,ll b)
//{
//    if(a==0||b==0)
//        return 0;
//    return (a*b)/(__gcd(a,b));
//}
//void sieve(ll n)
//{
//    bool isPrime[n+1];
//    isPrime[0]=false; isPrime[1]=false;
//    for(ll i=2;i<=n;i++)
//        isPrime[i]=true;
//    for(ll i=2;i<=n;i++)
//    {
//        if(isPrime[i]==true)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//                isPrime[j]=false;
//        }
//    }
//}
//bool isPowerOfTwo(ll n)
//{
//    return (n&&!(n&(n-1)));
//}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,j=0,k=0,p=0,q=0; cin>>n; string s;
    for(i=0;i<n;i++){
        cin>>s;
        if(s[0]=='A') j++;
        else if(s[0]=='W')  k++;
        else if(s[0]=='T')  p++;
        else                q++;
    }
    cout<<"AC x "<<j<<endl;
    cout<<"WA x "<<k<<endl;
    cout<<"TLE x "<<p<<endl;
    cout<<"RE x "<<q;
}


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

int main(){
	int n;
	cin >> n;
	int ac=0,wa=0,tle=0,re=0;
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		if(s=="AC") ac++;
		if(s=="WA") wa++;
		if(s=="TLE") tle++;
		if(s=="RE") re++;
	}
	cout << "AC x " << ac << '\n';
	cout << "WA x " << wa << '\n';
	cout << "TLE x " << tle << '\n';
	cout << "RE x " << re << '\n';
}

Measured memory_bytes: 3604
#include <iostream>
bool f[100001];
int c[100002];
int N;

int main () {
  for(int i=2;i<=100000;i++)if(!f[i])for(int j=i+i;j<=100000;j+=i) f[j]=true;
  for(int i=3;i<=100000;i+=2)if(!f[i]&&!f[(i+1)/2])c[i]++; for(int i=3;i<=100000;i++)c[i]+=c[i-1];
  scanf("%d",&N);
  int L[N];
  int R[N];
  
  
  for(int i=0;i<N;i++){
      scanf("%d%d",&L[i],&R[i]);
      
  }
  for(int i=0;i<N;i++){
    
    printf("%d\n",c[R[i]]-c[L[i]-1]);
  }
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 #define MAX 1000000000005
 #define ll long long int
 int main()
 {    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        long long int m,sum=0,k=0,i,d=0,j,sum1=0,sum2=0,sum3=0,l,kk,sum4=0,sum5=0,sum6=0,c=0,x,y,q;
         ll n;
           cin>>n;
          ll a[n];
           for(i=0;i<n;i++)
             {cin>>a[i];
               c^=a[i];
             }
             for(i=0;i<n;i++)
               cout<<(c^a[i])<<" ";
    }
 







Measured memory_bytes: 5124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define imin INT_MIN
#define pll pair<ll,ll>
#define imax INT_MAX
int mod =1e9+7;

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

	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max({a*c,b*d,a*d,b*c});
	
	return 0;
}


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

int main()
{
	int n;
	cin >> n;
	vector<int>a(n);
	vector<int>f(1000005);
	int mx = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		f[a[i]]++;
		mx = max(mx, a[i]);
	}
	int ans = 0;
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		int x = a[i];
		if (f[x] == 1)ans++;
		for (int j = 2; x * j <= mx; j++)
			f[x * j] = 0;
	}
	cout << ans;
		
	
	
}

Measured memory_bytes: 7944
from collections import deque
data = deque()
num = [3,5,7]
def shiti(n):
    data.append(n)
    if n<=10**9:
        for i in range(3):
            shiti(n*10+num[i])
shiti(0)
data = list(data)
data = sorted(data)

N = int(input())
cnt = 0
for i in range(len(data)):
    if data[i] > N: break
    ni = list(str(data[i]))
    if "3" in ni and "5" in ni and "7" in ni:
        cnt += 1

print(cnt)

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

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

const int MAX=(1<<15);
int dp[5][MAX];

void solve()
{   
    dp[0][0]=1;
    for(int i=1;i*i<MAX;i++){
        for(int c=0;c<=3;c++){
            REP(j,MAX){
                if(j+i*i>=MAX) break;
                dp[c+1][j+i*i]+=dp[c][j];
            }
        }
    }
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
    int n;
    while(cin>>n,n){
        cout<<dp[1][n]+dp[2][n]+dp[3][n]+dp[4][n]<<endl;
    }
}


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String str = in.readLine();
    int n = Integer.parseInt(str);
    int sn = 0;
    for(int i = 0; i < str.length(); i++) {
      sn += Integer.parseInt(str.substring(i,i+1));
    }
    System.out.println(n%sn==0?"Yes":"No");
  }
}

Measured memory_bytes: 32604
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 100000;
const int MaxM = MaxN * 2 - 1;

int n, m;
int a[MaxM + 1];

inline int is_pillar(int l, int x)
{
	if (l > 1 && (a[l] > x) == (a[l - 1] > x))
		return a[l] > x;
	if (l < m && (a[l] > x) == (a[l + 1] > x))
		return a[l] > x;
	return -1;
}

inline bool check(int x)
{
	if (!is_pillar(n, x))
		return true;

	int pl = -1, vl = -1;
	for (int i = n; !~vl && i >= 1; --i)
		if (~(vl = is_pillar(i, x)))
			pl = i;

	int pr = -1, vr = -1;
	for (int i = n; !~vr && i <= m; ++i)
		if (~(vr = is_pillar(i, x)))
			pr = i;

	if (~vl && ~vr)
	{
		if (!vl && !vr)
			return true;

		int dl = n - pl, dr = pr - n;
		if (vl == 1)
			swap(dl, dr), swap(vl, vr);
		if (!vl && dl < dr)
			return true;
	}
	else
	{
		if (!vl || !vr)
			return true;

		int w = 0, b = 0;
		for (int i = 1; i <= m; ++i)
			a[i] <= x ? ++w : ++b;
		if (w > b)
			return true;
	}

	return false;
}

int main()
{
	cin >> n, m = n + n - 1;
	for (int i = 1; i <= m; ++i)
		a[i] = getint();

	int l = 1, r = m;
	while (l <= r)
	{
		int mid = l + r >> 1;
		if (check(mid))
			r = mid - 1;
		else
			l = mid + 1;
	}

	cout << l << endl;

	return 0;
}

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

int main(){
  int n;cin>>n;
  for(int i = 1; i <= 9; i++){
       if(n%i==0){
         if(n/i<10){
           cout<<"Yes";
           return 0;
         }
       }
  }
  cout<<"No";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }
    void run() {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next()),
            M = Integer.parseInt(sc.next());
        String[] A = new String[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.next();
        }
        String[] B = new String[M];
        for (int i = 0; i < M; i++) {
            B[i] = sc.next();
        }

        for (int i = 0; i + M <= N; i++) {
            for (int j = 0; j + M <= N; j++) {
                boolean yes = true;
                for (int k = 0; k < M; k++) {
                    yes = yes && (A[i + k].substring(j, j + M).equals(B[k]));
                }
                if (yes) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 22228
n = gets.to_i
a = gets.split.map(&:to_i).sort

ans = []
if a[0]<0 && a[-1]>0
  (n-2).times{|i|
    x = a.shift
    y = a.pop
    if 0 <= a.last
      a.unshift(x-y)
      ans<<[x,y]
    else
      a.push(y-x)
      ans<<[y,x]
    end
  }
  ans << [a.max, a.min]
  p a.max-a.min
else
  a.reverse! if a[0]<0
  (n-2).times{|i|
    y = a.pop
    ans << [a[0], y]
    a[0] -= y
  }
  ans << [a.max, a.min]
  p a.max-a.min
end

ans.each{|t| puts t*" "}

Measured memory_bytes: 25184
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define vbi vector<bool> 
#define mod 1000000007
#define INF 1000000000
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define ms(x,v) memset(x,v,sizeof x)
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
ll i,j,k;
void solve()
{
  ll n; cin>>n;
   vl v(n);
   frr(i,n) cin>>v[i];
   ll ans=0;
   for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
        ans=ans+(v[i]*v[j]);
    }
   }
   cout<<ans<<endl;
}
signed main(){
   
  
     solve();

  return 0;
}



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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    ll a, b , k;
    cin >> a >> b >> k;
    if(k < a){
        cout << a-k << " " << b << endl;
        return 0;
    }
    else{
        k -= a;
        if(k < b){
            cout << 0 << " " << b-k << endl;
         }
        else{
            cout << 0 << " " << 0 << endl;
        }
    }
}

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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    ll k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int pos = 1;
    vector<bool> vis(n + 1, 0);
    vi bef;
    vi cycle;
    while (!vis[pos]) {
        vis[pos] = 1;
        bef.pb(pos);
        pos = a[pos - 1];
    }
    fill(vis.begin(), vis.end(), 0);
    while (!vis[pos]) {
        vis[pos] = 1;
        cycle.pb(pos);
        pos = a[pos - 1];
    }
    int nb = bef.size(), nc = cycle.size();
    if (k <= nb - 1) {
        cout << bef[k] << '\n';
    } else {
        k -= nb - 1;
        k %= nc;
        if (k - 1 < 0) k += nc;
        cout << cycle[k - 1] << '\n';
    }
    return 0;
}

Measured memory_bytes: 6292
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
constexpr ll MOD = 998244353;
/*
void solve(){
  string s; cin >> s; int n = s.size();
  bool flg = true;
  FOR(i,0,n/2){
    if(s[i] != s[n/2-1-i]) flg = false;
  }
  FOR(i,0,n/2){
    if(s[n/2+1+i] != s[n-1-i]) flg = false;
  }
  if(flg) cout << "Yes";
  else cout << "No";
}
*/

/*
void solve(){
  int n, s;cin >> n >> s;
  vector<int> a(n);
  RPT(i,0,n) cin  >> a[i];
  vector<vector<int>> dp(n+1,vector<int>(n+1,0));
}
*/





void solve(){
  int h, w,k;
  cin >> h >> w >> k; vector<string> s(h); vector<vector<int>> mb(h,vector<int>(w,0));
  RPT(i,0,h) cin >> s[i];
  RPT(i,0,h)RPT(j,0,w) s[i][j] -= '0';
  int ans = h+w-2;
  for(int hh=0; hh<(1<<(h-1)); ++hh){
    int hcut = __builtin_popcount(hh);
    vector<int> hhh(h,0);
    FOR(i,0,h-1) hhh[i+1] = ( ((hh>>i)&1)==1);
    FOR(i,0,h-1) hhh[i+1] += hhh[i];
    int wcut = 0; vector<int> white(hcut+1,0);
    bool unable = false;
    for(int i=0;i<w; ++i){
      for(int j=0; j<h; ++j){
        if(s[j][i]==1) white[hhh[j]]++;
      }
      bool flg = false;
      for(int j=0; j<hcut+1;++j){
        if(white[j]>k){
          flg = true;
          wcut++;
          break;
        }
      }
      if(flg){ 
        FOR(j,0,hcut+1) {white[j] = 0;}
        for(int j=0; j<h; ++j){
          if(s[j][i]==1) white[hhh[j]]++;
        }
        flg = false;
        for(int j=0; j<hcut+1;++j){
          if(white[j]>k){
            unable = true;
            wcut+=98765432;
            break;
          }
        }
      }
      if(unable) {break; wcut = 987654321;break;}
    }
    ans = min(ans,hcut+wcut); //cout << hcut+wcut << endl;
  }
  cout << ans << endl;
}

int main(void){
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

int n, b, f, r, v;
int d[4][3][10] = { 0 };

int main() {
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		d[b - 1][f - 1][r - 1] += v;
	}
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 10; k++)
				cout << " " << d[i][j][k];
			cout << endl;
		}
		if (i != 3) cout << "####################" << endl;
	}
}

Measured memory_bytes: 1164
N,M = map(int,input().split())
AList = list(map(int,input().split()))
AList.sort(reverse=True)
NList=[0,2,5,5,4,5,6,3,7,6]
CList=[]
minnum = (-1)*(10**10)
dp = [0]*(N+1)

for a in AList:
    u = NList[a]
    if (u in CList) == False:
        CList.append(u)

dp[0] = 0
for n in range(1,N+1):
    max1 = minnum
    for c in CList:
        if c <= n:
            if dp[n-c] == minnum:
                num = minnum
            else:
                num = dp[n-c]+1
            if max1 < num:
                max1 = num
    dp[n] = max1
keta = dp[N]
s = ''
nn = N
for n in range(keta):
    for a in AList:
        if nn >= NList[a] and dp[nn-NList[a]] == dp[nn]-1:
            s += str(a)
            nn -= NList[a]
            break
print(s)


Measured memory_bytes: 3424
import copy

def add_num(li, op):
    ans = li[0]
    ans_str = ''
    for i in range(len(op)):
        if op[i] == 0:
            ans -= li[i + 1]
            op_str = '-'
        else:
            ans += li[i + 1]
            op_str = '+'
        ans_str += (str(li[i]) + op_str)
    if ans == 7:
        ans_str += str(li[-1])
        print(ans_str + '=7')
        exit()
    return ans


if __name__ == '__main__':
    tmp = list(input())
    tmp = [int(v) for v in tmp]
    op = [0,0,0]
    for i in range(0, 3):
        op_w = copy.copy(op)
        op_w[i] = 1
        add_num(tmp, op_w)
    for i in range(0,3):
        op_w = copy.copy(op)
        op_w[i] = 1
        if i + 1 == len(op):
            j = 0
        else:
            j = i + 1
        op_w[j] = 1
        add_num(tmp, op_w)
    add_num(tmp, op)
    add_num(tmp, [1,1,1])


Measured memory_bytes: 3444
#include<iostream>
using namespace std;
int a[1000000];
int search(int a[],int n,int key)
{
	int i=0;
	a[n]=key;
	while(a[i]!=key)
	{
		i++;
	}
	return i!=n;
}
int main()
{
     int i,n,key,q,num=0;
     cin>>n;
     for(int i=0;i<n;i++)
     {
     	cin>>a[i];
	 }
	 cin>>q;
	 for(int i=0;i<q;i++)
	 {
	 	cin>>key;
	 	if(search(a,n,key))
	 	{
	 		num++;
		 }
	 }
	 cout<<num<<endl;
	 return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
const ll INF = 1e9;

int main() {
    int a,b,c,d,e,f; cin >> a >> b >> c >> d >> e >> f;
    a *= 100;
    b *= 100;

    set<int> X;
    vector<int> Y;
    for (int i = 0; i < f/a + 1; i ++) {
        for (int j = 0; j < (f - a * i)/b + 1; j ++) {
            if (i == 0 && j == 0) continue;
            else X.insert(a * i + b * j);
        }
    }

    for (int i = 0; i < f/c + 1; i ++) {
        for (int j = 0; j < (f - c * i)/d + 1; j ++) {
            Y.push_back(c * i + d * j);
        } 
    }

    sort(Y.begin(),Y.end());
    double con = 0.0;
    pint ans = {0,0};
    for (int x:X) {
        int lim = min(e * x / 100, f - x);
        auto iter = upper_bound(Y.begin(),Y.end(), lim);
        if (iter == Y.begin()) continue;
        int y = *(iter - 1);
        if ((con * (x + y)) <= y) {
            con = (double)y/(x + y);
            ans = {x + y,y};
        }
    }

    cout << ans.first << ' ' << ans.second << endl;
}

Measured memory_bytes: 1400
n = int(input())
ab = [list(map(int,input().split())) for i in range(n-1)]
graph = [[] for i in range(n+1)]
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
ansls = []
for i in range(1,n+1):
  root = i
  stack = [i]
  dist = [-1 for i in range(n+1)]
  dist[root] = 0
  while stack:
    x = stack.pop()
    for y in graph[x]:
      if dist[y] == -1:
        dist[y] = dist[x]+1
        stack.append(y)
  mxd = max(dist)
  dls = [1 for i in range(mxd+1)]
  dls[0] = len(graph[root])
  ans1 = mxd+1
  ans2 = 1
  for j in range(1,n+1):
    d = dist[j]
    dls[d] = max(dls[d],len(graph[j])-1)
  for x in dls:
    ans2 *= x
  ansls.append((ans1,ans2))
for i in range(n-1):
  r1,r2 = ab[i]
  stack = [r1,r2]
  dist = [-1 for i in range(n+1)]
  dist[r1] = 0
  dist[r2] = 0
  while stack:
    x = stack.pop()
    for y in graph[x]:
      if dist[y] == -1:
        dist[y] = dist[x]+1
        stack.append(y)
  mxd = max(dist)
  dls = [1 for i in range(mxd+1)]
  ans1 = mxd+1
  ans2 = 2
  for j in range(1,n+1):
    d = dist[j]
    dls[d] = max(dls[d],len(graph[j])-1)
  for x in dls:
    ans2 *= x
  ansls.append((ans1,ans2))
ansls.sort()
print(*ansls[0])

Measured memory_bytes: 43632
import math

X = int(input())


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


for i in range(X,100000000):
    if is_prime(i):
        print(i)
        break


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;

struct Edge {
    int v, flow, C, rev;
};
 
const int SZ = 102;

struct Dinic {
    int level[SZ], start[SZ];
    vector<Edge> adj[SZ]; 
     
    void addEdge(int u, int v, int C) {
        Edge a{v, 0, C, (int)adj[v].size()};
        Edge b{u, 0, 0, (int)adj[u].size()};
        adj[u].pb(a);
        adj[v].pb(b); 
    } 
     
    bool BFS(int s, int t) {
        F0R(i,SZ) level[i] = -1;
        level[s] = 0;  
      
        queue<int> q; q.push(s);
        while (!q.empty()) {
            int u = q.front(); q.pop();
            for (auto e: adj[u]) 
                if (level[e.v] < 0  && e.flow < e.C) {
                    level[e.v] = level[u] + 1;
                    q.push(e.v);
                }
        }
     
        return level[t] >= 0;
    }
      
    ll sendFlow(int u, int flow, int t) {
        if (u == t) return flow;
      
        for (  ; start[u] < adj[u].size(); start[u] ++) {
            Edge &e = adj[u][start[u]]; 
                                          
            if (level[e.v] == level[u]+1 && e.flow < e.C) {
                int curr_flow = min(flow, e.C - e.flow);
                int temp_flow = sendFlow(e.v, curr_flow, t);
    
                if (temp_flow > 0) {
                    e.flow += temp_flow;
                    adj[e.v][e.rev].flow -= temp_flow;
                    return temp_flow;
                }
            }
        }
      
        return 0;
    }
     
    ll DinicMaxflow(int s, int t) {
        if (s == t) return -1;
        ll total = 0;  
      
        while (BFS(s, t)) {
            F0R(i,SZ) start[i] = 0;
            while (ll flow = sendFlow(s, INT_MAX, t)) total += flow;
        }
     
        return total;
    } 
};
  
Dinic D;

ll N, A[101], ans;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> N; 
	FOR(i,1,N+1) {
	    cin >> A[i];
	    for (int j = 2*i; j <= N; j += i) D.addEdge(i,j,1e18);
	    if (A[i] <= 0) D.addEdge(0,i,-A[i]);
	    else {
	        ans += A[i];
	        D.addEdge(i,N+1,A[i]);
	    }
	}
	ans -= D.DinicMaxflow(0,N+1);
	cout << ans;
}

// read!
// ll vs. int!

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3
#define MOD (ll)(1e9 + 7)

ll fact[100010];

void factorial() {
    fact[0] = 1;
    repl(i, 1, 100010) fact[i] = (i * fact[i - 1]) % MOD;
}

int main(){
    cin.sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    if (abs(n - m) > 1) {
        cout << 0 << endl;
    } else {
        factorial();
        if (n == m) cout << (((fact[n] * fact[m]) % MOD) * 2) % MOD << endl;
        else cout << (fact[n] * fact[m]) % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  int i,j;
  int n;
  cin>>n;
  int m=1<<n;
  int a[m];
  for(i=0;i<m;i++){
    cin>>a[i];
  }
  int ans=-1;
  for(i=1;i<m;i++){
    int m1=-1,m2=-1;
    int sub=i;
    do{
      if(m1<=a[sub]){
        m2=m1;
        m1=a[sub];
      }
      else if(m2<=a[sub]) m2=a[sub];
      sub=(sub-1)&i;
    } while(sub!=i);
    if(m1>=0&&m2>=0){
      ans=max(ans,m1+m2);
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string s;
    string t;

    for (int i = 0; i < 4; i++) {
        cin >> s;
        t += s;
    }

    sort(t.begin(), t.end());

    if (t == "1479") cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    ostr << p.first << " " << p.second;
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
// vll x(n); x[i]=a;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll n, ans = 0, tmp = 0;
    cin >> n;
    vll a(n);
    REP(i,n){
        cin >> tmp;
        a[tmp-1] = i+1;
    }
    cout << a << endl;
    return 0;
}


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

using namespace std;

long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}

int main(void){
    long long k;
    cin >> k;
    
    long long ans = 0;
    
    for (long long a = 1; a <=k; a++){
        
        for (long long b = 1; b <= k; b++){
            
            for (long long c = 1; c <= k; c++){
                
                long long temp = gcd(b, c);
                ans += gcd(a, temp);
            }
            
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout << endl
#define sp(x) cout << setprecision(x);
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vd vector<double> 
#define vvd vector<vector<double>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vd p(n);
	rep(i, n)cin >> p[i];
	vvd dp(n + 1, vd(n + 1, 0.));
	dp[0][0] = 1.;
	rep(i, n)rep(j, n)
	{
		dp[i + 1][j + 1] += p[i] * dp[i][j];
		dp[i + 1][j] += (1 - p[i]) * dp[i][j];
	}
	double ans = 0;
	rep(i, n+1)
	{
		if (i > n - i)ans += dp[n][i];
	}
	cout << setprecision(12);
	co(ans);
	return 0;
}


Measured memory_bytes: 70784
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    s = input()
    if s == "AC":
        ac += 1
    elif s=="WA":
        wa += 1
    elif s=="TLE":
        tle += 1
    else:
        re += 1

print("AC x ", ac)
print("WA x ", wa)
print("TLE x ", tle)
print("RE x ", re)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
#define rep(i, n) for(int i = 0; i < n; i++)
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main(){
    int n, m;
    int p[100000], y[100000];
    scanf("%d%d",&n,&m);
    pair<ll, ll> Pair;
    vector<int> v[100001];
    rep(i, m){
        scanf("%d%d", &p[i],&y[i]);
        v[p[i]].push_back(y[i]);
    }
    rep(i, n){
        sort(v[i+1].begin(), v[i+1].end());
    }
    rep(i, m){
        printf("%012lld\n", ll(p[i])*1000000+int(lower_bound(v[p[i]].begin(),
        v[p[i]].end(), y[i]) - v[p[i]].begin())+1);
    }
}



Measured memory_bytes: 7808
n = gets.to_i
n.times do
  line = gets
  s = line.split(" ").map(&:to_f)
  a1 = 2 * (s[2] - s[0])
  a2 = 2 * (s[4] - s[0])
  b1 = 2 * (s[3] - s[1])
  b2 = 2 * (s[5] - s[1])
  c1 = s[0] * s[0] - s[2] * s[2] + s[1] * s[1] - s[3] * s[3]
  c2 = s[0] * s[0] - s[4] * s[4] + s[1] * s[1] - s[5] * s[5]
  x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)
  y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1)
  r = Math.sqrt((x - s[0]) * (x - s[0]) + (y - s[1]) * (y - s[1]))
  printf("%.3f %.3f %.3f\n", x, y, r)
end

Measured memory_bytes: 6176
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define sz(x) ((int)x.size())

int dp[100005] = {0};
vector<int> g[100005];

void dfs(int u)
{
    if(dp[u])
        return;
    int mx = 0;
    for(auto &k: g[u])
        dfs(k), mx = max(mx, dp[k]);
    dp[u] = mx+1;
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
        if(!dp[i])
            dfs(i), ans = max(ans, dp[i]);
    cout << ans-1 << endl;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

class quick_find_weighted{
	public:
	int size=0,count_group;
	vector<int> belong;
	vector<set<int>> groups;
	quick_find_weighted(int size_):size(size_),belong(size_),groups(size_){
        count_group=size;
		for(int i=0; i<size; ++i){
			belong[i]=i;
			groups[i].insert(i);
		}
	}
	void unite(int x,int y){
		int gx=belong[x],gy=belong[y];
        assert(gx!=-1);
        assert(gy!=-1);
		if(gx==gy) return;
		if(groups[gx].size()<groups[gy].size()) swap(gx,gy);
		for(int z:groups[gy]) belong[z]=gx;
		groups[gx].insert(groups[gy].begin(),groups[gy].end());
		groups[gy].clear();
        --count_group;
	}
	int find(int x)const{
		return belong[x];
	}
    bool is_same_group(int x,int y)const{
        return find(x)==find(y);   
    }
	void erase(int x){
		int gx=belong[x];
		if(gx==-1) return;
		belong[x]=-1;
		groups[gx].erase(x);
	}
    int group_size(int x)const{
        int gx=belong[x];
        assert(gx!=-1);
        return groups[gx].size();   
    }
};


void solve(){
    int N,M;
    cin >> N >> M;
    
    vector<i64> a(N);
    rep(i,0,N) cin >> a[i];

    quick_find_weighted uf(N);
    rep(i,0,M){
        int x,y;
        cin >> x >> y;
        uf.unite(x,y);
    }

    if(uf.count_group==1){
        cout << 0 << endl;
        return;
    }

    if(2*(N-M-1)>N){
        cout << "Impossible" << endl;
        return;
    }

    vector<bool> used(N);
    i64 ans=0;
    rep(i,0,N){
        if(uf.find(i)!=i) continue;
        int idx;
        i64 cost=inf64;
        for(int j:uf.groups[i]){
            if(a[j]<cost){
                cost=a[j];
                idx=j;
            }
        }
        ans+=cost;
        used[idx]=true;
    }

    vector<i64> v;
    rep(i,0,N){
        if(used[i]) continue;
        v.push_back(a[i]);
    }
    sort(begin(v),end(v));
    rep(i,0,N-M-2) ans+=v[i];

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

int main(){
  int N, C;
  cin >> N >> C;
  vector<vector<int64_t>> color(C,vector<int64_t>(C));
  for(int i=0; i<C; i++){
    for(int j=0; j<C; j++){
      cin >> color.at(i).at(j);
    }
  }
  vector<vector<int64_t>> num(N,vector<int64_t>(N));
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cin >> num.at(i).at(j);
    }
  }
  
  /*vector<vector<int64_t>> vec(3,vector<int64_t>(0));
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      vec.at((i+j) %3).push_back(num.at(i).at(j));
    }
  }*/
  
  vector<vector<int64_t>> sum(C,vector<int64_t>(3));
  for(int k=0; k<C; k++){
    int one = 0;
    int two = 0;
    int three = 0;
    for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
        if((i+j) %3 == 0){
          one += color.at(num.at(i).at(j)-1).at(k);
        }
        if((i+j) %3 == 1){
          two += color.at(num.at(i).at(j)-1).at(k);
        }
        if((i+j) %3 == 2){
          three += color.at(num.at(i).at(j)-1).at(k);
        }
      }
    }
    sum.at(k).at(0) = one;
    sum.at(k).at(1) = two;
    sum.at(k).at(2) = three;
  }
  
  
  int64_t cost = 100000000000;
  for(int i=0; i<C; i++){
    for(int j=0; j<C; j++){
      if(j == i){
        continue;
      }
      for(int k=0; k<C; k++){
        if(k == i || k == j){
          continue;
        }
        int64_t cost_x = sum.at(i).at(0) + sum.at(j).at(1) + sum.at(k).at(2);
        cost = min(cost,cost_x);
      }
    }
  }

  cout << cost << endl;          
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
 
using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
 
template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }
 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
 
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
 
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
 
const int MAX = 100010;
int n;
int x[MAX];
int il[16];
int dp[1 << 17];
int xx[1 << 17];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n-1){
    int a,b,c;
    cin >> a >> b >> c;
    x[a]^=c;
    x[b]^=c;
  }
  R(i,n){
    il[x[i]]++;
  }
  vector<int> pom;
  int res = 0;
  R(i,16)if(i){
    if(il[i]&1){
      pom.PB(i);
    }
    res += il[i]/2;
  }
  R(i,1<<SZ(pom)){
    R(j,SZ(pom))if((i >> j)&1){
      xx[i] ^= pom[j];
    }
  }
  R(i,1<<SZ(pom)){
    debug(xx[i],i);
    if(xx[i] == 0){
      dp[i] = 1;
      for(int j = (i - 1) & i; j ; j = (j -1)&i){
        if(xx[j] == 0){
          maxi(dp[i], dp[j] + 1);
        }
      }
    }
  }
  debug(SZ(pom),res,dp[(1 << SZ(pom))-1]);
  cout << res + max(0ll, SZ(pom) - dp[(1 << SZ(pom))-1]) << "\n";
}

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

namespace AizuOnlineJudgement.ITP1_3_C
{
	public static class Program
	{
		public static void Main (string[] args)
		{
			for (; ; )
			{
				var xy = Console.ReadLine ().Split (' ').Select (s => int.Parse (s)).ToArray ();
				if (xy[0] + xy[1] == 0)
				{
					break;
				}
				Console.WriteLine (string.Format (xy[0] < xy[1] ? "{0} {1}" : "{1} {0}", xy[0], xy[1]));
			}
		}
	}
}



Measured memory_bytes: 9568
// code.begin();
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back 
#define what_is(x) cerr<<#x<<" is "<<x<<endl;
#define print(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define my_time ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define endl "\n"
#define MOD 1000000007
const long long int INF=1e18;
#define mod 1000000007
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    ordered_set; 
//find_by_order(x)
//order_of_key(x)  


int power(int x,unsigned int y)
{
    int res=1;
    
    while(y>0)
    {
        // if y is odd multiply with result
        if(y&1)
        res=res*x;
        
        y=y>>1; // y=y/2;
        x=x*x;
        
    }
    return res;
}

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

ll  max3(ll  a, ll  b, ll c)
{
    return max(c, max(a, b));
}
int min3(int a, int  b, int  c)
{
    return min(a, min(b, c));
}

int  powermod(int  x, int  y, int p )
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int logg(int  a)
{
    int  x = 0;
    while (a > 1)
    {
        x++;
        a /= 2;
    }
    return x;
}


int modinv(int x)
{
    return powermod(x, mod - 2, mod);
}


int  main(){
	my_time;

int t;
t=1;
//cin>>t;int test=0;
while(t--)
{
int n;
cin>>n;

int k;
cin>>k;
int arr[n];  
for(int i=0;i<n;i++)
cin>>arr[i];

vector<bool> dp(k+1,false);

for(int i=0;i<=k;i++)
{
    for(int j=0;j<n;j++)
    {
        if(arr[j]<=i && !dp[i-arr[j]])
        dp[i]=true;
    }
}
  if(dp[k])
  cout<<"First"<<endl;
  else
  cout<<"Second"<<endl;
  
  
}
    return 0;
}


//code.end();





Measured memory_bytes: 3632
#include<stdio.h>
#define MAX 10000000
#define NIL -1

typedef struct{
  int parent,left,right;
}Node;

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
    if(u == NIL)return;
    D[u]=d;
    setDepth(T[u].left,d+1);
    setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].left != NIL)
    h1=setHeight(T[u].left)+1;
  if(T[u].right != NIL)
    h2=setHeight(T[u].right)+1;
  return H[u]=(h1>h2 ? h1:h2);
}

int getSibling(int u){
  if(T[u].parent == NIL)return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    return T[T[u].parent].right;
  return NIL;
}

void printer(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg=0;
  if(T[u].left != NIL)deg++;
  if(T[u].right != NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }else {
    printf("internal node\n");
  }
}

int main(){
  int i,v,l,r,root = 0;
  scanf("%d",&n);

  for(i=0;i<n;i++)
    T[i].parent = NIL;
  
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL)T[l].parent=v;
    if(r!=NIL)T[r].parent=v;
  }
  for(i=0;i<n;i++)
    if(T[i].parent==NIL)root=i;

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++)printer(i);
  return 0;
}

Measured memory_bytes: 4712
// atcoder/abc144/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n;
  while (cin >> n) {
    lli mn = 1LL << 62;
    for (lli i = 1; i * i <= n; ++i) {
      if (n % i == 0) {
        lli j = n / i;
        setmin(mn, i + j - 2);
      }
    }
    cout << mn << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 10000

int main(){
  int i,n;
  unsigned short *A,*B;
  int C[N+1];
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0 ; i<n ; i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0 ; i<N+1 ; i++){
    C[i]=0;
  }
  for(i=0 ; i<n ; i++){
    C[A[i]]++;
  }
  for(i=1 ; i<N+1 ; i++){
    C[i] = C[i] + C[i-1];
  }
  for(i=n-1 ; i>=0 ; i--){
    B[C[A[i]]-1] = A[i];
    C[A[i]]--;
  }

  for(i=0 ; i<n ; i++){
    if(i<n-1)  printf("%d ",B[i]);
    else printf("%d\n",B[i]);
  }
  return 0;
}



Measured memory_bytes: 9584
using System;

namespace _0576
{
    class Program
    {
        static void Main(string[] args)
        {
            int win = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());
            int m = int.Parse(Console.ReadLine());
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c, d;
            if (k % a == 0) { c = k / a; } else { c = k / a + 1; }
            if (m % b == 0) { d = m / b; } else { d = m / b + 1; }
            if ((c) > (d)) { Console.WriteLine(win - (c)); }
            else { Console.WriteLine(win - (d)); }
        }
    }
}

Measured memory_bytes: 9204
#include<iostream>
#include<algorithm>
using namespace std;
int n,k,a[100005],dp[100005];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		int b1=1000000005;
		for(int j=1;j<=k;j++){
			if(i-j>=0) b1=min(b1,abs(a[i-j]-a[i])+dp[i-j]);
		}
		dp[i]=b1;
		//cout<<dp[i]<<"\n";
	}
	/*for(int i=0;i<n;i++){
		cout<<dp[i]<<" ";
	}
	cout<<"\n";*/
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1<<28;
int LevenshteinDistance(const string& s, const string& t) {
    const int N = s.size(), M = t.size();
    vector< vector<int> > dp(N + 1, vector<int>(M + 1, INF));
    for (int i = 0; i < N; i++) dp[i][0] = i;
    for (int j = 0; j < M; j++) dp[0][j] = j;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            int& v = dp[i][j];
            v = min(v, dp[i - 1][j] + 1);
            v = min(v, dp[i][j - 1] + 1);
            v = min(v, dp[i - 1][j - 1] + (s[i - 1] != t[j - 1]));
        }
    }
    return dp[N][M];
}

int main() {
    string s, t; cin >> s >> t;
    cout << LevenshteinDistance(s, t) << endl;
    return 0;
}

Measured memory_bytes: 4964
//ABC124B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
using namespace std;

int main(){
	int n;
	int count = 1;
	cin >> n;
	vector <int> a(n);
	for(int i=0;i<n;i++){
		cin >> a.at(i);
	}
	int highest = a.at(0);
	for(int i=1;i<n;i++){
		if(highest <= a.at(i)){
			count++;
		}else{
			count = count;
		}
		highest = max(highest,a.at(i));
	}
	cout << count << endl;
}

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

string calc(int n) {
	int sum = (n == 1 ? 0 : 1);
	for(int i = 2; i * i <= n; ++i) {
		if(n % i == 0) {
			sum += i;
			if(i * i != n) sum += n / i;
		}
	}

	return sum < n ? "deficient number" :
		sum == n ? "perfect number" : "abundant number";
}

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

	for(int n; cin >> n && n;) {
		cout << calc(n) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1196
#include <stdio.h>

int main(void) {
    int N, K, p1, a;
    double P = 0.0f;

    a = scanf("%d %d", &N, &K);

    for(int i = 1; i <= N; i++){
        p1 = 1;
        while(1) {
            if (K <= i*p1) {
                p1 * 2;
                break;
            }
            p1 *= 2;
        }
        P += (1.0 / (double)(p1*N));
    }
    printf("%13.12lf", P);
    return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())
nop = [0]*m
 
for i in range(n):
    l = list(map(int, input().split()))
    # print(l)
    for j in range(l[0]):
        nop[l[j+1]-1] += 1
 
# print(nop, n)
 
print(nop.count(n))

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int d = h2 * 60 + m2 - (h1 * 60 + m1);
    cout << max(0, d - k) << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>          // printf(), scanf(), fgets()
#include <string.h>         // strlen(), strncmp()
#include <ctype.h>          // isalpha()

const int NUL = '\0';

int
gcd(int a, int b)
{
	if (b == 0)
		return a;

	return gcd(b, a % b);
}

void
decryption(char *t, const char *s, int len, int alpha, int beta)
{
	int i;

	for (i = 0; i < len; ++i)
	{
		if (isalpha(*s))
			*t = ((*s - 'a') * alpha + beta) % 26 + 'a';

		s++;
		t++;
	}
}

int
main(int argc, char **argv)
{
	char line[257];
	const char *key[2] = {"this", "that"};
	char trans[4];
	int alpha, beta;
	char *s, *t;
	int n;
	int i;

	scanf("%d\n", &n);
	while (n--)
	{
		fgets(line, sizeof(line), stdin);
		s = line + strlen(line) - 1;
		if (s >= line && *s == '\n')
			*s = NUL;

		for (s = line; *s != NUL; ++s)
		{
			if (!isalpha(*s))
				continue;

			t = s++;
			for (i = 1; isalpha(*s); ++i)
				s++;

			if (i != 4 || (*s != ' ' && *s != NUL))
				continue;

			for (alpha = 1; alpha < 26; ++alpha)
			{
				if (gcd(alpha, 26) != 1)
					continue;

				for (beta = 0; beta < 26; ++beta)
				{
					decryption(trans, t, 4, alpha, beta);
					for (i = 0; i < 2; ++i)
					{
						if (strncmp(trans, key[i], 4) == 0)
							goto l_found;
					}
				}
			}
		}

		printf("%s\n", line);
		continue;

l_found:
		decryption(line, line, strlen(line), alpha, beta);
		printf("%s\n", line);
	}

	return 0;
}

Measured memory_bytes: 588