akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,m,x;
int c[22];
int a[22][22];
int ptr;
string s[4444];
int q[22];
void dfs(string cnt){
	if(cnt.size()==n){
		s[ptr++]=cnt;
		return ;
	}
	dfs(cnt+'1');
	dfs(cnt+'0');
}
int main()
{
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	}
	dfs("0");
	dfs("1");
	int ans=1e9;
	for(int i=0;i<ptr;i++){
		int cur=0;
		for(int j=0;j<m;j++)
			q[j]=0;
		for(int j=0;j<s[i].size();j++)
			if(s[i][j]=='1'){
				cur+=c[j];
				for(int k=0;k<m;k++)
					q[k]+=a[j][k];
			}
		bool flag=true;
		for(int j=0;j<m;j++)
			if(q[j]<x)
				flag=false;
		if(flag==true)
			ans=min(ans,cur);
	}
	if(ans==1e9)
		cout<<-1<<endl;
	else
		cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll s[3][3];
bool ok[3][3];
int main() {
	
	REP(i, 3)REP(j, 3)cin >> s[i][j];
	ll n;
	cin >> n;
	REP(i, n) {
		ll a;
		cin >> a;
		REP(j, 3) {
			REP(k, 3) {
				if (s[j][k] == a)ok[j][k] = true;
			}
		}
	}
	bool ans = false;
	REP(i, 3) {
		bool now = true;
		REP(j, 3) {
			if (!ok[i][j])now = false;
		}
		if (now)ans = true;
	}
	REP(i, 3) {
		bool now = true;
		REP(j, 3) {
			if (!ok[j][i])now = false;
		}
		if (now)ans = true;
	}
	if (ok[0][0] and ok[1][1] and ok[2][2])ans = true;
	if (ok[0][2] and ok[1][1] and ok[2][0])ans = true;
	cout << (ans ? "Yes" : "No") << endl;
}



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

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int f = sc.nextInt();
		int s = sc.nextInt();
		boolean[][] white = new boolean[f][s];
		for (int i = 0; i < f; i++) {
			 char[] tmp = sc.next().toCharArray();
			for (int j = 0; j < s; j++) {
				white[i][j] = tmp[j] == '.';
			}
		}
		int[][] best = new int[f][s];
		boolean[][] vis = new boolean[f][s];
		for (int i = 0; i < f; i++) {
			for (int j = 0; j < s; j++) {
				if (white[i][j]) {
					best[i][j] = i == 0 && j == 0 ? 0 : Integer.MAX_VALUE;
					if (i > 0) {
						best[i][j] = Math.min(best[i][j], best[i-1][j]);
					}
					if (j > 0) {
						best[i][j] = Math.min(best[i][j], best[i][j-1]);
					}
				} else {
					if ((i == 0 || white[i-1][j]) && (j == 0 || white[i][j-1])) {
						best[i][j] = i == 0 && j == 0 ? 1 : Integer.MAX_VALUE;
						if (i > 0) {
							best[i][j] = Math.min(best[i][j], best[i-1][j] + 1);
						}
						if (j > 0) {
							best[i][j] = Math.min(best[i][j], best[i][j-1] + 1);
						}
					} else {
						for (int k = 0; k <= i; k++) {
							for (int l = 0; l <= j; l++) {
								vis[k][l] = false;
							}
						}
						best[i][j] = Integer.MAX_VALUE;
						vis[i][j] = true;
						for (int k = i; k >= 0; k--) {
							for (int l = j; l >= 0; l--) {
								if (!white[k][l]) {
									if (k < i && !white[k+1][l] && vis[k+1][l]) {
										vis[k][l] = true;
									}
									if (l < j && !white[k][l] && vis[k][l+1]) {
										vis[k][l] = true;
									}
									if (vis[k][l]) {
										best[i][j] = Math.min(best[i][j], best[k][l]);
									}
								}
							}
						}
					}
				}
				//System.err.println(i + " " + j + " => " + best[i][j]);
			}
		}
		out.println(best[f-1][s-1]);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename W>
struct N008 {
   typedef std::vector<long> LI;
   typedef std::vector<W>    LW;
   long n, e;
   const LI &ss, &ds;
   const LW &ws;
   std::vector<LI> fi;
   std::vector<LI> ri;
   N008(long n_, const LI& ss_, const LI& ds_, const LW& ws_)
      : n(n_), e(ss_.size()), ss(ss_), ds(ds_), ws(ws_) {
      ri.resize(n+1);
      fi.resize(n+1);
      for(long i = 0; i < e; ++i) {
         fi[ss[i]].push_back(i);
         ri[ds[i]].push_back(i);
      }
   }
};

template<typename W>
struct N009 {
   typedef std::vector<long> LI;
   typedef std::vector<W>    LW;
   const N008<W>& g;
   LW xs;
   std::vector<bool> visited;
   W res;
   N009(const N008<W>& g_, long s, long t, W inf)
      : g(g_), xs(g.e, 0), visited(g.n+1) {
      res = 0;
      for(;;) {
         initDFS();
         W a = dfs(s, t, inf);
         res += a;
         if( a == 0 ) break;
      }
   }
   void initDFS() {
      for(long i = 0; i < (long)visited.size(); ++i) visited[i] = false;
   }
   W dfs(long s, long t, W f) {
      if( s == t ) return f;
      if( visited[s] ) return 0;
      visited[s] = true;
      for(bool b : {true, false}) {
         for(long i : b ? g.fi[s] : g.ri[s]) {
            long to = b ? g.ds[i] : g.ss[i];
            W rem = b ? g.ws[i] - xs[i] : xs[i];
            if( rem == 0 ) continue;
            W a = dfs(to, t, std::min(f, rem));
            if( a == 0 ) continue;
            xs[i] += b ? a : -a;
            return a;
         }
      }
      return 0;
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long v, e;
      scan(v, e);
      std::vector<long> ss(e), ds(e), ws(e);
      for(long i = 0; i < e; ++i) {
         scan(ss[i], ds[i], ws[i]);
      }
      N008<long> g(v, ss, ds, ws);
      N009<long> ford(g, 0, v - 1, (1LL << 50));
      printf("%ld\n", ford.res);
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}

Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

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

  if (x >= a && x <= a + b)
  cout << "YES" << endl;
  else
  cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,ans1,ans2;
char ch;
int a[300];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			for(ch=getchar();!isalpha(ch);ch=getchar());
			a[ch]++;
			if(a[ch]==4) a[ch]=0;
		}
	for(char ch='a';ch<='z';ch++)
	{
		if(a[ch]==1) ++ans1;
		else
		if(a[ch]==2) ++ans2;
		else
		if(a[ch]==3)
			++ans1,++ans2;
	}
	if((n&1)&&(m&1))
	{
		puts(ans2<=n/2+m/2 && ans1<=1?"Yes":"No");
	}
	else
	if((n&1))
		puts(ans1==0 && ans2<=m/2?"Yes":"No");
	else
	if((m&1))
		puts(ans1==0 && ans2<=n/2?"Yes":"No");
	else
		puts(ans1==0 && ans2==0?"Yes":"No");
	return 0;
} 

Measured memory_bytes: 256
// Believe in yourself...
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) (c).size()
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)

#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf=4e18;
const ll maxn=2e5+10;
const ll mod=1e9+7;

#pragma GCC Optimize("Ofast")

void ans(ll num){
	cout<<num;
	exit(0);
}
int main(){
	ll n,m;cin>>n>>m;
	if(n==1&&m==1)
		ans(1);
	if(n==1)
		ans(m-2);
	if(m==1)
		ans(n-2);
	ans((n*m)-(2*n)-(2*m)+4);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(), cout.tie(0);
    while(cin >> s) {
        if(s[0] != 'A') s.insert(0, "A");
        for(int i = 0; s[i]; ++i) {
            if(s[i] == 'A' || s[i] == 'K' || s[i] == 'I')
                continue;
            if(s[i] != 'A' && s[i + 1] != 'A') s.insert(i + 1, "A");
        }
        int l = s.length();
        if(s[l - 1] != 'A') s += "A";
        cout <<(s == "AKIHABARA" ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<vector<int> > G;
int d[111],f[111],u[111];
void dfs(int v,int& p){
  if(u[v]) return;
  u[v]=1;
  sort(G[v].begin(),G[v].end());
  d[v]=++p;
  for(int u:G[v]) dfs(u,p);
  f[v]=++p;
}
signed main(){
  int n;
  cin>>n;
  G.resize(n,vector<int>());
  for(int i=0;i<n;i++){
    int u,k;
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      int c;
      cin>>c;
      c--;
      G[u].push_back(c);
    }
  }
  int p=0;
  for(int i=0;i<n;i++)
    if(!u[i]) dfs(i,p);
  for(int i=0;i<n;i++) cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;;
  return 0;
}

Measured memory_bytes: 3144
import itertools
n = int(input())
a = list(map(int,input().split()))
mod = 1000000007

total = 0
for i in range(len(a)-1):
    if(i == 0):
        before_sum = sum(a) - a[i]
    else:
        before_sum -= a[i]
    total += a[i] * (before_sum) 


print(total%mod)



Measured memory_bytes: 31260
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, M;
  std::cin >> N >> M;
  vvl cake = vv(N, 4, 0, ll);
  range(i, N) std::cin >> cake[i][1] >> cake[i][2] >> cake[i][3];
  ll ab[2] = {-1, 1};
  ll ans = 0, reg;
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        reg = 0;
        range(l, N){
          cake[l][0] = cake[l][1]*ab[i];
          cake[l][0] += cake[l][2]*ab[j];
          cake[l][0] += cake[l][3]*ab[k];
        }
        sort(cake.begin(), cake.end());
        reverse(cake.begin(), cake.end());
        range(m, M) {
          reg+=cake[m][0];
        }
        ans = max(reg, ans);
      }
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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


using ll = long long int;
using namespace std;


int mod = 998244353;


int main()
{
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	
	int n, i, j, x, d;
	cin >> n;
	vector<pair<int, int>> a(n);
	for(i = 0; i < n; ++i)
	{
		cin >> x >> d;
		a[i] = {x, d};
	}
	
	sort(a.begin(), a.end());
	
	// vector<int> pash(n);
	// vector<int> u(n);
	// for(i = n - 1; i >= 0; i--)
	// {
		// x = a[i].first;
		// d = a[i].second;
		// int l = i;
		// int r = n;
		// while(r > l + 1)
		// {
			// int m = (l + r) / 2;
			// if (a[m].first < x + d)
			// {
				// l = m;
			// }
			// else
			// {
				// r = m;
			// }
		// }
		// pash[i] = l;
		// int res = i;
		// j = i + 1;
		// while(j <= l)
		// {
			// res = max(res, pash[j]);
			// ++j;
		// }
		// u[i] =  res;
	// }
	
	vector<int> from(n, n);
	for(i = n - 2; i >= 0; --i)
	{
		int l, r, m, dist;
		l = i + 1;
		r = n;
		dist  = a[i].first + a[i].second;
		while(l < r)
		{
			m = (l + r) / 2;
			if (dist > a[m].first)
			{
				l = m + 1;
			}
			else
			{
				r = m;
			}
		}
		
		// while(l < r)
		// {
			// if (a[l].first >= dist)
			// {
				// break;
			// }
			// ++l;
		// }
		
		from[i] = l;
	}
	
	int B = 1;
	while(B < n)
	{
		B <<= 1;
	}
	
	vector<int> tree(2 * B, n);
	
	for(i = 0; i < n; ++i)
	{
		tree[B + i] = from[i];
	}
	for(i = B - 1; i > 0; --i)
	{
		tree[i] = max(tree[2*i], tree[2*i+1]);
	}
	
	auto get_max = [&](int l, int r){
		l+=B;
		r+=B;
		int res = -mod;
		while(l <= r)
		{
			if (l & 1)
			{
				res = max(res, tree[l]);
			}
			if ((r & 1) == 0)
			{
				res = max(res, tree[r]);
			}
			l = (l + 1) / 2;
			r = (r - 1) / 2;
		}
		return res;
	};
	
	auto set_v = [&](int l, int v){
		l+=B;
		tree[l] = v, l/=2;
		while(l > 0)
		{
			tree[l] = max(tree[l*2], tree[l*2 + 1]);
			l /= 2;
		}
	};
	
	// auto gt_max  = [&](int l, int r)
	// {
		// l+=B;
		// r+=B;
		// int res = from[l];
		// while(l <= r)
		// {
			// res = max(res, from[l]);
			// ++l;
		// }
		// return res;
	// };
	
	// for(i =0; i < 2*B; ++i)
	// {
		// cout << tree[i] << " ";
	// }
	// cout << endl;
	
	// for(i =0; i < n; ++i)
	// {
		// cout << "("<< a[i].first << " " << a[i].second << "),[" << i << "]   ";
	// }
	// cout << endl;
	// for(i =0; i < n; ++i)
	// {
		// cout << from[i] << " ";
	// }
	// cout << endl;
	// for(i =0; i < n; ++i)
	// {
		// cout << pash[i] << " ";
	// }
	// cout << endl;
	// for(i =n - 1; i >= 0; --i)
	// {
		// cout << u[i] << " ";
	// }
	// cout << endl;
	// cout << endl;
	// cout << endl;
	// cout << get_max(1, 1);
	// cout << endl;
	// cout << get_max(2, 2);
	// cout << endl;
	// cout << get_max(0, 2);
	
	vector<int> dp(n+1);
	dp[n] = 1;
	for(i = n - 1; i >= 0; --i)
	{
		int l = from[i];
		int r = get_max(i, l - 1);
		
		// int r = gt_max(i, l - 1);
		set_v(i, r);
		// from[i] = r;
		// cout << r << " ";
		//r = max(i+1, r);
		dp[i] = dp[i + 1];
		dp[i] += dp[r];
		dp[i] %= mod;
	}
	cout << dp[0];
	

	
	return 0;
}

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

using namespace std;

typedef long long ll;

// 最近点対問題を解く(O(nlogn))
/*
点を x 座標, y 座標によって左半分と右半分に分けるとする。
最近点対の距離は、1), 2) の最小値
1) 2点 p, q が共に左半分または右半分に含まれるような組(p, q)の距離

2) 2点 p, q が異なる領域に含まれるような組(p, q)の距離
点を左半分と右半分に分ける直線を l として、その直線の x 座標を l として、
x_0 - d < x < x_0 + d を満たす(x_p, y_p) に対して y_p - d < y <= y_p を満たす点との
距離を考えればよい
*/

// first を x 座標, second を y 座標とする
typedef pair<double, double> PD;

const double INF = 1000000000;
const int MAX_N = 100010;

pair<double, double> A[MAX_N];

// y 座標の昇順で merge するための比較関数
bool compare_y(PD a, PD b){
    return a.second < b.second;
}

// a は x 座標の昇順
double closest_pair(PD *a, int n){
    if(n <= 1) return INF;
    int m = n / 2;
    double x = a[m].first;
    // 1) にあたる
    double d = min(closest_pair(a, m), closest_pair(a + m, n - m));
    inplace_merge(a, a + m, a + n, compare_y); // sorted な 2 つの範囲を merge
    // ここで a は　y 座標の昇順

    // 2) にあたる
    vector<PD> b; // 直線から距離 d 未満の頂点
    for(int i=0;i<n;i++){
        if(fabs(a[i].first - x) >= d) continue;

        // b に入っている頂点を、末尾から y 座標の差が d 以上になるまで見ていく
        for(int j=0;j<b.size();j++){
            double dx = a[i].first - b[b.size() - j - 1].first;
            double dy = a[i].second - b[b.size() - j - 1].second;
            if(dy >= d) break;
            d = min(d, sqrt(dx * dx + dy * dy));
        }
        b.push_back(a[i]);
    }
    return d;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int N; cin >> N;
    for(int i=0;i<N;i++){
        double x, y; cin >> x >> y;
        A[i] = make_pair(x, y);
    }
    sort(A, A + N);
    cout << fixed << setprecision(15) << closest_pair(A, N) << endl;
}


Measured memory_bytes: 7980
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    string S;
    cin >> S;
    int N = S.size();
    vector<int> ans(N);

    int cnt = 0;
    for(int i=0; i<N; i++) {
        if(S[i] == 'R') {
            ++cnt;
        } else {
            ans[i] += cnt/2;
            ans[i-1] += cnt - cnt/2;
            cnt = 0;
        }
    }
    cnt = 0;
    for(int i=N-1; i>=0; i--) {
        if(S[i] == 'L') {
            ++cnt;
        } else {
            ans[i] += cnt/2;
            ans[i+1] += cnt - cnt/2;
            cnt = 0;
        }
    }

    for(auto e: ans) {
        cout << e << ' ';
    }
    return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
#include<math.h>
int main()
{
int N;
double v,y,x,t;
while(scanf("%lf",&v)!=EOF)
{

t=v/9.8;
y=4.9*t*t;
x=(y+5)/5;


N=(int)x;
N = (x - (double)N) ? N+1 : N;

printf("%d\n",N);
}
return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, a[101010];
void solve(){
	cin >> n;
	int cnt = 0;
	i64 ans = 0;
	int mi = INF;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] < 0) cnt++;
		chmin(mi, abs(a[i]));
		ans += abs(a[i]);
	}
	
	if(cnt & 1) ans -= mi*2;
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	double EPS = 10.e-08;
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			StringBuilder sb = new StringBuilder();
			for(int i = -a+1; i < a; i++){
				sb.append(" " + (i + b));
			}
			System.out.println(sb.substring(1));
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 23764
#include <cstdio>
#include <vector>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF (int)1e9
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool shortestPath(const Graph g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF+INF); dist[s] = 0;
  prev.assign(n, -2);
  bool negative_cycle = false;
  REP(k, n) REP(i, n) if(dist[i]<INF) FOR(e,g[i]) {
    if (dist[e->dst] > dist[e->src] + e->weight) {
      dist[e->dst] = dist[e->src] + e->weight;
      prev[e->dst] = e->src;
      if (k == n-1) {
        dist[e->dst] = -INF;
        negative_cycle = true;
      }
    }
  }
  return !negative_cycle;
}

int main(){
	int r,T,V,E,s,t,e,i;
	//for(scanf("%d",&T);T;putchar(--T?' ':'\n')){
		scanf("%d%d%d",&V,&E,&r);
		Graph g(V);
		vector<Weight> dist;
		vector<int> prev;
		for(;E--;)scanf("%d%d%d",&s,&t,&e),g[s].push_back(Edge(s,t,e));
		if(!shortestPath(g,r,dist,prev))puts("NEGATIVE CYCLE");
		else for(i=0;i<V;i++){
			if(dist[i]>=INF)puts("INF");
			else printf("%d\n",dist[i]);
		}
	//}
}

Measured memory_bytes: 1168
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
using namespace std;

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

const int inf1=2e9+9;
const ll inf2=8e18+9;
const ll mol=998244353;
const int maxn=1e5+9;
const int maxx=1e9+9;

ll n;

int main()
{
    scanf("%lld",&n);
    int m=sqrt(n+0.5);
    int cnt=0;
    for(int i=2;i<=m;i++)
    {
        if(n%i==0)
        {
            int tmp=0;
            while(n%i==0) n/=i,tmp++;
            for(int i=1;tmp-i>=0;i++)
                tmp-=i,cnt++;
        }
    }
    if(n>1) cnt++;
    printf("%d\n",cnt);
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  string s,t; cin>>s>>t; int c=0,d=0;
  int l=t.length(),p=s.length();
  for(int i=0;i<=p-l;i++){
    string z=s.substr(i,l); c=0;
    for(int j=0;j<l;j++){
        if(z[j]==t[j])c++;
    }
    d=max(d,c);
  } cout<<l-d;
}


Measured memory_bytes: 3628
import sys

input = sys.stdin.readline

n = int(input())
a = [list(map(int, input().split())) for _ in range(3)]
a[0].sort()
a[2].sort()


def bin_chisaimono(b):
    if a[0][0] >= b:
        return 0
    pl = 0
    pr = n - 1

    while True:
        pc = (pl + pr) // 2
        if pc == n - 1 and a[0][pc] < b:
            return n
        elif a[0][pc] < b <= a[0][pc + 1]:
            return pc + 1
        elif a[0][pc] >= b:
            pr = pc - 1
        else:
            pl = pc + 1


def bin_okimono(b):
    if a[2][n - 1] <= b:
        return 0
    pl = 0
    pr = n - 1

    while True:
        pc = (pl + pr) // 2
        if pc == 0 and a[2][pc] > b:
            return n
        elif a[2][pc - 1] <= b < a[2][pc]:
            return n - pc
        elif a[2][pc] <= b:
            pl = pc + 1
        else:
            pr = pc - 1


cnt = 0
for i in range(n):
    cnt += bin_chisaimono(a[1][i]) * bin_okimono(a[1][i])
print(cnt)


Measured memory_bytes: 23184
n,m=map(int,input().split())
from collections import Counter
cc=Counter()
for _ in range(m):
    a,b=map(lambda x:int(x)-1, input().split())
    cc[(a,b)]=1
    cc[(b,a)]=1
for i in range(1,n-1):
    if cc[(0,i)] and cc[(i,n-1)]:
        print('POSSIBLE')
        import sys
        sys.exit()
print('IMPOSSIBLE')


Measured memory_bytes: 73612
n = int(input())

A = list(map(int, input().split()))

def partition(B, p, r):
  x = B[r]
  global i
  i = p-1
  for j in range(p, r):
    if B[j] <= x:
      i += 1
      y = B[i]
      z = B[j]
      B[i] = z
      B[j] = y
  a = B[i+1]
  b = B[r]
  B[i+1] = b
  B[r] = a

partition(A, 0, n-1)

print(" ".join(map(str, A[:i+1])), end='')
print(" [" + str(A[i+1]) + "] ", end='')
print(" ".join(map(str, A[i+2:])))


Measured memory_bytes: 16384
#include<iostream>
using namespace std;
long long gcd(long a, long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main() {
    long long a,b;
    cin >> a >> b;
    cout << (a * b) / gcd(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
template<class T>
class BST {
private:
    struct Node {
        T key;
        Node* left;
        Node* right;
        Node(T key) {
            this->key = key;
            this->left = nullptr;
            this->right = nullptr;
        }
        Node(T key, Node left, Node right) {
            this->key = key;
            this->left = left;
            this->right = right;
        }
    };
    Node* root = nullptr;
public:
    ~BST() {
        makeEmpty(root);
    }
    void insert(T key) {
        root = insertHelper(key, root);
    }
    void inorder() {
        inorderHelper(root);
        std::cout << std::endl;
    }
    void preorder() {
        preorderHelper(root);
        std::cout << std::endl;
    }

private:
    Node* insertHelper(T key, Node* root) {
        if (root == nullptr) return new Node(key);
        if (key < root->key) root->left = insertHelper(key, root->left);
        else root->right = insertHelper(key, root->right);
        return root;
    }
    void makeEmpty(Node* root) {
        if (root == nullptr) return;
        makeEmpty(root->left);
        makeEmpty(root->right);
        delete root;
    }
    void inorderHelper(Node* root) {
        if (root == nullptr) return;
        inorderHelper(root->left);
        std::cout << " " << root->key;
        inorderHelper(root->right);
    }
    void preorderHelper(Node* root) {
        if (root == nullptr) return;
        std::cout << " " << root->key;
        preorderHelper(root->left);
        preorderHelper(root->right);
    }
};
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    BST<int> T;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        if (s[0] == 'i') {
            int x;
            cin >> x;
            T.insert(x);
        }
        else {
            T.inorder();
            T.preorder();
        }
    }
}

Measured memory_bytes: 18836
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int A, B, C, X, Y; 
    cin >> A >> B >> C >> X >> Y;

    int ans = 0;
    if (A+B <= C*2) {
        ans = A * X + B * Y;
    } else {
        if (X <= Y) {
            ans = min(C * X * 2 + B * (Y - X), C * Y * 2);
        } else {
            ans = min(C * Y * 2 + A * (X - Y), C * X * 2);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int,int> pii;
typedef priority_queue<int,vector<int>,greater<int> > small_heap;
typedef priority_queue<int> big_heap;
ll n,c1,c2;
int main()
{
    scanf("%lld",&n);
    if(n&1){
        cout<<0<<endl;
        return 0;
    }
    for(ll i=10;i<=n;i*=5){
        c1+=n/i;
    }
    cout<<c1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
int a,b,c,d;
signed main(){
	cin>>a>>b>>c>>d;
	if(a>=b&&a>=c){
		rep(i,d){
			a*=2;
		}
	}elif(b>=c&&b>=a){
		rep(i,d){
			b*=2;
		}
	}else{
		rep(i,d){
			c*=2;
		}
	}
	cout<<a+b+c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    ll a = n/k;
    if (k%2) PRINT(a*a*a);
    else{
        ll b = n/(k/2)/2+n/(k/2)%2;
        PRINT(a*a*a+b*b*b);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll po(ll k ,ll n,ll ans,ll temp,ll ans1){
    if(n==0)return ans;
    while(temp<=n){
        ans*=ans1;ans%=mod;ans1=ans1*ans1;ans1%=mod;n=n-temp;temp*=2;
    }
    return po(k,n,ans,1,k)%mod;
    //eg. po(2,78,1,1,2);
}
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //cin>>t;
    t=1;
    while(t--){
        cin>>n>>m;
        ll ans[n][m];
        char c[n][m];
        fo(i,n)fo(j,m)cin>>c[i][j];
        if(c[0][0]=='.')ans[0][0]=1;
        fo1(i,n-1)if(c[i][0]=='.'&& ans[i-1][0]==1)ans[i][0]=1;else ans[i][0]=0;
        fo1(i,m-1)if(c[0][i]=='.'&&ans[0][i-1]==1)ans[0][i]=1;else ans[0][i]=0;
        fo1(i,n-1)fo1(j,m-1){
            if(c[i][j]=='#')ans[i][j]=0;
            else ans[i][j]=ans[i-1][j]+ans[i][j-1];
            ans[i][j]%=mod;
        }
        cout<<ans[n-1][m-1];

        

        
    }

    return 0;
}


Measured memory_bytes: 9088
N = int(input())
A_ = list(map(int,input().split()))

A = []
for i,a_ in enumerate(A_):
    A.append(a_-i-1)

d = {}
for a in A:
    if a in d.keys():
        d[a] += 1
    else:
        d[a] = 1

count = 0
for d_ in sorted(d.items()):
    if count >= len(A)/2:
        break
    count += d_[1]
    d_prev = d_[0]

b1 = d_prev
b2 = d_[0]

ans1 = 0
ans2 = 0
for a in A:
    ans1 += abs(a-b1)
    ans2 += abs(a-b2)

print(min(ans1,ans2))

Measured memory_bytes: 47260
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <utility>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> a(N);
    REP(i,N) cin >> a[i];

    int ans = 0;
    for(int i=1; i < N-1;++i)
        if((a[i-1] < a[i] && a[i] < a[i+1]) || (a[i-1] > a[i] && a[i] > a[i+1])) ++ans;
    cout << ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
#define NIL -1
void preorder(int);
void inorder(int);
void postorder(int);
struct Node {
  int parent;
  int left;
  int right;
};

struct Node T[N];
int n;

int main()
{
  int a,b,c,i,l;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      T[i].parent=NIL;
      T[i].left=NIL;
      T[i].right=NIL;
    }
  
  for(i=0;i<n;i++)
    {
      scanf("%d%d%d",&a,&b,&c);
      T[a].left=b;
      T[a].right=c;
      if(b!=NIL) T[b].parent=a;
      if(c!=NIL) T[c].parent=a;
    }
  
  for(i=0;i<n;i++)
    {
      if(T[i].parent==NIL) l=i;
    }
      printf("Preorder\n");
      preorder(l);
      printf("\n");
      printf("Inorder\n");
      inorder(l);
      printf("\n");
      printf("Postorder\n");
      postorder(l);
      printf("\n");

      return 0;
}

void preorder(int u)
{
  if(u==NIL) return;
  printf(" %d",u);
  preorder(T[u].left);
  preorder(T[u].right);
}

void inorder(int u)
{
  if(u==NIL) return;
  inorder(T[u].left);
  printf(" %d",u);
  inorder(T[u].right);
}

void postorder(int u)
{
  if(u==NIL) return;
  postorder(T[u].left);
  postorder(T[u].right);
  printf(" %d",u);
}

Measured memory_bytes: 2732
import Control.Monad
import Data.List

solve 0 xs = [[]]
solve _ [] = []
solve n (x:xs) = [x:y | y <- solve (n-1) xs] ++ solve n xs

isT a b c = (a + b > c && a + c > b && b + c > a)


main = do
    n <- readLn :: IO Int
    ls <- map read . words <$> getLine :: IO [Int]
    if n >= 3
        then print $ length $ filter (\xs -> (length $ group $ sort xs) == 3 && isT (xs!!0) (xs!!1) (xs!!2)) $ map sort $ solve 3 ls
        else print $ 0

Measured memory_bytes: 6900
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    //stの入力
    String s = sc.next();
    String t = sc.next();
    int point;//参照位置
    //続行条件の論理型変数
    boolean con1 = true;
    boolean con2 = true;
    
    for(int i = 0; i < s.length() && con1;i++) {
      con2 = true;
      //iからi-1までを参照し、一致するかどうかをチェック
      for(int j = i; j < (s.length()+i) && con2;j++) {
      	if(j >= s.length()) point = j - s.length(); //jが文字列の長さを超えた場合、0から参照していくようにする
        else point = j; 
        
        if(s.charAt(j - i) != t.charAt(point)) con2 = false; //不一致であればループ終了
      }
      if(con2) con1 = false;//一致していればループ終了
    }
    
    //出力
    if(!con1) System.out.println("Yes");
    else System.out.println("No");
  }
}


Measured memory_bytes: 35600
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;

constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
class modint{
public:
  long long x;
  constexpr modint(long long x=0):x((x%MOD+MOD)%MOD){}
  constexpr modint operator-() const{return modint(-x);}
  constexpr modint& operator+=(const modint& a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  constexpr modint& operator-=(const modint& a){
    if((x+=MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  constexpr modint& operator*=(const modint& a){
    (x*=a.x)%=MOD;
    return *this;
  }
  constexpr modint operator+(const modint& a) const{return modint(*this)+=a;}
  constexpr modint operator-(const modint& a) const{return modint(*this)-=a;}
  constexpr modint operator*(const modint& a) const{return modint(*this)*=a;}
  constexpr bool operator==(const modint& a) const{return this->x==a.x;}
  constexpr bool operator!=(const modint& a) const{return this->x!=a.x;}
  constexpr modint pow(long long expo) const{
    if(expo==0)  return 1;
    modint a=pow(expo>>1);
    a*=a;
    if(expo&1)  a*=(*this);
    return a;
  }
  //for prime MOD
  constexpr modint inv() const{return pow(MOD-2);}
  constexpr modint& operator/=(const modint& a){return (*this)*=a.inv();}
  constexpr modint operator/(const modint& a) const{return modint(*this)/=a;}
};
istream& operator>>(istream& is,const modint& a){return is >> a.x;}
ostream& operator<<(ostream& os,const modint& a){return os << a.x;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll N,K;
  cin >> N >> K;

  modint ans=0;
  ll sum=0;
  for(ll i=1;i<=N+1;i++){
    if(i>=K){
      modint tmp=(i*N-sum-sum+1);
      ans+=tmp;
    }
    sum+=i;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstring>
using namespace std;
bool isprim[100050];
int prim[100050], f[100050];
void Set(int n){
  int ans = 0;
  memset(isprim, 1, sizeof(isprim));
  memset(prim, 0, sizeof(prim));
  isprim[0] = 0;
  isprim[1] = 0;
  for(int i = 2; i <= n; i++){
    if(isprim[i]){
      prim[++ans] = i;
    }
    for(int j = 1; j <= ans && i*prim[j]<=n; j++){
      isprim[i*prim[j]] = 0;
      if(i % prim[j] == 0){
        break;
      }
    }
  }
  for(int i = 2; i <= 100005; i++){
    if(i%2==1 && isprim[i]==1 && isprim[(i+1)/2]==1){
      f[i] = 1 + f[i-1];
    }else{
      f[i] += f[i-1];
    }
  }
}
int main(){
  int q;
  cin>>q;
  Set(100050);
  for(int k = 0; k < q; k++){
    int x, y;
    cin>>x>>y;
    cout<<f[y]-f[x-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  long long N, T;
  cin >> N >> T;
  vector<long long> t(N);
  for (int i = 0; i < N; i++) cin >> t.at(i);
  
  int ans = 0;
  for (int i = 1; i < N; i++)
  {
    ans += min(t.at(i) - t.at(i - 1), T);
  }
  ans += T;
  
  cout << ans << endl;
}

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n, a;

	cin >> n;
	while (n--) {
		cin >> a;
		if (a % 2) {
			cout << "first" << endl;
			return 0;
		}
	}

	cout << "second" << endl;

	return 0;
}

Measured memory_bytes: 256
import numpy as np

def snuke_coloring(h, w, poses):
    counts = np.zeros(10, np.int64)
    searched = {}

    for pos in poses:
        for y in range(max(1, pos[0] - 2), min(h - 2, pos[0]) + 1):
            for x in range(max(1, pos[1] - 2), min(w - 2, pos[1]) + 1):
                index = y * w + x
                if index in searched:
                    searched[index] = searched[index] + 1
                else:
                    searched[index] = 1

    for v in searched.values():
        counts[v] += 1

    nonzero_count = int(np.sum(counts))
    counts[0] = (h - 2) * (w - 2) - nonzero_count
    for v in counts: print(v)

h, w, n = map(int, input().split())
poses = [tuple(map(int, input().split())) for _ in range(n)]
snuke_coloring(h, w, poses)

Measured memory_bytes: 127256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val A = new Array[Int](N+1)
  for (i <- 1 to N)
    A(i) = in.next().toInt

  //
  val MOD = 1000000007

  val dp = new Array[Int](3)
  var ans = 1L

  breakable {
    for (e <- A.drop(1)) {
      var cnt = 0

      for (i <- 0 until 3) {
        if (dp(i) == e) {
          if (cnt == 0)
            dp(i) += 1

          cnt += 1
        }
      }

      if (cnt == 0) {
        ans = 0
        break
      }

      ans *= cnt
      ans %= MOD
    }
  }

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 41036
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a[3];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	for(int i = 0; i < 3; i++) cin >> a[i];
	sort(a, a + 3, greater<int>());
	cout << a[0] * 10 + a[1] + a[2] << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 100000
#define INF 1<<30
using namespace std;
class Edge{
public:
  int t,w;
  Edge(){}
  Edge(int t,int w):t(t),w(w){}
};
vector<Edge>G[MAX];
int n,d[MAX];
bool vis[MAX];
int cnt;

void bfs(int s){
  for(int i=0;i<n;i++)d[i]=INF;
  queue<int>q;
  q.push(s);
  d[s]=0;
  int u;
  while(!q.empty()){
    u=q.front();q.pop();
    for(int i=0;i<G[u].size();i++){
      Edge e=G[u][i];
      if(d[e.t]==INF){
        d[e.t]=d[u]+e.w;
        q.push(e.t);
      }
    }
  }
}
void solve(){
  bfs(0);
  int maxv=0;
  int tgt=0;
  for(int i=0;i<n;i++){
    if(d[i]==INF)continue;
    if(maxv<d[i]){
      maxv=d[i];
      tgt=i;
    }
  }
  bfs(tgt);
  maxv=0;
  for(int i=0;i<n;i++){
    if(d[i]==INF)continue;
    maxv=max(maxv,d[i]);
  }
  cout<<maxv<<endl;
}
int main(){
  int s,t,w;
  cin>>n;
  for(int i=0;i<n-1;i++){
    cin>>s>>t>>w;
    G[s].push_back(Edge(t,w));
    G[t].push_back(Edge(s,w));
  }
  solve();
}

Measured memory_bytes: 9832
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

    map<string, int> m;
    rep(i, n) {
        string s;
        cin >> s;
        sort(all(s));
        m[s]++;
    }

    ll ans = 0;
    for(auto i : m) {
        ll s = i.second;
        ans += (ll)s*(s-1)/2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
import numpy as np

N,K,*P = map(int,open(0).read().split())
P = [(P[i]+1)/2 for i in range(N)]
P = np.cumsum(P)
M = P[K-1]
#print(P)
for i in range(N-K):
  #print(P[i+K],P[i])
  if M < P[i+K]-P[i]:
    M = P[i+K]-P[i]
print(M)

Measured memory_bytes: 33724
using System;
using System.Collections.Generic;
using System.Linq;

namespace cs
{
    public class Program
    {
        public static void Main(string[] args)
        {


            
            var N = int.Parse(Console.ReadLine());

            var input = new int[N];
            var currentLine = new int[N + 1];
            currentLine[1] = int.MinValue;
            var currentMin = int.MaxValue;
            int cnt = 1;
            int x;

            for(int i = N-1; i >=0; i--){
                x = int.Parse(Console.ReadLine());
                if(x > currentLine[1]){
                    currentLine[1] = x;
                }else if(x <= currentLine[cnt]){
                    cnt++;
                    currentLine[cnt] = x;
                }else{
                    for(int k = 2; k <= cnt; k++){
                        if(x > currentLine[k]){
                            currentLine[k] = x;
                            break;
                        }
                    }
                }
                /*
                for(int j = 1; j < cnt+1; j++){
                    Console.Write(currentLine[j] + ",");
                }
                */
                //Console.WriteLine();


            }


            Console.WriteLine(cnt);

            //Console.ReadKey();
           
        }


        public static long modder(){
            return (long)Math.Pow(10,9) + 7;
        }

        public static long GCD(long n, long m){
            
            if(m % n == 0) return n;
            else return GCD(m%n, n);

        }

        public static long LCD(long n, long m){

            return m * n / GCD(n,m);
        }
    }
}


Measured memory_bytes: 17208
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		boolean ans = false;
		for(int a=0;a<=n;a++) {
			for(int b=0;b<=m;b++) {
				if ((n - a) * b + (m - b) * a == k) {
					ans = true;
				}
			}
		}
		System.out.println(ans ? "Yes" : "No");
	}
}

Measured memory_bytes: 23508
import sys
H,W = map(int,input().split())
S = []
A = "ABCDEFGHIJKLNMOPQRSTUVWXYZ"
for i in range(H):
    S.append(list(map(str,input().split())))

for i in range(H):
    for j in range(W):
        if S[i][j] == "snuke":
            sys.stdout.write(A[j])
            sys.stdout.write(str(i+1))

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int t[] = new int[n];
        for (int L = 0; L != n; L++) {
            t[L] = scan.nextInt();
        }

        for (int i = n - 1; i >= 0; i--) {
            if (i != 0) {
                System.out.print(t[i] + " ");
            } else {
                System.out.println(t[i]);

            }
        }
    }
}



Measured memory_bytes: 26116
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n, m; cin >> n >> m;
    vector<int> r(n + 1, 0);

    REP(_, m) {
        int a, b; cin >> a >> b;
        r[a] += 1; r[b] += 1;
    }

    FOR(i, 1, n + 1) cout << r[i] << endl;
}


Measured memory_bytes: 3192
Q = int(input())
Start = []
End = []
for _ in range(Q):
    l, r = map(int, input().split())
    Start.append(l)
    End.append(r)

e = max(End)


def primes(n):
    ass = set([])
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.add(i)
    return ass


def like_primes(n):
    A = [0] * (e+2)
    for i in range(1, e+2):
        if (i in n) and ((i + 1) // 2 in n):
            A[i] = A[i-1] + 1
        else:
            A[i] = A[i-1]
    return A


A = like_primes(primes(e))
for i in range(Q):
    print(A[End[i]] - A[Start[i]-1])


Measured memory_bytes: 66904