akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;
const double e = exp(1);

void go() {
    int n, k;
    cin >> n >> k;
    ll ans = 1LL * n * n;
    for (int i = 1 ; i <= n ; i++) {
        int cnt = n / i * (min(i,k));
        cnt += min(max(0,k-1),n % i);
        ans -= cnt;
    }
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <utility>
using ll=long long;
using namespace std;

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

    int keta=1;
    int tmp=0;
    int ed=10e7;
    for(int i=0;i<ed;i++){
        tmp+=keta*7;
        tmp%=K;
        if(tmp==0){
            cout<<i+1<<endl;
            return 0;
        }
        keta*=10;
        keta%=K;
    }
    cout<<-1<<endl;

    return 0;
}

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

void solve();

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	for(int i = 0; i < t; i++){
		solve();
	}
	return 0;	
}

void solve(){
	int n , m;
	cin >> n >> m;
	cout << (n*(n-1))/2 + (m*(m-1))/2;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

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

vector<int> to [100005];
int fact[100005];
int ifact[100005];
ll ans = 1;
int n,k;



int PowMod(int n,int m)
{
    ll temp;
    if (m == 0)
    {
        return 1;
    }
    if (m % 2 == 0)
    {
        temp = (ll)PowMod(n, m / 2);
        temp = (ll)temp * (ll)temp % (ll)MOD;
        return (int)temp;
    }
    temp =(ll)n * (ll)PowMod(n, m - 1) % (ll)MOD;
    return (int)temp;
}

int inv_num(int num)
{
    return PowMod(num, MOD - 2);
}


void factorial()
{
    fact[0] = 1;
    ifact[0] = 1;
    ll temp;
    for (int i = 1; i < 100005; i++)
    {
        temp = (ll)fact[i - 1] * (ll)i % (ll)MOD;
        fact[i] = (int)temp;
        ifact[i] = inv_num(fact[i]);
    }
}

int perm(int n, int a)
{
    if(a>n) return 0;
    int X = fact[n];
    int Y = ifact[n-a];
    ll temp;
    temp =  (ll)X * (ll)Y % (ll)MOD;
    return (int)temp;
}

void dfs(int v, int p = -1)
{
    for (auto u : to[v])
    {
        if(u == p) continue;
        dfs(u,v);
    }
    int nk = (p == -1) ? k:k-2;
    int c  = (p==-1) ? sz(to[v])+1: sz(to[v])-1;
    ans *= (ll)perm(nk,c);
    ans %= MOD;
}



int main()
{
    
    cin >> n >> k;
    //to.resize(n);
    rep(i,n-1)
    {
        int a,b;
        cin >> a  >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    factorial();
    dfs(0);
    //cout << PowMod(2,MOD-1) << endl;

    //cout << perm(5,2) << endl;
    //cout << inv_num(2) << endl;
    
    cout  << ans%MOD << endl;

}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })


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

	vvl dist(n,vl(n,oo));
	FOR(i,0,n) dist[i][i] = 0;

	vvl adj(n);
	FOR(i,1,n) {
		ll a, b; cin >> a >> b;
		a--, b--;
		adj[a].pb(b);
		adj[b].pb(a);
		dist[a][b] = dist[b][a] = 1;
	}
	
	FOR(k,0,n) FOR(i,0,n) FOR(j,0,n) dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
	
	ll diam = 0;
	FOR(i,0,n) FOR(j,0,n) diam = max(diam,dist[i][j]);

	ll col = diam/2 + 1;
	
	auto calc = [&](vl lvl) {
		FOR(i,0,n) if (lvl[i] >= col) return oo;
		
		vl branch(col);
		FOR(i,0,n) {
			ll cnt = 0;
			for (ll j: adj[i]) if (lvl[j] > lvl[i]) cnt++;
			branch[lvl[i]] = max(branch[lvl[i]],cnt);
		}

		ll res = 0;
		FOR(i,0,n) if (lvl[i] == 0) res++;
		FOR(i,0,col) if (branch[i]) res *= branch[i];
		return res;
	};
	
	ll res = oo;

	FOR(c1,0,n) {
		res = min(res,calc(dist[c1]));
		for (ll c2: adj[c1]) {
			vl lvl(n);
			FOR(i,0,n) lvl[i] = min(dist[c1][i],dist[c2][i]);
			res = min(res,calc(lvl));
		}
	}

	cout << col << " " << res << endl;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;

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

int main(){
    ll N;
    string A, B, C;
    cin >> N >> A >> B >> C;
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        if(A[i] == B[i]){
            if(B[i] != C[i]) ans++;
        }else{
            if(B[i] == C[i]) ans++;
            else if(A[i] == C[i]) ans++;
            else ans += 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define end "\n"
#define endl "\n"
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
 
int main() {
    io;
    
  int x,y;
  int total = 0;
  cin>>x>>y;
  if(x == 1) total+=300000;
else if(x == 2) total +=200000;
else if (x==3) total +=100000;

 if(y == 1) total+=300000;
else if(y == 2) total +=200000;
else if (y==3) total +=100000;

if(x == 1 && y == 1) total+=400000;
    

cout<<total<<end;
 
 
    
 
    return 0;
}

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

public class Main {
	private int lots[][];

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int n = scan.nextInt();
		lots = new int[n+1][w];
		
		for (int j = 0; j < w; j++) {
			lots[0][j] = j+1;
		}
		
		for (int i = 1; i < n + 1; i++) {
			String num = scan.next();
			int a = num.indexOf(",");
			int p = Integer.parseInt(num.substring(0, a))-1;
			int q = Integer.parseInt(num.substring(a+1, num.length()))-1;
			
			for (int j = 0; j < w; j++) {
				if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				}
			}
			//debug(n);
		}
		
		for (int j = 0; j < w; j++) {
			System.out.println(lots[n][j]);
		}
	}
	
	private void debug(int n) {
		for (int i = 0; i < n+1; i++) {
			System.out.println(Arrays.toString(lots[i]));
		}
		System.out.println();
	}

}

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

def gcd(x,y):
    if x<y:
        x,y = y,x
    if y==0:
        return x
    return gcd(x%y,y)

ans = a[0]
for i in a:
    ans = gcd(ans, i)

print(ans)


Measured memory_bytes: 14252
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;
    if(b % a == 0){
        cout << a + b << endl;
    }else {
        cout << b - a << endl;
    }
    
}


Measured memory_bytes: 256
// 未解決

#include <bits/stdc++.h>

#include <iostream>
using namespace std;

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

//**********

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

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

  int z = min(b - 1, n);
  int ans = (a * z) / b;

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 3592
n = int(input())
l = list(map(int, input().split()))

even = len([i for i in l if i % 2 == 0])
four = len([i for i in l if i % 4 == 0])
even_wo_four = even - four

if four >= n//2:
    print('Yes')
elif n - four * 2 == even_wo_four:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
n = gets.to_i
ary = gets.split.map(&:to_i)

def countingSort(aAry, bAry, k)
    # puts "aAry = #{aAry}, bAry = #{bAry}, k = #{k}"
    n = aAry.size
    cAry = Array.new(k + 1, 0)
    # puts "n = #{n}, cAry = #{cAry}"
    aAry.each { |a| cAry[a] += 1 }
    1.upto(k) { |i| cAry[i] = cAry[i] + cAry[i - 1] }
    (n - 1).downto(0) do |j|
        bAry[cAry[aAry[j]]] = aAry[j]
        cAry[aAry[j]] -= 1
    end
end

bAry = []
countingSort(ary, bAry, ary.max)
bAry.shift
puts bAry.join(' ')


Measured memory_bytes: 155340
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n , k;
  double ans = 0;
  cin>>n>>k;
  double dice;
  double coin;

  for(int i = 1; i <= n; i++ ){
    int j = 1;
    int temp;
    temp = i;
    while(k > temp){
      temp *= 2;
      j *= 2;
    }
    double dice = n;
    double coin = j;
    ans += (1.00000000000/dice)*(1.00000000000/coin);
    //cout<<"i ="<<i<<", dice = "<<dice<<", coin = "<<coin<<", ans = "<<ans<<endl;
  }
  cout << setprecision(18)<<ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#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 FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;
int n;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a > b)Swap(&a, &b);
	if (b > c)Swap(&b, &c);
	if (a > b)Swap(&a, &b);
	PRINTD(abs(a - b) + abs(b - c));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
int main(){
  ll n; cin >> n;
  if(n==7||n==5||n==3) cout << "YES";
  else cout << "NO";

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<pair<int,pair<int,int>>> v;
    rep(i,n){
        int t,x,y;
        cin >> t >> x >> y;
        v.push_back(make_pair(t,make_pair(x,y)));
    }
    sort(v.begin(),v.end());
    pair<int,int> now;
    int time = 0;
    now.first = 0; now.second = 0;
    rep(i,n){
        int dis = abs(v[i].second.first - now.first) + abs(v[i].second.second - now.second);
        if(dis > v[i].first - time){
            cout << "No" << endl;
            return 0;
        }else{
            if((v[i].first - time)%2 != dis%2 ){
                cout << "No" << endl;
                return 0;
            }else{
                now.first = v[i].second.first;
                now.second = v[i].second.second;
                time = v[i].first;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1912
#include <iostream>

const int MAXN = (int)2e5 + 1;

int count[MAXN];

int main() {
  int n;
  std::cin >> n;
  for (int i = 2, u; i <= n; ++i) {
    std::cin >> u;
    ++count[u];
  }
  for (int i = 1; i <= n; ++i) 
    std::cout << count[i] << std::endl;
  return 0;
}


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

using namespace std;

template <class T> bool uax(T& a, T b) {return a < b ? (a = b, true) : false; }
template <class T> bool uin(T& a, T b) {return a > b ? (a = b, true) : false; }

const int mod = (int) 1e9 + 7;
const int MANY = 1 << 30;
const int N = (int) 1e6;

int a[N], n, m;

int d[N];

int32_t main() {
//#ifndef QQQ
//    freopen("input.in", "r", stdin);
//    freopen("output.out", "w", stdout);
//#endif
#ifdef QQQ
    freopen("../input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(11);
    cerr << fixed << setprecision(6);

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

    for (int j = 1; j < n; ++j) {
        int cost = MANY;
        for (int i = max(0, j - m); i < j; ++i) {
            uin(cost, d[i] + abs(a[j] - a[i]));
        }
        d[j] = cost;
    }
    cout << d[n-1];
}

Measured memory_bytes: 4736
use std::io::*;
use std::str::FromStr;
use std::collections::HashSet;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let d: Vec<i32> = (0..n).map(|_| read()).collect();
    let s: HashSet<&i32> = d.iter().collect();
    println!("{}", s.len());
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N, A, B, C; cin >> N >> A >> B >> C;
  string s[N]; rep(i,N) cin >> s[i];
  string result[N];
  rep(i,N) {
    if (s[i]=="AB") {
      if (A==0&&B==0) {
        cout << "No" << endl;
        return 0;
      }
      if (A==1&&B==1) {
        if (i==N-1) { result[i] = "A"; A++; B--; }
        else {
          if (s[i+1]=="AC") { result[i] = "A"; A++; B--; }
          else { result[i] = "B"; A--; B++; }
        }
      }
      else {
        if (A<=B) { result[i] = "A"; A++; B--; }
        else { result[i] = "B"; A--; B++; }
      }
    }
    if (s[i]=="BC") {
      if (B==0&&C==0) {
        cout << "No" << endl;
        return 0;
      }
      if (B==1&&C==1) {
        if (i==N-1) { result[i] = "B"; B++; C--; }
        else {
          if (s[i+1]=="AB") { result[i] = "B"; B++; C--; }
          else { result[i] = "C"; B--; C++; }
        }
      }
      else {
        if (B<=C) { result[i] = "B"; B++; C--; }
        else { result[i] = "C"; B--; C++; }
      }
    }
    if (s[i]=="AC") {
      if (C==0&&A==0) {
        cout << "No" << endl;
        return 0;
      }
      if (C==1&&A==1) {
        if (i==N-1) { result[i] = "C"; C++; A--; }
        else {
          if (s[i+1]=="BC") { result[i] = "C"; C++; A--; }
          else { result[i] = "A"; C--; A++; }
        }
      }
      else {
        if (C<=A) { result[i] = "C"; C++; A--; }
        else { result[i] = "A"; C--; A++; }
      }
    }
  }
  cout << "Yes" << endl;
  rep(i,N) cout << result[i] << endl;
  return 0;
}

// 4 1 0 0
// AB
// BC
// AC
// AB

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int P;
int A[3030];
ll from[3030],to[3030],B[3030];
ll mo;

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>P;
	mo=P;
	
	FOR(i,P) cin>>A[i];
	
	from[0]=1;
	FOR(i,P) {
		ZERO(to);
		FOR(j,3000) to[j+1]=from[j];
		FOR(j,3000) {
			to[j]-=i*from[j];
			to[j]=(to[j]%P+P)%P;
		}
		swap(from,to);
	}
	
	
	for(i=0;i<P;i++) if(A[i]) {
		ll Q=1;
		for(j=0;j<P;j++) if(j!=i) Q=Q*(i-j)%mo;
		Q=modpow((Q%mo+mo)%mo);
		
		memmove(to,from,sizeof(from));
		for(j=3000;j>=1;j--) {
			(B[j-1]+=to[j]*Q)%=mo;
			to[j-1]=(to[j-1]+to[j]*i)%mo;
		}
		
	}
	FOR(i,P) cout<<B[i]%P<<" ";
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair

const int MAX_V = 100100;

int main(){
  int n; cin >> n;
  vector<pii> a(MAX_V), b(MAX_V);

  rep(i, MAX_V){
    a[i] = mp(0, i);
    b[i] = mp(0, i);
  }

  rep(i, n){
    int v; cin >> v;
    if(i%2 == 0) a[v].fi++;
    else b[v].fi++;
  }

  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());

  int ans;
  if(a[0].se != b[0].se) ans = n - a[0].fi - b[0].fi;
  else{
    ans = min(n - a[0].fi - b[1].fi, n - a[1].fi - b[0].fi);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <tuple>

using namespace std;

#define all(i) i.begin(), i.end()
#define rep(i,n) for(int i=0;i<n;i++)

#define int long long
typedef pair<int, int> p;
const int INF = 1e16;

int dp[1001][201];

int ld[201][201];
int sd[201][201];

signed main() {
	int n, m;
	while (cin >> n >> m && n) {
		rep(i, 201)rep(j, 201) {
			ld[i][j] = sd[i][j] = INF;
		}
		rep(i, 201) {
			ld[i][i] = 0;
			sd[i][i] = 0;
		}
		rep(i, m) {
			int x, y, t;
			char s;
			cin >> x >> y >> t >> s;
			x--; y--;
			if (s == 'S') {
				sd[y][x] = sd[x][y] = t;
			}
			else {
				ld[y][x] = ld[x][y] = t;
			}
		}
		rep(k, n)rep(i, n)rep(j, n) {
			sd[i][j] = min(sd[i][j], sd[i][k] + sd[k][j]);
			ld[i][j] = min(ld[i][j], ld[i][k] + ld[k][j]);
		}
		int r;
		cin >> r;
		vector<int> z(r);
		rep(i, r) {
			cin >> z[i];
			z[i]--;
		}
		rep(i, 1001)rep(j, 201) {
			dp[i][j] = INF;
		}

		dp[0][z[0]] = 0;
		rep(i, r - 1) {
			rep(s, n) {
				//z[i] to z[i+1]
				dp[i + 1][s] = min(dp[i + 1][s], dp[i][s] + ld[z[i]][z[i + 1]]);
				rep(j, n) {
					dp[i + 1][j] = min(dp[i + 1][j], dp[i][s] + ld[z[i]][s] + sd[s][j] + ld[j][z[i + 1]]);
				}
			}
		}
		int ans = INF;
		rep(s, n) {
			ans = min(ans, dp[r - 1][s]);
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 5216
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define ll long long

using namespace std;

void
solve() {
  ll n, w;
  cin>>n>>w;

  vector<ll> dp(100005, -1);
  dp[0] = 0;

  ll x, v;
  for (ll i=0; i<n; i++) {
    cin>>x>>v;

    for (ll j=dp.size()-1; j>=0; j--) 
      if (dp[j] >= 0 && dp[j] + x <= w && (dp[j+v] == -1 || dp[j+v] > dp[j] + x))
        dp[j+v] = dp[j] + x;
  }

  ll ans = 0;
  for (ll i=0; i<dp.size(); i++)
    if (dp[i] >= 0)
      ans = max(ans, i);

  cout<<ans<<endl;
}

int
main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);

  ll t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 3952
/*author - Aryan Mittal*/
#include<bits/stdc++.h>
using namespace std;

#pragma GCC push_options
#pragma GCC optimize ("unroll-loops")

#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"

#define ll long long

int main() {

	// Use ctrl+shift+b ( second option )
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt" , "w" , stderr);
#endif

	// int a,b;
	// cin>>a>>b;

	// cout << a << " " << b << "\n";
	// cout << "Aryan" << "\n";
	// cerr << "Aryan " << a;

	// while(1){
	// 	cout<<"Aryan"<<"\n";
	// }

	ll n, m;
	cin >> n >> m;

	vector<ll> gr[n + 2];
	for (ll i = 1; i <= m; i++) {
		ll a, b;
		cin >> a >> b;

		gr[a].push_back(b);
		gr[b].push_back(a);
	}

	map<ll, ll> mp;
	queue<ll> q;
	q.push(1ll);

	while (!q.empty()) {

		ll node = q.front();
		q.pop();

		for (ll elem : gr[node]) {
			if (mp[elem] == 0) {
				mp[elem] = node;
				q.push(elem);
			}
		}
	}

	ll flag = 0;
	for (ll i = 2; i <= n; i++) {
		if (mp[i] == 0) {
			flag = 1;
		}
	}

	if (flag == 1) {
		cout << "No" << "\n";
	} else {
		cout << "Yes" << "\n";
		for (ll i = 2; i <= n; i++) {
			cout << mp[i] << "\n";
		}
	}


	return 0;
}


Measured memory_bytes: 18364
#include <iostream>

using namespace std;

int binarySearch(int* a, int size, int x){
    int left = 0,right = size;
    int mid;

    while (left < right){
        mid = (left + right) / 2;
        if (a[mid] == x) {
            return mid;
        } else if(x < a[mid]){
            right = mid;
        } else if(x > a[mid]){
            left  = mid + 1;
        }
    }
    return -1;
}

int main(){
    int n,q;
    int S[100000];
//    freopen("in", "r", stdin);

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> S[i];
    }
    cin >> q;
    int count = 0;
    for (int j = 0; j < q; ++j) {
        int t;
        cin >> t;
        if (binarySearch(S, n, t) != -1) {
             count++;
        }
    }

    cout << count << endl;
    return 0;
}

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

int main () {
  int a, b;
  cin >> a >> b;
  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Yes" << endl;  
  }  
  else {
    cout << "No" << endl;  
  }
}

Measured memory_bytes: 256
N, K, Q = map(int,input().split())
A = [int(input()) for i in range(Q)]

if K > Q:
    for i in range(N):
        print("Yes")

else:
    B = []
    for i in range(N):
        B.append(K - Q)

    for i in range(Q):
        ans = A[i] - 1
        P = B[ans] + 1
        B[ans] = P

    for i in range(N):
        if B[i] > 0:
            print("Yes")
        else:
            print("No")

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

using namespace std;


int main() {
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < 4; i++) {
        if(s[i] == '2') {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3552
import itertools
n = int(input())
l = list(map(int, input().split()))
lis = list(set(l))

if n < 3:
    print(0)
    exit()
flag = 0
for i in itertools.combinations(lis, 3):
    a = list(i)
    if (a[0] + a[1] > a[2]) and (a[1] + a[2] > a[0]) and (a[0] + a[2] > a[1]):
        max_ = l.count(a[0])*l.count(a[1])*l.count(a[2])
        flag += max_ 
print(flag)

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

int power(int x,int n)
{
    if(n==0)
        return 1;
    return x*power(x,n-1);
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    // ll n;cin>>n;
    // while(n--)
    // {
        ll k;cin>>k;
        ll a,b;cin>>a>>b;ll fl=0;
        for(ll i=a;i<=b;i++)
        {
            if(i%k==0){fl=1;cout<<"OK";break;}
        }if(fl==0)cout<<"NG";
    // }
    return 0;
}

Measured memory_bytes: 3652
import Control.Monad
import Data.List
import Data.Array

type House = Array (Int, Int, Int) Int
type Info = ((Int, Int, Int), Int)

initialHouse :: House
initialHouse = array ((1, 1, 1), (b, f, r)) [((i, j, k), 0) | i <- [1..b], j <- [1..f], k <- [1..r]]
  where (b, f, r) = (4, 3, 10)

printHouse :: House -> IO ()
printHouse house = mapM_ putStrLn $ intercalate [replicate 20 '#'] $ [[(' ':) $ unwords $ map show $ [house!(b, f, r) | r <- [1..10]] | f <- [1..3]] | b <- [1..4]]

applyInfo :: Info -> House -> House
applyInfo info@((b, f, r), v) house = house//[((b, f, r), v + house!(b, f, r))]

makeInfo :: [Int] -> Info
makeInfo [b, f, r, v] = ((b, f, r), v)

main :: IO ()
main = do
  n <- readLn
  input <- replicateM n getLine
  let infos = map (makeInfo . map read . words) input
  printHouse $ foldr applyInfo initialHouse infos

Measured memory_bytes: 4400
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

vector<pair<int, int>> arr;

long long calc(long long q){
    return q * (q + 1) / 2;
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;
    multiset<int> yeet, cur;
    vector<int> arr;

    for(int a, i = 0; i < (1 << n); ++i){
        cin >> a;
        arr.push_back(a);
    }

    sort(arr.begin(), arr.end());
    reverse(arr.begin(), arr.end());

    for(int i = 1; i < (1 << n); ++i)
        yeet.insert(-arr[i]);
    cur.insert(-arr[0]);

    for(int i = 0; i < n; ++i){
        vector<int> to_add = {};
        for(auto j : cur){
            auto it = yeet.upper_bound(j);
            if(it == yeet.end()){
                cout << "No";
                return 0;
            }
            to_add.push_back((*it));
            yeet.erase(it);
        }
        for(auto j : to_add)
            cur.insert(j);
    }

    cout << "Yes";

    return 0;

}


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

int main() {
  int A, B;
  cin >> A >> B;
  int res = 0;
  for (int i = A; i <= B; i++) {
    if (i/10000 == i%10) {
      if (i/1000%10 == i%100/10) {
        res += 1;
      }
      i += 9;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>

using namespace std;

void abc_170a();

int main()
{
  abc_170a();

}

void abc_170a()
{
  vector<int> x(5);
  for (int i = 0; i < 5; ++i) cin >> x[i];

  for (int i = 0; i < 5; ++i)
  {
    if (x[i] == 0)
    {
      cout << i + 1 << "\n";
      return;
    }
  }
}


Measured memory_bytes: 3628
class ArrayDeque:
    def __init__(self):
        self.a_size = 1
        self.a = [None]
        self.n = 0
        self.head = 0
        self.tail = 0

    def __bool__(self):
        return self.n != 0

    def _resize(self):
        new_a = [None] * ((self.n + 1) << 1)
        for i in range(self.n):
            new_a[i] = self.a[(self.head + i) & (self.a_size - 1)]
        self.a = new_a
        self.a_size = (self.n + 1) << 1
        self.head = 0
        self.tail = self.n

    def append(self, val):
        if self.n == self.a_size - 1:
            self._resize()
        self.a[self.tail] = val
        self.tail = (self.tail + 1) & (self.a_size - 1)
        self.n += 1

    def appendleft(self, val):
        if self.n == self.a_size - 1: 
            self._resize()
        self.head = (self.head - 1) & (self.a_size - 1)
        self.a[self.head] = val
        self.n += 1

    def popleft(self):
        if self.n == 0:
            raise IndexError()
        val = self.a[self.head]
        self.head = (self.head + 1) & (self.a_size - 1)
        self.n -= 1
        if self.a_size >= 4 * self.n + 2:
            self._resize()
        return val

    def pop(self):
        if self.n == 0:
            raise IndexError()
        self.tail = (self.tail - 1) & (self.a_size - 1)
        val = self.a[self.tail]
        self.n -= 1
        if self.a_size >= 4 * self.n + 2:
            self._resize()
        return val


a = list(input().split())
stack = ArrayDeque()

for item in a:
    if item == '+':
        a = stack.pop()
        b = stack.pop()
        stack.append(b + a)
    elif item == '-':
        a = stack.pop()
        b = stack.pop()
        stack.append(b - a)
    elif item == '*':
        a = stack.pop()
        b = stack.pop()
        stack.append(b * a)
    else:
        stack.append(int(item))

ans = stack.pop()
print(ans)


Measured memory_bytes: 5616
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>

using namespace std;

#define PI 3.14159265358979323846
#define INF 1e+9
#define DIV_NUM (1000000007)



int main() {

	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;
	if (U == S) A--;
	if (U == T) B--;

	cout << A << " " << B << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

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

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
    
  int main(){
string s,t;
cin>>s>>t;
reverse(all(s));
reverse(all(t));
lint g=-1;
 rep(i,s.size()-t.size()+1){
     lint count=0;
     rep(j,t.size()){
         if(s[i+j]==t[j]||s[i+j]=='?')count++;
         else break;
     }
     if(count==t.size()){
         g=i;
         break;
     }
 }
 rep(i,t.size()){
     if(g==-1)break;
     s[i+g]=t[i];
 }
 rep(i,s.size()){
     if(s[i]=='?')s[i]='a';
 }
 reverse(all(s));
 if(g==-1)cout<<"UNRESTORABLE";
 else cout<<s;
    }
     
  


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

string S(int a){
  //return "#";
  return to_string(a)+" ";
}
string S(vector<int> &v){
  string res;
  for(int p:v)res+=S(p);
  return res;
}
void DEB(string a){
  if(a[0]=='#')return;
  cout<<a<<endl;
}

template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}

signed main(){
  int a,b,k;cin>>a>>b>>k;
  int t=min(a,k);
  a-=t;b-=k-t;chmax(b,0LL);
  DEB(S(a)+S(b));
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>

using namespace std;

int main() {
	int a, b;
	int d, r;
	double f;
	cin >> a >> b;
	d = a / b;
	r = a%b;
	f = (double)a / b;
	printf("%d %d %.8f", d, r, f);
}

Measured memory_bytes: 3220
H,W = map(int,input().split())
L = []


for _ in range(H):
    s=input()
    l=[]
    for x in s:
        l.append(x)
    for x in l:
        if x == ".":
            pass
        else:
            L.append(l)
            break
delete=[]
cou=0
for i in range(W):
    cnt = 0
    for j in range(len(L)):
        if L[j][i]  == '.':
            cnt += 1
        else:
            cnt = 0
    if cnt == len(L):
        delete.append(i-cou)
        cou+=1
for i in delete:
    for j in range(len(L)):
        del L[j][i]

for x in L:
    for y in x:
        print(y,end="")
    print()


Measured memory_bytes: 4596
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

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

char t[210000], d[210000];
int N, Q;
string s;

int sim(int idx)
{
  REP(i, Q) {
    if (s[idx] == t[i]) {
      if (d[i] == 'L') idx--;
      else idx++;
    }
    if (idx < 0 || idx >= N) return idx;
  }
  return idx;
}

int main()
{
  cin >> N >> Q;
  cin >> s;
  REP(i, Q) cin >> t[i] >> d[i];

  int l, r;

  int cnt = 0;
  l = -1, r = N;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (sim(mid) >= N) r = mid;
    else l = mid;
  }
  cnt += N - r;

  l = -1, r = N;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (sim(mid) < 0) l = mid;
    else r = mid;
  }
  cnt += l + 1;
  cout << (N - cnt) << endl;

  return 0;
}

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

int main(){
  int N;
  string S;
  cin >> N;
  int a[4]={};
  for (int i = 0; i < N; i++)
  {
    cin >> S;
    if (S=="AC") a[0]++;
    else if (S=="WA")a[1]++;
    else if (S=="TLE")a[2]++;
    else if (S=="RE")a[3]++;
  }

  cout <<"AC x " << a[0] << endl;
  cout << "WA x " << a[1] << endl;
  cout << "TLE x " << a[2] << endl;
  cout << "RE x " << a[3] << endl;
}


Measured memory_bytes: 3572
using System;
using System.Collections.Generic;

namespace cswork {
    class Program {
        static void Main (string[] args) {
            List<string> ss =  ReadListStr();
            if(ss[1].Equals("+")){
                Write(int.Parse(ss[0]) + int.Parse(ss[2]));
            }else{
                Write(int.Parse(ss[0]) - int.Parse(ss[2]));
            }
            Exit ();
        }

        public static void Write (string str) {
            Console.WriteLine (str);
        }

        public static void Write (int i) {
            Console.WriteLine (i);
        }

        public static void Write (double d) {
            Console.WriteLine (d);
        }

        public static string ReadStr () {
            return Console.ReadLine ();
        }

        public static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }

        public static long Read () {
            return long.Parse (Console.ReadLine ());
        }

        public static double ReadDouble () {
            return double.Parse (Console.ReadLine ());
        }

        public static void Exit () { }

        public static List<string> ReadListStr () {
            return new List<string> (ReadStr ().Split (" "));
        }

        public static List<long> ReadList () {
            return ReadListStr ().ConvertAll (x => long.Parse (x));
        }

        public static List<int> ReadListInt () {
            return ReadListStr ().ConvertAll (x => int.Parse (x));
        }
    }
}

Measured memory_bytes: 27828
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
typedef long long ll;
using namespace std;

const int N = 3001;
const int mod = 998244353;

int n, s;
int a[N];
ll dp[N];

int main(){
    IOS

    cin >> n >> s;
    FOR(i,1,n){
        cin >> a[i];
    }
    ll ans = 0;
    FOR(i,1,n){
        dp[0]++;
        ROF(j,s-a[i],0){
            dp[j + a[i]] = (dp[j + a[i]] + dp[j]) % mod;
        }
        ans = (ans + dp[s]) % mod;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3676
import math

while True:
	N = int(input())
	if N == 0:
		break
	
	S = list(map(int, input().split()))
	S2 = [x ** 2 for x in S]
	
	V = sum(S2)/N - (sum(S)/N) ** 2
	print(math.sqrt(V))

Measured memory_bytes: 7784
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << #x << "=" << x << "]" << '\n'
#define deb2(x,y) cout << "[" << #x << "=" << x << "] [" << #y << "=" << y << "]" << '\n'
#define deb3(x,y,z) cout << "[" << #x << "=" << x << "] [" << #y << "=" << y << "] [" << #z << "=" << z << "]" << '\n'

void solve(){
	int a,b,c; cin>>a>>b>>c;
	int f=0;
	if(a==b && a!=c) f=1;
	else if(b==c && b!=a) f=1;
	else if(a==c && a!=b) f=1;
	cout<<(f ? "Yes" : "No");LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  //int _;
  //for(cin>>_ ; _ ; --_){
    //cout<<"Case "<<_<<": ";
    solve();
  //}
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>

using namespace std;
int main()
{
  int s,hh,mm,ss;
  cin>>s;
  hh = s / 3600;
  mm = s % 3600 / 60;
  ss = s % 3600 % 60;
 
  cout << hh << ':' << mm << ':' << ss << endl;
return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int n;
    cin >> n;
    map<ll, ll> p;
    p[0] = 1;
    ll sum = 0;
    ll ans = 0;
    while (n--) {
        int temp;
        cin >> temp;
        sum += temp;
        ans += p[sum];
        p[sum]++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
inline void rd(int &x) {
	char ch; for(;!isdigit(ch=getchar()););
	for(x=ch-'0';isdigit(ch=getchar());)x=x*10+ch-'0';
}
typedef long long LL;
const int MAXN = 300005;
int N, n, a[MAXN], cnt[MAXN];
LL sum[MAXN];
int ans[MAXN];

inline bool chk(int k, int x) {
	int pos = upper_bound(a + 1, a + n + 1, x) - a;
	return sum[pos-1] + 1ll*(n-pos+1)*x >= 1ll*k*x;
}

int main() {
	rd(N);
	for(int i = 1, x; i <= N; ++i) rd(x), ++cnt[x];
	for(int i = 1; i <= 300000; ++i) if(cnt[i]) a[++n] = cnt[i];
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; ++i) sum[i] = sum[i-1] + a[i];
	int now = 0;
	for(int k = n; k >= 1; --k) {
		while(now < N && chk(k, now+1)) ++now;
		ans[k] = now;
	}
	for(int i = 1; i <= N; ++i) printf("%d\n", ans[i]);
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
struct edge{ll to;};
struct graph{
    ll N;
    vector<vector<edge> > G;
    vector<bool> used;
    vector<ll> grundy;

    graph(ll n): N(n), G(N), used(N,false), grundy(N) {}

    void add_edge(ll s, ll t){
        G[s].emplace_back((edge){t});
        G[t].emplace_back((edge){s}); //無向ならON
    }

    void dfs(ll v=0){
        used[v]=true;
        ll ans=0;
        for(auto& E : G[v]){
            if(!used[E.to]){
                dfs(E.to);
                ans^=grundy[E.to]+1;
            }
        }
        grundy[v]=ans;
    }
};
//--MAIN-----------------------------------
void Main(){
    ll N; cin>>N;
    graph g(N);
    rep(i,N-1){
        ll x,y; cin>>x>>y; --x; --y;
        g.add_edge(x,y);
    }
    g.dfs();
    cout<< ( g.grundy[0]!=0 ? "Alice" : "Bob" )<<"\n";

}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define all(a)                      a.begin(), a.end()
#define pb                          push_back
#define ll							long long
#define index(a)            		order_of_key(a)
#define value(a)					find_by_order(a)
#define count_1 					__builtin_popcount
#define mod(x, m)					((((x) % (m)) + (m)) % (m))
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
int dp[100005],a[100005];
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout<<setprecision(12);
	
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	
	for(int i=0;i<=k;i++){
		for(int j=0;j<n;j++){
			if(i-a[j]>=0 && !dp[i-a[j]])
			dp[i]=true;
		}
	}
	cout<<(dp[k]?"First":"Second");
	return 0;
}

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

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

    //good luck kittu!
    int n, x, y, d; cin>>n>>x>>y;
    map<int, int> m;
    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=n; j++){
            d = min({abs(i-j), abs(i-x)+1+abs(j-y), abs(i-y)+1+abs(j-x)});
            m[d]++;
        }
    }

    for(int i = 1; i<n; i++) cout<<m[i]/2<<"\n";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;


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

  char S, T;
  cin >> S >> T;
  if(S != '1' && T != '1'){
    cout << '1'<< endl;
  }
  if(S != '2' && T != '2'){
    cout << '2'<< endl;
  }
  if(S != '3' && T != '3'){
    cout << '3'<< endl;
  }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  ll n,k;
  cin >> n >> k;
  ll ans = k*pow(k-1,n-1);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=110;
int n,a[N],b[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",a+i,b+i);
	for(int i=1;i<=n-2;i++)
		if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
			puts("Yes");
			return 0;
		}
	puts("No");
	return 0;
}

Measured memory_bytes: 3168