akhauriyash/Code-Regression huggingface dataset:
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val branches = Array(n + 1) { mutableListOf<Pair<Int, Int>>() }//行先、枝番号
    val colors = Array(n + 1) { 0 }
    (1 until n).forEach {
        val (a, b) = readLine()!!.split(' ').map(String::toInt)
        branches[a].add(Pair(b, it))
        branches[b].add(Pair(a, it))
    }

    val queue = ArrayDeque<Pair<Int, Int>>()//to,from color
    queue.add(Pair(1, 0))
    while (queue.isNotEmpty()) {
        val (cur, fromColor) = queue.pop()
        var nextColor = if (fromColor == 1) 2 else 1
        val bs = branches[cur]
        for (b in bs) {
            val (to, bnum) = b
            if (colors[bnum] != 0) continue
            colors[bnum] = nextColor
            queue.add(Pair(to,nextColor))
            nextColor++
            if (nextColor == fromColor) nextColor++
        }
    }


    println(colors.max())
    for (i in 1 until n) {
        println(colors[i])
    }
}

Measured memory_bytes: 98476
program ABC165_D
  integer(8)::A,B,N,X,M,F
  read(*,*)A,B,N
  if(N<B-1) then
     M=int(A*N/B)-A*int(N/B)
  else
     M=int(A*(B-1)/B)
  end if
  write(*,*)M
end program ABC165_D

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	int ans=0,sum=0,flag=0,a,b,c,n;
	vector<int> v(100,0);
	cin>>a>>n;
	if(a==0){
	    if(n!=100)
	    cout<<n<<'\n';
	    else
	    cout<<101<<'\n';
	}
	if(a==1){
	    if(n!=100)
	    cout<<n*100<<'\n';
	    else
	    cout<<10100<<'\n';
	}
	if(a==2){
	    if(n!=100)
	    cout<<n*10000<<'\n';
	    else
	    cout<<1010000<<'\n';
	}
	return 0;
}

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

coords = [list(map(int, input().split(' '))) for _ in range(N)]

coords.sort(key=lambda x: x[2], reverse=True)

# 全探索
def search():
    for Cx in range(101):
        for Cy in range(101):
            x, y, h = tuple(coords[0])
            H = h + abs(Cx - x) + abs(Cy - y)
            for x, y, h in coords:
                if max(H - abs(Cx - x) - abs(Cy - y), 0) != h:
                    break
            else:
                return Cx, Cy, H

x, y, h = search()
print("{} {} {}".format(x, y, h))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

int N, M, K, Q, W, H, R, C;
string S;

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

    cin >> N;
    vector<int> T(N + 1, 0), A(N + 1, 0), H_max(N, INF), H_min(N, 0);
    REP(i, N) cin >> T.at(i + 1);
    REP(i, N) cin >> A.at(i);

    FOR(i, 1, N + 1) {
        if (T[i - 1] < T[i]) {
            chmin(H_max[i - 1], T[i]);
            chmax(H_min[i - 1], T[i]);
        } else {
            chmin(H_max[i - 1], T[i]);
            chmax(H_min[i - 1], 1);
        }
    }

    RREP(i, N - 1) {
        if (A[i] > A[i + 1]) {
            chmin(H_max[i], A[i]);
            chmax(H_min[i], A[i]);
        } else {
            chmin(H_max[i], A[i]);
            chmax(H_min[i], 1);
        }
    }
    /*REP(i, N) { cout << H_max[i] << " "; }
    cout << endl;
    REP(i, N) { cout << H_min[i] << " "; }
    cout << endl;
*/
    ll ans = 1;
    REP(i, N) {
        ll num = (ll)(H_max[i] - H_min[i] + 1);
        if (num <= 0) {
            cout << 0 << endl;
            return 0;
        }
        ans *= num;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


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

void judge(double weight){
	if(weight <= 48.00){
		cout << "light fly" << endl;
	}else if(weight <= 51.00){
		cout << "fly" << endl;
	}else if(weight <= 54.00){
		cout << "bantam" << endl;
	}else if(weight <= 57.00){
		cout << "feather" << endl;
	}else if(weight <= 60.00){
		cout << "light" << endl;
	}else if(weight <= 64.00){
		cout << "light welter" << endl;
	}else if(weight <= 69.00){
		cout << "welter" << endl;
	}else if(weight <= 75.00){
		cout << "light middle" << endl;
	}else if(weight <= 81.00){
		cout << "middle" << endl;
	}else if(weight <= 91.00){
		cout << "light heavy" << endl;
	}else {
		cout << "heavy" << endl;
	}
}

int main(){
	double weight;
	while(cin >> weight) judge(weight);
	return 0;
}

Measured memory_bytes: 0
# N%2 == 0
# 2 < N < 2 * 10**5
# 全員のxorは全部足せば求まる?
# 1100のとき、0, 100の時1 0100のとき1, 100の時1
# 100, 100, 110, 110は1, 1, 0, 0

# 1110のとき1
# 110 0, 110 0, 110 0, 111 1
# 1がN, 0がMなら(N-1)個1があるのがN個、(N)個1があるのがM個
# N^2 - N + N*M Nが奇数ならかならず奇数(1) Nが偶数なら必ず偶数(0)
# 自分が1なら偶奇が変わる
# 自分が0なら偶奇は変わらない
# Nが奇数ならMが偶数なら1, Mが奇数なら0

#100なら全体で1
# 10は1, 10は1, 00は0
# 110なら全体で0
# 11 0, 10 1, 10 1

# 奇数回でた箇所と偶数回出た箇所がわかる
N = int(input())
a = [int(i) for i in input().split()]
p = 0b0
for i in range(N):
    p = p ^ a[i]
for i in range(N):
    print(p^a[i])

Measured memory_bytes: 105240
h,w=map(int,input().split())
if h==1 or w==1:
    print(1)
    exit()
if h%2==0 and w%2==0:
    print(h*w//2)
if (h+w)%2!=0:
    print(h*w//2)
if h%2!=0 and w%2!=0:
    num=(min(h,w)+1)//2
    num1=(max(h,w)+1)//2
    ans=num*num1+(num1-1)*(min(h,w)-num)
    print(ans)


Measured memory_bytes: 3060
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
# print(p,q)
p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r, reverse=True)
p = [int(1e10)]+p[:x]
q = [int(1e10)]+q[:y]
k = 0
i, j = x, y
# print(p, q)
while 1:
   if k >= c:
      break
   if min(p[i], q[j]) >= r[k] :
      break
   if p[i] < q[j]:
      p[i] = r[k]
      i -= 1
   else :
      q[j] = r[k]
      j -=1
   k += 1
print(sum(p[1:])+sum(q[1:]))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s, str, t, tt;
    int ans = INT_MAX;

    cin >> s;

    map<char, int> table;
    map<char, int>::iterator it;
    char ch;
    int m;

    int i, len = s.size();

    for (i = 0; i < len; i++) table[s[i]] = 1;

    for (it = table.begin(); it != table.end(); it++) {
        ch = it->first;
        t = s;
        m = 0;

        while (!std::all_of(t.begin(), t.end(), [&ch](char c){ return c == ch; })) {
            tt = "";
            len = t.size() - 1;
            for (i = 0; i < len; i++) {
                if (t[i] == ch) {
                    tt += string(1, ch);
                } else {
                    if (t[i + 1] == ch) tt += string(1, ch);
                    else tt += string(1, t[i]);
                }
            }

            t = tt;

            m++;

            if (ans < m) break;
        }

        ans = min(ans, m);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = (s.length()-1)/2; i > 0; i--){
        if(s.substr(0, i) == s.substr(i, i)){
            ans = i;
            break;
        }
    }
    cout << ans*2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,m,n) for(int i = m; i < n; ++i)
#define RFOR(i,m,n) for(int i = n - 1; i >= m; --i)
#define CIN(a) cin >> a
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a << endl
#define COUT2(a, b) cout << a << " " << b << endl
#define COUT3(a, b, c) cout << a << " " << b << " " << c << endl
#define pb(v, a) v.push_back(n)
#define VINT(v, n) vector<int> v(n); REP(i, n) { v[i] = 0 }
#define VINT2(v, n, m) vector<vector<int> > v(n, vector<int>(m)); REP(i, n) { REP(j, m) { v[i][j] = 0 } }
#define VCHAR(v, n) vector<char>v(n)
#define MAX(a, b) a > b ? a : b;
#define MIN(a, b) a < b ? a : b;
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 100000000

using namespace std;

string A, B, C;
int winner;
void solve(char w) {
    if(w == 'a') {
        if(A.size() == 0) winner = 1;
        else {
            char ww = A[0];
            A = A.erase(0, 1);
            if(ww == 'a') solve('a');
            if(ww == 'b') solve('b');
            if(ww == 'c') solve('c');
        }
    }
    if(w == 'b') {
        if(B.size() == 0) winner = 2;
        else {
            char ww = B[0];
            B = B.erase(0, 1);
            if(ww == 'a') solve('a');
            if(ww == 'b') solve('b');
            if(ww == 'c') solve('c');
        }
    }
    if(w == 'c') {
        if(C.size() == 0) winner = 3;
        else {
            char ww = C[0];
            C = C.erase(0, 1);
            if(ww == 'a') solve('a');
            if(ww == 'b') solve('b');
            if(ww == 'c') solve('c');
        }
    }
}

int main() {
    CIN3(A, B, C);
    solve('a');
    switch(winner) {
        case 1:
            COUT('A');
            break;
        case 2:
            COUT('B');
            break;
        case 3:
            COUT('C');
            break;

    }
    
}


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

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

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};


int main(){
    CIN(N);
    I vec;
    REP(a,N){
        CIN(b);
        vec.pb(b);
    }
    LL hoge = accumulate(ALL(vec),0LL);
    hoge /= N;
    LL ans = INF;
    for(int a = 0;a < 2;a++){
        LL h = 0;
        REP(b,N){
            h += ((hoge+a)-vec.at(b))*((hoge+a)-vec.at(b));
        }
        ans = min(ans,h);
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
from math import factorial

def comb(n, r):
    if n == 1:
        return 0
    return factorial(n) // factorial(r) // factorial(n - r)

N = int(input())
S = [input() for _ in range(N)]
str_dict = {}
for s in S:
    sorted_s = "".join(sorted(s))
    if sorted_s not in str_dict:
        str_dict[sorted_s] = 0
    str_dict[sorted_s] += 1
ans = sum([comb(v, 2) for v in str_dict.values()])
print(int(ans))

Measured memory_bytes: 24968
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	int k, t, i, s, n;

	cin >> n;
	vector<int> a(n);
	for (i = 0; i < n; i++){
		cin >> a[i];
	}
	
	ll x = 1000;
	for (i = 0; i < n-1; i++){
		s = a[i];
		t = a[i + 1];

		if (t > s){
		ll k = x/s;
		x = x%s;
		x += k*t;
		}
	}

	cout << x << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
//4008802802
//4008160009
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define pb push_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)
#define forn(i, a) for(register int i=0; i<a; i++)
#define Forn(i, a) for(register int i=1; i<=a; i++)
#define memINF 127
#define all(x) x.begin(), x.end()
#define FAST ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<int,int> pi;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;

inline int in() 
{
    int x=0, c;
    while((uint)((c=getchar())-48)>=10) 
		if(c=='-') 
			return -in();
    do 
	{ x=(x<<3)+(x<<1)+(c^48); }
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}

const int MAX=1e6+5;

struct DSU
{
    int par[MAX];
    inline void init(int x)
    {
        par[x]=x;
    }
    inline int find(int x)
    {
        return par[x]==x?x:par[x]=find(par[x]);
    }
    inline void unite(int x, int y)
    {
        x=find(x), y=find(y);
        if(x==y)
            return;
        par[x]=y;    
    }
}dsu;

int N, M, a, b, c, tot, to[MAX], dist[MAX];
vector<pi> e[MAX];
vi adj[MAX];
bool inside[MAX];
queue<int> q;

int main()
{
    N=in(), M=in();
    while(M--)
    {
        a=in(), b=in(), c=in();
        e[c].eb(mp(a, b));
    }
    tot=N;
    Forn(i, 1000000)
    {
        if(!e[i].size())
            continue;
        int pa;
        foreach(it, e[i])
        {
            dsu.init(it->f);
            dsu.init(it->s);
            inside[it->f]=false;
            inside[it->s]=false;
            to[it->f]=-1;
            to[it->s]=-1;
        }
        foreach(it, e[i])
            dsu.unite(it->f, it->s);
        foreach(it, e[i])
        {
            if(!inside[it->f])
            {
                pa=dsu.find(it->f);
                inside[it->f]=true;
                if(to[pa]<=0)
                    to[pa]=++tot;
                adj[to[pa]].eb(it->f);
                adj[it->f].eb(to[pa]);
            }
            if(!inside[it->s])
            {
                pa=dsu.find(it->s);
                inside[it->s]=true;
                if(to[pa]<=0)
                    to[pa]=++tot;
                adj[to[pa]].eb(it->s);
                adj[it->s].eb(to[pa]);
            }
        }
    }
    memset(dist, -1, sizeof(dist));
    dist[1]=0;
    q.push(1);
    while(!q.empty())
    {
        int t=q.front();
        q.pop();
        foreach(it, adj[t])
            if(dist[*it]<0)
                dist[*it]=dist[t]+1, q.push(*it);
    }
    printf("%d\n", dist[N]<0?-1:dist[N]>>1);
    return 0;
} 

Measured memory_bytes: 70656
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<bitset>
#include<algorithm>

using namespace std;

#define LL long long
inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 2000010;
const int INF = 2147483600;

int N; int a[5001];
int sum=0; 
bitset<2000*2000+1> f;

int main(){
	//freopen("a.in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); for(int i=1;i<=N;i++) a[i]=read(),sum+=a[i]; sort(a+1,a+N+1); 
	f[0]=1; int S=sum,T=0; sum=(sum+1)>>1; for(int i=1;i<=N;i++) f=f|(f<<a[i]);
	for(int i=sum;;i++){if(f[i]){printf("%d\n",i);return 0;}}
	return 0;
}

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

using namespace std;

using ll_t = long long;
using occ_t = unordered_map<int, int>;

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

  ll_t sum = 0;
  occ_t occ;
  while(n--) {
    int i;
    cin >> i;
    sum += i;
    occ[i] += 1;
  }
  
  int q;
  cin >> q;
  while(q--) {
    int a, b;
    cin >> a >> b;

    sum += (b - a) * occ[a];
    occ[b] += occ[a];
    occ[a] = 0;
    cout << sum << "\n";    
  }
  return 0;
}

Measured memory_bytes: 7044
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	vector<int> N(4);
	for (int i = 0; i < 4; i++)
	{
		cin >> N[i];
	}

	sort(N.begin(), N.end());

	bool flag = true;

	int arr[4] = { 1, 4, 7, 9 };
	for (int i = 0; i < 4; i++)
	{
		if (N[i] != arr[i])
		{
			flag = false;
			break;
		}
	}

	if (flag)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = sum(map(int, input().split()))
c = list(map(int, input().split()))
s = 0
for i in range(n-1):
  if a[i+1] - a[i] == 1:
    s += c[a[i] - 1]
print(b + s)

Measured memory_bytes: 9096
#include <stdio.h>

int main(void)
{
	int kinds_of_sweets, number_of_sunuke, not_having_sweet;
	int having_sweets;
	int sunuke[100], number_of_sweet[100];
	int i, j, k, l;

	scanf("%d%d", &number_of_sunuke, &kinds_of_sweets);

	for (k = 0; k < number_of_sunuke; k++)
	{
		sunuke[k] = 1;
	}

	/* お菓子の種類ごとに、そのお菓子の個数を入力させる */
	for (i = 0; i < kinds_of_sweets; i++)
	{
		scanf("%d", &number_of_sweet[i]);

		/* お菓子を持っているすぬけ君をカウント対象から除外する */
		for (j = 0; j < number_of_sweet[i]; j++)
		{
			scanf("%d", &having_sweets);
			sunuke[having_sweets - 1] = 0;
		}
		
	}

	not_having_sweet = 0;

	for (l = 0; l < number_of_sunuke; l++)
	{
		if (sunuke[l] == 1)
		{
			not_having_sweet++;
		}
	}
	
	printf("%d\n", not_having_sweet);

	return 0;

}

Measured memory_bytes: 1732
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n; cin>>n;
  /*vecrtor<ll> a(n),b(n);
  map<ll,ll> mp
  rep(i,n) [
    cin >>a[i]>>b[i];
    }*/
  vector<pair<ll,ll>> c(n);
  rep(i,n) cin >>c[i].second>>c[i].first;
  sort(all(c));
  ll sum=0;
  rep(i,n){
    sum+=c[i].second;
    if(sum>c[i].first){
      cout <<"No"<<endl;
      return 0;
    }
  }
  cout <<"Yes"<<endl;
}

Measured memory_bytes: 6432
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;
using u64 = unsigned long long;
u64 n, k, a[100000], cnt[60];
u64 sub(int b) {
	u64 r = 0;
	for (int i = 0; i < b; i++)
		r += max(cnt[i], n - cnt[i]) * (1ull << i);
	return r;
}
u64 solve(int p, u64 k) {
	if (p < 0)
		return 0;
	if ((k >> p) & 1) {
		u64 o = (n - cnt[p]) * (1ull << p) + solve(p - 1, k ^ (1ull << p));
		u64 z = cnt[p] * (1ull << p) + sub(p);
		return max(o, z);
	}
	return cnt[p] * (1ull << p) + solve(p - 1, k);
}
int main() {
	scanf("%llu %llu", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%llu", a + i);
		for (int j = 0; j < 60; j++)
			cnt[j] += (a[i] >> j) & 1;
	}
	printf("%llu\n", solve(59, k));
}

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

using namespace std;

int main() 
{
    int a[1<<18];
    int n;

    cin >> n;

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

    sort(a, a + n);

    long long ans = 0;
    if (n % 2) {
        int b = a[n/2];
        for (int i = 0; i < n; i++) ans += abs(a[i] - b);
    } else {
        long long cand = 0;
        int b = a[n/2];
        for (int i = 0; i < n; i++) cand += abs(a[i] - b);
        b = a[n/2-1];
        for (int i = 0; i < n; i++) ans += abs(a[i] - b);
        ans = min(ans, cand);
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    int a,x=0,ans=0;
    string b;
    cin >> a >> b;
    for(int i=0;i<a;i++){
        if(b[i]=='I') x++;
        else x--;
        ans=max(ans,x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
#define pi acos(-1);
ll strtoint(string str);
int main(){
	fast;
	ll n,s=0; cin>>n;
	vector<ll> arr(n);
	for(auto i=0;i<n;++i)cin>>arr[i];
	for(auto i=0;i<n;++i){
		for(auto j=i+1;j<n;++j){
			ll tmp=arr[i]*arr[j];
			s+=tmp;
		}
	}
	cout<<s<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;


lli n, m;
char a[1007][1007];

lli cache[1007][1007];

lli dp(lli i, lli j) {

    if(i >= n || j >= m ) {
        return 0;
    }

    if(a[i][j] == '#')
        return 0;

    if(i == n - 1 and j == m - 1)
        return 1;

    lli &ans = cache[i][j];

    if(ans != -1)
        return ans;

    ans = 0;

    ans += dp(i + 1, j) + dp(i, j + 1);

    ans %= mod;

    return ans ;

}

void solve()
{

    cin>>n>>m;

    memset(cache, -1, sizeof cache);

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

    lli ans = dp(0, 0);

    cout<<ans;

    cout<<'\n';
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll N;
    cin >> N;
    ll ans = (N / 11) * 2;
    if(N % 11 != 0)ans += (N % 11 <= 6 ? 1 : 2);
    cout << ans << endl;
}

Measured memory_bytes: 256
import Data.List (sort)

main = do
    line <- getLine
    let [_, k] = map read . words $ line
    putStrLn . show . solve k . map read . lines =<< getContents

solve :: Int -> [Int] -> Int
solve k ns =
    let sorted = sort ns
        shifted = drop (k - 1) sorted
        diffs = zipWith (-) shifted sorted
    in  minimum diffs


Measured memory_bytes: 17660
ai = lambda: list(map(int, input().split()))
ai_ = lambda: [int(x) - 1 for x in input().split()]

s = input()
t = input()

import string
S = string.ascii_lowercase

ss = [[] for _ in range(26)]
for i in range(26):
    for j in range(len(s)):
        if S[i] == s[j]:
            ss[i].append(j)
ss = [tuple(k) for k in ss]


tt = [[] for _ in range(26)]
for i in range(26):
    for j in range(len(s)):
        if S[i] == t[j]:
            tt[i].append(j)
tt = [tuple(k) for k in tt]


from collections import Counter
if Counter(ss) == Counter(tt):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 21596
#pragma GCC diagnostic error "-std=c++11"
#include <iostream>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define FIN freopen("in.txt","r",stdin)
#define IO ios_base::sync_with_stdio(0),cin.tie(0)
#define fuck(name) cout<<#name<<": "<<name<<endl;
#define pb push_back
typedef long long LL;
typedef pair<int, int> PIR;

const int MAXN = 2e5+5;

int a, b, c;

int main ()
{
    cin >> a >> b >> c;
    if (a == b) cout << c << endl;
    if (a == c) cout << b << endl;
    if (b == c) cout << a << endl;
    return 0;
}

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

class P
{
    static void Main()
    {
        int[] NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Dictionary<int, int> dict = new Dictionary<int, int>();
        foreach (var i in A)
        {
            if (!dict.ContainsKey(i)) dict.Add(i, 0);
            dict[i]++;
        }
        int[] value = dict.Values.ToArray().OrderBy(x => x).ToArray();
        if (value.Length <= NK[1])
        {
            Console.WriteLine(0);
        }
        else
        {
            Console.WriteLine(value.Take(value.Length - NK[1]).Sum());
        }
    }
}

Measured memory_bytes: 42704
import sys
input = sys.stdin.readline

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

S = sum(A)
ok = True
if S % ((N+1)*N//2) != 0:
    ok = False
else:
    K = S // ((N+1)*N//2)
    c = 0
    for i in range(N):
        a = K-A[i]+A[i-1]
        if a % N != 0:
            ok = False
            break
        x = a // N
        if 0 <= x <= K:
            c += x
        else:
            ok = False
            break
    if c != K:
        ok = False

if ok:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 15020
using System;

public class hello
{
    public static void Main()
    {
        string line2;
        for (; (line2 = Console.ReadLine()) != null;)
        {
            var a = new decimal[8];
            string[] line = line2.Trim().Split(' ');
            for (int i = 0; i < 8; i++)
                a[i] = decimal.Parse(line[i]);
            var x1 = a[2] - a[0];
            var y1 = a[3] - a[1];
            var x2 = a[6] - a[4];
            var y2 = a[7] - a[5];
            var ip = x1 * x2 + y1 * y2;
            Console.WriteLine(ip == 0 ? "YES" : "NO");
        }
    }
}



Measured memory_bytes: 15984
import Data.List as L
import Control.Monad

bit::Int -> [Int]
bit n = [2^i|i<-[0..n-1]]

odd_even::[(Int,Int)] -> (Bool, Bool)
odd_even a = let (h:t) = (map (\(x,y)->mod(x+y) 2) a) in
  (and (map (h==) t),h==0)

ls_accum::(b->(b,c))->(b->Bool)->b->[c]
ls_accum f condition state = if condition state then [] else let (next,res) = f state  in res:(ls_accum f condition next)

bit_expand::Int->[Bool]
bit_expand n = ls_accum (\ i -> (div i 2 , (mod i 2)==1) ) (0==) n

sigma_bit::Int->Int->[Bool]
sigma_bit n m = let bits = bit_expand (div (m + (2^n - 1)) 2) in bits++(take (n - (length bits))) (repeat False)

solver::Int->(Int,Int)->[Char]
solver n (x,y) = (map to_char) (zip (sigma_bit n (x+y)) (sigma_bit n (x-y)))
                                  where to_char (b,c) = case (b,c) of
                                                        (True,True)  -> 'R'
                                                        (True,False) -> 'U'
                                                        (False,True) -> 'D'
                                                        (False,False)-> 'L'

adj_solver::Int->(Int,Int)->[Char]
adj_solver n (x,y) = if mod (x+y) 2 == 1
                          then solver n (x,y)
                          else 'R':(solver n (x-1,y))

main=do
  (n:_) <-L.map read . words<$>getLine::IO[Int]
  inputs<- forM [1..n] (\_->(return.(\(x:y:[])->(x,y)).(map read).words)=<<getLine)
  case odd_even inputs of
    (False,_) -> do
      putStr "-1\n"
    (True,b) -> do
      putStr $ (if b then show (d+1) else show d)
      putStr "\n"
      putStr $ concat (intersperse " "  (map (\x-> show x) ((if b then [1] else[])++(bit d))))
      putStr "\n"
      forM_ inputs (\(x,y)->do
        case b of
          True -> putStr $ 'R':solver d (x-1, y)
          False -> putStr $ solver d (x, y)
        putStr "\n"
        )
  where
    d=31

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split(' ');
            var N = r[0].ToInt();
            var r2 = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                var A = r2[i].ToInt();
                if (A % 2 == 0)
                {
                    if (!(A % 3 == 0 || A % 5 == 0))
                    {
                        Console.WriteLine("DENIED");
                        return;
                    }
                }
            }
            Console.WriteLine("APPROVED");
            Console.ReadLine();
        }
    }
}

public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 11092
#include <stdio.h>

int main(){


	int h, w, x, y;


	while(1){

		scanf( "%d %d", &h, &w );

		if( h==0 && w==0 ) break;

		for( x=0; x<w; x++ ) printf( "#" );
		printf( "\n" );

		for( y=1; y<(h-1); y++ ){

			printf( "#" );

			for( x=1; x<(w-1); x++){
				printf( "." );
			}

			printf( "#\n" );
		}

		for( x=0; x<w; x++ ) printf( "#" );
		printf( "\n\n" );

	}


	return 0;

}

Measured memory_bytes: 588
// Written By NewbieChd
#include <cstdio>
#include <cctype>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    int f = 0;
    char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int maxN = 100003;

int main() {
    int m = read(), d = read(), i, j, ans = 0;
    for (i = 1; i <= m; ++i)
        for (j = 20; j <= d; ++j)
            if (j % 10 >= 2 && (j / 10) * (j % 10) == i)
                ++ans;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main (void)
{
  int x,y,z,i=1,n=3000;
  do{
    x=0;
    y=0;
    scanf("%d%d",&x,&y);
    if(x==0&&y==0)break;
    if(x>y){
      z=x;
      x=y;
      y=z;
    }
    printf("%d %d\n",x,y);
    i++;
  }while(i<=n);
  return 0;
}

Measured memory_bytes: 600
import sys

N = int(sys.stdin.readline())
mod = 10**9 + 7

values = [i for i in range(N+1)]
factors = {}
exists = set()
for i in range(2, N+1):
    if i not in factors:
        factors[i] = 0
    for j in range(i, N+1, i):
        tmp = values[j]
        while tmp % i == 0:
            factors[i] += 1
            tmp //= i
        values[j] = tmp

# print(values)
# print(factors)
ans = 1
for factor, count in factors.items():
    ans *= count + 1
    ans %= mod

print(ans)

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

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

int n;
bool ans[203];
bool ins[203];

void print(vector<int> vec)
{
	for(int i = 0; i < n; i++)
		cout << vec[i] << ((i == n-1)? '\n' : ' ');
	fflush(stdout);
}


int ask(vector<int> vec)
{
	cout << "? ";
	print(vec);
	string pet;
	cin >> pet;
	return (pet == "Red")? 0 : 1;
}

vector<int> cons(int x)
{
	vector<int> vec;
	for(int i = 1; i <= n-x; i++) vec.push_back(i);
	for(int i = n+1; i <= n+x; i++) vec.push_back(i);
	return vec;
}

vector<int> binser(int bef, int &piv1, int &piv2, int &idx)
{
	int kir = 0, kan = n;
	while(kir < kan)
	{
		int mid = (1+kir+kan)/2;
		if(ask(cons(mid)) == bef) kir = mid;
		else kan = mid-1;
	}
	idx = n-kir-1;
	piv1 = n-kir;
	piv2 = n+kir+1;
	return cons(kir);

}

int main()
{
	scanf("%d", &n);
	vector<int> vec, nvec;
	for(int i = 1; i <= n; i++)
		vec.push_back(i);

	int bef = ask(vec), piv1, piv2, idx;
	vec = binser(bef, piv1, piv2, idx);

	ans[piv1] = bef;
	ans[piv2] = bef^1;
	
	for(int x : vec) ins[x] = 1;

	nvec = {piv2};
	for(int i = 1; i <= 2*n; i++)
		if(!ins[i] && i != piv2)
			nvec.push_back(i);

	// cout << idx << " " << piv1 << " " << piv2 << "\n";
	// print(vec);
	// print(nvec);

	for(int i = 1; i <= 2*n; i++)
	{
		if(i == piv1 || i == piv2) continue;
		if(ins[i])
		{
			vector<int> temp = nvec;
			temp[0] = i;
			if(ask(temp) != bef) ans[i] = ans[piv2];
			else ans[i] = ans[piv2]^1; 
		}
		else
		{
			vector<int> temp = vec;
			temp[idx] = i;
			if(ask(temp) == bef) ans[i] = ans[piv1];
			else ans[i] = ans[piv1]^1; 
		}
	}
	cout << "! ";
	for(int i = 1; i <= 2*n; i++)
	{
		if(ans[i] == 0)
			cout << "R";
		else cout << "B";
	} fflush(stdout);
	// return 0;
}

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

int A, B, C;

int main() {
    cin>>A>>B>>C;
    int cnt = 0;
    while(1) {
        if(A % 2 || B % 2 || C % 2) {
            printf("%d", cnt);
            return 0;
        }
        if(A == B && B == C) {
            printf("-1");
            return 0;
        }
        int a = (A + B) / 2;
        int b = (B + C) / 2;
        int c = (C + A) / 2;
        A = a;
        B = b;
        C = c;
        cnt++;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    long long int a[n];
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long long dp[n+1]={0};
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	printf("%.10lf\n", sqrt(pow(x2 - x1, 2.0) + pow(y2 - y1, 2.0)));
	return 0;
}

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

int main() { 
  int N,T; cin >> N >> T;
  vector<int> t(N,0); for(int i = 0;i < N;i++) { cin >> t[i]; }
  int total = T;

  for(int i = 1;i < N;i++) {
    if( t[i] - t[i-1] > T ) { total += T; }
    else { total += t[i] - t[i-1]; }
  }
  
  cout << total << endl;
  return 0;
}

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

const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(a*n<b)cout<<a*n<<endl;
    else cout<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main ()
{
    int H, A, number_of_attacks;

    scanf("%d %d", &H, &A);

    number_of_attacks = H/A;

    if (H % A != 0){
        number_of_attacks = number_of_attacks + 1;
    }

    printf("%d", number_of_attacks);

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

long long gcd(long long,long long);

int main()
{
	long long a,b,Gcd,Lcm;
	while(scanf("%lld %lld",&a,&b) != EOF){
		Gcd = gcd(a,b);
		Lcm = a * b / Gcd;
		printf("%lld %lld\n",Gcd,Lcm);
	}

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

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int H, W;
char map[20][20];
int dist_value;
int dist[20][20];

void initdist(){
  dist_value = 0;
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      dist[i][j] = -1;
    }
  }
  return;
}

struct coord  {
  int x;
  int y;
};

int drow[4]={1,-1,0,0};
int dcolumn[4]={0,0,1,-1};
std::queue<coord > queue_next;
coord last;

void bfs(int start_i, int start_j){
  queue_next.push((coord){start_i,start_j});
  dist_value = 0;
  while(queue_next.size()){
    std::queue<coord > queue(queue_next);
    // clear queue_next
    std::queue<coord> empty;
    std::swap(queue_next, empty);
    while(queue.size()){
      int thisi = queue.front().x;
      int thisj = queue.front().y;
      last.x = thisi;
      last.y = thisj;
      queue.pop();
      dist[thisi][thisj]=dist_value;
      for(int k=0; k<4; k++){
        if (thisi+drow[k]>=0 && thisi+drow[k]<H && thisj+dcolumn[k]>=0 && thisj+dcolumn[k]<W){
          if (dist[thisi+drow[k]][thisj+dcolumn[k]]==-1 && map[thisi+drow[k]][thisj+dcolumn[k]]!='#'){
            queue_next.push((coord){thisi+drow[k], thisj+dcolumn[k]});
            dist[thisi+drow[k]][thisj+dcolumn[k]] = dist_value+1;
          }
        }
      }
    }
    dist_value++;
  }
  return;
}


int maxdist(){
  int ans = 0;
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      if (map[i][j]=='#'){
        continue;
      }
      initdist();
      bfs(i,j);
      ans = std::max(ans,dist_value-1);
    }
  }
  return ans;
}

int main(){
  scanf("%d",&H);
  scanf("%d",&W);
  std::string S;

  for (int i=0; i<H; i++){
    std::cin >> S;
    for (int j=0; j<W; j++){
      map[i][j] = S[j];
    }
  }
  int ans = maxdist();
  printf("%d\n",ans);

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static long mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();

			long ans = Dfs(n, "");
			Console.WriteLine(ans);


			Console.Out.Flush();
		}

		static readonly Dictionary<string, long> memo = new Dictionary<string, long>();
		static long Dfs(int len, string s)
		{
			var key = $"{len}{s}";
			if (memo.ContainsKey(key)) {
				return memo[key];
			}
			if (len == 0) {
				return 1;
			}
			long result = 0;
			foreach (var c in "ACGT") {
				string next = c + s;
				if (next.Length > 4) {
					next = next.Substring(0, 4);
				}
				if (Check(next)) {
					result = (result + Dfs(len - 1, next)) % mod;
				}
			}
			memo.Add(key, result);
			return result;
		}

		static bool Check(string s)
		{
			if (s.Length < 3) { return true; }
			if (s.Length >= 3) {
				// AGC
				if (s[0] == 'A' && s[1] == 'G' && s[2] == 'C') { return false; }
				// GAC
				if (s[0] == 'G' && s[1] == 'A' && s[2] == 'C') { return false; }
				// ACG
				if (s[0] == 'A' && s[1] == 'C' && s[2] == 'G') { return false; }
			}
			if (s.Length >= 4) {
				// A*GC
				if (s[0] == 'A' && s[2] == 'G' && s[3] == 'C') { return false; }
				// AG*C
				if (s[0] == 'A' && s[1] == 'G' && s[3] == 'C') { return false; }
			}
			return true;
		}

	}
}


Measured memory_bytes: 20040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	double r;
	cin >> r;
	cout << (2.0f * r * acos(-1)) << endl;
	return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int a,b,c,N;
	cin>>a>>b>>c>>N;
	int ans=0;
	rep(i,N/a+1)rep(j,N/b+1){
		int x=N-i*a-j*b;
		if(x<0)continue;
		if(x%c==0)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s.size() == unique(s.begin(), s.end())-s.begin()) {
        cout << "yes\n";
    } else cout << "no\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>
using namespace std;
const long double EPS=1e-8;
bool maziwatteruno(complex<long double>a1,complex<long double>a2,complex<long double>b1,complex<long double>b2 ){
	a2-=a1;
	b1-=a1;
	b2-=a1;
	a1-=a1;
	b1/=a2;
	b2/=a2;
	a2/=a2;
	long double kouten=(abs(b1.imag())*b2.real()+abs(b2.imag())*b1.real());
	
	if(abs(b1.imag())+abs(b2.imag())<EPS&&(b1.real()<0&&b2.real()<0)||(b1.real()>1&&b2.real()>1))
	{
		return false;
	}else if(abs(b1.imag())+abs(b2.imag())<EPS){return true;}
	
	if(b1.imag()*b2.imag()>0){
		
		
		return false;
	}else if(kouten<0||kouten>(abs(b1.imag())+abs(b2.imag()))){
		
		
		
		return false;
	}else{
		return true;
	}
}


int main(){
	cout << fixed << setprecision(10);
	
	long double Re,Im;
	int q;
	complex<long double>p1,p2;
	
	cin>>q;
	
	for(int i=0;i<q;i++){
		
		
		complex<long double>p1,p2,p3,p4;
		
		cin>>Re>>Im;
		p1.real(Re);
		p1.imag(Im);
		cin>>Re>>Im;
		p2.real(Re);
		p2.imag(Im);
		cin>>Re>>Im;
		p3.real(Re);
		p3.imag(Im);
		cin>>Re>>Im;
		p4.real(Re);
		p4.imag(Im);
		if(maziwatteruno(p1, p2, p3, p4)){
			cout<<1<<endl;
		}else{
		cout<<0<<endl;	
		}
	}
	
}


Measured memory_bytes: 3228
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = Console.ReadLine().Split(' ');
            var a = int.Parse(A[0]);
            var b = int.Parse(A[1]);
            for (int i = 0; i < 1500; i++)
            {
                if (a == Math.Floor(i * 0.08) && b == Math.Floor(i * 0.1))
                {
                    Console.WriteLine(i);
                    break;
                }
                if (i == 1300)
                {
                    Console.WriteLine("-1");

                }
            }

        }
    }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9, MX = 805;

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

char grid[MX][MX];
int dist[MX][MX];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    int sx, sy;
    rep(i,h)rep(j,w){
        cin >> grid[i][j];
        if(grid[i][j] == 'S'){
            sy = i;
            sx = j;
        }
        dist[i][j] = INF;
    }
    dist[sy][sx] = 0;
    int ans = INF;
    queue<P> que;
    que.push(P(sy, sx));
    while(!que.empty()){
        P p = que.front();
        que.pop();
        int cost = INF;
        chmin(cost, 1 + (p.first + k - 1) / k);
        chmin(cost, 1 + (h - 1 - p.first + k - 1) / k);
        chmin(cost, 1 + (p.second + k - 1) / k);
        chmin(cost, 1 + (w - 1 - p.second + k - 1) / k);
        chmin(ans, cost);
        rep(i,4){
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(ny < 0 || h <= ny) continue;
            if(nx < 0 || w <= nx) continue;
            if(dist[ny][nx] != INF) continue;
            if(grid[ny][nx] == '#') continue;
            if(dist[p.first][p.second] + 1 > k) continue;
            dist[ny][nx] = dist[p.first][p.second] + 1;
            que.push(P(ny, nx));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6780
#include <iostream>

int swap(int* a, int* b) {
	int temp = *a;
	*a = *b;
	*b = temp;

	return 0;
}

int main() {
	int i, temp1, temp2;
	for (i = 0; i < 10000; i++) {
		std::cin >> temp1 >> temp2;
		if (temp1 == 0 && temp2 == 0) break;
		if (temp1 > temp2) swap(&temp1, &temp2);
		std::cout << temp1 << " " << temp2 << std::endl;
	}

	return 0;
}


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

int N;

void dfs(string s, char mx) {
    if (s.length() == N) cout << s << endl;
    else {
        for (char c = 'a'; c < mx; c++) {
            dfs(s+c, mx);
        }
        dfs(s+mx, (char)(mx+1));
    }
}

int main() {
    cin >> N;
    dfs("", 'a');
}


Measured memory_bytes: 1536