akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define maxn 300005
#define lc now<<1
#define rc lc|1
using namespace std;

int w,h,n,x[maxn],y[maxn],num[maxn],up[maxn],dn[maxn],c[maxn],z[maxn];
inline bool cmp(const int &a,const int &b){ return x[a]<x[b]; }

int Max[maxn*10],lazy[maxn*10];
inline void dt(int now)
{ if(lazy[now]){ Max[now]+=lazy[now],lazy[lc]+=lazy[now],lazy[rc]+=lazy[now],lazy[now]=0; } }
inline void upd(int now){ Max[now]=max(Max[lc],Max[rc]); }
void Add(int now,int l,int r,int ql,int qr,int val)
{
	dt(now);
	if(qr<l || ql>r) return;
	if(ql<=l && r<=qr){ lazy[now]+=val,dt(now);return; }
    int mid=(l+r)>>1;
	Add(lc,l,mid,ql,qr,val),Add(rc,mid+1,r,ql,qr,val);
	upd(now);
}
int Query(int now,int l,int r,int ql,int qr)
{
    dt(now);
    if(qr<l || ql>r) return -0x3f3f3f3f;
    if(ql<=l && r<=qr) return Max[now];
    int mid=(l+r)>>1;
    int tmp=max(Query(lc,l,mid,ql,qr) , Query(rc,mid+1,r,ql,qr));
    upd(now);
    return tmp;
}

int ans=0,Q[2][maxn],tp[2];
void solve()
{
	tp[0]=tp[1]=0;
	memset(Max,0,sizeof Max);
	memset(lazy ,0 ,sizeof lazy);
    sort(c+1,c+1+n,cmp);
	num[0]=0;
	for(int i=1;i<=n;i++) if(i==1 || x[c[i-1]] != x[c[i]]) num[++num[0]] = x[c[i]];
	for(int i=1;i<=num[0];i++) up[i] = h , dn[i] = 0;
	int loc = h/2;
    for(int i=1;i<=n;i++)
	{
		x[c[i]] = lower_bound(num+1,num+1+num[0],x[c[i]]) - num;
		if(y[c[i]] >= loc) up[x[c[i]]] = min(up[x[c[i]]] , y[c[i]]);
		if(y[c[i]] <= loc) dn[x[c[i]]] = max(dn[x[c[i]]] , y[c[i]]);
	}
	for(int i=1;i<=num[0];i++)
	{
		ans=max(ans,Query(1,1,num[0],1,i-1) - (w - num[i]));
		if(i) Add(1,1,num[0],i-1,i-1,max(up[i-1],up[i])-min(dn[i-1],dn[i])-h);
		for(;tp[0] && up[Q[0][tp[0]-1]]>up[i];tp[0]--)
			Add(1,1,num[0],Q[0][tp[0]-2],i-1,max(up[i],up[Q[0][tp[0]-2]]) - up[Q[0][tp[0]-1]]);
		Q[0][tp[0]++] = i;
        for(;tp[1] && dn[Q[1][tp[1]-1]]<dn[i];tp[1]--)
			Add(1,1,num[0],Q[1][tp[1]-2],i-1,dn[Q[1][tp[1]-1]] - min(dn[i],dn[Q[1][tp[1]-2]]));
		Q[1][tp[1]++] = i;
		Add(1,1,num[0],i,i,h+w-num[i]);
	}
}

int main()
{
    scanf("%d%d%d",&w,&h,&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&x[i],&y[i]),c[i]=i;
    x[n+1] = 0 , y[n+1] = h/2 , c[n+1] = n+1;
    x[n+2] = w , y[n+2] = h/2 , c[n+2] = n+2;
    x[n+3] = w/2 , y[n+3] = 0 , c[n+3] = n+3;
    x[n+4] = w/2 , y[n+4] = h , c[n+4] = n+4;
    n+=4;
    memcpy(z,x,sizeof x);
    solve();

	swap(w,h);
	memcpy(x,z,sizeof z);
	for(int i=1;i<=n;i++) swap(x[i],y[i]);
	solve();

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



Measured memory_bytes: 33024
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N = input()
    M = [int(c) for c in N]
    lm=len(M)
    NN=int(N)
    if lm==1:
        print(NN)
    else:
        if set(M[1:])=={9}:
            print(M[0]+(lm-1)*9)
        else:

            print(M[0]-1+(lm-1)*9)



resolve()

Measured memory_bytes: 38384
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  ll n, k;
  cin >> n >> k;
  map<ll, ll> m;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    if (m.find(a) == m.end()) {
      m[a] = b;
    } else {
      m[a] += b;
    }
  }
  ll tmp = 0;
  for (auto &x : m) {
    tmp += x.second;
    if (tmp >= k) {
      cout << x.first << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 5100
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll f(ll x){
    if(x==0) return 1;
    else if(x==1) return 1;
    else return (x%MOD) * (f(x-1)%MOD) % MOD;
}

int main(){
    ll n; cin >> n;
    string s; cin >> s;
    ll cnt=0;
    ll ans=1;
    rep(i,s.size()){
        if(i==s.size()-1){
            if(cnt!=1 || s[i]=='W'){
                cout << 0 << endl;
                return 0;
            }
        }else{
            if(s[i]=='W'){
                if((cnt+1) % 2 == 1){
                    ans *= cnt;
                    ans %=MOD;
                    cnt--;
                }else{
                    cnt++;
                }
            }else{
                if((cnt+1) % 2 == 1){
                    cnt++;
                }else{
                    ans *= cnt;
                    ans %=MOD;
                    cnt--;
                }
            }
            if(cnt==-1){
                cout << 0 << endl;
                return 0;
            }
            //cout << cnt << endl;
        }
    }
    cout << (ans*f(n))%MOD << endl;
}

Measured memory_bytes: 2180
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void)
{		
	int n, m;
	cin >> n >> m;
	
	int a[100][100];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	
	int b[100];
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	
	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			sum += a[i][j] * b[j];
		}
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3132
//
//  Atcoder_1.cpp
//  
//
//  Created by Nishith on 17/05/20.
//

#include <stdio.h>
#include<string.h>
#include<iostream>

using namespace std;









int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n;
    cin>>n;
    
    int temp = n%10;
    
    if(temp ==2 || temp ==4 || temp==5 || temp==7 ||temp ==9)
    {
        cout<<"hon"<<endl;
    }
    else if(temp==0 || temp ==1 || temp==6 || temp==8 )
    {
        cout<<"pon"<<endl;
    }
    else{
        cout<<"bon"<<endl;
    }
    
    
    
}


Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int n;
    cin >> n;
    string temp = to_string(n);
    string temp_ = temp;
    reverse(temp.begin(), temp.end());
    if (temp_ == temp) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int debt = 100000;
	int i;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		debt *= 1.05;
		if (debt % 1000 != 0){
			debt = (debt / 1000 + 1) * 1000;
		}
	}
	
	printf("%d\n", debt);
	
	return (0);
}

Measured memory_bytes: 592
import math
N,M,X = map(int,input().split())
#a[i][0]:price of the i-th book
a = [[] for i in range(N)]
for i in range(N):
    a[i] = list(map(int,input().split()))

def is_greater(b):
    for i in b:
        if i < X:
            return False
    return True 
    
cost = math.inf
for i in range(2**N):
    b = [0]*(M+1)
    for j in range(N):
        if ((i >> j)&1):
            for k in range(M+1):
                b[k] += a[j][k]
    if b[0] < cost and is_greater(b[1:]):
        cost = b[0]

if cost == math.inf:
    print(-1)
else:
    print(cost)

Measured memory_bytes: 9220
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
n=int(input())
if n<105:
    print(0)
    exit()
ans=1
for i in range(106,n+1):
    if i%2==0:
        continue
    l=make_divisors(i)
    if len(l)==8:
        ans+=1
print(ans)


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

int main(){
	int n;
	cin >> n;
	vector<int> w(n);
	int all = 0;
	int t = 0;
	int min = 1000000000;
	for(int i=0; i<n; i++){
    	cin >> w.at(i);
    	all += w.at(i);
    }
	for(int i=0; i<n; i++){
    	t += w.at(i);
    	if(pow(all-2*t, 2) < min) min = pow(all-2*t, 2); 
    }
	cout << sqrt(min) << endl;
}

Measured memory_bytes: 256
var
	N,M,i,u,v,id:Longint;
	Gv,Gp:Array[1..2000]of Longint;
	Gi:Array[1..1000]of Longint;
	cnt:Array[1..1000]of Longint;
	Q:Array[1..1000]of Longint;
	Qs:Longint;
begin
	read(N,M);if (N=1000)and(M<1000) then begin writeln(-1);exit;end;
	for i:=1 to M do begin
		read(u,v);
		Gv[i]:=v;
		if Gi[u]>0 then begin
			Gp[i]:=Gi[u];
		end;
		Gi[u]:=i;
		inc(cnt[v]);
	end;
	for i:=1 to N do begin
		if cnt[i]=0 then begin
			inc(Qs);
			Q[Qs]:=i;
		end;
	end;
	id:=1;
	while id<=Qs do begin
		u:=Q[id];
		inc(id);
		i:=Gi[u];
		while i<>0 do begin
			dec(cnt[Gv[i]]);
			if cnt[Gv[i]]=0 then begin
				inc(Qs);
				Q[Qs]:=Gv[i];
			end;
			i:=Gp[i];
		end;
	end;
	if Qs<N then writeln(0)else writeln(-1);
end.

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

using namespace std;

const int MAX = 1e5 + 10;
int imos[MAX];

bool is_prime(int v) {
  if (v < 2) {
    return false;
  }
  for (int i = 2; i * i <= v; i++) {
    if (v % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  for (int i = 0; i < MAX; i++) {
    imos[i] = is_prime(i) && is_prime((i + 1) / 2);
  }
  //for (int i = 0; i < 10; i++) cout << i << " = " << imos[i] << endl;
  for (int i = 0; i < MAX - 1; i++) {
    imos[i + 1] += imos[i];
  }
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << imos[r] - imos[l - 1] << endl;
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		vector<long long int> data(n+1);
		vector<long long int> data2(n);
		cin >> data[0];
		for (int i = 1; i <= n; i++) {
			cin >> data[i];
			data2[i-1] = data[i]-data[i-1];
		}
		if (data2[0] != data2[1]) {
			if (data2[0] == data2[n-1]) {
				cout << data[2] << endl;
			} else if(data2[1] == data2[n-1]) {
				cout << data[0] << endl;
			} else {
				cout << data[1] << endl;
			}
		} else {
			if (data2[0] != data2[2]) {
				if (data2[2] == data2[3]) {
					if (data2[0] == (data[4]-data[2])) {
						cout << data[3] << endl;
					} else {
						cout << data[1] << endl;
					}
				} else {
					cout << data[3] << endl;
				}
			} else {
				for (int i = 3; i < n; i++) {
					if (data2[0] != data2[i]) {
						cout << data[i+1] << endl;
						break;
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>

using namespace std;

int main(){
  long long x, a, b;
  string s;
  cin >> x >> a >> b;
  if (a >= b) {
    s = "delicious";
  } else if (a < b && b - a <= x) {
    s = "safe";
  } else {
    s = "dangerous";
  }
  cout << s << endl;
}


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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int r;
    cin >> r;
    if(r < 1200){
        cout << "ABC" << endl;
    }else if(r < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
ll n,m,x,y,z,t1,t2,t3,d[1005];
vector <int> a[1005],b[1005];
int main(int argc,char const* argv[])
{
  cin >> n >> m;
  for(ll i=0;i<m;i++)
    {
      cin >> t1>> t2 >> t3;
      a[t1].push_back(t2);
      b[t1].push_back(-t3);
    }
  for(ll i=2;i<=n;i++) d[i]=2e15;
  for(ll i=0;i<n;i++)
    {
      for(ll j=1;j<=n;j++)
	{
	  for(ll k=0; k<a[j].size();k++)
	    {
	      x=a[j][k];
	      y=b[j][k];
	      if(d[x]>d[j]+y)
		{
		  d[x]=d[j]+y;
		  if(i==n-1 && x == n)
		    {
		      cout << "inf" << endl;
		      return 0;
		    }
		}
	    }
	}
    }
  cout << -d[n] << endl;
  return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String keyword = input.readLine();

		String str_containing_key = "";

		int count=0;



		while (true) {

			str_containing_key = input.readLine();

			if (str_containing_key.equals("END_OF_TEXT")) {

				break;

			}

			String []str_array=str_containing_key.split(" ");

			for(int array_spot=0; array_spot<str_array.length; array_spot++){


			if(str_array[array_spot].equalsIgnoreCase(keyword)){

				count++;
			}
			}

		}

		System.out.println(count);
	}
}//??§???????°?????????????????°????????????????????????????

Measured memory_bytes: 24292
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define do double
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mkp make_pair

typedef vector <int> vi;
typedef map <int,int> mii;
typedef set <int> si;
typedef pair <int,int> pii;
typedef unordered_map <int,int> um;
typedef unordered_set <int> us;
typedef multiset <int> ms;
typedef vector < pair <int,int> > vpii;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  int a[n],b[n],c[n],dp[n+1][3]={},m[n];
  loop(i,n) 
    cin>>a[i]>>b[i]>>c[i];

    dp[0][0]= a[0];
    dp[0][1]= b[0];
    dp[0][2]= c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0]= max(dp[i-1][1],dp[i-1][2])+ a[i];
        dp[i][1]= max(dp[i-1][0],dp[i-1][2])+ b[i];
        dp[i][2]= max(dp[i-1][0],dp[i-1][1])+ c[i];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
}


Measured memory_bytes: 2560
#include <iostream>
#include <cctype>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <complex>
using namespace std;

char e[1000];

typedef long long ll;
typedef complex<ll> C;

inline bool valid(C x){
    ll t = max(abs(x.real()),abs(x.imag()));
    return t <= 10000;
}

class OverFlow {};

C expr(char* &p);
C term(char* &p);
C fact(char* &p);
C num(char* &p);

inline bool ispm(char c){
    return c=='+' || c=='-';
}
inline bool ispd(char c){
    return c=='*' || c=='/';
}

C num(char* &p){
    C res = 0;
    if(isdigit(*p) || *p == 'i'){
        ;
    }else{
        throw "num begin";
    }
    if(isdigit(*p)){
        while (isdigit(*p)){
            res*=10;
            res+=*p-'0';
            if(!valid(res)) throw OverFlow();
            p++;
        }
    }else{
        res = C(0,1);
        p++;
    }

    if(*p=='\0' || *p==')' || ispm(*p) || ispd(*p)){
        ;
    }else{
        throw "num end";
    }

    if(!valid(res)) throw OverFlow();
    return res;
}

C fact(char* & p){
    C res = 0;
    if(*p=='(' || isdigit(*p) || *p == 'i'){
        ;
    }else{
        throw "fact begin";
    }

    if(*p=='('){
        p++;
        res += expr(p);
        p++;
    }else if(isdigit(*p) || *p == 'i'){
        res += num(p);
    }
    if(*p=='\0' || *p==')' || ispm(*p) || ispd(*p)){
        ;
    }else{
        cout << p-e << endl;
        throw "fact end";
    }

    if(!valid(res)) throw OverFlow();
    return res;
}

C term(char* & p){
    C res;
    if(*p=='(' || isdigit(*p) || *p == 'i'){
        res = fact(p);
    }else{
        throw "term begin";
    }
    while(1){
        if(*p=='*'){
            p++;
            res *= fact(p);
            if(!valid(res)) throw OverFlow();
        }else if(*p=='/'){
            p++;
            res /= fact(p);
            if(!valid(res)) throw OverFlow();
        }else if(*p=='\0' || *p==')' || *p=='+' || *p=='-'){
            break;
        }else{
            throw "term end";
        }
    }

    if(!valid(res)) throw OverFlow();
    return res;
}

C expr(char* & p){
    C res;
    if(*p=='(' || isdigit(*p) || *p == 'i'){
        res=term(p);
    }else{
        throw "exp begin";
    }

    while(1){
        if(*p=='+'){
            p++;
            res += term(p);
        }else if(*p=='-'){
            p++;
            res -= term(p);
        }else if(*p=='\0' || *p==')' || ispm(*p) || ispd(*p)){
            break;
        }else{
            throw "exp end";
        }
        if(!valid(res)) throw OverFlow();
    }

    return res;
}

void print(C c){
    int a=c.real(), b=c.imag();
    if(a==0 && b==0) cout << 0 << endl;
    else if(a==0) cout << b << "i" << endl;
    else if(b==0) cout << a <<endl;
    else if(b>0) cout << a << "+" << b << "i" << endl;
    else cout << a << b << "i" << endl;
}

int main(){
    while(cin>>e){
        try {
            char* p = e;
            print(expr(p));
        } catch(const OverFlow e){
            cout << "overflow" << endl;
        }
    }
}

Measured memory_bytes: 1256
#include<iostream>
#include<algorithm>
#include<string>


using namespace std;


bool contains(const std::string& str1, const std::string& str2)
{
	std::string::size_type pos = str1.find(str2);
	if (pos == std::string::npos)
	{
		return false;
	}
	return true;
}


int main()
{

	string S, s;

	cin >> S;

	if (contains(S, "AC"))s = "Yes";
	else s = "No";

	cout << s << endl;

	return 0;
}




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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	int ans1, ans2, ans3;
	ans1 = a + b - c;
	ans2 = b + c - a;
	ans3 = c + a - b;

	if (ans1 == 0 || ans2 == 0 || ans3 == 0) {
		cout << "Yes" << endl;
	}

	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

type four struct {
	a int
	b int
	c int
	d int
}

func makeArray(n int, m int, p []four) int {
	var temp,max int
	an := make([]int,n)
	for i:=0;i<n;i++{
		an[i]+=1
	}
	for ;; {
		flag := true
		for i:=n-1;i>=0;i--{
			if an[i] < m {
				an[i]++
				for j:=i+1;j<n;j++{
					an[j] = an[i]
				}
				flag = false
				break
			}
		}
		temp = calc(an,p)
		if max < temp {
			max = temp
		}
		if flag {
			break
		}
	}
	return max
}


func calc (an []int, p []four) int {
	n := len(p)
	temp := 0
	for i:=0 ; i<n ; i++ {
//fmt.Println(p[i].b,len(an))
		if an[p[i].b-1] - an[p[i].a-1] == p[i].c {
			temp += p[i].d
		}
	}
//fmt.Println(an,temp)
	return temp
}


func main(){
	var n,m,q int
	fmt.Scan(&n,&m,&q)
	p := make([]four,q)
	for i:=0 ; i<q ; i++ {
		fmt.Scan(&p[i].a,&p[i].b,&p[i].c,&p[i].d)
	}
	fmt.Println(makeArray(n,m,p))
}


Measured memory_bytes: 1840
import itertools
import math

n = int(input())
p = [tuple(map(int, input().split())) for _ in range(n)]

path = itertools.permutations([i for i in range(n)])

ans = []
for town in list(path):
    total = 0
    for i in range(n-1):
        total += math.sqrt((p[town[i]][0]-p[town[i+1]][0])**2 + (p[town[i]][1]-p[town[i+1]][1])**2)
    ans.append(total)

print(sum(ans)/math.factorial(n))

Measured memory_bytes: 46704
/* https://atcoder.jp/contests/abc125/tasks/abc125_c */

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>

using namespace std;

/* {{{ Variables */
int N;
vector<int> A;
/* }}} */

/* {{{ Functions */
int gcd(int a, int b)
{
  int x = std::max(a, b);
  int y = std::min(a, b);

  if (y == 0) {
    return x;
  }

  int z = x%y;
  while (z)
  {
    x = y;
    y = z;
    z = x%y;
  }

  return y;
}
/* }}} */

int main(int argc, char *argv[])
{
  /* {{{ Input */
  cin >> N;

  A = vector<int>(N);

  for (int& e: A)
    cin >> e;
  /* }}} */

  /* {{{ Output */
  vector<int> L = vector<int>(N+1);
  L.at(0) = 0;
  
  for (int i = 1; i < N+1; ++i) {
    L.at(i) = gcd(L.at(i-1), A.at(i-1));
  }

  vector<int> R = vector<int>(N+1);
  R.at(N) = 0;

  for (int i = N-1; i >= 0; --i) {
    R.at(i) = gcd(A.at(i), R.at(i+1));
  }

  int max_gcd = 0;

  for (int i = 0; i < N; ++i) {
    int g = gcd(L.at(i), R.at(i+1));

    max_gcd = max(max_gcd, g);
  }

  cout << max_gcd << endl;
  /* }}} */

  return 0;
}


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

using namespace std;

int longest_palindrome(string &str, int N)
{
    int r[2*N], k;

    for (int i = 0, j = 0; i < 2*N; i += k, j = max(j-k, 0)) {
	while (i-j >= 0 && i+j+1 < 2*N && str[(i-j)/2] == str[(i+j+1)/2]) ++j;
	r[i] = j;
	for (k = 1; i-k >= 0 && r[i]-k >= 0 && r[i-k] != r[i]-k; k++) {
	    r[i+k] = min(r[i-k], r[i]-k);
	}
    }
    return *max_element(r, r + 2 * N);
}

int main()
{
    string str;
    int cnt = 0;
    while (cin >> str) {
        int N = str.size();
        if (longest_palindrome(str, N) == (int)str.size()) {
            cnt++;
        } 
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3012
#include<stdio.h>
int main (){
	int a,b;
	int c,d;
	for(;;){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0)break;
			for(c=0;c<a;c++){
				for(d=0;d<b;d++){
				if(c==0||c==a-1||d==0||d==b-1){
				printf("#");
				}else{
				printf(".");
			}
		}printf("\n");
	}printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int x;
    cin>>x;
    if(x >= 30) cout<<"Yes\n";
    else cout<<"No\n";

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

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

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};


int main() {
    int N, M, K, B, C; string s; cin >>s;
    vector<string>A;
    A.emplace_back("SUN");
    A.emplace_back("MON");
    A.emplace_back("TUE");
    A.emplace_back("WED");
    A.emplace_back("THU");
    A.emplace_back("FRI");
    A.emplace_back("SAT");
    string ans;

    int num=0;
    for(int i=0; i<A.size(); i++){
        if(A[i]==s){
            num=i;
            break;
        }
    }

    cout << 7-num << endl;
    return 0;
}


Measured memory_bytes: 888
import Foundation


func readStr() -> String {
  return readLine()!
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readTwoInts() -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

let N = readInt()
var A = readInts()
let Alice = A.sorted { $0 > $1 }.enumerated().filter{ $0.0 % 2 == 0 }.map{ $0.1 }.reduce(0, +)
let Bob = A.sorted { $0 > $1 } .enumerated().filter{ $0.0 % 2 != 0 }.map{ $0.1 }.reduce(0, +)
print(Alice - Bob)



Measured memory_bytes: 13688
(defun split (x str)
  (let (
      (pos (search x str))
      (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(defun get-bingo-card ()
  (let ((string-bingo-card (loop 
      as i 
      below 3
      collect (split " " (read-line)))))
    (loop
      as line
      in string-bingo-card
      collect (mapcar #'parse-integer line))))

(defun get-bingo-lines (bingo-card)
  (list
    (nth 0 bingo-card)
    (nth 1 bingo-card)
    (nth 2 bingo-card)
    (map 'list 'first bingo-card)
    (map 'list 'second bingo-card)
    (map 'list 'third bingo-card)
    (loop
      as i
      below 3
      collect (nth i (nth i bingo-card)))
    (loop
      as i
      below 3
      collect (nth (- 2 i) (nth i bingo-card)))
  ))

(defun get-open-numbers ()
  (let (
      (n (read)))
    (loop
      as i
      below n
      collect (read))))

(defun opened-bingo-card (bingo-card numbers)
  (loop
    for line
    in bingo-card
    collect (loop
      for bingo-number
      in line
	    collect (if (position bingo-number numbers) 0 bingo-number))))

(defun exist-bingo-line (lines)
  (if
    (not (zerop 
    (count 
      3
      (loop
        as line
        in lines
        collect (count 0 line)))))
    "Yes"
    "No"))
  

(princ (exist-bingo-line (get-bingo-lines (opened-bingo-card (get-bingo-card) (get-open-numbers)))))

Measured memory_bytes: 6504
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        ((a)*((b)/gcd((a),(b))))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    cout<<fixed<<setprecision(12);

    ld a,b;
    ld h,m;
    cin>>a>>b>>h>>m;

    ld tot=h*60+m;

    ld one=tot/2;
    ld two=m*6;
    //cout<<one<<" "<<two<<"\n";
    ld ang=fabs(one-two);

    //cout<<ang<<"\n";

    ang=(ang*pi)/180;

    ld c=a*a+b*b-2*a*b*cos(ang);
    c=sqrt(c);
    cout<<c;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 4180
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll x, a, b;
    cin >> x >> a >> b;
    cout << (x - a) % b << endl;
    return 0;
}

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

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

setA = set(factorize(A))
setB = set(factorize(B)) 
ans = len(setA & setB) + 1

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
	double a,b,c,d,e,f;
	double x,y;
	while((scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f))!=EOF){
		y=(c*d-a*f)/(b*d-a*e);
		x=(c-b*y)/a;
		printf("%0.3lf %0.3lf\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 1080
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>

#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    if(N == 2) {
        cout << A[0] << endl;
        return 0;
    }

    int cnt = 0;
    int idx = 2;
    uint64_t ret = 0;
    for(int i=1; i<N-1; ++i) {
        if(i <= 2) {
            ret += A[i-1];
            continue;
        }
        ret += A[idx];
        if(++cnt == 2) {
            idx++;
            cnt = 0;
        }
    }
    ret += A[1];
    cout << ret << endl;

    return 0;
}


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

int main(){
  long long n,k;cin>>n;
  k=pow(n,0.5)+1;
  long long a=1,b=n;
  for(int i=1;i<=k;i++){
     if(n%i==0&&b>n/i){
        a=i;
        b=n/i;
     }
  }
  cout<<a-1+b-1<<endl;
}

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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


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

    int odd, even;
    odd = (n+1)/2;
    even = n-odd;
    cout << odd*even << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = 0, x, y;
		int data [][] = new int[3000][2];
		
		do {
			x = stdIn.nextInt();
			y = stdIn.nextInt();
			
			if(x == 0 && y == 0 )break;
			
			data[n][0] = x;
			data[n][1] = y;
			n++;
		}while( n < 3000 );
		
		
		for(int i = 0; i < n ; i++) {
			if(data[i][0] > data[i][1]) {
				x = data[i][1];
				y = data[i][0];
			}else {
				x = data[i][0];
				y = data[i][1];
			}
			
			System.out.println(x + " " + y);
			
		}
	}
}


Measured memory_bytes: 36660
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


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

  int lin, rin;
  int lmax=1, rmin=n;
  REP(i, m){
    cin>>lin>>rin;
    lmax=max(lmax, lin);
    rmin = min(rmin, rin);
  }

  cout<<max(0, rmin-lmax+1)<<endl;
  return 0;
}


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

int main(){
    ll N ; cin >> N;
    ll t = 0,x = 0,y = 0;
    bool ok = true;
    rep(i,N){
        ll nt,nx,ny; cin >> nt >> nx >> ny;
        
        ll di = abs(nx - x) + abs(ny - y);
        if(di > nt - t) ok = false;
        if(di % 2 != (nt - t) % 2) ok = false;
        t = nt; x = nx; y = ny;
    }
    if(!ok){
        cout << "No" << endl;
    }else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 0;
    REP(A, 1, N) {
        for(int B = 1; A * B < N; B++) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#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, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

void solve() {
	int N; cin >> N;
	string S; cin >> S;
	N++;
	S = '.' + S;
	ll ans = 0;
	FOR(i, 1, N) {
		if (S[i] != S[i - 1])ans++;
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  int s=0;
  rep(i,N) {
    cin >> A[i];
    s ^= A[i];
  }
  rep(i,N) {
    cout << (s^A[i]) << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 4064
#include<stdio.h>
int main(void){
  int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
  if(a==5&&b==5&&c==7){
  	printf("YES");
  }
  else if(a==5&&b==7&&c==5){
  	printf("YES");
  }
  else if(a==7&&b==5&&c==5){
  	printf("YES");
  }
  else{
 	printf("NO");
  }
}

Measured memory_bytes: 128
#include <stdio.h>
#define NSTART 1
#define NEND 9
int main(void) {
    int a,b;
    for(a=NSTART;a<NEND+1;a++){
        for(b=NSTART;b<NEND+1;b++){
            printf("%dx%d=%d\n",a,b,a*b);
        }
    }
	return 0;
}

Measured memory_bytes: 524
fun main() {
    val (h, m) = readLine()!!.split(" ").map { it.toInt() }
    var sList = Array<String>(h) { i -> "" }
    for (i in 0 until h) {
        sList[i] = readLine()!!
    }

    val answerList = Array<String>(h) { i -> ""}

    val dx = arrayOf(-1, 0, 1, -1, 1, -1, 0, 1)
    val dy = arrayOf(-1, -1, -1, 0, 0, 1, 1, 1)

    for (i in 0 until h) {
        var answer = ""
        for (j in 0 until m) {
            if (sList[i][j] == '#') {
                answer += "#"
                continue
            }

            var count = 0
            for (k in 0 until 8) {
                val ni = i + dy[k]
                val nj = j + dx[k]

                if (ni < 0 || ni > h - 1) {
                    continue
                }

                if (nj < 0 || nj > m - 1) {
                    continue
                }

                if (sList[ni][nj] == '#') {
                    count += 1
                }
            }
            answer += count.toString()
        }
        answerList[i] = answer
    }

    for (x in answerList) {
        println(x)
    }
}


Measured memory_bytes: 38444
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <cstdint>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second

const ll INFL = 1LL << 60;//10^18 = 2^60
ll MOD = 1000000007;
//ll MOD = 998244353;

struct mint{
  ll x;
  mint(ll x):x(x % MOD){}
  mint& operator+=(const mint a){
    (x += a.x) %= MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    (x += MOD-a.x) %= MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x *= a.x) %= MOD;
    return *this;
  }
  mint& operator%=(const mint a){
    (x %= a.x);
    return *this;
  }
  mint& operator++ (int){
    (x += 1) %= MOD;
    return *this;
  }
  mint& operator-- (int){
    (x += MOD-1) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint operator%(const mint a) const{
    mint res(*this);
    return res%=a;
  }
  mint po(ll t) const{
    if(!t) return 1;
    mint a = po(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }
  mint inverse() const{
    return po(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inverse();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
  bool operator == (const mint a){
    return this->x == a.x;
  }
  bool operator != (const mint a){
    return this->x != a.x;
  }
  void get(){
    cout << x << endl;
  }
};mint Mint = 0;


//二項演算
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
mint comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    mint res = fac[n];
    res *= finv[k] * finv[n-k];
    return res;
}

vector<vector<mint>> dp(1010, vector<mint>(1010, Mint));
char mp[1010][1010];
int main(){
  ll H, W;
  cin >> H >> W;
  rep(i, H)rep(j, W) cin >> mp[i][j];
  dp[0][0] = 1;
  rep(i, H)rep(j, W)if(mp[i][j] == '.'){
    dp[i+1][j] += dp[i][j];
    dp[i][j+1] += dp[i][j];
  }
  dp[H-1][W-1].get();
}


Measured memory_bytes: 9216
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << endl;
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int64_t, int >prime_factor(int64_t n){map< int64_t, int > ret;for(int64_t i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    int a[100]; a[0]=1; FOR(i,1,100)a[i]=a[i-1]*2%MOD;
    int ans = 0;
    int cnt[100][2]={0};
    while(n--){
        int x; cin >> x;
        REP(i,61){
            int bit = x%2;
            ans += cnt[i][bit^1]*a[i]%MOD;
            ans %= MOD;
            cnt[i][bit]++;
            x /= 2;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 
	string S, T;
	cin >> S >> T;
	int N = S.size();
	int M = T.size();

	if(N+1 != M){
		cout << "No" << endl;
	}
	else{
		rep(i,N){
			if(S[i] != T[i]){
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
}

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

#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pii pair<int,int> 

const double PI = 3.141592653589793238463;

bool myfn (const pii &a, const pii &b){
	return atan2(a.ss,a.ff) < atan2(b.ss,b.ff);
}

long double dis(pair<ll,ll> a, pair<ll,ll> b){
	long double x = abs(a.ff-b.ff), y = abs(a.ss-b.ss);
	return (x*x + y*y);
}

int main(){
	int n;
	cin >> n;
	int x[n], y[n];
	for(int i=0;i<n;i++)	cin>>x[i]>>y[i];
	vector <pii> v;
	for(int i=0;i<n;i++)	v.pb(mp(x[i],y[i]));
	sort(v.begin(), v.end(), myfn);
	vector <long double> angle;
	for(int i=0;i<n;i++)	angle.pb(atan2(v[i].ss,v[i].ff));
	vector < pair<ll,ll> > prefix(2*n);
	prefix[0] = v[0];
	for(int i=1;i<n;i++)
		prefix[i] = mp(prefix[i-1].ff+v[i].ff, prefix[i-1].ss+v[i].ss);
	for(int i=n;i<2*n;i++)	
		prefix[i] = mp(prefix[i-1].ff+v[i%n].ff, prefix[i-1].ss+v[i%n].ss);
	long double ans = 0.0;
	for(int i=0;i<n;i++){
		for(int j=i;j<i+n;j++){
			ans = max(ans, dis(prefix[j], i>0?prefix[i-1]:mp(0LL,0LL)));
		}
	}
	cout << fixed << setprecision(50) << sqrt(ans) << endl;
	return 0;
}

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

int main(){
  int x;
  cin >> x;
  for(int i=1;i<=9;i++){
    if(x%i==0){
      if(x/i>0 && x/i<10){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256