akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

ll A, B, C;

void solve() {
	cin >> A >> B >> C;
	if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0) cout << 0 << "\n";
	else cout << min({A * B, B * C, C * A}) << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

long long N,i,j,k,K;

priority_queue<long long> H;

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

  for(i=0;i<N;i++)
  {
    cin>>k;
    H.push(k);
  }
  
  for(i=0;i<K;i++)
  {
    H.pop();
  }
  
  k=0;
  for(i=0;i<N-K;i++)
  {
    k+=H.top();
    H.pop();
  }
  
  
  cout <<k;

}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

long long A,B,K;

cin>>A>>B>>K;


if(A>=K){
    A-=K;
    K=0;
}
else{
    K=K-A;
    A=0;
    
}
cout<<A<<" ";
A=B;
if(A>=K){
    A-=K;
    K=0;
}
else{
    K=K-A;
    A=0;
}
cout<<A<<" ";

return 0;

}
/*
2 3 3

0 2

500000000000 500000000000 1000000000000

0 0

*/


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

int main() {
  string s;
  cin>>s;
  if(s=="SAT"){
    cout<<1<<endl;
  }
  if(s=="FRI"){
    cout<<2<<endl;
  }
  if(s=="THU"){
    cout<<3<<endl;
  }
  if(s=="WED"){
    cout<<4<<endl;
  }
  if(s=="TUE"){
    cout<<5<<endl;
  }
  if(s=="MON"){
    cout<<6<<endl;
  }
  if(s=="SUN"){
    cout<<7<<endl;
  }
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        mut a: [i32; n],
    }
    a.sort_by_key(|a| Reverse(*a));
    println!(
        "{}",
        a.chunks(2)
            .map(|arr| if arr.len() == 2 {
                arr[0] - arr[1]
            } else {
                arr[0]
            })
            .sum::<i32>()
    );
}


Measured memory_bytes: 2104
#include <iostream>
using namespace std;
 
int main()
{
	double v, t, y;
     while(cin >> v)
	{
		t = v / 9.8;
        y = 4.9*t*t;
         for(int i = 1; i > 0; i++)
		{
            if((5*i-5) > y)
			{
                cout << i << endl;
                break;
            }
        }
    }
     
    return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int ans,cnt,h,w,a[30][30],chk[30][30],dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
struct point{int x;int y;int num;};
bool safe(int x,int y)
{
    return (x>=0&&x<h&&y>=0&&y<w&&a[x][y]&&(!chk[x][y]));
}
void bfs(int x0,int y0)
{
    queue<point> Q;
    Q.push({x0,y0,0});
    chk[x0][y0]=1;
    while(!Q.empty())
    {
        int x=Q.front().x;
        int y=Q.front().y;
        int num=Q.front().num;
        cnt=max(cnt,num);
        for(int i=0;i<4;i++)
        {
            int xx=x+dx[i];
            int yy=y+dy[i];
            if(safe(xx,yy))
            {
                chk[xx][yy]=1;
                Q.push({xx,yy,num+1});
            }
        }
        Q.pop();
    }
}
int main()
{
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++)
    {
        char b[30];
        scanf("%s",b);
        for(int j=0;j<w;j++)
        {
            if(b[j]=='.')
            {
                a[i][j]=1;
            }
        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            for(int i=0;i<h;i++)
            {
                for(int j=0;j<w;j++)
                {
                    chk[i][j]=0;
                }
            }
            cnt=0;
            if(a[i][j])
            {
                bfs(i,j);
                ans=max(ans,cnt);
            }
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
using namespace std;

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

    int H, W;
    cin >> H >> W;

    map<int, int> candidates;
    map<int, int> moves;

    rep(i, W) {
        candidates[i] = i;
    }
    moves[0] = W;

    rep(i, H) {
        int A, B;
        cin >> A >> B;
        A--;

        int r = -1;
        while (true) {
            auto it = candidates.lower_bound(A);
            if (it == candidates.end() || it->first > B) break;

            r = max(r, it->second);
            int t = it->first - it->second;
            moves[t]--;
            if (moves[t] == 0) {
                moves.erase(t);
            }
            candidates.erase(it);
        }
        if (r != -1 && B != W) {
            moves[B - r]++;
            candidates[B] = r;
        }

        if (moves.size() == 0) {
            cout << -1 << "\n";
        } else {
            cout << moves.begin()->first + (i + 1) << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 12960
import java.util.Scanner;
class Main{
	public static void main(String[] a){
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		char[] rev = str.toCharArray();
		for(int i = rev.length - 1; i >= 0; i--){
			System.out.print(rev[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 17124
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int    
#define mod 1000000007
using namespace std;
int main()
{	
	string s,t;
	cin>>s>>t;
	bool ans = true;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
			{
				ans=false;
				break;
			}
	}
	if(s.size()+1==t.size() && ans)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int x;
  char s[100];
  int stack[100];
  int i=0;
  /* 逆ポーランドの計算 */

  while( scanf("%s", s) != EOF ){

    if ( s[0] == '+' ){
      stack[i-2]=stack[i-1]+stack[i-2];
      i--;

    } else if ( s[0] == '-' ){
      stack[i-2]=stack[i-2]-stack[i-1];
      i--;
      
    } else if ( s[0] == '*' ){
      stack[i-2]=stack[i-1]*stack[i-2];
      i--;

    } else {
      x = atoi(s);
      stack[i]=x;
      i++;
  }



  }
  /* ----------- out put ----------- */
  printf("%d\n",stack[i-1]);
  /* ------------------------------- */
  return 0;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve()
{
  int n;int d;cin>>n>>d;
  int ans=0;
  while(n--)
  {
      int x;int y;cin>>x>>y;
      int dist=x*x + y*y;
      if(dist<=(d*d))
      ans++;
  }
  cout<<ans<<endl;
}
int32_t main()
{
    rapido;
    int t;
    //cin>>t;
     t=1;
    while(t--)
     solve();
}

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

int main(){
	ll a;
  	double b;
  	cin >> a >> b;
  
  	int bb = b*100 + 0.1; //誤差を消すため小数を足す
  	a *= bb;
  	a /= 100;
  	cout << a << endl;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    llint k, s;
    cin >> k >> s;

    llint ans = 0, z;
    for(llint ix=0;ix<=k;ix++) {
        for(llint iy=0;iy<=k;iy++) {
            z = s-ix-iy;
            if(0<=z&&z<=k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return list(set(a))

a = prime_factorize(N)
count, j = 0, 0
for i in a:
    j = 0
    while N % pow(i, j+1) == 0:
        N /= pow(i, j+1)
        j += 1
    count += j
        
print(count)
        


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

int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	int has=a-b;
	if(has<0)has*=-1;
	if(has%2==0)printf("Alice\n");
	else printf("Borys\n");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int> Pi;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()

void solve(){
	int H, W; scanf("%d%d", &H, &W);
	rep(i, H)rep(j, W){
		string s; cin >> s;
		if(s == "snuke"){
			printf("%c%d", j+'A', i+1);
			return;
		}
	}
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int h = s.nextInt();
        int a = s.nextInt();
        int r = (int)Math.ceil(1.0 * h / a);
        System.out.println(r);
    }
}



Measured memory_bytes: 21716
#  095C
import sys
A,B,C,x,y = map(int, sys.stdin.readline().split())

ans = float('inf')
for i in range(0, 2*max(x, y)+1, 2):
    tmp = A*max(x-i//2, 0) + C*i + B*max(y-i//2, 0)
    #print(tmp, i)
    if ans > tmp:
        ans = tmp
print(ans)

Measured memory_bytes: 3060
/*
    _____
  .'|||||'.
 /  >   <  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
    |||||
*/

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
#define CL(x,v); memset(x,v,sizeof(x));
#define INF 0x3f3f3f3f
#define LL long long
#define REP(i,r,n) for(int i=r;i<=n;i++)
#define RREP(i,n,r) for(int i=n;i>=r;i--)
const int maxn=2e5+10;
int n;
LL k;
int f[maxn],a[maxn];
multiset<int> s;
bool ok(LL x)
{
    LL num=0;
    for (int i=1;i<=n;i++)
    {
        LL y;
        y=x/(LL)a[i];
        if (y>=f[i]) continue; else num+=f[i]-y;
    }
    if (num>k) return(0); else return(1);
}
bool cmp(int a, int b)
{
    return(a>b);
}
int main()
{
    scanf("%d%lld",&n,&k);
    for (int i=1;i<=n;i++)
        scanf("%d",&f[i]);
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+1+n,cmp);
    sort(f+1,f+1+n);
    LL l=0;
    LL r=1e13;
    while (l!=r)
    {
        LL mid=(l+r)/2;
        if (ok(mid)) r=mid; else l=mid+1;
    }
    printf("%lld\n",l);
    return(0);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG



signed main() {
  int N, M; cin >> N >> M;
  
  if(N >= M/2) cout << M/2 << endl;
  else cout << N + (M/2-N)/2 << endl;
  
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;
import core.vararg;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	while(true) {
		auto NQ = readInts();
		auto N = NQ[0];
		auto Q = NQ[1];
		if(N == 0) {
			return;
		}
		auto c = new int[100];
		for(int i; i < N; ++i) {
			foreach(d; readInts().dropOne()) {
				--c[d-1];
			}
		}
		auto ans = zip(c, iota(100).array).sort[0][1];
		if(-c[0] >= Q) {
			writeln(ans+1);
		} else {
			writeln(0);
		}
	}
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 100 + 10;
int a[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;
    for (int i=1; i<=n; i++) {
        cin >> a[i];
    }
    for (int i=1; i<=n; i++) {
        if (!(a[i] & 1) && __gcd(a[i], 15) == 1) {
            cout << "DENIED\n";
            return 0;
        }
    }
    cout << "APPROVED\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

void nextv(std::vector<std::string>const& in,
           std::vector<std::string>& out) {
  out.clear();
  for(auto s: in) {
    char mc = 'a';
    for(auto c: s) mc = std::max(mc, c);
    ++mc;
    for(char c = 'a'; c <= mc; ++c) out.push_back(s+c);
  }
}

int main() {
  int N; std::cin >> N;
  std::vector<std::string> v1, v2;
  v1.push_back("a");
  while(--N > 0) { nextv(v1, v2); v1.swap(v2); }
  for(auto s: v1) std::cout << s << std::endl;
  return 0;
}


Measured memory_bytes: 11124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[5];
    rep(i,0,5) cin >> A[i];
    ll v = INF;
    rep(i,0,5) v = min(v, A[i]);
    ll ans = 5 + (N + v - 1) / v - 1;
    print(ans);


    



    
}

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

namespace ConsoleApp15
{
    class Class390
    {
        static void Main()
        {
            var r = Console.ReadLine().Split().Select(long.Parse).ToArray();
            double W = r[0];
            double H = r[1];
            double x = r[2];
            double y = r[3];

            double ans = (H * W) / 2;
            if (H / 2 == y && W / 2 == x)
            {
                Console.WriteLine($"{ans} {1}");
            }
            else
            {
                Console.WriteLine($"{ans} {0}");
            }

        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <map>
#include <string>

std::map<char, char> rules;
std::string str;

bool get_input() {
    str.clear();
    rules.clear();

    int no_rules;
    std::cin >> no_rules;

    if (no_rules == 0) {
        return false;
    }

    int i;
    char before, after;
    for (i = 0; i < no_rules; i++) {
        std::cin >> before >> after;
        rules[before] = after;
    }

    int no_chars;
    char c;
    std::cin >> no_chars;
    for (i = 0; i < no_chars; i++) {
        std::cin >> c;
        str.push_back(c);
    }

    return true;
}

void convert() {
    std::map<char, char>::iterator rule_itr;
    for (std::string::iterator i = str.begin(); i != str.end(); i++) {
        if ((rule_itr = rules.find(*i)) != rules.end()) {
            *i = (*rule_itr).second;
        }
    }
}

int main() {
    while (get_input()) {
        convert();
        std::cout << str << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //g h ; " string  if(st[i]-'0'==7)
    long long n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3==0 && i%5==0)
            //sum+=i;
            continue;
        else if((i%3==0 && i%5==0)|| (i%3==0))
            continue;
        else if((i%3==0 && i%5==0)||(i%5==0))
            continue;

        else sum+=i;
    }
    cout<<sum<<endl;

       //Alhamdulilla..

}





Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;

typedef long long ll;
ll INF = 1LL << 60;
ll MAX = 100010;
ll MOD = 2019;

int
main() 
{
  ll l, r; cin >> l >> r;

  if(r - l > 2019){
    cout << 0 << endl;
    return 0;
  }

  ll min = INF;
  rep(i, l, r){
    repe(k, i + 1, r){
      if((i * k % MOD) < min){
        min = i * k % MOD;
      }
    }
  }

  cout << min << endl;
}



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

template <typename T>
struct ReRooting
{
  using F = function<T(T, int)>;
  using F2 = function<T(T, T)>;
  static const int MAX_V = 200010;
  int V;
  vector<int> E[MAX_V];
  vector<T> dp[MAX_V];
  //f(v) = g(merge(f(dp_c1,c1), f(dp_c2,c2), ..., f(dp_ck,ck)) , v)
  F f, g;
  F2 merge;
  T mi; //identity of merge

  ReRooting(int V_, F f_, F2 merge_, T mi_, F g_ = [](T a, T b) { return a; })
      : V(V_), f(f_), merge(merge_), mi(mi_), g(g_) {}

  void add_E(int a, int b)
  {
    E[a].push_back(b);
    E[b].push_back(a);
  }

  T dfs1(int p, int v)
  {
    T res = mi;
    for (int i = 0; i < E[v].size(); ++i)
    {
      if (E[v][i] == p)
        continue;
      dp[v][i] = dfs1(v, E[v][i]);
      res = merge(res, f(dp[v][i], E[v][i]));
    }
    return g(res, v);
  }

  void dfs2(int p, int v, T add)
  {
    for (int i = 0; i < E[v].size(); ++i)
    {
      if (E[v][i] == p)
      {
        dp[v][i] = add;
        break;
      }
    }

    vector<T> pL(E[v].size() + 1), pR(E[v].size() + 1);
    pL[0] = mi;
    for (int i = 0; i < E[v].size(); ++i)
      pL[i + 1] = merge(pL[i], f(dp[v][i], E[v][i]));
    pR[E[v].size()] = mi;
    for (int i = E[v].size(); i > 0; --i)
      pR[i - 1] = merge(pR[i], f(dp[v][i - 1], E[v][i - 1]));

    for (int i = 0; i < E[v].size(); ++i)
    {
      if (E[v][i] == p)
        continue;
      T val = merge(pL[i], pR[i + 1]);
      dfs2(v, E[v][i], g(val, v));
    }
  }

  void calc(int root = 0)
  {
    for (int i = 0; i < V; ++i)
      dp[i].resize(E[i].size());
    dfs1(-1, root);
    dfs2(-1, root, mi);
  }

  T solve(int v)
  {
    T ans = mi;
    for (int i = 0; i < E[v].size(); ++i)
    {
      ans = merge(ans, f(dp[v][i], E[v][i]));
    }
    return g(ans, v);
  }
};

int main()
{
  int n, m;
  cin >> n >> m;
  auto f = [&](long long a, int v) {
    (void)v;
    return (a + 1) % m;
  };
  auto merge = [&](long long a, long long b) {
    return a * b % m;
  };
  ReRooting<long long> re(n, f, merge, 1);
  for (int i = 0; i < n - 1; ++i)
  {
    int x, y;
    cin >> x >> y;
    x--, y--;
    re.add_E(x, y);
  }
  re.calc();
  for (int i = 0; i < n; ++i)
  {
    cout << re.solve(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 38528
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int w=0,r=0,ans=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='W')
            w++;
        else
            r++;
    }
    ans=min(w,r);
    int count=0;
    for(int i=0;i<r;i++)
    {
        if(s[i]=='W')
        {
            count++;

        }
    }
    ans=min(ans,count);
    cout<<ans<<endl;

}


Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;
int N;
int K;
int sum = 0;
int boundary = 0; //区切りの数
int happy = 0; //しあわせの数
int adjust = 0;
string S;
string strTmp[3];




int main() {
	int tmp;
	cin >> N >> K;
	cin >> S;

	for (int i = 0; i < N - 1;i++) {
		strTmp[0] = S[i]; //バグ回避
		strTmp[1] = S[i + 1]; //バグ回避

		if (strTmp[0] != strTmp[1]) {
			boundary++;
		}

		if (i != 0) {
			strTmp[2] = S[i - 1];
			if (strTmp[0] == strTmp[1] && strTmp[0] == "R") {
				happy++;
			} else if (strTmp[0] == strTmp[2] && strTmp[0] == "L") {
				happy++;
			}
		}

	}
	//はじっこのhappy
	if (N > 1) {
		strTmp[0] = S[0]; //バグ回避
		strTmp[1] = S[1]; //バグ回避
		if (S[0] == S[1] && strTmp[0] == "R") {
			happy++;
		}
	}
	if (N > 2) {
		strTmp[0] = S[N - 2]; //バグ回避
		strTmp[1] = S[N - 1]; //バグ回避
		if (S[N - 2] == S[N - 1] && strTmp[0] == "L") {
			happy++;
		}
	}

	if (boundary > 0) {
		//adjust = ((boundary + 1) % 2);
	}

	cout << happy + min(2 * K, min(boundary + adjust, N-1));

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef std::numeric_limits< double > dbl;
int main()
{	
	int n,b;
	cin >> n;
	double ans=0,sum =0;
	double arr[1000] ={};
	while(n!=0){
		for(int i=0; i<n;i++){
			cin >> b;
			sum +=b;
			arr[i] = b;
		}

		for(int i=0 ;i<n ;i++){
			ans += (sum/n - arr[i])*(sum/n - arr[i]);
		}
		ans /=n;
		
		cout <<std::setprecision (8) <<sqrt(ans) << endl;
		ans =0,sum=0;
		cin >> n;
	}
	
    return 0;
}



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

int x,y;
int field[50][50];

void dfs(int w, int h){
	field[w][h]=0;
	for(int dy=-1; dy<=1; dy++){
		for(int dx=-1; dx<=1; dx++){
			int nx = w + dx;
			int ny = h + dy;
			if(nx>=0 && nx<x && ny>=0 && ny<y && field[nx][ny]==1)
				dfs(nx,ny);
		}
	}
	return;
}


int main(){
	while(1){
		int result = 0;
		cin >> x >> y;
		if(x == 0 && y == 0)
			break;
		for(int j=0; j<y; j++){
			for(int i=0; i<x; i++){
				cin >> field[i][j];
			}
		}
		for(int j=0; j<y; j++){
			for(int i=0; i<x; i++){
				if(field[i][j]==1){
					result++;
					dfs(i,j);
				}
			}
		}
		cout << result << endl;
	}
}


Measured memory_bytes: 3244
import sys
import math
from collections import Counter
import itertools
import fractions
from decimal import Decimal
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

a,b,c=MI()
print(int(a*b*0.5))

Measured memory_bytes: 5268
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

int num1[500005];
int num2[500005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    cin >> s;
    int n = (int)s.length();
    for(int i = 0; i < n; ++i){
        if(s[i] == '<')     num1[i+1] = num1[i] + 1;
        else        num1[i+1] = 0;
    }
    for(int i = n-1; i >= 0; --i){
        if(s[i] == '>')     num2[i] = num2[i+1] + 1;
        else        num2[i] = 0;
    }
    ll sum = 0;
    for(int i = 0; i <= n; ++i){
        sum += max(num1[i], num2[i]);
    }
    cout << sum << "\n";
}

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

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

using namespace std;

int main(){
  ll n,k;cin>>n>>k;
  ll a[n];
  rep(i,n)cin>>a[i];
  int all_bits=40;

//40bit全部見る
//kの中でbitが立っている箇所を全部見る
//bitが立っている場所を0にして、その桁数を記憶
//桁数よりも大きい位置にあるbitはkを真似る
//同じ桁は0にする
//それよりも小さい桁はaの同じ桁のビットを見てカウントし、少ない方にする(xがk以下でresultを最大化する値にする)

  ll result=0;
  rep(i,n)result+=(k^a[i]);

  rep(i,all_bits){
    ll current=(1LL<<i);
    if(!(current & k))continue;

    ll tmp_result=0;
    rep(j, all_bits){
      ll mask=1LL<<j;
      ll count=0;
      rep(k,n)if( a[k]&mask )count++;

      if(i<j){//もし低減予定のbitよりも高い位置のbitを確認中なら
        if(k & mask){//そこにbitが立っていたら
          //xのそこのbitは1になる、よってこの時のXによる結果は数列の当該bitの0の数だけ増加する(つまりn-countだけ増える。
          tmp_result+=mask*(n-count);
        }else{
          //そこのbitが立っていなければxも同じく0になる。
          //0になるということは数列のうちそこにibtが立っているものの個数だけ増える。のでmask*countとなる
          tmp_result+=mask*count;
        }
      }else if(i==j){//もし低減予定のbitと同一のbitを確認中なら
        tmp_result+=mask*count;
      }else if(i>j){//もし低減予定のbitよりも低い位置のbitを確認中なら
        //可能な限り大きな値にする。
        tmp_result+=mask*max(count, n-count);
      }
    }

//cout<<result<<' '<<tmp_result<<endl;


    result=max(result, tmp_result);
  }

  cout<<result;

  return 0;
}

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


int main()
{

  int N,M;
  cin >> N >> M;

  int A[N];
  long long a = 0;
  for(int i=0;i<M;i++)
  {
    cin >> A[i];
    a += A[i];
  }
  if (N < a){
    cout<< "-1" <<endl;
  }else{
    cout << N-a <<endl;
  }
  return 0;

}

Measured memory_bytes: 3680
a=list(map(int,input().split()))
a.sort()
b=a[1]-a[0]
ans=0
if b%2==0:
    ans+=b//2
else:
    a[0]=a[0]+1
    a[2]=a[2]+1
    ans+=b//2+1
print(a[2]-a[1]+ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

// template from zscoder
ll length(0),n,c(0),last;

void getl(ll x)
{
    while(x>=1)
    {
        length++;
        c += x%10;
        last = x%10;
        x /= 10;
    }
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    cin >> n;
    getl(n);
    length --;
    c = max(length*9+last-1,c);
    cout << c << endl;
}


Measured memory_bytes: 256
class SCCGraph
	# n 頂点の有向グラフを作る
	# @complexity O(n)
	def initialize(n = 0)
		@n, @edges = n, []
	end

	# 頂点 from から頂点 to へ有向辺を足す
	# @complexity O(1) amortized
	def add_edge(from, to)
		raise "invalid params" unless (0...@n).include? from and (0...@n).include? to
		@edges << [from, to]
	end

	# 強連結成分を成分ごとにトポロジカルソートして返す
	# @complexity O(@n + @edges.size)
	def scc
		group_num, ids = scc_ids
		counts = [0] * group_num
		ids.each { |x| counts[x] += 1 }
		groups = Array.new(group_num) { [] }
		ids.each_with_index { |x, i| groups[x] << i }
		groups
	end

	private

	def scc_ids
		start, elist = csr
		now_ord = group_num = 0
		visited, low, ord, ids = [], [], [-1] * @n, []
		dfs = ->(v) {
			low[v] = ord[v] = now_ord
			now_ord += 1
			visited << v
			(start[v]...start[v + 1]).each do |i|
				to = elist[i]
				low[v] = if ord[to] == -1
					dfs.(to)
					[low[v], low[to]].min
				else
					[low[v], ord[to]].min
				end
			end
			if low[v] == ord[v]
				loop do
					u = visited.pop
					ord[u] = @n
					ids[u] = group_num
					break if u == v
				end
				group_num += 1
			end
		}
		@n.times { |i| dfs.(i) if ord[i] == -1 }
		ids = ids.map { |x| group_num - 1 - x }
		[group_num, ids]
	end

	def csr
		start, elist = [0] * (@n + 1), [nil] * @edges.size
		@edges.each { |(i, _)| start[i + 1] += 1 }
		@n.times { |i| start[i + 1] += start[i] }
		counter = start.dup
		@edges.each do |(i, j)|
			elist[counter[i]] = j
			counter[i] += 1
		end
		[start, elist]
	end
end

n, m = gets.split.map &:to_i
g = SCCGraph.new(n)
m.times do
  a, b = gets.split.map &:to_i
  g.add_edge(a, b)
end

groups = g.scc
puts groups.size
groups.each do |group|
  puts ([group.size] + group).join(" ")
end

Measured memory_bytes: 108604
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int ans = 1;
  for(int i=1; i < N; ++i){
    if(i*i > N){
      ans = i-1;
      break;
    }
  }

  cout << ans*ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

int main() {
    double a, b;
    cin >> a >> b;
    cout << (2*b - a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <unordered_map>
#define M ((ll)1e12)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
typedef long long ll;
using namespace std;

void solve()
{
   int a,b,c;cin>>a>>b>>c;
   string s="bust";
   if(a+b+c<22)
   s="win";
   cout<<s<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    solve();
    return 0;}

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

int main(){
  int N; cin >> N;
  vector<int> boss(N,0);
  for(int i=0; i<N-1; i++){
    int a; cin >> a;
    boss[a-1]++;
  }
  for(int i=0; i<N; i++){
    cout << boss[i] << endl;
  }
}

Measured memory_bytes: 4000
object Main extends App {
	var Array(a, b, c) = scala.io.StdIn.readLine.split(" ").map(_.toInt).sorted

	def  test(a: Int, b: Int, c: Int) = a==b && b==c

	var ans = 0

	while(! test(a,b,c)){
		if(a==b){
			val t = c-a
			ans += t
			a = 1
			b = 1
			c = 1
		}else if(b==c){
			val t = (b-a)/2
			(b-a)%2 match {
				case 0 => {
					ans += t
					a = b
				}
				case 1 => {
					ans += t + 2
					a = 1
					b = 1
					c = 1
				}
			}
		}else{
			val t = c-b
			ans += t
			b += t
			a += t
		}
	} 

	println(ans)
}

Measured memory_bytes: 25532
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

void _yn(bool p) {
	p ? _y() : _n();
}

void _YN(bool p) {
	p ? _Y() : _N();
}


LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 




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

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

	int n = 5;
	vpi p(n);
	f(i, 0, n) {
		cin >> p[i].S;
		p[i].first = p[i].second % 10;
	}
	sort(all(p));
	int ans = 0;
	bool f = true;
	f(i, 0, n) {
		if (p[i].first != 0) {
			if (f) {
				ans += p[i].second;
				f = false;
			}
			ei (p[i].first == p[i].S) {
				ans += 10;
			}
			else {
				ans += (p[i].second - p[i].first + 10);
			}
		}
		else {
			ans += p[i].second;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<deque>
#include<ext/rope>
#define ll long long
#define ld long double
#define ull unsigned long long
#define sc(x) scanf("%d",&x)
using namespace std;
using namespace __gnu_cxx;
const int N = 1e6 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ld pi = acos(-1.0);
int t,n,m,l,r,x,Case;
char mp[1003][1003];
int sx,sy,ex,ey,type[1003][1003];
bool vis[1003][1003];
struct node {
    int x,y,z;
};
deque<node>q;
void dfs(node now){
    int x,y,z;
    x=now.x;y=now.y;z=now.z;
    if(y+1<m&&mp[x][y+1]=='.')q.push_front({x,y+1,z});
    if(x+1<n&&mp[x+1][y]=='.')q.push_front({x+1,y,z});
    if(y-1>=0&&mp[x][y-1]=='.')q.push_front({x,y-1,z});
    if(x-1>=0&&mp[x-1][y]=='.')q.push_front({x-1,y,z});
    for(int i=now.x-2;i<=now.x+2;i++)
        for(int j=now.y-2;j<=now.y+2;j++)
            if(i>=0&&j>=0&&i<n&&j<m&&mp[i][j]=='.')q.push_back({i,j,now.z+1});

}

void run(){
    cin>>n>>m;
    cin>>sx>>sy;
    cin>>ex>>ey;
    sx--;
    sy--;
    ex--;
    ey--;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>mp[i][j],type[i][j]=inf;
    q.push_back((node){sx,sy,0});
    node now;
    while(q.size()){
        now=q.front();q.pop_front();
        if(vis[now.x][now.y])continue;
        vis[now.x][now.y]=1;
        type[now.x][now.y]=min(now.z,type[now.x][now.y]);
        dfs(now);
    }
    if(type[ex][ey]==inf)cout<<-1<<'\n';
    else cout<<type[ex][ey]<<'\n';
}
int main(){
#ifdef haosao
freopen("main.h", "r", stdin);
//freopen("out.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
//    while()
        run();
    return 0;
}


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

typedef long long int ll;

#define first fs
#define second se
#define make_pair mk
#define push_back pb

vector< pair<ll,ll> > vec;


int main()
{
	ll n;
	cin>>n;
	ll arr[n];
	for(ll i=0;i<n;i++)
	{
       cin>>arr[i];
	}
	ll dp[n+1];
	memset(dp,0,sizeof(dp));

	
	for(ll i=0;i<n;i++)
	{
        ll m = 1000000000000;
		for(ll j=i-1;j>=i-2;j--)
		{
			m = min(m,dp[j]+abs(arr[i]-arr[j]));
		}
		if(i==0)m=0;
		dp[i]=m;
		//cout<<dp[i]<<endl;
	}
	cout<<dp[n-1]<<endl;

}


Measured memory_bytes: 1792
import collections
N, M, *AB = [int(_) for _ in open(0).read().split()]
parent_children = collections.defaultdict(set)
child_parents = collections.defaultdict(set)
for a, b in zip(AB[::2], AB[1::2]):
    parent_children[a].add(b)
    child_parents[b].add(a)
root = (set(range(1, N + 1)) - set(child_parents.keys())).pop()


def bfs(root):
    Q = collections.deque([root])
    while Q:
        cur = Q.pop()
        for to in parent_children[cur]:
            if len(child_parents[to]) > 1:
                child_parents[to].remove(cur)
            else:
                Q += [to]


bfs(root)
child_parents[root] = {0}
for i in range(1, N + 1):
    print(child_parents[i].pop())


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0 ; i < s.size() ; i += 1){
        if(s[i]+n <= 'Z'){
            s[i] += n;
            cout << s[i];
        }else{
            int f = n;
            f -= 'Z'-s[i]+1;
            s[i] = 'A'+f;
            cout << s[i];
        }
    }
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String a = "0";
		String b = "0";

		try {
			scanner = new Scanner(System.in);
			a = scanner.next();
			b = scanner.next();

			BigDecimal aB = new BigDecimal(a);
			BigDecimal bB = new BigDecimal(b);

			BigDecimal res = aB.add(bB);

			System.out.println(res.divide(new BigDecimal("2"), 0, RoundingMode.HALF_UP));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		String s = "";
		String t = "";

		try {
			scanner = new Scanner(System.in);
			s = scanner.next();
			t = scanner.next();

			List<String> wkList = new ArrayList<String>();
			char[] sA = s.toCharArray();
			char[] tA = t.toCharArray();
			Arrays.sort(sA);
			Arrays.sort(tA);

			String wkSa = new String(sA);
			String wkTa = new StringBuilder(new String(tA)).reverse().toString();
			wkList.add(wkSa);
			wkList.add(wkTa);

			Collections.sort(wkList);

			boolean res = false;
			if (s.equals(t)) {
				res = false;
			} else {
				res = wkList.get(0).equals(wkSa);
			}
			if (res) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int n = 0;

		try {
			scanner = new Scanner(System.in);
			n = scanner.nextInt();

			int[] wk = new int[n];
			for (int i = 0; i < n; i++) {
				wk[i] = scanner.nextInt();
			}

			Map<Integer, Integer> wkMap = new HashMap<Integer, Integer>();
			for (int i = 0; i < wk.length; i++) {
				if (!wkMap.containsKey(wk[i])) {
					wkMap.put(wk[i], 1);
				} else {
					wkMap.put(wk[i], wkMap.get(wk[i]) + 1);
				}
			}

			int res = 0;
			for (Iterator<Integer> ite = wkMap.keySet().iterator(); ite.hasNext();) {
				int num = ite.next();
				int size = wkMap.get(num);
				if (num == size) {
				} else if (num > size) {
					res += size;
				} else if (num < size) {
					res += Math.abs(size - num);
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

string solve(string s){
    string res = "";
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '?'){
            res += 'D';
        }else{
            res += s[i];
        }
    }
    return res;
}


int main(){
    string s;
    cin >> s;
    cout << solve(s) << endl;

    return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
    int n,k;
    while (scanf("%d%d",&n,&k)!=EOF) {
        int a;
        for(int i=1;i<=n;i++)scanf("%d",&a);
        cout<<(n-2)/(k-1)+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstdlib>
#define lnt long long 
#define rnt register int
using namespace std;
inline lnt gcd(lnt a,lnt b)
{
	if(!b) return a;
	return gcd(b,a%b);
}
lnt a,b,cnt,ans;
lnt c[50];
int main()
{
	scanf("%lld %lld",&a,&b);
	lnt g=gcd(a,b),sq=sqrt(g);
	for(rnt i=2;i<=sq;i=-~i)
	{
		while(!(g%i))
		{
			c[++cnt]=i;
			g/=i;
		}
	}if(g!=1) ans=-~ans;
	for(rnt i=1;i<=cnt;i=-~i)
		if(c[i]!=c[i-1])
			ans=-~ans;
	printf("%d",ans+1);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o set
int D;
ll c[26];
ll s[365][26];
void input(){
    cin >> D;
    for(int i=0;i<26;i++) cin >> c[i];
    for(int i=0;i<D;i++) for(int j=0;j<26;j++) cin >> s[i][j];
}
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    input();
    vector<int> last(26,0);
    vector<ll> ans(D);
    set<ll> day[26];
    rep(i,26) day[i].insert(0);
    ll score=0;
    rep(i,D){
        cin >> ans[i];
        ans[i]--;
        last[ans[i]]=i+1;
        score+=s[i][ans[i]];
        rep(j,26){
            score-=c[j]*(i+1-last[j]);
        }
        day[ans[i]].insert(i+1);
    }
    rep(i,26) day[i].insert(D+1);
    
    int m; cin >> m;
    while(m--){
        ll d,q; cin >> d >> q;
        q--;
        ll p=ans[d-1];
        ans[d-1]=q;
        score+=(s[d-1][q]-s[d-1][p]);
        
        ll prev=0,nxt=D+1;
        for(ll u:day[p]){
            if(u<d) chmax(prev,u);
            else if(u>d) chmin(nxt,u);
        }
        score-=c[p]*(d-prev)*(nxt-d);
        day[p].erase(d);
        
        prev=0,nxt=D+1;
        for(ll u:day[q]){
            if(u<d) chmax(prev,u);
            else if(u>d) chmin(nxt,u);
        }
        score+=c[q]*(d-prev)*(nxt-d);
        day[q].insert(d);
        
        cout << score << endl;
    }
}


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

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

signed main() {
    accell();
    int n, a, b;
    cin >> n >> a >> b;
    if (a % 2 == b % 2) {
        cout << abs(b - a) / 2;
    } else {
        int x = min(a, b);
        int res = x - 1;
        int c = max(a, b);
        x = 1, c = c - res;
        --c;
        res++;
        res += abs(c - 1) >> 1;
        x = max(a, b);
        c = min(a, b);
        int res1 = n - x;
        x = n;
        c += res1;
        ++c;
        res1++;
        res1 += abs(n - c) >> 1;
        cout << min(res, res1) << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Int32;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        label:
        WriteLine(ReadLine().Count(c => c == '1'));
        //goto label;
    }
}


Measured memory_bytes: 11220
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
int main() {
	ll n,ans;
	cin >> n;
	for (ll i = sqrt(n); i >=1; --i) {
		if (n%i == 0) { ans = n/i; break; }
	}
	ll ct = 0;
	while (ans > 0)ans /= 10, ++ct;
	cout << ct << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

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

const int MOD = 1000000007;

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

int main(){
	LL n;cin>>n;
	VS s(n);
	for(LL i=0;i<n;i++){
		cin>>s.at(i);
		sort(all(s.at(i)));
	}
	sort(all(s));
	LL ans=0;
	LL cnt=0;
	string cur=s.at(0);
	for(LL i=0;i<n;i++){
		if(s.at(i)==cur){
			cnt++;
		}else{
			ans+=cnt*(cnt-1)/2;
			cur=s.at(i);
			cnt=1;
		}
	}
	ans+=cnt*(cnt-1)/2;
	cout<<ans<<endl;
	return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	char c;
	cin >> c;
	if (isupper(c)) {
		cout << "A\n";
	} else {
		cout << "a\n";
	}
	return 0;
}


Measured memory_bytes: 3644
N,K,Q = map(int,input().split())
point = [0 for i in range(0,N)]
for i in range(0,Q):
    A = int(input())
    point[A-1] += 1
for i in range(0,N):
    if Q - point[i] < K:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4672