akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int K;
    cin >> K;

    if (K % 2 == 0 || K % 5 == 0) {
        cout << "-1" << endl;
        return 0;
    }
    
    int ans = 1;
    int mod = 0;
    do
    {
        /* code */
        mod = 10 * mod + 7;
        mod %= K;
        if (mod == 0) {
            cout << ans << endl;
            break;
        }
        ans++;
    } while (true);
    

    return 0;
}


Measured memory_bytes: 3696
# 2019-11-14 17:27:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    x, a = [int(i) for i in sys.stdin.readline().split()]
    print(0 if x < a else 10)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){

  int m,f,r;

  while(1){
    scanf("%d %d %d",&m,&f,&r);
    if((m == -1) & (f == -1) & (r == -1)){
      break;
    }
    if((m == -1) | (f == -1) | ((m + f) < 30)){
      printf("F\n");
    }else if((m + f) >= 80){
      printf("A\n");
    }else if(((m + f) >= 65) & ((m + f) < 80)){
      printf("B\n");
    }else if(((m + f) >= 50) & ((m + f) < 65)){
      printf("C\n");
    }else if(((m + f) >= 30) & ((m + f) < 50)){
      if(r >= 50){
        printf("C\n");
      }else{
        printf("D\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 584
import sys

a, b = map(int, sys.stdin.readline().split())

if a > b:
    for i in range(a):
        print(b,end = "")
elif a < b:
    for i in range(b):
        print(a,end = "")
else:
    for i in range(a):
        print(b, end = "")

Measured memory_bytes: 3060
a = input().strip()
stack = []
area = 0
area_list = []

for i, slope in enumerate(a):
    if slope == '\\':
        stack.append(i)
    elif slope == '/' and len(stack) != 0:
        ip = stack.pop(len(stack)-1)
        area += (i - ip)
        a = i - ip
        while len(area_list) != 0 and area_list[len(area_list)-1][0] > ip:
            temp = area_list.pop(len(area_list)-1)
            a += temp[1]
        area_list.append([ip, a])
    
print(area)
print('{}'.format(len(area_list)), end='')
if len(area_list) != 0:
    print(' ', end='')
print(' '.join([str(i[1]) for i in area_list]))
    


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

int dp[5][4001];
int main(){
	int n;
	dp[0][0] = 1;
	for (int i = 0; i < 4;i++){
		for (int j = 0; j <= i * 1000;j++){
			for (int k = 0; k <= 1000;k++){
				dp[i + 1][j + k] += dp[i][j];
			}
		}
	}
	/*for (int i = 0; i < 10;i++){
		for (int j = 0; j < 10;j++){
			printf("%d ", dp[i][j]);
		}
		puts("");
	}*/
	while (cin >> n){
		printf("%d\n", dp[4][n]);
	}
	return 0;
}

Measured memory_bytes: 1204
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <string>
#include <functional>
#include <map>
#include <cstring>
#include <set>
#include <cmath>
using namespace std;

using ii = pair < int , int >;
using ti = tuple < int ,int ,int >;
using lint = long long;
using ll = pair < lint , lint >;

int main(){
	//freopen("in.txt","r",stdin);
	int n,a;
	scanf("%d%d",&n,&a);
	n%=500;
	if(n<=a)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main()
{
   IOS;
   int n;
   cin >> n;
   if(n%2==0)cout<<n/2<<endl;
   else
   {
       cout<<n/2+1<<endl;
   }
   
}


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

int main(){
  int n, k;
  std::cin >> n >> k;
  std::vector<int> h(n);
  long min = 10000000000;
  for(int i = 0; i < n; i++){
    std::cin >> h[i];
  }
  std::sort(h.begin(), h.end());
  for(int i = 0; i < n - k + 1; i++){
    if(min > h[i + k - 1] - h[i]) min = h[i + k - 1] - h[i];
  }
  std::cout << min << std::endl;
}

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

#define boost ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;
using LL = long long;

constexpr int MAXN = 1e5 + 5;

template <typename T>
inline void read(T &x) {
    int f = 1;
    x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

int n, val[4], u[MAXN], v[MAXN];
string opt[MAXN];
vector<char> choice;

int main() {
    // freopen("test.in", "r", stdin);
    // freopen("test.out", "w", stdout);
    boost;
    cin >> n;
    cin >> val[1] >> val[2] >> val[3];
    for (int i = 1; i <= n; i++) {
        cin >> opt[i];
        if (opt[i] == "AB")
            u[i] = 1, v[i] = 2;
        else if (opt[i] == "AC")
            u[i] = 1, v[i] = 3;
        else
            u[i] = 2, v[i] = 3;
    }
    for (int i = 1; i < n; i++) {
        if (!val[u[i]] && !val[v[i]]) {
            cout << "No" << endl;
            return 0;
        }
        if (val[u[i]] < val[v[i]]) {
            val[u[i]]++, val[v[i]]--;
            choice.push_back(u[i] - 1 + 'A');
        } else if (val[u[i]] > val[v[i]]) {
            val[u[i]]--, val[v[i]]++;
            choice.push_back(v[i] - 1 + 'A');
        } else {
            val[u[i]]++, val[v[i]]--;
            if (!val[u[i + 1]] && !val[v[i + 1]]) {
                val[u[i]]--, val[v[i]]++;
            } else {
                choice.push_back(u[i] - 1 + 'A');
                continue;
            }
            val[u[i]]--, val[v[i]]++;
            if (!val[u[i + 1]] && !val[v[i + 1]]) {
                val[u[i]]++, val[v[i]]--;
            } else
                choice.push_back(v[i] - 1 + 'A');
        }
    }
    if (!val[u[n]] && !val[v[n]]) {
        cout << "No" << endl;
        return 0;
    }
    if (val[u[n]]) choice.push_back(v[n] - 1 + 'A');
    else choice.push_back(u[n] - 1 + 'A');
    cout << "Yes" << endl;
    for (auto &c : choice) cout << c << endl;
    return 0;
}

Measured memory_bytes: 7704
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
const ll mod = 1000000007;
#define int ll
int m, n, T, a, b;
pair <int, int> t[200002];
 
ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}
 
int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
   	cin>>n>>a>>b;
   	if((a-b)%2==0) cout<<(b-a)/2;
   	else cout<<min((a+b-1)/2, n-b+(b-a+1)/2);
}

Measured memory_bytes: 256
#include <stdio.h>

int r[200000];

int root(int i) {
   if (r[i]<0) return i;
   else        return root(r[i]);
}

int main(){
   int i,ans,n,m,a,b,ra,rb;

   scanf("%d %d",&n,&m);
   for (i=0;i<n;i++) r[i]=-1;
   for (i=0;i<m;i++) {
      scanf("%d %d",&a,&b);
      a--;b--;
      ra=root(a);rb=root(b);
      if (ra!=rb) 
         if (r[ra]>r[rb]) {
            r[rb]+=r[ra];
            r[ra]=rb;
         } else {
            r[ra]+=r[rb];
            r[rb]=ra;
         }
   }
   ans=0;
   for (i=0;i<n;i++)
      if (ans>r[i]) ans=r[i];
   printf("%d\n",-ans);
   return 0;
}


Measured memory_bytes: 2460
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vi = vector<int>;
int main(){
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if(abs(A - B) > (V - W)*T){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;

int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k){
        cout<<k<<endl;
    }else if(a+b>=k){
        cout<<a<<endl;
    }else{
        ll minu=k-(a+b);
        cout<<a-minu<<endl;
    }

}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> num(N, 0);
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        num[a - 1]++;
    }
    sort(num.begin(), num.end(), greater<int>());
    int ans = 0;
    for(int i = K; i < N; ++i) {
        if(num[i] == 0)
            break;
        ans += num[i];
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
int xz[200005];
int main()
{
    int h,w,m;
    scanf("%d%d%d",&h,&w,&m);
    int j=1;while(j<=h)
    {
        xz[j]=w+1;
        j++;
    }
    int i=1;while(i<=m)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        xz[x]=min(xz[x],y);
        i++;
    }
    int r=1;
    i=1;while(i<=h)
    {
        if(i==h||xz[i+1]<=r)
        {
            cout<<i<<endl;
            break;
        }
        r++;
        if(xz[i+1]==r) r--;
        i++;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <ctype.h>
 
int main(void)
{
  int len,i;
  char m;
 
  while((m=getchar())!=EOF){
 
    if(isupper(m)){
        printf("%c",tolower(m));
      }
    else {
        printf("%c",toupper(m));
      }
  }
       
  return 0;
}

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

const int N = 1e5 + 5;

int n, m;
vector<pair<int,long long>> g[N];
long long a[N];
bool was[N], color[N];
vector<int> ver;
vector<long long> edge;

void out(int z) { cout << z << '\n'; exit(0); } 

void solve(int u,long long z) {
	a[u] = z; was[u] = 1;
	for (auto gg : g[u]) {
		int v = gg.first; long long w = gg.second;
		if (was[v]) { if (a[u] + a[v] != w) out(0); }
		else {
			solve(v, w - z);
		}
	}
}

void dfs(int u,int c) {
	was[u] = 1, color[u] = c;
	ver.push_back(u);
	for (auto gg : g[u]) {
		int v = gg.first; long long w = gg.second;
		if (was[v]) {
			if (color[u] == color[v]) {
				edge.push_back(w);
				reverse(edge.begin(), edge.end());
				reverse(ver.begin(), ver.end());
				while (ver.back() != v) ver.pop_back(), edge.pop_back();
				// for (auto z : ver) cout << z << ' '; cout << '\n';
				// for (auto z : edge) cout << z << ' '; cout << '\n';
				long long sum = 0;
				for (auto z : edge) sum += z;
				if (sum & 1ll) out(0); sum /= 2;
				for (int i = 1; i < edge.size(); i += 2) sum -= edge[i];
				memset(was, 0, sizeof was);
				solve(ver.back(), sum);
				// for (int i = 1; i <= n; ++i) cout << a[i] << ' '; cout << '\n';
				for (int i = 1; i <= n; ++i) if (a[i] <= 0ll) out(0);
				out(1);
			}
		}
		else {
			edge.push_back(w);
			dfs(v, c ^ 1);
			edge.pop_back();
		}
	}
	ver.pop_back();
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		int u, v;long long w; cin >> u >> v >> w;
		g[u].push_back({v, w}), g[v].push_back({u, w});
	}  
	dfs(1, 0);
	memset(was, 0, sizeof was);
	solve(1, 0);
	long long l = -2e9, r = 2e9;
	for (int i = 1; i <= n; ++i) {
		if (color[i]) l = max(l, -a[i] + 1);
		else r = min(r, a[i] - 1);
	}
	out(max(0ll, r - l + 1ll));
}

Measured memory_bytes: 19568
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

long long P = 1000000007;
struct N {
  int i, j;
  long long v;
};
vector<N> ns;
vector<vector<int>> p;
int h, w, n;

class C {
public:
  int n;
  vector<long long> fac, inv, facInv;
  long long power(long long e, long long x) {
    if (x == 0)
      return 1;
    if (x == 1)
      return e;
    if (x % 2 == 0)
      return power((e * e) % P, x / 2);
    return (e * power(e, x - 1)) % P;
  }
  C(int n_) {
    n = n_;
    fac.resize(n + 1);
    inv.resize(n + 1);
    facInv.resize(n + 1);
    fac[0] = fac[1] = 1;
    for (int i = 2; i <= n; i++)
      fac[i] = (i * fac[i - 1]) % P;
    inv[0] = inv[1] = 1;
    for (int i = 2; i <= n; i++)
      inv[i] = power(i, P - 2);
    facInv[0] = facInv[1] = 1;
    for (int i = 2; i <= n; i++)
      facInv[i] = (inv[i] * facInv[i - 1]) % P;
  }
  long long comb(int N, int K) {
    if (N < K || K < 0 || N < 0)
      return 0;
    if (N == 0 || K == 0 || K == N)
      return 1;
    return ((fac[N] * facInv[K]) % P * facInv[N - K]) % P;
  }
  long long hcomb(int N, int K) {
    if (N == 0 && K == 0)
      return 1;
    return comb(N + K - 1, K);
  }
  long long mul(long long a, long long b) { return (a * b) % P; }
  long long add(long long a, long long b) { return (a + b) % P; }
  long long div(long long a, long long b) { return (a * power(b, P - 2)) % P; }
};
C cmp(202020);

int main() {
  cin >> h >> w >> n;
  ns.resize(n + 2);
  p.resize(n + 2);
  ns[0] = N{0, 0, 1};
  for (int i = 1; i <= n; i++) {
    cin >> ns[i].i >> ns[i].j;
    ns[i].i--;
    ns[i].j--;
    ns[i].v = 0;
  }
  ns[n + 1] = N{h - 1, w - 1, 0};
  sort(ns.begin(), ns.end(), [](const N &l, const N &r) {
    if (l.i == r.i)
      return l.j < r.j;
    return l.i < r.i;
  });
  for (int i = 0; i < n + 2; i++)
    for (int j = i + 1; j < n + 2; j++) {
      if (ns[i].i <= ns[j].i && ns[i].j <= ns[j].j)
        p[i].push_back(j);
    }
  for (int i = 0; i <= n; i++) {
    for (auto &j : p[i]) {
      int h = (ns[j].i - ns[i].i);
      int w = (ns[j].j - ns[i].j);
      long long diff =
          (ns[i].v *
           cmp.mul(cmp.fac[h + w], cmp.mul(cmp.facInv[h], cmp.facInv[w]))) %
          P;
      if (i != 0) {
        ns[j].v += P - diff;
      } else {
        ns[j].v += diff;
      }
      ns[j].v %= P;
    }
  }
  cout << ns[n + 1].v << endl;

  return 0;
}


Measured memory_bytes: 29312
#include <stdio.h>
int main (){
	int n,k,h=1;
	scanf("%d %d", &n, &k);
	for (int i=0 ;i<n ;i++)
	{
		if(h<k)
		{
			h*=2;
		}
		else 
		{
			h+=k;
		}
	}
printf("%d",h);
return 0;
}


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

using namespace std;

template <class T>
class SegmentTree
{
private:
	int n; // 葉の数
	vector<T> data; // データを格納するコンテナ
	T def;
	function<T(T, T)> operation; // 区間クエリで使う処理
	function<T(T, T)> update; // 点更新で使う処理

	// 区間[a, b)の総和, ノードk=[l, r)に着目している
	T _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return def;
		if (a <= l && r <= b) return data[k];
		else {
			T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
			T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
			return operation(c1, c2);
		}
	}

public:
	// _n: 必要サイズ, _def: 初期値かつ単位元, _operation: クエリ関数, _updata: 点更新関数
	SegmentTree(int _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
		: n(_n), def(_def), operation(_operation), update(_update) {
		n = 1; while (n < _n) n *= 2;
		data = vector<T>(2 * n - 1, def);
	}

	// 場所iの値をxで更新
	void change(int i, T x) {
		i += n - 1;
		data[i] = update(data[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}

	// 半開区間[a, b)でクエリを実行
	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}

	// 添字でアクセス
	T operator[](int i) {
		return data[i + n - 1];
	}
};

void solve(const int & N, const int & Q, SegmentTree<long long> & st) {
	int c, x, y; cin >> c >> x >> y; // c: コマンド(0: 点更新, 1: 区間クエリ)

	if (c == 0) st.change(x, y);
	else {
		cout << st.query(x, y + 1) << endl;
	}
}

int main(void) {
	int N, Q; cin >> N >> Q;
	SegmentTree<long long> st(N, (1LL << 31) - 1
		, [](long long a, long long b) {return min(a, b); }
		, [](long long d, long long x) {return x; });

	rep(q, Q) solve(N, Q, st);

	return 0;
}


Measured memory_bytes: 4948
N = int(input())
g = 0
for _ in range(N):
    x, k = map(int, input().split())
    while x % k != 0:
        x = x - (x // k + 1) * max(1, (x - x // k * k) // (x // k + 1))
    g ^= x // k
print('Takahashi' if g != 0 else 'Aoki')

Measured memory_bytes: 69924
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	int n,i,j,a=0,b=0,c=0;
	cin>>n;
	string s;
	cin>>s;
	for(i=0;i<n;++i)
	{
		if(s[i]=='R')		++a;
		if(s[i]=='G')		++b;
		if(s[i]=='B')		++c;
	}
	ll ans = 1ll*a*b*c,cnt=0ll;
//	cout<<ans<<"\n";
	for(i=0;i<n;++i)
	{
		for(j=i+1;j<n;++j)
		{
			if(j+j-i<n&&s[i]!=s[j])
			{
				if(s[j+j-i]!=s[i]&&s[j+j-i]!=s[j])
				{
				//	printf("%d %d %d\n",i,j,j+j-i);
					++cnt;
				}
			}
		}
	}
	printf("%lld",ans-cnt);
}

Measured memory_bytes: 3732
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	int c[4][4];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>c[i][j];
		}
	}
	if(c[0][0]-c[0][1]==c[1][0]-c[1][1] && c[1][0]-c[1][1]==c[2][0]-c[2][1] && c[0][1]-c[0][2]==c[1][1]-c[1][2] && c[1][1]-c[1][2]==c[2][1]-c[2][2])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
  int n, m; cin >> n >> m;
  vector<vector<bool>> g(n, vector<bool>(m));
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    for (int j = 0; j < m; j++)
      g[i][j] = s[j] == '.';
  }
  
  auto compress = [&](int i, int j) -> int {
    return i * m + j;
  };
  
    int N = n * m;

  const int INF = 1 << 20;
  vector<vector<int>> dist(N, vector<int>(N, INF));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m - 1; j++) {
      if (g[i][j] && g[i][j + 1]) {
        dist[compress(i, j)][compress(i, j+1)] = 1;
        dist[compress(i,j+1)][compress(i,j)] = 1;
      }
    }
  }
  for (int j = 0; j < m; j++) {
      for (int i = 0; i < n - 1; i++) {
          if (g[i][j] && g[i+1][j]) {
            dist[compress(i,j)][compress(i+1,j)] = 1;
            dist[compress(i+1,j)][compress(i,j)] = 1;
          }
      }
  }
  for (int i = 0; i < N; i++)
    dist[i][i] = 0;
  
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      if (dist[i][j] != INF) ans = max(ans, dist[i][j]);
  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define int long long int
#define mpp make_pair
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MOD 100000007
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
const int MAXN = 1e5+5;
#define MAXI 2e18+3
#define all(v) v.begin(), v.end()
#define endl "\n"
# define PI 3.14159265358979323846



signed main(){
 
    fast;
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    string s, t;
    int i;
    cin>>s>>t;
    if(s.length()+1==t.length()){
    	int flag=1;
    	for(i=0;i<s.length();i++){
    		if(s[i]!=t[i])
    		{
    			flag=0;
    			break;
    		}
    	}
    	if(!flag){
    		cout<<"No"<<endl;
    	}
    	else{
    		cout<<"Yes"<<endl;
    	}
    }
    else{
    	cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int ans = m + f;
			if (m == -1 && f == -1 && r == -1) {
				break;
			} else if (m == -1 || f == -1) {
				System.out.println("F");
			} else {
				if (ans >= 80) {
					System.out.println("A");
				} else if (ans >= 65) {
					System.out.println("B");
				} else if (ans >= 50) {
					System.out.println("C");
				} else if (ans >= 30) {
					if (r >= 50) {
						System.out.println("C");
					} else {
						System.out.println("D");
					}
				} else {
					System.out.println("F");
				}
			}
		}
		sc.close();
	}

}



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

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  char dif = 'A' - 'a';
  printf("%c%c%c\n",a[0] + dif,b[0] + dif,c[0] + dif);
  return 0;
}


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

int main()
{
    int m = 0;
    int ans = 0;
    for(int i=0; i<5; i++){
        int t;
        cin >> t;
        if(t % 10){
            m = max(m, 10 - t % 10);
            t = (t / 10 + 1) * 10;
        }
        ans += t;
    }
    cout << ans - m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (n > k * 2) {

	}
	return fac[n] / (fac[k] * fac[n - k]);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
vector<vector<ll>>tree;
ll cnt[202020];
ll n, A, B, C;
vector<ll>L;

ll dfs(ll depth,ll a,ll b,ll c) {
	if (depth == n) {
		if (!a || !b || !c)return INF;
		return abs(a - A) + abs(b - B) + abs(c - C);
	}
	ll res = dfs(depth + 1, a, b, c);
	res = min(res, dfs(depth + 1, a + L[depth], b, c) + (a ? 10 : 0));
	res = min(res, dfs(depth + 1, a, b + L[depth], c) + (b ? 10 : 0));
	res = min(res, dfs(depth + 1, a, b, c + L[depth]) + (c ? 10 : 0));
	return res;
}

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	cin >> n >> A >> B >> C;
	L.resize(n);
	rep(i, n) {
		cin >> L[i];
	}
	cout << dfs(0, 0, 0, 0) << endl;
	return 0;
}


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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 100000000000000
#define MOD 10007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

  int A,B,Q;
  cin>>A>>B>>Q;
  vector<ll>s(A),t(B),x(Q);
  for(int i=0;i<A;i++)cin>>s[i];
  for(int i=0;i<B;i++)cin>>t[i];
  for(int i=0;i<Q;i++)cin>>x[i];

  for(int i=0;i<Q;i++){
    ll cost=INF;
    int sl=-1,sr=A;
    int sm;
    while(sr-sl>1){
      sm=(sl+sr)/2;
      if(s[sm]<x[i])sl=sm;
      else sr=sm;
    }
    int tl=-1,tr=B;
    int tm;
    while(tr-tl>1){
      tm=(tl+tr)/2;
      if(t[tm]<x[i])tl=tm;
      else tr=tm;
    }
    //右sから左t
    if(sr!=A&&tl!=-1) cost=min(cost,2*(s[sr]-x[i])+x[i]-t[tl]);
    //右tから左s
    if(tr!=B&&sl!=-1) cost=min(cost,2*(t[tr]-x[i])+x[i]-s[sl]);
    
    //左sから右t
    if(sl!=-1&&tr!=B) cost=min(cost,2*(x[i]-s[sl])+t[tr]-x[i]);
   
    //左tから右s
    if(tl!=-1&&sr!=A) cost=min(cost,2*(x[i]-t[tl])+s[sr]-x[i]);

    
    //左sから左t
    //左tから左s
    if(sl!=-1&&tl!=-1) cost=min(cost,x[i]-min(s[sl],t[tl]));

    
    //右sから右t
    //右tから右s
    if(sr!=A&&tr!=B) cost=min(cost,max(s[sr],t[tr])-x[i]);

    cout<<cost<<endl;
  }
  return 0;
}


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

set<int> calc(string &a, string &b){
    int A = a.size(), B = b.size();
    set<int> st;
    rep(i,A+1){
        bool ok = true;
        rep(j,B){
            if (i+j >= A) break;
            if (a[i+j] == '?' || b[j] == '?') continue;
            if (a[i+j] != b[j]) ok = false;
        }
        if (ok) st.insert(i);
    }
    return st;
}

int main(void){
    vector<string> vs(3);
    rep(i,3) cin >> vs[i];
    int res = 6000;
    int pos[] = {0,1,2};
    do {
        string &a = vs[pos[0]], &b = vs[pos[1]], &c = vs[pos[2]];
        int A = a.size(), B = b.size(), C = c.size();
        auto fab = calc(a,b), fbc = calc(b,c), fac = calc(a,c);
        for (int x : fab) {
            rep(y, max(B+1, A-x+1)){
                if (y <= B && !fbc.count(y)) continue;
                if (x+y >= A || fac.count(x+y)) {
                    res = min(res, max({A, x+B, x+y+C}));
                }
            }
        }
    } while(next_permutation(pos, pos+3));
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
  string N;
  cin >> N;

  int up = 0, num = 0;
  ll ans = 0;

  for(ll i=N.size()-1; i>=0; i--) {
    num = (N[i] - '0') + up;

    if(num<5) {
      ans += num;
      up = 0;
    } else if(num==5) {
      if(N[i-1]-'0'>4 && i>0) {
        ans += 10 - num;
        up = 1;
      } else {
        ans += num;
        up = 0;
      }
    } else {
      ans += 10 - num; // おつり
      up = 1;
    } 

    //cout << N[i] << ' ' << ans << endl;
  }

  if(up==1) {
    ans++;
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 1412
#include<stdio.h>
int main()
{
    int i;
    char a;
    scanf("%c", &a);
 
    if((a>= 'a') && (a<='z'))
    {
        printf("a\n");
    }
    else
    {
        printf("A\n");
    }
 
  return 0;
}


Measured memory_bytes: 1592
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var sums = new Array(N);
  var output = 0;
  for(var i = 0; i < N; i++){
    var tmp = nextIntArray();
    var A = tmp[0];
    var B = tmp[1];
    sums[i] = A + B;
    output -= B;
  }
  sums.sort(function(a,b){
  	return b - a;
  });
  for(var i = 0; i < N; i += 2){
    output += sums[i];
  }
  myout(output);
}


Measured memory_bytes: 59668
#include <cstdio>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 50005;
const ll mod = 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;

int n,m;
int a[maxn];
char s[maxn];

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int ans=a^b^c;
    printf("%d\n",ans);
}


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

using namespace std;

int main(void) {
    long long a, b, k;
    cin >> a >> b;
    if ((a - b) % 2 == 0) {
        k = (a + b) / 2;
        cout << k << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      for(char c='a';c<'z';c++)if(c==s.charAt(0))System.out.println(++c);
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}
class Pair{
    int a,b;

    Pair(int a, int b){
      this.a = a;
      this.b = b;
    }
}

Measured memory_bytes: 21332
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

ab = abs(a - b)
ac = abs(a - c)
ad = abs(a - d)
ae = abs(a - e)
bc = abs(b - c)
bd = abs(b - d)
be = abs(b - e)
cd = abs(c - d)
de = abs(d - e)


if ab > k or ac > k or ad > k or ae > k or bc > k or bd > k or be > k or cd > k or de > k:
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3064
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, M, X = rl()
C = []
As = []
for i in range(N):
	A = rl()
	C.append(A[0])
	As.append(A[1:])

def is_ok(b):
	sums = [0] * M
	for j in range(M):
		for i, v in enumerate(b):
			if v == 0: continue
			sums[j] += As[i][j]
		if sums[j] < X:
			return False
	return True

def cost(b):
	c = 0
	for i, v in enumerate(b):
		if v == 0: continue
		c += C[i]
	return c

import itertools
ans = float('inf')
for b in itertools.product([0, 1], repeat = N):
	if is_ok(b):
		ans = min(ans, cost(b))
if ans == float('inf'):
	print(-1)
else:
	print(ans)


Measured memory_bytes: 69300
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)

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

#define MAX 50
int brd[MAX][MAX];
int h, w;

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

int dfs(int y, int x)
{
	if (!(0 <= y && y < h)) return 0;
	if (!(0 <= x && x < w)) return 0;
	if (brd[y][x] == 0) return 0;
	brd[y][x] = 0;
	rep(d, 8) dfs(y+dy[d], x+dx[d]);
	return 1;
}

int main(void)
{
	while (cin >> w >> h, w|h) {
		rep(j, h) rep(i, w) cin >> brd[j][i];

		int cnt = 0;
		rep(j, h) rep(i, w) cnt += dfs(j, i);
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();

    let mut count: i32 = 0;
    let mut tmp: i32 = 0;

    for i in 0..s.len() {
        match s[i] {
            'A' | 'C' | 'G' | 'T' => tmp = tmp + 1,
            _ => tmp = 0,
        }
        if tmp > count {
            count = tmp;
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int K,N,M,A[100001],MAX=0,cnt=0,sum=0,B[100],C[100001];
    cin >> N >> K;

    for(int i=0;i<N;i++){
        cin >> A[i];
        C[i] = A[i];
    }
    for(int i=0;i<100;i++)
        B[i] = 0;
    for(int i=0;i<N;i++){
        int j =0;
        while(A[i] > 0){
            if(A[i] % 2 == 1)
                B[j]++;
            A[i] /= 2;
            j++;
        }
    }
    long long int X=0;
    for(int i=62;i>=0;i--){
        if(B[i] <= N/2){
            if(((X | (1LL) << i)) <= K)
                X |= (1LL) << i;
        }
    }
    long long int res = 0;
    for(int i=0;i<N;i++)
        res += C[i] ^ X;
    
    cout << res << endl;
    return 0;
}

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

int main(){
    ll key = 1;
    string s, sf, sb;
    cin >> s;
    ll q;
    cin >> q;

    rep(i,q){
        ll t;
        cin >> t;
        if(t == 1)key*=-1;
        else{
            ll t2; char s2;
            cin >> t2 >> s2;
            if(t2 == 1){
                if(key == 1){
                    sf.push_back(s2);
                    //s = s2 + s;
                }else{
                    sb.push_back(s2);
                    //s = s + s2;
                }
            }else{
                if(key == 1){
                    sb.push_back(s2);
                    //s = s + s2;
                }else{
                    sf.push_back(s2);
                    //s = s2 + s;
                }
            }
        }
    }
    reverse(sf.begin(), sf.end());
    s = sf + s + sb;
    if(key == -1)reverse(s.begin(), s.end());
    cout << s << endl;

}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;

    reverse(S.begin(), S.end());

    string word[4] = {"maerd", "remaerd", "esare", "resare"};

    int i = 0;
    while (true) {
        if (i == S.size()) break;
        bool ok = false;
        rep(j, 4) {
            string w = word[j];
            if (i + w.size() > S.size()) continue;

            bool ok2 = true;
            rep(k, w.size()) {
                if (S[i + k] != w[k]) ok2 = false;
            }
            if (ok2) {
                ok = ok2;
                i += w.size();
                break;
            }
        }

        if (!ok) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> v;
    int dp[n+1];
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
   
    
    
    for(int i=2;i<n;i++){
        
        for(int j=1;j<=k;j++){
        if(i-j>=0){
        dp[i]=min(dp[i-j]+abs(v[i]-v[i-j]),dp[i]);
        }
        }
       // cout<<dp[i];
    }
    cout<<dp[n-1];
 
}

Measured memory_bytes: 1148
<?php
  
 fscanf(STDIN,"%d",$n);
 $a_li = array();
 for($i=0;$i<$n;$i++){
   $a_li[] = trim(fgets(STDIN));
 }

//print_r($a_li);
$index = $a_li[0];
if($index==2){
  echo "1\n";
  exit;
}
 for($i=1;$i<10**6;$i++){
   //echo $a_li[$index-1]."\n";
   if($a_li[$index-1]==2){
     echo ($i+1)."\n";
     exit;
   }
   $index = $a_li[$index-1];
 }

echo "-1\n";
 

Measured memory_bytes: 12792
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,i,l[11],ans;
void dfs(int x,int A,int B,int C,int s){
	if (x>n){
		if (A && B && C) ans=min(ans,s+abs(a-A)+abs(b-B)+abs(c-C));
		return;
	}
	dfs(x+1,A,B,C,s);
	dfs(x+1,A+l[x],B,C,s+10*(A>0));
	dfs(x+1,A,B+l[x],C,s+10*(B>0));
	dfs(x+1,A,B,C+l[x],s+10*(C>0));
}
int main(){
	ans=1e9;
	scanf("%d%d%d%d",&n,&a,&b,&c);
	for (i=1;i<=n;i++) scanf("%d",&l[i]);
	dfs(1,0,0,0,0);
	printf("%d",ans);
}

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

using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  
 if(a<=c &&b<=c) cout<<a+b;
 else if(a<=b && c<=b) cout<<a+c;
  else if(b<=a && c<=a) cout<<b+c;
  
  return 0;
}
  


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

int main() {
  // int A,B,C;

  // cin >> A >> B >> C;
  // if (A == B  && B == C && C == A) {
  //   cout << "No" << endl;
  // } 
  // else if (A != B && B != C && A != C)
  // {
  //   cout << "No" << endl;
  // }
  // else {
  //   cout << "Yes" << endl;
  // }
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  string ans = "APPROVED";
  for (int i = 0; i < N; i++)
  {
    if (A.at(i) % 2 != 0) {
      continue;
    }
    if (A.at(i) % 3 == 0 || A.at(i) % 5 == 0) {
      continue;
    } else {
      ans = "DENIED";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
a,n,r;
main(b,c){
  for(;~scanf("%d",&n);a=r=!printf("%d\n",r))
      for(;a<10;a++)
          for(b=0;b<10;b++)
              for(c=0;c<10;c++)
                  r+=n-a-b-c>=0&n-a-b-c<10;
}

Measured memory_bytes: 0
#include<stdio.h>
int min(int a,int b){return a>b?b:a;}
int abs(int a){return a<0?-a:a;}
int main(){
	int a;
	scanf("%d",&a);
	while(a--){
		int b,c;
		scanf("%d:%d",&b,&c);
		int hun=12*c;
		int ji=b*60+c;
		int ans=min(abs(hun-ji),720-abs(hun-ji));
		if(ans>=180)printf("safe\n");
		else if(ans>=60)printf("warning\n");
		else printf("alert\n");
	}
}

Measured memory_bytes: 0
A,B,C,D = map(int,input().split())
line1 = list(range(A,B))
line2 = list(range(C,D))
line1_line2_and = set(line1) & set(line2)
line1_line2_and_list = list(line1_line2_and)
botton = len(line1_line2_and_list) 
print(botton)

Measured memory_bytes: 3060
//Volume1-0104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//initialization
        String[] s;
        int      x,y,i;
        int [][] map;
        char[][] mat;
        boolean  loop;

        //input
        Scanner sc = new Scanner(System.in);

        while(true){
        	s = sc.nextLine().split("\\s");
        	y = Integer.parseInt(s[0]);
        	x = Integer.parseInt(s[1]);
        	if(x == 0 && y == 0){break;}
        	mat = new char[y][x];
        	map = new int [y][x];
        	for(i=0;i<y;i++){mat[i] = sc.nextLine().toCharArray();}
        	x=0;y=0;
        	loop = false;
        	out:while(true){
        		if(map[y][x] == 1){loop = true; break;}
        		else              {map[y][x] = 1;     }
        		switch (mat[y][x]){
        			case '>' : { x++; break; }
        			case '<' : { x--; break; }
        			case 'v' : { y++; break; }
        			case '^' : { y--; break; }
        			case '.' : { break out;  }
        		}
        	}
        	if(loop){System.out.println("LOOP");     }
        	else    {System.out.println(x + " " + y);}
        }
	}
}

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

using namespace std;

#define fi first
#define sc second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define up(x, v) upper_bound(all(x), v)
#define low(x, v) lower_bound(all(x), v)
#define bin(x, v) binary_search(all(x), v)
#define FOR(k, a, b) for(int k = (a); k < (b); ++k)
#define ROF(k, a, b) for(int k = (a); k > (b); --k)
#define pq priority_queue

typedef long long ll;
typedef unsigned long long ull;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

int main() {

	int n;

	ios_base :: sync_with_stdio(false);
	cin.tie(nullptr);

	cin >> n;

	vi x(n);

	FOR(k, 0, n) cin >> x[k];

	sort(all(x));

	int k = 1;

	while(k < n && x[k] > x[k - 1]) ++k;

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

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

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

int w,h;
string p[65];
int cnt,id[65][15];
vector<double> ps[160],bottom[160];
vector<int> G[160];
bool stable;
using P = pair<double,int>;

void dfs(int y, int x, int _id) {
  id[y][x] = _id;
  ps[_id].push_back(x+0.5);
  REP(i,3) {
    int ny = y+dy[i];
    int nx = x+dx[i];
    if (IN(ny,0,h-1) && IN(nx,0,w-1) && p[ny][nx] == p[y][x] && id[ny][nx] < 0) {
      dfs(ny,nx,_id);
    }
  }
}


P get_g(int _id) {
  double g = 0;
  int s = 4;
  for (auto p : ps[_id]) g += p;
  for (auto i : G[_id]) {
    P tmp = get_g(i);
    g += tmp.first*tmp.second;
    s += tmp.second;
  }
  g /= s;
  if (!(bottom[_id].front() < g && g < bottom[_id].back()+1)) {
    stable = false;
  }
  return P(g,s);
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while (cin >> w >> h, w) {
    REP(i,h) cin >> p[i];
    cnt = 0;
    MINUS(id);
    REP(i,160) {
      ps[i].clear();
      bottom[i].clear();
      G[i].clear();
    }
    REP(i,h) REP(j,w) {
      if (p[i][j] == '.' || id[i][j] >= 0) continue;
      dfs(i,j,cnt);
      cnt++;
    }
    int start_id = -1;
    REP(i,h) REP(j,w) {
      if (p[i][j] == '.') continue;
      if (i+1 == h || (p[i+1][j] != '.' && p[i+1][j] != p[i][j])) {
        bottom[id[i][j]].push_back(j);
        if (i+1 < h) {
          G[id[i+1][j]].push_back(id[i][j]);
        } else {
          start_id = id[i][j];
        }
      }
    }
    REP(i,cnt) {
      UNI(bottom[i]);
      UNI(G[i]);
    }
    stable = true;
    REP(i,cnt) P g = get_g(i);
    cout << (stable ? "STABLE" : "UNSTABLE") << endl;
  }

  return 0;
}


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


int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int res = INT32_MAX;
    for (int i = 0; i <= 100000; i++) {
        res = min(res, 2 * C * i + A * max(0, X - i) + B * max(0, Y - i));
    }

    cout << res << endl;
    return 0;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    rep(i,n){
        int h;
        cin>>h;
        if(h>=k) ans++;
    }
    cout<< ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Rep(i,j,n) for(int i=j; i<n; i++)
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int a,b; cin >> a >> b;
    cout << (b-a-1)*(b-a)/2-a << endl;
    return 0;
}

Measured memory_bytes: 3588
# coding: utf-8
# Here your code !
s = input()
q = int(input())

for i in range(q):
    line = input().split()
    
    if len(line) == 4:
        com,a,b,r = line
        a,b = int(a),int(b)
        s = s[:a] + r + s[b+1:]
    else:
        com,a,b = line
        a,b = int(a),int(b)
        if com == "print":
            print(s[a:b+1])
        else:
            sab = s[a:b+1]
            s = s[:a] + sab[::-1] + s[b+1:]

Measured memory_bytes: 7652
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i,j;
  int n;
  cin>>n;
  ll x=0,y=0;
  rep(i,n){
    ll t,a;
    cin>>t>>a;
    ll i=max((ll)1, max(x/t,y/a));
    while(x>t*i||y>a*i)i++;
    x=t*i;
    y=a*i;
  }
  cout<<x+y<<endl;
}

Measured memory_bytes: 256
h, w, n = map(int, input().split())
ar, ac = map(int, input().split())
s = input()
t = input()
r = ac
l = ac
u = ar
d = ar
ans = False

for i in range(n):
    if s[i] == "R":
        r += 1
    if s[i] == "L":
        l -= 1
    if s[i] == "U":
        u -= 1
    if s[i] == "D":
        d += 1
    if l==0 or r==w+1 or u==0 or d==h+1:
        print("NO")
        ans = True
        break
        
    if t[i] == "R" and l != w:
        l += 1
    if t[i] == "L" and r != 1:
        r -= 1
    if t[i] == "U" and d != 1:
        d -= 1
    if t[i] == "D" and u != h:
        u += 1
 
if ans != True:
    print("YES")

Measured memory_bytes: 3888