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

int main()
{
	int h,w;
	cin >> h >> w;
	int ans[h][w];
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			char a;
			cin >> a;
			if(i == 0 && j == 0){
				ans[i][j] = 1;
			}else if(i == 0){
				if(a == '.'){
					ans[i][j] = ans[i][j-1];
				}else{
					ans[i][j] = 0;
				}
			}else if(j == 0){
				if(a == '.'){
					ans[i][j] = ans[i-1][j];
				}else{
					ans[i][j] = 0;
				}
			}else{
				if(a == '.'){
					ans[i][j] = (ans[i-1][j] + ans[i][j-1]) % 1000000007;
				}else{
					ans[i][j] = 0;
				}
			}
		}
	}

	cout << ans[h-1][w-1] << "\n";

	return 0;
}


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

 int main() {
   int A,B,C,D;
   cin >> A >> B >> C >> D;
   
   int a = min(A,B);
   int b = min(C,D);
   
   int ans = a + b;
   cout << ans << endl;
   
 }

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#define all(a) (a).begin(),(a).end()
#define rep(i,a) for(int i=0;i<(a);i++)
#define pb push_back
using namespace std;

int main(){
  int n;
  double xl[110],xr[110],yd[110],yu[110],r;
  bool g[220][220];
  int test = 1;

  while(scanf("%d",&n),n){
    vector<double> h,w;
    rep(i,n){
      scanf("%lf%lf%lf",&xl[i],&yd[i],&r);
      xl[i] -= r; xr[i] = xl[i]+r+r;
      yd[i] -= r; yu[i] = yd[i]+r+r;
      w.pb(xl[i]); w.pb(xr[i]);
      h.pb(yd[i]); h.pb(yu[i]);
    }

    sort(all(h));
    h.erase(unique(all(h)),h.end());
    sort(all(w));
    w.erase(unique(all(w)),w.end());

    rep(i,n){
      xl[i] = lower_bound(all(w),xl[i]) - w.begin();
      xr[i] = lower_bound(all(w),xr[i]) - w.begin();
      yd[i] = lower_bound(all(h),yd[i]) - h.begin();
      yu[i] = lower_bound(all(h),yu[i]) - h.begin();
    }

    rep(i,h.size())rep(j,w.size())g[i][j] = false;
    rep(i,n)
      for(int j=yd[i];j<yu[i];j++)
	for(int k=xl[i];k<xr[i];k++)g[j][k] = true;

    double ans = 0;
    rep(i,h.size())rep(j,w.size())
      if(g[i][j])ans += (h[i+1]-h[i])*(w[j+1]-w[j]);
    printf("%d %.2lf\n",test++,ans);
  }
}
    

    
      

Measured memory_bytes: 1148
#003
N,x= [int(i) for i in input().split(" ")]
list = [int(i) for i in input().split(" ")]
count = 0 
for i in range(N):
    if(i==0):
        if list[i]>x:
            temp = list[i]-x
            count+=temp
            list[i]-=temp
    else:
        temp = list[i]+list[i-1]-x
        if(temp>0):
            count+=temp
            list[i]-=temp    
print(count)

Measured memory_bytes: 14548
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
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;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n;
	while(cin >> n){
		vector<LL> a(n);
		REP(i,n) cin >> a[i];
		LL p = 1;
		LL ma = 1;
		LL ans = 0;
		REP(i,n){
			LL num = a[i]/p;
			if(a[i]%p == 0){
				num--;
			}
			if(num > 0){
				LL pp = (a[i]-1)/num;
				a[i] = a[i]%pp;
				ans += num;
			}
			DEBUG(i); DEBUG(ans);
			ma = max(a[i],ma);
			p = ma+1;
		}
		dpite(ALL(a));
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int digdist(long long a, long long b){
    int diga = 0;
    int digb = 0;
    while(a > 0){
        a /= 10;
        diga++;
    }
    while(b > 0){
        b /= 10;
        digb++;
    }
    return max(diga, digb);
}
int main(){
    long long N;
    cin >> N;
    int ans = 100;
    for(int i = 2; i <= sqrt(N); i++){
        if(N % i == 0){
            ans = min(ans, digdist(i, N/i));
        }
    }
    if(ans == 100){
        ans = digdist(1, N);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  vector<vector<char>>a(3,vector<char>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<3;i++){
    cout<<a[i][i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
s=[]
for i in range(h):
    s.append(input())
def cnt(i,j):
    tmp=0
    if i!=0:
        if s[i-1][j]=='#':
            tmp+=1
    if i!=h-1:
        if s[i+1][j]=='#':
            tmp+=1
    if j!=0:
        if s[i][j-1]=='#':
            tmp+=1
    if j!=w-1:
        if s[i][j+1]=='#':
            tmp+=1
    if i!=0 and j!=0:
        if s[i-1][j-1]=='#':
            tmp+=1
    if i!=0 and j!=w-1:
        if s[i-1][j+1]=='#':
            tmp+=1
    if i!=h-1 and j!=0:
        if s[i+1][j-1]=='#':
            tmp+=1
    if i!=h-1 and j!=w-1:
        if s[i+1][j+1]=='#':
            tmp+=1
    return tmp

t=[]
for i in range(h):
    tmp=[]
    for j in range(w):
        if s[i][j]=='.':
            tmp.append(cnt(i,j))
        else:
            tmp.append('#')
    t.append(tmp)
for i in range(h):
    print(*t[i],sep='')

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
char s[101];
int main()
{
    int left,right,sum;
    char t[11];
    cin>>s;
    for(int i=0; i<strlen(s); i++)
        if(isalpha(s[i]))
        {
            left=i;
            break;
        }
    for(int i=strlen(s); i>0; i--)
        if(isalpha(s[i]))
        {
            right=i;
            break;
        }
    sum=right-left-1;
    sprintf(t, "%d", sum);
    cout<<s[left]<<t<<s[right]<<endl;
    return 0;
}

Measured memory_bytes: 256
// Author : Hardik Upadhyay
// college: SVNIT 
// slogan : Ab to phod dunga
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,b) for(int i=0;i<b;i++)
#define rrep(i,b) for(int i = b - 1; i >= 0; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int MAXN = 100005;
ll mod=1000000007;
const int INF = 1e9 + 5;
//int dp[MAXN][2]; // dp[i][j] --> min cost to reach stone i with last leap of j+1
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int h[n];
	for(int i = 0; i < n; i++) cin>>h[i];
	vector<int> dp(n,INF);
	dp[0] = 0;
	for(int i = 0; i < n ; i++){
		for(auto j: { i+1,i+2}){
			if( j < n)
			dp[j] = min(dp[j],	dp[i] + abs(h[i] - h[j]));
		}
	}
	cout<<dp[n-1]<<nl;
	return 0;

}



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

using namespace std;


typedef long long ll;

int main()
{
    int n,k;
    cin>>n>>k;
    vector<ll> a(n+1);
    vector<ll> b(n+1);
    a[0]=99999;
    b[0]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=2;i<=n;i++)
    {
        b[i]=99999999999999;
        for(int j=1,l=i-1;l>0&&j<=k;l--,j++)
        {
           b[i]=min(abs(a[i]-a[l])+b[l],b[i]);
        }
    }
    cout<<b[n];
}


Measured memory_bytes: 1792
#!/usr/bin/env python
#-*- coding: utf-8 -*-

# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_B

if __name__ == '__main__':
    i = 1
    while 1:
        line = raw_input()
        if line == '0':
            break
        print "Case %d: %s" % (i, line)
        i += 1


Measured memory_bytes: 4632
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;

    vector<int> neg;
    vector<int> pos;

    for (int i = 0; i < n; i += 1) {
        int x;
        cin >> x;

        if (x >= 0) {
            pos.push_back(x);
        } else {
            neg.push_back(x);
        }
    }
    reverse(neg.begin(), neg.end());

    int64_t res = 1e18;
    for (int i = 0; i <= min<int>(k, neg.size()); i += 1) {
        if (k - i > (int)pos.size()) {
            continue;
        }

        int64_t left = (i > 0 ? abs(neg[i - 1]) : 0);
        int64_t right = (i < k ? pos[k - i - 1] : 0);

        int64_t cost = right + left + min(right, left);
        res = min(res, cost);
    }

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


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647

int main() {
  kyun;
  string s;
  cin >> s;
  bool ans = 1;
  if(s[2] != s[3] || s[4] != s[5]) ans = 0;
  if(ans) cout << "Yes";
  else cout << "No";
  hinata;
}


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

ll gcf(ll a, ll b){
    if(b == 0) return a;
    return gcf(b,a%b);
}

int main(){
    int N; cin >> N;
    vector<ll> A(N,0); for(int i = 0; i < N; i++) cin >> A.at(i);
    
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans = gcf(ans,A.at(i));
    }
    
    cout << ans << endl;
}



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

const int MAXN = 107;
int n;
int w;
int a, b;


int main() {

    cin >> n >> w;
    vector <long long int> dp(w + 1, 0);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &a, &b);
        for (int j = w - a; j >= 0; j--) {
            dp[j + a] = max(dp[j + a], dp[j] + b);
        }
    }
    cout << dp[w];
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
	int n, x,ans=0,d=0; cin >> n >> x;
	int L[110];
	for (int i = 0; i < n; i++) {
		cin >> L[i];
	}
	for (int i = 0; i < n; i++) {
		d += L[i];
		if (d < x + 1)ans++;
	}
	cout << ans+1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, m, c, ans = 0;
  scanf("%lld%lld%lld", &n, &m, &c);
  ll a, b[m], now;
  for(i = 0; i < m; ++i) scanf("%lld", &b[i]);
  for(i = 0; i < n; ++i) {
    now = c;
    for(j = 0; j < m; ++j) scanf("%lld", &a), now += a * b[j];
    if(now > 0) ++ans;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//test
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long long n,m,nn;
    cin>>n>>m;
    vector<long long> a;
    for(int i=0;i<n;i++){
        cin>>nn;
        nn/=2;
        a.push_back(nn);
    }
    
    sort(a.begin(),a.end(),greater<int>());
    a.erase(unique(a.begin(),a.end()),a.end());
    
    long long mul=1;
    for(int i=0;i<a.size();i++){
        mul=abs(mul*a[i])/__gcd(mul,a[i]);
        
    }
    if(mul>m){
        cout<<"0"<<endl;
        return 0;
    }
    
    for(int i=0;i<a.size();i++){
        if(mul/a[i]%2==0){
            cout<<"0"<<endl;
            return 0;
        }
    }
    
    int ans=m/mul-m/mul/2;;
    cout<<ans<<endl;
}

Measured memory_bytes: 1400
#gcd関数(最大公約数を求める)
from fractions import gcd
a,b,c,d = map(int,input().split())
 
#c,dにおける最小公倍数を求める
z = c*d // gcd(c,d)
#a - 1以下の個数を求める
i = a - 1

#xはb以下で割り切れない個数を求める
x = b - (b // c + b // d - b // z)
#yはa - 1以下で割り切れない個数を求める
y = i - (i // c + i // d - i // z)
#b以下で割り切れない個数からa- 1以下で割り切れない個数引いた個数
print(x - y)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int n;
    cin >> n;

    set<int> num;
    rep(i, n){
        int a;
        cin >> a;

        num.insert(a);

    }

    if(num.size() == n) puts("YES");
    else puts("NO");

    return 0;
}

Measured memory_bytes: 9600
def check(input_list):
    for a in input_list:
        a = int(a)
        if(a % 2 == 0 and not(a % 3 == 0 or a % 5 == 0)):
            return False
    
    return True

if __name__ == '__main__':
    num = input()
    input_list = [int(a) for a in input().split()]
    
    if check(input_list):
        print("APPROVED")
    else:
        print("DENIED")



Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int n,m,a[110];
int main()
{
	scanf("%d%d",&n,&m);
	if (m==1)
	{
		if (n==1)
		{
			printf("1\n1\n1\n");
		}
		else
		{
			printf("%d\n2\n1 %d\n",n,n-1);
		}
		return 0;
	}
	int t1=0,t2=0;
	for (int i=1;i<=m;i++)
	{
		scanf("%d",&a[i]);
		if (a[i]&1)
		{
			if (!t1)
			{
				t1=i;
			}
			else if (!t2)
			{
				t2=i;
			}
			else
			{
				puts("Impossible");
				return 0;
			}
		}
	}
	if (t1)
	{
		swap(a[1],a[t1]);
	}
	if (t2)
	{
		swap(a[m],a[t2]);
	}
	for (int i=1;i<=m;i++)
	{
		printf("%d ",a[i]);
	}
	puts("");
	if (a[1]==1)
	{
		printf("%d\n",m-1);
	}
	else
	{
		printf("%d\n%d ",m,a[1]-1);
	}
	for (int i=2;i<m;i++)
	{
		printf("%d ",a[i]);
	}
	printf("%d\n",a[m]+1);
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		ArrayDeque<String> q = new ArrayDeque<String>();
		
		try {
			int lim = Integer.parseInt(in.readLine());
			
			for (int i = 0; i < lim; i++) {
				String[] str = in.readLine().split(" ");
				
				if (str[0].equals("insert")) {
					q.addFirst(str[1]);
				} else if (str[0].equals("delete")) {
					q.remove(str[1]);
				} else if (str[0].equals("deleteFirst")) {
					q.removeFirst();
				} else {
					q.removeLast();
				}
			}
			
			System.out.print(q.remove());
			while (q.isEmpty() == false) {
				System.out.print(" " + q.remove());
			}
			System.out.println();
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 229520
#include<stdio.h>
 
int main(void){
 
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(c>b&&b>a){
printf("%d %d %d\n",a,b,c);
}
if(b>c&&c>a){
printf("%d %d %d\n",a,c,b);
}
if(a>c&&c>b){
printf("%d %d %d\n",b,c,a);
}
if(c>a&&a>b){
printf("%d %d %d\n",b,a,c);
}
if(b>a&&a>c){
printf("%d %d %d\n",c,a,b);
}
if(a>b&&b>c){
printf("%d %d %d\n",c,b,a);
}
if(a==b&&b==c){
printf("%d %d %d\n",a,a,a);
}
if(a==b&&b>c){
printf("%d %d %d\n",c,a,a);
}
if(a==b&&c>b){
printf("%d %d %d\n",a,a,c);
}
 
if(a>c&&b==c){
printf("%d %d %d\n",b,b,a);
}
if(c>a&&b==c){
printf("%d %d %d\n",a,b,b);
}
if(b>c&&c==a){
printf("%d %d %d\n",a,a,b);
}
 
return(0);
}

Measured memory_bytes: 596
//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
#define UPADHYAY int t;cin>>t;while(t--)
int main(){
    ll a,b,c,d,k;
    cin>>a>>b>>c>>d;
    k=a*c;
    k=max(k,a*d);
    k=max(k,b*c);
    k=max(k,b*d);
    cout<<k;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF 200000000
#define MOD 2019
#define lli long long
using namespace std;
int main(){
  lli l,r,m=INF,i,j;
  cin >> l >> r;
  
  if(r-l>=673){
    cout << "0" << endl;
    return 0;
  }
  
  for(i=l;i<=r;i++){
    for(j=i+1;j<=r;j++){
      m=min(m,((i%MOD)*(j%MOD))%MOD);
    }
  }
  cout<<m<<endl;
  return 0;
}
//2019=3*673

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

int main() {
	
	int n;
	cin >> n;
	for(int i = 1; i<=n; i++){
		if( (int) (i * 1.08)  == n){
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& x : a)
        cin >> x;
    cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end()) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;
int N;
vector<ll> A(200010);
vector<ll> W(200010, -INFL);

int main() {
    cin >> N;
    W.at(0) = 0;
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
        W.at(i+1) = W.at(i) + A.at(i);
    }
    W.at(N+1) = INFL;
    sort(W.begin(), W.end());
    vector<ll> cnt(0);
    ll pre, now;
    now = -INFL;
    ll l = 1;
    for(int i = 1; i < 200010; i++){
        pre = now;
        now = W.at(i);
        if(pre == now){
            l++;
        }else{
            cnt.push_back(l);
            l = 1;
        }
    }
    
    ll ans = 0;
    for(int i = 1; i < cnt.size(); i++){
        ans += cnt.at(i) * (cnt.at(i) - 1) / 2;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 5492
#include <iostream>

using namespace std;

int gcd(int x, int y)
{
    if (x < y) return gcd(y, x);
    if (!y) return x;
    return gcd(y, x % y);
}

int main(void)
{
    int X, Y;
    cin >> X >> Y;
    cout << gcd(X, Y) << endl;
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int C, R, k;
    cin >> R >> C >> k;
    vector<int> r(k, 0), c(k, 0), v(k, 0);
    for(int i = 0; i < k; i++)
        cin >> r[i] >> c[i] >> v[i];
    vector<vector<int>> arr(R, vector<int> (C));
    for(int i = 0; i < k; i++)
        arr[r[i] - 1][c[i] - 1] = v[i];
    vector<vector<vector<ll>>> dp(R + 1, vector<vector<ll>>(C + 1, vector<ll>(4, 0)));
    for(int i = 0; i < R; i++){
        for(int j = 0; j < C; j++){
            for(int k = 2; k >= 0; k--){
                dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k] + arr[i][j]);
            }
            for(int k = 0; k < 4; k++){
                dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
                dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < 4; i++)
        ans = max(ans, dp[R - 1][C - 1][i]);
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n ; cin >> n ;
  if(n==100000){
    cout << 90000+900+9 << endl ;
  }else if(n>=10000){
    cout << n-9999+900+9 << endl ;
  }else if(n>=1000){
    cout << 900+9 << endl ;
  }else if(n>=100){
    cout << n-99+9 << endl ;
  }else if(n>=10){
    cout << 9 << endl ;
  }else{
    cout << n << endl ;
  }
}

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

using namespace std;

int main(void){
	int N,M;
	long long ans;
	cin >> N >> M;
	long long X[M];
	for(int i=0;i<M;i++){
		cin >> X[i];
	}
	sort(X,X+M);
	ans = abs(X[M-1] - X[0]);
	if(N>=M){
		cout << "0" << endl;
		return 0;
	}else{
		vector<long long> d(M-1);
		for(int i=0;i<M-1;i++){
			d[i] = abs(X[i+1]-X[i]);
		}
		sort(d.rbegin(),d.rend());
		for(int i=0;i<N-1;i++)ans-=d[i];
		cout << ans << endl;
	}
	
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;

int main(){
	int N, M;
	cin >> N >> M;
	vint a(M), dp(N+1, -INF);
	int b[] = {0,2,5,5,4,5,6,3,7,6};
	for(int i = 0;i < M;i++)	cin >> a[i];
	dp[0] = 0;
	for(int i = 1;i <= N;i++){
		for(int j = 0;j < M;j++){
			if(i- b[a[j]] >= 0)	dp[i] = max(dp[i], dp[i-b[a[j]]]+1);
		}
	}
	int r = N;
	sort(a.rbegin(), a.rend());
	while(r > 0){
		for(int i = 0;i < M;i++){
			if(r-b[a[i]] >= 0 && dp[r-b[a[i]]] == dp[r]-1){
				cout << a[i];
				r -= b[a[i]];
				break;
			}
		}
	}
}

Measured memory_bytes: 256
ans_l = []
while True:
    try:
        d = int(input())
        x_coordinate = -d
        def height(x_coordinate):
            return x_coordinate**2
        ans = 0
        for i in range(600//d):
            x_coordinate += d
            ans += d * height(x_coordinate)
        ans_l.append(ans)
    except:
        break
print(*ans_l,sep='\n')


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N,K;
  cin >> N >> K;
  int ans=1;
  
  for(int i=0; i<N; i++){
  	if(ans<=K) ans*=2;
    else ans+=K;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
bool a[8];
ll N;
ll cnt=0;
ll z=0;

int main()
{
	cin>>N;
	ll x;
	rep(i,N){
		cin>>x;
		x=x/(400LL);
		if(x>=8){ z++; continue;}
		else if(!a[x]){
			a[x]=1;
			cnt++;
		}
	}
	
	cout<<max(cnt,1LL)<<" "<<cnt+z<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 0; i < n; i++){
			BigInteger num = sc.nextBigInteger();
			num = num.add(sc.nextBigInteger());
			String temp = num.toString();
			if(temp.length() > 80){
				System.out.println("overflow");
			}else{
				System.out.println(temp);
			}
		}
	}
}

Measured memory_bytes: 26696
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
using namespace std;
int main() {
	vector<int> www;
	for (int i = 0;i < 2;++i) {
		int b;
		scanf("%d", &b);
		for (int q = 0;q < b;++q) {
			int c, d;
			scanf("%d%d", &c, &d);
			www.push_back((c * 60) + d);
		}
	}
	set<int> wa(www.begin(), www.end());
	vector<int> a(wa.begin(), wa.end());
	sort(a.begin(), a.end(), greater<int>());
	while(a.empty() == false){
		int aaa = a.back();a.pop_back();
		int hour = aaa / 60;
		int minute = aaa % 60;
		if (minute >= 10) {
			printf("%d:%d", hour, minute);
		}
		else {
			printf("%d:0%d", hour, minute);
		}
		if (a.empty() == false) {
			printf(" ");
		}
		else {
			printf("\n");
		}
	}
}


Measured memory_bytes: 1068
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
using namespace std;

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

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

    for (int i = 0; i < 3; i++) {
        int tmp = n % 10;
        n /= 10;
        if (tmp == n % 10) {
            cout << "Bad" << "\n";
            return 0;
        }
    }
    cout << "Good" << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static final int BINGO = -1;

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

        int[][] a = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++)
            a[i][j] = scanner.nextInt();
        }

        int n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int b = scanner.nextInt();

            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (a[j][k] == b) {
                        a[j][k] = BINGO;
                    }
                }
            }
        }

        boolean isBingo = false;

        // ななめ
        if (a[0][0] == BINGO && a[1][1] == BINGO && a[2][2] == BINGO) {
            isBingo = true;
        } else if (a[0][2] == BINGO && a[1][1] == BINGO && a[2][0] == BINGO) {
            isBingo = true;
        } else {
            // 縦 or 横
            for (int i = 0; i < 3; i++) {
                if (a[i][0] == BINGO && a[i][1] == BINGO && a[i][2] == BINGO) {
                    isBingo = true;
                } else if (a[0][i] == BINGO && a[1][i] == BINGO && a[2][i] == BINGO) {
                    isBingo = true;
                }
            }
        }
        System.out.println(isBingo ? "Yes" : "No");
    }
}


Measured memory_bytes: 23764
// Problem03.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	int start = max(ceil(a / 0.08), ceil(b / 0.1));
	int end = min(floor((a + 1) / 0.08), floor((b + 1) / 0.1));
	if (start >= end)
		cout << -1 << endl;
	else
		cout << start << endl;

    return 0;
}



Measured memory_bytes: 256
N=int(input())
A=[]
B=[]
for i in range(N):
	if i%2==0:
		A.append(int(input()))
	else:
		B.append(int(input()))
		
A=sorted(A)
B=sorted(B)
C=sorted(A+B)
#ここまでNlogN
c=0
j=0
for i in range(N):
	if j>=len(A):
		break
	if A[j]==C[i]:
		if i%2==1:
			c+=1
		j+=1
print(c)

Measured memory_bytes: 8932
h,w=map(int,input().split())
list1=[[0 for i in range(w)]for j in range(h)]
list2=[[0 for i in range(w)]for j in range(h)]
dx=[-1,-1,-1,0,0,1,1,1]
dy=[-1,0,1,-1,1,-1,0,1]
for j in range(h):
 s=input()
 for i in range(w):
  list1[j][i]=s[i]
for j in range(h):
  for i in range(w):
   if list1[j][i]=="#":
    for k in range(8):
     xk=i+dx[k]
     yk=j+dy[k]
     if xk>=0 and xk<w and yk>=0 and yk<h:
      list2[yk][xk]+=1
for j in range(h):
  for i in range(w):
    if list1[j][i]=="#":
      list2[j][i]="#"
    else:
      list2[j][i]=str(list2[j][i])
for j in range(h):
 print("".join(list2[j]))

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

int main(){
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> x(N), y(N);
    vector<ll> xs, ys;
    for(int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
        xs.push_back(x[i]);
        ys.push_back(y[i]);
    }
    sort(begin(xs), end(xs));
    sort(begin(ys), end(ys));
    xs.erase(unique(begin(xs), end(xs)), end(xs));
    ys.erase(unique(begin(ys), end(ys)), end(ys));
    ll res = 4 * inf<ll>;
    for(int i = 0; i < xs.size(); ++i) {
        for(int j = i; j < xs.size(); ++j) {
            for(int k = 0; k < ys.size(); ++k) {
                for(int l = k; l < ys.size(); ++l) {
                    ll x1 = xs[i], x2 = xs[j];
                    ll y1 = ys[k], y2 = ys[l];
                    int cnt = 0;
                    for(int m = 0; m < N; ++m) {
                        cnt += (x1 <= x[m] && x[m] <= x2 && y1 <= y[m] && y[m] <= y2);
                    }
                    if(cnt >= K) {
                        res = min(res, (y2 - y1) * (x2 - x1));
                    }
                }
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h,w ; 
  cin >> h >> w ; 
  vector<vector<char>> data(h ,vector<char> (w));
  for (int i = 0; i < (int)(h); i++){
    for (int j = 0; j < (int)(w); j++){
      cin >> data.at(i).at(j) ;
    }
  }
  
  vector<int> yoko , tate;
  
    for (int i = 0; i < (int)(h); i++){
    int  count = 0 ;
     for (int j = 0; j < (int)(w); j++){
      if(data.at(i).at(j) == '.') count ++ ;
    }
    if(count != w) yoko.push_back(i) ;
  }
  
  for (int i = 0; i < (int)(w); i++){
    int  count = 0 ;
    for (int j = 0; j < (int)(h); j++){
      if(data.at(j).at(i) == '.')  count ++  ;
    }
    if(count != h) tate.push_back(i) ;
  }
  
  
 for (int i = 0; i < (int)(yoko.size());i++){
     for (int j = 0; j < (int)(tate.size());j++){
      cout << data.at(yoko.at(i)).at(tate.at(j)) ;
    }
    cout <<endl;
  }
  
}

Measured memory_bytes: 3584
import java.util.Scanner;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		int N = s.length();
		System.out.println("" + s.charAt(0) + (N - 2) + s.charAt(N - 1));
	}
}


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

int main(){
	int s=100000,n;
	
	cin >> n;
	
	for(int i=0;i<n;i++){
		s*=1.05;
		if(0!=s%1000) s = (s / 1000 + 1) * 1000;
	}
	
	cout << s <<endl;
	
	return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 2019
mans = inf ;ans = 0 ;count = 0 ;pro = 1

S = list(map(int,input()))
n = len(S)
now10 = 1
for i in range(n-1,-1,-1):
  S[i] = S[i] * now10 % mod
  now10 = now10 * 10 % mod
A = [0]* (n+1)
for i in range(n):
  A[i+1] = (A[i] + S[i]) % mod
C = collections.Counter(A)
for k,e in C.items():
  ans += (e-1)*e//2
print(ans)



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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll N;
  scanf("%lld",&N);
  ll ans=0;
  for (int i=1; i<=N; i++) {
    ans+=i;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
from itertools import permutations
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

N, M, R = map(int, input().split())
R = list(map(int, input().split()))
A, B, C = np.array([input().split() for _ in range(M)], dtype=int).T
G = csr_matrix((C, (A - 1, B - 1)), shape=(N, N))
path = dijkstra(G, directed=False)
path = (path + 0.5).astype(int)

ans = 10 ** 18
for p in permutations(R):
    cnt = 0
    for x, y in zip(p[:-1], p[1:]):
        x -= 1
        y -= 1
        cnt += path[x][y]
    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 22376
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N;

void func(){

	string base_string;

	getline(cin,base_string);

	int loc = 0;

	int Q,right;
	scanf("%d",&Q);
	getchar();

	string tmp;
	bool FLG;

	for(int i = 0; i < Q; i++){
		getline(cin,tmp);

		if(tmp == "forward char"){
			if(loc < base_string.size())loc++;
		}else if(tmp == "forward word"){
			if(loc < base_string.size()){
				while(loc < base_string.size() && base_string[loc] == ' ')loc++;
				while(loc < base_string.size() && base_string[loc] != ' ')loc++;
			}
		}else if(tmp == "backward char"){
			if(loc > 0)loc--;
		}else if(tmp == "backward word"){
			while(loc > 0 && base_string[loc-1] == ' ')loc--;
			while(loc > 0 && base_string[loc-1] != ' ')loc--;
		}else if(tmp == "delete char"){
			if(loc < base_string.size()){
				string str1 = base_string.substr(0,loc);
				string str2 = base_string.substr(loc+1);

				base_string = str1+str2;
			}
		}else if(tmp == "delete word"){
			if(loc < base_string.size()){
				right = loc;
				while(right < base_string.size() && base_string[right] == ' ')right++;
				FLG = false;
				while(right < base_string.size() && base_string[right] != ' '){
					right++;
					FLG = true;
				}
				if(!FLG)continue;

				string str1 = base_string.substr(0,loc);
				string str2 = base_string.substr(right);

				base_string = str1 + str2;

			}
		}else{ //Insert
			base_string.insert(loc,tmp.substr(8,tmp.size()-9));
			loc += tmp.size()-9;
		}
	}

	base_string.insert(loc,"^");
	printf("%s\n",base_string.c_str());
}


int main(){

	scanf("%d",&N);
	getchar();

	for(int i = 0; i < N; i++)func();

	return 0;
}

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

int main() {
    string S;
    cin >> S;
    int ans = 0;

    int tmp = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') {     
            tmp++;
            if (tmp > ans) ans = tmp;
        }
        else {
            tmp = 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define SIZE 9
#define MAX 362880
#define TRUE 1
#define GOAL 2

/*8パズルの繋りを示す隣接リスト*/
int puzzle[SIZE][5]={
  1,3,-1,-1,-1,  0,4,2,-1,-1,  1,5,-1,-1,-1,
  0,4,6,-1,-1,   1,3,5,7,-1,   2,4,8,-1,-1,
  3,7,-1,-1,-1,  4,6,8,-1,-1,  5,7,-1,-1,-1
};

int board[MAX][SIZE];  /*局面*/
int Space[MAX];        /*スペースの位置*/
int prev_board[MAX];
int check_table[MAX];
int init_board[SIZE];
int goal_board[SIZE]={1,2,3,4,5,6,7,8,0};

int change_num(int *);  /*局面を番号に変換*/
void Search(void);
void print_answer(int);

int main(){
  int i;

  for(i=0;i<SIZE;i++) scanf("%d",&init_board[i]);

  Search();

  return 0;

}
  

int change_num(int *board){
  int work[SIZE];
  int i,j,k,value=0;
  int fact_table[SIZE]={40320,5040,720,120,24,6,2,1,0};

  for(i=0;i<SIZE;i++) work[i]=board[i];

  for(i=0;i<SIZE-1;i++){
    value+=fact_table[i]*work[i];
    for(j=i+1;j<SIZE;j++){
      if(work[i]<work[j]) work[j]-=1;
    }
  }
  return value;
}

void Search(void){
  int i,j,k,n,s,front=0,rear=1,count=0,init,goal;

  for(i=0;i<SIZE;i++){
    board[0][i]=init_board[i];
    if(init_board[i]==0) Space[0]=i;
  }
  prev_board[0]=-1;
  init=change_num(init_board);
  goal=change_num(goal_board);
  check_table[init]=TRUE;
  check_table[goal]=GOAL;

  if(init==goal) {
      print_answer(0);
      return;
  }
  
  while(front<rear){
    s=Space[front];
    for(i=0;(n=puzzle[s][i])!=-1;i++){
      /*状態のコピー*/
      for(j=0;j<SIZE;j++) board[rear][j]=board[front][j];
      board[rear][s]=board[rear][n]; /*空白に移動*/
      board[rear][n]=0;
      Space[rear]=n;
      prev_board[rear]=front;
      k=change_num(board[rear]);
      if(check_table[k]==GOAL){
	/*発見*/
	print_answer(rear);
	return;
      }
      
      else if(!check_table[k]){
	  /*キューに登録*/
	  check_table[k]=TRUE;
	  rear++;
	}
    }
    front++;
  }
}
	
void print_answer(int n){
  int i,j,count=0;

  while(n!=0){
    count++;
    n=prev_board[n];
  }

  printf("%d\n",count);

  /* if(n!=0) print_answer(prev_board[n]); */

  /* for(i=0;i<3;i++){ */
  /*   for(j=0;j<3;j++){ */
  /*     printf("%d ",board[n][i*3+j]); */
  /*   } */
  /*   printf("\n"); */
  /* } */
  /* printf("\n"); */
}



Measured memory_bytes: 10968
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7

s = [0]*n
for i in reversed(range(1,n)):
    s[i-1] = s[i] + a[i]
# print(s)

ans = 0
for i in range(n-1):
    ans += a[i]*s[i] % mod

print(ans % mod)

Measured memory_bytes: 105316
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	long long a,b;
	cin>>a>>b;
	if(a>=13)
	{
		cout<<b;
	}
	else if(a>=6)
	{
		cout<<b/2;
	}
	else
		cout<<0;

	return 0;
}

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

int main() {
	int a; cin >> a;
	int b[a];
	for (int i = 0; i < a; i++) cin >> b[i];
	for (int i = 0; i < a - 1; i++) cout << b[i] << " ";
    cout << b[a - 1] << endl;
	for (int i = 1; i < a; i++) {
	    int key = b[i], j = i - 1;
	    while (j >= 0 && b[j] > key) {
	        b[j + 1] = b[j];
	        j--;
	    }
	    b[j + 1] = key;
	    for (int i = 0; i < a - 1; i++) cout << b[i] << " ";
    	cout << b[a - 1] << endl;
	}
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> Point;
#define X real()
#define Y imag()
#define LE(n,m) ((n)<(m)+EPS)
#define GE(n,m) ((n)+EPS>(m))
#define EQ(n,m) (abs((n)-(m))<EPS)
const double EPS=1e-8;
const double pi=acos(-1);

double dot(const Point &a,const Point &b){
    return (conj(a)*b).X;
}
double cross(const Point &a,const Point &b){
    return (conj(a)*b).Y;
}
int ccw(const Point &a,Point b,Point c){
    b-=a,c-=a;
    if (cross(b,c)>EPS) return 1;
    if (cross(b,c)<-EPS) return -1;
    if (dot(b,c)<-EPS) return 2;
    if (norm(b)<norm(c)) return -2;
    return 0;
}

int cmp_x(const Point &a,const Point &b){
    return a.X!=b.X?a.X<b.X:a.Y<b.Y;
}

vector<Point> convex_hull(vector<Point> ps){
    int n=ps.size(),k=0;
    sort(ps.begin(),ps.end(),cmp_x);
    vector<Point> ch(2*n);
    for (int i=0;i<n;ch[k++]=ps[i++])
        while(k>=2&&ccw(ch[k-2],ch[k-1],ps[i])<=0) --k;
    for (int i=n-2,t=k+1;i>=0;ch[k++]=ps[i--])
        while(k>=t&&ccw(ch[k-2],ch[k-1],ps[i])<=0) --k;
    ch.resize(k-1);
    return ch;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int N; cin >> N;
    vector<Point> centers;
    map<pair<double,double>,int> m;
    for (int i=0;i<N;++i){
        double x,y; cin >> x >> y;
        centers.emplace_back(x,y);
        m[{x,y}]=i;
    }
    vector<Point> conv=convex_hull(centers);
    vector<double> rate(N,0);
    int n=conv.size();
    for (int i=0;i<n;++i){
        Point pre=(conv[i]+conv[(i-1+n)%n])/2.0
                ,nxt=(conv[i]+conv[(i+1)%n])/2.0;
        Point rot=(pre-conv[i])/(nxt-conv[i]);
        rot/=abs(rot);
        double theta=atan2(rot.Y,rot.X);
        rate[m[{conv[i].X,conv[i].Y}]]=(pi-theta)/pi/2.0;
    }
    for (int i=0;i<N;++i) cout << rate[i] << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int n,m;
bool b[200000];
int dp[200000];

main(){
  cin>>n>>m;
  rep(i,m){
    int a;
    cin>>a;
    b[a]=true;
  }

  dp[0]=1;

  rep(i,n){
    if(!b[i+1]) dp[i+1]+=dp[i];
    if(!b[i+2]) dp[i+2]+=dp[i];
    dp[i+1]%=M;
    dp[i+2]%=M;
  }

  

  cout<<dp[n]<<endl;
}


Measured memory_bytes: 1152
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.*;
 
public class Main {
	     
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		 
		int pm = 1000000;
		boolean[] prime = new boolean[pm+10000];
		for(int i=2;i<=pm;i++) prime[i] = true;
		for(int i=2;i<=pm+1;i++){
			for(int j=i+i;j<=pm;j+=i){
				prime[j] = false;
			}
		}
		
		int[][] map = new int[1010][1010];
		Point2D.Double[] p = new Point2D.Double[1100000];
		int x = 500;
		int y = 500;
		int z = 1;
		int cnt = 1;
		boolean flag = true;
		while(true){
			if(flag==true){
				for(int i=0;i<z;i++){
					map[y][x] = cnt;
					p[cnt] = new Point2D.Double(x, y);
					cnt++;
					x++;
				}
				for(int i=0;i<z;i++){
					map[y][x] = cnt;
					p[cnt] = new Point2D.Double(x, y);
					cnt++;
					y--;
				}
				flag = false;
			}else if(flag==false){
				for(int i=0;i<z;i++){
					map[y][x] = cnt;
					p[cnt] = new Point2D.Double(x, y);
					cnt++;
					x--;
				}
				for(int i=0;i<z;i++){
					map[y][x] = cnt;
					p[cnt] = new Point2D.Double(x, y);
					cnt++;
					y++;
				}
				flag = true;
			}
			z++;
			if(cnt>1003000) break;
		}


		
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n==0 && m==0) break;
			
			int s = (int)p[m].x;
			int t = (int)p[m].y;
			ArrayDeque<Integer> q = new ArrayDeque<Integer>();
			ArrayDeque<Integer> r = new ArrayDeque<Integer>();
			int[][] dp = new int[1002][1002];
			for(int i=0;i<1002;i++) Arrays.fill(dp[i], -1);
			dp[t][s] = 0;
			q.offer(s);
			r.offer(t);
			int num = 0;
			int max = 0;
			if(prime[m]==true){
				dp[t][s] = 1;
				max = 1;
				num = m;
			}
			
			int u, v;
			while(q.size()!=0){
				s = q.poll();
				t = r.poll();
				for(int i=-1;i<=1;i++){
					v = map[t+1][s+i];
					if(0<=s+i && s+i<=1000 && v<=n){
						if(prime[v]==true){
							if(dp[t+1][s+i]<dp[t][s]+1){
								dp[t+1][s+i] = dp[t][s]+1;
								q.offer(s+i);
								r.offer(t+1);
								if(dp[t+1][s+i]>max){
									max = dp[t+1][s+i];
									num = v;
								}else if(dp[t+1][s+i]==max){
									num = Math.max(num, v);
								}
							}
						}else{
							if(dp[t+1][s+i]<dp[t][s]){
								dp[t+1][s+i] = dp[t][s];
								q.offer(s+i);
								r.offer(t+1);
							}
						}
					}
				}
			}
			System.out.println(max + " " + num);
		}
    }   
}

Measured memory_bytes: 153536
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int c = abs(a-b);
    if (c%2 == 1)cout << "Borys";
    else cout << "Alice";
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc114/tasks/abc114_b


S = list(map(int, list(input())))

ans = 999

for i in range(len(S)-2):
    v = S[i] * 100 + S[i+1] * 10 + S[i+2]
    # print(v)
    ans = min(ans, abs(753-v))

print(ans)


Measured memory_bytes: 2940
# coding: utf-8

import bisect

A,B,Q = map(int, input().split())
*S, = [int(input()) for _ in range(A)]
*T, = [int(input()) for _ in range(B)]
*X, = [int(input()) for _ in range(Q)]

for x in X:
    # 2分探索で、「現在地」と神社群の位置関係を探る
    sx = bisect.bisect(S, x)
    # 現在地から見て東側で最も近い神社
    try:
        se = S[sx]
    except:
        # 東側に存在しない場合は、神社群の中での最東
        se = S[-1]
    # 現在地から見て西側で最も近い神社
    try:
        sw = S[sx-1]
    except:
        # 西側に存在しない場合は、神社群の中での最西
        sw = S[0]

    tx = bisect.bisect(T, x)
    # 現在地から見て東側で最も近いお寺
    try:
        te = T[tx]
    except:
        # 東側に存在しない場合は、お寺群の中での最東
        te = T[-1]
    # 現在地から見て西側で最も近いお寺
    try:
        tw = T[tx-1]
    except:
        # 西側に存在しない場合は、お寺群の中での最西
        tw = T[0]

    # 候補 (8通り) をシミュレーション
    # 東神社 -> 東寺
    # 東寺 -> 東神社
    # 東神社 -> 西寺
    # 西寺 -> 東神社
    # 西神社 -> 東寺
    # 東寺 -> 西神社
    # 西神社 -> 西寺
    # 西寺 -> 西神社
    routes = []
    for s in [se, sw]:
        for t in [te, tw]:
            routes.append(abs(s - x)+abs(t - s))
            routes.append(abs(t - x)+abs(s - t))

    # 最小距離を選ぶ
    print(min(routes))

Measured memory_bytes: 21452
K,X = map(int, input().split())
a, b = 0,0
A = []
if X - K+1 < -1000000:
  a = -1000000
else:
  a = X - K+1

if X + K-1 > 1000000:
  b = 1000000
else:
  b = X + K-1

for _ in range(a,b+1):
  print(_,end=' ')


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;

const int N_MAX = 100000;
const int R_MAX = 50;

const int BigNumber = 1000000007;	


 struct squaence{
	int start,length, counter;
	
	squaence(){}
	squaence(int _start, int _end){
		start = _start;
		length = _end - _start + 1;
		counter = 0;
	}
};



int main(){	
	int s[R_MAX], t[R_MAX];
	int N,R;
		
	long long Factrial[N_MAX];
	Factrial[0] = 1;
	for(int i=1; i<N_MAX; i++){
		Factrial[i] =  (Factrial[i-1] * i) % BigNumber;
	}
	

	while(true){
		cin >> N;
		if(N==0) break;
		cin >> R;
	
		vector<int> st_vector(2*R);
		for(int r=0; r<R; r++){
			int tmp_s, tmp_t;
			cin >> tmp_s >> tmp_t;
			s[r] = tmp_s-1;
			t[r] = tmp_t-1;
			st_vector[2*r  ] = s[r];
			st_vector[2*r+1] = t[r];
		}
		sort(st_vector.begin(), st_vector.end());
		st_vector.erase(unique(st_vector.begin(), st_vector.end()), st_vector.end());
		const int st_vector_size = st_vector.size();
		
		vector<squaence> number;//(st_vector.size()*2+1);
		int n=0;
		for(int j=0; j<st_vector_size; j++){
			if(n <st_vector[j])number.push_back(squaence(n, st_vector[j]-1));
			n = st_vector[j];
			number.push_back(squaence(n, n));
			n++;
		}
		if(n<N)number.push_back(squaence(n, N-1));
			
		map<int,int> index_map;
		for(int i=0; i<st_vector_size; i++){
			int v = st_vector[i];
			auto it = find_if(number.begin(), number.end(), [v](squaence s){return s.start==v;});
			index_map[v] = distance(number.begin(), it) ;
		}

		for(int r=0; r<R; r++){
			int rs = index_map[s[r]];
			int rt = index_map[t[r]];

			int ns = number[rs].start;
			int nt = number[rt].start;
			int cs = number[rs].counter;
			int ct = number[rt].counter;
				
			if(ns<nt)	ct++;
			else		cs--;
			for(int i=rs+1; i<rt; i++){
				int ni = number[i].start;
				if(ni < nt){
					ct+=number[i].length;
					if(ns<ni) number[i].counter++;
				}
				if(ni < ns){
					cs-=number[i].length;
					if(nt<ni) number[i].counter--;
				}
			}

			number[rs].counter = cs;
			number[rt].counter = ct;
			swap(number[rs], number[rt]);
		}
	
		n=0;
		long long  index = 0;
		const int number_size = number.size();
		for(int i=0; i<number_size; i++){
			const squaence* s = &number[number_size-1-i];
			if(s->counter != 0){
				long long f = 0;
				for(int j=0; j< s->length; j++,n++){
					f += Factrial[n];
				}
				index += s->counter * f % BigNumber;
			}
			else{
				n += s->length;
			}
		}
		cout << index%BigNumber << endl;
	}

	return 0;
}

Measured memory_bytes: 2000