akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> c(n);
    REP(i,n) cin >> c[i];
    vec a(n),b(n),r(n);
    rep(i,n){
        r[c[i]-1]=i+1;
    }
    rep(i,n){
        a[i]=30000*(i+1);
        b[i]=30000*(n-(i+1))+r[i];
    }


    rep(i,n) cout<<a[i]<<endl;
    rep(i,n) cout<<b[i]<<endl;
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main()
{
	long long x,a,b,ans,c;
	cin>>x>>a>>b;
	ans=x-a;
	c=ans/b;
	if(ans%b==0)
	cout<<"0"<<endl;
	else cout<<x-a-b*c<<endl;
	return 0;
}


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

int main(){
    int p=0,s;
    int data[1000000];
    cin >>s;
    data[0]=s;
    while (1){
        p++;
        if(s%2==0){
            s=s/2;
        }else{
            s = 3*s + 1;
        }
        data[p]=s;

        for (int i = 0; i < p; i++){
            if(data[i]==s){
                cout << p+1 <<endl;
                return 0;
            }
        }
    }
}


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

using namespace std;

int main()
{
    int b,n,sum=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum=sum+a[i]*a[j];
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
s = [input().split() for _ in range(h)]

memo_yoko1 = [[-1 for i in range(w)] for j in range(h)]
memo_tate1 = [[-1 for i in range(w)] for j in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][0][j] == '.':
            if j == 0:
                memo_yoko1[i][j] = 1
            else:
                memo_yoko1[i][j] = memo_yoko1[i][j-1] + 1

            if i == 0:
                memo_tate1[i][j] = 1
            else:
                memo_tate1[i][j] = memo_tate1[i-1][j] + 1
        else:
            memo_yoko1[i][j] = 0
            memo_tate1[i][j] = 0

# transpose
s_t = [[''] for j in range(h)]
for i in range(h):
    s_t[i] = s[h - i - 1][0][::-1]

memo_yoko2 = [[-1 for i in range(w)] for j in range(h)]
memo_tate2 = [[-1 for i in range(w)] for j in range(h)]

for i in range(h):
    for j in range(w):
        if s_t[i][j] == '.':
            if j == 0:
                memo_yoko2[i][j] = 1
            else:
                memo_yoko2[i][j] = memo_yoko2[i][j-1] + 1

            if i == 0:
                memo_tate2[i][j] = 1
            else:
                memo_tate2[i][j] = memo_tate2[i-1][j] + 1
        else:
            memo_yoko2[i][j] = 0
            memo_tate2[i][j] = 0


memo = [[-1 for i in range(w)] for j in range(h)]
ans = -1
for i in range(h):
    for j in range(w):
        _memo = memo_tate1[i][j] + memo_tate2[h - i - 1][w - j - 1] + memo_yoko1[i][j] + memo_yoko2[h - i - 1][w - j - 1] - 3
        memo[i][j] = _memo

        ans = max(ans, _memo)

print(ans)


Measured memory_bytes: 234244
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		long K = scanner.nextLong();
		
		
		for(int i=0; i<S.length(); i++) {
			char c = S.charAt(i);
			K = (long) (K - Math.pow(Integer.parseInt(Character.toString(c)), 5*Math.pow(10, 15)));
			if(K <= 0) {
				System.out.println(c);
				break;
			}
			
		}
		

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h> 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL MOD=1e9+7;

int main(){
    int N;cin>>N;
    vector<LL>A(N);
    LL sum=0;
    REP(i,N){
        cin>>A[i];sum+=A[i];
    }
    sum/=2LL;
    LL sum2=0;
    for(int i=1;i<N;i+=2){
        sum2+=A[i];
    }
    LL x=sum-sum2;
    //LL x=A[0]-xn;
    REP(i,N){
        cout<<2LL*x<<" ";
        x=A[i%N]-x;
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int a[10];
bool used[11];

int judge(){
  int mod = a[9];
  int sum = (a[0]+a[1]+a[2])%mod;
  if((a[3]+a[4]+a[5])%mod != sum || (a[6]+a[7]+a[8])%mod != sum) return 0;
  if((a[0]+a[3]+a[6])%mod != sum || (a[1]+a[4]+a[7])%mod != sum || (a[2]+a[5]+a[8])%mod != sum) return 0;
  if((a[0]+a[4]+a[8])%mod != sum || (a[2]+a[4]+a[6])%mod != sum) return 0;
  return 1;
}

int dfs(int n, bool *used){
  if(n == 10) return judge();
  if(a[n]) return dfs(n+1, used);
  int res = 0;
  REP(i, 1, 11){
    if(used[i]) continue;
    a[n] = i;
    used[i] = 1;
    res += dfs(n+1, used);
    a[n] = 0;
    used[i] = 0;
  }
  return res;
}

int main(){
  while(1){
    bool used[11];
    memset(used, 0, sizeof(used));
    rep(i, 10){
      scanf("%d", a+i);
      if(a[i]) used[a[i]] = 1;
    }
    if(a[0] == -1) break;

    printf("%d\n", dfs(0, used));
  }
  return 0;
}

Measured memory_bytes: 1188
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
	int n;
	int C[510];
	int S[510];
	int F[510];
	scanf("%d",&n);
	for(int i=0;i<n-1;i++)
		scanf("%d%d%d",&C[i],&S[i],&F[i]);
	for(int i=0;i<n-1;i++)
	{
		int ans=S[i]+C[i];
		for(int j=i+1;j<n-1;j++)
		{
			if(ans<S[j])ans=S[j];
			else ans+=(F[j]-ans%F[j])%F[j];
			ans+=C[j];
		}
		printf("%d\n",ans);
	}
	printf("0\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    int t;
  	t=1;

    while(t--){
    	int D,T,S;
    	cin>>D>>T>>S;

    	if(ceil(D/(S*1.0))<=T)
    		cout<<"Yes"<<endl;
    	else
    		cout<<"No"<<endl;
    }
    return 0;
}


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

const int INF = 1 << 30;

int main()
{
  int N;
  while (cin >> N) {
    if (N == 0)
      break;

    vector<int> c(N+2);
    for (int i = 0; i < N; ++i)
      cin >> c[i+1];
    // sentinel
    c[0] = INF;
    c[N+1] = -INF;

    int ans = 0;
    for (int i = 1; i <= N; ++i) {
      for (int j = 1; j <= 3; ++j) {
        if (c[i] == j)
          continue;

        int tmp = c[i];
        c[i] = j;

        int up = i, down = i, sum = 0;
        while (c[up] == c[down]) {
          int color = c[up], cnt = 0;
          if (up == i)
            --cnt;

          while (up > 0 && c[up] == color) {
            --up;
            ++cnt;
          }
          while (down <= N && c[down] == color) {
            ++down;
            ++cnt;
          }
          if (cnt >= 4)
            sum += cnt;
          else
            break;
        }

        c[i] = tmp;
        ans = max(ans, sum);
      }
    }
    cout << N-ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#ifdef _LOCAL
#	include <dbg_print.h>
#else
#	define NDEBUG
#	define dprint(...)
#endif

#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <iostream>
#include <algorithm>
#include <assert.h>
using namespace std;
typedef long long ll;


int main()
{
	ios::sync_with_stdio(false);
	
	int n, d, a;
	cin >> n >> d >> a;
	vector< pair<int,int> > ends;

	//std::map<int, Elem> m;
	vector< pair<int,int> > xh(n);
	for(int i=0; i<n; ++i)
	{
		//int x, h;
		cin >> xh[i].first >> xh[i].second;
		//m[x].dh = h;
	}

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

	ll ans = 0;
	int currd = 0, currp = 0;
	for(int i=0; i<n; ++i)
	{
		int x = xh[i].first;
		int h = xh[i].second;
		while(currp < ends.size() && ends[currp].first <= x)
		{
			currd -= ends[currp++].second;
		}
		assert(0 <= currd);

		h -= currd;
		if(0 < h)
		{
			int attacks = (h+a-1) / a;
			currd += attacks * a;
			ends.push_back({x + 2*d+1, attacks * a});
			ans += attacks;
		}
	}



	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3956
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            int n=scan.nextInt();
            int[] arr=new int[n];
            for(int i=0;i<n;i++){
                arr[i]=scan.nextInt();
            }
            long cur=1000;
            int si=0;
            for(int i=0;i<n;i++){
                int li=-1;
                int less=arr[i];
                for(int j=i-1;j>=si;j--){
                    if(arr[j]<less){
                        less=arr[j];
                        li=j;
                    }else{
                        break;
                    }
                }
                if(li!=-1){
                    cur+=(cur/arr[li])*(arr[i]-arr[li]);
                    si=i;
                }
            }
            out.println(cur);
        }
        out.flush();
        out.close();
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


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

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

int main() {
    int K, X;
    cin >> K >> X;
    int begin = X - K + 1;
    int end = K + X - 1;
    for(int i = begin; i < end; ++i){
        cout << i << " ";
    }
    cout << end << endl;
}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    int X,Y,Z,K;
    cin>>X>>Y>>Z>>K;
    vector<ll> A(X),B(Y),C(Z);
    REP(i,X){
        cin>>A[i];
    }
    REP(i,Y){
        cin>>B[i];
    }
    REP(i,Z){
        cin>>C[i];
    }
    priority_queue<ll> AB,AB_K,ABC;
    REP(i,X){
        REP(j,Y){
            AB.push(A[i]+B[j]);
        }
    }
    ll tmp;
    REP(i,K){
        if(AB.empty()) break;
        tmp=AB.top();
        AB.pop();
        AB_K.push(tmp);
    }
    ll tmp2;
    while(!AB_K.empty()){
        tmp=AB_K.top();
        AB_K.pop();
        REP(i,Z){
            tmp2=tmp+C[i];
            ABC.push(tmp2);
        }
    }

    int cnt=1;
    while(!ABC.empty()){
        tmp=ABC.top();
        cout<<tmp<<endl;
        if(cnt==K){
            return 0;
        }
        cnt++;
        ABC.pop();
    }
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    int ans = __gcd(a[0], a[1]);
    for(int i = 1; i < n; ++i) {
        ans = __gcd(ans, a[i]);
    }

    cout << ans << '\n';

    return 0;
}


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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, dp[max_n];
pair<int, int> p[max_n];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x, r;
        scanf("%d%d", &x, &r);
        p[i] = {x - r, x + r};
    }
    sort(p, p + n);
    for (int i = n - 1; i >= 0; --i) {
        int pos = lower_bound(p, p + n, make_pair(p[i].second, -inf)) - p;
        dp[i] = max(dp[i + 1], 1 + dp[pos]);
    }
    printf("%d\n", dp[0]);
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,w;
    cin>>n>>w;
    vector<vector<int> > input(n,vector<int>(2));
    for(int i=0;i<n;++i){
        cin>>input[i][0]>>input[i][1];
    }
    ll ninf=LLONG_MIN;
    vector<vector<ll> > dp(n+1,vector<ll>(w+1,0));
    //dp[0][0]=0;
    for(int i=1;i<=n;++i){
        for(int j=0;j<=w;++j){
            int weight=input[i-1][0];
            int value=input[i-1][1];
            dp[i][j]=max((j-weight>=0?dp[i-1][j-weight]+value:0),dp[i-1][j]);
        }
    }
    cout<<dp[n][w];
    cout<<endl;
}


Measured memory_bytes: 83088
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define INF 1<<29
using namespace std;

int a[101010];

void solve(){
 int n,k;
 for(;;){
  scanf("%d %d",&n,&k);
  if(n==0) break;
  FOR(i,k) scanf("%d",&a[i]);
  sort(a,a+k);
  int ma=0;
  FOR(i,k){
   if(a[i]==0) continue;
   FORR(j,i+1,k){
    if(!a[0]){
     if(a[j]-a[i]<=j-i+1) ma=max(ma,a[j]-a[i]+1);
     else break;
    }
    else{
     if(a[j]-a[i]==j-i) ma=max(ma,a[j]-a[i]+1);
     else break;
    }
   }
  }
  printf("%d\n",ma);
 }
}

int main(){
 solve();
 return 0;
}

Measured memory_bytes: 3416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

const int mod = 998244353;
template<typename T>
T add(T x) {
  return x;
}
template<typename T, typename... Ts>
T add(T x, Ts... y) {
  T res = x + add(y...);
  if (res >= mod)
    res -= mod;
  return res;
}
template<typename T, typename... Ts>
T sub(T x, Ts... y) {
  return add(x, mod - add(y...));
}
template<typename T, typename... Ts>
void udd(T& x, Ts... y) {
  x = add(x, y...);
}
template<typename T, typename... Ts>
void uub(T& x, Ts... y) {
  x = sub(x, y...);
}
template<typename T>
T mul(T x) {
  return x;
}
template<typename T, typename... Ts>
T mul(T x, Ts... y) {
  return (x * 1ll * mul(y...)) % mod;
}
template<typename T, typename... Ts>
void uul(T& x, Ts... y) {
  x = mul(x, y...);
}
int bin(int a, ll deg) {
  int r = 1;
  while (deg) {
    if (deg & 1)
      uul(r, a);
    deg >>= 1;
    uul(a, a);
  }
  return r;
}
int inv(int x) {
  assert(x);
  return bin(x, mod - 2);
}

signed main() {
#ifdef LOCAL
  assert(freopen("b.in", "r", stdin));
#endif
  ll n, a, b, k;
  cin >> n >> a >> b >> k;
  vector<int> c(n + 1);
  int x = c[0] = 1;
  for (int i = 1; i <= n; ++i) {
    uul(x, inv(i));
    uul(x, n - i + 1);
    c[i] = x;
  }
  int res = 0;
  for (ll na = 0; na <= n; ++na) {
    ll nb = k - na * a;
    if (nb % b) {
      continue;
    }
    nb /= b;
    if (nb < 0 || nb > n) {
      continue;
    }
    udd(res, mul(c[na], c[nb]));
  }
  cout << res << '\n';
}


Measured memory_bytes: 1408
from itertools import permutations
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
per = list(permutations([i for i in range(1, n+1)], n))
a = per.index(p) + 1
b = per.index(q) + 1
print(abs(a-b))


Measured memory_bytes: 8052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	static int n;
	static int[] arr;
	static int[] memo;
	static boolean f = false;
	static boolean t = false;
	static int OO = (int) 1e9 + 7;

	static int dp(int i) {
		if (i == n - 1)
			return 0;
		
		if (memo[i] != -1)
			return memo[i];

		int a = Integer.MAX_VALUE, b = Integer.MAX_VALUE;
		if (i < n - 1)
			a = Math.abs(arr[i + 1] - arr[i])+dp(i + 1);
		if (i < n - 2)
			b =  Math.abs(arr[i + 2] - arr[i])+dp(i + 2);
		
		return memo[i] = Math.min(a, b);

	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);

		n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());

		arr = new int[n];
		for (int i = 0; i < n; i++)
			arr[i] = Integer.parseInt(st.nextToken());
		memo = new int[n + 1];
		Arrays.fill(memo, -1);
		pw.print(dp(0));
		pw.close();
	}
}


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

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		int[] data = new int[Dice.SURFACE];

		for(int i = 0; i < data.length; i++){
			data[i] = Integer.parseInt(input[i]);
		}

		Dice dice = new Dice(data);
		char[] ope = br.readLine().toCharArray();

		for(int i = 0; i < ope.length; i++){

			switch(ope[i]){
				case 'N':
					dice.moveN();
					break;
				case 'E':
					dice.moveE();
					break;
				case 'W':
					dice.moveW();
					break;
				case 'S':
					dice.moveS();
					break;
			}

		}

		System.out.println(dice.getNum(Dice.TOP));


	}
}

class Dice{

	static final int SURFACE = 6;
	static final int TOP = 0;
	static final int FRONT = 1;
	static final int RIGHT = 2;
	static final int LEFT = 3;
	static final int BACK = 4;
	static final int BOTTOM = 5;
	int[][] dice = new int[SURFACE][2];

	public Dice(){

		for(int i = 0; i < SURFACE; i++){
			dice[i][0] = i + 1;
			dice[i][1] = dice[i][0];
		}

	}

	public Dice(int[] data){

		this();

		for(int i = 0; i < SURFACE; i++){
			dice[i][1] = data[i];
		}

	}

	public void moveN(){

		int[] temp = dice[TOP];
		dice[TOP] = dice[FRONT];
		dice[FRONT] = dice[BOTTOM];
		dice[BOTTOM] = dice[BACK];
		dice[BACK] = temp;

	}

	public void moveE(){

		int[] temp = dice[TOP];
		dice[TOP] = dice[LEFT];
		dice[LEFT] = dice[BOTTOM];
		dice[BOTTOM] = dice[RIGHT];
		dice[RIGHT] = temp;

	}

	public void moveW(){

		int[] temp = dice[TOP];
		dice[TOP] = dice[RIGHT];
		dice[RIGHT] = dice[BOTTOM];
		dice[BOTTOM] = dice[LEFT];
		dice[LEFT] = temp;

	}

	public void moveS(){

		int[] temp = dice[TOP];
		dice[TOP] = dice[BACK];
		dice[BACK] = dice[BOTTOM];
		dice[BOTTOM] = dice[FRONT];
		dice[FRONT] = temp;

	}

	public void turnR(){

		int[] temp = dice[FRONT];
		dice[FRONT] = dice[RIGHT];
		dice[RIGHT] = dice[BACK];
		dice[BACK] = dice[LEFT];
		dice[LEFT] = temp;

	}

	public void turnL(){

		int[] temp = dice[FRONT];
		dice[FRONT] = dice[LEFT];
		dice[LEFT] = dice[BACK];
		dice[BACK] = dice[RIGHT];
		dice[RIGHT] = temp;

	}

	public int getNum(int position){

		return dice[position][1];

	}
}

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

int main()
{
    string S;
    cin >> S;
    map<char, int> mp;
    for (int i = 0; i < 4; i++)
    {
        mp[S[i]]++;
    }
    if (mp.size() == 2)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
	    int num1,num2,num3,num4,num5;
	    int time1,time2,def;

      	string[] str = Console.ReadLine().Split(' ');
	    num1 = int.Parse(str[0]);
	    num2 = int.Parse(str[1]);
	    num3 = int.Parse(str[2]);
	    num4 = int.Parse(str[3]);
	    num5 = int.Parse(str[4]);
      
      	time1 = num1 * 60 + num2;
      	time2 = num3 * 60 + num4;
        def = time2 - time1;

      	Console.Write(def - num5);
    }
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

int n, m, p;
int px[500], py[500];
int a[10][10][10];

void put(int x, int y, int c) {
    int z = 0;
    while (a[x][y][z] != -1) z++;
    a[x][y][z] = c;
}

bool inside(int x, int y, int z) {
    return x >= 0 && y >= 0 && z >= 0 && x < n && y < n && z < n;
}

bool seq(int x, int y, int z, int k) {
    int nx = x, ny = y, nz = z;
    int cnt = 0;
    while (inside(nx, ny, nz) && a[nx][ny][nz] == a[x][y][z]) {
        nx += dx[k];
        ny += dy[k];
        nz += dz[k];
        cnt++;
    }
    return cnt >= m;
}

bool check(int x, int y, int z) {
    if (a[x][y][z] == -1) return false;

    rep(k, 13) {
        if (seq(x, y, z, k)) return true;
    }
    return false;
}

bool update(int t) {
    put(px[t], py[t], t % 2);

    rep(x, n) {
        rep(y, n) {
            rep(z, n) {
                if (check(x, y, z))
                    return true;
            }
        }
    }

    return false;
}

void solve() {
    rep(i, n) rep(j, n) rep(k, n) a[i][j][k] = -1;
    rep(i, p) {
        cin >> px[i] >> py[i];
        px[i]--, py[i]--;
    }

    rep(i, p) {
        if (update(i)) {
            cout << (i % 2 == 0 ? "Black" : "White") << " " << i + 1 << endl;
            return;
        }
    }

    cout << "Draw" << endl;
}

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

    while (cin >> n >> m >> p, n) {
        solve();
    }
}

Measured memory_bytes: 3124
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


int N, M;
int[] A, B;

int[][] G;
bool[] vis;
int[] us;

void dfs(int u) {
  if (!vis[u]) {
    vis[u] = true;
    foreach (v; G[u]) {
      dfs(v);
    }
    us ~= u;
  }
}

void main() {
  try {
    for (; ; ) {
      N = readInt();
      M = readInt();
      M += (N - 1);
      A = new int[M];
      B = new int[M];
      foreach (i; 0 .. M) {
        A[i] = readInt() - 1;
        B[i] = readInt() - 1;
      }
      
      auto indeg = new int[N];
      foreach (i; 0 .. M) {
        ++indeg[B[i]];
      }
      // const rt = indeg.minIndex;
      int rt;
      foreach (u; 0 .. N) {
        if (indeg[rt] > indeg[u]) {
          rt = u;
        }
      }
      assert(indeg[rt] == 0);
      
      G = new int[][N];
      foreach (i; 0 .. M) {
        G[A[i]] ~= B[i];
      }
      vis = new bool[N];
      us = [];
      dfs(rt);
      us.reverse();
      debug {
        writeln("us = ", us);
      }
      
      auto ord = new int[N];
      foreach (j; 0 .. N) {
        ord[us[j]] = j;
      }
      
      auto par = new int[N];
      par[] = -1;
      foreach (u; us) {
        foreach (v; G[u]) {
          if (ord[u] < ord[v]) {
            par[v] = u;
          }
        }
      }
      foreach (u; 0 .. N) {
        writeln(par[u] + 1);
      }
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 14460
#include <iostream>
#include <sstream>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a + b < 10)
        cout << a + b;
    else cout << "error";
}

Measured memory_bytes: 3572
n = int(input())
h = list(map(int,input().split()))
h.reverse()
p = 1
for i in range(n-1):
    if h[i] >= h[i+1]:
        continue
    else:
        if h[i] < h[i+1] -1:
            print('No')
            p = 0
            break
        else:
            h[i+1] -= 1
if p == 1:
    print('Yes')

Measured memory_bytes: 20660
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)


int main() {
  ll D, T, S;
  cin >> D >> T >>S;
  //vector<ll> a(N);
  //vector<vector<int>> data(3, vector<int>(4));
  if(S*T>=D) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main() {
  int n;
  while(cin >> n, n) {
    int ans = 0;
    for(int i = 0; i < n/4; i++) {
      int p;
      cin >> p;
      ans += p;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
object SumOfNumbers {
  val sc = new java.util.Scanner(System.in)


  def run {
    var l = sc.nextLine()
    while (l != "0") {
      println(sum(l))
      l = sc.nextLine()
    }
  }
  def sum(line:String): Int = {
    val a =line.toCharArray

    val b = a.map( n => n.asDigit)

    b.sum

  }

}


object Main extends App{
 SumOfNumbers.run
}

Measured memory_bytes: 45488
#pragma once
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int N;
  cin >> N;
  cout << N*N*N;
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/

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

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

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

int main(){
    int n;scanf("%d",&n);
    printf("0\n");fflush(stdout);
    int l=0,r=n;
    int lp=2,rp=2;
    char s[15];
    scanf("%s",s);
    if(s[0]=='V')lp=0;
    else if(s[0]=='M'){
        lp=1;rp=1;
    }
    if(lp==0){
        return 0;
    }
    
    while(1){
        int m=(l+r)/2;
        printf("%d\n",m);
        fflush(stdout);
        scanf("%s",s);
        int mp;
        if(s[0]=='V')mp=0;
        else if(s[0]=='M')mp=1;
        else mp=2;
        if(mp==0)return 0;
        int a=0;
        if(lp==mp)a++;
        if((m-l)%2==0)a++;
        if(a==1){
            r=m;
            rp=mp;
        }else{
            l=m;
            lp=mp;
        }
    }
    return 0;
}

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

char map[100][101];
int fdx[] = {1, -1, 0, 0};
int fdy[] = {0, 0, -1, 1};
char chr;
int h, w;

void dfs(int x, int y) {
    if(x < 0 || y < 0 || x >= w || y >= h) return;
    if(map[y][x] == '.' || map[y][x] != chr) return;
    map[y][x] = '.';
    for(int r = 0; r < 4; r++) {
        dfs(x + fdx[r], y + fdy[r]);
    }
}

int main(void) {
    cin.tie();
    ios::sync_with_stdio(false);
    
    while(true) {
        cin >> h >> w;
        if(h + w == 0) break;
        
        for(int r = 0; r < h; r++) {
            for(int c = 0; c < w; c++) {
                cin >> map[r][c];
            }
        }
        
        int count = 0;
        while(true) {
            bool flag = false;
            for(int r = 0; r < h; r++) {
                for(int c = 0; c < w; c++) {
                    if(map[r][c] != '.') {
                        flag = true;
                        chr = map[r][c];
                        dfs(c, r);
                        count++;
                    }
                    if(flag) break;
                }
                if(flag) break;
            }
            if(!flag) break;
        }
        cout << count << endl;
    }
    return(0);
}

Measured memory_bytes: 1516
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-12-15 21:49:53
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

const int C = 10000;
// const ll M = 1000000007;

int N;
int A[200010];
int K[C];

bool solve(int X)
{
  fill(K, K + A[0], 0);
  for (auto i = 0; i < N - 1; i++)
  {
    if (A[i] > A[i + 1])
    {
      continue;
    }
    else if (A[i] == C)
    {
      continue;
    }
    else
    {
      bool ok = false;
      for (auto j = A[i] - 1; j >= 0; j--)
      {
        K[j]++;
        if (K[j] == X)
        {
          K[j] = 0;
        }
        else
        {
          ok = true;
          break;
        }
      }
      if (!ok)
      {
        return false;
      }
      for (auto j = A[i]; j < A[i + 1]; j++)
      {
        K[j] = 0;
      }
    }
  }
  return true;
}

int main()
{
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    cin >> A[i];
    A[i] = min(C, A[i]);
  }
  reverse(A, A + N);
  int ub = N;
  int lb = 0;
  while (ub - lb > 1)
  {
    int t = (ub + lb) / 2;
    if (solve(t))
    {
      ub = t;
    }
    else
    {
      lb = t;
    }
  }
  cout << ub << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=61
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int n;
  cin>>n;
  n%=10;
  if(n==3)cout<<"bon"<<endl;
  else if(n==2||n==4||n==5||n==7||n==9)cout<<"hon"<<endl;
  else cout<<"pon"<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define stop exit(0)
#define dd double
#define po pop_back
#define pb push_back
#define ub upper_bound
#define lb lower_bound
int main(){
    vector <long long> v;
    ll a,b,c=0,d=0,e=0,f=0,g=0,i,j,k=1,l=0,r=1,n,m[300001],z[400001],h[600001],p[600001];
    string s,t,x,y[1001];
    dd q,u,w;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0){
        if(k%2==0){
            a-=d;
        }
        else{
            c-=b;
        }
        k++;
        if(a<=0){
            cout<<"No";
            stop;
        }
        if(c<=0){
            cout<<"Yes";
            stop;
        }
    }
}

Measured memory_bytes: 3660
object Main {
  import java.util.Scanner
  import scala.annotation.tailrec

  def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }
  def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }
  def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }
  def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')
  def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)
  def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def solve(implicit sc: Scanner): Unit = {
    @tailrec
    def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)

    val Array(n, x) = readLineInts
    val xs = readLineInts
    val sortedXs = (xs.toList :+ x).sorted
    val pairs = sortedXs.zip(sortedXs.drop(1))
    val firstDistance = sortedXs(1) - sortedXs.head
    println(pairs.drop(1).foldRight(firstDistance){ (pair, d) => gcd(pair._2 - pair._1, d) })
  }
}


Measured memory_bytes: 73396
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;typedef long long LL;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e9+7;
const ll inf=1e9+7;
const long double eps=1e-8;
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
const double pi=acos(-1);

map<int,int> mp;

int main()
{
    TB
    int n;
    cin>>n;
    mp.clear();
    for(int i=1;i<101;i++){
        for(int j=1;j<101;j++){
            for(int k=1;k<101;k++){
                mp[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }
    fdd(1,n+1) cout<<mp[i]<<'\n';
    return 0;
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int a, b;
		cin >> a >> b;
		cout << (b-1+a-2)/(a-1) << "\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
S = gets.chomp
T = gets.chomp
min_cnt = T.size
S.size.times do |n|
    break if S.size - n < T.size
    cnt = 0
    T.size.times do |m|
        cnt += 1 if T[m] != S[n+m]
    end
    min_cnt = [min_cnt, cnt].min
end
puts min_cnt

Measured memory_bytes: 14268
package main

import (
	"fmt"
	"math"
)

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func main(){
	var n,a,b,c int
	activity_number := 3
	var day_activity [][]int
	var DP [][]int

	//何日に何を選ぶかでDP表を作る

	fmt.Scan(&n)
	for i:=0;i<n;i++{
		fmt.Scanf("%d %d %d",&a,&b,&c)
		day_activity = append(day_activity,[]int{a,b,c})
	}

	for i:=0;i<n+1;i++{
		DP = append(DP,make([]int,activity_number))
	}

	for day:=1;day<n+1;day++{
		for activity := 0;activity<activity_number;activity++{
			if activity == 0{
				DP[day][activity] = max(
					DP[day-1][1]+day_activity[day-1][activity],
					DP[day-1][2]+day_activity[day-1][activity],
				)
			}else if activity == 1{
				DP[day][activity] = max(
					DP[day-1][0]+day_activity[day-1][activity],
					DP[day-1][2]+day_activity[day-1][activity],
				)
			}else{
				DP[day][activity] = max(
					DP[day-1][0]+day_activity[day-1][activity],
					DP[day-1][1]+day_activity[day-1][activity],
				)
			}
		}
	}
	fmt.Println(max(DP[n]...))
}


Measured memory_bytes: 21376
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String ab = a + b;
		int num = Integer.parseInt(ab);
		for(int i = 1; i < 1000; i++) {
			if(i * i == num) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main() {
	int N;cin>>N;
	vector<vector<int>>B(N, vector<int>(N));
	for (int i = 0; i < N; i++)
	{
		int a;cin>>a;
		for (int j = 0; j < a; j++)
		{
			int x,y;cin>>x>>y;
			x--;
			if(y==1)B[i][x] = 1;
			else B[i][x] = -1;
		}
	}

	int ans = 0;
	for (int x = 0; x < (1 << N); x++)
	{
		vector<int>list(N);
		int cnt = 0;
		for(int i=0;i<N;i++)
		{
			if(x & (1 << i))
			{
				list[i]=1;
				cnt++;
			}
			else list[i] = -1;
		}

		bool flag = true;
		for (int i = 0; i < N; i++)
		{
			if(list[i] == -1)continue;

			for (int j = 0; j < N; j++)
			{
				if(B[i][j] == 0)continue;
				if(B[i][j] != list[j])flag = false;
			}
		}

		if(flag)ans = max(ans, cnt);
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(llong i = 0;i < n;i++)
#define REPR(i, n) for(llong i = n;i >= 1;i--)
#define FOR(i, m, n) for(llong i = m;i < n;i++)
#define FORR(i, m, n) for(llog i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
llong mod = 10000000000;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};


int main(){
  llong N;cin>>N;
  llong S =N;
  llong a =2;
  llong b= 0;
  llong c= 0;
  llong cc= 0;
  llong tem= 0;
  tem = sqrt (N);
  if(tem*tem == N){
    b = tem;
  }else{
    b = tem +1;
    c = b*b- N;
    cc =c;
  }

  priority_queue<llong> que1;
  priority_queue<llong> que2;
que1.push(1);
  while(c >= a*a ){
    if(c % a == 0){
      c /= a;
      que1.push(a);
    }else{
      a++;
    }
    que1.push(c);
  }

  vector<llong> ans(6);
  ans[0] = b;
  ans[3] = b;
  if(b != tem){
    ans[1] = que1.top();
    ans[2] = cc/ans[1];
  }
  REP(i,6){
    cout << ans[i]<<" ";
  }cout<<endl;

}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		String[] R = new String[N];
		String[] S = new String[N];
		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		}

		for (int i = 0; i < N; i++) {
			String s = S[i];
			if (s.equals("AB")) {
				if (A == B && A == 1 && i != N - 1 && !s.equals(S[i + 1])) {
					if (S[i + 1].contains("A")) {
						A++;
						B--;
						R[i] = "A";
					} else {
						A--;
						B++;
						R[i] = "B";
					}
				} else if (A > B) {
					A--;
					B++;
					R[i] = "B";
				} else {
					A++;
					B--;
					R[i] = "A";
				}
			} else if (s.equals("BC")) {
				if (B == C && B == 1 && i != N - 1 && !s.equals(S[i + 1])) {
					if (S[i + 1].contains("B")) {
						B++;
						C--;
						R[i] = "B";
					} else {
						B--;
						C++;
						R[i] = "C";
					}
				} else if (B > C) {
					B--;
					C++;
					R[i] = "C";
				} else {
					B++;
					C--;
					R[i] = "B";
				}
			} else {
				if (C == A && C == 1 && i != N - 1 && !s.equals(S[i + 1])) {
					if (S[i + 1].contains("C")) {
						C++;
						A--;
						R[i] = "C";
					} else {
						C--;
						A++;
						R[i] = "A";
					}
				} else if (C > A) {
					C--;
					A++;
					R[i] = "A";
				} else {
					C++;
					A--;
					R[i] = "C";
				}
			}
			if (A < 0 || B < 0 || C < 0) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
		for (int i = 0; i < N; i++) {
			System.out.println(R[i]);
		}
	}

}

Measured memory_bytes: 64976
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <list>
#include <set>
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
using namespace std;
using ll = long long;
const int INF = 1e9 + 1;
ll MOD = 1e9+7;
ll dx[9] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
ll dy[9] = {-1,  0,  1,-1, 0, 1,-1, 0, 1};

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

    int A, B, K;
    cin >> A >> B >> K;
    int d = max(A,B);
    RREP(i, d+1){
        if(A % i == 0 && B % i == 0){
            K--;
            if(K == 0){
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import math
p=1000000007
g1=[1,1]
g2=[1,1]
inverse=[0,1]
for i in range(2,2*(10**5)+1):
    g1.append((g1[-1]*i)%p)
    inverse.append((-inverse[p%i]*(p//i))%p)
    g2.append((g2[-1]*inverse[-1])%p)
def cmb2(n, r, mod):
    if (r<0 or r>n):return 0
    r = min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod
def chwp(h,w,p):
    if h==1 or w==1:return 1
    else:return cmb2(h+w-2,h-1,p)
h,w,a,b= map(int,input().split())
ans=0
for i in range(1,h-a+1):ans=(ans+chwp(i,b,p)*chwp(h-i+1,w-b,p))%p
print(ans)

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

#define fast_input() {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); }
#define For(i, l, r) for(int (i) = (l); (i) <= (r); ++(i))
#define For1(i, l, r) for(int (i) = (r); (i) >= (l); --(i))

/*
MIKUNO - 15/02/1999
*/
//	priority_queue <ll, vector<ll>, greater<ll> > q;
#define INF 1e9+5
using ll = long long;
const int N = 1e5 + 5;
const ll mod = 998244353;
vector<int> edges[N];
bool visited[N];
int dist[N];
int in_degree[N]; 
void dfs(int a) {
	visited[a] = 1;
	for (int b : edges[a]) {
		dist[b] = max(dist[b], dist[a] + 1);
		in_degree[b]--;
		if (in_degree[b] == 0) {
			dfs(b);
		}
	}
}

int main() {
	fast_input();
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int x, y;
		cin >> x >> y;
		edges[x].push_back(y);
		in_degree[y]++;
	}
	for (int i = 1; i <= n; ++i) {
		if (!visited[i] && in_degree[i] == 0) {
			dfs(i);
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans = max(ans, dist[i]);
	}
	cout << ans;
}



Measured memory_bytes: 9728
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

#素因数分解
def factorization(n):
	arr = []
	tmp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if tmp%i == 0:
			cnt = 0
			while tmp%i == 0:
				cnt += 1
				tmp //= i
			arr.append([i, cnt])
	if tmp != 1:
		arr.append([tmp, 1])

	return arr
	
N = INT()

arr = factorization(N)
lis = []
for i, j in arr:
	for k in range(1, j+1):
		lis.append(i**k)

lis.sort()
#print(arr)
#print(lis)

cnt = 0
for x in lis:
	if N%x == 0:
		cnt += 1
		N //= x

print(cnt)


Measured memory_bytes: 10360