akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    int v[n], c[n];
    for (int i = 0;i < n;i++) cin >> v[i];
    for (int i = 0;i < n;i++) cin >> c[i];

    int x = 0, y = 0;
    for (int i = 0;i < n;i++) {
        if (1 < (double)v[i] / c[i]) {
            x += v[i];
            y += c[i];
        }
    }
    cout << x - y << endl;
}


Measured memory_bytes: 256
A,B,C,D,E,F = map(int,input().split())

ws = set()
for i in range(F+1):
    if 100*A*i > F: break
    for j in range(F+1):
        if 100*A*i + 100*B*j > F: break
        ws.add(100*A*i + 100*B*j)
ws.remove(0)
ss = set()
for i in range(F+1):
    if C*i > F: break
    for j in range(F+1):
        if C*i + D*j > F: break
        ss.add(C*i + D*j)

opt_w = 1
opt_s = -1
for w in ws:
    for s in ss:
        if w+s > F: continue
        if s*100 > w*E: continue
        if opt_s * (w+s) < s * (opt_w+opt_s):
            opt_w,opt_s = w,s
print(opt_w+opt_s, opt_s)

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

using namespace std;

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

	if(A>=B)cout<<"delicious"<<"\n";
	else if(A+X>=B)cout<<"safe"<<"\n";
	else cout<<"dangerous"<<"\n";
	
	
	
	return 0;
}


Measured memory_bytes: 256
h,w = map(int, input().split())
s = ["." + str(input()) + "." for i in range(h)]
s.append("."*(w+2))
s.insert(0,"."*(w+2))
l = []

for h in range(1,h+1):
    s1 = ""
    for j in range(1,w+1):
        if s[h][j] == "#":
            s1 += "#"
        else:
            num = 0
            for x in range(-1,2):
                for y in range(-1,2):
                    if s[h+x][j+y] == "#":
                        num += 1
            s1 += str((num))
    l.append(s1)
for z in l:
    print(z)

Measured memory_bytes: 9228
#include<stdio.h>
int main(void){
    int H,W;
    int i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if((H==0)&&(W==0))
            break;
        for(i=0;i<H;i++){
            for(j=0;j<W;j++)
                printf("#");
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  vector<int> n(125);
  for(int i=0; i<s.size(); i++){n.at(s.at(i))++;}
  for(int i=0; i<125; i++){
    if(n.at(i)%2==1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include <cstdio>
#include<cmath>
#define endl '\n'
#define sz 1000001
using namespace std;
typedef long long ll;
ll siv[sz],cnt;
std::vector<ll>prime(sz,0);

int main()
{
	ll limit = sqrt(sz+1);
	for(ll i = 3; i<=limit; i++)
		if(!siv[i])
			for(ll j = i*i; j<sz; j+=i+i)
				if(!siv[j])siv[j]=1;
	prime[cnt++]=2;
	for(ll i = 3; i<sz; i+=2)
		if(!siv[i])prime[cnt++]=i;
	ll x;
	cin>>x;
	vector<ll>::iterator it;
	// sort(prime.begin(),prime.end());
	it = lower_bound(prime.begin(),prime.begin()+cnt,x);
	cout<<*it;
	return 0;
}

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

int check(int N, int C, int K, int* T)
{
	int bus_cnt = 0;
	int buf = 0;
	int pos = 0;

	sort(T, T + N);

	for (int i = 0; i < N; ++i) {
		if (buf == 0) {
			pos = i;
		}
		++buf;
		if (buf == C) {
			++bus_cnt;
			buf = 0;
			continue;
		}
		if (i == N - 1) {
			++bus_cnt;
			break;
		}
		if ((T[i + 1] > T[pos] + K)) {
			++bus_cnt;
			buf = 0;
		}
	}

	return bus_cnt;
}

int main(void)
{
	int N, C, K;
	cin >> N >> C >> K;

	int* T = new int[N];	
	for (int i = 0; i < N; ++i) {
		cin >> T[i];
	}

	int ans = check(N, C, K, T);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
     int a,b,c,d,e,f,g,h,i,j;
     map<int,int>m;
     vector<pair<int,int> >v;
     vector<pair<int,int> >v1;
     map<int,int>::iterator it;
     cin>>a>>b;
     for(i=0;i<b;i++)
     {
         cin>>c>>d;
         if(c==1)
         {v.push_back(make_pair(c,d));}
         else if(d==a)
         {
             v1.push_back(make_pair(c,d));
         }
     }
     for(i=0;i<v.size();i++)
     {
          m[v[i].second]++;
     }
         for(i=0;i<v1.size();i++)
     {
         m[v1[i].first]++;
     }
     int flag=0;
     e=0;
     f=0;

     for(it=m.begin();it!=m.end();it++)
     {
         if((*it).second>1)
         {
             flag=1;
             break;
         }
     }
     if(flag==0)
     {
         cout<<"IMPOSSIBLE"<<endl;
     }
     else{
        cout<<"POSSIBLE"<<endl;
     }
     m.clear();

 }


Measured memory_bytes: 11220
#include <stdio.h>
#include <string.h>

int main(void) {
  char s[10001], t[4];
  int cj, ci, slen, i, j;
  while (scanf("%s", s) != EOF) {
    cj = 0;
    ci = 0;
    slen = strlen(s);

    for (i = 0; i < slen - 2; i++) {
      for (j = i; j < i + 3; j++)
	t[j - i] = s[j];
      t[3] = '\0';
      if (strcmp(t, "JOI") == 0) cj++;
      if (strcmp(t, "IOI") == 0) ci++;
    }
    printf("%d\n", cj);
    printf("%d\n", ci);
  }
  return 0;
}

Measured memory_bytes: 552
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define WM 1e5
using namespace std;

int main() {
    int N, W;
    cin >> N >> W;

    vector<vector<long long>> dp(N + 1, vector<long long>(WM+1, 1e9 + 1));
    dp[0][0] = 0;

    for (int n = 1; n <= N; n++) {
        pair<int, int> knap;
        cin >> knap.first >> knap.second;

        dp[n][knap.second] = knap.first;
        for (int v = 0; v <= WM; v++) {
            dp[n][v] = min(dp[n][v], dp[n - 1][v]);
            if (v - knap.second >= 0) {
                dp[n][v] = min(dp[n][v], dp[n - 1][v - knap.second] + knap.first);
            }
        }

    }
    long long ans;
    for (int v = WM; v >= 0; v--) {
        if (dp[N][v] <= W) {
            ans = v;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 80256
import Control.Applicative

main = do
    n <- readLn :: IO Int
    xs <- map read . words <$> getLine
    print $ solve 0 xs

solve :: Int -> [Int] -> Int
solve _ [] = 0
solve 0 (x:xs) = solve x xs
solve x1 (x2:xs)
    | x1 == x2 = 1 + (solve 0 xs)
    | otherwise = solve x2 xs


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

int us[10];

bool check(int now) {
  	if (now == 0) {
     	return !us[0]; 
    }
	while (now) {
     	int cur = now % 10;
      	now /= 10;
      	if (us[cur])
          	return false;
    }
  	return true;
}

signed main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(k);
  for (int i = 0; i < k; ++i)
    cin >> a[i];
  for (int i = 0; i < k; ++i)
    us[a[i]] = 1;
  for (int i = n; i < 100000; ++i) {
  	 if (check(i)) {
      	cout << i << endl;
       	return 0;
     }
  }
  return 0;
}

Measured memory_bytes: 3612
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		Queue<Sell> sellQueue = new ArrayDeque<>();
		boolean[][] fldFlg = new boolean[H][W];
		for (int x = 0; x < H; x++) {
			String[] temp = sc.next().split("");
			for (int y = 0; y < temp.length; y++) {
				if (temp[y].equals("#")) {
					sellQueue.add(new Sell(x, y, 0));
					fldFlg[x][y] = true;
				}
			}
		}
		sc.close();
		
		int[] dx = { 0, 0, 1, -1 };
		int[] dy = { 1, -1, 0, 0 };
		
		int count = 0;
		while (sellQueue.size() != 0) {
			Sell sell = sellQueue.poll();
			for (int dxy_index = 0; dxy_index < dx.length; dxy_index++) {
				int x = sell.x + dx[dxy_index];
				int y = sell.y + dy[dxy_index];
				if(x<0|| x >=H || y < 0 || y >= W)continue;
				
				if (fldFlg[x][y])continue;
				
				int countPlus = sell.count + 1;
				sellQueue.add(new Sell(x, y, countPlus));
				fldFlg[x][y] = true;
			}
			
			if(sellQueue.size() == 0)
				count = sell.count;
		}
		System.out.println(count);
	}
	
	static class Sell {
		int x;
		int y;
		int count;

		Sell(int x_, int y_,int count_) {
			x = x_;
			y = y_;
			count = count_;
		}
	}
}

Measured memory_bytes: 90236
import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	private static int n=sc.nextInt();
	private static int m=sc.nextInt();
	private static int l=sc.nextInt();
	private static int[][] a=new int[n][m];
	private static int[][] b=new int[m][l];
	private static long[][] c=new long[n][l];
	public static void main(String[] args){
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				a[i][j]=sc.nextInt();
			}
		}
		for(int i=0;i<m;i++){
			for(int j=0;j<l;j++){
				b[i][j]=sc.nextInt();
			}
		}
		multiply();
		for(int i=0;i<n;i++){
			for(int k=0;k<l-1;k++){
				System.out.print(c[i][k]+" ");
			}
			System.out.println(c[i][l-1]);
		}
	}
	private static void multiply(){
		for(int i=0;i<n;i++){
			for(int k=0;k<l;k++){
				for(int j=0;j<m;j++){
					c[i][k]+=a[i][j]*b[j][k];
				}
			}
		}
	}
}

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

int main() {

  int H, N;
  cin >> H >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int S = 0;
  for (int i = 0; i < N; i++) {
    S += A.at(i);
  }
  if (S >= H) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N/1000;
  b = (N-a*1000)/100;
  c = (N-a*1000-b*100)/10;
  d = N-a*1000-b*100-c*10;
  
  if ((a == b && b == c) || (b == c && c == d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 3592
def s():
 n=int(input())+1
 e=[input().split()for _  in[0]*~-n]
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for l in range(2,n):
  for i in range(1,n-l+1):
   j=i+l-1;m[i][j]=1e6
   for k in range(i,j):m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
 print(m[1][n-1])
if'__main__'==__name__:s()


Measured memory_bytes: 5728
input1 = list(map(int, (input().split())))

a = input1[0]
b = input1[1]
m = input1[2]

alist = list(map(int, (input().split())))
blist = list(map(int, (input().split())))

mlist = [[]] * m
# print(mlist)

for i in range(m):
    mlist[i] = list(map(int, (input().split())))


amin = min(alist)
bmin = min(blist)

res = amin + bmin

for e in mlist:
    x = e[0] - 1
    y = e[1] - 1
    c = e[2]
    if alist[x] + blist[y] - c < res:
        res = alist[x] + blist[y] - c

print(res)


Measured memory_bytes: 38572
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair
#define sz size
#define inf 1e9+5
 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n;
    ll q;
    cin>>n>>q;
    if(n-2*q>0)
        cout<<n-2*q;
    else
        cout<<"0";


    

    return 0;  
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;

int main() {
    cin >> n;

    if (n < 1200) {
    	std::cout << "ABC" << '\n';
    } else {
    	std::cout << "ARC" << '\n';
    }

    return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// }}} 1

int main() {

    int a,b,h;
    Scd3(a,b,h);

    printf("%d\n", (a+b)*h/2 );

    return 0;
}



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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    ll a[n + 1];
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    vector <ll> hz(n + 1, 0);
    hz[1] = 0;
    hz[2] = abs(a[2] - a[1]);
    for (int i = 3; i <= n; i++)
    {
        hz[i] = min(hz[i - 2] + abs(a[i - 2] - a[i]), hz[i - 1] + abs(a[i - 1] - a[i ]));
    }

    cout << hz[n];
}


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

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

    //good luck kittu!
    int n;
    string s, t, x = "";
    cin>>n>>s>>t;
    //int n = s.size();
    for(int i = 0; i<n; i++){
        x.push_back(s[i]);
        x.push_back(t[i]);
    }
    cout<<x<<"\n";
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]
X = [[0] * N for _ in range(N)]
for i in range(M):
  X[ab[i][0]-1][ab[i][1]-1] = 1
  X[ab[i][1]-1][ab[i][0]-1] = 1

def dfs(u):
  c = 0
  if len(u) == N:
    return 1
  for i in range(len(X[u[-1]])):
    if X[u[-1]][i] == 1 and i not in u:
      c += dfs(u + [i])
  return c

print(dfs([0]))


Measured memory_bytes: 3064
#include <string>
#include <iostream>
#include <cstdlib>
#define INF (1e9)

int main(void)
{
  int n, count = 0, ans = INF;
  scanf("%d", &n);
  std::string s;
  std::cin >> s;

  for (int i = 1; i < n; i++) {
    if (s[i] == 'E') {
      count++;
    }
  }

  ans = count;
  if (s[0] == 'W') {
    count++;
  }

  for (int i = 1; i < n; i++) {
    if (s[i] == 'E') {
      count--;
    }else if (s[i] == 'W') {
      count++;
    }
    if (ans > count) {
      ans = count;
    }
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 900
from itertools import product
N, M, X = map(int, input().split())

val0 = [0]*(M+1)
ans = 10**9
val = []
for _ in range(N):
    val.append(list(map(int, input().split())))

for i in range(2**N):
    ls = ["+"]*N
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = "-"
    for m, n in enumerate(ls):
        if n == '+':
            val0 = [x + y for (x, y) in zip(val0, val[m])]
    if ans > val0[0]:
        for k, l in enumerate(val0[1:]):
            if l < X:
                break
            elif k == len(val0[1:])-1:
                ans = val0[0]
    val0 = [0]*(M+1)
        
if ans == 10**9:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9272
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C
 */
#include <iostream>
#include <string>
#include <list>

using namespace std;

int
main()
{
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n; cin.ignore();

    list<int> lst;
    for (int i = 0; i < n; i++) {
        string cmd;
        getline(cin, cmd);

        switch (cmd[6]) {
          case 'F':
            lst.pop_front();
            break;
          case 'L':
            lst.pop_back();
            break;
          default:
            int k = 0;
            int len = cmd.length() - 7;
            switch (len) {
                case 10: k += (cmd[ len - 3 ] - '0') * 1000000000;
                case 9: k += (cmd[ len - 2] -  '0') * 100000000;
                case 8: k += (cmd[ len - 1] -  '0') * 10000000;
                case 7: k += (cmd[len] -       '0') * 1000000;
                case 6: k += (cmd[ len + 1] -  '0') * 100000;
                case 5: k += (cmd[ len + 2] -  '0') * 10000;
                case 4: k += (cmd[ len + 3] -  '0') * 1000;
                case 3: k += (cmd[ len + 4] -  '0') * 100;
                case 2: k += (cmd[ len + 5] -  '0') * 10;
                case 1: k += (cmd[ len + 6] -  '0');
            }
            if(cmd[0] == 'i') {
                lst.push_front(k);
            } else {
                for (auto it = lst.cbegin(); it != lst.cend(); it++) {
                    if (*it == k) {
                        lst.erase(it);
                        break;
                    }
                }
            }
        }
    }
    for (auto it = lst.begin(); it != lst.end(); it++) {
        if (it != lst.begin()) { cout << ' '; }
        cout << *it;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 34368
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
} point;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}


template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	ll K, N = 50;
	cin >> K; 

	vll ans(N);
	for (int i = 0; i < N; i++) ans[i] = i + (K / N);

	K %= N;

	for (int i = 0; i < K; i++)
		for (int idx = 0; idx < N; idx++) {
			if (idx == i) ans[idx] += N;
			else ans[idx]--;
		}

	cout << N << endl;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
#define vec(n) vector<int> a(n)
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<endl
#define AA(i) cout<<i<<endl
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main() {
  int N,M,X; cin>>N>>M>>X;
  int ca[N][M+1];
  int i,j;
  rep(i,N)rep(j,M+1) cin>>ca[i][j];
  int ans=INF;

  for(int bit=0; bit < (1<<N); bit++){
    vector<int> S(0);
    rep(i,N) if(bit & (1<<i)) S.push_back(i);
    vector<int> t(M+1,0);
    rep(i,S.size()) rep(j,M+1) t[j]+=ca[S[i]][j];
    for(int i=1;i<M+1;i++){
      if(t[i]<X)break;
      if(i==M&&t[i]>=X) ans=min(t[0],ans);
    }
  }
  if(ans==INF) AA(-1);
  else AA(ans);
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
long long roomcontent[4][3][10] = {0};
int main() {
    long long N;
    long long b, f, r, v;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> b >> f >> r >> v;
        roomcontent[b - 1][f - 1][r - 1] += v;
    }

    for (int k = 0; k < 4; k++) {
        for (int j = 0; j < 3; j++) {
            for (int i = 0; i < 10; i++) {
                cout << ' ' << roomcontent[k][j][i];
            }
            cout << '\n';
        }
        if (!(k == 3)) {
            for (int l = 0; l < 20; l++) {
                cout << '#';
            }
            cout << '\n';
        }
    }
}


Measured memory_bytes: 3108
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
int n;
string s;
int ans;
int a1[500000];
int a2[500000];

int main(){
  cin >> n;
  cin >> s;
  if (s[0]=='W') a1[0]=1;
  for(int i=1;i<n;i++){
    if(s[i]=='W') a1[i] =  a1[i-1] +1;
    else a1[i] = a1[i-1];
  }
  if (s[n-1]=='E') a2[n-1]=1;
  for(int i=n-2;i>=0;i--){
    a2[i] = a2[i+1];
    if(s[i]=='E') a2[i]++;
  }
  ans = min(a1[n-2],a2[1]);
  for(int i=1;i<=n-2;i++){
    ans = min(a1[i-1]+a2[i+1],ans);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int rows,columns;
    cin>>rows>>columns;
    char s[rows][columns];
    
    for(int i=0;i<rows;i++)
    {
        for(int j=0;j<columns;j++)
            cin>>s[i][j];
        
    }

    for(int i=0;i<columns+2;i++)
    cout<<"#";
    cout<<endl;
    for(int i=0;i<rows;i++)
    {
        cout<<"#";
        for(int j=0;j<columns;j++)
        cout<<s[i][j];
        cout<<"#"<<endl;
    }

    for(int i=0;i<columns+2;i++)
    cout<<"#";
    cout<<endl;

	return 0;
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

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

	while (true) {
	    int N , M;
	    cin >> N;
	    if (N == 0) {
	        break;
	    }
	    vector<pair<int, int>> m;
	    FOR(i, 0, N) {
	        int h, r;
	        cin >> h >> r;
	        m.emplace_back(make_pair(h, r));
	    }
	    cin >> M;
        FOR(i, 0, M) {
            int h, r;
            cin >> h >> r;
            m.emplace_back(make_pair(h, r));
        }

        vector<vector<int>> dp(1001, vector<int>(1001, -1));
        dp[0][0] = 0;

        FOR(j, 0, dp.size()) {
            FOR(k, 0, dp[0].size()) {
                if (dp[j][k] == -1) {
                    continue;
                }
                FOR(i, 0, m.size()) {
                    int h = m[i].first;
                    int r = m[i].second;

                    if (j < h and k < r) {
                        dp[h][r] = max(dp[h][r], dp[j][k] + 1);
                    }
                }
            }
        }

        int ans = 0;
        FOR(j, 0, dp.size()) {
            FOR(k, 0, dp[0].size()) {
                ans = max(ans, dp[j][k]);
            }
        }

        print(ans);
	}

	return 0;
}


Measured memory_bytes: 6800
#include<stdio.h>

int main(void){
    int n, tmp, minj;
    scanf("%d", &n);
    int a[n];
    for(int i=0 ; i<n ; i++) scanf("%d",&a[i]);
    int c=0;
    for(int i=0 ; i<n-1 ; i++){
        minj=i;
        for(int j=i ; j<n ; j++)
            if(a[j]<a[minj]) minj=j;
        tmp=a[i], a[i]=a[minj] , a[minj]=tmp;
        if(i!=minj) c++;
    }
    for(int i=0 ; i<n ; i++){
        if(i==n-1)  printf("%d\n", a[i]);
        else        printf("%d ", a[i]);
    }
    printf("%d\n", c);
    return 0;
}


Measured memory_bytes: 2044
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		//int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();

		Integer[] cards = new Integer[3];

		for(int i=0;i<3;i++) {
			cards[i]=sc.nextInt();
		}
		Arrays.sort(cards,Collections.reverseOrder());
		String tmp = cards[0].toString() + cards[1].toString();
		Integer ans = Integer.valueOf(tmp) + cards[2];
		System.out.println(ans);

	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    int n , x;
    cin>>n>>x;
    
    n = 2*n - 1;
    if(x == n || x == 1) {
        cout<<"No\n";
        return 0;
    }
    if( n == 3 && x== 2 ) {
        
        cout<<"Yes\n";
        for(int i =1 ; i <=3 ; i++ ) cout<<i<<'\n';
        return 0;
    }
    vector<int>taken(n+1);
    
    deque<int>dq;
    
    dq.push_back(x);
    dq.push_back(x+1);
    dq.push_front(x-1);
    
    taken[x] = taken[x+1] = taken[x-1] = 1;
    
    int turn = 0;
    
    if(x == n-1) {
        dq.push_back(x-2);
        taken[x-2] =1;
    }
    else {
        dq.push_front(x+2);
        taken[x+2] = 1;
        turn = 1;
    }

    for(int i = 1 ; i<=n ; i++  ) {
        if(taken[i]) continue;
        taken[i] = 1;
        
        if(turn) dq.push_back(i);
        else dq.push_front(i);
        
        turn ^=1;
    }
    
    
    
    cout<<"Yes\n";
    for(auto x : dq) cout<<x<<'\n';
    
    
    
}

Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>


#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;

vector<int> a;

ll solve(){
}

int main(void){
    int n;
    cin >> n;
    a.resize(n);
    for(auto &b: a) cin >> b;
    vector<int> b = a;
    sort(b.begin(), b.end());
    rep(i,n){
        if(a[i] <= b[n/2-1]){
            cout << b[n/2] << endl;
        }else{
            cout << b[n/2-1] << endl;
        }
    }


    return 0;
}



Measured memory_bytes: 3712
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int n,m;
vector<int> v[2*maxn];
int ans[2*maxn];
int d[2*maxn];
bool vis[2*maxn];
void bfs(int node)
{
    queue<int> q;
    q.push(node);
    vis[node]=true;
    while(!q.empty())
    {
        int temp=q.front();
        q.pop();
        for(auto i: v[temp])
        {
            if(!vis[i])
            {
                d[i]=d[temp]+1;
                vis[i]=true;
                ans[i]=temp;
                q.push(i);
            }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x=0,y=0;
    cin>>n>>m;
    for(int i=0;i<m;++i)
    {
        cin>>x>>y;
        --x;--y;
        v[x].pb(y);
        v[y].pb(x);
    }
    bfs(0);
    for(int i=0;i<n;++i)
    {
        if(!vis[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=1;i<n;++i)
    {
        cout<<ans[i]+1<<endl;
    }
}

Measured memory_bytes: 13432
/*
 * Code be weshen zyk :'(
 */
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define F first
#define S second

using ll = long long;
using ii = pair<int, int>;
using db = long double;

#ifdef ONLINE_JUDGE
#define cerr if(0)cerr
#endif

template<class C> void amin(C &a4, C b4) {
	a4 = min(a4, b4);
}
template<class C> void amax(C &a4, C b4) {
	a4 = max(a4, b4);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
	os << "[";
	for (auto vv : V)
		os << vv << ",";
	return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
	return os << "(" << P.first << "," << P.second << ")";
}

const int N = 1e5 + 5;
int dp[N];
vector<int> adj[N];
int solve(int u) {
	int &ret = dp[u];
	if (~ret)
		return ret;
	ret = 0;
	for (auto v : adj[u])
		ret = max(ret, 1 + solve(v));
	return ret;
}
int main() {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int n, m;
	cin >> n >> m;
	for (int i = 0, u, v; i < m; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
	}
	memset(dp, -1, sizeof dp);
	for (int i = 1; i <= n; i++) {
		solve(i);
	}

	cout << *max_element(dp + 1, dp + n + 1) << '\n';
	return 0;
}


Measured memory_bytes: 7296
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;

int main() {
        int n, m;
        scanf("%d%d", &n, &m);
        priority_queue<pair<pair<int, pair<int, int>>, bool>> que;
        for (int i = 0; i < m; i ++) {
                int a, b, c;
                scanf("%d%d%d", &a, &b, &c);
                que.push({{-c, {a, b}}, false}); //only once
                que.push({{-(c + 1), {a, (a + 1) % n}}, true}); 
                que.push({{-(c + 2), {b, (b + 1) % n}}, true});
        }
        vector<int> par(n);
        for (int i = 0; i < n; i ++) par[i] = i;
        function<int (int)> root = [&](int x) { return x == par[x] ? x : par[x] = root(par[x]); };
        long long ans = 0;
        while (!que.empty()) {
                auto e = que.top();
                que.pop();
                if (root(e.first.second.first) != root(e.first.second.second)) {
                        par[root(e.first.second.first)] = root(e.first.second.second);
                        ans += -e.first.first;
                        if (e.second) que.push({{-(-e.first.first + 2), {(e.first.second.first + 1) % n, (e.first.second.second + 1) % n}}, true});
                }
        }
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 18664
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < S.size()/2; i++){
    if (!(S.at(i) == S.at(S.size()-1-i))){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

struct UnionFind {
  vector<int> v;
  UnionFind(int n): v(n) {
    rep(i, n) v[i] = i;
  }
  int find(int x) {
    if(v[x] == x) return x;
    return v[x] = find(v[x]);
  }
  void unite(int x, int y) {
    v[find(x)] = find(y);
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  vector<int> x(m), y(m);
  rep(i, m) cin >> x[i] >> y[i];

  UnionFind uf(n);
  rep(i, m) uf.unite(x[i]-1, y[i]-1);

  int cnt = 0;
  rep(i, n) cnt += uf.same(p[i]-1, i);
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using vi = vector<int>;
using vii = vector<vi>;

int main() {
	int n; cin >> n;
	vi a(n + 2), b(n + 1);
	rep(i, n + 1)	cin >> a[i+1];
	rep(i, n) cin >> b[i+1];

	//rep(i, n + 2)	cout << a[i];
	//rep(i, n + 1) cout << b[i];

	long long int ans = 0;

	for(int i=1;i<=n+1;i++){
		if (a[i] >= b[i - 1]) {
			a[i] -= b[i - 1];
			ans += b[i - 1];
		}
		else {
			ans += a[i];
			b[i - 1] -= a[i];
			a[i] = 0;
		}

		if (i == n + 1) break;

		if (a[i] >= b[i]) {
			ans += b[i];
			b[i] = 0;
		}
		else {
			ans += a[i];
			b[i] -= a[i];
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 1024
N = int(input())
S = input()
alpha = ['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']
print("".join([alpha[(alpha.index(S[i])+N)%26] for i in range(len(S))]))

Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
  long N, M; // 店舗数, 必要な本数
  cin >> N >> M;

  vector<tuple<long, long>> shops;
  long a, b;
  for( int i = 0; i < N; i++ ){
    cin >> a >> b;
    shops.push_back(make_tuple(a, b)); // (価格, 本数)
  }
  
  sort(shops.begin(), shops.end(), 
       //[](tuple<int, int> const &x, tuple<int, int> const &y) 
       [](auto &x, auto &y) 
       { return get<0>(x) < get<0>(y); } // 降順
      );

  //for( auto it = shops.begin(); it < shops.end(); it++ ){
    //cout << get<0>(*it) << " " << get<1>(*it) << endl;
  //}
  
  long sum = 0;
  long n;
  for( auto it = shops.begin(); it < shops.end(); it++ ){
    n = min(M, get<1>(*it));
    sum += get<0>(*it) * n;
    M -= n;
    if( M <= 0 ){ cout << sum; break; }
  }
  
  return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    int cnt=0;
    vector<int> vec;
    for(int n=1; n<=N; n++) {
        int p;
        cin >> p;
        
        if(cnt) {
            if(p==n) {
                cnt++;
            } else {
                vec.push_back(cnt);
                cnt=0;
            }
        } else {
            if(p==n) {
                cnt++;
            }
        }
    }
    if(cnt!=0) {
        vec.push_back(cnt);
    }
    
    int ans=0;
    for(int i=0; i<vec.size(); i++) {
        ans += vec[i]/2;
        ans += vec[i]%2;
    }
    
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int inf = 1e17;
const int mod = 1000000007;
typedef pair<int, int> P;
typedef pair<int, P> PP;
int a[200006];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];

	rep(i, n)a[i] -= i + 1;
	sort(a, a + n);
	int sum = 0;
	rep(i, n)sum += abs(a[i] - a[n / 2]);
	cout << sum << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int H,W;
    char s[52][52];
    int sai[52][52];
    int C=0;
    long long int K[52][52]={};
    cin >> H >> W;
    REP(i,H){
        REP(j,W){
            cin >> s[i][j];
            sai[i][j]=114514;
            if(s[i][j]=='#'){
                C++;
            }
        }
    }
    sai[0][0]=0;
    REP(i,H){
        if(i==0){K[0][0]=1;continue;}
        if(s[i][0]=='.' && K[i-1][0]==1){
            K[i][0]=1;
        }
    }
    REP(i,W){
        if(i==0){K[0][0]=1;continue;}
        if(s[0][i]=='.' && K[0][i-1]==1){
            K[0][i]=1;
        }
    }
    
    REP(k,1300){
    
    REP(i,H){
        REP(j,W){
            if(i!=0){
            if(s[i][j]=='.' && s[i-1][j]=='.' && K[i-1][j]==1){K[i][j]=1;sai[i][j]=min(sai[i][j],sai[i-1][j]+1);}
            }
            if(j!=0){
            if(s[i][j]=='.' &&s[i][j-1]=='.' && K[i][j-1]==1){K[i][j]=1;sai[i][j]=min(sai[i][j],sai[i][j-1]+1);}
            }
            if(i!=H-1){
            if(s[i][j]=='.' &&s[i+1][j]=='.' && K[i+1][j]==1){K[i][j]=1;sai[i][j]=min(sai[i][j],sai[i+1][j]+1);}
            }
            if(j!=W-1){
            if(s[i][j]=='.' &&s[i][j+1]=='.' && K[i][j+1]==1){K[i][j]=1;sai[i][j]=min(sai[i][j],sai[i][j+1]+1);}
            }
        }
    }
    
    }
    //REP(i,H){REP(j,W){cout << K[i][j] << " ";}cout << endl;}
    //cout << endl;
    //REP(i,H){REP(j,W){cout << sai[i][j] << " ";}cout << endl;}
    //cout << endl << sai[H-1][W-1] << endl;
    
    if(K[H-1][W-1]==0){
        cout << "-1" << endl;
    }else{
        cout << H*W-sai[H-1][W-1]-C-1 << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,k; scanf("%d%d",&n,&k);
  int sum=0,y0,y,max=0; scanf("%d",&y); y0=y;
  for(int i=0; i<k; i++){
    int x; scanf("%d",&x);
    sum+=(x-y);
    if(x-y>max) max=x-y;
    y=x;
   //printf("%d %d\n",sum,max);
  } 
  sum+=(y0+n-y);
  if(y0-y+n>max) max=y0-y+n;
  printf("%d\n",sum-max);
  return 0;
}

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

int main() {
    int n,i,j,count,c[100];
    count=0;
    cin >> n;
    for (i=0; i<n; i++) {
        cin >> c[i];
    }
    for (i=n-1; i>=1; i--) {
        for (j=0; j<i; j++) {
            if (c[j] > c[j + 1]) {
                c[j] += c[j + 1];
                c[j + 1] = c[j] - c[j + 1];
                c[j] = c[j] - c[j + 1];
                count++;
            }
        }
    }
    for (i=0; i<n; i++) {
        if (i < n-1) { cout << c[i] << " ";}
            else {
            cout << c[i] << endl;
        }
    }
    cout << count << endl;
}



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

int main()
{
  int n;
  cin >> n;
  int m[6] = { 0, 0, 0, 0, 0, 0, };

  for (int i=0; i<n; i++)
  {
    double height;
    cin >> height;
    if ( height < 165.0 )
    {
      m[0]++;
    }
    else if ( height < 170.0 )
    {
      m[1]++;
    }
    else if ( height < 175.0 )
    {
      m[2]++;
    }
    else if ( height < 180.0 )
    {
      m[3]++;
    }
    else if ( height < 185.0 )
    {
      m[4]++;
    }
    else
    {
      m[5]++;
    }
  }

  for (int i=0; i<6; i++)
  {
    cout << i+1 << ':' << flush;
    for (int j=0; j<m[i]; j++)
    {
      cout << '*' << flush;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1232
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define inf 2147483647
#define LL long long
using namespace std;
int n,m,a[100],b[100],ans = 1,x[100],y[100],z[100],cnt;
int main()
{
	scanf("%d", &n);
	while(n>=2)
	{
		if(n&1)
		{
			a[++m] = ans;
			b[m] = --n;
		}
		//if(n)
		//{
			x[++cnt] = ans;
			y[cnt] = ++ans;
			z[cnt] = n >>= 1;
			x[++cnt] = ans - 1;
			y[cnt] = ans;
			z[cnt] = 0;
		//}
			
	}
	printf("%d %d\n",ans,2*ans+m-2);
	for(int i=1;i<=m;++i)printf("%d %d %d\n",a[i],ans,b[i]);
	for(int i=1;i<=cnt;++i)printf("%d %d %d\n",x[i],y[i],z[i]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    vi a(m, 0);
    REP(i, n)
    {
        int k, v;
        cin >> k;
        REP(j, k)
        {
            cin >> v;
            a[v - 1]++;
        }
    }

    int ans = 0;
    REP(i, m)
    {
        if(a[i] == n)
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

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

const int N = 300 + 10;
int MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, dp[N], DP[N][N], nCr[N][N], K;
int add(int a, int b){
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

int minu(int a, int b){
	a -= b;
	if (a < MOD) a += MOD;
	return a;
}

int mul(int a, int b){
	return a * 1ll * b % MOD;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> K >> MOD;
	nCr[0][0] = 1;
	for (int i = 0; i < N; i++) for (int j = 0; j <= i; j++) nCr[i][j] = (j == 0?1:add(nCr[i - 1][j], nCr[i - 1][j - 1]));
	DP[0][K + 1] = 1;
//	cout << nCr[6][3] << '\n';
	for (int k = K; k >= 1; k--){
		for (int i = 0; i <= n; i++) DP[i][k] = DP[i][k + 1];
		memset(dp, 0, sizeof dp);
		dp[0] = 1;
		dp[1] = 1;
		for(int i = 2; i <= n; i++){
			for (int j = 1; j <= i; j++){
				dp[i] = add(dp[i], mul(mul(dp[i - j], DP[j - 1][k + 1]), nCr[i - 1][j - 1]));  
			}
//			cout << i << ' ' << k << ' ' << dp[i] << '\n';
		}
		for (int i = 1; i <= n; i++){
			DP[i][k] = add(DP[i][k], dp[i]);
			for (int j = 2; j <= i; j++){
				DP[i][k] = add(DP[i][k], mul(mul(DP[j - 1][k + 1], nCr[i][j - 1]), dp[i - j + 1]));
			}
		}
	}
	cout << DP[n][1];










	return 0;
}


Measured memory_bytes: 4272
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        // Your code here!
        
        int n = int.Parse(Console.ReadLine());
        var v = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var c = Console.ReadLine().Split().Select(y => int.Parse(y)).ToArray();
        int sum = 0;
        
        for(int i=0;i!=n;i++){
            if(v[i]>c[i]){
                sum += v[i]-c[i];
            }
        }
        
        Console.WriteLine(sum);
        
    }
}


Measured memory_bytes: 13268
n,m=map(int,input().split())
ken=[[] for i in range(n)]
for i in range(m):
    p,y=map(int,input().split())
    ken[p-1].append([i,y])
for i in range(n):
    ken[i].sort(key=lambda x:x[1])
ken0=[]
for i in range(n):
    for j in range(len(ken[i])):
        mae=str(i+1)
        ato=str(j+1)
        while len(mae)<6:
            mae='0'+mae
        while len(ato)<6:
            ato='0'+ato
        ken0.append([ken[i][j][0],mae+ato])
ken0.sort(key=lambda x:x[0])
for i in ken0:
    print(i[1])

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

vector<ll> primes;
void eratos() {
	vector<bool> isPrime(2e5, true);
	for(ll i=2;i<=2e5;i++) {
		if(isPrime[i]) {
			for(int j=2*i;j<=2e5;j+=i)
				isPrime[j] = false;
		}
	}
	for(ll i=2;i<=2e5;i++)
		if(isPrime[i])
			primes.push_back(i);
}

int main(){
	ll X;
	cin >> X;
	eratos();
	cout << *lower_bound(primes.begin(), primes.end(), X) << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n;
    cin >> n;
    vector<string> vec(n);

    for(int i = 0; i < n; i++){
        cin >> vec[i];
    }

    LL count = 0;

    for(int i = 0; i < n; i++){
        bool frag = true;
        for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                if(vec[j][(k+i)%n] != vec[k][(i+j)%n]){
                    frag = false;
                }
            }
        }
        if(frag){
            count += n;
        }
    }

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 384
#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<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}


int main() {
  int n,k;
  cin >> n >>k;
  vector<int> a(k);
  rep(i,k) cin >> a[i];
  int ans=0;
  rep(i,k) ans+=a[i];
  if(ans>n) pt(-1);
  else pt(n-ans);
  return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
map<string,int> num;
string s[200010];
int n,mx=-1;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		cin>>s[i];
		num[s[i]]++;
		mx=max(mx,num[s[i]]);
	}
	sort(s+1,s+n+1);
	for(int i=1;i<=n;++i)
		if(mx==num[s[i]]&&s[i]!=s[i-1])
			cout<<s[i]<<endl;
	return 0;
}

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

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    N--;
    ll ans = (N + K - 2)/(K - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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



using namespace std;

bool is_integer( float x ){
    return floor(x)==x;
}


int main() {

    string s;
    int maxPoint = 0;
    int minPoint = 0;

    cin >> s;
    int n = s.length();

    rep(i,n){
        if(s[i] == 'A'){
            minPoint = i;
            break;
        }
    }
    rep(i,n){
        if(s[n-1-i] == 'Z'){
            maxPoint = n-1-i;
            break;
        }
    }
    cout << maxPoint - minPoint + 1;

    return 0;
}











Measured memory_bytes: 3688