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

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

ll L, R;

int main() {
    cin >> L >> R;
    ll ans = (L * R) % 2019;
    for (ll i = L; i <= min(R, L+2019); ++i) {
        for (ll j = i+1; j <= min(R, L+2019); ++j) {
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, M, K;
        cin >> N >> M >> K;
        vll A(N), B(M);
        rep(i, 0, N) cin >> A[i];
        rep(i, 0, M) cin >> B[i];
        vll acc1(N+1), acc2(M+1);
        rep(i, 1, N+1) acc1[i] += acc1[i-1] + A[i-1];
        rep(i, 1, M+1) acc2[i] += acc2[i-1] + B[i-1];


        ll ans = 0;
        rep(i, 0, N) {
                if (K - acc1[i+1] < 0) break;
                ll pos = upper_bound(all(acc2), K-acc1[i+1]) - acc2.begin() - 1;
                ll tmp = max(pos, 0LL);
                chmax(ans, i+1+tmp);
        }

        rep(i, 0, M) {
                if (K - acc2[i+1] < 0) break;
                ll pos = upper_bound(all(acc1), K-acc2[i+1]) - acc1.begin() - 1;
                ll tmp = max(pos, 0LL);
                chmax(ans, i+1+tmp);
        }

        cout << ans << endl;
}

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


int main() {
    ll n,k;
    cin>>n>>k;
    ll ans;
    if (n>k){
        ans = n-k*(n/k);
    }else{
        ans = n;
    }
    ans = min(ans,abs(k-ans));
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3640
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<stack>
#include<tuple>
using namespace std;
#define INF 1100000000000
#define MAX 100000
#define MOD 100000
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

ll dp[110000];

int main(){
    int N,h[110000];
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>h[i];
    }
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<N;i++){
        dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
    }
    cout<<dp[N-1]<<endl;
}



Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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


vector<int> v[10100];
ll c[10100];
ll res[10100];
int index;

void dfs(int s, int prev){
    res[s] = c[index];
    index--;

    for(auto x: v[s]){
        if(x != prev){
            dfs(x, s);
        }
    }
}



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

    for(int i = 0; i < N-1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[b].push_back(a);
        v[a].push_back(b);
    }

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

    sort(c, c+N);
    index = N-1;

    dfs(0, 0);

    ll s = 0;
    for(int i = 0; i < N-1; i++){
        s += c[i];
    }
    cout << s << endl;
    for(int i = 0; i < N; i++){
        cout << res[i] << " ";
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
using namespace std;
long long a,b,c,k,ans;
int main()
{
    cin>>a>>b>>c>>k;
    if(a>=k) ans=k;
    else{
        if(a+b>=k) ans=a;
        else{
            ans=2*a-k+b;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, m;
vector<P> ans;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	if(n%2){
		llint x = 2*m+1;
		for(int i = 1; i <= m; i++) cout << i << " " << x-i << endl;
	}
	else{
		llint h = n/2;
		for(int i = 1; i <= h/2; i++) ans.push_back(P(i, h+1-i));
		for(int i = 1; i <= h/2; i++) ans.push_back(P(n/2+i, n-i));
		for(int i = 0; i < m; i++) cout << ans[i].first << " " << ans[i].second << endl;
	}
	
	return 0;
}

Measured memory_bytes: 5236
import collections
num = int(input())

arr = []

for i in range(num):
    arr.append("".join(sorted(input())))


c = collections.Counter(arr)


cnt = 0
for i in list(c.values()):
    if i ==1:
        continue
    
    cnt += (i-1)*(i)//2

print(cnt)



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

using namespace std;

const double EPS = 1e-10;

struct star {
    double x, y, z;
    bool find;
};

struct telescope {
    double x, y, z, phi;
};

star s[505];
telescope t[51];
int n;  // number of stars
int m;  // number of telescopes

bool check(int tn, int sn)
{
    double inner, ss, ts, theta;
 
    inner = t[tn].x * s[sn].x + t[tn].y * s[sn].y 
        + t[tn].z * s[sn].z;
    ss = sqrt(s[sn].x * s[sn].x + s[sn].y * s[sn].y
              + s[sn].z * s[sn].z);
    ts =  sqrt(t[tn].x * t[tn].x + t[tn].y * t[tn].y
               + t[tn].z * t[tn].z);
    theta = acos(inner / (ss * ts));

    if (EPS <= theta && theta <= t[tn].phi + EPS)
        return true;
    else
        return false;
}

void solve()
{
    int ans = 0;
    
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            if (!s[j].find && check(i, j)) {
                s[j].find = true;
                ans++;
            }
        }
    }
    cout << ans << endl;
}

int main()
{
    while (cin >> n, n) {
        for (int i = 0; i < n; i++) {
            cin >> s[i].x >> s[i].y >> s[i].z;
            s[i].find = false;
        }
        cin >> m;
        for (int i = 0; i < m; i++)
            cin >> t[i].x >> t[i].y >> t[i].z >> t[i].phi;

        solve();
    }

    return 0;
}

Measured memory_bytes: 1316
N = int(input())
S = input()

R = S.count("R")
G = S.count("G")
B = S.count("B")
total = R*G*B

for i in range(N):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            total -= 1

print(total)


Measured memory_bytes: 68148
#include<stdio.h>
#include<math.h>
int main(void){
    long int n,m,nkai,mkai,nmkai,i,large;
    large=1000000000+7;
    scanf("%ld %ld",&n,&m);
    if(n-m>1 || m-n>1){
        printf("0\n");
        return 0;
    }
    nkai=1;
    for(i=n;i>0;i--){
        nkai*=i;
        nkai=nkai % large;
    }
    mkai=1;
    for(i=m;i>0;i--){
        mkai*=i;
        mkai=mkai%large;
    }
    nmkai=nkai*mkai;
    nmkai=nmkai%large;
    if(n-m==0){
        nmkai*=2;
        nmkai=nmkai%large;
    }
    printf("%ld\n",nmkai);
    return 0;
}



Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		Node2[] arr = new Node2[n];
		for (int i = 0; i < n; i++) {
			Node2 o = new Node2();
			arr[i] = o;
		}
		for (int i = 0; i < n - 1; i++) {
			sa = br.readLine().split(" ");
			int a = Integer.parseInt(sa[0]) - 1;
			int b = Integer.parseInt(sa[1]) - 1;
			arr[a].nexts.add(b);
			arr[b].nexts.add(a);
		}
		br.close();

		Queue<Integer> que = new ArrayDeque<>();
		que.add(0);
		arr[0].grp = 1;
		while (!que.isEmpty()) {
			int cur = que.poll();
			for (int next : arr[cur].nexts) {
				if (arr[next].grp == 0) {
					que.add(next);
					arr[next].grp = 3 - arr[cur].grp;
				}
			}
		}

		int[] rem = new int[4];
		int n2 = n / 3;
		rem[1] = n2;
		rem[2] = n2;
		rem[3] = n2;
		int n3 = n % 3;
		if (n3 > 0) rem[1]++;
		if (n3 > 1) rem[2]++;

		int[] cnt = new int[3];
		for (int i = 0; i < n; i++) {
			cnt[arr[i].grp]++;
		}
		int mincnt = cnt[1];
		int mingrp = 1;
		if (cnt[1] > cnt[2]) {
			mincnt = cnt[2];
			mingrp = 2;
		}

		int[] ans = new int[n];
		if (mincnt <= rem[3]) {
			for (int i = 0; i < n; i++) {
				if (arr[i].grp == mingrp) {
					ans[i] = rem[3] * 3;
					rem[3]--;
				} else {
					for (int j = 1; j <= 3; j++) {
						if (rem[j] > 0) {
							rem[j]--;
							ans[i] = rem[j] * 3 + j;
							break;
						}
					}
				}
			}
		} else {
			for (int i = 0; i < n; i++) {
				for (int j = 1; j <= 3; j++) {
					if (arr[i].grp == j && rem[j] > 0 || j == 3) {
						rem[j]--;
						ans[i] = rem[j] * 3 + j;
						break;
					}
				}
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(ans[i]).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}

	static class Node2 {
		int grp;
		Integer target;
		List<Integer> nexts = new ArrayList<>();
	}
}


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N, M; cin>>N>>M;
    vec_int k(M);
    vector<vector<int>> s(M);
    rep(i,M){
        cin>>k.at(i);
        vec_int temp(k.at(i));
        rep(j,k.at(i))cin>>temp.at(j);
        s.at(i) = temp;
    }
    vec_int p(M);
    rep(i,M){
        cin>>p.at(i);
    }

    int tott = 0;
    for(int combi=0;combi<pow(2,N);combi++){
        bitset<10> bits(combi);
        int num=0;
        for(int i=0;i<M;i++){
            // 電球:iに関して
            vec_int light_arr = s.at(i);
            int tot_on = 0;
            for(int j=1;j<N+1;j++){//N個のスイッチがlight_arrの中にあるかをチェック
            if(bits[j-1]==0)continue;
                for(auto aaa : light_arr){
                    if(aaa==j){
                        tot_on++;
                        break;
                    }
                }
            }
            if(tot_on%2==p.at(i)){
                num++;
            }
        }
        if(num==M){
            tott++;
        }
    }
    cout<<tott<<endl;



    return 0;
}

Measured memory_bytes: 4068
#include <bits/stdc++.h>
#include<utility>
#include<map>
typedef long long ll;
typedef unsigned long long ull;
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
ll pow1(ll n,ll p)
{
	if(p==0)	return 1;
	ll x=pow1(n, p/2);
	x=(x*x)%mod;
	if(p%2==0)
		return x;
	else
		return (x*n)%mod;
}

using  namespace std;

int main()
{
        ll n,i,k,j;
        std::cin >> n>>k;
        ll a[n],b[n],sum=0;
        for(i=0;i<n;i++)
        {
            std::cin >> a[i];
            b[i]=1000000007;
        }
        b[n-1]=0;
        b[n-2]=llabs(a[n-1]-a[n-2]);
        for(i=n-3;i>=0;i--)
        {
            for(j=1;j<=k&&i+j<n;j++)
            {
                b[i]=min(llabs(a[i+j]-a[i])+b[i+j],b[i]);
            }
        }
        std::cout << b[0] << std::endl;
}

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

int main()
{
    string S;
    cin >> S;
    if (S.at(2) == S.at(3) && S.at(4) == S.at(5))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3644
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    println!("{}", s.trim().chars().filter(|&c| c == '1').count());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 1e9+7;
const lint INF = mod;
const int MAX = 100010;

int main(){
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d\n", d==1);
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n, q, i, j, min, max;
    scanf("%d %d", &n, &q);
    char s[200001];
    scanf("%s", s);
    char t[200001], d[200001];
    for(i = 0; i < q; ++i) {
        scanf("\n%c %c", &t[i], &d[i]);
    }
    for(i =q-1, min = 0, max = n-1; i >= 0; --i) {
        switch(d[i]) {
            case 'R':
                if(t[i] == s[max]) { max--; }
                if(min > 0 && t[i] == s[min-1]) { min--; }
                break;
            case 'L':
                if(t[i] == s[min]) { min++; }
                if(max < n-1 && t[i] == s[max+1]) { max++; }
                break;
        }
    }
    printf("%d\n", max - min + 1);
    return 0;
}

Measured memory_bytes: 768
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int a,b;cin>>a>>b;
  for(int i = 0; 100000 > i; i++){
    if(i*8/100 == a && i*10/100 == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,x,ans=0; cin>>n>>x; 
    int a[n];
    for (int &i: a) cin>>i;
    sort(a,a+n);
    int i;
    for (i=0;i<n;i++){
        if (x>=a[i]) ans++, x -= a[i];
        else break;
    }
    if (x and ans and i>=n) ans--;
    cout << ans << endl;
    
}

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


Measured memory_bytes: 3620
def gcd(a, b):
	'''最大公約数'''
	while b != 0:
		a, b = b, a % b
	return a

def lcm(a, b):
	'''最小公倍数'''
	return (a * b) // gcd(a, b)

def ex_gcd(a, b):
	'''拡張ユークリッドアルゴリズム'''
	x1, x2 = 0, 1
	y1, y2 = 1, 0
	q = 0
	while b != 0:
		x1, x2 = x2, x1 - q * x2
		y1, y2 = y2, y1 - q * y2
		q = a // b
		a, b = b, a % b
	return a, x2, y2

def gcd_n(a, *numbers):
	'''複数の数の最大公約数'''
	d = a
	for b in numbers:
		d = gcd(d, b)
	return d

def lcm_n(a, *numbers):
	'''複数の数の最小公倍数'''
	m = a
	for b in numbers:
		m = lcm(m, b)
	return m

def factorize(n):
	'''素因数分解'''
	factor = 2
	factors = []
	while factor * factor <= n:
		if n % factor == 0:
			count = 1
			n //= factor
			while n % factor == 0:
				n //= factor
				count += 1
			factors.append((factor, count))
		factor += 1
	if n != 1:
		factors.append((n, 1))
	return factors

def totient(n):
	'''オイラーのトーシェント関数'''
	phi = 1
	for prime, count in factorize(n):
		phi *= (prime - 1) * (prime ** (count - 1))
	return phi

def carmichael(n):
	'''カーマイケル関数'''
	prime_carmichaels = [1]
	for prime, count in factorize(n):
		if prime == 2:
			prime_carmichaels.append(count if count <= 2 else (2 ** (count - 2)))
		else:
			prime_carmichaels.append((prime - 1) * (prime ** (count - 1)))
	return lcm_n(*prime_carmichaels)


class Modulo (object):
	def __init__(self, mod):
		self.mod = mod
		self.carmichael = carmichael(mod)
	
	def add(self, x, y):
		return (x + y) % self.mod
	
	def sub(self, x, y):
		return (x - y) % self.mod
	
	def mul(self, x, y):
		return (x * y) % self.mod
	
	def div(self, x, y):
		return self.mul(x, self.inv(y))
	
	def inv(self, x):
		return self.pow(x, self.carmichael - 1)
	
	def pow(self, x, count):
		return pow(x, count, self.mod)


from functools import reduce


MOD = Modulo(998244353)

N, M, K = map(int, input().split())

F = [1] * N
for n in range(1, N):
	F[n] = MOD.mul(F[n-1], n)

print(
	reduce(
		MOD.add,
		(
			MOD.mul(
				MOD.div(
					F[N-1],
					MOD.mul(F[k], F[(N-1)-k])
				),
				MOD.mul(
					M,
					MOD.pow(M-1, (N-k)-1)
				)
			)
			for k in range(K+1)
		)
	)
)


Measured memory_bytes: 17136
#include<stdio.h>

long long int max(long long int a, long long int b){return a<b?b:a;}

int N, W, w[100001], v[100001], i, j;
long long int d[101][100001];

int main(){
	scanf("%d%d", &N, &W);
	for(i=0; i<N; i++){
		scanf("%d%d", w+i, v+i);
	}
	for(i=N-1; i>=0; i--){
		for(j=0; j<=W; j++){
			if(j<w[i]){
				d[i][j] = d[i+1][j];
			}else{
				d[i][j] = max(d[i+1][j], d[i+1][j-w[i]]+v[i]);
			}
		}
	}
	printf("%lld\n", d[0][W]);
}


Measured memory_bytes: 78336
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;

const int MAX = 510000;
const int MOD = 1000000007;
const long long INF = 1LL << 60;

ll dp[100001][101] = {0};

int main(){
    int N,W;
    int w[101];
    int v[101];

    cin >>N>>W;

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

    for(int i = 0; i < 100001; i++){
        for(int j = 0;j < 101;j++){
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;

    for(int i = 0; i <= 100000;i++){
        for(int j = 0; j < N; j++){
            if(i >= v[j])dp[i][j+1] = min(dp[i][j], dp[i-v[j]][j] + w[j]);
            else dp[i][j+1] = dp[i][j];
        }
    }

    ll ans = -1;

    for(int v = 0; v <= 100000; v++){
        if(dp[v][N] <= W){
            ans = v;
        }
    }
    cout <<ans<<endl;

    return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;

bool comp(const pair<int,int> a, const pair<int,int> b) {
    return a.second < b.second;
}

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


*/


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

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            List<int> gather = new List<int>();
            int[] ans = new int[S.Length];

            for (int i = 0; i < S.Length - 1; i++)
            {
                if(S[i] == 'R' && S[i+1] == 'L')
                {
                    gather.Add(i);
                }
                ans[i] = 0;
            }
            ans[S.Length - 1] = 0;
            int j = 0;

            for(int i=0; i<S.Length; i++)
            {
                if (S[i] == 'R')
                {
                    if((gather[j] - i) % 2 == 0)
                    {
                        ans[gather[j]]++;
                    }
                    else
                    {
                        ans[gather[j]+1]++;
                    }
                }
                if(j < gather.Count())
                {
                    if (i == gather[j])
                    {
                        j++;
                    }
                }
                if(S[i] == 'L')
                {
                    if((i - gather[j-1]) % 2 == 0)
                    {
                        ans[gather[j-1]]++;
                    }
                    else
                    {
                        ans[gather[j - 1] + 1]++;
                    }
                }

            }
            for(int i=0; i<S.Length; i++)
            {
                Console.Write(ans[i]);
                if (i + 1 < S.Length)
                {
                    Console.Write(' ');
                }
            }


        }
    }
}

Measured memory_bytes: 13468
// #pragma GCC optimize(“O2”)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include<bitset>
using namespace std;
#define pi 3.14159265358979323846264338327950254
 #define STDIN freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);//************************************
 
#define ll long long
// #define int ll

const int mod = 100999;

int main()
{
    //STDIN
    int r; cin >> r;
    printf("%f\n", pi*r*2);
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int a[3];
    bool f = false;
    rep(i, 0, 3){
        cin >> a[i];
        if(a[i] % 2 == 0) f = true;
    }
    if(f){
        cout << 0 << endl;
        return 0;
    }
    sort(a, a + 3);
    int ans = a[0] * a[1] * (a[2] % 2);
    cout << ans << endl;
}

Measured memory_bytes: 256
def prime(a)
    if a==1
        return false
    end
    limit = Math::sqrt(a).to_i
    for i in 2..limit
        if a%i==0
            return false
        end
    end
    return true
end

while true
    line = gets
    a, d, n = line.split.map(&:to_i)
    if a==0 && d==0 && n==0
        break
    end
    count = 0

    while true
        if prime a
            count += 1
        end
        if count>=n
            puts a
            break
        end
        a += d
    end
end

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

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto dp = new long[string][](N+1);
	dp[0][""] = 1;
	auto str = "ACGT";
	foreach (i; 0..N)
	{
		foreach (key; dp[i].keys)
		{
			foreach (j; 0..4)
			{
				auto nKey = key ~ str[j];
				if (nKey.length > 4)
					nKey.popFront;
				else if (nKey.length < 3)
				{
					auto tmp = dp[i+1].get(nKey, 0);
					tmp.moda(dp[i][key]);
					dp[i+1][nKey] = tmp;
					continue;
				}
				if (nKey[$-3..$] == "AGC") continue;
				if (nKey[$-3..$] == "ACG") continue;
				if (nKey[$-3..$] == "GAC") continue;
				if (nKey[0..2] == "AG" && nKey[$-1] == 'C') continue;
				if (nKey[0] == 'A' && nKey[$-2..$] == "GC") continue;
				auto tmp = dp[i+1].get(nKey, 0);
				tmp.moda(dp[i][key]);
				dp[i+1][nKey] = tmp;
			}
		}
	}

	long ans;
	foreach (key; dp[N].keys)
		ans.moda(dp[N][key]);

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 4988
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int w, h;
	cin >> w >> h;
	int x[w], y[h], xsum = 0, ysum = 0;
	for(int i = 0; i < w; i++) cin >> x[i], xsum += x[i];
	for(int i = 0; i < h; i++) cin >> y[i], ysum += y[i];
	sort(y, y + h, greater<int>());
	int flg = 1;
	for(int i = 0; i < h; i++){
		sort(x, x + w, greater<int>());
		for(int j = 0; j < y[i]; j++){
			x[j]--;
			if(x[j] < 0) flg = 0;
		}
	}
	if(flg) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3148
/*
AizuOnline A0105
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
struct STR_Index 
{ char title[31];
  int  page;} Index[100];

//
int comp_index(void * x,void * y)
{
  int ret;
  ret= strcmp(((struct STR_Index *)x)->title,
    ((struct STR_Index *)y)->title);
  if(ret)
    return(ret);
  else
  return(((struct STR_Index *)x)->page-
    ((struct STR_Index *)y)->page);
}
main()
{
  int i,num,first;
  char prev_t[30];

  i=0;
  while(EOF != scanf("%s %d",Index[i].title,&(Index[i].page)))
    i++;
  num=i;
  qsort(Index,num,sizeof(struct STR_Index),comp_index);
    
  prev_t[0]='\0';
  first=1;
  for(i=0;i<num;i++)
    {
    if(0==strcmp(prev_t,Index[i].title))
      printf(" %d",Index[i].page);
    else
      {
	if(first)
	  first=0;
	else
	  printf("\n");
	printf("%s",Index[i].title);
	printf("\n%d",Index[i].page);
      }
    strcpy(prev_t,Index[i].title);
    }
  printf("\n");
return(0);
}

Measured memory_bytes: 680
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;
int n, k;
pair<int,char>x[3]; 
string s;
char an[N]; 

int main(){
    scanf("%d%d", &n, &k);
    for(int i = 0; i<3; ++i){
        scanf("%d", &x[i].first);
        if(!i)x[i].second = 'r';
        if(i == 1)x[i].second = 's';
        if(i == 2)x[i].second = 'p';
    }
    for(int i = 0; i<n; ++i)an[i] = '.';
    cin >> s;
    sort(x,x+3);
    ll ad = 0;
    for(int i = 2; i>=0; --i){
        char cur = x[i].second;
        if(cur == 'r'){
           for(int j = 0; j<n; ++j){
               if(an[j] != '.')continue;
               if(s[j] == 's'){
                  if(j-k >= 0){
                     if(an[j-k] != 'r')ad += x[i].first, an[j] = 'r';
                  }
                  else an[j] = 'r', ad += x[i].first;
               }
           }
        }
        if(cur == 's'){
           for(int j = 0; j<n; ++j){
               if(an[j] != '.')continue;
               if(s[j] == 'p'){
                  if(j-k >= 0){
                     if(an[j-k] != 's')ad += x[i].first, an[j] = 's';
                  }
                  else an[j] = 's', ad += x[i].first;
               }
           }
        }
        if(cur == 'p'){
           for(int j = 0; j<n; ++j){
               if(an[j] != '.')continue;
               if(s[j] == 'r'){
                  if(j-k >= 0){
                     if(an[j-k] != 'p')ad += x[i].first, an[j] = 'p';
                  }
                  else an[j] = 'p', ad += x[i].first;
               }
           }
        }
    }
    printf("%lld\n", ad);
} 

Measured memory_bytes: 512
N,Q=list(map(int,input().split(" ")))
s=input()

arr=[0]*N
for i,z in enumerate(arr):
  if i==0:
    continue
  if s[i-1]=="A" and s[i]=="C":
    arr[i]=arr[i-1]+1
  else:
    arr[i]=arr[i-1]
for z in range(0,Q):
  i=list(map(int,input().split(" ")))
  print(arr[i[1]-1]-arr[i[0]-1])

Measured memory_bytes: 6188
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
int main() {
	int n;
	vi a,b;
	scanf("%d ",&n);
	int f = n/2*2+1;
	for(int i=1;i<=n;i++) {
		for(int j=i+1;j<=n;j++) {
			if(i+j != f) {
			a.push_back(i);
			b.push_back(j);
			}
		}
	}
	printf("%d\n",a.size());
	for(int i=0;i<a.size();i++) {
		printf("%d %d\n",a[i],b[i]);
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;

const int N=305;

string gr[N];
vector<int> pos[N];
int res[N][N];
int n,m,k;

int main()
{
	scanf("%d %d %d",&n,&m,&k);
	int li=-1;
	for(int i=0;i<n;i++)
	{
		cin >> gr[i];
		for(int j=0;j<m;j++)
		{
			if(gr[i][j]=='#') {li=i; pos[i].push_back(j);}
		}
	}
	int las=-1;
	vector< pair< pair<int,int>, pair<int,int> > > ans;
	for(int i=0;i<n;i++)
	{
		if(pos[i].size()==0) continue;
		int lasx=-1;
		int endx=i; if(i==li) endx=n-1;
		for(int j=0;j<pos[i].size()-1;j++)
		{
			ans.push_back({{las+1,lasx+1},{endx,pos[i][j]}});
			lasx=pos[i][j];
		}
		ans.push_back({{las+1,lasx+1},{endx,m-1}});
		las=i;
	}
	int co=1;
	for(auto i:ans)
	{
		for(int j=i.F.F;j<=i.S.F;j++)
			for(int k=i.F.S;k<=i.S.S;k++)
				res[j][k]=co;
		co++;
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			printf("%d%c",res[i][j]," \n"[j==m-1]);
}


Measured memory_bytes: 6188
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<template<class...> class ContT, class ValueT, size_t Dim>
struct vec_type
{
    using type = ContT<typename vec_type<ContT, ValueT, Dim-1>::type>;
};

template<template<class...> class ContT, class ValueT>
struct vec_type<ContT, ValueT, 0>
{
    using type = ValueT;
};

template<class ValueT, size_t Dim = 1>
using vec_t = typename vec_type<std::vector, ValueT, Dim>::type;


template<class ValueT, size_t Dim, class = typename std::enable_if<Dim == 0>::type>
auto make_vec(ValueT value = ValueT()) -> ValueT
{
    return value;
}

template<class ValueT, size_t Dim, class... Rest>
auto make_vec(size_t size0, Rest... rest)
{
    auto vec = make_vec<ValueT, Dim-1>(rest...);
    return std::vector(size0, vec);
}

int diffabs(int l, int r)
{
    if (l < r) return r-l;
    else return l-r;    
}


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

int main()
{
    int K;
    string S;
    cin >> K >> S;

    if (S.size() > K)
    {
        S = S.substr(0, K) + "..."s;
    }

    cout << S << endl;
}

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

using namespace std;

bool compare_by_second_reverse(pair<string, int> a, pair<string, int> b)
{
    if(a.second != b.second)
    {
        return a.second > b.second;
    }
    else
    {
        return a.first < b.first;
    }
}


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

    unordered_map<string, int> mp;
    for(int i = 1; i <= n; ++i)
    {
        string Si;
        cin >> Si;
        mp[Si]++;
    }

    vector<pair<string, int> > vs;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        vs.push_back(make_pair(itr->first, itr->second));
    }

    sort(vs.begin(), vs.end(), compare_by_second_reverse);

    int max = vs[0].second;
    for(int i = 0; i < vs.size(); ++i)
    {
        if(vs[i].second == max)
            cout << vs[i].first << endl;
        else
            break;
    }

    return 0;
}


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

int main()
{
   int n; cin>>n;
   if(n%2==0 || n%5==0) {
       cout<<"-1"; 
   }
   else {
       long long a = 7, i = 1;
       while(a%n != 0 && i != INT_MAX) {
           a = a*10 % n + 7%n;
           i++;
       }
       cout<<(i == INT_MAX ? -1 : i);
   }
   return 0;
}

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

using namespace std;

int n;

string s, t;

int main() {
    cin >> n >> s >> t;
    for (int i = n, j = 0; i >= 0 && j <= n; --i, ++j) {
        string f = s + t.substr(i, j);
        if (f.substr(j, n) == t) {
            cout << n + j;
            return 0;
        }

    }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {
    
    public static void main(String[] args) {
        
        Scanner input = new Scanner (System.in);
        
        int n = input.nextInt();
        int m = input.nextInt();
        
        int [][] array = new int [n][m];
        
        for(int i = 0 ; i < n ; i++)
        {
            String s = input.next();
            
            for(int j = 0 ; j < m ; j++)
            {
                char c = s.charAt(j);
                
                if(c == '#')
                    array[i][j] = -1;
            }
        }
        
        array[0][0] = 1;
        
        int mod = (int)1e9 + 7;
        
        for(int i = 0 ; i < n ; i++)
        {
            for(int j = 0 ; j < m ; j++)
            {
                if(array[i][j] == -1)
                    continue;
                
                if(isValid(i-1) && array[i-1][j] != -1)
                    array[i][j] = ((array[i][j] % mod) + (array[i-1][j] % mod)) % mod;
                
                
                if(isValid(j-1) && array[i][j-1] != -1)
                    array[i][j] = ((array[i][j] % mod) + (array[i][j-1] % mod)) % mod;    
                 
            }
        }
        
        System.out.println(array[n-1][m-1]);
    }
    
    public static boolean isValid(int num)
    {
        if(num < 0)
            return false;
        else
            return true;
    }
    
}


Measured memory_bytes: 34420
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
 
int zet(int x){
    if(x>0){
        return x;
    }else{
        return -x;
    }
}
int main(){
    int a,b,x;
    scanf("%d %d %d",&x,&a,&b);
    if(zet(x-a)>zet(x-b)){
        cout << "B" << endl;
    }else{
        cout << "A" << endl;

    }
    
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 ll n,l ;
 cin >> n>>l;
 double pi=acos(-1) ;
 vector<ll> A(n) ;
 rep(i,n) cin>> A[i] ;
 sort(A.begin(),A.end()) ;
 vector<double> x(n) ;
 rep(i,n) x[i] =cos(pi*A[i]/l) ;
 vector<double> y(n) ;
 rep(i,n) y[i] =sin(pi*A[i]/l);
  double sumx=0 ;
  double sumy=0 ;
  double sumz=0 ;
  rep(i,n) {
    rep(j,n){
      if(i!=j) {
        sumx+= x[i]*x[j] ;
        sumy+= y[i]*y[j] ;
        sumz+=x[i]*y[j] ;
    }
    }
  }
 double kx = 0; double ky=0 ;double kz=0 ;
  rep(i,n-1){
    rep2(j,i+1,n-1){
      kx+= x[i]*x[j]*(j-i-1) ;
      ky+= y[i]*y[j]*(j-i-1) ;
      kz+= x[i]*y[j]*(j-i-1) ;
      kz+= x[j]*y[i]*(j-i-1) ;
    }
  } 
  double ansx= (sumx-sumy)*3/(n*(n-1))
  -(kx-ky)*2*6/(n*(n-1)*(n-2)) ;
  double ansy= sumz*6/(n*(n-1)) 
  -kz*2*6/(n*(n-1)*(n-2)) ;
  cout << fixed << setprecision(20);
  cout<<ansx<<endl ;
  cout <<ansy<<endl ;
 return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
const int inf=1e9,mod=998244353;
int a,b,c,d,sl,fh;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void upd(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
int main()
{
	a=rd();b=rd();c=rd();d=rd();
	printf("%d\n",c>a);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<unordered_map>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define mod2 998244353
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
typedef pair<int, int> pii;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
} 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
} 
ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
#define pb push_back
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	map<string, int> mp;
	while(n--){
		string s; cin>>s;
		mp[s]++;
	}
	cout<<mp.size()<<endl;
}

Measured memory_bytes: 19200
#include<stdio.h>
#define T 0
#define H 1
#define N 2
int l[210],b;
int main(void) {
	int i,n,t,m[2],x;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=1;i<=n*2;i++){
			l[i]=H;
		}
		for(i=1;i<=n;i++){
			scanf("%d",&t);
			l[t]=T;
		}
		m[0]=m[1]=n;
		x=T;
		b=0;
		while(m[0]>0&&m[1]>0){
			for(i=b+1;i<=n*2;i++){
				if(x==l[i]){
					b=i;
					l[i]=N;
					m[x]--;
					break;
				}
			}
			if(i>n*2){
				b=0;
			}
			x=!x;
		}
		printf("%d\n%d\n",m[H],m[T]);
	}
	return 0;
}

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

int main() {
	int x1, y1, x2, y2;
	while (cin>> x1 >>y1>>x2>>y2){
		string route="";
		string routeU = "";
		for (int i=1; i<=y2-y1; i++){
			routeU+='U';
		}
		string routeR="";
		for (int i=1; i<=x2-x1; i++){
			routeR += 'R';
		}
		string routeD="";
		for (int i=1; i<=y2-y1; i++){
			routeD += 'D';
		}
		string routeL="";
		for (int i=1; i<=x2-x1; i++){
			routeL +='L';
		}
		route=routeU+routeR+routeD+routeL;
		route=route+'L'+routeU+'U'+routeR+'R'+'D';
		route=route+'R'+routeD+'D'+routeL+'L'+'U';
		cout << route<<endl;
	}
}

Measured memory_bytes: 384
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int main()
{
	char S[100];
	scanf("%s", S);
	string T = S;
	if (T.size() > 3 && T.substr(0, 4) == "YAKI") {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 256
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+2;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;

int main()
{
    IOS();
   
    int n,i;
    cin>>n;
    ld a[n],sum=0;
    f(i,0,n)
    {
      cin>>a[i];
    }
    sort(a,a+n);
    sum=(a[0]+a[1])/2;
    f(i,2,n)
    {
        sum=(sum+a[i])/2;
    }
    cout<<fixed<<setprecision(10)<<sum;



  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >>n;
  int l,r;
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>l>>r;
    sum+=r-l+1;
  }
  cout<<sum<<endl;
  return 0;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
void dbg(){cerr<<endl;}
template<typename A,typename... B>void dbg(A x,B... y){cerr<<x<<" ";dbg(y...);}
#define debug(...) cerr<<#__VA_ARGS__<<"=",dbg(__VA_ARGS__)
int n,del[N];
void gao(int y,int len,int cur)
{//	debug(y,len,cur);
	if(len==1){cout<<cur<<" ";return;}
	int pos=0; for(rint i=0;i<n;i++)if((y>>i&1)&&!del[i]){del[i]=1;pos=i;break;}
	vector<int> v; v.push_back(0);
	for(rint i=0;i<n;i++)
	if(!del[i]){for(rint j=v.size()-1;j>=0;j--)v.push_back(v[j]|(1<<i));}
	for(auto x:v) cout<<(x^cur)<<" ";
	gao(y^v.back()^(1<<pos),len/2,cur^v.back()^(1<<pos));
}
int main()
{	int x,y; cin>>n>>x>>y;
	if(__builtin_popcount(x^y)%2==0) return !printf("NO");
	cout<<"YES\n"; gao(x^y,1<<n,x);
	return 0;
}



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

typedef unsigned long long ull;

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

    ull count = 0;

    vector<string> s;

    map<string, ull> m;
    map<string, ull>::iterator it;
    string si;
    for ( int i = 0; i < n; i++)
    {
        cin >> si;
        sort(si.begin(), si.end());

        it = m.find(si);
        if (it == m.end())
        {
            m.insert(make_pair(si, 1));
        }
        else
        {
            it->second++;
        }

        //s.push_back(si);

    }

    ull val;
    for (it = m.begin(); it != m.end(); it++)
    {
        val = it->second;
        if (val > 1) count += ((val * (val-1))/2);
    }

    cout << count << endl;
}


Measured memory_bytes: 11136