akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

// CumulativeSum2D {{{
class CumulativeSum2D {
    vector<vector<intmax_t>> cum;

public:
    CumulativeSum2D() {}
    CumulativeSum2D(const size_t h, const size_t w) : cum(h + 1, vector<intmax_t>(w + 1)) {}

    inline void build() {
        const size_t h = cum.size(), w = cum[0].size();
        for (size_t y = 1; y < h; ++y) {
            for (size_t x = 1; x < w; ++x) {
                cum[y][x] += cum[y][x - 1] + cum[y - 1][x] - cum[y - 1][x - 1];
            }
        }
    }

    inline intmax_t sum(size_t sy, size_t sx, size_t gy, size_t gx) const {
        return cum[gy][gx] - cum[sy - 1][gx] - cum[gy][sx - 1] + cum[sy - 1][sx - 1];
    }

    inline intmax_t operator()(size_t y, size_t x) const {
        return cum[y][x];
    }

    inline intmax_t& operator()(size_t y, size_t x) {
        return cum[y][x];
    }

    inline void resize(const size_t h, const size_t w) {
        cum.assign(h + 1, vector<intmax_t>(w + 1));
    }

    inline intmax_t height() const noexcept {
        return cum.size() - 1;
    }

    inline intmax_t width() const noexcept {
        return cum[0].size() - 1;
    }

    friend ostream& operator<<(ostream &out, const CumulativeSum2D &matrix) {
        const size_t h = matrix.cum.size();
        const size_t w = matrix.cum[0].size();
        for (size_t y = 1; y < h; ++y) {
            for (size_t x = 1; x < w; ++x) {
                out << matrix.cum[y][x] << (x == w - 1)[" \n"];
            }
        }
        return out;
    }
};
// }}}

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

    size_t N, M, Q; cin >> N >> M >> Q;

    CumulativeSum2D cum(N + 1, N + 1);
    for (size_t i = 0; i < M; ++i) {
        size_t L, R; cin >> L >> R;
        cum(L, R)++;
    }

    cum.build();

    while (Q--) {
        size_t p, q; cin >> p >> q;
        cout << cum.sum(p, p, q, q) << "\n";
    }


    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <memory>

using namespace std;

struct Node {
	int v;
	shared_ptr<Node> next;
};

void solve(int v, int e) {
	vector<vector<int>> capacities(v, vector<int>(v, 0));
	auto residual = [&](int from, int to) {
		return capacities[from][to];
	};

	for (int i = 0; i < e; i++) {
		int from, to, capacity;
		cin >> from >> to >> capacity;
		capacities[from][to] = capacity;
	}

	int max_flow = 0;
	while (true) {
		stack<shared_ptr<Node>> paths;
		vector<int> visited(v, 0);
		paths.push(make_shared<Node>(Node{ 0, nullptr }));
		bool traveresed_all = false;
		while (!traveresed_all) {
			auto path = paths.top();
			paths.pop();
			auto last = path->v;
			if (!visited[last]) {
				visited[last] = 1;
				if (last == v - 1) {
					for (shared_ptr<Node> node = path; node->next != nullptr; node = node->next) {
						capacities[node->next->v][node->v]--;
						capacities[node->v][node->next->v]++;
					}
					max_flow++;
					break;
				}
				for (int i = 0; i < v; i++) {
					if (!visited[i] && residual(last, i) > 0) {
						auto new_path = make_shared<Node>(Node{ i, path });
						paths.push(new_path);
					}
				}
			}
			traveresed_all = paths.empty();
		}
		if (traveresed_all) {
			cout << max_flow << endl;
			return;
		}
	}
}

int main() {
	int v, e;
	cin >> v >> e;
	solve(v, e);
}

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

constexpr int MAXN = 2e5 + 5, MOD = 1e13 + 7;

template<typename T>
inline void read(T& x, T f = 1, char ch = getchar()) {
    x = 0;
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

struct SegTree {
    SegTree *lson, *rson;
    int l, r;
    int min, Lval;
    int tag1, tag2;
} *root, tree[MAXN << 1];
int h, w, a[MAXN], b[MAXN], ans[MAXN];

inline SegTree* newNode(SegTree*& root) {
    static int tot;
    return root = &tree[tot++];
}

inline void update(SegTree* root) {
    root->min = min(root->lson->min, root->rson->min);
}

inline void build(SegTree* root, int l, int r) {
    root->l = l, root->r = r;
    if (l == r) return;
    int mid = (l + r) >> 1;
    build(newNode(root->lson), l, mid);
    build(newNode(root->rson), mid + 1, r);
    update(root);
}

inline void pushTag(SegTree* root) {
    if (root->tag1) {
        root->lson->tag1 += root->tag1, root->rson->tag1 += root->tag1;
        root->lson->Lval += root->tag1, root->rson->Lval += root->tag1;
        root->lson->min += root->tag1, root->rson->min += root->tag1;
    }
    if (root->tag2) {
        root->lson->tag2 = root->tag2, root->rson->tag2 = root->tag2;
        root->lson->min = root->lson->Lval
            = root->Lval + (root->lson->l - root->l) * root->tag2;
        root->rson->min = root->rson->Lval
             = root->Lval + (root->rson->l - root->l) * root->tag2;
    }
    root->tag1 = root->tag2 = 0;
}

inline void modify(SegTree* root, int l, int r, int val, int type) {
    if (l <= root->l && root->r <= r) {
        if (type == 1)
            root->min += val, root->Lval += val, root->tag1 += val;
        else { //区间赋值
            root->Lval = root->min = root->l - l + 1 + val;
            root->tag2 = 1; //公差为 1 的等差数列
        }
        return;
    }
    pushTag(root);
    int mid = (root->l + root->r) >> 1;
    if (l <= mid) modify(root->lson, l, r, val, type);
    if (r > mid) modify(root->rson, l, r, val, type);
    update(root);
}

inline int query(SegTree* root, int l, int r) {
    if (l <= root->l && root->r <= r)
        return root->min;
    pushTag(root);
    int mid = (root->l + root->r) >> 1, res = 1e18;
    if (l <= mid) res = min(res, query(root->lson, l, r));
    if (r > mid) res = min(res, query(root->rson, l, r));
    return res;
}

signed main() {
    read(h), read(w);
    for (int i = 1; i <= h; i++) read(a[i]), read(b[i]);
    build(newNode(root), 1, w);
    for (int i = 1; i <= h; i++) {
        modify(root, a[i], b[i], 1e12, 1);
        if (a[i] > 1) modify(root, 1, a[i] - 1, 1, 1);
        if (b[i] < w) modify(root, b[i] + 1, w, 1, 1);
        int mi = a[i] == 1 ? 1e12 : query(root, a[i] - 1, a[i] - 1);
        modify(root, a[i], b[i], mi, 2);
        ans[i] = query(root, 1, w);
    }
    for (int i = 1; i <= h; i++) printf("%lld\n", ans[i] >= 1e12 ? -1 : ans[i]);
    return 0;
}

Measured memory_bytes: 33356
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    ll N;
    cin >> N;
    cout << N * (N - 1) /2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int cnt[31];

int main() {
    int n, m;
    scanf("%d %d", &n, &m);

    for (int i = 1;i <= n;++i) {
        int k;
        scanf("%d", &k);

        for (int j = 1;j <= k;++j) {
            int u;
            scanf("%d", &u);

            cnt[u]++;
        }
    }

    int total = 0;
    for (int i = 1;i <= m;++i)
        if (cnt[i] == n)
            total++;

    printf("%d", total);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){
	string s;
	int a = 0;

	cin >> s;


	for (int i = 0; i < 4; i++){
		if (s[i] == '+'){
			a++;
		}
		if (s[i] == '-'){
			a--;

		}
	}
		cout << a << endl;
		return 0;
	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		
		int n = sc.nextInt();
		String[] ws = new String[n];
		
		String w = sc.next();
		ws[0] = w;
		char next = w.charAt(w.length() - 1);
		
		for(int i = 1; i < n; i++) {
			w = sc.next();
			if(w.charAt(0) != next) {
				System.out.println("No");
				return;
			}
			for(int j = 0; j < i; j++) {
				if(w.equals(ws[j])) {
					System.out.println("No");
					return;
				}
			}
			ws[i] = w;
			next = w.charAt(w.length() - 1);
		}
		
		System.out.println("Yes");
	}
}

Measured memory_bytes: 23252
#include <stdio.h>
#define N 36

typedef struct {
	char v;
	
	int n;}
	tmp;
	
int main () {
	int num, i, j, a, mini;
	tmp b[N], c[N], t;
	
	scanf("%d", &num);
	
	for ( i = 0; i < num; i++ ) {
		scanf("%c%c%d", &b[i].v, &b[i].v, &b[i].n);
		c[i] = b[i];
		}
		
	for ( i = 0; i < num; i++ ) {
		for ( j = num - 1; j >= i + 1; j-- ) {
			if ( b[j].n < b[j-1].n ) {
				t = b[j];
				b[j] = b[j-1];
				b[j-1] = t;
				}
			}
		}
			
			
	 for ( i = 0; i < num; i++ ) {
		mini = i;
		for ( j = i; j < num; j++ )
		if ( c[j].n < c[mini].n )
		mini = j;
		t = c[i];
		c[i] = c[mini];
		c[mini] = t;
		}
		
	for ( i = 0; i < num - 1; i++ ) {
		printf("%c%d ", b[i].v, b[i].n);
		}
	printf("%c%d\n", b[num-1].v, b[num-1].n);
	printf("Stable\n");
	
	for ( i = 0; i < num - 1; i++ ) {
		printf("%c%d ", c[i].v, c[i].n);
		}
	printf("%c%d\n", c[num-1].v, c[num-1].n);
	
	a = 1;
	
	for ( i = 0; i < num; i++ )
	if ( b[i].v != c[i].v )
	a = 0;
	
	if ( a == 1 )
	printf("Stable\n");
	
	else
	printf("Not stable\n");
	
	return 0;
}


Measured memory_bytes: 1992
#include<iostream>
#include<cstdio>
#include<cstring>
namespace Midium
{
	const int N=201000;
	int s[N],t[N];
	int cnt[N];
	int n,m,ans;
	void initialize()
	{
		scanf("%d%d",&n,&m);
		for(int i=1;i<=n;i++)scanf("%d",s+i),t[s[i]]++;
		for(int i=1;i<=n;i++)
			for(int j=std::max(i-t[i]+1,1);j<=i;j++)
				cnt[j]++;
		for(int i=1;i<=n;i++)
			if(!cnt[i])ans++;

	}
	void modify(int x,int y)
	{
		int tmp=x;
		x=s[x];s[tmp]=y;
		if(x==y)return;
		int p1=x-t[x]+1,p2=y-t[y];

		if(p1>0)
		{
			cnt[p1]--;
			if(!cnt[p1])ans++;
		}
		if(p2>0)
		{
			if(!cnt[p2])ans--;
			cnt[p2]++;
		}
		t[x]--;
		t[y]++;

	}
	void solve()
	{
		initialize();
		for(int x,y;m--;)
		{
			scanf("%d%d",&x,&y);
			modify(x,y);
			printf("%d\n",ans);
		}
	}
}
int main()
{
	Midium::solve();
	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n;
int k;
int a[200005];
int mx;
bool check(long double len){
    if(len==0.0) return 0;
    ll num=0;
    for(int i=1;i<=n;i++)
        num+=ceil(a[i]*1.0/len)-1;
    return num<=k;
}
int main(){
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),mx=max(mx,a[i]);
    long double lb=0.0,ub=mx;
    while(ub-lb>=1e-6){
        long double mid=(ub+lb)*1.0/2.0;
        if(check(mid))
            ub=mid;
        else
            lb=mid;
    }
    long double ans=(lb+ub)/2.0;
    if(ans-floor(ans)-0.5<=1e-6) ans=floor(ans)+0.5;
    printf("%d\n",(int)round(ans));
    return 0;
}

Measured memory_bytes: 4512
import collections


class TwoDimQueue():
    def __init__(self, num_queues):
        self.queues = [collections.deque() for i in range(0, num_queues, 1)]

    def enqueue(self, t, x):
        self.queues[t].appendleft(x)
        return self

    def front(self, t):
        if len(self.queues[t]) > 0:
            print(f'{self.queues[t][len(self.queues[t])-1]}')
        return self

    def dequeue(self, t):
        if len(self.queues[t]) > 0:
            self.queues[t].pop()
        return self


num_queues, q = tuple(map(int, input().split(' ')))
stacks = TwoDimQueue(num_queues)

for i in range(0, q):
    queue = tuple(map(int, input().split(' ')))
    if queue[0] == 0:
        stacks.enqueue(queue[1], queue[2])
    elif queue[0] == 1:
        stacks.front(queue[1])
    elif queue[0] == 2:
        stacks.dequeue(queue[1])


Measured memory_bytes: 14688
#include <iostream>
using namespace std;
int n;

int main(){
	cin>>n;
	long long a=1;
	long long b=2;
	long long c;
	for(int i=1;i<n;i++){
			c=a;
			a+=b;
			b=c;
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = Integer.parseInt(sc.next());
        if(d==25){
            System.out.println("Christmas");
        }else if(d==24){
            System.out.println("Christmas Eve");
        }else if(d==23){
            System.out.println("Christmas Eve Eve");
        }else{
            System.out.println("Christmas Eve Eve Eve");
        }
        sc.close();
    }
    
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=10000010;
const double EPS=1e-3;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
char c[12][12];
bool v[12][12];
bool f(int y,int x){
	if(x<0||x>=12||y<0||y>=12||v[y][x]||c[y][x]=='0'){
		return false;
	}
	return true;
}
void dfs(int y,int x){
	v[y][x]=true;
	for(int i=0;i<4;i++){
		int ny=y+dy[i];
		int nx=x+dx[i];
		if(f(ny,nx)){
			dfs(ny,nx);
		}
	}
}
int main(){
	while(cin>>c[0]){
		for(int i=1;i<12;i++){
			cin>>c[i];
		}
		memset(v,false,sizeof(v));
		int ans=0;
		for(int i=0;i<12;i++){
			for(int j=0;j<12;j++){
				if(c[i][j]=='1'&&(!v[i][j])){
					dfs(i,j);
					ans++;
				}
			}
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	vector<int> B(N - 1), A(N,1e6);
	FOR(i, 0, N - 1)
	{
		cin >> B.at(i);
	}

	FOR(i,0,N-1){
		if(B.at(i)<A.at(i))
			A.at(i) = B.at(i);
		if(B.at(i)<A.at(i+1))
			A.at(i+1) = B.at(i);
	}

	cout << accumulate(range(A), 0) << endl;

	return 0;
}



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

int main(){
  int n, count = 0;
  cin >> n;
  vector<int> hoge(n);
  for (int i = 0; i < n; i++){
    cin >> hoge.at(i);
  }
  
  for (int i = 0; i < n - 2; i++){
    if (hoge[i] < hoge[i+2]){
      if (hoge[i] < hoge[i+1] && hoge[i+1] < hoge[i+2]){
        count += 1;
      }
    }else if(hoge[i] > hoge[i+2]){
      if (hoge[i + 2] < hoge[i+1] && hoge[i+1] < hoge[i]){
        count += 1;
      }
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,x;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	x=a+b;
	if(x>=c) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <tuple>
#include <math.h>
#include <iomanip>
#include <string>

using namespace std;

class Sover {
};
int main()
{
	while (true) {
		int n;
		cin >> n;
		if (n == 0)break;

		string s;
		cin >> s;
		set<tuple<int, int>> commands;
		int now = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] == 'u') {
				now = 0;
			}
			else {
				int num = s[i] - '0';
				commands.emplace(now, num);
				now += 1 << num;
			}
		}

		set<tuple<int, int>> dp;
		for (tuple<int, int> tpl : commands) {
			dp.emplace(tpl);
		}
		bool can = true;
		for (int i = 0; i < 9; i++) {
			set<tuple<int, int>> next;
			for (tuple<int, int> val : dp) {
				int pat, num;
				tie(pat, num) = val;
				next.emplace(val);
				for (tuple<int, int> tmp : commands) {
					int pat_tmp, num_tmp;
					tie(pat_tmp, num_tmp) = tmp;
					if ((pat ^ pat_tmp) == pat + pat_tmp) {
						if ((((1 << num) & (pat + pat_tmp)) > 0)
							&& (((1 << num_tmp) & (pat + pat_tmp)) == 0)) {
							next.emplace(pat + pat_tmp, num_tmp);
						}
						if ((((1 << num) & (pat + pat_tmp)) == 0)
							&& (((1 << num_tmp) & (pat + pat_tmp)) > 0)) {
							next.emplace(pat + pat_tmp, num);
						}
						if ((((1 << num) & (pat + pat_tmp)) > 0)
							&& (((1 << num_tmp) & (pat + pat_tmp)) > 0)) {
							can = false;
						}
					}
					if (!can)break;
				}
				if (!can)break;
			}
			dp = next;
			if (!can)break;
		}

		if (can)		cout << "SAFE" << endl;
		else cout << "UNSAFE" << endl;
	}
}


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

bool my_compare1(pair<ll,pair<ll,ll>> a,pair<ll,pair<ll,ll>> b){
  if(a.first != b.first) return a.first < b.first;
  else return true;
}

bool my_compare2(pair<ll,pair<ll,ll>> a,pair<ll,pair<ll,ll>> b){
  return a.second.second < b.second.second;
}

int main(){
  ll N,M;
  cin >> N >> M;
  vector<vector<pair<ll,pair<ll,ll>>>> v(N);
  vector<pair<ll,pair<ll,ll>>> ans;
  for(ll i=0;i<M;++i){
    ll p,y;cin>>p>>y;p--;
    v[p].push_back(make_pair(y,make_pair(p,i)));
  }
  for(ll i=0;i<N;++i){
    sort(v[i].begin(),v[i].end(),my_compare1);
  }
  for(ll i=0;i<N;++i){
    for(ll j=0;j<v[i].size();++j){
      ans.push_back(make_pair(j,v[i][j].second));
    }
  }
  sort(ans.begin(),ans.end(),my_compare2);
  for(ll i=0;i<ans.size();++i){
    string pref,rank;
    cout << setfill('0') << right << setw(6) << ans[i].second.first + 1;
    cout << setfill('0') << right << setw(6) << ans[i].first + 1;
    cout << endl;
    }
}

Measured memory_bytes: 10992
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int m = scan.nextInt();
		
		if(n == m) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21972
n,m,l=list(map(int,input().split()))
A=[]
B=[]
for i in range(n):
	A.append(list(map(int,input().split())))
for i in range(m):
	B.append(list(map(int,input().split())))

res=[[0 for i in range(l)] for i in range(n)]

for i in range(n):
	for k in range(l):
		for j in range(m):
			res[i][k]+=A[i][j]*B[j][k]

for i in res:
	print(" ".join(list(map(str,i))))

Measured memory_bytes: 8736
#include <stdio.h>
int main()
{
	int a,n,i,j;
	scanf("%d\n%d",&n,&a);
	if(n%500==0)
		printf("Yes");
	else if(n%500!=0&&(n%500)<a)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
n, m = gets.split.map(&:to_i)
a = []
b = []
n.times do
    a << gets.to_i
end
m.times do 
    b << gets.to_i
end
a = a.map.with_index.to_a
cnt = [0] * n
b.each do |x|
    cnt[ a.select{ |elem, idx| x >= elem }[0][1] ] += 1
end

puts cnt.map.with_index.to_a.max[1] + 1

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

int main() {
  int H,W;
  while(1){
    cin >> H >> W;
    
    if(H==0 && W==0)
      break;
    
    for(int i=1; i<=H; i++){
      for(int j=1; j <= W; j++){
        cout << "#";
    }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int a[100007],f[100007],ans,n;
int main(){
	cin>>n;
	for(int i=n;i>=1;--i)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)//逆向遍历
		if(f[ans]<=a[i])//如果f数组里比较小，把a数组放进f数组，让大的放在ans位置上
            f[++ans]=a[i];
		else
            f[upper_bound(f+1,f+1+ans,a[i])-f]=a[i];//f数组比较大，把它变成a数组的数，继续向前找更小的，使得这一串只要染色一次
	cout<<ans;//ans就是f数组里的数字个数，代表有一些小的数字在后面没有办法找到前面更小的数字使得一齐染色
	return 0;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val (N, K) = listOfLong()
    if (K == 0L) {
        println(N * N)
        return
    }
    var ans = 0L
    for (b in K + 1..N) {
        val p = N / b
        val r = N % b
        val k = Math.max(b - K, 0) * p + Math.max(r - K + 1, 0)
        ans += k
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { it.toInt() + d }
fun listOfLong(d: Long = 0) = listOfString().map { it.toLong() + d }


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

int main ()
{
    int n;
    while (cin >> n, n) {
        vector<string> V;
        while (n--) {
            string tmp;
            cin >> tmp;
            V.push_back(tmp);
        }
        n = V.size();
        vector<vector<int> > N(n, vector<int>(n, 0));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n -1; j++) {
                if (V[i][j] == '.') N[i][j]++;
                if (V[i][j] == V[i][j+1] && V[i][j] == '.') {
                    N[i][j+1] += N[i][j];
                }
            }
            if (V[i][n-1] == '*') N[i][n-1] = 0;
            else N[i][n-1]++;
        }
        int res = 0;
        for (int i = 0; i < N.size(); i++) {
            for (int j = 0; j < N[i].size(); j++) {
                if (N[i][j] > res) {
                    int t = N[i][j];
                    bool flag = true;
                    for (int k = 0; k < t; k++) {
                        if (i + k >= n) {
                            flag = false;
                            break;
                        }
                        if (N[i+k][j] < t) {
                            t = N[i+k][j];
                        }
                    }
                    if (flag && res < t) {
                        res = t;
                    }
                }
            }
        }
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 6100
import sys
input = sys.stdin.readline

N = int(input())
L = [list(input().strip()) for _ in range(N)]

M = []
ANS = {}

for i in range(N):
    M.append({})
    
    for v in L[i]:
        if M[i].get(v) != None:
            M[i][v] += 1
        else:
            M[i][v] = 1

    for k, v in M[i].items():
        if ANS.get(k) != None:
            ANS[k] = min(ANS[k], v)
        else:
            ANS[k] = v

keys = list(ANS.keys())
for k in keys:
    for mv in M:
        if mv.get(k) == None:
            del ANS[k]
            break

if len(ANS) == 0:
    print("")
else:
    keys = list(ANS.keys())
    keys.sort()
    
    for k in keys:
        print(k * ANS[k], end = "")
        
    print("")

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP((i),0,(n))
#define RREP(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rrep(i,n) RREP(i,n,0)
#define each(it,X) for(__typeof((X).begin())  it=(X).begin();it!=(X).end();it++)
#define all(v) ((v).begin(),(v).end())
#define fi first
#define se second
#define pb push_back
typedef pair<int,int>pr;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef set<int>si;
const int INF=1070000000ll;
const int mod=1000000007ll;


int N,Q;
int ma[700010];
signed main(){
    cin.tie(0);ios_base::sync_with_stdio(0);

    cin>>N>>Q;
    rep(i,N){
        int c;cin>>c;
        ma[c]=c;
    }

    rep(i,700000)ma[i+1]=max(ma[i],ma[i+1]);
    while(Q--){
        int ans=0;
        int q;cin>>q;
        for(int i=1;i*q<650000;i++){
            ans=max(ans,ma[i*q-1]%q);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 6660
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
using namespace std;
int main(){
    ll a, b, c;    
    cin >> a >> b >> c;
    if ((c - a - b) > 0 && (c - a - b) * (c - a - b) > 4 * a * b)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }   
 
    return 0;
}

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

int N,ans=1e9;
int S,T,W[100];
int main(void){
    cin >> N;
    rep(i,N){cin >> W[i];S+=W[i];}
    rep(i,N){T+=W[i];ans = min(ans,abs(S-2*T));}
    cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

int main(){

    ll A, B, C, D;

    cin >> A >> B >> C >> D;

    cout << (A + B < C + D ? "Right" : (A + B > C + D ? "Left" : "Balanced")) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  string s;
  cin >> s;
  int n = s.size();
  rep(i,n){
    if(i % 2 == 0 && s.at(i) == 'L'){
      cout << "No" << endl;
      return 0;
    }
    if(i % 2 == 1 && s.at(i) == 'R'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

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

  if(S == "ABC")  cout << "ARC" <<endl;
  else   cout << "ABC" <<endl;


}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(), x.end()

int main() {
  string s;
  cin >> s;
  ll cou = 0;
  for (ll i = 0; i < s.size() / 2; i++) {
    if (s.at(i) != s.at(s.size() - 1 - i)) cou++;
  }
  cout << cou << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+5;

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

	int l,r;
	cin>>l>>r;
	for(int i=l;i<=min(l+2019,r);i++)
		if(i%2019==0) {
			cout<<0;
			return 0;
		}

	int ans = 1e9;
	for(int i=l;i<=r;i++)
		for(int j=i+1;j<=r;j++)
			if( (i*1LL*j)%2019<ans)
				ans = (i*1LL*j)%2019;
	cout<<ans;
	
	return 0;
}

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

int main(){
  long t[100000],sum=0,x;
  int n,m,p;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%ld",&t[i]);
    sum+=t[i];
  }
  scanf("%d",&m);
  for(int i=0;i<m;i++){
    scanf("%d %ld",&p,&x);
    printf("%ld\n",sum-t[p-1]+x);
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define UGOKE_EI_EI_EI_YAAAAAAAAAA int main() { int a, b; std::cin >> a >> b; std::cout << std::max({a+b,a-b,a*b}) << std::endl; return 0; }

UGOKE_EI_EI_EI_YAAAAAAAAAA 

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int number1, number2;
    scanf("%d", &number1);
    number2 = number1;
    for(int i = 0; i < 2; i++){
        number2*=number1;
    }
    printf("%d\n", number2);
    return 0;
}


Measured memory_bytes: 2052
N=int(input())
s=[int(input()) for _ in range(N)]
count=0
flag=0
max=sum(s)
s.sort()
if not(max%10==0):
 print(max)
 flag=1
else:
 for i in range(0,N):
  if not((max-s[i])%10==0):
   print(max-s[i])
   flag=1
   break
if flag==0:
 print("0")

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, q; cin >> n >> m >> q;
    vector<vector<int>> cnt(n + 1, vector<int>(n + 1, 0));
    for(int i = 0; i < m; i++)
    {
        int l, r; cin >> l >> r;
        cnt[l][r]++;
    }
    for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) cnt[i][j] += cnt[i][j - 1];
    while(q--)
    {
        int l, r; cin >> l >> r;
        int res = 0;
        for(int i = l; i <= r; i++) res += cnt[i][r] - cnt[i][l - 1];
        cout << res << "\n";
    }
    return 0;
}



Measured memory_bytes: 1920
defmodule Main do
  def main do
    [n, x, t] =
      IO.read(:line)
      |> String.trim |> String.split
    n = String.to_integer(n)
    x = String.to_integer(x)
    t = String.to_integer(t)
    IO.puts(ceil(n / x) * t)

  end
end


Measured memory_bytes: 30780
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, M;

int main() {
    cin >> N >> M;

    vvi A(M, vi(100, 0));
    vi k(M);
    for (int i = 0; i < M; i++) {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    vi p(M);
    for (int i = 0; i < M; i++) {
        cin >> p[i];
    }

    int ans = 0;
    for (int mask = 0; mask < (1 << N); mask++) {
        bool f = true;
        for (int i = 0; i < M; i++) {
            int x = 0;
            for (int j = 0; j < k[i]; j++) {
                if ((mask >> A[i][j]) & 1) {
                    x++;
                }
            }
            if (x % 2 != p[i]) {
                f = false;
                break;
            }
        }
        if (f) ans++;
    }

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int v[3][3];
bool mark[3][3];

int main() {

  int n, p;
  for(int i = 0;i < 3;i++){
    for(int j = 0;j < 3;j++){
      cin >> v[i][j];
    }
  }
  cin >> n;
  for(int i = 1;i <= n;i++){
    cin >> p;
    for(int i = 0;i < 3;i++){
      for(int j = 0;j < 3;j++){
        if(p == v[i][j]){
          mark[i][j] = true;
        }
      }
    }
  }
  if(mark[0][0] == true && mark[1][1] == true && mark[2][2] == true){
    cout << "Yes";
  }else if(mark[0][2] == true && mark[1][1] == true && mark[2][0] == true){
    cout << "Yes";
  }else if(mark[0][0] == true && mark[0][1] == true && mark[0][2] == true){
    cout << "Yes";
  }else if(mark[1][0] == true && mark[1][1] == true && mark[1][2] == true){
    cout << "Yes";
  }else if(mark[2][0] == true && mark[2][1] == true && mark[2][2] == true){
    cout << "Yes";
  }else if(mark[0][0] == true && mark[1][0] == true && mark[2][0] == true){
    cout << "Yes";
  }else if(mark[0][1] == true && mark[1][1] == true && mark[2][1] == true){
    cout << "Yes";
  }else if(mark[0][2] == true && mark[1][2] == true && mark[2][2] == true){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 3580
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


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

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, X, Y, a[2222] = {0};

  std::cin >> N >> X >> Y;

  X --;
  Y --;

  for (int i = 0; i < N; i ++)
    std::cin >> a[i];

  for (int i = 0; i < N; i ++)
    for (int j = i + 1; j < N; j ++) {
      int d0 = j - i;
      int d1 = std::abs(X - i) + std::abs(Y - j) + 1;
      int d2 = std::abs(Y - i) + std::abs(X - j) + 1;

      int d = std::min({d0, d1, d2});

      a[d] ++;
    }

  for (int i = 1; i < N; i ++)
    std::cout << a[i] << std::endl;

  assert(std::accumulate(a + 1, a + N, 0) == N * (N - 1) / 2);

  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>

using namespace std;

int dp[100001];
map <long long int, int> memo;
set <long long int,greater<long long int>> s;
vector <long long int> v2[100001];
bool cmp(pair <long long int, long long int> a, pair <long long int, long long int> b)
{
	if (a.first - a.second == b.first - b.second)
	{
		return a.first + a.second < b.first + b.second;
	}
	return a.first - a.second < b.first - b.second;
}
bool cmp2(pair <long long int, long long int> a, pair <long long int, long long int> b)
{
	if (a.second==b.second)
	{
		return a.first < b.first;
	}
	return a.second < b.second;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	vector<pair<long long int, long long int>> v;
	long long int a, b;
	//ifstream cin("10.txt");

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> a >> b;
		v.push_back(make_pair(a, b));
	}

	sort(v.begin(), v.end(), cmp);

	for (int i = 0; i < n; i++)
	{
		s.insert(v[i].first + v[i].second);
		//cout << v[i].first - v[i].second << ' ' << v[i].first + v[i].second << '\n';
	}
	
	int m = s.size();

	for (auto it : s)
	{
		memo[it] = m--;
	}

	int Max = 0;
	int res = 0;
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < n; i++)
	{
		auto it = s.lower_bound(v[i].first - v[i].second);
		if (it == s.end())
		{
			int idx = memo[v[i].first + v[i].second];
			v2[0].push_back(idx);
		}
		else
		{
			int idx1 = memo[*it];
			int idx2 = memo[v[i].first + v[i].second];
			v2[idx1].push_back(idx2);
		}
	}

	for (int i = 0; i <= s.size(); i++)
	{
		Max = max(Max, dp[i]);
		for (int j = 0; j < v2[i].size(); j++)
		{
			//cout << i << ' ' << v2[i][j] << '\n';
			dp[v2[i][j]] = max(dp[v2[i][j]], Max + 1);
			res = max(res, dp[v2[i][j]]);
		}
	}

	cout << res << '\n';

	return 0;
}

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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	int n,m;cin>>n>>m;

	int sum=0;
	for(int i=0; i<m; i++){
		int tmp;cin>>tmp;
		sum +=tmp;
	}

	if(n >=sum){
		writeln(n-sum);
	}else {
		writeln(-1);
	}
}




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

int main(){
  int a,b;
  cin >> a >> b;
  int ans = 0;
  ans = max(max((a + (a-1)), (a + b)), b + (b-1));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
l = input().split()
N = int(l[0])

F = [[] for i in range(N)]
P = [[] for i in range(N)]

for i in range(N):
    l = input().split()
    F[i] = [int(x) for x in l]

for i in range(N):
    l = input().split()
    P[i] = [int(x) for x in l]

# print(N, F, P)

max_p = -10**9
for i in range(1, 1024):
    p = 0
    for n in range(N):
        num_open = 0
        for j in range(10):
            is_open = ((i >> j) & 1) == 1
            if is_open and F[n][j] == 1:
                num_open += 1
        p += P[n][num_open]
    max_p = max(p, max_p)

print(max_p)


Measured memory_bytes: 42092
#include <stdio.h>

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

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

	long long result = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				result += gcd(gcd(i, j), k);
			}
		}
	}
	printf("%I64d\n", result);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using pll = pair<ll,ll>;
using vll = vector<pll>;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

int main() {
    int K; cin >> K;
    ll ans = 0;
    rng(a,1,K+1) rng(b,1,K+1) rng(c,1,K+1) {
        ans += gcd(gcd(a, b), c);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
N = int(input())
A = list(map(int,input().split()))

for i in range(N):
    if A[i]%2 == 0:
        if A[i]%3 == 0 or A[i]%5 == 0:
            continue
        else:
            print("DENIED")
            break
else:
    print("APPROVED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,k,c;
  string s;
  cin >> n >> k >> c >> s;
  vector<int>left(n+1,0),right(n+1,0);
  int cnt=0;int pre=-c-1;
  rep(i,n){
    if(s[i]=='o' && i-pre>c){
      cnt++;
      pre=i;
    }
    left[i+1]=cnt;
  }
  reverse(s.begin(),s.end());
  cnt=0, pre=-c-1;
  rep(i,n){
    if(s[i]=='o' && i-pre>c){
      cnt++;
      pre=i;
    }
    right[i+1]=cnt;
  }
  reverse(s.begin(),s.end());
  rep(i,n){
    if(s[i]=='x')continue;
    if(left[i]+right[n-i-1]<k)cout << i+1 << endl;
  }
  return 0;     
}


Measured memory_bytes: 3348
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, c;
    cin >> n >> c;
    VV uum(c, V(c));
    rep(i, c) rep(j, c) cin >> uum[i][j];
    VV vec(n, V(n));
    rep(i, n) rep(j, n) cin >> vec[i][j];
    ll res = 1e18;
    map<ll, ll> mp1;
    map<ll, ll> mp2;
    map<ll, ll> mp3;
    rep(i, n)
    {
        rep(j, n)
        {
            if ((i + j) % 3 == 0)
            {
                mp1[vec[i][j]]++;
            }
            else if ((i + j) % 3 == 1)
            {
                mp2[vec[i][j]]++;
            }
            else
            {
                mp3[vec[i][j]]++;
            }
        }
    }
    rep3(i, 1, c + 1)
    {
        rep3(j, 1, c + 1)
        {
            if (i == j)
                continue;
            rep3(k, 1, c + 1)
            {
              //   cout<<i<<" "<<j<<" "<<k<<endl;
                if (i == k || j == k)
                    continue;
                ll sum = 0;
                rep3(m, 1, c+1)
                {
                    sum += mp1[m] * uum[m - 1][i - 1];
                    sum += mp2[m] * uum[m - 1][j - 1];
                    sum += mp3[m] * uum[m - 1][k - 1];
                }
                chmin(res, sum);
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main()
{
	char in[110];
	int N;
	char *S;
	int x = 0;
	int max;
	int i;


	fgets(in, sizeof(in), stdin);
	sscanf(in, "%d", &N);

	S = (char *)malloc(sizeof(char) * N + 1);

	fgets(in, sizeof(in), stdin);
	in[strlen(in) - 1] = '\0';
	sscanf(in, "%s", S);

	max = x;
	for(i = 0; i < N; i++){
		if(S[i] == 'I')
			x++;
		else
			x--;

		if(max < x)
			max = x;
	}

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

	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(!cin.eof()){
    vector<vector<int>> v(110,vector<int>(0,0));
    int a,b;
    while(cin>>a >> b){
      if(a + b == 0)break;
      v[a].pb(b);
      v[b].pb(a);
    }
    if(cin.eof()) break;
    bool f = true;
    int cnt = 0;
    REP(i,0,110){
      if(v[i].size() % 2){
        if(i < 3)
          ++cnt;
        else
          cnt += 10;
      }
    }
    if(cnt != 2){
      f = false;
    }
    if(f){
      cout << "OK"<<endl;
    }
    else{
      cout << "NG"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> box;
    for(int i = 0; i < n; i++) cin >> x[i];
    for(int i = 1; i <= 100; i++){
        int res = 0;
        for(int j = 0; j < n; j++){
            res += pow(x[j] - i, 2);
        }
        box.push_back(res);
    }
    int ans = *min_element(box.begin(), box.end());
    cout << ans;
}


Measured memory_bytes: 256
#include <cstdio>
#define rep(i,n)for(int i=0;i<n;i++)
int dx1[]={-1,-1,-1,0,1,0},dx2[]={0,-1,0,1,1,1};
int dy1[]={1,0,-1,-1,0,1},dy2[]={1,0,-1,-1,0,1};
int map[100][100],w,h;
void paint(int x,int y) {
	int *dx,*dy;
	map[x][y]=2;
	if(y&1)dx=dx1,dy=dy1;
	else dx=dx2,dy=dy2;
	rep(i,6) {
		int nx=x+dx[i],ny=y+dy[i];
		if(0>nx||nx>=w||0>ny||ny>=h)continue;
		if(!map[nx][ny])paint(nx,ny);
	}
}
int main() {
	scanf("%d %d",&w,&h);
	rep(j,h)rep(i,w) {
		scanf("%d",&map[i][j]);
	}
	rep(j,h) {
		if(!map[0][j])paint(0,j);
		if(!map[w-1][j])paint(w-1,j);
	}
	rep(i,w) {
		if(!map[i][0])paint(i,0);
		if(!map[i][h-1])paint(i,h-1);
	}
	int sum=0;
	rep(j,h)rep(i,w) {
		if(map[i][j]!=1)continue;
		int *dx,*dy;
		if(j&1)dx=dx1,dy=dy1;
		else dx=dx2,dy=dy2;
		rep(k,6) {
			int nx=i+dx[k],ny=j+dy[k];
			if(0>nx||nx>=w||0>ny||ny>=h||map[nx][ny]==2)sum++;
		}
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;
int main() {
    int l, k; scanf("%d%d", &l, &k);
    vector<ll> dp(l + 1);
    REP (i, l + 1) {
        if (i == 1 or i == k) dp[i] += 1;
        if (i - 2 >= 0) dp[i] += dp[i - 2];
        if (i - k - 1 >= 0) dp[i] += dp[i - k - 1];
    }
    ll result = accumulate(ALL(dp), 0ll);
    printf("%lld\n", result);
    return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    string tmp;
    vector<string> shiritori;
    int N;
    int judge = 0;

    cin >> N;
    for(int i=0; i<N; i++){
        cin >> tmp;
        shiritori.push_back(tmp);
    }

    for(int i=0; i<N-1; i++){
        if(shiritori[i].back() != shiritori[i+1].front())  
            judge = 1;
    }    

    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            if(shiritori[i] == shiritori[j])
                judge = 1;
        }
    }

    if(judge == 0)  cout << "Yes\n";
    else    cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    reverse(all(a));
    if (a[0] != 2) {
        cout << -1 << endl;
        return 0;
    }

    ll mn = 2, mx = 3;
    for (int i = 0; i < n - 1; i++) {
        mn = ((mn - 1) / a[i + 1] + 1) * a[i + 1];
        mx = (mx / a[i + 1] + 1) * a[i + 1] - 1;
        //cerr << mn _ mx << endl;
        if (mx < mn) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << mn _ mx << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(string S){
	rep(i, S.length()) {
		cout << "x";
	}
	cout << endl;
}

int main(){	
	string S;
	cin >> S;
	solve(S);
	return 0;
}



Measured memory_bytes: 256