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


typedef struct{
  int parent;
  int left;
  int right;
  int id;
}Node;

Node T[MAX];

int main(){
  int l,k,n,i,j,count=0;
  int flag=0;
 
  int id;


  for(i=0;i<MAX;i++){
    T[i].parent=-1;
    T[i].left=MAX;
    T[i].right=MAX;
    T[i].id=0;
  }

  scanf("%d",&n);
 

  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d",&k);
    T[id].id=id;
    if(k!=0){
      scanf("%d",&T[id].left);
      l=T[id].left;
      T[l].parent=id;
      for(j=0;j<k-1;j++){
	scanf("%d",&T[l].right);
	l=T[l].right;
	T[l].parent=id;

      } 
    }
  }



  for(i=0;i<n;i++){
    printf("node %d:",T[i].id);
    printf(" parent = %d,",T[i].parent);

    j=i;
    while(T[j].parent!=-1){
      j=T[j].parent;
      count++;
    }
    printf(" depth = %d,",count);
    count=0;

    if(T[i].parent==-1)printf(" root,");
    else if(T[i].left!=MAX)printf(" internal node,");
    else printf(" leaf,");


    j=T[i].left;
    printf(" [");


    while(j!=MAX){
      if(flag==0)printf("%d",j);
      if(flag==1)printf("% d",j);
      j=T[j].right;
      if(j!=MAX)printf(",");
      flag=1;
    }
    printf("]");



    printf("\n");
      flag=0;
  }


  


  return 0;
}

Measured memory_bytes: 2164
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int H, N;
  cin >> H >> N;
  vector<pair<int, int>> pi(N);
  for (int i = 0; i < N; i++) {
    cin >> pi[i].first >> pi[i].second;
  }
  sort(pi.begin(), pi.end(), [](const auto& x, const auto& y) {
    if (x.second == y.second)
      return x.first < y.first;
    else
      return x.second < y.second;
  });
  debug(pi);
  vector<int> dp(202020, (int)1e9);
  dp[0] = 0;
  int idx = 1;
  for (int i = 0; i < N; i++) {
    for (int j = idx; j < pi[i].first; j++) {
      dp[j] = pi[i].second;
      idx++;
    }
  }
  // for (int i = 0; i < N; i++) {
  //   debug(dp[i]);
  // }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < H + 1; j++) {
      dp[j + pi[i].first] = min(dp[j + pi[i].first], dp[j] + pi[i].second);
    }
  }
  // for (int i = 0; i < H + 1; i++) {
  //   debug(dp[i]);
  // }
  cout << dp[H] << endl;
  return 0;
}

Measured memory_bytes: 4052
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()

    val actions = (1..n).map { readLine()!!.split(" ").map { it.toInt() }.toTypedArray() }.toTypedArray()

    val dp = Array(n) { Array(3) { 0 } }

    dp[0][0] = actions[0][0]
    dp[0][1] = actions[0][1]
    dp[0][2] = actions[0][2]
    for (i in 1 until n) {
        for (j in 0 until 3) {
            dp[i][j] = Math.max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + actions[i][j]
        }
    }

    println(listOf(dp[n-1][0], dp[n-1][1], dp[n-1][2]).max())
}

Measured memory_bytes: 83304
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

int d[105][105];
int edge[105][105];

int main(){
    cin.tie(0);

    int N, M; cin >> N >> M;
    int INF = 1000000000;
    fill(d[0], d[105], INF);
    fill(edge[0], edge[105], INF);
    for (int i = 0; i < M; i++){
        int a, b, c; cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
        edge[a][b] = c;
        edge[b][a] = c;
    }

    for (int i = 1; i <= N; i++){
        for (int j = 1; j <= N; j++){
            for (int k = 1; k <= N; k++){
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }

    int ans = 0;
    for (int i = 1; i <= N; i++){
        for (int j = 1; j <= N; j++){
            if (edge[i][j] != INF){
                if (edge[i][j] > d[i][j]) ans++;
            }
        }
    }
    cout << ans/2 << endl;
}


Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int x, n, p;
  vector<int> v;
  cin >> x >> n;
  rep(i,n)
  {
    cin >> p;
    v.push_back(p);
  }
  sort(v.begin(), v.end());
  if (binary_search(v.begin(), v.end(), x)) {
    int div = 1;
    while (true) {
      if (!binary_search(v.begin(), v.end(), x - div)) {
        cout << x - div;
        break;
      } else if (!binary_search(v.begin(), v.end(), x + div)) {
        cout << x + div;
        break;
      } else {
        div++;
      }
    }
  } else {
    cout << x;
  }
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

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

        char array[] = new char[3];
        String s = scan.next();
        int counter = 0;
        
        array[0] = s.charAt(0);
        array[1] = s.charAt(1);
        array[2] = s.charAt(2);

        for(int i =0; i < array.length; i++) {
        	if(array[i] == '1') {
        		counter += 1;
        	}
        }
        
        System.out.println(counter);
        
	}

}

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

int main(void)
{
        int i,num, count;
        bool l, r;
        string lu = "lu", ru = "ru", ld = "ld", rd = "rd";
        string input;

        while(1){
                count = 0;
                l = false, r = false;
                cin >> num;
                if(num == 0){ 
                        break;
                }   

                for(i = 0; i < num; i++){
                        cin >> input;
                        if(input == lu || input == ld){
                                l = !l; 
                        }else{
                                r = !r; 
                        }   

                        if(l && r){ 
                                count += 1;
                                l = false, r = false;
                        }   
                }   

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

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

//for study sourcode
using namespace std;
int main(){
	long long n,m,ans=0,cnt=0;
	cin >> n >> m;
	long long x[n],y[n],z[n],a[n];
	for(int i=0;i<n;i++){
		cin >> x[i] >> y[i] >> z[i];
	}
	for(int i=-1;i<2;i+=2){
		for(int j=-1;j<2;j+=2){
			for(int k=-1;k<2;k+=2){
				cnt=0;
				for(int l=0;l<n;l++){
					a[l]=i*x[l]+j*y[l]+k*z[l];
				}
				sort(a,a+n);
				reverse(a,a+n);
				for(int l=0;l<m;l++){
					cnt+=a[l];
				}
				ans=max(ans,cnt);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

int main () {
	int H, W, K;
	char grid[6][6];
	cin >> H >> W >> K;
	int cnt = 0;
	for (int col=0; col<H; col++) {
		for (int row=0; row<W; row++) {
			cin >> grid[col][row];
			if (grid[col][row]=='#')
				cnt ++;
		}
	}
	if (cnt < K) {
		cout << 0 << endl;
		return 0;
	}/*
	   	else if (cnt == K) {
		cout << 1 << endl;
		return 0;
	}*/
	int ans = 0;
	for (int cb=0; cb < (1<<H); cb++) {
		vector<int> cv;
		for (int i=0; i<H; i++) {
			if (cb & (1<<i)) {
				cv.push_back (i);
			}
		}
		for (int rb=0; rb<(1<<W); rb++) {
			vector<int> rv;
			for (int j=0; j<W; j++) {
				if (rb & (1<<j)) {
					rv.push_back (j);
				}
			}
			int nb = 0;
			for (int &c: cv) {
				for (int j=0; j<W; j++) {
					if (grid[c][j] == '#')
						nb ++;
				}
			}
			for (int& r: rv) {
				for (int i=0; i<H; i++) {
					if (grid[i][r] == '#')
						nb ++;
				}
			}
			for (int& c: cv) {
				for (int& r: rv) {
					if (grid[c][r] == '#') {
						nb--;
					}
				}
			}
			if (nb+K==cnt) {
				ans ++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long n, p; cin >> n >> p;
  if (n == 1) {
    cout << p << '\n';
    return 0;
  }
  int ans = 1;
  FOR(i, 2, 2000000) {
    long long a = pow(i, n);
    if (p % a == 0) ans = i;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int findSumOfDigits(int n)
{
  int sum = 0;
  while (n > 0)
  { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
main()
{
  int N,a,b;
  cin >> N >> a >> b;
  int total = 0;
  for (int i = 1; i <= N;i++){
    int sum = findSumOfDigits(i);
    if(a<=sum&&sum<=b)
      total += i;
  }
  cout << total << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define MAX_V 2000005
//lower_bound使え

struct edge{int to; long double cost;};
typedef pair<long double, int> P;//最短距離、頂点番号

int V;
vector<edge> G[MAX_V];
long double d[MAX_V];

void dijkstra(int s){
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d,d+V,LINF);
  d[s] = 0;
  que.push(P(0,s));

  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    rep(i, G[v].size()){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

/*
 * 頂点数をVに代入すること
 */
int main(void){
  cout<<fixed<<setprecision(15);
  ll xs,ys,xt,yt;cin>>xs>>ys>>xt>>yt;
  ll n;cin>>n;
  V = n+2;

  vector<long double> X(n+2), Y(n+2), R(n+2);
  X[0] = xs;
  Y[0] = ys;
  R[0] = 0;
  reps(i,n){
    cin>>X[i]>>Y[i]>>R[i];
  }
  X[n+1] = xt;
  Y[n+1] = yt;
  R[n+1] = 0;
  rep(i,n+2){
    rep(j,n+2){
      G[i].push_back({j, max((long double)0, sqrt(pow((X[i] - X[j]),2)  + pow((Y[i] - Y[j]),2)) - R[i] - R[j] )});
    }
  }

  dijkstra(0);
  cout<<d[n+1]<<endl;

  return 0;
}

Measured memory_bytes: 90256
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define F first
#define S second


int main()
{

// #ifndef ONLINE_JUDGE
// 	// for getting input from input.txt
// 	freopen("input1.txt", "r", stdin);
// 	// for writing output to output.txt
// 	freopen("output1.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n, k;
	cin >> k >> n;
	vector<ll> a(n, 0);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	ll max_dis = -1;
	for (int i = 0; i < n - 1; i++)
	{
		if (abs(a[i + 1] - a[i]) > max_dis)
			max_dis = abs(a[i + 1] - a[i]);
		//cout << max_dis << " okk\n";
	}
	ll dis = abs(k - a[n - 1] + a[0]);
	if (dis > max_dis)
		max_dis = dis;
	cout << k - max_dis << "\n";
	return 0;
}

Measured memory_bytes: 1792
import java.text.*;
import java.math.*;
import java.util.*;

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

		while(true) {
			num[0] = scan.nextInt();
			num[1] = scan.nextInt();
			if(num[0] == 0) break;
			for(int i1 = 0; i1 < num[0];i1++) {
				for(int i2 = 0;i2 < num[1];i2++) {
					if(i1 % 2 != 0) {
						if(i2 % 2 == 0) {
							System.out.print(".");
						}else {
							System.out.print("#");
						}
					}else {			
						if(i2 % 2 == 0) {
							System.out.print("#");
						}else {
							System.out.print(".");
						}
					}
				}
				System.out.println();
			}
			System.out.println();
		}
		
	}
}

Measured memory_bytes: 26844
import std.algorithm, std.conv, std.range, std.stdio, std.string;

version(unittest) {} else
void main()
{
  string line;
  while ((line = readln) !is null) {
    auto rd = line.split.to!(int[]), a = rd[0], b = rd[1];
    writeln((a + b).numDigits);
  }
}

int numDigits(int n)
{
  auto r = 1;
  for (; n >= 10; n /= 10) ++r;
  return r;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    vector<bool> used(n+1, false);
    int cur=1, ans=0;
    while(1){
        if(used[cur]){
            cout << -1 << endl;
            break;
        }
        if(cur == 2){
            cout << ans << endl;
            break;
        }
        used[cur] = true;
        ans++;;
        cur = a[cur];
    }
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	int n,i,x;
	scanf(" %d",&n);
	for(i=1;i<=n;i++){
		if(i%3==0 || i%10==3){
			printf(" %d",i);
		}else{
			for(x=i;x>1;){
				x /= 10;
				if(x==3 || x%10 == 3){
					printf(" %d",i);
					x = 0;
				}
			}
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2052
#include<iostream>
using namespace std;
#define int long long

signed main(){
	int n,w;
	cin>>n>>w;

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

	int dp[n+1][w+1];

	for(int i=0;i<=w;i++){
		dp[0][i] = 0;
	}

	for(int i=0;i<=n;i++){
		dp[i][0] = 0;
	}

	for(int i=1;i<=n;i++){
		for(int j=1;j<=w;j++){
			if(j<arr[i-1][0]){
				dp[i][j] = dp[i-1][j];
			}else{
				dp[i][j] = max(arr[i-1][1],max(dp[i-1][j],arr[i-1][1] + dp[i-1][j-arr[i-1][0]]));
			}
		}
	}

	// for(int i=0;i<=n;i++){
	// 	for(int j=0;j<=w;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	cout<<dp[n][w];
}

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

pair<int, int> pos[200005];
pair<int, int> poss[200005];

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> pos[i].first >> pos[i].second;
        poss[i] = {pos[i].first + pos[i].second, pos[i].first - pos[i].second};
    }

    int par = abs(pos[0].first + pos[0].second) % 2;
    for(int i = 1; i < n; ++i){
        if(abs(pos[i].first + pos[i].second) % 2 != par){
            cout << "-1\n";
            return 0;
        }
    }

    vector<int> d;
    for(int i = 30; i >= 0; --i){
        d.push_back((1LL << i));
    }
    if(!par){
        d.push_back(1);
    }

    cout << (int)d.size() << "\n";
    for(auto x : d){
        cout << x << " ";
    }
    cout << "\n";

    for(int i = 0; i < n; ++i){
        int xdir, ydir;
        int xcur = 0, ycur = 0;
        for(int j = 0; j < (int)d.size(); ++j){
            if(xcur > poss[i].first){
                xdir = -1;
                xcur -= d[j];
            }else{
                xdir = 1;
                xcur += d[j];
            }
            if(ycur > poss[i].second){
                ydir = -1;
                ycur -= d[j];
            }else{
                ydir = 1;
                ycur += d[j];
            }

            if(xdir == 1 && ydir == 1)cout << "R";
            else if(xdir == 1 && ydir == -1)cout << "U";
            else if(xdir == -1 && ydir == -1)cout << "L";
            else cout << "D";
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
x = [0.]*n
u = ['']*n
for i in range(n):
    xu = input().split()
    x[i], u[i] = float(xu[0]), str(xu[1])

sum = 0
for i in range(n):
    if u[i] == 'BTC':
        sum += x[i] * 380000.0
    else:
        sum += x[i]

print(sum)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<stack>
#include<cmath>
#include<cstring>
using namespace std;

int a[55];
int main()
{
	int n;
	while(cin>>n)
	{
		memset(a,0,sizeof(a));
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
		}
		long long int sum=0;
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				sum+= a[i]*a[j];
			}
		}
		cout<<sum<<endl;
	}
}

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

int top=0,S[1000];

void push(int x){
	S[++top]=x;
}

int pop(){
	top--;
	return S[top+1];
}

int main(void)
{
	int a,b;
	char s[1000];
	top=0;
	
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	
	return 0;
}

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

int main(){
  int N; cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++) cin >> a[i];
  vector<int> ans(N+1,0);
  int M = 0;
  for (int i=N; i>0; i--){
    int tmp = 0;
    for (int j=i; j<=N; j+=i){
      tmp += ans[j];
    }
    tmp %= 2;
    if (tmp != a[i-1]) {
      ans[i] = 1;
      M++;
    }
  }
  cout << M << endl;
  bool flag = false;
  for (int i=1; i<=N; i++){
    if(ans[i]==1){
      if(flag) cout << ' ';
      flag = true;
      cout << i << endl;
    }
  }
  cout << endl;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll dp[1<<16];
ll a[20][20];
int main(){
	ll n;
	while(scanf("%lld\n",&n),n){
		rep(i,0,1<<n)dp[i]=INF;
		dp[0]=0;
		rep(i,0,n)rep(j,0,n+1)scanf("%lld",&a[i][j]);
		rep(i,0,1<<n)rep(k,0,n)if(!bit(i,k)){
			//配るDP
			ll cost=a[k][0];
			rep(x,0,n)if(bit(i,x))cost=min(cost,a[k][x+1]);
			dp[i|1<<k]=min(dp[i|1<<k],dp[i]+cost);
		}
		printf("%lld\n",dp[(1<<n)-1]);
	}
	return 0;
}


Measured memory_bytes: 2312
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<long long Mod>
struct mint{
    long long x;
    mint(long long x=0) :x((x% Mod+Mod)%Mod){}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {
        if((x += a.x) >= Mod) x -= Mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if((x += Mod-a.x) >= Mod) x -= Mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= Mod;
        return *this;
    }

    mint operator^(long long t) const {
        mint ret(1);
        mint a = *this;
        while(t){
            if(t&1){
                ret *= a;
            }
            a *= a;
            t >>= 1;
        }
        return ret;
    }
    mint inv() const { return *this ^ (Mod-2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }

    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint operator/(const mint a) const { return mint(*this) /= a; }

    friend istream& operator>>(istream& is, mint& a) { return is >> a.x; }
    friend ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
};

int S;

bool vis[2001] ={};
mint<MOD> dp[2001];
mint<MOD> solve(int n){
    if(n == 0) return 1;
    if(vis[n]) return dp[n];
    vis[n] = true;
    dp[n] = 0;
    for(int i=3; i<=n; i++){
        dp[n] += solve(n-i);
    }
    return dp[n];
}

signed main(){
    cin >> S;
    cout << solve(S) << endl;
}

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

long long dp[3005][3005];

int main()
{
	string s1 , s2;
	
	cin >> s1 >> s2;
	
	for(int i = 0 ; i<= s1.size() ; i++)
	{
		for(int j = 0 ; j<=s2.size() ; j++)
		{
			if(i==0 || j==0)
				dp[i][j] = 0;
			else if(s1[i-1]==s2[j-1])
				dp[i][j] = dp[i-1][j-1] + 1;
			else
				dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
		}
	}
	string ans;
	int r = s1.size();
	int c = s2.size();
	while(r>0 && c>0)
	{
		if(dp[r][c]!=dp[r-1][c] && dp[r][c]!=dp[r][c-1])
		{
			ans += s1[r-1];
			r = r-1;
			c = c-1;
		}
		else if(dp[r][c]==dp[r-1][c])
			r = r-1;
		else
			c = c-1;
	}
	
	reverse(ans.begin() , ans.end());
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 70784
#include<iostream>
using namespace std;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  a=n-a;
  b=n-b;
  if(a<0)
    a=-a;
  if(b<0)
    b=-b;
  if(a<b)
    cout<<"A"<<endl;
  else
    cout<<"B"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main(){
	
	
	int x,y,w,h,r;
	cin >> w >> h >> x >> y >> r;
	
	
	if((x<=w-r)&&(x>=r)&&(y<=h-r)&&(y>=r )) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

void fnInput(vector<int>& rvnTrg, vector<int>& rvnSch)
{
  int nTrgCnt;
  cin >> nTrgCnt;

  rvnTrg.resize(nTrgCnt);
  for (int i = 0; i < nTrgCnt; i++)
    cin >> rvnTrg[i];

  int nSchCnt;
  cin >> nSchCnt;

  rvnSch.resize(nSchCnt);
  for (int i = 0; i < nSchCnt; i++)
    cin >> rvnSch[i];
}

void fnBinSch(const vector<int>& cnrvnTrg, const vector<int>& cnrvnSch, int& rnFnd)
{
  for (int i = 0; i < cnrvnSch.size(); i++)
  {
    int nLow  = 0;
    int nHigh = cnrvnTrg.size();
    while (nLow < nHigh)
    {
      int nMid = (nLow + nHigh) / 2;
      if (cnrvnSch[i] == cnrvnTrg[nMid])
      {
        rnFnd++;
        break;
      }
      else if (cnrvnSch[i] < cnrvnTrg[nMid])
        nHigh = nMid;
      else
        nLow  = nMid + 1;
    }
  }
}

void fnResult(int nFnd)
{
  cout << nFnd << endl;
}

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

  vector<int> vnTrg, vnSch;
  int nFnd = 0;

  fnInput(vnTrg, vnSch);
  fnBinSch(vnTrg, vnSch, nFnd);
  fnResult(nFnd);

  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template <class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template <class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

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

  if (s.length() == 2) {
    p(s);
  } else {
    reverse(s);
    p(s);
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#include <iostream>
#include <string>

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

std::string s;

int main() {
	std::cin >> s;
	
	int c = 0, p;
	do {
		int i = 1;
		p = c;
		while(i + 1 < s.size()) {
			if(s[i - 1] == s[i + 1]) { i++; } else { s.erase(i, 1); c++; }
		}
	} while(c != p);
	
	// わからん
	bool ans = (c % 2 == 1);
	
	printf("%s\n", ans ? "First" : "Second");
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pub push_back
#define mp make_pair
#define MAX 

using namespace std;

ifstream fin("input.txt");
string str;


int main()
{
  ios :: sync_with_stdio(false);
  int t ;
  cin >> t ;
  if (t >= 30)
  cout<<"Yes";
  else
  cout<<"No";
  
  
  
}

Measured memory_bytes: 3648
n = gets.to_i
a = 0
b = 1
i = 1
c = 0
while i<=n do
    a = 0
    b = 1
    while b<=i do
        if i % b==0
            a+=1
            end
        b+=1
        end
    if a==8 && i%2!=0
        c+=1
        end
    i+=1
    end
puts c

Measured memory_bytes: 1788
s = input()
tcd_g = s.count("g")
tcd_p = len(s) - tcd_g

acd_p = len(s)//2
acd_g = len(s) - acd_p

if tcd_g >= acd_p:
    print(acd_p - tcd_p)
else:
    print(tcd_g - acd_g)

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

int main() {
    vector<int> abc (3);
    cin >> abc.at(0) >> abc.at(1) >> abc.at(2);
    sort(abc.begin(),abc.end());
    int ans = 0;
    while(abc.at(1) != abc.at(2)){
        ans++;
        abc.at(0)++; abc.at(1)++;
    }
    while(abc.at(0) < abc.at(1)){
        ans++;
        abc.at(0) += 2;
    }
    if(abc.at(0) != abc.at(1)) ans++;
    cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N;
  cin >> N;

  cout << N*N*N << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
typedef pair<int,int> P;

const int kInf = 1 << 28;
const string msg[] = {"SAFE", "SUSPICIOUS"};
char m[60][60];
int H, W;

bool solve() {
  string s, base;
  rep(i,H) rep(j,W) if (m[i][j] != '.') s += m[i][j];
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  // printf("%s\n", s.c_str());

  base = s;
  vector<P> xs, ys;

  rep(i,s.size()) {
    int mnx = kInf, mny = kInf, mxx = -1, mxy = -1;
    rep(j,H) rep(k,W) if (m[j][k] == s[i]) {
      mnx = min(mnx, k); mxx = max(mxx, k);
      mny = min(mny, j); mxy = max(mxy, j);
    }
    xs.push_back(P(mnx, mxx));
    ys.push_back(P(mny, mxy));
  }
  
  do {
    bool ok = true;
    rep(i,s.size()) {
      for (int y = ys[i].first; y <= ys[i].second; ++y) {
        for (int x = xs[i].first; x <= xs[i].second; ++x) {
          if (base[i] != m[y][x]) {
            if (s.find(base[i]) < s.find(m[y][x])) ok = false;
          }
        }
      }
    }
    if (ok) return false;
  } while (next_permutation(s.begin(), s.end()));
  
  return true;
}

int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &H, &W);
    rep(i,H) fscanf(stdin, "%s", m[i]);
    printf("%s\n", msg[solve()].c_str());
  }
  return 0;
}

Measured memory_bytes: 924
#include <bits/stdc++.h>
using namespace std;
#define lli long long int 
#define MOD 1000000007
#define fi(i,a,n) for(lli i = a; i < n; i++)
#define fd(i,a,n) for(lli i = a; i > n; i--)
#define fv(i,a) for(auto i:a)
#define pb push_back
#define mp make_pair


int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout<<fixed<<setprecision(10);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

lli div[1000005 + 1]; 
memset(div, 0, sizeof div); 
lli num=1000005;

for (lli i = 1; i <= num; i++) { 

    for (lli j = 1; j * i <= num; j++) 
        div[i * j]++; 
} 


lli t=1;
//cin>>t;
while(t--)
{
	lli n;
	cin>>n;
	lli ans=0;
	fi(c,1,n+1)
	{
		lli x=n-c;
		if(x>0)
		{
			ans+=div[x];
		}
	}	
	cout<<ans;
}
return 0;
}

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

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    ll n; cin >> n;
    if (n % 2) {
        cout << "0\n";
        return 0;
    }

    vector<ll> v = {10};
    ll x = 25;
    while (v.back() <= n) {
        v.push_back(x * 2);
        x *= 5;
    }

    ll ans = 0;
    for (auto it : v) {
        ans += n / it;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcount((unsigned int)x);};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    map<char, ll> m;
    rep(i, 4){
        m[s[i]]++;
    }
    bool ok = true;
    FORMAP(it, m){
        if(it->ss != 2) ok = false;
    }
    cout << (ok ? "Yes" : "No") << endstr;
    return 0;
}


Measured memory_bytes: 764
import math

n = int(input())
a_array = list(map(int, input().split()))

def get_primenumber(number):#エラトステネスの篩
    prime_list = []
    search_list = list(range(2,number+1))
    #search_listの先頭の値が√nの値を超えたら終了
    while search_list[0] <= math.sqrt(number):
        #search_listの先頭の値が√nの値を超えたら終了
        #search_listの先頭をprime_listに入れて、先頭をリストに追加して削除
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        #head_numの倍数を除去
        for i in range(number // head_num):
            index = head_num * (i + 1)
            if D[index] == index:
                D[index] = head_num
        search_list = [num for num in search_list if num % head_num != 0]
    #prime_listにsearch_listを結合
    prime_list.extend(search_list)
    return prime_list


def factrization_prime(number):
    div = D[number]
    s = math.sqrt(number)
    div_set = set()
    while number > 1:
        number //= div
        div_set.add(div)
        div = D[number]
    if number > 1:
        div_set.add(div)
    for div in div_set:
        ans_array[div] += 1


# thre = pow(10, 6) + 1
thre = max(a_array) + 1
ans_array = [0] * thre
D = list(range(thre + 1))

prime_list = get_primenumber(thre)
# print(D[-10:])
for a in a_array:
    factrization_prime(a)
# print(ans_array)

max_ans_array = max(ans_array)
if max_ans_array <= 1:
    print('pairwise coprime')
elif max_ans_array < n:
    print('setwise coprime')
else:
    print('not coprime')

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

using namespace std;

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

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
	int a,b,d;
	while(cin >> a >> b >> d){
		if(a==0)
			break;

		int cmin=inf;
		int cmin2=inf;
		int x,y;

		rep(dx,50010)rep(j,2){
			int sum=j?d+a*dx:d-a*dx;
			if(sum%b)
				continue;
			int dy=sum/b;
			if(dy<0)
				continue;
			if(cmin>dx+dy){
				x=dx,y=dy;
				cmin=x+y;
				cmin2=a*x+b*y;
			}else if(cmin==dx+dy){
				if(cmin2>a*dx+b*dy){
					x=dx,y=dy;
					cmin2=a*x+b*y;
				}
			}
		}
		rep(dy,50010)rep(j,2){
			int sum=j?d+b*dy:d-b*dy;
			if(sum%a)
				continue;
			int dx=sum/a;
			if(dx<0)
				continue;
			if(cmin>dx+dy){
				x=dx,y=dy;
				cmin=x+y;
				cmin2=a*x+b*y;
			}else if(cmin==dx+dy){
				if(cmin2>a*dx+b*dy){
					x=dx,y=dy;
					cmin2=a*x+b*y;
				}
			}
		}
		cout << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;




int main() {
    int k,x;
    cin >> k>>x;
    vector<int> ZZZ(2000001);


    for (int i = -(k-1); i <= 0; i++) {
        cout << x+i << " ";
    }
    for (int i = 1; i < k; i++) {
        cout << x + i << " ";
    }
    
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;


ll gcd(ll i,ll j){
    if(j == 0) return i;
    return gcd(j,i%j);
}

int main(){
    int x;
    cin >> x;
    int p = gcd(x,360);
    int ans = 360 / p;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
   int N;
   cin >> N;
   N *= 2;
   vector<int> kushi(N);
   for (int i = 0; i < N; ++i)
   {
       cin >> kushi[i];
   }
   sort(kushi.begin(), kushi.end());
   int sum = 0;
   for (int i = 0; i < N; i += 2)
   {
       sum += std::min(kushi[i], kushi[i + 1]);
   }
   cout << sum << endl;
   return 0;
}


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

int main(){
  long long int N,L;
  long long int a=0;
  cin>>N;
  L = N%2;
  if(L==1){
    cout<<0<<endl;
    return 0;
  }
  long long int n = N;
  n = n/10;
  a = a + n;
  while(n>4){
    n = n/5;
    a = a + n;
  }
  cout<<a<<endl;
  return 0;
}


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

int main()
{
  int n,sum=0;
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(v.begin(),v.end());
  rep(i,n-1)
  {
    for (int j = i+1; j<v.size(); j++)
    {
      sum+=v[i]*v[j];
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll m,d,res=0;
    cin>>m>>d;
    for(ll z=1;z<=m;z++)
    for(ll i=10;i<=d;i++){
        ll x=i/10,y=i%10;
        if(x>=2&&y>=2&&(x*y==z))
        res++;
    }
    cout<<res;
}


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

int main()
{
    string str;
    cin >> str;
    for(int i=0;i<(int)str.size();i++){
        if(str[i]=='A') str[i]='X';
        else if(str[i]=='B') str[i]='Y';
        else if(str[i]=='C') str[i]='Z';
        else str[i]-=3;
    }
    cout << str << endl;
    return 0;
}



Measured memory_bytes: 3172
as=[];gets.to_i.times{as<<gets.to_i}
max=-999999999999
min=999999999999
as.each_with_index{|a,i|
  if min > a
    min = a
    as[i+1..-1].each{|a2|
      max=a2-a if a2-a >max
    }
  end
}
puts max



Measured memory_bytes: 9244
#include <iostream>
using namespace std;
int main(){
    int a, b, c, x;
    cin >> a >> b >> c;
    if (a > b){
        x = a;
        a = b;
        b = x;
    }
    if (b > c){
        x = b;
        b = c;
        c = x;
    }
     if (a > b){
        x = a;
        a = b;
        b = x;
    }
    cout << a << " " << b << " " << c << endl;
}

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

using namespace std;

int main(){
	int N;
	while(cin >> N, N){
		string name[20];
		vector< vector<int> > t(N);
		vector<int> pt(30, N+1);
		for(int i=0;i<N;i++){
			cin >> name[i];
			int m; cin >> m;
			for(int j=0;j<m;j++){
				int d; cin >> d;
				t[i].push_back(d);
				pt[d]--;
			}
		}
		int idx = 0, mpt = 10000000;
		for(int i=0;i<N;i++){
			int cur = 0;
			for(int j=0;j<t[i].size();j++)
				cur += pt[t[i][j]];
			if(cur < mpt){
				mpt = cur;
				idx = i;
			}
			else if(cur == mpt){
				if(name[idx] > name[i]) idx = i;
			}
		}
		cout << mpt << " " << name[idx] << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N, M;
    cin >> N >> M;
    if(N==1 and M==1)
    cout<<1;
    else if(N==1)
    cout<<M-2;
    else if(M==1)
    cout<<N-2;
    else
    cout << (N - 2) * (M - 2);
    return 0;
}

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

using namespace std;

int main(void)
{
    string S;
    string s1 = "Yes";
    string s2 = "No";

    cin >> S;

    if (S[2]==S[3]&&S[4]==S[5])
        cout << s1 << endl;
    else 
        cout << s2 << endl;
    
    return 0;

}

Measured memory_bytes: 256
(defn input []
  (->> (repeatedly 3 read-line)
    (map
      (comp
        (partial map #(Integer/parseInt %))
        #(clojure.string/split % #"\s")))))

(defn CollectingBalls [[[_] [K] Xs]]
  (bit-shift-left (reduce #(+ %1 (min %2 (- K %2))) 0 Xs) 1))

(-> (input)
  CollectingBalls
  println)

Measured memory_bytes: 86236
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, M; cin >> N >> M; 
	bool ok[100010] = {}; 
	int cnt[100010] = {}; 
	int ac = 0; int pn = 0; 
	for(int i = 0; i < M; i++){
		int p; string s; cin >> p >> s; 
		if(ok[p]) continue; 
		else if(s == "AC"){
			ok[p] = true; ac ++; pn += cnt[p]; 
		}
		else if(s == "WA") cnt[p] ++;  
	}
	cout << ac << " " << pn << endl; 
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {


	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt()-1;
		int b = sc.nextInt()-1;
		int c = sc.nextInt()-1;
		int d = sc.nextInt()-1;
		
		String s = sc.next();
		
		if (c<d) {
			if (reachable(a,c,s) && reachable(b,d,s)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			if (reachable(a,c,s) && passable(b,d,s)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
		


	}
	
	
	static boolean reachable(int start, int end, String s) {
		for (int i=start; i<end; i++) {
			if (s.charAt(i)=='#' && s.charAt(i+1)=='#') {
				return false;
			}
		}
		return true;
	}
	
	static boolean passable (int start, int end, String s) {
		for (int i=start; i<=end; i++) {
			if (s.charAt(i-1)=='.' && s.charAt(i)=='.' && s.charAt(i+1)=='.') {
				return true;
			}
		}
		return false;
	}
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();

		pr.println((a - 1) * (b - 1));
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23252
#include<stdio.h>
#include<ctype.h>
#include<string.h>
main(){
    char p[200],p2[100],s[100];
 
    scanf("%s",p);
  strcpy(p2,p);
    strcat(p,p2);
    scanf("%s",s);
 
    if(strstr(p,s)){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 540
def ceil(x,y):
    if x%y==0:
        return x//y
    else:
        return (x//y) + 1

n = int(input())
T,A = 1,1
for _ in range(n):
    t,a = map(int,input().split())
    x = max(ceil(T,t),ceil(A,a))
    if x == 0:
        x = 1
    T,A = t*x,a*x
print(T+A)

Measured memory_bytes: 3060
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();

		System.out.println((x - z)/(y + z));
	}
}


Measured memory_bytes: 22612