akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    scanf("%d",&n);
    string s[3];
    cin >> s[0] >> s[1] >> s[2];


    int ans = 0;
    
    rep(i,n){
        if(s[0][i] == s[1][i] && s[1][i] == s[2][i]){
            ;
        }else if(s[0][i]!=s[1][i] && s[1][i]!=s[2][i] && s[2][i]!=s[0][i]){
            ans++;
            ans++;
        }else{
            ans++;
        }
    }

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


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

int main() {
  
  	int N;
  	cin >> N;
  
  	vector<char> color(N);

  	for(int i=0;i<N;i++){
    	cin >> color.at(i);
    }
  	
  	int judge=0;
  	for(int i=0;i<N;i++){
    	if(color.at(i)=='Y'){
        	judge++;
        }
    }
	
  	if(judge>0){
    	cout << "Four" << endl;
    }
  	else{
    	cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
//	file();
	fast();
	ll n, k; cin >> n >> k;
	ll ans = n % k;
	ans = min(ans, k - (n % k));
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

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

N = I()
A = LI()

for i in range(N):
    if A[i]%2==0:
        if A[i]%3!=0 and A[i]%5!=0:
            print('DENIED')
            exit()

print('APPROVED')

Measured memory_bytes: 39860
n = gets.to_i

road = Array.new(n + 1) {[]}
(n - 1).times do
    a, b, c = gets.split.map(&:to_i)
    road[a] << [b, c]
    road[b] << [a, c]
end

q, k = gets.split.map(&:to_i)

dis = Array.new(n + 1)
visit = Array.new(n + 1, false)

dis[k] = 0
visit[k] = true
queue = [k]

while now = queue.shift
    road[now].each do |t, d|
        next if visit[t]
        dis[t] = dis[now] + d
        visit[t] = true
        queue << t
    end
end

q.times do
    x, y = gets.split.map(&:to_i)
    puts dis[x] + dis[y]
end

Measured memory_bytes: 29364
import sys
import math

def str_input():
    S = raw_input()
    if S[len(S)-1] == "\r":
        return S[:len(S)-1]
    return S

def float_to_str(num):
    return str("{:.10f}".format(num))

def list_input(tp):
    return map(tp, str_input().split())

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

class Dice:
    pip = [0 for i in xrange(6)]

    def __init__(self, arg):
        self.pip = arg

    def rollDir(self, dr):
        nextPip = [0 for i in xrange(6)]
        if dr == "N":
            nextPip[0] = self.pip[1]
            nextPip[1] = self.pip[5]
            nextPip[2] = self.pip[2]
            nextPip[3] = self.pip[3]
            nextPip[4] = self.pip[0]
            nextPip[5] = self.pip[4]
        elif dr == "E":
            nextPip[0] = self.pip[3]
            nextPip[1] = self.pip[1]
            nextPip[2] = self.pip[0]
            nextPip[3] = self.pip[5]
            nextPip[4] = self.pip[4]
            nextPip[5] = self.pip[2]
        self.pip = nextPip

    def roll(self, dr):
        if dr == "N" or dr == "E":
            self.rollDir(dr)
        elif dr == "S":
            self.rollDir("N")
            self.rollDir("N")
            self.rollDir("N")
        elif dr == "W":
            self.rollDir("E")
            self.rollDir("E")
            self.rollDir("E")

    def check(self, a, b):
        while self.pip[0] != a:
            if self.pip[2] != a and self.pip[3] != a:
                self.roll("N")
            else:
                self.roll("N")
                self.roll("W")
                self.roll("S")

        while self.pip[1] != b:
            self.roll("N")
            self.roll("W")
            self.roll("S")
        return self.pip[2]

def sameCheck(dice1, dice2):
    for i in xrange(4):
        for j in xrange(4):
            if dice1.pip == dice2.pip:
                return True
            dice2.roll("E")
        dice2.roll("N")
    dice2.roll("N")
    dice2.roll("E")
    dice2.roll("S")
    for i in xrange(4):
        if dice1.pip == dice2.pip:
            return True
        dice2.roll("E")
    dice2.roll("N")
    dice2.roll("E")
    dice2.roll("E")
    dice2.roll("S")
    for i in xrange(4):
        if dice1.pip == dice2.pip:
            return True
        dice2.roll("E")
    return False

n = input()
dice = []

for i in xrange(n):
    tmp_dice = Dice(list_input(int))
    dice.append(tmp_dice)

for i in xrange(n):
    for j in xrange(i+1, n):
        if sameCheck(dice[i], dice[j]):
            print "No"
            sys.exit()

print "Yes"

Measured memory_bytes: 6560
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        String s=sc.next();
        int k=sc.nextInt();
        String S=s.substring(k-1,k);
        String ans="";
        for(int i=0;i<s.length();i++) {
        	if(s.substring(i,i+1).equals(S))ans+=S;
        	else ans+="*";
        }
        System.out.println(ans);
    }
}


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

using ll = long long;
using namespace std;

// gcd(a,b) および ax+by=gcd(a,b) となる x, y の導出
ll Extgcd(ll a, ll b, ll& x, ll& y)
{ 
    ll g = a;
    if (b != 0) {
        Extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1, y = 0;
    }
    return g;
}

// ax = gcd(a, m)となるxの導出
// a,m が互いにその時、x は mod m での a のモジュラ逆数となる
ll ModInverse(ll a, ll m)
{
    ll x, y;
    Extgcd(a, m, x, y);
    return (x % m + m) % m;
}

// mod MOD での i! のモジュラ逆数テーブルの生成
// i は 0 ~ MAX_NUM-1
constexpr ll MOD = 1000000007;
constexpr ll MAX_NUM = 100000 * 2;

vector<ll> fact(MAX_NUM);
vector<ll> rfact(MAX_NUM);

void FactInit()
{
    fact[0] = rfact[0] = 1;
    for(int i = 1; i < MAX_NUM; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        rfact[i] = rfact[i - 1] * ModInverse(i, MOD) % MOD;
    }
}

// C(n,k) (mod MOD)の導出
inline ll Combination(ll n, ll k)
{
    return (fact[n] * rfact[k] % MOD) * rfact[n - k] % MOD;
}

int main() {
    FactInit();
    int num;
    vector<int> v;
    cin >> num;
    for(int i = 0; i < num + 1; i++) {
        int input;
        cin >> input;
        v.push_back(input);
    }

    int dup;
    vector<int> v2;
    copy(v.begin(), v.end(), back_inserter(v2));
    sort(v2.begin(), v2.end());
    for (int i = 0; i < num; i++) {
        if (v2[i] == v2[i + 1]) {
            dup = v2[i];
        }
    }
    int dup_id1, dup_id2;
    for (int i = 0; i < num + 1; i++) {
        if (v[i] == dup) {
            dup_id1 = i;
            for (int j = i + 1; j < num + 1; j++) {
                if (v[j] == dup) {
                    dup_id2 = j;
                    break;
                }
            }
            break;
        }
    }

    for (int i = 1; i <= num + 1; i++) {
        cout << ((Combination(num + 1, i) - (dup_id1 + num - dup_id2 >= i - 1 ? Combination(dup_id1 + num - dup_id2, i - 1) : 0)) % MOD + MOD) % MOD << endl;
    }

    return 0;
}


Measured memory_bytes: 5240
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;
/*
int maximum(int* x, int N)
{
	int M = 0;
	for (int i = 0; i < N; i++)
		M = (M > x[i] ? M : x[i]);
	return M;
}
int minimum(int* x, int N)
{
	int m = 0;
	for (int i = 0; i < N; i++)
		m = (m < x[i] ? m : x[i]);
	return m;
}*/
int height(int x, int y, int x_pot, int y_pot, int H_pot)
{
	int h;
	h = max(H_pot - abs(x - x_pot) - abs(y - y_pot), 0);
	return h;
}

int main()
{
	/*---Read Parameters-----*/
	int N;
	cin >> N;
	int* x = new int[N];
	int* y = new int[N];
	long long* h = new long long[N];
	for (int i = 0; i < N; i++)
		cin >> x[i] >> y[i] >> h[i];
	/*---Read Parameters: Completed-----*/
	/*-----Try every (x, y) for the centre-----*/
	//for (int i = 0; i < N; i++)
	//	cout << x[i] << ' ' << y[i] << ' ' << h[i] << '\n';
	int xc = 0, yc = 0;
	long long H = 0;
	//putchar('\n');
	for (int x_pot = 0; x_pot <= 100; x_pot++)
	{
		//printf("x_pot = %d\t", x_pot);
		bool larger_flag = false;
		for (int y_pot = 0; y_pot <= 100; y_pot++)
		{
			//printf("y_pot = %d\n", y_pot);
			long long H_pot = 1;	//pot means "potential".
			for (int n = 0; n < N; n++)	//To find the potential H_pot, and that requires an h != 0.
				if (h[n] != 0)	//And if no h != 0 is in the array, H_pot will be considered 1.
				{
					//cout << h[n] << ' ' << n;
					H_pot = h[n] + abs(x[n] - x_pot) + abs(y[n] - y_pot);
					break;
				}
			bool flag = true;
			for (int n = 0; n < N; n++)
				if (h[n] != height(x[n], y[n], x_pot, y_pot, H_pot))
				{
					flag = false;
					break;
				}
			if (flag == true)
			{
				larger_flag = true;
				yc = y_pot;
				H = H_pot;
				break;
			}
		}
		if (larger_flag == true)
		{
			xc = x_pot;
			break;
		}
	}
	std::cout << xc << ' ' << yc << ' ' << H;
	getchar(); getchar();
	return 0;
}

//Ref: https://blog.csdn.net/qq_33241119/article/details/82954937

Measured memory_bytes: 3164
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int n;
vector<pair<int,int> >  v;
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    v.push_back(make_pair(a,b));
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  cout<<v[0].fi+v[0].se<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 1400
using System;

namespace _9_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string s = Console.ReadLine();
                if (s == "-")
                {
                    break;
                }
                int n = int.Parse(Console.ReadLine());
                for (int i = 0; i < n; i++)
                {
                    int x = int.Parse(Console.ReadLine());
                    s = s.Substring(x, s.Length - x) + s.Substring(0, x);
                }
                Console.WriteLine(s);
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 8864
#include <iostream>
#include <cstdio>
using namespace std;
int gcd(int a,int b){
    return !b?a:gcd(b,a%b);
}
int main(void){
    int a,b;
    cin>>a>>b;
    cout<<gcd(a,b)<<endl;
    return 0;
}


Measured memory_bytes: 3096
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[0]*n

for i in range(m):
    a,b=map(int,input().split())
    if h[a-1] < h[b-1]:
        ans[a-1] = 1
    elif h[a-1] > h[b-1]:
        ans[b-1] += 1
    else:
        ans[a-1] += 1
        ans[b-1] += 1

print(ans.count(0))

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    ll cnt = 0;
    for(i=1;2*i<n;i++){
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

int n;
vector<vector<pair<long long, int>>> edge;
vector<long long> cost;

void hawawa()
{
	cin >> n;
	cost.resize(n);
	edge.resize(n);
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		long long w;
		cin >> u >> v >> w;
		edge[u - 1].push_back(make_pair(w, v - 1));
		edge[v - 1].push_back(make_pair(w, u - 1));
	}
	set<int> s;
	s.insert(0);
	priority_queue < pair<long long, int>, vector < pair<long long, int>>, greater<pair<long long, int>>> pq;
	for (auto&& i : edge[0]) {
		pq.push(i);
	}
	while (pq.size()) {
		auto status = pq.top();
		pq.pop();
		if (s.count(status.second)) continue;
		s.insert(status.second);
		cost[status.second] = status.first;
		long long c = cost[status.second];
		for (auto&& i : edge[status.second]) {
			if (s.count(i.second)) continue;
			pq.push(make_pair(c + i.first, i.second));
		}
	}
	for (int i = 0; i < n; i++) {
		if (cost[i] % 2 == 0) {
			cout << "0\n";
		}
		else {
			cout << "1\n";
		}
	}
}


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


Measured memory_bytes: 13312
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        char[] d = Integer.toString(N).toCharArray();
        char last = d[d.length-1];
        HashMap<Character, String> map = new HashMap<>();
        map.put('2', "hon");
        map.put('4', "hon");
        map.put('5', "hon");
        map.put('7', "hon");
        map.put('9', "hon");
        map.put('0', "pon");
        map.put('1', "pon");
        map.put('6', "pon");
        map.put('8', "pon");
        map.put('3', "bon");

        System.out.println(map.get(last));
    }
}


Measured memory_bytes: 35840
fun main(args: Array<String>) {
    val (n,k)= readLine()!!.split(" ").map { it.toInt() }

    if(k==0){
        println(n*n.toLong())
        return
    }

    val ans = (1L..n).map { b ->
        n/b*Math.max(0,b-k) + Math.max(0,n%b-k+1)
    }.sum()

    println(ans)
}

Measured memory_bytes: 40680
N = int(input())
A = []
m = 0
for i in range(N):
    A.append(int(input()))
task = 0
m = max(A)
m2 = sorted(A)[-2]
maxindex = []
for i in range(N):
    if A[i] == m:
        print(m2)
    else:
        print(m)

Measured memory_bytes: 13404
#include<cstdio>
main(){int a,b,d=0,c;while(scanf("%d%d",&a,&b),a){d++&&puts("");for(c=0;a<=b;a++)if(a%4<1&&a%25||a%16<1)c++,printf("%d\n",a);if(!c)puts("NA");}}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
    int i,n,x[100],y[100];
    double p_1=0,p_2=0,p_3=0,p_0=0;
    
    scanf("%d",&n);

    for(i=0;i<n;i++) scanf("%d",&x[i]);
    for(i=0;i<n;i++) scanf("%d",&y[i]);

    for(i=0;i<n;i++){
        p_1+=abs(x[i]-y[i]);
        p_2+=pow(fabs( (double)x[i]-y[i] ),2.0 );
        p_3+=pow(fabs( (double)x[i]-y[i] ),3.0 );
        if( p_0<abs(x[i]-y[i]) ) p_0=abs(x[i]-y[i]);
    }

    printf("%lf\n%lf\n%lf\n%lf\n",p_1,pow(p_2,1.0/2),pow(p_3,1.0/3),p_0);

    return 0;
}



Measured memory_bytes: 2132
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[100005];

int main(int argc, char* argv[])
{
    long n, k;
    scanf("%ld%ld", &n, &k);

    scanf("%s", str);
    
    vector<long> z;
    long i;
    long one=(str[0]=='1'? 1:0);
    for(i=0; i<n; i++) {
        long k=i+1;
        while(k<n) {
            if(str[k]==str[i])
                k++;
            else break;
        }
        long cnt=k-i;
        //printf("%ld\n", cnt);
        z.push_back(cnt);
        i=k-1;
    }

    long siz=(long)z.size();

    vector<long> s(siz+1);
    s[0]=0;
    for(i=0; i<siz; i++) {
        s[i+1]=s[i]+z[i];
    }

    long mm=0;
    for(i=0; i<siz; i++) {
        if((i+one)%2==0) {
            long tmp = s[MIN(siz,i+2*k)]-s[i];
            mm = MAX(mm, tmp);
        }
        else {
            long tmp = s[MIN(siz,i+2*k+1)]-s[i];
            mm = MAX(mm, tmp);
        }
    }
    printf("%ld\n", mm);
 
    return 0;
}


Measured memory_bytes: 2036
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = (1..n).map { readLine()!!.first() }
        .filter { it in "MARCH" }.groupBy { it }.map { it.value.size.toLong() }

    var ans = 0L
    for (i in 0 until s.size-2) for (j in i+1 until s.size-1) for (k in j+1 until s.size) {
        ans += s[i]*s[j]*s[k]
    }
    println(ans)
}

Measured memory_bytes: 37536
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        if (n > m) {
            long tmp = m;
            m = n;
            n = tmp;
        }
        if (n == 1) {
            if (m == 1)
                System.out.println(1);
            else
                System.out.println(m - 2);
        } else {
            System.out.println((n - 2) * (m - 2));
        }
    }
}


Measured memory_bytes: 20948
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int maxNum = scan.nextInt();
		List<Integer> numArray = new ArrayList<Integer>();
		for(int i = 0; i < maxNum; ++i) {
			numArray.add(scan.nextInt());
		}
		scan.close();

		int count = 0;
		while(true) {
			boolean finishFlg = false;
			for(int i=0; i < numArray.size(); ++i) {
				// 2で割れるなら割って更新
				if(numArray.get(i) % 2 == 0) {
					numArray.set(i, numArray.get(i) / 2);
				} else {
					finishFlg = true;
					break;
				}
			}
			if(finishFlg) break;
			count++;
		}
		System.out.println(count);
	}
}


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

int main() {
	int a, b;
	cin >> a >> b;
	int c = a * b;
	if (c % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}
}

Measured memory_bytes: 256
a,b = map(int,raw_input().split(" "))

if a == b:
  print a
  exit(0)

x = bin(b)[2:]
l = len(x)

if a > 0: a = a - 1

aa = a%4
if aa == 1 or aa == 2: axor = "1"
else: axor = "0"
bb = b%4
if bb == 1 or bb == 2: bxor = "1"
else: bxor = "0"

for x in range(1,l):
  q = 2**(x+1)
  # pre = "0" * (2*x)
  # num = "10" * x
  ll = a % q
  if ll < (q/2): axor = "0" + axor
  else: 
    if a % 2 == 0: axor = "1" + axor
    else: axor = "0" + axor

  # pre = "0" * (2*x)
  # num = "10" * x
  ll = b % q
  if ll < (q/2): bxor = "0" + bxor
  else: 
    if b % 2 == 0: bxor = "1" + bxor
    else: bxor = "0" + bxor

if a == -1:
  print int(bxor,2)
else: 
  print int(axor,2) ^ int(bxor,2)



Measured memory_bytes: 2696
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>

const int kMaxTown = 21; //0?????????????????????
const int kInf = 1 << 16;

int d[kMaxTown];
int arrived[kMaxTown];
int cost[kMaxTown][kMaxTown];

void dijkstra(const int s, const int n){
	for (int i = 0; i < kMaxTown; i++) d[i] = kInf;
	for (int i = 0; i < kMaxTown; i++) arrived[i] = false;

	d[s] = 0;

	while (1){
		int minTown = 0;
		for (int i = 1; i <= n; i++)
			if (!arrived[i] && (d[i] < d[minTown]))
				minTown = i;
		if (minTown == 0) break;
		arrived[minTown] = true;
		for (int i = 1; i <= n; i++)
			d[i] = std::min(d[i], d[minTown] + cost[minTown][i]);
	}

}

int main(){

	for (int i = 0; i < kMaxTown; i++)
		for (int j = 0; j < kMaxTown; j++)
			cost[i][j] = kMaxTown;

	int n, m;
	scanf("%d", &n);
	scanf("%d", &m);
	for (int i = 0; i < m; i++){
		int a, b, c, d;
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		cost[a][b] = c;
		cost[b][a] = d;
	}
	int x1, x2, y1, y2;
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
	
	dijkstra(x1, n);
	y1 -= d[x2];
	dijkstra(x2, n);
	y1 -= d[x1];

	printf("%d\n", y1-y2);
}

Measured memory_bytes: 1028
import Control.Applicative

main :: IO ()
main = do
    [width, heigth, x, y, r] <- map (read::String->Int) . words <$> getLine
    putStrLn . yesno . circInRect $ (width, heigth, x, y, r)

type RectCirc = (Int, Int, Int, Int, Int)

circInRect :: RectCirc -> Bool
circInRect (w, h, x, y, r) =
    let xcond = x - r >= 0 && x + r <= w
        ycond = y - r >= 0 && y + r <= h
    in xcond && ycond

yesno :: Bool -> String
yesno b = if b then "Yes" else "No"

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

using namespace std;

int a[105];
bool dp[100005];

int main() {
    int n, k;
    scanf("%d%d", &n, &k);

    for (int i = 0; i < n; i++) scanf("%d", &a[i]);

    //0 = first win
    //
    
    dp[0] = 1;
    for (int i = 1; i <= k; i++) {
        bool flag = 0;
        for (int j = 0; j < n; j++) {
            if (i - a[j] >= 0) flag |= dp[i - a[j]];
        }
        dp[i] = !flag;
    }

    if (dp[k] == 0) printf("First\n");
    else printf("Second\n");
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll A;
  cin>>A;
  string B;
  cin>>B;
  ll B1 = (B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0');
  cout<<A*B1/100<<endl;
}



Measured memory_bytes: 3556
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return(false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return(true);
  }

  int find(int k)
  {
    if(data[k] < 0) return(k);
    return(data[k] = find(data[k]));
  }

  int size(int k)
  {
    return(-data[find(k)]);
  }

  bool same(int x, int y)
  {
      return find(x) == find(y);
  }
};

int main()
{
    vector<vector<int> > c(3);
    REP(i, 3) c[i].resize(3);
    REP(i, 3) REP(j, 3) cin >> c[i][j];
    for (int a1 = 0; a1 <= 100; ++a1)
    {
        int b[3] = {c[0][0] - a1, c[0][1] - a1, c[0][2] - a1};
        int a[3] = {c[0][0] - b[0], c[1][0] - b[0], c[2][0] - b[0]};
        bool ok = true;
        REP(i, 3)
        {
            REP(j, 3)
            {
                if (c[i][j] != (a[i] + b[j]))
                {
                    ok = false;
                    break;
                }
            }
            if (!ok)
            {
                break;
            }
        }
        if (ok)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();

//        int mm = -1;
//        if (m%5 == 0)
//        {
//            mm = m/5;
//        }

        double ans = 0.0D;
        if (h==0 && m==0)//短針と長針が重なっているときは (大)a-(小)b 長針or短針の値を合わせる
        {
            ans = Math.max(a,b) - Math.min(a,b);
            System.out.println(ans);
        }
        else
        {
            double kakudo1 = 30.0 * h + 0.5 * m;
            double kakudo2 = 6.0 * m;
            if (kakudo1 == 0) kakudo1 = 360.0;
            if (kakudo2 == 0) kakudo2 = 360.0;
            double kakudo3 = Math.max(kakudo1,kakudo2) - Math.min(kakudo1,kakudo2);
            double aa = Math.sqrt((Math.pow(a,2.0)) + (Math.pow(b,2.0)) - (2 * a * b * Math.cos(Math.toRadians(kakudo3))));
            System.out.println(BigDecimal.valueOf(aa));
        }
        sc.close();
    }
}

Measured memory_bytes: 36244
n = int(input())
s = input()
newlist = []
for ni in range(n):
    newlist.append([s[0:ni+1],s[ni+1:n]])
count = 0
for n in newlist:
    if len(set(n[0]) & set(n[1]))>count:
        count = len(set(n[0]) & set(n[1]))
print(count)

Measured memory_bytes: 3064
use std::io::stdin;
use std::str::FromStr;
use std::cmp::max;
use std::cmp::min;

fn main(){
    let (_n, m, v, p)  = {
        let v: Vec<usize> = get_vec();
        (v[0], v[1], v[2], v[3])
    };
    let mut xs: Vec<i64> = get_vec();
    xs.sort();
    xs.reverse();

    let s = p as i64 - 1;
    let u = max(0, v as i64 - s);
    let zs = &xs[s as usize..];

    let loc = solve_local(zs, u, m as i64) as i64;

    println!("{}", s + loc);
}

fn solve_local(zs: &[i64], v: i64, m: i64) -> usize {
    let ok = |i: usize| {
        let a = zs[i] + m;
        if a < zs[0] { return false };
        let sum: i64 = zs.iter().map(|z| min(a-z, m)).sum();
        if sum < v*m { return false };
        true
    };
    upper_bound(&ok, 0, zs.len()) + 1
}

fn upper_bound<F>(ok: &F, left: usize, right: usize) -> usize 
    where F: Fn(usize) -> bool {
    if left+1 >= right {
        return left;
    }
    let m = (left + right) / 2;
    if ok(m) {
        return upper_bound(ok, m, right);
    } else {
        return upper_bound(ok, left, m);
    }
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}

#[allow(dead_code)]
fn vec_min(xs: &Vec<i64>) -> i64 {
    xs.iter().map(|&x|x).fold(std::i64::MAX, std::cmp::min)
}

#[allow(dead_code)]
fn vec_max(xs: &Vec<i64>) -> i64 {
    xs.iter().map(|&x|x).fold(std::i64::MIN, std::cmp::max)
}

#[allow(dead_code)]
fn vec_sum(xs: &Vec<i64>) -> i64 {
    xs.iter().fold(0, |acc, &x| acc+x)
}


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

ans = 0
for i in range(N-2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            a, b, c = sorted([L[i], L[j], L[k]])
            if a == b or b == c or a == c:
                continue
            if a + b > c:
                ans += 1

print(ans)

Measured memory_bytes: 68784
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int n;cin>>n;

    VPII a(n);
    REP(i,n){
        cin>>a[i].first;
        a[i].second=i;
    }

    SORT_ASC(a);

    int result = 0;

    REP(i,n){
        if(i%2 != a[i].second%2){
            result++;
        }
    }
    cout<<result/2<<endl;

	return;
}

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

Measured memory_bytes: 1152
module ABC124

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_C

  ! constants for this <module>
  integer(kind=INT32), parameter, private :: len_string_max = 100000_INT32

  ! variables for this <module>
  character(len=len_string_max, kind=1) :: given_string
  character(len=len_string_max, kind=1) :: reference_0, reference_1
  integer  (kind=INT32)                 :: len_string
  integer  (kind=INT32)                 :: num_operations(0:1)

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_C

    ! variables for this <subroutine>
    integer(kind=INT32) :: itr

    ! STEP.01
    ! read out the given string
    read(unit=INPUT_UNIT, fmt='(A)') given_string

    ! STEP.02
    ! count up the number of operations
    len_string     = len_trim(given_string)
    num_operations = 0_INT32

    do itr = 1_INT32, len_string, 2_INT32
      reference_0(itr:itr) = '0'
      reference_1(itr:itr) = '1'
    end do

    do itr = 2_INT32, len_string, 2_INT32
      reference_0(itr:itr) = '1'
      reference_1(itr:itr) = '0'
    end do

    do itr = 1_INT32, len_string, 1_INT32
      if (given_string(itr:itr) .ne. reference_0(itr:itr)) num_operations(0) = num_operations(0) + 1_INT32
      if (given_string(itr:itr) .ne. reference_1(itr:itr)) num_operations(1) = num_operations(1) + 1_INT32
    end do

    ! STEP.04
    ! output the result
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') min(num_operations(0), num_operations(1))

    ! STEP.END
    return

  end subroutine task_C

end module ABC124


program main

  ! <module>s to import
  use, non_intrinsic :: ABC124

  ! require all variables to be explicitly declared
  implicit none

  call task_C

end program main

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define int long long

int n;
signed main() {
	cin >> n;
	double x[11]{};
	string u[11]{};
	for (size_t i = 0; i < n; i++)
	{
		cin >> x[i];
		cin >> u[i];
	}

	double sum = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (u[i] == "BTC") {
			sum += 380000.0 * x[i];
		}
		else {
			sum += x[i];
		}
	}

	cout << sum << endl;
}


Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    x, n = map(int, input().split())
    P = set(map(int, input().split()))
    diff = 0
    while 1:
        if not x - diff in P:
            print(x - diff)
            return
        if not x + diff in P:
            print(x + diff)
            return
        diff += 1
resolve()

Measured memory_bytes: 61940
#include <iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	while (N) {
		if (N % 10 == 7) {
			cout << "Yes" << endl;
			break;
		}
		N = N / 10;
	}
	if (N == 0) {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
import sys


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()))


def main():
    N = II()
    ac = 0
    wa = 0
    tle = 0
    re = 0
    for i in range(N):
        target = input()
        if target == "AC":
            ac += 1
        if target == "WA":
            wa += 1
        if target == "TLE":
            tle += 1
        if target == "RE":
            re += 1
    print("AC x "+str(ac))
    print("WA x "+str(wa))
    print("TLE x "+str(tle))
    print("RE x "+str(re))


# oj t -c "pypy3 main.py"
# acc s main.py -- --guess-python-interpreter pypy
main()


Measured memory_bytes: 69888
#include <stdio.h>
#include<math.h>
typedef long long int llint;

llint sum(llint n) {
	return n * (n + 1) / 2;
}

int main() {
	llint b;
	llint l, d, i, k;
	for (;;) {
		scanf("%lld", &b);
		if (b == 0) break;
		b *= 2;
		k = 0;
		for (i = 1; i <= sqrt(b); i++)
		{
			if (b % i == 0)
			{
				d = b / i;
				l = i;
				l--;
				l -= d;
				if (l < 0)
					continue;
				if (l % 2 == 1)
					continue;
				l /= 2;
				printf("%lld %lld\n", l + 1, d);
				k++;
				break;
			}
		}
		if (k > 0)
			continue;
		for (i = sqrt(b); i > 0; i--)
		{
			if (b % i == 0)
			{
				d = i;
				l = b / i;
				l--;
				l -= d;
				if (l < 0)
					continue;
				if (l % 2 == 1)
					continue;
				l /= 2;
				printf("%lld %lld\n", l + 1, d);
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2040
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

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

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 long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int n;
        cin >> n;
        if (n == 0) return;

        vector<int> v(n);
        rep(i, 0, n) cin >> v[i];
        sort(all(v));

        int ans = v[1] - v[0];
        for (int i = 0; i + 1 < n; ++i) {
            chmin(ans, v[i + 1] - v[i]);
        }
        cout << ans << endl;
        solve();
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}



Measured memory_bytes: 3148
#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<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
void radd(int &a, int b)
{
	a=add(a,b); 
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
void rmult(int &a, int b)
{
	a=mult(a,b);
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}
	
vi adj[222222];
int sub[222222];

void dfs(int u, int p=-1)
{
	sub[u]=1;
	for(int v:adj[u])
	{
		if(v==p) continue;
		dfs(v,u);
		sub[u]+=sub[v];
	}
}

int dp[222222];
int dpup[222222];
int ans[222222];

void dfs1(int u, int p)
{
	int prod=1;
	for(int v:adj[u])
	{
		if(v==p) continue;
		dfs1(v,u);
		prod=mult(prod,dp[v]);
		prod=mult(prod,ifact[sub[v]]);
	}
	prod=mult(prod,fact[sub[u]-1]);
	dp[u]=prod;
}
int par[333333];
int n; 
void dfs2(int u, int p)
{
	par[u]=p;
	for(int v:adj[u])
	{
		if(v==p) continue;
		//compute dpup[v]
		int totsiz = n-sub[v];
		dpup[v]=mult(dp[u],ifact[sub[u]-1]);
		dpup[v]=mult(dpup[v],inverse(dp[v]));
		dpup[v]=mult(dpup[v],fact[sub[v]]);
		if(u!=0)
		{
			dpup[v]=mult(dpup[v],dpup[u]);
			dpup[v]=mult(dpup[v],ifact[n-sub[u]]);
		}
		dpup[v]=mult(dpup[v],fact[totsiz-1]);
		dfs2(v,u);
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	init(333333);
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int u,v; cin>>u>>v; u--; v--;
		adj[u].pb(v); adj[v].pb(u);
	}
	dfs(0,-1);
	dfs1(0,-1);
	dfs2(0,-1);
	for(int i=0;i<n;i++)
	{
		int ans=fact[n-1];
		for(int v:adj[i])
		{
			if(v!=par[i])
			{
				ans=mult(ans,dp[v]);
				ans=mult(ans,ifact[sub[v]]);
			}
			else
			{
				ans=mult(ans,dpup[i]);
				ans=mult(ans,ifact[n-sub[i]]);
			}
		}
		cout<<ans<<'\n';
	}
}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll a, b;
  cin >> a >> b;
  cout << a * b << endl;
	return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  VI M;
  if(N==0) cout<<0<<endl;
  else{
    while(N!=0){
      if(N%2){
        N--;
        M.push_back(1);
      }else{
        M.push_back(0);
      }
      N/=(-2);
    }
    rep(i,M.size()) cout<<M[M.size()-1-i];
    cout<<endl;
  }
}


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


class Program {

	static long mod = 998244353;
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		//int res = 0; ;
		//int t = int.Parse(Console.ReadLine());
		//string str = Console.ReadLine();
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = int.Parse(Console.ReadLine());
		//string res="";

		long res = 0;
		//int n = int.Parse(Console.ReadLine());

		int[] vals = parseAry(Console.ReadLine().Split(cs));
		int y = vals[0];
		int x = vals[1];

		List<int[]> now = new List<int[]>();
		List<int[]> next = new List<int[]>();

		string strs = "";
		int[,] map = new int[y, x];
		for ( int i = 0; i < y; i++ ) {
			strs = Console.ReadLine();
			for ( int k = 0; k < strs.Length; k++ ) {
				if ( strs[k] == '#' ) { map[i, k] = '#'; now.Add(new int[] { i, k }); } else { map[i, k] = '.'; }
			}
		}

		int[,] nextmap =
			(int[,])map.Clone(); ;

		int[] DX = new int[4] { -1, 1, 0, 0 };
		int[] DY = new int[4] { 0, 0, -1, 1 };
		while (true ) {
			for ( int i = 0; i < now.Count; i++ ) {
				for ( int d = 0; d < DX.Length; d++ ) {
					int xx = now[i][1] + DX[d];
					int yy = now[i][0] + DY[d];
					if ( 0 <= yy && yy < y && 0 <= xx && xx < x ) {
						if ( map[yy, xx] == '.' ) {
							map[yy, xx] = '#';
							next.Add(new int[2] { yy, xx });
						}
					}
				}
			}
			res++;
			if ( next.Count == 0 ) { break; }
			now=new List<int[]>();
			for ( int i = 0; i < next.Count; i++ ) {
				now.Add((int[])next[i].Clone());
			}
			next = new List<int[]>();
		}


		res--;

		Console.WriteLine(res);


		return;

	}

	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 102404
#include <iostream>
#include <string>  
using namespace std;
int main(void){
    int a,b,c,d,e,k;
    string x;
    cin >> a >> b >> c >> d >> e >> k;
    if (e-a<=k){
        x="Yay!";
        cout << x;
    }
    else{
        printf("%s\n",":(");
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int ans = 0;
  int sum = 0;
  int right = 0;
  REP(left, N){
    while(right < N && (sum^A[right]) == sum+A[right]){
      sum += A[right];
      right++;
    }
    ans += right-left;

    sum -= A[left];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792