akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int N = 100;
const double EPS = 1e-8;
int n;

struct Point {
    double x, y;
    Point(double _x = 0, double _y = 0) {
        x = _x, y = _y;
    }
    friend Point operator+ (const Point &a, const Point &b) {
        return Point(a.x + b.x, a.y + b.y);
    }
    friend Point operator- (const Point &a, const Point &b) {
        return Point(a.x - b.x, a.y - b.y);
    }
    friend double operator^ (const Point &a, const Point &b) {
        return a.x * b.y - a.y * b.x;
    }
};

struct Circle {
    double r;
    Point centre;
    Circle(Point _centre = Point(0, 0), double _r = 0) {
        centre = _centre;
        r = _r;
    }
};

struct Triangle {
    Point p[3];
};

Point Dots[N];
Circle ans;

double Distance(Point p1,Point p2){
    p2=p2-p1;
    return sqrt(p2.x*p2.x+p2.y*p2.y);
}

double TriangleArea(Triangle t){
    return fabs((t.p[1]-t.p[0])^(t.p[2]-t.p[0]))/2.0;
}

Circle CircumCircleOfTriangle(const Triangle &t){
    Circle tmp;
    double a,b,c,c1,c2;
    double xa,ya,xb,yb,xc,yc;
    a=Distance(t.p[0],t.p[1]);b=Distance(t.p[1],t.p[2]);c=Distance(t.p[2],t.p[0]);
    tmp.r=a*b*c/TriangleArea(t)/4.0;
    xa=t.p[0].x;ya=t.p[0].y;
    xb=t.p[1].x;yb=t.p[1].y;
    xc=t.p[2].x;yc=t.p[2].y;
    c1=(xa*xa+ya*ya-xb*xb-yb*yb)/2.0;
    c2=(xa*xa+ya*ya-xc*xc-yc*yc)/2.0;
    tmp.centre.x=(c1*(ya-yc)-c2*(ya-yb))/((xa-xb)*(ya-yc)-(xa-xc)*(ya-yb));
    tmp.centre.y=(c1*(xa-xc)-c2*(xa-xb))/((ya-yb)*(xa-xc)-(ya-yc)*(xa-xb));
    return tmp;
}

Circle MinCircle2(int u,Triangle t){
    if(u==0) return Circle(Point(0,0),-2.0);
    else if(u==1) return Circle(t.p[0],0);
    else if(u==2) return Circle(Point((t.p[0].x+t.p[1].x)/2.0,(t.p[0].y+t.p[1].y)/2.0),Distance(t.p[0],t.p[1])/2.0);
    else if(u==3) return CircumCircleOfTriangle(t);
    return Circle();
}

void MinCircle(int n,int u,Triangle t){
    ans=MinCircle2(u,t);
    if(u==3) return ;
    for(int i=1;i<=n;++i){
        if(Distance(Dots[i],ans.centre)>ans.r){
            t.p[u]=Dots[i];
            MinCircle(i-1,u+1,t);
            Point temp=Dots[i];
            for(int j=i;j>=2;--j){
                Dots[j]=Dots[j-1];
            }
            Dots[1]=temp;
        }
    }
}

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

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> Dots[i].x >> Dots[i].y;
    }

    Triangle t;
    MinCircle(n, 0, t);
    cout << setprecision(10) << fixed << ans.r << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
#define PI 3.14159265358979323846264338327950L
typedef unsigned long long uint64;
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  for(int i= 1;i<=9;i++){
    for(int j = 1;j<=9;j++){
      if(i*j==n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main(){

	int A,B;

	scanf("%d %d",&A,&B);

	if(B%A == 0){

		printf("%d\n",B/A);

	}else{

		printf("%d\n",B/A+1);
	}

	return 0;
}



Measured memory_bytes: 3200
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	int x3,y3,x4,y4;
	x3=x2-(y2-y1);
	y3=y2+(x2-x1);
	x4=x3-(y3-y2);
	y4=y3+(x3-x2);
	cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4;
    return 0;
} 

Measured memory_bytes: 256
N, M = map(int, input().split())
from collections import Counter
a = [int(i) for i in input().split()]
cumsum = [0] * N
for i in range(N):
    cumsum[i] = cumsum[i-1] + a[i]
cumsum = [0] + cumsum
c = Counter(sorted([i % M for i in cumsum]))
ans = 0
def comb(n, r):
    a = 1
    for i in range(n-r+1, n+1):
        a *= i
    b = 1
    for i in range(1, r+1):
        b *= i
    return a // b
for k in c.keys():
    v = c[k]
    if v < 2:
        continue
    ans += comb(v, 2)
print(ans)


Measured memory_bytes: 18128
#include <iostream>
int main(){
  int sx,sy,tx,ty,dx,dy, i;
  std::cin>>sx>>sy>>tx>>ty;
  dx = tx-sx; dy = ty - sy;
  for(i=0;i<dx;++i)std::cout<<'R';
  for(i=0;i<dy;++i)std::cout<<'U';
  std::cout<<'L';
  for(i=0;i<dy-1;++i)std::cout<<'D';
  for(i=0;i<dx-1;++i)std::cout<<'L';
  std::cout<<"DLUU";
  for(i=0;i<dx-1;++i)std::cout<<'R';
  for(i=0;i<dy-1;++i)std::cout<<'U';
  std::cout<<"RRD";
  std::cout<<'R';
  for(i=0;i<dy+1;++i)std::cout<<'D';
  for(i=0;i<dx+1;++i)std::cout<<'L';
  std::cout<<'U';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  ll m=n%100;
  n=n/100;
  if(1<=min(n,m)&&max(n,m)<=12){
    cout << "AMBIGUOUS" << endl;
  }
  else if((min(n,m)==0&&max(n,m)>=13)||(max(n,m)==0)||(min(n,m)>=13)){
    cout << "NA" << endl;
  }
  else if(1<=n&&n<=12){
    cout << "MMYY" << endl;
  }
  else
    cout << "YYMM" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

	vector<int> A(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	bool result = true;
	for (size_t i = 0; i < N; i++)
	{
		if (A[i] % 2 == 0)
		{
			if (A[i] % 3 != 0 && A[i] % 5 != 0)
			{
				result = false;
				break;
			}
		}
	}

	cout << (result ? "APPROVED" : "DENIED") << endl;
	return 0;
}

Measured memory_bytes: 3120
// ABC082B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(),greater<int>());
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

int main(void)
{
    long long a,b,c;
    cin>>a>>b>>c;
    if(2*b==a+c)
    {
        cout <<"YES"<<endl;
    }
    else
    {
        cout <<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

class SuffixArray{
	private:
		int n;
		vector<int> rank;
	public:
		string s;
		vector<int> idx;
		SuffixArray(string& s) : n(s.size()), rank(s.size() + 1), s(s), idx(s.size() + 1) {
			rep(i,n + 1){
				idx[i] = i;
				rank[i] = i < n ? s[i] : -1;
			}

			int k;
			auto comp = [&](const int i, const int j) -> bool {
				if(rank[i] != rank[j]) return rank[i] < rank[j];
				else{
					int ri = i + k <= n ? rank[i + k] : -1;
					int rj = j + k <= n ? rank[j + k] : -1;
					return ri < rj;
				}
			};

			vector<int> tmp(n + 1);
			for (k = 1; k <= n; k*=2) {
				sort(all(idx), comp);

				tmp[idx[0]] = 0;
				range(i,1,n + 1){
					tmp[idx[i]] = tmp[idx[i - 1]] + (comp(idx[i - 1], idx[i]) ? 1 : 0);
				}
				rank = tmp;
			}
		}
		bool contain(string& t){
			int right = n, left = 0;
			while(right - left > 1){
				int mid = (right + left) / 2;
				if(s.substr(idx[mid], t.size()) < t) left = mid;
				else right = mid;
			}
			return s.substr(idx[right], t.size()) == t;
		}
};

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

	SuffixArray suf(s);
	rep(i,n){
		string a;
		cin >> a;
		cout << suf.contain(a) << endl;
	}
}



Measured memory_bytes: 16668
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        final int m = sc.nextInt();
        final long mod = 1000000007;
        boolean []broken = new boolean[n+1];
        Arrays.fill(broken,false);
        for (int i = 0;i<m;++i)
        {
            int a = sc.nextInt();
            broken[a] = true;
        }

        long [] dp = new long[n+2];
        dp[n] = 1;
        for (int now = n-1;now >= 0;--now)
        {
            if (broken[now])
            {
                dp[now] = 0;
                continue;
            }
            dp[now] = (dp[now+1]+dp[now+2]) % mod;
            //debug
//            StringBuilder sb = new StringBuilder();
//            for (int i = 0;i<dp.length;++i) sb.append(dp[i]+",");
//            System.out.println(sb.toString());
//            System.out.println("--------------------");
            //end debug
        }
        System.out.println(dp[0]);
        sc.close();
    }
}

Measured memory_bytes: 50192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
template<class T>  //多次元ベクトルの生成
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
	int h,w;
	std::cin >> h>>w;
	auto s= make_vec<char> (w,h);
	bool han=1;
	rep(j,h)rep(i,w)std::cin >> s[i][j];
	rep(j,h)rep(i,w){{
	    if(s[i][j]=='#')
	    if(!(i>=1&&s[i-1][j]=='#'||j>=1&&s[i][j-1]=='#'||i<w-1&&s[i+1][j]=='#'||j<h-1&&s[i][j+1]=='#'))han=0;
	    
	}}
	if(han)std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
}














Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;


int A[1000000];
int n;
long long cnt;
int m;
vector<int> G;

void isort(int g)
{
	for (int i = g; i < n; i++) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void ssort() 
{
	cnt = 0;
	for (int i = 1; i <= n; i = i * 3 + 1) {
		G.push_back(i);
	}
	for (int i = G.size() - 1; i >= 0; i--) {
		isort(G[i]);
	}


}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", A + i);
	}
	ssort();
	cout << G.size() << endl;
	for (int i = G.size() - 1; i>= 0; i--) {
		cout << G[i];
		if (i != 0) cout << " ";
		else cout << endl;
	}
	cout << cnt << endl;
	for (int i = 0; i < n; i++) {
		printf("%d\n", A[i]);
	}
	return 0;
}


Measured memory_bytes: 7128
#include <bits/stdc++.h>
using namespace std;
#define BS 313
#define ull unsigned long long
#define rint register int
#define gc() getchar()
inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
ull H[605][605], R[605][605], B[605]; char S[605][605]; int n, Ans;
inline ull HH(int i, int l, int r){return H[i][r]-H[i][l-1]*B[r-l+1];}
inline ull HR(int j, int l, int r){return R[r][j]-R[l-1][j]*B[r-l+1];}
inline bool Check(int a, int b)
{
	for(rint i = 1, x = a, y = b; i <= n; i++, x = x%n+1, y = y%n+1)
		if(HH(x,y,y+n-1) != HR(y,x,x+n-1)) return false; return true;
}
int main()
{
	n = read(); for(rint i = 1, j; i <= n; i++) for(scanf("%s",S[i]+1), j = 1; j <= n; S[i+n][j] = S[i][j+n] = S[i+n][j+n] = S[i][j], j++);
	B[0] = 1; B[1] = BS; for(rint i = 2; i <= n<<1; B[i] = B[i-1]*BS, i++);
	for(rint i = 1, j; i <= n<<1; i++) for(j = 1; j <= n<<1; H[i][j] = H[i][j-1]*BS+S[i][j], j++);
	for(rint j = 1, i; j <= n<<1; j++) for(i = 1; i <= n<<1; R[i][j] = R[i-1][j]*BS+S[i][j], i++);
	for(rint A = 1, B; A <= n; A++) for(B = 1; B <= n; B++) Ans += Check(A,B); printf("%d\n",Ans); return 0;
}

Measured memory_bytes: 6400
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	int a[N];
	int b[N];
	int c[N];
	int d[N];
	vector<int>e;
	f(i, N) {
		a[i] = 0;
		b[i] = 0;
		c[i] = 0;
      d[i]=0;
	}
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	f(i, n) {
		scanf("%d", &a[i]);
		a[i]--;
	}
	if (n == 2) {
		printf("-1\n");
		return 0;
	}
	f(i, n) {
		b[a[i]]++;
	}
	f(i, n)c[b[i]]++;
	x = 0;
	y = 1;
	z = -1;
	f(i, n) {
		if (((n - i - 1) > 1) && (c[n - i - 1] > 0)) {
			if (b[x] == (n - i - 1))k = x;
			else {
				for (int j = y; j < n; j++) {
					if (b[j] == (n - i - 1))k = j;
				}
			}
			d[i] = k;
			if (x != k)e.push_back(x);
			for (int j = y; j < n; j++) {
				if (j != k)e.push_back(j);
			}
			f(j, e.size()) {
				d[i + j + 1] = e[j];
			}
			if (a[d[i]] == d[i + 1])swap(d[i + 1], d[i + 2]);
			break;
		}
		if (z != x) {
			d[i] = x;
			z = a[x];
			b[a[x]]--;
			c[b[a[x]]]++;
			c[b[a[x]] + 1]--;
			c[b[x]]--;
			x = y;
			y = y + 1;
		}
		else {
			d[i] = y;
			z = a[y];
			b[a[y]]--;
			c[b[a[y]]]++;
			c[b[a[y]] + 1]--;
			c[b[y]]--;
			y = y + 1;
		}
	}
  bool g[N];
  f(i,N)g[i]=false;
	if (d[n - 1] >= n) {
		f(i,n-3)g[d[i]]=true;
      e.clear();
      f(i,n)if(!g[i])e.push_back(i);
		sort(e.begin(), e.end());
		if ((a[d[n - 4]] != e[0]) && (a[e[0]] != e[1]) && (a[e[1]] != e[2])) {
			d[n - 3] = e[0];
			d[n - 2] = e[1];
			d[n - 1] = e[2];
		}
		else if ((a[d[n - 4]] != e[0]) && (a[e[0]] != e[2]) && (a[e[2]] != e[1])) {
			d[n - 3] = e[0];
			d[n - 2] = e[2];
			d[n - 1] = e[1];
		}
		else if((a[d[n - 4]] != e[1]) && (a[e[1]] != e[0]) && (a[e[0]] != e[2])) {
			d[n - 3] = e[1];
			d[n - 2] = e[0];
			d[n - 1] = e[2];
		}
		else if((a[d[n - 4]] != e[1]) && (a[e[1]] != e[2]) && (a[e[2]] != e[0])) {
			d[n - 3] = e[1];
			d[n - 2] = e[2];
			d[n - 1] = e[0];
		}
		else if((a[d[n - 4]] != e[2]) && (a[e[2]] != e[0]) && (a[e[0]] != e[1])) {
			d[n - 3] = e[2];
			d[n - 2] = e[0];
			d[n - 1] = e[1];
		}
		else {
			d[n - 3] = e[2];
			d[n - 2] = e[1];
			d[n - 1] = e[0];
		}
	}
f(i,n-1){
  if(a[d[i]]==d[i+1])swap(d[i],d[i+1]);
}
	f(i, n) {
		printf("%d", d[i] + 1);
		if (i < (n - 1))printf(" ");
		else printf("\n");
	}

	return 0;
}


Measured memory_bytes: 4600
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int dp[20000];

int main() {
	int h, n; cin >> h >> n;
	vector<pair<int, int> > ab(n);
	for (auto& e : ab) cin >> e.first >> e.second;
	fill(dp, dp + 20000, 1e9);
	dp[0] = 0;
	int ans = 1e9;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= h; ++j) {
			dp[j + ab[i].first] = min(dp[j + ab[i].first], dp[j] + ab[i].second);
			if (j + ab[i].first >= h) ans = min(ans, dp[j + ab[i].first]);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

struct Edge {
  int t,next;
  Edge() {}
  Edge(int a,int b):t(a),next(b) {}
};

Edge e[200005];
int head[100005];

int dfs(int x,int fa) {
  int s=0;
  for(int i=head[x];i;i=e[i].next)
    if (e[i].t!=fa) s^=dfs(e[i].t,x)+1;
  return s;
}

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<n;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	e[2*i-1]=Edge(y,head[x]);
  	head[x]=2*i-1;
  	e[2*i]=Edge(x,head[y]);
  	head[y]=2*i;
  }
  puts((dfs(1,0))?"Alice":"Bob");
  return 0;
}

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

int main(){
  
  int a,b;
  cin >> a >> b;
 
  if( a%b == 0 ){
    
  cout << a/b << endl;
  
}
  
  else{
    
  cout << a/b + 1 << endl;
    
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s,t;	cin>>s>>t;
	int i,n=s.length();
	int a[26];
	for(i=0;i<26;i++){
		a[i]=-1;
	}
	bool flag=1;
	map<int,int> mymap[26];
	for(i=0;i<n;i++){
		mymap[s[i]-'a'][t[i]-'a']=1;

		if(a[t[i]-'a']==-1 || a[t[i]-'a']==s[i]-'a')	a[t[i]-'a']=s[i]-'a';
		else	flag=0;

	}
	for(i=0;i<26;i++){
		if(mymap[i].size() > 1)	flag=0;
	}
	if(!flag)	cout<<"No";
	else	cout<<"Yes";
	return 0;
}

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

typedef pair<int, int> Pair;
struct Edge {
  int to, w;
  bool operator < (const Edge &e) const {
    return w > e.w;
  }
};

typedef vector<vector<Edge> > Graph;
const int INF = 1<<28;
const int di[] = {0,1,0,-1};
const int dj[] = {1,0,-1,0};

int dijkstra(int src, int dst, const Graph &g) {
  int n = g.size();
  vector<int> cost(n, INF);
  priority_queue<Edge> que;
  cost[src] = 0;
  que.push((Edge){src, 0});
  while(que.size()) {
    const Edge s = que.top();
    que.pop();
    if(cost[s.to] < s.w) continue;
    if(s.to == dst) return s.w;
    for(int i = 0; i < g[s.to].size(); ++i) {
      const Edge &e = g[s.to][i];
      const Edge t = {e.to, s.w + e.w};
      if(cost[t.to] <= t.w) continue;
      cost[t.to] = t.w;
      que.push(t);
    }
  }
  return -1;
}

int main() {
  for(int W, H, N; cin >> W >> H >> N; ) {
    Pair s, t;
    cin >> s.first >> s.second
        >> t.first >> t.second;
    int cnt[501][501][4] = {};
    for(int i = 0; i < N; ++i) {
      int x, y; cin >> x >> y;
      int T; string S; cin >> T >> S;
      while(T--) {
        for(int j = 0; j < S.size(); ++j) {
          int k;
          if(S[j] == 'R') k = 0;
          if(S[j] == 'D') k = 1;
          if(S[j] == 'L') k = 2;
          if(S[j] == 'U') k = 3;
          int nx = x + dj[k];
          int ny = y + di[k];
          if(nx < 0 || nx >= W ||
             ny < 0 || ny >= H) {
            continue;
          }
          if(ny == y) {
            int p = max(x, nx);
            cnt[y][p][1] += 1;
            cnt[y+1][p][3] += 1;
          } else {
            int p = max(y, ny);
            cnt[p][x][0] += 1;
            cnt[p][x+1][2] += 1;
          }
          x = nx;
          y = ny;
        }
      }
    }
    Graph G((H+1)*(W+1));
    for(int i = 0; i <= H; ++i) {
      for(int j = 0; j <= W; ++j) {
        for(int k = 0; k < 4; ++k) {
          int ni = i + di[k];
          int nj = j + dj[k];
          if(ni < 0 || ni >= H+1) continue;
          if(nj < 0 || nj >= W+1) continue;
          int a = i * (W+1) + j;
          int b = ni * (W+1) + nj;
          G[a].push_back((Edge){b, cnt[i][j][k]});
        }
      }
    }
    int src = s.second * (W+1) + s.first;
    int dst = t.second * (W+1) + t.first;
    cout << dijkstra(src, dst, G) << endl;
  }
  return 0;
}

Measured memory_bytes: 25696
#include<bits/stdc++.h>
using namespace std;
int n,k;
char s[2333];
int d[4];
int main()
{
	ios_base::sync_with_stdio(false);
	scanf("%s",s);
	n=strlen(s);
	for(int i=0;i<n;i++)
	{
		if(s[i]=='N')d[0]=1;
		else if(s[i]=='E')d[1]=1;
		else if(s[i]=='W')d[2]=1;
		else d[3]=1;
	}
	if(d[0]^d[3])cout<<"No"<<endl;
	else if(d[1]^d[2])cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}
// const ll N=2e5=5;
// ll fac[N];
int32_t main()
{   
     IOS;
     ll n,m,i,j,k;
     cin>>n>>k;
     ll pre[n+5]={};
     ll suf[n+5]={};
     ll a[n+5];
     for(i=0;i<=n;i++) a[i]=i;
     pre[1]=a[0];
 for(i=2;i<=n+1;i++)
 	{
 		pre[i]=pre[i-1]+a[i-1];
 		pre[i]%=MOD;
 	}
    suf[1]=a[n];
    for(i=2;i<=n+1;i++)
    {
    	suf[i]=suf[i-1]+a[n+1-i];
    	suf[i]%=MOD;
    }
    ll ans=0;
    // for(i=1;i<=n+1;i++) cout<<i<<" "<<pre[i]<<" "<<suf[i]<<endl;
    for(i=k;i<=n+1;i++)
    {
    	ll x=(suf[i]-pre[i]+1ll+MOD)%MOD;
    	ans+=x;
    	ans%=MOD;
    }
    cout<<ans;

     

     
     
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 8468
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	ll N, A, B, C, D;
	string S;
	cin >> N >> A >> B >> C >> D >> S;
	A--;
	B--;
	C--;
	D--;
	bool flag = true;
	int cnt, pos;
	if(C < D){
		//ふぬけがゴールできるか
		for(int i = B; i < D && flag; i ++){
			if(S[i] == '#' && S[i + 1] == '#'){
				flag = false;
			}
		}
		//すぬけがゴールできるか
		for(int i = A; i < C && flag; i ++){
			if(S[i] == '#' && S[i + 1] == '#'){
				flag = false;
			}
		}
		if(flag)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else{
		//ふぬけが孤立できるか
		for(int i = B; i <= D; i ++){
			if(S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.'){
				B = i;
				break;
			}
		}
		S[B] = '#';
		//すぬけがゴールできるか
		for(int i = A; i < C && flag; i ++){
			if(S[i] == '#' && S[i + 1] == '#'){
				flag = false;
			}
		}
		//ふぬけがゴールできるか
		for(int i = B; i < D && flag; i ++){
			if(S[i] == '#' && S[i + 1] == '#'){
				flag = false;
			}
		}
		if(flag)cout << "Yes" << endl;
		else cout << "No" << endl;
	}

//"Hiroakimm0415"

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

//static const long long MOD = 1000000007;

int main() {
    int A, B, answer = 0;

    // input
    cin >> A >> B;

    // process
    answer = A + B;
    if (answer < A - B) {
        answer = A - B;
    }
    if (answer < A * B) {
        answer = A * B;
    }

    cout << answer;

    return 0;
}

Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(M)]

rs = [0]
t = 0

class UnionFind():
    # https://qiita.com/hukuhuku11111a1/items/1bbf67d90630552eb512
    def __init__(self, size):
        self.table = [-1] * size

    def find(self, x):
        while 1:
            i = self.table[x]
            if i < 0:
                return x
            x = i

    def union(self,x,y):
        global t
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 == s2:
            rs.append(t)
            return
        x1, y1 = self.table[s1], self.table[s2]
        if x1 <= y1:
            x2 = x1 + y1
            self.table[s1] = x2
            self.table[s2] = s1
            t = t - (-x1*(-x1-1)//2) - (-y1*(-y1-1)//2) + (-x2*(-x2-1)//2)
        else:
            y2 = y1 + x1
            self.table[s2] = y2
            self.table[s1] = s2
            t = t - (-x1*(-x1-1)//2) - (-y1*(-y1-1)//2) + (-y2*(-y2-1)//2)
        rs.append(t)

uf = UnionFind(N + 1)
#print(uf.table)

for a,b in AB[::-1]:
    uf.union(a, b)
    #print(uf.table)

#print(rs)

tt = N*(N-1)//2
for r in rs[-2::-1]:
    print(tt - r)


Measured memory_bytes: 28400
#include<bits/stdc++.h>
using namespace std;
const long long int mod = 1e9+7;

int main(){
    int N,K;
    cin >> N >> K;
    int i;
    long long int tmp;
    long long int ans=0;
    long long int MIN=0;
    long long int MAX=N;
    for(i=1;i<=N+1;i++){
        tmp=(MAX-MIN)+1;
        MIN+=i;
        MAX+=(N-i);
        if(i>=K){
            ans+=tmp;
            ans%=mod;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,ans=0;
    string s;
    cin>>n>>s;
    ll dp[5010][5010];
    rep(i,5010)rep(j,5010) dp[i][j]=0;
    for(ll i=n-1;i>=0;i--){
        for(ll j=n-1;j>i;j--){
            if(s[i]==s[j]){
                dp[i][j]=max(dp[i][j],dp[i+1][j+1]+1);
            }
            ans = max(ans,min(dp[i][j],j-i));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 196352
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
int n,x,pos[200005],ans,k;
int main()
{
    scanf("%d",&n);
    ans=n;
    for(int i=1;i<=n;i++)scanf("%d",&x),pos[x]=i;
    for(int i=1;i<=n;i++)
    {
        if(pos[i]<pos[i-1])k=1;
        else k++;
        ans=min(ans,n-k);
    }
    printf("%d",ans);
}


Measured memory_bytes: 4524
N = int(input())
Result = {"AC":0, "WA":0, "TLE":0, "RE":0}

for i in range(N):
  Result[input()] += 1

print("AC", "x", Result["AC"])
print("WA", "x", Result["WA"])
print("TLE", "x", Result["TLE"])
print("RE", "x", Result["RE"])


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

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n == 0) break;
			int[] a = new int[n];
			double mean = 0.0;
			for(int i = 0; i < n; ++i){
				a[i] = sc.nextInt(); mean += a[i];
			}
			mean /= n;
			double vari = 0.0;
			for(int i = 0; i < n; ++i){
				double dev = a[i] - mean;
				vari += dev*dev/n;
			}
			System.out.printf("%.6f\n", Math.sqrt(vari));
		}
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

    int n;
    cin >> n;

    ll x[n];
    ll y[n];
    rep(i, n){
        ll tmp;
        cin >> tmp;
        y[i] = tmp;
        x[i] = 2*tmp;
    }

    sort(x, x+n);
    ll fullmed = (x[n/2] + x[n/2-1]) / 4LL;
    ll upmed = x[n/2]/2LL;
    ll domed = x[n/2-1]/2LL;

    cerr << upmed << sp << domed << endl;

    for(auto n : y){
        if(n > fullmed){
            ppp(domed);
        }
        else{
            ppp(upmed);
        }
    }

    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int N,X,k,mini=10000000;
int main()
{
    scanf("%d %d",&N,&X);
    for(int i=1;i<=N;i++){
            scanf("%d",&k);
            mini = min(mini,k);
            X-=k;
    }
    printf("%d",X/mini+N);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	s.push_back('#');
	int n=s.size();
	int ans=0, cur=0;
	vector<int>v;
	if(s[0]=='>') v.push_back(0);
	for(int i=0;i<n;i++){
		if(i==0) cur++;
		else if(s[i]!=s[i-1]){
			v.push_back(cur);
			ans+=cur*(cur-1)/2;
			cur=1;
		}
		else cur++;
	}
	if(s[n-2]=='<') v.push_back(0);
	//if(s[0]=='<'){
		for(int i=0;i<v.size()-1;i+=2){
			ans+=max(v[i], v[i+1]);
		}
	//}
	cout<<ans;
}

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

int main() {
	/*
cout<<"Hello World"<<endl;

	int x;
	cin>> x;
	cout<< x*x*x <<endl;

int a;
int b;
cin>>a>>b;
cout<<a*b<<" "<<2*a+2*b<<endl;

	int a;
	int b;
	cin>>a>>b;
	if (a<b){
		cout<< "a < b" <<endl;
	}else if(a>b){
		cout<<"a > b" <<endl;
	}else if(a==b){
		cout<<"a == b"<<endl;
	}else{

	}
*/	int a;
	int b;
	int c;
	cin>>a>>b>>c;
	if (a<b&&b<c){
		cout<<"Yes"<<endl;
	}else {
		cout<<"No"<<endl;
	}




	return 0;
}

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

void solve(std::string s, std::string t)
{
    ll N = s.size();
    ll M = t.size();
    vector<vec> dp(N + 1, vec(M + 1, -1e+18));
    vector<vector<pair<ll, ll>>> back(N + 1, vector<pair<ll, ll>>(M + 1, pair<ll, ll>(-1, -1)));
    dp[0][0] = 0;
    for (ll i = 0; i <= N; i++)
    {
        for (ll j = 0; j <= M; j++)
        {
            if (i + 1 <= N and dp[i + 1][j] < dp[i][j])
            {
                dp[i + 1][j] = dp[i][j];
                back[i + 1][j] = {i, j};
            }
            if (j + 1 <= M and dp[i][j + 1] < dp[i][j])
            {
                dp[i][j + 1] = dp[i][j];
                back[i][j + 1] = {i, j};
            }
            if (i + 1 <= N and j + 1 <= M and s[i] == t[j])
            {
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
                back[i + 1][j + 1] = {i, j};
            }
        }
    }

    // Back Track
    string ans;
    ll ci = N;
    ll cj = M;
    while (dp[ci][cj] != 0)
    {
        pair<ll, ll> b = back[ci][cj];
        ll pi = b.first;
        ll pj = b.second;
        if (dp[ci][cj] == dp[pi][pj] + 1)
        {
            ans = s.substr(ci - 1, 1) + ans;
        }
        ci = pi;
        cj = pj;
    }
    cout << ans << endl;
}

signed main()
{
    std::string s;
    std::cin >> s;
    std::string t;
    std::cin >> t;
    solve(s, t);
    return 0;
}


Measured memory_bytes: 214668
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

template<typename T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template<typename T> bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    vll A(M);
    for(ll i=0;i<M;i++)cin>>A[i];
    
    ll sum=0;
    for(ll i=0;i<M;i++){
        sum+=A[i];
    }
    if(sum>N)cout<<-1<<endl;
    else cout<<N-sum<<endl;
    
    return 0;
}


Measured memory_bytes: 3700
from bisect import bisect_right, bisect_left
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
A = [0] + A
a = list(accumulate(A))
answer = a[-1]

# 切り口はN-1個, 真ん中の選び方はN-3
for i in range(N - 3):
    left = a[i + 2]
    right = a[-1] - left
    p = bisect_left(a, left // 2)
    P1 = a[p]
    Q1 = left - P1
    P2 = a[p - 1]
    Q2 = left - P2
    if abs(P1 - Q1) <= abs(P2 - Q2):
        P = P1
        Q = Q1
    else:
        P = P2
        Q = Q2

    s = bisect_right(a, a[-1] - right // 2)
    S1 = a[-1] - a[s - 1]
    R1 = right - S1
    S2 = a[-1] - a[s]
    R2 = right - S2
    if abs(S1 - R1) <= abs(S2 - R2):
        S = S1
        R = R1
    else:
        S = S2
        R = R2

    answer = min(answer, max(P, Q, R, S) - min(P, Q, R, S))

print(answer)

Measured memory_bytes: 24308
def fibonacci(N, dp):
    if dp[N] != 0:
        return dp[N]
    if N == 1 or N == 0:
        dp[N] = 1
    else:
        dp[N] = fibonacci(N - 1, dp) + fibonacci(N - 2, dp)
    return dp[N]


def main():
    N = int(input())
    dp = [0] * (N + 1)
    print(fibonacci(N, dp))


if __name__ == '__main__':
    main()



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

int main(){
  char X;
  cin >> X;
  
  if (X == 'a' || X ==  'i' ||  X =='u' || X == 'e'  ||  X == 'o'){
    cout << "vowel" << endl;
  }
  else  {
    cout << "consonant" << endl;
  } 
  
}

Measured memory_bytes: 256
#写経
#https://atcoder.jp/contests/abc167/submissions/13072107
import sys
readline = sys.stdin.readline

def resolve():
    N = int(readline())
    S = [readline().strip() for i in range(N)]
    L,R = [],[]
    D = []
    for s in S:
        l, r = 0, 0
        for c in s:
            if c == ')':
                if l > 0:
                    l -= 1
                else:
                    r += 1
            else:
                l += 1
        if l == 0 and r == 0:
            pass
        elif l == 0:
            R.append(r)
        elif r == 0:
            L.append(l)
        else:
            D.append((l, r))
    L = sum(L)
    R = sum(R)

    inc = []
    dec = []
    for l,r in D:
        if l > r:
            inc.append((l, r))
        else:
            dec.append((l, r))
    
    inc.sort(key=lambda x:x[1])
    dec.sort(key=lambda x:-x[1])
    
    D = inc + dec
    
    for i, (l,r) in enumerate(D):
        L -= r
        if L < 0:
            print('No')
            exit(0)
        L += l
    
    if L == R:
        print('Yes')
    else:
        print('No')
resolve()

Measured memory_bytes: 66712
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;

    int cnt = 0, cntgaikoku = 0;
    rep(i, n) {
        if(cnt >= a+b) {
            cout << "No";
        }
        else if(s[i] == 'a') {
            cout << "Yes";
            cnt++;
        }
        else if(s[i] == 'b' && cntgaikoku < b) {
            cout << "Yes";
            cnt++;
            cntgaikoku++;
        }
        else {
            cout << "No";
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int X, A;
int main(void){
    cin >> X >> A;
    if(X >= A) cout << 10 << endl;
    else cout << 0 << endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

def check(flag):
    acc = 0
    cnt = 0

    flag = flag
    for i in a:
        acc += i
        if (flag == 1 and flag > acc) or (flag == -1 and flag < acc) or i == 0:
            cnt += abs(flag - acc)
            acc = flag
        flag *= -1
    return cnt

print(min(check(1), check(-1)))



Measured memory_bytes: 15868
#include <stdio.h>

int main(){
    int a=0;
    int b=0;

    scanf("%d %d",&a, &b);

    if (a < b){
        printf("a < b\n");
    }else if (a > b){
        printf("a > b\n");
    }else if (a == b){
        printf("a == b\n");
    }

    return 0;
}

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

int main(){
	bool time[24][60],first=1;
	for (int i = 0; i < 24; i++) {
		for (int j = 0; j < 60; j++) {
			time[i][j] = false;
		}
	}
	int n,h,m;
	for (int i = 0; i < 2; i++) {
		cin >> n;
		for (int j = 0; j < n; j++) {
			cin >> h >> m;
			time[h][m] = true;
		}
	}
	for (int i = 0; i < 24; i++) {
		for (int j = 0; j < 60; j++) {
			if (time[i][j]) {
				if (!first)cout << " ";
				else first = 0;
				if (j < 10)cout << i << ":0" << j;
				else cout << i << ":" << j;
			}
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int x, a, b, y, z;

	cin >> x >> a >> b;

	if (x > a) {
		y = x - a;
	}
	else {
		y = a - x;
	}

	if (x > b) {
		z = x - b;
	}
	else {
		z = b - x;
	}


	if (y < z) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;

	}
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a + b == c || a + c == b || a == b + c ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
char x[1000005];
int a=0,b=0,c=0,d=0,e,f,i,j,k,maxi=0;
int main(){
	
	scanf("%s",x);
int leng=strlen(x);
while(1){
if(a==leng){break;}
if(x[a]!='J'){
a++;
}else{
  while(1){
    if(x[a]=='J'){
      b++;
      a++;
    }else{
       break;
}}
while(1){
if(x[a]=='O'){
c++;
a++;
}else{
break;
}}
while(1){
if(x[a]=='I'){
d++;
a++;
}else{
break;
}}
if(b>=c && c<=d){
maxi=max(maxi,c);
}
b=0;
c=0;
d=0;
}
}
printf("%d\n",maxi);scanf("%d",&a);
return 0;
}

Measured memory_bytes: 1944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  string w;
  cin >> w;
  string t;
  int cnt = 0;
  while (cin >> t, t != "END_OF_TEXT")
  {
    for (int i = 0; i < t.size(); ++i)
      if (isalpha(t[i]))
        t[i] = tolower(t[i]);
    if (t == w)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3172
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String sch = sc.nextLine();
		int n = Integer.parseInt(sc.nextLine());
		String[] rings = inputRing(n);

		searchRing(sch, n, rings);
	}

	private static void searchRing(String sch, int n, String[] rings) {
		int cnt = 0;

			for (int i = 0; i < n; i++) {

				if ( rings[i].contains(sch) ) {
					cnt++;
				}


			}

			System.out.println(cnt);


	}

	private static String[] inputRing(int n) {
		String[] rings = new String[n];
		StringBuilder sb = new StringBuilder();
		String str = "";

			for (int i = 0; i < n; i++) {
				str = sc.nextLine();
				sb.append(str).append(str);

				rings[i] = sb.toString();
				sb.delete(0, sb.length());
			}

		return rings;
	}

}


Measured memory_bytes: 26328
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f(5, 5, 7).
f(5, 7, 5).
f(7, 5, 5).

main :-
    get_number(A, B, C),
    f(A, B, C) -> writeln("YES") ; writeln("NO").


Measured memory_bytes: 7976
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;
	ll t[n];
	ll ans;
	REP(i, n){
		cin >> t[i];
		if (i == 0) ans = t[0];
		ans = t[i] / GCD(ans, t[i]) * ans;
	}

	cout << ans << endl;
}


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


int K, N;
vector<int> A;


void input() {
    cin >> K >> N;
    A = vector<int>(N);
    rep(i, N) cin >> A[i];
}


int main() {
    input();
    vector<int> w(N);
    w[0] = A[0] + K - A.back();
    for (int i = 1; i < N; i++) {
        w[i] = A[i] - A[i-1];
    }
    int ans = K - *max_element(w.begin(), w.end());
    cout << ans << endl;
}


Measured memory_bytes: 1792
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
int ckck(int n)
{
    if(n==2||n==3)
        return 1;
    else if(n%2==0||n%3==0)
        return 0;
    else
    {
        for(int j=2;j*j<=n;j++)
        {
            if(n%j==0)
                return 0;
        }
        return 1;
    }
}
const ll N=1e5+5;
ll freq[N+1]={0};
int main()
{
    int i,j;
    int n;
    cin>>n;
    ll A[n];
    ll S=0;
    for(i=0;i<n;i++)
    {
        cin>>A[i];
        freq[A[i]]++;
        S+=A[i];
    }
    int Q;
    cin>>Q;
    while(Q--)
    {
        ll B,C;
        cin>>B>>C;
        ll d=freq[B];
        ll res=S-d*B;
        res+=d*C;
        S=res;
        freq[B]=0;
        freq[C]+=d;

        cout<<res<<"\n";
    }




}




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

ll N;
vector<ll> A(200001, 0);
map<ll, ll> mp;

int main(void){
    
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> A[i];
    
    ++mp[0];
    ll sum = 0, ans = 0;
    for(int i = 0; i < N; ++i){
        sum += A[i];
        ans += mp[sum];
        ++mp[sum];
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
  int A;
  int B;
  int A_min;
  int A_max;
  int B_min;
  int B_max;

  cin >> A >> B;
  if (A%2==0){
    A_min = A * 12.5;
  }else{
    A_min = A*12.5+1;
  }

  if(A%2==0){
    A_max = (A+1)*12.5;
  }else{
     A_max = (A+1)*12.5-1;
  }
  B_min = B * 10;
  B_max = (B+1)*10-1;

  //cout << A_min << endl << A_max << endl << B_min << endl << B_max << endl;
  if(B_max < A_min){
    cout << "-1" << endl;
  }else if(A_max < B_min){
    cout << "-1" << endl;
  }else if(B_min <= A_min){
    cout << A_min << endl;
  }else{
    cout << B_min << endl;
  }
  return 0;
}

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

int top,new_num[MAX];
int isEmpty(void){
return top==0;
}
int isFUll(){
	return top >=MAX -1;
}


void push(int x){
	if(isFUll()){
		printf("overflow\n");
		exit(1);
	}
	top++;
	new_num[top]=x;
}
int pop(){
	if(isEmpty()){
		printf("underflow");
		exit(1);
	}
	top--;
	return new_num[top+1];
}
int main(void){
	int x,y,X;
	char num[MAX];

	top=0;
	while(scanf("%s",num) != EOF){
		if(num[0] == '+'){
			x=pop();
			y=pop();
			push(x+y);
		}
		else if(num[0] == '-'){
			x=pop();
			y=pop();
			push(y-x);
		}
		else if(num[0] == '*'){
			x=pop();
			y=pop();
			push(x*y);
		}
		else{
			X=atoi(num);
			push(X);
		}
	}
	printf("%d\n",pop());
	return 0;
}



Measured memory_bytes: 2128
n = int(input())
A = [list(map(int, input().split())) for i in range(n)]
dp = [[0,0,0] for i in range(n)]

dp[0] = A[0]
for i in range(n-1):
    for j in range(3):
        for l in range(3):
            if j == l: continue
            dp[i+1][l] = max(dp[i+1][l], dp[i][j]+A[i+1][l])

print(max(dp[n-1]))

Measured memory_bytes: 78592