akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
using namespace std;

char ss[30];
int len;
bool o1,o2,o3,o4;

int main(){
	o1=o2=o3=o4=false;
	cin>>ss; len=strlen(ss);
	for(int i=0;i<len;i++){
		if(ss[i]=='W')
			o1=true;
		if(ss[i]=='S')
			o2=true;
		if(ss[i]=='E')
			o3=true;
		if(ss[i]=='N')
			o4=true;
	}
	if(o4==o2&&o3==o1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll LCM = lcm(c, d);
    ll total = b - a + 1;
    ll not_c = b / c - (a - 1) / c;
    ll not_d = b / d - (a - 1) / d;
    ll not_c_d = b / LCM - (a - 1) / LCM;
    cout << total + not_c_d - not_c - not_d << endl;

    return 0;
}

Measured memory_bytes: 256
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 998244353;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N; string a[10000]; cin >> N;
  int ans = 0, A = 0, B = 0, C = 0;
  REP(i, N){
    cin >> a[i];
    REP(j, a[i].size()-1){
      if(a[i][j] == 'A' and a[i][j+1] == 'B') ans++;
    }
    if(a[i][0] == 'B') B++;
    if(a[i].back() == 'A') A++;
    if(a[i][0] == 'B' and a[i].back() == 'A') C++;
  }
  A-= C; B-=C;
  cerr << A << endl << B << endl << C << endl << ans << endl;
  if(C > 0){
  if(A > 0 and B > 0){
    ans += C+1;
    A--; B--;
  } else if(A <= 0 and B > 0) {
    ans += C; B--;
  } else if(A > 0 and B <= 0) {
    ans += C; A--;
  } else {
    ans += C-1;
  }
  }
  cout << ans + min(A, B) << endl;

  return 0;
}

Measured memory_bytes: 768
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

ll lcm(ll n, ll m) { return (n / __gcd(n, m)) * m; }

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vll as(n), bs(n);
  rep(i, n) { cin >> as[i] >> bs[i];
  }

  ll sum = 0;
  rep(i, n) {
    ll j = n - 1 - i;
    ll val = as[j] + sum;
    ll tar = bs[j] * ((val + bs[j] - 1) / bs[j]);
    sum += tar - val;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1792
N = int(input())
L = list(map(int, input().split()))

# SL = list(set(L))
SL = L
SL.sort()

anss = set()
for ix in range(len(SL)):
    for jx in range(ix+1,len(SL)):
        for ux in range(jx+1,len(SL)):
            if SL[ix] != SL[jx] != SL[ux] and SL[ix]+SL[jx] > SL[ux]:
                anss.add((ix+1, jx+1, ux+1))

print(len(anss))

Measured memory_bytes: 30852
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int N; cin >> N;
    vi a(N);
    vi b(N);
    ll sum_a = 0;
    ll sum_b = 0;
    rep(i, N) { cin >> a[i]; sum_a += a[i]; }
    rep(i, N) { cin >> b[i]; sum_b += b[i]; }

    bool yes = false;

    ll max_op = sum_b - sum_a;
    if (max_op >= 0) {
        ll a_1 = 0, a_2 = 0, b_1 = 0;
        rep(i, N) {
            if (a[i] < b[i]) {
                a_2 += (b[i]-a[i]) / 2;
                a_1 += (b[i]-a[i]) % 2;
            } else if (a[i] > b[i]) {
                b_1 += a[i] - b[i];
            }
        }
        // D3(a_1, a_2, b_1);
        if (a_2 >= b_1) {
            int op = b_1 + (a_2 - b_1)*2+a_1;
            if (op <= max_op) {
                yes = true;
            }
        }
    }
    cout << (yes ? "Yes" : "No") << endl;
}


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

int n;

void solve() {
	vector<int> ans;
	
	for (int i = 2; i <= n; i++) {
		if ((i % 7 == 1 || i % 7 == 6) && n % i == 0) {
			bool isPrime = true;
			for (int j = 2; j < i; j++) {
				if ((j % 7 == 1 || j % 7 == 6) && i % j == 0) {
					isPrime = false;
					break;
				}
			}
			if (isPrime) ans.push_back(i);
		}
	}
	
	cout << n << ":";
	for (int i = 0; i < ans.size(); i++) {
		cout << " " << ans[i];
	}
	cout << endl;
}

int main() {
	while (cin >> n) {
		if (n == 1) break;
		solve();
	}
	return 0;
}

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		//入力表示

		double L = sc.nextDouble();

		System.out.println(( L * L * L) / 27);

	}
}

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

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

    vector<int> a(n);

    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }

    sort(a.begin(),a.end(),greater<int>());

    int max=0;

    for(int i=0; i<n; i++){
        if(i%2 == 0){
            max += a.at(i);
        }else{
            max -= a.at(i);
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
//Ford-Fulkerson O(FE)
#include<algorithm>
#include<utility>
#include<vector>
#include<limits>
template<typename T>
struct MF{
	struct edge{
		int to,rev;
		T cap;
	};
	vector<vector<edge> >G;
	vector<int>used;
	MF(int n_=0):G(n_),used(n_,0){}
	void add_edge(int from,int to,T cap)
	{
		G[from].push_back({to,(int)G[to].size(),cap});
		G[to].push_back({from,(int)G[from].size()-1,0});
	}
	T dfs(int u,int t,T f,int dfstime)
	{
		if(u==t)return f;
		used[u]=dfstime;
		for(edge&e:G[u])
		{
			if(used[e.to]<dfstime&&e.cap>0)
			{
				T d=dfs(e.to,t,min(f,e.cap),dfstime);
				if(d>0)
				{
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	T max_flow(int s,int t)
	{
		T ret=0;
		for(int dfstime=1;;dfstime++)
		{
			T f=dfs(s,t,numeric_limits<T>::max(),dfstime);
			if(f>0)ret+=f;
			else break;
		}
		return ret;
	}
};
int H,W;
string s[100];
int d[4]={1,0,-1,0};
main()
{
	cin>>H>>W;
	for(int i=0;i<H;i++)cin>>s[i];
	MF<long>P(H*W*2+2);
	int st=H*W*2,go=H*W*2+1;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)
	{
		int id=i*W+j;
		if(i==0||j==0||i==H-1||j==W-1)P.add_edge(id*2+1,go,1e9);
		if(s[i][j]=='X')
		{
			P.add_edge(st,id*2,1e9);
			P.add_edge(id*2,id*2+1,1e9);
		}
		else P.add_edge(id*2,id*2+1,1);
		for(int r=0;r<4;r++)
		{
			int x=i+d[r],y=j+d[r^1];
			if(x<0||y<0||x>=H||y>=W)continue;
			P.add_edge(id*2+1,2*(x*W+y),1e9);
		}
	}
	long ans=P.max_flow(st,go);
	if(ans<1e9)cout<<ans<<endl;
	else cout<<-1<<endl;
}


Measured memory_bytes: 3836
// This template code suggested by KT BYTE Computer Science Academy
//   for use in reading and writing files for USACO problems.

// https://content.ktbyte.com/problem.java

import java.util.*;
import java.io.*;

public class Main {

    static StreamTokenizer in;

    static int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    static double nextDouble() throws IOException {
        in.nextToken();
        return in.nval;
    }

    public static void main(String[] args) throws Exception {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = nextInt();
        int k = nextInt();

        int[] sizes = new int[n];

        for (int i = 0; i < n; i++) {
            sizes[i] = nextInt();
        }

        boolean[] dp = new boolean[k+1];

        for (int i = 0; i <= k; i++) {
            for (int x: sizes) {
                if (i - x >= 0 && !dp[i - x]) { // if starting from before is not good, then it is possible at this state
                    dp[i] = true;
                }
            }
        }

        if (dp[k]) {
            out.println("First");
        }

        else {
            out.println("Second");
        }

        out.close();
    }
}

Measured memory_bytes: 33480
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())
graph = [0] + [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

from collections import deque

def bfs(graph, queue, dist, prev):
    while queue:
        current = queue.popleft()

        for n in graph[current]:
            if dist[n] != -1:
                continue
            else:
                dist[n] = dist[current] + 1
                prev[n] = current
                queue.append(n)

queue = deque([1])
dist = [0] + [-1] * n
prev = [0] + [-1] * n

bfs(graph, queue, dist, prev)

if -1 in prev:
    print('No')
else:
    print('Yes')
    for i in range(2, n+1):
        print(prev[i])


Measured memory_bytes: 95504
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int dataset;
  cin >> dataset;
  for (int i = 0; i < dataset; i++) {
    int x, y, w, h;
    cin >> x >> y >> w >> h;
    
    int n, cats = 0;
    cin >> n;
    for (int j = 0; j < n; j++) {
      int a, b;
      cin >> a >> b;
      if (x <= a && a <= x+w &&
          y <= b && b <= y+h)
        cats++;
    }
  
    cout << cats << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
n = int(raw_input())
a = map(int,raw_input().split())
b = map(int,raw_input().split())
ans = 0
for i in range(n):
  temp = min(a[i],b[i])
  a[i] -= temp
  b[i] -= temp
  ans += temp
  temp = min(a[i+1],b[i])
  a[i+1] -= temp
  b[i]   -= temp
  ans += temp
print ans

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

bool exist[1100000];
int s;
signed main() {
    cin>>s;
    int i;
    for(i=1;!exist[s];i++){
        exist[s]=1;
        if(s%2==0)
            s/=2;
        else
            s=s*3+1;
    }
    cout<<i<<endl;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val xx = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    val xxs = xx.sorted()

    val m1 = xxs[(n/2)-1]
    val m2 = xxs[n/2]

    xx.forEach {
        if (it <= m1) {
            println(m2)
        } else {
            println(m1)
        }
    }
}

Measured memory_bytes: 93456
class UnionFind:
    def __init__(self, n=0):
        self.d = [-1]*n
    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.d[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def size(self, x):
        return -self.d[self.find(x)]

n, m = map(int, input().split())

uf = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.unite(a, b)

ans = 1
for i in range(n):
    ans = max(ans, uf.size(i))
print(ans)


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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int NX = 1e6, B = 55555;
int prime[NX];

vector<int> v;

void pre() {
    REP(i, 2, NX) prime[i] = 1;
    REP(i, 2, NX) {
        if(prime[i]) {
            string s = to_string(i);
            if(s[sz(s)-1] == '3' && i <= B) {
                v.pb(i);
            }
            for(int j=2*i; j<NX; j+=i) {
                prime[j] = 0;
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    int N;
    cin >> N;
    REP(i, 0, N) {
        cout << v[i] << " " ;
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 7604
#include <iostream>
#include <cmath>

using namespace std;

constexpr int MAX_N = 300;

int memo[MAX_N+1][MAX_N+1];
int w[MAX_N];

int dfs(int i, int j) {
    if(memo[i][j] != -1) return memo[i][j];

    // あるペアの差の絶対値が1以下で，ペアの間の数が全て消せていたら，
    // そのペアを含めた区間も全て消せる
    if(abs(w[i]-w[i+j-1]) <= 1 && dfs(i+1, j-2) == j-2) {
        return memo[i][j] = j;
    }

    // 区間を途中で区切って最大の場合を見つける
    for(int k=i+1;k<=i+j;++k) {
        memo[i][j] = max(memo[i][j], dfs(i, k-i) + dfs(k, i+j-k));
    }
    return memo[i][j];
}

int solve(int n) {
    for(int i=0;i<n;++i){
        cin >> w[i];
    }

    fill_n(memo[0], (MAX_N+1)*(MAX_N+1), -1);
    for(int i=0;i<=n;++i) {
        memo[i][0] = 0;
        memo[i][1] = 0;
    }
    
    return dfs(0, n);
}

int main() {
    int n;
    while(cin >> n && n) {
        cout << solve(n) << endl;
    }
}


Measured memory_bytes: 3468
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	char a, b; cin >> a >> b;
	if (a == 'H' && b == 'H') cout << 'H' << endl;
	else if (a == 'H' && b == 'D')cout << 'D' << endl;
	else if (a == 'D' && b == 'H')cout << 'D' << endl;
	else cout << 'H' << endl;
	return 0;
}

Measured memory_bytes: 3524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
      int result = 0;
		for(int i = 1;i <= a;i++){
          result += i;
        }
      System.out.print(result);
      scan.close();
	}

}


Measured memory_bytes: 21332
N, K = map(int, input().split())


def Base_10_to_n(X, n):
    X_dumy = X
    out = ""
    while X_dumy > 0:
        out = str(X_dumy % n) + out
        X_dumy = int(X_dumy / n)
    return out


print(len(Base_10_to_n(N, K)))



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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    double a, b;
    cin >> a >> b;
    int ans = -1;
    for (int i = 1; i <= 1300; i++) {
        if (a / 0.08 <= i && i < (a + 1) / 0.08 && b / 0.1 <= i && i < (b + 1) / 0.1) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>

using namespace std;
const long long int MOD=1e9+7;

int main(){
  long long a, b, k;
  cin >> a >> b >> k;
  if(a>=k){
    cout << a-k<< ' ' << b << endl;
  }
  else{
    cout << 0 << ' ' << max((long long)0, b-(k-a)) << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct LowestCommonAncestor{
  int n,h;
  vector<vector<int> > G,par;
  vector<int> dep;
  LowestCommonAncestor(){}
  LowestCommonAncestor(int sz):
    n(sz),G(sz),dep(sz){
    h=1;
    while((1<<h)<=n) h++;
    par.assign(h,vector<int>(n,-1));
  }

  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }
  
  void dfs(int v,int p,int d){
    par[0][v]=p;
    dep[v]=d;
    for(int i=0;i<(int)G[v].size();i++){
      if(G[v][i]!=p) dfs(G[v][i],v,d+1);
    }
  }
  
  void build(int r=0){
    dfs(r,-1,0);
    for(int k=0;k+1<h;k++){
      for(int v=0;v<n;v++){
	if(par[k][v]<0) par[k+1][v]=-1;
	else par[k+1][v]=par[k][par[k][v]];
      }
    }
  }
  
  int lca(int u,int v){
    if(dep[u]>dep[v]) swap(u,v);
    for(int k=0;k<h;k++){
      if((dep[v]-dep[u])>>k&1){
	v=par[k][v];
      }
    }
    if(u==v) return u;
    for(int k=h-1;k>=0;k--){
      if(par[k][u]!=par[k][v]){
	u=par[k][u];
	v=par[k][v];
      }
    }
    return par[0][u];
  }

  int distance(int u,int v){
    return dep[u]+dep[v]-dep[lca(u,v)]*2;
  }
};
//END CUT HERE

signed main(){
  int n;
  cin>>n;
  LowestCommonAncestor lca(n);
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int c;
      cin>>c;
      lca.add_edge(i,c);
    }
  }
  lca.build();
  int q;
  cin>>q;
  while(q--){
    int u,v;
    cin>>u>>v;
    cout<<lca.lca(u,v)<<endl;
  }
  return 0;
}
/*
  verified on 2017/11/20
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C&lang=jp
*/



Measured memory_bytes: 18492
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = sc.nextLong()
    val c = sc.nextLong()
    var ans = Math.min(a + b + 1, c)
    ans += b
    println(ans)
}

Measured memory_bytes: 29356
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
cnt=0
ans=0
for i in range(3):
    if s[i]=="R":
        cnt+=1
    else:
        ans=max(ans,cnt)
        cnt=0
ans=max(cnt,ans)
print(ans)

Measured memory_bytes: 68212
#include <stdio.h>

int main(){
    int a, b, i, cnt=0;

    scanf("%d %d", &a, &b);

    for(i=a; i<=b; i++){
        if(i/10000 == i%10 && i/1000%10 == i/10%10)
            cnt++;
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int X, A;
  cin >> X >> A;

  if(X<A) cout << 0 << endl;
  else cout << 10 << endl;
    
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S = in<string>();
    bool ok = 1;
    int N = S.size();
    REP(i,N/2)if(S[i] != S[N-1-i])ok = 0;
    REP(i,(N/2)/2)if(S[i] != S[N/2-1-i])ok = 0;
    REP(i,(N/2)/2)if(S[N-1-i] != S[N/2+1+i])ok = 0;
    cout << (ok ? "Yes" : "No") << "\n";
}

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

#define sorted(vector) sort(vector.begin(),vector.end())
#define vmin(vector) *min_element(vector.begin(),vector.end())
#define vmax(vector) *max_element(vector.begin(),vector.end())
#define vsum(vector) accumulate(vector.begin(),vector.end(),0)
#define append(a) push_back(a)
#define int(a) stoi(a)
#define str(a) to_string(a)
#define bisect_left(vector,a) lower_bound(vector.begin(),vector.end(),a)
#define bisect_right(vector,a) upper_bound(vector.begin(),vector.end(),a)

using namespace std;

int main(void) {
    int a;
    cin>>a;
    double b;
    b=a;
    cout<<(a/2+a%2)/b<<endl;
}


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

using namespace std;

#define ll long long int

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

    ll x=n;
    ll ans=0;

    for(int i=1;i<n;i++){
        ans+= i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a<=0&&b>=0){
    cout << "Zero" << endl;
  } else if (a>0){
    cout << "Positive" << endl;
  } else if ((b-a+1)%2==0){
    cout << "Positive" << endl;
  } else {
    cout << "Negative" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
 
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define FOR0(i,n) for(int i=0;i<n;i++)
#define For(v) for(auto it = v.begin();it!=v.end();it++)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define FORD(i,a,b) for(int i=(a);i>=(int)(b);i--)
#define sf(n) scanf("%d", &n)
#define sfc(x) scanf("%c", &x)
#define pf(x) printf("%d", x)
#define pff(x) printf("%lf", x)
#define pfc(x) printf("%c", x)
#define pfs(x) printf("%s", x)
#define sf2(a,b) scanf("%d %d", &a, &b)
#define sf3(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()
#define ll long long
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
bool prime[33554440];
void SieveOfEratosthenes(ll n)
{
    memset(prime,true, sizeof(prime));
 
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
 
ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}
 

ll power1(ll a,ll b){
  ll res=1;
  while(b){
    if(b&1){
      res*=a;
    }
    a=a*a;
    b>>=1;
  }
  return res;
}

bool isPrime(ll n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    if (n%2 == 0 || n%3 == 0) return false;

    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}
ll divisor(ll number)
    {
        ll i;
        for (i = 2; i <sqrt(number); i++)
        {
            if (number % i == 0)
            {
                break;
            }
        }
        return number/i;
    }

ll fun(ll n,ll k) 
{ 
    ll count = 0; 
    for (ll i = k; n / i >= 1; i *= k) 
        count += n / i; 
  
    return count; 
}     
long long maxp(long long n) 
{ 
    long long maxPrime = -1; 
    while (n % 2 == 0) { 
        maxPrime = 2; 
        n >>= 1;  
    } 
   
    for (ll i = 3; i <= sqrt(n); i += 2) { 
        while (n % i == 0) { 
            maxPrime = i; 
            n = n / i; 
        } 
    } 
    if (n > 2) 
        maxPrime = n; 
  
    return maxPrime; 
} 
int main(){
  fast 
  ll n,m;
  cin>>n>>m;
  ll freq[31]={0};
  FOR0(i,n){
    ll k;
    cin>>k;
    FOR0(j,k){
      ll x;
      cin>>x;
      freq[x]++;
    }
  }
  ll count=0;
  FOR0(i,31)if(freq[i]==n)count++;
  cout<<count;
}

Measured memory_bytes: 256
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

left = 1
right = W
bottom = 1
top = H

if S[-1] == 'L':
    left += 1
elif S[-1] == 'R':
    right -= 1
elif S[-1] == 'U':
    bottom += 1
elif S[-1] == 'D':
    top -= 1

for i in range(N - 1)[:: -1]:
    if T[i] == 'L':
        right = min(W, right + 1)
    elif T[i] == 'R':
        left = max(1, left - 1)
    elif T[i] == 'U':
        top = min(H, top + 1)
    elif T[i] == 'D':
        bottom = max(1, bottom - 1)

    if S[i] == 'L':
        left += 1
    elif S[i] == 'R':
        right -= 1
    elif S[i] == 'U':
        bottom += 1
    elif S[i] == 'D':
        top -= 1

    if left > right or bottom > top:
        print('NO')
        break
else:
    if left <= sc <= right and bottom <= sr <= top:
        print('YES')
    else:
        print('NO')



Measured memory_bytes: 3888
fun main(args: Array<String>) {
    val n = readLine()!!

    val f = n.first().toString()
    val z = f.repeat(3)

    val ans = if (n.toInt() <= z.toInt()) {
        z
    } else {
        (f.toInt() + 1).toString().repeat(3)
    }

    println(ans)
}

Measured memory_bytes: 33724
#include<stdio.h>
int main(void)
{
  int i,n;
  for(i=1; i<10; i++){

    printf("1x%d=%d\n" ,i,1*i);
  }
 for(i=1; i<10; i++){

    printf("2x%d=%d\n" ,i,2*i);
  
}

 for(i=1; i<10; i++){

    printf("3x%d=%d\n" ,i,3*i);
 }
for(i=1; i<10; i++){

    printf("4x%d=%d\n" ,i,4*i);
 }
for(i=1; i<10; i++){

    printf("5x%d=%d\n" ,i,5*i);
 }
for(i=1; i<10; i++){

    printf("6x%d=%d\n" ,i,6*i);
 }
for(i=1; i<10; i++){

    printf("7x%d=%d\n" ,i,7*i);
 }

for(i=1; i<10; i++){

    printf("8x%d=%d\n" ,i,8*i);
 }
for(i=1; i<10; i++){

    printf("9x%d=%d\n" ,i,9*i);
 }



 return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main() {
	int h, w;
	cin >> h >> w;
	Pi at, ter;
	int ans = 0;
	cin >> at >> ter;
	at.F--;
	at.S--;
	ter.F--;
	ter.S--;
	vector<string> data(h);
	///	input(data);
	cin >> data;
	VVi dis(h, Vi(w, INF));
	deque<Pi> q;
	q.push_back(at);
	dis[at.F][at.S] = 0;
	while (!q.empty()) {
		at = q.front();
		q.pop_front();
		for (int ni = max(0, at.F - 2); ni < min(h, at.F + 3); ni++) {
			for (int nj = max(0, at.S - 2); nj < min(w, at.S + 3); nj++) {
				if (data[ni][nj] == '#') continue;
				if (abs(at.F - ni) + abs(at.S - nj) == 1) {
					if (chmin(dis[ni][nj], dis[at.F][at.S])) {
						q.push_front(mp(ni, nj));
					}
				} else {
					if (chmin(dis[ni][nj], dis[at.F][at.S] + 1)) {
						q.push_back(mp(ni, nj));
					}
				}
			}
		}
	}

	ans = dis[ter.F][ter.S];
	if (ans == INF) {
		cout << -1 << endl;
	} else {
		cout << ans << endl;
	}
	//	cout<<ans<<endl;
}

Measured memory_bytes: 9512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 200010;
 
// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}
 
ll inverse(ll a) {
    return modpow(a, mod-2);
}
 
ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];
 
void init() {
    inv[0] = fact[0] = invfact[0] = 1;
    inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n <= 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}
 
//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n;
    cin >> n;
 
    vl a(n+1);
    vl v(n+1);  // v[i] : aにiが現れる回数
    ll l, r;
    ll u;
    rep(i, n+1) {
        cin >> a[i];
        v[a[i]]++;
        if(v[a[i]] == 2) {
            r = i;
            u = a[i];
        }
    }
 
    rep(i, n) {
        if(a[i] == u) {
            l = i;
            break;
        }
    }
 
    init();
 
    exrep(k, 1, n+1) {
        if(k == 1) {
            out(n);
        }
        else if(k == n+1) {
            out(1);
        }
        else {
            ll ans = mod + Comb(n+1, k) - Comb(n-r+l, k-1);
            ans %= mod;
            out(ans);
        }
    }
 
    re0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          firstn
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define fr(i,l,u) 	for(i=l;i<=u;i++)
#define bk(i,l,u)	for(i=l;i>=u;i--)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll posx[]={1,-1,0,0};
ll posy[]={0,0,1,-1};

void solve()
{
    ll n,i,j,k;
    cin>>n;
    ll a[n][3],dp[n][3];
    for(i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
        dp[i][0]=mod;
        dp[i][1]=mod;
        dp[i][2]=mod;
    }
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(i=1;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+a[i][j];
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 4992
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	final long MOD = (long) 1e9 + 7;

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long[][][] dp = new long[N][N + 1][1 + N * (N + 1)];// curPos, go, sum
		dp[0][0][0] = 1;// 1-1
		dp[0][1][0] = 1;// 1-?
		for (int pos = 0; pos < N - 1; ++pos) {
			for (int go = 0; go <= pos + 1; ++go) {
				for (int sum = 0; sum <= N * (N + 1); ++sum) {
					if (dp[pos][go][sum] == 0)
						continue;
					for (int pre_go = 0; pre_go <= 1; ++pre_go) {
						for (int cur_go = 0; cur_go <= 1; ++cur_go) {
							int npos = pos + 1;
							int ngo = go + 1 - pre_go - cur_go;
							int nsum = sum + 2 * go;
							if (ngo < 0)
								continue;
							long coe = (pre_go == 1 ? go  : 1) * (cur_go == 1 ? go : 1) % MOD;
							dp[npos][ngo][nsum] = (dp[npos][ngo][nsum] + dp[pos][go][sum] * coe % MOD) % MOD;
						}
					}
					dp[pos + 1][go][sum + 2 * go] = (dp[pos + 1][go][sum + 2 * go] + dp[pos][go][sum]) % MOD;
				}
			}
		}
		
		System.out.println(dp[N - 1][0][K]);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 87916
#include<bits/stdc++.h>
 
using namespace std;
#define MAXN   1000001 

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int n;
cin>>n;

int x= (n + 999)/1000;

cout<< x*1000 - n;

}

 
 

 


Measured memory_bytes: 3628
n = gets.to_s.to_i
# d,n = gets.to_s.split.map{|i|i.to_i}
#cts = Array.new(n){ gets.to_s.split.map{|i|i.to_i} }

ans = n / 11 * 2 

r = n % 11

if 0 < r && r <= 6
  ans += 1
elsif 6 < r && r < 11
  ans += 2
end

puts ans

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>
#include<queue>

using namespace std;

#define ll long long
typedef pair<ll, ll> P;

int main(){
    string A,B;
    cin >> A >> B;
    int dif = 'A' - 'a';
    // cout << dif;
    if(A.size() == B.size()){
        for(int i=0; i<A.size(); i++){
            if(A[i] > B[i]){
                cout << "GREATER" << endl;
                return 0;
            }else if(A[i] < B[i]){
                cout << "LESS" << endl;
                return 0;
             } 
            if(i == A.size()-1 && A[i] == B[i]) cout << "EQUAL" << endl;
        }
    }else{
        if(A.size() > B.size()){
            cout << "GREATER" << endl;
        }else{
            cout << "LESS" << endl;
        }
    }
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int mod = 998244353;
const int N = 2e5+23;

int n, m, k;
int f[N];

int binpow(long long b, long long e) {
  if (!e) return 1;
  if (e&1) return b*binpow(b, e-1)%mod;
  return binpow(b*b%mod, e/2);
}

int C(int n, int k) {
  return 1LL * f[n] * binpow(f[k], mod-2) % mod * binpow(f[n-k], mod-2) % mod;
}

void solve() {
  scanf("%d%d%d", &n, &m, &k);
  f[0] = 1;
  for (int i = 1; i <= n; ++i) {
    f[i] = 1LL * f[i-1] * i % mod;
  }
  long long ans = 0;
  for (int i = 0; i <= k; ++i) {
    ans = ans + 1LL * m * C(n-1, i) % mod * binpow(m-1, n-1-i) % mod;
    ans %= mod;
  }
  printf("%lld", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4644
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = list(iss())
    ret = 0
    for n in range(N):
        ret = max(ret, len(set(S[:n]) & set(S[::-1][:-n])))
    print(ret)


if __name__ == '__main__':
    main()


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

// https://scrapbox.io/ganariya/%E3%82%BB%E3%82%B0%E3%83%A1%E3%83%B3%E3%83%88%E6%9C%A8%E3%80%80%E3%83%A9%E3%82%A4%E3%83%96%E3%83%A9%E3%83%AA
template <typename T>
struct SegmentTree {
   private:
    vector<T> node;
    int n;
    function<T(T, T)> func;
    T init_v;

   public:
    // 初期化
    SegmentTree(vector<T> &a, function<T(T, T)> _func, T _init_v) {
        int sz = a.size();
        func = _func;
        init_v = _init_v;
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2 * n, _init_v);
        for (int i = 0; i < sz; ++i) node[i + n - 1] = a[i];
        for (int i = n - 2; i >= 0; --i) node[i] = func(node[i * 2 + 1], node[i * 2 + 2]);
    }

    void update(int pos, T v) {
        int k = pos + n - 1;
        node[k] = v;
        while (k > 0) {
            k = (k - 1) / 2;
            node[k] = func(node[k * 2 + 1], node[k * 2 + 2]);
        }
    }

    T get(int pos) {
        int k = pos + n - 1;
        return node[k];
    }

    // [a, b)
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return init_v;
        if (a <= l && r <= b) return node[k];
        T lv = query(a, b, k * 2 + 1, l, (l + r) / 2);
        T rv = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return func(lv, rv);
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    auto f = [](int a, int b) -> int { return a < b ? a : b; };
    vector<int> a(n, INT_MAX);
    SegmentTree<int> Sgt(a, f, INT_MAX);
    int com, x, y;
    while (q--) {
        cin >> com >> x >> y;
        if (com == 0) {
            // update
            Sgt.update(x, y);
        } else {
            // find
            cout << Sgt.query(x, y + 1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4092
using System;
class Program
{
    static void Main(string[] args)
    {
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        //出力
        if (a < b) Console.WriteLine("a < b");
        if (a == b) Console.WriteLine("a == b");
        if (a > b) Console.WriteLine("a > b");
    }
}


Measured memory_bytes: 15948
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iso646.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll t = (C + B - 1) / B;
    ll a = (A + D - 1) / D;
    if(t <= a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3100
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		long n = sc.nextLong();
		long m = sc.nextLong();
		
		if (2*n>=m) {
			System.out.print(m/2);
		}
		else {
			long a = m-2*n;
			long b = n + a/4;
			System.out.print(b);
		}
	}

}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main()
{
    int inputR;
    int inputG;
    int inputB;
    int inputN;
    
    cin >> inputR >> inputG >> inputB >> inputN;
    
    if (3000 < inputR) {
        cout << "Invalid argument R = " << inputR << "¥n";
        return 1;
    }
    
    if (3000 < inputG) {
        cout << "Invalid argument G = " << inputG << "¥n";
        return 1;
    }
    
    if (3000 < inputB) {
        cout << "Invalid argument B = " << inputB << "¥n";
        return 1;
    }
    
    if (3000 < inputN) {
        cout << "Invalid argument N = " << inputN << "¥n";
        return 1;
    }
    
    int i = 0, j = 0, k = 0;
    int resolv_count = 0;
    for (i = 0; i <= inputN; i++) {
        int Rr = inputR * i;
        if (inputN < Rr) {
            break;
        }
        
        if (inputN == Rr) {
            resolv_count++;
            // これ以降は全てダメ
            break;
        }
        
        for (j = 0; j <= inputN; j++) {
            int Gg = inputG * j;
            if (inputN < Rr + Gg) {
                break;
            }
            
            if (inputN == Rr + Gg) {
                resolv_count++;
                break;
            }
            
            int a = inputN - ( Rr + Gg );
            
            if (a % inputB == 0) {
                resolv_count++;
            }
        }
    }
    
    cout << resolv_count;
}

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

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int a = in.nextInt();
        int b = in.nextInt();

        if (a >= 13) {
            out.println(b);
        } else if (a >= 6 && a <= 12) {
            out.println(b / 2);
        } else {
            out.println(0);
        }
    }
}


Measured memory_bytes: 21204
n,k = map(int,input().split())
A = [int(i) for i in input().split()]
dp = ["Second"]+["First"]*k
for i in range(1,k+1):
    win = "Second"
    for a in A:
        if i-a >= 0 and dp[i-a] == "Second":
            win = "First"
    dp[i] = win
print(dp[k])


Measured memory_bytes: 41964
#include<bits/stdc++.h>
using namespace std;
int jc(int n){
	if(n==0) return 0;
	if(n==1) return 1;
	return n*jc(n-1); 
}
int a[8],b[8],aa[9],bb[9];
bool d[9];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	memset(d,0,sizeof(d));
    for(int i=0;i<n;i++){
    	int ans=1;
    	for(int j=1;j<=a[i];j++){
    		if(!d[j])
    		ans++;
		}
    	aa[a[i]]=ans-1;
    	d[a[i]]=true;
	}
	memset(d,0,sizeof(d));
	for(int i=0;i<n;i++){
    	int ans=1;
    	for(int j=1;j<=b[i];j++){
    		if(!d[j])
    		ans++;
		}
    	bb[b[i]]=ans-1;
    	d[b[i]]=true;
	}
	int sum1=0,sum2=0;
	for(int i=0;i<n;i++){
		sum1+=jc(n-1-i)*aa[a[i]];
		sum2+=jc(n-1-i)*bb[b[i]];
	}
	cout<<abs(sum1-sum2);
	return 0;
} 

Measured memory_bytes: 256