akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur = nil->next;
  while(cur != nil && cur ->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

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

void deleteNode(Node *t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

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(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{
	deleteKey(key); nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}

Measured memory_bytes: 33836
#include "bits/stdc++.h"
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INF 100000000
typedef long long ll;

using namespace std;


int main() {
    int n;
    ll ans=0,str[5];
    cin >> n;
    REP(i, 5)str[i] = 0;
    REP(i, n) {
        string s;
        cin >> s;
        switch (s[0]) {
            case 'M':
                str[0]++;
                break;
            case 'A':
                str[1]++;
                break;
            case 'R':
                str[2]++;
                break;
            case 'C':
                str[3]++;
                break;
            case 'H':
                str[4]++;
                break;
            default:
                break;
        }
    }
    REP(i, 5) {
        FOR(j, i + 1, 5) {
            FOR(k, j + 1, 5) {
                ans += str[i] * str[j] * str[k];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
bool cmp(pair<ll,ll> &p1, pair<ll,ll> &p2){
   return p1.second > p2.second;
}
// UnionFind
// coding: https://youtu.be/TdR816rqc3s?t=726
// comment: https://youtu.be/TdR816rqc3s?t=6822
struct UnionFind {
  vector<int> d;
  vector<int> min_;
  UnionFind(int n=0): d(n,-1) {
     for (int i = 0; i < n; i++){
        min_.push_back(i);
     }
  }
  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);
    if (min_[x] > min_[y])min_[x] = min_[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 ret_min(int x){return min_[find(x)];}
};
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n, m; cin >> n >> m;
   vector<pair<ll,ll>> p;
   rep(i,n){
      int a, b; cin >> a >> b;
      p.push_back(make_pair(m-a+1, b));
   }
   sort(p.begin(), p.end(), cmp);
   UnionFind uf(100001);
   ll ans = 0;
   for (auto &&i : p)
   {
      if (i.first <= 0 || uf.same(0,i.first))continue;
      uf.unite(uf.ret_min(i.first)-1, i.first);
      ans += i.second;
   }
   cout << ans << endl;  
}

Measured memory_bytes: 6088
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;

    #define MAXN 1000005
    int spf[MAXN];
    void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;

        for (int i=3; i*i<MAXN; i++)
        {
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)

                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }


    vector<int> gf(int x)
    {
        vector<int> ret;
        while (x != 1)
        {
            ret.push_back(spf[x]);
            x = x / spf[x];
        }
        return ret;
    }
    int BIT[100050]; //fenwick
    void upd(int x) { ++x;  while(x<=MAXN)  {  BIT[x]++;  x+=(x&-x);  } }
    int cal(int x) {  ++x;  int res=0;  while(x>0)  {  res+=BIT[x];  x-=(x&-x);  } return res; }
    ll Com[1051][1051];
    void pre()
    {

        ll i,j,n=1051;
        rep(i,0,n) Com[i][0]=Com[i][i]=1;
        rep(i,2,n)
        {
            rep(j,1,i)
            {
                Com[i][j]=Com[i-1][j]+Com[i-1][j-1];
                Com[i][j]%=hell;
            }
        }

    }
    ll mod=hell;
    ll pr( ll x , ll y)
    {
        ll ans=1;
        if(y==0) return ans;
        while(y>1)
        {
            if(y&1) ans*=x;
            x*=x;
            y/=2;
            x%=mod;
            ans%=mod;
        }
        ans*=x;
        ans%=mod;
        return ans;
    }
    ll inv(ll n)
    {
        return pr(n,mod-2);
    }
    ll stoi(string s)
    {
        int n=s.size();
        ll k=0; int i;
        rep(i,0,n)
        {
            k+=s[i]-'0';
            k*=10;
        }
        return k/10;
    }
    string to_string(ll n)
    {  if(!n) return "0";
        string s=""; int a,b;
        while(n>0)
        {
            b=n%10;
            s+=(b+'0');
            n/=10;
        }
        reverse(all(s));
        return s;
    }


    void solve()
    {
    double i,j=0,r=200,p,q,k=0,d,y=0,n,h=10000000,flag=0,m=0,a=hell,b=hell,id,h1,h2,a1,b1,a2,w,x,u,f,l,c=0,e,ans=0;
     cin>>n;
     double pie=6.28318530717958623200/2.000000;
     n*=pie;
     cout<<fixed<<setprecision(10)<<2*n;
    }
    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
       // cin>>t;
        while(t--)
        solve();
    }


Measured memory_bytes: 3792
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	
	if(v<=w)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	ll dis=(v-w)*t;
	ll n=abs(a-b);
	if(n<=dis)
	{
		cout<<"YES"<<endl;
		return 0;
	}
	else
	{
		cout<<"NO"<<endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;
 
int main() {
	char a[3];
	for(int i = 0; i< 3; i++) {
		cin >> a[i];
	}

	for(int i = 1; i< 3; i++) {
		if (a[i] != a[i-1]) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
 
vector<lli> b;

lli countMask(lli a){
	lli ret=0;
	for(lli x:b) if((x&a)==a)ret++;
	return ret;
}

signed main(){
 
 	lli n,k;
 	cin>>n>>k;
 	vector<lli> a(n);
 	REP(i,0,n)cin>>a[i];

 	for(lli i=0;i<n;i++){
 		lli tmp = 0;
 		for(lli j=i;j<n;j++){
 			tmp += a[j];
 			b.push_back(tmp);
 		}
 	}

 	sort(b.begin(),b.end(),greater<lli>());

 	lli mask = 0;
 	for(lli i=40;i>=0;i--){
 		if(countMask(mask|(1LL<<i)) >= k){
 			mask |= (1LL<<i);
 		}
 	}
 	cout<<mask<<endl;

	return 0;
}

Measured memory_bytes: 6260
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	long sisan;
	int n;
	int nen;
	cin>> sisan>> nen>> n;
	
	long ans = sisan;
	for(int i=0;i<n;i++){
		long s = sisan;
		int hukuri;
		double riritu;
		int tesuu;
		cin>> hukuri>> riritu>> tesuu;
		if(!hukuri){
			long risokuwa = 0;
			for(int j=0;j<nen;j++){
				risokuwa += s * riritu;
				s -= tesuu;
			}
			s += risokuwa;
		}else{
			for(int j=0;j<nen;j++){
				s *= (1+riritu);
				s -= tesuu;
			}
		}
		ans = max(ans, s);
	}
	cout<< ans<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int n;
	cin>> n;
	for(int i=0;i<n;i++){
		solve();
	}
	
	return 0;
}

 

Measured memory_bytes: 1232
inf = 10 ** 15

N, M, L = map(int, input().split())
dp = [[inf] * N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    dp[a-1][b-1] = c
    dp[b-1][a-1] = c
for i in range(N):
    dp[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
#print('distance={}'.format(dp))


dp2 = [[inf] * N for _ in range(N)]
for a in range(N - 1):
    for b in range(a+1, N):
        if dp[a][b] <= L:
            dp2[a][b] = 1
            dp2[b][a] = 1
for k in range(N):
    for i in range(N):
        for j in range(N):
            dp2[i][j] = min(dp2[i][j], dp2[i][k] + dp2[k][j])
#print('times={}'.format(dp2))


Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    cost = dp2[s-1][t-1]
    if cost != inf:
        print(cost - 1)
    else:
        print(-1)


Measured memory_bytes: 60376
#include<iostream>
using namespace std;
long long gcd(long long x,long long y){return y?gcd(y,x%y):x;}
long long lcm(long long x,long long y){return x*y/gcd(x,y);}
int main(){
    long long a,b;
    cin>>a>>b;
    cout<<lcm(a,b)<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace A___Two_Coins
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var c = int.Parse(input[2]);
            if (a + b >= c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
local read = io.read
local insert = table.insert

local h, w, m = read("n", "n", "n")
local grid_t = {}
for i = 1, h do
	grid_t[i] = {}
end

local sum_h_i_t, sum_w_i_t = {}, {}
for i = 1, m do
	local h_i = read("n")
	local w_i = read("n")
	grid_t[h_i][w_i] = true
	sum_h_i_t[h_i] = sum_h_i_t[h_i] and sum_h_i_t[h_i] + 1 or 1
	sum_w_i_t[w_i] = sum_w_i_t[w_i] and sum_w_i_t[w_i] + 1 or 1
end

local max_h, max_w = 0, 0
local max_h_index_t, max_w_index_t = {}, {}
for i = 1, h do
	if sum_h_i_t[i] and sum_h_i_t[i] > max_h then
		max_h = sum_h_i_t[i]
		max_h_index_t = {i}
	elseif sum_h_i_t[i] and sum_h_i_t[i] == max_h then
		insert(max_h_index_t, i)
	end
end
for i = 1, w do
	if sum_w_i_t[i] and sum_w_i_t[i] > max_w then
		max_w = sum_w_i_t[i]
		max_w_index_t = {i}
	elseif sum_w_i_t[i] and sum_w_i_t[i] == max_w then
		insert(max_w_index_t, i)
	end
end

local is_dup = true
for i = 1, #max_h_index_t do
	for j = 1, #max_w_index_t do
		if grid_t[max_h_index_t[i]][max_w_index_t[j]] == nil then
			is_dup = false
			break
		end
	end
	if not is_dup then
		break
	end
end

print(is_dup and max_h + max_w - 1 or max_h + max_w)


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003;
const ll INF=1LL<<60;

int main(){
    
    int N;
    ll x;cin>>N>>x;
    vector<vector<ll>> S(N,vector<ll>(N));
    for(int i=0;i<N;i++){
        cin>>S[0][i];
    }
    for(int i=1;i<N;i++){
        for(int j=0;j<N;j++){
            S[i][j]=min(S[i-1][j],S[0][(j+N-i)%N]);
        }
    }
    ll ans=INF;
    for(int i=0;i<N;i++){
        ll sum=x*i;
        for(int j=0;j<N;j++){
            sum+=S[i][j];
        }
        ans=min(ans,sum);
    }
    
    cout<<ans<<endl;
}


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

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

  int x = 0, y = 1;
  for (int i = 0; i < h; ++i) {
    if (i == b)
      swap(x, y);
    for (int j = 0; j < w; ++j) {
      cout << (j < a ? x : y);
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int N, M; cin >> N >> M;
  vector<vector<int>> path(N+1);
  int A, B;
  rep(i,M){
    cin >> A >> B;
    path.at(A).push_back(B);
    path.at(B).push_back(A);
  }

  vector<int> d(N+1,100000000); // ノード１からの最短距離
  d[1] = 0;
  vector<int> prev(N+1,-1); // 前のノード
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int, int>>> Q; //優先度付きキュー
  //for (int i=1;i<=N;i++) Q.push(make_pair(d[i],i));
  Q.push(make_pair(0,1));


  while (!Q.empty()){
    pii pu = Q.top(); Q.pop();
    int u = pu.second;
    for (auto v :path.at(u)){
      int alt = d[u]+1;
      if (d[v]>alt){
        d[v] = alt;
        prev[v] = u;
        Q.push(make_pair(d[v],v));
      }
    }

  }

  /*for (int i=1;i<=N;i++){
    for (auto v :path[i]){
      cout << v <<" ";
    }
    cout << endl;
  }*/
  for (int i=2;i<=N;i++) {
    if (prev[i]==-1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (int i=2;i<=N;i++) cout << prev[i] << endl;


  
  return 0;
}

Measured memory_bytes: 11056
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val a = scanner.nextLong()
    val b = scanner.nextLong()
    val n = scanner.nextLong()
    if(b>n){
        println(a*n/b)
    }
    else if(b===n){
        println(a*(n-1)/b)
    }
    else{
        println(Math.max((a*n/b)-(n/b*a), (a*(b-1)/b)))
        //println((Math.floor((a*n/b.toDouble())).toLong())-(a*Math.floor((n/b.toDouble())).toLong()))
    }
}

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

int main() {
  int n,i,t,a;
  cin>>n>>t>>a;
  double h[n];
  double x[n];
  for(i=0;i<n;i++){
    cin>>h[i];
    x[i]=abs(a-t+0.006*h[i]);
  }
  int ans=0;
  double tmp=1000000;
  
  for(i=0;i<n;i++){
    if(tmp>x[i]){
      tmp=x[i];
       ans=i+1;
     
    }
  }
  cout<<ans;
       
    
}

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

using namespace std;

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

  int D, N, pos = 0;
  cin >> D >> N;
  for (int i = 1; i < 200; ++i) {
    if (i%100 == 0) continue;
    pos++;
    if (pos == N) {
      cout << i * (int)pow(100, D) << endl;
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
 
 
int main(){
	int n, m;
	std::cin>>n>>m;
 
	std::vector<std::vector<int>> sList(m);
	std::vector<int> pList(m);
	std::vector<int> pow2List(11, 1);
 
	for(int i=0; i<m; i++){
		int iter;
		std::cin>>iter;
		sList[i].resize(iter);
 
		for(int j=0; j<iter; j++)
			std::cin>>sList[i][j];		
	}
	
	for(int i=0; i<m; i++)
		std::cin>>pList[i];
 
	for(int i=1; i<11; i++)
		pow2List[i]= pow2List[i-1]*2;
 
	int ans= 0;

	for(int i=0; i<pow2List[n]; i++){
		bool isSame= true;
		for(int j=0; j<m; j++){
			int numOn=0;

			for(int k=0; k<sList[j].size(); k++)
				numOn+= ((i & pow2List[sList[j][k]-1])>0)?1:0;

			if(numOn%2!=pList[j])
				isSame= false;
		}
 
		if(isSame)
			ans++;
	}
  
	std::cout<<ans<<std::endl;
 
	return 0;
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))
if K == 0:
    print(N**2)
else:
    res = 0
    for b in range(1, N+1):
        L = max(b-K, 0)
        res += L*(N//b) + max(0, (N%b)+1-K)

    print(res)

Measured memory_bytes: 9104
n = int(input())
ls = [int(input()) for _ in range(n)]


def judge(n):
    if n == 2 or n == 3:
        return 1
    if n % 2 == 0:
        return 0
    i = 3
    while i <= n/i:
        if n%i == 0:
            return 0
        else:  
            i += 2
    return 1

print(sum(map(judge, ls)))


Measured memory_bytes: 5984
//To debug :  g++ -g file.cpp -o code
//cout<<setprecision(p)<<fixed<<var
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 INT_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 INT_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<int>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
 

ll n;
ll dp[401][401];
ll ps[401]; //prefix sums
ll a[401];


ll fun(ll s,ll l) //starting and last
{
	if(dp[s][l]!=-1)
		return dp[s][l];
	else if(s>=l)
		return 0;


	ll ans=big,sums = ps[l] - ps[s-1];
	ll i;

	for(i=s;i<l;++i)
	{
		if(i==1)
			ans = fun(s,i)+sums+fun(i+1,l);
		else
			ans = min(ans,fun(s,i)+sums+fun(i+1,l));
	}

	dp[s][l] = ans;

	return ans;

}


int main()
{

	ll i;
	cin>>n;

	ps[0] = 0;	
	a[0] = 0;

	memset(dp,-1,sizeof(dp));

	rep(i,1,n+1)
	{
		cin>>a[i];
		ps[i] = ps[i-1] + a[i];
	}




	ll ans = big;



	for(i=1;i<n;++i)  //till i one side and from i+1 to n other side
	{

		if(i==1)
			ans = fun(1,i)+ps[n]+fun(i+1,n) ;
		else
			ans = min(ans,fun(1,i)+ps[n]+fun(i+1,n)) ;
 
		 //i is the position of partiton 
		//from 1 to i one block and (i,n] the other block
	}

	dp[1][n] = ans;

	cout<<ans;

	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int A[] = {-1, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

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

  int K;
  std::cin >> K;

  std::cout << A[K] << std::endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[50];
ll N;
int main(){
  cin >> N;
  dp[1] = 3;
  int i;
  for(i=1;dp[i]<N;i++){
    dp[i+1] = dp[i]*3;
  }
  cout << i << endl;
}

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

int main() {
    long long N, x; cin >> N >> x;
    long long a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    long long ans = 0;
    for (int i = 1; i < N; i++)
    {
        if(a[i] + a[i-1] > x) {
            ans += a[i] + a[i-1] - x;
            a[i] = max(0LL, x - a[i-1]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
using System;

namespace ITP1_3_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var count = 0;

            while (true)
            {
                var n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                Console.WriteLine("Case {0}: {1}", ++count, n);
            }
        }
    }
}

Measured memory_bytes: 9280
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll a[Max];

void solve(){
	ll n,ans=0;
	cin>>n;
	unordered_map<ll,ll> ma;
	rep(i,0,n){
		cin>>a[i];
		ma[a[i]]++;
	}
	for(auto m:ma){
		ans+=(m.se-1)*(m.se)/2;
	}
	rep(i,0,n){
		cout<<ans-(ma[a[i]]-1)*(ma[a[i]])/2+(ma[a[i]]-1>=2?(ma[a[i]]-2)*(ma[a[i]]-1)/2:0)<<endl;
	}
}
int main() {
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 9160
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int N, X, T;
    cin >> N >> X >> T;

    int ans = ((N+X-1) / X) * T;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
import math
x1,y1 = map(int,input().split())
x2,y2 = map(int,input().split())
x3,y3 = map(int,input().split())
ans = 0
for (xa,ya,xb,yb,xn,yn) in (x1,y1,x2,y2,x3,y3),(x2,y2,x3,y3,x1,y1),(x3,y3,x1,y1,x2,y2):
  xa -= xn
  ya -= yn
  xb -= xn
  yb -= yn
  xab = xa-xb
  yab = ya-yb
  L = math.hypot(xab,yab)
  cosa = (xab*xa+yab*ya)/(math.hypot(xa,ya)*math.hypot(xab,yab))
  cosb = (-xab*xb-yab*yb)/(math.hypot(xb,yb)*math.hypot(xab,yab))
  anga = math.acos(cosa)
  angb = math.acos(cosb)
  tana = math.tan(anga/2)
  tanb = math.tan(angb/2)
  ans = max(ans,L/(2+1/tana+1/tanb))
print(ans)

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

int main() {
    string s;cin>>s;
    map<ll,ll> mp;
    vector<ll> a;
    ll tmp=0;
    ll mod=2019;
    ll k=1;
    ll ans=0;

    a.push_back(0);
    for(int i=0;i<s.size();i++){
        int num = s[s.size() - i - 1] - '0';
        tmp+=num*k%mod;
        tmp%=mod;
        a.push_back(tmp);
        k*=10;
        k%=mod;
    }
    for(auto g: a){
        mp[g]++;
    }
    for(auto it: mp){
        ll num = it.second;
        ans+=num*(num - 1)/2;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n)　for(int i=(k);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    return (x*y);
}

#define WA printf("WA\n");
int main()
{
    ll n,min=M;
    cin >> n;
    vll a(5);
    rep(i,5){
        cin >> a[i];
        if(min > a[i])min = a[i];
    }
    
    cout << ((n%min == 0)?n/min : n/min+1) + 4 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {
    int d;
    cin >> d;
    string s = "Christmas";
    REP(i, 25-d) s += " Eve";
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : abc144_d.cpp
// Author      : abb
// Version     :
// Copyright   : [My copyright notice]
// Description : https://atcoder.jp/contests/abc144/tasks/abc144_d
//============================================================================

/*
 D - Water Bottle

 実行時間制限: 2 sec / メモリ制限: 1024 MB

 配点 : 400 点

 問題文
 高橋君は、底面が 1 辺 a~\mathrm{cm} の正方形であり、高さが b~\mathrm{cm} であるような
 直方体型の水筒を持っています。(水筒の厚みは無視できます。)
 この水筒の中に体積 x~\mathrm{cm}^3 の水を入れ、底面の正方形の 1 辺を軸として、この水筒を徐々に傾けます。
 水を溢れさせずに水筒を傾けることができる最大の角度を求めてください。

 制約

 ・入力は全て整数
 ・1 ≤ a <= 100
 ・1 ≤ b <= 100
 ・1 ≤ x ≤ a^2b
 */

#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

using ll = long long;
using ull = unsigned long long;

#define rep(i, m, n) for (int i = m; i < n; ++i)
# define M_PI 3.14159265358979323846 /* pi */
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

/**
 * エントリポイント．
 * @return 0.
 */
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	double a, b, x;
	cin >> a >> b >> x;

	// a^2*b/2 > x [cm^3] なら，水が少ないので傾きを大きくできる
	// そうでないなら，あまり傾けられない．
	double whole = a * a * b;
	float rad;
	if (x < whole / 2) {
		// 水は少ない，
		// 容量は a*b*h/2 (= x), この h を用いて角度は atan(b/h)
		// double h = 2 * x / a / b;
		// b/h = b/(2 * x / a / b) = b/(2*x / (a*b)) = (a*b*b)/(2*x) = (a*b*b)/x/2
		rad = atan((float) ((a * b * b) / x / 2));
	} else {
		// 水は多い．
		// 容量は whole - a^2*h/2 (=x), この h を用いて角度は atan(h/a)
		// whole - x = a^2*h/2
		// double h = 2 * (whole - x) / a / a;
		// h/a = (2*(whole-x) / (a*a))/a = 2*(whole-x) / (a*a*a)
		rad = atan((float) (2 * (whole - x) / (a * a * a)));
	}

	cout << setprecision(12) << rad_to_deg(rad) << endl;
	return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
h_w_list = [list(input()) for i in range(h)]
h_li = []
w_li = []
for i in range(h):
    if "#" in h_w_list[i]:
        h_li.append(i)
for j in range(w):
    if "#" in [h_w_list[k][j] for k in range(h)]:
        w_li.append(j)
for i in h_li:
    for j in w_li:
        print(h_w_list[i][j], end="")
    print()



Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int H,W;
  cin>>H>>W;
  int ans1 = (H%3 != 0) ? W : 0;
  int ans2 = (W%3 != 0) ? H : 0;
  int a,b,c;
  a = (W/3)*H;
  if(H%2 != 0){
    b = (W-W/3)*(H/2);
    c = (W-W/3)*((H/2)+1);
  }
  else{
    b = (W-W/3)*(H/2);
    c = b;
  }
  int ans3 = max(a,c)-min(a,b);
  
  a = ((W/3)+1)*H;
  if(H%2 != 0){
    b = (W-W/3-1)*(H/2);
    c = (W-W/3-1)*((H/2)+1);
  }
  else{
    b = (W-W/3-1)*(H/2);
    c = b;
  }
  int ans4 = max(a,c)-min(a,b);

  
  
  a = (H/3)*W;
  if(W%2 != 0){
    b = (H-H/3)*(W/2);
    c = (H-H/3)*((W/2)+1);
  }
  else{
    b = (H-H/3)*(W/2);
    c = b;
  }
  int ans5 = max(a,c)-min(a,b);
  
  a = ((H/3)+1)*W;
  if(W%2 != 0){
    b = (H-H/3-1)*(W/2);
    c = (H-H/3-1)*((W/2)+1);
  }
  else{
    b = (H-H/3-1)*(W/2);
    c = b;
  }
  int ans6 = max(a,c)-min(a,b);
 // cout << ans1 << " " << ans2 << " " << ans3 << " " << ans4 << " " << ans5 << " " << ans6 << endl;
  cout << min(ans1,min(ans2,min(ans3,min(ans4,min(ans5,ans6))))) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
int M, S[3];

int main()
{
	for(int i = 0; i < 3; ++i)
		scanf("%d", &S[i]);
	bool odd = true; M = 0;
	for(int i = 0; i < 3; ++i)
	{
		if(!(S[i] & 1))
			odd = false;
		if(S[i] > S[M])
			M = i;
	}
	if(!odd) return puts("0"), 0;
	printf("%lld\n", std::min(1LL*S[0]*S[1], std::min(1LL*S[0]*S[2], 1LL*S[1]*S[2])));
	return 0;
}

Measured memory_bytes: 128
#https://qiita.com/white1107/items/52fd4149bb1846862e38

N, Q = map(int,input().split())
par = [i for i in range(N+1)]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]
def same(x,y):
    return find(x) == find(y)
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y
    
    
for i in range(Q):
    t, u, v = map(int,input().split())
    if t == 0:
        unite(u,v)
    else:
        if same(u,v):
            print(1)
        else:
            print(0)

Measured memory_bytes: 85000
source_lst = list(map(lambda x:x,input()))
dest_lst = list(map(lambda x:x,input()))

source_lst.sort()
dest_lst.sort(reverse=True)

source = ''.join(source_lst)
dest = ''.join(dest_lst)

if source < dest :
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; } // 1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; } // 8,7,6,5
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab

int mod(LL x) {
	if (x == 26)return 26;
	return x % 26;
}

#define N 200009


int main(){
	int n, a[N], xor=0;
	scanf("%d", &n);
	rep(i, n) { scanf("%d", a + i); xor = xor ^a[i]; }

	rep(i, n) {
		int ans = xor;
		ans ^= a[i];
		printf("%d ", ans);
	}
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    REP(i, 0, X) cin >> A[i];
    REP(i, 0, Y) cin >> B[i];
    REP(i, 0, Z) cin >> C[i];


    vector<ll> AB(X * Y);
    REP(i, 0, X) {
        REP(j, 0, Y) {
            AB[Y * i + j] = A[i] + B[j];
        }
    }

    sort(ALL(AB), greater<>());
    sort(ALL(C), greater<>());

    priority_queue<ll, vector<ll>, greater<ll>> pq;
    REP(i, 0, Z) {
        // cout << "# i : " << i << " : " << C[i] << endl;
        REP(j, 0, min((int)AB.size(), K)) {
            if ((int)pq.size() < K) {
                pq.push(C[i] + AB[j]);
                // cout << "--> pushed "  << C[i] + AB[j] << endl;
            } else {
                if (pq.top() >= C[i] + AB[j]) break;
                pq.pop();
                pq.push(C[i] + AB[j]);
                // cout << "--> pushed "  << C[i] + AB[j] << endl;
            }
        }
    }

    vector<ll> ans(K);
    REP(i, 0, K) {
        ans[K - i - 1] = pq.top();
        pq.pop();
    }
    for (auto a : ans) cout << a << endl;
    return 0;
}

Measured memory_bytes: 11272
N = int(input())
h_list = list(map(int, input().split()))


dp_list = [0, abs(h_list[0] - h_list[1])]
for n in range(2, N):
    h0 = h_list[n-2]
    h1 = h_list[n-1]
    h2 = h_list[n]
    tmp_min = min(abs(h2-h1)+dp_list[n-1], abs(h2-h0)+dp_list[n-2])
    dp_list.append(tmp_min)
print(dp_list[-1])


Measured memory_bytes: 20476
#include <stdio.h>
int main(void){
   
    char s[101];
    
    scanf("%s",s);
    int i,num=0;
    
    i=0;
    while(s[i]!='\0'){
        if(s[i]=='C'){
            int k=i+1;
            while(s[k]!='\0'){
                if(s[k]=='F'){
                    num=1;
                    break;
                }
                k++;
            }
        }
        i++;
    }
    
    if(num==0){
    printf("No\n");
    }else if(num==1){
    printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 128
n = int(input())
A = list(map(int,input().split()))

prod = 1
flag = 0
lim = 1e18
A.sort()
for num in A:
  prod = num*prod
  if prod > lim:
    flag = 1
    break
if flag == 1:
  print(-1)
else:
  print(prod)

Measured memory_bytes: 84656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

	int N;
	cin >> N;
	int kotae;
	rep1(i, 9) {
		if (N <= i * 111) {
			kotae = i * 111;
			break;
		}
	}
	co(kotae);
	Would you please return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

int x, P; 

int read() {
  if (scanf("%d%d", &x, &P) < 2) {
    return 0;
  }
  return 1;
}

ld p;

ld solve(int x) {
  return x / p;
}

void solve() {
  p = P / (ld) 100;
  ld res = 0;
  if (x & 1) {
    res = 1 + p * solve(x / 2) + (1 - p) * solve(x / 2 + 1);
  } else {
    res = solve(x / 2);
  }
  printf("%.18f\n", (double) res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int N, A[1000000], cnt;

void Out(const vector<int> G) {
	cout << G.size() << endl;
	cout << G.back();
	for (int i = G.size() - 2; i >= 0; i--) {
		cout << ' ' << G[i];
	}
	cout << endl;
	cout << cnt << endl;
	for (int i = 0; i < N; i++)
		cout << A[i] << endl;
}

void InsertionSort(int g) {
	for (int i = g; i < N; i++) {
		int v = A[i], j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}
void ShellSort(const vector<int> G) {
	cnt = 0;
	for (int i = G.size() - 1; i >= 0; i--) {
		InsertionSort(G[i]);
	}
}

int main()
{
	vector<int> G;
	cin >> N;
	int calc = 1;
	while (calc <= N) {
		G.push_back(calc);
		calc = calc * 3 + 1;
	}
	for (int i = 0; i < N; i++)
		cin >> A[i];
	ShellSort(G);
	Out(G);
	return 0;
}


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


int main() { 
    int n;
    cin >> n;
    vector< pair<int, int> > a1, a2;
    int a,b;
    for (int i=0;i<n;i++) {
        cin >> a >> b;
        a1.push_back(make_pair(a, b));
    }
    for (int i=0;i<n;i++) {
        cin >> a >> b;
        a2.push_back(make_pair(a, b));
    }
    sort(a1.begin(), a1.end());
    sort(a2.begin(), a2.end());
    vector<int> matched(n);
    for (int i = 0; i < n; ++i) matched[i] = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int j = 0, k = -1;
        int tmp = -1;
        while (a1[j].first < a2[i].first) {
            if (a1[j].second < a2[i].second && a1[j].second >= tmp && !matched[j]) {
                tmp = a1[j].second;
                k = j;
            }
            j++;
            if (j == n) break;
        }
        if (k >= 0 && k < n) {
            matched[k] = 1;
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
const ll mods[] = {(ll)1e9 + 7, (ll)1e9 + 9};
const ll ps[] = {29, 31};
ll p[2][30];
int n;
string s;
map<vector<ll> , ll> mp;
int main(){
    cin >> n >> s;
    for(int i = 0; i < 30; ++i){
        for(int j = 0; j < 2; ++j){
            if(i){
                p[j][i] = (p[j][i - 1] * ps[j]) % mods[j];
            }
            else{
                p[j][i] = 1 % mods[j];
            }
        }
    }
    // 0 - red, 1 - blue
    for(int msk = 0; msk < (1 << n); ++msk){
        int cnt[2] = {};
        vector<ll> cur_msk = {0, 0};
        for(int i = 0; i < n; ++i){
            if((1 << i) & msk){
                cnt[0]++;
                for(int j = 0; j < 2; ++j){
                    cur_msk[j] += p[j][cnt[0] - 1] * (s[i] - 'a' + 1);
                    cur_msk[j] %= mods[j];
                }
            }
            else{
                cnt[1]++;
                for(int j = 0; j < 2; ++j){
                    cur_msk[j] -= p[j][n - cnt[1]] * (s[i] - 'a' + 1);
                    cur_msk[j] %= mods[j];
                    cur_msk[j] += mods[j];
                    cur_msk[j] %= mods[j];
                }
            }
        }
        mp[cur_msk]++;
    }
//    for(auto it : mp){
//        cout << "new" << endl;
//        for(auto j : it.first){
//            cout << j << " ";
//        }
//        cout << endl;
//        cout << it.second << endl;
//    }
    ll ans = 0;
    for(int msk = 0; msk < (1 << n); ++msk){
        int cnt[2] = {};
        vector<ll> cur_msk = {0, 0};
        for(int i = n - 1; i >= 0; --i){
            if((1 << i) & msk){
                cnt[0]++;
                for(int j = 0; j < 2; ++j){
                    cur_msk[j] += p[j][n - cnt[0]] * (s[i + n] - 'a' + 1);
                    cur_msk[j] %= mods[j];
                }
            }
            else{
                cnt[1]++;
                for(int j = 0; j < 2; ++j){
                    cur_msk[j] -= p[j][cnt[1] - 1] * (s[i + n] - 'a' + 1);
                    cur_msk[j] %= mods[j];
                    cur_msk[j] += mods[j];
                    cur_msk[j] %= mods[j];
                }
            }
        }
        for(int j = 0; j < 2; ++j){
            cur_msk[j] = -cur_msk[j];
            if(cur_msk[j] < 0) cur_msk[j] += mods[j];
        }
        ans += mp[cur_msk];
    }
    cout << ans << endl;
}


Measured memory_bytes: 57600
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
	
	string s,t;
	cin>>s>>t;
	ll ans=LONG_MAX;
	for(unsigned ll i=0;i<=(s.length()-t.length());i++)
	{
	    
	    ll k=0;
	    for(unsigned ll j=0;j<t.length();j++)
	    {
	        if(t[j]!=s[i+j])
	        {
	            k++;
	        }
	        
	    }
	    ans=min(ans,k);
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3648
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const long double PI = acos(-1),eps=1.0e-14;
void solve(){
    int n;
    cin>>n;
    loop(10,i,1)
        loop(10,j,1)
            if(i*j==n){
                cout<<"Yes"<<endl;
                return;
            }
    cout<<"No"<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3620
N=gets.to_i
red=[]
N.times{
	a,b=gets.split.map(&:to_i)
	red << [a,b]
}
blue=[]
N.times{
	c,d=gets.split.map(&:to_i)
	blue << [c,d]
}
red.sort!
blue.sort!
warn red.inspect
warn blue.inspect
r=0
until red.empty? || blue.empty?
	if blue[0][0] <= red[0][0]
		blue.shift
		next
	end
	i=-1
	max_i=nil
	while i<red.size-1
		i+=1
		break if red[i][0]>=blue[0][0]
		next if red[i][1]>blue[0][1]
		if !max_i || red[i][1] > red[max_i][1]
			max_i = i
		end
	end
	unless max_i
		blue.shift
		next
	end
	warn [max_i, red[max_i], blue[0]].inspect
	r+=1
	red.delete_at(max_i)
	blue.shift
end
puts r


Measured memory_bytes: 14352
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		int n;
		cin>>n;
		string s;
		cin>>s;

		int count = 0,max_count = 0;
		for(int i=0; i<n; i++) {
			if(s[i] == 'I') {
				count++;
			}
			else if(s[i] == 'D') {
				count--;
			}
			max_count = max(count,max_count);
		}
		cout<<max_count<<endl;
		return 0;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<string>>A(H,vector<string>(W));
    int line,row;
    rep(i,H){
        rep(j,W){
            cin>>A[i][j];
            if(A[i][j]=="snuke"){
                line=i;
                row=j;
            }
        }
    }
    char c='A'+row;
    cout<<c<<line+1<<endl;

    return 0;
}

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

int main() {
  int K,S;
  cin>>K>>S;
  
  int count=0;
  for(int X=0;X<=K;++X){
    for(int Y=0;Y<=K;++Y){
      int Z=S-X-Y;
      if(0<=Z && Z<=K)
        ++count;
    }
  }
  
  cout<<count<<endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

vector < int > go(LL x)
{
	if (x == 1)
		return vector<int>(2, 1);

	

	

	// dodac tylko 1 pare na srodku
	if (x % 2 == 0)
	{
		auto tmp = go(x -1);
		vector < int > res(tmp.begin(), tmp.begin() + tmp.size() / 2);
		int mx = res.back();
		res.push_back(mx + 1);
		res.push_back(mx + 1);
		res.insert(res.end(), tmp.begin() + tmp.size() / 2, tmp.end());

		return res;
	}

	// wymnozyc wynik*2+1 - dodaj pare na koncu obu polowek
	auto tmp = go(x / 2);
	vector < int > res(tmp.begin(), tmp.begin() + tmp.size() / 2);
	int mx = res.back();
	res.push_back(mx + 1);
	res.insert(res.end(), tmp.begin() + tmp.size() / 2, tmp.end());
	res.push_back(mx + 1);

	return res;
}

int main()
{
	LL N = 0;
	scanf("%lld", &N);

	auto res = go(N);

	printf("%d\n", res.size());

	REP(i, res.size())
		printf("%d ", res[i]);
	printf("\n");

	return 0;
}

Measured memory_bytes: 256