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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

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

using namespace std;
using ll=long long;
const ll offset=2000;
ll dp[4010][4010];
ll comb[4010][4010];

const ll mod=1000000007LL;

void init(){
	comb[0][0]=1LL;
	rep(i,4010)rep(j,4010){
		if(i-1>=0) comb[i][j]+=comb[i-1][j];
		if(j-1>=0) comb[i][j]+=comb[i][j-1];
		comb[i][j]%=mod;
	}
	return;
}

const int nmax=200000;
int a[nmax+10],b[nmax+10];

int main(void){
	init();

	int n;
	cin >> n;
	rep(i,n){
		cin >> a[i] >> b[i];
		dp[-a[i]+offset][-b[i]+offset]++;
	}

	rep(i,4010)rep(j,4010){
		if(i-1>=0) dp[i][j]+=dp[i-1][j];
		if(j-1>=0) dp[i][j]+=dp[i][j-1];
		dp[i][j]%=mod;
	}

	ll ans=0LL;
	rep(i,n){
		ans+=dp[a[i]+offset][b[i]+offset];
		ans+=(mod-comb[2*a[i]][2*b[i]]);
		ans%=mod;
	}

	const ll inv=1000000008/2LL;
	cout << ans*inv%mod << endl;
	return 0;
}

Measured memory_bytes: 253056
#include<bits/stdc++.h>
#include<tuple>
using namespace std;
int main()
{
   // vector<int>a;
    int i,j,b,c,n,r,k;
    string p;
    char x;
    long long int t;
    cin>>n;
  tuple<int,int,char,long long int,string> a[n];

   for(i=0;i<n;i++)
   {
       cin>>b>>c>>x>>t>>p;
    a[i]=make_tuple(b,c,x,t,p);

   }
  sort(a,a+n);
  for(i = 0; i < n; i++) {
        cout << get<0>(a[i]) << " " << get<1>(a[i]) << " " << get<2>(a[i])
            << " " << get<3>(a[i]) << " " << get<4>(a[i]) << "\n";
   }
return 0;

}




Measured memory_bytes: 12448
#include <bits/stdc++.h>
#define smax(a, b) ((a) < (b) ? ((a)=(b), true) : false)
#define smin(a, b) ((a) > (b) ? ((a)=(b), true) : false)
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;
typedef long long ll;

ll dp[1001][1001];
bool wall[1001][1001];
int h, w;
const ll MOD = 1e9 + 7;

int main() {
    cin >> h >> w;
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            char t;
            cin >> t;
            if(t == '#')
            {
                wall[i][j] = true;
            }
        }
    }

    dp[1][1] = 1;

    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            if(wall[i][j]) continue;
            dp[i][j] = max(dp[i][j], dp[i-1][j] + dp[i][j-1]);
            dp[i][j] = dp[i][j] % MOD;
        }
    }

    cout << dp[h][w] << endl;
    return 0;
}

Measured memory_bytes: 9088
using Yorukatsu016.Questions;
using Yorukatsu016.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu016.Questions
{
    /// <summary>
    /// ABC074 B
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var k = inputStream.ReadInt();
            var x = inputStream.ReadIntArray();

            yield return x.Select(i => 2 * Math.Min(Math.Abs(i), Math.Abs(i - k))).Sum();
        }
    }
}


namespace Yorukatsu016
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu016.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu016.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11348
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

const int INF = 1e9;

int n, A, B, C;
vector<int> l(10);

int dfs(int depth, int a, int b, int c){
  if (depth == n) {
    if (min({a, b, c}) > 0) return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    else return INF;
  }
  else {
    int ret0 = dfs(depth + 1, a + l[depth], b, c) + 10;
    int ret1 = dfs(depth + 1, a, b + l[depth], c) + 10;
    int ret2 = dfs(depth + 1, a, b, c + l[depth]) + 10;
    int ret3 = dfs(depth + 1, a, b, c);
    return min({ret0, ret1, ret2, ret3});
  }
}

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

  cin >> n >> A >> B >> C;
  rep(i, n) cin >> l[i];

  print(dfs(0, 0, 0, 0));

  return 0;
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          
          Console.WriteLine(a[0]*a[1]%2==0 ? "No":"Yes");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

#define N 100

int main() {
  int i, j, k, l, n, p[N+1], cost[N+1][N+1], min_cost;

  cin >> n;
  for (i = 1; i <= n; i++) cin >> p[i-1] >> p[i];

  // 初期値
  for (i = 1; i <= n; i++) cost[i][i] = 0;

  for (l = 2; l <= n; l++) {  // 行列の個数
    for (i = 1; i <= n - l + 1; i++) {
      j = i + l - 1;
      for (k = i; k < j; k++) {
        if (k == i) min_cost = cost[i][k] + cost[k+1][j] + p[i-1] * p[k] * p[j];
        else min_cost = min(min_cost, cost[i][k] + cost[k+1][j] + p[i-1] * p[k] * p[j]);
      }
      cost[i][j] = min_cost;
    }
  }

  cout << cost[1][n] << endl;

  return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <chrono>
#include <random>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

using circle = pair<PII, double>;
int xs, ys, xg, yg;
int N;
VT<circle> xyr;

int main(void) {
    scanf("%d%d%d%d", &xs, &ys, &xg, &yg);
    scanf("%d", &N);
    xyr.resize(N + 2);
    xyr[0] = MP(MP(xs, ys), 0);
    xyr[N + 1] = MP(MP(xg, yg), 0);
    REP(i, N) {
        int x, y, r;
        scanf("%d%d%d", &x, &y, &r);
        xyr[i + 1] = MP(MP(x, y), r);
    }
    VD ans(N + 2, LLINF);
    VT<bool> vis(N + 2, false);
    ans[0] = 0;
    while (true) {
        double nowCost = LLINF;
        int nowId = -1;
         REP(i, N + 2) {
             if (!vis[i] && nowCost > ans[i]) {
                 nowCost = ans[i];
                 nowId = i;
             }
         }
         if (nowId == -1) break;
         vis[nowId] = true;
         int x1, y1, r1;
         x1 = xyr[nowId].first.first;
         y1 = xyr[nowId].first.second;
         r1 = xyr[nowId].second;
         REP(i, N + 2) {
             if (vis[i]) continue;
             int x2, y2, r2;
             x2 = xyr[i].first.first;
             y2 = xyr[i].first.second;
             r2 = xyr[i].second;
             double nextCost = nowCost + max(0.0, hypot(x1 - x2, y1 - y2) - r1 - r2);
             ans[i] = min(ans[i], nextCost);
         }
    }
    assert(count(ALL(vis), false) == 0);
    cout << fixed << setprecision(10) << ans[N + 1] << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 1e+9
using namespace std;

struct edge{ int to,cost; };
typedef pair<int,int> P;

int par[100000],rnk[100000];

void init(int n){
	for(int i = 0;i < n;i++){
		par[i] = i;
		rnk[i] = 0;
	}
}

int find(int x){
	if(par[x] == x) return x;
	return par[x] = find(par[x]);
}

void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(rnk[x] < rnk[y]) par[x] = y;
	else{
		par[y] = x;
		if(rnk[x] == rnk[y]) rnk[y]++;
	}
}

bool same(int x,int y){
	return find(x) == find(y);
}

signed main(){
	int n,m,k,q,d[100000],x[100000],y[100000],l[100000],r[100000];
	vector<edge> G[100000];
	cin >> n >> m >> k >> q;
	for(int i = 0;i < n;i++) d[i] = INF;
	for(int i = 0;i < m;i++){
		int a,b,l;
		cin >> a >> b >> l; a--;b--;
		G[a].push_back({b,l});
		G[b].push_back({a,l});
	}
	priority_queue<P,vector<P>,greater<P> > que;
	for(int i = 0;i < k;i++){
		int t;
		cin >> t; t--;
		d[t] = 0;
		que.push(P(0,t));
	}
	while(!que.empty()){
		P p = que.top();que.pop();
		int cost = p.first,v = p.second;
		if(d[v] < cost) continue;
		for(edge e : G[v]){
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
	vector<P> ds;
	for(int i = 0;i < n;i++) ds.push_back(P(d[i],i));
	sort(ds.begin(),ds.end(),greater<P>());
	for(int i = 0;i < q;i++){
		cin >> x[i] >> y[i]; x[i]--;y[i]--;
		l[i] = -1;
		r[i] = n;
	}
	vector<int> vec[100000];
	bool used[100000];
	for(int t = 0;t < 35;t++){
		init(n);
		for(int i = 0;i < n;i++){
			vec[i].clear();
			used[i] = false;
		}
		for(int i = 0;i < q;i++){
			if(r[i] - l[i] > 1) vec[(r[i] + l[i]) / 2].push_back(i);
		}
		for(int i = 0;i < n;i++){
			used[ds[i].second] = true;
			for(edge e : G[ds[i].second]){
				if(used[e.to]) unite(ds[i].second,e.to);
			}
			for(int v : vec[i]){
				if(same(x[v],y[v])) r[v] = i;
				else l[v] = i;
			}
		}
	}
	for(int i = 0;i < q;i++) cout << ds[r[i]].first << endl;
	return 0;
}

Measured memory_bytes: 27100
import math
a, b, h, m = map(int, input().split())

theta1 = math.radians(90 - 0.5 * (h * 60 + m))
theta2 = math.radians(90 - 6 * m)

y1 = a * math.sin(theta1)
x1 = a * math.cos(theta1)

y2 = b * math.sin(theta2)
x2 = b * math.cos(theta2)

print(math.sqrt((x1 - x2)**2 + (y1 - y2)**2))


Measured memory_bytes: 9512
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let S = R string
    match S with
    | "SAT" -> 1
    | "FRI" -> 2
    | "THU" -> 3
    | "WED" -> 4
    | "TUE" -> 5
    | "MON" -> 6
    | _ -> 7
    |>stdout.WriteLine
    0


Measured memory_bytes: 13140
module Main where


printResult (s, t) (a, b) u
  | s == u = putStrLn (mconcat [show (a - 1), " ", show b])
  | t == u = putStrLn (mconcat [show a, " ", show (b - 1)])
  | otherwise = putStrLn (mconcat [show a, " ", show b])


main :: IO ()
main =
  words <$> getLine >>= \[s, t] ->
  (map (read :: String -> Int) . words) <$> getLine >>= \[a, b] ->
  getLine >>= \u ->
  printResult (s, t) (a, b) u


Measured memory_bytes: 508
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
  
int main(void){
   int a,b,c;
   cin >> a >> b >> c;
   double PI = acos(-1);
   double rad = c*PI/180;
   cout << fixed << setprecision(5);
   cout << a*b*sin(rad)/2 << endl << a + b + sqrt(a*a + b*b - 2*a*b*cos(rad)) << endl << b*sin(rad) << endl;
}



Measured memory_bytes: 3620
#include<string>
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cassert>
using namespace std;

 
static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = { 'r', 'u', 'l', 'd'};

#define N 4
#define N2 16
#define LIMIT 100
int MDT[N2][N2];
 
struct Puzzle{int f[N2], space, MD;};
 
Puzzle state;
int limit;
int path[LIMIT];
 
int getAllMD(Puzzle pz){
  int sum = 0;
  for(int i = 0 ; i < N2 ; i++){
    if(pz.f[i] == N2) continue;
    sum += MDT[i][pz.f[i] - 1];
  }
  return sum;
}
 

bool dfs(int depth, int prev){
  if(state.MD == 0) return true;
  if(depth + state.MD > limit) return false;
 
  int sx = state.space / N;
  int sy = state.space % N;
  Puzzle tmp;
 
  for(int r = 0 ; r < 4 ; r++){
    int tx = sx + dx[r];
    int ty = sy + dy[r];
    if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
    if(max(prev, r)-min(prev, r) == 2) continue;
    tmp = state;
    state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
    state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
    swap(state.f[tx * N + ty], state.f[sx * N + sy]);
    state.space = tx * N + ty;
    if(dfs(depth + 1, r)) {path[depth] = r; return true;}
    state = tmp;
  }
 
  return false;
}
 
string ku(Puzzle in){
  in.MD = getAllMD(in);
 
  for(limit = in.MD ; limit <= LIMIT ; limit++){
    state = in;
    if(dfs(0, -100)){
      string ans = "";
      for(int i = 0 ; i < limit ; i++) ans += dir[path[i]];
      return ans;
    }
  }
 
  return " ";
}
 
int main(){
  for(int i = 0 ; i < N2 ; i++)
    for(int j = 0 ; j < N2 ; j++)
      MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
 
  Puzzle in;
 
  for(int i = 0 ; i < N2 ; i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = ku(in);
  cout << ans.size() << endl;
 
  return 0;
}


Measured memory_bytes: 3204
function main()
  
  (N,X,Y) = map(x -> parse(Int,x), split(readline()))
  
  dict = Dict()
  
  for i in 1:N-1
    
    check = 0
    for j in i:N
        
      check = min(j-i, abs(X-i) + abs(Y-j) + 1)
      dict[check] = get(dict, check, 0) + 1
        
    end
  end
  
  for i in 1:N-1
    println(get(dict, i, 0))
  end
  
end

main()

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

bool flg[1000001];

void solve(long long s){
	long long n = s, c = 1;
	for(int i = 0; i<=1000000; i++) flg[i] = false;
	flg[s] = true;
	for(int i = 0; i<=1000000; i++) {
		if (n%2==0) {
			n /= 2;
		} else {
			n = 3*n+1;
		}
		c++;
		if (flg[n]) {
			printf("%lld\n", c);
			break;
		} else {
			flg[n] = true;
		}
	}
}

int main(){
	long long s;
	scanf("%lld",&s);
	solve(s);
	return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
int main(){
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if (x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    int id = 0;
    vector<int> ids(h, 0);
    rep(i,h){
        cin >> s[i];
        bool ok = false;
        rep(j,w){
            if(s[i][j] == '#') ok = true;
        }
        if(ok) ++id;
        ids[i] = id;
        chmax(ids[i], 1);
    }
    vector<vector<int>> ans(h, vector<int>(w, -1));
    int cnt = 1;
    rep(i,h){
        int lim = i;
        while(lim+1 < h && ids[lim] == ids[lim+1]) ++lim;
        bool flag = true;
        rep(j,w){
            bool ok = false;
            for(int l = i; l <= lim; ++l){
                if(s[l][j] == '#') ok = true;
            }
            if(ok){
                if(flag) flag = false;
                else ++cnt;
            }
            for(int l = i; l <= lim; ++l){
                ans[l][j] = cnt;
            }
        }
        i = lim;
        ++cnt;
    }
    rep(i,h){
        rep(j,w) cout << ans[i][j] << " ";
        cout << endl;
    }
	return 0;
}

Measured memory_bytes: 3880
#include<bits/stdc++.h>
using namespace std;
#define int long long

int a[100001];
bool dp[100001]; //石の残り数i個の局面

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

  int n,k; cin >> n >> k;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  dp[0] = false; //石0個で負け
  for(int i = 1; i <= k; i++){
    for(int j = 0; j < n; j++){
      if(i-a[j] >= 0) dp[i] |= !dp[i-a[j]];
    }
  }

  if(dp[k]) cout << "First" << endl;
  else cout << "Second" << endl;

  return 0;
}


Measured memory_bytes: 384
/**********************************************************************************************
******************************AUTHOR:**********************************************************
****************************ASHISH RANJAN******************************************************
***********************************************************************************************/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<chrono>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define mod 1000000007
#define fr(i,n) for(int i=0;i<n;i++)
#define frs(i,a,b) for(int i = a;i<b;i++)
#define meme(a,b) memset(a,b,sizeof(a)); //works only for 0 and -1
int main(){
  fast();
ll n;
cin>>n;
string ans = "";
while(n){
ll k = n/26;
ll z = n%26;
if(z==0){
k--;
ans = (char)'z' + ans;
}
else{
ans = (char)(('a'+z-1))+ans;
}
n = k;
}
cout<<ans;
 return 0;
}


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



int main(){
    int N;

    cin >> N;
    std::vector<int> building(N);

    for(int i=0; i < N; i++){
        cin >> building.at(i);
    }
    int life = building.at(0);
    for(int i=1; i < N; i++){
        if(building.at(i-1) > building.at(i)){
            if(building.at(i-1)-building.at(i)>1){
                cout << "No" << endl;
                return 0;
            }else{
                if(building.at(i)<life){
                    cout << "No" << endl;
                    return 0;
                }else{
                    life = building.at(i);
                }
            }
        }
    }
    cout << "Yes" << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int;
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl;
#define pb push_back
#define ull unsigned long long 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define mod 100000007
#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 
bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
    return false;
}
//me
ll const mod = 998244353 ;
ll const inf = 1e18;
ll const maxn = 1e5+1;

void solve()
{    
    
    ll n; cin >> n;

    ll prev =-1, cnt=0;
    f(i,0,n){
        ll x,y; cin >> x >> y;

        if(x!=y)
            prev = -1, cnt=0;
        else if(x==y)
            cnt++;
        else{
            prev = -1, cnt =0;
        }
        if(cnt==3){
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";


}   


int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/ 
  
          ll t;
          /**/t=1;
          /*/cin>>t;/**/
          f(testcases,0,t){
               //cout << "Case #" <<testcases+1<<": ";
               solve();
          }
 
 
    return 0;
}


Measured memory_bytes: 3648
S=int(input())
S1=S%100
S2=int(S/100)
if S1<=12 and S1!=0 and S2 <=12 and S2!=0:
    ans='AMBIGUOUS'
elif S1<=12 and S1!=0:
    ans='YYMM'
elif S2 <=12 and S2!=0:
    ans='MMYY'
else:
    ans='NA'
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <map>
#define REP(i,m,n) for(int i = (int)(m) ; i < (int) (n);i++)
#define rep(i,n) REP(i , 0 ,n)
using namespace std;

string s;



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

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

int main(){
    int x,y=0;
    int tmp=0;
    while (1)
    {
        cin >> x >> y;
        if (x==0 && y==0){
            break;
        }else if(x>y){
            tmp = x;
            x = y;
            y = tmp;
        }
        cout << x << " " << y << endl;
    }
    
    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, K; scanf("%d %d", &N, &K);
  vector<ll> X(N), Y(N);
  vector<pair<ll, ll>> P(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld %lld", &X[i], &Y[i]);
    P[i] = make_pair(X[i], Y[i]);
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  ll ans = numeric_limits<ll>::max();
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        for (int l = k + 1; l < N; ++l) {
          int cnt = count_if(P.begin(), P.end(),
                             [=](pair<ll, ll> p) {
                               return X[i] <= p.first and p.first <= X[j] and
                               Y[k] <= p.second and p.second <= Y[l];
                             });
          if (cnt >= K) {
            ans = min(ans, abs(X[i] - X[j]) * abs(Y[k] - Y[l]));
          }
        }
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
auto in = [](auto &&... args) { (cin >> ... >> args); };


signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  
  int N;
  cin >> N;
  vector<int> d(N+1,1);

  for(int i = 2; i <= N; i++) {
    for(int j = i; j <= N; j+=i) {
      d[j]++;
    }
  }
  int ans = 0;
  for(int i = 1; i <= N; i++) {
    ans += (i * d[i]);
  }
  cout << ans << '\n';
}

Measured memory_bytes: 81328
import java.io.*;
import java.util.*;

class Main{
	
	public static void calendar(ArrayList<Integer> list){
		int y = 2004,m,d,wd;
		
		String[] arrWday = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
		
		for(int i=0;i<list.size()/2;i++){
			m = list.get(i*2);
			d = list.get(i*2+1);
			if( m == 0 && d == 0)break;
			if(m == 1 || m == 2) {
				y--;
				m += 12;
			}
			wd = (y+y/4-y/y+100/400+(13*m+8)/5+d ) % 7;
			System.out.println(arrWday[wd]);
		}

		
	}

	public static void main(String args[]) throws IOException{
		String str;
		ArrayList <Integer> inp = new ArrayList<Integer>();

		Scanner scan = new Scanner(System.in);
		
		while(scan.hasNext()){
			
			str = scan.next();
			int x = Integer.valueOf(str).intValue();
			inp.add(x);
		}
		calendar(inp);
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b;
    cin>>a>>b;
    b/=2;
    cout<<(a+b)<<endl;

    return 0;
}


Measured memory_bytes: 3636
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i];}cerr<<endl //[l, r))

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

template<typename T> inline void in(T &e){cin>>e;}
template<typename H,typename... T>void in(H &a, T&... b){in(a);in(b...);}
template<typename T> inline void out(T e){cout<<e<<endl;}
template<typename H,typename... T> void out(H a, T... b){out(a);out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

const int MAX_H = 100,MAX_W=100;

int h,w;
char grid[MAX_H][MAX_W];

vector<bool> contY,contX;

signed main(){
    io();
    in(h,w);
    contY.resize(h,false);
    contX.resize(w,false);
    rep(y,h){
        rep(x,w) in(grid[x][y]);
    }
    bool f;
    rep(y,h){
        f=true;
        rep(x,w){
            if(grid[x][y]=='#'){
                f=false;
                break;
            }
        }
        if(f) contY[y]=true;
    }

    rep(x,w){
        f=true;
        rep(y,h){
            if(grid[x][y]=='#'){
                f=false;
                break;
            }
        }
        if(f) contX[x]=true;
    }

    rep(y,h){
        rep(x,w){
            if(!contX[x] && !contY[y]){
                printf("%c",grid[x][y]);
            }
        }
        if(!contY[y]) cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    vector<int> B(n);
    int maxcandy = 0;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < n; i++) {
        int candy = 0;
        for (int j = 0; j <= i; j++) candy += A[j];
        for (int j = i; j < n; j++)  candy += B[j];
        maxcandy = max(maxcandy, candy);
    }
    cout << maxcandy << endl;
    return 0;
}


Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  ds <- getLine :: IO String
  let
    s = VU.length . VU.filter id . (VU.zipWith (==) <$> id <*> VU.tail) . VU.fromList $ ds :: Int
  print $ (s + 2 * k) `min` (n - 1)


Measured memory_bytes: 9248
n,k=map(int,input().split())
teleport=list(map(int,input().split()))
double_counter=set()
# mojiretu="1"
mojiretu=["1"]
index=1
double_counter.add(index)
flag=False
for i in range(k):
    tmp=teleport[index-1]
    if tmp in double_counter:
        flag=True
        break
    else:
        double_counter.add(tmp)
        # mojiretu+=str(tmp)
        mojiretu.append(str(tmp))
        index=tmp
else:
    print(tmp)

if flag:
    # index=mojiretu.find(str(tmp))
    # roop_str=mojiretu[index:]
    # length=k%len(roop_str)-len(mojiretu[:index])%len(roop_str)
    # print(roop_str[length])

    index = mojiretu.index(str(tmp))
    roop_str=mojiretu[index:]
    length=k%len(roop_str)-len(mojiretu[:index])%len(roop_str)
    print(roop_str[length])


Measured memory_bytes: 40000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int cnt[26];

void ext(){ cout << "No" << endl; exit(0);}

int main(){

  int H,W; cin >> H >> W;
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      char c; cin >> c; cnt[c-'a']++;
    }
  }
  
  
  if((H*W)%2 == 1){
    for(int i = 0; i < 26; i++){
      if(cnt[i]%2 == 1){ cnt[i]--; break;}
    }
  }
  
  for(int i = 0; i < 26; i++){ if(cnt[i]%2 == 1){ ext();}}
  
  int g2 = 0;
  
  if(H%2 == 1){ g2 += W/2;}
  if(W%2 == 1){ g2 += H/2;}
  
  g2 *= 2;
  
  int m2 = 0;
  
  for(int i = 0; i < 26; i++){
    m2 += cnt[i]%4; // ここでcnt[i]%4は0か2しかありえないことに注意
  }
  
  
  if( m2 > g2){ ext();}
  
  cout << "Yes" << endl; 
  
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

//???
class Point {
public:
    double x, y;
    
    Point (double x = 0, double y = 0):x(x), y(y){}
    Point operator + (Point p){return Point(x + p.x, y + p.y);}
    Point operator - (Point p){return Point(x - p.x, y - p.y);}
    Point operator * (double a){return Point(a * x, a * y);}
    Point operator / (double a){return Point(x / a, y / a);}
    
    double norm(){return x*x + y*y;};
    double absolute(){return sqrt(norm());};
    
    bool operator < (const Point &p) const{
        return x != p.x ? x < p.x : y < p.y;
    }
    
    bool operator == (const Point &p) const{
        return equals(x, p.x) && equals(y, p.y);
    }
    
};
typedef Point Vector;                               //????????????
typedef struct Segment{Point p1, p2;}Segment;       //??????
typedef Segment Line;                               //??´???
//????????????a????????????
double norm(Vector a){
    return a.x * a.x + a.y * a.y;
}
//????????????a?????§??????
double absolute(Vector a){
    return sqrt(norm(a));
}

//????????????a,b?????????
double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}
//????????????a,b?????????
double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

//??????p0, p1, p2???????????????????????????p0p1???????????????p2??????????????????
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a, b) < -EPS) return CLOCKWISE;
    if(dot(a, b) < -EPS) return ONLINE_BACK;
    if(norm(a) < norm(b)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

int main(){
    
    int x0, y0, x1, y1, x2, y2;
    
    int q;
    
    cin >> x0 >> y0 >> x1 >> y1;
    cin >> q;
    
    Point p0 = Point(x0, y0);
    Point p1 = Point(x1, y1);
    
    for (int i = 0; i < q; i++) {
        cin >> x2 >> y2;
        Point p2 = Point(x2, y2);
        
        int ans = ccw(p0, p1, p2);
        
        if(ans == COUNTER_CLOCKWISE) cout << "COUNTER_CLOCKWISE" << endl;
        if(ans == CLOCKWISE) cout << "CLOCKWISE" << endl;
        if(ans == ONLINE_BACK) cout << "ONLINE_BACK" << endl;
        if(ans == ONLINE_FRONT) cout << "ONLINE_FRONT" << endl;
        if(ans == ON_SEGMENT) cout << "ON_SEGMENT" << endl;
    }

    return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
using namespace std;


int main() {
  int N;
  cin >> N;
  cout << "AB" << char('C' + N / 1000) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  int a[m];
  int i;
  for(i=0;i<m;i++){
    scanf("%d",&a[i]);
  }
  int sum=0;
  for(i=0;i<m;i++){
    sum+=a[i];
  }
  if(n-sum>=0){
    printf("%d\n",n-sum);
  }else{
    printf("-1\n");
  }
  return 0;
}


Measured memory_bytes: 1736
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int a[] = new int[2];
		for (int i=0;i<S.length();i++) {
			a[S.charAt(i)-'0']++;
		}
		if (a[0]>a[1]) {
			System.out.println(a[1]*2);
		} else {
			System.out.println(a[0]*2);
		}
	}
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

struct SegmentTree {
  vi32 v;
  int n;
  SegmentTree(int size) {
    n = 1;
    while (n < size) n <<= 1;
    v.resize(n * 2, 0);
  }
  void set(int k, int x) {
    v[k + n] = x;
  }
  void build() {
    rrep(i, n) v[i] = (int) gcd(v[i * 2 + 0], v[i * 2 + 1]);
  }
  int query(int a, int b, int k = 1, int l = 0, int r = -1) {
    if (r == -1) r = n;
    if (b <= l || r <= a) return 0;
    if (a <= l && r <= b) return v[k];
    return (int) gcd(
      query(a, b, k * 2 + 0, l, (l + r) >> 1),
      query(a, b, k * 2 + 1, (l + r) >> 1, r)
    );
  }
};

void solve() {
  int n; cin >> n;
  auto st = SegmentTree(n);
  rep(i, n) {
    int a; cin >> a;
    st.set(i, a);
  }
  st.build();
  int ans = 1;
  rep(i, n) {
    amax(ans, (int) gcd(st.query(0, i), st.query(i + 1, n)));
  }
  cout << ans << '\n';
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using ll = int64_t;
using ld = double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;     

ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int t;
    for (cin >> t; t--;) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;

        if (b > a || b > d) {
            cout << "No\n";
            continue;
        }

        ll g = gcd(b, d);
        a %= d;
        ll dv = (c + d - a) / g + 1;
        
        ll cur = (a + dv * g) % d;

        if (cur > c && cur < b) {
            cout << "No\n";
        } else {
            cout << "Yes\n";
        }
    }
}

Measured memory_bytes: 256
N = int(input())
S = input()
r = 0
g = 0
b = 0
for s in S:
    if s == "R":
        r += 1
    elif s == "G":
        g += 1
    else:
        b += 1

ret = r * g * b

for i in range(N):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ret -= 1

print(ret)


Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=998244353;
const int siz=2e5;
const int inf=1e9;
int main(){
	int N; cin>>N;
	int A[N]; int sum = 0;
	rep(i,0,N){ cin>>A[i]; sum ^= A[i]; }
	rep(i,0,N) cout<<(i ? " " : "")<<(sum ^ A[i]);
	cout<<endl;
}

Measured memory_bytes: 4340
N = int(input())
card = list(input().split())

card_buble = card.copy()
card_select = card.copy()

#bubble sort
flag = 1
i = 0
count = 0
while flag==1:
    flag = 0
    for j in range(i+1,len(card_buble))[::-1]:
        if int(card_buble[j][-1]) < int(card_buble[j-1][-1]):
            temp  = card_buble[j]
            card_buble[j] = card_buble[j-1]
            card_buble[j-1] = temp
            flag = 1
    i += 1


#select sort
for i in range(0,len(card_select)):
    mini = i
    for j in range(i,len(card_select)):
        if int(card_select[j][-1]) < int(card_select[mini][-1]):
            mini = j
    temp = card_select[i]
    card_select[i] = card_select[mini]
    card_select[mini] = temp

print(" ".join(card_buble))
print("Stable")

print(" ".join(card_select))
if card_select == card_buble: print("Stable")
else: print("Not stable")





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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 2e5 + 5;
using ll = long long;
constexpr ll mod = 1e9 + 7;

vector<int> g[N];
ll down[N];
int sz[N];

ll fac[N];

ll fexp(ll x, ll e) {
    ll ans = 1;
    for (; e > 0; e >>= 1) {
        if (e & 1)
            ans = ans * x % mod;
        x = x * x % mod;
    }
    return ans;
}

ll inv(ll x) {
    return fexp(x, mod-2);
}

ll C(ll n, ll k) {
    if (n - k < 0)
        return 0;
    return fac[n] * inv(fac[n - k] * fac[k] % mod) % mod;
}

void build(int u, int p = 0) {
    sz[u] = 1;
    for (int v : g[u]) if (v != p) {
        build(v, u);
        sz[u] += sz[v];
    }
}

void go_subtree(int u, int p = 0) {
    // down[u] = product{ down[v], for every v child of u } * (sz[u] - 1)! / product{ sz[v]!, for every v child of u }
    down[u] = fac[sz[u] - 1];
    ll k = 1;
    for (int v : g[u]) if (v != p) {
        go_subtree(v, u);
        down[u] = down[u] * down[v] % mod;
        k *= fac[sz[v]];
        k %= mod;
    }

    down[u] = down[u] * inv(k) % mod;
    debugf("down[%d] = %lld\n", u, down[u]);
}

void go_root(int u, int p = 0) {
    for (int v : g[u]) if (v != p) {
        ll down_wo_v = down[u];
        down_wo_v *= inv(down[v]); down_wo_v %= mod;
        down_wo_v *= inv(fac[sz[u] - 1]); down_wo_v %= mod;
        down_wo_v *= fac[sz[v]]; down_wo_v %= mod;
        down_wo_v *= fac[sz[u] - sz[v] - 1]; down_wo_v %= mod;

        down[v] *= down_wo_v; down[v] %= mod;
        down[v] *= inv(fac[sz[v] - 1]); down[v] %= mod;
        down[v] *= fac[sz[u] - 1]; down[v] %= mod;
        down[v] *= inv(fac[sz[u] - sz[v]]); down[v] %= mod;

        sz[v] = sz[u];
        go_root(v, u);
    }
}

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    fac[0] = 1;
    for (int i = 1; i < N; i++)
        fac[i] = fac[i-1] * i % mod;

    int n; cin >> n;
    for (int i = 0; i < n-1; i++) {
        int u, v;
        cin >> u >> v;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }

    build(1);
    go_subtree(1);
    go_root(1);

    for (int i = 1; i <= n; i++)
        cout << down[i] << endl;

    return 0;
%>

Measured memory_bytes: 17908
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
bool sosu(int n) {
  if (n <= 1)
    return false;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0)
      return false;
  return true;
}
int main() {
  long long a[10010], n, m = 1;
  a[1] = 2;
  for (int i = 3; m < 10000; i++) {
    if (sosu(i)) {
      a[m + 1] = a[m] + i;
      m += 1;
    }
  }
  while (cin >> n, n)
    cout << a[n] << endl;
  return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w",stdout);
    #endif
     int a ,b;
     cin>>a>>b;
     if(a>b){cout<<"safe";}
     else if(a<=b){ cout<<"unsafe";}
}

Measured memory_bytes: 3636