akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define INF 1000000009
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define so sizeof 
#define pii pair<ll,ll>
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define max3(a, b, c) max(c, max(a, b))
#define max4(a, b, c, d) max(d, max(c, max(a, b)))
#define repe(i,a) for(auto i:a)
#define st string
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rrep(i,a,b) for(ll i=b;i>=a;i--)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); 
void solve(){
   ll n;
   cin>>n;
   vector<pair<ll,ll>> a;
   rep(i,0,n-1){
       ll x,y;
       cin>>x>>y;
       a.pb(mp(x,y));
   }
   bool status=false;
   rep(i,0,n-3){
      if(a[i].ff==a[i].ss){
          if(a[i+1].ff==a[i+1].ss && a[i+2].ff==a[i+2].ss){
            status=true;
              break;
          }
      }
   }
  if(status){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
#endif
    fast
    // ll t;
    // cin>>t;
    // while(t--)
    solve();
    return 0;
}

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


int ans[300050];
int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    if(a+b>n+1)
        puts("-1");
    else
    {
        int f=0;
        if(a<b)
            swap(a,b),f=1;

        int c=(n+b-1)/b;
        if(c>a)
            puts("-1");
        else
        {
            int x=-1,y;
            for(int i=0;i<=n;i++)
                if(i+((n-i+b-1)/b)==a)
                {
                    x=i;
                    break;
                }
            int now=n,pos=n-1;
            for(int i=0;i<x;i++)
                ans[pos--]=now--;
            int p=1,pos2=b-1,cnt=0;
            while(p<=now)
            {
                ans[pos2--]=p++;
                cnt++;
                if(cnt%b==0)
                {
                    pos2+=b+min(b,now-p+1);
                }
            }
            if(f)
            {
                for(int i=0;i<n/2;i++)
                    swap(ans[i],ans[n-i-1]);
            }
            printf("%d",ans[0]);
            for(int i=1;i<n;i++)
                printf(" %d",ans[i]);
            puts("");
        }
    }
	return 0;
}



Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>
using namespace std;

long long a;
char s[110];
int main(){
    scanf(" %s",s);
    scanf("%lld",&a);


    int len = strlen(s);
    for(int i=0;i<len;i++){
        if(s[i]!='1'){
            printf("%c\n",s[i]);
            break;
        }else{
            if(i+1>=a){
                printf("%c\n",s[i]);
                break;
            }
        }
    }
    return 0;
}


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

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

int main() {
    string s,t; cin >> s >> t;
    int a,b; cin >> a >> b;
    string U; cin >> U;
    if(s == U) cout << a-1 << " " << b << endl;
    else cout << a << " " << b-1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int s;
    s=a*b;
    if(s<c)
    {
        cout<<s<<endl;
        return 0;
    }
    else if(s>c) 
    {
        cout<<c<<endl;
        return 0;
    }
    else
    {
        cout<<s<<endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
def baseorder(num):
    i=0
    while num>=2**(i+1):
        i+=1
    return i

def function(num):
    if num==0:
        return 0
    elif num==1:
        return 1
    elif num==2:
        return 3
    elif num==3:
        return 0
    else:
        x=baseorder(num)
        return (2**x)*((num-2**x+1)%2)+function(num-2**x)

A,B=map(int,input().split())
if A==0:
    print(function(B))
else:
    print(function(B)^function(A-1))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <cstdlib>
#include <ctime>
#include <queue>
using namespace std;

#define X first
#define Y second
#define N 1010
#define M 500010

typedef unsigned long long ull;
typedef long long ll;
const int INF = 1 << 30;
const int Mod = 1000000007;

const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
char s[N][N];
bool vis[N][N];

queue<pair<int, pair<int, int > > > Q;

int Ceil(int x, int y)
{
	if (x % y == 0) return x / y;
	else return x / y + 1;
}

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);

	int n, m, K;
	scanf("%d %d %d", &n, &m, &K);
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			scanf(" %c", &s[i][j]);
			if (s[i][j] == 'S') 
				Q.push(make_pair(0, make_pair(i, j))), vis[i][j] = true;
		}
	}
	int res = INF;
	while (!Q.empty())
	{
		int x = Q.front().Y.X, y = Q.front().Y.Y, k = Q.front().X; Q.pop();
		if (x == 1 || x == n || y == 1 || y == m) res = 1;
		else res = min(res, Ceil(min(min(n - x, x - 1), min(m - y, y - 1)), K) + 1);
		if (k == K) continue;
		for (int i = 0; i < 4; ++i)
		{
			int tx = x + dx[i], ty = y + dy[i];
			if (!tx || !ty || tx > n || ty > m || s[tx][ty] == '#' || vis[tx][ty]) continue;
			vis[tx][ty] = true, Q.push(make_pair(k + 1, make_pair(tx, ty)));
		}
	}
	printf("%d\n", res);
	
	return 0;
}

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

namespace ABC113_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var xy = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var x = xy[0];
                var y = xy[1];
            Console.WriteLine(x+ y/2);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;

int main() {
	int N; cin >> N;
	vector<int> v;
	for (int i = 0; i < N; i++) {
		int a; cin >> a; v.push_back(a);
	}
	sort(v.begin(), v.end(), greater<int>());

	int length = v[0];

	int* count = new int[length + 1];
	for (int i = 0; i <= length; i++) {
		count[i] = 0;
	}
	for (auto itr = v.begin(); itr != v.end(); itr++) {
		count[*itr]++;
	}

	if (length % 2 == 0) {
		for (int i = length; i > length / 2; i--) {
			if (count[i] < 2) { cout << "Impossible" << endl; return 0; }
		}
		if (count[length / 2] != 1) { cout << "Impossible" << endl; return 0; }
	}
	else {
		for (int i = length; i * 2 > length + 2; i--) {
			if (count[i] < 2) { cout << "Impossible" << endl; return 0; }
		}
		if (count[(length + 1) / 2] != 2) { cout << "Impossible" << endl; return 0; }
	}

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

Measured memory_bytes: 256
import numpy as np

#a, b = map(int, input().split())
N = int(input())

#map(int, input().split())

# def bubble_sort(lst):
#     cnt = 0
#     for i in range(len(lst)-1):
#         for j in range(len(lst)-1, i, -1):
#             if lst[j-1] > lst[j]:
#                 tmp = lst[j]
#                 lst[j] = lst[j-1]
#                 lst[j-1] = tmp
#                 cnt += 1
#     return cnt

P = list(map(int, input().split()))

cnt = 1

tmp = P[0]
for i in range(1, N):    
    if P[i] < tmp:
        tmp = P[i]
        cnt += 1
        
            
print(cnt)
        


Measured memory_bytes: 34116
N, Q = map(int, input().split())
S=input()
li = [list(map(int, input().split())) for _ in range(Q)]

A=[0]*(N)

for i in range(N-1):
    if S[i:i+2]=='AC':
        A[i+1]=A[i]+1
    else:
        A[i+1]=A[i]

for k in li:
    l=k[0]-1
    r=k[1]-1
    print(A[r]-A[l])

Measured memory_bytes: 30664
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define int long long

#define NUM 1000000007

struct _chunk {
	int name;
	int nextNum;
	vector<int> next;
};

int factorial(int num1, int num2){
    int sum = 1;
    for (int i = num1 + 1; i <= num1 + num2; ++i)
    {
        sum *= i;
    }

    for (int i = num2; i >= 1; --i) {
    	sum /= i;
    }
    return sum;
}

signed main(void) {
  int L, R;
  cin >> L >> R;
  int l = L%2019;
  int r = R%2019;

  // there's 2019*k
  if (R-L+1 >= 2019) {
  	cout << 0 << endl;
  } else if (l >= r){
  	cout << 0 << endl;
  } else {
  	int min = 2018;
  	for (int i=l; i<r; i++) {
  		for (int j=i+1; j<=r; j++) {
  			int tmp = (i*j)%2019;
  			if (tmp < min) {
  				min = tmp;
  			}
  		}
  	}
  	cout << min << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from sys import stdin

input = stdin.readline
lines = stdin.readlines

N = int(input())

txy = [[int(i) for i in line.split()] for line in lines()]


def main():
    pt = 0
    px = 0
    py = 0

    flg = False

    for t, x, y in txy:
        dt = t - pt - abs(x - px) - abs(y - py)
        # 余った時間が奇数 戻れない
        if dt < 0 or dt % 2 == 1:
            break

        pt = t
        px = x
        py = y
    else:
        # break しなかった 完走
        flg = True

    print("Yes" if flg else "No")
    return


main()


Measured memory_bytes: 28176
#include <algorithm>
#include <cstdio>
#include <cstring>

const int MaxN = 8000, MaxM = 200;
const int MaxV = (1 << 14);
const int Mod = 998244353, Prt = 3;

int N, M, V;
int Fac[MaxN + 5], InvFac[MaxN + 5];
int Rev[MaxV + 5];
int W[MaxV + 5][2];
int F[MaxM + 5][MaxN + 5];
int Tmp[MaxV + 5], G[MaxV + 5];

inline int add(int x, int y) { return (x += y) >= Mod ? x - Mod : x; }
inline int sub(int x, int y) { return (x -= y) < 0 ? x + Mod : x; }
inline int mul(int x, int y) { return 1LL * x * y % Mod; }
inline int pw(int x, int y) { int z = 1; for (; y; y >>= 1, x = mul(x, x)) if (y & 1) z = mul(z, x); return z; }
inline int inv(int x) { return pw(x, Mod - 2); }
inline int sep(int x, int y) { return mul(x, inv(y)); }
inline void inc(int &x, int y = 1) { x = add(x, y); }
inline void dec(int &x, int y = 1) { x = sub(x, y); }
inline int binom(int n, int m) { return mul(Fac[n], mul(InvFac[m], InvFac[n - m])); }

void init() {
  scanf("%d %d", &N, &M);
  Fac[0] = 1;
  for (int i = 1; i <= N + 2; ++i) Fac[i] = mul(Fac[i - 1], i);
  InvFac[N + 2] = inv(Fac[N + 2]);
  for (int i = N + 2; i >= 1; --i) InvFac[i - 1] = mul(InvFac[i], i);
  for (V = 1; V < N + N + 5; V <<= 1);
  for (int i = 1; i < V; ++i) {
    Rev[i] = (Rev[i >> 1] >> 1);
    if (i & 1) Rev[i] |= (V >> 1);
  }
  for (int i = 1; i < V; i <<= 1) {
    W[i][0] = pw(Prt, (Mod - 1) / (i << 1));
    W[i][1] = pw(inv(Prt), (Mod - 1) / (i << 1));
  }
}

inline void ntt(int *a, int n, int f) {
  for (int i = 1; i < n; ++i)
    if (i < Rev[i]) std::swap(a[i], a[Rev[i]]);
  for (int i = 1; i < n; i <<= 1) {
    int w = W[i][f];
    for (int j = 0; j < n; j += (i << 1)) {
      int x = 1;
      for (int k = 0; k < i; ++k, x = mul(x, w)) {
        int ls = a[j + k], rs = a[i + j + k];
        a[j + k] = add(ls, mul(rs, x));
        a[i + j + k] = sub(ls, mul(rs, x));
      }
    }
  }
  if (f == 1) {
    int invn = inv(n);
    for (int i = 0; i < n; ++i) a[i] = mul(a[i], invn);
  }
}

void solve() {
  F[0][0] = 1;
  for (int i = 1; i <= N; ++i) G[i] = InvFac[i + 2];
  ntt(G, V, 0);
  for (int i = 1; i <= M; ++i) {
    memset(Tmp, 0, V << 2);
    for (int j = 0; j <= N; ++j) Tmp[j] = mul(F[i - 1][j], InvFac[j]);
    ntt(Tmp, V, 0);
    for (int j = 0; j < V; ++j) Tmp[j] = mul(Tmp[j], G[j]);
    ntt(Tmp, V, 1);
    for (int j = 0; j <= N; ++j) F[i][j] = mul(Tmp[j], Fac[j + 2]);
    for (int j = 0; j <= N; ++j) inc(F[i][j], mul(F[i - 1][j], (1LL * j * (j + 1) / 2 + 1) % Mod));
  }
  int ans = 0;
  for (int i = 0; i <= N; ++i) inc(ans, mul(F[M][i], binom(N, i)));
  printf("%d\n", ans);
}

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

Measured memory_bytes: 6656
n=int(input())
d,x=map(int,input().split())
A=[]
for i in range(n):
  a=int(input())
  A.append(a)
Amounts=[]
for i in range(n):
  j=0
  count=0
  while A[i]*j+1<=d:
    count+=1
    j+=1
  Amounts.append(count)
print(sum(Amounts)+x)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
#define REP(i,m,n) for(int i = (int) (m);i < (int) (n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int a, b, ans;



int main() {
	cin >> a >> b;
	if (a > 9 || b > 9) {
		ans = -1;
	}
	else ans = a * b;
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    int N;
    cin >> N;
    string S;
    cin >> S;

    int counter = 0;
    int maximum = counter;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'I')
        {
            counter++;
        }
        else
        {
            counter--;
        }
        maximum = max(maximum, counter);
    }
    cout << maximum << endl;
    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int o, z, m;
    cin>>s;
    o=z=0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='0') o++;
        else z++;
    }
    m=min(o,z);
    cout<<m*2<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define EXIST(c,e) ( (c).find( e ) != (c).end() )
#define INF 1<<30
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int, int> > vp;
typedef map<int,int> mpii;
typedef priority_queue<int, vi, greater<int> > pqi;

typedef long long ll;


int main(){
	int n; cin>>n;
	vi a(n);
	rep(i,n) cin>>a[i];
	sort(all(a),greater<int>());

	int x[2] = {0};
	rep(i,n){
		x[i%2]+=a[i];
	}
	cout<<x[0]-x[1]<<endl;

	return 0;
}


Measured memory_bytes: 256
mod = 10**9 + 7
n = int(input())
c = list(map(int, input().split()))
c.sort(reverse=True)

b = pow(2, 2*n-2, mod)
a = 2 * b % mod

ans = 0
for i in range(n):
    ans += c[i] * (a + i * b)
    ans %= mod

print(ans)

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

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);
#define endl '\n'

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
void print() {}
template<typename T, typename... Args>
void print(T firstArg, Args... args) {
	#ifdef LOCAL
	cout << firstArg << " ";
	print(args...);
	#endif
}
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e6 + 5;

long long modPow(long long b, long long pow){
	long long ans = 1;
	long long p = b;
	while(pow){
		if(pow & 1)
			ans = (ans * p) % 1000000007;
		p = (p * p) % 1000000007;
		pow >>= 1;
	}
	return ans;
}

int main() {
	//usaco("milkvisits");

	#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
	#endif

	ll n;
	cin >> n;

	ll a, b;
	cin >> a >> b;

	ll ans = 0;

	ll first = 1;
	for(int i = 0; i < a; i++){
		 first = (first *  (n - i))	% MOD;
	}
	ll second = 1;
	for(int i = 0; i < b; i++){
		second = (second * (n - i)) % MOD;
	}

	ans = modPow(2, n) - 1;

	ll fac1 = 1;
	for(int i = 1; i <= a; i++){
		fac1 = (fac1 * i) % MOD;
	}

	ll fac2 = 1;
	for(int i = 1; i <= b; i++){
		fac2 = (fac2 * i) % MOD;
	}

	ans = ans - (first * modPow(fac1, MOD - 2));
	ans %= MOD;

	ans = ans - (second * modPow(fac2, MOD - 2));
	ans = ((ans % MOD) + MOD) % MOD;

	cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  string s;

  cin >> n >> s;

  llong num_R = 0, num_G = 0,  num_B = 0;
  REP(i,n){
    if(s[i] == 'R') num_R++;
    else if(s[i] == 'G') num_G++;
    else num_B++;
  }

  llong ans = num_R * num_G * num_B;
  for(int i = 1; i < n - 1; ++i){
    int j = 1;
    while(i - j >= 0 && i + j < n){
      if(s[i] != s[i - j] && s[i] != s[i + j] && s[i - j] != s[i + j]) ans--;
      j++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAXN 200010
#define LL long long
using namespace std;

const LL P=1000000007;

LL getPow(LL x,LL y){
	LL res=1;
	while(y){
		if(y&1) res=res*x%P;
		x=x*x%P;
		y>>=1;
	}
	return res;
}

struct edge{
	int to,next;
	edge(int _to=0,int _next=0):to(_to),next(_next){}
}e[MAXN];

int n;
int g[MAXN],nume;
int p[MAXN];
bool visit0[MAXN],visit[MAXN];
int b[MAXN],l[MAXN],sl[MAXN],numb;
int cnt[MAXN];
LL f[MAXN],fac[MAXN],invfac[MAXN];
LL ans=1;

void addEdge(int u,int v){
	e[nume]=edge(v,g[u]);
	g[u]=nume++;
}

int dfs(int x){
	visit[x]=1;
	int numch=0;
	int res=0;
	for(int i=g[x];~i;i=e[i].next)
		if(!visit[e[i].to]){
			numch++;
			res=dfs(e[i].to)+1;
		}
	if(numch>=2) ans=0;
	return res;
}

void gao(int x){
	numb=0;
	while(!visit[x]){
		visit[x]=1;
		b[++numb]=x;
		x=p[x];
	}
	int pos=0;
	for(int i=1;i<=numb;i++){
		l[i]=dfs(b[i]);
		if(l[i]) pos=i;
	}
	if(!pos){
		cnt[numb]++;
		return;
	}
	for(int i=1;i<=numb;i++){
		b[i+numb]=b[i];
		l[i+numb]=l[i];
		b[i]=b[i+pos-1];
		l[i]=l[i+pos-1];
	}
	for(int i=1;i<=numb;i++) sl[i]=sl[i-1]+l[i];
	LL res1=0,res2=0;
	if(sl[numb]-sl[numb-(l[1]-1)]==0){
		res1=1;
		for(int i=2;i<=numb;i++){
			if(!l[i]) continue;
			LL temp=0;
			if(sl[i-1]-sl[max(0,i-l[i])]==0) temp++;
			if(sl[i-1]-sl[max(0,i-l[i]-1)]==0) temp++;
			res1=res1*temp%P;
		}
	}
	if(sl[numb]-sl[numb-l[1]]==0){
		res2=1;
		for(int i=2;i<=numb;i++){
			if(!l[i]) continue;
			LL temp=0;
			if(sl[i-1]-sl[max(0,i-l[i])]==0) temp++;
			if(sl[i-1]-sl[max(0,i-l[i]-1)]==0) temp++;
			res2=res2*temp%P;
		}
	}
	ans=ans*(res1+res2)%P;
}

void init(){
	f[0]=1;
	for(int i=2;i<=n;i++) f[i]=f[i-2]*(i-1)%P;
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%P;
	invfac[n]=getPow(fac[n],P-2);
	for(int i=n-1;i>=0;i--) invfac[i]=invfac[i+1]*(i+1)%P;
}

LL getC(int x,int y){
	return fac[x]*invfac[y]%P*invfac[x-y]%P;
}

int main(){
#ifdef DEBUG
	freopen("E.in","r",stdin);
#endif
	memset(g,-1,sizeof g);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",p+i);
		addEdge(p[i],i);
	}
	for(int i=1;i<=n;i++)
		if(!visit[i]){
			int x=i;
			for(;!visit0[x];x=p[x]) visit0[x]=1;
			gao(x);
		}
	init();
	for(int i=1;i<=n;i++)
		if(cnt[i]){
			LL res=0;
			for(int j=0;j<=cnt[i];j+=2)
				if(i>=3 && (i&1)) res=(res+getC(cnt[i],j)*f[j]%P*getPow(i,j/2)%P*getPow(2,cnt[i]-j))%P;
				else res=(res+getC(cnt[i],j)*f[j]%P*getPow(i,j/2))%P;
			ans=ans*res%P%P;
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll a, b, q; cin >> a >> b >> q;
  vll s(a+2, HIGHINF), t(b+2, HIGHINF);
  s.at(0) *= -1; t.at(0) *= -1;
  REP(i, a) cin >> s.at(i+1); sort(s.begin(), s.end());
  REP(i, b) cin >> t.at(i+1); sort(t.begin(), t.end());
  REP(i, q) {
    ll ans = HIGHINF;
    ll x; cin >> x;
    ll mins = *(lower_bound(s.begin(), s.end(), x)-1);
    ll maxs = *(upper_bound(s.begin(), s.end(), x));
    ll mint = *(lower_bound(t.begin(), t.end(), x)-1);
    ll maxt = *(upper_bound(t.begin(), t.end(), x));
    ans = min(min(max(x-mins, x-mint), max(maxs-x, maxt-x)),
      min(min(x-mins+x-mins+maxt-x, x-mint+x-mint+maxs-x), min(maxs-x+maxs-x+x-mint, maxt-x+maxt-x+x-mins)));
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2944
#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 r,g,b;
   cin>>r>>g>>b;
   r*=100;
   g*=10;
   int sum =0;
   int check =0;
   sum = r+g+b;
   check = g+b;
   if(check%4==0){
   cout<<"YES";
   }else{
      cout<<"NO";
   }
	}

Measured memory_bytes: 256
// 2011/05/26 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int a, b;
		cin >> a;
		if(cin.eof())
			break;
		cin >> b;

		int sum = a+b;

		int cnt = 0;
		while(sum>0){
			cnt++;
			sum /= 10;
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

ll f(ll x) {
        if (x == 1) {
                return 1;
        } else {
                return 1 + 2 * f(x / 2);
        }
}

int main() {
        ll h;
        cin >> h;

        cout << f(h) << endl;

        return 0;
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
    #define gc getchar()
    template <typename T>
    inline void read(T& x) {
        x = 0; bool f = 1; char ch;
        for (ch = gc; ch < '0' || '9' < ch; ch = gc) if (ch == '-') f ^= 1;
        for (; '0' <= ch && ch <= '9'; ch = gc) x = (x << 3) + (x << 1) + (ch ^ 48);
        x = f ? x : -x;
    }
    #undef gc
}

const int MAXN = 2e5 + 10;

int n;
long long arr[MAXN];
long long ans = 0;

int main() {
    IO::read(n);
    rep(i, 1, n) IO::read(arr[i]);
    rep(i, 2, n) {
        ans += max(0ll, arr[i - 1] - arr[i]);
        arr[i] = max(arr[i], arr[i - 1]);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 5260
import java.util.*

fun main(args: Array<String>) {
    try {
        val sc = Scanner(System.`in`)
        val n = Integer.parseInt(sc.nextLine())
        if (n < 1 || n > 100) {
            throw Exception("Unexpected input.")
        }
        val a = Array(n) { IntArray(n) }
        for (i in 0 until n) {
            val u = sc.nextInt()
            val k = sc.nextInt()
            for (j in 0 until k) {
                val v = sc.nextInt()
                a[u - 1][v - 1] = 1
            }
        }
        for (i in a.indices) {
            println(a[i].joinToString(" "))
        }
    } catch (e: Exception) {
        println(e)
    }
}


Measured memory_bytes: 32332
#!/usr/bin/env python3

def main():
    S = input()
    T = input()

    ct = [-1] * 26
    dt = [-1] * 26

    oa = ord('a')
    f = True
    for i in range(len(S)):
        c1 = S[i]
        c2 = T[i]
        j1 = ord(c1) - oa
        j2 = ord(c2) - oa
        if ct[j1] == -1:
            if dt[j2] == -1:
                ct[j1] = j2
                dt[j2] = j1
            else:
                f = False
                break
        elif ct[j1] != j2:
            f = False
            break


    print('Yes' if f else 'No')


if __name__ == '__main__':
    main()



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

int main(){
  string s, result;
  cin >> s;
  
  result = "Yes";
  for(int i = 0; i < s.size(); i++){
    if((i+1)%2 == 0){
      
      if(s[i] == 'R'){
        result = "No";
      }
    }else{
      if(s[i] == 'L'){
        result = "No";
      }
    }
  }
  
  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n;
    cin >> n;
    string s, t;
    cin >> s >> t;


    rep(i, 0, 2 * n){
        if(i % 2 == 0){
            cout << s[i / 2];
        }else{
            cout << t[i / 2];
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int x=0,y,z,r,c,i,j,sumr=0,sumc=0;
  int a[102][102]={0};
  scanf("%d %d",&r,&c);
  for(i=1;i<=r;i++){
    for(j=1;j<=c;j++){
      scanf("%d",&a[i][j]);
      sumc+=a[i][j];
      if(j==c){
	a[i][c+1]=sumc;
	x+=sumc;
	sumc=0;
      }
    }
  }
  for(j=1;j<=c;j++){
    for(i=1;i<=r;i++){
      sumr+=a[i][j];
      if(i==r){
	a[r+1][j]=sumr;
	sumr=0;
      }
    }
  }
  a[r+1][c+1]=x;
  for(i=1;i<=r+1;i++){
    for(j=1;j<=c+1;j++){
      printf("%d",a[i][j]);
      if(j<c+1){
	printf(" ");
      }else if(j==c+1){
	printf("\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2104
N = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
puts a.join(' ')

for i in (1 .. (N - 1)) do
    v = a[i]
    j = i - 1
    while j >= 0 && a[j] > v do
        a[j + 1] = a[j]
        j -= 1
    end
    a[j+1] = v
    puts a.join(' ')
end



Measured memory_bytes: 6892
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j] <= x) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

int main(void) {
  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  q = partition(0,n-1);

  for(i=0; i<n; i++) {
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
int main(){
ll n ,x=0,y=0 ;
cin >> n ;
int a[n] ,b[n] ;
for(int i=0;i<n;i++)
{
    cin >> a[i] ;

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

}
for(int i=0;i<n;i++)
{
    if(a[i]>b[i])
    {
        x+=a[i] ;
        y+=b[i] ;
    }

}

cout << x-y<<endl ;

 return 0  ;
}



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

int main(){
  string s;
  
  cin >> s;
  
  if(s == "ABC"){
    cout << "ARC\n";
  }
  if(s == "ARC")
    cout << "ABC\n";
  
  //cout << << endl;
  
  return 0;
  
}


Measured memory_bytes: 3624
local mmi, mma = math.min, math.max
local h, w = io.read("*n", "*n")
local t = {}
local asked = {}
local len = {}
local inf = 1000000007
for i = 1, 10 do
  t[i] = {}
  asked[i] = false
  len[i] = inf
  for j = 1, 10 do
    t[i][j] = io.read("*n")
  end
end
len[2] = 0
for i = 1, 10 do
  local dst = false
  for j = 1, 10 do
    if not asked[j] then
      if not dst or len[j] < len[dst] then
        dst = j
      end
    end
  end
  asked[dst] = true
  for src = 1, 10 do
    len[src] = mmi(len[src], len[dst] + t[src][dst])
  end
end

local ret = 0
for i = 1, h * w do
  local a = 1 + io.read("*n")
  if 0 < a then
    ret = ret + len[a]
  end
end
print(ret)


Measured memory_bytes: 760
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> b(n), ans;
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    while (!b.empty()) {
        bool update = false;
        for (int i = (int) b.size() - 1; i >= 0; --i) {
            if (b[i] == i + 1) {
                ans.emplace_back(b[i]);
                b.erase(b.begin() + i);
                update = true;
                break;
            }
        }
        if (!update) {
            cout << -1 << endl;
            return 0;
        }
    }

    reverse(ans.begin(), ans.end());
    for (auto &i : ans) cout << i << endl;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long num = 0;
        int count=0;
        while (num<n){
            count++;
            num+=(long)Math.pow(26,count);
        }
        long instance = n-num+(long)Math.pow(26,count)-1;
        ArrayList<Character> array = new ArrayList<>();
        for (int i=0;i<count;i++){
            int mod = (int) (instance%26);
            array.add((char)mod);
            instance /= 26;
        }
        String s = "";
        for (int i=0;i<array.size();i++){
            s = (char) (array.get(i) + 'a') +s;
        }
        System.out.println(s);
    }
}


Measured memory_bytes: 39092
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let n: usize = read_line().trim().parse().unwrap();
    let a: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut pos = HashMap::new();
    for i in 0..n {
        pos.insert(a[i], i);
    }

    let mut ans = 0i64;

    let mut pr = vec![0i32; n+1];
    let mut nr = vec![0i32; n+1];
    for i in 0..n {
        pr[i] = i as i32 -1;
        nr[i] = i as i32 +1;
    }

    for i in (1i64..(n+1) as i64).rev() {
        let x = pos.get(&i).unwrap();
        let v = *x as i64;
        let n = nr[*x];
        let p = pr[*x];
        ans += i * (v - p as i64) * (n as i64 - v);
        
        if (n >= 0) {
            pr[n as usize] = p;
        }
        if (p >= 0) {
            nr[p as usize] = n;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 18060
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    rep(i, n) cin >> m[i];
    int s = 0;
    rep(i, n) s += m[i];
    x -= s;
    cout << n + x / (*min_element(m.begin(), m.end())) << endl;
    
}


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

int main() {
  
  int N; cin >> N; int ans = 0, count = 1;
  
  vector<int64_t> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  sort(vec.begin(), vec.end());
  
  for (int i = 0; i < N - 1; i++) {
    
    if (i == N - 2) {
      
      if (vec[i] == vec[i + 1]) count++;
      
      else ans++;
      
      if (count % 2 == 1) ans++;
      
      break;
      
    }
    
    if (vec[i] == vec[i + 1]) count++;
    
    else {
      if (count % 2 == 1) ans++;
      count = 1;
    }
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 4024
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
using ll=long long;
using namespace std;
//const int INF = 7+(1e+9);
ll GCD(ll x, ll y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return GCD(y, x % y);
    }
}
ll LCM(ll x, ll y)
{
    return x / GCD(x, y) * y;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
vector<vector<char>> vec(12,vector<char>(12));

int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};
int dfs(int y,int x){
    vec[y][x]='5';
    for(int i=0;i<4;i++){
        if(x+dx[i]<12&&x+dx[i]>=0&&y+dy[i]<12&&y+dy[i]>=0&&vec[dy[i]+y][dx[i]+x]=='1'){
            dfs(y+dy[i],x+dx[i]);
        }
    }
    return 0;
}
int main(){
   ll v,e;cin>>v>>e;
   vector<vector<ll>> vec(v,vector<ll>(v,1e15));
   for(int i=0;i<e;i++){
       ll x,y,w;
       cin>>x>>y>>w;
       vec[x][y]=w;
   }
   for(int k=0;k<v;k++){
       for(int i=0;i<v;i++){
           for(int j=0;j<v;j++){
               if(vec[i][k]!=1e15&&vec[k][j]!=1e15){
                   vec[i][j]=min(vec[i][j],vec[i][k]+vec[k][j]);
               }
           }
       }
    }
    for(int i=0;i<v;i++){
       if(vec[i][i]<0){
           cout<<"NEGATIVE CYCLE"<<endl;
           return 0;
       }
   }
   for(int i=0;i<v;i++){
       for(int j=0;j<v;j++){
           if(i==j){
               cout<<0;
               if(j!=v-1)cout<<" ";
               continue;
           }
           if(vec[i][j]==1e15){
               cout<<"INF";
           }else{
               cout<<vec[i][j]; 
           }
           if(j!=v-1)cout<<" ";
       }
       cout<<endl;
   }
}



Measured memory_bytes: 3224
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    h, w = read_int_list()
    s = [list(read_str()) for i in range(h)]
    for i in range(h):
        for j in range(w):
            if s[i][j] == '.':
                c = 0
                for k in [-1, 0, 1]:
                    for l in [-1, 0, 1]:
                        if 0 <= i + k < h:
                            if 0 <= j + l < w:
                                if s[i + k][j + l] == '#':
                                    c += 1
                s[i][j] = str(c)
    for i in range(h):
        print(''.join(s[i]))


main()


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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define eps 1e-9

ll A[3005];

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

	ll n, i, j, k;
	cin >> n;
	ll ans = 0;
	for (i = 0; i < n; ++i) {
			cin >> k; ans += k-1;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <vector>
#include <stack>
#include <string>
#include <iostream>
using namespace std;
typedef long long LL;

const int MaxN = 1e5;
int n;
LL a[MaxN + 5], sum[MaxN + 5];

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	sort(a + 1, a + n + 1);
	sum[0] = 0;
	for(int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
	int num = 1;
	for(int i = n - 1; i >= 1; i--)
		if(2LL * sum[i] < a[i + 1])	break;
		else num++;
	printf("%d\n", num);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rrep(n) for(int i=n-1;i+1;i--)
int n,k,sum,cnt;
main() {
	cin>>n>>k;
	vector<int>a(n);
	rrep(n)cin>>a[i];
	sort(a.begin(),a.end());
	rrep(n){
		if(sum+a[i]<k){
			sum+=a[i];
			cnt++;
		}
		else cnt=0;
	}
	cout<<cnt<<endl;
}

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

int main()
{
  int m[10];
  for (int i=0; i<10; i++)
  {
    cin >> m[i];
  }

  for(int i=0; i<3; i++)
  {
    int max = 0;
    for(int j=0; j<9; j++)
    {
      if ( m[max] < m[j+1] ) max = j+1;
    }
    cout << m[max] << endl;
    m[max] = -1;
  }
}

Measured memory_bytes: 1160
import sys
stdin = sys.stdin
#n = int(stdin.readline().rstrip())
n,Y = map(int, stdin.readline().rstrip().split())

for x in range(n+1):
    for y in range(n+1):
        z = n - x - y
        money = 10000*x + 5000*y + 1000*z
        if z >= 0 and money == Y:
            print(x,y,z)
            exit()
        else:
            pass

print(-1,-1,-1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, sum=0, mod, in;
  cin >> N;
  in = N;
  while(N > 0){
    mod = N % 10;
    sum += mod;
    N /= 10;
  }

  if(in % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, m; cin >> n >> m;
    auto g = vec<bool>(n, n);
    FOR(i, 0, m) {
        int a, b; cin >> a >> b;
        --a, --b;
        g[a][b] = true;
        g[b][a] = true;
    }

    int ans = 0;
    VI p(n - 1);
    FOR(i, 0, n - 1)p[i] = i + 1;
    do {
        int now = 0;
        bool ok = true;
        FOR(i, 0, n - 1) {
            ok &= g[now][p[i]];
            now = p[i];
        }
        if (ok)++ans;
    } while (next_permutation(all(p)));

    cout << ans << "\n";
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
while (a!=0) or (b!=0) or (c!=0):
    ans = 0
    for i in range(1,c):
        j = c - i
        ori_i,ori_j = 0,0
        for i_ori in range(1,i+1):
            if int(i_ori*(100+a)/100)==i:
                ori_i = max(ori_i,i_ori)
        for j_ori in range(1,j+1):
            if int(j_ori*(100+a)/100)==j:
                ori_j = max(ori_j,j_ori)
        ans = max(ans,int(ori_i*(100+b)/100)+int(ori_j*(100+b)/100))
        
    print(ans)
    a,b,c = map(int,input().split())


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    int h,w;
    ll ans = 0;
    cin >> h >> w;
    int mx[] = {1, 0, -1, 0},my[] = {0, 1, 0, -1};
    vector<vector<bool> > s(h + 2,vector<bool>(w + 2,false));
    queue<pair<ll, ll>> q;
    rep0(i, h){
        string S;
        cin >> S;
        rep0(j, w)if(S[j] == '#'){
            s[i + 1][j + 1] = true;
            q.push(make_pair(i + 1, j + 1));
        }
    }
    vector<vector<bool> > c(h + 2,vector<bool>(w + 2,false));
    while (!q.empty()) {
        queue<pair<ll, ll>> cq;
        ll x = q.front().first,y = q.front().second;
        c[x][y] = true;
        cq.push(q.front());
        ll cnt = 1,cnt2 = 0;
        while (!cq.empty()) {
            x = cq.front().first;
            y = cq.front().second;
            rep0(i, 4){
                if(!c[x - mx[i]][y - my[i]] && y - my[i] <= w && y - my[i] > 0 && x - mx[i] <= h && x - mx[i] > 0 && s[x][y] != s[x - mx[i]][y - my[i]]){
                    cq.push(make_pair(x - mx[i], y - my[i]));
                    c[x - mx[i]][y - my[i]] = true;
                    if(!s[x - mx[i]][y - my[i]])++cnt2;
                    else ++cnt;
                }
            }
            cq.pop();
        }
        ans += cnt * cnt2;
        q.pop();
    }
    pf(ans)
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<utility>
#include<set>
#include <queue>
#define ull unsigned long long
#define ll long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define S(x) scanf("%d",&x)
#define Sl(x) scanf("%lld",&x)
#define M(x,i) memset(x,i,sizeof(x))
#define F(i,a,n) for(i=(a);i<(n);++i)
#define FD(i,a,n) for(i=(a);i>=(n);--i)
using namespace std;
vector<string> a(10);
int vis[10][10];
int main()
{
    int i,j,h,w;
    ios_base :: sync_with_stdio(false); 

    cin>>h>>w;
    F(i,0,h){
        cin>>a[i];
    }

    j = 0;
    F(i,0,h){
        if(a[i][j] == '.'){
            cout<<"Impossible"<<endl;
            return 0;
        }
        while(j<w){
            if(a[i][j] == '.'){
                j--;
                break;
            }
            vis[i][j] =1;
            j++;
        }
        j = min(j,w-1);
    }

    F(i,0,h){
        F(j,0,w){
            if(a[i][j] == '#' && vis[i][j] ==0){
                cout<<"Impossible"<<endl;
                return 0;
            }
        }
    }


    cout<<"Possible"<<endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#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 pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	ll x,y,i;
	cin >> x >> y;
	for(i=0;x<=y;i++) x*=2;
	cout << i << endl;
	return 0;
}


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

int main() {
    double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(12);
    cout << sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)) << endl;
    
    return 0;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*
C[Y][X]
2^12*6*6まにあうか
*/
int main(){
  ll H,W,K,ans=0; cin>>H>>W>>K;
  vector<vector<char>> C(H, vector<char>(W, '.'));
  for(ll y=0; y<H; y++) for(ll x=0; x<W; x++){
      char c; cin>>c;
      if(c=='.') continue;
      C[y][x]=c;  
  }
  ll h=1<<H, w=1<<W;
  for(ll i=0; i<h; i++) for(ll j=0; j<w; j++){
    ll tmp=0;    
    for(ll y=0; y<H; y++){
      if(((1<<y)&i)>0) continue;
      for(ll x=0; x<W; x++){
        if(((1<<x)&j)>0) continue;
        if(C[y][x]=='#') tmp++;
      }
    }
    if(tmp==K) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3644