akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

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

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	LL N;
	cin >> N;
	cout << (N + 1) * N / 2 - N << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

int main(){

    int n,k;
    cin  >> n >> k;

    int t=0;

    rep(i,n){
        if(i%2==0){
            t++;
        }
    }
    if(t>=k){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int p[101],j[101],i,k,a,g=0,s=0;
	for(i=0;i<3;i++)scanf("%d",&p[i]);
	for(k=0;k<2;k++)scanf("%d",&j[k]);
	for(i=0;i<3;i++){
		for(k=i;k<3;k++){
			if(p[i]>p[k]){
				s=p[i];
				p[i]=p[k];
				p[k]=s;
			}
		}
	}
	s=0;
	for(i=0;i<2;i++){
		for(k=i;k<2;k++){
			if(j[i]>j[k]){
				s=j[i];
				j[i]=j[k];
				j[k]=s;
			}
		}
	}
	g=p[0]+j[0]-50;
	printf("%d\n",g);
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
 
#define pi 3.1415926535

int main()
{
  char a;
  cin >> a;

  if(a >= 'a' && a <= 'z'){
    cout << 'a' << endl;
  }
  else{
    cout << 'A' << endl;
  }

  return 0; 
}

Measured memory_bytes: 3628
function main(input) {
  const args = input.split('\n');
  const ary1 = args[0].split(' ').map(n => parseInt(n, 10));
  const N = ary1[0];
  const L = ary1[1];
  let ary2 = [];
  
  for (let i = 1; i <= N; i++) {
  	ary2.push(args[i]);
  }
  
  ary2 = ary2.sort((a, b) => {
  	a = a.toString().toLowerCase();
    b = b.toString().toLowerCase();
    if (a < b) {
      return -1;
    } else if (a > b) {
      return 1;
    }
    return 0;
  });
  
  console.log(ary2.join(''));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  int A , B ,C;
  cin >> A >> B >> C;
  if((A<C && C<B)||(B<C && C<A)){
  cout <<"Yes"<<endl;}  
  //if(B<C && C<A){
  //cout <<"Yes"<<endl;}
  else{
  cout <<"No"<<endl;}
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
ans = ((max(x)-min(x)))**2*n
for i in range(min(x),max(x)+1):
    t = 0
    for j in x:
       t+= (j-i)**2 
    ans = min(ans,t)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    string cardTaro, cardHana;
    int n;
    int scoreT=0;
    int scoreH=0;
    int i = 0;

    cin >> n;

    while (i < n) {
        //手札入力
        cin >> cardTaro >> cardHana;
        //得点計算
        if (cardTaro<cardHana) {
            scoreH = scoreH + 3;
        }
        else if (cardTaro >cardHana ) {
            scoreT = scoreT + 3;
        }
        else if (cardTaro == cardHana) {
            scoreT = scoreT + 1;
            scoreH = scoreH + 1;
        }

        i++;

    }
    cout << scoreT << " " << scoreH << endl;


    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

VI a[100010];

void solve() {
  LL n, k;
  cin >> n>> k;
  REP(i, n-1) {
    int b, c;
    cin >> b >> c;
    b--;c--;
    a[b].push_back(c);
    a[c].push_back(b);
  }

  queue<pair<int,pair<int, int>>> q;
  q.push(make_pair(0, make_pair(0, -1)));
  LL res = k;
  while(SZ(q) > 0) {
    pair <int, pair<int, int>> node = q.front();
    q.pop();
    int depth = node.second.first;
    int d = depth;
    if (d > 1) d = 1;
    int parent = node.second.second;
    REP(i, SZ(a[node.first])) if (a[node.first][i] != parent){
      d++;
      // OUT2(a[node.first][i], d);
      res = (res * (k-d)) % 1000000007;
      q.push(make_pair(a[node.first][i], make_pair(depth+1, node.first)));
    }
  }
  cout << res << endl;
}

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


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

int main()
{
 int n;
  cin>>n;
  set<int> s;
  while(n--)
  {
    int t;
    cin>>t;
    s.insert(t);
  }
  cout<<s.size()<<"\n";
  
  
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

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

	cin >> H >> W >> N;
	vector<pair<int, int>>box;
	for (int i = 0; i < N; i++) {
		int sx, sy, gx, gy;
		cin >> sy >> sx >> gy >> gx;
		if (sx != 0 && sx != W&&sy!=0&&sy!=H) {
			continue;
		}
		if (gx != 0 && gx != W&&gy!=0&&gy!=H) {
			continue;
		}
		if (sy == 0) {
			box.push_back({ sx,i });
		}
		else if (sx == W) {
			box.push_back({ W + sy,i });
		}
		else if (sy == H) {
			box.push_back({ 2 * W + H - sx,i });
		}
		else {
			box.push_back({ 2 * W + 2 * H - sy,i });
		}
		if (gy == 0) {
			box.push_back({ gx,i });
		}
		else if (gx == W) {
			box.push_back({ W + gy,i });
		}
		else if (gy == H) {
			box.push_back({ 2 * W + H - gx,i });
		}
		else {
			box.push_back({ 2 * W + 2 * H - gy,i });
		}
	}
	if (box.empty()) {
		cout << "YES\n";
		return 0;
	}
	sort(box.begin(), box.end());
	M = box.size();
	if (M <= 2) {
		cout << "YES\n";
		return 0;
	}
	queue<int>Q;
	for (int i = 0; i < M; i++) {
		if (box[i].second == box[(i + 1) % M].second) {
			Q.push(i);
		}
	}
	if (Q.empty()) {
		cout << "NO\n";
		return 0;
	}
	vector<int>nx(M);
	vector<int>bf(M);
	vector<bool>flag(M, true);
	for (int i = 0; i < M; i++) {
		nx[i] = (i + 1) % M;
		bf[i] = (i - 1 + M) % M;
	}
	K = M;
	int l = Q.front();
	Q.pop();
	int r = l + 1;
	r %= M;
	while (K > 2) {
		if (box[l].second == box[r].second) {
			flag[l] = false;
			flag[r] = false;
			K -= 2;
			bf[nx[r]] = bf[l];
			nx[bf[l]] = nx[r];
			l = bf[l];
			r = nx[r];
			continue;
		}
		if (box[l].second == box[bf[l]].second) {
			flag[l] = false;
			flag[bf[l]] = false;
			K -= 2;
			bf[nx[l]] = bf[bf[l]];
			nx[bf[bf[l]]] = nx[l];
			l = bf[bf[l]];
			continue;
		}
		if (box[r].second == box[nx[r]].second) {
			flag[r] = false;
			flag[nx[r]] = false;
			K -= 2;
			bf[nx[nx[r]]] = bf[r];
			nx[bf[r]] = nx[nx[nx[r]]];
			r = nx[nx[r]];
			continue;
		}
		if (Q.empty()) {
			cout << "NO\n";
			return 0;
		}
		l = Q.front();
		r = nx[l];
		Q.pop();
		while (!flag[l]) {
			if (Q.empty()) {
				cout << "NO\n";
				return 0;
			}
			l = Q.front();
			r = nx[l];
			Q.pop();
		}
	}
	cout << "YES\n";
	return 0;
}

Measured memory_bytes: 3568
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
list<int> Prime(int M) {
	list<int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= M; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}


long long int N;
long long int ans;

long long int a, b;

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> a >> b;
	if ((N == 1 && a != b) || a > b)cout << "0\n";
	else if (a == b || N < 3)cout << "1\n";
	else cout << b*(N - 2) - a*(N - 2) + 1 << endl;


	return 0;
}

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

using namespace std;

typedef long long ll;

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

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

int num[100005],use[3],s1,s2;
bool ok,vis[100005];

void dfs(int x) {
  use[num[x]]++;
  vis[x]=1;s2++;
  for(int i=head[x];i;i=e[i].next) {
  	int u=e[i].t;
  	s1++;
  	if (!vis[u]) {
  		num[u]=((num[x]+e[i].v)%3);
  		dfs(u);
	  }
	else if (num[u]!=((num[x]+e[i].v)%3)) ok=0;
  }
}

int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=1;i<=m;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	e[2*i-1]=Edge(y,1,head[x]);
  	head[x]=2*i-1;
  	e[2*i]=Edge(x,2,head[y]);
  	head[y]=2*i;
  }
  ll ans=0;
  for(int i=1;i<=n;i++)
    if (!vis[i]) {
    	memset(use,0,sizeof(use));
    	ok=1;s1=s2=0;
    	dfs(i);
    	if (!ok) ans+=(ll)s2*s2;
    	else {
    		for(int j=0;j<3;j++)
    		  if (!use[j]) ok=0;
    		if (!ok) ans+=(s1>>1);
    		else ans+=(ll)use[0]*use[2]+(ll)use[1]*use[2]+(ll)use[0]*use[1];
		}
	}
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 6528
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<29;

int dp[1<<18][51];

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b(n);
  rep(i,n) cin >> b[i];
  rep(mask,1<<n)rep(last,51) dp[mask][last]=inf;
  dp[0][0]=0;
  rep(mask,1<<n)rep(last,51)if(dp[mask][last]!=inf){
    rep(i,n){
      if(mask&(1<<i)) continue;
      bool f=abs(__builtin_popcount(mask)-i)%2;
      if(f==0&&a[i]<last||f==1&&b[i]<last) continue;
      int cnt=0;
      rep(j,i) if(!(mask&(1<<j))) cnt++;
      chmin(dp[mask|(1<<i)][f==0?a[i]:b[i]],dp[mask][last]+cnt);
    }
  }
  int ans=inf;
  rep(last,51) chmin(ans,dp[(1<<n)-1][last]);
  if (ans==inf) ans=-1;
  cout << ans << endl;
}


Measured memory_bytes: 52480
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{

    class Program
    {
        static void Main(string[] args)
        {
            var D = c2i(RL());
            D = D < 400 ? 400 : D;
            D = (1999-D)/200+1;



            Console.WriteLine(D);
            Console.ReadLine();

        }

        static IEnumerable<int> RL2IE() { return spr(RL()).Select(x => (int)c2i(x)); }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


Measured memory_bytes: 27480
#include "stdio.h"


int main()
{
	int n ,b, f, r, v, t;
	int a[4][3][10];

	for (b = 0; b < 4; b++) {
		for (f = 0; f < 3; f++) {
			for (r = 0; r < 10; r++) {
				a[b][f][r] = 0;
			}
		}
	}

	scanf("%d\n", &n);

	for(t = 0;t < n;t++){
		scanf("%d %d %d %d\n",&b,&f,&r,&v);
		a[b-1][f-1][r-1] += v;
	}
	for (b = 0; b < 4; b++) {
		for (f = 0; f < 3; f++) {
			for (r = 0; r < 10; r++) {
			printf(" %d", a[b][f][r]);
				if(r==9)printf("\n");
					if(b<3&&f==2&&r==9)
					printf("####################\n");
			}
		}
	}
    return 0;
}


Measured memory_bytes: 2072
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int main(void){
	int i,n;
	ll ti,ai,t=0,a=0,c;
	cin >> n;
	cin >> t >> a;
	for(i=1; i<n; i++){
		cin >> ti >> ai;
		c = max((t-1)/ti,(a-1)/ai);
		c++;
		t = ti*c;
		a = ai*c;
	}
	cout << (t+a) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  int K;  cin>>K;
  string s="ACL";
  string ans="";
  rep(i,0,K) ans+=s;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S; cin >> S; 
	int N = S.size(); 
	vector<int> M(67108864); 
	int A[200010] = {}; 
	bool odd[30] = {}; 
	for(int i = 1; i <= N; i++){
		int c = S.at(i-1) - 'a'; 
		if(odd[c]){
			A[i] = A[i-1] - (1 << c); 
			odd[c] = false; 
		}
		else{
			A[i] = A[i-1] + (1 << c); 
			odd[c] = true; 
		}
	}
	M[0] = 1; 
	for(int i = 1; i <= N; i++){
		int tmp = 1145141919;
		if(M[A[i]]) tmp = M[A[i]];  
		for(int j = 0; j < 26; j++){
			if(((A[i] >> j) & 1) && M[A[i] - (1 << j)]){
				tmp = min(tmp, M[A[i] - (1 << j)] + 1); 
			}
			if(!((A[i] >> j) & 1) && M[A[i] + (1 << j)]){
				tmp = min(tmp, M[A[i] + (1 << j)] + 1); 
			}
		}
		M[A[i]] = tmp;
	}
	cout << max(M[A[N]] - 1, 1) << endl; 
}

Measured memory_bytes: 263556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long A, long long B, long long C, long long X, long long Y)
{
    ll ans = INF;
    for (int i = 0; i <= max(2 * X, 2 * Y); i++)
    {
        ll a = max(X - i / 2, 0LL);
        ll b = max(Y - i / 2, 0LL);
        ans = min(ans, i * C + a * A + b * B);
    }

    cout << ans << endl;
}

int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    solve(A, B, C, X, Y);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

const int MAX = 100;
int N;
int yakusu[MAX];

void divisor(int n){
    for(int i = 2; i * i <= n; i++){
        while(n % i == 0){
            ++yakusu[i];
            n /= i;
        }
    }
    if(n != 1) yakusu[n]++;
}

int main(){
    cin >> N;
    for(int i = 1; i <= N; i++){
        divisor(i);
    }

    //REP(i,MAX){
    //    printf("%d:%d\n", i, yakusu[i]);
    //}

    int ans = 0;
    REP(i,MAX){
        if(yakusu[i] >= 74) ans++;
    }

    REP(i,MAX){
        if(yakusu[i] >= 24){
            REP(j,MAX){
                if(i == j) continue;
                if(yakusu[j] >= 2) ans++;
            }
        }
    }

    REP(i,MAX){
        if(yakusu[i] >= 14){
            REP(j,MAX){
                if(i == j) continue;
                if(yakusu[j] >= 4) ans++;
            }
        }

    }

    int tmp = 0;
    REP(i,MAX){
        if(yakusu[i] >= 4){
            REP(j,MAX){
                if(i == j) continue;
                if(yakusu[j] >= 4){
                    REP(k,MAX){
                        if(i == k || j == k) continue;
                        if(yakusu[k] >= 2) tmp++;
                    }
                }
            }
        }
    }
    ans += tmp/2;

    cout << ans << endl;
    return 0;
}


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

public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[][]	map = null;

		while((map = parseMap()) != null) {
			for (int y = 0; y < map.length; y++) {
				String	out = "";
				for (int x = 0; x < map.length; x++) {
					out += String.format("%5d", map[y][x]);
				}
				System.out.println(out);
			}
		}
	}

	private static int[][] parseMap() {
		int		len = parseCnt();
		int[][]	map = null;

		if (len > 0) {
			String	str = null;

			map = new int[len+1][len+1];
			for (int y = 0; y < len; y++) {
				if ((str = parseStdin()) != null) {
					String[]	lines = str.split(" ");
					for (int x = 0; x < len; x++) {
						map[y][x]      = Integer.parseInt(lines[x]);
						map[y][len]   += map[y][x];
						map[len][x]   += map[y][x];
						map[len][len] += map[y][x];
					}
				}
			}
		}
 
		return map;
	}

	private static int parseCnt() {
		int		cnt = 0;
		String	str = null;

		if ((str = parseStdin()) != null) {
			cnt = Integer.parseInt(str);
		}

		return cnt;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) {
            		stdin = tmp;
            	}
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 20940
using System;
using System.Linq;
using System.Windows.Markup;

class IDONTKNOWCSHARP
{

    public static void Main()
    {
        int num = int.Parse(Console.ReadLine());
        long korosita = 0;
        long[] monsters = AAA(Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries));
        long[] koroseru = AAA(Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries));

        for (int i = 0; i < num; i++)
        {
            if (monsters[i] - koroseru[i] >= 0)
            {
                korosita += koroseru[i];
                monsters[i] -= koroseru[i];
            }
            else
            {
                korosita += monsters[i];
                koroseru[i] -= monsters[i];
                monsters[i] = 0;


                if (monsters[i + 1] - koroseru[i] >= 0)
                {
                    korosita +=  koroseru[i];
                  //  korosita += monsters[i + 1] - koroseru[i];
                    monsters[i + 1] -= koroseru[i];
                }
                else
                {
                    korosita += monsters[i + 1];
                    koroseru[i] -= monsters[i + 1];
                    monsters[i + 1] = 0;


                }
            }


        }

        Console.WriteLine(korosita);
  //      Console.ReadLine();

    }

    static long[] AAA(string[] a)
    {
        long[] temp = new long[a.Length];

        for (int i = 0; i < a.Length; i++)
        {
            temp[i] = long.Parse(a[i]);
        }

        return temp;
    }
}

Measured memory_bytes: 48852
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;


int main() {
	int n;
	int a;
	while (cin >> n&&n != 0) {
		int sum = 0;
		for (int i = 0; i < n / 4; i++) {
			cin >> a;
			sum += a;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3012
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	diff := b - a
	bHeight := func(d int) int {
		b := 0
		for i := 0; i < d; i++ {
			b += i + 1
		}
		return b
	}(diff)

	fmt.Println(bHeight - b)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
 
    int N;
    cin >> N;

    int ans;

    if (N%2==0){
        ans = N/2;
    }
    else
    {
        ans = N/2+1;
    }

    cout << ans << endl;

    return 0;
}


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

int n;
vector<int> a, b, c;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	a.resize(n);
	b.resize(n);
	for(auto &i:a) cin >> i;
	for(auto &i:b) cin >> i;
	for(int i=0; i<n; ++i) c.push_back(a[i] - b[i]);
	sort(c.begin(), c.end());
	int ans = 0;
	long long sum = 0;
	for(int i=0; i<n; ++i){
		if(c[i] >= 0) break;
		sum -= c[i];
		++ans;
	}
	for(int i=n-1; i>=0; --i){
		if(c[i] <= 0 || sum <= 0) break;
		sum -= c[i];
		++ans;
	}
	if(sum > 0) cout << -1 << "\n";
	else cout << ans << "\n";
}

Measured memory_bytes: 1660
#include<stdio.h>
int main()
{
    int a,b,s=0,i;
    scanf("%d%d",&a,&b);
    for(i=a;i<=b;i++)
    {
        if((i%10==i/10000)&&((i/10)%10==(i/1000)%10))s++;
    }
    printf("%d",s);
}


Measured memory_bytes: 128
#include <stdio.h>

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



Measured memory_bytes: 2044
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main{
    public static void main(String args[]){
	try{
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String str;
	    int d;
	    int sum = 0;
	    while(null != (str = br.readLine())){
		d = Integer.parseInt(str);
		for (int i = 1; i*d<600; i++) {
		    sum += i*d*d*i*d;
		}
		System.out.println(sum);
		sum = 0;
	    }
	}
	catch(Exception e){
	    System.exit(0);
	}
    }
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll,ll> memo;
    rep(i,N){
        ll tmp;
        cin >> tmp;
        A[i] = tmp;
        memo[tmp]=(memo[tmp]+1)%2;
    }
    ll ans = 0;
    for(auto itr = memo.begin();itr!=memo.end();itr++){
        ans += itr->second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
N = int(input())

explore = 1
for h in range(1,3500) :
    if not explore : break
    for n in range(1,3500) :
        if (4*h*n - N*n - N*h) == 0 :
            continue
        elif (N*h*n % (4*h*n - N*n - N*h) == 0) and (N*h*n//(4*h*n - N*n - N*h) > 0) :
            w = N*h*n//((4*h*n - N*n - N*h))
            ans = [h,n,w]
            explore = 0
            break

print(*ans)


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

int main(){
    int A[210000];
    int N;
    cin >> N;
    rep(i, N){
        cin >> A[i];
    }

    sort(A,A+N)
    rep(i, N-1){
        if(A[i]==A[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 1024
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))
pc="pairwise coprime"
sc="setwise coprime"
nc="not coprime"
a.sort()
tmp=a[0]

for i in range(n):
    tmp=math.gcd(tmp,a[i])
if tmp!=1:
    print(nc)
    exit()

dic=defaultdict(int)
for i in range(n):dic[a[i]]+=1

ans=0
for i in range(a[-1]):
    now=i+1
    cnt=0
    # print(i)
    while now<=a[-1]:
        cnt+=dic[now]
        now+=i+1
    if cnt>1:
        ans=i+1

if ans!=1:
    print(sc)
else:
    print(pc)
# print(ans)

Measured memory_bytes: 250344
#include<cstdio>
#include<iostream>

#define INF 2100000000

using namespace std;

int minix(int a,int b,int c){
	if(b>=a && c>=a){
		return a;
	}
	if(a>=b && c>=b){
		return b;
	}
	if(b>=c && a>=c){
		return c;
	}
}

int main(){
	int n,maxi,i,j;
	int masu[1002][1002];
	int ura[1002][1002];
	char str[1002];
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=1;i<=n;i++){
			scanf("%s",str);
			for(j=1;j<=n;j++){
				if(str[j-1]=='.'){
					ura[i][j]=0;
				}else{
					ura[i][j]=1;
				}
			}
		}
		for(i=0;i<=n;i++){
			masu[i][0]=masu[0][i]=0;
		}
		maxi=0;
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				if(ura[i][j]==0){
					masu[i][j]=minix(masu[i-1][j],masu[i][j-1],masu[i-1][j-1])+1;
					maxi=max(masu[i][j],maxi);
				}else{
					masu[i][j]=0;
				}
			}
		}
		
		printf("%d\n",maxi);
	}
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void){
    int num,i,o,sign,temp,line[100];
    for(;sign=0,scanf("%d",&num),num;){
        for(i=0;i<num;i++)
            scanf("%d",&line[i]);
        for(i=num-1;i>=0;i--)
            for(o=0;o<i;o++)
                if(line[o]>line[o+1]){
                    sign++;
                    temp=line[o];
                    line[o]=line[o+1];
                    line[o+1]=temp;
                }
        printf("%d\n",sign);
    }
    return 0;
}

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

int main(){
	long long N,K;
	cin >> N >> K;
	long long loop,loop2;
	long long Ans=1,sumN=N*(N+1)/2,minN=sumN-N;
	for(loop=1;loop<N-K+2;loop++){
		Ans += sumN-minN+1;
		sumN -= loop;
		minN -= N-loop;
		Ans = Ans % 1000000007;
	}
	cout << Ans << endl;
	return 0;
}


Measured memory_bytes: 3640
import Control.Monad
import Control.Applicative
 
main = do
  _ <- getLine
  nums <- map (read :: String -> Int) . words <$> getLine
  forLike (length nums) nums $ \n ns -> do
    let sorted = instSort n ns
    putStrLn . unwords . map show $ sorted
    return sorted

forLike :: Int -> b -> (Int -> b -> IO b) -> IO ()
forLike 0 _ _ = return ()
forLike n e f = do
   res <- f n e
   forLike (n - 1) res f

instSort :: Ord a => Int -> [a] -> [a]
instSort n xs
  |n > len  = []
  |otherwise = (insert (>=) sorted y) ++ ys
  where len = length xs
        (sorted, (y:ys)) = splitAt (len - n) xs
 
insert :: (a -> a -> Bool) -> [a] -> a -> [a]
insert _ [] y = [y]
insert f (x:xs) y
  | f x y     = y : x : xs
  | otherwise = x : insert f xs y

Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#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 n, k; cin >> n >> k;

    typedef function<bool(pair<ll, ll>, pair<ll, ll>)> comparator;
    comparator compfactor = [](pair<ll, ll> elem1, pair<ll, ll> elem2) {
        return elem1.second < elem2.second;
    };
    map<ll, ll> a;
    rep(i, n) {
        ll m; cin >> m;
        a[m]++;
    }

    // for (auto elem : a) {
    //     cout << elem.first << " " << elem.second << endl;
    // }

    if (a.size() <= k) {
        cout << 0 << endl;
        return 0;
    }
    vector<ll> v;
    for (auto elem : a) {
        v.push_back(elem.second);
    }
    sort(all(v));
    cout << accumulate(v.begin(), v.begin() + a.size() - k, 0) << endl;
    return 0;
}

Measured memory_bytes: 14964
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
vector<vi> adj(512345);
vi vec;
int main(){
    std::ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int i,u,v,j,cur;
    rep(i,m){
    	cin>>u>>v;
    	adj[u].pb(v);
    	adj[v].pb(u);
    }
    rep(i,adj[1].size()){
    	vec.pb(adj[1][i]);
    	//cout<<adj[1][i]<<" ";
    	//cout
    }
    rep(i,vec.size()){
    	cur=vec[i];
    	rep(j,adj[cur].size()){

    		if(adj[cur][j]==n){
    			cout<<"POSSIBLE"<<endl;
    			return 0;
    		}
    	}
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;      

}



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

typedef long long int ll;



int main()
{
    ll n, k;
    cin >> n >> k;
    vector<double> p(n), l(n + 1);
    for(ll i = 0;i < n;i++){
        cin >> p[i];
        p[i] = (p[i] + 1) / 2;
    }

    l[1] = p[0];
    for(ll i = 2;i <= n;i++){
        l[i] = p[i - 1] + l[i - 1];
    }

    double ans = 0;
    for(ll i = k;i < n + 1;i++){
        ans = max(ans, l[i] - l[i - k]);
    }

    cout << setprecision(10) <<  ans;

    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
const int maxn = 5000 + 5;
ll dp[maxn] , p[maxn] , c[maxn] , k , n , pre[maxn] , ans;
int start;
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> k;
    ans = -2e18;
    for (int i = 1 ; i <= n ; i++) cin >> p[i];
    for (int i = 1 ; i <= n ; i++) cin >> c[i];
    for (int i = 1 ; i <= n ; i++){
        ll res = -2e18;
      //  memset(dp , 0 , sizeof dp);
      //  memset(pre , 0 , sizeof pre);
        ll now = i;
        ll cir = 1;
        ll j = 1;
        ll start = i;
        while (p[now] != start){
            now = p[now];
            dp[j] = dp[j - 1] + c[now];
            cir++;
            j++;
        }
        dp[j] = dp[j - 1] + c[start];

     //   cout << cir << endl;
        pre[0] = -2e18;

      /*  cout << "第" << i << "位跑出来的dp至" << endl;
        for (int j = 1 ; j <= n ; j++)
            cout << dp[j] << " ";
        cout << endl;*/
        for (int j = 1 ; j <= min ( cir , k ); j++) {
            pre[j] = max (pre[j - 1] , dp[j]);
        }
        res = pre[min(cir , k)];
        if (k > cir && dp[cir] > 0){
            //决策1:直接跑完
            ll cnt = k / cir;
            res = max (res , cnt * dp[cir] + max(pre[k - cir * cnt] , 0ll));
            //决策2:少跑一段
            if (cnt > 1){
                res = max (res , (cnt - 1) * dp[cir] + pre[cir]);
            }
        }
        ans = max (ans , res);
      //  cout << res << endl;
    }
    cout << ans << endl;
    return 0;
}

/*
988782657 + 695279662 + 389386780 + 980092719 - -151885171 + 37619092
6 * 9 = 54
 + 988782657 + 695279662 + 389386780 + 980092719
*/


Measured memory_bytes: 3792
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: Snuke Festival
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int M = 3;

/* typedef */

typedef long long ll;

/* global variables */

int as[M][MAX_N];
ll dp[M][MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < M; i++) {
    for (int j = 0; j < n; j++) scanf("%d", &as[i][j]);
    sort(as[i], as[i] + n);
  }

  for (int j = 0; j < n; j++) dp[0][j] = j + 1;

  for (int i = 1; i < M; i++) {
    for (int j = 0; j < n; j++) {
      int k = lower_bound(as[i - 1], as[i - 1] + n, as[i][j]) - as[i - 1];
      dp[i][j] = (k > 0) ? dp[i - 1][k - 1] : 0;
    }
    for (int j = 1; j < n; j++) dp[i][j] += dp[i][j - 1];
  }

  printf("%lld\n", dp[M - 1][n - 1]);
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> C(N);
	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < N; ++ i) {
		cin >> C[i];
		for (auto& x : A[i]) cin >> x;
	}
	const int INF = 1<<30;
	int res = INF;
	for (int p = 1; p < (1<<N); ++ p) {
		int c = 0;
		vector<int> a(M);
		for (int i = 0; i < N; ++ i) if ((p>>i)&1) {
			c += C[i];
			for (int j = 0; j < M; ++ j) a[j] += A[i][j];
		}
		for (int i = 0; i < M; ++ i) if (a[i] < X) goto next;
		res = min(res, c);
		next:;
	}
	if (res == INF) res = -1;
	cout << res << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;


int main(){

    string s;
    cin >> s;

    if(s == "Sunny"){
        s = "Cloudy";
    }else if(s == "Cloudy"){
        s = "Rainy";
    }else{
        s = "Sunny";
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	
	map<char, int> sm, tm;
	int length = s.size();
	for (int i = 0; i < length; ++i) {
		sm[s[i]] += 1;
		tm[t[i]] += 1;
	}
	
	vector<int> sv(length), tv(length);
	auto it = sm.begin();
	for (int i = 0; i < length && it != sm.end(); ++i, ++it)
		sv[i] = it->second;
	
	it = tm.begin();
	for (int i = 0; i < length && it != tm.end(); ++i, ++it)
		tv[i] = it->second;
	
	sort(sv.begin(), sv.end());
	sort(tv.begin(), tv.end());
	
	if (sv == tv)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 2312
from fractions import gcd


def lcm(x, y):
    return x // gcd(x, y) * y


N, M = map(int, input().split())
S = input()
T = input()

L = lcm(N, M)
X = {}

for i in range(N):
    X[(L // N) * i] = S[i]

for i in range(M):
    if (L // M) * i in X and X[(L // M) * i] != T[i]:
        print(-1)
        exit()
print(L)


Measured memory_bytes: 17464
#include <iostream>
#include <algorithm>
using namespace std;
int dir[] = { 0, 1, 0, -1 };
int n, a[9][9], cnt, px[75], py[75]; bool vis[9][9];
bool solve(int sx, int sy, int cur, int vcnt, int sum) {
	if (cur == cnt) return vcnt == n * n + 1;
	if (sum == -a[px[cur]][py[cur]]) {
		vis[px[cur + 1]][py[cur + 1]] = true;
		bool res = solve(px[cur + 1], py[cur + 1], cur + 1, vcnt + 1, 0);
		vis[px[cur + 1]][py[cur + 1]] = false;
		return res;
	}
	for (int i = 0; i < 4; i++) {
		int tx = sx + dir[i], ty = sy + dir[i ^ 1];
		if (0 <= tx && tx < n && 0 <= ty && ty < n && !vis[tx][ty] && a[tx][ty] > 0 && sum + a[tx][ty] <= -a[px[cur]][py[cur]]) {
			vis[tx][ty] = true;
			bool res = solve(tx, ty, cur, vcnt + 1, sum + a[tx][ty]);
			vis[tx][ty] = false;
			if (res) return true;
		}
	}
	return false;
}
int main() {
	while (cin >> n, n) {
		cnt = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cin >> a[i][j];
				if (a[i][j] < 0) {
					px[cnt] = i;
					py[cnt] = j;
					cnt++;
				}
			}
		}
		vis[px[0]][py[0]] = true;
		bool ret = solve(px[0], py[0], 0, 1, 0);
		vis[px[0]][py[0]] = false;
		cout << (ret ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 2940
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define For(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    string s; cin >> s;
    cout << s.substr(0, 3) << endl;

return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> s(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    cin >> s[i];
  }
  int white_cnt = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '.') white_cnt++;
    }
  }
  debug(white_cnt);
  vector<vector<int>> g(H * W);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '#') continue;
      if (i != 0) {  // ue
        if (s[i - 1][j] == '.') g[i * W + j].push_back((i - 1) * W + j);
      }
      if (j != 0) {  // hidari
        if (s[i][j - 1] == '.') g[i * W + j].push_back(i * W + j - 1);
      }
      if (i != H - 1) {  // sita
        if (s[i + 1][j] == '.') g[i * W + j].push_back((i + 1) * W + j);
      }
      if (j != W - 1) {  // migi
        if (s[i][j + 1] == '.') g[i * W + j].push_back(i * W + j + 1);
      }
    }
  }
  debug(g);
  vector<int> visit_status(H * W), distance(H * W, -1);

  auto bfs = [&](int start_node) {
    distance[start_node] = 0;
    visit_status[start_node] = 1;
    queue<int> q;
    q.push(start_node);
    while (!q.empty()) {
      int node_id = q.front();
      q.pop();
      for (auto next_node_id : g[node_id]) {
        if (visit_status[next_node_id] != 0) continue;
        q.push(next_node_id);
        visit_status[next_node_id] = 1;
        distance[next_node_id] = distance[node_id] + 1;
      }
    }
  };

  bfs(0);
  debug(distance);
  if (distance.back() == -1) {
    cout << -1 << endl;
    return 0;
  }
  cout << white_cnt - distance.back() - 1 << endl;
  return 0;
}

Measured memory_bytes: 3728
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();sc.nextLine();
		while(t--!=0)
		System.out.println(sc.nextLine().replaceAll("Hoshino", "Hoshina"));
	}
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



int main() {
	
	int n;
	cin >> n;
	vector<pair<int, int>> v;
	REP(I, n) {
		int a;
		cin >> a;
		v.push_back({ a,I + 1 });
	}
	sort(ALL(v));

	REP(i, n) {
		cout << v[i].second << ' ';
	}
	
}




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A, B, C, D; cin >> A >> B >> C >> D;
    cout << max(A*B, C*D) << endl;
}


Measured memory_bytes: 256