akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;

    cout << static_cast<unsigned char>(toupper(s1.front()));
    cout << static_cast<unsigned char>(toupper(s2.front()));
    cout << static_cast<unsigned char>(toupper(s3.front()));
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : ITP_1_4_A.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
//	cout << a/b << " " << a%b << " " << (double)a/(double)b << endl;
	printf("%d %d %.5lf",a/b,a%b,(double)a/(double)b);
	return 0;
}

Measured memory_bytes: 3208
/*
क्षमाशील हो रिपु-समक्ष
तुम हुये विनत जितना ही
दुष्ट कौरवों ने तुमको
कायर समझा उतना ही।
*/
#include<bits/stdc++.h>
using namespace std;
 
#define int                 long long int
#define ull                 unsigned int
#define ld                  long double
#define pb                  push_back
#define ff                  first
#define ss                  second
#define S(arr)              sort(arr.begin(),arr.end());
#define all(p)              p.begin(), p.end()
#define RS(arr)             sort(arr.rbegin(),arr.rend());
#define R(arr)              reverse(arr.begin(),arr.end());
#define pii                 pair <int, int>
#define vpi                 vector <pii>
#define vi                  vector <int>
#define vld                 vector <ld>
#define vvi                 vector <vector <int>>
#define vvpi                vector <vector <pii>>
#define vs                  vector <string>
#define si                  set <int>
#define spi                 set <pii>
#define setbits(x)          __builtin_popcountll(x)
#define zrobits(x)          __builtin_ctzll(x)
#define mii                 map <int, int>
#define mci                 map<char, int>
#define mpi                 map <pii, int>
#define T                   int tcf;cin>>tcf;while(tcf--)
#define que_max(t)          priority_queue <t>
#define que_min(t)          priority_queue <t, vector<t>, greater<t>>
#define endl                "\n"
#define dba(a, l, r)        for(auto x:a)cout<<x<<" ";cout<<endl;
#define db1(x)              cout << #x " = " << x << endl;
#define db2(x,y)            cout << #x " = " << x << " " << #y " = " << y << endl;
#define db3(x,y,z)          cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define db4(x,y,z,w)        cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << endl;
#define db5(x,y,z,w,v)      cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << " " << #v " = " << v << endl;
#define db6(x,y,z,w,v,a)    db3(a, y, x)db3(w, v, a)
#define p2d(v)              for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)              for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppi(v)              for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;

// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;  
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//  // *( hsh.find_by_order(k) ) kth smallest, from 0
//  // hsh.order_of_key(k) num of ele str less than k
//  // change less to less_equal for multiset pbds
 
void read(int n=10){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    #ifndef ONLINE_JUDGE
         freopen("input.txt",  "r",  stdin);
         freopen("output.txt", "w", stdout);
    #endif
}
 
int M = 1e9 + 7;
int M1 = 998244353;
#define qqq 4000005
#define pi 3.14159265358979323851



int32_t main(){
    read();
    ld n;
    cin>>n;
    cout<<2*pi*n<<endl;
}  

Measured memory_bytes: 3804
function main(input){
	var data = input.split('\n');
	for (var i = 0, l = data[1].length; i < l; i++) {
		if (data[0] == data[1]) break;
		x = data[0].split('');
		x.push(x.shift());
		data[0] = x.join('');
	}
	console.log(['No','Yes'][Number(data[0] == data[1])]);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    int h, a;
    cin >> h >> a;

    int ans = h / a + (h % a > 0);
    cout << ans << endl;
    
    return 0;
}

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

string o = "keyence";

int main(){
	string s;
	cin >> s;
	bool an = s == o;
	f(i, 0, s.size())f(j, i, s.size())if (s.substr(0, i + 1) + s.substr(j) == o)an = true;
	printf("%s\n", an ? "YES" : "NO");
}

Measured memory_bytes: 256
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String str = sc.next();
		String[] input = str.split("");
		// String result = "";

		StringBuilder sb = new StringBuilder();
		sb.append("");

		for (int i = 0; i < n; i++) {
			if (sb.length() == 0) {
			// if (result.isEmpty()) {
				// result += input[i];
				sb.append(input[i]);
				continue;
			}

			if (input[i].equals(input[i-1])) {
				continue;
			}
			sb.append(input[i]);
			// result += input[i];
		}

		// System.out.println(result.length());
		System.out.println(sb.length());

	}
}


Measured memory_bytes: 34128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main()
{
  const int m = 1000002;
  int n, t, ans = 0;
  cin >> n;
  vector<bool> a(m, false);
  vector<int> b(n);
  rep(i, n)
  {
    cin >> b[i];
  }
  sort(b.begin(), b.end());
  rep(i, n - 1)
  {
    if (a[b[i]] == true)
      continue;
    if (b[i] == b[i + 1])
    {
      a[b[i]] = true;
    }
    for (int j = 2; j < b[n - 1] / b[i] + 1; j++)
    {
      a[j * b[i]] = true;
    }
  }
  rep(i, n)
  {
    if (a[b[i]] == false)
      ans++;
  }
  cout << ans;
}


Measured memory_bytes: 3980
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int h, w;
    cin >> h >> w;
    vector<vector<int>> v(10, vector<int>(10, 0));
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> v[i][j];
        }
    }
    vector<int> dist(10, 0x3f3f3f3f);
    dist[1] = 0;
    priority_queue<pair<int, int>> pq;
    pq.push(make_pair(0, 1));
    while (pq.size() > 0) {
        auto p = pq.top();
        pq.pop();
        int d = -p.first;
        int index = p.second;
        if (d != dist[index]) continue;
        for (int i = 0; i < 10; i++) {
            if (i == index) continue;
            if (dist[i] > dist[index] + v[i][index]) {
                dist[i] = dist[index] + v[i][index];
                pq.push(make_pair(-dist[i], i));
            }
        }
    }
    int res = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int t;
            cin >> t;
            res += dist[t];
        }
    }
    cout << res << endl;
}


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

#define MAX 2000000000
#define MAX2 1000000
#define MAX3 2000000

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int);
void init();
void printList();
void deleteNode(NodePointer );
void deleteFirst();
void deleteLast();
void delete(int);
void insert(int);



int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  
  scanf("%d", &n);
  
  init();
  
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if(!( 0 <= key && key <= MAX)){
      printf("error\n") ;
    }
    if ( com[0] == 'i' ) {
      insert(key); np++; size++;
    }
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) {
	  deleteFirst();
	}
	else if ( com[6] == 'L' ) {
	  deleteLast();
	}
      } else {
	delete(key); nd++; 
      }
      size--;
    }
    if ( size > MAX2 ) {
      printf("error\n");
    }
  }

  if(!( np+nd <= MAX3)){
    printf("error\n");
  }
  if(!( nd <= 20)){
    printf("error\n");
  }
  
  printList();
  return 0;
}

NodePointer listSearch(int key){
  NodePointer c = nil->next;
  while( c != nil && c->key != key ){
    c = c->next;
  }
  return c;  
}

void init(){  
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  
  while(1){   
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t); 
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t); 
}

void delete(int key){
  NodePointer t = listSearch(key);
  if(t == nil) return;
  deleteNode(t);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

Measured memory_bytes: 31788
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

const string YES = "Possible";
const string NO = "Impossible";

void solve(long long A, long long B){
    if(A%3 ==0 || B%3 == 0 || (A+B) %3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
}

int main(){

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,i,j,k,cnt;
int main()
{
    cin>>a>>b>>c>>x;
    for(i=0;i<=a&&500*i<=x;i++)
    {
        for(j=0;j<=b&&100*j+500*i<=x;j++)
        {
            for(k=0;k<=c&&50*k+100*j+500*i<=x;k++)
            {
                if(500*i+100*j+50*k==x)
                    cnt++;
            }
        }
	}
    cout<<cnt;
    return 0;
}

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

using namespace std;

#define pb push_back

int
main(void){
	int n, m; cin >> n >> m;
	vector<vector<int> > adj(n);
	int u, v;
	for(int i = 0; i < m; i++){
		cin >> u >> v;
		--u; --v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	for(int i = 0; i < adj[0].size(); i++){
		int v = adj[0][i];
		for(int j = 0; j < adj[v].size(); j++){
			if(adj[v][j] == (n - 1)){
				cout << "POSSIBLE";
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE";
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


int main(){
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	vi cnt(3);
	rep(i, n) cnt[a[i]%3]++;
	if(cnt[0] == n) {
		cout << 1 << endl;
		return 0;
	}
	int ans = cnt[0], tmp = min(cnt[1], cnt[2]);
	ans += tmp * 2;
	if(cnt[1] < cnt[2]) ans += min(3, cnt[2]-tmp);
	else ans += min(3, cnt[1]-tmp);
	cout << ans << endl;
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,Q;

template<int um> class UF {
	public:
	vector<int> par,rank,cnt;
	UF() {par=rank=vector<int>(um,0); cnt=vector<int>(um,1); for(int i=0;i<um;i++) par[i]=i;}
	void reinit() {int i; FOR(i,um) rank[i]=0,cnt[i]=1,par[i]=i;}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int count(int x) { return cnt[operator[](x)];}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		cnt[y]=cnt[x]=cnt[x]+cnt[y];
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<202020> uf;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	FOR(i,Q) {
		cin>>j>>x>>y;
		if(j==0) {
			uf(x,y);
		}
		else {
			cout<<(uf[x]==uf[y])<<endl;
		}
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main(){
    int n;
    long long a,max,min,sum;
    max = -1000000;
    min = 1000000;
    sum = 0;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a;
        if (a > max)max = a;
        if (a < min)min = a;
        sum += a;
    }
    cout << min << " " << max << " " << sum << endl;    
return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p)
#define pf1(n)     printf("%lld\n",n);
#define mem(a,b)   memset(a,b,sizeof(a))
#define en         cout<<endl;
#define pb         push_back
#define gcd(n,m)   __gcd(n,m)
#define lcm(n,m)   ((n)/__gcd(n,m))*(m)
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(a,b)     for(ll i=a;i<b;i++)
#define all(x)     (x).begin(),(x).end()
#define allr(x)    (x).rbegin(),(x).rend()
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long
#define PI         2*acos(0.0)

int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,c,res,c1,x,y,w,z,c2;
    char ch;
    ci>>ch;
    if(ch=='A') co<< "T";
    else if(ch=='T') co<< "A";
    else if(ch=='G') co<< "C";
    else if(ch=='C') co<< "G";
}


Measured memory_bytes: 3564
h,w = gets.chomp.split.map(&:to_i)
gs = h.times.map{gets.chomp.chars}

gs.map!{|g| g if g.any?{|a| a == "#"}}.compact!
gs = gs.transpose
gs.map!{|g| g if g.any?{|a| a == "#"}}.compact!

gs.transpose.each do |g|
	puts g.join("")
end


Measured memory_bytes: 2556
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(void)
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c && c==a)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1e9 + 7;


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

    cout << r * r << endl;

}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int N, K;
    int A[N];
    int d = 0;
    int i, j, a;
    int count = 0;
    
    scanf("%d", &N);
    scanf("%d", &K);

    for(i = 0; i < N; i++){
      A[i] = 0;
    }

  for(j = 0; j < K; j++){  
    scanf("%d", &a);
    for (i = 0; i < a; i++){
      scanf("%d", &d);
      A[d-1] += 1;
    }
  }

  for(i = 0; i < N; i++){
    if(A[i] == 0){
      count += 1;
    }
  }

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

    return 0;
}


Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, M;
int edge[710][710];
int st[710];
bool flag = true;
vector<pii> ps;

void dfs(int v, int* dat){
    dat[st[v]]++;
    int to = (st[v] + 1) & 1;
    for(int i = 1; i <= N; ++i){
        if(edge[v][i] == 0){
            if(st[i] == -1) st[i] = to, dfs(i, dat);
            else if(st[i] != to) flag = false;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M;
    for(int i = 1; i <= N; ++i) st[i] = -1, edge[i][i] = 1;

    for(int i = 0; i < M; ++i){
        int A, B;
        cin >> A >> B;
        edge[A][B] = 1;
        edge[B][A] = 1;
    }
    for(int i = 1; i <= N; ++i){
        if(st[i] != -1) continue;
        
        int dat[2] = {};
        st[i] = 0;
        dfs(i, dat);
        ps.push_back({dat[0], dat[1]});
    }
    if(flag){
        bitset<710> res = {};
        res[0] = 1;
        for(auto u : ps){
            res = (res << u.first) | (res << u.second);
        }

        int ans = inf;
        for(int i = 0; i <= N; ++i){
            if(res[i] == 1){
                auto culc = [] (int a){return a * (a - 1) / 2;};
                chmin(ans, culc(i) + culc(N - i));
            }
        }
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

int N, A, B, C;
vector<int> L;

int mp(int level, int a, int b, int c)
{
  if (level == N) {
    if (a == 0 || b == 0 || c == 0) {
      return numeric_limits<int>::max()-30;
    } else {
      return abs(a-A)+abs(b-B)+abs(c-C)-30;
    }
  }

  int ret_a = mp(level+1, a+L[level], b, c) + 10;
  int ret_b = mp(level+1, a, b+L[level], c) + 10;
  int ret_c = mp(level+1, a, b, c+L[level]) + 10;
  int ret_null = mp(level+1, a, b, c);

  return min(min(min(ret_a, ret_b), ret_c), ret_null);
}


int main(int argc, char* argv[])
{
  cin >> N >> A >> B >> C;

  for (int i = 0; i < N; i++) {
    int l; cin >> l;
    L.push_back(l);
  }

  cout << mp(0, 0, 0, 0) << endl;
  
  return 0;
}


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

sm = sum(a)
tmp = a[0]*2
ans = abs(sm-a[0]*2)
for i in range(1,n-1):
    tmp += a[i]*2
    ans = min(abs(sm-tmp),ans)
print(ans)
        

Measured memory_bytes: 23800
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7;
bool gone[605], empty[605];
ll dp[305][305], ndp[305][305];
void add(ll& x, ll y) {
	x += y;
	if (x >= MOD) x -= MOD;
}
int main() {
	int n;
	scanf("%d", &n);
	int slots = 0;
	ll mult = 1;
	for (int i = 0; i < n; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		if (a == -1 && b == -1) {
			++slots;
			mult = mult * slots % MOD;
		} else if (a == -1 || b == -1) {
			empty[a + b + 1] = true;
		} else {
			gone[a] = gone[b] = true;
		}
	}
	dp[0][0] = 1;
	for (int i = 2 * n; i >= 1; --i) {
		if (gone[i]) continue;
		memset(ndp, 0, sizeof(ndp));
		for (int j = 0; j <= n; ++j) // # of unused numbers
			for (int k = 0; k <= n; ++k) { // # of unput cells
				if (empty[i]) {
					// Grab unused number from before
					if (j) add(ndp[j - 1][k], dp[j][k]);
					// Leave as unput
					if (k < n) add(ndp[j][k + 1], dp[j][k]);
				} else {
					// Grab unused number from before
					if (j) add(ndp[j - 1][k], dp[j][k]);
					// Put on one of the unput cells
					if (k) add(ndp[j][k - 1], k * dp[j][k] % MOD);
					// Leave as unused
					if (j < n) add(ndp[j + 1][k], dp[j][k]);
				}
			}
		swap(dp, ndp);
	}
	ll ans = dp[0][0] * mult % MOD;
	printf("%lld\n", ans);
}


Measured memory_bytes: 1664
S = input()
T = input()
s = len(S)
t = len(T)
M = 0
tmp = [ord(char) for char in T]
for n in range(s-t+1):
  m = [ord(char) - tmp[i] for i, char in enumerate(S[n:n+t])].count(0)
  if M < m:
    M = m
print(t-M)

Measured memory_bytes: 73024
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))

dummy=set()
loop=[]
X=set(range(N))
while len(dummy)!=N:
  a=[]
  k=min(X-dummy)
  a.append(k)
  dummy.add(k)
  l=P[k]-1
  while l!=k:
    a.append(l)
    dummy.add(l)
    l=P[l]-1
  loop.append(a)

ans=-(10**300)
for l in loop:
  temp=0
  s=len(l)
  ssum=0
  k=0
  for i in range(s):
    ssum+=C[l[i]]
  if ssum>0:
    temp+=((K-1)//s)*ssum
    k=K-((K-1)//s)*s
  else:
    k=min(K,s)
  kmax=-(10**300)
  for ii in range(s):
    tempscore=temp
    for jj in range(1,k+1):
      tempscore+=C[l[(ii+jj)%s]]
      if tempscore>kmax:
        kmax=tempscore
  if kmax>ans:
    ans=kmax
print(ans)


Measured memory_bytes: 77012
using static System.Console;

class Program {
	static void Main() {
		var N = int.Parse(ReadLine());

		for (var c = 0; c * 4 <= N; c++) {
			for (var d = 0; d * 7 <= N; d++) {
				if (c * 4 + d * 7 == N) {
					WriteLine("Yes");
					return;
				}
			}
		}
		WriteLine("No");
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
int main()
{
    /*string s;
    cin>>s;
    if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3]))
      cout<<"Yes";
    else
      cout<<"No";*/
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min((a*n),b);
    nl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

int main(){
    int r;cin >> r;
    cout << 3*r*r << endl;
}

Measured memory_bytes: 384
N = int(input())
a = list(map(int, input().split()))

h = N // 2 + N % 2
ans = [-1] * N

for i in range(h, N):
    ans[i] = a[i]
for i in range(h - 1, -1, -1):
    ans[i] = ((sum(ans[i::i + 1]) + 1) % 2) ^ a[i]

print(sum(ans))
for i, x in enumerate(ans):
    if x == 1:
        print(i+1)


Measured memory_bytes: 8380
def floor(N):
    return int(N)
A, B, N = list(map(int, input().split()))
result = 0

### floor(x / B) が0のうち最もxが大きい時が正解であると仮定する
if B <= N:
    result = floor(A * (B - 1) / B) - A * floor((B - 1) / B)
else:
    result = floor(A * N / B) - A * floor(N / B)
print(result)

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef double ld;

int main()

{ 
ios_base::sync_with_stdio(false);

cin.tie(NULL);

ll a,b;
cin>>a>>b;
cout<<max(max(a+b,a-b),a*b);
return 0;

}


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


int main()
{
	while (1){
		int n;
		char qq[1000], ww[1000];
		cin >> n;
		if (n == 0)break;
		for (int i = 0; i < n; i++)
		{
			cin >> qq[i] >> ww[i];
		}
		int len = 0;
		cin >> len;
		while (len--)
		{
			char u;
			cin >> u;
			for (int i = 0; i < n; i++)
			{
				if (qq[i] == u){
					u = ww[i];
					cout << u;
					break;
				}
				if (qq[i] != u&&i == n - 1)
				{
					cout << u;
					break;
				}
			}
		}
		cout << endl;
	}




	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

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

  const int R = 26;
  vector<set<int>> idx(R);
  for (int i = 0; i < (int)(N); ++i) idx[S[i] - 'a'].insert(i);

  int Q;
  cin >> Q;
  for (int i = 0; i < (int)(Q); ++i) {
    int t;
    cin >> t;
    if (t == 1) {
      int i;
      char c;
      cin >> i >> c;
      --i;
      idx[S[i] - 'a'].erase(i);
      S[i] = c;
      idx[c - 'a'].insert(i);
    } else {
      int l, r;
      cin >> l >> r;
      --l, --r;
      int ans = 0;
      for (int c = 0; c < (int)(R); ++c) {
        auto it = idx[c].lower_bound(l);
        if (it == idx[c].end()) continue;
        if (*it <= r) ++ans;
      }
      cout << ans << endl;
    }
  }
  return 0;
}


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

#define ll long long
#define F first
#define S second
using namespace std;

template <class T, class P>
ostream &operator << (ostream &out, pair<T, P> &a){
    out << a.F << " " << a.S;
    return out;
}

template <class T>
ostream &operator << (ostream &out, vector <T> &a){
    for(auto &x : a)out << x << ' ';
    return out;
}

template <class T>
ostream &operator << (ostream &out, set <T> &a){
    for(auto &x : a) out << x << ' ';
    return out;
}

template <class T, class P>
ostream &operator << (ostream &out, map <T, P> &a){
    for(auto &x : a) out << x.F << " " << x.S << endl;
    return out;
}
const int N = 1e5 + 10;
const ll INF = 1e9 + 7;

int n, m;
string s;
int t[N];
ll ans;
void solution(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> t[i];
    }
    for(int i = 1; i <= n; i++){
        int minl = min(t[i], t[i - 1]);
        t[i] -= minl;
        t[i - 1] -= minl;
        ans += minl;
        ans += t[i] / 2;
        t[i] %= 2;
    }
    cout << ans;
}


int main(){
    int n = 1;
   //cin >> n;
    while(n){
        n--;
        solution();
    }
}


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

int main(){
    int n; cin >> n;
    string march = "MARCH";
    map<char, ll> ma;
    rep(i,n){
        string s; cin >> s;
        ma[s[0]]++;
    }
    ll ans = 0;
    int cnt = 0;
    for(int i = 0; i < 5; ++i){
        for(int j = i+1; j < 5; ++j){
            for(int k = j+1; k<5; ++k){
                ans += ma[march[i]]*ma[march[j]]*ma[march[k]];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    long long X;
    long long a=0;
    long long b=0;
    long long c=0;
    cin>>X;
    a = int(X/500);
    b = int((X%500)/5);
    c = 1000*a+5*b;
    cout<<c;
}


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

int main(){
	int a, b, theta;
	double c, s, l, h, rad;
	
	scanf("%d%d%d", &a,&b,&theta);
	
	rad = theta * M_PI / 180;
	s = 0.5 * a * b * sin(rad);
	c = sqrt(a*a + b*b -(2*a*b*cos(rad)));
	l = a+b+c;
	h = b*sin(rad);
	
	printf("%f\n%f\n%f\n", s, l, h);
	
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int main(void)
{
    int n;
    cin >> n;
    vector<int> d;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        d.push_back(tmp);
    }

    long long res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            res += d[i] * d[j];
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double N;
  cin >> N;
  int ans = 0;
  
  for(int i = 1; i <= 9; i++){
  	for(int j = 1; j <= 9; j++){
    	if(N / double(i) == double(j)){
        	ans = 1;
        }
    }
  }
  
  if(ans==1){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N,L;
  cin >> N >> L;
  int sum = (2*L+N-1)*N/2;
  if(L <= 0 && 0 < L+N-1){
    cout << sum << endl;
  }else if(0 < L){
    cout << sum-L << endl;
  }else{
    cout << sum-(L+N-1) << endl;
  }
}


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

int main() {
	int A,B;
  	cin >> A >> B;
  
  	int sum = A + B;
  
  	if(A % 3 == 0 || B % 3 == 0 || sum % 3 == 0) {
    	cout << " Possible" << endl;
    }else {
    	cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;




int main(){
    long long N;
    cin >> N;
    
    long long B=1;
    for(long long i=1; i*i<=N; i++){
        if(N%i==0){
            B=N/i;
        }
    }
    
    long long ans=0;
    while(B>0){
        ans++;
        B/=10;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
t1 = [[0 for i in range(10)] for j in range(3)]
t2 = [[0 for i in range(10)] for j in range(3)]
t3 = [[0 for i in range(10)] for j in range(3)]
t4 = [[0 for i in range(10)] for j in range(3)]

n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    if b == 1:
        t1[f - 1][r - 1] += v
    elif b == 2:
        t2[f - 1][r - 1] += v
    elif b == 3:
        t3[f - 1][r - 1] += v
    else:
        t4[f - 1][r - 1] += v

for i in range(3):
    for j in range(10):
        print("", t1[i][j], end = "")
    print()
print("#" * 20)
for i in range(3):
    for j in range(10):
        print("", t2[i][j], end = "")
    print()
print("#" * 20)
for i in range(3):
    for j in range(10):
        print("", t3[i][j], end = "")
    print()
print("#" * 20)
for i in range(3):
    for j in range(10):
        print("", t4[i][j], end = "")
    print()



Measured memory_bytes: 5640
#include <iostream>
#include <map>
using namespace std;
typedef pair<int,int> P;
int N,U,V,M;
int card[100010];
int USAGI[510][510],NEKO[510][510];

int main(){
    cin >> N >> U >> V >> M;
    map<int,P> usagi,neko;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            cin >> USAGI[i][j];
            usagi[USAGI[i][j]] = {i,j};
        }
    }
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            cin >> NEKO[i][j];
            neko[NEKO[i][j]] = {i,j};
        }
    }
    for(int i=1;i<=M;i++) cin >> card[i];
    int res_usagi = 0,res_neko = 0;
    if(N==1){
        for(int i=1;i<=M;i++){
            if(usagi.count(card[i])) res_usagi++;
            if(neko.count(card[i])) res_neko++;
            if(res_usagi>=U && res_neko<V){
                cout << "USAGI" << endl;
                return 0;
            }
            if(res_usagi<U && res_neko>=V){
                cout << "NEKO" << endl;
                return 0;
            }
            if(res_usagi>=U && res_neko>=V){
                cout << "DRAW" << endl;
                return 0;
            }
        }
        cout << "DRAW" << endl;
        return 0;
    }
    map<int,int> c_usagi[4],c_neko[4];
    for(int i=1;i<=M;i++){
        if(usagi.count(card[i])){
            P u = usagi[card[i]];
            c_usagi[0][u.first]++; c_usagi[1][u.second]++; c_usagi[2][u.first+u.second]++; c_usagi[3][u.first-u.second]++;
            if(c_usagi[0][u.first]==N){
                res_usagi++;
                c_usagi[0][u.first] = 0;
            }
            if(c_usagi[1][u.second]==N){
                res_usagi++;
                c_usagi[1][u.second] = 0;
            }
            if(c_usagi[2][u.first+u.second]==N){
                res_usagi++;
                c_usagi[2][u.first+u.second] = 0;
            }
            if(c_usagi[3][u.first-u.second]==N){
                res_usagi++;
                c_usagi[3][u.first-u.second] = 0;
            }
        }
        if(neko.count(card[i])){
            P v = neko[card[i]];
            c_neko[0][v.first]++; c_neko[1][v.second]++; c_neko[2][v.first+v.second]++; c_neko[3][v.first-v.second]++;
            if(c_neko[0][v.first]==N){
                res_neko++;
                c_neko[0][v.first] = 0;
            }
            if(c_neko[1][v.second]==N){
                res_neko++;
                c_neko[1][v.second] = 0;
            }
            if(c_neko[2][v.first+v.second]==N){
                res_neko++;
                c_neko[2][v.first+v.second] = 0;
            }
            if(c_neko[3][v.first-v.second]==N){
                res_neko++;
                c_neko[3][v.first-v.second] = 0;
            }
        }
        if(res_usagi>=U && res_neko<V){
            cout << "USAGI" << endl;
            return 0;
        }
        if(res_usagi<U && res_neko>=V){
            cout << "NEKO" << endl;
            return 0;
        }
        if(res_usagi>=U && res_neko>=V){
            cout << "DRAW" << endl;
            return 0;
        }
    }
    cout << "DRAW" << endl;
}


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


//N^P(modM)




int main() {
  ll n;
  cin>>n;
  vector<ll>a(n+5);
  rep(i,n+1)cin>>a[i];

  vector<ll>A(n+5);//上限
  ll now=1;

  rep(i,n+1){
    A[i]=now;
    now-=a[i];


    if (now<0){
      cout<<-1;
      return 0;
    }

    if (now<100100100100100)now*=2;
  //  cout<<A[i]<<endl;
  }





  if (n==0){
    if (a[0]==1)cout<<1;
    else cout<<-1;
    return 0;
  }
  else if (n==1){
    if (a[0]==1) {
      cout<<-1;
      return 0;
    }
    else{
      if (a[1]>2){
        cout<<-1;
        return 0;
      }
      if (a[1]==2){
        cout<<3;
        return 0;
      }
      if (a[1]==1){
        cout<<2;
        return 0;
      }


    }
  }

else{


  vector<ll>ans(n+5);
  bool check=true;
  if (a[n]<=A[n]) {
    ans[n]=a[n];
  }
  else {
    cout<<-1;
    return 0;
  }
  ll cnt=0;
  cnt+=ans[n];
  //cout<<cnt<<"c"<<endl;


if (a[0]==1) {
  cout<<-1;
  return 0;
}

  for(ll i=n-1;i>=0;i--){
    if (a[i]>A[i]){
      check=false;
      break;
    }
    ans[i]=ans[i+1]+a[i];
    if (ans[i]>A[i]){
      ans[i]=A[i];
    }
      cnt+=ans[i];
    //  cout<<ans[i]<<endl;
    }


if (check==false){
  cout<<-1;
  return 0;
}
else{
  cout<<cnt;
  return 0;
}
}

}


Measured memory_bytes: 5636
let readInt () = Scanf.scanf " %d" (fun x -> x)

let main () =
  let n = readInt () in
  let a = Array.init n (fun _ -> readInt ()) in
  let b = Array.copy a in
  Array.fast_sort compare b;
  for i=0 to n-1 do
    Printf.printf "%d\n" (if a.(i) = b.(n-1) then b.(n-2) else b.(n-1))
  done

let () = main ()


Measured memory_bytes: 8448
a, b =map(int,input().split())
s = []
for i in range(a):
    s.append(input())

ans =[]
dx = [1, 0, -1,0,1,-1,-1,1]
dy = [0,1,0,-1,1,1,-1,-1]
for i in range(a):
    ans1=[]
    for j in range(b):
        if s[i][j]=="#":
            ans1.append('#')
            continue

        cnt=0
        for k in range(8):
            if (dx[k]+j>=0 and dy[k]+i>=0 and dx[k]+j<b and dy[k]+i<a):
                if (s[dy[k]+i][dx[k]+j]=='#'):
                    cnt+=1
        ans1.append(str(cnt))
    ans.append(ans1)

for i in range(a):
    for j in range(b):
        print(ans[i][j],end='')

    print()                     


Measured memory_bytes: 3572
import sys
import collections

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	v = [-1]*1001
	v[0]=0
	v[1]=0
	for i in range(2,1000+1):
		if v[i] == -1:
			c=1
			while c * i <= 1000:
				v[c*i] = i
				c+= 1
	
	n = int(input())
	dd=collections.defaultdict(lambda :0)
	for i in range(2, n+1):
		p=i
		while p > 1:
			yakusuu = v[p]
			dd[yakusuu] += 1
			p = p // yakusuu
	
	ret = 1
	for k in dd:
		ret *= dd[k]+1
		ret %= mod
		
	return ret
	
	
	#b , c = tin()
	#s = input()	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 68116
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {

  lint n; cin >> n;
  lint ans = 0;
  while(n > 1) {
    n = (n + 3 - 1) / 3;
    ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int n = s.size(), cnt = 0;
	rep(i,n) if(s.at(i) == 'g') cnt++;
	cout << (cnt - (n - cnt)) / 2 << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int i,a,b,c,sum=0;
    cin>>a>>b>>c;
    for(i=0;i<b;i++){
    sum+=a%b;
    if(sum%b==c){
    cout<<"YES"<<endl;
    return 0;
    }
    }
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <iterator>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

typedef long long int ll;

int main(int argc, char *argv[])
{
    ll x, y;
    scanf("%lld %lld", &x, &y);
    ll a = x;
    int cnt = 0;
    while (true)
    {
        if (a > y)
        {
            printf("%d\n", cnt);
            break;
        }

        a *= 2;
        ++cnt;
    }
}


Measured memory_bytes: 256
P(n){
	int i;
	for(i=3;i<n;i+=2)
		if(n%i==0)
			return 0;
	return 1;
}
main(n){
	for(;scanf("%d",&n),n;){
		for(;n%2==0||!P(n-2)||!P(n);n--);
		printf("%d %d\n",n-2,n);
	}
	exit(0);
}

Measured memory_bytes: 408
import math
import itertools


N = int(input())

array = [list(map(int, input().split())) for _ in range(N)]

result = 0
count = 0
permutation_list = itertools.permutations([x for x in range(N)])
for data in permutation_list:
    count += 1
    for i in range(1, len(data)):
        result += math.sqrt((array[data[i]][0] - array[data[i - 1]][0]) ** 2 +
                            (array[data[i]][1] - array[data[i - 1]][1]) ** 2)
print(result / count)


Measured memory_bytes: 3064
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	int n = kbd.nextInt();
	while(n>0){
	    String[][] c = {
		{null, null, null, null, null},
		{".", ",", "!", "?", " ", null},
		{"a", "b", "c", null, null, null},
		{"d", "e", "f", null, null, null},
		{"g", "h", "i", null, null, null},
		{"j", "k", "l", null, null, null},
		{"m", "n", "o", null},
		{"p", "q", "r", "s", null},
		{"t", "u", "v", null},
		{"w", "x", "y", "z", null},
	    };
	    solve(c);
	    n--;
	}
    }

    static void solve(String[][] c){
	String s = kbd.next();
	int i, cnt=0, a=0;
	String ans = "";
	for(i=0; i<s.length(); i++){
	    int b = Integer.parseInt(s.substring(i, i+1));
	    if(b!=0){
		a = b;
		cnt++;
		if(c[a][cnt-1]==null){
		    cnt = 1;
		}
		//System.out.println(a+" "+cnt);
	    }
	    else if(a==0);
	    else{
		ans += c[a][cnt-1];
		cnt = 0;
		a=0;
		//System.out.println(ans);
	    }
	}
	System.out.println(ans);
    }
}

Measured memory_bytes: 26748
N, K, S = map(int, input().split())

str_S = str(S)
str_S1 = str(S+1)
ans = []
for _ in range(K):
    ans.append(str_S)
for _ in range(N-K):
    if S != 1000000000:
        ans.append(str_S1)
    else:
        ans.append('1')
print(' '.join(ans))


Measured memory_bytes: 7064
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	a = min(a,min(b,min(c,min(d,e))));
	cout << 4 + n/a + (n%a>0) << endl;
}

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


public class Main {
	
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		String s = input.next();
		String t = input.next();
		boolean canD = false;
		String finalCheck = "";
		for (int i = s.length() - t.length(); i >= 0; i--) {
			String check = "";
			int counter = 0;
			for (int j = i; j < t.length() + i; j++) {
				if (s.charAt(j) == t.charAt(counter)) {
					check += s.charAt(j);
					counter++;
				} else if (s.charAt(j) == '?') {
					check += t.charAt(counter);
					counter++;
				} else{
					break;
				}
			}
			if (check.equals(t)) {
				for (int k = 0; k < i; k++) {
					if (s.charAt(k) == '?') {
						finalCheck += 'a';
					} else {
						finalCheck += s.charAt(k);
					}
				}
				finalCheck += check;
				for (int l = i + t.length(); l < s.length(); l++) {
					if (s.charAt(l) == '?') {
						finalCheck += 'a';
					} else {
						finalCheck += s.charAt(l);
					}
				}
				canD = true;
				break;
			}
		}
		if (canD) {
			System.out.println(finalCheck);
		} else {
			System.out.println("UNRESTORABLE");
		}
	}
}







Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
typedef long long ll;
const ll INF = 1e16;
struct P {
	int l, r, c;
	bool operator < (const P& b) const {
		if(l != b.l) return l < b.l;
		if(r != b.r) return r < b.r;
		return c < b.c;
	}
} p[maxn];
int n, m;
ll seg[maxn << 2], tg[maxn << 2];
void push_down(int o) {
	if(tg[o] == -1) return;
	seg[o << 1] = seg[o << 1 | 1] = tg[o];
	tg[o << 1] = tg[o << 1 | 1] = tg[o];
	tg[o] = -1;
}
void push_up(int o) {seg[o] = min(seg[o << 1], seg[o << 1 | 1]);}
void build(int l = 1, int r = n, int o = 1) {
	tg[o] = -1;
	if(l == r) {seg[o] = INF; return;}
	int m = (l + r) >> 1;
	build(l, m, o << 1), build(m + 1, r, o << 1 | 1);
	push_up(o);
}
void update(int ql, int qr, ll k, int l = 1, int r = n, int o = 1) {
	if(ql <= l && r <= qr) {
		seg[o] = tg[o] = k;
		return;
	}
	push_down(o);
	int m = (l + r) >> 1;
	if(ql <= m) update(ql, qr, k, l, m, o << 1);
	if(qr > m) update(ql, qr, k, m + 1, r, o << 1 | 1);
	push_up(o);
}
ll query(int ql, int qr, int l = 1, int r = n, int o = 1) {
	if(ql <= l && r <= qr) return seg[o];
	push_down(o);
	int m = (l + r) >> 1;
	if(qr <= m) return query(ql, qr, l, m, o << 1);
	if(ql > m) return query(ql, qr, m + 1, r, o << 1 | 1);
	return min(query(ql, qr, l, m, o << 1), query(ql, qr, m + 1, r, o << 1 | 1));
}
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) scanf("%d%d%d", &p[i].l, &p[i].r, &p[i].c);
	sort(p, p + m);
	if(p[0].l != 1) return puts("-1"), 0;
	int cur = 1;
	build();
	update(1, 1, 0);
	for(int i = 0; i < m; i++) { 
		ll x = query(p[i].l, n);
		if(x == INF) return puts("-1"), 0;
		ll now = query(p[i].r, n);
		if(now > x + p[i].c) update(p[i].r, p[i].r, x + p[i].c);
		if(cur < p[i].r)	
			cur = p[i].r; 
	}
	ll ans = query(n, n);
	if(ans == INF) puts("-1");
	else printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 7552
#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 998244353
#define P pair<ll, ll>

ll n, k;
vector<ll> s(210000);
vector<ll> used(210000, INF);
ll ans;

void dfs(ll a, ll b){
    if(used[a] != INF){
        ll now = b - used[a];
        if (k < used[a]) return;
        k -= used[a];
        k %= now;
        k += used[a];
        return;
    }
    used[a] = b;
    dfs(s[a], b + 1);
}
void dfs2(ll a, ll b){
    if(b == k){
        ans = a;
        return;
    }
    dfs2(s[a], b + 1);
}
int main() {
    cin >> n >> k;
    REP(i, n){
        cin >> s[i];
        s[i]--;
    }
    dfs(0, 0);
    dfs2(0, 0);
    cout << ans + 1 << endl;
}


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

int N;

bool isName(string shop, string board) {
    int m = board.length();
    for(int step=1; step<=m; step++) {
        for(int i=0; i<m; i++) {
            string s = "";
            for(int j=i; j<m; j+=step) {
                s += board[j];
            }
            if(s.find(shop) != string::npos) return true;
        }
    }
    return false;
}

int main(void) {
    cin >> N;
    string shop, board;
    cin >> shop;
    int ans = 0;
    for(int i=0; i<N; i++) {
        cin >> board;
        if(isName(shop, board)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1224