akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

constexpr int MAX = 1001;
long long fac[MAX], inv[MAX], finv[MAX];
void CombInit(){
    fac[0] = inv[0] = finv[0] = 1;
    fac[1] = inv[1] = finv[1] = 1;
    for(int i=2; i<MAX; ++i){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

long long Comb(int n,int k){
    if(n < 0 || k < 0 || n < k) return 0;
    return (fac[n] * finv[n-k] % MOD) * finv[k] % MOD;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    CombInit();
    cout <<  Comb(k, n) << '\n';
    return 0;
}


Measured memory_bytes: 3228
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,c;
long long f(long long k) {
	if (k<=5) return 1;
	long long ans,base=2;
	while (!k) {
		if (!(k&1)) ans*=base;
		if (abs(ans*(a-b))>1e18) return ans*(a-b);
		base*=base;
		k>>=1;
	}
	return ans;
}
int main() {

	long long k,x;
	scanf("%d%d%d%lld",&a,&b,&c,&k);
	if (!(k%2)) x=f(k)*(a-b);
	else x=f(k)*(b-a);
	if (x>1e18) printf("Unfair");
	else printf("%lld",x);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

struct UnionFind {
    
    vector < int > node;
    UnionFind(int n) : node(n, -1) {}
    
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (node[y] < node[x]) swap(x, y);
            node[x] += node[y];
            node[y] = x;
        }
        return x != y;
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    int root(int x) {
        return node[x] < 0 ? x : node[x] = root(node[x]);
    }
    
    int size(int x) {
        return -node[root(x)];
    }
    
};
/*
 usage:
 
 初期化:
 UnionFind  UF(N);//ノードの数
 unite(x,y);// xとyノード連結
 same(a,b);// aとbが同じ所属かどうかを判別
 root(a); //aのルートのノードを計算
 */

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N , M ;
    cin >> N >> M;
    
    UnionFind UF(N);
    
    rep(i, M){
        ll X, Y, Z;
        cin >> X >> Y >> Z;
        X--;Y--;
        UF.unite(X,Y);
    }
    
    vector<ll> ans ;
    rep(i, N){
        ans.pb(UF.root(i));
    }

    rmsame(ans);
    cout << ans.size() << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n;
pair<string,P>p[110];

void input(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p[i].fr>>p[i].sc.fr;
		p[i].sc.fr=-p[i].sc.fr;	
		p[i].sc.sc=i;
	}
	return;
}

void solve(){
	sort(p+1,p+n+1);
	for(int i=1;i<=n;i++){
		cout<<p[i].sc.sc<<endl;
	}
	return;
}

int main(){
	input();
	solve();
	return 0;
}

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

using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[100002] = {};
	int b[100002] = {};
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		b[i]=a[i];
	}
	//偶数回目の合計が正
	long long eve = 0,sum=0, odd = 0;;
	for (int j = 0; j < n; j++)
  {
		if (j % 2 == 0 && sum + a[j] <=0) {
			eve += abs(a[j]+ sum)  + 1;
			a[j] = abs(sum) + 1;
		}

		if (j % 2 == 1 && sum +a[j] >=0) {
			eve += a[j] + sum + 1;//+1っていうのは0を隔てるから
			a[j] = -abs(sum)-1;
		}
    /*//1 -3 1 0
    //1 -2 -1 -1 sum
           |
            ->eve = abs(1+ -2) + 1 = 1+1=2
            -> a[2] =abs(-2) + 1 = 2 + 1 = 3
            ->sum = sum(=-2) + 3 = 1  <--偶数になった!*/

            /* 0
               |
               -> eve = eve(=2) + a[3](=0) + sum(=1) + 1 */
            // -> a[3] = -abs(1)-1 = -2;
		sum += a[j];

		//cout << a[j] << " " <<eve << " " <<sum << endl;
	}
	//cout << endl;
	//奇数回目が正
	sum = 0;
	for (int k = 0; k < n; k++) {
		if (k % 2 == 0 && sum + b[k] >= 0) {
			odd += abs(b[k] + sum) + 1;
			b[k] = -abs(sum) - 1;

		}
		if (k % 2 == 1 && sum + b[k] <= 0) {
			odd += abs(sum + b[k]) + 1;
			b[k] = abs(sum) + 1;
		}
		sum += b[k];
		//cout << b[k] << " " <<odd << " " << sum<<endl;
	}
	//cout << endl;
	cout << min(odd, eve) << endl;
}


Measured memory_bytes: 1024
n,m = (int(i) for i in input().split())
ac=0
pe=0
p = [0]*(n+1)
a = [0]*(n+1)
for i in range(m):
	x,y = input().split()
	x = int(x)
	if y=="AC":
		a[x]=1
	elif not a[x]: p[x]+=1
ac = sum(a)
pe = sum(p[i] for i in range(n+1) if a[i])
print(ac, pe)


Measured memory_bytes: 4596
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int x = Integer.parseInt(sc.next()) - Integer.parseInt(sc.next());
		System.out.println(x % Integer.parseInt(sc.next()));
	}
}


Measured memory_bytes: 35464
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  vector<int> x(1);

for(int i = 1;i < a+1;i++){
  int m = x.size();
  
  if(m == 1){
    if(x.at(0) == 9){x.at(0) = 1;x.push_back(0);}
    else{x.at(0)++;}
    continue;}
    else{
      int ss = 0;
  for(int j = m-1;j > 0;j--){
    if(x.at(j-1) >= x.at(j) && x.at(j) != 9){x.at(j)++;ss = 1;
                  for(int k = j;k < m-1;k++){
                    if(x.at(k) == 0){x.at(k+1) = 0;}
                    else{x.at(k+1) = x.at(k)-1;}
                  }
                               break;}}
        
      if(ss == 0){x.at(0)++;
                  
                 if(x.at(0) == 10){x.at(0) = 1;
                                   x.push_back(0);}
     
        for(int j = 1;j < m;j++){
         if(x.at(j-1) == 0){x.at(j) = 0;}
                    else{x.at(j) = x.at(j-1)-1;}
        }
                  
        }
      } 

    }
  int v = x.size();
  for(int i = 0;i<v;i++){
    cout << x.at(i);}
  cout << endl;}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $H, $W);
$d1 = $d2 = $d3 = $d4 = [];
$ans = 0;
$rest = $H * $W;

for ($y = 0; $y < $H; $y++) {
    $m[$y] = str_split(trim(fgets(STDIN)));
}

for ($x = 0; $x < $W; $x++) {
    for ($y = 0; $y < $H; $y++) {
        if ($m[$y][$x] == "#") {
            $s[$y][$x] = 1;
            $a[$y][$x] = 1;
            $rest--;
        }
    }
}

while($rest > 0) {
    $ans++;
    // echo $rest . PHP_EOL;
    $new_a = [];
    foreach ($a as $y => $v) {
        foreach ($v as $x => $dummy) {
            if ($x != 0) {
                if (!isset($s[$y][$x-1])) {
                    $new_a[$y][$x-1] = 1;
                    $s[$y][$x-1] = 1;
                    $rest--;
                }
            }
            if ($x != $W - 1) {
                if (!isset($s[$y][$x+1])) {
                    $new_a[$y][$x+1] = 1;
                    $s[$y][$x+1] = 1;
                    $rest--;
                }
            }
            if ($y != 0) {
                if (!isset($s[$y-1][$x])) {
                    $new_a[$y-1][$x] = 1;
                    $s[$y-1][$x] = 1;
                    $rest--;
                }
            }
            if ($y != $H - 1) {
                if (!isset($s[$y+1][$x])) {
                    $new_a[$y+1][$x] = 1;
                    $s[$y+1][$x] = 1;
                    $rest--;
                }
            }
        }
    }
    $a = $new_a;
}

echo $ans;


Measured memory_bytes: 182776
s = input()
def solve(query):
    while 1:
        for frag in ("erase", "eraser", "dream", "dreamer"):
            if query.endswith(frag):
                query = query[:-len(frag)]
                break
        else:
            print("NO")
            break
        if not query:
            print("YES")
            break

solve(s)

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
typedef double db;
const ll N=6e5+7;

ll d[N],M;
db t[N];
int n;

inline ll max(ll a,ll b)
{return a>b?a:b;}

inline ll read()
{
	ll o=0; char ch=' ';
	for(;ch<'0'||ch>'9';ch=getchar());
	for(;ch>='0'&&ch<='9';ch=getchar())o=o*10+ch-48;
	return o;
}

int main()
{
	cin>>n>>M;
	int r=0,l=1,ok=0;
	db zl=0; 
	fo(i,1,n)
	{
		ll T=read(),V=read();
		d[++r]=V; t[r]=(db)T*V;
		zl+=t[r]; ok+=d[r];
		for(;t[r]/d[r]<t[r-1]/d[r-1]&&l<r;--r)
		if(d[r-1]+d[r]<=M)t[r-1]=t[r-1]+t[r],d[r-1]+=d[r];
		else{
			t[r-1]=t[r]+(t[r-1]/d[r-1])*(M-d[r]);
			ok=d[r-1]=M; zl=t[r-1]; --r; l=r;
			break;
		}
		for(;ok>M;++l)
		if(ok-d[l]>=M)ok-=d[l],zl-=t[l];
		else{
			db every=t[l]/d[l];
			zl-=every*(ok-M);
			t[l]-=every*(ok-M);
			d[l]=d[l]-(ok-M);
			ok=M; break;
		}
		printf("%.7lf\n",zl/M);
	}
}

Measured memory_bytes: 17664
#include <stdio.h>
#include <stdlib.h>

int gcd(int x, int y)
{
    int common_divisor;

    if(x < y)
    {
        int tmp = x;
        x = y;
        y = tmp;
    }

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

int main(void)
{
    int x, y;

    scanf("%d%d", &x, &y);
    printf("%d\n", gcd(x, y));
    return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define nd second
#define st first
#define pb push_back
#define pa make_pair

using namespace std;
typedef long long int lo;

lo a,b,c,d,e,g,h[500005],arr[500005];

int main(){
	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
	cin >> a >> b;
	if((a+b)%2){
		cout << "IMPOSSIBLE";
	}
	else 
		cout << (a+b)/2; 
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n;
	scanf("%d",&n);
	
	int v[100];
	
	for(int i=0; i<n; i++) {
		scanf("%d",&v[i]);
	}
	
	for(int i=0; i<n; i++){
		printf("%d",v[n-1-i]);
		if(i !=n-1){
			printf(" ");
		}
		
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 2684
import sys
from collections import deque

n,m = map(int, sys.stdin.readline().rstrip("\n").split())
bridges = [[] for _ in range(n)]
done = [False]*n
for _ in range(m):
    a,b = map(int, sys.stdin.readline().rstrip("\n").split())
    bridges[a-1].append(b-1)
    bridges[b-1].append(a-1)
d = deque()
ans = -1
for i in range(n):
    if not done[i]:
        done[i] = True
        d.append(i)
        while d:
            cp = d.pop()
            for np in bridges[cp]:
                if not done[np]:
                    done[np] = True
                    d.append(np)
        ans += 1
print(ans)

Measured memory_bytes: 80924
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.array;

long[] read_nums() {return readln.strip.chomp.split(" ").map!(to!(long)).array;}

void main() {
  while(true) {
    long[] data = read_nums;
    long people = data[0];
    long kinds = data[1];
    if (people == 0 && kinds == 0) break;
    long[] limit = read_nums;
    long[] sum = new long[](kinds);
    bool ans = true;
    foreach(i; 0..people) {
      long[] line = read_nums;
      foreach(long j, x; line) {
        sum[j] += x;
      }
    }
    for(long i = 0; i < sum.length; i++) {
      if (sum[i] > limit[i]) {
        ans = false;
        break;
      }
    }
    writeln(ans ? "Yes" : "No");
  }  
}

Measured memory_bytes: 2024
let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
var a=arr[0]
var b=arr[1]
var c=arr[2]
var x = 0
 
x = a
a = b
b = x
 
x = a
a = c
c = x
print(String(a))
print(String(b))
print(String(c))

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

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

  int ans = 0;
  for (int i = 1; i < 33; i++) {
    for (int j = 2; j < 10; j++) {
      int n = pow(i, j);
      if (n <= X && ans < n) ans = n;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>

#include <boost/algorithm/string/predicate.hpp>

using namespace std;

#if 0
// memo
abs()

start_with(str, "hoge");
ends_with(str, "hoge");

std::sort(d.begin(), d.end());
d.erase(std::unique(d.begin(), d.end()), d.end());
#endif

using namespace boost;
using namespace boost::algorithm;

static inline bool isOdd(int v)
{
    return v & 0x01;
}

int main()
{
    long long N, K;
    scanf("%lld%lld", &N, &K);

    if (K == 0) {
        cout << (N*N) << endl;
        return 0;
    }

    long long c = 0;
    for (long long b = K + 1; b <= N; ++b) {
        long long P = N / b;
        long long Q = N % b;

        c += (b - K) * P;

        c += max(0LL, Q - K + 1);
        #if 0
        if (Q >= K) {
            c += Q - K + 1;
        }
        #endif
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int m,n,aa[110000][10],k,cnt=0,ab[10];
pair<int,int> p[220000];
string s,ss[220000],x;
char c;
signed main(){
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]){
        cout<<"No";
    }else{
        cout<<"Yes";
    }
}

Measured memory_bytes: 1920
n,m = [int(i) for i in input().split()]
a = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
	a[i] = [int(j) for j in input().split()]
b = [0 for i in range(m)]
for i in range(m):
	b[i] = int(input())
for i in range(n):
	sum = 0
	for j in range(m):
		sum += a[i][j] * b[j]
	print(sum)

Measured memory_bytes: 7788
#include <bits/stdc++.h>
using namespace std;
char s[22];
int n;
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    int sum=0;
    for(int i=1;i<=n;i++) sum+=s[i]-'0';
    printf("%d\n",max(sum,(n-1)*9+s[1]-'0'-1));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int abs( int a, int b)
  {
          if(  a > b)
              return a-b;
         return b-a;
}
int main()
{
   int x,a,b;
  cin>>x>>a>>b;
  if(  abs( x-a)  > abs( x-b))
          cout<<"B"<<endl;
   else
         cout<<"A"<<endl;
     return 0;
}

Measured memory_bytes: 256
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int H = nextInt();
        println((int)Math.ceil((double)H/nextInt()));
    }

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

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

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stdio.h>
using namespace std;

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

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 4000000000; //4*10^9;
constexpr auto MOD = 1000000007; //10^9+7;



int main()
{
    int k,x;
    cin >> k >> x;

    if (500 * k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for (;;) {
			int n = sc.nextInt(), m = sc.nextInt();
			if ((n|m) == 0) break;
			
			UF uf = new UF(n);
			PriorityQueue<E> q = new PriorityQueue<E>();
			for (int i=0;i<m;i++) q.add(new E(sc.nextInt(), sc.nextInt(), sc.nextInt()));
			
			int c = 0;
			for (;! q.isEmpty();) {
				E cur = q.remove();
				if (uf.same(cur.f, cur.t)) continue;
				uf.unite(cur.f,  cur.t);
				c += cur.c;
			}
			
			System.out.println(c);
		}
	}
	
	class E implements Comparable<E> {
		int f, t, c;
		E(int f, int t, int c) {
			this.f = f;
			this.t = t;
			this.c = c;
		}
		
		@Override
		public int compareTo(E o) {
			// TODO ティツ?ェテ・ツ仰陛ァツ板淌ヲツ按静」ツ?陛」ツつ古」ツ?淌」ツδ。テ」ツつステ」ツδε」ツδ嘉」ツδサテ」ツつケテ」ツつソテ」ツδ?
			return c - o.c;
		}
		
	}
	
	class UF {
		int[] par, rank;
		
		public UF(int n) {
			par = new int[n];
			rank = new int[n];
			for(int i=0;i<n;i++) par[i] = i;
		}
		
		//テ、ツサツ」ティツ。ツィテ・ツ?ε」ツつ津ヲツアツづ」ツつ?」ツつ?
		int find(int x) {
			if( par[x] == x ) return x;
			return par[x] = find(par[x]);
		}
		
		//ティツヲツ?ァツエツ?テ」ツ?ィyテ」ツつ津、ツスツオテ・ツ青暗」ツ?凖」ツつ?
		void unite(int x, int y) {
			x = find(x);
			y = find(y);
			if( x == y ) return;
			
			if( rank[x] < rank[y]  ) par[x] = y;
			else {
				par[y] = x;
				if( rank[x] == rank[y] ) rank[x]++;
			}
		}
		
		//テ・ツ青古、ツクツ?」ツ?ョテゥツ崢?・ツ青暗」ツ?ォテ・ツ青ォテ」ツ?セテ」ツつ古」ツつ凝」ツ?凝ィツェツソテ」ツ?ケテ」ツつ凝ッツシツ師rueテ」ツ?ェテ」ツつ悦テ」ツ?ィyテ」ツ?ッテ・ツ青古」ツ?佚ゥツ崢?・ツ青暗ッツシツ掲alseテ」ツ?ェテ」ツつ嘉ァツ閉ーテ」ツ?ェテ」ツつ?
		boolean same(int x, int y) {
			return find(x) == find(y);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 21428
n, m = gets.chomp.split.map(&:to_i)
sw = []

m.times do
  _, *s = gets.chomp.split.map(&:to_i)
  sw << s
end

p = gets.chomp.split.map(&:to_i)
res = 0

0.step(2 ** n - 1) do |b| # n が小さいのでbit全探索
  on = 0
  m.times do |i|
    break if sw[i].map {|x| b & (1 << (x - 1)) }.count {|x| x > 0 } % 2 != p[i]
    on += 1
  end
  if on == m
    res += 1
  end
end
puts res

Measured memory_bytes: 14436
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    cnt_P = 0
    cnt_N = 0

    for i in range(N):
        diff = B[i]-A[i]
        if diff>0:
            cnt_P += diff//2
        elif diff<0:
            cnt_N += -diff

    if sum(A)<=sum(B) and cnt_P>=cnt_N:
        ret = 'Yes'
    else:
        ret = 'No'

    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10352
#1_10_D
S = []
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
for i in range(1,4):
    s = 0
    for j in range(n):
        a = abs(x[j] - y[j])
        S.append(a)
        s += a ** i
    D = s ** (1/i)
    print('{:.06f}'.format(D))
print('{:.06f}'.format(max(S)))


Measured memory_bytes: 5648
#include<stdio.h>                                                                                                                                                                                           
#include<memory.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(void){
        int a,b;

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

        if(a - b*2 >= 0){ 
            printf("%d\n",a-b*2);
        }else{
            printf("0\n");
        }   
        return 0;
}


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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N, 0));
    for(int i=0;i<N;i++) cin >> A[0][i];
    for(int i=0;i<N;i++) cin >> A[1][i];

    int m = 0;
    for(int j=0;j<N;j++){
        int c = 0;
        for(int i=0;i<N;i++){
            if(i < j) c += A[0][i];
            else if(i == j) c+= A[0][i]+A[1][i];
            else c += A[1][i];
        }
        m = max(m, c);
    }

    cout << m << endl;
    
    return 0;
}

Measured memory_bytes: 256
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* It does not matter how slowly you go as long as you do not stop.*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 1005;



int32_t main(){
    FAST;

   int n;   cin >> n;
   cout << "ABC" << n << endl;

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<int,int>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 998244353;
inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

ld n,m,d;
int main(){
   cin>>n>>m>>d;

   ld ans=(m-1)*2*(n-d)/n/n;
   if(d!=0)printf("%.10Lf\n",ans);
   if(d==0)printf("%.10Lf\n",ans/2);

}

Measured memory_bytes: 3768
//
// Created by yuu on 2019-08-04.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;


int main(void){
    int A,B,C;
    cin>>A>>B>>C;


    if(B+C-A<0){
        cout<<0<<endl;
    } else{
        cout<<B+C-A<<endl;

    }

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    static long sum;
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sum += Long.valueOf(s);
        
        int plusNum = s.length() - 1;
        for(int i = 1; i <= plusNum; i++)
            dfs(s, i, 0, 0);
            
        System.out.println(sum);
    }
    
    private static void dfs(String s, int plusNum, int idx, long curSum) {
        if(plusNum == 0) {
            sum += Long.valueOf(s.substring(idx)) + curSum;
            return;
        }
        for(int i = idx; i < s.length() - plusNum; i++) {
            dfs(s, plusNum - 1, i + 1, curSum + Long.valueOf(s.substring(idx, i + 1)));
        }
    }
}

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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

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

const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;

vector< int > g[N];
int n, m, s[N], t[N];
bool used[N], deg[N];
map<int, int> e[N];
void dfs(int v, int pr = -1){
	used[v] = 1;
	for(auto to : g[v]){
		if(pr == to)
			continue;
		if(used[to]){
			if(e[to][v] == 0 && e[v][to] == 0){
				e[v][to] = 1;
				deg[v] ^= 1;
			}
		}else{
			dfs(to, v);
			if(deg[to])
				e[to][v] = 1, deg[to] ^= 1;
			else
				e[v][to] = 1, deg[v] ^= 1;
		}	
	}
}
int main()
{
	scanf("%d%d", &n, &m);
	if(m & 1){
		printf("-1");
		return 0;
	}

	for(int i = 0; i < m; i++){
		scanf("%d%d", &s[i], &t[i]);
		g[s[i]].pb(t[i]);
		g[t[i]].pb(s[i]);
	}
	dfs(1);
	for(int i = 0; i < m; i++){
		if(e[s[i]][t[i]] == 0)
			swap(s[i], t[i]);			
		printf("%d %d\n", s[i], t[i]);
	}
		
	return 0;
}


Measured memory_bytes: 36992
/* SmartCoder Apr 7, 2019 */
#include <bits/stdc++.h>
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end();i++)
#define present(c,x)  ( (c).find(x) !=(c).end())
#define cpresent(c,x) (find(all(c),x)!= (c).end() )
#define minei(x)  min_element(x.begin(),x.end())-(x).begin()
#define maxei(x)  max_element(x.begin(),x.end())-(x).begin()

#define uns(v)     sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())
#define acusum(x)  accumulate(x.begin(),x.end(),0)
#define acumul(x)  accumulate(x.begin(),x.end(),1, multiplies<int>());
#define bits(x)     __builtin_popcount( x )
#define oo INT_MAX
#define inf 1000000000

const double pi = acos(-1.0);
const double eps = 1e-11;
#define MAXN 3003
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
void fastIO() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
string s, t;
int dp[MAXN][MAXN];
pair<int, int> par[MAXN][MAXN];
int main() {
	fastIO();
	cin >> s >> t;
	s = " " + s;
	t = " " + t;
	int n = sz(s);
	int m = sz(t);
	for (int i = 0; i < n; i++) {

		for (int j = 0; j < m; j++) {
			if (i == 0 || j == 0) {
				dp[i][j] = 0;
				continue;
			}
			if (s[i] == t[j] && dp[i - 1][j - 1] + 1 >= dp[i - 1][j] && dp[i - 1][j - 1] + 1 >= dp[i][j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
				par[i][j] = mp(i - 1, j - 1);
			} else if (dp[i][j - 1] > dp[i - 1][j]) {
				dp[i][j] = dp[i][j - 1];
				par[i][j] = mp(i, j - 1);
			} else {
				dp[i][j] = dp[i - 1][j];
				par[i][j] = mp(i - 1, j);
			}
		}

	}
	string res = "";
	int i = n - 1, j = m - 1;
	while (i != 0 && j != 0) {

		if (s[i] == t[j]) {
			res += s[i];
		}
		int ii = i;
		int jj = j;
		i = par[ii][jj].first;
		j = par[ii][jj].second;
	}
	reverse(all(res));
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 105984
from math import sin, cos, radians


def c(l, p1, p2):
    l -= 1
    if l < 0:
        return
    s = ((p1[0] * 2 + p2[0]) / 3, (p1[1] * 2 + p2[1]) / 3)
    c(l, p1, s)
    print(s[0], s[1])
    t = ((p1[0] + p2[0] * 2) / 3, (p1[1] + p2[1] * 2) / 3)
    dx = t[0] - s[0]
    dy = t[1] - s[1]
    u = (dx * c60 - dy * s60 + s[0], dx * s60 + dy * c60 + s[1])
    c(l, s, u)
    print(u[0], u[1])
    c(l, u, t)
    print(t[0], t[1])
    c(l, t, p2)


r = radians(60)
s60 = sin(r)
c60 = cos(r)
print(0, 0)
c(int(input()), (0, 0), (100, 0))
print(100, 0)



Measured memory_bytes: 5780
#include <bits/stdc++.h>
#define pb push_back
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define ld double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007

#define par pair<int, int>
#define maxn 200005

using namespace std;
///All indexing is 0-based
using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

int cont;
char a[1001];


int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> a;
    int l = strlen(a);
    for(int i=0;i<l/2;i++)
        if(a[i]!=a[l-i-1])
            cont++;

    cout << cont;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  int k,t,a,ans=0;
  cin>>k>>t;
  fr(i,t){
    cin>>a;
    if(a>(k+1)/2) ans=2*a-k-1;
  }
  cout<<ans<<endl;
}

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

const int N = 100001;
const int infi = (int)((1ll << 31) - 1);


int n = 1;
int dat[N * 4];

void init(int _n){
	while(n < _n)n *= 2;
	for(int i = 0; i < 2 * n - 1; ++i)dat[i] = infi;
}

void update(int k, int x){
	k += n - 1;
	dat[k] = x;
	while(k > 0){
		k = (k - 1) / 2;
		dat[k] = std::min(dat[2 * k + 1], dat[2 * k + 2]);
	}
}

int rec(int a, int b, int k, int l, int r){
	if(b <= l || r <= a)return infi;
	if(a <= l && r <= b)return dat[k];
	else return std::min(rec(a, b, 2 * k + 1, l, (l + r) / 2),
				rec(a, b, 2 * k + 2, (l + r) / 2, r)); 
}

int query(int a, int b){
	return rec(a, b, 0, 0, n);
}

int main(){
	int _n, q;
	std::cin >> _n >> q;
	
	init(_n);
	
	for(int i = 0; i < q; ++i){
		int c, x, y;
		std::cin >> c >> x >> y;
		
		if(c == 0)update(x, y);
		else std::cout << query(x, y + 1) << std::endl;
	}

	return 0;
}

Measured memory_bytes: 4112
#include <bits/stdc++.h>
#define raul(x) (x)*(x)
using namespace std;

int raulfat(int i) {
  return i == 0 ? 1 : i*raulfat(i-1);
}
int main() {
  int n;
  cin >> n;
  double entrada;
  vector<int> x; vector<int> y;
  vector<int> caminho;
  for (int i = 0; i < n; i++) caminho.push_back(i);

  for (int i = 0; i < n; i++) {
    cin >> entrada;
    x.push_back(entrada);
    cin >> entrada;
    y.push_back(entrada);
  }

  int fatorial = raulfat(n);
  double soma = 0.0;
  for (int i = 0; i < fatorial; i++) {
    //calcula distancias
    for (int k = 0; k < n-1; k++) {
      soma += sqrt(raul(x[caminho[k]]-x[caminho[k+1]]) + raul(y[caminho[k]]-y[caminho[k+1]]));
    }
    //prox. permut.
    next_permutation(caminho.begin(), caminho.end());
  }
  printf("%lf\n", soma/fatorial);


  return 0;}


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

p = []
cnt = 0
while N % 2 == 0:
	cnt += 1
	N = N // 2
if cnt > 0:
	p.append(cnt)

t = 3
while N >= t and t <= 10**6:
	cnt = 0
	while N % t == 0:
		cnt += 1
		N = N // t
	if cnt > 0:
		p.append(cnt)
	t += 2

if N > 10**6:
	p.append(1)

ans = 0
for c in p:
	a = int((-1 + pow(1+8*c, 0.5))/2)
	ans += a
print(ans)

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    ll N, K; cin >> N >> K;
    ll A[N],F[N];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> F[i];
    sort(A, A+N); sort(F, F+N);
    reverse(F, F+N);
    //スコアXはたかだか10^12, スコアXについてそれが実現できるかをにぶたん
    ll ng = -1, ok = (ll) pow(10, 12);
    ll m = (ng + ok)/2;
    while(abs(ng-ok) > 1){
        ll cnt = 0;
        rep(i, N){
            //A[i]*F[i] <= mにする
            //必要な回数の最小値をkとすると, A[i]*F[i] - kF[i] <= m  ->  k >= A[i] - m/F[i]
            cnt += max(0ll, A[i] - m/F[i]);
        }
        if(cnt > K) ng = m;
        else ok = m;
        m = (ng + ok)/2;
    }
    cout << ok << endl;
/*
    if(K >= pow(10, 12)) cout << 0 << endl;
    else{
        
    }
*/
    return 0;
}

void solve(){}

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<bool> a (n+1,true);
    for(int i=0; i<m; i++){
        int x;
        cin >> x;
        a.at(x) = false;
    }
    vector<ll> dp (n+1);
    dp.at(0) = 1;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<=min(n,i+2); j++){
            if(a.at(j)){
                dp.at(j) += dp.at(i);
                dp.at(j) %= 1000000007;
            }
        }
    }
    cout << dp.at(n) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int main () {
    long long int   n,x,t=-1;
    cin>>n>>x;
    long long int a[n];
    for (long long int i=0;i<n;i++) cin>>a[i];
    sort (a,a+n);
    for (long long int i=0;i<n;i++) {
        if (a[i]>=x) {t=i;break;}
    }
    if (t==-1) cout<<"0"<<endl;
    else cout<<(n-t)<<endl;
}

Measured memory_bytes: 1024
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# import sys
# sys.setrecursionlimit(10**9)

def resolve():
    s = str(input())
    t = str(input())


    # 文字列S, Tのlongest common subsequenceを返す
    # なお、longest common substringではない
    # （要素同士がとなりあっていなくてもいい）ことに注意！
    def lcs(S, T):
        # 初期化
        dp = [[0] * (len(T) + 1) for j in range(len(S) + 1)]

        # dp[i][j]はS[:i]とT[:j]のlcsの長さを表す
        for i in range(len(S)):
            for j in range(len(T)):
                # その前までの値引き継ぎ
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j])
                # 望まれたニューカマーが来たら足す
                if S[i] == T[j]:
                    dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)

        # If you want to know just the length of the lcs, return dp[i + 1][j + 1].
        # Here we'll try to print the lcs.

        lcs_str = ''
        i, j = len(S)-1, len(T)-1
        while i >= 0 and j >= 0:
            if S[i] == T[j]:
                lcs_str += S[i]
                i -= 1
                j -= 1
            else:
                if dp[i][j+1] > dp[i+1][j]:
                    i -= 1
                else:
                    j -= 1

        return lcs_str[::-1]

    print(lcs(s, t))


resolve()

Measured memory_bytes: 112220
#include<bits/stdc++.h>
using namespace std;
#define M 55
#define ll long long
int n,p,A[M];
ll dp[M][2],ans;
int main(){
	scanf("%d%d",&n,&p);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		int s=A[i]&1;
		dp[i][0]=dp[i-1][0];
		dp[i][1]=dp[i-1][1];
		dp[i][0^s]+=dp[i-1][0];
		dp[i][1^s]+=dp[i-1][1];
	}
	printf("%lld\n",dp[n][p]);
	return 0;
}

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

int main(void)
{
    string s,t;
    cin >> s >> t;
    int min_sub = 1000;
    for(int i=0;i<int(s.size()-t.size()+1);i++)
    {
        int temp = 0;
        for(int j=0;j<int(t.size());j++)
        {
            if(t[j]!=s[i+j])temp++;
        }
        if(temp<min_sub)min_sub =temp;
    }
    cout << min_sub;
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
string s="";
int main(){
	char c;
	int len=0;
	while(cin>>c){
		if(len==0&&c=='B') continue;
		switch(c){
			case '0':s+='0',len++;break;
			case '1':s+='1',len++;break;
			case 'B':s.erase(s.size()-1,1),len--;break;
		}
	}
	cout<<s<<"\n";
	exit(0);
} 

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func sum(x int) int {
	ret := 0
	for x > 0 {
		ret += x % 10
		x /= 10
	}
	return ret
}

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	ans := 0
	for i := 1; i <= n; i++ {
		x := sum(i)
		if a <= x && x <= b {
			ans += i
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,A[100001];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	if(n&1){
		puts("0");
		return 0;
	}
	sort(A+1,A+n+1);
	int t=n>>1;
	printf("%d\n",A[t+1]-A[t]);
}

Measured memory_bytes: 640
s = gets.chomp.split("")
t = gets.chomp.split("")
hash_s = Hash.new(0)
hash_t = Hash.new(0)
s.each do |i|
    hash_s[i] += 1
end
t.each do |j|
    hash_t[j] += 1
end
hash_s =  hash_s.sort
hash_t =  hash_t.sort
s_size = hash_s.size
t_size = hash_t.size
if s_size == 1 && t_size == 1
    puts hash_s[0][1] < hash_t[0][1] ? "Yes" : "No"
else
    if hash_s[0][0] >= hash_t[-1][0]
        puts "No"
    else
        puts "Yes"
    end
end

Measured memory_bytes: 14336
import numpy as np

# 2つの整数の入力
N, L = map(int, input().split())

# 味を数列化
taste = np.arange(L, L + N, 1)

# 味の最小・最大ともに0以上の場合は最小値を選ぶ
if np.min(taste) >= 0 and np.max(taste) >= 0:
  print("{}".format(np.sum(taste) - np.min(taste)))

# 味の最小・最大ともに0以下の場合は最大値を選ぶ
elif np.min(taste) <= 0 and np.max(taste) <= 0:
  print("{}".format(np.sum(taste) - np.max(taste)))

# それ以外の場合は0を選ぶ
else:
  print("{}".format(np.sum(taste)))

Measured memory_bytes: 12508
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

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

    int n;
    cin >> n;
    n--;
    ll ans = 0;

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

    cout << ans << endl;

    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    for(auto& e : a) cin >> e;
    for(auto& e : b) cin >> e;
    
    for (int i = 0; i < n-m+1; i++) {
        for (int j = 0; j < n-m+1; j++) {
            size_t idx = a[i].find(b[0], j);
            if (idx == string::npos) continue;
            
            bool flg = true;
            for (int k = 1; k < m; k++) {
                if (a[i+k].find(b[k], j) != idx) {
                    flg = false;
                    break;
                }
            }
            if (flg) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <set>
using namespace std;

int main(void) {
  int i, j, k, n;
  scanf("%d", &n);
  int a[n];
  multiset<int> s;
  for(i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    if(i & 1) s.insert(a[i]);
  }
  sort(a, a + n);
  for(i = 1; i < n; i += 2) if(s.find(a[i]) != s.end()) s.erase(s.find(a[i]));
  printf("%d", s.size());
  return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int n;
	cin >> n;
	int cnt = 0;
	int theta = MOD;
	rep(i, n) {
		int a;
		scanf("%d", &a);
		int alpha = theta;
		theta = min(theta, a);
		if (alpha != theta) ++cnt;
	}
	cout << cnt;
}



Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    ll cnt = 0;
    bool f = false;
    while(cnt != k){
        if(!f){
            if(a % 2){
                a--;
            }
            b += a / 2;
            a /= 2;
        }else{
            if(b % 2){
               b--;
            }
            a += b / 2;
            b /= 2;
        }
        f = !f;
        cnt++;
    }
    print(a << " " << b);
}


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

using namespace std;

#define FaSt ios::sync_with_stdio(0),cin.tie(0);
#define random uniform_int_distribution<long long>(1, 2000000000000000LL)(rng)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * ((uint64_t) new char | 1));

const int N = 100005;
int n, a[N];
vector<int> v;
vector<int> ans;

int main() 
{
    FaSt
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        v.push_back(a[i]);
    }
    
    for (int i = 0; i < n; i++)
    {
        int idx = -1;
        for (int j = 0; j < v.size(); j++)
        {
            if (v[j] == j + 1)
            {
                idx = j;
            }
        }
        if (idx == -1)
        {
            cout << -1;
            return 0;
        }
        v.erase(v.begin() + idx);
        ans.push_back(idx);
    }
    
    for (int i = ans.size() - 1; i >= 0; i--)
    {
        cout << ans[i] + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;

int main(){
    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    ll m=min(a,min(b,min(c,min(d,e))));
    ll ans=5+(n-1)/m;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.1415926535

template <class T>
inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    ll a, b;
    cin >> a >> b;
    ll ans = LCM(a, b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll N=500001;
ll n,q,c[N],l[N],r[N],a[N],b[N],ans[N];
vector<pair<ll,ll>> x[N];

void add(ll x,ll v){
  for(int i=x;i<=n;i+=i&(-i))
    b[i]+=v;
}

int sum(ll x){
  ll v=0;
  for(int i=x;i>0;i-=i&(-i))v+=b[i];
  return v;
}

int main(){
  cin>>n>>q;
  for(int i=1;i<=n;i++)cin>>c[i];
  for(int i=1;i<=q;i++){
    cin>>l[i]>>r[i];
    x[r[i]].push_back({l[i],i});
  }
  for(int i=1;i<=n;i++){
    if(a[c[i]])add(a[c[i]],-1);
    a[c[i]]=i;
    add(i,1);
    for(auto [d,e]:x[i])ans[e]=sum(i)-sum(d-1);
  }
  for(int i=1;i<=q;i++)cout<<ans[i]<<endl;
}

Measured memory_bytes: 51960
n = int(input())
s = [0 for i in range(4)]
for i in range(n):
    t = input()
    if t == "AC":
        s[0] += 1
    elif t == "WA":
        s[1] += 1
    elif t == "TLE":
        s[2] += 1
    elif t == "RE":
        s[3] += 1

s_2 = ["AC","WA","TLE","RE"]
for i in range(4):
    print(s_2[i],"x",s[i])


Measured memory_bytes: 69956