akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define all(n) (n).begin(),(n).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int n;
void dfs(string s, char x){
	if(s.size()==n){
		cout<<s<<endl;
		return ;
	}

	for(char i='a' ; i<=x ; i++){
		if(x == i){
			dfs(s+i,x+1);
		}
		else{
			dfs(s+i,x);
		} 
			
	}
}
int main(){
	cin>>n;
	dfs("",'a');
}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
bool check(const vector<ll>& a, const vector<ll>& b, ll x) {
    bool G[51][51] = {0};
    const ll n = 51;
    rep(i, n) G[i][i] = true;
    rep(i, n) rep(j, n) {
        if ((1LL<<j+1) & x) {
            G[i][i % (j+1)] = true;
        }
    }
    rep(k, n) rep(i, n) rep(j, n) {
        if (G[i][k] && G[k][j]) G[i][j] = true;
    }
    rep(i, a.size()) {
        if (!G[a[i]][b[i]]) return false;
    }
    return true;
}
ll solve() {
    ll n; cin >> n;
    vector<ll> a(n), b(n); cin >> a >> b;
    ll ans = (1LL<<51)-1;
    if (!check(a, b, ans)) return -1;
    rrep(i, 51) {
        if (check(a, b, ans ^ (1LL<<i))) {
            ans ^= 1LL<<i;
        }
        else {
            // cout << i+1 << endl;
        }
    }
    return ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 100001;

int n, m, vis[N];
vector <int> v[N];

void dfs(int node, int &sz, int &b){
    sz++;
    for(auto &i : v[node]){
        if(vis[i] == -1){
            vis[i] = vis[node] ^ 1;
            dfs(i, sz, b);
        }
        if(vis[node] != (vis[i] ^ 1)) b = 1;
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(vis, -1, sizeof vis);
    cin >> n >> m;
    for(int i = 0 ; i < m ; i++){
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int ones = 0;
    int g = 0, h = 0;
    for(int i = 1 ; i <= n ; i++){
        if(vis[i] != -1) continue;
        vis[i] = 0;
        int sz = 0, b = 0;
        dfs(i, sz, b);
        if(sz == 1) ones++;
        else{
            if(b == 0) g++;
            else h++;
        }
    }
    ll ans = 2LL * g * g;
    ans += 1LL * (g + h) * (g + h) - 1LL * g * g;
    int cur = n - ones;
    while(ones--){
        ans += 2 * cur + 1;
        cur++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7,INF=1e17;
const int iINF=1e9;
#define enld endl
int main(){
    ll l,r,ans=INF;
    cin>>l>>r;
    if(r-l+1>=2019)cout<<0<<endl;
    else{   
        for(ll i=l;i<r;i++){
            for(ll j=l+1;j<=r;j++){
                ans=min(ans,(i*j)%2019);
            }
        }
        cout<<ans<<endl;
    }

}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int r;
    cin >> r;
    const double pi = acos(-1.0);
    double ans = 2 * pi * r;
    cout << setprecision(20) << fixed << ans << endl;
    return 0;
}


Measured memory_bytes: 3768
n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
  t[i+1]=t[i]+(1 if s[i:i+2]=='AC' else 0)
for j in range(q):
  l,r=map(int,input().split())
  print(t[r-1]-t[l-1])
  
    

    


Measured memory_bytes: 7748
n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n):
    a[i] -= 1

l = [-1]*n #list for order of teleportation
l[0] = 0
ct = 0 #current town
od = 1 #order of teleportation

while True:
    k -= 1
    ct = a[ct]
    if k == 0:
        break
    if l[ct] == -1:
        l[ct] = od
        od += 1
    else:
        cycle = od - l[ct]
        k %= cycle
        od += 1

print(ct + 1)

Measured memory_bytes: 32392
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func Min(x, y int) int {
	if x <= y {
		return x
	}
	return y
}

func main() {
	var str string
	fmt.Scan(&str)
	cs := strings.Split(str, "")
	n := len(str)
	xs := make([]int, n)
	for i, c := range cs {
		xs[i], _ = strconv.Atoi(c)
	}
	n0 := 0
	n1 := 0
	for i := 0; i < n; i++ {
		d0 := i % 2
		d1 := 1 - d0
		n0 += Abs(d0 - xs[i])
		n1 += Abs(d1 - xs[i])
	}
	val := Min(n0, n1)
	fmt.Print(val)
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define loop(i,L,R) for(int i=(L);i<=(R);i++)
#define rept(i,L,R) for(int i=(L);i<(R);i++)
#define isc(n) scanf("%d",&n)
#define llsc(n) scanf("%lld",&n)
#define dsc(n) scanf("%lf",&n)
#define enl cout<<endl
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
#define xx first
#define yy second
typedef long long ll;
typedef pair<int,int>PI;
typedef pair<int,pair<int,int> >PII;

const int mx=1e4+10;
int arr[2][mx];
int main()
{
	int n;
	cin>>n;
	rept(i,0,n)cin>>arr[0][i];
	rept(i,0,n)cin>>arr[1][i];
	ll have=0;
	rept(i,0,n)
	{
		if(arr[0][i]<arr[1][i])have+=((arr[1][i]-arr[0][i])/2);
	}
	ll need=0;
	rept(i,0,n)
	{
		if(arr[1][i]<arr[0][i])need+=((arr[0][i]-arr[1][i])/1);
	}
	if(need<=have)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
#define tl 1'000'000'007

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll bb= n-2;
    ll acnt= 2, bcnt= bb%10;
    int adig,bdig;
    while(bb/=10) bcnt+= bb%10;
    ll cnt= acnt+bcnt;
    ll mmin= acnt+bcnt;
    // cout << mmin << endl;
    FOR(i,3,n){
        ll a= i,b= n-i;
        adig=0;
        bdig=0;
        if(a%10==0) {while(a>0&&a%10==0) {adig++;a/=10;}cnt-= (adig*9-1);}
        else cnt++;
        if(b%10==9) {while(b>0&&b%10==9) {bdig++;b/=10;}cnt+= (bdig*9-1);}
        else cnt--;
        // cout << "a:"<<i << " b:"<<n-i<<cnt << enådl;
        mmin= min(cnt,mmin);
    }
    cout << mmin << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc042_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(x);
            if(x[0] == 5 && x[1] == 5 && x[2] == 7)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 2776
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextInt();
		long sumJ = 0;
		for (int j = 1; j < n; j++)
			sumJ += a[j];
		long ans = 0;
		for (int i = 0; i < n - 1; i++) {
			long aj = sumJ % 1000000007L;
			ans += (long) a[i] * aj;
			ans %= 1000000007L;
			sumJ -= a[i + 1];
		}
		System.out.println(ans);
	}
}


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

int main(){
	int n,t;
	cin>>n>>t;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin>>a[i];
	}
	//d[i]:a[i]~a[n-1]での最大値
	vector<int> d(n);
	d[n-1]=a[n-1];
	for (int i = n-2; i >= 0; i--) {
		if (a[i]<=d[i+1]) {
			d[i]=d[i+1];
		}else {
			d[i]=a[i];
		}
	}
	vector<int> profit(n);
	for (int i = 0; i < n; i++) {
		profit[i]=d[i]-a[i];
	}
	sort(profit.begin(),profit.end(),greater<int>());		
	int ans=0;
	int e=0;
	while (profit[e]==profit[0]&&e<n) {
		ans++;
		e++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1408
def get_possible(n, people):
    counts = {}
    values = set([])
    for person in people:
        if not counts.get(person):
            counts[person] = 1
            values.add(person)
        else:
            counts[person] += 1
 
    # If even
    if n % 2:
        start_value = 0
    else:
        start_value = 1
 
    if values != set([i for i in xrange(start_value, n , 2)]):
        return 0
 
    possibilities = 1
 
    if 0 in values:
        values.remove(0)
 
    for key in list(values):
        if counts.get(key) != 2:
            return 0
        else:
            possibilities *= counts.get(key)
 
    return possibilities
 
 
 
if __name__ == "__main__":
    n = int(raw_input())
    people = map(int, raw_input().split(' '))
    print (get_possible(n, people) % (10**9 + 7))

Measured memory_bytes: 15292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N =2e5+100;
ll s[N],s1[N];
int main()
{
    ll n;
    while(~scanf("%lld",&n))
    {

        for(int i=0; i<n; i++)
        {
            scanf("%lld",&s[i]);
            s1[i] =s[i];
        }
        sort(s,s+n);
        ll Max =s[n-1],MAX =s[n-2];

        for(int i=0; i<n; i++)
        {
            if(s1[i]!=Max)
                printf("%lld\n",Max);
            else
                printf("%lld\n",MAX);
        }
    }
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h> 
using namespace std ; 
#define ll long long int 
#define pb push_back
#define ff first 
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second 
#define S(x) scanf("%d",&x) 
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()
#define N 3005 

ll dp[5][N] ,R , G , B , tot ;

ll f(int idx , int rem){
	if(idx == 4){
		if(rem == 0){
			return 1 ; 
		}
		return 0 ; 
	}

	if(dp[idx][rem] != -1){
		return dp[idx][rem] ; 
	}
    
    ll res = 0 ; 
    int lmt , mult ; 
	
	if(idx == 1)
		lmt = rem/R , mult = R ;  
	if(idx == 2)
		lmt = rem/G , mult = G ; 
	if(idx == 3)
		lmt = rem/B , mult = B ; 
    
    //cout<<mult<<endl; 
	for(int i=0;i<=lmt;i++){
		res += f(idx + 1, rem - i*mult) ;
	}

	return dp[idx][rem] = res ; 
}	 
int main(){
	cin>>R>>G>>B>>tot ; 
	memset(dp , -1 , sizeof(dp)) ; 
	ll ans = f(1 , tot) ; 
	cout<<ans<<"\n" ; 
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
int main() {
	map<string, int>m;
	m["AC"] = 0;
	m["WA"] = 0;
	m["TLE"] = 0;
	m["RE"] = 0;
	int n;
	cin >> n;
	for (int i = 1;i <= n;i++) {
		string s;
		cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;
}


Measured memory_bytes: 3628
a = [[int(i) for i in input().split()] for _ in range(3)]
for i in range(int(input())):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                a[j][k] = 0

ans = "No"
for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == 0:
        ans = "Yes"
    if a[0][i] == a[1][i] == a[2][i] == 0:
        ans = "Yes"
if a[0][0] == a[1][1] == a[2][2] == 0:
    ans = "Yes"
if a[2][0] == a[1][1] == a[0][2] == 0:
    ans = "Yes"
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
  int n, m,i,j,k,l;
  scanf("%d%d",&n,&m);
  char a[55][55],b[55][55];
  for(i=0;i<n;i++){
    scanf("%s",a[i]);
  }
  for(i=0;i<m;i++){
    scanf("%s",b[i]);
  }
  for(i=0;i<n-m+1;i++){
    for(j=0;j<n-m+1;j++){
      int t=1;
      for(k=0;k<m;k++){
        for(l=0;l<m;l++){
          if(a[i+k][j+l]!=b[k][l])t=0;
        }
      }
      if(t){
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <map>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define efo(i,q) for(int i=A[q];i;i=B[i][0])
using namespace std;
typedef long long LL;
const int N=100500,mo=1e9+7;
int m,n;
int fj[N][2],fj0;
int d[N];
LL ans;
map<int,int>f;
LL ksm(LL q,int w) {
	LL ans=1;
	for(; w; w>>=1,q=q*q%mo)if(w&1)ans=ans*q%mo;
	return ans;
}
int ss1(int q,int w,int e) {
	if(q>w)return f[e];
	int ans=ss1(q+1,w,e);
	fo(i,1,d[q])((ans+=ss1(q+1,w,(e=e*fj[q][0])))>=mo?ans-=mo:0);
	return ans;
}
void ss(int q,int e) {
	if(q>fj0) {
		LL t=(((n/e)%2?ksm(m,(e+1)>>1):ksm(m,e))-ss1(1,q,1)+mo)%mo;
		f[e]=t;
		ans=(ans+t*e)%mo;
		return;
	}
	d[q]=0;
	ss(q+1,e);
	fo(i,1,fj[q][1])d[q]=i,ss(q+1,(e*=fj[q][0]));
}
int main() {
	int q,w;
	scanf("%d%d",&n,&m);
	if(n==1)return printf("%d\n",m),0;
	q=n;
	for(int i=2; i*i<=q; ++i)if(q%i==0) {
			for(fj[++fj0][0]=i; !(q%i); ++fj[fj0][1],q/=i);
		}
	if(q>1)fj[++fj0][0]=q,fj[fj0][1]=1;
	ss(1,1);
	printf("%lld\n",(ans+mo)%mo);
	return 0;
}

Measured memory_bytes: 384
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int
    fmt.Scan(&n)
    ans := 0
    for i:=1; i<=n; i+=2{
        cnt := 0
        for j:=1; j<=i; j++{
            if i%j==0{
                cnt++
            }
        }
        if cnt==8{
            ans++
        }
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
a, b, c, x, y = list(map(int, input().split()))
if x == y:
  if a + b >= 2*c:
    print(2*c*x)
  else:
    print(a*x + b*y)
    
elif x > y:
  if a + b >= 2*c:
    if a <= 2*c:
      print(2*c*y + a*(x-y))
    else:
      print(2*c*x)
  else:
    if a <= 2*c:
      print(a*x + b*y)
    else:
      print(a*y + b*y + 2*c*(x-y))
      
else:
  if a + b >= 2*c:
    if b <= 2*c:
      print(2*c*x + b*(y-x))
    else:
      print(2*c*y)
  else:
    if b <= 2*c:
      print(a*x + b*y)
    else:
      print(a*x + b*x + 2*c*(y-x))

Measured memory_bytes: 9200
#include<stdio.h>
short FLG[10001][721];
main(){
  int N,M,t,n,m,s,r,i,j,k,cnt,pc[1001];
  while(1){
    for(i=0;i<=1000;i++)pc[i]=0;
    scanf("%d %d",&N,&M);
    if(N==0&&M==0)break;
    for(i=0;i<=M;i++){
      for(j=0;j<721;j++){
	FLG[i][j]=0;
      }
    }
    scanf("%d",&r);
    for(i=0;i<r;i++){
      scanf("%d %d %d %d",&t,&n,&m,&s);
      if(s==1){
	pc[n]=t;
      }else{
	for(j=pc[n];j<t;j++){
	  FLG[m][j-540]=1;
	}
      }
    }
    scanf("%d",&N);
    for(i=0,cnt=0;i<N;i++,cnt=0){
      scanf("%d %d %d",&t,&n,&m);
      for(j=t;j<n;j++){
	if(FLG[m][j-540]==1){
	  cnt++;
	}
      }
      printf("%d\n",cnt);
    }
  }
  return 0;
}

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

int main(){
    int n = 0, m = 0;
    cin >> n >> m;
    if( n <= m ){
        for (int i = 0; i < m; i++)
            cout << n;
    }
    else{
        for (int i = 0; i < n; i++)
            cout << m;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        String s = sc.next();

        if (s.substring(Math.min(a, c) - 1, Math.max(a, c)).contains("##")) {
            System.out.println("No");
            return;
        }
        if (s.substring(Math.min(b, d) - 1, Math.max(b, d)).contains("##")) {
            System.out.println("No");
            return;
        }
        if (c > d) {
            System.out.println(s.substring(b - 2, Math.min(n, d + 1)).contains("...") ? "Yes" : "No");
            return;
        }

        System.out.println("Yes");
    }
}

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


int main() {
  int N,M;
  cin>>N>>M;
  vector<vector<bool>> road(N+1,vector<bool>(N+1,false));
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    road.at(a).at(b)=true;
    road.at(b).at(a)=true;
  }
  
  vector<int> town(0);
  for(int i=2;i<=N;i++){
    town.push_back(i);
  }

  int count=0;
  do{
    bool judge=true;
    if(road.at(1).at(town.at(0))==false){
      judge=false;
    }
    for(int i=0;i<N-2;i++){
      if (road.at(town.at(i)).at(town.at(i+1))==false){
        judge=false;
      }
    }
    if(judge){count++;}
  }while(next_permutation(town.begin(),town.end()));
  
  cout<<count<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int search(char str[], int i);

int main(void)
{
	char str[101];
	int i;
	int count;
	
	scanf("%s", str);
	for(i = 0; str[i] != '\0'; i++) {
		if(str[i] == ' ') {
			continue;
		}
		count = search(str, i);
		if(count % 2 != 0) {
			break;
		}
	}
	if(count % 2 == 0) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}
int search(char str[], int i)
{
	char m = str[i];
	int j, count = 0;
	
	for(j = 0; str[j] != '\0'; j++) {
		if(str[j] == m) {
			count++;
			str[j] = ' ';
		}
	}
	return count;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_c() {
	ll N;
	ll ans = 0;

	cin >> N;

	vector<P> A[15];
	ll x, y, size;
	rep(i, N) {
		cin >> size;
		rep(j, size) {
			cin >> x >> y;
			A[i].push_back(make_pair(x, y));
		}
	}

	ll cnt = 0;
	ll p, q;
	bool ret = true;
	rep(i, 1LL<<N) {
		ret = true;
		rep(j, N) {
			p = (i >> j) & 1;
			if (p == 1) {
				rep(k, A[j].size()) {
					q = A[j][k].first;
					if (((i >> (q-1)) & 1) != A[j][k].second) {
						ret = false;
						break;
					}
				}
			}
		}
		if (ret) {
			cnt = 0;
			rep(j, N) {
				if (((i >> j) & 1) == 1) {
					cnt++;
				}
			}
			ans = max(ans, cnt);
		}
	}

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

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

	solve_abc_c();

	return 0;
}

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

constexpr int inf = 1000000009;

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
  static_assert(D >= 1, "Vector dimension must be greater than zero!");
  template<typename... Args>
  Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
  }
};
template<typename T>
struct Vec<1, T> : public vector<T> {
  Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
  }
};

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> X(2), Y(2);
  cin >> X[0] >> Y[0] >> X[1] >> Y[1];
  --X[0]; --Y[0]; --X[1]; --Y[1];
  vector<string> g(n);
  vector<vector<int>> R(n), C(m);
  for(int i = 0; i < n; ++i) {
    cin >> g[i];
    for(int j = 0; j < m; ++j) {
      if(g[i][j] == '@') R[i].push_back(j), C[j].push_back(i);
    }
  }
  vector<set<int>> row(n), col(m);
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < m; ++j) {
      if(g[i][j] == '.') {
        row[i].insert(j);
        col[j].insert(i);
      }
    }
  }
  Vec<2, int> dist(n, m, inf);
  queue<pair<int, int>> q;
  dist[X[0]][Y[0]] = 0;
  q.push({X[0], Y[0]});
  row[X[0]].erase(Y[0]);
  col[Y[0]].erase(X[0]);
  while(q.size()) {
    auto [i, j] = q.front();
    q.pop();
    auto it = upper_bound(R[i].begin(), R[i].end(), j);
    int big = m;
    int low = -1; 
    if(it != R[i].end()) big = *it;
    if(it != R[i].begin()) {
      --it;
      low = *it;
    }
    big = min(big, j + k + 1);
    low = max(low, j - k - 1);
    for(auto Jit = row[i].upper_bound(low); Jit != row[i].end() && *Jit < big; ){
      dist[i][*Jit] = dist[i][j] + 1;
      q.push({i, *Jit});
      col[*Jit].erase(i);
      Jit = row[i].erase(Jit);
    }
    big = n;
    low = -1;
    it = upper_bound(C[j].begin(), C[j].end(), i);
    if(it != C[j].end()) big = *it;
    if(it != C[j].begin()) {
      --it;
      low = *it;
    }
    big = min(big, i + k + 1);
    low = max(low, i - k - 1);
    for(auto Jit = col[j].upper_bound(low); Jit != col[j].end() && *Jit < big; ){
      dist[*Jit][j] = dist[i][j] + 1;
      q.push({*Jit, j});
      row[*Jit].erase(j);
      Jit = col[j].erase(Jit);
    }
  }
  cout << (dist[X[1]][Y[1]] == inf ? -1 : dist[X[1]][Y[1]]) << '\n';
}

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

struct Point{
    int x,y;
};

int main(){
    Point s,t; 
    cin >> s.x >> s.y;
    cin >> t.x >> t.y;
    int u,r;
    u = abs(s.y- t.y);
    r = abs(s.x-t.x);
    for(int i = 0; i < u; i++){
        cout << 'U';
    }
    for(int i = 0; i < r; i++){
        cout << 'R';
    }
    for(int i = 0; i < u; i++){
        cout << 'D';
    }
    for(int i = 0; i < r; i++){
        cout << 'L';
    }

    cout << 'L';
    for(int i = 0; i < u+1; i++){
        cout << 'U';
    }
    for(int i = 0; i < r+1; i++){
        cout << 'R';
    }
    cout << "DR";
    for(int i = 0; i < u+1; i++){
        cout << 'D';
    }
    for(int i = 0; i < r+1; i++){
        cout << 'L';
    }
    cout << 'U';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	t := make([]uint, n)
	for i := range t {
		fmt.Scan(&t[i])
	}

	ans := t[0]
	for i := 1; i < n; i++ {
		ans = lcm(ans, t[i])
	}
	fmt.Println(ans)
}

func gcd(n, m uint) uint {
	if n%m == 0 {
		return m
	}
	return gcd(m, n%m)
}

func lcm(n, m uint) uint {
	// return n * m / gcd(n, m)
	return n / gcd(n, m) * m
}


Measured memory_bytes: 512
import sys

N = int(sys.stdin.readline())
S = sys.stdin.readline()

ans = 0
for i in range(1000):
    password = str(i).zfill(3)
    p_i = 0
    s_i = 0
    while s_i < len(S) and p_i < 3:
        # print(p_i, s_i)
        if S[s_i] == password[p_i]:
            p_i += 1
        s_i += 1
    if p_i == 3:
        ans += 1
print(ans)

Measured memory_bytes: 41180
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>
#define mod 998244353
#define pb push_back
#define ll long long
using namespace std;
int main(){
	ll n,x;
	cin>>n>>x;
	if( n/2 < x) x = n-x;
	n -= x;
	ll ans=0;
	while(x>=1){
		ans += (n/x) * x * 3;
		ll tmpx = x;
		ll tmpn = n;
		n = tmpx;
		x = tmpn%tmpx;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  ll a, b, c, k, ans = 0;
  cin >> a >> b >> c >> k;
  if(k <= a) ans = k;
  else if(k <= a+b) ans = a;
  else ans = 2*a + b - k ;
  cout << ans << endl;
}


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

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    int a[n];
    int dp[n]={0};
    for(int i=0;i<n;i++)
    {
        dp[i]=1e18;
        cin>>a[i];
        if(i==0)
        {
            dp[i]=0;
            continue;
        }
        for(int j=i-1;j>=max((long long)0,i-k);j--)
            dp[i]=min(dp[i],dp[j] + abs(a[i]-a[j]));
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 5184
#include <stdio.h>
#include <cmath>
#include <algorithm>

#define NUM 120000

int main(){
	int table[NUM],limit;

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int n,count,sum;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		sum = count = 0;
		for(int i=2; i< NUM; i++){
			if(table[i] == 1){
				sum += i;
				count++;
				if(count == n)break;
			}

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

Measured memory_bytes: 3052
#include<stdio.h>
int main(){
int l,a,b,c,d,jap,mat,sum;
scanf("%d\n%d\n%d\n%d\n%d",&l,&a,&b,&c,&d);
jap = a / c;
if((a%c)>0) jap++;
mat = b / d;
if((b%d)>0) mat++;
if(jap>=mat) sum = l - jap; else sum = l - mat;
printf("%d\n",sum);
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll A, B, P;
struct SegmentTree {
private:
    int n;
    vector<int> node;
 
public:
    SegmentTree() {
        int sz = 100010;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);
        for(int i=0; i<sz; i++) node[i+n-1] = 0;
        for(int i=n-2; i>=0; i--) node[i] = (node[2*i+1] + node[2*i+2]) % P;
    }
 
    void update(int x, int val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = (node[2*x+1] + node[2*x+2]) % P;
        }
    }
    // hannkaikukann 
    int getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];
 
        int vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        int vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return (vl + vr) % P;
    }
};

typedef pair<string, ll> sl;
ll ans;

void solve() {
    vector<sl> v;
    ans = 0;
    SegmentTree seg;
    for(ll i = A; i <= B; i++) {
        string S = to_string(i);
        ll j = i - A;
        v.push_back({S, j});
    }
    sort(v.begin(), v.end());
    for(auto tmp : v) {
        int idx = tmp.second;
        ll val = seg.getsum(0, idx);
        //cerr << idx << " " << val << endl;
        seg.update(idx, val + 1);
    }
    cout << seg.getsum(0, B - A + 1) << endl;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> A >> B >> P) {
        if(P == 0) break;
        solve();
    }
    return 0;
}


Measured memory_bytes: 10436
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair
#define debug_vec(x, n) cout << (#x) << ": "; for(int i = 0; i < n; i++) cout << x[i] << (i == n - 1 ? "\n" : " ");

#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << "\n";
    err(++it, args...);
}

typedef long long ll;
typedef long double ld;

ll pow5(ll x){
    return (x * x * x * x * x);
}

void solve(){
    ll x;
    cin >> x;
    vector<ll> all;
    for(ll i = -4000; i <= 4000; i++){
        all.pb(pow5(i));
    }
    for(ll i = 0; i <= 8000; i++){
        ll res = x + all[i];
        auto it = lower_bound(all.begin(), all.end(), res) - all.begin();
        if(all[it] == res){
            cout << it - 4000 << " " << i - 4000 << "\n";
            return;
        }
    }
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ls = new List<int>();
            var n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var str = int.Parse(Console.ReadLine());
                if (!ls.Contains(str))
                    ls.Add(str);
            }
            Console.WriteLine(ls.Count);
            Console.ReadLine();
        }
    }

}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

    ll n;
    cin >> n;

    if (n % 2 == 1 || n == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll div = 10;
    ll ans = 0;
    while (n / div > 0) {
        ans += n / div;
        div *= 5;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#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 show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#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>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);

int main () {
  int n, k;
  cin >> n >> k;
  vi h(n);
  rep(i,n) cin >> h[i];
  
  int ans = 0;
  rep(i,n) {
    if (h[i] >= k) ans++;
  }

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

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int main() {
	string s;
	cin >> s;
	int a = 0, b = 0;
	for (auto p : s) {
		if (p == '0')
			a++;
		else
			b++;
	}
	cout << s.size() - abs(a - b) << endl;
	return 0;
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	int min = 0, max = n;
	for (int i = 0; i < m; i++)
	{
		int L, R;
		cin >> L >> R;
		if (min < L)
			min = L;
		if (max > R)
			max = R;
	}
	cout << (max - min >= 0 ? max - min + 1 : 0) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N;
	int n[4];
	int ans;
	int i,j,k;

	scanf("%d", &N);

	n[3] = N % 10;
	n[2] = (N % 100)/10;
	n[1] = (N % 1000)/100;
	n[0] = (N % 10000)/1000;


							ans = n[0]+n[1]+n[2]+n[3];
							if(ans == 7){
								printf("%d+%d+%d+%d=7",n[0],n[1],n[2],n[3]);
								return 0;
							}

							ans = n[0]+n[1]+n[2]-n[3];
							if(ans == 7){
								printf("%d+%d+%d-%d=7",n[0],n[1],n[2],n[3]);
								return 0;
							}

							ans = n[0]+n[1]-n[2]+n[3];
							if(ans == 7){
								printf("%d+%d-%d+%d=7",n[0],n[1],n[2],n[3]);
								return 0;
							}
						
							ans = n[0]+n[1]-n[2]-n[3];
							if(ans == 7){
								printf("%d+%d-%d-%d=7",n[0],n[1],n[2],n[3]);
								return 0;
							}

							ans = n[0]-n[1]+n[2]+n[3];
							if(ans == 7){
								printf("%d-%d+%d+%d=7",n[0],n[1],n[2],n[3]);
								return 0;
							}

							ans = n[0]-n[1]+n[2]-n[3];
							if(ans == 7){
								printf("%d-%d+%d-%d=7",n[0],n[1],n[2],n[3]);
								return 0;
							}

							ans = n[0]-n[1]-n[2]+n[3];
							if(ans == 7){
								printf("%d-%d-%d+%d=7",n[0],n[1],n[2],n[3]);
								return 0;
							}
						
							ans = n[0]-n[1]-n[2]-n[3];
							if(ans == 7){
								printf("%d-%d-%d-%d=7",n[0],n[1],n[2],n[3]);
								return 0;
							}
						
					
				
			
		
	

return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int count_digits(ll val)
{
  int ret = 0;
  while (val > 0) {
    val /= 10;
    ++ret;
  }
  return ret;
}

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

  int ans = INF;
  for (ll i = 1; i * i <= N; ++i) {
    if (N % i != 0) { continue; }
    ans = min(ans, max(count_digits(i), count_digits(N / i)));
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

int main() {
    while (true) {
        int turn, n;
        cin >> turn >> n;
        if (turn == 0)break;
        vector<vector<bool>> can(300, vector<bool>(300, true));
        for (int i = 0; i < n; i++) {
            int x, y;
            cin >> x >> y;
            can[x + 100][y + 100] = false;
        }
        int fx, fy;
        cin >> fx >> fy;
        can[fx + 100][fy + 100] = false;

        queue<vector<int>> que;
        que.push({fx + 100, fy + 100});
        que.push({-1, -1});
        int depth = 1;

        vector<vector<int>> moves = {{1,  1},
                                     {1,  0},
                                     {0,  1},
                                     {0,  -1},
                                     {-1, 0},
                                     {-1, -1}};
        int ret = 0;
        while (depth <= turn) {
            vector<int> now = que.front();
            que.pop();
            if (now[0] < 0) {
                depth++;
                que.push({-1, -1});
            } else {
                for (auto move:moves) {
                    if (can[now[0] + move[0]][now[1] + move[1]]) {
                        ret++;
                        que.push({now[0] + move[0], now[1] + move[1]});
                        can[now[0] + move[0]][now[1] + move[1]] = false;
                    }
                }
            }
        }
        cout << ret + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
// scanf("%d %d %d %d",&w,&b,&d,&s); %lld
// printf("%d\n" ,points);
// const double PI=acos(-1);

int main(){
    fastIO;
    int x;
    cin >> x;
    if(x<600) cout << 8 << endl;
    else if(x>599 && x<800) cout << 7 << endl;
    else if(x>799 && x<1000) cout << 6 << endl;
    else if(x>999 && x<1200) cout << 5 << endl;
    else if(x>1199 && x<1400) cout << 4 << endl;
    else if(x>1399 && x<1600) cout << 3 << endl;
    else if(x>1599 && x<1800) cout << 2 << endl;
    else cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {

  public static void Main (string[] args) {
    var temp = ReadLineLongList();
    var X = temp.ElementAt(2);
    var Y = temp.ElementAt(3);
    var listX = ReadLineLongList();
    var listY = ReadLineLongList();
    var ans ="War";

    for(var i = X + 1; i <= Y; i++){
      if(listX.Max() < i && i <= listY.Min()){
        ans = "No War";
      }
    }
    
    Console.WriteLine(ans);
  }

  static int ReadLineInt_1() {
    return int.Parse(Console.ReadLine());
  }

  static IEnumerable<long> ReadLineLongList() {
    return Console.ReadLine().Split(' ').Select(long.Parse);
  }

}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define ri register int
using namespace std;
typedef long long ll;
#define pb push_back
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
const int N=3e5+5;
char s[55];
int n;
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  int a,b;
  cin>>a>>b;
  puts(a*500>=b?"Yes":"No");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);
    string S;
    // rep(i,2200) {
    //     S.push_back('1');
    //     S.push_back('2');
    //     S.push_back('3');
    //     S.push_back('4');
    //     S.push_back('5');
    //     S.push_back('6');
    //     S.push_back('7');
    //     S.push_back('8');
    //     S.push_back('9');
    // }
    cin >> S;
    ll ans = 0;
    int T = 0;
    int pow10 = 1;
    vector<int> count(2019,0);
    count.at(0)++;
    for (int i = S.size()-1; i >= 0; i--) {
        int Snum = S.at(i) - '0';
        T = (T+Snum*pow10)%2019;
        pow10 = pow10*10%2019;
        count.at(T)++;
        // cout << T << endl;
    }
    rep(i,2019) {
        ans += count.at(i)*(count.at(i)-1)/2;
    }
    cout << ans << endl;
}

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

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

  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }

  int ori = n;
  int count = 0;
  int minimum = v.at(0);
  for (int i = 1; i < n; i++) {
    if (i == 1) {
      if (v.at(1) > v.at(0)) {
        count++; // number of Ng
        continue;
      }
      minimum = v.at(1);
    }
    int min1 = min(v.at(i), minimum);
    if (v.at(i) > min1) {
      count++;
      continue;
    }
    minimum = v.at(i);
  }
  cout << ori - count;
  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

class Main
{
    public static void main (String[] args) throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine()),i,k=0;
        char s[]=bu.readLine().toCharArray();
        long p21[]=new long[n], p22[]=new long[n];
        for(i=0;i<n;i++)
        if(s[i]=='1') k++;

        boolean flag=true;
        if(k-1==0) flag=false;
        p21[0]=1; p22[0]=1;
        for(i=1;i<n;i++)
        {
            p21[i]=p21[i-1]*2%(k+1);
            if(flag) p22[i]=p22[i-1]*2%(k-1);
        }

        long l1[]=new long[n],r1[]=new long[n],sum1=0,sum2=0,l2[]=new long[n],r2[]=new long[n];
        for(i=0;i<n;i++)
        {
            l1[i]=sum1;
            l2[i]=sum2;
            if(s[i]=='1')
            {
                sum1+=p21[n-i-1];
                sum2+=p22[n-i-1];
            }
        }
        sum1=0; sum2=0;
        for(i=n-1;i>=0;i--)
        {
            r1[i]=sum1;
            r2[i]=sum2;
            if(s[i]=='1')
            {
                sum1+=p21[n-i-1];
                sum2+=p22[n-i-1];
            }
        }

        for(i=0;i<n;i++)
        {
            if(s[i]=='0')
            {
                sum1=l1[i]+r1[i]+p21[n-i-1];
                sb.append(rounds(sum1,k+1)+"\n");
            }
            else
            {
                if(!flag) {sb.append("0\n"); continue;}
                sum1=l2[i]+r2[i];
                sb.append(rounds(sum1,k-1)+"\n");
            }
        }
        System.out.print(sb);
    }

    static int rounds(long n,int k)
    {
        int ans=1; n%=k;
        while(n!=0)
        {
            n=n%setbits((int)n);
            ans++;
        }
        return ans;
    }

    static int setbits(int n)
    {
        int c=0;
        while(n!=0)
        {
            if((n&1)==1) c++;
            n>>=1;
        }
        return c;
    }
}

Measured memory_bytes: 63344
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.lang.Math.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int MX = (int)(1e6);
        int n = in.nextInt();
        int m1 = in.nextInt();
        int m2 = in.nextInt();
        int [][][] shops = new int[n+1][401][401];
        for(int i =0;i<=n;i++)
            for(int j=0;j<=400;j++)
                for(int k =0;k<=400;k++)
                    shops[i][j][k] = MX;
        shops[0][0][0]=0;
        for(int i=1;i<=n;i++){
            int ma = in.nextInt();
            int mb = in.nextInt();
            int cost = in.nextInt();
            for(int j =0;j<=400;j++){
                for(int k=0;k<=400;k++){
                    if(j>=ma && k>=mb ){
                        int pa = j-ma;
                        int pb = k-mb;
                        int c = cost+shops[i-1][pa][pb];
                        shops[i][j][k] = Math.min(c,shops[i-1][j][k]);
                    }
                    else {
                        shops[i][j][k]=shops[i-1][j][k];
                    }
                }
            }
        }
        int mn =MX;
        int ma = m1;int mb=m2;
        while (ma<=400 && mb<=400){
            if (shops[n][ma][mb]!=0){
                mn = Math.min(mn,shops[n][ma][mb]);
            }
            ma+=m1;
            mb+=m2;
        }

        if(mn!=MX){
            System.out.println(mn);
        }
        else {
            System.out.println(-1);
        }

    }
}


Measured memory_bytes: 56412
#include<iostream>
using namespace std;
int main(){
	int h,w;
	char x;
	int map[101][101];
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>x;
			if(x=='.')map[i][j]=-1;
			else map[i][j]=0;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(map[i][j]==0){
				int s=1;
				for(int z=j+1;z<w;z++){
					if(map[i][z]!=-1)break;
					else{
						map[i][z]=s;
						s++;
					}
				}
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(j!=0){
				cout<<" ";
			}
			cout<<map[i][j];
			if(j==w-1){
				cout<<endl;
			}
		}
	}
}

Measured memory_bytes: 3120
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int[] v = new int[n];
		for(int i = 0; i < n; i++) {
			v[i] = stdIn.nextInt();
		}
		int[]c = new int[n];
		for(int i = 0; i < n; i++) {
			c[i] = stdIn.nextInt();
		}
		
		int sum = 0;
		
		for(int i = 0; i < n; i++) {
			if(v[i]-c[i]>0) {
				sum+= v[i]-c[i];
			}
		}
		System.out.println(sum);
		
	}

}


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

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << s1.at(0) << s2.at(1) << s3.at(2) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,i,b;
	char s[100];
	scanf("%d %d",&a,&b);
	for(i=0;i<a;i++) {scanf("%s",s);
	printf("%s\n%s\n",s,s);
	}
	return 0;
	
	
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
bool isok(string a){
	string b=a;
	if(a.size()%2==0&&a.substr(0,a.size()/2)==a.substr(a.size()/2,a.size())) return true;
	else return false;
}
int main(){
	string s;
	cin>>s;
	int n=0;
	for(int i=0;i<s.size();i++){
		for(int j=0;j<s.size();j++){
			string t=s.substr(i,j);
			if(t.size()<s.size()&&isok(t)==true){
				if(t.size()>n) n=t.size();
				else continue;
			}
		}
	}
	cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 256