akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n, k; cin >> n >> k;
	string str; cin >> str;
	char c_min = 'z';
	for( char c : str ) c_min = min( c, c_min );
	k = min(k, 14);
	string tmp = "";
	while( k-- ){
		tmp += str; reverse( str.begin(), str.end() );
		tmp += str;
		if( k > 0 ) reverse( tmp.begin(), tmp.end() );
		vector<string> candy;
		for( int i = 0; i <= n; ++i ){
			candy.push_back( tmp.substr(i, n) );
		}
		sort( candy.begin(), candy.end() );
		str = candy.front();
		if( k > 0 ) reverse( str.begin(), str.end() );
		// cout << str << endl;
		tmp = "";
		if( k == 0 ){
			cout << str << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 40304
#![allow(dead_code,unused_variables)]
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize;n],
    }

    let mut ag =a[0];
    for i in 1..n{
        ag = gcd(ag,a[i]);
    }

    let mut p = [false;1000010];
    let mut f = true;
    let fact = Factorize::new(1000000);

    for e in &a{
        let hm = fact.factorize(*e);
        for (k,v) in &hm{
            if p[*k] == true{
                f = false;
                break;
            }else{
                p[*k] = true;
            }
        }
    }

    if f{
        println!("pairwise coprime");
    }else if ag == 1{
        println!("setwise coprime");
    }else{
        println!("not coprime");
    }


}

fn gcd(x : usize, y: usize) -> usize{
    if y == 0{
        return x;
    }
    gcd(y,x%y)
}
struct Factorize{
    fac : Vec<usize>
}

impl Factorize{
    fn new(max_n: usize) -> Self{
        let mut fac : Vec<usize>= (0..max_n+1).collect();
        
        let mut i = 2;
        while i * i <= max_n{
            if fac[i] == i{
                for j in (i*i..=max_n).step_by(i){
                    if fac[j] == j{
                        fac[j] = i;
                    }
                }
            }
            i += 1;
        }
        Factorize{
            fac,
        }
    }

    fn factorize(&self, n : usize) -> HashMap<usize,usize>{
        let mut hm = HashMap::new();
        let mut tmp = n;
        while tmp != 1{
            let cnt = hm.entry(self.fac[tmp]).or_insert(0);
            *cnt += 1;
            tmp /= self.fac[tmp];
        }
        hm
    }
}


Measured memory_bytes: 26336
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++)
#define per(i , n , x)  for(int i = n ; i >= x ; i --)
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  cout << '*' << x << '\n'
#define ddebug(x , y)  cout << '*' << x << ' ' << y << '\n'
#define ios std::ios::sync_with_stdio(false) , cin.tie(0)
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
const int inf = 0x3f3f3f3f ;
const int maxn = 2005 ;
const int maxm = 30 ;
const double eps = 1e-6 ;
int main()
{
	int a , b , c , d ;
	rr(a , b) , rr(c , d) ;
	bool flag = 0 ;
	while(a > 0 && c > 0)
	{
		if(flag)  a -= d ;
		else  c -= b ;
		flag = !flag ;
	}
	if(!flag)  puts("No") ;
	else  puts("Yes") ;
	return 0 ;
}

Measured memory_bytes: 3684
n=int(input())
#n,m=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]


l=[7,5,3]
count=0

def dfs(cur,use):
    global count
    if cur>n:
        return
    if use==0b111 :
        count+=1
    dfs(cur*10+3,use | 0b001)
    dfs(cur*10+5,use | 0b010)
    dfs(cur*10+7,use | 0b100)

dfs(0,0b000)
print(count)

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

int main() {
  int n;
  string t_str, h_str;
  int t_point = 0, h_point = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t_str >> h_str;
    if (t_str > h_str) {
      t_point += 3;
    } else if (t_str < h_str) {
      h_point += 3;
    } else {
      t_point += 1;
      h_point += 1;
    }
  }
  cout << t_point << " " << h_point << endl;

  return 0;
}

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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353




int main() {
    int D; cin >> D;
    cout << "Christmas ";
    rep(i,25-D) cout << "Eve ";
    cout << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;

int main()
{
   char str;

   int sum[26] = {0};
   
   while(cin >> str)
   {
        str = tolower(str);
            
       if(isalpha(str))
       {
           sum[str - 97]++;
       }
   }
   
   for(int j = 0; j < 26; j++)
   {
        printf("%c : %d\n", 97 + j, sum[j]);
   }
}



Measured memory_bytes: 3232
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>
#include <stack>
#include <vector>
using namespace std;
 
 
const int mod=1e9+7;
const int maxn=1e6+10;
#define _int64 unsigned long long
 
map<_int64,_int64> mp;
vector<int> g[maxn];
 
_int64 d[maxn];


_int64 ans;

int n; 

 
void dfs(int u,int fa){
    d[u]=1;
    for(int i=0;i<g[u].size();++i)
	{
        int v=g[u][i];
        if(v==fa)continue;
        dfs(v,u);
        d[u]+=d[v]*mod;
    }
    mp[d[u]]++;
}
 
 

int main()
{
	while(~scanf("%d",&n))
    {
    	
    	for(int i=0; i<=n; i++)
            g[i].clear();
        mp.clear();
        ans=0;
        for(int i=1;i<n;i++)
		{
            int u,v;
			scanf("%d%d",&u,&v);
            g[u].push_back(v);
			g[v].push_back(u);
        }
      
        dfs(1,0);
        for(map<_int64,_int64>::iterator it=mp.begin(); it!=mp.end(); it++)
            ans+=(_int64)it->second*(it->second-1)/2;
        cout<<ans<<endl;
    }
    return 0; 
}


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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
#define rep2(i, m, n) for(int i=m;i<(n);i++)
#define rrep(i, n, m) for(int i=n;i>=(m);i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    if (S[K-1] == 'A'){
        S[K-1] = 'a';
    } else if (S[K-1] == 'B'){
        S[K-1] = 'b';
    }else{
        S[K-1] = 'c';
    }

    cout << S << endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll int 
#define mp make_pair
#define int long long 
#define ff first 
#define ss second
const int p=1e9 + 7;
const int mod=1e9 + 7;
const int Mod=1e9 + 7;
const int INF=1e9 + 7;
const int Maxn=1000000;
using namespace std;
 
void solve()
{
int n;
cin >> n;
int a[n];
for(int i=0;i<n;i++)
cin >> a[i];
sort(a,a+n);
int count=0;
for(int i=0;i<n;i++)
{
    for(int j=i+1;j<n;j++)
    {
        if(a[i]!=a[j])
        {
            for(int k=j+1;k<n;k++)
        {
            if(a[i]+a[j]>a[k] && a[i]!=a[k] && a[j]!=a[k])
            count++;
        } 
        }
       
    }
}

cout << count << endl;
 
}
 
signed main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   int t;
   t=1;
   while(t--)
    solve();
  
 
}

Measured memory_bytes: 3656
/*For the name of God*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

template< class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd<T>(b, a%b) : a);
}
template< class T > T lcm(T a, T b)
{
    return (a / gcd<T>(a, b) * b);
}
const int N = 200200;
pair<int,int>c[1000001];
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    ll a,b;
    cin>>a>>b;
    if(a>b && a%b!=0)
    {
        cout<<(a/b)+1<<endl;
    }
    else if(a>b && a%b==0)
    {
        cout<<(a/b)<<endl;
    }
    else
    {
        cout<<1<<endl;
    }
}


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N,M;

bool f(int k,vector<int>& A)
{
	int x = -1,y = -1;
	for(int i = 1;i <= N - 1;i++){
		if(A [i] >= k && A [i - 1] >= k && abs(i - (N - 1)) < abs(x - (N - 1))){
			x = i;
		}
		else if(A [i] < k && A [i - 1] < k && abs(i - (N - 1)) < abs(y - (N - 1))){
			y = i;
		}
	}
	for(int i = M - 2;i >= N - 1;i--){
		if(A [i] >= k && A [i + 1] >= k && abs(i - (N - 1)) < abs(x - (N - 1))){
			x = i;
		}
		else if(A [i] < k && A [i + 1] < k && abs(i - (N - 1)) < abs(y - (N - 1))){
			y = i;
		}
	}
	if(x == -1 && y == -1){
		return ((N - 1) & 1) ^ (A [N - 1] >= k);
	}
	return abs(x - (N - 1)) < abs(y - (N - 1));
}

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

	cin >> N;
	M = N * 2 - 1;
	vector<int> A(M);
	FOR(i,0,M){
		cin >> A [i];
	}

	int ok = 2,ng = M,mid;
	while(ng - ok > 1){
		mid = (ok + ng) / 2;
		if(f(mid,A)){
			ok = mid;
		}
		else{
			ng = mid;
		}
	}
	

	cout << ok << endl;

	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define MAX_N 10000000

using namespace std;

int prime[MAX_N];
bool is_prime[MAX_N + 1];
int size;

int sieve(int n){
  int p = 0;
  for(int i=0;i<=n;i++){
    is_prime[i] = true;
  }
  is_prime[0] = is_prime[1] = false;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      prime[p++] = i;
      for(int j=2*i;j<=n;j+=i) is_prime[j] = false;
    }
  }
  return p;
}

main(){
  size = sieve(MAX_N);
  int n, p;
  while(cin >> n >> p){
    if(n == -1 && p == -1) break;
    vector<int> data;
    data.clear();
    int r, l;
    for(int i=0;i<size;i++){
      if(i == size){
	r = l = i;
	break;
      }
      if(prime[i]>n){
	r = l = i;
	break;
      }
    }
    for(int i=0;i<=p;i++){
      for(int j=i;j<=p;j++){
	data.push_back(prime[r+i]+prime[r+j]);
      }
    }
    sort(data.begin(), data.end());
    cout << data[p-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 13000
# coding: utf-8
S = input()
l = {"E":0, "W":0, "S":0, "N":0}
for i in range(len(S)):
    l[S[i]] += 1
f1, f2 = False, False
if (l["W"] != 0 and l["E"] != 0) or l["W"] == l["E"] == 0:
    f1 = True
if (l["N"] != 0 and l["S"] != 0) or l["N"] == l["S"] == 0:
    f2 = True
print("Yes" if f1 and f2 else "No")

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	bs := NewBufScanner(in)
	bw := NewBufWriter(out)
	defer bw.w.Flush()
	n, m := bs.IntScan(), bs.IntScan()
	a := make([]int, n)

	allVote := 0
	for i:=0; i<n; i++ {
		a[i] = bs.IntScan()
		allVote += a[i]
	}

	count := 0
	for _, v := range a {
		if (float64(v) >= float64(allVote) / float64(4 * m)) {
			count++
			if count == m {
				bw.Printf("Yes")
				return
			}
		}
	}

	bw.Printf("No")
}

// BufScanner original scanner
type BufScanner struct {
	s *bufio.Scanner
}

// NewBufScanner constructer
func NewBufScanner(in io.Reader) *BufScanner {
	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 1024), 1e+9)
	s.Split(bufio.ScanWords)
	return &BufScanner{
		s: s,
	}
}

// Scan Scan Data
func (b *BufScanner) Scan() string {
	b.s.Scan()
	return b.s.Text()
}

// IntScan Scan Data
func (b *BufScanner) IntScan() int {
	v, err := strconv.Atoi(b.Scan())
	if err != nil {
		panic(err)
	}
	return v
}

// BufWriter original writer
type BufWriter struct {
	w *bufio.Writer
}

// NewBufWriter constructer
func NewBufWriter(out io.Writer) *BufWriter {
	w := bufio.NewWriter(out)
	return &BufWriter{
		w: w,
	}
}

// Printf Output file
func (b *BufWriter) Printf(format string, a ...interface{}) {
	fmt.Fprintf(b.w, format, a...)
}

Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int a,b,c,d[100005] = {},n,m;
string s,t;

int main(){
    
    cin >> n;
    if(n == 1)P("Hello World");
    else{
        cin >> a >> b;
        P(a+b);
    }
    
    
	return  0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans = min(a,b)+min(c,d);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
signed main(){
    fast;
    int n,k;
    cin>>n>>k;
    int ans = 0;
    while(n!=0){
    	ans++;
    	n = n/k;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    for(int i=0;i<=a/4;i++){
        for(int j=0;j<=a/7;j++){
            if(i*4+j*7==a){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, w;
  cin >> h >> w;
  
  vector<string> vec(h);  
  
  for(int i=0; i<h; i++){
	cin >> vec.at(i);
  }

  for(int i=0; i<w+2; i++){
    cout << "#";
  }
  cout << endl;
  
  for(int i=0; i<h; i++){
	cout << "#" << vec.at(i) << "#" << endl;
  }
  
  for(int i=0; i<w+2; i++){
    cout << "#";
  }
  cout << endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>

int f(int a){
    if(a < 0){
        return a * -1;
    }
    return a;
}

int main(){
    int n;
    scanf("%d", &n);
    int w[n];
    int a=0, b=0;
    scanf("%d", &w[0]);
    a = w[0];
    for(int i=1; i<n; i++){
        scanf("%d", &w[i]);
        b += w[i];
    }
    int min = f(a-b);
    for(int i=1; i<n; i++){
        a += w[i];
        b -= w[i];
        if(min > f(a-b)){
            min = f(a-b);
        }
    }
    printf("%d", min);

    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
const int INF = 1000000009;
const ll LINF = 1e18;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> ab(n, vector<int>(n, 0));
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    ab[a][b] = ab[b][a] = 1;
  }

  vector<int> p(n - 1);
  for (int i = 0; i < n - 1; ++i) p[i] = i + 1;

  int cnt = 0;

  do {
    // for (int t = 0; t < n - 1; ++t) cout << p[t] << " ";
    // cout << endl;
    bool rst = true;
    if (ab[0][p[0]] == 0) continue;
    for (int j = 0; j < n - 2; ++j) {
      if (ab[p[j]][p[j + 1]] == 0) rst = false;
    }
    if (rst) ++cnt;

  } while (next_permutation(p.begin(), p.end()));

  cout << cnt << endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

const int max_v = 3*100000;

struct UnionFind {
    vector<int> d;

    UnionFind(int N=0) : d(N, -1){} 

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x); 
        y = find(y); 
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x; 
        return true;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x){
        return -d[find(x)];
    }
};

int main(){

    int N,M; cin >> N >> M;
    vector<pair<int, int>> edges;
    rep(i,M){
        int x, y, z; cin >> x >> y >> z;
        x--;
        y--;
        edges.emplace_back(x,y);
    }

    UnionFind uf(N);    
    rep(i,M){
        uf.unite(edges[i].first, edges[i].second);
    }

    set<int> roots;
    rep(i, N){
        roots.insert(uf.find(i));
    }

    cout << roots.size() << endl;

    

}

Measured memory_bytes: 8940
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct Node {
	int key;
	struct Node* parent;
	struct Node* left;
	struct Node* right; 
};

typedef struct Node * NodePointer;

void insert( NodePointer t , int z){
	NodePointer x;
	if ( t -> key <= z){
		if  ( t -> right  == NULL){
			x =  (NodePointer) malloc (sizeof(struct Node));
			x -> key = z;
			x -> right = NULL;
			x -> left = NULL;
			t -> right = x;
			x -> parent = t;
		}else {
			insert ( t -> right , z);
		}
	
	}else {
		if  ( t -> left  == NULL){
			x =  (NodePointer) malloc (sizeof(struct Node));
			x -> key = z;
			x -> right = NULL;
			x -> left = NULL;
			t -> left = x;
			x -> parent = t;
		}else {
			insert ( t -> left , z);
		}
	}
};

void search ( NodePointer t, int tag){
	int flag = 0;
	while ( t != NULL){
		if ( t -> key == tag){flag = 1; break;}
		else if ( t -> key >= tag){
			t = t -> left;
		}else {
			t = t -> right;
		}
	}
	if (flag == 0 ){ printf("no\n");
	}else if (flag == 1){printf("yes\n");}
};

NodePointer delete (NodePointer t, int tag ){
	if (t == NULL){return NULL;}
	
	if ( t -> key > tag){
		t -> left = delete ( t -> left , tag);
	}else if (t -> key < tag){
		t -> right = delete ( t -> right , tag);
		
		
	}else if ( t -> key == tag){
		if ( t -> left == NULL){
			NodePointer temp = t -> right;
			if ( t -> right != NULL){
				t -> right -> parent = t -> parent;
			}
			free(t);
			return temp;
		}
		if ( t -> right == NULL){
			NodePointer temp = t -> left;
			if ( t -> left != NULL){
				t -> left -> parent = t -> parent;
			}
			free(t);
			return temp;
		}
		
		NodePointer i ;
		for ( i = t -> right; i -> left != NULL ; i = i -> left) ;	
		t -> key = i -> key;
		if ( i -> parent == t){
			t -> right = i -> right;
		}else {
			i -> parent  -> left = i -> right;
		}
		if ( i -> right != NULL){
			i -> right -> parent = i -> parent;
		}
		free(i);
	}
	return t;
};

void preorder ( NodePointer t){
	if ( t == NULL ){ return; }
	printf(" %d", t -> key);
	preorder( t -> left);
	preorder( t -> right);
};	

void inorder (NodePointer t){
	if ( t == NULL ){ return; }
	inorder( t -> left);
	printf(" %d", t -> key);
	inorder( t -> right);
};

void postorder (NodePointer t){
	if ( t == NULL ){ return; }
	postorder( t -> left);
	postorder( t -> right);
	printf(" %d", t -> key);
};


int main (){
	int n;
	scanf("%d\n",&n);

	NodePointer tree = (NodePointer) malloc (sizeof(struct Node));
	
	char input [8];
	int k;
	
	for ( int i = 0; i  < n; i++){
		scanf("%s" ,input);
		
		if ( strcmp( input , "insert") == 0 ){
			scanf("%d\n",&k);
			if ( i == 0)
			{
			tree -> key = k;
			tree -> right = NULL;
			tree -> left = NULL;
			}
			else {insert(tree , k);
			}
		}else if ( strcmp( input , "find") == 0 ){
			scanf("%d\n",&k);
			search( tree , k);
		}else if ( strcmp( input , "delete") == 0 ){
			scanf("%d\n",&k);
			delete( tree , k);
		}else {
			inorder(tree);
			printf("\n");
			
			preorder(tree);
			printf("\n");
		}
	}
	
	
	return 0;
}



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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    cout << a+b+c-max({a, b, c}) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    int tmpx = (n-1)/111;
    cout << (tmpx+1) * 111 << endl;
}


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

int main()
{
  int n,q;
  cin>>n>>q ;
  fenwick_tree<long long> f(n);
  for(int i=0 ; i<n ; ++i)
  {
    int el;
    cin>>el;
    f.add(i,el);
  }


  for(int i=0 ; i<q ; ++i)
  {
    int t,u,x ;
    cin>>t>>u>>x ;
    if(t==0)
      f.add(u,x);
    else
      cout<<f.sum(u,x)<<"\n";
  }
  
  return 0;
}


Measured memory_bytes: 8220
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int N;
    cin>>N;
    int A,A0,B,B0,C,C0;
    cin>>A>>B>>C;
    A0=A;
    B0=B;
    C0=C;
    for(int i=1;i<N;i++)
    {
        cin>>A>>B>>C;
        int a0,b0,c0;
        a0=A+max(B0,C0);
        b0=B+max(A0,C0);
        c0=C+max(B0,A0);
        A0=a0;
        B0=b0;
        C0=c0;
    }
    cout<<max(A0,max(B0,C0));
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
in p2(in a){
  return 1LL<<a;
}
VI hs;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  hs.resize(32);
  in xr=0;
  in a;
  forn(z,n){
    cin>>a;
    in cv;
    for(in i=0;i<32;++i){
      if(a&p2(i)){
	cv=i;
	break;
      }
    }
    hs[cv]=1;
    xr^=a;
  }
  in eat=0;
  for(in i=31;i>=0;--i){
    if(xr&p2(i)){
      if(hs[i]){
	++eat;
	xr^=(p2(i+1)-1);
      }
    }
  }
  if(xr)
    cout<<-1<<endl;
  else
    cout<<eat<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}
/*================================*/
#if DEBUG
#define SIZE 10
#else
#define SIZE 223450
#endif

int N,Q,K;
int A[SIZE];
int DP[SIZE];

void solve() {
    cin>>N;
    REP(i,N)cin>>A[i];
    DP[0]=1000;
    int ans = 0;
    REP1(j,N-1) {
        chmax(DP[j], DP[j-1]);
        REP(i,j) {
            // i日目に買ってj日目に売る場合の金額
            int add = (DP[i]/A[i])*A[j];
            int remain = DP[i]%A[i];
            if (chmax(DP[j], remain+add)) {
                debug("%lld->%lld, add:%lld, remain: %lld, DP[%lld]: %lld\n",i,j,add,remain,j+1,DP[j]);
            }
        }
        chmax(ans, DP[j]);
    }
    
     cout << ans << endl;
}



Measured memory_bytes: 3644
fun main(arg: Array<String>) {
    val N = nextLong()
    var ans = (N / 11) * 2 +
            when (N % 11) {
                0L -> 0
                in 1..6 -> 1
                else -> 2
            }
    println(ans)
}

fun next() = readLine()!!
fun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }


Measured memory_bytes: 33604
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int main(){
    int N, M;
    while(std::cin >> N >> M, N && M){
        std::vector<int> v;
        REP(i, N){
            v.push_back(i);
        }
     
        int pos = 0;
        while(v.size() > 1){
            pos = (pos + M) % v.size();
            // printf("Exit: %d\n", v[pos]);
            v.erase(v.begin() + pos);
            pos = (pos + v.size() - 1) % v.size();
        }

        int res = v[0]>0?v[0]:N;
        printf("%d\n", res);
    }

    return 0;
}

Measured memory_bytes: 1208
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int x ;
    cin >> x ;
    for(int i = 1; ; i++){
        if ( i * x % 360 == 0 ) {
            cout << i << endl;
            return false ;
        }
    }
    assert(false) ;
    return 0; 
}

Measured memory_bytes: 3632
import java.util.*;
import java.lang.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int [n+n];
		for(int i=1;i<=n;i++)
		{	
			for(int j=1;j<=n;j++)
			{
				for(int k=1;k<=n;k++)
				{
					int b=(i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i);
					if(b<=n)
						a[b]=a[b]+1;
					else
						break;
				}
			}
		}
		for(int i=1;i<=n;i++)
			System.out.println(a[i]);		
	}
}


Measured memory_bytes: 39052
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 70, INF = 1e9;
const ll Mod = 1e9 + 7;

/*******************************************************************************
 *
 *
 *
 ******************************************************************************/

ll f[N][2][2][2];
// k, high, R, L
ll A[N], B[N];

ll Dfs(int k, int flh, int flr, int fll) {
//     cout << k << " " << flh << " " << flr << " " << fll << " " << f[k][flh][flr][fll] << endl;
    if (k == 0) return flh;
    if (~f[k][flh][flr][fll]) return f[k][flh][flr][fll];
    ll res = 0;
    int upr = (flr ? A[k] : 1), dwl = (fll ? B[k] : 0);
    if (!flh && upr)
        res = Dfs(k - 1, 1, flr, fll && dwl == 1);
    if (!flh && !dwl)
        (res += Dfs(k - 1, 0, flr && upr == 0, fll && dwl == 0)) %= Mod;
    else if (flh) rep (i, dwl, 1) rep (j, i, upr)
        (res += Dfs(k - 1, 1, flr && upr == j, fll && dwl == i)) %= Mod;
//     cout << k << " " << flh << " " << flr << " " << fll << " " << res << endl;
    return f[k][flh][flr][fll] = res;
}

ll Solve(ll L, ll R) {
    A[0] = B[0] = 0;
    memset(f, -1, sizeof f);
    while (R) A[++A[0]] = R & 1, R >>= 1;
    while (L) B[++B[0]] = L & 1, L >>= 1;
    return Dfs(A[0], 0, 1, 1);
}

int main() {
    ll L, R; cin >> L >> R ;
    cout << Solve(L, R) << endl;
    return 0;
}



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

#define ran 101101

int n, m;
vector<int> e[ran];
bool v[ran];

void dfs(int cur) {
	v[cur] = true;
	for(int i=0;i<e[cur].size();i++) {
		int nxt = e[cur][i];
		if(v[nxt]) continue;
		dfs(nxt);
	}
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i=0;i<m;i++) {
		int x, y, z; scanf("%d%d%d", &x, &y, &z);
		e[x].push_back(y); e[y].push_back(x);
	}
	
	int ans=n;
	for(int i=1;i<=n;i++) {
		if (v[i]) {
			ans--;
			continue;
		}
		dfs(i);
	}
	printf("%d\n", ans);
	
	return 0;
}

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

ll n, x;
ll a[4010];
ll m[4010];
ll ans = (1ll << 62), t;

int main(){
	cin >> n >> x;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = n; i < 2 * n; i++) a[i] = a[i - n];
	for(int i = 0; i < n; i++) m[i] = a[i];
	for(int i = 0; i < n; i++){
		ll ct = 0;
		for(int j = 0; j < n; j++) ct += m[j];
		ans = min(ans, ct + t);
		t += x;
		for(int j = 0; j < n; j++) m[j] = min(m[j], a[j + i + 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct node
{
    int x;
    int y;
    friend bool operator < (const node &a,const node &b)
    {
        return a.x<b.x;
    }
};
node c[200005];
int x[200005],y[200005];
const int inf=1000000007;
int mins[200005],maxs[200005];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    scanf("%d",&n);
    int i;
    int r_max=-1,b_max=-1;
    int r_min=inf,b_min=inf;
    for (i=0;i<n;i++)
    {
        scanf("%d%d",&x[i],&y[i]);
        if (x[i]>y[i]) swap(x[i],y[i]);
        c[i].x=x[i];
        c[i].y=y[i];
        r_max=max(r_max,x[i]);
        b_max=max(b_max,y[i]);
        r_min=min(r_min,x[i]);
        b_min=min(b_min,y[i]);
    }
    long long ans1=(long long)(r_max-r_min)*(b_max-b_min);
    //B can be chosen randomly now!
    b_min=r_min;
    sort(c,c+n);
    int ans=inf;
    for (i=0;i<n;i++)
    {
        mins[i]=c[i].y;
        maxs[i]=c[i].y;
        if (i>0) mins[i]=min(mins[i-1],c[i].y);
        if (i>0) maxs[i]=max(maxs[i-1],c[i].y);
        if (i!=n-1)
        {
            ans=min(ans,max(maxs[i],c[n-1].x)-min(mins[i],c[i+1].x));
        }
        else
        {
            ans=min(ans,maxs[i]-mins[i]);
        }
    }
    cout<<min((long long)ans*(b_max-b_min),ans1)<<endl;
    return 0;
} 


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

int main() {
    int W, a, b;
    cin >> W >> a >> b;

    // 考え方メモ
    // 1, a + W < b -> b - (a + W)
    // 2, b <= a + W && a <= b -> 0
    // 3, b < a -> a - (b + W)

    int distance = 0;
    if (a + W < b) {
        distance = b - (a + W);
    } else if (b < a) {
        distance = a - (b + W);
    } else {
        distance = 0;
    }

    cout << distance << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int length=s.length();
	bool flag=false;
	for(int i=0;i<length;i++){
		if(s==t)
		{
			flag=true;
			break;
		}
		char temp=s[length-1];
		string ss=temp+s.substr(0,length-1);
		s=ss;
	}
	if(flag)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long int ll;
int main(){
	io;
	int a[3][3];
	for(int i = 0;i < 3;++i){
		for(int j = 0;j < 3;++j){
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	bool f[3][3];
	memset(f,0,sizeof(f));
	int b;
	for(int i = 0;i < n;++i){
		cin >> b;
		for(int j = 0;j < 3;++j){
			for(int k = 0;k < 3;++k){
				if(a[j][k] == b){
					f[j][k] = 1;
					break;
				}
			}
		}
	}
	bool ans = 0,temp = 1;
	for(int i = 0;i < 3;++i){
		temp = 1;
		for(int j = 0;j < 3;++j){
			if(f[i][j] == 0){
				temp = 0;
			}
		}
		if(temp == 1){
			//cout << "OK0" << endl;
			ans = 1;
		}
	}
	for(int i = 0;i < 3;++i){
		temp = 1;
		for(int j = 0;j < 3;++j){
			if(f[j][i] == 0){
				temp = 0;
			}
		}
		if(temp == 1){
			//cout << "OK1" << endl;
			ans = 1;
		}
	}
	temp = 1;
	for(int i = 0;i < 3;++i){
		if(f[i][i] == 0){
			temp = 0;
		}
	}
	if(temp == 1){
		//cout << "OK2" << endl;
		ans = 1;
	}
	temp = 1;
	for(int i = 0;i < 3;++i){
		if(f[i][2-i] == 0){
			temp = 0;
		}
	}
	if(temp == 1){
		//cout << "OK3" << endl;
		ans = 1;
	}
	if(ans)
		cout << "Yes";
	else
		cout << "No"; 
	return 0;
}

Measured memory_bytes: 256
import sys
N, Y = map(int, input().split())

for i in range((Y // 10000) + 1):
    for j in range((Y // 5000) + 1):
        tmp = N - i - j
        if tmp >= 0:
            ans = (i * 10000) + (j * 5000) + ((N - i - j) * 1000)
            if ans == Y:
                print(i, j, tmp)
                sys.exit()
print(-1, -1, -1)


Measured memory_bytes: 40812
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;

const ll Inf = 1e18;
const int N = 16;

int n;
int a[N][N];
long long cost[1 << N];
long long dp[1 << N];

int main()
{
  cin >> n;
  for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
      cin >> a[i][j];
  for(int msk = 0; msk < (1 << n); msk++) {
    cost[msk] = 0;
    for(int i = 0; i < n; i++)
      if(msk & (1 << i))
        for(int j = i + 1; j < n; j++)
          if(msk & (1 << j))
            cost[msk] += a[i][j];
  }
  dp[0] = 0;
  for(int msk = 1; msk < (1 << n); msk++) {
    dp[msk] = -Inf;
    for(int sub = msk; sub > 0; sub = (msk & (sub - 1))) {
      dp[msk] = max(dp[msk], cost[sub] + dp[msk ^ sub]);
    }
  }
  cout << dp[(1 << n) - 1] << endl;
  return 0;
}


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

typedef long long ll;

using namespace std;

ll sum(ll a, ll b) {
	return (b-a+1)*(a+b)/2;
}

int main() {
	ll n, k, ans = 0; cin >> n >> k;
	for (int i = k; i <= n + 1; i++) {
			ans += sum(n-i+1, n) - sum(1, i-1) + 1;
	}
	cout << ans % 1000000007;;		
}





Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(){
    int a[28],b;
    for(int i=0;i<28;i++){
        cin>>a[i];
    }
    for(int i=1;i<=30;i++){
        b=0;
        for(int j=0;j<28;j++){
            if(a[j]==i){
                b=1;
            }
        }
        if(b==0){
        cout<<i<<endl;
        }
    }
}

Measured memory_bytes: 3044
#include <iostream>
using namespace std;
int main(void){
    int n,m;
    cin >> n >>m;
    int matrix[n][m];
    int vector1[m];
    int vector2[n];
    int i,j;
    for (i=0;i<n;i++){
        for (j=0;j<m;j++){
            cin >> matrix[i][j];
        }
    }
    for (j=0;j<m;j++){
        cin >> vector1[j];
    }
    for (i=0;i<n;i++){
    vector2[i]=0;
        for (j=0;j<m;j++){
            vector2[i]+=matrix[i][j]*vector1[j];
        }
        cout << vector2[i] <<endl;
    }
    return 0;
}


Measured memory_bytes: 3112
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <iostream>
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a+b+c<22) cout << "win\n";
    
    else cout << "bust\n";
}


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

namespace ABC128B
{
    class Program
    {
        class Restaurant
        {
            public int ID { get; set; }
            public string City { get; set; }
            public int Point { get; set; }

            public Restaurant(int id, string city, int point)
            {
                this.ID = id;
                this.City = city;
                this.Point = point;
            }
        }

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var list = new List<Restaurant>();
            foreach (var i in Enumerable.Range(0, n))
            {
                var input = Console.ReadLine().Trim().Split(' ');
                var city = input[0];
                var point = int.Parse(input[1]);

                list.Add(new Restaurant(i + 1, city, point));
            }

            // 降順ソート
            list.Sort((x, y) => y.Point - x.Point);
            // 安定ソート
            list = list.OrderBy(x => x.City).ToList();

            foreach (var r in list)
            {
                Console.WriteLine(r.ID);
            }
        }
    }
}


Measured memory_bytes: 13536
#include<iostream>
using namespace std;
int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int sum = 0;
  for (int i=A;i<=N;i++){
    int sum_p = 0;
    int tp = i;
    sum_p += tp/10000;
    tp -= (tp/10000)*10000;
    sum_p += tp/1000;
    tp -= (tp/1000)*1000;
    sum_p += tp/100;
    tp -= (tp/100)*100;
    sum_p += tp/10;
    tp -= (tp/10)*10;
    sum_p += tp;
    if (A<=sum_p && sum_p<=B) sum += i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(),m = sc.nextInt();
    String a[] = new String[n];
    String b[] = new String[m];
    for(int i = 0;i < n;i++){
      a[i] = sc.next();
    }
    for(int i = 0;i < m;i++){
      b[i] = sc.next();
    }
    int ans = 0;
    //こっから捜索開始
    int count = 0;
    for(int i = 0;i<n-m+1;i++){//b箱を縦にさげる
      for(int j = 0;j<n-m+1;j++){//b箱を右にずらす
        count = 0;
        for(int k = 0;k<m;k++){//bの行を下げる
          if(b[k].equals(a[i+k].substring(j,j+m ) ) ){
            count++;
          }
          if(count == m){//最後までいききったらおっけー
            ans=1;
          }
        }
      }
    }
    if(ans==1){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 24404
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int d, n;
	cin >> d >> n;
	int num = 1;
	rep(i,d) num *= 100;
	int cnt = 0;
	for(int i = 1; i >= 0; i++){
		if(i%num == 0){
			int tmp = i / num;
			if(tmp%100 != 0){
				cnt++;
				if(cnt == n){
					cout << i << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256