akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

char a[105][20], b[105][20];
int c[105], n, m, i, j, k, t, vis;

int main()
{
	while(~scanf("%d",&n))
	{
		getchar();
		k = 0, t = 0;
		for(i = 0; i < n; i++)
		{
			scanf("%s",a[i]);
			getchar();
		}
		scanf("%d",&m);
		getchar();
		for(i = 0; i < m; i++)
		{
			scanf("%s",b[i]);
			getchar();
		}
		for(i = 0; i < n; i++)
		{
			k = 0;
			for(j = 0; j < n; j++)
				if(strcmp(a[i], a[j]) == 0)  k++;
			for(j = 0; j < m; j++)
				if(strcmp(a[i], b[j]) == 0)  k--;
			c[t++] = k;
		}
		sort(c, c + t);
		if(c[t - 1] >= 0) cout << c[t - 1] << endl;
		else cout << 0 << endl;
	}
	return 0;
}

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

using namespace std;

#define ALL(x) x.begin(), x.end()

typedef long long int lld;
typedef pair<int, int> pii;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;

	string s, t;
	vector<lld> pos[26];

	cin >> s >> t;

	for (int i = 0; i < s.length(); i++) {
		pos[s[i] - 'a'].push_back(i);
	}

	lld res = 0;
	int now = 0;

	bool flag = true;
	for (int i = 0; i < t.length(); i++) {
		
		if (flag)
			now = -1;
		else
			now = res % s.length();
		

		int w = t[i] - 'a';
		auto it = upper_bound(ALL(pos[w]), now);

		if (it == pos[w].end()) {
			if (pos[w].size() != 0) {
				res += (s.length() - res % s.length());
				i--;
				flag = true;
			} else {
				cout << -1 << '\n';
				return 0;
			}
		} else {
			res += *it - (res % s.length());
			flag = false;
		}
	}
	cout << res + 1 << '\n';




	return 0;
}

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

if A % 2 == 0 and B % 2 == 0:
    print("Alice")
elif A % 2 == 0 and B % 2 != 0:
    print("Borys")
elif A % 2 != 0 and B % 2 == 0:
    print("Borys")
elif A % 2 != 0 and B % 2 != 0:
    print("Alice")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n, k, a[N]; bool dp[N];

void solve()
{
    cin >> n >> k;
    for (int i=1; i<=n; ++i) cin >> a[i];

    for (int i=0; i<=k; ++i) {
        for (int j=1; j<=n; ++j) {
            if (i>=a[j] && !dp[i-a[j]]) dp[i] = true;
        }
    }
    nout(dp[k]?"First":"Second");
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int N, K;
	cin >> N >> K;
	
	int n = 1;
	for (int i = 0; i < N; i++) {
		if (n < K) n *= 2;
		else n += K;
	}

	cout << n << endl;
}


Measured memory_bytes: 3628
abef=0
bbef=1
s=input()
for i in range(len(s)):
  curr=int(s[len(s)-1-i])
  a=abef+curr
  b=bbef+9-curr
  a=min(a,1+bbef+curr)
  b=min(b,abef+10-curr)
  abef=a
  bbef=b
curr=0
a=abef+curr
b=bbef+9-curr
a=min(a,1+bbef+curr)
b=min(b,abef+10-curr)
print(min(a,b))

Measured memory_bytes: 75680
n=int(input())
c=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

ans = ''
tmp = 0

if n < 26:
    print(c[n-1])
    exit()

while(n > 0):
    tmp = int(n % 26)
    if tmp == 0:
        tmp = 26
    ans = c[tmp-1] + ans
    n = n - tmp
    n = n / 26

print(ans)

Measured memory_bytes: 8992
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
  //stream
  friend ostream& operator<<(ostream& os, const mint a);
};
ostream& operator<<(ostream& os, const mint a){
  os << a.x;
  return os;
}

int main(void) {
	int n,k; cin >> n >> k;
	vvi to(n);
	rep(i,n-1){
		int a,b; cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	mint ans=k;
	queue<int> q;
	vector<bool> visited(n,false);
	visited[0]=true;
	q.push(0);
	while(q.size()){
		int u = q.front(); q.pop();
		int c = k-2+(u==0);
		for(auto v: to[u]){
			if(visited[v]) continue;
			ans *= c--;
			visited[v] = true;
			q.push(v);
		}
	}
	cout << ans << endl;
}




Measured memory_bytes: 6520
#include <stdio.h>

/* 整数を入れ替える */
void swap(int *a, int *b){
	int c;
	c = *b;
	*b = *a;
	*a = c;
}

/* 配列を複製する */
/*
void copy(int *d, const int *s, int length){
	int i;
	for (i = 0; i < length; i++){
		d[i] = s[i];
	}
}
*/

/* 与えられた配列を逆順にして複製する */
void copyRverse(int *d, const int *s, int length){
	int i;
	for (i = 0; i < length; i++){
		d[i] = s[length-1-i];
	}
}

/* 整数配列を昇順に並び替える */
void sortAscending(int *array, int length){
	int i, j;
	for (i = 0; i < length - 1; i++){
		for (j = 0; j < length - 1 - i; j++){
			if (array[j] > array[j+1]){
				swap(&array[j], &array[j+1]);
			}
		}
	}
}

/* 整数を 1 桁ごとに分けて配列化する */
int* toMulti(int *m, int a, int length){
	int i;
	for (i = 0; i < length; i++){
		m[i] = a % 10;
		a /= 10;
	}
	return m;
}

/* 配列化された整数を int 型に変換する */
int toSingle(const int *m, int length){
	int a = 0;
	int i;
	for (i = 0; i < length; i++){
		a *= 10;
		a += m[length-1-i];
	}
	return a;
}

int main(void){
	int a[21];
	int l;
	int max[6];
	int min[6];
	int i, j;

	while(scanf("%d %d", &a[0], &l) == 2){
		if (a[0] == 0 && l == 0){
			break;
		}

		for (i = 1; i <= 20; i++){
			toMulti(max, a[i-1], l);
			sortAscending(max, l);
			copyRverse(min, max, l);
			/* 次の整数 ai を計算する */
			a[i] = toSingle(max, l) - toSingle(min, l);
			/* printf("    a[%2d]: %6d - %6d = %d\n", i, toSingle(max, l), toSingle(min, l), a[i]); */
			/* ai = aj を満たす j を探す */
			for (j = 0; j < i; j++){
				if (a[i] == a[j]){
					break;
				}
			}
			if (j < i){
				break;
			}
		}

		/* j の値, ai の値, i - j の値 */
		printf("%d %d %d\n", j, a[i], i - j);
	}

    return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  998244353;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

signed main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  using Node = tuple<int, int, ll>;
  vector<Node> edges;
  REP(_, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;b--;
    edges.emplace_back(a, b, -c);
  }
  vector<ll> d(n, inf);
  d[0] = 0;
  REP(i, n - 1) {
    REP(j, m) {
      if(d[get<0>(edges[j])] == inf) continue;
      d[get<1>(edges[j])] = min(d[get<1>(edges[j])], d[get<0>(edges[j])] + get<2>(edges[j]));
    }
  }
  vector<bool> update(n, false);
  REP(i, 2 * n) {
    REP(j, m) {
      if(d[get<0>(edges[j])] == inf) continue;
      if(d[get<1>(edges[j])] > d[get<0>(edges[j])] + get<2>(edges[j])) {
        update[get<1>(edges[j])] = true;
        d[get<1>(edges[j])] = d[get<0>(edges[j])] + get<2>(edges[j]);
      }
    }
  }
  REP(i, n - 1) {
    REP(j, m) {
      if(d[get<0>(edges[j])] == inf) continue;
      if(update[get<0>(edges[j])]) {
        update[get<1>(edges[j])] = true;
      }
    }
  }
  if(update[n-1]) {
    cout << "inf" << endl;
    return 0;
  }
  cout << -d[n-1] << endl;
  return 0; 
}


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


int main()
{
  string aa, bb, cc;
  cin>>aa>>bb>>cc;
  int n_a = aa.size();
  int n_b = bb.size();
  int n_c = cc.size();

  int i_c =0, i_a = 0, i_b = 0;

  char chance = 'a';
  //i_c++;
  while(i_c<=n_c && i_b <=n_b && i_a <=n_a)
  {
    if(chance=='a')
    {
        chance = aa[i_a];
        i_a++;

      //  cout<<"inside the block a\n";
        // if(i_a == n_a -1)
        // break;
    }
    else if(chance=='b')
    {
      chance = bb[i_b];
      i_b++;
      //cout<<"inside the block b\n";
      // if(i_b == n_b -1)
      // break;
    }
    else if(chance =='c')
    {
      chance = cc[i_c];
      i_c++;
      //cout<<"inside the block c\n";
      // if(i_c == n_c -1)
      // break;
    }
    //cout<<"inside the loop\n";
  }
  //cout<<"outside the loop\n";
  if(i_c == n_c+1)
  cout<<"C\n";
  else if(i_b == n_b+1 )
  cout<<"B\n";
  else if(i_a == n_a+1)
  cout<<"A\n";



}


Measured memory_bytes: 256
const solve = xs => {
    const m = xs.reduce((acc, x) => x > acc ? x : acc);

    let cs = Array(m);
    for (let i = 0; i <= m; i++) { cs[i] = 0 };

    let rs = [];

    xs.forEach( x => cs[x] = cs[x] + 1 );

    for (let i = 0; i <= m; i++) {
        if (cs[i] !== undefined) {
            let c = cs[i]
            while (c !== 0) {
                rs.push(i);
                c = c - 1;
            }
        }
    }

    return rs;

}


const main = () => {
    args = require('fs').
           readFileSync('/dev/stdin', 'UTF-8').
           split("\n").
           map(line =>
                line.split(' ').map(x => parseInt(x))
              );
    args.pop();

    const xs = solve(args[1].concat());

    console.log(xs.join(' '));
};

main();


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

int main() {
    string s,t;
    cin>>s>>t;
    for (int i=0;i<s.size()+t.size();i++) {
        if (i%2==0)
            cout<<s[i/2];
        else
            cout<<t[i/2];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int i,n,srx[100001],t,sry,lhy;
int max(int x,int y)
{
    if(x>y)
    return x;
    return y;
}
int main()
{
    scanf("%d",&n);
    for(i=1;i<=n;++i)
    {scanf("%d",&t);
    if(sry<t)
    sry=t;
    srx[t]++;}
    for(i=0;i<=sry;++i)
    lhy=max(lhy,srx[i]+srx[i-1]+srx[i+1]);
    printf("%d\n",lhy);
    return 0;
}

Measured memory_bytes: 512
def calc(K, xyc):
    K2 = K * 2
    N = len(xyc)

    p = [[0] * K2 for i in range(K2)]
    for x, y, c in xyc:
        y += c * K
        p[x % K2][y % K2] += 1
        p[(x + K) % K2][(y + K) % K2] += 1

    def calcsum(xs):
        r = sum(xs[:K])
        yield r
        for a, b in zip(xs[:K], xs[K:]):
            r += -a + b
            yield r

    pksum = [list(calcsum(xs)) for xs in p]

    rmax = N / 2
    for y in range(K):
        rcount = sum(row[y] for row in pksum[:K])
        for x in range(K):
            rmax = max(rmax, rcount, N - rcount)
            rcount += -pksum[x][y] + pksum[x + K][y]

    return rmax

if __name__ == '__main__':
    N, K = [int(e) for e in input().split()]
    xyc = [(int(x), int(y), c == "W") for x, y, c in [input().split() for i in range(N)]]
    print(calc(K, xyc))


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

int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0) {
      break;
    }
    vector<int> p(n, 0);
    int input;
    int i, j;
    for (i = 0; i < m; i++) {
      for (j = 0; j < n; j++) {
        cin >> input;
        p[j] += input;
      }
    }
    int result = 0;
    for (i = 0; i < n; i++) {
      result =  max(result, p[i]);
    }
    cout << result << endl;
  }
  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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 dp[110][10010];

int main() {
	int N,W;
	cin >> N >> W;
	vector<int> v(N),w(N);
	rep(i,N) cin >> v[i] >> w[i];
	rep(i,N+1) rep(j,W+1) dp[i][j] = -1e9;
	dp[0][0] = 0;
	rep(i,N+1) {
		if(i == 0) continue;
		rep(j,W+1) {
			if(j < w[i-1]) dp[i][j] = max({dp[i][j], dp[i-1][j]});
			else dp[i][j] = max({dp[i][j], dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1], dp[i][j-w[i-1]] + v[i-1]});
		}
	}
	int maxi = -1;
	rep(i,W+1) chmax(maxi, dp[N][i]);
	cout << maxi << endl;


  return 0;
}


Measured memory_bytes: 7060
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-8)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
//*
// シンプルな構文解析用
typedef string::const_iterator State;
class ParseError {};
//*/
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;


int main(void) {
	ll Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;
	ll L2 = min(8 * Q, min(4 * H, min(2 * S, D)));
	ll ans = (N / 2) * L2;
	if (N % 2 == 1) {
		ans += min(4 * Q, min(2 * H, S));
	}
	cout << ans << endl;
	return 0;
}

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

int ans[200006];
vector <int> G[200006];

void dfs(int v,int p){
  int i;
  for(i = 0;i < G[v].size();i++){
    int u = G[v][i];
    if(u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
}

int main(){
  int n,q;
  int i;
  int now;

  scanf("%d %d", &n, &q);
  for(i = 1;i <= n;i++){
    ans[i] = 0;
  }

  int a,b;
  for(i = 0;i < n - 1;i++){
    scanf("%d %d", &a, &b);
    G[b].push_back(a);
    G[a].push_back(b);
  }

  for(i = 0;i < q;i++){
    scanf("%d %d", &a, &b);
    ans[a] += b;
  }

  dfs(1,-1);

  for(i = 1;i <= n;i++){
    printf("%d\n", ans[i]);
  }

  return 0;
}

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

using namespace std;


typedef long long ll;
ll mod=1e9+0LL;
ll MOD=1e18+0LL;
double pi=acos(-1);


int main()
{
    int cs=1;
    //scanf("%d",&cs);
    while(cs--)
    {int n,k;
        string s;
        cin>>k;
        cin>>s;
        n=s.length();
        if(n>k){
            s=s.substr(0,k);
            s+="...";
        }
        cout<<s;

    }
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
int N;
string S;
string ansS;
void solve() {
	for (int i = 1; i < N + 1; ++i) {
		if ('o' == S[i]) {
			if ('S' == ansS[i]) {
				ansS += ansS[i - 1];
			}
			else {
				if ('S' == ansS[i - 1]) {
					ansS += "W";
				}
				else {
					ansS += "S";
				}
			}
		}
		else {
			if ('W' == ansS[i]) {
				ansS += ansS[i - 1];
			}
			else {
				if ('S' == ansS[i - 1]) {
					ansS += "W";
				}
				else {
					ansS += "S";
				}
			}
		}
	}
}
int main() {
	cin >> N;
	cin >> S;
	S += S[0];
	S += S[1];
	string S[] = { "SS","WW","SW","WS" };
	for (int i = 0; i < 4; ++i) {
		ansS = S[i];
		solve();
		if ((ansS[0] == ansS[N])&&(ansS[1] == ansS[N+1])){
			cout << ansS.substr(0,N)<<endl;
			return 0;
		};
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3824
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    string S;
    cin(S);

    //vll X(N);
    //REP(i,N) cin(X[i]);


    //本文
    ll ans = 0;
    
        if(S[0] == 'R'){
            if(S[1] == 'R'){
                if(S[2]== 'R'){
                    ans = 3;
                }
                else{ans = 2;}
            }
            else{
                ans = 1;
            }
            
        }
        else{
         if(S[1] == 'R'){
                if(S[2]== 'R'){
                    ans = 2;
                }
                else{ans = 1;}
            }
            else{if(S[2] == 'R'){ ans = 1;}
            else{ans  = 0;}


            }
        }
    
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3652
import sys
N = int(input())

W = [input() for _ in range(N)]


for i in range(N-1):
    if W.count(W[i]) >= 2:
        print('No')
        sys.exit()
    if W[i][-1] != W[i+1][0]:
        print('No')
        sys.exit()

print('Yes')


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


int main() {
  
    int x, a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	int a,b,c,p,q,x,y,z;
	cin>>a>>b>>c;
	x=abs(a-b)+abs(a-c);
	y=abs(b-c)+abs(b-a);
	z=abs(c-a)+abs(c-b);
	p=min(y,z);
	q=min(p,x);
	cout<<q;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 998244353;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int a,b;

void work(){
    scanf("%d",&a);
    int ok=0;
    for(int i=1;i<=9;i++){
        if(a%i==0){
            b=a/i;
            if(1<=b&&b<=9) ok=1;
        }
    }
    if(ok) printf("Yes\n");
    else printf("No\n");
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}






Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
        long n = long.Parse(input[0]);
        long k = long.Parse(input[1]);
      
        long cnt = 0;
        for(long i = k; i <= n+1; i++)
        {
          long tmp = (i*n - i*(i-1) + 1) % 1000000007;
          cnt = (cnt + tmp) % 1000000007;
        }
      
        Console.WriteLine(cnt);

	}

}

Measured memory_bytes: 27524
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()

    var lcm = 1L

    repeat(n) {
        val t = readLine()!!.toLong()
        lcm = lcm(lcm, t)
    }

    println(lcm)
}

fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

fun lcm(a : Long, b : Long) : Long {
    return (a / gcd(a, b)) * b
}


Measured memory_bytes: 31528
#include <bits/stdc++.h>
using namespace std;
string divide[4]={"dream","dreamer","erase","eraser"};
int main(){
    string s;
    cin>>s;
    int cnt=0;
    if(s[0]=='o') cnt++;
    if(s[1]=='o') cnt++;
    if(s[2]=='o') cnt++;
    cout<<700+cnt*100<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ret = [0] * (max(A) + 3) # -1 から始まる

for i in range(N):
    cur = A[i]
    ret[A[i]] += 1
    ret[A[i] + 1] += 1
    ret[A[i] + 2] += 1

print(max(ret))

Measured memory_bytes: 52908
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define VFOR(x,begin,num) for(int x=(begin);x<((begin)+(num));x++)
#define INF_ ((long long)1 << 60)
int main(){
    int N; cin >> N;
    cout << ((N+2-1)/2);
    return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 3000.cc: 
 */

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

/* constant */

const double PI = acos(-1.0);

/* typedef */

/* global variables */

/* subroutines */



/* main */

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

  double t0 = PI * a0 / 180, t1 = PI * a1 / 180;
  double t = atan2(sin(t0) + sin(t1), cos(t0) + cos(t1));
  if (t < 0.0) t += PI * 2;
  printf("%.1lf\n", t * 180 / PI);
  return 0;
}



Measured memory_bytes: 3588
package main

import (
        "fmt"
        "strings"
)

func main() {
        var s string
        fmt.Scanln(&s)

        if strings.Count(s, "a") == 1 && strings.Count(s, "b") == 1 && strings.Count(s, "c") == 1 {
                fmt.Println("Yes")
        } else {
                fmt.Println("No")
        }
}

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


string s,t;
int dp[3100][3100];


void LIS(){
  FOR(i,1,s.size()+1){
    FOR(j,1,t.size()+1){
      if(s[i-1]==t[j-1]){
        if(i==0||j==0){
          dp[i][j]=1;
        }
        else{
          dp[i][j] = dp[i-1][j-1]+1;
        }
      }
      dp[i][j] = max(dp[i][j],dp[i-1][j]);
      dp[i][j] = max(dp[i][j],dp[i][j-1]);
    }
  }
}


signed main(){
  cin>>s>>t;

  LIS();

  string ans;
  int n=s.size();
  int m=t.size();

  while(dp[n][m]!=0){
    if(s[n-1]==t[m-1]){
      ans+=s[n-1];
      n--;
      m--;
    }
    else if(dp[n-1][m]==dp[n][m])
      n--;
    else
      m--;
  }

  reverse(all(ans));
  cout<<ans<<endl;
}


Measured memory_bytes: 73984
import sys
read = sys.stdin.buffer.read

N, *h = map(int, read().split())
#print(N, h)

def chmin(l, i, v):
  if l[i] > v:
    l[i] = v
    return True
  return False

def chmax(l, i, v):
  if l[i] < v:
    l[i] = v
    return True
  return False

# コスト無限大で初期化
INF = float("inf")
dp = [ INF ] * N
dp[0] = 0

for i in range(1, N):
  # i番目の梯子までの最小移動コストは、
  # 「i-1番目までの移動コスト」+「i-1番目からi番目への移動コスト」
  # もしくは、
  # 「i-2番目までの移動コスト」+「i-3番目からi番目への移動コスト」
  # のうち、どちらか小さいほうが、最小移動コストになる
  chmin(dp, i, dp[i-1] + abs(h[i] - h[i-1]))
  if i > 1:
    # i = 1のとき、i-2の梯子が無いので注意
    chmin(dp, i, dp[i-2] + abs(h[i] - h[i-2]))
  # print(dp)

print(dp[N-1])

Measured memory_bytes: 12308
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N;
	int A[100], B[100];
	//input
	cin >> N ;
	for (int i = 1; i < N; i++) {
		cin >> B[i];
	}
	//compute
	int sum = 0;
	A[1] = B[1];
	A[N] = B[N-1];
	for (int i = 2; i < N; i++) {
		A[i] = min(B[i - 1], B[i]);
	}
	for (int i = 1; i <= N; i++) {
		sum += A[i];
//		cout << A[i];
	}
	//output
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define pb push_back
int main(int argc, char** argv) {
	int k,a,b,fg;
	cin>>k>>a>>b;
	fg=0;
	rep(i,a,b)
	{
		if(i%k==0)
		{
		fg=1;	
		}
	}
	if(fg)
	{
		printf("OK");
		
	}
	else printf("NG");
	return 0;
}



Measured memory_bytes: 3716
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n,x;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll dp[n][n][2];
	for(int i=0;i<n;i++)
	{
		dp[i][i][1]=a[i];
		dp[i][i][0]=-a[i];
	}
	for(int i=1;i<n;i++)
	{
		for(int l=0,r=i;r<n;r++,l++)
		{
			dp[l][r][0]=min(dp[l+1][r][1]-a[l],dp[l][r-1][1]-a[r]);
			dp[l][r][1]=max(dp[l+1][r][0]+a[l],dp[l][r-1][0]+a[r]);
		}
	}
	cout<<dp[0][n-1][1];
	return 0;
}

Measured memory_bytes: 85460
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
#define ALL(v) (v).begin(), (v).end()
const int mod = INF+7;
using namespace std;

//下から行くと大小判定が難しい
//上から行くと０を含みにくい。

bool judge(string S, int n){
  bool flag3=false;
  bool flag5=false;
  bool flag7=false;
  rep(i,n){
    if(S[i]=='3'){
      flag3=true;
    }
    else if(S[i]=='5'){
      flag5=true;
    }
    else if(S[i]=='7'){
      flag7=true;
    }
  }
  if(flag3==true && flag5==true && flag7==true){
    return true;
  }
  else{
    return false;
  }
}

int dfs(bool upper, int index, string S, string temp, int n, int count){
  if(index==n){
    count+=judge(temp, n);
  }
  else if(upper==false){
    temp+='3';
    count=dfs(false, index+1, S, temp, n, count);
    temp[index]='5';
    count=dfs(false, index+1, S, temp, n, count);
    temp[index]='7';
    count=dfs(false, index+1, S, temp, n, count);
  }
  else if(upper==true){
    if(S[index]=='8' || S[index]=='9'){
      temp+='3';
      count=dfs(false, index+1, S, temp, n, count);
      temp[index]='5';
      count=dfs(false, index+1, S, temp, n, count);
      temp[index]='7';
      count=dfs(false, index+1, S, temp, n, count);
    }
    else if(S[index]=='7'){
      temp+='3';
      count=dfs(false, index+1, S, temp, n, count);
      temp[index]='5';
      count=dfs(false, index+1, S, temp, n, count);
      temp[index]='7';
      count=dfs(true, index+1, S, temp, n, count);
    }
    else if(S[index]=='6'){
      temp+='3';
      count=dfs(false, index+1, S, temp, n, count);
      temp[index]='5';
      count=dfs(false, index+1, S, temp, n, count);
    }
    else if(S[index]=='5'){
      temp+='3';
      count=dfs(false, index+1, S, temp, n, count);
      temp[index]='5';
      count=dfs(true, index+1, S, temp, n, count);
    }
    else if(S[index]=='4'){
      temp+='3';
      count=dfs(false, index+1, S, temp, n, count);
    }
    else if(S[index]=='3'){
      temp+='3';
      count=dfs(true, index+1, S, temp, n, count);
    }
  }
  //cout << "temp=" << temp << ", count=" << count <<endl;
  return count;
}

int main(){
  string S;
  cin >> S;
  int n=S.length();
  if(n<=2){
    printf("%d\n", 0);
  }
  else{
    bool upper=true;
    int index=0;
    string temp="";
    int count=0;
    count=dfs(upper, index, S, temp, n, count);
    if(n>3){
      srep(i,3,n)
      count+=pow(3,i)-(pow(2,i)-2)*3-3;
    }
    printf("%d\n", count);
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long a,b,c,d,e[1000001]={0},f[1000001];
int main(){
	cin>>a;
	for(long long i=1;i<35;i++){
	    b=1;
		for(long long j=1;j<11;j++){
			b*=i;
			if(b>a){
				break;
			}
			if(j!=1){
				e[b]=1;
			}			
		}
	}
	for(long long i=a;i>=1;i--){
		if(e[i]==1){
			cout<<i<<endl;
			return 0;
		}
    }
}

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

int main(){
    int n, m;cin >> n >> m;
    cout << ((n * (n - 1)) / 2) + ((m * (m - 1)) / 2) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  int a, b, c;

  cin >> a >> b >> c;
  puts((a == b && a == c) ? "Yes" : "No");

  return 0;
}



Measured memory_bytes: 256
h,w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
b = [list(map(int, input().split())) for i in range(h)]
m = 13120
DP = [[[0]*m for i in range(w)] for i in range(h)]

for i in range(h):
    for j in range(w):
        k = abs(a[i][j]-b[i][j])
        if i==0 and j==0:
            DP[i][j][k] = 1
        else:
            for l in range((i+j+1)*80+1):
                DP[i][j][l] = DP[i][j-1][abs(l-k)] | DP[i][j-1][l+k] | DP[i-1][j][abs(l-k)] | DP[i-1][j][l+k]
print(DP[-1][-1].index(1))

Measured memory_bytes: 692872
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int n;
int MOD;

vector<int>E[200000];
ll dp[200000],dp2[200000];
ll dpa[200000],dpb[200000];

void dfs(int v,int p){
	for(int u:E[v]){
		if(u==p)continue;
		dfs(u,v);
	}
	dp[v]=1;
	for(int u:E[v]){
		if(u==p)continue;
		dpa[u]=dp[v];
		(dp[v]*=(dp[u]+1))%=MOD;
	}
}
void dfs2(int v,int p){
	ll a=1;
	for(int i=0;i<E[v].size();i++){
		int u=E[v][i];
		dpa[u]=a;
		if(u==p)(a*=(dpa[v]*dpb[v]%MOD+1))%=MOD;
		else (a*=(dp[u]+1))%=MOD;
	}
	a=1;
	for(int i=E[v].size()-1;i>=0;i--){
		int u=E[v][i];
		dpb[u]=a;
		if(u==p)(a*=(dpa[v]*dpb[v]%MOD+1))%=MOD;
		else (a*=(dp[u]+1))%=MOD;
	}
	dp2[v]=a;
	for(int u:E[v]){
		if(u==p)continue;
		dfs2(u,v);
	}
}
int main(){
	cin>>n>>MOD;
	rep(i,n-1){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	dfs(0,-1);
	dfs2(0,-1);
	rep(i,n){
		printf("%lld\n",dp2[i]);
	}
}

Measured memory_bytes: 20096
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        try{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] s1 = reader.readLine().split(" ");
        String[] s2 = reader.readLine().split(" ");
        List<Integer> point = new ArrayList<>();
        
        for (int i=0; i<s2.length; i++){
            point.add(Integer.parseInt(s2[i]));
        }

        Collections.sort(point);
        
        for (int i=0; i<point.size()-1; i++){
            point.set(i, point.get(i+1)-point.get(i));
        }
        
        point.remove(point.size()-1);
        Collections.sort(point);
        int ans=0;
        
        if (Integer.parseInt(s1[0]) < Integer.parseInt(s1[1])){
            for(int i=0; i<point.size()-(Integer.parseInt(s1[0])-1); i++){
                ans += point.get(i);
            }
        }
        
        System.out.println(ans);
        
        }catch(Exception e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 46500
#include <iostream> 

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;
	int odd = 0, even = 0, quad = 0;

	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		if (n % 4 == 0) quad++;
		else if (n % 2 == 0) even++;
		else if (n % 2 != 0) odd++;
	}

	if ((even > 0 && odd <= quad) || (even == 0 && odd <= quad + 1))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <ctime>

using namespace std;

#define EPS 1e-8
#define PI acos(-1)
#define Vector Point

struct Point
{
    double x, y, r;
    Point(){}
    Point(double a, double b, double c) { x = a; y = b; r = c; }
    double mod2() { return x*x + y*y; }
    double mod()  { return sqrt(x*x + y*y); }
};

bool operator ==(const Point &a, const Point &b)
{
    return fabs(a.x - b.x) < EPS && fabs(a.y - b.y) < EPS;
}
bool operator !=(const Point &a, const Point &b)
{
    return !(a==b);
}
bool operator <(const Point &a, const Point &b)
{
    if(a.x != b.x) return a.x < b.x;
    return a.y < b.y;
}

bool XYorder(Point P1, Point P2)
{
	if(P1.x != P2.x) return P1.x < P2.x;
	return P1.y < P2.y;
}
bool YXorder(Point P1, Point P2)
{
	if(P1.y != P2.y) return P1.y < P2.y;
	return P1.x < P2.x;
}

double dist(const Point &A, const Point &B)
{
	return hypot(A.x - B.x, A.y - B.y) - A.r - B.r;
}

double R;

double closest_recursive(vector <Point> vx, vector <Point> vy)
{
	if(vx.size()==1) return 1e20;
	if(vx.size()==2) return dist(vx[0], vx[1]);
	
	Point cut = vx[vx.size()/2];
	
	vector <Point> vxL, vxR;
	for(int i=0; i<vx.size(); i++)
		if(vx[i].x < cut.x || (vx[i].x == cut.x && vx[i].y <= cut.y))
			vxL.push_back(vx[i]);
		else vxR.push_back(vx[i]);
	
	vector <Point> vyL, vyR;
	for(int i=0; i<vy.size(); i++)
		if(vy[i].x < cut.x || (vy[i].x == cut.x && vy[i].y <= cut.y))
			vyL.push_back(vy[i]);
		else vyR.push_back(vy[i]);
	
	double dL = closest_recursive(vxL, vyL);
	double dR = closest_recursive(vxR, vyR);
	double d = min(dL, dR);
	
	vector <Point> b;
	for(int i=0; i<vy.size(); i++)
		if(abs(vy[i].x - cut.x) <= d + 2*R + EPS)
			b.push_back(vy[i]);
	
	for(int i=0; i<b.size(); i++)
		for(int j=i+1; j<b.size() && (b[j].y - b[i].y) <= d + 2*R + EPS; j++)
			d = min(d, dist(b[i], b[j]));
	
	return d;
}
double closest(vector <Point> points)
{
	vector <Point> vx = points, vy = points;
	sort(vx.begin(), vx.end(), XYorder);
	sort(vy.begin(), vy.end(), YXorder);
	return closest_recursive(vx,vy);
}

int main()
{
	int n;
	while(cin>>n)
	{
		if(n == 0) break;
		R = 0;
		
		vector <Point> P(n);
		for(int i=0; i<n; i++){
			cin>>P[i].r>>P[i].x>>P[i].y;
			R = max(R, P[i].r);
		}
		printf("%.10lf\n", closest(P));
	}
	
	return 0;
}

Measured memory_bytes: 28000
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, L;
	cin >> N >> M >> L;
	int INF = (int)1 << 60;
	vector<vector<int> > D(N, vector<int>(N, INF));
	for (int i = 0; i < N; i++) {
		D[i][i] = 0;
	}
	int a, b, c;
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c;
		a--; b--;
		D[a][b] = c;
		D[b][a] = c;
	}
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			for (int k = 0; k < N; k++)
				D[j][k] = min(D[j][k], D[j][i] + D[i][k]);
	vector<vector<int> > E(N, vector<int>(N, INF));
	for (int i = 0; i < N; i++) {
		E[i][i] = 0;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i != j) {
				if (D[i][j] <= L) {
					E[i][j] = 1;
				}
			}
		}
	}
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			for (int k = 0; k < N; k++)
				E[j][k] = min(E[j][k], E[j][i] + E[i][k]);
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> a >> b;
		a--; b--;
		if (E[a][b] >= INF) {
			cout << -1 << endl;
		}
		else {
			cout << E[a][b] - 1 << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 1920
program main
  implicit none

  integer, parameter ::     i8 = selected_int_kind  ( 18 )

  integer ( kind = i8 ) :: nn, i, jdg
  integer ( kind = i8 ), allocatable, dimension ( : ) :: aa, rtn

  jdg = 1
  read *, nn
  allocate ( aa ( nn ) )

  read *, aa ( : )

  aa = iqsort ( aa )

  do i = 1, nn - 1
     if ( aa ( i + 1 ) == aa ( i ) ) then
        print *, "NO"
        jdg = -1
        exit
     end if
  end do

  if ( jdg == 1 ) then
     print *, "YES"
  end if
  
  
  
 contains
    recursive function iqsort ( ix ) result ( ires )
      integer ( 8 ), allocatable, dimension ( : ) :: ires
      integer ( 8 ),              dimension ( : ), intent(in)  :: ix
      integer :: k
      if ( size( ix ) <= 1 ) then 
        ires = ix
      else  
        k = ix ( size ( ix ) / 2 )
        ires = [ iqsort ( pack ( ix, ix < k ) ), pack ( ix, ix == k ), iqsort ( pack ( ix, ix > k ) ) ] 
      end if
    end function iqsort
    
end program main


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

typedef long long LL;

const int N = 50;
const int M = 250;

bool mat[N][N];

int n, m, s;
LL mod;

LL pow_mod(LL x, int p){
    LL s = 1;
    while(p){
        if(p & 1)   s = s * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return s;
}

int query(int a, int b, int c, int d){
    printf("? %d %d %d %d\n", a, b, c, d);
    fflush(stdout);
    int x;
    scanf("%d", &x);
    return x;
}

void solve2(int x, int y1, int y2, int s){
    if(s == 0 || y1 > y2)   return;
    if(s == y2 - y1 + 1){
        for(int i=y1; i<=y2; i++){
            mat[x][i] = 1;
        }
        return;
    }

    int mid = y1 + y2 >> 1;
    int ans = query(x, y1, x, mid);
    solve2(x, y1, mid, ans);
    solve2(x, mid+1, y2, s - ans);
}

void solve(int x1, int x2, int s){
    if(s == 0 || x1 > x2)  return;
    int area = (x2 - x1 + 1) * m;
    if(area == s){
        for(int i=x1; i<=x2; i++){
            for(int j=0; j<m; j++){
                mat[i][j] = 1;
            }
        }
        return;
    }
    if(x1 == x2){
        solve2(x1, 0, m-1, s);
    } else {
        int mid = x1 + x2 >> 1;
        int ans = query(x1, 0, mid, m-1);
        solve(x1, mid, ans);
        solve(mid+1, x2, s - ans);
    }
}

int main(){
    while(~scanf("%d %d %d %lld", &n, &m, &s, &mod)){
        memset(mat, 0, sizeof(mat));
        solve(0, n-1, s);

        LL ans = 0;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                if(mat[i][j]){
                    ans = (ans + pow_mod(2, i*m+j)) % mod;
                }
            }
        }
        printf("! %lld\n", ans);
        fflush(stdout);
    }
    return 0;
}


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

// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;

int main() {
  ll x, k, d;
  cin >> x >> k >> d;

  ll l = -x / d;
  ll ans;
  if (l < -k) {
    ans = min(abs(x - k * d), abs(x - (k - 2) * d));
  } else if (l > k) {
    ans = min(abs(x + k * d), abs(x + (k - 2) * d));
  } else {
    if (k % 2 == abs(l) % 2) {
      ll tmp = min(abs(x + (l - 2) * d), abs(x + (l + 2) * d));
      ans = min(abs(x + l * d), tmp);
    } else {
      ans = min(abs(x + (l + 1) * d), abs(x + (l - 1) * d));
    }
  }

  // mp::cpp_int X, K, D;
  // cin >> X >> K >> D;
  // mp::cpp_int L = -X / D;
  // mp::cpp_int ans;

  // if (X - K * D > 0) {
  //   ans = abs(X - K * D);
  // } else if (X + K * D < 0) {
  //   ans = abs(X + K * D);
  // } else {
  //   if (K % 2 == L )
  // }

  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

const uint64_t INF = static_cast<uint64_t>(-1);

struct VectorItem
{
  uint64_t w, v;
  VectorItem(uint64_t w = INF, uint64_t v = 0) : w(w), v(v) {}
};

istream& operator>>(istream &is, VectorItem &item)
{
  is >> item.w >> item.v;
  return is;
}

int main()
{
  uint64_t N, W;
  cin >> N >> W;

  vector<VectorItem> items(N);
  N_TIMES(n, N) { cin >> items[n]; }

  array<vector<uint64_t>, 2> dp;
  N_TIMES(i, 2) { dp[i] = vector<uint64_t>(W + 1, 0); }
  N_TIMES(n, N) {
    N_TIMES(w, W + 1) {
      dp[(n + 1) % 2][w] = max(dp[(n + 1) % 2][w], dp[n % 2][w]);

      if (w + items[n].w <= W) {
        dp[(n + 1) % 2][w + items[n].w] = max(
          dp[(n + 1) % 2][w + items[n].w], 
          max(
            dp[n % 2][w + items[n].w], 
            dp[n % 2][w] + items[n].v
          )
        );
      }
    }
  }
  cout << *max_element(dp[N % 2].begin(), dp[N % 2].end()) << endl;

  return 0;
}

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

signed main(void)
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	priority_queue<long double>a;
	for (int i = 0; i < n; i++) {
		long double x;
		cin >> x;
		a.push(-x);
	}
	while (a.size() > 1) {
		long double f = a.top(); a.pop();
		long double s = a.top(); a.pop();
		a.push((f + s) / 2);
	}
	cout << -a.top();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,k,c;
	cin >> n >> k >> c;
	char s[n];
	bool schedule[n];
	int lower[k],upper[k];
	rep(i,n){
		cin >> s[i];
		schedule[i] = s[i] == 'o';
	}
	int j=0,index=0;
	while(j<n && index < k){
		if(schedule[j]){
			lower[index]=j;
			j+=c;
          //cout << lower[index] << endl;
			index++;
          
		}
		j++;
	}
	j=n-1,index=0;
	while(j>=0 && index < k){
		if(schedule[j]){
			upper[index]=j;
			j-=c;
            //cout << upper[index] << endl;
			index++;
		}
		j--;
	}
	rep(i,k){
		if(lower[i]==upper[k-1-i])
			cout << lower[i]+1 << endl;
	}
}


Measured memory_bytes: 3456
i_l_s = input().split()
i_l = list(map(int, i_l_s))
 
hour = i_l[4]//60
min = i_l[4]%60
 
before = [i_l[0]+hour, i_l[1]+min]
after = [i_l[2], i_l[3]]
 
if(after[0]-before[0] ==0):
    print(after[1]-before[1])
else:
  result = after[1]-before[1] + 60*(after[0]-before[0])
  print(result)

Measured memory_bytes: 9228