akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  int t, a;
  while (cin >> n >> t >> a) {
    vector<lli> h(n);
    cin >> h;

    auto fn = [&] (lli h) { return abs((t * 1000 - h * 6) - a * 1000); };

    lli idx = 0;
    for (int i = 0; i < n; ++i) {
      if (fn(h[idx]) > fn(h[i])) {
        idx = i;
      }
    }
    cout << idx + 1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n, p;
	cin >> n >> p;
	int a[51];
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	long long int result[51][2] = {};
	result[0][0] = 1;
	for(int i = 0; i < n; i++){
		result[i + 1][0] = result[i][0] + result[i][a[i + 1] % 2];
		result[i + 1][1] = result[i][1] + result[i][(1 + a[i + 1] % 2) % 2];
	}
	cout << result[n][p] << endl;
	return 0;
}

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

int v[4];
int e[51];
int a[51];
double dp[51][5010][2];

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

	int vn, g, en;
	while (cin >> vn >> g >> en , vn) {

		for (int i = 0; i < vn; i++) {
			cin >> v[i];
		}

		memset(e, 0, sizeof e);
		for (int i = 0; i < en; i++) {
			int n;
			cin >> n;
			cin >> e[n] >> a[n];
		}

		memset(dp, 0, sizeof dp);
		dp[0][0][0] = 1.0;

		for (int i = 0; i < g; i++) {
			for (int j = 0; j <= 5000; j++) {
				for (int skip = 0; skip <= 1; skip++) {
					if (dp[i][j][skip] == 0) continue;

					int nj = j;
					if (skip == 0) {
						if (e[i] == 1) {
							int ni = min(i + a[i], g);
							dp[ni][j][1] += dp[i][j][0];
							continue;
						}
						if (e[i] == 2) nj = j + a[i];
						if (e[i] == 3) nj = max(0, j - a[i]);
					}

					for (int k = 0; k < vn; k++) {
						int ni = min(i + v[k], g);
						dp[ni][nj][0] += dp[i][j][skip] / vn;
					}
				}
			}
		}

		double ans = 0;
		for (int j = 0; j <= 5000; j++) {
			for (int s = 0; s < 2; s++) {
				ans += j * dp[g][j][s];
			}
		}
		cout << int(ans) << endl;
	}
}

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

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  cout << x * min(k, n) + y * max(0, n - k) << endl;
  return 0;
}


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



int main() {
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  mins(c,a+b+1);
  cout<<b+c<<endl;
  return 0;
}






















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

template<class T>
T gcd(T a,T b){
	return b ? gcd(b,a % b) : a;
}

signed main(){
	int t;
	cin >> t;
	for(int _t = 0;_t < t;_t++){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		int g = gcd(b,d);
		if(a >= b && d >= b && (b - a % b - 1) / g * g + a % b <= c) Yes();
		else No();
	}
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int h,w,k;
    cin>>h>>w>>k;
    char c[h][w];
    for (int i=0;i<h;i++)
        for (int j=0;j<w;j++)
            cin>>c[i][j];
    int lim1=pow(2,h);
    int lim2=pow(2,w);
    int ans=0;
    for (int i=0;i<lim1;i++){
        for (int j=0;j<lim2;j++){
            int cnt=0;
            for (int x=0;x<h;x++){
                for (int y=0;y<w;y++){
                    if(c[x][y]=='#' and !(i & 1<<x) and !(j & 1<<y))
                        cnt++;
                }
            }
            if(cnt==k) ans++;
        }
    }   
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 4096
s=input()
K=int(input())
a=[]

for i in range(K):
    for j in range(len(s)-i):
        a.append(s[j:j+i+1])
a.sort()
cnt=1
i=1
while cnt<K:
    if a[i]!=a[i-1]:
        cnt+=1
    i+=1
print(a[i-1])


Measured memory_bytes: 40944
import qualified Data.ByteString.Char8 as B
import Data.Maybe

div1 a b = let (d,m) = divMod a b in d + signum m

binSearch op xmin xmax p
 | succ xmin == xmax = if p xmin == EQ then xmin else xmax
 | otherwise = case p h of
  EQ -> binSearch op xmin h p 
  LT -> binSearch op h xmax p
  GT -> binSearch op xmin h p 
 where h = op xmin xmax

main = do
 [_,a,b] <- map read . words <$> getLine
 hs <- map (fst . fromJust . B.readInt) . B.words <$> B.getContents
 print (wideSpread a b hs)

wideSpread a b hs = binSearch med xmin xmax (explode a b hs)
 where
  med x y = x + div (y-x) 2
  xmin = 0
  xmax = sum . map (`div1` a) $ hs

explode a b hs x = compare x nmag
 where
  dadd = a - b
  mrest = map (max 0 . subtract (x*b)) hs
  nmag = sum . map (`div1` dadd) $ mrest

Measured memory_bytes: 8572
N = int(input())
ans = N % 10

if ans == 2 or ans == 4 or ans == 5 or ans == 7 or ans == 9:
    print('hon')
elif ans == 0 or ans == 1 or ans == 6 or ans == 8:
    print('pon')
elif ans == 3:
    print('bon')


Measured memory_bytes: 61884
def main():
    x,y=map(int,input().split())
    cnt=0
    if x==1:
        cnt+=300000
    elif x==2:
        cnt+=200000
    elif x==3:
        cnt+=100000
    if y==1:
        cnt+=300000
    elif y==2:
        cnt+=200000
    elif y==3:
        cnt+=100000
    if x==y==1:
        cnt+=400000
    print(cnt)
main()

Measured memory_bytes: 3060
#include<iostream>
#define MOD 1000000007LL
using namespace std;
int main(){
    long long n,ans=0LL;
    bool f0,f1;
    string s1,s2;
    cin>>n>>s1>>s2;
    ans=((f0=s1[0]==s2[0])?3LL:6LL);
    for(int i=1+!f0;i<n;i+=(f1?1:2),f0=f1){
        f1=(s1[i]==s2[i]);
        ans*=(f0?2LL:f1?1LL:3LL);
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        int K = sc.nextInt();
      
      List<Integer> a = new ArrayList<>();
      
      for(int i=0; i<N; i++){
      a.add(sc.nextInt());
      }
      Collections.sort(a);
      int sum =0;
      for(int i=0; i<K; i++){
      sum += a.get(i);
      }
      System.out.println(sum);
    }
}

Measured memory_bytes: 38916
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

// s = "112223" -> [[1,2],[2,3],[3,1]]
vector<pair<int,int>> rle (vector<int> x) {
  vector<pair<int,int>> res;
  int n = (int)x.size();
  for (int i = 0; i < n;) {
    int j = i;
    int cnt = 0;
    while (j < n && x[j] == x[i]) {
      ++j;
      ++cnt;
    }
    res.emplace_back(x[i], cnt);
    i = j;
  }
  return res;
}

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) {
    cin >> a[i];
  }

  int ans = 0;

  bool ex1 = false;
  rep(i,n) {
    if (a[i] == 1) ex1 = true;
  }
  if (!ex1) {
    cout << -1 << endl;
    return 0;
  }

  int now = 1;
  rep(i,n) {
    if (a[i] != now) {
      ans++;
    }
    else {
      now++;
    }
  }

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

Measured memory_bytes: 1024
#include <stdio.h>
void QSort(int x[ ], int left, int right);
void Swap(int x[ ], int i, int j);
void ShowData(int x[ ], int n);

void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }
    //ShowData(x, 10);               /* 途中経過を表示 */

    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

void ShowData(int x[ ], int n)
{
    int i;

    for (i = 0; i < n ; i++)
        printf("%d  ", x[i]);
    printf("\n");
}

int main(void){
    int i, n, k, l[51], sum=0;
    
    scanf(" %d %d", &n, &k);
    for(i=0; i<n; i++){
        scanf(" %d",&l[i]);
    }
    
    for(i=0; i<n; i++){
        //printf("%d ",l[i]);
    }
    //printf("\n");
    
    QSort(l, 0, n - 1);
    //printf("ソート後:\n");
    //ShowData(l, n);
    
    for(i=n-1; i>=(n-k); i--){
        sum = sum + l[i];
        //printf("sum->%d ", sum);
    }
    printf("%d\n", sum);
    
    return 0;
}

Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """
        親が同じか判別する
        """
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """
        yをxの根に繋ぐ
        """
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        """
        xとyが同じ連結成分か判別する
        """
        return self.find(x) == self.find(y)

    def size(self, x):
        """
        xの連結成分の大きさを返す
        """
        return -self.parents[self.find(x)]

    def kruskal(self, edge):
        """
        :param edge: edge = [(コスト, 頂点1, 頂点2),...]の形で重み付き隣接リストを渡して下さい
        :return: 最小全域木のコストの和
        """
        edge.sort()
        cost_sum = 0
        for cost, node1, node2 in edge:
            if not self.same(node1, node2):
                cost_sum += cost
                self.union(node1, node2)
        return cost_sum


def resolve():
    n = int(input())
    XY = [list(map(int, input().split())) for _ in range(n)]
    XY_sort = sorted([[xy[0], xy[1], i] for i, xy in enumerate(XY)])

    uf = UnionFind(n)
    stack = []
    for x, y, idx in XY_sort:
        mi = y
        mi_idx = idx
        while stack and XY[stack[-1]][1] < y:
            v = stack.pop()
            if mi > XY[v][1]:
                mi = XY[v][1]
                mi_idx = v
            uf.union(idx, v)
        stack.append(mi_idx)

    for i in range(n):
        print(uf.size(i))


if __name__ == '__main__':
    resolve()


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

int fac(int);

int main() {
  int n,i,j;
  double ans;
  double len=0;
  int c=0;
  int k=0;

  cin >> n;

  double x[n],y[n];

  for(i=0;i<n;i++){
    cin >> x[i] >> y[i];
  }

  for(i=0;i<n;i++) {
    for(j=i+1;j<n;j++) {
      len+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
      c++;
    }
  }

  if(n==2){
    ans = len;
  }
  else if(n>2) {
    for(i=0;i<=n-3;i++){k=fac(n)*(n-1)/c;}
    ans = len*k/fac(n);
  }

  cout << setprecision(10) << ans << endl;

  return 0;
}

int fac(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}


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

int main(){
	ll N, M;
	cin >> N >> M;
	if (N == 1) {
        if (M == 1) {
			cout << 1 << endl;
		}
		else {
			cout << M - 2 << endl;
		}
	}
	else if(M==1){
		cout << N - 2 << endl;
	}
	else {
		cout << (N - 2)*(M - 2);
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    vector<ll> X(5);
    cin >> N;
    REP(i, 5) {
        cin >> X[i];
    }
    ll m = *min_element(X.begin(), X.end());
    cout << (N - 1) / m + 5 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int i,j,l = str.length();
    for(i=0;i<l;i++)
    {
        if(str[i] == 'B'&&i == 0)
        {
            for(j=1;j<l;j++)
                str[j-1] = str[j];
            l--;
            i--;
        }
        if(str[i]=='B'&&i > 0)
        {
            for(j=i+1;j<l;j++)
                str[j-2] =str[j];
            l -= 2;
            i -= 2;
        }
    }
    cout<<str.substr(0,l)<<endl;
    return 0;

}

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

int main() {
	int n;
	int a, b;
	int sumA, sumB;
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		
		sumA = 0;
		sumB = 0;
		for(int i = 0; i < n; i++){
			cin >> a >> b;
			if(a > b){
				sumA += a + b;
			}else if(a < b){
				sumB += a + b;
			}else{
				sumA += a;
				sumB += b;
			}
		}
		
		cout << sumA << " " << sumB << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

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;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  int r, g, b;
  r = g = b = -1;
  lint ans = 1;
  
  lint n; cin >> n;
  for(int i = 0; i < n; i++) {
    lint a; cin >> a;
    a--;
    lint cnt = 0;
    cnt += (r == a);
    cnt += (b == a);
    cnt += (g == a);

    ans *= cnt;
    ans %= MOD;
    
    if(r == a) {
      r++;
      continue;
    }
    if(b == a) {
      b++;
      continue;
    }
    if(g == a) {
      g++;
      continue;
    }
  }

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


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

int main(void){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 1; i < s.length(); i++){
        if(s[i]==s[i-1]&&s[i-1]=='0'){
            s[i]='1'; ans++;}
        else if(s[i]==s[i-1]&&s[i-1]=='1'){
            s[i]='0'; ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
//#define int LL
bool isPrime(int n) {
    if (n < 2) return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

void solve(int a, int d, int n) {
    int cnt = 0;
    for (int i = a; ; i += d) {
        cnt += isPrime(i);
        if (cnt == n) {
            cout << i << endl;
            return;
        }
    }
    return;
}

signed main(void) {
    int n, p, m, w, h;
    string s;
    int a, b, c, d;
    while (cin >> a >> d >> n) {
        if (a == 0 && d == 0 && n == 0) return 0;
        solve(a, d, n);
        //return 0;
    }
}

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

ll perm(ll n,ll k){
  ll a = 1;
  for(int i = 1;i<=n;i++){
    a = (a*i)%k;
  }
  return a;
}


int main() {
 ll N,M;
 cin >> N >> M;
 ll k = 1000000000+7;
  int ans = 0;
  if(abs(N-M)>=2) ans = 0;
  else if(abs(N-M) == 0){
    ans = (2*perm(N,k)*perm(M,k))%k;
  }
  else if(abs(N-M) ==1){
    ans = perm(N,k)*perm(M,k)%k;
  }
  
  cout << ans<< endl;
    
}

Measured memory_bytes: 256
function main(arg) {
    arg = arg.split("\n");
    var N = parseInt(arg[0].split(" ")[0]);
    var H = parseInt(arg[0].split(" ")[1]);
    var W = parseInt(arg[0].split(" ")[2]);
    
    var count = 0;
    arg.shift();

    
    for(var i=0; i<arg.length; i++) {
        var h = parseInt(arg[i].split(" ")[0]);
        var w = parseInt(arg[i].split(" ")[1]);
        
        if( h >= H && w >= W ) {
            count++;
        }
    }
    
    console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long x = sc.nextLong();
		
		long[] map = new long[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextLong();
		}
		
		Arrays.sort(map);
		long sum = 0;
		for (int i = 0; i < N; i++) {
			if (sum + map[i] > x) {
				System.out.println(i);
				return;
			}
			sum += map[i];
		}
		
		if (sum == x) {
			System.out.println(N);
		} else {
			System.out.println(N - 1 );
		}
		
	}
}

Measured memory_bytes: 22228
#!/usr/bin/env python3
import sys
h, w = map(int, input().split())
s = [[c for c in l.strip()] for l in sys.stdin]

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            if i != 0:
                if s[i - 1][j] == "#":
                    continue
            if j != 0:
                if s[i][j - 1] == "#":
                    continue
            if j != w - 1:
                if s[i][j + 1] == "#":
                    continue
            if i != h - 1:
                if s[i + 1][j] == "#":
                    continue
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 9192
#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;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    vector<int> b=a;
    sort(b.begin(),b.end());
    for(int i=0;i<n;i++){
        if(a[i] == b[n-1]){
            cout << b[n-2] << endl;
        }else{
            cout << b[n-1] << endl;
        }
    }
}

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

int main() {
  int N;

  cin >> N;

  vector<string> s(N);

  for(int i=0; i<N; i++) {
      cin >> s.at(i);
  }

  int M;

  cin >> M;

  vector<string> t(M);

  for(int i=0; i<M; i++) {
      cin >> t.at(i);
  }

  vector<int> count(N,0);

  for(int i=0;i<N;i++) {
      for(int j=0;j<N;j++) {
          if(s.at(i) == s.at(j)) count.at(i)++;
      }
  }

  for(int i=0;i<N;i++) {
      for(int j=0;j<M;j++) {
          if(s.at(i) == t.at(j)) count.at(i)--;
      }
  }

  int maxcount =0;
  for(int i=0; i<N; i++) {
      if(maxcount<=count.at(i)) maxcount=count.at(i);
  }

  cout << maxcount << endl;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n , a , b;

int main()
{
    _FastIO;
    cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
        return 0;
    }
    cin >> a >> b;
    cout << a + b << endl;
    return 0;
}


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

namespace AtCoder.Heuristics
{
    class Introduction
    {
        private static int d;

        private static int[] c;

        private static int[] t;

        private static int[][] s;

        private static int[] last;

        private static int sumC;

        public static void Main()
        {
            d = int.Parse(Console.ReadLine());
            c = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            sumC = c.Sum();

            s = new int[d + 1][];
            for (int i = 1; i <= d; i++)
                s[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            
            t = new int[d+1];
            last = new int[c.Length];
            var v = 0;
            var sum = c.Sum();
            var dec = 0;
            for (int i = 1; i <= d; i++)
            {
                t[i] = int.Parse(Console.ReadLine()) - 1;
                dec += sum - (c[t[i]] * (i - last[t[i]]));
                last[t[i]] = i;
                v -= dec;
                v += s[i][t[i]];
                Console.WriteLine(v);
            }
        }
    }
}


Measured memory_bytes: 28780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int N=2e6+1;
int n,k;
ll a[N];
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> k;
	ll l=1,r;
	for(int i=1; i<=n ;i++){
		cin >> a[i];
		r=max(r,a[i]);
	}
	while(l!=r){
		ll mid=(l+r)/2;
		ll s=0;
		for(int i=1; i<=n ;i++){
			s+=(a[i]-1)/mid;
		}
		if(s<=k) r=mid;
		else l=mid+1;
	}
	cout <<l << endl;
}

Measured memory_bytes: 5200
using System;

namespace ConsoleApp23
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] array = line.Split(' ');
            
            int a = int.Parse(array[0]);           
            int b = int.Parse(array[1]);
            int c = int.Parse(array[2]);
            int d = int.Parse(array[3]);

            int ar = 0;
            int br = 0;
            if (c % b == 0)
            {
                ar = c / b;
            }
            else
            {
                ar = c / b;
                ar +=1;
            }

            if (a % d == 0)
            {
                br = a / d;
            }
            else
            {
                br = a / d;
                br += 1;
            }

            if ( ar <= br )
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27496
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

vector<long long int> divisor(long long int n) {
	vector<long long int> res;
	for (long long int i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			res.push_back(i);
			if (i * i != n) res.push_back(n / i);
		}
	}
	sort(begin(res), end(res));
	return res;
}

vector<int>compress(vector<int>nums) {
	auto divs(divisor(nums.size()));
	reverse(divs.begin(),divs.end());
	for (auto div : divs) {
		bool ok=true;

		for (int i = 0; i < nums.size() / div; ++i) {
			for (int j = 1; j < div; ++j) {
				if(nums[i*div+j])ok=false;
			}
		}
		if (ok) {
			vector<int>ans(nums.size()/div);
			for (int i = 0; i < nums.size() / div; ++i) {
				ans[i]=nums[i*div];
			}
			return ans;
		}
	}
	assert(false);
	return vector<int>();
}

vector<int>mk(string st) {
	vector<int>nums(st.size()/2);
	for (int i = 0; i < st.size() / 2; ++i) {
		char c1 = st[2*i];
		char c2=st[2*i+1];
		int num=!isdigit(c1)?(c1-'A'+10):c1-'0';
		num*=16;
		num+=!isdigit(c2)?(c2-'A'+10):c2-'0';

		nums[i]=num;
	}
	return compress(nums);
}

long long int gcd(long long int l, long long int r) {
	if (l > r)return gcd(r, l);
	else {
		if (r%l) {
			return gcd(l, r%l);

		}
		else {
			return l;
		}
	}
}

int main() {
	int Q;cin>>Q;
	while (Q--) {
		int L;cin>>L;
		vector<int>es(L);
		for(int i=0;i<L;++i)cin>>es[i];

		if (L < 2) {
			cout<<es[L-1]<<endl;
		}
		else {
			vector<vector<vector<int>>>dp(L, vector<vector<int>>(200, vector<int>(200)));
			dp[0][es[0]][es[1]] = 1;
			for (int l = 0; l < L - 2; ++l) {
				for (int a = 0; a < 200; ++a) {
					for (int b = 0; b < 200; ++b) {
						if (dp[l][a][b]) {

							if (b) {
								dp[l + 1][b - 1][a + es[l + 2]] = true;
							}
							dp[l + 1][b][es[l + 2]] = true;
						}
					}
				}
			}
			int ans=0;
			for (int i = 0; i < 200; ++i) {
				for (int j = 0; j < 200; ++j) {
					if(dp[L-2][i][j])ans=max(ans,j);
				}
			}
			cout<<ans<<endl;
		}

		
	}
	return 0;
}


Measured memory_bytes: 15488
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int ans=0;

  for(int i=0;i<=A;i++){
    if(X<500*i) break;
    for(int j=0;j<=B;j++){
      if(X<500*i+100*j) break;
      for(int k=0;k<=C;k++){
	if(X==500*i+100*j+50*k) ++ans;
      }
    }
  }

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(int x){write(x);putchar('\n');}
const int MAXN=200005;
char ch[MAXN];
int f[MAXN][2],a[MAXN];
int n;
int main()
{
	n=read();
	scanf("%s",ch+1);
	for(int i=1;i<=n;i++)a[i]=(ch[i]=='.'?0:1);
	f[1][a[1]]=0;f[1][a[1]^1]=1;
	for(int i=2;i<=n;i++)
	{
		if(a[i])f[i][a[i]]=min(f[i-1][a[i]],f[i-1][a[i]^1]);
		else f[i][a[i]]=f[i-1][a[i]];
		
		if(a[i]^1)f[i][a[i]^1]=min(f[i-1][a[i]^1],f[i-1][a[i]])+1;
		else f[i][a[i]^1]=f[i-1][a[i]^1]+1;
	}
	pr2(min(f[n][0],f[n][1]));
	return 0;
}



Measured memory_bytes: 2688
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

ll n, m, l;
ll a[2000];
ll b[100000];
ll s[100010];
ll dp[2000][2000];

ll sum(ll i, ll j){
  return (s[max(i, j) + 1] - s[min(i, j)]) / l;
}

ll dfs(ll i, ll j){
  if (i == n) return sum(a[i - 1], a[j]);
  if (~dp[i][j]) return dp[i][j];
  ll vl = sum(a[i - 1], a[i]) + dfs(i + 1, j);
  ll vr = sum(a[j], a[i]) + dfs(i + 1, i - 1);
  return dp[i][j] = min(vl, vr);
}

int main(){
  cin >> n >> m >> l;
  rep(i, n) cin >> a[i], a[i]--;
  rep(i, m) cin >> b[i];
  rep(i, m) s[i + 1] = s[i] + b[i];
  sort(a, a + n);
  memset(dp, -1, sizeof(dp));
  cout << dfs(1, 0) << endl;
}

Measured memory_bytes: 36112
N,Q=map(int,input().split())
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
X=[0 for i in range(N)]
for i in range(Q):
    p,x=map(int,input().split())
    X[p-1]+=x
q=[0]
reached=[0 for i in range(N)]
ans=[0 for i in range(N)]
#print(X)
while(len(q)>0):
    r=q.pop()
    ans[r]+=X[r]
    reached[r]=1
    for p in G[r]:
        if reached[p]==0:
            ans[p]+=ans[r]
            q.append(p)
print(*ans)


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

int main () {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  
  int a = h2*60+m2-h1*60-m1, ans;
  if (a == k) {
    ans = 0;
  }
  else {
    ans = a-k;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=1001001001001001;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    ll n,ans=inf;cin>>n;
    vi v(n);
    cin>>v[0];
    REP(i,1,n){
        int a;cin>>a;
        v[i]=v[i-1]+a;
    }
    ll l=-1,r=0,m=inf,p=inf;
    REP(k,1,n+1){
        while((l+1<k)&&((abs(v[k-1]-v[l+1]-v[l+1]))<abs(m))){
          m=v[k-1]-v[l+1]*2;
            l++;
        }
        while(r<n&&abs(v[n-1]-v[r]*2+v[k-1])<abs(p)){
            p=v[n-1]-v[r]*2+v[k-1];
            r++;
        }
        ll a=v[n-1]-v[r-1],b=v[r-1]-v[k-1],c=v[k-1]-v[l],d=v[l];
        chmin(ans,max(max(a,b),max(c,d))-min(min(a,b),min(c,d)));
        m+=(v[k]-v[k-1]);
        if(k==r)r++;
        else p+=(v[k]-v[k-1]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

struct Main {}

impl Main {
    fn invoke() {}
}

fn main() {
    let mut x: i32 = read();
    let mut res = 0;
    if x >= 500 {
        let five_hundreds_count = x / 500;
        res += five_hundreds_count * 1000;
        x = x % 500;
    }
    if x >= 5 {
        let five_count = x / 5;
        res += five_count * 5;
        x = x % 5;
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define se second
#define fi first
bool nthbith(int a, int i)
{
  return a & (1 << i);
}
int main()
{

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  int n, m, k;
  cin >> n >> m >> k;
  char arr[n][m];
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {

      cin >> arr[i][j];
    }
  }
  int ans = 0;
  for (int a = 0; a < (1 << n); a++)
  { for (int b = 0; b < (1 << m); b++)
    { int cnt = 0;
      for (int i = 0; i < n; i++)
      {
        for (int j = 0; j < m; j++)
        {
          if (arr[i][j] == '#' && !nthbith(a, i) && !nthbith(b, j))
            cnt++;
        }

      }
      if (cnt == k)
        ans++;
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

vector<int> tree[9];
int pass[9];
int n,m,ans;
void dfs(int v, int d) {
    if(d==n) {
        ans++;
        return;
    }
    for(int i = 0; i < tree[v].size(); i++) {
        if(pass[tree[v][i]]==0) {
            pass[tree[v][i]] = 1;
            dfs(tree[v][i],d+1);
            pass[tree[v][i]] = 0;
        }

    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    pass[0] = 1;
    dfs(0,1);
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

class combination
{
public:
  vector<ll> fac, finv, inv;

  combination(ll M)
  {
    fac.resize(M + 1);
    finv.resize(M + 1);
    inv.resize(M + 1);

    fac.at(0) = 1, finv.at(0) = 1, inv.at(0) = 1;
    fac.at(1) = 1, finv.at(1) = 1, inv.at(1) = 1;

    for (ll i = 2; i <= M; i++)
    {
      fac.at(i) = fac.at(i - 1) * i % MOD;
      inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
      finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
    }
  }

  ll P(ll N, ll K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * finv.at(N - K) % MOD;
  }

  ll C(ll N, ll K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * (finv.at(K) * finv.at(N - K) % MOD) % MOD;
  }

  ll H(ll N, ll K)
  {
    return C(N + K - 1, K);
  }
};

combination com(2 * (1e6 + 10));

ll s(ll r, ll c)
{
  if (r == 0 || c == 0)
    return 0;
  
  ll ret = 0;
  for (ll i = 0; i < c; i++)
  {
    ret += com.C(r + 2 + i, 2 + i) + MOD - 1;
    ret %= MOD;
  }

  return ret;
}

int main()
{
  ll r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  ll ans = ((s(r2, c2) + s(r1 - 1, c1 - 1)) % MOD) + MOD - ((s(r1 - 1, c2) + s(r2, c1 - 1)) % MOD);
  ans %= MOD;
  cout << ans << endl;

  //cerr << s(r2, c2) << " " << s(r1 - 1, c1 - 1) << endl;
  //cerr << s(r1 - 1, c2) << " " << s(r2, c1 - 1) << endl;
}

Measured memory_bytes: 47104
#include <iostream>
#include <algorithm>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
    ll n;cin>>n;
    int ans=100;
    for(int i=1;i<sqrt(n)+1;i++){
        if(n%i==0){
            ll b=n/i;
            int d_a=log10(i)+1;
            int d_b=log10(b)+1;
            ans=min(ans,max(d_a,d_b));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
import Data.List
main = interact $ unlines . show' . itp1_7_d . read' . lines
 where
  read' xs = let ([n,m,l]:xs') = map (map read . words) xs in splitAt n xs'
  show' = map (unwords . map show)
itp1_7_d (mat_a, mat_b) = map (\v -> map (sum . zipWith (*) v) (transpose mat_b)) mat_a

Measured memory_bytes: 12296
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>


typedef long long ll;


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

#define pb push_back
#define all(v) v.begin(),v.end()

using namespace std;

ll MAX = 1000000000000000000;





int main()
{
	int n; cin >> n;
	ll ans = 1;

	bool flag = true;

	rep(i, n) {
		ll a; cin >> a;
		if (a == 0) {
			flag = true;
			ans = 0;
			break;
		}
		else if ((double)MAX / ans < a || a * ans > MAX) {
			flag = false;

		}
		else {
			ans *= a;
		}
	}

	if (flag)
		cout << ans << endl;
	else
		cout << -1 << endl;
}

Measured memory_bytes: 3620
import numpy as np
n = int(input())
a = np.array(input().split(), dtype=np.int32)
b = np.array(input().split(), dtype=np.int32)

#print(a)
#print(b)
ans = 0;mod = 1
for k in range(30):
    mod *= 2;t = mod // 2;cnt = 0
    bb = np.sort(b % mod)
    aa = a % mod
    #print(aa)
    #print(bb)
    #print(np.searchsorted(bb,t-aa))
    l1, r1, l2, r2 = (np.searchsorted(bb, v - aa).sum() for v in (t, 2*t, 3*t, 4*t))
    cnt += r1 - l1
    cnt += r2 - l2

    if cnt % 2:
        ans += t
print(ans)

Measured memory_bytes: 35884
#include<stdio.h>
#include<math.h>


int main(){

  double x, y, x1, x2, y1, y2;

  scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
  x=fabs(x2-x1);
  x=pow(x, 2);
  y=fabs(y2-y1);
  y=pow(y, 2);

  printf("%f\n", sqrt(x+y));

  return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
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=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE(x) ((ll)(x).size()) 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define ALL(x) (x).begin(),(x).end() 

#define INF 1000000000000 
#define MOD 1000000007 
#define MAXR 100000 

#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<int> value(110);
  vector<ll> weight(110);
  int j, n, w;
  cin >> n >> w;
  REP(i, n) cin >> weight[i] >> value[i];
  int max_v = MAX(value);
  int k = n*max_v;
  ll dp[n+1][k+1];
  REP(i, n+1) REP(j, k+1) dp[i][j] = INF;
  dp[0][0] = 0;
  REP(i, n){
      REP(j, k+1){
          if(j >= value[i]){ 
            dp[i+1][j] = min(dp[i][j], dp[i][j-value[i]] + weight[i]);
          }else{
            dp[i+1][j] = dp[i][j];
          }
      }
  }
  ll ans = k;
  while(dp[n][ans] > w) ans--;
  cout << ans << endl;
}

Measured memory_bytes: 79232
H, W = map(int, input().split())
costs = [list(map(int, input().split())) for _ in range(10)]
wall = [list(map(int, input().split())) for _ in range(H)]
for k in range(10):
    for i in range(10):
        for j in range(10):
            costs[i][j] = min(costs[i][j], costs[i][k] + costs[k][j])

d = {-1: 0, 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0}
for i in wall:
    for n in range(-1, 10):
        d[n] += i.count(n)
min_cost = 0
for i in range(-1, 10):
    if i == 1:
        continue
    if i == -1:
        min_cost += d[i] * costs[1][1]
    else:
        min_cost += d[i] * costs[i][1]
print(min_cost)


Measured memory_bytes: 3444