akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

pre_sum = sum(a)
limit = 0

for i in range(n):
  limit = b[i]
  if limit > a[i]:
    limit -= a[i]
    a[i] = 0
    if limit < a[i+1]:
      a[i+1] -= limit
      limit = 0
    else:
      a[i+1] = 0
      limit = 0
  else:
    a[i] -= limit
    limit = 0
    
result_sum = sum(a)
result = pre_sum - result_sum
print(result)

Measured memory_bytes: 82020
import sys 
MOD = 10**9 +7
INF = 10**5

def main():
    h,w,k = map(int,input().split())
    grid = [[0] * (w + 1)] + [[0] + [int(i) for i in list(input())] for _ in range(h)]
    

    for i in range(h + 1):
        for j in range(1,w + 1):
            grid[i][j] += grid[i][j - 1]
    
    for i in range(1,h + 1):
        for j in range(w + 1):
            grid[i][j] += grid[i - 1][j]
    #print(grid)
    ans = INF
    for bit in range(1<<(h - 1)):
        flag = False
        cut = [0]
        for i in range(h - 1):
            if (bit>>i)&1:
                    cut.append(i + 1)
        cut.append(h)
        #print(cut)
        l = len(cut)
        cnt = l - 2
        c = 0
        for j in range(1,w + 1):
            for i in range(1,l):
                #print(c)
                a = cut[i - 1]
                b = cut[i]
                if grid[b][j] - grid[b][c] - grid[a][j] + grid[a][c] > k:
                    if j != 1:
                        c = j - 1
                        cnt += 1
                        break
                    else:
                        flag = True
                        break
            if flag:
                break
        if flag == False:
            ans = min(ans,cnt)
    
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 43100
from math import sin,cos,pi
pos = [0,0]
d = 0
cmd = map(int, raw_input().split(','))
while cmd != [0,0]:
    pos[0] += cmd[0]*sin(pi*d/180)
    pos[1] += cmd[0]*cos(pi*d/180)
    d += cmd[1]
    cmd = map(int, raw_input().split(','))
for c in map(int, pos):
    print c

Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m;
vector<bool> seen;
vector<vector<P>> G;

void dfs(int i, int v) {
    seen[v]=true;
    for (const auto& nv: G[v]) {
        if (i==nv.se) continue;
        if (seen[nv.fi]) continue;
        dfs(i, nv.fi);
    }
}

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

    cin >> n >> m;
    G.resize(n);
    rep(i, m) {
        int x, y; cin >> x >> y;
        x--; y--;
        G[x].emplace_back(y, i);
        G[y].emplace_back(x, i);
    }
    int ans = 0;
    rep(i, m) {
        seen.assign(n, false);
        dfs(i, 0);
        rep(i, n) {
            if(!seen[i]) {ans++; break;}
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

const int MAX = 100000;

struct Proc
{
    std::string name;
    int time;
};

class Queue
{
    private:
        Proc procs[MAX];
        int head;
        int tail;

    public:
        Queue()
        {
            head = 0;
            tail = 0;
        }
        void enqueue(Proc p)
        {
            procs[tail] = p;
            if (tail + 1 == MAX)
                tail = 0;
            else
                ++tail;
        }

        Proc dequeue()
        {
            Proc p = procs[head];
            if (head + 1 == MAX)
                head = 0;
            else
                ++head;
            return p;
        }

        bool isfull()
        {
            return head == (tail + 1) % MAX;
        }

        bool isempty()
        {
            return head == tail;
        }
};

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

    Queue queue;
    int n, q;
    std::cin >> n >> q;
    while (n--) {
        std::string name;
        int time;
        std::cin>> name >> time;
        Proc p;
        p.name = name;
        p.time = time;
        queue.enqueue(p);
    }
    int time = 0;
    while (!queue.isempty()) {
        Proc p = queue.dequeue();
        if (p.time <= q) {
            time += p.time;
            p.time = 0;
            std::cout << p.name << " " << time << std::endl;
            continue;
        }
        p.time -= q;
        queue.enqueue(p);
        time += q;
    }
}



Measured memory_bytes: 7080
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String[] a = s.split(" ");
        int x = Integer.parseInt(a[0]);
        int y = Integer.parseInt(a[1]);
        if( x < y ){
            System.out.println("a < b");
        }else if( x > y ){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }

    }
}

Measured memory_bytes: 24148
#include<cstdio>
#include<cstring>

int main(){
    char str[1001];
    
    while(1){
        scanf("%s", &str);
        if(str[0] == '0') break;
        int sum = 0;
        for(int i = 0; i < strlen(str); i++){
            sum = sum + (str[i] - '0');
        }
        printf("%d\n", sum);
    }
    return 0;
}


Measured memory_bytes: 2732
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

istream& operator>> (istream& a, pii& b) {
    cin >> b.first >> b.second;
    return a;
}

ostream& operator<< (ostream& a, const pii& b) {
    cout << "{" << b.first << ", " << b.second << "}";
    return a;
}

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e5;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int x = 0;
    for (int i = 0; i < n; i++) {
        x ^= a[i];
    }
    for (int i = 0; i < n; i++) {
        cout << (x ^ a[i]) << " ";
    }
}
/*

*/

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

int main()
{
	int h, w;
	cin >> h >> w;
	int a[h][w];
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> a[i][j];
		}
	}
	vector<pair<pair<int, int>, pair<int, int>>> ans;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (a[i][j] % 2)
			{
				{
					int ni = i;
					int nj = j + 1;
					if (nj < w)
					{
						ans.push_back({{i, j}, {ni, nj}});
						a[ni][nj]++;
						continue;
					}
				}
				{
					int ni = i + 1;
					int nj = j;
					if (ni < h)
					{
						ans.push_back({{i, j}, {ni, nj}});
						a[ni][nj]++;
					}
				}
			}
		}
	}
	cout << ans.size() << endl;
	for (auto pp : ans)
	{
		auto p = pp.first;
		auto q = pp.second;
		cout << p.first + 1 << ' ' << p.second + 1 << ' ' << q.first + 1 << ' ' << q.second + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(auto& x: a) cin >> x;
	sort(a.begin(),a.end());
	int sum = 0;
	for(int i = 0; i < k; i++) {
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}





Measured memory_bytes: 3656
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007
#define DEBUG 0


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}


int main()
{

	int n, k;
	cin >> n >> k;

	vector<int> a(n);
	int max = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > max)max = a[i];
	}

	int gcdnum = a[0];
	for (int i = 1; i < n; i++) {
		gcdnum = gcd(gcdnum, a[i]);
	}

	if (k % gcdnum == 0 && k <= max) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	




	return 0;

}



Measured memory_bytes: 640
#include <stdio.h>

int F[44] = {0};

int fibonacci(int n){

  if(n == 1 || n == 0) return F[n] = 1;
  if(F[n] != 0) return F[n];
  return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}


int main(){
  int n;
  int fib;

  scanf("%d",&n);

  fib = fibonacci(n);

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

  return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<string>

using namespace std;

string s;
long long c=0,d[200010]={0};

signed main(){
    cin>>s;

    if(s.length()==1){
        cout<<0<<endl;
        return 0;
    }
    for(int i=s.length()-1;i>0;--i){
        d[i]=c;
        if(s[i-1]=='B'&&s[i]=='C')c++;
        else if(s[i-1]=='A'&&s[i]=='B')continue;
        else if(s[i-1]=='A'&&s[i]=='A')continue;
        else if(s[i-1]=='C'&&s[i]=='A')continue;
        else if(s[i-1]=='C'&&s[i]=='B')continue;
        else c=0;
    }
    d[0]=c;

    long long ans=0;
    for(int i=0;i<s.length();++i){
        if(s[i]=='A')ans+=d[i];
    }

    cout<<ans<<endl;

    return 0;
}

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

void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  v[0]--;
  bool isPossible = true;
  for (int i = 1; i < n; ++i) {
    if (v[i - 1] <= v[i]) {
      if (v[i - 1] < v[i]) v[i]--;
      else continue;
    } else {
      isPossible = false;
      break;
    }
  }

  if (isPossible) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define FOR(i, s, n) for(int i=(int)(s); i<(int)(n); ++i)
#define ALL(n) (n).begin(), (n).end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> mat;
// mat dtable(M, vl(N, 0)); M行N列 のサイズで,0で初期化


const ll MAX_V = 100000;
const ll INF = 1e9;
const ll MOD = 998244353;

int main(){
    int A, B, Q; cin >> A >> B >> Q;
    vl S(A), T(B);
    REP(i, A) cin >> S[i];
    REP(i, B) cin >> T[i];
    REP(i, Q){
        ll q; cin >> q;
        auto it_a = lower_bound(ALL(S), q);
        int idx_a = it_a - S.begin();

        vl a, b;

        if (idx_a == A){
            if (idx_a-1 >= 0) a.pb(S[idx_a-1]);
            if (idx_a-2 >= 0) a.pb(S[idx_a-2]);
        }else if (idx_a == A-1){
            a.pb(S[idx_a]);
            if (idx_a-1 >= 0) a.pb(S[idx_a-1]);
        }else{
            if (idx_a-1 >= 0) a.pb(S[idx_a-1]);
            a.pb(S[idx_a]);
            a.pb(S[idx_a+1]);
        }

        auto it_b = lower_bound(ALL(T), q);
        int idx_b = it_b - T.begin();

        if (idx_b == B){
            if (idx_b-1 >= 0) b.pb(T[idx_b-1]);
            if (idx_b-2 >= 0) b.pb(T[idx_b-2]);
        }else if (idx_b == B-1){
            b.pb(T[idx_b]);
            if (idx_b-1 >= 0) b.pb(T[idx_b-1]);
        }else{
            if (idx_b-1 >= 0) b.pb(T[idx_b-1]);
            b.pb(T[idx_b]);
            b.pb(T[idx_b+1]);
        }

        ll ans = 1e16;

        REP(i, a.size()){
            REP(j, b.size()){
                // cout << a[i] << " " << b[j] << " " << j << endl;
                ans = min(ans, abs(a[i]-q)+abs(b[j]-a[i]));
                ans = min(ans, abs(a[i]-b[j])+abs(b[j]-q));
            }
        }

        cout << ans << endl;
        // cout << "===" << endl;
    }
}

Measured memory_bytes: 2944
import java.util.*;
import java.math.*;
import java.util.Arrays;

public class Main {

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

    int count = 0;

    while (h > 0) {
      h -= a;
      count++;
    }

    System.out.println(count);

  }

}


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

int main()
{
	int N, K;
	string S;

	cin >> N;
	cin >> S;
	cin >> K;

	char key = S[K-1];
	//cout << "key:" << key << endl;

	for (int i = 0; i < N; i++) {
		if (key == S[i]) {

		}
		else {
			S.replace(i, 1,"*");
		}
	}
	cout << S;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAXL 7

void convert(int x, char s[MAXL + 1]);

int is_kaibun(char s[MAXL + 1]);

int main(void){
    int a, b;
    scanf("%d %d", &a, &b);

    char s[MAXL + 1];
    int ans = 0;
    for(int i = a; i <= b; i++){
        convert(i, s);
        if(is_kaibun(s)) ans++;
    }
    printf("%d\n", ans);
    return 0;
}

void convert(int x, char s[MAXL + 1]){
    int addr = 0;
    while(x > 0){
        s[addr] = '0' + x % 10;
        addr++;
        x /= 10;
    }
    s[addr] = '\0';
    return;
}

int is_kaibun(char s[MAXL + 1]){
    for(int i = 0; i <= strlen(s) / 2; i++){
        if(s[i] != s[strlen(s) - 1 - i]) return 0;
    }
    return 1;
}

Measured memory_bytes: 128
// "for if God is with them who can be against them."
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define endl '\n'
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
int ans = 0;
int cnt[400004];
void solve() {
	ll n, ans = 0, x = 0;
	cin >> n;
	ll a[n], b[n];
	REP(i, 0, n - 1) {
		cin >> a[i];
		x = x ^ (a[i]);
	}
	REP(i, 0, n - 1) {
		b[i] = x ^ a[i];
		cout << b[i] << " ";
	}

}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	IOS;
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}


#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
	return 0;
}

Measured memory_bytes: 6728
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int> G[200000];
int bi[200000];
int n,m;
void dfs(int v,int c){
    bi[v]=c;
    for(auto p:G[v]){
        if(bi[p]==0)dfs(p,-c);
    }
    return ;
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int K;
            cin>>K;
            G[i].push_back(n-1+K);
            G[n-1+K].push_back(i);
        }
    }
    bool ok=true;
    dfs(0,1);
    for(int i=0;i<n;i++){
        if(!bi[i])ok=false;
    }
    if(ok)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

const ll N=1e5+10;
mat G(N);
vec dp(N);
ll n,m;

void dfs(ll cur,ll pre) {
  dp[cur]=1;
  for(ll nex:G[cur]) {
    if(nex==pre) continue;
    dfs(nex,cur);
    (dp[cur]*=dp[nex]+1)%=m;
  }
}

void dfs1(ll cur,ll pre,ll dp_p=0) {
  ll n=G[cur].size();
  vec mul1(n),mul2(n);
  for(ll i=0;i<n;i++) {
    ll nex=G[cur][i];
    if(nex==pre) {
      mul1[i]=mul2[i]=(dp_p+1)%m;
      dp[cur]*=dp_p+1;
      dp[cur]%=m;
    }
    else {
      mul1[i]=mul2[i]=(dp[nex]+1)%m;
    }
  }
  for(ll i=0;i+1<n;i++) {
    (mul1[i+1]*=mul1[i])%=m;
  }
  for(ll i=n-1;i-1>=0;i--) {
    (mul2[i-1]*=mul2[i])%=m;
  }
  for(ll i=0;i<n;i++) {
    ll nex=G[cur][i];
    if(nex==pre) continue;
    ll a=(i?mul1[i-1]:1);
    ll b=(i+1<n?mul2[i+1]:1);
    dfs1(nex,cur,a*b%m);
  }
}

int main() {
  cin >> n >> m;
  for(ll i=0;i<n-1;i++) {
    ll x,y;
    cin >> x >> y;
    x--,y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(0,-1);
  dfs1(0,-1);
  for(ll i=0;i<n;i++) cout << dp[i] << endl;
}

Measured memory_bytes: 17792
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
using namespace std;
int main()
{
    long long int n,k,d,b=0,a;
    cin>>n>>k;
    if(n>k) {
        a=n/k;
        n=n-a*k;
    }
    while(n!=0) {
        d=abs(n-k);
        if(d>n)break;
        n=d;
        if(b==n)break;
        b=n;
    }
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template <typename T> using V = vector<T>;

bool solve() {
    ll N, M;
    cin >> N >> M;
    if(!(N + M)) return false;
    V<ll> max_score(N), min_score(N);
    for(ll i = 0; i < M; i++) {
        ll S, K;
        cin >> S >> K;
        bool one = K == 1;
        while(K--) {
            ll c;
            cin >> c;
            c--;
            max_score[c] += S;
            if(one) min_score[c] += S;
        }
    }

    ll ans = 0;
    for(ll i = 0; i < N; i++) {
        ll max_diff = 0;
        for(ll j = 0; j < N; j++) {
            if(i == j) continue;
            max_diff = max(max_diff, max_score[i] - min_score[j]);
        }
        ans = max(ans, max_diff);
    }

    cout << ans + 1 << endl;
    return true;
}

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



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

using namespace std ;

const int MAX = 2e5 + 5 ;
const int MAXLOG = 20 ;

int lg[MAX] , st[MAX][MAXLOG] , st2[MAX][MAXLOG] , arr[MAX] , s[MAX];
int n , k;

void preprocess()
{
	lg[1] = 0 ;
	for(int i = 2 ; i < MAX ; ++i)
		lg[i] = lg[i/2] + 1 ;
	for(int i = 0 ; i < n ; ++i)
		st[i][0] = st2[i][0] = arr[i] ;
	for(int j = 1 ; j <= lg[n] ; ++j)
	{
		for(int i = 0 ; i + (1 << j) <= n ; ++i)
		{
			st[i][j] = min(st[i][j-1] , st[i + (1 << (j-1))][j-1]) ;
			st2[i][j] = max(st2[i][j-1] , st2[i + (1 << (j-1))][j-1]) ;
		}
	}
	return ;
} 

int rminq(int l , int r)
{
	int j = lg[r-l+1] ;
	return min(st[l][j] , st[r - (1 << j) + 1][j]) ;
}

int rmaxq(int l , int r)
{
	int j = lg[r-l+1] ;
	return max(st2[l][j] , st2[r - (1 << j) + 1][j]) ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>k ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	preprocess() ;
	int l = 0 , r = 0 ;
	while(r < n)
	{
		++r ;
		if(l == r)
			++r ;
		if(arr[r] > arr[r-1])
		{
			if(r-l+1 == k)
			{
				s[l] = 1 ;
				++l ;
			}
		}	
		else
			l = r ;
	}
	bool flag = false ;
	int ans = 0 ; 
	for(int i = 0 ; i < n ; ++i)
	{
		if(i+k-1 >= n)
			break ;
		if(s[i])
		{
			if(!flag)
				ans++ ;
			flag = true ;
			continue ;
		}
		if(i == 0)
			ans++ ;
		else if(rminq(i-1 , i+k-2) != arr[i-1] || rmaxq(i , i+k-1) != arr[i+k-1])
			ans++ ;
	}
	return cout<<ans<<"\n" , 0 ;
}

Measured memory_bytes: 33920
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

void foreach_permutation(int n, std::function<void(int *)> f) {
	int indexes[n];
	for (int i = 0; i < n; i++)
		indexes[i] = i;
	do {
		f(indexes);
	} while (std::next_permutation(indexes, indexes + n));
}

string P;
string Q;

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N;
	cin >> N;
	P.resize(N);
	Q.resize(N);

	for (size_t i = 0; i < N; i++) {
		cin >> P[i];
	}
	for (size_t i = 0; i < N; i++) {
		cin >> Q[i];
	}

	string s;
	s.resize(N);

	int loop_count = 0;
	int a = -1;
	int b = -1;
	foreach_permutation(N, [&](int *indexes) {
		for (size_t i = 0; i < 8; i++) {
			s[i] = '1' + indexes[i];
		}

		//cout << s << endl;

		if (P == s) {
			a = loop_count;
		}
		if (Q == s) {
			b = loop_count;
		}

		loop_count++;
	});

	cout << abs(a - b) << endl;

	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
struct State { int dist; int u; int c; };
 
const int N = 100005, M = 200005;
 
int n, m;
vector< pair<int,int> > G[N];
map <int,int> d[N];
 
void dijkstra() {
	deque<State> q;
	q.push_back({0, 1, 0}); d[1][0] = 0;
 
	while(!q.empty()) {
		State f = q.front(); q.pop_front();
		int u = f.u, c = f.c;
		if (f.dist != d[u][c]) continue;
 
		if (!d[u].count(0) || (d[u].count(0) && d[u][0] > f.dist)) {
			d[u][0] = f.dist; q.push_front({f.dist, u, 0});
		}
 
		if (c) {
			int pos = lower_bound(G[u].begin(), G[u].end(), make_pair(c, 0)) - G[u].begin();
			while(pos < G[u].size() && G[u][pos].first == c) {
				int v = G[u][pos].second;
				if (!d[v].count(c) || (d[v].count(c) && d[v][c] > f.dist)) {
					d[v][c] = f.dist; q.push_front({f.dist, v, c});
				}
				++pos;
			}
		} else {
			for (auto e : G[u]) {
				int v = e.second, cc = e.first;
				if (!d[v].count(cc) || (d[v].count(cc) && d[v][cc] > f.dist + 1)) {
					d[v][cc] = f.dist + 1; q.push_back({f.dist + 1, v, cc});
				}
			}
		}
	}
}
 
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	while(m--) {
		int u, v, c; cin >> u >> v >> c;
		G[u].push_back(make_pair(c, v));
		G[v].push_back(make_pair(c, u));
	}
	for (int i = 1; i <= n; ++i) {
		sort(G[i].begin(), G[i].end());
	}
	dijkstra();	
 
	if (!d[n].count(0)) cout << -1 << endl; else cout << d[n][0] << endl;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int N;
vector<int> A, B;
vector<pair<int, int>> AB;

bool cmp(pair<int, int> l, pair<int, int> r){
  return l.first + l.second < r.first + r.second;
}
int main(){
  cin >> N;
  A.resize(N), B.resize(N);
  AB.resize(N);
  REP(i, N){
    cin >> A[i] >> B[i];
    AB[i] = {A[i], B[i]};
  }
  ll taka = 0, ao = 0;
  sort(AB.rbegin(), AB.rend(), cmp);
  REP(i, N){
    if(i%2){
      ao += AB[i].second;
    }
    else{
      taka += AB[i].first;
    }
  }
  cout << taka - ao << endl;
  return 0;
}


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

int main() {
    int a;
    cin>>a;
    int answer;
    answer=a+a*a+a*a*a;
    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

const ll MOD = 1e9 + 7;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }

ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128

ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}



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


int main(){
    fastio
    ll tc=1;// cin >> tc;
    while(tc--) __sol();
    return 0;
}


Measured memory_bytes: 3656
"use strict"
let fs = require('fs');
let input = fs.readFileSync("/dev/stdin", "utf8").split(/\s/);
 
const a = BigInt(input[0]);
const b = BigInt(input[1]);
const c = BigInt(input[2]);
const d = BigInt(input[3]);
 
const ac = a * c;
const ad = a * d;
const bc = b * c;
const bd = b * d;

let ans = ac;
ans = ans < ad ? ad : ans;
ans = ans < bc ? bc : ans;
ans = ans < bd ? bd : ans;
 
console.log(String(ans).replace('n', ''));

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int r;
    cin >> r;
    double a = M_PI;
    cout << 2 * r * a << endl;
    return 0;
}

Measured memory_bytes: 3784
# -*- coding:utf8 -*-

n = int(input())
l = list(map(int, input().split()))
c = 0
for i in range(n):
    minj = i + l[i:].index(min(l[i:]))
    if minj != i:
        l[i], l[minj] = l[minj], l[i]
        c += 1
print(' '.join(map(str, l)))
print(c)


Measured memory_bytes: 5612
#include <iostream>
#include <algorithm>

using namespace std;

char tb[100][100];

void circle(int h, int w, char mk){
    for(int i=-1; i<2; i++){
        for(int j=-1; j<2; j++){
            if(!(i==0 && j==0)) tb[h + i][w + j] = mk;
        }
    }
}

void dot(int h, int w, char mk){
    tb[h][w] = mk;
}

int main(){
    int A, B;
    cin >> A >> B;
    char mj, mn;
    if (A > B) {
        mj = '.';
        mn = '#';
    }
    else {
        mj = '#';
        mn = '.';
    }

    for(int i=0; i<100; i++) {
        for(int j=0; j<100; j++) tb[i][j] = mn;
    }

    
    int h = 2, w = 2;
    for(int i=0; i<max(A, B); i++){
        if(i < min(A, B)-1) circle(h, w, mj);
        else dot(h, w, mj);
        w += 4;
        if(w > 95){
            w %= 96;
            h += 4;
        }
    }
    cout << 100 << " " << 100 << endl;
    for(int i=0; i<100; i++){
        for(int j=0; j<100; j++){
            cout << tb[i][j];
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
    int N,X;
    cin >> N >> X;
    vector<int> m(N);
    for (int i = 0;i < N;i++) {
        cin >> m[i];
    }

    int ras = 1000;
    for (int i = 0;i < N;i++) {
        if(m[i] < ras){
            ras = m[i];
        }
    }
    int kan = 0;
    int ans = 0;
    for (int i = 0;i < N;i++) {
        kan+= m[i];
    }
    ans = (X - kan) / ras;
    cout<<ans+N<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define INF -1

int Mini( int , int );
int MatrixChainOrder( int n, int p[] );

int main(){
    int n, i, value, p[200];//this p means the row and column

    //input
    scanf("%d", &n);
    scanf("%d", &p[0]);
    for(i = 1; i<n; i++) scanf("%d%d",&p[i], &p[i]);
    scanf("%d", &p[n]);
    //calcurate
    value = MatrixChainOrder(n, p);
    //print
    printf("%d\n", value);
    
    return 0;
}
int Mini( int x, int y ){
    if(x<0) return y;
    else if(y<0) return x;
    else if(x > y) return y;
    else return x;
}

int MatrixChainOrder( int n, int p[] ){//p is index of matrix
    int l, i, j, k, m[n+1][n+1], value;//0-origin
    //initialize
    for(i = 1; i<=n; i++) m[i][i] = 0;
    //calculate
    for(l = 1; l<n; l++){
	for(i = 1; i<=n-l; i++){
	    j = i+l;
	    m[i][j] = INF;
	    for(k = i; k<j; k++){
		value = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
		m[i][j] = Mini(m[i][j], value);
	    }
	}
    }
    return m[1][n];
}



Measured memory_bytes: 2112
///
// File:  1124.cpp
// Author: ymiyamoto
//
// Created on Fri Nov 10 15:22:43 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  while (true) {
    uint32_t N, Q;
    cin >> N >> Q;
    if (N == 0) break;

    vector<uint32_t> nums(101, 0);

    for (uint32_t i = 0; i < N; i++) {
      uint32_t n;
      cin >> n;
      for (uint32_t j = 0; j < n; j++) {
        uint32_t day;
        cin >> day;
        nums[day]++;
      }
    }

    uint32_t max_num = 0;
    uint32_t the_day = 0;
    for (uint32_t i = 1; i < 101; i++) {
      if (nums[i] >= Q) {
        if (nums[i] > max_num) {
          max_num = nums[i];
          the_day = i;
        }
      }
    }

    cout << the_day << endl;
  }

  return 0;
}

Measured memory_bytes: 3060
inp=int(input())
if 400<=inp<=599:
    print(8)
if 600<=inp<=799:
    print(7)
if 800<=inp<=999:
    print(6)
if 1000<=inp<=1199:
    print(5)
if 1200<=inp<=1399:
    print(4)
if 1400<=inp<=1599:
    print(3)
if 1600<=inp<=1799:
    print(2)
if 1800<=inp<=1999:
    print(1)

Measured memory_bytes: 9192
#import<ios>
int T,F,R,c,a,t;char s[9];
main()
{
for(;c+21&&scanf("%s",s);a+=T)
c=*s-69,
c<0?a&&printf("%d\n",a),a=0,T=1,F=2,R=3:0,
c==9?t=T,T=F,F=7-t:0,
c==14?t=F,F=T,T=7-t:0,
!c?t=R,R=T,T=7-t:0,
c==18?t=T,T=R,R=7-t:0,
c==13?t=F,F=R,R=7-t:0,
c==7?t=R,R=F,F=7-t:0;
}

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

using namespace std;

bool p[66666];

int main()
{
	for (int i = 2; i < 333; i++) {
		if (p[i]) continue;
		for (int j = i * i; j < 66666; j += i)
			p[j] = true;
	}
	int n;
	cin >> n;
	for (int i = 3; n; i += 10)
		if (!p[i]) n--, cout << i << ' ';
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		List<Integer> prime = new ArrayList<Integer>();
		prime.add(2); prime.add(3);
		int[] check = new int[50001];
		check[2] = 1; check[3] = 1;
		
	outer:	for(int i = 5; i < 50000; i += 2){
			for(int j = 1; prime.get(j) <= Math.sqrt(i); j++){
				if( i%prime.get(j) == 0 ){
					continue outer;
				}
			}
			prime.add(i);
			check[i] = 1;			
		}
		
		List<Integer> result = new ArrayList<Integer>();
		int n = stdIn.nextInt();
		while( n != 0 ){
			if( n%2 != 0 ){
				if( check[n-2] == 1 ){
					result.add(1);
				} else {
					result.add(0);
				}
			
			} else {
				int sum = 0;
				int index = 0;
				while( prime.get(index) <= n/2 ){
					if( check[n-prime.get(index)] == 1 ){
						sum++;
					}
					index++;
				}
				result.add(sum);
			}
			n = stdIn.nextInt();
		}
		for(Integer sum : result){
			System.out.println(sum);
		}
	}
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int H, W; cin >> H >> W;
    string A[H];
    vector<int> skip_h, skip_w;
    REP(i, H) cin >> A[i];
    REP(i, H) {
        if (count(A[i].begin(), A[i].end(), '#') == 0) {
            skip_h.push_back(i);
        }
    }
    REP(j, W) {
        bool is_skip = true;
        REP(i, H) {
            if (A[i][j] == '#') {
                is_skip = false;
            }
        }
        if (is_skip) {
            skip_w.push_back(j);
        } 
    }

    REP(i, H) {
        if (find(skip_h.begin(), skip_h.end(), i) != skip_h.end()) {
            continue;
        }
        REP(j, W) {
            if (find(skip_w.begin(), skip_w.end(), j) != skip_w.end()) {
                continue;
            }
            cout << A[i][j];
        }
        cout << "\n";
    }
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int N, Q;

int bit[500010], C[500010], ball[500010], ans[500010];
vi query[500010], query_id[500010];

void init(){
  rep(i, 0, 500010)
    bit[i] = 0;
}

void add(int i, int x){
  for(int idx = i; idx < 500010; idx += (idx & -idx)){
    bit[idx] += x;
  }
}

int sum(int i){
  int s = 0;
  for(int idx = i; idx > 0; idx -= (idx & -idx)){
    s += bit[idx];
  }
  return s;
}

int rangesum(int l, int r){
  return sum(r) - sum(l-1);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cin >> N >> Q;
  rep(i, 1, N+1)
    cin >> C[i];
  
  rep(i, 0, Q){
    int l, r;
    cin >> l >> r;
    query[r].push_back(l);
    query_id[r].push_back(i);
  }
  
  init();
  rep(i, 1, N+1)
    ball[i] = 0;
  rep(i, 1, N+1){
    if(ball[C[i]] > 0)
      add(ball[C[i]], -1);
    add(i, +1);
    ball[C[i]] = i;
    rep(j, 0, query[i].size()){
      ans[query_id[i][j]] = rangesum(query[i][j], i);
    }
  }
  
  rep(i, 0, Q){
    cout << ans[i] << "\n";
  }
  
  return 0;
  
}

Measured memory_bytes: 84344
from collections import Counter


N = int(input())
A = list(map(int, input().split()))
Q = int(input())

S = sum(A)
C = Counter(A)

ans = []
for _ in range(Q):
    b, c = map(int, input().split())
    count = C[b]
    S += (c - b) * count
    C[b], C[c] = 0, C[c] + count
    ans.append(S)

print('\n'.join(map(str, ans)))

Measured memory_bytes: 33832
/**
*    created: 25.07.2020 06:50:45
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8]={0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8]={1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int prim[MAX];
    rep(i,MAX) prim[i] = -1;
    rep2(i,2,MAX) {
        if (prim[i] != -1) continue;
        int j = i + i;
        while (j < MAX) {prim[j]++; j += i;}
    }
    prim[1]++;
    prim[0]++;
    int cnt[MAX];
    rep(i,MAX) {
        if (prim[i] == -1) cnt[i] = 1;
        else cnt[i] = 0;
    }
    int alk[MAX];
    rep(i,MAX) alk[i] = 0;
    rep(i,MAX) {
        if (i*2-1 >= MAX) break;
        if (cnt[i] == 1 && cnt[i*2-1] == 1) alk[i*2-1] = 1;
    }
    rep2(i,1,MAX) alk[i] += alk[i-1];
    int n; cin >> n;
    rep(i,n) {
        int l, r; cin >> l >> r;
        cout << alk[r] - alk[l-1] << endl;
    }
    return 0;
}

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

int main() {
	int i, j, k, c, H[100], W[100];
	i = 0;
	while (1) {
		scanf("%d %d", &H[i], &W[i]);
		if (0 == H[i] && 0 == W[i]) {
			break;
		}
		i++;
	}
	c = i;
	for (k = 0; k < c; k++) {
		for (i = 0; i < H[k]; i++) {
			for (j = 0; j <W[k]; j++) {
				if ((i+j)%2 == 0) {
					printf("#");
				}
				else {
					printf(".");
				}

			}
			printf("\n");
		}
		printf("\n");
	}
}

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

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

    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }

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

    bool same = false;
    for (int i = 0; i < n - 1; i++){
        if (data.at(i) == data.at(i + 1)){
            same = true;
            break;
        }
    }

    cout << (same ? "NO" : "YES") << endl;
}

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

void call(int n) {
    int i = 1;
CHECK_NUM:
    int x = i;
    if (x % 3 == 0) {
        cout << " " << i;
        goto END_CHECK_NUM;
    }
INCLUDE3:
    if (x % 10 == 3) {
        cout << " " << i;
        goto END_CHECK_NUM;
    }
    x /= 10;
    if (x)
        goto INCLUDE3;
END_CHECK_NUM:
    if (++i <= n)
        goto CHECK_NUM;

    cout << endl;
}

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

    call(n);

    return 0;
}


Measured memory_bytes: 3092
object Main extends App {
  val n: Int = io.StdIn.readInt()
  val matrix: Array[Array[Int]] = Array.ofDim(n, n)
  for (i <- 0 until n) {
    val indices: Array[Int] = io.StdIn.readLine().split(" ").drop(2).map(_.toInt)
    indices foreach (j => matrix(i)(j-1) = 1)
  }
  for (x <- matrix) println(x.mkString(" "))
}


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

int n,a,k,ans[200000];

int main(){
	cin>>n;
	for (int i=1;i<n;i++){
		cin>>a;
		ans[a]++;
	}
	for (int i=1;i<=n;i++){
		cout<<ans[i]<<"\n";
	}
}

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

int divisor(int n){
    vector<long long> ret;
    for (int i=1; i * i <=n; i++){
        if (n % i == 0){
            ret.push_back(i);
            if (i * i != n) ret.push_back(n/i);
        }
    }
    return ret.size();
}

int main() {

    int n;
    cin >> n;
    int ans = 0;

    for(int i=1;i<=n;i+=2){
        if (divisor(i) == 8) ans += 1;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(){
   int n, i;
   long a, min, max, sum;
   sum = 0;
   scanf("%d", &n);
   for(i = 0; i < n; i++){
      scanf("%ld", &a);
      if(i == 0){
         min = a;
         max = a;
      }
      /* calculate the min */
      if(min > a){
         min = a;
      }

      /* calculate the max */
      if(max < a){
         max = a;
      }

      /* calcilate the sum */
      sum = sum + a;
   }

   printf("%ld %ld %ld\n", min, max, sum);

   return 0;
}



Measured memory_bytes: 2140
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin>>x;
    if(x==0)
    {
        cout<<"1"<<endl;
    }
    else if(x==1)
    {
        cout<<"0"<<endl;
    }
 return 0;
}


Measured memory_bytes: 3592
h=int(input())
w=int(input())
n=int(input())

_max=max(h,w)
_min=min(h,w)
ans=0

for i in range(_min):
    n-=_max
    ans+=1
    if n<=0:
        print(ans)
        exit()
    
for i in range(_max):
    n-=_min
    ans+=1
    if n<=0:
        print(ans)
        exit()

Measured memory_bytes: 3064
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto G = new int[][](N);
    foreach (i; 0..N-1) {
        auto s = readln.split.map!(to!int);
        G[s[0]-1] ~= s[1]-1;
        G[s[1]-1] ~= s[0]-1;
    }

    auto sub = new int[](N);

    void dfs1(int n, int p) {
        sub[n] = 1;
        foreach (m ;G[n]) if (p != m) {
            dfs1(m, n);
            sub[n] += sub[m];
        }
    }

    dfs1(0, -1);

    long ans = 0;

    void dfs2(int n, int p) {
        if (G[n].length > 1) {
            long prob = powmod(2, MOD-2, MOD);
            long bb = 0;
            long b0 = 1;
            foreach (m; G[n]) {
                long num = m == p ? N - sub[n] : sub[m];
                long q = powmod(2, num, MOD);
                b0 = b0 * powmod(q, MOD-2, MOD) % MOD;
            }
            bb = b0;
            foreach (m; G[n]) {
                long num = m == p ? N - sub[n] : sub[m];
                long q = powmod(2, num, MOD);
                long b1 = b0 * q % MOD;
                q = (q - 1) * powmod(q, MOD-2, MOD) % MOD;
                q = (q + MOD) % MOD;
                b1 = b1 * q % MOD;
                (bb += b1) %= MOD;
            }
            bb = (1 - bb) % MOD;
            bb = (bb + MOD) % MOD;
            (ans += prob * bb % MOD ) %= MOD;
        }
        foreach (m; G[n]) if (m != p) {
            dfs2(m, n);
        }
    }

    dfs2(0, -1);

    ans.writeln;
}


long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}


Measured memory_bytes: 28668
import math
mod = 10**9+7
n,k = map(int,input().split())
b = math.factorial(k-1)%mod
fact = [0]*(n-k+1)
a = math.factorial(k-1)%mod
c = 1
for i in range(k-1, n):
    if i == k-1:
        fact[0] = (a*pow(b*c, mod-2, mod))%mod
    else:
        a = a*i%mod
        c = c*(i-k+1)%mod
        fact[i-k+1] = (a*pow(b*c, mod-2, mod))%mod
A = list(map(int,input().split()))
A.sort()
ans = 0
for i in range(k-1,n):
    ans += fact[i-k+1]*(A[i]-A[n-i-1])
    ans %= mod
print(ans)


Measured memory_bytes: 16736
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 123456789012345
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;


int main() {

	int a,b,c,d;cin >>a>>b>>c>>d;

	if(abs(a-c) <= d)
	{
		cout << "Yes" << endl;
		return 0;
	}

	if(abs(a-b) <= d && abs(b-c) <=d)
	{
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long ll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll i=0; i<(n); i++)
#define forn3(i, x, n) for(ll i=(x); i<(n); i++)

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll ans=180LL*(n-2);
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  if(a+b<=c) cout<<0<<" "<<0;
  else if(a<=c) cout<<0<<" "<<(a+b)-c;
  else cout<<a-c<<" "<<b;
  return 0;
}


Measured memory_bytes: 3620
import bisect
import collections
n = int(input())
a = list(map(int,input().split()))
# 1,...,n の身長はa[n-1]
# abs(i-j) == a[i]+a[j]
# a[i]+a[j]-j+i (i<=j) == 0 ????
# a[i]+i+a[j]-j == 0 ????
#とりあえず a[i]+i a[j]-j つくろう
x = [a[i]+i for i in range(n)]
y = [a[i]-i for i in range(n)]
#xに対して-yと一致するものは何こ有る？
c = collections.Counter(y)
cnt = 0
for i in range(n):
	cnt += c[-x[i]]
print(cnt)

Measured memory_bytes: 50692