akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int X,t; cin >> X >> t;
    cout << max(0,X-t) << endl;
    return 0;
}

Measured memory_bytes: 256
// TEMPLATE {{{
#include <bits/stdc++.h>
using namespace std;
#ifndef LOCAL
#define OJ 1
#else
#define OJ 0
#endif
 
#define endl '\n'
#define TIMESTAMP merr << "Execution time: " << (double)clock()/CLOCKS_PER_SEC << " s.\n"
class C_ {}; template <typename T> C_& operator <<(C_& __m, const T& __s) { if (!OJ) cerr << "\E[91m" << __s << "\E[0m"; return __m; }
C_ merr;
 
struct __s { __s() { if (OJ) { ios_base::Init i; cin.sync_with_stdio(0); cin.tie(0); } } ~__s(){ TIMESTAMP; } } __S;
/// END OF TEMPLATE }}}

#define size_t unsigned long long

int main(void) {
    string s;
    size_t k,n;
    cin >> n >> k;
    cin >> s;
    if ('A' <= s[k-1] && s[k-1] <= 'Z') {
        s[k-1] -= 'A';
        s[k-1] += 'a';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
// C++bool練習用.cpp : アプリケーションのエントリ ポイントを定義します。
//
#include<iostream>

using namespace std;


int main()
{
	int i, j, k, l, m, N,cnt, T;
	long long int sum;
	long long int t[200000];
	cin >> N;
	cin >> T;
	for (i = 0; i < N; i++) {
		cin >> t[i];
	}
	sum = T;
	for (i = 0; i < N-1; i++) {
		if (t[i] + T <= t[i + 1]) {
			sum += T;
		}
		else {
			sum += t[i + 1] - t[i];
		}
	}
	cout << sum << endl;
    return 0;
}



Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;

int main()
{
   int n,c;
   int a[10],ans=0,Count=0;
   memset(a,0,sizeof(a));
   cin >> n;

   for(int i=0;i<n;i++)
   {
       cin >> c;
       if(c>=1&& c<=399) a[1] = 1;
       if(c>=400 && c<=799) a[2] = 1;
       if(c>= 800 && c<= 1199) a[3] = 1;
       if(c>=1200 && c<= 1599) a[4] = 1;
       if(c>=1600 && c<=1999) a[5] =1;
       if(c>=2000 && c<= 2399) a[6]=1;
       if(c>=2400 && c<= 2799) a[7] = 1;
       if(c>=2800 && c<=3199) a[8] =1;
        if(c>3199) ans++;
   }

   for(int i=1;i<=8;i++)
   {
       if(a[i]==1) Count++;
   }
   
   if(Count!=0)
    printf("%d ",Count);
    else
        printf("1 ");
    
    printf("%d\n",Count+ans);

}


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

using namespace std;

const int N = 100007;
const int INF = 1000000007;

int h[N], dp[N];

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

  for(int i = 1; i <= n; ++i) cin >> h[i];

  for(int i = 2; i <= n; ++i) {
    dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]);
    if(i > 2 && dp[i] > dp[i - 2] + abs(h[i - 2] - h[i]))
      dp[i] = dp[i - 2] + abs(h[i - 2] - h[i]);
  }

  cout << dp[n] << "\n";
  return 0;
}


Measured memory_bytes: 1024
a = []
for i in range(6):
  a.append(int(input()))
  
f = 0
for i in range(5):
  for j in range(5):
    if j > i:
      if a[j] - a[i] > a[5]:
        f = 1

print("Yay!") if f == 0 else print(":(")

Measured memory_bytes: 3060
//拘り者いろはちゃん//
//イテラブル版
//
using System;
using System.Linq;
using System.Collections.Generic;

namespace tst
{
    class Program
    {
        public static int[] Q = new int[4];//分けられた桁が保管　x=1000なら　Q[3]=1, Q[2]=0,,,
        public static int[] NG = new int[10];

        public static void Wake(int x)
        {//桁抽出
            for (int i = 0; i < 4; i++)
            {
                Q[i] = x % 10;
                x /= 10;
            }
        }
        public static bool Check(int now)
        {
            for (int i = 0; i < NG.Length; i++)
            {
                int Qtimes = 4;
                if (1 <= now && now <= 9) Qtimes = 1;//Nが1桁のスタートの時
                else if (10 <= now && now <= 99) Qtimes = 2;//Nが2桁の時
                else if (100 <= now && now <= 999) Qtimes = 3;//Nが3桁の時

                for (int j = 0; j < Qtimes; j++)
                {
                    if (NG[i] == Q[j]) return false;
                }
            }
            return true;
        }
        public static void Main()
        {   //支払金額N円、嫌いな数字K個
            string[] text1 = Console.ReadLine().Split(' ');
            int N = int.Parse(text1[0]);
            int K = int.Parse(text1[1]);
            //嫌いな数字0～9
            string[] D = Console.ReadLine().Split(' ');
            NG = D.Select(s => int.Parse(s)).ToArray();
            //逆に使える数の配列
            List<string> All = new List<string>() { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
            for (int i = 0; i < K; i++)
            {
                All.Remove(D[i]);
            }
            int[] Ok = new int[10 - K];
            for (int i = 0; i < Ok.Length; i++)
            {
                Ok[i] = int.Parse(All[i]);
            }
            bool flag = false;
            for (int i = N; i < 10000; i++)
            {
                Wake(i);//Q[0],,Q[3]
                if (Check(i))
                {
                    //終了条件
                    flag = true;
                    Console.WriteLine(i);
                    break;
                }
            }
            if (!flag)//4桁で成功しなかったら
            {
                //４ケタで支払えず、minが初期値のままだった場合//５ケタの最小の数を返す
                if (Ok[0] == 0)
                {
                    Console.WriteLine(Ok[1] * 10000);
                }
                else if (1 <= Ok[0] && Ok[0] <= 9)
                {
                    Console.WriteLine(Ok[0] * 10000 + Ok[0] * 1000 + Ok[0] * 100 + Ok[0] * 10 + Ok[0]);
                }
            }

        }

    }
}

Measured memory_bytes: 13280
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> p(n);
    map<int, int> m;
    forn(i, 0, n) {
        scanf(" %d", &p[i]);
        m[p[i]] = i;
    }
    int mx = 0;
    map<int, int> dp;
    forn(i, 0, n + 1) dp[i] = 0;
    forn(i, 0, n) {
        dp[p[i]] = dp[p[i] - 1] + 1;
        mx = max(mx, dp[p[i]]);
    }
    printf("%d\n", n - mx);
    return 0;
}


Measured memory_bytes: 19840
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

k,x = LI()

if 500*k>=x:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 5172
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;

int main(){
    ll b=0,c=0,d=0,ans=0,ret=M,n,m;
	string s;
	bool x = false;
	cin >> s;
	rep(i,s.size()){
		if(s[i] == '2') ans++;
	}
	cout << ans << endl;
    return 0;
}  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0 || c>0)
    {
        c=c-b;
        a=a-d;
        if(c<=0)
        {
            cout<<"Yes"<<endl;
            break;
        }
        else if(a<=0)
        {
            cout<<"No"<<endl;
            break;
        }
    }
}






Measured memory_bytes: 3532
#include<iostream>
using namespace std;
typedef long long ll;

ll mod = 1e9 + 7, fac[((int)1e6 + 5)], v[((int)1e6 + 5)];

ll modRec(ll a, ll b) {
	if (b == 0)return 1;
	if (b % 2 == 0)return modRec((a * a) % mod, b / 2);
	return ((a % mod) * modRec((a * a) % mod, b / 2)) % mod;
}

int main() {
	fac[0] = 1, v[0] = 1;
	for (int i = 1; i <= 1e6; i++) {
		fac[i] = (i * fac[i - 1]) % mod;
		v[i] = modRec(fac[i], mod - 2);
	}
	ll h, w, a, b, ans = 0; cin >> h >> w >> a >> b;
	for (ll i = b; i < w; i++) {
		ll p = i, q = h - a - 1, r = w - i - 1, s = a - 1;
		ll x = (((fac[p + q] * v[p]) % mod) * v[q]) % mod;
		x *= (((fac[r + s] * v[r]) % mod) * v[s]) % mod;
		ans = (ans + x) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15872
#include <stdio.h>

int main( ) {
	int n;
	int R[200000];
	int i;
	int min;
	int score;
	int buff;

	scanf("%d", &n);

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

	min = R[0];
	score = R[1] - R[0];

	for (i = 1; i < n; i++) {
		score = (score < (R[i] - min)) ? R[i] - min : score;
		if (min > R[i]) min = R[i];
	}

	printf("%d\n", score);

	return 0;
}

Measured memory_bytes: 1376
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] line = br.readLine().toCharArray();
		Map<Character,Integer> map = new HashMap<Character,Integer>();
		
		for(char c : line){
			if(!map.containsKey(c)){
				map.put(c, 1);
			}else{
				map.put(c, map.get(c)+1);
			}
		}
		
		for(int i : map.values()){
			if(i%2!=0){
				System.out.println("No");
				return;
			}
		}
				
		System.out.println("Yes");
	}
}


Measured memory_bytes: 8020
a=gets.split("").map(&:to_i)
a=a[0..-2]

b=0

i=-1
loop{
  unless a[i]  
    break
else
    k=10**(-i-1)
    b+=a[i]*k
end
i-=1
    
}

sum=a.inject(:+)


if b%sum==0
    puts "Yes"
else
    puts "No"
end






Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define INF (1e9)
#define N 16
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

struct dat{
  int cost, ay, ax, by, bx, cy, cx; 
};

int w, h, n;
bool d[N][N][N][N][N][N];
string s[16];
int ay, ax, by, bx, cy, cx;
int dy[5]={-1,0,1,0,0};
int dx[5]={0,1,0,-1,0};

queue<dat> q;

bool check(int nay, int nax){
  if(nay<0||nax<0||h<=nay||w<=nax) return false;
  if(s[nay][nax]=='#') return false;
  return true;
}

bool check2(int Ay,int Ax,int By,int Bx,int ai,int bi){
  
  if(Ay==By){
    if(Ax+1==Bx&&ai==1&&bi==3) return false;
    if(Bx+1==Ax&&bi==1&&ai==3) return false;
  }
  
  if(Ax==Bx){
    if(Ay+1==By&&ai==2&&bi==0) return false;
    if(By+1==Ay&&bi==2&&ai==0) return false;
  }
  
  return true;
}

int bnf(){
  
  memset(d,0,sizeof(d));
  
  d[ay][ax][by][bx][cy][cx]=1;
  q.push(dat{0,ay,ax,by,bx,cy,cx});
  
  int res;
  
  while(!q.empty()){
    
    dat t=q.front(); q.pop();
    
    if(n==1&&s[t.ay][t.ax]=='A'+s[ay][ax]-'a'){
      res=t.cost;
      break;
    }
    
    if(n==2&&s[t.ay][t.ax]=='A'+s[ay][ax]-'a'&&
       s[t.by][t.bx]=='A'+s[by][bx]-'a'){
      res=t.cost;
      break;
    }
    
    if(n==3&&s[t.ay][t.ax]=='A'+s[ay][ax]-'a'&&
       s[t.by][t.bx]=='A'+s[by][bx]-'a'&&
       s[t.cy][t.cx]=='A'+s[cy][cx]-'a'){
      res=t.cost;
      break;
    }
    
    rep(i,5){
      int nay=dy[i]+t.ay, nax=dx[i]+t.ax;
      if(!check(nay,nax)) continue;
      
      rep(j,5){
	int nby=dy[j]+t.by, nbx=dx[j]+t.bx;
	if(n==1) nby=0, nbx=0;
	if(n>=2&&!check(nby,nbx)) continue;
	
	rep(k,5){
	  
	  int ncy=dy[k]+t.cy, ncx=dx[k]+t.cx;
	  if(n<=2) ncy=0, ncx=0;
      	  if(n==3&&!check(ncy,ncx)) continue;
      
	  if(n>=2&&!check2(t.ay,t.ax,t.by,t.bx,i,j)) continue;
	  if(n==3&&!check2(t.ay,t.ax,t.cy,t.cx,i,k)) continue;
	  if(n==3&&!check2(t.by,t.bx,t.cy,t.cx,j,k)) continue;
	  
	  if(n>=2&&nay==nby&&nax==nbx) continue;
	  if(n==3&&nay==ncy&&nax==ncx) continue;
	  if(n==3&&nby==ncy&&nbx==ncx) continue;

	  if(!d[nay][nax][nby][nbx][ncy][ncx]){
	    d[nay][nax][nby][nbx][ncy][ncx]=1;
	    q.push(dat{t.cost+1,nay,nax,nby,nbx,ncy,ncx});
	  }
	  
	}
      }
    }
  }
  
  while(!q.empty()) q.pop();
  
  return res;  
}

int main(){
  
  while(1){
    
    cin>>w>>h>>n;
    if(!w&&!h&&!n) break;
    
    unordered_set<char> memo;

    ay=ax=by=bx=cy=cx=0;
    
    getline(cin,s[0]);
    rep(i,h){
      getline(cin,s[i]);
      rep(j,w){
	char c=s[i][j];
	if('a'<=c&&c<='z'&&!memo.count(c)){
	  if(memo.size()==0) ay=i, ax=j;
	  if(memo.size()==1) by=i, bx=j;
	  if(memo.size()==2) cy=i, cx=j;
	  memo.insert(c);
	}
      }
    }
    
    cout<<bnf()<<endl;
      
  }
  
  return 0;
}

Measured memory_bytes: 25748
import java.util.*;
 
public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int C = scan.nextInt();
    int D = 0;
    
    D = B + C - A;
    if(D >= 0){
      System.out.println(D);
    } else {
      System.out.println(0);
    }

  }
}

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

int main() {
  int A,B,flag = 0;
  cin >> A >> B;
  for(int i = 1;i <= 1000;i++){
    if(floor(i * 0.08) == A && floor(i * 0.1) == B){
      cout << i << endl;
      flag = 1;
      break;
    }
  }
  if(flag == 0){
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ans =INT_MAX;
void mincost(vector<int> & v,int i,int n,int res,vector<int> &dp)
{
	if(i+1==n)
    {
      dp[i] = min(ans,res);
    }
  if(i+1<n)
  {
      if(dp[i+1]==-1)
      {
          res = res+abs(v[i]-v[i+1]);
          dp[i]=res;
          mincost(v,i+1,n,res+abs(v[i]-v[i+1]),dp);
      }
      else
      {
          res = res+dp[i+1];
          return ;
      }
      
  }
   if(i+2<n)
   {
       if(dp[i+2]==-1)
       {
          res = res+abs(v[i]-v[i+2]);
          dp[i] = res+abs(v[i]-v[i+2]);
          mincost(v,i+2,n,res+abs(v[i]-v[i+2]),dp); 
       }
       else
       {
            res = res+dp[i+2];
            return ;
       }
       
   }
         
      
              
    return;
}
int main() {
	
	int n;
	cin>>n;
	vector<int> v(n+1);
	for(int i=1;i<=n;i++)
	{
	    cin>>v[i];
	}
	vector<int> dp(n+1,0);
	int i=0,j=0;
	dp[2] =abs(v[2]-v[1]);
	for(int i=3;i<=n;i++)
	{
	    dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
	}
	cout<<dp[n]<<endl;
   // mincost(v,i,n,0,dp);
    /*for(int i=0;i<dp.size();i++)
    {
        cout<<dp[i]<<" ";
    }
    cout<<ans<<endl;*/
    return 0;

}


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

int main(){
  typedef struct card{
    int num[4];//?????????????????????
    int sr;//??????????????????
  }card_sd;
  typedef struct inout{
    int num[4];
    int sr;
  }inout_sd;
  card_sd card;
  inout_sd inout;
  vector<int> bit;
  vector<int> hit;
  int h = 0;
  int abit = 0;
  int ahit = 0;

  for(h = 0;;h++){
    cin >> card.sr;

    if(card.sr == 0){
      break;
    }
    for(int g = 0;g<4;g++){
      card.num[3-g] = (card.sr)%10;
      card.sr /= 10;
    }
    cin >> inout.sr;

    for(int g = 0;g<4;g++){
      inout.num[3-g] = (inout.sr)%10;
      inout.sr /= 10;
    }
    for(int n = 0;n<4;n++){
      for(int t = 0;t<4;t++){
        if(card.num[n] == inout.num[t]){
          if(n == t){
            abit += 1;
          }else{
            ahit += 1;
          }
        }
      }
    }
    bit.push_back(abit);
    hit.push_back(ahit);
    abit = 0;
    ahit = 0;
  }
  for(int n = 0;n<h;n++){
    cout << bit[n] << " " << hit[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 1344
#include <iostream>
#include <numeric>
#include <utility>
#include <map>

using namespace std;
using ll = long long;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

const ll MOD = 1000000007;

#include <cstdint>

template <std::uint_fast64_t Mod>
class ModInt {
  using u64 = std::uint_fast64_t;

 public:
  u64 val;

  constexpr ModInt(const u64 x = 0) noexcept : val(x % Mod) {}
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    val += rhs.val;
    if (val >= Mod) {
      val -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (val < rhs.val) {
      val += Mod;
    }
    val -= rhs.val;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    val = val * rhs.val % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    u64 exp = Mod - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

template <typename T>
T power(T x, int n) {
  T ans{1};
  while (n) {
    if (n % 2) ans *= x;
    x *= x;
    n >>= 1;
  }
  return ans;
}

using mint = ModInt<MOD>;

int main() {
  int N;
  cin >> N;
  
  ll A,B;
  ll zero{0};

  map<pair<ll,ll>,pair<ll,ll>> m; 
  for (int i = 0; i < N; i++) {
    cin >> A >> B;

    if (!A && !B) {
      ++zero;
      continue;
    }

    if (!A) {
      m[{0,1}].first += 1;
      continue;
    } else if (!B) {
      m[{0,1}].second += 1;
      continue;
    }
    
    ll g = gcd(A,B);
    A /= g;
    B /= g;
    if (A < 0) {
      A *= -1;
      B *= -1;
    }

    if (B >= 0) {
      m[{A,B}].first += 1;
    } else {
      m[{-B,A}].second += 1;
    }
  }

  mint ans {1};
  for (auto & [key,value]: m) {
    mint p = power(mint(2),value.first) + power(mint(2),value.second) - 1;
    ans *= p;
    //    cout << key.first << " " << key.second << ": "
    //         << value.first << " " << value.second << ", "
    //         << p.val << " " << ans.val << endl;
  }
  //  cout << "zero: " << zero << endl;
  ans += zero;
  ans -= 1;

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


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

#define ll       long long
#define LL       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(s)    (int) s.size()
#define all(s)   s.begin(), s.end()

template<typename T> inline void smin(T &a, T b) {
    a = a < b ? a : b;
}
template<typename T> inline void smax(T &a, T b) {
    a = a > b ? a : b;
}

template<typename T> inline void Int(T &n) {
    n = 0;
    int f = 1;
    register int ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n *= f;
}
template<typename T, typename TT> inline void Int(T &n, TT &m) {
    Int(n), Int(m);
}
template<typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) {
    Int(n), Int(m, l);
}

#define error(args...) { string _s = #args; replace(all(_s), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {
    cout << endl;
}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

const int mod = (int) 1e9 + 7;

int add(int a, int b) {
    a += b;
    if(a >= mod) a -= mod;
    return a;
}
int sub(int a, int b) {
    a -= b;
    if(a <= 0) a += mod;
    return a;
}
int mul(int a, int b) {
    return (ll) a * b % mod;
}

const int inf = (int) 1e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int   N = (int) 3e2 + 5;

double p[N][N][N];
double ev[N][N][N];


int solve() {
    int n;
    Int(n);
    vector<int> cnt(4, 0);
    for(int i = 1; i <= n; i++) {
        int c ;
        Int(c);
        cnt[c]++;
    }
    p[cnt[1]][cnt[2]][cnt[3]] = 1.0;
    for(int c = n; c >= 0; c--) {
        for(int b = n; b >= 0; b--) {
            for(int a = n; a >= 0; a--) {
                if(a + b + c == 0 or a + b + c > n) continue;
                double p_waste = (double) (n - (a + b + c)) / n;
                double ev_waste = p_waste / (1.0 - p_waste) + 1.0;
                ev[a][b][c] += ev_waste * p[a][b][c];

                if(a != 0) {
                    double p_go = (double)a / (a + b + c);
                    p[a - 1][b][c] += p[a][b][c] * p_go;
                    ev[a - 1][b][c] += ev[a][b][c] * p_go;
                }

                if(b != 0) {
                    double p_go = (double)b / (a + b + c);
                    p[a + 1][b - 1][c] += p[a][b][c] * p_go;
                    ev[a + 1][b - 1][c] += ev[a][b][c] * p_go;
                }

                if(c != 0) {
                    double p_go = (double)c / (a + b + c);
                    p[a][b + 1][c - 1] += p[a][b][c] * p_go;
                    ev[a][b + 1][c - 1] += ev[a][b][c] * p_go;
                }
            }
        }
    }
    printf("%.10f\n", ev[0][0][0]);
    return 0;
}

int main() {
    int test = 1, tc = 0;
    //Int(test);
    while(test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}




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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
vi g[252521];

ll modpow(ll a, ll b){
    ll r = 1;
    while(b){
        if(b&1)r=r*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return r;
}
ll modinv(ll a){
    return modpow(a, MOD-2);
}

int sz[252521];
int dfs(int p, int bef){
    sz[p] = 1;
    for(int to : g[p])if(to != bef){
        sz[p] += dfs(to, p);
    }
    return sz[p];
}

ll ans = 0;
void dfs2(int p, int bef){
    {
        ll prod = modpow(2,n-1);
        ll sum = 1;
        for(int to : g[p]){
            ll s2 = modpow(2,sz[to]);
            prod = prod * modinv(s2) % MOD;
            sum = (sum + s2 - 1 + MOD) % MOD;
        }
        ll add = (modpow(2,n-1) - prod * sum % MOD + MOD) % MOD;
        ans = (ans + add) % MOD;
    }
    for(int to : g[p])if(to != bef){
        int old = sz[to];
        sz[p] -= sz[to];
        sz[to] = n;
        dfs2(to, p);
        sz[to] = old;
        sz[p] = n;
    }
}

int main(){
    scanf("%d",&n);
    REP(i,n-1){
        int a,b;
        scanf("%d%d",&a,&b);
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0,-1);
    dfs2(0,-1);
    ans = ans * modinv(modpow(2,n)) % MOD;
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 28800
#include"stdio.h"
#include"stdlib.h"
#include"queue"
#include"map"
#include"iostream"
#include"string.h"
#include"algorithm"
using namespace std;
struct mmm
{
	char kk[10];
	int x,sum;
}vv;
char xx[10];
int minn = 0;
char ww[10] = {"01234567"};
int dir[8][3] = {{1,4},{0,2,5},{1,3,6},{2,7},{0,5},{1,4,6},{2,5,7},{3,6}};
map <string,int> mp;
void bfs(int x1)
{
	queue <mmm> qq;
	vv.x = 0;
	vv.sum = 0;
	strcpy(vv.kk,ww);
	qq.push(vv);
	int l = 0;
	while(!qq.empty())
	{
		vv = qq.front();
		qq.pop();
		char yy[10];
		strcpy(yy,vv.kk);
		if(l && strcmp(yy,ww) == 0) continue;
		if(mp[yy]) continue;
		l ++;
		mp[yy] = vv.sum;
		int x0 = vv.x;
		int sum0 = vv.sum;
		if(x0 == 0 || x0 == 3 || x0 == 4 || x0 == 7)
		{
			for(int i = 0;i < 2;i ++)
			{
				vv.x = dir[x0][i];
				swap(vv.kk[vv.x],vv.kk[x0]);
				vv.sum = sum0 + 1;
				qq.push(vv);
				swap(vv.kk[vv.x],vv.kk[x0]);
			}
		}
		else
		{
			for(int i = 0;i < 3;i ++)
			{
				vv.x = dir[x0][i];
				swap(vv.kk[vv.x],vv.kk[x0]);
				vv.sum = sum0 + 1;
				qq.push(vv);
				swap(vv.kk[vv.x],vv.kk[x0]);
				//strcpy(vv.kk,yy);
			}
		}
	}
}
int main()
{
	int a,b,c,d;
	int pp[10];
	bfs(0);
//	freopen("ooo.txt","r",stdin);
//	freopen("out1.txt","w",stdout);
	while(~scanf("%d",&pp[0]))
	{
		xx[0] = pp[0] + '0';
		if(!pp[0]) b = 0;
		for(int i = 1;i < 8;i ++)
		{
			scanf("%d",&pp[i]);
			xx[i] = pp[i] + '0';
			if(!pp[i])
			{
				b = i;
			}
		}
		xx[8] = '\0';
		minn = 0;
		printf("%d\n",mp[xx]);
	}
	return 0;
}

Measured memory_bytes: 3468
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>
using ll = long long;
using namespace std;
int N, M;
ll x[1010], y[1010], z[1010];
int a[2] = {1, -1};
int main(void)
{
    cin >> N >> M;
    for (int i = 0; i < N; ++i)
        cin >> x[i] >> y[i] >> z[i];

    ll ans = 0;
    for (int bit = 0; bit < (1 << 3); ++bit)
    {
        ll t[N];
        for (int i = 0; i < N; ++i)
        {
            t[i] = a[bit & 1] * x[i] + a[(bit >> 1) & 1] * y[i] + a[(bit >> 2) & 1] * z[i];
        }
        sort(t, t + N);
        reverse(t, t + N);
        ll tmp = 0;
        for (int i = 0; i < M; ++i)
        {
            tmp += t[i];
        }

        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H,W;
  std::cin >> H >> W;
    vector<vector<int>> table(10, vector<int>(10));
    for (size_t i = 0; i < 10; i++) {
      for (size_t j = 0; j < 10; j++) {
         std::cin >> table[i][j];
      }
    }
    for (int k = 0; k < 10; k++){       // 経由する頂点
      for (int i = 0; i < 10; i++) {    // 始点
        for (int j = 0; j < 10; j++) {  // 終点
          table[i][j] = min(table[i][j], table[i][k] + table[k][j]);
        }
      }
    }
    int x =0;
    int a =0;
    for (size_t i = 0; i < H; i++) {
      for (size_t j = 0; j < W; j++) {

        std::cin >> a;
        if (a>= 0) {
                x += table[a][1];
        }
      }
    }
    std::cout << x << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  double a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  set<double> water;
  set<double> sugar;
  
  vector<int> dp(3000, 0);
  dp[0] = 1;
  for(int i = 0; i < 30; i++) {
    if(dp[i] == 1) {
      water.insert(i * 100);
      if(i + a < 30) {
        dp[i + a] = 1;
      }
      if(i + b < 30) {
        dp[i + b] = 1;
      }
    }
  }
  for(int i = 0; i<3000; i++){
    dp[i] = 0;
  }

  dp[0] = 1;
  for(int i = 0; i < 3000; i++) {
    if(dp[i] == 1) {
      sugar.insert(i);
      if(i + c < 3000) {
        dp[i + c] = 1;
      }
      if(i + d < 3000) {
        dp[i + d] = 1;
      }
    }
  }
  double per = 0;
  pair<int, int> ans = {0, 0};
  for(auto p : water) {
    if(p == 0){
      continue;
    }
    //cout << p << " ";
    for(auto q : sugar) {
      //cout << q << " ";
      if(p + q > f) {
        break;
      }
      if(p * e < q * 100) {
        break;
      }
      if(per * (p + q) <= 100.0 * q) {
        per = 100.0 * q /(double)(p + q);
        ans.first = p;
        ans.second = q;
      }
    }
    //cout << endl;
  }
  cout << ans.first + ans.second << " " << ans.second << endl;
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <set>

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	int p[100000];
	rep(i,n) scanf("%d",p+i), p[i]--;

	int f[100000];
	rep(i,n) f[p[i]]=i;

	set<int> S={f[n-1],-2,-1,n,n+1};

	long long ans=0;
	for(int i=n-2;i>=0;i--){
		auto it=S.upper_bound(f[i]);
		int c=*it;
		++it;
		int d=*it;
		--it; --it;
		int b=*it;
		--it;
		int a=*it;

		a=max(a,-1);
		b=max(b,-1);
		c=min(c,n);
		d=min(d,n);

		if(c< n) ans+=(i+1LL)*(f[i]-b)*(d-c);
		if(b>=0) ans+=(i+1LL)*(b-a)*(c-f[i]);

		S.insert(f[i]);
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <limits.h>
#define NIL NULL
#define TREE_VALUE INT_MAX

typedef struct Node* NodePointer;
typedef NodePointer Tree;

typedef struct Node {
  int key;
  NodePointer p, left, right;
} Node;

NodePointer makeNode(int key) {
  NodePointer node = (NodePointer)malloc(sizeof(Node));
  node->key = key;
  node->p = node->left = node->right = NIL;
  return node;
}

void treeInsert(Tree tree, NodePointer z) {
  NodePointer y = NIL;
  NodePointer x = tree->left;
  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->p = y;
  if(y == NIL) {
    tree->left = z; // if T is empty
  } else if(z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
}

void printInorder(NodePointer node) {
  if(node->left  != NIL) printInorder(node->left);
  if(node->key != TREE_VALUE) printf(" %d", node->key);
  if(node->right != NIL) printInorder(node->right);
}

void printPreorder(NodePointer node) {
  if(node->key != TREE_VALUE) printf(" %d", node->key);
  if(node->left  != NIL) printPreorder(node->left);
  if(node->right != NIL) printPreorder(node->right);
}

int main() {
  int N, key;
  char str[10];
  Tree tree;

  // initialize tree
  tree = makeNode(TREE_VALUE);

  scanf("%d", &N);
  while(N--) {
    scanf("%s", str);
    if(str[0] == 'i') {
      scanf("%d", &key);
      treeInsert(tree, makeNode(key));
    } else {
      printInorder(tree);
      printf("\n");
      printPreorder(tree);
      printf("\n");
    }
  }
  return 0;
}

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

int main() {
	int n,k;
  	cin>>n>>k;
  
  	vector <int> p(n);
  	rep(j,n){cin>>p[j];}
  
  	sort(p.begin(), p.end());
  
  	ll ans = 10000000000;
  
  	for(int i=0;i<n-k+1;i++){
    	ll tmp=p[i+k-1]-p[i];
        	ans=min(ans,tmp);
        }
    
      cout<<ans<<endl;
    }

Measured memory_bytes: 3756
import itertools
from scipy.sparse.csgraph import floyd_warshall

n,m,l=map(int,input().split())
arr=list(map(int,input().split()))
d=[[10**10 for i in range(n)] for j in range(n)]
for i in range(m):
  u,v,w=map(int,input().split())
  d[u-1][v-1]=w
  d[v-1][u-1]=w
for i in range(n):
  d[i][i]=0
d=floyd_warshall(d,directed=False)
c=list(itertools.permutations(arr,min(8,l)))
ans=10**10
for i in c:
  tmp=0
  for j in range(min(8,l)-1):
    tmp+=d[i[j]-1][i[j+1]-1]
  ans=min(tmp,ans)
print(int(ans))

Measured memory_bytes: 22276
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function lower_bound(d,a,b,e){for(var c;1<b-a;)d[c=0|(a+b)>>1]<e?a=c:b=c;return d[a]<e?b:a};

console.log(main());
function main(){
  var s = o.a(1);
  var t = o.a(1);
  var a = {};
  var sl = s.length, tl = t.length;
  var ans = 0, k = 0;
  for(var i = 0; i < sl; i++){
    if(a[s[i]])a[s[i]].push(i);
    else a[s[i]] = [i];
  }
  for(var i = 0; i < tl; i++){
    var u = t[i];
    if(!a[u])return -1;
    var j = lower_bound(a[u],0,a[u].length,k);
    if(j === a[u].length){
      ans += sl;
      j = 0;
    }
    k = a[u][j]+1;
  }
  return ans+k;
}

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

int main(){
	long long a,b;
	cin >> a >> b;
	if(a*b<=0)cout << "Zero" << endl;
	else if(a>0)cout << "Positive" << endl;
	else{
		if((b-a)%2==0)cout << "Negative" << endl;
		else cout << "Positive" << endl;
	}
	
	return 0;
}

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

int x[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
  int k;
  cin >> k;
  --k;
  cout << x[k] << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            var count = 0;
            var result = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] == 'R') count++;
                else if (count > result)
                {
                    result = count;
                    count = 0;
                }
                else
                {
                    count = 0;
                }
            }
            if (count > result) result = count;
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 25756
#include<iostream>
using namespace std;
int main() {
	int n;
	bool a=false,b=false,c=false,d=false;
	cin>>n;
	for(int i=0; i<n; i++) {
		char ch;
		cin>>ch;
		switch(ch) {
			case 'P':
				a=true;
				break;
			case 'Y':
				b=true;
				break;
			case 'W':
				c=true;
				break;
			case 'G':
				d=true;
				break;
		}
	}
	if(a+b+c+d==4)
		cout<<"Four";
	else
		cout<<"Three";
	return 0;
}

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

using namespace std;

int main(){
        string s,t;
        bool ans=false;
        cin >> s >> t;
        for(int i=0;i<(int)s.length();i++){
            s.push_back(s[0]);
            s.erase(s.begin());
            if(s==t){
                    ans=true;
                    break;
            }
        }
        if(ans) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

istream& operator>> (istream& a, pii& b) {
    cin >> b.first >> b.second;
    return a;
}

ostream& operator<< (ostream& a, const pii& b) {
    cout << "{" << b.first << ", " << b.second << "}";
    return a;
}

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 100;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e15;
    // const int mod = 2600000069; 
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans;
}
/*

*/


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

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  rep(i,n) {
    cout << s[i] << t[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (m,k) = get!(usize, usize);
    if m == 0 {
        if k == 0 {
            println!("0 0");
        } else {
            println!("-1");
        }
        return;
    } else if m == 1 {
        if k == 0 {
            println!("0 0 1 1");
        } else {
            println!("-1");
        }
        return;
    }
    if (1<<m) <= k {
        println!("-1");
        return;
    }

    for j in (0..k).chain((k+1)..(1<<m)) {
        print!("{} ", j);
    }
    print!("{} ", k);
    for j in (0..k).chain((k+1)..(1<<m)).rev() {
        print!("{} ", j);
    }
    println!("{} ", k);
}


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

#define     ll      long long
#define     pb      push_back
#define     eps     1e-9
#define     bug     cout<<"debug"<<endl;
using namespace std;
typedef long double ld;

int main()
{
    int a;
    string s;
    cin>>a>>s;
    if(a<3200)
    {
        cout<<"red"<<endl;
    }
    else
    {
        cout<<s<<endl;
    }
    return 0;
}


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

int main(void)
{
    int N;

    cin >> N;
    vector<int> vec(N);

    for(int i = 0; i < N; i++) cin >> vec.at(i);

    int point = vec.at(0);
    int cnt = 0;
    int j;

    for(j = 0; j < N -1; j++)
    {
        cnt++;
        if(point == 2) break;
        point = vec.at(point - 1);
    }

    if(j == N-1) cout << -1 << endl;
    else cout << cnt << endl;

    

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
using namespace std; string s;
const int k = 8100;
int cnt, dpx[2670][2 * k + 10], x, dpy[2670][2 * k + 10], y, mode = 2;
int get() { int r; cin >> r; return r; }
signed main() {
	cin >> s; s += 'T'; dpy[y++][k] = 1;
	for (char c : s) {
		if (c == 'F')cnt++;
		else {
			if (mode == 2) dpx[x++][cnt + k] = 1;
			else if (mode == 1 && cnt > 0) {
				for0(i, 2 * k)
					if (dpy[y - 1][i]) {
						if (i + cnt < 2 * k)dpy[y][i + cnt] = 1;
						if (i - cnt >= 0)dpy[y][i - cnt] = 1;
					}
				y++;
			}
			else if (mode == 0 && cnt > 0) {
				for0(i, 2 * k)
					if (dpx[x - 1][i]) {
						if (i + cnt < 2 * k)dpx[x][i + cnt] = 1;
						if (i - cnt >= 0)dpx[x][i - cnt] = 1;
					}
				x++;
			}
			cnt = 0; mode = (++mode) % 2;
		}
	}
	cout << (dpx[x - 1][get() + k] && dpy[y - 1][get() + k] ? "Yes\n" : "No\n");
}

Measured memory_bytes: 254336
#include <iostream>
#include <string>
//#include <
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int n;
string s[10000];

int index = 0;

int solve(bool plus,int depth){
  depth++;
  int ans;
  if(plus)ans = 0;
  else ans = 1;
  while(index < n && s[index].size() >= depth + 1){//.wokuryosinai
  if(plus){
    if(s[index][depth] == '+'){//moguru
    index++;
    ans += solve(true,depth);
    }else if(s[index][depth] == '*'){
      index++;
      ans += solve(false,depth);
    }else{//heiretsu
    ans += s[index][depth] - '0';
    index++;
    }
  }else{
    if(s[index][depth] == '+'){//moguru
    index++;
    ans *= solve(true,depth);
    }else if(s[index][depth] == '*'){
      index++;
      ans *= solve(false,depth);
    }else{//heiretsu
    ans *= s[index][depth] - '0';
    index++;
    }
  }
  }
return ans;
}

int main(){
  while(cin>>n,n){
    REP(i,n){
      cin>>s[i];
    }
    if(isdigit(s[0][0])){
      cout << s[0][0] << endl;
    }else{
      index = 1;
      if(s[0][0] == '+')cout << solve(true,0) << endl;
      else cout << solve(false,0) << endl;
    }
  }

}

Measured memory_bytes: 3152
S = input()
N = len(S) + 1

l = [0] * N
r = [0] * N

tmp_l = 0
# <,>,>の場合、l=[0,1,0,0]となる
for i in range(N - 1):
    if S[i] == "<":

        tmp_l += 1
        l[i + 1] = tmp_l
    else:
        tmp_l = 0

tmp_r = 0
# Sを逆からチェック
#<,>,>の場合、l=[0,2,1,0]となる
for i in range(N - 2, -1, -1):
    if S[i] == ">":
        tmp_r += 1
        r[i] = tmp_r
    else:
        tmp_r = 0

ans = 0
for i in range(N):
    ans += max(l[i], r[i])

print(ans)


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  int taka = 0;
  int ao = 0;
  
  while(a > 0){a -= d;ao ++;}
  while(c > 0){c -= b;taka ++;}
  
  if(taka <= ao)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int A[100000];
int n;

int binarySearch(int key)
{
  int left = 0;
  int right = n;
  int mid;
  while (left < right){
    mid = (left + right) / 2;
    if (A[mid] == key)
      {

	return 1;
      }
    if (key < A[mid])
      {
	right = mid;
      }
    if (key > A[mid])
      {
	left = mid + 1;
      }
  }
  return 0;
}
      
  int main ()
  {

    int i,n2,keyword,judge=0;
    int M[100000];
  scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d",&A[i]);
    }
  
    scanf("%d",&n2);
      for(i=0;i<n2;i++){
	scanf("%d",&M[i]);
      }
      
 
      for(i=0;i<n2;i++){    
    if(binarySearch(M[i]))
      {

	judge++;
      }
      }
      printf("%d\n",judge);
    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	ll a, b;
	cin >> a >> b;
	ll ans = 0;
	while (a <= b) {
		ans++;
		a *= 2;
	}
	cout << ans << endl;
	return 0;
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

int main(void){
    int N, K, Q;
    scanf("%d %d %d",&N, &K, &Q);

    int A[Q+1]; //A[1]~A[Q]に格納
    for(int i=1;i<=Q;i++){
        scanf("%d",&A[i]);
    }

    int B[N+1]; //B[1]~B[N]に格納、B[i]はi番目の人の得点
    for(int i=1;i<=N;i++){
        B[i]=K-Q;
    }

    for(int i=1;i<=Q;i++){
        B[A[i]]++;
    }

    for(int i=1;i<=N;i++){
        if(B[i]>0){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }

    return 0;
}


//300点
//特に困らなかった！

Measured memory_bytes: 1280
#include <queue>
#include <cstdio>
#include <vector>
#include <iostream>
typedef long long ll;

int n,l[100005],r[100005];
ll Ans,tl,tr,lq,rq;
std::priority_queue<ll,std::vector<ll>,std::less<ll> > L;
std::priority_queue<ll,std::vector<ll>,std::greater<ll> > R;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d%d",&l[i],&r[i]),l[i]=r[i]-l[i];
    L.push(r[1]),R.push(r[1]);
    for(int i=2;i<=n;++i)
    {
        tl-=l[i-1],tr+=l[i],lq=L.top()+tl,rq=R.top()+tr;
        if(r[i]>=lq&&r[i]<=rq)L.push(r[i]-tl),R.push(r[i]-tr);
        else if(r[i]>=lq)Ans+=r[i]-rq,R.pop(),L.push(rq-tl),R.push(r[i]-tr),R.push(r[i]-tr);
        else Ans+=lq-r[i],L.pop(),R.push(lq-tr),L.push(r[i]-tl),L.push(r[i]-tl);
    }
    printf("%lld\n",Ans);
    return 0;
}

Measured memory_bytes: 2804