akhauriyash/Code-Regression huggingface dataset:
def digsum(a):
	sum=0
	A=str(a)
	for i in range(0,len(A)):
		sum=sum+int(A[i])
	return sum
n=int(input())
#print(digsum(n))
mini=n
a=0
b=0
for i in range(1,n):
	A=i
	B=n-i
	suma=digsum(A)+digsum(B)
	if(suma<mini):
		mini=suma
		a=A
		b=B
print(mini)
#print(a,b)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  string s;
  cin >> s;
  bool a[26] = {};
  for (int i = 0; i < (int)s.size(); i++) a[s[i]-'a'] = true;
  int i = 0;
  while (i < 26 && a[i] == true) i++;
  if (i == 26) {
    dump("None");
  }
  else {
    printf("%c\n", 'a'+i);
  }
  return 0;
}


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

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;
using vpi=vector<pii>;

struct node {
    int d = 0;
    int parent = 0;
    set<pii> to;

    node() = default;
};


int main() {
    int N;
    cin >> N;
    using vn=vector<node>;

    vn t;
    map<pii, int> m;
    for (int i = 1; i <= N - 1; i++) {
        for (int j = i + 1; j <= N; j++) {
            auto p = make_pair(i, j);
            t.emplace_back();
            m[p] = t.size() - 1;
        }
    }

    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;

        pii prev;
        if (i < a) {
            prev = make_pair(i, a);
        } else {
            prev = make_pair(a, i);
        }
        int prev_i = m[prev];

        for (int j = 1; j < N - 1; j++) {
            cin >> a;
            pii tmp;
            if (i < a) {
                tmp = make_pair(i, a);
            } else {
                tmp = make_pair(a, i);
            }

            t[prev_i].to.insert(tmp);
            prev_i = m[tmp];
            t[prev_i].parent++;
        }
    }

    queue<int> q;
    for (int i = 0; i < t.size(); i++) {
        if (t[i].parent == 0) {
            t[i].d = 1;
            q.push(i);
        }
    }

    vi sorted;
    while (!q.empty()) {
        auto i = q.front();
        q.pop();
        sorted.emplace_back(i);

        for (auto &&item : t[i].to) {
            int item_i = m[item];
            t[item_i].parent--;
            t[item_i].d = max(t[item_i].d, t[i].d + 1);

            if (t[item_i].parent == 0) {
                q.push(item_i);
            }
        }
    }

    if (sorted.size() != t.size()) {
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    for (int i : sorted) {
        ans = max(0, t[i].d);
    }

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


Measured memory_bytes: 110660
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const ll INF = 1e12;
signed main(){
    char a; cin >>a;
    if(a=='A')cout<<'T'<<endl;
    else if(a=='T') cout << 'A'<<endl;
    else if(a=='G')cout<<'C'<<endl;
    else cout<<'G'<<endl;
}


Measured memory_bytes: 256
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort()
r=[]
for i in range(m):

    b,c=list(map(int,input().split()))
    r.append((c,b))
r.sort()
r.reverse()
curr_r=0
ite_r=1
ans=0
flg=False
for i in a:
    if flg:
        ans+=i
    elif i<r[curr_r][0]:
        ans+=r[curr_r][0]
        if r[curr_r][1]==ite_r:
          curr_r+=1
          ite_r=1
          if curr_r==m:
            flg=True
        else:
          ite_r+=1
    else:
        ans+=i
print(ans)

Measured memory_bytes: 20956
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cmath>
#include <bitset>
#define REP(i,n) for(int i=0;i<n;i++)
using Int = long long;
using namespace std;
int main()
{
    Int N, M; cin >> N >> M;
    Int ans = 0;
    Int x = min(N, M / 2);
    M -= x * 2;
    ans += x;
    ans += M / 4;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)

int main(){
    int n, m;
    cin >> n >> m;
    int ans = 0;
    if(1 < n ){
        ans += n * (n-1) / 2;
    }
    if(1 < m ){
        ans += m * (m-1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,point,win[10],low[10];
    char str[10];
    while(cin>>n&&n!=0){
        for(int i=0;i<n;i++){
            win[i]=0;low[i]=0;
            cin>>str[i];
            for(int j=1;j<n;j++){
                cin>>point;
                if(point==0)win[i]++;
                else if(point==1)low[i]++;
            }
        }
        for(int i=0;i<n;i++){
            point=0;
            for(int j=1;j<n;j++)if(win[point]<win[j]||win[point]==win[j]&&low[point]>low[j])point=j;
            cout<<str[point]<<endl;
            win[point]=-1;
            low[point]=11;
        }
    }

}

Measured memory_bytes: 1152
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func main() {
	defer write.Flush()

	var k, x int
	fmt.Fscan(read, &k, &x)

	yesno(k*500 >= x)
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int n,c;
	c=0;
	scanf("%d",&n);
	while(n!=0)
	{
		if((n%10)==9)
		{
			printf("Yes\n");
			c++;
			break;
		}
		else
			n=n/10;
	}
	if(c==0)
		printf("No\n");
			return 0;
}

Measured memory_bytes: 1640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("YES");
	else say("NO");
}

int main() {
	makes(s);
	makes(t);
	makes(u);
	cout << (char)(s[0] - 'a' + 'A');
	cout << (char)(t[0] - 'a' + 'A');
	cout << (char)(u[0] - 'a' + 'A');
	cout << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int INF = 1e9 + 10;


int arr[3010];

using namespace std;

int main()
{



	IOS;



	ll n;
	cin >> n;
	ll k;
	cin >> k;

	ll a[n];



	for (ll i = 1; i <= n; i++)
	{
		cin >> a[i];
	}

	vector<ll>dp(n + 1, INF);
	dp[1] = 0;

	for (ll i = 2; i <= n; i++)
	{
		for (ll j = 1; j <= min(i, k); j++)
		{
			dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
		}
	}

	cout << dp[n];
}

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

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

    int n, m, k;
    cin >> n >> m >> k;
    char mat[n][m];
    int ans[n][m] = {}, cnt = 0;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> mat[i][j];

    for (int i = 0; i < n; i++) {
        bool empty = true;
        for (int j = 0; j < m; j++)
            if (mat[i][j] == '#')
                empty = false;

        if (!empty) {
            bool start = true;
            for (int j = 0; j < m; j++)
                if (mat[i][j] == '#')
                    ans[i][j] = ++cnt, start = false;
                else
                    ans[i][j] = cnt + start;
        }
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (ans[i][j]) {
                for (int ii = i - 1; ii >= 0 && !ans[ii][j]; ii--)
                    ans[ii][j] = ans[i][j];
                for (int ii = i + 1; ii < n && !ans[ii][j]; ii++)
                    ans[ii][j] = ans[i][j];
            }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++)
            cout << ans[i][j] << ' ';
        cout << '\n';
    }
}

Measured memory_bytes: 4092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.StringTokenizer;

class Main{
	static Queue<Integer> Q;
	static int H,W;
	static int[] xv= {1,0,-1,0};
	static int[] yv= {0,1,0,-1};
	static int[][] ary;
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		H=sc.nextInt();
		W=sc.nextInt();
		String[] s=new String[H];
		for(int i=0; i<H; i++) {
			s[i]=sc.next();
		}
		ary=new int[H][W];
		Q=new ArrayDeque<Integer>();
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				if(s[i].charAt(j)=='#') {
					ary[i][j]=0;
					Q.add(i*W+j);
				}
				else {
					ary[i][j]=114514;
				}
			}
		}
		while(!Q.isEmpty()) {
			int now=Q.poll();
			isvalid(now);
		}
		int max=0;
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				max=Math.max(max, ary[i][j]);
			}
		}
		/*for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				p(ary[i][j]+" ");
			}
			pl("");
		}*/
		pl(max);
	}
	public static void isvalid(int num) {
		int y=num/W;
		int x=num%W;
		for(int i=0; i<4; i++) {
			if(y+yv[i]>=0 && y+yv[i]<H) {
				if(x+xv[i]>=0 && x+xv[i]<W) {
					if(ary[y+yv[i]][x+xv[i]]>2000) {
						Q.add((y+yv[i])*W+(x+xv[i]));
						ary[y+yv[i]][x+xv[i]]=ary[y][x]+1;
					}
				}
			}
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 67472
package main

import (
  "fmt"
  "strings"
)

func main() {
  var str string
  fmt.Scan(&str)
  s := strings.Split(str, "")

  ans := 0
  rec := 0
  for i := 0; i < len(s); i++ {
    if s[i] == "W"{
      ans += rec
    }else{
      rec++
    }
  }
  fmt.Println(ans)
}


Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;


int main() {

    ll N, K, S;

    cin >> N >> K >> S;

    vector<ll> A(N);
    ll count = 0;
    rep(i, N) {
        if (count < K) {
            cout << S << " ";
        }
        else if(S != pow(10, 9)){
            cout << S + 1 << " ";
        }
        else {
            cout << S - 1 << " ";
        }
        count++;
    }

    return 0;
}


Measured memory_bytes: 3652
local n=io.read("*n")
local a={}
a[1],a[n+2]=0,0
for i=2,n+1 do
    a[i]=io.read("*n")
end

local total=0
for i=1,n+1 do
    total=total+math.abs(a[i]-a[i+1])
end

for i=2,n+1 do
    local x=math.abs(a[i-1]-a[i+1])
    local y=math.abs(a[i-1]-a[i])
    local z=math.abs(a[i]-a[i+1])
    print(total+x-y-z)
end

Measured memory_bytes: 4208
from math import sqrt
n = int(input())
stop = int(sqrt(n)) + 1
min_count = 10 ** 100
for a in range(1, stop):
    if n % a != 0:
        continue
    else:
        b = n // a
    count = a + b - 2
    if count < min_count:
        min_count = count
print(min_count)

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

int main() {
  int N;
  cin >> N;
  int A[1000];
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  double a = 0;
  for (int i = 0; i < N; i++){
    a = a + (((double) 1) / A[i]);
  }
  printf("%lf\n", ((double) 1)/a);
  return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const ll mod=1e9+7;

int main()
{
    int n;
    scanf(" %d", &n);
    vector<int> t(n),a(n);
    rep(i,n) scanf(" %d", &t[i]);
    rep(i,n) scanf(" %d", &a[i]);

    bool ok=(t[n-1]==a[0]);

    for(int i=1; i<n; ++i)
    {
        if(t[i-1]<t[i])
        {
            if(a[i]<t[i]) ok=false;
        }
    }
    for(int i=n-2; i>=0; --i)
    {
        if(a[i+1]<a[i])
        {
            if(t[i]<a[i]) ok=false;
        }
    }

    ll ans=0;
    if(ok)
    {
        ans=1;
        for(int i=1; i<n-1; ++i)
        {
            if(t[i]==t[i-1] && a[i]==a[i+1]) (ans*=min(t[i],a[i]))%=mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

int main(){
int N,j=1;
  scanf("%d",&N);
  int *a=(int*)malloc(sizeof(int)*N);
  for(int i=0;i<N;i++){
	scanf("%d",&a[i]);
    if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0){
    	j=0;
      break;
    }
  }
  if(j==1)printf("APPROVED\n");
  else printf("DENIED\n");
 return 0; 
}

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

int main()
{
	ll n, a, b;
	cin >> n >> a >> b;
	if (abs(a - b) % 2 == 0)
	{
		cout << abs(a - b) / 2 << endl;
	}
	else
	{
		if (a == min({a, b, n - a + 1, n - b + 1}))
		{
			cout << a + abs(b - a - 1) / 2 << endl;
		}
		else if (b == min({a, b, n - a + 1, n - b + 1}))
		{
			cout << b + abs(a - b - 1) / 2 << endl;
		}
		else
		{
			a = n - a + 1;
			b = n - b + 1;
			if (a == min({a, b}))
			{
				cout << a + abs(b - a - 1) / 2 << endl;
			}
			else if (b == min({a, b}))
			{
				cout << b + abs(a - b - 1) / 2 << endl;
			}
		}
	}
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static ArrayList<Integer> list = new ArrayList<Integer>();
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		makeList(10000000);
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) break;
			int min = 0;
			int max = 2;
			int ans = 0;
			int c = 1;
			while(true) {
				if(n == min || n == max) {
					ans = 0;
					break;
				}
				if(n > min && n < max) {
					ans = max - min;
					break;
				}
				min = max;
				max = list.get(c++);
			}
			System.out.println(ans);
		}
	}
	
	public static void makeList(int n) {
		boolean[] isPrime = new boolean[n];
		if(n > 2) {
			isPrime[2] = true;
		}
		for(int i = 3; i < n; i += 2) {
			isPrime[i] = true;
		}
		if(n > 2) {
			list.add(2);
		}
		for(int i = 3; i < n; i += 2) {
			if(isPrime[i]) {
				list.add(i);
				for(int j = i + i; j < n; j += i) {
					isPrime[j] = false; 
				}
			}
		}
	}
	
	
}

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



ll minCost(ll n,ll cost[],ll dp[],ll k)
{
    if(n==1)
    {
        return 0;
    }
    if(n==2)
    {
        return abs(cost[1]-cost[0]);
    }
    if(dp[n]!=-1)
    {
        return dp[n];
    }
    ll mcost = INT_MAX;
    for(int i=1;i<=k;i++)
    {
        if(n-i>=0)
        {
            mcost = min(mcost,abs(cost[n-1]-cost[n-1-i]) + minCost(n-i,cost,dp,k));
        }
    }
    dp[n] =mcost;
    return dp[n];
}



int main()
{
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    ll cost[n];
    for(ll i=0;i<n;i++)
    {
        cin>>cost[i];
    }
    ll dp[n+1];
    for(ll i=0;i<=n;i++)
    {
        dp[i] = -1;
    }
    cout<<minCost(n,cost,dp,k);
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int M1, D1, M2, D2;
signed main() {
    cin >> M1 >> D1 >> M2 >> D2;
    cout << !(M1 == M2) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repr(i, a, b) for (int i = (int)a; i > (int)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,w,n;cin>>h>>w>>n;
    map<pii,int> cnt;
    vll ans(10,0);
    ans[0]=1ll*(h-2)*(w-2);
    rep(i,n){
        int a,b;cin>>a>>b;
        repf(x,-1,2){
            repf(y,-1,2){
                int s=a+x,t=b+y;
                if (s<=1 || s>h-1 || t<=1 || t>w-1){
                    continue;
                }
                ans[cnt[mp(s,t)]]--;
                cnt[mp(s,t)]++;
                ans[cnt[mp(s,t)]]++;
            }
        }
    }
    rep(i,10){
        cout<<ans[i]<<ENDL;
    }
}


Measured memory_bytes: 56576
abcde =[ int(input()) for _ in range(5)] 
K = int(input())
flag = False
for i in range(5):
    for s in range(1,5-i):
        if abcde[s] - abcde[i] > K:
            flag = True
if flag:
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>

int comp( const void *c1, const void *c2 );

int main()
{
  long int  n, a[100001], max1=0, max2=0, i;
  
  scanf("%ld", &n);
  for(i=0; i < n; i++){
  scanf("%ld", &a[i]);
  }
  qsort(a, n, sizeof(long int), comp);

  for(i=0; i < n-1; i++){
    if(a[i] == a[i+1]){
      max1 = a[i];
      break;
    }
  }
  for(i+=2; i < n-1; i++){
    if(a[i] == a[i+1]){
      max2 = a[i];
      break;
    }
  }

  printf("%ld\n", max1 * max2);
  
  return 0;
}


int comp( const void *c1, const void *c2 )
{
  int tmp1 = *(int *)c1;
  int tmp2 = *(int *)c2;

  if( tmp1 > tmp2 )  return -1;
  if( tmp1 == tmp2 ) return  0;
  if( tmp1 < tmp2 )  return  1;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int w,h,x,y;
    while (cin >> w >> h >> x >> y) {
        const double A = 1.0*w*h/2;
        int ans = 0;
        if (w-x == x && h-y == y)
            ans = 1;
        printf("%.10f %d\n",A,ans);
    }
    return 0;
}


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

int main(){
	int a, b , sum = 0;
	cin >> a >> b;
	// 1
	if (a >= b) {
		sum += a;
		a -= 1;
	}
	else {
		sum += b;
		b -= 1;
	}
    //2
	if (a >= b) sum += a;
		else sum += b;
		
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
(n, m, l) = [int(i) for i in input().split()]

A = []
for nc in range(n):
    A.append([int(i) for i in input().split()])

B = []
for mc in range(m):
    B.append([int(i) for i in input().split()])

product = [[0 for d in range(l)] for dd in range(n)]

for nc in range(n):
    for lc in range(l):
        for mc in range(m):
            product[nc][lc] += A[nc][mc] * B[mc][lc]

for r in product:
    print(' '.join([str(d) for d in r]))

Measured memory_bytes: 7764
#include <iostream>
using namespace std;
int main()
{
    int n;
    while(cin >> n)
    {
        int a, b;
        a = n % 10;
        b = n /100;
        if(a==b)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}


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

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

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int H,W,h,w;scanf("%d%d%d%d",&H,&W,&h,&w);
	if (H%h==0&&W%w==0) {puts("No");return 0;}
	puts("Yes");
	for (int i=1;i<=H;i++)
		for (int j=1;j<=W;j++)
			printf("%d%c",(i-1)%h==0&&(j-1)%w==0 ? 700*(h*w-1)-1 : -700,j==W ? '\n' : ' ');
	return 0;
}


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

int main() {
    
  int N;
  cin >> N;
  int M=N;
  int sum=0;
  
	for(int M=N;M>0;M/=10){
      sum+=M%10;
    }
  
  if(N%sum==0){
  cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var NM = Console.ReadLine().SplittedStringToInt32List();
        var N = NM[0];
        var M = NM[1];
        var an = new List<KeyValuePair<int, int>>();
        var dp = new long[N + 1, M + 1];
        for (int i = 0; i < N; i++)
        {
            var vw = Console.ReadLine().SplittedStringToInt32List();
            an.Add(new KeyValuePair<int, int>(vw[0], vw[1]));
        }

        dp[0, 0] = 0;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j <= M; j++)
            {
                if (j - an[i].Key >= 0)
                    dp[i + 1, j] = Math.Max(dp[i, j], dp[i, j - an[i].Key] + an[i].Value);
                else
                    dp[i + 1, j] = dp[i, j];
            }
        }
        Console.WriteLine(dp[N,M]);
        Console.ReadLine();
    }


    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;
    #endregion
}



Measured memory_bytes: 89184
#include <stdio.h>
#include <stdlib.h>
 
struct node_t {
    int id;
    int parent;
    int depth;
    const char *kind;
    int degree;
    int *childs;
};
typedef struct node_t Node;
 
void calc_depth(Node *data, int i) {
    int j, idx;
 
    for (j = 0; j < data[i].degree; j++) {
        idx = data[i].childs[j];
        data[idx].depth += 1;
        calc_depth(data, idx);
    }
}
 
void print_node(Node *p) {
    int i;
    const char *fmt = "%d";
 
    printf(
        "node %d: parent = %d, depth = %d, %s, [",
        p->id, p->parent, p->depth, p->kind);
 
    for (i = 0; i < p->degree; i++) {
        printf(fmt, p->childs[i]);
        fmt = ", %d";
    }
    puts("]");
}
 
int main(void) {
    Node *data, *p;
    int n, id, degree, i, j;
 
    scanf("%d", &n);
    data = malloc(sizeof(Node)*n);
    for (i = 0; i < n; i++) {
        data[i].parent = -1;
        data[i].depth = 0;
    }
 
    for (i = 0; i < n; i++) {
        scanf("%d %d", &id, &degree);
        p = &data[id];
        p->id = id;
        p->degree = degree;
        p->kind = degree ? "internal node" : "leaf";
        p->childs = malloc(sizeof(int)*degree);
        for (j = 0; j < degree; j++) {
            scanf("%d", p->childs+j);
            data[p->childs[j]].parent = id;
        }
    }
 
    for (i = 0; i < n; i++) {
        calc_depth(data, i);
    }
 
    for (i = 0; i < n; i++) {
        if (data[i].depth == 0) {
            data[i].kind = "root";
        }
        print_node(data+i);
    }
    return 0;
}

Measured memory_bytes: 8036
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  ll N;
  cin >> N;
  vector<ll> p(5);
  for(int i=0; i<5; i++){
    cin >> p[i];
  }
  ll ans = 0;
  for(int i=0; i<5; i++){
    ans = max(ans,(N+p[i]-1)/p[i]+4);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 300005;

int main(){
	fastio;
	int d, t, s;
	cin >> d >> t >> s;
	cout << ((double)d/(double)t <= (double)s ? "Yes":"No") << '\n';
	return 0;
}


Measured memory_bytes: 3672
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


alias Bal = Tuple!(long, "a", long, "b");
alias Rat = Tuple!(long, "p", long, "q");

int N;
Bal[] P;
long[] rs;

Rat calc(int l) {
  Rat ret = Rat(-1, 1);
  long sum;
  BinaryHeap!(Array!long) que;
  foreach (i; 0 .. N) {
    if (i >= l) {
      /*
        sum + (P[i].a - (1 - t) P[i].b) + rs[i + 1] <= 0
      */
      debug {
        writeln(l, " ", i, ": ", sum, " ", P[i], " ", rs[i + 1]);
      }
      long p = -(sum + P[i].a - P[i].b + rs[i + 1]);
      long q = P[i].b;
      if (p >= 0) {
        chmin(p, q);
        if (ret.p * q < p * ret.q) {
          ret = Rat(p, q);
        }
      }
    }
    sum += P[i].a;
    que.insert(P[i].a);
    if (i >= l) {
      sum -= que.front;
      que.removeFront;
    }
  }
  debug {
    writeln("calc ", l, " = ", ret);
  }
  return ret;
}

void main() {
  try {
    for (; ; ) {
      N = readInt();
      P = new Bal[N];
      foreach (i; 0 .. N) {
        P[i].a = readLong();
        P[i].b = readLong();
      }
      P.sort!((x, y) => (x.b < y.b));
      
      rs = new long[N + 1];
      foreach_reverse (i; 0 .. N) {
        rs[i] = rs[i + 1];
        if (P[i].a - P[i].b < 0) {
          rs[i] += P[i].a - P[i].b;
        }
      }
      debug {
        writeln("P = ", P);
        writeln("rs = ", rs);
      }
      
      int lo = 0, hi = N;
      for (; lo + 1 < hi; ) {
        const mid = (lo + hi) / 2;
        const res = calc(mid);
        (res.p >= 0) ? (lo = mid) : (hi = mid);
      }
      
      /*
               res.p  
         lo + ------- 
               res.q  
        --------------
              N       
      */
      const res = calc(lo);
      long p = lo * res.q + max(res.p, 0);
      long q = res.q * N;
      const g = gcd(p, q);
      p /= g;
      q /= g;
      writeln(p, " ", q);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 6048
#include <stdio.h>

int main()
{
    int w, h, x, y, r;
    scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);
    if(0<=x-r && x+r<=w && 0<=y-r && y+r<=h) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    if(s.size() != a + b + 1){
        cout << "No" << endl;
        return 0;
    }
    
    for(int i = 0; i < a + b + 1; i++){
        if(i == a && s[i] == '-')
            continue;
        if(i != a && s[i] >= '0' && s[i] <= '9')
            continue;
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math

#入力
#S = str(input())
#N, i = map(int, input().split())
#K = int(input())
A, B, C = map(int, input().split())

l = []
l.append(A)
l.append(B)
l.append(C)
l.sort()

print ((l[2]*10) + l[1] + l[0])

Measured memory_bytes: 3060
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
#define A

#ifdef A
int main(void)
{
	int cunt = 0;
	int n;
	cin >> n;
	list<int> arr(n);
	for (auto& a : arr)
		cin >> a;
	bool cont = true;
	while (cont)
	{
		list<int>::iterator it1 =arr.begin() ,it2 = arr.begin();
		advance(it2,1);
		cont = false;
		for (int i = 1; i < n; ++i, advance(it1,1), advance(it2,1))
		{
			if (*it1 > *it2) {
				swap(*it1, *it2);
				cont = true;
				cunt++;
			}

		}

	}
	list<int>::iterator it = arr.begin();
	cout << *it;
	advance(it, 1);
	for (; it !=arr.end(); advance(it,1))
		cout <<" "<< *it;
	cout << endl << cunt << endl;
	return 0;
}
#endif // A

Measured memory_bytes: 3080
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define pi 3.1415926535897
#define noop

int main() {

    get2(t1,t2);
    get2(a1,a2);
    get2(b1,b2);

    if(a1<b1) {
        swap(a1,b1);
        swap(a2,b2);
    }

    if(a1*t1 + a2*t2 == b1*t1 + b2*t2) {
        printf("infinity\n");
        return 0;
    }

    if(a1*t1 + a2*t2 > b1*t1 + b2*t2) {
        printf("0\n");
        return 0;
    }

    ll res = 0;
    ll maxd = a1*t1-b1*t1;
    ll rel = b1*t1 + b2*t2 - (a1*t1 + a2*t2);

    if(maxd%rel==0) res++;
    if(maxd%rel==0) 
        res += 2*(maxd/rel);
    else
        res += 2*(1+maxd/rel);
    res--;

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

    return 0;  
}



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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.14159bus2653589793238
using namespace std;

int32_t main() {
    nitin;
    vector<pair<int,int>>v;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    for(int i=2;i<n;i++)
    {
        if(v[i].first==v[i].second && v[i-1].first==v[i-1].second && v[i-2].first==v[i-2].second)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main() {
    ll a,b,c,x,y,ans=1000000000;
    cin>>a>>b>>c>>x>>y;
    for(ll i=0;i<=2*max(x,y);i+=2){
        ll k=i*c;
       // k+=max(0,1);
       ll zero=0;
        k+=max(zero,x-i/2)*a;
        k+=max(zero,y-i/2)*b;
        ans=min(k,ans);
    }
    cout<<ans<<endl;
    
}



Measured memory_bytes: 3588
#include <stdio.h>
#include <memory.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2 
int queue[100],len[100],color[100],M[100][100],n;

void bfs(void){ 
    int sign,top,end,i;
    memset(len,-1,sizeof(len));
    len[0]=0;
    for(top=0,end=1;end != top;){
        sign=queue[top];
        top++;
        for(i=0;i<n;i++){
            if(M[sign][i]!=0 && color[i]==WHITE){
                queue[end++]=i;
                len[i]=len[sign]+1;
                color[i]=GRAY;
            }
        }
        color[sign]=BLACK;
    }
    for(i=0;i<n;i++)
        printf("%d %d\n",i+1,len[i]);
}
int main(void){
    int u,k,v,i,o;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        u--;
        for(o=0;o<k;o++){
            scanf("%d",&v);
            v--;
            M[u][v]=1;
        }
    }
    color[0]=BLACK;
    bfs();
    return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

template<typename T>
struct SegmentTree{
    struct Node{
        T val;
        Node *lch,*rch;
        Node(T val):val(val),lch(nullptr),rch(nullptr){}
    };

    Node *root;
    ll sz;
    T id;

    T f(T x,T y){
        return x*y;
    }

    T g(T x,T y){
        return x;
        //return x+y;
    }

    T val(Node* t){return t ? t->val : id;}

    SegmentTree(ll sz_,T id_=0):root(nullptr),id(id_){
        sz=1;
        while(sz<sz_)sz*=2;
    }

    void erase(Node* t){
        if(t->lch)erase(t->lch);
        if(t->rch)erase(t->rch);
        delete t;
    }

    void erase(){
        erase(root);
    }

    Node* update(Node* t,ll k, ll l, ll r, T x){
        //assert(l<=k&&k<r);
        if(!t)t=new Node(id);
        if(r-l==1){
            t->val=g(x,t->val);
            return t;
        }
        if(k<(l+r)/2)t->lch=update(t->lch,k, l, (l+r)>>1, x);
        else t->rch=update(t->rch,k, (l+r)>>1, r, x);
        t->val=f(val(t->lch), val(t->rch));
        return t;
    }

    T get(Node* t, ll a,ll b,ll l, ll r){
        if(!t)return id;
        if(b<=l||r<=a)return id;
        if(a<=l&&r<=b)return t->val;
        T lx=get(t->lch, a, b, l, (l+r)>>1);
        T rx=get(t->rch, a, b, (l+r)>>1, r);
        return f(lx,rx);
    }

    void update(ll k,T x){
        root = update(root, k, 0, sz, x);
    }

    T get(ll a, ll b){
        return get(root, a, b, 0, sz);
    }
};

typedef pair<double,double> P;
int main(){
    cout<<setprecision(12);
    ll n,m;
    cin>>n;
    SegmentTree<double> sg(1<<30,1);
    rep(i,n){
		int a,x;
		cin>>a>>x;
		sg.update(a,1.0-0.1*x);
	}
	cin>>m;
	rep(i,m){
		int l,r;
		cin>>l>>r;
		cout<<sg.get(l,r)*1e9<<"\n";
	}
    return 0;
}


Measured memory_bytes: 48284
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
int main(){
  int n,a,b,c,x;
  vector<int> y(101);
  cin >> n >> a >> b >> c >> x;
  while(n!=0){
    rep(i,n) cin >> y[i];
    int s=-1,f=x,p=0;
    while(p!=n&&s<=10000){
      if(f==y[p]) p++;
      s++;
      f=(a*f+b)%c;
    }
    if(s>10000) cout << -1 << endl;
    else cout << s << endl;
    cin >> n >> a >> b >> c >> x;
  }
}



Measured memory_bytes: 3096
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

uint[] bits(uint n) {
  uint[] res;
  for(uint i = 0; i <= 9; i++) {
    if ((n & (1 << i)) != 0) {
      res ~= (1 << i);
    }
  }
  return res;
}

void main() {
  string line;
  while((line = readln.chomp) != null) bits(line.to!(int)).map!(to!(string)).join(" ").writeln;
}

Measured memory_bytes: 1080
from collections import defaultdict

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

d = defaultdict(lambda: -1)
d[1] = 0
L = [1]
i = 0
k = i
while i<N:
    if d[A[k]]==-1:
        d[A[k]] = i+1
        L.append(A[k])
        k = A[k]-1
    else:
        p = d[A[k]]
        q = i+1
        break
    i += 1

try:
    print(L[K])
except:
    L = L[p:]
    print(L[(K-p)%(q-p)])



Measured memory_bytes: 39408
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


bool solve(int H, int W, int n, vector<string> vs) {
	for (int j = 0; j < W; j++) {
		for (int i = H - 2; i >= 0; i--) {
			int h = i;
			while (h < H - 1 && vs[h][j] != '.' && vs[h + 1][j] == '.') {
				vs[h + 1][j] = vs[h][j];
				vs[h][j] = '.';
				h++;
			}
		}
	}
	vector<string> ns(H, string(W, '.'));
	vector<string> g = ns;
	while (1) {
		if (vs == g) {
			return true;
		}

		ns = vs;

		bool flag = false;
		for (int i = 0; i < H; i++) {
			int cnt = 0;
			for (int j = 0; j < W; j++) {
				if(vs[i][j] != '.') cnt++;
				if (j == W - 1 or (vs[i][j] != vs[i][j + 1])) {
					if (cnt >= n) {
						flag = true;
						while (cnt--) {
							//cout << j<<" "<<cnt << endl;
							ns[i][j - cnt] = '.';
						}
					}
					cnt = 0;
				}
			}
		}
		for (int j = 0; j < W; j++) {
			int cnt = 0;
			for (int i = 0; i < H; i++) {
				if(vs[i][j] != '.') cnt++;
				if (i == H - 1 or vs[i][j] != vs[i + 1][j]) {
					if (cnt >= n) {
						flag = true;
						while (cnt--) {
							ns[i - cnt][j] = '.';
						}
					}
					cnt = 0;
				}
			}
		}
		if (!flag) return false;
		for (int j = 0; j < W; j++) {
			for (int i = H - 2; i >= 0; i--) {
				int h = i;
				while (h < H - 1 && ns[h][j] != '.' && ns[h + 1][j] == '.') {
					ns[h + 1][j] = ns[h][j];
					ns[h][j] = '.';
					h++;
				}
			}
		}
		vs = ns;
	}
}
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int H, W, n; scanf("%d %d %d", &H, &W, &n);
	vector<string> vs(H); for (int i = 0; i < H; i++) cin >> vs[i];

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W - 1; j++) {
			swap(vs[i][j], vs[i][j + 1]);
			if (solve(H, W, n, vs)) {
				puts("YES");
				return 0;
			}
			swap(vs[i][j], vs[i][j + 1]);
		}
	}
	puts("NO");

	return 0;

}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
long long a,b,c,k,ans=0,cnt=0;
string s;
int main(){
  cin >> a >> b >> c >> k;
  if(k%2==0){
    cout << a-b << endl;
  }else{
    cout << b-a << endl;
  }
  return 0;
}

Measured memory_bytes: 256