akhauriyash/Code-Regression huggingface dataset:
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<queue>
#include<iomanip>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    priority_queue<double, vector<double>, greater<double>> pq;
    int n;
    cin >> n;
    REP(i, n) {
        int vi;
        cin >> vi;
        pq.push(vi);
    }
    while(pq.size() > 1) {
        double a = pq.top(); pq.pop();
        double b = pq.top(); pq.pop();
        pq.push((a + b) / 2);
    }
    cout << fixed << setprecision(10) << pq.top() << endl;
}


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

public class Main {
	public static void main(String args[]) {

		Scanner scan = new Scanner (System.in);
		
		//list作成
		TreeSet<Integer> set = new TreeSet<>();
		
		int a = scan.nextInt();
		for(int i=0; i<a; i++) {
			int num = scan.nextInt();
			set.add(num);
		}
		
		//list2作成
		TreeSet<Integer> set2 = new TreeSet<>();
		
		int b = scan.nextInt();
		for(int i=0; i<b; i++) {
			int num = scan.nextInt();
			set2.add(num);
		}
		
		//積集合
		TreeSet<Integer> intersection = new TreeSet<>(set);
		intersection.retainAll(set2);
		
//		System.out.println("dubug");
//		System.out.println(intersection.size());
		
		for(int i : intersection) {
			System.out.println(i);
		}

	}
}



Measured memory_bytes: 170544
program repsept
  implicit none
  integer :: k, i, m = 0
  read(*,*) k
  do i = 1, 2 * k
    m = mod(10 * m + 7, k)
    if (m == 0) then
      write(*,'(i0)') i
      stop
    end if
  end do
  write(*,'(i0)') -1
end program repsept

Measured memory_bytes: 2928
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	p := make([]int, N)
	for i := range p {
		fmt.Scan(&p[i])
	}
	sort.Ints(p)
	sum := 0
	for i := 0; i < len(p)-1; i++ {
		sum += p[i]
	}
	sum = sum + p[len(p)-1]/2
	fmt.Println(sum)
}


Measured memory_bytes: 512
n = int(input(''))
ac = 0
wa = 0
tle= 0
re = 0
for i in range(n):
    s = input('')
    if s =='AC':
        ac+=1
    elif s == 'WA':
        wa+=1
    elif s == 'TLE':
        tle+=1
    elif s == 'RE':
        re+=1
    else:
        None

print('AC', ac, sep=' x ')
print('WA',wa,sep=' x ')
print('TLE',tle,sep=' x ')
print('RE',re,sep=' x ')


Measured memory_bytes: 9220
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

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


signed main(){
  ll K;
  cin >> K;

  ll ans = 0;
  for (int a = 1; a < K + 1; a++) {
    for (int b = 1; b < K + 1; b++) {
      int temp = gcd(a, b);
      for (int c = 1; c < K + 1; c++) {
        ans += gcd(temp, c);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    int h,w,k;
    cin >> h >> w >> k;

    vector<string> s(h);
    rep(i,h) cin >> s[i];

    int ans = 0;
    rep(a,1<<h) rep(b,1<<w) {
        int count = 0;
        rep(c,h) rep(d,w) {
            if (a >> c & 1) continue;
            if (b >> d & 1) continue;
            
            if (s[c][d] == '#') {
                count++;
            }
        }
        if (count == k) {
            ans++;
        }
    }

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

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

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

template <typename T>
bool isPrime(T x) {
    if(x==1) return false;
    for(T i = 2; i*i <= x; ++i) {
        if(x%i==0) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> s(100010);
    s[0]=0;
    REPP(i,s.size()) {
        s[i] = s[i-1] + (i%2==1 && isPrime(i) && isPrime((i+1)/2));
    }
    int q; cin >> q;
    int ans;
    REP(i,q) {
        int l,r; cin >> l >> r;
        ans = s[r]-s[l-1];
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    P=list(map(lambda x:int(x)-1,input().split()))
    cnt=0
    for i in range(n-1):
        if(P[i]==i and P[i+1]==i+1):
            cnt+=1
            P[i],P[i+1]=P[i+1],P[i]
    print(cnt+sum(P[i]==i for i in range(n)))
resolve()

Measured memory_bytes: 52588
// Sat May  2 17:37:17 IST 2020         
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)        for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long    
#define MOD                998244353 
#define pb                 push_back
#define f1                 first 
#define s1                 second    
#define all(x)             (x).begin(),(x).end() 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
#define tough_nut          numeric_limits<int64>::min()
const double pi=3.141592653589793238;
using namespace std ;     
using namespace __gnu_pbds;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
// const int N = 2e5; 
const int INF = 2e9;
int N,M ;
vector <vector <int>> Q ;
int ans  = 0;
void completesearch(int last,vector <int>& v){
    if((int)v.size() == N )
    {
        int best  = 0 ;
        for(auto it : Q){ 
            vector <int> vec = it ;
            if( v[vec[1]-1]- v[vec[0]-1] == vec[2])
                best += vec[3];
        } 
        ans = max(ans,best);
        return ;
    }
    for(int i = last ; i <= M ; i++ ){  
        v.push_back(i);
        completesearch(i,v);
        v.pop_back();
    }
    return ;
}
int tests(){
    cin >> N >> M  ;
    int q ;
    cin >> q ;
    for(int i = 0  ; i < q ;i ++){
        vector <int> V(4);
        for(auto &in : V)
            cin >> in ;
        Q.push_back(V);
    }
    vector <int> vec;
    completesearch(1,vec);
    cout << ans << '\n';
    return 0;
}   
int32_t main(){
    I__O ;    
    int cases = 1 ; 
    // cin >> cases ; 
    forn(iii,1,cases+1){   
        // cout << "Case #" << iii << ": ";
        tests(); 
    }
    return 0 ; 
}
 
// -Wall -Wextra -O2
// -pedantic -std=c++11
// -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC


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

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

    int counts[100000] = {0};

    int i;

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

      counts[c]++;
    }

    int ans = 0;
    for (i = 0; i < 99998; i++) {
        ans = max(ans, counts[i] + counts[i+1] + counts[i+2]);
    }

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


Measured memory_bytes: 640
#include <iostream>

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define m 100000

using namespace std;

int main()
{
    int A, B, M;
    int a[m], b[m];
    int minA, minB, minM;
    int ref, mic, disc;


    cin >> A >> B >> M;

    REP(i, 0, A)
    {
        cin >> a[i];
        if (i == 0)
            minA = a[i];
        else
        {
            if (a[i] < minA)
                minA = a[i];
        }
    }

    REP(i, 0, B)
    {
        cin >> b[i];
        if (i == 0)
            minB = b[i];
        else
        {
            if (b[i] < minB)
                minB = b[i];
        }
    }

    minM = minA + minB;

    REP(i, 0, M)
    {
        cin >> ref >> mic >> disc;
        if ((a[ref-1] + b[mic-1] - disc) < minM)
            minM = a[ref-1] + b[mic-1] - disc;
    }

    cout << minM << "\n";

    return 0;
}

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

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

int main(){
    char XX; cin >> XX;
    if(isupper(XX)){
        cout << 'A' << endl;
    }
    else cout << 'a' << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;

int main(){

    ll A, B;

    cin >> A >> B;

    ll ans = 1;

    ll num = A;

    if(B == 1){
        cout << 0 << endl;
        return 0;
    }

    if(num >= B){
        cout << ans << endl;
        return 0;
    }

    for(ll i = 0; i < 100; i++){
        num--;
        num += A;

        ans++;
        if(num >= B){
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	ll ar[n];
	for(ll i=0;i<n;i++)cin>>ar[i];
	ll ans[n];
	ans[n-1]=0;
	ans[n-2]=max(ar[n-1]-ar[n-2],ar[n-2]-ar[n-1]);
	for(ll i=n-3;i>=0;i--)
	{
		ans[i]=min(max(ar[i]-ar[i+1],ar[i+1]-ar[i])+ans[i+1],max(ar[i]-ar[i+2],ar[i+2]-ar[i])+ans[i+2]);
	}
	cout<<ans[0];
	return 0;
}

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

int main(){
  int a;
  cin >> a;
  vector<int> enemy(a + 1);
  rep(i, a + 1) cin >> enemy.at(i);
  vector<int> hero(a);
  rep(i, a) cin >> hero.at(i);
  int64_t ans = 0;
  rep(i, a){
    if (hero.at(i) >= enemy.at(i)){
      ans += enemy.at(i);
      if (hero.at(i) - enemy.at(i) <= enemy.at(i + 1)){
        enemy.at(i + 1) -= hero.at(i) - enemy.at(i);
        ans += hero.at(i) - enemy.at(i);
      }
      else{
        ans += enemy.at(i + 1);
        enemy.at(i + 1) = 0;
      }
    }
    else ans += hero.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	Int cnt = 0;
	Int temp;
	for (Int i = 1; i <= N; i+=2) {
		temp = 0;
		for (Int j = 1; j <= i; j++) {
			if (temp>8) {
				break;
			}
			if (i%j==0) {
				temp++;
			}
		}
		if (temp==8) {
			cnt++;
		}
	}
	cout << cnt << "\n";
}


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

int main() {
  long long x, y; cin >> x >> y;
  long long temp = x;
  int ans;
	
  for (int i = 1; i <= 100; i++) {
    if (temp * 2 > y) {
      ans = i;
      break;
    } else {
      temp *= 2;
    }
  }
	
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin  >> n;
  vector<ll> p(n);
  ll j=1;
  for(ll i=1;i<=n;i++){
    j=1;
    while(i+j-2<n){
      p.at(i+j-2)++;
      j+=i;
    }
  }
  ll ans=0;
  for(ll i=1;i<=n;i++){
    ans+=i*p.at(i-1);
  }
  cout << ans;
}
    
    

Measured memory_bytes: 81372
#include <stdio.h>
#include <math.h>
double dis(double a1, double a2, double a3, double a4)
{
	double distance;
	distance = sqrt((a1-a3)*(a1-a3)+(a2-a4)*(a2-a4));
	return distance;
}

int main(){
	double k1,k2,x1,y1,x2,y2,x3,y3,px,py,r,X1,X2,Y1,Y2,dx,dy,p[10];
	int n,i,k;
	//input
	scanf("%d",&i);
	for (k=1;k<=i;k++)
	{
		for (n=1;n<7;n++)
		scanf("%lf",&p[n]);
		x1=p[1];y1=p[2];x2=p[3];y2=p[4];x3=p[5];y3=p[6];
		X1=0.5*(x1+x2);
		Y1=0.5*(y1+y2);
		X2=0.5*(x1+x3);
		Y2=0.5*(y1+y3);
		if (y1==y2)
		{	px=X1;
		k2=-(x1-x3)/(y1-y3);
		py=k2*(px-X2)+Y2;
		}
		else if(y1==y3)
		{
			px=X2;
			k1=-(x1-x2)/(y1-y2);
			py=k1*(px-X1)+Y1;
		}
		else
		{
			k1=-(x1-x2)/(y1-y2);
			k2=-(x1-x3)/(y1-y3);
			px=(Y1-Y2-k1*X1+k2*X2)/(k2-k1);
			py=k1*(px-X1)+Y1;
		}

		r=dis(px,py,x1,y1);
		printf("%.3lf %.3lf %.3lf\n",px,py,r);
	}
    return 0;
}

Measured memory_bytes: 664
// 日本語
use std::io::stdin;
use std::cmp;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let vs: Vec<u64> = s.trim().split_whitespace().map(|token| token.parse().ok().unwrap()).collect();
    let a = vs[0];
    let b = vs[1];
    let c = vs[2];
    let result = cmp::min(b / a, c);
    println!("{}", result);
}


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

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,m;cin>>n>>m;
    ll arr[n];
    ll sum=0;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    ll a=0;
    long double b=(long double)sum/(long double)(4*m);
    for(ll i=0;i<n;i++){
        if(arr[i]>=b){
            a++;
        }
    }
    if(a>=m)cout<<"Yes\n";
    else cout<<"No\n";

}



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

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	long INF=Long.MAX_VALUE/2;
	int n,m;
	long[] dist;
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		m=sc.nextInt();
		
		Edge[] v=new Edge[m];
		for(int i=0;i<m;i++){
			v[i]=new Edge();
			v[i].from=sc.nextInt();
			v[i].to=sc.nextInt();
			v[i].cost=-sc.nextInt();
		}
		
		//dist[i]:iにたどり着く最短距離
		dist=new long[n+1];
		Arrays.fill(dist, INF);
		dist[1]=0; //初期化
		
		//ベルマンフォード法
		boolean flag=true;
		long ans=0;
		int cnt=0;
		while(flag){
			flag=false;
			for(int i=0;i<m;i++){
				if(dist[v[i].from]+v[i].cost<dist[v[i].to]){
					dist[v[i].to]=dist[v[i].from]+v[i].cost;
					flag=true;
				}
			}
			if(cnt==n){
				ans=dist[n];
			}
			if(cnt==2*n){
				if(ans>dist[n]){
					System.out.println("inf");
					return;
				}else{
					System.out.println(-dist[n]);
					return;
				}
			}
			cnt++;
			if(!flag)break;
		}
		
		System.out.println(-dist[n]);
	}
	class Edge{
		int to;
		int from;
		int cost;
	}
}


Measured memory_bytes: 29820
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//各種nil
template <class T>
constexpr T nil = static_cast<T>(-1);

constexpr int nil_i = nil<int>;
constexpr int nil_ll = nil<ll>;
constexpr double nil_d = nil<double>;

//vector
template <class T>
using vec = std::vector<T>;

struct Item
{
    int weight, value;
};

void solve()
{
    using namespace std;

    constexpr int inf = 1 << 29;

    int N, W;
    cin >> N >> W;

    vec<Item> items(N);
    for (auto& i : items) cin >> i.value >> i.weight;

    //dp[i + 1][w] i番目の品物までで、重さw以下のときの価値の最大値
    vec<vec<int>> dp(N + 1, vec<int>(W + 1, 0));

    for (int i = 0; i < N; ++i)
        for (int w = 0; w <= W; ++w)
        {
            dp[i + 1][w] = dp[i][w];
            if (items[i].weight <= w)
                dp[i + 1][w] = max(dp[i + 1][w], dp[i][w - items[i].weight] + items[i].value);
        }

    cout << dp[N][W] << endl;
}

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


Measured memory_bytes: 6824
import std.stdio, std.string, std.conv, std.algorithm;
void main()
{
  while(1){
    auto n = readln.chomp.to!int;
    if(n==0) break;
    int s=1;
    int max=50000001;
    for(int i=2;i*i<n;++i){
      if(n%i==0){
    if(i<max){
      s+=(i+n/i);
      max = n/i;
      if(i==max)
        s -= i;
    }else break;
      }else if(i>max) break;
    }
    if(s<n || n==1) writeln("deficient number");
    else if(s==n) writeln("perfect number");
    else writeln("abundant number");
  }
}

Measured memory_bytes: 2452
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
   int N; cin >> N;
   vector<int> a(N);
   int cnt2 = 0;
   int cnt4 = 0;
   rep(i,N){
       cin >> a[i];
       if(a[i] % 2 == 0) cnt2++;
       if(a[i] % 4 == 0) cnt4++;
   }
   cnt2 -= cnt4;
   bool ok = false;

   if(N/2 <= cnt4) ok = true;
   else{
       int cnt = ((N/2) - cnt4 - 1) * 2 + (N % 2 == 1) + 2;
       if(cnt2 >= cnt) ok = true;
   }

   if(ok) cout << "Yes" << endl;
   else cout << "No" << endl;

}


Measured memory_bytes: 640
pub struct Scanner<R> {
    reader: R,
}

impl<R> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader }
    }
}

fn is_whitespace(b: u8) -> bool {
    b == b' ' || b == b'\n' || b == b'\r' || b == b'\t'
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        let buf = std::io::Read::bytes(self.reader.by_ref())
            .map(|b| b.expect("Read failed"))
            .skip_while(|&b| is_whitespace(b))
            .take_while(|&b| !is_whitespace(b))
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error")
    }

    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());
    loop {
        let m: usize = sc.read();
        let n: usize = sc.read();
        if m == 0 {
            break;
        }
        let max = 7368791 + 1;
        let mut used = vec![false; max];
        let mut count = 0;
        for i in m..usize::max_value() {
            if !used[i] {
                count += 1;
                if count > n {
                    println!("{}", i);
                    break;
                }
                for k in 1..usize::max_value() {
                    let j = i * k;
                    if j >= max {
                        break;
                    }
                    used[j] = true;
                }
            }
        }
    }
}



Measured memory_bytes: 13208
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;


int main(){
    int N,M; cin >> N >> M;
    vector<int> X(M);
    rep(i,M) cin >> X[i];
    sort(X.begin(), X.end());
    ll total = 0;
    total = abs(X[X.size()-1] - X[0]);

    vector<int> diff(M-1,0);
    rep(i,M-1){
        diff[i] = X[i+1] - X[i];
    }
    sort(diff.rbegin(), diff.rend());

    rep(i,N-1){
        if (i >= diff.size()) break;
        total -= diff[i];
    }

    cout << total << endl;

}

Measured memory_bytes: 4048
N = int(input())
B = list(map(int, input().split()))
out = 0
flag = 0
while(1):
	for i in range(len(B)):
		if B[i] % 2 != 0:
			flag = 1
			break
		else:
			B[i] /= 2
	if(flag == 1): break
	out += 1
	
print(out)

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

int main(){
    int N;
    cin >> N;
    bool check = false;
    rep2(i, 1, 10){
        if(N%i == 0 && 0 < N/i && N/i < 10) check = true;
    }
    if(check) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
while 1:
	hit = blow = 0
	try: a = list(map(int,input().split()))
	except: break
	b = list(map(int,input().split()))
	for i in range(4):
		if a[i] == b[i]:
			hit += 1
		elif a[i] in b:
			blow += 1
	print(hit, blow)


Measured memory_bytes: 5596
N,M=map(int, input().split())
 
A=[]
B=[]
for i in range(N):
    a,b=map(int, input().split())
    A.append(a)
    B.append(b)
 
C=[]
D=[]
for i in range(M):
    c,d=map(int, input().split())
    C.append(c)
    D.append(d)
 
T=[]
S=[]
for i in range(N):
    for j in range(M):
        T.append(abs(A[i]-C[j])+abs(B[i]-D[j]))
    S.append(T.index(min(T))+1)
    T=[]
 
for i in range(N):
    print(S[i])

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

int main(void){
    int n;
    cin >> n;
    double x[n],y[n];
    for(int i = 0;i < n;i++)cin >> x[i] >> y[i];
    
    vector<int> num(n);
    for(int i = 0;i < n;i++)num[i] = i;
    
    long double ans = 0;
    long int ans2 = 0;
    do{
        long double sum = 0;
        for(int i = 1;i < n;i++){
            long double sum2 = 0;
            
            long double x2 = (x[num[i]]-x[num[i-1]]),y2 = (y[num[i]]-y[num[i-1]]);
            sum2 = sqrt(x2*x2 + y2*y2);
            
            sum += sum2;
        }
        ans += sum;
        ans2++;
        
    }while(next_permutation(num.begin(), num.end()));
    
    cout << setprecision(12) << ans / (long double)(ans2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (b-a == c-b)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 636
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int r, g;
  scanf("%d%d", &r, &g);
  printf("%d\n", 2*g-r);
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  double d;
  cin >> d;
  cout << (d / 3.0) * (d / 3.0) * (d / 3.0) << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


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

using namespace std;

int main(){
  int n,l;
  cin >> n >> l;
  int ans = 0;
  if(n <= -l){
    for(int i = 0; i < n-1 ; i++){
      ans += l + i;
    }
  }
  else if(l > 0){
    for(int i = 1; i < n ; i++){
      ans += l + i;
    }
  }
  else{
    for(int i = 0; i < n ;i++){
      if(l + i != 0)ans += l + i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>

using namespace std;

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

int N;
map<string, int> m;

signed main()
{
	cin >> N;
	rep(i, N) {
		string s; cin >> s;
		sort(begin(s), end(s));

		m[s]++;
	}

	int ans = 0;

	for (pair<string, int> a : m) {
		ans += a.second * (a.second - 1) / 2; 
	}

	cout << ans << endl;
}


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

// types - only for stuff used a lot 
using ll = long long;
#define vv vector
#define Pp pair

// IO
#define get(x) scanf("%d",&x)
#define getl(x) scanf("%lld",&x);

// Operations
#define pb push_back
#define pob pop_back
#define sz(a) int(a.size()) 
#define re(a,b) a=max(a,b) // relax
#define ri(a,b) a=min(a,b) // relaxi

// Debugging

#ifndef LOCAL
#define cerr if (0) cerr
#else
#define cerr cout
#endif

#define print(arr,n) {for (int _ = 0; _ < n; _++) cerr<<arr[_]<<" \n"[_+1==n]; }
#define printv(vec)  {for (int _ : vec) cerr<<_<<" "; cerr<<endl;}

const int mod = 1e9+7, oo = 1e9;
const ll loo = 1e18;

// Functions 
ll modpow(ll a, ll b) {
	ll ans = 1; // faster modpow than recursive
	for (; b; b/=2,a=a*a%mod)
		if (b&1) ans = (ans*a)%mod;
	return ans;
}
ll gcd(ll a, ll b) {
	while (a) b%=a,swap(a,b);
	return b;
}
#define bitcount __builtin_popcountll
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)


/* 

   ALRIGHT HACKERS, THIS IS WHERE THE ACTUAL CODE BEGINS

 */

const bool DEBUG = 1;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	if (DEBUG) freopen("input.txt", "r", stdin);
	if (DEBUG) freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n; ll L;
	cin>>L>>n;
	int p[n];
	f(i,0,n) cin>>p[i];
	ll prefix[n], suffix[n];
	f(i,0,n) prefix[i] = (i?prefix[i-1]:0)+p[i];
	fr(i,0,n) suffix[i] = (i!=n-1?suffix[i+1]:0)+(L-p[i]);
	ll ans = 0;
	auto pre = [&](int i, int k) {
		return i>=0?prefix[i]-(i-k>=0?prefix[i-k]:0):0;
	};
	auto post = [&](int i, int k) {
		return i<n?suffix[i]-(i+k<n?suffix[i+k]:0):0;
	};
	auto d = [&](int i) {
		return max(1LL*p[i],L-p[i]);	
	};
	f(i,0,n) {
		int k = min(i,n-1-i);
		if (k+k+1<n) {
			if (i>=k+1) {
				re(ans,2*pre(i-1,k+1)+2*post(i+1,k)+max(L-p[i],p[i]-2LL*p[i-1]));
			} else {
				re(ans,2*pre(i-1,k)+2*post(i+1,k+1)+max(2*p[i+1]-p[i]-L,1LL*p[i]));
			}					
		}
		re(ans,2*pre(i-1,k)+2*post(i+1,k)+d(i));			
	}
	cout << ans << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}




Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trv(a) cerr<<#a<<":\n";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define mod 1000000007
#define inf 9999999999999999ll

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vi a(n);
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll mi_value=inf;
    ll ans=0;
    for(ll x=1;x<=100;x++)
    {
        ll value=0;
        for(ll i=0;i<n;i++)
        {
            value+=(a[i]-x)*(a[i]-x);
        }
        if(value<mi_value)
        {
            mi_value=value;
            ans=x;
        }
    }
    cout<<mi_value<<endl;
}


Measured memory_bytes: 256
s=input()
ans=1
s0=s[0]
flag=0
for i in range(1,len(s)):
    if flag==1:
        s0+=s[i]
        flag=0
    elif s[i]==s0:
        if i!=len(s)-1:
            ans+=1
            flag=1
    else:
        ans+=1
        s0=s[i]
print(ans)

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

int main() {
	string S; cin >> S;
	int N = S.size();
	for( int i = 0; i < N; i++ ){
		for( int j = 0; j < N; j++ ){
			if( i != j && S[i] == S[j]){
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;
}

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

int main()
{
    int n, y;
    cin >> n >> y;
    int ans10000 = -1, ans5000 = -1, ans1000 = -1;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j + i <= n; j++) {
            int k = n - i  - j;
            if ((i*10000 + j*5000 + k*1000) ==y) {
                ans10000 = i;
                ans5000  = j;
                ans1000  = k;
                break;
            }
        }
    }

    cout << ans10000 << " " << ans5000 << " " << ans1000 << endl;
}

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

int N, A, B, C;

int dfs(int n, int a, int b, int c, const vector<int>& l) {
  if (n == N) {
    if (a == 0 || b == 0 || c == 0) return pow(10, 9);
    return abs(A - a) + abs(B - b) + abs(C - c) - 30;
  }
  int r0 = dfs(n+1, a, b, c, l);
  int r1 = dfs(n+1, a+l[n], b, c, l) + 10;
  int r2 = dfs(n+1, a, b+l[n], c, l) + 10;
  int r3 = dfs(n+1, a, b, c+l[n], l) + 10;
  return min({r0, r1, r2, r3});
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  cin >> N >> A >> B >> C;
  vector<int> l(N);
  rep(i, N) { cin >> l[i]; }

  cout << dfs(0, 0, 0, 0, l) << endl;
  return 0;
}



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

int main() {
   int n;
   cin >> n;
   double ans=0;
   rep(i,n){
      double x; string u;
      cin >> x >> u;
      u=="JPY" ? ans+=x : ans+=x*380000.0;
   }
   printf("%.10f\n",ans);
}

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

int main(){
  string s;
  cin >> s;

  for(int i=0; i < s.length(); i+=2){
    if(s[i] == 'L'){
      cout << "No" << endl;
      return 0;
    }
  }

  for(int i=1; i < s.length(); i+=2){
    if(s[i] == 'R'){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  vl d(n);
  rep(i,n){
    cin >> d[i];
  }
  d.pb(INF);
  sort(all(d));
  ll m;
  cin >> m;
  vl t(m);
  rep(i, m){
    cin >> t[i];
  }
  bool OK = true;
  rep(i, m){
    ll key = t[i];
    int left = 0, right = sz(d) - 1; // 配列 a の左端と右端
    ll a = -1;
    int mid = left + (right - left) / 2; // 区間の真ん中
    while (right >= left){
      mid = left + (right - left) / 2; 
      if (d[mid] == key){
        a = mid;
        break;
      }
      else if (d[mid] > key){
        right = mid - 1;
      }
      else if(d[mid] < key){
        left = mid + 1;
      }
    }
    if(a==-1){
      OK = false;
      break;
    }
    else{
      d.erase(d.begin() + mid);
    }
    
  }
  if(OK){
    print("YES");
  }
  else{
    print("NO");
  }
}

Measured memory_bytes: 6416
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)(1e7))
#define pi (2*acos(0))
#define mp make_pair
#define M ((int)(1e9 + 7))
#define xx first
#define yy second
#define NN ((int)(5e5+2))
#define N ((int)(2e5 + 2))
#define pq priority_queue
///#define Q queue
#define eps 0
#define log 20
#define pb push_back
#define MOD 998244353


using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int lu;

typedef tree < int ,  null_type ,  less < int > ,  rb_tree_tag ,  tree_order_statistics_node_update > o_set;

char s[20];

int main()
{
    int n;
    bool m, f;
    scanf("%d",&n);
    printf("0\n");
    fflush(stdout);
    scanf("%s",s);
    if(s[0]=='V'){
        return 0;
    }
    if(s[0]=='M'){
        m = 0;
        f = 1;
    }
    else{
        m = 1;
        f = 0;
    }
    int l = 1, r = n-1;
    while(l<r){
        int mid = (l+r)/2;
        printf("%d\n",mid);
        fflush(stdout);
        scanf("%s",s);
        if(s[0]=='V'){
            return 0;
        }
        if(s[0]=='M'){
            if(mid%2==m) l = mid+1;
            else r = mid;
        }
        else{
            if(mid%2==f) l = mid+1;
            else r = mid;
        }
    }
    printf("%d\n",l);
    fflush(stdout);
    return 0;
}


Measured memory_bytes: 852
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        e: [(usize1, usize1); n - 1],
    }
    let mut g = vec![vec![]; n];
    for (a, b) in e {
        g[a].push(b);
        g[b].push(a);
    }
    let mut q = Vec::with_capacity(n);
    let mut parent = vec![n; n];
    let mut s = vec![];
    s.push(0);
    while let Some(v) = s.pop() {
        q.push(v);
        for &u in g[v].iter() {
            if parent[v] == u {
                continue;
            }
            parent[u] = v;
            s.push(u);
        }
    }
    let mut dp = vec![0; n + 1];
    dp[n] = 1;
    for i in (0..n).rev() {
        let v = q[i];
        if dp[v] > 0 {
            continue;
        }
        let p = parent[v];
        if dp[p] > 0 {
            println!("First");
            return;
        }
        dp[p] = 1;
    }
    println!("Second");
}

fn main() {
    run();
}


Measured memory_bytes: 16636
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;
const ll inf = 1000000000000000000;

ll n, x, t, p;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> x >> t;
    p = (n / x) + (n % x != 0);
    cout << p * t;
    return 0;
}


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

int main(){
int A,B;
  cin>>A>>B;
  
  if(A==1){A+=13;}
  if(B==1){B+=13;}
  if(A>B){cout<<"Alice"<<endl;}
  else if(A<B){cout<<"Bob"<<endl;}
  else{cout<<"Draw"<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
ll mpower(ll a,ll b,ll c){
    int z;
    if(b==0){
        z=1;
        z%=c;
        return z;
    }
    if(b==1){
        z=a;
        z%=c;
        return z;
    }
    else{
        return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
    }
}

int main() {
  int n,m;
  cin>>n>>m;
  int vec[m][n];
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      vec[i][j]=0;
    }
  }
  int l;
  for(int i=0;i<m;i++){
    cin>>l;
    for(int j=0;j<l;j++){
      cin>>vec[i][j];
    }
  }
  int vecb[m];
  for(int i=0;i<m;i++){
    cin>>vecb[i];
  }
  int vecc[n];
  int ans=0;
  int g=0,h=0;
  for(int bit=0;bit<(1<<n);bit++){
    for(int i=0;i<n;i++){
      if(bit&(1<<i)){
        vecc[i]=1;
      }
      else{
        vecc[i]=0;
      }
    }
    for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
        if(vec[i][j]>0){
          if(vecc[vec[i][j]-1]==1){
            g++;
          }
        }
      }
      if(g%2==vecb[i]){
        h++;
      }
      g=0;
    }
    if(h==m){
      ans++;
    }
    h=0;
  }
  cout<<ans<<endl;      
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.rbegin(),v.rend()
#define see(x) cout<<#x<<" : "<<(x)<<endl;
#define ya cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define ff first
#define sc second
typedef long long ll;
using namespace std;

int main()
{
    int n,i,j,val=0,cost=0,ans=0;
    string s;
    cin>>n;
    cin>>s;
    queue<char>q;
    char p='&';
    for(i=0;i<n;i++)
    {
        if(s[i]!=p)
        {
            q.push(s[i]);
            p=s[i];
        }
    }
    cout<<q.size()<<endl;
    return 0;
}


Measured memory_bytes: 3816
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main()
{
    int n,m;
    int num[100000];
    cin>>n;
    for(int i=0;i<n;i++) cin>>num[i];
    sort(num,num+n);
    int max1=num[n-1];
    int s;
    if(max1%2==0) s=max1/2;
    else s=(max1/2)+1;
    int min1=1e10;
    int w=0;
    for(int i=0;i<n;i++){
        if(abs(num[i]-s)<min1){
            min1=abs(num[i]-s);
            w=num[i];
        }
    }
    printf("%d %d",max1,w);
    return 0;
}

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

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 3000 + 10;
const int MOD = 1000000007;
const int LOG = 20;
const int INF = 1000000010;
const int delta = 11353;

int n, m, DP[N][N][2];

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++) DP[0][i][0] = 1;
	DP[0][0][1] = 1;
	for (int i = 0; i < m; i++) for (int j = 0; j <= n; j++)for (int k = 0; k < 2; k++){
		if (j != 0){
			DP[i + 1][j][(j == 1) | k] = (DP[i + 1][j][(j == 1)|k] + DP[i][j][k]) % MOD;
			DP[i + 1][j - 1][(j == 1)| k] = (DP[i + 1][j - 1][(j == 1) | k] + DP[i][j][k]) % MOD;
		}if (j != n){
			DP[i + 1][j + 1][k] = (DP[i + 1][j + 1][k] + DP[i][j][k]) % MOD;
			DP[i + 1][j][k] = (DP[i + 1][j][k] + DP[i][j][k]) % MOD;
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) ans = (ans + DP[m][i][1]) % MOD;
	cout << ans;


	return 0;
}


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

typedef long long ll;

const long long INF = 1e18L + 7;

int main() {

    int n, W; 
    cin >> n >> W;


    long long sum_value = 0;

    vector<int> weight(n), value(n);
    for (int i=0; i<n; i++) {
        cin >> weight[i] >> value[i];
        sum_value += value[i];
    }

    vector<ll> dp(sum_value * 1000 + 1, INF);
    dp[0] = 0;

    for (int i=0; i<n; i++) {

        // value-already
        for (long long value_already = sum_value - value[i]; value_already >= 0; value_already--) {
            dp[value_already + value[i]] = min(dp[value_already + value[i]], dp[value_already] + weight[i]);
        }
    }

    long long ans = -INF;
    for (long long value = 0; value <= sum_value; value++) {
        if (dp[value] <= W)
            ans = max(ans, value);
    }

    cout << ans << endl; 
}

Measured memory_bytes: 781440
#include<bits/stdc++.h>
#define i64 long long

using namespace std;

int main()
{
    string str;
    cin>>str;
    int len = str.size();
    int sum = 0;
    for(int i=0; i<len; i++){
        if(str[i]=='+') sum++;
        else  sum--;
    }

    cout<<sum<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

int main() {
	int w, h, n; cin >> w >> h >> n;
	vector<int>x(n), y(n), a(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> a[i];
	}

	int area = w * h, blx = 0, brx = w, bby = 0,buy = h;


	for (int i = 0; i < n; i++) {
		if (a[i] == 1) blx = max(blx,x[i]);
		if (a[i] == 2) brx = min(brx, x[i]);
		if (a[i] == 3) bby = max(bby, y[i]);
		if (a[i] == 4) buy =  min(buy, y[i]);
	}
	//cout << blx << " " << brx << " " << bby << " " << buy << endl;
	if (brx <= blx || buy <= bby) cout << 0;
	else cout << (brx - blx) * (buy - bby);


	cout << endl;
	return 0;
}

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

int main(void) {
    int H, A;
    int ans;
    
    cin >> H >> A;
    
    while (H > 0) {
        H -= A;
        ans ++;
    }
    
    cout << ans << endl;
    
    return 0;
}

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

int main(){
	string S, T;
    cin >> S  >> T;
   
    int A, B;
    cin >> A >> B;
   
    string U;
    cin >> U;
   
	if(S==U) A=A-1;
    else B=B-1;
    	cout << A << " " << B;
}

Measured memory_bytes: 256
N, M= map(int, input().split())
zahyo = []
for i in map(int,input().split()):
    zahyo += [i]
sum=0
#マージソート用関数
# merge(p, q): あらかじめソートされた配列 p と q をまとめる。
def merge(p,q):
    result=[]
    i,j=0,0
    #p[i]とq[j]を比べて小さい方をresultに加える。
    while i<len(p) and j<len(q):
        #.appendで加える。小さかった方の数字を一つ進める。
        #これで小さいものから順にresultに加えることができる。
        if p[i] <= q[j]:
            result.append(p[i])
            i+=1
        else:
            result.append(q[j])
            j+=1

    #片方の配列が全て比較済みとなると、そこで上のwhile分は終了してしまう
    #なのでまだ比較していない要素が残っている配列をそのままresultに連結する
    #これは.extendを使う。まだ比較していない要素はスライスで簡単に分けることができる。
    if i<len(p):
        result.extend(p[i:])
    if j<len(q):
        result.extend(q[j:])
    #resultを返して終了
    return result

# mergesort(a): 配列 a をマージソートしたものを返す。
def mergesort(a):
    #要素が一つになるまで分割したらそれ自体を返す。
    if len(a)==1:
        return a
    #最初の半分を切り取ってソート
    p=mergesort(a[:len(a)//2])
    #残りの半分を切り取ってソート
    q=mergesort(a[len(a)//2:])
    #merge関数で連結させる
    return merge(p,q)

if M==1:
    print(0)
else:
    zahyo = mergesort(zahyo)
    gap = []
    for i in range(M-1):
        gap += [zahyo[i+1]-zahyo[i]] 
    gap = mergesort(gap)
    if N >= M:
        print(0)
    else:
        for i in gap[:M-N]:
            sum += i
        print(sum)

Measured memory_bytes: 13832
#include <stdio.h>

int main(void){
	int i,j,n;
	int max,min;
	scanf("%d",&n);
	
	long r[n];
	for(i=0;i<n;i++){
		scanf("%ld",&r[i]);
	}
	
	max=r[1]-r[0];
	min=r[0];
	for(i=1;i<n;i++){
		if(max<r[i]-min)
			max=r[i]-min;
		if(min>r[i])
			min=r[i];
	}
	
	
	printf("%d\n",max);
	
	
	return 0;
}

Measured memory_bytes: 3356
#include <stdio.h>
int main(void)
{
    int x, y, r, W, H;

    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    if (x-r>=0 && x+r<=W && y-r>=0 && y+r<=H)
      puts("Yes");
    else
      puts("No");

    return 0;
}

Measured memory_bytes: 584
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

og_sum = sum(A)

m = {}

for num in A:
    if num not in m:
        m[num] = 1
    else:
        m[num] += 1

for _ in range(Q):
    B, C = map(int, input().split())
    if B in m:
        cnt = m[B]
        new_sum = og_sum - cnt * B + cnt * C

        print(new_sum)
        og_sum = new_sum

        if C in m:
            m[C] += cnt
        else:
            m[C] = cnt

        del m[B]
    else:
        print(og_sum)

Measured memory_bytes: 84508