akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
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; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

#define MAX_N 100010
bool is_prime[MAX_N + 1];
bool like_2017[MAX_N + 1];

void eratosthenes(int n) {
	memset(is_prime, true, sizeof(is_prime));
	memset(like_2017, false, sizeof(like_2017));
	is_prime[0] = is_prime[1] = false;
	like_2017[0] = like_2017[1] = false;
	rep(i, 2, n + 1) {
		if(is_prime[i]) {
			for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
      if(i % 2 == 1 and is_prime[(i + 1) / 2]) like_2017[i] = true;
    }
	}
}

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

  int q;
  cin >> q;
  eratosthenes(MAX_N);
  int tmp[MAX_N];
  memset(tmp, 0, sizeof(tmp));
  rep(i, 1, MAX_N) {
    int a = (like_2017[i]) ? 1 : 0;
    tmp[i] += tmp[i - 1] + a;
  }

  vector<int> rsl;
  rep(i, 0, q) {
    int l, r;
    cin >> l >> r;
    rsl.push_back(tmp[r] - tmp[l - 1]);
  }
  rep(i, 0, rsl.size()) cout << rsl[i] << endl;
}



Measured memory_bytes: 1784
from collections import deque
import copy

H, W = map(int, input().split())
s=(0,0)
g=(H-1,W-1)
maze = [list(input()) for line in range(H)]
copied_maze = copy.deepcopy(maze)

def search(x, y):
  dq = deque()
  dq.append([x, y])
  copied_maze[x][y] = 0
  while len(dq) > 0:
    x,y = dq.popleft()
    if x==g[0] and y==g[1]:
      break
    for dx, dy in [[1,0], [0,1], [-1,0], [0,-1]]:
      nx,ny=[x+dx,y+dy]
      if 0 <= nx < H and 0 <= ny < W and copied_maze[nx][ny] != '#' and type(copied_maze[nx][ny]) is str:
        dq.append([nx,ny])
        copied_maze[nx][ny] = copied_maze[x][y]+1
search(s[0],s[1])
x,y=g
cost = copied_maze[g[0]][g[1]]
if type(cost) is str:
  print(-1)
  exit()
path = {s, g}
for i in range(copied_maze[g[0]][g[1]]):
  for dx, dy in [[1,0], [0,1], [-1,0], [0,-1]]:
    nx,ny=[x+dx,y+dy]
    if 0 <= nx < H and 0 <= ny < W and copied_maze[nx][ny] == cost - 1:
      path.add((nx,ny))
      x,y=nx,ny
      cost -= 1
      break
count = 0
for i in range(H):
  for j in range(W):
    if maze[i][j] == '.' and (i, j) not in path:
      count += 1
print(count)

Measured memory_bytes: 3572
def main():
    N, K = map(int, input().split())
    ans = set(range(N))
    for i in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for a in A:
            if a-1 in ans:
                ans.remove(a-1)
    print(len(ans))


if __name__ == "__main__":
    main()


Measured memory_bytes: 78908
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
string a,b;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>a>>b;
	a+=b[b.length()-1];
	if(a==b)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>

int main()
{
	char c, S[100000+1];		// 10^5
	int cnt = 0, len = 0, i;

	scanf("%s", &S);
	len = strlen(S);

	c = S[0];
	for (i = 1; i < len; i++) {
		if (c == '0') {
			if (c == S[i]) {
				cnt++;
			}
			c = '1';
		} else if (c == '1') {
			if (c == S[i]) {
				cnt++;
			}
			c = '0';
		}
	}

	printf("%d", cnt);

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <queue>

#define INF 1e9

struct Edge {
	int to, cost;
};
struct Node {
	int now, cost, pCost;
};
bool operator <(const Node& n1, const Node& n2) {
	return n1.cost < n2.cost;
}
bool operator >(const Node& n1, const Node& n2) {
	return n1.cost > n2.cost;
}

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		vector<Edge> edge[100];
		int m; cin >> m;
		for (int i = 0; i < m; ++i) {
			int a, b, d;
			scanf("%d,%d,%d", &a, &b, &d);

			int c = d / 100 - 1;
			edge[a].push_back( (Edge){ b, c } );
			edge[b].push_back( (Edge){ a, c } );
		}

		priority_queue<Node, vector<Node>, greater<Node> > Q; Q.push( (Node){ 0, 0, 0 } );
		bool f[100] = {0};
		int ans = 0;
		while ( !Q.empty() ) {
			Node node = Q.top(); Q.pop();
			if (f[node.now]) continue;
			f[node.now] = true;

			ans += node.pCost;

			for (int i = 0; i < edge[node.now].size(); ++i) {
				Edge& e = edge[node.now][i];
				Q.push( (Node){ e.to, e.cost, e.cost } );
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1600
n, x, m = map(int, input().split())

num, lst = set(), []
for i in range(n):
    num.add(x), lst.append(x)
    x = x ** 2 % m
    if x in num:
        cnt, idx = i + 1, lst.index(x)
        break

ans = sum(num)
if x in num:
    div, mod = divmod(n - cnt, len(lst) - idx)
    ans += sum(lst[idx:]) * div
    ans += sum(lst[idx:idx + mod])
print(ans)


Measured memory_bytes: 77344
import math

A, B, H, M = map(int, input().split())
rad1 = math.pi / 6 * (H + (M / 60))
rad2 = math.pi * 2 * M / 60
rad = rad1 - rad2
print((A ** 2 + B ** 2 - 2 * A * B * math.cos(rad)) ** 0.5)

Measured memory_bytes: 9504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll K;
    cin >> K;
    vector<ll> a(K);
    for (ll i = 0; i < K; i++) {
        cin >> a[i];
    }
    if(a[K-1] != 2){
        printf("-1\n");
        return 0;
    }
    ll L = 2; ll tmpl;
    ll S = 2; ll tmps;
    for (ll i = K-1; i >= 1; i--) {
        tmpl = ((L+a[i]-1) / a[i-1]) * a[i-1];
        if(tmpl < S){
            printf("-1\n");
            return 0;
        }

        tmps = ((S-1) / a[i-1]) * a[i-1] + a[i-1];
        if(tmps >= L + a[i]){
            printf("-1\n");
            return 0;
        }
        L = tmpl;
        S = tmps;
    }
    L = L + a[0] - 1;
    S = S;
    printf("%lld %lld\n", S, L);

}

Measured memory_bytes: 4048
fun main() {
    solve()
}

private fun solve() {
    val x = readInt()

    if (x == 1)
        println(0)
    else println(1)
}
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

Measured memory_bytes: 34456
N = int(input())
a = list(map(int,input().split()))
a4 = a2 = a0 = 0
for i in a:
  if i % 4 == 0:
    a4 += 1
  elif i % 2 == 0:
    a2 += 1
  else:
    a0 += 1
if a2 == 0:
    if a0 <= a4 + 1:
        print("Yes")
    else:
        print("No")
else:
    if a0 <= a4:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 15020
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    vector<char> words = {'M', 'A', 'R', 'C', 'H'};
    ll res = 0;
    map<char, ll> ma;

    rep(i, N) {
        string s;
        cin >> s;
        ma[s[0]]++;
    }

    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {
                res += ma[words[i]] * ma[words[j]] * ma[words[k]];
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if ( (a+b) > (c+d) ) {
    cout << "Left" << endl;
  }
  
  else if ( (a+b) < (c+d) ){
    cout << "Right" << endl;
  }
  
  else{
    cout << "Balanced" << endl;
  }
  
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
typedef long long Int;
int asc(const void *a, const void *b) {
    Int d = *(Int *)a - *(Int *)b;
    return (d > 0) ? 1 : (d < 0) ? -1 : 0;
}

int main() {
    Int n, c, k;
    scanf("%lld %lld %lld", &n, &c, &k);
    Int *T = (Int *)malloc(sizeof(Int) * n);
    rep(i, n) scanf("%lld", T + i);
    qsort(T, n, sizeof(Int), asc);
    bool waiting = false;
    Int start_time = 0;
    Int waiting_people = 0;
    Int ans = 0;
    rep(i, n) {
        Int t = T[i];
        if (waiting) {
            if (t - start_time <= k) {
                waiting_people++;
            } else {
                ans++;
                waiting = true;
                start_time = t;
                waiting_people = 1;
            }
        } else {
            waiting = true;
            start_time = t;
            waiting_people = 1;
        }
        if (waiting_people == c) {
            waiting = false;
            waiting_people = 0;
            ans++;
        }
    }
    if (waiting) {
        ans++;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 3696
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int N;

set <int> oconn[100050];

set <int> conn[100050];
vector <int> Vl;
void DFS(int n) {
	while (!conn[n].empty()) {
		auto it = conn[n].lower_bound(rand() % N + 1);
		if (it == conn[n].end()) it = prev(it);
		int t = *it;
		conn[n].erase(t);
		conn[t].erase(n);
		DFS(t);
	}
	Vl.push_back(n);
}

int main() {
	srand(135274);

	int M, i, j;
	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		oconn[t1].insert(t2);
		oconn[t2].insert(t1);
	}

	for (i = 1; i <= N; i++) if (oconn[i].size() % 2 != 0) return !printf("No\n");
	
	while (clock() < CLOCKS_PER_SEC*1.5) {
		for (i = 1; i <= N; i++) conn[i] = oconn[i];
		Vl.clear();

		DFS(1);
		Vl.pop_back();

		map <int, int> Mp;
		int d = INF, a1 = 0, a2 = 0;
		for (i = 0; i < 2 * Vl.size(); i++) {
			int t = Vl[i%Vl.size()];
			if (Mp.count(t)) {
				if (d > i - Mp[t]) {
					d = i - Mp[t];
					a1 = Mp[t];
					a2 = i;
				}
			}
			Mp[t] = i;
		}
		if (d >= Vl.size()) continue;

		map <int, int> Mc;
		a1++;
		for (i = 0; i < Vl.size(); i++) {
			if (a1 <= i && i <= a2) continue;
			if (a1 <= i + N && i + N <= a2) continue;
			Mc[Vl[i]]++;
		}
		for (auto it : Mc) if (it.second >= 2) return !printf("Yes\n");
	}
	return !printf("No\n");
}

Measured memory_bytes: 35256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  vector<ll> sum(N+1,0);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    sum.at(i+1)=sum.at(i)+A.at(i);
  }

  ll ss=sum.at(N);
  ll ans=INF;
  for(int i=0;i<=N;i++){
    ans=min<ll>(ans,abs<ll>(ss-2*sum.at(i)));
  }
  cout<<ans<<endl;
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

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

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<ll> T(2), A(2), B(2);
    cin >> T[0] >> T[1] >> A[0] >> A[1] >> B[0] >> B[1];

    vector<ll> L(2);
    L[0] = T[0] * A[0] + T[1] * A[1];
    L[1] = T[0] * B[0] + T[1] * B[1];
    if (L[0] == L[1] || A[0] == B[0]) {
        cout << "infinity" << endl;
        return 0;
    }
    if (L[0] < L[1]) {
        swap(A[0], B[0]);
        swap(A[1], B[1]);
        swap(L[0], L[1]);
    }
    if (A[0] >= B[0]) {
        cout << 0 << endl;
    } else {
        ll d = L[0] - L[1];
        ll k = (B[0] - A[0]) * T[0] / d;
        PRINT(d);
        PRINT(k);
        ll result;
        if ((B[0] - A[0]) * T[0] % d == 0) {
            result = 2 * k;
        } else {
            result = 2 * k + 1;
        }
        cout << result << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    vector<int> a(27);
    vector<char> b(s.size());
    for(int i = 0; i < s.size(); i++){
        b[i] = s[i];
    }
    sort(b.begin(),b.end());
    int cnt = 1,j = 0;
    for(int i = 1; i < s.size() + 1; i++){
        if(b[i] == b[i - 1])
        cnt++;
        if(b[i] != b[i - 1]){
            a[j] = cnt;
            cnt = 1;
            j++;
        }
    }
    bool ans = true;
    sort(a.begin(),a.end());
    for(int i = 0; i < 27; i++){
        if(a[i] % 2 != 0)
        ans = false;
    }
    if(ans)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    int n;
    cin >> n;
    int ans=0;
    for(int i=n;i<1000000000;++i) {
        int cnt=0;
        for(int j=1;j<=i;++j) {
            if(i%j==0) ++cnt;
        }
        if(cnt==2) {
            ans=i;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

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

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

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

    ll ans = INF;
    for(int i = 1; i < n; i++){
        ans = min(ans,abs(sum[i-1] - (sum[n-1] - sum[i-1])));
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n % 2 == 1) {
        cout << "No" << endl;
    } else if (s.substr(0, n / 2) == s.substr(n/2, n)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef pair<P,P> Edge;
typedef long long ll;

//ifstream ifs("input.txt");
//#define cin ifs

// 24ñÅ³ÉàÇé
class Dice{
private:
  int yoko;
  int tate;
  int round;

private:
    int face[3][4];

public:
  int getFace(const int idx)const{
    if(idx==0)
      return face[1][1];
    else if(idx==1)
      return face[2][1];
    else if(idx==2)
      return face[1][2];
    else if(idx==3)
      return face[1][0];
    else if(idx==4)
      return face[0][1];
    else if(idx==5)
      return face[1][3];
    return -1;
  }
  Dice(const vector<int> &v){
    init();
    face[1][1]=v[0];
    face[2][1]=v[1];
    face[1][2]=v[2];
    face[1][0]=v[3];
    face[0][1]=v[4];
    face[1][3]=v[5];
  }
private:
  // _CXÌú»
  void init(){
	  for(int i=0;i<3;i++)for(int j=0;j<4;j++)face[i][j]=-1;
    yoko=0;
    tate=0;
    round=0;
  }
public:
  // _CXÌñ]
  void rotate(){
    if(round<4){
    	int tmp = face[2][1];
    	face[2][1]=face[1][2];
    	face[1][2]=face[0][1];
    	face[0][1]=face[1][0];
    	face[1][0]=tmp;
    	round++;
    }
    if(round>=4){
    	round=0;
    	// àÇÁÄ«½çA¡ÌXbgðñ]³¹é
    	if(yoko<4){
    		int tmp = face[1][3];
    		for(int i = 2; i >= 0; i--){
    			face[1][i+1]=face[1][i];
    		}
    		face[1][0]=tmp;
    		yoko++;
    	}
    	// àÇÁÄ«½çAcÌXbgðñ]³¹é
    	if(yoko>=4){
    		if(tate<4){
    			tate++;
    			int tmp = face[1][3];
    			face[1][3]=face[0][1];
    			for(int i = 0; i < 2; i++){
    				face[i][1]=face[i+1][1];
    			}
    			face[2][1]=tmp;
    		}
    		if(tate>=4){
    			round=0;
    			tate=0;
    			yoko=0;
    		}
    	}
    }
  };
};

int main(){
	int n;
	while(cin>>n&&n!=0){
		map<string,int> dict;
		dict["Cyan"]=0;
		dict["Yellow"]=1;
		dict["Red"]=2;
		dict["Magenta"]=3;
		dict["Green"]=4;
		dict["Blue"]=5;
		vector<Dice> vd;
		for(int i=0;i<n;i++){
			vector<int> vs;
			for(int j=0;j<6;j++){
				string s;
				cin>>s;
				vs.push_back(dict[s]);
			}
			vd.push_back(Dice(vs));
		}
		int cnt=0;
		// ¡ÜÅÉo»µ½p^[ðo^
		set<vector<int> > svs;
		for(int i=0;i<n;i++){
			Dice &dice=vd[i];
			vector<int> vs2;
			// ¡ñÌÊðÂ­é
			for(int k=0;k<6;k++)
				vs2.push_back(dice.getFace(k));
			// ±ÌÊª¡ÜÅo»µÄ¢êÎAcontinue
			if(svs.find(vs2)!=svs.end())continue;
			// »¤ÅÈ¯êÎAJEgðâ·
			cnt++;
			// ¡ñÌ_CXÌSu«ûðo^
			for(int j=0;j<30;j++){
				vector<int> vs;
				for(int k=0;k<6;k++)
					vs.push_back(dice.getFace(k));
				// u«ûðo^
				svs.insert(vs);
				// _CXðñ]
				dice.rotate();
			}
		}
		// o»µ½p^[ÌðAn©çø­
		cout<<n-cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 976
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;
int N;
string S = "ACGT";
bool contain(string s) {
	int n = s.length();
	if (n <= 2) return false;
	
	rep(i, 0, n - 2) {
		string t = s.substr(i, 3);
		if (t == "AGC") return true;
	}

	return false;
}
string add(string s, char c) {
	string res = s + c;

	int n = res.length();
	if (n <= 2) return res;

	if (contain(res)) return "";

	rep(i, 0, n - 1) {
		string tes = res;
		swap(tes[i], tes[i + 1]);
		if (contain(tes)) return "";
	}

	if (4 <= n) res = res.substr(n - 3);

	return res;
}
void _main() {
	cin >> N;

	map<string, mint> dp;
	dp[""] = 1;

	rep(i, 0, N) {
		map<string, mint> pd;
		fore(p, dp) {
			fore(c, S) {
				string nxt = add(p.first, c);
				if (nxt != "") pd[nxt] += p.second;
			}
		}
		swap(dp, pd);
	}

	mint ans = 0;
	fore(p, dp) ans += p.second;
	cout << ans << endl;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
C = [input() for _ in range(H)]
ans = 0
for i in range(2**H):
    for j in range(2**W):
        res = [[0 for y in range(W)] for x in range(H)]
        for x in range(H):
            for y in range(W):
                if C[x][y] == '#':
                    res[x][y] = 1
        for x in range(H):
            if (i >> x) & 1:
                for y in range(W):
                    res[x][y] = 0
        for y in range(W):
            if (j >> y) & 1:
                for x in range(H):
                    res[x][y] = 0
        tmp = 0
        for x in range(H):
            for y in range(W):
                if res[x][y]:
                    tmp += 1
        if tmp == K:
            ans += 1
print(ans)

Measured memory_bytes: 74868
#include<cstdio>

#define rep(i, n) for ( int i = 0; i < n; i++ )
#define MAX 200
#define INFTY (1<<21)
int n, m, T[MAX][MAX], P[MAX][MAX];

void valid(int sx, int sy, int &lx, int &ly ){
    int ax = -1, ay;
    rep(y, m) rep(x, m){
	if ( P[x][y] == -1 ) continue;
	if ( P[x][y] != T[sx+x][sy+y] ) return;
	if ( ax == -1 ) {ay = y; ax = x;}
    }
    if ( ay < ly || (ay == ly && ax < lx) ) {ly = sy+ay; lx = sx+ax; }
}

bool rotate(int sx, int sy){
    int tmp[MAX][MAX];
    int ly = INFTY, lx;
    rep(r, 4){
	valid(sx, sy, lx, ly);
	rep(y, m) rep(x, m) tmp[x][y] = P[x][y];
	rep(y, m) rep(x, m) P[y][m-x-1] = tmp[x][y];
    }
    if ( ly == INFTY ) return false;
    printf("%d %d\n", lx+1, ly+1);
    return true;
}

void compute(){
    rep(y, n-m+1) rep(x, n-m+1) if ( rotate(x, y) ) return;
    printf("NA\n");
}

main(){
    while( scanf("%d %d", &n, &m) && n ){
	rep(y, n) rep(x, n) scanf("%d", &T[x][y]);
	rep(y, m) rep(x, m) scanf("%d", &P[x][y]);
	compute();
    }
}

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

int main(){
  long long N,K;
  cin >> N >> K;
  vector<long long> A(N),V(N,-1);
  for(int i=0;i<N;i++){
    cin >> A[i];
    A[i]--;
  }
  
  long long now = 0, step = 0;
  V[0] = 0;
  while(true){
    step++;
    long long next = A[now];
    
    if(now == next || step == K){
      cout << next+1 << endl;
      return 0;
    }
    if(V[next] != -1){
      long long x = ((K - step) % (step - V[next])) + V[next];
      for(int i=0;i<N;i++){
        if(V[i]==x){
          cout << i+1 << endl;
          return 0;
        }
      }
    }
    
    V[next] = step;
    now = next;
  }
  
  return 0;
}


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

#define LL long long

int main(){
	

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

	long double n,m,d;
	cin>>n>>m>>d;

	cout<<setprecision(13)<<fixed;
	if(d==0.0){
		cout<<(m-1)/n<<endl;
	}else{
		cout<<(m-1)*(2.0*(n-d))/(n*n)<<endl;
	}
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

bfr = 0
ans = 0

for i in range(2*n):
  idx = i//2
  if(i%2 == 0):
    nxt = min(a[idx]-bfr, b[idx])
  else:
    nxt = min(b[idx]-bfr, a[idx+1])
  ans += nxt
  bfr = nxt
  
print(ans)
  

        
      
    

Measured memory_bytes: 18476
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

struct UF {
	vector<int>par;//親
	vector<int>Rank;//木の深さ

            UF(int n){init(n);}

	//初期化
	void init(int n) {
		par.resize(n); Rank.resize(n);
		for (int i = 0; i < n; i++) {
			par[i]= i;
			Rank[i] = 0;
		}
	}

	//木の根を求める
	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

	//xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;//すでに同じ集合に属している

		if (Rank[x] < Rank[y]) {//高さが小さい方を下に
			par[x] = y;
		}
		else {
			par[y] = x;
			if (Rank[x] == Rank[y])Rank[x]++;//同じだとrankが変わらないままになるので増やす（それ以外は大きい方のrankが採用される）
		}
	}

	//xとyが同じ集合に属するかを判定
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int main() {
	ll n,m;
    cin>>n>>m;
    vector<ll>x(m),y(m),z(m);
    rep(i,m){
        cin>>x[i]>>y[i]>>z[i];
        x[i]--;y[i]--;
        }
    struct UF tree(n+1);
    rep(i,m){
        tree.unite(x[i],y[i]);
    }
    set<int>s;
    for(int i=0;i<n;++i){
        if(!s.count(tree.find(i)))s.insert(tree.find(i));
    }
    cout<<s.size()<<endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <map>
#include <cmath>
using namespace std;
int N,Z,W;
int V[2005];
int main()
{
    cin>>N>>Z>>W;
    for(int i=1;i<=N;i++)
        cin>>V[i];
    cout<<max(abs(W-V[N]),(N>1 ? abs(V[N-1]-V[N]):0));
    return 0;
}


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

int main()
{
    int a ,b ,i = 1 ;
    cin >> a >> b ;
    int nr = 0 ;
    if (b <= 9)
        nr = a * 10 + b ;
    else if ( b > 9 && b < 100)
        nr = a * 100 + b ;
    else if (b == 100)
        nr = a * 1000 + b ;
    /*if (sqrt(nr) == (int)sqrt(nr))
        cout << "Yes" ;
    else cout << "No" ;*/
    while (i*i <= nr)
    {
        i ++ ;
    }
    if ((i-1)*(i-1) == nr)
        cout << "Yes" ;
    else cout << "No" ;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)

int main(){
    int A,B,res;
    cin >> A >> B;

    res = (A*3 + B) / 2;
    cout << res << endl;
}



Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		long[] nums = new long[n];
    bool firstWin = false;
    for(int i = 0; i < n; i++)
    {
      nums[i] = long.Parse(Console.ReadLine());
      if(nums[i] % 2 == 1) firstWin = true;
    }
		Console.WriteLine((firstWin) ? "first" : "second");
	}
}

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


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

int main(){
  long long a;
  cin>>a;
  long long g=gcd(a,360);
  cout<<360/g<<endl;
  return 0;
}

Measured memory_bytes: 3564
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;


public class Main {
    private static int MOD = 1000000007;


    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String str = br.readLine();
        int k = Integer.parseInt(str);

        long total = 0;
        for (int i = 1; i <= k; i++) {
            for (int i1 = 1; i1 <= k; i1++) {
                for (int i2 = 1; i2 <= k; i2++) {
                    San s = new San(i, i1, i2);
                    int result = s.gcd();
                    total += result;
                }
            }
        }
        System.out.println(total);
    }


    static class San {
        public int a, b, c;

        public San(int a, int b, int c) {
            int[] is = {a, b, c};
            Arrays.sort(is);
            this.a = is[0];
            this.b = is[1];
            this.c = is[2];
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            San san = (San) o;
            return a == san.a &&
                    b == san.b &&
                    c == san.c;
        }

        @Override
        public int hashCode() {
            return Objects.hash(a, b, c);
        }

        public int gcd() {
            int g = Main.gcd(a, b);
            g = Main.gcd(g, c);
            return g;
        }
    }

    public static final int gcd(final int a, final int b) {
        return (b == 0) ? a : gcd(b, a % b);
    }
}


Measured memory_bytes: 42892
#include<stdio.h>
#define TRUE 1
#define FALSE 0

int n, A[20];

int search(int i, int m) {
  int res;
  if (m == 0) return TRUE;
  if(i >= n) return FALSE;
  res = search(i+1, m) || search(i+1, m-A[i]);
  return res;
}

int main() {
  int q, i, B[200], x;

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

  for(i = 0; i < q; i++) {
    x = search(0, B[i]);
    if(x == TRUE) printf("yes\n");
    if(x == FALSE) printf("no\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
#include<math.h>
int main() {

	
	long long int x;
	long long int k;
	long long int d;
	long long int i;
	

	scanf("%lld", &x);
	scanf("%lld", &k);
	scanf("%lld", &d);
	x = fabs(x);
	/*for (long long int i = 0;i < k;i++)
	{
		if (x > 0)
		{
			x -= d;
		}
		else
		{
			x += d;
		}
	}*/
	if (x / d < k)
	{
		for (i = 0;i<k;i++)
		{
				x -= d;
				if (x < 0)
				{
					break;
				}	
		}
		if ((k - i) % 2 == 0)
		{
			x += d;
		}
	}
	else
		x -= d*k;
	x = fabs(x);
	
	printf("%lld", x);
	
	return 0;
}

Measured memory_bytes: 1736
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define M 1000000007LL
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(v) ((ll)v.size())
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pii pair<ll,ll> 
#define mod 998244353LL
#define MAXN 300002
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
vector< pii > v;
int main() {
       ios::sync_with_stdio(false);
       cin.tie(0);
       cout.tie(0);
        ll n;
        cin>>n;
        vector<pii> ans;
        ll i,j;
          for(i=1;i<=n;i++)
          {
            for(j=i+1;j<=n;j++)
            {
              if(i+j!=(n+(n%2==0))) ans.pb({i,j});
            }
          }
          cout<<ans.size()<<endl;
          for(auto it: ans)
            cout<<it.F<<" "<<it.S<<endl;
        return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll lcm(ll a,ll b) { return a/GCD(a, b)*b; }

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b,c,d; cin>>a>>b>>c>>d;
  ll l = lcm(c,d);
  ll ans=b-a+1-(b/c-(a-1)/c+b/d-(a-1)/d - (b/l-(a-1)/l));
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int n;
	cin>>n;
	vector<ll> d(n);
	for(int i=0;i<n;i++){
		cin>>d[i];
	}
	sort(d.begin(),d.end());
	cout<<d[n/2]-d[n/2-1]<<endl;


	return 0;
}


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


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


ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}

int main(){
    ll A, B; cin>>A>>B;
    cout<<lcm(A, B)<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double


int main(void)
{
    int n[4];
    rep(i,4)
    {
        cin >> n[i];
    }

    sort(n, n+4);
    if(n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9)
        cout << "YES" << endl;
    else
        cout << "NO" << 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;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int n; cin >> n;
    //if(n < 105) cout << 0 << endl;
    int ans, num;
    ans = 0;
    for(int i = 1; i < n + 1; i = i + 2){
        num = 0;
        for(int j = 1; j < i + 1; j = j + 2){
            if(i % j == 0) num++;
            if(num == 9) break;
        }
        if(num == 8) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdio.h>
int main()
{

    int x, alph[26] = {0}, i;
    char c;

    for (i = 0; i < 1200; i++)
    {

        scanf("%c", &c);

        if (c >= 'A' && c <= 'Z')
        {

            x = c - 'A';

            alph[x]++;
        }
        else if (c >= 'a' && c <= 'z')
        {

            x = c - 'a';

            alph[x]++;
        }
    }

    for (i = 0; i < 26; i++)
    {

        printf("%c : %d\n", 'a' + i, alph[i]);
    }

    return 0;
}




Measured memory_bytes: 2104
import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner in=new Scanner(System.in);
      	String S=in.next();
      	String res;
      	if(S.equals("Sunny")){
        	res="Cloudy";
        }
        else if(S.equals("Cloudy")){
        	res="Rainy";
        }
        else{
        	res="Sunny";
        }
      	System.out.println(res);
        in.close();
    }      
}

Measured memory_bytes: 20948
#include <cstdio>
#include <cmath>
int main() {
	double n, m, a, p[1000];
	while (scanf("%lf", &n), n != 0) {
		m = 0;
		a = 0;
		for (int i = 0; i < n; i++) {
			scanf("%lf", &p[i]);
			m += p[i];
		}
		m /= n;
		for (int i = 0; i < n; i++)
			a += pow(p[i] - m, 2);
		printf("%f\n", sqrt(a / n));
	}
}

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

int main() {
  string s;
  cin >> s;
  
  int price = 700;
  if (s.at(0) == 'o') price += 100;
  if (s.at(1) == 'o') price += 100;
  if (s.at(2) == 'o') price += 100;
  
  cout << price << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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


#define MAX 1000000
#define MOD 998244353

ll fac[MAX], finv[MAX], inv[MAX];

void CombInit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR(i, 2, MAX) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll comb(int n, int k)
{
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(int argc, char **argv)
{
    int N, M, K;
    cin >> N >> M >> K;

    CombInit();

    ll m0e[N];
    ll m1e[N];
    m0e[0] = 1;
    m1e[0] = 1;
    REP(i, N - 1) {
        m0e[i + 1] = (m0e[i] * M) % MOD;
        m1e[i + 1] = (m1e[i] * (M - 1)) % MOD;
    }
    ll total = 0;

    REP(i, K + 1) {
        // N-1 C K
        ll c = M;
        c = (c * comb(N - 1, i)) % MOD;
        //c = (c * m0e[i]) % MOD;
        //c = (c * comb(N - 1, N - 1 - i)) % MOD;
        c = (c * m1e[N - 1 - i]) % MOD;
        total = (total + c) % MOD;
        //cout << c << ", " << total << endl;
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 30164
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::lowest();
using namespace std;

constexpr int PRIME_LIM = 55555;
std::vector<bool> isprime(PRIME_LIM + 1, true);
std::vector<int> prime;
int a = 0;

void calc_prime() {
  isprime[0] = false;
  isprime[1] = false;
  for (int i = 2; i < isprime.size(); i++) {
    if (!isprime[i]) {
      continue;
    }
    prime.push_back(i);
    for (int x = i + i; x < isprime.size(); x += i) {
      isprime[x] = false;
    }
  }
}

void solve() {
  int N;
  cin >> N;

  calc_prime();
  vector<int> ans;
  for (int x : prime) {
    if (x % 5 == 1) {
      ans.push_back(x);
    }
  }

  cout << ans[0];
  for (int i = 1; i < N; i++) {
    cout << " " << ans[i];
  }
  cout << endl;
}

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


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

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

int main() {
  int N, M;
  cin >> N >> M;
  int remain = N;
  rep(i, M) {
    int tmp; cin >> tmp;
    remain -= tmp;
  }
  int ans = remain;
  if (ans < 0) ans = -1;
  cout << ans << "\n";
}


Measured memory_bytes: 3572
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import sys

sys.setrecursionlimit(10000)
INF = float('inf')


class UnionFind:
    def __init__(self, nodes):
        """
        :param collections.Iterable nodes:
        """
        self._parents = {k: k for k in nodes}
        self._ranks = {k: 0 for k in nodes}
        self._sizes = {k: 1 for k in nodes}

    def union(self, x, y):
        """
        x が属する木と y が属する木を併合
        :param x:
        :param y:
        :return:
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            # rank が小さい方が下
            if self._ranks[x] > self._ranks[y]:
                self._parents[y] = x
                self._sizes[x] += self._sizes[y]
            else:
                self._parents[x] = y
                self._sizes[y] += self._sizes[x]
                if self._ranks[x] == self._ranks[y]:
                    self._ranks[y] += 1

    def find(self, x):
        """
        x が属する木の root
        :param x:
        :return:
        """
        if self._parents[x] == x:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]

    def size(self, x):
        """
        x が属する木のノード数
        :param x:
        :return:
        """
        return self._sizes[self.find(x)]


N, M = list(map(int, input().split()))
P = list(map(int, input().split()))

uf = UnionFind(range(N + 1))
for _ in range(M):
    x, y = list(map(int, input().split()))
    uf.union(x, y)

ans = 0
for i in range(N):
    if uf.find(P[i]) == uf.find(i + 1):
        ans += 1

print(ans)


Measured memory_bytes: 51164
a,b = map(int,input().split())
if a!=1 and b!=1:
  if a %2 == 0:
    #たて一列でぬれるのは
    c = int(a/2)
    print(c*b)
  else:
  #たて一列目は
    d = int((a+1)/2)
    e = int((a-1)/2)
    if b %2 == 0:
      print(int((d+e)/2*b))
    else:
      print(int((d+e)/2*(b-1)+d))
else:
  print(1)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
#define PI 3.141592
using namespace std;

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

	for (int i = 0; i < m; i++) {
		int tmp;
		cin >> tmp;
		sums[tmp] = -1;
	}

	sums[0] = 1;
	if (sums[1] == 0) {
		sums[1] = 1;
	}

	for (int i = 2; i < n + 1; i++) {
		if (sums[i] == -1)continue;
		if (sums[i - 1] != -1) {
			sums[i] = ((ll int)sums[i] + (ll int)sums[i - 1]) % MOD_P;
		}
		if (sums[i - 2] != -1) {
			sums[i] = ((ll int)sums[i] + (ll int)sums[i - 2]) % MOD_P;
		}
	}

	printf("%d", sums[n]);
	
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using System.Threading;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string s1 = S.Substring(0, (S.Length - 1) / 2);
            string s2 = S.Substring((S.Length + 3-1 ) / 2);
            if (s1 == s2)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

//文字列の入力
//string s = Console.ReadLine();
//整数の入力
//long n = long.Parse(Console.ReadLine());
//文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');
//整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine();
//Console.ReadKey();

Measured memory_bytes: 13140
#include<stdio.h>

void PrintArray(int a[], int N) {
	int i;
	for (i = 0; i < N; i++) {
		printf("%d", a[i]);
		if (!(i - N + 1)) break;
		printf(" ");
	}
	printf("\n");
}

void BubbleSort(int a[], int N) {
	int i, j, buff, cnt = 0;
	for (i = 0; i < N; i++) {
		for (j = N - 1; j > i; j--) {
			if (a[j] < a[j - 1]) {
				buff = a[j];
				a[j] = a[j - 1];
				a[j - 1] = buff;
				cnt++;
			}
		}
	}
	PrintArray(a, N);
	printf("%d\n", cnt);
}

int main() {
	int a[100], N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++)scanf("%d", &a[i]);
	BubbleSort(a, N);


	return 0;
}


Measured memory_bytes: 2708
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define N (1000000000+7)
#define INF (ll)1e16
typedef long long ll;

int main(void){
    ll n,k,ans=0;
    cin>>n>>k;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];

    for(ll i=0;i<n;i++){
        ll x=0,y=0;
        for(ll j=0;j<n;j++){
            if(i==j)continue;
            if(a[i]>a[j]){
                x++;
                if(i<j)y++;
            }
        }
        ans=(ans+((y*k)%N+(((k*(k-1)/2)%N)*x)%N)%N)%N;
    }
    cout<<ans<<endl;
    return 0;
}

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

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);

		int n;
		n = Integer.parseInt(reader.readLine());

		System.out.println((n * 800) - ((n / 15) * 200));

		reader.close();
	}
}

Measured memory_bytes: 21072