akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OJcsharp
{
    class Program
    {
        static bool sannkaku(string s)
        {
            string[] str = s.Split(' ');
            double x1 = double.Parse(str[0]), y1 = double.Parse(str[1]), x2 = double.Parse(str[2]), y2 = double.Parse(str[3]), x3 = double.Parse(str[4]), y3 = double.Parse(str[5]), xp = double.Parse(str[6]), yp = double.Parse(str[7]);
            double z1 = (x3 - x2) * (yp - y2) - (y3 - y2) * (xp - x2), z2 = (x1 - x3) * (yp - y3) - (y1 - y3) * (xp - x3), z3 = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1);
            if ((z1 > 0 && z2 > 0 && z3 > 0) || (z1 < 0 && z2 < 0 && z3 < 0))
                return true;
            else
                return false;
        }
        static void Main(string[] args)
        {
            bool[] ans = new bool[100];
            int count = 0;
            string str=Console.ReadLine();
            do
            {
                ans[count] = sannkaku(str);
                str=Console.ReadLine();
                count++;
            } while (String.IsNullOrEmpty(str) == false);
            for (int n = 0; n < count; n++)
            {
                if (ans[n] == true)
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 5780
fun main(args: Array<String>){
    val N = nextInt()
    val D = listOfInt()
    var ans = 0L
    for (n in 0 until N-1) {
        for (m in n+1 until N) {
            ans += D[n] * D[m]
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toLong() }

Measured memory_bytes: 37824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e5+10,mo=1e9+7;
ll f[N][3][3],n;
char s[N];
void move(ll &a,ll b){
	a=(a+b)%mo;
}
int main(){
	scanf("%s",s+1);
	f[0][0][0]=1;
	n=strlen(s+1);
	for (int i=1;s[i];i++){
		for (int x=0;x<=2;x++)
		for (int y=0;y<=2;y++){
			if (s[i]!='1'){
				if (y==2)
					move(f[i][x][1],f[i-1][x][y]);
				else 
					move(f[i][x][y+1],f[i-1][x][y]);
			}
			if (s[i]!='0'){
				if (y)
					move(f[i][x][y-1],f[i-1][x][y]);
				else 
					move(f[i][min(2,x+1)][y],f[i-1][x][y]);
			}
		}
	}
	ll ans=0;
	for (int x=0;x<=2;x++)
	for (int y=0;y<=x;y++)
		move(ans,f[n][x][y]);
	cout<<ans<<endl;
}

Measured memory_bytes: 21632
import java.util.Scanner;

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

		int n = scan.nextInt();
		int k = scan.nextInt();

		String[] d = new String[k];
		for(int i = 0; i < k; i++){
			d[i] = scan.next();
		}

		for(int i = n; i < 10*n; i++){
			int count = 0;
			for(int j = 0; j < k; j++){
				if(!String.valueOf(i).contains(d[j])){
					count ++;
				}
			}
			if(count == k){
				System.out.println(i);
				return;
			}
		}
	}
}


Measured memory_bytes: 40912
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
using Graph = vector<vector<pair<int, int> > >;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

int dp[100110];

int main() {
	int N; cin >> N;
	dp[0] = 0;
	for (int i = 1; i <= N; i++) {
		dp[i] = dp[i - 1] + 1;
		int sixes = 6;
		while (i - sixes >= 0) {
			dp[i] = min(dp[i], dp[i - sixes] + 1);
			sixes *= 6;
		}
		int nines = 9;
		while (i - nines >= 0) {
			dp[i] = min(dp[i], dp[i - nines] + 1);
			nines *= 9;
		}
	}
	cout << dp[N] << endl;





	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define MP make_pair
#define PB push_back
typedef long long LL;
const LL P = 998244353;
const int N = 1e5+10;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

struct dat{
	int a,b;
}a[N];
int n,m,fa[N];

int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}

int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n)scanf("%d%d",&a[i].a,&a[i].b);
	sort(a+1,a+n+1,[](dat a,dat b){return a.b>b.b;}); 
	rep(i,1,m)fa[i]=i;
	LL ans = 0;
	rep(i,1,n){
		if(m-a[i].a+1<=0)continue;
		int j = find(m-a[i].a+1);
		if(j<=0)continue;
		ans += 1ll * a[i].b;
		fa[j] = j-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(std::string S) {
  int cnt = 0;
  rep(i, 3) {
    if (S.at(i) == 'o') cnt++;
  }

  cout << 700 + 100 * cnt << endl;
}

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


Measured memory_bytes: 3612
#include <stdio.h>

int main() {
  int a, b;
  int x;
  scanf("%d %d", &a, &b);
  if ((a % 2 == 1 && b % 2 == 0) || (a % 2 == 0 && b % 2 == 1)) {
    x = (a + b) / 2 + 1;
  }
  else {
    x = (a + b) / 2;
  }
  printf("%d\n",x);
  return 0;
}


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

int main() {
  int K;
  string S;
  cin>>K;
  cin>>S;
  int a=S.size();
  if(a<=K){
    cout<<S<<endl;
  }
  else{
    for(int i=0;i<K;i++){
      cout<<S.at(i);
    }
    cout<<"..."<<endl;
  }
}


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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    vector<long long> acc(n+1, 0);
    priority_queue<long long> pq;
    pq.push(0);
    for (int i = 0; i < n; i++) {
        acc[i+1] = acc[i] + a[i];
        pq.push(acc[i+1]);
    }

    long long now = pq.top(); pq.pop();
    long long cnt = 1;
    long long ans = 0;
    for (int i = 0; i < n; i++){
        if (now == pq.top()) cnt++;
        else {
            if (cnt > 1) ans += cnt * (cnt - 1) / 2;
            now = pq.top();
            cnt = 1;
        }
        pq.pop();
    }
    if (cnt > 1) ans += cnt * (cnt - 1) / 2;
    
    cout << ans << endl;
}

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

int main() {
    ll x, money = 100;
    ll year = 0;
    cin >> x;
    while(1) {
        year++;
        money = money + money / 100;
        if(money >= x) {
            cout << year << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef long long llint;
typedef vector<long long int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	int N, K;
	string S;
	cin >> N >> K >> S;
	S[K - 1] -= 'A'-'a';
	cout << S << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long 
ll dp[5050],A,B;
int a[5050],n;
int main(){
	memset(dp,63,sizeof dp);
	scanf("%d",&n);
	scanf("%lld%lld",&A,&B);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	a[n+1]=n+1;
	dp[0]=0;
	for (int i=1;i<=n+1;i++){
		int g=0;
		for (int j=i-1;j>=0;j--)
			if (a[j]>a[i])g++;
			else dp[i]=std::min(dp[i],dp[j]+A*g+B*(i-j-1-g));
	}
	printf("%lld",dp[n+1]);
} 

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


int main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i,n){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y.begin(), y.end());
    int m1 = y[n/2-1], m2 = y[n/2];

    rep(i,n){
        if(x[i] <= m1){
            cout << m2 << endl;
        }else{
            cout << m1 << endl;
        }
    }
}



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

int main()
{
  vector<int> ans(8, 0);
  vector<double> eye(2);
  while (cin >> eye[0] >> eye[1]) {
    for (int i = 0; i < 2; ++i) {
      if (eye[i] >= 1.1)
	++ans[0+i];
      else if (eye[i] >= 0.6)
	++ans[2+i];
      else if (eye[i] >= 0.2)
	++ans[4+i];
      else
	++ans[6+i];
    }
  }

  for (int i = 0; i < 8; i += 2)
    cout << ans[i] << " " << ans[i+1] << endl;

  return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353LL
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
class Point{
public:
	long double x;
	long double y;
	const Point operator*(const long double &a) {
		Point ans;
		ans.x = x * a;
		ans.y = y * a;
		return ans;
	}
	const Point operator=(const Point &a){
		x = a.x;
		y = a.y;
		return *this;
	}
	const Point operator+(const Point &a) const{
		Point ans;
		ans.x = a.x + x;
		ans.y = a.y + y;
		return ans;
	}
	const Point operator+=(const Point &a){
		x += a.x;
		y += a.y;
		return *this;
	}
	const Point operator-(const Point &a) const{
		Point ans;
		ans.x = x - a.x;
		ans.y = y - a.y;
		return ans;
	}
	const Point operator-=(const Point &a) {
		x -= a.x;
		y -= a.y;
		return *this;
	}
	static long double inner(const Point &a, const Point &b) {
		return a.x * b.x + a.y * b.y;
	}
	static long double cross(const Point &a, const Point &b) {
		return a.x * b.y - a.y * b.x;
	}
	static Point norms(const Point &a) {
		long double hoge = abs(a);
		Point ans;
		ans.x = a.x / hoge;
		ans.y = a.y / hoge;
		return ans;
	}
	static long double abs(const Point &a) {
		return sqrtl(a.x * a.x + a.y * a.y);
	}
};
int main(){
	int n;
	cin >> n;
	vector<Point> input(n + 2);
	REP(i, n) {
		cin >> input[i].x >> input[i].y;
	}
	input[n] = input[0];
	input[n + 1] = input[1];
	for (int i = 1; i < n; ++i) {
		long double a = Point::cross(input[i] - input[i - 1], input[i + 1] - input[i]);
		long double b = Point::cross(input[i + 1] - input[i], input[i + 2] - input[i + 1]);
		if (a*b < 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << 1 << endl;
	return 0;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;
int h, w, k;
string s[12];

ll go (ll ver) {
    vector <pair<int, int>> cut;
    pair<int, int> p;
    p.first = 0;
    p.second = -1;
    ll ans = 0; 
    for (int j=0; j<h-1; j++) {
        if (ver & (1<<j)) {
            //there is a cut
            ans++;
            p.second = j;
            cut.push_back (p);
            p.first = j+1;
        }
    }
    p.second = h-1;
    cut.push_back (p);
    int n = cut.size();
    ll val[n+2] = {0};
    //find horizontal cuts
    for (int i=0; i<w; i++) {
        int ok = 1;
        for (int j=0; j<n; j++) {
            p = cut[j];
            for (int k1=p.first; k1<=p.second; k1++) {
                if (s[k1][i] == '1')
                    val[j]++;
            }
            if (val[j] > k) {
                ok = 0;
                ans++;
                break;
            }
        }
        if (ok == 0) {
            for (int j=0; j<n; j++) {
                val[j] = 0;
                p = cut[j];
                for (int k1=p.first; k1<=p.second; k1++) {
                    if (s[k1][i] == '1')
                        val[j]++;
                }
                if (val[j] > k) {
                    return inf;
                }
            }
        }
    }
    return ans;
}

void testCase() {
    cin >> h >> w >> k;
    for (int i=0; i<h; i++)
        cin >> s[i];
    ll ans = inf;
    for (ll i=0; i<(1ll << (h-1)); i++) {
        ans = min (ans, go(i));
    }
    cout << ans << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 256
// D - Wizard in Maze
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int h, w;
	cin >> h >> w;
	int cx, cy, dx, dy;
	cin >> cx >> cy >> dx >> dy;
	cx--; cy--; dx--; dy--;
	vector<string> s(h);
	for (int i = 0; i < h; i++) cin >> s[i];

	int id = 0;
	vector<vector<int>> vi(h, vector<int>(w));
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) {
			if (vi[i][j] || s[i][j] == '#') continue;
			queue<pair<int, int>> q;
			q.push({i, j});
			vi[i][j] = ++id;
			for ( ; !q.empty(); q.pop()) {
				int x = q.front().first, y = q.front().second;
				if (x - 1 >= 0 && s[x - 1][y] == '.' && vi[x - 1][y] == 0) vi[x - 1][y] = vi[x][y], q.push({x - 1, y});
				if (x + 1 < h && s[x + 1][y] == '.' && vi[x + 1][y] == 0) vi[x + 1][y] = vi[x][y], q.push({x + 1, y});
				if (y - 1 >= 0 && s[x][y - 1] == '.' && vi[x][y - 1] == 0) vi[x][y - 1] = vi[x][y], q.push({x, y - 1});
				if (y + 1 < w && s[x][y + 1] == '.' && vi[x][y + 1] == 0) vi[x][y + 1] = vi[x][y], q.push({x, y + 1});
			}
		}

	vector<int> dist(h * w, -1);
	auto sp = [&](int src) {
		dist[src] = 0;
		priority_queue<pair<int, int>> q;
		for (q.push(make_pair(0, src)); !q.empty(); ) {
			int u = q.top().second;
			q.pop();
			int x = u / w, y = u % w;
			for (int xx = x - 2; xx <= x + 2; xx++)
				for (int yy = y - 2; yy <= y + 2; yy++) {
					if (xx < 0 || xx >= h || yy < 0 || yy >= w) continue;
					if (s[xx][yy] != '.') continue;
					// if (vi[x][y] != vi[xx][yy]) cout << "!!!!!" << endl;
					int v = xx * w + yy, d = dist[u] + (vi[x][y] == vi[xx][yy] ? 0 : 1);
					if (dist[v] < 0 || d < dist[v]) {
						dist[v] = d;
						q.push({-d, v});
					}
				}
		}
	};

	sp(cx * w + cy);
	cout << dist[dx * w + dy] << endl;

	return 0;
}


Measured memory_bytes: 12348
#include <stdio.h>

int main(){
  double x,t,y,n;
  while(scanf("%lf",&x)!=EOF){
    t=x/9.8;
    y=4.9*t*t;
    n=(y+5)/5;
    if ((int)n!=n)n++;
    printf("%d\n",(int)n);
  }

  return 0;
}

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

int n, k, a[100001], b[100001], c[100001], dp[100001][3];
int main() {
	cin >> n;
	rep(i, n) cin >> a[i] >> b[i] >> c[i];
	rep(i, n) {
		dp[i + 1][0] = max({ dp[i + 1][0], dp[i][1] + b[i], dp[i][2] + c[i] });
		dp[i + 1][1] = max({ dp[i + 1][1], dp[i][0] + a[i], dp[i][2] + c[i] });
		dp[i + 1][2] = max({ dp[i + 1][2], dp[i][0] + a[i], dp[i][1] + b[i] });
	}
	cout << max({ dp[n][0],dp[n][1] ,dp[n][2] }) << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <complex>
#include <cstdio>
#include <cmath>
using namespace std;

// 点座標を型とする
typedef complex<double> P;
// πの定義
#define PI 3.1415926535898

// 許容する誤差ε
#define EPS (1e-10)
//XY座標
#define X real()
#define Y imag()
	
// 三角形クラス
class Triangle{

private:
	//三角形の３点の座標
	P a, b, c;
	//三角形の３辺の長さ
	double edgeA,edgeB,edgeC;
	//三角形の３角の大きさ(ラジアン)
	double angleA,angleB,angleC;
	//余弦定理から３つの角度を求める関数
	double LawOfCosines(double a,double b, double c){
		return acos( (b*b+c*c-a*a) / (2.0*b*c) );
	}
	//２つのdouble型の数値が等しいかどうか
	bool equal(double a, double b){
		return (abs( a-b ) < EPS)? true : false ;
	}

public:
	//コンストラクタ(３つの点と辺と角度を初期化)
	Triangle(P p1, P p2, P p3){
		a = p1;
		b = p2;
		c = p3;
		edgeB = abs(c-a);
		edgeA = abs(b-c);
		edgeC = abs(a-b);
		angleA = LawOfCosines(edgeA,edgeB,edgeC);
		angleB = LawOfCosines(edgeB,edgeC,edgeA);
		angleC = LawOfCosines(edgeC,edgeA,edgeB);
	}
	
	double circumscribedCircleRadius(){//外接円の半径を返す
		return ( edgeA / sin(angleA) / 2.0 );
	}
	double circumscribedCircleX(){//外心(外接円の中心)のX座標を返す
		double A = sin(2.0*angleA);
		double B = sin(2.0*angleB);
		double C = sin(2.0*angleC);
		return ( (a.X * A + b.X * B + c.X * C) / (A+B+C) );
	}
	double circumscribedCircleY(){//外心(外接円の中心)のY座標を返す
		double A = sin(2.0*angleA);
		double B = sin(2.0*angleB);
		double C = sin(2.0*angleC);
		return ( (a.Y * A + b.Y * B + c.Y * C) / (A+B+C) );
	}
};

int main(){
	int n;
	double x1, x2, x3, y1, y2, y3;
	double r, xp, yp;

	scanf("%d", &n);
	for (int i=0 ; i<n ; i++){
		scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
		P a( x1 , y1 );
		P b( x2 , y2 );
		P c( x3 , y3 );
		Triangle Tr(a,b,c);
		r  = Tr.circumscribedCircleRadius();
		xp = Tr.circumscribedCircleX();
		yp = Tr.circumscribedCircleY();
		printf("%.3f %.3f %.3f\n", xp,yp,r);
	}
}

Measured memory_bytes: 1176
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#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 chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#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 = 100010;

int main() {
    string s;
    cin >> s;
    string x = "keyence";

    if(s == x) {
        out("YES");
        re0;
    }

    ll n = s.size();
    rep(i, n) {
        exrep(j, i, n-1) {
            string t = "";
            rep(k, n) {
                if(i <= k && k <= j) {
                    continue;
                }
                t.pb(s[k]);
            }
            if(t == x) {
                out("YES");
                re0;
            }
        }
    }
    
    out("NO");
    re0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 99999999

using namespace std;


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


ll m = 1000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

int a[100010];
int main() {
	REP(i, 100010)a[i] = 0;
	int N;
	cin >> N;
	REP(i, N) {
		int x;
		cin >> x;
		if (x == 0) {
			a[0]++; a[1]++;
			continue;
		}
		else {
			a[x - 1]++; a[x]++; a[x + 1]++;
		}
	}
	int ans = 0;
	REP(i, 100001) {
		ans = max(ans, a[i]);
	}
	cout << ans << endl;

}

Measured memory_bytes: 640
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

template<typename T>
struct BIT {
  vector<T> data;
  BIT() {}
  BIT(int n) : data(n+1, 0) {}
  void init(int n) { data.assign(n+1, 0); }
  T sum(int ed) const {
    for(T res(0); ; ed &= ed-1) if(ed) res += data[ed]; else return res;
  }
  T total(void) const { return sum(data.size()-1); }
  void add(int i, const T& x) {
    for(++i; i < (int)data.size(); i += i&-i) data[i] += x;
  }
};
template<typename T> struct Compression {
  vector<T> idx2orig;
  Compression(const vector<T>& values): idx2orig(values) {
    sort(idx2orig.begin(), idx2orig.end());
    idx2orig.erase(unique(idx2orig.begin(), idx2orig.end()), idx2orig.end());
  }
  int toIndex(const T& orig) const { return lower_bound(orig); }
  int fromIndex(int idx) const { assert(0 <= idx && idx < (int)idx2orig.size()); return idx2orig[idx]; }
  int size(void) const { return idx2orig.size(); }
  int lower_bound(const T& orig) const { return std::lower_bound(idx2orig.begin(), idx2orig.end(), orig) - idx2orig.begin(); }
  int upper_bound(const T& orig) const { return std::upper_bound(idx2orig.begin(), idx2orig.end(), orig) - idx2orig.begin(); }
};

int n;
int xs[100000+10];
int vs[100000+10];
int cs[100000+10];

bool isOK(int md) {
  // cerr << "> " << md << endl;
  cs[0] = 0;
  REP(i, n) {
    vs[i] = xs[i] < md ? -1 : 1;
    cs[i+1] = cs[i] + vs[i];
  }
  // cerr << "vs: ";
  // REP(i, n) {
  //   cerr << vs[i] << " ";
  // }
  // cerr << endl;
  // cerr << "cs1: ";
  // REP(i, n+1) {
  //   cerr << cs[i] << " ";
  // }
  // cerr << endl;
  vector<int> vvs;
  REP(i, n+1) {
    vvs.push_back(cs[i]);
  }
  Compression<int> c(vvs);
  REP(i, n+1) {
    cs[i] = c.toIndex(cs[i]);
  }
  // cerr << "cs2: ";
  // REP(i, n+1) {
  //   cerr << cs[i] << " ";
  // }
  // cerr << endl;
  const ll threshold = (ll(n+1)*n/2+1)/2;
  ll tr = 0;
  BIT<int> bit(c.size()+10);
  REP(i, n+1) {
    // cerr << "tr = " << tr << endl;
    tr += bit.total() - bit.sum(cs[i]+1);
    bit.add(cs[i], 1);
  }
  // cerr << "tr = " << tr << endl;
  return ll(n+1)*n/2-tr >= threshold;
}

int main(void) {
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &xs[i]);
  }

  int left = 0;
  int right = 1000000001;
  while(left+1 < right) {
    int md = (left+right) / 2;
    if(isOK(md)) {
      left = md;
    } else {
      right = md;
    }
  }
  printf("%d\n", left);
  return 0;
}


Measured memory_bytes: 2772
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> v(n);
    rep(i, 0, n)
        cin >> v[i];
    vector<vector<ll>> dp(n, vector<ll>(n, 0));
    if (n % 2 != 0)
    {
        rep(i, 0, n)
            dp[i][i] = v[i];
        rep(len, 2, n + 1)
        {
            rep(i, 0, n - len + 1)
            {
                ll j = i + len - 1;
                if (len % 2 != 0)
                    dp[i][j] = max(dp[i+1][j] + v[i], dp[i][j-1] + v[j]);
                else 
                    dp[i][j] = min(dp[i+1][j] - v[i], dp[i][j-1] - v[j]);
            }
        }
    }
    else
    {
        rep(i, 0, n)
            dp[i][i] = - v[i];
        rep(len, 2, n + 1)
        {
            rep(i, 0, n - len + 1)
            {
                ll j = i + len - 1;
                if (len % 2 == 0)
                    dp[i][j] = max(dp[i+1][j] + v[i], dp[i][j-1] + v[j]);
                else 
                    dp[i][j] = min(dp[i+1][j] - v[i], dp[i][j-1] - v[j]);
            }
        }
    }
    cout << dp[0][n-1];
    return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int ans[32] =  {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int k;

  cin >> k;

  cout << ans[--k];

  return 0;
}
/*

*/


Measured memory_bytes: 3540
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

int done[33][33];

signed main(){
  int w,h;
  while(cin>>w>>h&&w&&h){
    bool wall[35][35][5];
    for(int i=0; i<33; i++) for(int j=0; j<33; j++) for(int k=0; k<=4; k++) {wall[i][j][k]=false; done[i][j]=INF;}
    
    for(int i=1; i<=2*h-1; i++){
      int tate=(i+1)/2;
      if(i%2){
        for(int j=1; j<w; j++){
          int a;
          cin>>a;
          if(a==1){
            wall[tate][j][1]=true;
            wall[tate][j+1][3]=true;
          }
        }
      }else{
        for(int j=1; j<=w; j++){
          int a;
          cin>>a;
          if(a==1){
            wall[tate][j][2]=true;
            wall[tate+1][j][0]=true;
          }
        }
      }
    }
    
    
    queue<P> que;
    que.push(mk(1,1));
    done[1][1]=1;
    
    int fast=INF;
    while(!que.empty()){
      int y=que.front().first,x=que.front().second;
      if(y==h&&x==w){
        fast=min(fast,done[y][x]);
      }
      que.pop();
      for(int k=0; k<4; k++){
        int new_y=y+dy[k],new_x=x+dx[k];
        if(wall[y][x][k]==false && new_x>=1 && new_y<=h && new_y>=1 && new_x<=w && done[new_y][new_x]==INF){
          done[new_y][new_x]=done[y][x]+1;
          que.push(mk(new_y,new_x));
        }
      }
    }
    
    
    if(fast==INF){
      cout<<0<<en;
    }else{
      cout<<fast<<en;
    }
  }
}



Measured memory_bytes: 3052
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.....╬╬............
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬..╬.╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.....╬..........
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬..╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.╬....╬╬╬╬╬╬╬...╬╬╬╬╬╬╬╬╬╬......╬......
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬..╬...╬╬╬╬╬╬╬..╬......╬╬╬╬..╬╬╬╬........
# ╬╬╬╬╬╬╬╬╬╬╬╬╬.╬╬.╬....╬╬╬╬╬╬╬╬╬........╬.╬........╬╬.╬╬╬....................
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬....╬.....╬╬╬...........╬.╬╬╬....╬..╬╬..╬╬╬╬╬╬╬╬..............
# ╬╬╬╬╬╬.╬╬╬╬╬╬╬╬........................╬╬╬╬╬╬╬╬╬..╬...╬╬╬╬╬╬╬╬...╬╬╬........
# ╬╬..╬╬╬..╬╬╬╬.....╬╬╬╬╬..................╬╬╬╬╬╬╬.......╬╬.╬╬╬╬..╬....╬......
# ╬╬......╬...╬╬╬╬╬╬╬╬╬╬╬.╬.................╬╬╬╬.........╬..╬╬╬...........╬...
# ╬╬.......╬╬╬╬╬....╬..................................╬....╬╬...............╬
# ╬╬.....╬╬╬╬╬╬╬╬....................................╬╬....╬..................
# ╬╬.....╬╬╬╬╬╬╬╬╬╬╬╬╬╬......................╬..........╬.....................
# ╬╬╬╬..╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬......................................╬................
# ╬╬╬╬╬.......╬╬╬╬╬..........................................╬................
# ╬╬╬╬╬╬╬....................................╬╬╬..............................
# ╬╬╬╬╬╬╬╬╬╬..........................╬..╬╬╬╬╬╬╬╬.............................
# ╬╬╬╬╬╬╬╬╬.╬..╬..................╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.........╬...................
# ╬╬╬╬╬╬╬╬╬╬╬╬..................╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬........╬....................
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬................╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.......╬......................
# ╬....╬╬╬╬╬╬╬╬╬╬╬.................╬╬╬╬╬╬╬╬╬╬.................................
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬...........................................................
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.╬╬...........................╬............................

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    if v[i] - c[i] > 0:
        ans += v[i] - c[i]

print(ans)

Measured memory_bytes: 3060
k = int(input())

arr = [0] * (k+1)
r = 7 % k
ans = 1

while arr[r] == 0:
    if r == 0:
        print(ans)
        exit()
    arr[r] += 1
    r = (10 * r + 7) % k
    ans += 1

print(-1)

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

int Watchman(int N, int D){
    int num_watchman=1;
    int Watchman_view = 2*D+1;
    
    while(N>num_watchman*Watchman_view){
        num_watchman++;
    }
    return num_watchman;
}

int main(){
    int N,D; cin >> N >> D;
    cout << Watchman(N,D) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main()
{
	ll x,k,d;
	cin>>x>>k>>d;
	if(abs(x)/d<=k)
	{	
		if((k-abs(x)/d)%2==0){
			cout<<abs(x)%d<<"\n";
		}
		else
			cout<<abs(abs(x)%d-d)<<"\n";
	}
	else
		cout<<abs(x)-k*d<<"\n";
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X.at(i);
  }
  int P = 0;
  int sum = 0;
  int sum2 = 0;
  for (int i = 0; i < N; i++) {
    sum += X.at(i);
    sum2 += X.at(i) * X.at(i);
  }
  P = sum / N;
  
  int power1 = 0;
  int power2 = 0;
  power1 = sum2 - 2 * P * sum + N * P * P;
  power2 = sum2 - 2 * (P + 1) * sum + N * (P + 1) * (P + 1);
  
  
  cout << min(power1, power2) << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    input = lambda : sys.stdin.readline().rstrip()
    sys.setrecursionlimit(max(1000, 10**9))


    from collections import defaultdict
    from queue import deque

    n = int(input())
    ns = defaultdict(set)
    for u in range(n):
        for v,b in enumerate(map(int, input())):
            if b:
                ns[u].add(v)
                ns[v].add(u)

    best = -1
    for start in range(n):
        q = deque([])
        seen = [False] * n
        vals = [-1] * n
        seen[start] = True
        vals[start] = 0
        v = 0
        q.appendleft((start, v))
        while q:
            u, val = q.pop()
            for v in ns[u]:
                if not seen[v]:
                    q.appendleft((v, val+1))
                    seen[v] = True
                    vals[v] = val + 1
                elif vals[v]==val:
                    print(-1)
                    return
        best = max(best, val+1)
    print(best)
main()

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

int main() {
  int H, W;
  cin >> H >> W;
  
  string Si;
  vector<vector<int> > is_bomb(H, vector<int>(W));
  vector<vector<int> > bomb_num(H + 2, vector<int>(W + 2));

  for (int i = 0; i < H; i++){
    cin >> Si;
    for (int j = 0; j < W; j++){
      if (Si.at(j) == '#') is_bomb.at(i).at(j) = 1;
    }
  }

  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (is_bomb.at(i).at(j) == 1) {
        for (int k = 0; k < 3; k++){
          for (int l = 0; l < 3; l++){
            bomb_num.at(i + k).at(j + l) += 1;
          }
        }
      }
    }
  }

  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cout << (is_bomb.at(i).at(j) == 1 ? "#" : to_string(bomb_num[i + 1][j + 1]));
    }
    cout << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<long> vl;
typedef vector<vector<long> > vvl;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

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

    long count = 0;
    for (int a = 0; a <= A; ++a) {
        for (int b = 0; b <= B; ++b) {
            for (int c = 0; c <= C; ++c) {
                if (500 * a + 100 * b + 50 * c == X) {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
const double eps=1e-9;
double ABS(double n){return n>=0?n:-n;}
bool same(double a,double b){return ABS(a-b)<eps;}
struct point{
	double x;
	double y;
	point(){}
	point(double a,double b){x=a;y=b;}
	point operator +(const point &a){return point(x+a.x,y+a.y);}
	point operator -(const point &a){return point(x-a.x,y-a.y);}
	point operator *(const double &a){return point(x*a,y*a);}
	point operator /(const double &a){return point(x/a,y/a);}
	void operator =(const point &a){x=a.x;y=a.y;}
	void operator +=(const point &a){x+=a.x;y+=a.y;}
	void operator -=(const point &a){x-=a.x;y-=a.y;}
	void operator *=(const double &a){x*=a;y*=a;}
	void operator /=(const double &a){x/=a;y/=a;}
	bool operator <(const point &a){return x<a.x||(same(x,a.x)&&y<a.y);}
	bool operator ==(const point &a){return same(x,a.x)&&same(y,a.y);}
	double length(){return sqrt(x*x+y*y);}
	void in(){scanf("%lf%lf",&x,&y);}
	void out(){printf("%.20lf %.20lf\n",x,y);}
};
struct line{
	double A;
	double B;
	double C;
	line(){}
	line(double a,double b,double c){A=a;B=b;C=c;}
	line(point a,point b){
		A=a.y-b.y;
		B=b.x-a.x;
		C=A*a.x+B*a.y;
	}
	line(double a,double b,point p){
		A=a;
		B=b;
		C=A*p.x+B*p.y;
	}
};
struct segment{
	point a;
	point b;
	segment(){}
	segment(point x,point y){a=x;b=y;}
};
double dist(point a,point b){return (a-b).length();}
double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-b.x*a.y;}
//angle only returns positive value
double angle(point a,point b){return acos(dot(a,b)/(a.length()*b.length()));}
double area(point a,point b,point c){return ABS(cross(b-a,c-a));}
double distancetoline(point a,line b){return (b.A*a.x+b.B*a.y-b.C)/sqrt(b.A*b.A+b.B*b.B);}
bool parallel(line a,line b){return same(a.A*b.B,b.A*a.B);}
point intersect(line a,line b){
	double x,y,det;
	x=(a.C*b.B-b.C*a.B);
	y=(a.A*b.C-b.A*a.C);
	det=(a.A*b.B-b.A*a.B);
	return point(x,y)/det;
}
/*
bool intersect(segment a,segment b){}
point intersect(segment a,segment b){}
*/
point projection(point a,point b){return b*(dot(a,b)/(b.length()*b.length()));}
point projection(point a,line b){return intersect(line(b.B,-b.A,a),b);}
int main(){
	point from,to,p;
	line l;
	int q;
	from.in();
	to.in();
	l=line(from,to);
	scanf("%d",&q);
	while(q--){
		p.in();
		projection(p,l).out();
	}
}



Measured memory_bytes: 2760
#include<iostream>
using namespace std;
 
int gcd(int x,int y){
  if(x<y){
    swap(x,y);
  }
  while(y>0){
    int r=x%y;
    x=y;
    y=r;
  }
  return x;
}
 
int main(){
  int x,y;
  cin >> x >> y;
  cout << gcd(x,y) << endl;
 
  return 0;
}


Measured memory_bytes: 3096
use std::io::Read;

fn input() -> (i32,Vec<i128>) {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n:i32 = iter.next().unwrap().parse().unwrap();
    let a:Vec<i128> = (0..n).map(|_|{iter.next().unwrap().parse().unwrap()}).collect();
    (n,a)
}

fn main() {
    let (_,a) = input();
    let mut sum:i128 = 1;
    let inf:i128 = 1e18 as i128 + 1;
    for v in a {
        sum *= v;
        if sum>=inf{
            sum = inf
        }
    }
    if sum >= inf {
        sum = -1;
    }
    println!("{}",sum);
}



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

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	cout << a.size() << endl;
}

Measured memory_bytes: 256
mod = (10 ** 9) + 7
N, K = map(int, input().split())
A = list(map(int, input().split()))

ten_f = 0
ten_l = 0

for i in range(N):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            ten_f += 1

for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            ten_l += 1

ans = (ten_f * (K)) + ((K * ((K - 1)) // 2) * ten_l)
print(ans % mod)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mx INT_MAX
#define mn INT_MIN
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define itr set<int> :: iterator
const int N = 1e5+10;

int n, m;
int dp[100011];

int dfs(vector<int> adj[], int v){

  //  vis[v] = true;
    if(dp[v] != -1)
        return dp[v];

    if(adj[v].size()==0){
        dp[v] = 0;
        return 0;
    }
    
    int res = mn;
    for(int u=0; u<adj[v].size(); u++){
        int x = adj[v][u];
        int t = 1 + dfs(adj, x);
        res = max(res, t);
    }

    dp[v] = res;
    return res;
}

int main(){
    // ******* START HERE ******

    cin>>n>>m;

    vector<int> adj[n+1];
    memset(dp, -1, sizeof(dp));

    for(int i=0; i<m; i++){
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
    }

    int res = mn;
    for(int i=1; i<=n; i++){
     //   vector<int> vis(n+1);
        res = max(res, dfs(adj, i));
    }

    cout<<res<<endl;
    // ***** END HERE ***** 
    return 0;
}

Measured memory_bytes: 11328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    double L; //1-1000

    //標準入力
    cin >> L;

    //極力等しい長さで分けるのが正しい？
    double volume;
    volume = (L*L*L)/27;

    cout << fixed;
    cout << setprecision(12) << volume << endl;

    return 0;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
t = list(map(int, input().split()))

u = []
for i in range(1,N):
    tmp = t[i-1] + T - t[i]
    if tmp > 0:
        u.append(t[i-1] + T - t[i])
    else:
        u.append(0)
print(T*N - sum(u))

Measured memory_bytes: 26836
#include <stdio.h>

int main(){
 int a,b;
 scanf("%d %d",&a,&b);
 if(a<b){
	 printf("a < b\n");
 }else if(a > b){
	 printf("a > b\n");
 }else{
	 printf("a == b\n");
 }
 return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

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

bool ba[100][100];
bool out[100][100];

int main() {
  int w,h;
  cin >> w >> h;
  REP(i, h) {
    REP(j, w) {
      cin >> ba[i][j];
    }
  }
  queue<pii> Q;
  REP(i, h) {
    if (!ba[i][0])Q.push(pii(i,0));
    if (!ba[i][w-1])Q.push(pii(i,w-1));
  }
  REP(i, w) {
    if (!ba[0][i]) Q.push(pii(0,i));
    if (!ba[h-1][i]) Q.push(pii(h-1,i));
  }
  
  while(!Q.empty()) {
    pii p = Q.front(); Q.pop();
    int y = p.first, x = p.second;
    if (out[y][x]) continue;
    out[y][x] = 1;
    REP(k,6) {
      int yy = y + dy[k];
      int xx = x + dx[y%2][k];
      if (yy < 0 || yy >= h || xx < 0 || xx >= w) continue;
      if (ba[yy][xx]) continue;
      Q.push(pii(yy,xx));
    }
  }
  // REP(i, h) {
  //   REP(j, w) {
  //     cout << out[i][j];
  //   }cout << endl;
  // }
  
  int ans = 0;
  REP(y, h) {
    REP(x,w) {
      if (!ba[y][x]) continue;
      REP(k,6) {
        int yy = y + dy[k];
        int xx = x + dx[y%2][k];
        if (yy < 0 || yy >= h || xx < 0 || xx >= w) {
          ans++;
          continue;
        }
        if (out[yy][xx]) ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 0
############################
# 再帰的に呼出す関数
def half(a,b,low,high):

    if(low > high):
        return 0

    c = int((low+high)/2)

    if(a[c] == b):
        return 1
    elif(a[c] < b):
        return half(a,b,c+1,high)
    elif(a[c] > b):
        return half(a,b,low,c-1)
#############################


n = int(input())
s = list(map(int,input().split()))
q = int(input())
r = list(map(int,input().split()))
cou = 0

for i in range(q):
    cou += half(s,r[i],0,n-1)

print(cou)


Measured memory_bytes: 16712
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    if(a.substring(0,1).equals(a.substring(2,3))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
vector<lli> p;
int main() {
  cin >> n; read_n(p, n, 1);
  lli ans = 0;
  for (lli i=1; i<=n-1; ++i) {
    if (p[i]==i && p[i+1]==i+1) {
      swap(p[i], p[i+1]);
      ++ans;
    }
  }
  for (lli i=1; i<=n; ++i) {
    if (p[i]==i) ++ans;
  }
  cout << ans << endl;
  return 0;
}



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

int k;

int scoreMax(vector<int> &a){
	int ans = 0;
	for(int i = 0 ; i < a.size()-k+1 ; i++){
		int s = 1;
		for(int j = 0 ; j < k ; j++){
			s *= a[i+j];	
		}
		ans = max(s,ans);
		
	}
	return ans;
}

int main(){
	int n;
	while(cin >> n>>k&&n){
		vector<int>a(n);
	
		for(int i = 0 ; i < n ; i++)cin >> a[i];
		int ans = 0 , t = scoreMax(a);
		for(int i = 0 ; i < n ; i++)
			for(int j = i+1 ; j < n ; j++)
				swap(a[i],a[j]),ans=max(ans,scoreMax(a)-t),swap(a[i],a[j]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 908
A,B,K = map(int, input().split())

if A >= K:
    A_rest = A - K
    B_rest = B

else:
    A_rest = 0
    n = K - A
    
    if n <= B:
        B_rest = B - n
    else:
        B_rest = 0
        
print(A_rest, B_rest)


Measured memory_bytes: 3064
S = input()
N = len(S)
even_set = {S[i] for i in range(N) if i % 2 == 1}
odd_set = {S[i] for i in range(N) if i % 2 == 0}
even_Yes = {'L', 'U', 'D'}
odd_Yes = {'R', 'U', 'D'}
if even_set <= even_Yes and odd_set <= odd_Yes:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
  int x,y;
  for(;cin>>x>>y,x;)
    {
      int step=0;
      if(x<y)
        swap(x,y);
      for(;y!=0;step++)
        {
          x=x%y;
          swap(x,y);
        }
      cout<<x<<" "<<step<<endl;
    }
}

Measured memory_bytes: 1164
import java.util.Scanner;
class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n=sc.nextInt();
		System.out.println(fact(n));
	}
	public static long fact(int n){
		if(n==0)return 1;
		//if(n==1)return 1;
		//if(n==2)return 2;
		//if(n==3)return 6;
		//といった具合に計算結果を保存しておけばメモ化
		return  n*fact(n-1);
	}
	}


Measured memory_bytes: 26068
#include <cstdio>
#include <vector>

using namespace std;

int main(void) {
  const int N = int(1e5);
  vector<bool> is_prime(N + 1, true);
  
  is_prime[1] = false;
  for (int i = 2; i <= N; i++) {
    if (!is_prime[i]) {
      continue;
    }
    for (int j = i + i; j <= N; j += i) {
      is_prime[j] = false;
    }
  }
  
  vector<int> ps(N + 1);
  for (int i = 1; i <= N; i++) {
    ps[i] += ps[i-1];
    if (i % 2 && is_prime[i] && is_prime[(i+1)/2]) {
      ps[i]++;
    }
  }
  
  int q;
  scanf("%i", &q);
  
  while (q--) {
    int l, r;
    scanf("%i %i", &l, &r);
    printf("%i\n", ps[r] - ps[l-1]);
  }
  
  return 0;
}

Measured memory_bytes: 1024
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

n = int(input())
print(l[n -1])

Measured memory_bytes: 3060