akhauriyash/Code-Regression huggingface dataset:
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1
x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy
print(str(x3)+' '+str(y3)+' '+str(x4)+' '+str(y4))

Measured memory_bytes: 38256
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n: usize;
    let a: usize;
    let mut flag = false;
    input!(n);
    input!(a);

    for z in 0..a + 1 {
        if (n - z) % 500 == 0 {
            flag = true;
            break;
        }
    }
    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
    
#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
//#define int long long int
    
using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_mset = tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
    
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    
const ll mod = 998244353;
const int INF = 0x3f3f3f3f;
//const ll INFLL = (ll)1e17;
const int MAXN = 112345;
const double pi = 3.14159265359;
const double eps = 0.00000001;

int dp[MAXN], h[MAXN];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &h[i]);
    }
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; ++i) {
        dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i]));
    }
    printf("%d\n", dp[n - 1]);
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n+1);
	REP(i,n){
		cin >> a[i];
	}
	int ans = 0;
	REP(i,n){
		if(i % 2 == 1 && a[i] % 2 == 1) ans++;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define FOR(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int d;
	for(;cin>>d;){
		int r=0;
		for(int i=0;i<600;i+=d){
			r+=d*i*i;
		}
		cout<<r<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	string s,t="2019/04/30";
	cin>>s;
	if(s<=t)cout<<"Heisei"<<endl;
	else cout<<"TBD"<<endl;
}


Measured memory_bytes: 256
import numpy as np

H, W = list(map(int, input().split()))
S = np.array([list(input()) for _ in range(H)]) == '.'
ups = np.zeros((H, W), dtype=int)
downs = np.zeros((H, W), dtype=int)
rights = np.zeros((H, W), dtype=int)
lefts = np.zeros((H, W), dtype=int)

for i in range(H):
  lefts[i] = (lefts[i - 1] + 1) * S[i]
  rights[-1 - i] = (rights[-i] + 1) * S[-1 - i]
for i in range(W):
  ups[:, i] = (ups[:, i - 1] + 1) * S[:, i]
  downs[:, -1 - i] = (downs[:, -i] + 1) * S[:, -1 - i]
  
ans = np.max(lefts + rights + ups + downs) - 3
print(ans)  

Measured memory_bytes: 219812
#include<stdio.h>
int main(void)
{
	int sec,h,n,m,s;

	scanf("%d", &sec);

	h = sec / 3600;
	n = sec % 3600;
	m = n / 60;
	s = n % 60;
	

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    int ans = 0;
    int a = 0,b = 0,k = 0;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        for(int j = 0; j < s[i].size()-1; j++){
            if(s[i][j] == 'A' && s[i][j+1] == 'B') ans++;
        }
        if(s[i][s[i].size()-1] == 'A') a++;
        if(s[i][0] == 'B') b++;
        if(s[i][s[i].size()-1] == 'A' && s[i][0] == 'B') k++;
    }    
    if(a == b && b == k && k != 0) ans--;
    ans += min(a,b);
    cout << ans << endl;
}

Measured memory_bytes: 768
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	string s;
	cin>>s;
	string ans = "";
	rep(i,s.size()){
		if(s[i]=='B'){
			if(ans.size()==0){
				continue;
			}
			else{
				ans = ans.substr(0,ans.size()-1);
			}
		}
		else{
			ans += s[i];
		}
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int n,m;
int k[10],s[10][10];
int p[10];
int ans;
vector<int> S[11];
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            cin>>s[i][j];
            S[s[i][j]-1].push_back(i);
        }
    }for(int i=0;i<m;i++)cin>>p[i];
    int x[10];
    for(int i=0;i<1<<n;i++){
        for(int j=0;j<m;j++)x[j]=0;
        for(int j=0;j<n;j++){
            if((i>>j)%2==0) continue;
            for(int k=0;k<S[j].size();k++){
                x[S[j][k]]++;
            }
        }
        for(int j=0;j<m;j++){
            if(x[j]%2!=p[j]) break;
            if(j==m-1) ans++;
        }
    }
    cout<<ans;
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    map<int,int> data;
    for (int i = 0; i < 3; ++i) {
        int v;
        cin>>v;
        data[v]++;
    }
    if(data[5] == 2 && data[7] == 1){
        cout<<"YES"<<endl;
    }else cout<<"NO"<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
offset = 10**10

def main():
    N, W = map(int, input().split())
    w0, v0 = map(int, input().split())
    item = [0, w0 * offset + v0]
    weight_sum, value_sum = w0, v0
    for _ in range(1, N):
        w, v = map(int, input().split())
        item.append(w * offset + v)
        weight_sum += w
        value_sum += v

    if W < w0:
        print(0)
        return
    if weight_sum <= W:
        print(value_sum)
        return

    if w0 <= 3 * (N - 1):
        # dp[i][j] = (1~i番目の荷物を重さj以下で詰めたときの最大価値)
        dp = [[0] * (W + 1) for _ in range(N + 1)]
        for i in range(1, N + 1):
            w, v = item[i] // offset, item[i] % offset
            for j in range(w): dp[i][j] = dp[i - 1][j]
            for j in range(w, W + 1):
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)
        print(dp[N][W])
        return

    # dp[i][j][k] = (1~i番目までのものを見たとき、重さが(j * w0 + k)以下で最大価値がいくらか)
    dp = [[[0] * (3 * (N - 1) + 1) for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(1, N + 1):
        w, v = item[i] // offset, item[i] % offset
        for j in range(i + 1):
            for k in range(3 * (N - 1) + 1):
                weight = j * w0 + k
                q, r = (weight - w) // w0, (weight - w) % w0
                if weight < w:
                    dp[i][j][k] = dp[i - 1][j][k]
                elif (weight - w) % w0 > 3 * (N - 1):
                    dp[i][j][k] = max(dp[i - 1][j][k], dp[i - 1][q][3 * (N - 1)] + v)
                else:
                    dp[i][j][k] = max(dp[i - 1][j][k], dp[i - 1][q][r] + v)
    q, r = W // w0, min(W % w0, 3 * (N - 1))
    print(dp[N][q][r])


if __name__ == "__main__":
    main()


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

#define ll 					long long
#define db					double
#define ull 				unsigned long long
#define pii 				pair<int,int>
#define fi 					first
#define se 					second
#define vi 					vector<int>
#define vl					vector<ll>
#define psb 				push_back
#define ppb 				pop_back
#define all(x)			 	(x).begin(),(x).end()
#define sz(x)				(int)(x).size()
#define endln 				printf("\n")
#define gc					getchar_unlocked
#define setmin(x)			memset((x), -1, sizeof((x)))
#define setnul(x)			memset((x), 0, sizeof((x)))
#ifndef getchar_unlocked
#define getchar_unlocked 	getchar
#endif
const int inf = 1e9 + 5;
const ll infll = 1e18+5;
const int mod = 1e9 + 7;

template <typename T>
void gi(T &ret) {
	ret = 0; char inp=gc(); int kl=1;
	while (inp<'0' || inp>'9') {if (inp=='-') kl=-1; inp=gc();}
	while ('0'<=inp && inp<='9') ret=(ret<<3)+(ret<<1)+(inp-'0'), inp=gc();
	if (kl<1) ret=-ret;
}

const int MAXN = 2e5+5;
int n, val[MAXN];

ll solve () {
	ll ret = 0ll;
	int lst = 0;
	for (int i=n; i>=1; i--) {
		lst = max(0,lst-1);
		if (val[i]<lst) return -1;
		if (val[i]==lst) continue;
		ret += (ll)val[i];
		lst = val[i];
	}
	if (lst>0) return -1;
	return ret;
}

int main() {
	gi(n);
	for (int i=1; i<=n; i++) gi(val[i]);
	printf ("%lld\n", solve());
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
int x, y;
scanf("%d %d", &x, &y);
    if(x==2||y==2){
        printf("No\n");
    }
    else if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))
    {
        printf("Yes\n");
    }
    else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11))
    {
        printf("Yes");
    }
    else{
        printf("No");
    }
return 0;
}

Measured memory_bytes: 2044
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
int x;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>x;
	for(int i=1;i<=3333;i++)if((i*x)%360==0){cout<<i<<'\n'; return 0;}
	return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

#define pi acos(-1)
int main() {
  int n; cin >> n;
  vector<int> vi;
  for (int i = 0; i < n; i++) {
    int l; cin >> l;
    vi.push_back(l);
  }
  sort(vi.begin(), vi.end());

  long long int res = 0;
  for (int i = 0; i < n; i++) {
    for ( int j = i+1; j < n; j++) {
      for (int k = j+1; k < n; k++) {
        if (vi[i]==vi[j]||vi[j]==vi[k]) continue;
        if (vi[i]+vi[j] > vi[k]) res++;
      }
    }
  }

  cout << res << endl;
  return 0;
}



Measured memory_bytes: 3628
d = int(input())
c = list(map(int, input().split()))
prev = [0] * 26
for i in range(d):
  s = list(map(int, input().split()))
  happy = - (10 ** 10)
  ans = -1
  for j in range(26):
    tmp = s[j]
    cost = 0
    for k in range(26):
      if j == k:
        continue
      cost += c[k] * (i - prev[k])
    tmp -= cost
    if tmp > happy:
      happy = tmp
      ans = j
  prev[ans] = i
  print(ans+1)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    sort(all(s));

    string ans = "";
    rep(i, n) ans += s[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;
int main()
{
	char cards[3][101];
	char ptr[3];
	char next = 0;

	for(int i = 0; i < 3; i++){
		scanf("%s", &cards[i]);
		ptr[i] = 0;
	}

	while(1){

		char card = cards[next][ptr[next]++];
		if(card == '\0')
			break;
		next = card - 'a';
	}

	printf("%c", next + 'A');
	return 0;
}


Measured memory_bytes: 128
fn main() {
    fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    let n: i32 = read_line().parse().unwrap();
    if n == 1 {
        println!("Hello World");
    } else {
        let a: i32 = read_line().parse().unwrap();
        let b: i32 = read_line().parse().unwrap();
        println!("{}", a + b);
    }
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] suit={"S","H","C","D"};
        Set<String> list = new HashSet<String>();
        for (int i = 0; i < n; i++) {
            list.add(br.readLine());
        }
        for (int i=0;i<4;i++) {
            for(int j=1;j<=13;j++){
                if(!list.contains(suit[i]+" "+j)){
                    System.out.println(suit[i]+" "+j);
                }
            }
        }
    }
}

Measured memory_bytes: 24288
n = int(input())
c = list(map(int,input().split()))
c.sort(reverse = True)
a = 0
b = 0
if n % 2 == 0:
    for i in range(n // 2 ):
        a += c[i * 2]
        b += c[i * 2 + 1]
else:
    for i in range(n // 2 ):
        a += c[i * 2]
        b += c[i * 2 + 1]
    a += c[n - 1]

print(a - b)

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


int main(){
    int N,K;
    int A[200000];
    int B[200001] = {};
    cin >> N >> K;
    rep(i,N){
        cin >> A[i];
        B[A[i]]++;
    }
    sort(B,B+200001);
    int sum=0;
    rep(i,200001-K){
        sum += B[i];
    }
    cout << sum << endl;

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


Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
  int i,j,n,s,count=0,k=0,A[100];

  scanf("%d",&n);

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

  for(i=0;i<=n-1;i++)
    {
      s = i;
      for(j=i;j<=n-1;j++)
	{
	  if(A[j] < A[s])
	    {
	      s = j;
	    }
	}
      if(A[i] != A[s])
	{
	  k = A[i];
	  A[i] = A[s];
	  A[s] = k;
	  count++;
	}
    } 
  for(i=0;i<n-1;i++)
    {
      printf("%d ",A[i]);
    }
  printf("%d\n",A[n-1]);
  printf("%d\n",count);

  return 0;
}
  

Measured memory_bytes: 600
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
int n,k;
int main(){
    cin >> n>> k;
    ll ans=0;
    for(int b=max(1,k+1);b<=n;b++){
        for(int a=1;a<=n;){
            if(a%b>=k){
                ans+=b-(a%b);
                a+=b-(a%b);
                if(a>n){
                    ans-=(a-n-1);
                }
            }else{
                a+=(k-(a%b));
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
import math


def is_prime(num):
    if num == 1:
        return False
    n = int(math.sqrt(num))
    for i in range(2, n + 1):
        if num % i == 0:
            return False
    return True


x = int(input())

t = x
while True:
    if is_prime(t):
        print(t)
        break
    t += 1


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
    int a, b;
	int n, m;
	double x;

	scanf("%d %d", &a, &b);

	n = a / b;
	m = a % b;
	x = (double)a / b;

	printf("%d %d %.5lf", n, m, x);
	
	return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a>b?b:a)
#define INF 0x3f3f3f3f
#define sz size()
#define pb push_back
#define ph push
#define mem(x, y) memset(x, y, sizeof(x));
#define mem0(x) mem(x,0)
#define mem1(x) mem(x,-1)
#define memINF(x) mem(x,INF)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define setI freopen("input.txt","r",stdin);
#define setIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
typedef long long ll;

typedef vector<int> vi;
typedef pair<int, int> pii;

int const Max_N = 3e3+50;

int main()
{
    #ifdef Anani_leaf
      setI;
    #endif

    int A,B,C,D,E,F;
    scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
    int aa,bb,cc,dd;
    int ansa = 0,ansb = 0;
    rep(i,0,31)
    {
        if(i*A*100>F) continue;
        rep(j,0,31)
        {
            if(i==0&&j==0) continue;
            if(i*A*100 + j*B*100> F) continue;
            rep(k,0,3001)
            {
                if(i*A*100 + j*B*100 + k*C> F) continue;
                if(k*C>(i*A+j*B)*E) continue;
                rep(z,0,3001)
                {
                    if(i*A*100 + j*B*100 + k*C + z*D > F) continue;
                    if(k*C + z*D > (i*A + j*B)*E) continue;
                    int a = i*A*100 + j*B*100;
                    int b = k*C + z*D;
                    if(ansa==0)
                    {
                        ansa = a;ansb = b;
                    }
                    else if(b*(ansa+ansb) > ansb*(a+b))
                    {
                        ansa = a;ansb = b;
                    }


                }
            }
        }
    }
    ll p = ansa+ansb ;
    ll q = ansb;
    printf("%lld %lld\n",p,q);

    return 0;
}
    //freopen("in.txt","r",stdin);
//std::ios::sync_with_stdio(false);


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision; // int64_tは9*10^18まで、intは2*10^9まで

int main() {
  string s, t;
  cin >> s >> t;
  int lens = s.length(), lent = t.length(), i;
  bool flag;
  if (lent > lens) {
    cout << "UNRESTORABLE";
    return 0;
  }
  for (i = lens - lent; i >= 0; i--) {
    flag = false;
    for (int j = 0; j < lent; j++) {
      if (s[i + j] == '?' || s[i + j] == t[j])
        continue;
      else {
        flag = true;
        break;
      }
    }
    if (!flag)
      break;
  }
  if (flag) {
    cout << "UNRESTORABLE";
    return 0;
  }
  for (int j = 0; j < lens; j++) {
    if (i <= j && j < i + lent)
      cout << t[j - i];
    else if (s[j] == '?')
      cout << 'a';
    else
      cout << s[j];
  }
  return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
char a[101000];
long long k,m,n;
int main(){
	ios::sync_with_stdio(false);
    cin>>a;//input a
    n=strlen(a);//length of a
    for(int i=0;i<n;i++){//length
        if(a[i]=='e'){//if 'e'
            if(a[i+1]=='r'&&a[i+2]=='a'&&a[i+3]=='s'&&a[i+4]=='e'){//judge: erase or eraser
                if(a[i+5]=='r') i+=5;//it's eraser
				else i+=4;//it's erase
            }
        }else if(a[i]=='d'){//if 'd'
            if(a[i+1]=='r'&&a[i+2]=='e'&&a[i+3]=='a'&&a[i+4]=='m'){//dream or dreamer or dreamerase or dreameraser
                if(a[i+5]=='e'&&a[i+6]=='r'&&a[i+7]=='a'&&a[i+8]=='s'&&a[i+9]=='e') i+=4;//it's dreamerase
                else
                    if(a[i+5]=='e'&&a[i+6]=='r') i+=6;//only 'dreamer' left, so it's 'dreamer'
                    else i+=4;
            }
        }else{//no answer 
            cout<<"NO\n"<<endl;//output 'NO'
            return 0;
        }
    }
    cout<<"YES\n"<<endl;//ok 
    return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    if M % 2 == 0:
        for m in range(1, M+1):
            if m % 2 == 1:
                k = (m+1) // 2
                print(k, M+1-k)
            elif m % 2 == 0:
                k = m // 2
                print(M+k, 2*M+2-k)
    if M % 2 == 1:
        for m in range(1, M+1):
            if m % 2 == 1:
                k = (m+1) // 2
                print(k, M+2-k)
            elif m % 2 == 0:
                k = m // 2
                print(M+1+k, 2*M+2-k)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 9240
/////////////////////////////////////////Info/////////////////////////////////////////////////
//Problem:
//Date:
//Skill:
//Bug:
/////////////////////////////////////////Definations/////////////////////////////////////////////////
//循环控制
#define CLR(a) memset((a),0,sizeof(a))
#define F(i,a,b) for(int i=a;i<=int(b);++i)
#define F2(i,a,b) for(int i=a;i>=int(b);--i)
#define RE(i,n)  for(int i=0;i<int(n);i++)
#define RE2(i,n) for(int i=1;i<=int(n);i++)
//简化敲击
#define PII pair<int,int>
#define PLL pari<long long ,long long>
#define PB push_back
#define ENDL '\n'
#define x first
#define y second
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const long long llinf = 0x3f3f3f3f3f3f3f3f;
////////////////////////////////////////Options//////////////////////////////////////////////////////
#define stdcpph
#define CPP_IO

#ifdef stdcpph
#include<bits/stdc++.h>
#else
#include<ctype.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<map>
#include<algorithm>
#include<functional>
#ifdef CPP_IO
#include<iostream>
#include<iomanip>
#include<string>
#else
#include<stdio.h>
#endif
#endif
////////////////////////////////////////Basic Functions//////////////////////////////////////////////
template<typename INint> inline void IN(INint &x)
{
	x = 0; int f = 1; char c; cin.get(c);
	while (c<'0' || c>'9') { if (c == '-')f = -1; cin.get(c); }
	while (c >= '0'&&c <= '9') { x = x * 10 + c - '0'; cin.get(c); }
	x *= f;
}
template<typename INint> inline void OUT(INint x)
{
	if (x > 9)OUT(x / 10); cout.put(x % 10 + '0');
}
////////////////////////////////////////Added Functions//////////////////////////////////////////////
const int maxn = int(20);

////////////////////////////////////////////Code/////////////////////////////////////////////////////
int main()
{
	//freopen("C:\\Users\\VULCAN\\Desktop\\data.in", "r", stdin);
	int T(1), times(0);
#ifdef CPP_IO// CPP_IO
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//cin >> T;
#else
	//IN(T);
#endif 
	/////////////////////////////////////////////////////////////////////////////////////////////////
	while (++times, T--)
	{
		int a, b; cin >> a >> b;
		cout << a - b + 1 << endl;
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////
	return 0;
}

Measured memory_bytes: 256
using System;
class Program{
  static void Main(string[] args){
    string[] input = Console.ReadLine().Split(' ');
    int k = int.Parse(input[0]);
    int x = int.Parse(input[1]);
    if (500 * k >= x) {
      Console.WriteLine("Yes");
    } else {
      Console.WriteLine("No");
    }
  }
}


Measured memory_bytes: 11092
n,t = gets.chomp.split.map(&:to_i)

l = []
n.times do
  l << gets.chomp.split.map(&:to_i)
end


ans = 10**9

n.times do |i|
  next if l[i][1] > t

  ans = [ans, l[i][0]].min
end

if ans == 10**9
  puts 'TLE'
else
  puts ans
end

Measured memory_bytes: 3836
#include <stdio.h>

int main(void){
    int a,b;
    char op;
    scanf("%d %c %d",&a,&op,&b);
    while(op != '?'){
        switch(op){
            case '+': printf("%d\n",a+b);
            break;
            case '-': printf("%d\n",a-b);
            break;
            case '/': printf("%d\n",a/b);
            break;
            case '*': printf("%d\n",a*b);
        }
    scanf("%d %c %d",&a,&op,&b);
    }
    
    return 0;
}


Measured memory_bytes: 2032
//dhruv
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define fro(i,j,n) for(int i = (j);i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second
const int mod = 1e9 + 7;
const int inf = 1e18 + 5;
 
template<typename T>
T binpow(T a,T b,T modi){
	T res = 1;
	while(b){
		if(b&1){
			res = (res*a)%modi;
		}
		b /= 2;
		(a *= a) %= modi;
	}
	return res;
}
 
 
template<typename T>
T binpow(T a,T b){
	T res = 1;
	while(b){
		if(b&1){
			res = (res*a);
		}
		b /= 2;
		a *= a;
	}
	return res;
}
 
template<typename T>
T add(T a,T b){
	return (a + b)%mod;
}
template<typename T>
T sub(T a,T b){
	return add(a,mod - b);
}
template<typename T>
T mul(T a,T b){
	return (a*b)%mod;
}
template<typename T>
T inv(T a){
	return binpow(a,mod - 2,mod);
}

int make_int(string s){
	int x = 0;
	reverse(s.begin(),s.end());
	string tmp = s;
	for(int i = 0;i < s.length(); ++i){
		x *= 10;
		x += (int)(tmp.back() - '0');
		tmp.pop_back();
	}
	return x;
}
 
string make_string(int s){
	string x;
	while(s){
		x.push_back(char(s%10 + '0'));
		s /= 10;
	}
	reverse(x.begin(),x.end());
	return x;
}

random_device rd;
mt19937 g(rd());

int dx[] = {0,-1,0,1};
int dy[] = {1,0,-1,0};

const int N = 100;

vi fact;

void factorial(){
	fact.resize(N);
	fact[0] = 1,fact[1] = 1;
	fro(i,2,N){
		fact[i] = (fact[i - 1]*i)%mod;
	}
}

int nCr(int n,int r){
	return (mul(fact[n],inv(mul(fact[r],fact[n - r]))));
}

int nPr(int n,int r){
	return(mul(nCr(n,r),fact[r]));
}

// Linear Seive


int lp[N + 1];
vector<int> pr;
void ls(){
	for(int i = 2;i <= N; ++i){
		// means prime
		if(lp[i] == 0){
			lp[i] = i;
			pr.push_back(i);
		}
		for(int j = 0;j < pr.size() && pr[j] <= lp[i] && i*pr[j] <= N; j++){
			lp[i*pr[j]] = pr[j];
		}
	}
}


// getting the prime factorisation

vector<int> getfc(int n){
	vi factors;
	while(n != 1){
		int x = lp[n];
		factors.push_back(x);
		while(n%x == 0){
			n /= x;
		}
	}
	return factors;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	// shuffle(all(a),g);
	int n;
	cin >> n;
	map<string,int> cnt;
	while(n--){
		string s;
		cin >> s;
		cnt[s]++;
	}
	vector<string> opt = {"AC","WA","TLE","RE"};
	for(int i = 0;i < opt.size(); ++i){
		cout << opt[i] << ' ' << "x " << cnt[opt[i]] << '\n';
	} 
	return 0;
}

Measured memory_bytes: 3664
class UnionFind():
    def __init__(self, n):
        self.size = n
        self.data = [-1 for _ in range(n)]
        self.sizes = [1 for _ in range(n)]

    def __len__(self):
        return self.size

    def root(self, i):
        """0 <= i < n"""
        if self.data[i] < 0:
            return i
        self.data[i] = self.root(self.data[i])
        return self.data[i]

    def connected(self, i, j):
        return self.root(i) == self.root(j)

    def groupsize(self, i):
        return self.sizes[self.root(i)]

    def roots(self):
        """O(n)"""
        return [i for i, v in enumerate(self.data) if v < 0]

    def unite(self, i, j):
        i = self.root(i)
        j = self.root(j)
        if i == j:
            return
        if (-self.data[i]) < (-self.data[j]):
            self.data[i] = j
            self.sizes[j] += self.sizes[i]
        elif (-self.data[i]) > (-self.data[j]):
            self.data[j] = i
            self.sizes[i] += self.sizes[j]
        else:
            self.data[i] += -1
            self.data[j] = i
            self.sizes[i] += self.sizes[j]


N, M = map(int, input().split())
uf = UnionFind(N)
for _ in range(M):
    x, y, _ = map(int, input().split())
    uf.unite(x-1, y-1)

print(len(uf.roots()))


Measured memory_bytes: 8624
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  ll a,b,x;
  cin >> a >> b >> x;
  auto f = [&](ll n) {
    if(n == -1ll) return 0ll;
    return n/x+1;
  };
  cout << f(b) - f(a-1) << endl;
  return 0;
}

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

#define int long long

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

  int a[5], b[5];
  int c[5][5] = {{}};  
  for ( int i = 0; i < 3; i++ ) {
    cin >> a[i] >> b[i];
    c[a[i]][b[i]] = 1;
    c[b[i]][a[i]] = 1;    
  }

  for ( int i = 1; i <= 4; i++ ) {
    for ( int j = 1; j <= 4; j++ ) {
      for ( int k = 1; k <= 4; k++ ) {
	for ( int l = 1; l <= 4; l++ ) {
	  set<int> all = {i, j, k, l};
	  if ( all.size() < 4 ) continue;
	  if ( c[i][j] && c[j][k] && c[k][l] ) {
	    cout << "YES" << endl;
	    return 0;
	  }
	}
      }
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///
int n, m;
vi a;

bool solve(int i, int m)
{
	if (i == n)
	{
		if (m == 0) return true;
		else return false;
	}
	else return solve(i + 1, m) || solve(i + 1, m - a[i]);
}

int main()
{
	cin >> n;
	REP(i, n)
	{
		int t; cin >> t;
		a.push_back(t);
	}
	int q; cin >> q;
	REP(i, q)
	{
		cin >> m;
		if (solve(0, m)) puts("yes");
		else puts("no");
	}
	return 0;
}

Measured memory_bytes: 1164
from collections import deque


K = int(input())
path = [K] * K

q = deque()
path[1] = 0
q.append(1)
while q:
    p = q.popleft()
    p1 = (p + 1) % K
    if path[p1] > path[p] + 1:
        path[p1] = path[p] + 1
        q.append(p1)
    
    p10 = (p * 10) % K
    if path[p10] > path[p]:
        path[p10] = path[p]
        q.appendleft(p10)

print(path[0] + 1)


Measured memory_bytes: 6004
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const LL MOD = 1000000007;


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

    int N;
    cin >> N;
    vector<LL> A(N);
    rep(i, N) cin >> A[i];

    __int128 ans = 0;

    LL bit = 1;
    while(bit < (1LL<<60)) {
        LL count = 0;
        rep(i, N) {
            if ((A[i]&bit) != 0) ++count;
        }
        if (0 < count && count < N) {
            __int128 tmp = (count * (N-count)) % MOD; 
            tmp = (tmp * bit) % MOD;
            ans = (ans + tmp) % MOD;
        }
        bit = bit <<1;
    }

    cout << static_cast<LL>(ans) << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

/*
*/

int main(void){
	ll n,x;
	cin>>n>>x;
	if(x==1 || x==2*n-1){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	if(n==2){
		cout<<1<<endl;
		cout<<2<<endl;
		cout<<3<<endl;
	}else if(x==2*n-2){
		reg(i,1,n-3)cout<<i<<endl;
		cout<<2*n-4<<endl;
		cout<<2*n-1<<endl;
		cout<<2*n-2<<endl;
		cout<<2*n-3<<endl;
		reg(i,n-2,2*n-5)cout<<i<<endl;
	}else{
		vector<ll> v;
		reg(i,1,2*n-1){
			if(i<x-1 || i>x+2)v.push_back(i);
		}
		rep(i,n-3)cout<<v[i]<<endl;
		cout<<x+2<<endl;
		cout<<x-1<<endl;
		cout<<x<<endl;
		cout<<x+1<<endl;
		reg(i,n-3,2*n-6)cout<<v[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string S;
	string T;
	cin >> S >> T;
	sort(all(S));
	sort(all(T));
	reverse(all(T));
	if (S.compare(T) < 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int cnt[100005];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,x;
	int a,b,c;
	cin>>n;
	int sum=0;
	FOR(i,1,n){
		cin>>x;cnt[x]++;sum+=x;
	}
	cin>>m;
	FOR(i,1,m){
		cin>>b>>c;
		sum-=cnt[b]*(b-c);
		cnt[c]+=cnt[b];
		cnt[b]=0;
		cout<<sum<<'\n'; 
	}
	RE 0;
}




Measured memory_bytes: 4324
#include<iostream>
using namespace std;
int main(){
    int n,k,a,u,V[200][200];
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a>>k;
        for(int j=1;j<=k;j++){
            cin>>u;
            V[a][u]++;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(j==1) cout<<V[i][1];
            else cout<<" "<<V[i][j];
        }
        cout<<endl;
    }
}


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

int main() {
	string s;
	cin >> s;
	int cnt_red = 0, cnt_blue = 0;
	rep(i, s.size()) {
		if(s[i] == '0') cnt_red++;
		else cnt_blue++;
	}
	cout << min(cnt_red, cnt_blue) * 2 << endl;
	return 0;
}

Measured memory_bytes: 512
n,k=(map(int,input().split()))

ans_list=[0]*(10**5+1)
#print(len(ans_list))

for _ in range(n):
  a,b=(map(int,input().split()))
  ans_list[a]+=b

#print(ans_list)
s=0
ans=0

for n,i in enumerate(ans_list):
  s+=i
  ans=n
  if s>=k:
    print(ans)
    break

Measured memory_bytes: 5748
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   ll arr[n], arr1[n-1];
   for(ll i=0;i<n-1;i++)
        cin>>arr1[i];
   arr[0] = arr1[0];
   arr[1] = arr1[0];
   for(ll i=1;i<n-1;i++)
   {
       if(arr1[i]<arr[i])
            arr[i] = arr1[i];
       arr[i+1] = arr1[i];         
   }
    
    ll sum = 0;     
       
   for(ll i=0;i<n;i++)
        sum+=arr[i];
   cout<<sum;        
   
   return 0;
}

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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  if (N == 1) return cout << 0 << "\n", 0; 
  if (N == 2) return cout << 2 << "\n", 0;

  long a = 1, b = 1, c = 1;
  for (int i = 0; i < N; i++) {
    a *= 10;
    a %= MOD;
    b *= 9;
    b %= MOD;
    c *= 8;
    c %= MOD;
  }
  b *= 2;
  b %= MOD;
  b -= c;
  b %= MOD;
  while (b < 0) b += MOD;
  a -= b;
  a %= MOD;
  while (a < 0) a += MOD;
  cout << a << "\n";
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
#include <iostream>
#include<algorithm>
using namespace std;

typedef long long LL;

const int INF = 0x3f3f3f3f;
const int maxn = 100 + 10;
LL F[maxn][maxn];
LL P[maxn][maxn];
LL D[maxn];

int main()
{
    LL n;
    while(scanf("%lld",&n) == 1)
    {
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= 10; j++)
                scanf("%lld",&F[i][j]);

        for(int i = 1; i <= n; i++)
            for(int j = 0; j <= 10; j++)
                scanf("%lld",&P[i][j]);

        LL Max = -1 * INF;
        for(int s = 1; s < (1 << 10); s++)
        {
            for(int i = 1; i <= n; i++)
            {
                D[i] = 0;
                for(int j = 1; j <= 10; j++)
                {
                    if((F[i][j] << (j - 1)) & s) D[i]++;
                }
            }

            LL ans = 0;
            for(int i = 1; i <= n; i++)
                ans += P[i][D[i]];

            Max = max(Max,ans);
        }
        cout<< Max <<endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

ll R, S, P;
ll get(char hand)
{
        if (hand == 'r') return P;
        else if (hand == 's') return R;
        else return S;
}

int main()
{
        ll N, K;
        string T;
        cin >> N >> K >> R >> S >> P >> T;

        ll ans = 0;
        rep(i, 0, K) {
                ans += get(T[i]);
        }

        rep(i, K, N) {
                if (T[i] != T[i-K]) ans += get(T[i]);
                else T[i] = 'x';
        }

        cout << ans << endl;
}


Measured memory_bytes: 3740
using System;
using System.Collections.Generic;
using System.Linq;

namespace procon
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var list = new List<int[]>();
            while (true)
            {
                var tmp = Console.ReadLine().Split().Select(int.Parse).ToList();
                if (tmp[0] == 0 && tmp[1] == 0) break;

                list.Add(tmp.OrderBy(s => s).ToArray());
            }

            foreach (var item in list)
            {
                var str = string.Join(" ", item.Select(ss => ss.ToString()).ToArray<string>());
                Console.WriteLine(str);
            }
        }
    }
}

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

int N[100000+3];

int BinarySearch( int N[], int n, int key ) {
    int left = 0;
    int right = n;
    while ( left < right ) {
        int mid = ( left + right ) / 2;
        if ( N[mid] == key ) {
            return 1;
        } else if ( N[mid] < key ) {
            left = mid + 1;
        } else if ( N[mid] > key ) {
            right = mid;
        }
    }
    return 0;
}

int main() {
    int n;
    cin >> n;
    for ( int i = 0; i < n; ++i ) cin >> N[i];
    
    int q, t;
    cin >> q;
    int sum = 0;
    for ( int i = 0; i < q; ++i ) {
        cin >> t;
        if ( BinarySearch( N, n, t ) ) {
            sum++;
        }
    }
    
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

#define rep(i,n,m) for(int i=n;i<(int)(m);i++)

using namespace std;

int main() {

	string s;

	cin >> s;
	rep(i, 0, 4) {
		cout << s[i];
	}

	cout << " ";
	rep(i, 4, s.length())cout << s[i];
	cout << endl;





	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC120A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c,d;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            d = b / a;
            if(d<c)
            {
                Console.WriteLine(d);
            }
            else if(d>=c)
            {
                Console.WriteLine(c);
            }
            else 
            {
                Console.WriteLine(" ");
            }
            Console.ReadKey();

        }
    }
}

Measured memory_bytes: 13140