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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

// ...
// .#.
// ...
// ...



// ......
// #.....
// ......
// ......
// ......
//
// RLDRRUDDLRL
// URRDRLLDLRD

// ...
// .#.
//
// RRL
// LUD


int main() {
	int H, W, N;
	cin >> H >> W >> N;
	int sr, sc;
	cin >> sr >> sc;
	string S, T;
	cin >> S >> T;

	//みぎ
	{
		pair<int, int> pos = { sr,sc };
		for (int i = 0; i < N; i++) {
			if (pos.second == W && S[i] == 'R') {
				cout << "NO" << endl;
				return 0;
			}
			else if (S[i] == 'R')pos.second++;
			if (pos.second != 1 && T[i] == 'L')pos.second--;
		}
	}
	//ひだり
	{
		pair<int, int> pos = { sr,sc };
		for (int i = 0; i < N; i++) {
			if (pos.second == 1 && S[i] == 'L') {
				cout << "NO" << endl;
				return 0;
			}
			else if (S[i] == 'L')pos.second--;
			if (pos.second != W && T[i] == 'R')pos.second++;
		}
	}
	//うえ
	{
		pair<int, int> pos = { sr,sc };
		for (int i = 0; i < N; i++) {
			if (pos.first == 1 && S[i] == 'U') {
				cout << "NO" << endl;
				return 0;
			}
			else if (S[i] == 'U')pos.first--;
			if (pos.first != H && T[i] == 'D')pos.first++;
		}
	}
	//した
	{
		pair<int, int> pos = { sr,sc };
		for (int i = 0; i < N; i++) {
			if (pos.first == H && S[i] == 'D') {
				cout << "NO" << endl;
				return 0;
			}
			else if (S[i] == 'D')pos.first++;
			if (pos.first != 1 && T[i] == 'U')pos.first--;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc166/abc166_e.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> c(N);
  vector<int> h(N);
  rep(i, N) {
    cin >> c[i];
    h[i] = c[i] - i;
  }
  sort(h.begin(), h.end());

  ll ans = 0;
  rep(i, N) {
    // printf("i:%d\n", i);
    auto comps = [&](int x) -> bool {
      // printf("-- %d %d\n", x, c[i]);
      return x + c[i] + i < 0;
    };
    auto compe = [&](int x) -> bool { return x + c[i] + i < 1; };
    auto s = partition_point(h.begin(), h.end(), comps);
    auto e = partition_point(h.begin(), h.end(), compe);
    ans += e - s;
  }

  cout << ans << endl;
}

Measured memory_bytes: 4792
N = int(input())
A = list(map(int,input().split()))
A = [0] + A
res = [0]*(N+1)
M = 0

for i in range(N,0,-1):
  if sum(res[j] for j in range(i,N+1,i)) % 2 != A[i]:
    res[i] = 1
    M += 1
    
print(M)
print(*[k for k, r in enumerate(res) if r])

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

using namespace std; 
#define ll long long
#define ld long double
void findDivisors(ll n) 
{ 
  
    // Array to store the count 
    // of divisors 
    ll div[n + 1]; 
    memset(div, 0, sizeof div); 
  
    // For every number from 1 to n 
    for (ll i = 1; i <= n; i++) { 
  
        // Increase divisors count for 
        // every number divisible by i 
        for (ll j = 1; j * i <= n; j++) 
            div[i * j]++; 
    } 
  	ll ans=0;
    // Print the divisors 
    for (int i = 1; i <= n; i++) 
    {
    	ans+=div[i]*i;
    }
    cout << ans << "\n";
} 
int main()
{
	ll n;
	cin >> n;
	findDivisors(n);
}

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

int main() {

	ll n; cin >> n;
	map<ll, ll> mp;
	for (int i = 0; i < n; i++) {
		ll a; cin >> a;
		mp[a]++;
	}
	ll cnt = 0;
	for (auto u : mp) {
		if (1 < u.second) cnt++;
	}
	string ans = "YES";
	if (1 <= cnt) ans = "NO";
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15980
#include <bits/stdc++.h>
#define FASTIO
#define endl "\n" // Since endl forces a buffer flush which slows down large I/O operations.
#define ff first
#define ss second
#define pb push_back
#define input(c, n)             \
	for (int i = 0; i < (n); i++) \
		cin >> (c)[i];
#define exit_message(s) return 0 * printf(s)
#define show(c)           \
	for (auto i : (c))      \
		cout << i << " "; \
	cout << "\n";
#define display(c, n)           \
	for (int i = 0; i < (n); i++) \
		cout << (c)[i] << " ";    \
	cout << "\n";
#define forl(i, a, n) for (int (i) = (a); (i) < (n); (i)++)
#define dugbe(k) cout << "-\t> " << #k << " = " << k << "\n";

/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/

using namespace std;
typedef long long ll;
typedef pair<int, int> pr;
typedef pair<ll, ll> prll;
typedef vector<int> vi;
typedef vector<ll> vill;
typedef vector<pr> vpr;
ifstream in("input.txt");
const ll mod = 1e9 + 7;

ll mod_pow(ll a, ll b)
{
	if (b == 0)
		return 1LL;

	ll res = mod_pow(a, b >> 1);
	res = (res * res) % mod;
	if (b & 1LL)
		res = (res * a) % mod;

	return res;
}

const int N = 300 + 5;

double n;
int a[N];
double cache[N][N][N];

double find(int a, int b, int c)
{
	// a = 1, b = 2, c = 3, d = 0

	int d = n - a - b - c;
	int total = a + b + c;

	if (a < 0 || b < 0 || c < 0)
		return 0.0;

	if (total == 0)
		return 0.0;

	double &memo = cache[a][b][c];

	if (memo != 0)
		return memo;

	double zerolol = 1.0 / ( (1.0 - (d / n)) * (1.0 - (d / n)) );
	// zerolol accounts for the selection of zero sushi in a move.
	// It is the summation of an infinite GP.
	memo = (a / n) * zerolol + (a / (n - d)) * find(a - 1, b, c);
	memo += (b / n) * zerolol + (b / (n - d)) * find(a + 1, b - 1, c);
	memo += (c / n) * zerolol + (c / (n - d)) * find(a, b + 1, c - 1);
	return memo;
}

int32_t main()
{
#ifdef FASTIO
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#endif
	// freopen("in.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	memset(cache, 0, sizeof cache);

	cin >> n;
	int f[4] = {};
	forl(i, 0, n)
	{
		cin >> a[i];
		f[a[i]]++;
	}
	double ans = find(f[1], f[2], f[3]);
	cout << fixed << setprecision(10) << ans << "\n";

	// forl (i, 0, 4) forl(j, 0, 4) forl(k, 0, 4)
	// 	if (cache[i][j][k] != 0)
	// 		cout <<	 "a : " << i << " b : " << j << " c : " << k << " " << cache[i][j][k] << "\n";

	return 0;
}

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

#define ll long long
#define pii pair<ll,ll>

using namespace std;

int main(void)
{
   ll sum = 0;
   string s;
   cin>>s;

   for(char c: s)
   {
       sum += (int)(c-'0') ;
   }

   if(sum%9 == 0)
   {
       cout << "Yes" << endl;
   }
   else
   {
       cout << "No" << endl;
   }
   
}

Measured memory_bytes: 3716
#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
#include <bitset>
#include <cstdint>
#include <stdexcept>
using namespace std;

// 整数型

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

// [0,n)を昇順/降順でループ

#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)

// [a,b)を昇順/降順でループ

#define FOR(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)

// デバッグ

#ifdef DEBUG
#include <cassert>
#define my_assert(x) assert(x)
#else
#define my_assert(x)
#define assert(x)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // 浮動小数の表示の精度
    cout << setprecision(15);

    int n;
    cin >> n;
    vector<i64> l_s(n);
    rep(i, n)
    {
        cin >> l_s[i];
    }
    int ans = 0;
    rep(i, n)
    {
        FOR(j, i + 1, n)
        {
            FOR(k, j + 1, n)
            {
                if (l_s[i] == l_s[j] or l_s[j] == l_s[k] or l_s[k] == l_s[i])
                {
                    continue;
                }
                if (l_s[i] + l_s[j] > l_s[k] and l_s[j] + l_s[k] > l_s[i] and l_s[k] + l_s[i] > l_s[j])
                {
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<int>;
using Vll = vector<ll>;
using VV = vector<V>;
using VVV = vector<VV>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << '\n'; return os; }
inline int popcount(const int x) { return __builtin_popcount(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;


int main() {
  int n; cin >> n;
  VV xy(2, V(n));
  Vll p(n);
  rep(i, n) cin >> xy[0][i] >> xy[1][i] >> p[i];

  int N = 1<<n;
  VVV dst(2, VV(n, V(N)));

  rep(i, 2) rep(S, N) {
    VV res(n, V(n+1, INF));
    rep(j, n) rep(k, n) if (S>>k&1) res[j][k] = abs(xy[i][j]-xy[i][k]);
    rep(j, n) res[j][n] = abs(xy[i][j]);
    rep(j, n) dst[i][j][S] = *min_element(all(res[j]));
  }

  Vll ans(n+1, INFll);

  rep(S, N) drep(T, S+1) {
    T &= S;
    int U = S^T;
    ll res = 0;
    rep(i, n) res += p[i] * min(dst[0][i][T], dst[1][i][U]);
    int k = popcount(S);
    chmin(ans[k], res);
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 9348
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,f=0;
	cin>>n;
	while(n>0){
		if(n%10==7)f=1;
		n/=10;
	}
	if(f)cout<<"Yes";else cout<<"No";
	return 0;
}

Measured memory_bytes: 3608
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,a[100111];
int main()
{
	get1(n);
	for(int i=1;i<=n;i++)get1(a[i]);
	LL tl=2,tr=2;
	for(int i=n;i>=1;i--)
	{
		tl=(tl+a[i]-1)/a[i]*a[i];
		tr=tr/a[i]*a[i];
		if(tl>tr)
		{
			puts("-1");
			return 0;
		}
		tr+=a[i]-1;
	}
	printf("%lld %lld\n",tl,tr);
	return 0;
}

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

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

constexpr int MAX_N = 1e5;
constexpr int INF = 1e9+9;


int h[MAX_N];
int dp[MAX_N+1];

int main() {
  int N; cin >> N;
  for (int i{}; i < N; ++i) cin >> h[i];

  fill_n(dp, MAX_N+1, INF);
  dp[0] = 0;
  for (int i{}; i < N-1; ++i) {
    chmin(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
    chmin(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
  }

  cout << dp[N-1] << endl;
  return 0;
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    set<int> st;
    rep(i, n){
        int a;
        cin >> a;
        if(st.count(a)){
            st.erase(a);
        }else{
            st.insert(a);
        }
    }
    cout << st.size() << endl;
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> map(H);
  int count;
  for (int i=0; i < H; i++) {
    cin >> map.at(i);
  }
  for (int i=0; i < H; i++) {
    for (int j=0; j < W; j++) {
      if (map.at(i).at(j) == '#') {
        cout << '#';
        if (j == W - 1) {
          cout << endl;
        }
        continue;
      }
      count = 0;
      for (int k=i-1; k <= i+1; k++) {
        for (int L=j-1; L <= j+1; L++) {
          if (k >= 0 && k < H && L >= 0 && L < W && map.at(k).at(L) == '#') {
            count++;
          }
        }
      }
      cout << count;
      if (j == W - 1) {
        cout << endl;
      }
    }
  }
}


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

int main() {
	int n,l,i,j;
	cin >> n>> l;
	string s[n];
	for(i=0;i<n;i++){
			cin >> s[i];
		}
	string tmp,sum;
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(s[i]>s[j]){
				tmp=s[i];
				s[i]=s[j];
				s[j]=tmp;
			}
		}
	}
	for(i=0;i<n;i++){
		sum += s[i];
	}
	cout << sum << "\n";
}


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

using namespace std;

int hoge(int a, int b, int k, int n) {
  if (k == 0)
    return (a == b && a <= n);

  if (k <= 1)
    return (a * 10 + b <= n);

  int vmin = a * pow(10, k) + b;
  int vmax = a;
  for (int i = 0; i < k; ++i)
    vmax = (i == k -1) ? vmax * 10 + b : vmax * 10 + 9;

  if (n < vmin)
    return 0;
  else if (n < vmax)
    return (n - vmin) / 10 + 1;
  return (vmax - vmin) / 10 + 1;
}

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

  long long sum = 0;
  for (int k = 0; k < 6; ++k) {
    for (int l = 0; l < 6; ++l) {
      for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 10; ++j) {
          long long cnt1 = hoge(i, j, k, n);
          long long cnt2 = hoge(j, i, l, n);
          sum += cnt1 * cnt2;
        }
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int M = 520000;
typedef long long ll;
int n,m,k;
int hd;
int tl;
vector<int> g[M];
char s[M];
bool vs[M]={0};
int main(){
    cin>>s;
    n=strlen(s);
    fo(i,1,n-2){
        g[i].push_back(i-1);
        g[i].push_back(i+1);
    }
    if(n>1){
        g[0].push_back(1);
        g[n-1].push_back(n-2);
    }
    hd=0;
    tl=n-1;
    cin>>m;
    int cnt=n;
    char c[10];
    fo(i,1,m){
        cin>>k;
        if(k==1){
            swap(hd,tl);
        }
        else{
            cin>>k>>c;
            s[cnt]=c[0];
            if(k==1) {
                g[cnt].push_back(hd);
                g[hd].push_back(cnt);
                hd=cnt;
            }
            else{
                g[tl].push_back(cnt);
                g[cnt].push_back(tl);
                tl=cnt;
            }
            cnt++;
        }
    }
    int u=hd;
    queue<int> q;
    q.push(u);
    vs[u]=1;
    while(!q.empty()){
        u=q.front();
        q.pop();
        cout<<s[u];
        for(int to:g[u]){
            if(vs[to]) continue;
            vs[to]=1;
            q.push(to);
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 22656
import java.io.*;
import java.text.*;
import java.util.*;

public class Main {

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        solver s = new solver();
        int t = 1;
        while (t > 0) {
            s.solve();
            t--;
        }
        out.close();
    }

    static class InputReader {

        public BufferedReader br;
        public StringTokenizer token;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream), 32768);
            token = null;
        }

        public String sn() {
            while (token == null || !token.hasMoreTokens()) {
                try {
                    token = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return token.nextToken();
        }

        public int ni() {
            return Integer.parseInt(sn());
        }

        public String snl() throws IOException {
            return br.readLine();
        }

        public long nlo() {
            return Long.parseLong(sn());
        }

        public double nd() {
            return Double.parseDouble(sn());
        }

        public int[] na(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.ni();
            return a;
        }

        public long[] nal(int n) {
            long a[] = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.nlo();
            return a;
        }
    }

    static int inf = 5000013;

    static class solver {
        DecimalFormat df = new DecimalFormat("0.00000000000000000000");
        long max = 1000000000000000l, min = -10000000000000000l;
        long mod = (long) 1e9 + 7;

        long pro(long a, long b) {
            return (a % mod * b % mod) % mod;
        }

        long add(long a, long b) {
            return (a + b) % mod;
        }

        long sub(long a, long b) {
            return ((a % mod - b % mod) + mod) % mod;
        }

        long ncr3(long n) {
            return (n * (n - 1) * (n - 2)) / 6l;
        }

        long ncr2(long n) {
            return n * (n - 1) / 2l;
        }

        long modPow(long x, long y) {
            long res = 1;
            x = x % mod;
            while (y > 0) {
                if (y % 2 != 0)
                    res = pro(res, x);
                x = pro(x, x);
                y = y >> 1;
            }
            return res;
        }

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

        final int maxn = 1000005;

        void solve() {
            int n = sc.ni();
            int a[] = new int[n];
            for (int i = 1; i < n; i++) {
                int t = sc.ni() - 1;
                a[t]++;
            }
            for (int h : a)
                out.println(h);
        }
    }
}


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

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadLong();
        var M = sc.ReadLong();
        var max = (double)M / N;
        for (long i = (long)max; i >= 1; i--)
        {
            var x = M - (i * (N - 1));
            if (x % i == 0)
            {
                Console.WriteLine(i);
                return;
            }
        }
    }
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 13140
from collections import defaultdict, deque
from heapq import heappop, heappush
import sys
input = sys.stdin.readline

N, M, P = map(int, input().split())
d = defaultdict(list)
e = defaultdict(list)
cd = defaultdict(list)
l = []

for _ in range(M):
    a, b, c = map(int, input().split())
    cd[a].append((b, P-c))
    d[a].append(b)
    e[b].append(a)

def check_visited(d, start):
    visited = [False]*(N+1)
    visited[start] = True
    q = deque([start])
    while q:
        s = q.popleft()
        for t in d[s]:
            if visited[t]:continue
            visited[t] = True
            q.append(t)
    
    s = set()
    for i in range(1, N+1):
        if visited[i]:
            s.add(i)
    return s

def shortest_path(s):
    INF = 10**18
    dist = [float("inf")]*(N+1)
    dist[s] = 0

    for i in range(N):
        for a, b, c in l:
            if dist[b]>dist[a]+c:
                dist[b] = dist[a]+c
                if i==N-1:
                    return dist, True
    return dist, False

add_l = check_visited(d, 1)&check_visited(e, N)
for a in add_l:
    for b, c in cd[a]:
        l.append((a, b, c))
d1, neg = shortest_path(1)
if neg:
    print(-1)
elif d1[N]<0:
    print(-d1[N])
else:
    print(0)


Measured memory_bytes: 49112
#include <cstdio>
#include <vector>
const int MAXN = 605;
double dp[MAXN];
std::vector<int> G[MAXN];
int M, N;

// 1. Fix an edge to block
// 2. Try blocking every edge
// 3. Only need to consider blocking worst outgoing edge for each node
// 4. Try blocking worst edge for each node

double solve(int node) {
    // Block outgoing edges from `node` only
    for (int i = 1; i <= N; ++i) {
        dp[i] = 0.0;
    }
    for (int i = N-1; i >= 1; --i) {
        int K = G[i].size();
        if (K == 1) {
            dp[i] = dp[G[i][0]] + 1.0;
            continue;
        }
        double max = 0.0;
        double sum = 0.0;
        int skip = 1;
        for (auto nxt: G[i]) {
            sum += dp[nxt];
            max = std::max(dp[nxt], max);
        }
        if (i != node) {
            max = 0.0;
            skip = 0;
        }
        dp[i] = 1.0 * (sum - max) / (K - skip) + 1.0;
    }
    return dp[1];
}

int main() {
    scanf(" %d%d", &N, &M);
    for (int i = 0; i < M; ++i) {
        int s, t;
        scanf(" %d%d", &s, &t);
        G[s].push_back(t);
    }
    double ret = N;
    for (int i = 1; i <= N; ++i) {
        ret = std::min(solve(i), ret);
    }
    printf("%.9f\n", ret);
    return 0;
}

Measured memory_bytes: 1408
n, k = map(int, input().split())
a = list(set(map(int, input().split())))
if k>max(a):
    print('IMPOSSIBLE')
    exit()

def gcd_base(a, b):
    while b!=0:
        a, b = b, a%b
    return a

def gcd(num_list):
    ans = 0
    for i in num_list:
        ans = gcd_base(ans, i)
    return ans

if k%gcd(a)==0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

int main() {
    int N; cin >> N;
    ll tnow, anow; cin >> tnow >> anow;
    rep(i, N-1){
        ll t, a; cin >> t >> a;
        ll x = ((tnow-1) / t) + 1;
        ll y = ((anow-1) / a) + 1;
        ll z = max(x, y);
        tnow = t*z;
        anow = a*z;
    }

    cout << tnow + anow << endl;

    return 0;
}

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

int main(){
    string A, B;
    cin >> A >> B;
    int n = A.length(), m = B.length();
    int d[n + 1][m + 1];
    for(int i = 0; i < n + 1; i++)
        d[i][0] = i;
    for(int i = 0; i < m + 1; i++)
        d[0][i] = i;
    for(int i = 1; i < n + 1; i++)
        for(int j = 1; j < m + 1; j++){
            d[i][j] = min({d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + (int)(A[i - 1] != B[j - 1])});
        }
    cout << d[n][m] << endl;
    return 0;
}


Measured memory_bytes: 7060
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,m,x[N][N][2],wh;
bool dp[81][81][12801];
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>x[i][j][0];
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>x[i][j][1];
	dp[0][0][6400+x[0][0][0]-x[0][0][1]]=true;
	dp[0][0][6400+x[0][0][1]-x[0][0][0]]=true;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			for(int k=0;k<=12800;k++)
			{
				int cha=x[i][j][0]-x[i][j][1];
				if(i>=1)
				{
					if(k+cha>=0)dp[i][j][k+cha]|=dp[i-1][j][k];
					if(k-cha>=0)dp[i][j][k-cha]|=dp[i-1][j][k];
				}
				if(j>=1)
				{
					if(k+cha>=0)dp[i][j][k+cha]|=dp[i][j-1][k];
					if(k-cha>=0)dp[i][j][k-cha]|=dp[i][j-1][k];
				}
			}
		}
	}
	int ans=1e9;
	for(int i=0;i<=12800;i++)
	{
		if(dp[n-1][m-1][i])
		{
			ans=min(ans,abs(6400-i));
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 82176
N = int(input())
A = list(map(int, input().split()))

i = 0
count = -1
flg = True
while flg:
	count += 1
	for i in range(N):
		if A[i]%2 == 1:
			flg = False
		A[i] = A[i]/2
		i += 1

print(count)

Measured memory_bytes: 3064
import scala.io.Source.stdin

object Main {
  def sieve(n:Int) = {
    val primes = Array.tabulate(n+1) { _ % 2 }
    primes(1) = 0
    primes(2) = 1

    for( i <- 3 to Math.sqrt(n).toInt by 2 )
      if(primes(i) == 1)
        (i*i to n by i*2).foreach { primes(_) = 0 }
    primes
  }

  def main(args:Array[String]) = {
    val p = sieve(51000)
    for(i <- stdin.getLines){
      val n = i.toInt
      val l = (n+1 to 51000).find(p(_)==1).get
      val s = (n-1 to 1 by -1).find(p(_)==1).get
      println(s + " " + l)
    }
  }
}

Measured memory_bytes: 44916
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979
int main()
{
    rep(i, 5)
    {
        int x;
        cin >> x;
        if (x == 0)
        {
            cout << i + 1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main(){
    int a, b;
    string op;
    while (1){
        cin >> a >> op >> b;
        if (op == "+"){
            cout << a + b << endl;
        } else if (op == "-"){
            cout << a - b << endl;
        } else if (op == "*"){
            cout << a * b << endl;
        } else if (op == "/"){
            cout << a / b << endl;
        } else{
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 3132
#include <iostream>

using namespace std;

long long func(long long a) {
    if (a % 2 == 0)
        return a / 2;
    else
        return 3 * a + 1;
}

int main() {
    long long i, s, p, q;
    int a[1000001] = {0};
    cin >> s;
    q = s;
    a[s]++;
    for (i = 2; i <= 1000000; i++) {
        long long p = func(q);
        a[p]++;
        if (a[p] == 2) {
            cout << i << endl;
            return 0;
        }
        q = p;
    }

    return 0;
}

Measured memory_bytes: 4224
def myAnswer(a:int,b:int) -> str:
   # ゼロがまたがっている場合はzero ex)-1 2
   if(a <= 0 and b >= 0): return "Zero"
   
   if(a < 0):# aが負の数で
      if(b < 0): # bも負の数だった場合は,負の数の個数をカウントし、奇数ならNegative,偶数ならポジティブ
         return "Negative" if((abs(a-b) + 1)%2==1) else "Positive"
   else:
      return "Positive"


def modelAnswer():
   tmp=1
def main():
   a,b = map(int,input().split())
   print(myAnswer(a,b))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3060
#include <string>
#include <iostream>
#include <map>
using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, N, L;
	string S[100];

	cin >> N >> L;
	for (i = 0; i < N; i++)cin >> S[i];

	for (i = 0; i < N-1; i++) {
		for (j = N-1; j >= i+1; j--) {
			for (k = 0; k < L; k++) {
				if ((S[j][k] - 'a') != (S[j - 1][k] - 'a')) {
					if ((S[j][k] - 'a') < (S[j - 1][k] - 'a')) {
						string t = S[j];
						S[j] = S[j - 1];
						S[j - 1] = t;
					}
					break;
				}

			}
		}
	}
	for (i = 0; i < N; i++)cout << S[i] ;
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N, T, A;
    cin >> N >> T >> A;
    vector<int> H(N);
    for(int i = 0; i < N; i++)
        cin >> H.at(i);
    double min = 1000000000.0;        
    int ret = 1;
    for(int i = 0; i < N; i++)
    {
        // cout << T - H[i] * 0.006 << endl;
        double dt = abs(double(A) - (double(T) - double(H.at(i) * 0.006)));
        // cout << dt << endl;
        if(min > dt)
        {
            // cout << i << endl;
            min = dt;
            ret = i + 1;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    print(i+1,i+2)
    exit(0)
for i in range(len(s)-2):
  if s[i]==s[i+2]:
    print(i+1,i+3)
    exit(0)
print(-1,-1)

Measured memory_bytes: 3188
/*
Read the question and constraints carefully .Take pen and paper and start solving.
write it down
*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define pi acos(-1.0)/*
#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second*/
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main()
{

    int n,i,j,o,c,tot=0,k,o1,c1,f;

    cin>>n;

    string s;
    pair<int,string> p[n];

    rep(i,0,n)
    {
        cin>>s;
        p[i].second = s;

        tot += s.size();

        o1 = c1 = 0;

        for(j=o=0;j<s.size();++j)
        {
            if(s[j]==')')
            {
                if(o==0)
                    ++c1;
                else
                    --o;
            }
            else
                ++o;

        }

        for(j=s.size()-1,c=0;j>=0;--j)
        {
              if(s[j]=='(')
              {
                  if(c==0)
                    ++o1;
                  else
                    --c;
              }
              else
                  ++c;  
        }

        
        if(o1==0)
            p[i].first = INT_MIN;
        else if(c1==0)
            p[i].first = INT_MAX;
        else if(o1>c1)
            p[i].first = INT_MAX-c1;
        else if(o1<c1)
            p[i].first = INT_MIN+o1;
        else
            p[i].first = 0;



    }

    sort(p,p+n,greater<pair<int,string>>());

     string ans(tot,'a');



    k=0;
    for(i=0;i<n;++i)
    {
        s = p[i].second;

        for(j=0;j<s.size();++j,++k)
        {
            ans[k] = s[j];
        }
    }


    //cout<<ans<<"\n";

    for(i=o=c=0;i<tot;++i)
    {
        if(ans[i]=='(')
            ++o;
        else
            --o;

        if(o<0)
        {
            cout<<"No";
            return 0;
        }
    }


    if(o==0)
        cout<<"Yes";
    else
        cout<<"No";


    return 0;
}

Measured memory_bytes: 43304
from collections import deque

n , q = map(int, input().split())
r = [[]for i in range(n)]
s = [0]*n
v = [0]*n
for i in range(n-1):
    a , b = map(int, input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)
for i in range(q):
    p , x = map(int, input().split())
    s[p-1]+=x
d= deque()
d.append(0)
def bfs(now):
    v[now]=1
    while d:
        i = d.popleft()
        for j in r[i]:
            if v[j]==0:
                s[j]+=s[i]
                v[j]=1
                d.append(j)
    return
bfs(0)
print(' '.join(list(map(str,s))))


Measured memory_bytes: 67200
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> x(n);
	vector<int> y(n);
	vector<int> h(n);
	int tmph = 0, tmpx = 0, tmpy = 0; 
	for( int i = 0; i < n; ++i ){
		cin >> x[i] >> y[i] >> h[i];
		if( h[i] > 0 && tmph == 0 ){
			tmpx = x[i];
			tmpy = y[i];
			tmph = h[i];
		}
	}
	for( int i = 0; i <= 100; ++i ){
		for( int j = 0; j <= 100; ++j ){
			int candy = tmph+abs(i-tmpx)+abs(j-tmpy);
			bool flag = true;
			int bound = x.l_ength();
			for( int k = 0; k < bound; ++k ){
				if( h[k] != max( 0, candy-abs(i-x[k])-abs(j-y[k]) ) ){
					flag = false;
					break;
				}
			}
			if( flag ){
				cout << i << ' ' << j << ' ' << candy << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

    int w,h;
    while(cin>>w>>h){
        if(w==0)break;
        int data[16][16]={{0}},dp[17][17]={{0}};
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>data[i][j];
                if(i==0&&data[i][j]!=1)dp[i][j]=1;
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(dp[i][j]!=0){
                    if(data[i][j]==0){
                        if(i!=h-1&&j!=0&&data[i+1][j-1]==0)dp[i+1][j-1]+=dp[i][j];
                        if(data[i+1][j]!=1)dp[i+1][j]+=dp[i][j];
                        if(i!=h-1&&j!=w-1&&data[i+1][j+1]==0)dp[i+1][j+1]+=dp[i][j];
                    }
                    else if(data[i][j]==2){
                        if(i==h-1)dp[i+1][j]+=dp[i][j];
                        else if(data[i+2][j]!=1)dp[i+2][j]+=dp[i][j];
                    }
                }
            }
        }
        /*
        cout<<endl;
        for(int i=0;i<=h;i++){
            cout<<i<<":";
            for(int j=0;j<w;j++){
                cout<<dp[i][j]<<" ";
            }
            cout<<endl;
        }*/
        int ans=0;
        for(int j=0;j<w;j++)ans+=dp[h][j];
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1164
# 2019/06/10
# AtCoder Beginner Contest 129 - B

# Input
n = int(input())
w = list(map(int, input().split()))

sumw = 0
acmw = list()
acmw.append(0)

# Make Accumulated Sum List
for i in range(n):
    acmw.append(acmw[i] + w[i])
    sumw += w[i]

# Search Minimum(abs)
wmin = 101
for i in range(1, n):
    ww = abs(acmw[i] - (acmw[n] - acmw[i]))
    if ww < wmin:
        wmin = ww

# Output
print(wmin)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
int main() {
	int M, D;
	scanf("%d%d", &M, &D);
	int ans = 0;
	for (int i = 1; i <= M; ++i) {
		for (int j = 1; j <= D; ++j) {
			int d1 = j % 10;
			int d10 = j / 10;
			if (d1 >= 2 && d10 >= 2 && d1 * d10 == i) ++ans;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <iterator>
using namespace std;

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

typedef long long ll;

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

int main() {
    ll n;
    ll a, b;
    ll ac = 0, bc = 0, cc = 0;
    vector<int> st(3);
    cin >> n;
    cin >> a >> b;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

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

    for (int j = 0; j < n; j++) {
        if (p[j] <= a) {
            st[0]++;
        } else if (p[j] <= b) {
            st[1]++;
        } else if (p[j] <= 20) {
            st[2]++;
        }
    }
    sort(st.begin(), st.end());

    cout << st[0] << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int H, W;
    cin >> H >> W;
    vector<char> s(H*W);
    for(int i = 0; i < H*W; i++) cin >> s.at(i);
    
    vector<int> yoko(H*W, 0);
    vector<int> tate(H*W, 0);
    int answer = 0;
    int tmp;
    for (int h = 0; h < H; h++) {
        tmp = 0;
        for (int w = 0; w < W; w++) {
            if(s[w+W*h] == '.'){
                tmp++;
                yoko[w+W*h] = tmp;
            }
            else{
                tmp = 0;
            }
        }
        tmp = 0;
        for (int w = W-1; w >= 0; w--) {
            if(tmp == 0){
                tmp = yoko[w+W*h];
            }
            if(yoko[w+W*h] >= 1){
                yoko[w+W*h] = tmp;
            }
            else{
                tmp = 0;
            }
        }
    }

    for (int w = 0; w < W; w++) {
        tmp = 0;
        for (int h = 0; h < H; h++) {
            if(s[w+W*h] == '.'){
                tmp++;
                tate[w+W*h] = tmp;
            }
            else{
                tmp = 0;
            }
        }
        tmp = 0;
        for (int h = H-1; h >= 0; h--) {
            if(tmp == 0){
                tmp = tate[w+W*h];
            }
            if(tate[w+W*h] >= 1){
                tate[w+W*h] = tmp;
            }
            else{
                tmp = 0;
            }
        }
    }

    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            answer = max(answer, yoko[w+W*h] + tate[w+W*h] -1);
        }
    }
    printf("%d\n", answer);

}


Measured memory_bytes: 35456
#080-C 
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
F=[int(input().replace(" ",""), 2) for _ in range(n)]
P=[IL() for i in range(n)]
ans=-pow(10,10)
for i in range(1,pow(2,10)):
    t=0
    for f,p in zip(F,P):
        t+=p[bin(f&i).count("1")]
    ans=max(ans,t)
print(ans)

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
  
	int W,H;
	cin>>H>>W;
	while(H!=0||W!=0){
		for(int a=1;a<=H;a++){
			if(a%2==0){
				for(int b=1;b<=W;b++){
					if(b%2==0){
						cout<<"#";
					}
					if(b%2==1){
						cout<<".";
					}
				}
			}
			if(a%2==1){
				for(int c=1;c<=W;c++){
					if(c%2==0){
						cout<<".";
					}
					if(c%2==1){
						cout<<"#";
					}
				}
			}
		cout<<endl;
		}
		cout<<endl;
		cin>>H>>W;
	}
				
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n=s.size(),count=0;
  bool flag = true;
  if(s[0] != 'A') flag = false;  
  for(int i=0; i<n; i++) {
    if(s[i] == 'C') count++;
  }
  if(count != 1) flag = false;
  if(s[0] == 'C' || s[1] == 'C' || s[n-1] == 'C') flag = false;
  for(char c : s) {
    if((c != 'A' && c != 'C') && isupper(c)) flag = false;
  }
  if(flag) cout << "AC" << endl;
  else cout << "WA" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	d := make([]int, n)
	for i := range d {
		fmt.Scan(&d[i])
	}

	sort.Ints(d)
	count := 1
	for i := 0; i < n-1; i++ {
		if d[i] != d[i+1] {
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int num = 1;

		for (int i = 1; i <= N; i++) {
			if (i == 1) {
				num *= K;
			} else {
				num *= K-1;
			}
		}
		System.out.println(num);
	}
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n, a, b; cin >> n >> a >> b;

    cout << min(n * a, b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}



//ここまでライブラリ
//ここから本文
//周りはみんなおとなになってます

int main() {
	int n;
	cin >> n;
	map<string, int> m;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		if (m.find(s) == m.end()) {
			m.insert(make_pair(s,1));
		}
		else {
			m.at(s)++;
		}
	}
	Int sum = 0;
	for (auto a : m) {
		Int n = a.second -1;
		sum += (n * (n + 1)) / 2;
	}
	cout << sum << endl;
}


Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int l=sc.nextInt();
		long[][] A=new long[n][m];
		long[][] B=new long[m][l];
		long[][] C=new long[n][l];

		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				int a=sc.nextInt();
				A[i][j]=a;
			}

		}

		for(int i=0;i<m;i++) {
			for(int j=0;j<l;j++) {
				int b=sc.nextInt();
				B[i][j]=b;
			}

		}
		for(int i=0;i<n;i++) {
			for(int j=0;j<l;j++) {
				for(int k=0;k<m;k++) {
					C[i][j]+=A[i][k]*B[k][j];
				}
			}
		}
		for(int i=0;i<n;i++) {
			for(int j=0;j<l-1;j++) {
				System.out.print(C[i][j]+" ");
			}
			System.out.println(C[i][l-1]);

		}
	}
}


Measured memory_bytes: 54016
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
5
5 2 3 4 1
---+/
/+---test
5
2 4 3 5 1
---+/
/+---test
7
1 2 3 4 5 6 7
---+/

void main(string[] args) {
  readln;
  const P = readln.split.map!(to!long).array;
  const N = P.length;

  if (zip(iota(1, N+1), P).count!(x => x[0] != x[1]) <= 2) {
    "YES".writeln;
  } else {
    "NO".writeln;
  }
}


Measured memory_bytes: 256