akhauriyash/Code-Regression huggingface dataset:
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define pb push_back
# define pdd pair < db , db >
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int a,b;
    fi>>a>>b;
    if (a < b)
    {
        if (0 < a || b < 0)
            return fo << b - a << '\n',0;
        return fo << min(b - a,1 + abs(a + b)) << '\n',0;
    }
    else
    {
        if (a < 0 || b > 0)
            return fo << 2 + a - b << '\n',0;
        return fo << min(1 + a - b,1 + abs(a + b)) << '\n',0;
    }
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


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



int main(){

	double R;
	scanf("%lf",&R);

	printf("%.10lf\n",2.0*R*M_PI);

	return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
//Start from Here
int main(){
    ll A;
    cin>>A;
    ll cnt=0;
    ll B=100;
    while(B<A){
        B+=B/100;
        cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N (100000+1000)
using namespace std;

long long n,q,x,a[N],cnt,ans[N],f[N];

int main()
{
	scanf("%lld%lld",&n,&q);
	a[++cnt]=n;
	for (int i=1; i<=q; ++i)
	{
		scanf("%lld",&x);
		while (cnt && x<=a[cnt]) --cnt;
		a[++cnt]=x;
	}
	f[cnt]=1;
	for (int i=cnt; i>=1; --i)
	{
		long long k=a[i];
		while (k>a[1])
		{
			long long t=lower_bound(a+1,a+cnt+1,k)-a-1;
			f[t]+=f[i]*(k/a[t]);
			k%=a[t];
		}
		ans[k]+=f[i];
	}
	for (int i=n; i>=1; --i) ans[i]+=ans[i+1];
	for (int i=1; i<=n; ++i) printf("%lld\n",ans[i]);
}

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    map<ll,ll> l;
    for(ll i=0; i<n; i++) {
	ll x;
	cin >> x;
	l[x]++;
    }

    ll r = 0;
    for(auto &[a, x]: l)
    for(auto &[b, y]: l)
    for(auto &[c, z]: l) {
	if(a >= b) continue;
	if(b >= c) continue;
	bool ok = true;
	ok &= abs(a - b) < c && c < a + b;
	ok &= abs(b - c) < a && a < b + c;
	ok &= abs(c - a) < b && b < c + a;
	r += ok * (x*y*z);
    }
    cout << r << endl;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main(){
  int i,l,n;
  char s[1000];
  scanf("%s%d",s,&l);
  for(n=0;s[n]!=0;n++);
  for(i=0;i<n;i+=l)printf("%c",s[i]);
  puts("");
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.awt.geom.*;
public class Main {
	
	//0:50 cording start
	//1:13 cording fin
	//1:37 sleep
	class P3D {
		double x,y,z;

		public P3D(double x, double y, double z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}
		
		
		public double distance(P3D b) {
			double x = this.x - b.x;
			double y = this.y - b.y;
			double z = this.z - b.z;
			double dissq =  x * x + y * y + z * z;
			return Math.sqrt(dissq);
		}
	}

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0 ) break;
			P3D [] plist = new P3D[n];
			double cx = 0,cy = 0,cz=0;
			for(int i = 0; i < n; i++){
				double x = sc.nextDouble();
				double y = sc.nextDouble();
				double z = sc.nextDouble();
				plist[i] = new P3D(x, y, z);
				cx += x;
				cy += y;
				cz += z;
			}
			cx = cx / n;
			cy = cy / n;
			cz = cz / n;
			P3D startP = new P3D(50, 50, 50);
			double mindis = 1 << 24;
			double move = 0.5;
			double mostdis = -1;
			while(move > 1.0e-10){
				for(int i = 0; i < 10000; i++){
					mostdis = -1;
					mindis = 1 << 24;
					int mostdisId = -1;
					for(int j = 0; j < n; j++){
						double nowdis = startP.distance(plist[j]);
						mindis = Math.min(mindis, nowdis);
						if(mostdis < nowdis){
							mostdis = nowdis;
							mostdisId = j;
						}
					}
					P3D mostdisP = plist[mostdisId];
					double movex = (mostdisP.x - startP.x) * move;
					double movey = (mostdisP.y - startP.y) * move;
					double movez = (mostdisP.z - startP.z) * move;
					startP.x = startP.x + movex;
					startP.y = startP.y + movey;
					startP.z = startP.z + movez;
				}
				move = move / 2;
			}
			System.out.printf("%.5f\n",mostdis);
		}
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l=-1,r=-1;
  bool judge = true;
  string s;cin>>s;
  for(i=0;i<s.size();i++){
    if(i<s.size()-1&&s[i]==s[i+1]){
      l=i+1;
      r=i+2;
      break;
    }
    if(i<s.size()-2&&s[i]==s[i+2]){
      l=i+1;
      r=i+3;
      break;
    }
  }
  cout<<l spa r<<endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)

typedef pair<int, int> P;


int main() {
    int n,m,x; cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> c(n);
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }

    int ans = INT_MAX;
    for (int bit = 0; bit < (1<<n); ++bit) {
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) {
                S.push_back(i);
            }
        }

        int tmpans = 0;
        vector<int> rikai(m, 0);
        rep(i, S.size()) {
            tmpans += c[S[i]];
            rep(j, m) {
                rikai[j] += a[S[i]][j];
            }
        }

        bool flag = true;
        rep(i, m) {
            if(rikai[i] < x) {
                flag = false;
                break;
            }
        }
        if(flag) {
            ans = min(ans, tmpans);
        }

    }

    if(ans == INT_MAX) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;

}

Measured memory_bytes: 3624
/* ex 7_3
   アカウント名 */

#include <stdio.h>

#define ROW 100
#define COLUMN 100

int main(void){
    int i, j, k, row, column;
    scanf("%d %d\n", &row, &column);
    int row_flag[ROW] = {0}, column_flag[COLUMN] = {0};
    for(i = 0; i < row; i++){
        row_flag[i] = 0;
    }
    for(i = 0; i < column; i++){
        column_flag[i] = 0;
    }
    char matrix[row][column];
    for(i = 0; i < row; i++){
        for(j = 0; j < column; j++){
            scanf(" %c", &matrix[i][j]);
            if(matrix[i][j] == '#'){
                row_flag[i] = 1;
                column_flag[j] = 1;
            }
        }
    }

    for(i = 0; i < row; i++){
        k = 0;
        for(j = 0; j < column; j++){
            if(row_flag[i] == 1 && column_flag[j] == 1){
                printf("%c", matrix[i][j]);
                k = 1;
            }
        }
        if(k == 1){
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 1668
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,ans = 0;
    cin >> n;
    for(int i = 1;;i++)
    {
        if(n < i * i){ans = (i - 1) * (i - 1); break;}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var hw = toIntArr(input[0].split(' '));
	var h = hw[0];
	var w = hw[1];
	var as = [];
	for(var i = 0; i < h; i++){
		as[i] = input[i+1];
	}

	var hs = [];
	var ws = [];

	var temp;
	for(var i = 0; i < h; i++){
		temp = true;
		for(var j = 0; j < w; j++){
			if(as[i][j] === '#'){
				temp = false;
				break;
			}
		}
		if(!temp) hs.push(i);
	}
	for(var j = 0; j < w; j++){
		temp = true;
		for(var i = 0; i < h; i++){
			if(as[i][j] === '#'){
				temp = false;
				break;
			}
		}
		if(!temp) ws.push(j);
	}

	for(var i = 0; i < hs.length; i++){
		temp = '';
		for(var j = 0; j < ws.length; j++){
			temp += as[hs[i]][ws[j]];
		}
		console.log(temp);
	}
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin >> s;
	int ans = 0;
	for (char &c : s) {
		ans = (ans + c - '0') % 9;
	}
	cout << (ans ? "No" : "Yes") << '\n';
	return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
static const int MAX_N = 16;

int n;
int x[MAX_N], y[MAX_N];

int l[MAX_N];
int p1[MAX_N / 2], p2[MAX_N / 2];

void rec(int num, int &res){
	if(num == n / 2){
		int cnt = 0;
		for(int i = 0; i < n / 2; i++){
			for(int j = i + 1; j < n / 2; j++){
				if((x[p2[i]] - x[p1[i]]) * (y[p2[j]] - y[p1[j]]) == (x[p2[j]] - x[p1[j]]) * (y[p2[i]] - y[p1[i]])) cnt++;
			}
		}
		res = max(res, cnt);
		return;
	}
	int num2;
	for(int i = 0; i < n; i++){
		if(l[i] == -1){
			l[i] = num;
			p1[num] = i;
			num2 = i;
			break;
		}
	}
	for(int i = 0; i < n; i++){
		if(l[i] == -1){
			l[i] = num;
			p2[num] = i;
			rec(num + 1, res);
			l[i] = -1;
		}
	}
	l[num2] = -1;
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d %d", &x[i], &y[i]);
	fill(l, l + n, -1);
	int res = 0;
	rec(0, res);
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 3224
N = int(input())
a = list()
for i in range(N):
    a.append(int(input()))

temp = 1
count = 0
while temp != 2 and count <= 100001:
    temp = a[temp - 1]
    count += 1

if count > 100000:
    print(-1)
else:
    print(count)  

Measured memory_bytes: 7084
#include<cstdio>
#include<climits>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
struct S{int b,e;string s;}s;
int C(S l,S r){return l.b<r.b;}
int main()
{
	int N,Q;
	char _[32];
	typedef vector<S>V;
	V v;
	V::iterator i;
	v.reserve(1002);
	while(scanf("%d%d",&N,&Q),N)
	{
		v.clear();
		s.b=s.e=-1;
		v.push_back(s);
		while(N--)
		{
			scanf("%s%d%d",&_,&s.b,&s.e);
			s.b=s.e-s.b+1;
			s.s=_;
			v.push_back(s);
		}
		s.b=s.e=INT_MAX;
		v.push_back(s);
		sort(v.begin(),v.end(),C);
		while(Q--)
		{
			scanf("%d",&N);
			s.b=N;
			i=lower_bound(v.begin(),v.end(),s,C);
			if(i->b==N)printf("%s 1\n",i->s.c_str());
			else if(i[-1].b<=N&&N<=i[-1].e)
				printf("%s %d\n",i[-1].s.c_str(),N-i[-1].b+1);
			else puts("Unknown");
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int n,a,num[112];
long long knap[55][2510];
long long totalsum = 0;

int main()
{
	int i,j,k;
	
	scanf("%d %d",&n,&a);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
	}
	
	knap[0][0] = 1;
	for(i=0;i<n;i++)
	{
		for(j=n-1;j>=0;j--)
		{
			for(k=0;k<=2500;k++)
			{
				knap[j+1][k+num[i]] += knap[j][k];
			}
		}
	}
	
	int mul=0;
	for(i=1;i<=n;i++)
	{
		mul += a;
		totalsum += knap[i][mul];
	}
	printf("%lld\n",totalsum);
	
}

Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    IO
    ll n;
    cin>>n;
    ll a[n+1];
    ll dp[n+1][2];
    map <ll,ll> mp;
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
        dp[i][0]=i+a[i];
        dp[i][1]=(i-a[i]);
        mp[dp[i][1]]++;
    }
    ll ss=0;
    for(ll i=1;i<=n;i++)
    {
        mp[dp[i][1]]--;
        ll ans=mp[dp[i][0]];
        ss+=ans;
        // mp[dp[i][0]]--;
    }
    cout<<ss;
    return 0;
}

Measured memory_bytes: 30944
// AtCoder ABC105: D - Candy Distribution
// 2019.9.11 bal4u

#include <stdio.h>

typedef long long ll;

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int s[100005];

void Qsort(int *a, int l, int r) {
	int i, j, m, t;
	
	i = l, j = r, m = a[(l+r) >> 1];
	while (1) {
		while (a[i] < m) i++;
		while (m < a[j]) j--;
		if (i >= j)	break;
		t = a[i], a[i] = a[j], a[j] = t;
		i++, j--;
	}
	if (l+1 < i) Qsort(a, l, i-1);
	if (j+1 < r) Qsort(a, j+1, r);
}
	
int main()
{
	int i, N, M; ll w, ans;
	
	N = in(), M = in();
	for (i = 1; i <= N; i++) s[i] = (s[i-1] + in()) % M;
	Qsort(s, 1, N);
	ans = 0;
	w = 0; for (i = 1; i <= N; i++) {
		if (s[i] == s[i-1]) w++;
		else ans += w*(w+1)/2, w = 0;
	}
	ans += w*(w+1)/2;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 512
from math import gcd
n = int(input())
l = list(map(int,input().split()))
mi = 1
gcd_l = [l[0]]
gcd_r = [l[-1]]
for i in range(1,n):
  gcd_l.append(gcd(l[i],gcd_l[-1]))
for i in range(n-2,-1,-1):
  gcd_r.append(gcd(l[i],gcd_r[-1]))
  
for i in range(0,n-2):
  t = gcd(gcd_l[i], gcd_r[n-3-i])
 # print(t)
  mi = max(mi,t)
#print(gcd_l)
#print(gcd_r)
mi = max(mi,gcd_r[-2])
mi = max(mi,gcd_l[-2])
print(mi)

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

int main() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    rep(i, 3) {
        if (s[i] == t[i]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
s = input()
if s[0] == "A" and s[2:-1].count("C") == 1 and "C" in s[2:-1]:
    x = s.replace("A", "a").replace("C", "c")
    y = x.lower()
    if x == y:
        print("AC")
        exit()
print("WA")
        

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e7+5;

int main(){
	int n,sum=0,a=0,b=0,c=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		string s;
		cin>>s;
		int l=s.size();
		if(s[0]=='B') b++;
		if(s[l-1]=='A') a++;
		if(s[0]=='B'&&s[l-1]=='A') c++;
		for(int j=1;j<l;j++){
			if(s[j-1]=='A'&&s[j]=='B') sum++;
			//cout<<sum<<" "<<b<<" "<<a<<endl;
		}
	}
	if(b==c&&a==c&&c!=0) sum--;
	cout<<sum+min(a,b)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
#include <bitset>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=2000;

int n;
bool win[MAXN][MAXN];

bool canfst[MAXN][MAXN];
bool canlst[MAXN][MAXN];
bool canfinal[MAXN][MAXN];

bitset<MAXN> bwin[MAXN]; // win[i][k]
bitset<MAXN> bfst[MAXN]; // canfst[k][i]
bitset<MAXN> blst[MAXN]; // canlst[i][k]
bitset<MAXN> bfst2[MAXN]; // canfst[i][k]
bitset<MAXN> blst2[MAXN]; // canlst[k+1][j]
bitset<MAXN> bfin1[MAXN]; // canfinal[i][k]
bitset<MAXN> bfin2[MAXN]; // canfinal[k][i]

int solve() {
	//REP(i,n) { printf("win%d: ",i); REP(j,n) printf("%c",win[i][j]?'v':'.'); puts(""); }
	REP(i,n) REP(j,n) canfst[i][j]=canlst[i][j]=canfinal[i][j]=false;
	REP(i,n) canfst[i][i]=canlst[i][i]=true;
	REP(i,n) bwin[i].reset(),bfst[i].reset(),blst[i].reset(),bfin1[i].reset(),bfin2[i].reset(),bfst2[i].reset(),blst2[i].reset();
	REP(i,n) REP(j,n) if(win[i][j]) bwin[i][j]=true;
	REP(i,n) bfst[i][i]=blst[i][i]=bfst2[i][i]=blst2[i][i]=true;
	FORE(len,2,n) REPE(i,n-len) {
		int j=i+len-1;
		
		if((bfst2[i]&(blst2[j]>>1)).any()) canfinal[i][j]=true;
		if(canfinal[i][j]) bfin1[i][j]=bfin2[j][i]=true;
		//bool chk1=false; FORE(k,i,j-1) if(canfst[i][k]&&canlst[k+1][j]) chk1=true; assert(chk1==canfinal[i][j]);

		//FORE(k,i+1,j) if(win[i][k]&&canfst[k][j]&&canfinal[i][k]) canfst[i][j]=true;
		if((bwin[i]&bfst[j]&bfin1[i]).any()) canfst[i][j]=true;
		if(canfst[i][j]) bfst[j][i]=bfst2[i][j]=true;

		//FORE(k,i,j-1) if(win[j][k]&&canlst[i][k]&&canfinal[k][j]) canlst[i][j]=true;
		if((bwin[j]&blst[i]&bfin2[j]).any()) canlst[i][j]=true;
		if(canlst[i][j]) blst[i][j]=blst2[j][i]=true;

		//printf("%d..%d: fst=%c lst=%c final=%c\n",i,j,canfst[i][j]?'v':'.',canlst[i][j]?'v':'.',canfinal[i][j]?'v':'.');
	}
	int ret=0; REP(i,n) if(canlst[0][i]&&canfst[i][n-1]) ++ret; return ret;
}

void run() {
	scanf("%d",&n);
	REP(i,n) win[i][i]=false;
	FOR(i,1,n) { string s; cin>>s; REP(j,i) win[i][j]=s[j]=='1',win[j][i]=!win[i][j]; }
	printf("%d\n",solve());
}

void stress() {
	REP(rep,100) {
		n=100;
		REP(i,n) win[i][i]=false;
		REP(i,n) REP(j,i) win[i][j]=rand()%2==0,win[j][i]=!win[i][j];
		solve();
	}
}

int main() {
	run();
	//stress();
	return 0;
}


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

using namespace std;

long euclid(long a,long b) {
	long r;

	do {
		r = a%b;
		a = b;
		b = r;
	} while (r != 0);

	return a;
}

long n;
long x;
long len;

int main() {

	cin >> n >> x;

	x = (euclid(n, x));

	len = 3 * (n - 1) - 3 * (min(n, x) - 1);

	cout << len << endl;
}



Measured memory_bytes: 256
/*
 * Shubham Jain
 */
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define MOD 10000000009

int main() {
    ll i,j,n,a,b,c,x,k,count=0;
    cin>>a>>b>>c>>x;
    for(i=0;i<=a;i++){
        for(j=0;j<=b;j++){
            for(k=0;k<=c;k++){
                if(500*i+100*j+50*k==x)
                    count++;
            }
        }
    }
    cout<<count<<endl;
return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);
    vb used(n, false);
    vector<int> data(m);
    for (int i = 0; i < m; i++) {
        cin >> data[i];
        used[data[i]-1] = true;
    }

    vb out(n, false);
    for (int i = m-1; i >= 0; i--) {
        if (!out[data[i]-1]) {
            cout << data[i] << endl;
            out[data[i]-1] = true;
        }
    }

    rep(i, n) {
        if (!used[i]) cout << i+1 << endl;
    }
    

    return 0;
}



Measured memory_bytes: 3740
#ABC102C
import numpy as np
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    b[i] = a[i]-(i+1)
ave = round(np.median(b))
ans = 0
for i in range(n):
    ans += abs(b[i]-ave)
print(int(ans))

Measured memory_bytes: 34216
import java.io.*;
import java.math.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int x=Integer.parseInt(s[0]),n=Integer.parseInt(s[1]);
        int i,c[]=new int[201];
        if(n>0) s=bu.readLine().split(" ");
        for(i=0;i<n;i++)
        c[Integer.parseInt(s[i])]++;
        int min=Integer.MAX_VALUE,minv=x;
        for(i=0;i<=200;i++)
        if(c[i]==0 && Math.abs(i-x)<min) {min=Math.abs(i-x); minv=i;}
        System.out.print(minv);
    }
}


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

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  m++;
  vector<vector<int>> vec(n, vector<int>(m));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> vec.at(i).at(j);
    }
  }
  vector<int> ans;
  
  for(int tmp = 0; tmp < (1 << n); tmp++){
    bitset<12> b(tmp);
    vector<int> vec2(m);
    
    for(int i = 0; i < n; i++){
      if(b.test(i)){
        for(int j = 0; j < m; j++){
          vec2.at(j)+= vec.at(i).at(j);
        }
      }
    }
    
    for(int i = 1; i < m; i++){
      if(vec2.at(i) >= x){
        if(i == m - 1){
          ans.push_back(vec2.at(0));
        }
      }
      else{
        break;
      }
    }
  }
  
  if(ans.empty()){
    cout << -1 << endl;
  }
  else {
    sort(ans.begin(), ans.end());
    cout << ans.at(0) << endl;
  }
}

Measured memory_bytes: 3652
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1;
static const int MAX = 100;
static const int INF = (1 << 23);
ll fact(ll n){
    if(n==0)return 1;
    else return n*fact(n-1)%MOD;
}
ll calc(ll n,ll k){
    if(k==0)return 1;
    ll m=n*n%MOD;
    if(k%2)return n*calc(m,k/2)%MOD;
    else return calc(m,k/2)%MOD;
}
ll comb(ll n,ll k){
    ll ret=fact(n);
    ret=ret*calc(fact(k),MOD-2)%MOD;
    ret=ret*calc(fact(n-k),MOD-2)%MOD;
    return ret;
}

int main() {
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n);
    ll ans = 0;
    rep(i,n){
        cin>>a[i];
       // if(a[i]%m==0)ans++;
    }

    vector<ll> u(n+1,0);

    rep(i,n){
        u[i+1]+=u[i]+a[i];
    }
    map<ll,ll> ma;
    for(int i=1;i<n+1;i++){
        ll k=u[i]%m;
        ma[k]++;
    }

    for(auto &a:ma){
       // cout<<a.second<<endl;
        if(a.first==0){
            ans+=a.second;
        }

        if(a.second>=2) {
            ans += (a.second)*(a.second-1)/2;
        }


    }

    cout<<ans<<endl;





    return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll, ll> primeFactorization(ll n)
{
    map<ll, ll> primeFacMap;
    ll q = 2;
    while(q * q <= n)
    {
        while(n % q == 0)
        {
            n = n / q;
            if (primeFacMap.find(q) == primeFacMap.end())
            {
                primeFacMap[q] = 1;
            }
            else
            {
                primeFacMap[q]++;
            } 
        }
        q++;
    }
    if (n != 1) primeFacMap[n] = 1;

    return primeFacMap;
}

int main()
{
    ll N, M;
    cin >> N >> M;

    COMinit();
    map<ll, ll> primeFactMap = primeFactorization(M);

    ll ans = 1;
    REPV(it, primeFactMap)
    {
        ll num = it->second;
        ans = (ans * COM(num + N - 1, num)) % MOD;
    }


    cout << ans << endl;
}


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

long long N;
long long A[1000000];
long long c = 1;
long long s = 0;
bool small = true;
int j;

void solve(){
  for(int i = 1; i < N; i++){
    if(s + 1 == i){
      if(A[i] > A[s]){
        small = false;
      }else if(A[i] < A[s]){
        small = true;
      }else{
        j = i+1;
        while(j < N){
          if(A[j] > A[s]){
            small = false;
            break;
          }else if(A[j] < A[s]){
            small = true;
            break;
          }else{
            j++;
          }
        }
        if(j == N -1){
          break;
        }
      }
      continue;
    }
    if(A[i] > A[i - 1] && small){
      s = i;
      c += 1;
    }else if(A[i] < A[i - 1] && !small){
      s = i;
      c += 1;
    }else{
      continue;
    }

  }

  cout << c << endl;
}

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

  solve();
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	long long a,b,i,x=0,f=0;
	scanf("%lld %lld",&a,&b);
	if(b<10) x=10*a+b;
	if (b >= 10 && b < 100) x= 100 * a + b;
	if (b == 100) x= 1000 * a + b;
	// printf("%d\n",x);
	for(i=1;i<=1000;i++){
		if(i*i==x) f=1;
	}
	if(f==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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


int main(void)
{
  int w,n,i,tmp;
  scanf("%d",&n);
  scanf("%d",&w);

  int a[n][2],b[n+1];

  for(i=1;i<=n;i++)
    b[i]=i;
  for(i=0;i<w;i++){
    scanf("%d,%d",&a[i][0],&a[i][1]);
  }

  /* for(i=0;i<n;i++)
     printf("%d,%d\n",a[i][0],a[i][1]);  
  */
  for(i=0;i<w;i++){
    tmp=b[a[i][0]];b[a[i][0]]=b[a[i][1]];b[a[i][1]]=tmp;
  }
  
  for(i=1;i<=n;i++)
    printf("%d\n",b[i]);
  return 0;
}

Measured memory_bytes: 596
import Foundation
let arr = ["dream", "erase", "eraser", "dreamer"]
var S = readLine()!
while true {
    var flag = true
    for s in arr {
        if S.hasSuffix(s) {
            S = S.substringToIndex(S.endIndex.advancedBy(-s.characters.count))
            flag = false
        }
    }
    if flag {
        break
    }
}
print(S=="" ?"YES":"NO")

Measured memory_bytes: 7272
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cstdio>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {-1,0,1,0};

struct Node {
  int to;
  int idx;
  int flow;
  Node(int to,int idx,int flow) :
    to(to),idx(idx),flow(flow) {}
};

class FordFulkerson {
private:
  vector<Node>* _graph;
  bool* _used;
  int _size;

  int dfs(int src,int flow,int sink){
    if(src == sink) return flow;

    _used[src] = true;
    for(int i= 0;i < _graph[src].size();i++){
      Node& e = _graph[src][i];
      if(_used[e.to]) continue;
      if(e.flow <= 0) continue;
      int d = dfs(e.to,min(flow,e.flow),sink);
      if(d <= 0) continue;

      Node& rev_e = _graph[e.to][e.idx];
      e.flow -= d;
      rev_e.flow += d;
      return d;
    }
    return 0;
  }

public:  
  FordFulkerson(int n) {
    _size = n;
    _graph = new vector<Node>[_size];
    _used = new bool[_size];
  }

  ~FordFulkerson(){
    delete[] _graph;
    delete[] _used;
  }

  FordFulkerson(const FordFulkerson& f){
    _size = f.size();
    _graph = new vector<Node>[_size];
    _used = new bool[_size];
    fill((bool*)_used,(bool*)_used + _size,false);

    for(int i = 0; i < f.size(); i++){
      for(int j = 0; j < f.graph()[i].size(); j++){
        _graph[i].push_back(f.graph()[i][j]);
      }
    }
  }

  void add_edge(int from,int to,int flow) {
    _graph[from].push_back(Node(to,_graph[to].size(),flow));
    _graph[to].push_back(Node(from,_graph[from].size()-1,flow));
  }

  int compute_maxflow(int src,int sink){
    int res = 0;

    while(true){
      fill((bool*)_used,(bool*)_used + _size,false);
      int tmp = dfs(src,numeric_limits<int>::max(),sink);
      if(tmp == 0) break;
      res += tmp;
    }
    return res;
  }

  int size() const{
    return _size;
  }
  vector<Node>* graph() const{
    return _graph;
  }
};

int main(){
  int num_of_houses;
  int num_of_paths;
  while(~scanf("%d %d",&num_of_houses,&num_of_paths)){
    if(num_of_houses == 0 && num_of_paths == 0) break;

    FordFulkerson ff(num_of_houses);
    int bonus = 0;

    for(int path_i = 0; path_i < num_of_paths; path_i++){
      int from,to;
      int cost;
      scanf("%d %d %d",&from,&to,&cost);
      if(cost < 0) bonus += cost; 
      ff.add_edge(from,to,max(0,cost));
    }

    int res = numeric_limits<int>::max();

    for(int house_i = 1; house_i< num_of_houses; house_i++){
      FordFulkerson tmp(ff);
      res = min(res,tmp.compute_maxflow(0,house_i));
    }
    printf("%d\n",bonus + res);
  }
}

Measured memory_bytes: 1208
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

ll getdigit(ll n,ll k){
  return (to_string(n)[k]-'0');
}

ll getsize(ll n){
  return to_string(n).size();
}

bool check(ll x,ll n,ll m,ll s[],ll c[]){
  if(getsize(x)!=n)return false;
  rep(i,m){
    if(getdigit(x,s[i]-1)!=c[i])return false;
  }
  return true;
}

void solve(){
  ll n,m;cin>>n>>m;
  ll s[m];
  ll c[m];
  rep(i,m)cin>>s[i]>>c[i];
  rep(x,pow(10,5))if(check(x,n,m,s,c)){
    cout<<x<<endl;
    return;
  }
  cout<<-1<<endl;

}

signed main(){
	ios::sync_with_stdio(false);
  cin.tie(nullptr);cout<<fixed;
  cout<<setprecision(30);
	solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back


int main(void){
  int n;

  while(cin >> n,n){
    string s;
    bool d = true;
    bool r = true;
    bool l = true;
    int ans = 0;

    rep(i,n){
      cin >> s;
      if(s == "lu"){
        l = false;
      }else if(s == "ld"){
        l = true;
      }else if(s == "ru"){
        r = false;
      }else if(s == "rd"){
        r = true;
      }
      if(r == l && r != d){
        d = !d;
        ans++;
      }
    }
    cout << ans << endl;
  }

  return 0;
}

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

int main(){
  long n;
  cin >> n;
  vector<long> t(n),a(n);
  for(long i = 0;i < n;i++){
    cin >> t.at(i) >> a.at(i);
  }
  long hyo = a.at(0) + t.at(0);
  //cout << hyo << endl;
  long k,na,nt;
  for(long i = 1;i < n;i++){
    if(a.at(i-1) % a.at(i) == 0){
      na = a.at(i-1) / a.at(i);
    }else{
      na = a.at(i-1) / a.at(i) + 1;
    }
    if(t.at(i-1) % t.at(i) == 0){
      nt = t.at(i-1) / t.at(i);
    }else{
      nt = t.at(i-1) / t.at(i) + 1;
    }
    k = max(na,nt);
    a.at(i) *= k;t.at(i) *= k;
    hyo = a.at(i) + t.at(i);//(t.at(i) + a.at(i)) * (ceil(hyo / (a.at(i) + t.at(i))));
    //cout << hyo << " " << t.at(i) << " " << a.at(i) << endl;
 
  }
  cout << hyo << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <cstdlib>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main(){
    int a,b,q;
    cin>>a>>b>>q;
    vector<ll> s(a),t(b),X(q);
    for(int i=0; i<a; i++) cin>>s[i];
    for(int i=0; i<b; i++) cin>>t[i];
    for(int i=0; i<q; i++) cin>>X[i];
    sort(ALL(s));
    sort(ALL(t));
    for(ll x : X){
        ll sr,sl,tr,tl;
        sr = (lower_bound(ALL(s),x)<s.end())? *lower_bound(ALL(s),x):1000000000000000;
        sl = (lower_bound(ALL(s),x)-1>=s.begin())? *(lower_bound(ALL(s),x)-1):-1000000000000000;
        tr = (lower_bound(ALL(t),x)<t.end())? *lower_bound(ALL(t),x):1000000000000000;
        tl = (lower_bound(ALL(t),x)-1>=t.begin())? *(lower_bound(ALL(t),x)-1):-1000000000000000;
        ll dis1,dis2,dis3,dis4;
        dis1 = max(llabs(x-sr),llabs(x-tr));
        dis2 = max(llabs(x-sl),llabs(x-tl));
        dis3 = llabs(x-sr)+llabs(x-tl)+min(llabs(x-sr),llabs(x-tl));
        dis4 = llabs(x-sl)+llabs(x-tr)+min(llabs(x-sl),llabs(x-tr));
        cout << min({dis1,dis2,dis3,dis4}) << endl;
    }
}


Measured memory_bytes: 3712
from typing import List


def minkowski():
    num_elements = int(input())
    x_list: List[int] = list(map(int, input().split()))
    y_list: List[int] = list(map(int, input().split()))

    for p in range(1, 4):  # p = 1, 2, 3
        sum_error = 0
        for i in range(num_elements):
            sum_error += abs(x_list[i] - y_list[i]) ** p
            sum_dist = sum_error ** (1 / p)
        print(f"{sum_dist:.6f}")

    max_dist = 0  # p = infinity
    for i in range(num_elements):
        dist = abs(x_list[i] - y_list[i])
        if dist > max_dist:
            max_dist = dist
    print(f"{max_dist:.6f}")


if __name__ == "__main__":
    minkowski()



Measured memory_bytes: 7244
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll A[55];
int main ()
{
    int N;cin >> N;
    ll pw=2LL;
    for(int i=1;i<=N;i++){
        cin >> A[i];
    }
    sort(A+1,A+1+N);
    ll sum=A[1]+A[2];
    for(int i=3;i<=N;i++){
            sum+= pw*A[i];
            pw*=2LL;
    }
    double ans = (double)sum/pw;
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n); i>=0; --i)

const int INF = (int)1e6+5;
const int NAX = (int)3e5+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
   cin >> a >> b;
   cout << max({a+b, a-b, a*b}) << "\n"; 
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;

void main() {
    string s = readln.chomp;
    bool can = 1;
    foreach(c; "abc") can &= (count(s, c) == 1);
    writeln(can ? "Yes" : "No");
}

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

int main() {
  int n,m,xmax,ymin,x,y,xn,ym;
  cin >> n >> m >> x >> y >> xmax;
  for(int i = 1; i < n; i++){
    cin >> xn;
    if(xmax < xn){
      xmax = xn;
    }
  }
  cin >> ymin;
  for(int i = 1; i < m; i++){
    cin >> ym;
    if(ymin > ym){
      ymin = ym;
    }
  }
  if((xmax < ymin && x < ymin)&&(xmax < ymin && xmax < y)){
    cout << "No War" << endl;
  }
  else{
    cout << "War" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int 		  long long
#define	pb 			  push_back
#define all(a)		  (a).begin(),(a).end()
#define sz(x)		  (int)x.size()
#define endl	 	  "\n"
#define inf 		  1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)

mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers.

//int dp[1000001] = {0};


void solve(){
	int n, x;
	cin>>n>>x;
	if(n*500>=x){
		cout<<"Yes"<<endl;
	}	
	else{
		cout<<"No"<<endl;
	}
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 10000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

struct edge{int to, cost;};

class Graph
{
public:
    int V;
    vector<vector<edge>> G;

    Graph(int V): V(V){
        G = vector<vector<edge>>(V, vector<edge>(0));
    }

    void add_edge(int from, int to, int cost){
        G[from].push_back(edge({to, cost}));
    }

    void add_edge2(int v1, int v2, int cost){
        add_edge(v1, v2, cost);
        add_edge(v2, v1, cost);
    }

    bool dfs(vec &val, int v, vector<bool> &used, int c, int &m1, int &m2, int R){
        used[v] = true;
        val[v] = c;
        if(v < R) m1 = min(m1, c);
        else m2 = min(m2, c);
        REP(i, G[v].size()){
            if(used[G[v][i].to]){
                if(val[v] + val[G[v][i].to] != G[v][i].cost) return false;
            }else{
                if(!dfs(val, G[v][i].to, used, G[v][i].cost - val[v], m1, m2, R)) return false;
            }
        }
        return true;
    }

};

signed main(){

    int R, C; cin >> R >> C;
    Graph G(R + C);
    int N; cin >> N;
    vec r(N), c(N), a(N);
    REP(i, N){
        cin >> r[i] >> c[i] >> a[i];
        G.add_edge2(r[i] - 1, R + c[i] - 1, a[i]);
    }

    vector<bool> used(R + C, false);
    vec val(R + C, INF);
    bool f = true;
    REP(i, R + C){
        if(!used[i]){
            int m1 = INF, m2 = INF;
            if(!G.dfs(val, i, used, 0, m1, m2, R)) f = false;
            if(m1 + m2 < 0) f = false;
        }
    }
    
    if(f) cout << "Yes";
    else cout << "No";
    
    return 0;
}

Measured memory_bytes: 18304
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

//long long int a[100100];

int main(){
	int x, y;
	scanf("%d%d", &x, &y);
	int f=0;
	for(int a=0; a<=100; a++){
		for(int b=0; b<=100; b++){
			if((a+b==x) && (2*a+4*b==y)){
				f=1;
				break;
			}
		}
	}
	if(f==1) printf("Yes\n");
	else printf("No\n");
	//printf("%d", ans+1);
	
	return 0;
}


Measured memory_bytes: 1624
n = int(input())
s = str(input())
w = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
t = ""
for i in range(len(s)):
    for h in range(26):
        if s[i] == w[h]:
            t += w[h+n]
            break
print(t)

Measured memory_bytes: 8952
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define watch(x) cout << (#x) << " is: " << (x) << endl
#define vw(v)                        \
    cout << endl                     \
         << endl                     \
         << (#v) << " is: " << endl; \
    for (ll B : (v))                 \
    {                                \
        cout << B << " ";            \
    }                                \
    cout << endl
#define check(x) cout << "here " << (x) << "?" << endl
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a) for (long long i = (a - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rv(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
ll const MAX = 2147483647, REALMAX = 9223372036854775806;
// ll const N = ;

int main()
{
    FAST_IO
    ll n, m, sum = 0, sum1 = 0;
    cin >> n >> m;
    vector<ll> v(n + 1, 0), v1(n + 1, 0);
    rep(i, 0, m)
    {
        ll x;
        string c;
        cin >> x >> c;
        if (c == "WA" && v[x] == 0)
            v1[x]++;
        if (c == "AC" && v[x] != 1)
            sum1++, v[x] = 1, sum += v1[x];
    }
    cout << sum1 << " " << sum;
}

Measured memory_bytes: 1792
n=int(input())
tou=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for _ in range(n):
    b,f,r,v=map(int, input().split())
    tou[b-1][f-1][r-1]+=v

for i in range(4):
    for j in range(3):
        print(' ', end='')
        print(*tou[i][j])
    if i!=3: print('#'*20)


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

int main()
{
    ll x, y;
    cin >> x >> y;

    ll a = 4*x - y;
    ll b = y - 2*x;
    if(a >= 0 && a % 2 == 0 && b >= 0 && b % 2 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


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

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;

    if (a == b){
        cout << 2 * a;
    } else{
        int t;
        t = max(a, b);
        cout << (t*2) -1;
    }
    return 0;
}


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

using namespace std;

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

	int ans = 0;
	int min = 1e9;
	for (int i = 0; i < N; ++i) {
		if (min > P[i]) {
			++ans;
			min = P[i];
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
import bisect

N = int(input())
L = [int(n) for n in input().split()]
L = sorted(L)

total = 0

for i in range(N - 2):
    a = L[i]
    for j in range(i + 1, N - 1):
        b = L[j]
        right_endpoint = bisect.bisect_left(L, a+b, j)
        total += right_endpoint - j - 1

print(total)

Measured memory_bytes: 3188
from collections import defaultdict

def getlist():
	return list(map(int, input().split()))

#受け取り、初期化
N, C = getlist()
D = []
x0 = defaultdict(int)
x1 = defaultdict(int)
x2 = defaultdict(int)
for i in range(C):
	d = getlist()
	D.append(d)
for i in range(N):
	c = getlist()
	for j in range(N):
		if (i + j) % 3 == 0:
			x0[c[j]] += 1
		elif (i + j) % 3 == 1:
			x1[c[j]] += 1
		else:
			x2[c[j]] += 1

#D処理
cost0 = [0] * (C)
cost1 = [0] * (C)
cost2 = [0] * (C)
for i in range(C):
	for j in x0:
		cost0[i] += D[j - 1][i] * x0[j]
for i in range(C):
	for j in x1:
		cost1[i] += D[j - 1][i] * x1[j]
for i in range(C):
	for j in x2:
		cost2[i] += D[j - 1][i] * x2[j]

#最小値計算
ans = float("inf")
for i in range(C):
	for j in range(C):
		for k in range(C):
			val = cost0[i] + cost1[j] + cost2[k]
			if i != j and j != k and k != i:
				ans = min(ans, val)

print(ans)

Measured memory_bytes: 3444