akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
    char s[36][3], bobble_s[36][3], selection_s[36][3];
    int i, j, k, l, n, c, flag, minj, stability = 1;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%s", s[i]);
        for (j = 0; j < 3; j++){
            selection_s[i][j] = bobble_s[i][j] = s[i][j];
        }
    }

    i = 0;
    flag = 1;
    while(flag != 0){
        flag = 0;
        for (j = n -1; j > i; j--){
            if(bobble_s[j][1] < bobble_s[j-1][1]){
                for (l = 0; l < 2; l++){
                    c = bobble_s[j][l];
                    bobble_s[j][l] = bobble_s[j-1][l];
                    bobble_s[j-1][l]  = c;
                    flag = 1;
                }
            }
        }
        i++;
    }
    
    printf("%s", bobble_s[0]);
    for(k = 1; k < n; k++){
        printf(" %s", bobble_s[k]);
    }
    printf("\n");

    for (i = 0; i < n; i++){
        for (j = i + 1; j < n; j++){
            for (k = 0; k < n; k++){
                for(l = k + 1; l < n; l++){
                    if(s[i][1] == s[j][1] && s[i][0] == bobble_s[l][0] && s[j][0] == bobble_s[k][0] && s[i][1] == bobble_s[l][1] && s[j][1] == bobble_s[k][1]){
                        stability = 0;
                    }
                }
            }
        }
    }

    if(stability == 1){
        printf("Stable\n");
    } else if (stability == 0){
        printf("Not stable\n");
    }

    stability = 1;
    for (i = 0; i < n; i++){
        minj = i;
        for (j = i; j < n; j++){
            if(selection_s[j][1] < selection_s[minj][1]){
                minj = j;
            }
        }
        if(minj != i){
            for (k = 0; k < 2; k++){
                c = selection_s[i][k];
                selection_s[i][k] = selection_s[minj][k];
                selection_s[minj][k] = c;
            }
        }
    }

    printf("%s", selection_s[0]);
    for (i = 1; i < n; i++){
        printf(" %s", selection_s[i]);
    }
    printf("\n");

    for (i = 0; i < n; i++){
        for (j = i + 1; j < n; j++){
            for (k = 0; k < n; k++){
                for(l = k + 1; l < n; l++){
                    if(s[i][1] == s[j][1] && s[i][0] == selection_s[l][0] && s[j][0] == selection_s[k][0] && s[i][1] == bobble_s[l][1] && s[j][1] == bobble_s[k][1]){
                        stability = 0;
                    }
                }
            }
        }
    }

    if(stability == 1){
        printf("Stable\n");
    } else if (stability == 0){
        printf("Not stable\n");
    }
    
    return 0;
}


Measured memory_bytes: 1960
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <functional>
using namespace std;

int main()
{
	int n,l,min,sum=0,diff=10000;

	cin >> n >> l;

	std::vector<int> sums;

	sums.push_back(0);

	for(int i=0; i<n; i++){
		sum += l+i;
		sums.push_back(sum);
	}

	int ans;
	for(int i=0; i<n; i++){
		ans = sums[i] + (sums.back() - sums[i+1]);
		if(abs(sums.back() - ans) < diff){
			diff = abs(sums.back() - ans);
			min = ans;
		}
	}

	cout << min << endl;

	return 0;
}


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




int main(){
    string s;cin>>s;
    if(s=="AAA"||s=="BBB")cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}







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

int main() {
int N; cin >> N;
  
  vector<char> s(N);
  bool n = false;
    
    for (int i = 0; i < N; ++i) cin >> s.at(i);
  
  for (int i = 0; i < N; ++i){
    if (s.at(i) == 'Y') n = true;
  }
  if ( n == true ) cout << "Four" << endl;
  if ( n == false ) cout << "Three" << endl;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
        a[i] = abs(a[i]-x);
    }

    int g = a[0];
    for (int i = 1; i < n; i++) g = gcd(g, a[i]);
    cout << g << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3648
C = []
for i in range(3):
    c = list(map(int,input().split()))
    C.append(c)
# a_1_1 を固定
for a_1_1 in range(0,C[0][0] + 1):
    b = [c_1_j - a_1_1 for c_1_j in C[0]]
    a = [C[i][0] - b[0] for i in range(3)]
    # a_i, b_i が確定 あとは矛盾がないかチェック
    C_empty = []
    for i in range(3):
        c = [a[i] + b[j] for j in range(3)]
        C_empty.append(c)
    if C == C_empty:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
 
bool isPrime(int n)
{
    for(int i = 2; i*i <= n; i++){
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    while(!isPrime(n)){
        n++;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, m;
    cin >> n >> m;
    if(m % n == 0) cout << n+m;
    else cout << m-n;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int i,j,r,c,s;
    scanf("%d %d",&r,&c);
    int cell[r][c];
    int sum[c];
    for(i=0;i<c;i++)sum[i]=0;

    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            scanf("%d",&cell[i][j]);
            sum[j]+=cell[i][j];
        }
    }
    

    for(i=0;i<r;i++){
        s=0;
        for(j=0;j<c;j++){
            printf("%d ",cell[i][j]);
            s+=cell[i][j];
        }
        printf("%d\n",s);
    }
    s=0;
    for(i=0;i<c;i++){
        printf("%d ",sum[i]);
        s+=sum[i];
    }
    printf("%d\n",s);
    return 0;
}




Measured memory_bytes: 2104
def main(input = STDIN)
  while ab = input.gets
    dem = Array.new(101, 0)
    a, b = ab.split(" ").map(&:to_i)
    dem[a], dem[b] = dem[a] + 1, dem[b] + 1
    while (a, b = input.gets.split(" ").map(&:to_i)) != [0, 0]
      dem[a], dem[b] = dem[a] + 1, dem[b] + 1
    end
    if (dem[1] * dem[2]) % 2 == 1 and !dem[3..-1].any?{|i|i % 2 == 1}
      puts "OK"
    else
      puts "NG"
    end
  end
end
main

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

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

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  ll ans = n % k;
  chmin(ans, -((n % k) - k));
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846;
typedef long long  ll;
int main()
{
int n;
cin>>n;
ll a[n];
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
int c=0;
int ans=0;
for(int i=1;i<n;i++)
{c++;
    if(a[i]>a[i-1])
{
    c=0;
}
ans=max(c,ans);
}


cout<<ans;
return 0;
}


Measured memory_bytes: 1024
import itertools

n, m, x = list(map(int, input().split()))

c = []
a = []
for i in range(n):
    data = list(map(int, input().split()))
    c.append(data[0])
    a.append(data[1:])

minmoney = -1
for use in itertools.product([0, 1], repeat=n):
    for j in range(m):
        if sum([a[i][j]*use[i] for i in range(n)]) < x:
            break
    else:
        money = sum([c[i]*use[i] for i in range(n)])
        if minmoney == -1:
            minmoney = money
        else:
            minmoney = min(minmoney, money)

print(minmoney)

Measured memory_bytes: 9236
#include <stdio.h>

int main()
{
    int N,i;
    scanf("%d",&N);
    char s[N];
    scanf("%s",s);
    int c_w=0,c_e=0;
    for(i=0;i<N;i++){
        if(s[i]=='E'){
            c_e++;
        }else{
            c_w++;
        }
    }

    int change_min=4000000;
    int change_w = 0;
    int change_e = c_e;
    for(i=0;i<N;i++){
        if(s[i]=='E'){
            change_e--;
        }
        if(change_e+change_w <= change_min){
            change_min = change_e+change_w;
        }
        if(s[i]=='W'){
            change_w++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, M, a, b;
    cin >> N >> M;
    vector<int> vec(N);
    for(int i = 0; i < M; i++){
        cin >> a >> b;
        vec[a - 1]++;
        vec[b - 1]++;
    }
    for(int i = 0; i < N; i++){
        cout << vec[i] << endl;
    }
}

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

int main() {
	string s;
	cin >> s;
	
	if(s[s.size() - 1] == 's') {
		cout << s + "es";
	} else {
		s.push_back('s');
		cout << s << endl;
	}
	
	
	return 0;
}

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

using namespace std;

#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair

#define debug(args...) { string _s = #args; replace(ALL(_s), ',', ' '); stringstream ss(_s); cerr << endl;_debug(ss, args); }
#define _rg auto it = next(v.begin()); it != v.end(); it++
#define _input ostream& operator <<(ostream& out

template<typename T, typename U>
_input, const pair<T, U>& p) {
	out << "(" << p.first << ", " << p.second << ")";
	return out;
}

#define cont(c) template<typename T> _input, const c<T>& v) { \
					if (v.empty()) return out; \
					out << "[" << *v.begin(); \
					for (_rg) out << ", " << *it; \
					out << "]"; return out; \
				}
				
#define cont2(c) template<typename T, typename U> _input, const c<T, U>& v) { \
					if (v.empty()) return out; \
					out << "[" << *v.begin(); \
					for (_rg) out << ", " << *it; \
					out << "]"; return out; \
				}

cont(vector) cont(set) cont(multiset) cont(queue) cont2(map)

template<typename T, size_t n, typename= enable_if_t<!is_same<T, char>::value>>
_input, const T(&v)[n]) {
	if (n == 0) return out;
	out << "[" << v[0];
	for (int i = 1; i < (int)n; i++) out << ", " << v[i];
	out  << "]"; return out;
}

template<typename T, typename... Ts>
void _debug(stringstream& ss, const T &arg) {
	string name; ss >> name;
	cerr << name << " = " << arg << endl;
}

template<typename T, typename... Ts>
void _debug(stringstream& ss, const T& arg, const Ts&... args) {
	string name; ss >> name; 
	cerr << name << " = " << arg << ", ";
	if (is_class<T>::value || is_array<T>::value) cerr << endl;
	_debug(ss, args...);
}

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;
const double PI = 3.141592653589793238;

struct S {
	int w, s, v;
	bool operator <(const S& b) {
		return w + s < b.w + b.s;
	}
};

int32_t main() {
	FAST_IO;
	
	int n;
	cin >> n;
	vector<S> list(n);
	int MAX_S = 20123;
	for (int i = 0; i < n; i++) {
		cin >> list[i].w >> list[i].s >> list[i].v;
	}
	
	sort(ALL(list));
	vi dp(MAX_S + 1);
	
	for (S block: list) {
		for (int w = min(block.s, MAX_S-block.w); w >= 0; --w) {
			dp[w + block.w] = max(dp[w + block.w], dp[w] + block.v);
		}
	}
	int ans = 0;
	for (int i = 0; i <= MAX_S; i++) {
		ans = max(ans, dp[i]);
	}
	
	cout << ans << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

struct UnionFind{
	vector<int> par;
	vector<int> rank;
	
	UnionFind(int n){
        init(n);
    }
	
	//n要素で初期化
	void init(int n){
		par.resize(n);
		rank.resize(n);
		for(int i = 0; i < n; i++){
			par[i] = i;
			rank[i] = 0;
		}
	}
	
	//木の根を求める
	int root(int x){
		if(par[x] == x) return x;
		else return par[x] = root(par[x]);
	}
	
	//xとyの属する集合を併合
	void unite(int x, int y){
		x = root(x);
		y = root(y);
		if(x == y) return;
		if(rank[x] < rank[y]) par[x] = y;
		else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}
	
	bool same(int x, int y){
		return root(x) == root(y);
	}
};

int main(){
	int n,m;
	cin >> n >> m;
	int a[m],b[m];
	REP(i,m){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}
	int ans = 0;
	REP(i,m){
		UnionFind uf(n);
		REP(j,m){
			if(j != i) uf.unite(a[j], b[j]);
		}
		REP(j,n - 1){
			if(uf.root(j) != uf.root(j + 1)){
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int d;
  	long long int g;
  	cin >>d>>g;
  	vector<long int>p(d);
  	vector<long long int>c(d);
   	for(int i=0;i<d;i++){
    cin >>p[i]>>c[i];
    }
  
  long long int score=0;
  int ans=10000;
  int count;
  
  for(int tmp=0;tmp<(1<<d);tmp++){
  	bitset<10>bs(tmp);
    score=0;count=0;
    int restmax=-1;
    
  	 for(int i=0;i<d;i++){
    	if(bs.test(i)){
         score=score+(i+1)*100*p[i]+c[i];
         count+=p[i];
        }
      else{restmax=i+1;} 
     }
  	if(score>=g){ans=min(ans,count);}
  	else{long int s1=100*restmax;
      	long int need=(g-score+s1-1)/s1;
      	if(need >= p[restmax-1]){
                continue;	
      	}
      else{count+=need;ans=min(ans,count);}
    }   
  } 
  cout <<ans; 
}
 

Measured memory_bytes: 256
fun main(arr: Array<String>) {
    println(solve().toString().toUpperCase())
}

fun solve():Char {
    val dic = mutableMapOf('a' to readLine()!!)
    dic['b'] = readLine()!!
    dic['c'] = readLine()!!
    var current = 'a'
    for(i in (1..400)) {
        if(dic[current]!!.isEmpty()) {
            return current
        }
        val next = dic[current]!!.first()
        dic[current] = dic[current]!!.drop(1)
        current = next
    }
    return current
}

Measured memory_bytes: 36328
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 200005
#define F first
#define S second
using namespace std;

int n, s;
pair<int, int> a[N];
int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n; i++) scanf("%d %d", &a[i].S, &a[i].F);
	sort(a, a + n);
	for (i = 0; i < n; i++) {
		s += a[i].S;
		if (s > a[i].F) {puts("No"); return 0;}
	}
    puts("Yes");
    return 0;
}

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

signed main()
{
	int A, B;
	cin >> A >> B;

	// 1口のときは必要ないので B-1 そこから(A-1)個ずつ増えるので(A-1)で割った数
	// を出力にしているが，切り上げしたいので(A-1)-1を引いてあげている
	cout << (B - 1 + A - 2) / (A - 1) << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] costs = new int[10][10];
		for (int i = 0; i < 10; i++) {
		    for (int j = 0; j < 10; j++) {
		        costs[i][j] = sc.nextInt();
		    }
		}
		for (int i = 0; i < 10; i++) {
		    for (int j = 0; j < 10; j++) {
		        for (int k = 0; k < 10; k++) {
		            costs[j][k] = Math.min(costs[j][k], costs[j][i] + costs[i][k]);
		        }
		    }
		}
		long total = 0;
		for (int i = 0; i < h * w; i++) {
		    int x = sc.nextInt();
		    if (x == -1) {
		        continue;
		    }
		    total += costs[x][1];
		}
		System.out.println(total);
    }
}



Measured memory_bytes: 45192
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

ans = 0

class UFT:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1] * N
    def add_size(self, dst, size):
        dst_tmp = self.parent[dst]
        self.size[dst] += size
        if dst_tmp != dst:
            self.add_size(dst_tmp, size)
        #
        return
    def connect(self, src, dst):
        dst_prev = self.parent[src]
        size_src = self.size[src]
        if dst_prev != src:
            self.add_size(dst_prev, -size_src)
        if dst != src:
            self.add_size(dst, size_src)
        self.parent[src] = dst
        return
    def root(self, src):
        dst = self.parent[src]
        if src == dst:
            ret = src
        else:
            src_root = self.root(dst)
            ret = src_root
        #
        return ret
    def unite(self, src, dst):
        src_root = self.root(src)
        dst_root = self.root(dst)
        if src != src_root:
            self.unite(self.parent[src], dst_root)
        self.connect(src, dst_root)
        #
        return

ans = []
ans_tmp = N * (N - 1) // 2
tree = UFT(N)
for i_inv, (Ai, Bi) in enumerate(AB[::-1]):
    i = N - 1 - i_inv
    # print("#", tree.parent, tree.size)
    ans.append(ans_tmp)
    A_root = tree.root(Ai - 1)
    B_root = tree.root(Bi - 1)
    if A_root != B_root:
        ans_tmp -= (tree.size[A_root] * tree.size[B_root])
    if A_root < B_root:
        tree.unite(Ai - 1, Bi - 1)
    else:
        tree.unite(Bi - 1, Ai - 1)
        
# print("#", tree.parent, tree.size)
for ansi in ans[::-1]:
    print(ansi)

Measured memory_bytes: 128856
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(In));
        }

        public long Min(params long[] a)
        {
            var min = a[0];
            for (int i = 1; i < a.Length; i++)
            {
                if (min > a[i]) min = a[i];
            }
            return min;
        }

        public void Solve(ConsoleInput input)
        {
            var t = input.ReadInt;
            var x = input.ReadInt;

            WriteLine($"{(double)t / x}");


            //Solve(input);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private readonly char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            _separator = separator;
            _stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m;
ll ans;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> m;
    vector<ll> a(n);
    map<ll, ll> mem;
    rep(i, 0, n) cin >> a[i];
    ll sum = 0;
    mem[0] = 1;
    rep(i, 0, n) {
        sum = sum + a[i];
        mem[sum%m]++;
    }
    for (auto itr = mem.begin(); itr != mem.end(); ++itr) {
        ll p = itr->second;
        ans += p * (p - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


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

void fnInput(int& rnMaxNum, int& rnWinPnt)
{
  cin >> rnMaxNum >> rnWinPnt;
}

double fnWinRate(int nMaxNum, int nWinPnt)
{
  double nWinRate = 0;

  for (int n = 1; n <= nMaxNum; n++)
  {
    double nOneRate = 1.0 / nMaxNum;
    int nCur = n;

    while (nCur < nWinPnt)
    {
      nOneRate /= 2;
      nCur *= 2;
    }
    nWinRate += nOneRate;
  }
  return nWinRate;
}
  
int main()
{
  int nMaxNum, nWinPnt;
  fnInput(nMaxNum, nWinPnt);
  cout << fixed << setprecision(10) << fnWinRate(nMaxNum, nWinPnt) << endl;

  return 0;
}

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

#define ll long long
#define db double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	char a, b, c;
	cin >> a >> b >> c;
	if (a == '7' || b == '7' || c == '7') {
		cout << "Yes";
	}	else {
		cout << "No";
	}
}


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

using namespace std;

#define ff first
#define ss second
#define mp make_pair
#define sz size()
#define pb push_back
using ll = long long;
using pii = pair<int, int>;

int main() {

  ll ans = 0LL, n;

  cin >> n;

  ans += (n / 500) * 1000LL;
  n %= 500;
  ans += (n / 5) * 5LL;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef long long LL;
typedef vector<int> vi;

stack<ii> S;
stack<LL> res;
LL incon;

class UFDS {
   public:
      vi p, rank, sz;
      UFDS(const int N) {
         p.assign(N, 0);
         rank.assign(N, 0);
         sz.assign(N, 1);
         for (int i = 0; i < N; i++)
            p[i] = i;
      }//constructor
      int findSet(const int i) {
         return p[i] == i ? i : p[i] = findSet(p[i]);
      }//findSet
      int getSize(const int i) {
         return sz[findSet(i)];
      }//getSize
      bool isSameSet(const int i, const int j) {
         return findSet(i) == findSet(j);
      }//isSameSet
      void unite(const int i, const int j) {
         int r1 = findSet(i), r2 = findSet(j);
         if (r1 == r2)
            return;
         rank[r1] >= rank[r2] ? p[r2] = r1, sz[r1] += sz[r2] : p[r1] = r2, sz[r2] += sz[r1];
         if (rank[r1] == rank[r2])
            rank[r1]++;
      }//unite
};

int main() {
   int N, M, n1, n2;
   scanf("%d %d", &N, &M);
   UFDS U(N + 5);
   incon = 0.5 * N * LL(N - 1);
   for (int i = 0; i < M; i++) {
      scanf("%d %d", &n1, &n2);
      S.push(ii(n1, n2));
   }//for
   res.push(incon);
   while (!S.empty()) {
      ii curr = S.top();
      S.pop();
      int l1 = U.findSet(curr.first);
      int l2 = U.findSet(curr.second);
      if (!U.isSameSet(l1, l2)) {
         incon -= U.getSize(l1) * U.getSize(l2);
         U.unite(l1, l2);
      }//if
      res.push(incon);
   }//while
   res.pop();
   while (!res.empty())
      printf("%lld\n", res.top()), res.pop();
   return 0;
}//main


Measured memory_bytes: 3328
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;

int n;
int d[105];
bool vis[105];

int cmp(int a, int b){
	return a > b;
}

int main(){
	scanf("%d\n", &n);
	for(int i = 1; i <= n; i++) scanf(" %d", &d[i]);
	sort(d + 1, d + 1 + n, cmp);
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(vis[d[i]] == 0){
			ans++;
			vis[d[i]] = 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= (n - i); ++j) {
            for (int k = 0; k <= (n - i - j); ++k) {
                if (y == (10000*i + 5000*j + 1000*k) && n == (i + j + k)) {
                    cout << i << " " << j << " " << k << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		String buf = "";

		for(int i = 3; i <= n; i++) {

			if(i % 3 == 0 | i % 10 == 3) {
				buf += " " + String.valueOf(i);
				continue;
			}

			int j = i / 10;
			while(j >= 3) {

				if(j % 10 == 3) {
					buf += " " + String.valueOf(i);
					break;
				} else {
					j = j / 10;
				}

			}

		}

		System.out.println(buf);

	}

}





Measured memory_bytes: 185276
#include <stdio.h>
#include <stdlib.h>
 
typedef struct{
    int key;
    int left;
    int right;
} Node;
 
void insert(Node*, int, int);
void print1(Node*, int);
void print2(Node*, int);
 
int main()
{
    char s[10];
    Node *t;
    int m;
    int a;
    int i;
 
    scanf("%d", &m);
    t=(Node*)malloc(sizeof(Node)*m);
 
    int count=0;
    for(i=0; i<m; i++){
        scanf("%s", &s);
        if(s[0]=='i'){ scanf("%d", &a); insert(t, count, a); count++; }
        if(s[0]=='p'){
            if(count>0) print1(t, 0);
            printf("\n");
            if(count>0) print2(t, 0);
            printf("\n");
        }
    }
     
    return 0;
 
}
 
void print1(Node *t, int p)
{
    if(t[p].left>=0) print1(t, t[p].left);
    printf(" %d", t[p].key);
    if(t[p].right>=0) print1(t, t[p].right);
}
 
void print2(Node *t, int p)
{
    printf(" %d", t[p].key);
    if(t[p].left>=0) print2(t, t[p].left);
    if(t[p].right>=0) print2(t, t[p].right);
}
 
void insert(Node *t, int count, int z)
{
    int x=0, y;
    if(count<1) x=-1;
 
    t[count].key = z;
    t[count].left = -1;
    t[count].right= -1;
 
    while(x>=0){
        y = x; 
        if(z < t[x].key)
            x = t[x].left; 
        else
            x = t[x].right; 
    }
 
    if(count<1){}
    else if(z < t[y].key){
        t[y].left = count; 
    }
    else {
        t[y].right = count; 
    }
}

Measured memory_bytes: 6464
#include <stdio.h>

int main(void){
    
int n,i,a[100],x,y,temp,alice,bob,card,flg,result;

n = i = temp = alice = bob = card = flg = result = 0;

scanf("%d",&n);

for(i = 0 ; i < n ; i++){

    scanf("%d",&a[i]);

}

for(x = 0; x < (n - 1); x++){
	for (y = (n - 1 ); y > x; y--){
		if(a[y-1] > a[y]){
			temp = a[y-1];
			a[y-1] = a[y];
			a[y] = temp;
		}
	}
}

for (card = (n - 1) ; card >= 0 ; card--){
	if(flg == 0){
		alice += a[card];
		flg = 1;
	}else{
		bob += a[card];
		flg = 0;
	}
}

result = alice - bob;
printf("%d",result);

return 0;
}

Measured memory_bytes: 128
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.range;
import std.numeric;

void main() {
    auto point = readln.chomp.split.map!(to!double).array;
    auto p1 = point[0..2];
    auto p2 = point[2..4];

    int q = readln.chomp.to!int;
    for (int i = 0; i < q; i++) {
        auto p = readln.chomp.split.map!(to!double).array;
        double[2] p1p = p[] - p1[];
        double[2] p1p2 = p2[] - p1[];
        double[2] ph = p1p2[] * dotProduct(p1p, p1p2) / dotProduct(p1p2, p1p2)
                       + p1[];
        writefln("%.10f %.10f", ph[0], ph[1]);
    }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int l,d,r,x,y;
	cin>>l>>r>>d;
	if(l%d)
    {
        x=l/d;
    }
    else
    {
        x=l/d-1;
    }
    y=r/d;
    cout<<y-x<<endl;
	return 0;
}


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

int main() 
{
  string S;
  cin >> S;

  for (int i = 0; i < S.size(); i++) 
    {
    if (S.at(i) == 'a') 
    {
        cout << "vowel" << endl;
    }
    else if(S.at(i) == 'i')
    {
        cout << "vowel" << endl;
    }
    else if(S.at(i) == 'u')
    {
        cout << "vowel" << endl;
    }
    else if(S.at(i) == 'e')
    {
        cout << "vowel" << endl;
    }
    else if(S.at(i) == 'o')
    {
        cout << "vowel" << endl;
    }
    else
    {
       cout << "consonant" << endl;
    }
  }  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"yes"<<endl;}else cout<<"no"<<endl;//条件によってYes、Noを出力する
int main(){
    string s;
    cin>>s;
    int n = s.length();
    set<char> se;
    rep(i,n){
        se.insert(s[i]);
    }
    YN(se.size()==n);
}

Measured memory_bytes: 3644
from collections import defaultdict
import itertools

n = int(input())

l = [[] for i in range(n)]
p = [i for i in range(n)]

for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        l[i].append((x,y))

for i in range(n,-1,-1):
    for comb in itertools.combinations(p,i):
        tmp = [1 if j in comb else 0 for j in range(n)]
        F = True
        for c in comb:
            for k in l[c]:
                if tmp[k[0]-1] != k[1]:
                    F = False
        if F:
            print(i)
            exit()

print(0)

Measured memory_bytes: 9424
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        String p = sc.next();

        int j = 0;

        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == p.charAt(0)){
                int a = i;
                j = 0;
                while(true){
                    if(j == p.length())
                        break;
                    if(a + j == s.length())
                        a = -j;
                    if(s.charAt(a + j) != p.charAt(j))
                        break;
                    j++;
                }
                if(j == p.length())
                    break;
                else
                    j = 0;
            }
        }
        if(j == p.length())
            System.out.println("Yes");
        else
            System.out.println("No");

        sc.close();
    }
}


Measured memory_bytes: 26332
#include<stdio.h>


int main()
{
  int n,j,i,key,k;

  scanf("%d",&n);
  int a[n];
  
  for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
      printf("%d",a[i]);
      if(i!=n-1)
	{
         printf(" ");
        }
    }
printf("\n");

  for(i=1;i<=n-1;i++)
    {
      key=a[i];
       j=i-1;
       while(j>=0 && a[j]>key)
	 {
	   a[j+1]=a[j];
	   j-=1;
	  
	 }
        a[j+1]=key;
       for(k=0;k<n;k++)
	 {
          printf("%d",a[k]);
          if(k!=n-1)
            { 
             printf(" ");
            }
	 }
       printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2104
# -*- coding: utf-8 -*-

def main(N, A):
    st = 0
    check = [0]*8
    for i in range(N):
        if(1<=A[i]<=399):
            check[0] = 1
        elif(400<=A[i]<=799):
            check[1] = 1
        elif(800<=A[i]<=1199):
            check[2] = 1
        elif(1200<=A[i]<=1599):
            check[3] = 1
        elif(1600<=A[i]<=1999):
            check[4] = 1
        elif(2000<=A[i]<=2399):
            check[5] = 1
        elif(2400<=A[i]<=2799):
            check[6] = 1
        elif(2800<=A[i]<=3199):
            check[7] = 1
        else:
            st += 1
            
    cnt = check.count(1)
    print(max(1, cnt), cnt+st)
    
if __name__ == '__main__':
    N = int(input())
    A = [int(a) for a in input().split()]
    
    main(N, A)


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

int main(void){
    ll a, b;
    cin >> a >> b;
    cout << (a-1) * (b-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

#define inc(...)      \
  char __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

#define rep(i, n) for (long long i = 0; i < n; i++)

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    ini(A);
    inc(op);
    ini(B);
    
    if (op == '+')
        out(A + B);
    else
        out(A - B);
}


Measured memory_bytes: 3612
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n;
int h[MAXN];

ll dp[MAXN];

ll solve() {
	dp[0]=0;
	FORE(i,1,n-1) {
		dp[i]=LLONG_MAX;
		FORE(j,1,2) if(j<=i) dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
	}
	return dp[n-1];
}

void run() {
	scanf("%d",&n);
	REP(i,n) scanf("%d",&h[i]);
	printf("%lld\n",solve());
}

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


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

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

int main()
{
    long long n;
    long long a, b;

    long long amari_blue;

    cin >> n >> a >> b;

    long long num = n / (a + b);
    //cout << num << endl;

    long long amari = n % (a + b);
    //cout << amari << endl;

    if (amari < a)
    {
        amari_blue = amari;
    }
    else
    {
        amari_blue = a;
    }

    cout << num * a + amari_blue << endl;

    return 0;
}


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

typedef long long ll;

int main(){
    int N;
    cin>>N;
    
    vector<ll> A(N);
    for(int i=0;i<N;++i)cin>>A[i];
    
    vector<ll> cnt(N,0);
    for(int i=0;i<N;++i)++cnt[A[i]-1];
    
    ll t=0;
    for(int i=0;i<N;++i){
        if(!cnt[i])continue;
        t+=cnt[i]*(cnt[i]-1)/2;
    }
    
    for(int i=0;i<N;++i)cout<<t-cnt[A[i]-1]+1<<endl;
}


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

int main() {
	string s;
	cin>>s;
	int a = -1;
	for (int i = 0;i<s.length();i++){
		if (s[i] == 'C'){
			a = i;
			break;
		}
	}
	if (a>=0){
		for (int i = a+1;i<s.length();i++){
			if (s[i]=='F'){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    
    int h1;
    int m1;
    int h2;
    int m2;
    int k;
    std::cin >> h1 >> m1 >> h2 >> m2 >> k;
    int mdiff = m2 - m1;
    int hsub = 0;
    if (mdiff < 0) {
        mdiff = 60 + mdiff;
        hsub = 1;
    }
    int hdiff = h2 - h1 - hsub;
    int totalTime = hdiff * 60 + mdiff;
    std::cout << totalTime - k << std::endl;
    return 0;
}



Measured memory_bytes: 3636
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ sx, sy, tx, ty ] <- readInts
	let
		dx = tx - sx
		dy = ty - sy
		a = solve dx dy
		b = map inverse a
		c = "D" ++ solve ( dx + 1 ) ( dy + 1 ) ++ "L"
		d = map inverse c
	putStrLn $ concat [ a, b, c, d ]

solve x y = replicate x 'R' ++ replicate y 'U'

inverse 'U' = 'D'
inverse 'D' = 'U'
inverse 'L' = 'R'
inverse 'R' = 'L'

Measured memory_bytes: 1020
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int K = sc.nextInt();
  int A = 1;
  int B = 0;
  while(A <= K){
    A *= 2;
    B += 1;
  }
  if(N > B) {
  System.out.println((int)Math.pow(2,B) + K*(N-B));
  }
  else if(N <= B)System.out.println((int)Math.pow(2,N));
}
}

Measured memory_bytes: 21204
n = int(input())
s = [str(input()) for i in range(n)]
m = int(input())
t = [str(input()) for i in range(m)]
a = [0]
for i in range(n):
    p = s.count(s[i])
    m = t.count(s[i])
    a.append(p-m)
print(max(a))

Measured memory_bytes: 3064
while True:
    H, W = list(map(int, input().split()))
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if i == 0 or i == H - 1:
                print("#", end = "")
            else:
                if j == 0 or j == W - 1:
                    print("#", end = "")
                else:
                    print(".", end = "")
        print()
    print()


Measured memory_bytes: 7004
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>

#define int long long
//typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); i++)

using namespace std;

signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N, M;

    cin >> N >> M;

    int ans = 0;
    int scc_cnt1 = min(N, M / 2);
    ans += scc_cnt1;
    M -= 2 * scc_cnt1;
    ans += M / 4;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

ll cnt[1005];

int main(){

	int n,x,maxN;

	scanf("%d",&maxN);

	for(n=2;n<=maxN;n++){
		int tmp=n;
		for( x = 2 ; tmp > 1 ; x++ ){
			while( ( tmp % x ) == 0 ){
				cnt[x]+=1ll;
				tmp /= x;
			}
		}
	}
	ll mod=1000000007ll;

	ll ans=1ll;

	for(n=2;n<=maxN;n++){
	ans*=(cnt[n]+1ll);
	ans%=mod;
	}
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main()
{
  int i,j,n,u,k,v,a[1000][1000];

  scanf("%d",&n);

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

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",a[i][j]);
      if(j!=n) printf(" ");
    }
    printf("\n");
  }		

  return 0;
}

Measured memory_bytes: 996
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int h, w, a, b; cin >> h >> w >> a >> b;
    REP(i, 0, h-b){
        REP(l, 0, w-a){
            cout << 1;
        }
        REP(l, 0, a){
            cout << 0;
        }
        cout << endl;
    }
    REP(i, 0, b){
        REP(l, 0, w-a){
            cout << 0;
        }
        REP(l, 0, a){
            cout << 1;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    for(int i = 0;i < N;i++)cin >> V[i];
    if(V[0] != 0){
        cout << -1 << endl;
        return 0;
    }
    for(int i = 1;i < N;i++){
        if(V[i] - V[i-1] > 1){
            cout << -1 << endl;
            return 0;
        }
    }
    int num = V[N-1];
    ll cnt = num;
    for(int i = N-2;i >= 0;i--){
        if(num - 1 != V[i]){
            cnt += V[i];
        }
        num = V[i];
    }
    cout << cnt << endl;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}



void smain() {

    int m,d;
    cin>>m>>d;
    int ans=0;
    for(int i=1;i<=d;i++){
        int d10=i/10,d1=i%10;
        if(d10*d1<=m&&d10>=2&&d1>=2){
            ans++;
        }
    }
    cout<<ans;

}

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

template<typename T>
void print_vec(const vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; ++i) {
    if (i > 0) cout << ' ';
    cout << v[i];
  }
  cout << '\n';
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (auto &an: a) cin >> an;
  for (auto &bn: b) cin >> bn;
  reverse(b.begin(), b.end());
  vector<int> same;
  for (int i = 0; i < n; ++i) {
    if (a[i] == b[i]) same.push_back(i);
  }
  int cnt = same.size();
  if (cnt == 0) {
    cout << "Yes\n";
    print_vec(b);
    return 0;
  }

  int val = b[same[0]];
  vector<int> exchange;
  for (int i = 0; i < n; ++i) {
    if (a[i] != val && b[i] != val && cnt > 0) {
      exchange.push_back(i);
      --cnt;
    }
  }
  if (cnt > 0) {
    cout << "No\n";
    return 0;
  }
  for (int i = 0; i < (int)same.size(); ++i) {
    swap(b[same[i]], b[exchange[i]]);
  }
  cout << "Yes\n";
  print_vec(b);

  return 0;
}


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

int main(){
  long long N,n[100001],q,t,min,sum=0,k,qu;
  cin>>N>>q;
  for(int i=0;i<N;i++)cin>>n[i];
  for(int j=0;j<q;j++){//???????????°??????
    cin>>qu;
    t=0;
    k=0;
    sum=0;
    for(int i=0;i<N;i++){//???????????????????????§
      sum+=n[i];
      if(sum<=qu){
	k+=i-t+1;
      }else if(sum>qu){//??§???????????£??????
	while(sum>qu&&i>t){
	  sum-=n[t];
	  t++;
	}
	if(n[i]<=qu)k+=i-t+1;
      }
      //cout<<k<<endl;///
    }
    cout<<k<<endl;
  }
  return 0;
}

Measured memory_bytes: 3840