akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	boolean[][] matrix;
	int n, m;
	
	void print(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(j!=0) System.out.print(" ");
				if(matrix[i][j]==true) System.out.print(1);
				else System.out.print(0);
			}
			System.out.println();
		}
	}
	
	void Rotate(int r, int c, int size, int angle){
		boolean[][] temp = new boolean[size][size];
		for(int k=0;k<angle/90;k++){
			for(int i=0;i<size;i++){
				for(int j=0;j<size;j++){
					temp[i][j] = matrix[r+i][c+j];
				}
			}
			for(int i=0;i<size;i++){
				for(int j=0;j<size;j++){
					matrix[r+i][c+j] = temp[size-1-j][i];
				}
			}
		}
	}
	
	void Island(int r, int c){
		boolean f = matrix[r][c];
		int py = r;
		int px = c;
		int sy, sx;
		int[] a = new int[]{0,0,1,-1};
		int[] b = new int[]{1,-1,0,0};
		ArrayDeque<Integer> y = new ArrayDeque<Integer>();
		ArrayDeque<Integer> x = new ArrayDeque<Integer>();
		y.add(r);
		x.add(c);
		matrix[py][px] ^= true;
		while(y.size()!=0){
			py = y.poll();
			px = x.poll();
			for(int i=0;i<4;i++){
				sy = py+a[i];
				sx = px+b[i];
				if(0<=sy && sy<=n-1 && 0<=sx && sx<=n-1){
					if(matrix[sy][sx]==f){
						y.offer(sy);
						x.offer(sx);
						matrix[sy][sx] ^= true;
					}
				}
			}
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		matrix = new boolean[n][n];
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				int p = sc.nextInt();
				if(p==1) matrix[i][j] = true;
			}
		}
		for(int i=0;i<m;i++){
			int o = sc.nextInt();
			int r = sc.nextInt()-1;
			if(o==0){
				int c = sc.nextInt()-1;
				int size = sc.nextInt();
				int angle = sc.nextInt();
				if(angle==90 || angle==180 || angle==270) Rotate(r, c, size, angle);
			}else if(o==1){
				int c = sc.nextInt()-1;
				int size = sc.nextInt();
				for(int j=0;j<size;j++){
					for(int k=0;k<size;k++) matrix[r+j][c+k] ^= true;
				}
			}else if(o==2){
				boolean f = matrix[r][0];
				for(int j=0;j<n-1;j++) matrix[r][j] = matrix[r][j+1];
				matrix[r][n-1] = f;
			}else if(o==3){
				boolean f = matrix[r][n-1];
				for(int j=n-1;j>0;j--) matrix[r][j] = matrix[r][j-1];
				matrix[r][0] = f;
			}else if(o==4){
				int c = sc.nextInt()-1;
				Island(r, c);
			}
		}
		print();
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 21260
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    char c;
    cin >> c;
    switch(c) {
        case 'A': cout << 'T'; break;
        case 'T': cout << 'A'; break;
        case 'G': cout << 'C'; break;
        case 'C': cout << 'G'; break;
    }
    cout << endl;
    return 0;
}

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

typedef long long LL;

#define REP(i, n) for(LL i = 0; i < (LL)(n); i++)
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const LL IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 2019;

LL power(LL x, LL y) {
    LL res = 1;
    for(;0 < y;) {
        if(y%2 == 0) {
            x *= x;
            x %= MOD;
            y /= 2;
        }else{
            res *= x;
            res %= MOD;
            y--;
        }
    }
    return res;
}

int main() {
    string s;
    cin >> s;
    reverse(ALL(s));
    LL N;
    N = s.size();
    vector<LL> v(N, 0);
    vector<LL> c(MOD, 0);
    v[0] = s[0] - '0';
    c[v[0]]++;
    c[0]++;
    FOR(i, 1, N) {
        LL p = s[i] - '0';
        v[i] = power(10, i)*p + v[i - 1];
        v[i] %= MOD;
        c[v[i]]++;
    }
    LL res = 0;
    REP(i, MOD) {
        res += c[i]*(c[i] - 1)/2;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define FALSE 0
#define TRUE  1

#define MIN(a, b) ((a)<(b) ?  (a) : (b))
#define MAX(a, b) ((a)>(b) ?  (a) : (b))
#define ABS(a) 	((a)< 0  ? -(a) : (a))
#define IMPAR(a)	((a)&1)
#define CTOI(a)	((a) - '0')
#define ITOC(a)	((a) + '0')

#define MAX_TAM	100

typedef struct {int peso, valor;} TItem;
TItem itens[MAX_TAM];
	
// Variaveis do knapsack
int C[MAX_TAM + 1][10001], V[MAX_TAM + 1][10001];

int knapsack01(int, int);

int main()
{	int T, L, l;
	char possivel;
	
	while (scanf("%d %d", &L, &T) != EOF)
	{	for (l = 0, possivel = FALSE; l < L; l++)
		{	scanf("%d %d", &itens[l].valor, &itens[l].peso);
			if (itens[l].peso <= T )
				possivel = TRUE;
		}
/*		
		for (l = 0; l < L; l++)
			printf("%d %d\n", itens[l].valor, itens[l].peso);
		printf("\n\n");
*/		
		if (!possivel)
			puts("-1");
		else
			printf("%d\n", knapsack01(L, T));
/*			
			for (xi = 0; xi <= L; xi++)
			{	for (xw = 0; xw <= MW; xw++)
					printf("%2d ", C[xi][xw]);
				printf("\n");
			}
			printf("*************************\n");
*/
	}
	
	return 0;
}

int knapsack01(int qtItens, int tamMochila)
{	int xi, xw, MW;

 //The solution can be found in C[N][W];
	MW = tamMochila;			// Tamanho da mochila
	
	for (xi = 0; xi <= qtItens; xi++)
		C[xi][0] = V[xi][0] = 0;
			
	for (xw = 0; xw <= MW; xw++) 
		C[0][xw] = V[0][xw] = 0;
			
	for (xi = 1; xi <= qtItens; xi++)
		for (xw = 1; xw <= MW; xw++)
		{	if (itens[xi - 1].peso > xw)
			{	C[xi][xw] = C[xi - 1][xw];
				V[xi][xw] = V[xi - 1][xw];
			}
			else
				if (C[xi - 1][xw] > C[xi - 1][xw - itens[xi - 1].peso] + itens[xi - 1].valor)
				{	C[xi][xw] = C[xi - 1][xw];
					V[xi][xw] = V[xi - 1][xw];
				}
				else
				{	C[xi][xw] = C[xi - 1][xw - itens[xi - 1].peso] + itens[xi - 1].valor;
					V[xi][xw] = V[xi - 1][xw - itens[xi - 1].peso] + itens[xi - 1].peso;
				}
		}

	return C[qtItens][MW];
}

Measured memory_bytes: 8488
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

from itertools import accumulate
acc = [0] + a
acc = list(accumulate(acc))

suma = sum(a)

ans = float('inf')

for i in range(n):
    ans = min(abs( 2*acc[i]-suma  ),ans  )

print(ans)


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

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

void test_case() {
	int n, k;
	cin >> n >> k;
	set<int> disliked;
	
	for(int i = 0; i < k; i ++) {
		int temp;
		cin >> temp;
		disliked.insert(temp);
	}
	debug() << imie(disliked);
	int tempN = n;
	while(true) {
		int temp = tempN;
		bool valid = true;
		while(temp){
			int m = temp % 10;
			if(disliked.find(m) != disliked.end()) {
				valid = false;
				break;
			}
			temp /= 10;
		} 	
		if(valid) break;
		tempN += 1;
	}
	cout << tempN;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1; 
	//scanf("%d", &t);
	while(t --) {
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  vvi C(3, vi(3));
  cin >> C;

  if(C[0][0] - C[0][1] != C[1][0] - C[1][1] or C[0][0] - C[0][1] != C[2][0] - C[2][1]){
    cout << "No\n";
    return;
  }

  if(C[0][0] - C[0][2] != C[1][0] - C[1][2] or C[0][0] - C[0][2] != C[2][0] - C[2][2]){
    cout << "No\n";
    return;
  }

  if(C[0][0] - C[1][0] != C[0][1] - C[1][1] or C[0][0] - C[1][0] != C[0][2] - C[1][2]){
    cout << "No\n";
    return;
  }

  if(C[0][0] - C[2][0] != C[0][1] - C[2][1] or C[0][0] - C[2][0] != C[0][2] - C[2][2]){
    cout << "No\n";
    return;
  }

  cout << "Yes\n";


}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(int argc, char* argv[])
{
    int n,a,b,c,x,cnt=0,ans;
    int y[10000];
    while(1){
        cin >> n >> a >> b  >> c  >> x;
        if(n==0 && a==0 && b==0 && c==0 && x==0){
            return 0;
        }
        for(int i=0;i<n;i++){
            cin >> y[i];
            while(cnt<=10000){
                if(i==0 && y[i]==x){
                    break;
                }
                ans=(a*x+b)%c;
                cnt++;
                if(ans==y[i]){
                    x=ans;
                    break;
                }
                x=ans;
            }
        }
        if(cnt>10000)
            cout << -1 << endl;
        else
            cout << cnt << endl;
        cnt=0;
        ans=0;
    }
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    vint a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(all(a));
    vint ptr = {5, 5, 7};
    yn(a == ptr);
    return 0;
}

Measured memory_bytes: 256
def diff(a, b):
    ret = 0
    for c1, c2 in zip(a, b):
        if c1 != c2:
            ret += 1

    return ret

S = input()
T = input()

l = len(T)
ans = 10 ** 9
for i in range(len(S) - l + 1):
    # print(S[i:i+l])
    ans = min(ans, diff(S[i:i+l], T))

print(ans)

Measured memory_bytes: 67436
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
#include <vector>

using namespace std;
bool cmp(int x,int y){
    return x>y;
}
int main(){
    int n,a[1000],sum1=0,sum2=0;
    while(scanf("%d",&n)!=EOF){
        sum1=0;
        sum2=0;
        for(int i=0;i<n;i++){
            scanf("%d",&a[i]);
        }
        sort(a,a+n,cmp);
        for(int i=0;i<n;i++){
            if(i%2==0){
                sum1+=a[i];
            }
            else sum2+=a[i];
        }
        printf("%d\n",sum1-sum2);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=301000;
int n,L;
int x[N],t[N];
ll val[N][2][2],nc[N];
int ret,v0[N],v1[N];
int main() {
	scanf("%d%d",&n,&L);
	rep(i,1,n+1) scanf("%d",x+i);
	rep(i,1,n+1) scanf("%d",t+i);
	rep(i,1,n+1) rep(p1,0,2) rep(p2,0,2) {
		ll r1=p1==0?x[i]:2*L-x[i];
		ll r2=p2==0?x[i]:2*L-x[i];
		r1=(r1+t[i])%(2*L);
		val[i][p1][p2]=t[i]+((r1<=r2)?r2-r1:r2+2*L-r1);
	}
	rep(i,1,n+1) {
		nc[i]=min(val[i][0][0],val[i][1][1]);
		val[i][1][0]-=2*x[i];
		val[i][0][1]+=2*x[i];
		nc[i]/=(2*L); val[i][1][0]/=(2*L); val[i][0][1]/=(2*L);
	}
	ret+=val[n][0][1];
	int p1=0,p2=0;
	rep(i,1,n) {
		ret+=val[i][1][0];
		v0[i]=nc[i]-val[i][1][0];
		v1[i]=val[i][0][1]-val[i][1][0];
		if (v0[i]==1&&v1[i]==2) p1++;
		else if (v0[i]==1&&v1[i]==1) {
			if (p1==p2) p1++; else p2++;
		} else if (v0[i]==0&&v1[i]==0) {
			if (p1==p2) p2--; else p1--;
			p1=max(p1,0); p2=max(p2,0);
		}
	}
//	if (p1>=0) ret+=2; else if (p2>=0) ret+=1;
	printf("%lld\n",(ret+p1)*2ll*L);
}

Measured memory_bytes: 16768
#include<stdio.h>

int main()
{
int n,i,count;
long  d,x,y;
  count=0;
  scanf("%d %d",&n,&d);
  
  //int a[1][n];
  
  for (i=0;i<n;i++)
  {
  scanf("%ld %ld",&x,&y);
  
  if (x*x+y*y <= d*d)
  {
  	count+=1;  
  }
  
  }
  

  printf("%d",count);
  
  return 0;
 
}


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

void a(){
    string s,t;
    cin >> s >> t;
    cout << t << s;
}

void b(){
    ll a,b,k;
    cin >> a >> b >> k;
    
  	if(a<=k){
    	cout << 0 << " ";
      	if(b>= k-a){
        	cout << b-(k-a);
        }else{
        	cout << 0;
        }
    }else{
    	cout << a-k << " " << b;
    }
}

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


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 1000

int main(void){
  int i,n,j;
  int line[N];
  double x,y;
  double angle;

  for(i=0;;i++){
    scanf("%d",&line[i]);
    if(line[i]==-1){
      n=i;
      break;
    }
  }
  for(i=0;i<n && i<20;i++){
    x=1.0;
    y=0.0;
    angle=180.0;
    for(j=1;j<line[i];j++){
      angle-=90.0;
      x+=cos(angle*3.141592/180.0);
      y+=sin(angle*3.141592/180.0);
      if(x>=0)
        angle=180+(atan(y/x))*180.0/3.141592;
      else
        angle=360+(atan(y/x))*180.0/3.141592;
    }
    printf("%0.2f\n%0.2f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
int main() {
  int n=0,p,q,r;
  double ax=0,ay=0,bx=0,by=0,cx=0,cy=0,S=0,R=0,a=0,b=0,c=0,x=0,y=0;
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>ax>>ay>>bx>>by>>cx>>cy;
    S=abs(((bx-ax)*(cy-ay)-(cx-ax)*(by-ay))/2);
    a=sqrt((cx-bx)*(cx-bx)+(cy-by)*(cy-by));
    b=sqrt((cx-ax)*(cx-ax)+(cy-ay)*(cy-ay));
    c=sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
    R=a*b*c/(4*S);
    x=(a*a*(b*b+c*c-a*a)*ax+b*b*(c*c+a*a-b*b)*bx+c*c*(a*a+b*b-c*c)*cx)/(16*S*S);
    y=(a*a*(b*b+c*c-a*a)*ay+b*b*(c*c+a*a-b*b)*by+c*c*(a*a+b*b-c*c)*cy)/(16*S*S);
    printf("%.3f %.3f %.3f\n",x,y,R);
  }
}

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

int cnt=0;

void DFS(int k, vector<vector<int> >& V, vector<pair<int,int> >& time) {
	time[k].first=cnt++;
	for(int i=1; i<=(int)V[k].size(); ++i) {
		if(time[V[k][i]].first==-1) {
			DFS(V[k][i],V,time);
		}
	}
	time[k].second=cnt++;
	return;
}

int main() {
	int i,j;
	int n;
	int u,k;
	vector<vector<int> > V;
	vector<pair<int,int> > time;
	scanf("%d",&n);
	V.resize(n+1);
	V[0].resize(n+1);
	time.resize(n+1);
	for(i=1; i<=n; ++i) {
		V[0][i]=i;
		scanf("%d%d",&u,&k);
		V[u].resize(k);
		time[u]={-1,-1};
		for(j=1; j<=k; ++j) {
			scanf("%d",&V[u][j]);
		}
	}
	DFS(0,V,time);
	for(i=1; i<=n; ++i) {
		printf("%d %d %d\n",i,time[i].first,time[i].second);
	}
	return 0;
}

Measured memory_bytes: 2708
#include<stdio.h>

int main(void){
        int i=1,x;

        do{
                scanf("%d",&x);
                if(x == 0)
                        break;
                else{
                        printf("Case %d: %d\n",i,x);
                        i++;
                }
        }while(1);
        return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;

/////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{

   ll n, m; cin >> n >> m;
   ll a[1001] = {};
   ll sum = 0;
   rep(i, 0, n) {
       cin >> a[i];
       sum += a[i];
   }
   sort(a, a + n);
   reverse(a, a + n);

   int cnt = 0;
   rep(i, 0, n) {
       if (4 * a[i] * m >= sum) {
           cnt++;
       }
   }
   cout << ((cnt >= m) ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    double r;
    cin>>r;
double ans=2*PI*r;
cout<<prec(10)<<ans;

}


Measured memory_bytes: 3784
H,W =[int(i) for i in input().split()]
if H*W==1:
    print(1)
elif H==1 and W!=1:
    print(max(0, W-2))
elif W==1 and H!=1:
    print(max(0, H-2))
else:
    print(max(H-2, 0)*max(W-2, 0))


Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args){
        
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int R = scanner.nextInt();
        
        int X = 100*(10-N);
        
        if(N>=10){
            System.out.println(R);
        }else{
            System.out.println(R+X);
        }
        
    }
}


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

int main()
{
    int a,b,s;
    cin>>a>>b;
    s=a*b;
    if(s%2==0)
    {
        cout<<"Even"<<"\n";
    }
    else
    {
        cout<<"Odd"<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))



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

long long lcm(long long a, long long b)
{
	return a * b / gcd(a, b);
}

int main() {
	int N;
	cin >> N;
	vector<int> T(N + 1), X(N + 1), Y(N + 1);
	T.at(0) = 0; 
	X.at(0) = 0;
	Y.at(0) = 0;

	for (int i = 1; i <= N; i++) {
		cin >> T.at(i) >> X.at(i) >> Y.at(i);
	}

	for (int i = 0; i < N; i++) {
		if (abs(T.at(i) - T.at(i + 1)) < abs(X.at(i) - X.at(i + 1)) + abs(Y.at(i) - Y.at(i + 1)) ||
			abs(T.at(i) - T.at(i + 1)) % 2 != (abs(X.at(i) - X.at(i + 1)) + abs(Y.at(i) - Y.at(i + 1))) % 2) {
			cout << "No" << endl;
			exit(0);
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 1408
import sys
from bisect import bisect_left
from collections import deque

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    color = deque([A[0]])

    for i in range(1, N):
        idx = bisect_left(color, A[i])
        if idx == 0:
            color.appendleft(A[i])
        else:
            color[idx - 1] = A[i]

    print(len(color))


if __name__ == "__main__":
    main()


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

int main(){
	 
	long long int X; cin >> X;
	for(long long A = -200; A <= 200; A++){
		for(long long B = -200; B <= 200; B++){
			auto a = A*A*A*A*A, b = B*B*B*B*B;
			if(a - b == X) {
				cout << A << " " << B << endl;
				return 0;
			}
		}
	}




    
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

void wdfs(int x,int y,char f[51][51])
{
    if(f[y][x] == '.') f[y][x] = 'w';
    for(int i = 0; i < 4; i++){
        int nx = x+dx[i];
        int ny = y+dy[i];
        if(nx >= 0 && ny >= 0 && nx < w && ny < h && f[ny][nx] == '.'){
            wdfs(nx,ny,f);
        }
    }
    return ;
}

void bdfs(int x,int y,char f[51][51])
{
    if(f[y][x] == '.') f[y][x] = 'b';
    for(int i = 0; i < 4; i++){
        int nx = x+dx[i];
        int ny = y+dy[i];
        
        if(nx >= 0 && ny >= 0 && nx < w && ny < h && f[ny][nx] == '.'){
            
            bdfs(nx,ny,f);
        }
    }
    return ;
}

int main()
{
    while(true){
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        char white[51][51];
        char black[51][51];
        char f[51][51];
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                char c;
                cin >> c;
                white[i][j] = c;
                black[i][j] = c;
                f[i][j] = c;
            }
        }
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(f[i][j] == 'W'){
                    wdfs(j,i,white);
                } 
                if(f[i][j] == 'B'){
                    bdfs(j,i,black);
                }
            }
        }
        int wcnt = 0,bcnt = 0;
        for(int i = 0; i < h; i++){
            for(int j= 0; j < w; j++){
                if(white[i][j] == 'w' && black[i][j] == '.'){
                    wcnt++;
                }
                if(white[i][j] == '.' && black[i][j] == 'b'){
                    bcnt++;
                }
            }
        }
        cout << bcnt << ' ' << wcnt << endl;
    }
}


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

int main(){
  int n, m, x;
  int a, cost0 = 0, costn = 0;
  
  cin >> n >> m >> x;
  
  for ( int i = 0; i < m; i++ ){
    cin >> a;
    if ( a < x )
      cost0++;
    else
      costn++;
  }
  
  cout << min( cost0, costn ) << endl;
}

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

int main() {
    string S;
    cin >> S;
    bool ans = false;
    if (S[0] == S[1] && S[2] == S[3]) ans = true;
    if (S[0] == S[2] && S[1] == S[3]) ans = true;
    if (S[0] == S[3] && S[1] == S[2]) ans = true;
    if (S[0] == S[1] && S[1] == S[2] && S[2] == S[3]) ans = false;
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n, a, b, t, c;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> a >> b;
  while (n--) {
    cin >> t;
    if (t < a || t >= b)
      ++c;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.StreamSupport;

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

        while(sc.hasNext()){
            int i=0;
            String word = sc.nextLine();
            String result = "";
            for(i=0; i<word.length(); i++){
                char ch = word.charAt(i);
                if (Character.isLowerCase(ch)){
                    ch = Character.toUpperCase(ch);
                }
                else if (Character.isUpperCase(ch)){
                    ch = Character.toLowerCase(ch);
                }

                result += ch;
            }

            System.out.println(result);

        }
    }
}



Measured memory_bytes: 31536
using System; 
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq; 
using E = System.Linq.Enumerable; 


class Program {
    static void Main(string[] args) {
        
        var NAB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var A = NAB[0];
        var B = NAB[1];
        var C = NAB[2];
        var D = NAB[3];
        
        if((Math.Abs(A-B)<= D && Math.Abs(C-B)<= D)|| Math.Abs(A-C)<= D){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
        
     }
}
     
     
                   
public class PriorityQueue<T> : IEnumerable<T> { private readonly List<T> _data = new List<T>(); private readonly IComparer<T> _comparer; private readonly bool _isDescending; public PriorityQueue(IComparer<T> comparer, bool isDescending = true) { _comparer = comparer; _isDescending = isDescending; } public PriorityQueue(Comparison<T> comparison, bool isDescending = true) : this(Comparer<T>.Create(comparison), isDescending) { } public PriorityQueue(bool isDescending = true) : this(Comparer<T>.Default, isDescending) { } public void Enqueue(T item) { _data.Add(item); var childIndex = _data.Count - 1; while (childIndex > 0) { var parentIndex = (childIndex - 1) / 2; if (Compare(_data[childIndex], _data[parentIndex]) >= 0) break; Swap(childIndex, parentIndex); childIndex = parentIndex; } } public T Dequeue() { var lastIndex = _data.Count - 1; var firstItem = _data[0]; _data[0] = _data[lastIndex]; _data.RemoveAt(lastIndex--); var parentIndex = 0; while (true) { var childIndex = parentIndex * 2 + 1; if (childIndex > lastIndex) break; var rightChild = childIndex + 1; if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0) childIndex = rightChild; if (Compare(_data[parentIndex], _data[childIndex]) <= 0) break; Swap(parentIndex, childIndex); parentIndex = childIndex; } return firstItem; } public T Peek() { return _data[0]; } private void Swap(int a, int b) { var tmp = _data[a]; _data[a] = _data[b]; _data[b] = tmp; } private int Compare(T a, T b) { return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b); } public int Count => _data.Count; public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); }


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl



int main() {
    IN(int, x);
    int n500 = x/500;
    x -= n500 * 500;
    int n5 = x/5;
    COUT(n500*1000+n5*5);
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
city = []
count = 1
for i in range(M):
    p,y = map(int,input().split())
    city.append([p,y])
city_sorted = sorted(city)
for i in range(M):
    if city_sorted[i][0] == city_sorted[i-1][0] and i != 0:
        count += 1
    else:
        count = 1
    city_sorted[i][1] = count
for i in range(M):
    number_f = "0"*(6-len(str(city[i][0]))) + str(city[i][0])
    number_b = "0"*(6-len(str(city[i][1]))) + str(city[i][1])
    print(number_f + number_b)

Measured memory_bytes: 65240
N = int(input())
S = [input() for i in range(N)]

AC = 0
WA = 0
TLE = 0
RE = 0

for i in S:
  if i == "AC":
    AC += 1
  if i == "WA":
    WA += 1
  if i == "TLE":
    TLE += 1  
  if i == "RE":
    RE += 1
    
print("AC","x",AC)
print("WA","x",WA)
print("TLE","x",TLE)
print("RE","x",RE)

Measured memory_bytes: 16212
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,a[N];
bool dp[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    dp[0]=true;
    for(int i=1;i<=n;i++)
        dp[a[i]]|=dp[a[i]-1];
    int ans=-1;
    for(int i=n;i>=1;i--)
        if(dp[i])
    {
        ans=i;break;
    }
    if(ans!=-1) ans=n-ans;
    cout<<ans;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 1;
    rep(i, n - 1) if (s[i] != s[i + 1]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;

const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-13;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
long long dp[110][110];
long long dp2[110][110];

int p[110];
void solve(int a,int b,int c){
	if(dp[a][b]!=-1)return;
	if(a==b){
		int has=p[a]-c;
		dp[a][b]=0;
		dp2[a][b]=pw(2,has);
		return;
	}
	int mn=mod;
	for(int i=a;i<=b;i++){
		mn=min(mn,p[i]);
	}
	int left=a;
	vector<long long>d1;
	vector<long long>d2;
	int mc=0;
	for(int i=a;i<=b;i++){
		if(mn==p[i]){
			mc++;
			if(left<i){
				solve(left,i-1,mn);
				d1.push_back(dp[left][i-1]);
				d2.push_back(dp2[left][i-1]);
			}
			left=i+1;
		}
	}
	if(left<=b){
		solve(left,b,mn);
		d1.push_back(dp[left][b]);
		d2.push_back(dp2[left][b]);
	}
	long long ks2=1;
	for(int i=0;i<d2.size();i++)ks2=ks2*d2[i]%mod;
	dp2[a][b]=ks2*pw(2,mn-c)%mod;
	long long ks1=pw(2,mc);
	for(int i=0;i<d1.size();i++)ks1=ks1*(d1[i]+d2[i]*2)%mod;
	ks1=(ks1+mod*2-ks2*2)%mod;
	dp[a][b]=ks1;
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	for(int i=0;i<110;i++)for(int j=0;j<110;j++)dp[i][j]=-1;
	solve(0,a-1,0);
	printf("%lld\n",(dp[0][a-1]+dp2[0][a-1])%mod);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int main(){
    int n, k;
    cin >> n >> k;
    int l[n];
    rep(i, n)cin >> l[i];
    sort(l, l + n);
    int ans = 0;
    rep(i, k)ans += l[n - i - 1];
    cout << ans << endl;

}

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

const int INF = 1000000000;
const int maxn = 100 + 10;
int pa[maxn];

int findset(int x) { return x == pa[x] ? x : pa[x] = findset(pa[x]); }

struct Edge
{
    int u, v, w;
    Edge(int u, int v, int w):u(u), v(v), w(w) {}
    bool operator < (const Edge& rhs) const
    {
        return w < rhs.w;
    }
};

vector<Edge> G;

int main()
{
    //freopen("in.txt", "r", stdin);
    int n, m;
    while(scanf("%d%d", &n, &m) == 2 && n)
    {
        G.clear();
        int u, v, w;
        for(int i = 0; i < m; ++i)
        {
            scanf("%d%d%d", &u, &v, &w);
            G.push_back(Edge(u, v, w));
        }
        sort(G.begin(), G.end());
        int ans = INF;
        for(int L = 0; L <= m - n + 1; ++L)
        {
            for(int i = 1; i <= n; ++i) pa[i] = i;
            int cnt = n;
            for(int R = L; R < m; ++R)
            {
                int u = findset(G[R].u), v = findset(G[R].v);
                if(u != v)
                {
                    pa[u] = v;
                    if(--cnt == 1) { ans = min(ans, G[R].w - G[L].w); }
                }
            }
        }
        if(ans == INF) ans = -1;

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

    return 0;
}

Measured memory_bytes: 2720
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
using ll = long long;
int N, K;

ll dp[2002][2002];	// dp(n, k) = chosing k objects out of n
unsigned long long ans;

inline ll add (ll a, ll b) { return ((a%MOD) + (b%MOD))%MOD;}
inline ll mul (ll a, ll b) { return ((a%MOD)*(b%MOD))%MOD;}
void solve () {
	for (int k = 0; k <= K; k++)
		dp[0][k] = 0;
	for (int n = 0; n <= N; n++) 
		dp[n][0] = 1;
	for (int n = 1; n <= N; n++) {
		for (int k = 1; k <= K; k++) {
			dp[n][k] = add(dp[n - 1][k], dp[n - 1][k - 1]);
		}
	}
	return;
}

int main () {
	cin >> N >> K;
	solve();
	for (int i = 1; i <= K; i++) {
		ans = mul(dp[K - 1][i - 1], dp[N - K + 1][i]);
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 31488
// Last Change: 12/05/2019 19:12:36.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

struct Harvest {
  string name;
  ll price, A, B, C, D, E, F, S, M;
  double rate;
  void input() {
    cin >> name >> price >> A >> B >> C >> D >> E >> F >> S >> M;
  }

  bool operator<(const Harvest &another) const {
    if (this->rate == another.rate) {
      return this->name > another.name;
    }
    return this->rate < another.rate;
  }
  bool operator>(const Harvest &another) const {
    if (this->rate == another.rate) {
      return this->name < another.name;
    }
    return this->rate > another.rate;
  }

  void calc() {
    double income = S * F * M - price;
    double time = A + B + C + (D + E) * M;
    rate = income / time;
  }
};

void solve(ll N) {
  vector<Harvest> harvest(N);
  for (auto &&e : harvest) {
    e.input();
    e.calc();
  }
  sort(harvest.begin(), harvest.end(), greater<Harvest>());

  for (auto &&e : harvest) {
    cout << e.name << endl;
  }
  cout << '#' << endl;
}

int main() {
  ll N;
  while (cin >> N and N > 0) {
    solve(N);
  }
}


Measured memory_bytes: 3180
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;

#define PB push_back
#define MP make_pair

void Input();
void Calc();
void Output();

int N=100;
int dp[100][100]; //100...行列の最大個数
vector<int> ivr;
int n,x;

int main(int argc,char* argv[]){

  memset(dp,15,sizeof(dp));
  for(int i=0;i<=100;i++) dp[1][i]=0;
  ivr.clear();
  
  Input();
  Calc();
  Output();
  return 0;
}

void Input(){
  ivr.PB(0);
  cin>>n;
  for(int i=0;i<2;i++){
    cin>>x;
    ivr.PB(x);
  }
  for(int i=1;i<n;i++){
    cin>>x;
    cin>>x;
    ivr.PB(x);
  }
}

void Calc(){

  for(int i=2;i<=n;i++){
    for(int j=1;j<=n-i+1;j++){
      for(int k=1;k<i;k++){
	dp[i][j]=min(dp[k][j]+dp[i-k][j+k]+ivr[j]*ivr[j+k]*ivr[i+j],dp[i][j]);
      }
    }
  }
}

void Output(){
  cout<<dp[n][1]<<endl;
}

Measured memory_bytes: 1264
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <cmath>
#include <utility>
#include <algorithm>

using namespace std;

int count(int a){
	int ret = 0;
	for(int i=1;i<=a;i++){
		ret += i;
	}
	return ret;
}

int main(){

   int a,b;
   cin >> a >> b;

   int ret = count(b-a);

   cout << ret-b << endl;

return 0;
}



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

int main() {
  long long n, d;
  cin >> n >> d;
  int i;
  i = 0;
  int cnt;
  cnt = 0;
  long long x;
  long long y;
  while ( i < n)
  {
    cin >> x >> y;
    if ( d * d >= x * x + y * y)
    {
      cnt++;
    }
    i++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int W,H,K;cin >> W >> H >> K;
  bool sat = false;
  rep(x,W+1) rep(y,H+1){
    int n = x*H + y*W - 2*x*y;
    if(n==K)sat = true;
  }
  YesNo(sat);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e6+1;
int A[N],n,p,d;
LL rez,x;
bool cmp(int a,int b){
    return (a>b);
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    sort(A+0,A+n,cmp);
    int i=0;
    while(i<n){
        if(A[i]==A[i+1]){
            if(p){
                d=A[i];
                x=(LL)p*A[i];
                cout<<x;
                return 0;
            }
            p=A[i];
            int cnt=0;
            while(A[i]==A[i+1]){
                i++;
                cnt++;
            }
            if(cnt>=3){
                x=(LL)p*p;
                cout<<x;
                return 0;
            }
        }
        else
            i++;
    }
    x=(LL)p*d;
    cout<<x;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 200010;

vvl G;
vl ans(MAX_N);

void dfs(ll v, ll p = -1) {
    for(auto u : G[v]) {
        if(u == p) {
            continue;
        }
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {
    ll n, q;
    cin >> n >> q;    

    G.resize(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    rep(i, q) {
        ll p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    
    dfs(0);

    rep(i, n) {
        out(ans[i]);
    }
    
    re0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
char s[3],t[3];
cin >> s >> t;
int ans = 0;
REP(i,3) {
  if(s[i]==t[i]) ans++;
}
cout << ans << endl;

return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n = ni()
a = li()

a_diff = []
ans = 1
for i in range(n-1):
    a_diff.append(a[i+1] - a[i])
    
cur = 0
for i in range(n-1):
    if cur == 0:
        if a_diff[i] == 0:
            continue
        elif a_diff[i] > 0:
            cur = +1
        else:
            cur = -1
            
    elif cur == +1:
        if a_diff[i] >= 0:
            continue
        else:
            cur = 0
            ans += 1
            
    elif cur == -1:
        if a_diff[i] <= 0:
            continue
        else:
            cur = 0
            ans += 1
            
    else:
        print("バグってます／(^o^)＼")
            
        
print(ans)

Measured memory_bytes: 14168
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n;
    cin >> n;
    vector<double>p(n);
    rep(i,n) cin >> p[i];
    vector<vector<double>>dp(n,vector<double>(n+1));
    rep(i,n){
        rep(j,n+1){
            if(j>i+1)break;
            if(i==0){
                if(j==0)dp[i][j]=1-p[i];
                else dp[i][j]=p[i];
            }
            else{
                if(j==0){
                    dp[i][j]=dp[i-1][j]*(1-p[i]);
                }
                else if(i+1==j){
                    dp[i][j]=dp[i-1][j-1]*p[i];
                }
                else{
                    dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
                }
            }
        }
    }
    double ans=0;
    int lim=(n+1)/2;
    for(int i=lim;i<=n;i++){
        ans+=dp[n-1][i];
    }
    printf("%.12lf\n",ans);
    return 0;
}


Measured memory_bytes: 70784
package main

import "fmt"

func main(){
	var n,m,d float64
	fmt.Scan(&n,&m,&d)
	var ans float64
	if d == 0 {
		ans = (m-1)/n
	} else {
		ans = 2 * (n-d) / (n * n) * (m-1)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

int main(){
string str;
set <string> co;

int n;

cin >> n;
 for(int i=0;i<n;i++){
   cin >> str;
   string s[4];
   for(int j=1;j<str.size();j++){
     s[0] = s[2] = str.substr(0,j);
     s[1] = s[3] = str.substr(j);
     reverse(s[2].begin(),s[2].end());
     reverse(s[3].begin(),s[3].end());
     // reverse(str.begin(),str.end());
     //s[2] = str.substr(0,j);
     //s[3] = str.substr(j);
     for(int k=0;k<4;k+=2){
       for(int l=1;l<4;l+=2){
	 //cout << s[k] << "+" << s[l] << endl;
	 co.insert(s[k]+s[l]);
	 //cout << s[l] << "+" << s[k] << endl;
	 co.insert(s[l]+s[k]);
       }
     }
   }
   cout << co.size() << endl;
   co.clear();
 }
 return 0;
}

     
       

Measured memory_bytes: 1292