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

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

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

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;
}

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

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 printList(){
  Node *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");
}

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: 33948
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    ll sum = 0;
    ll pre = 0;
    REP(i, 0, n){
        ll b; cin >> b;
        if(pre > b){
            sum += pre - b;
        }else{
            pre = b;
        }
    }
    cout << sum << endl;
}

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

int main() {
  int N, sum, x;
  cin >> N;
  sum = 0;
  x = N;

  for (int i = 8; i >= 0; i--) {
    int p = pow(10,i);
    
    if (x/p != 0){
      sum += x/p;
      x -= (x/p)*p;
    } 
    
  }
  if (N % sum == 0)
    cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	ll N, D;
	cin >> N >> D;
	
	int ans = 0;
	REP(i, N) {
		ll X, Y;
		cin >> X >> Y;
		ll d = X * X + Y * Y;
		if (d <= D * D) ++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    map<P,int> mp;
    ll H,W,N;
    cin >> H >> W >> N;
    for(int i = 0;i < N;i++){
        int x,y;
        cin >> y >> x;
        int dx[] = {-1, 0, 1,-1, 0, 1,-1, 0, 1};
        int dy[] = {-1,-1,-1, 0, 0, 0, 1, 1, 1};
        for(int j = 0;j < 9;j++){
            int nx = x + dx[j],ny = y + dy[j];
            if(nx < 1 || nx > W || ny < 1 || ny > H)continue;
            mp[P(ny,nx)]++;
        }
    }
    ll cnt[10] = {(W-2)*(H-2)};
    for(auto p:mp){
        int x = p.first.second,y = p.first.first;
        if(x == 1 || x == W || y == 1 || y == H)continue;
        cnt[p.second]++;
        cnt[0]--;
    }
    for(ll n:cnt)cout << n << endl;
}

Measured memory_bytes: 56448
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long ll; typedef long double ld ;using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define rep(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  int n;
  cin>>n;
  for(int i=n;;i++){
    if(primenum(i)){
      cout<<i<<endl;
      return 0;
    }
  }

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int c1;
    //1円玉を定義
    int c5;
    //5円玉を定義
    int c10;
    //10円玉を定義
    int c50;
    //50円玉を定義
    int c100;
    //100円玉を定義
    int c500;
    //500円玉を定義
    int A = 0;
    //できない数
    cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
    //順番に標準入力
    A = c1 + 5 * c5 + 10 * c10 + + 50 * c50 + 100 * c100 + 500 * c500;
    //
    if(A >= 1000){
        cout << 1 << endl;
        /*なんと言えば良いのか・・・
        思いついたことをコードに書いてみました*/
    } else {
        cout << 0 << endl;
        //それ以外は0と出力
    }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1e9+7;
const int INF=1001001001;

int main() {
  int N,M;
  cin>>N>>M;
  vector<bool>a(N+1,false);
  for(int i=0;i<M;i++){
    int x;
    cin>>x;
    a[x]=true;
  }
  vector<int64_t>dp(N+1);
  dp[0]=1;
  for(int i=0;i<=N;i++){
    if(a[i]){continue;}
    if(i<=N-1){dp[i+1]+=dp[i];dp[i+1]%=mod;}
    if(i<=N-2){dp[i+2]+=dp[i];dp[i+2]%=mod;}
    dp[i]%=mod;
  }
  cout<<dp[N]<<endl;
  return 0;  
}

Measured memory_bytes: 4060
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main{
	
	static final Scanner s=new Scanner(System.in);
	
	public static void main(String[] __){
		String in[]=new String[s.nextInt()];
		s.next();
		for(int i=0;i<in.length;i++) in[i]=s.next();
		System.out.println(Arrays.stream(in).sorted().collect(Collectors.joining()));
	}
}

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

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

    int count = 0;
    for (int i = 105; i <= n; i = i + 2) {
        int tmp = 0;
        for (int j = 1; j <= n; j++) {
            if (i % j == 0) {
                tmp++;
            }
        }
        if (tmp == 8)
            count++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int cnt_digits(ll N){
    int digits=0;

    while(N>0){
        N/=10;
        digits++;
    }

    return digits;
}

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

    int ans=cnt_digits(N);

    for(ll A=1LL;A*A<=N;A++){
        if(N%A!=0) continue;
        const ll B=N/A;

        const int cur=max(cnt_digits(A),cnt_digits(B));

        ans=min(ans,cur);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int solution = 0;
        if(a!=0 && b!=0 && c!=0){
            for(int  i = a; i>=0; i--){
                for(int j = b; j>=0; j--){
                    for(int k = c; k>=0; k--){
                        if((500*i)+(100*j)+(50*k)==x) solution++;
                    }
                }
            }
        }else if(a!=0 && b!=0 && c==0){
            for(int  i = a; i>=0; i--){
                for(int j = b; j>=0; j--){
                    if((500*i)+(100*j)==x) solution++;
                }
            }
        }else if(a!=0 && b==0 && c!=0){
            for(int  i = a; i>=0; i--){
                for(int j = c; j>=0; j--){
                    if((500*i)+(50*j)==x) solution++;
                }
            }
        }else if(a!=0 && b==0 && c==0){
            for(int  i = a; i>=0; i--){
                if(500*i==x) solution++;
            }
        }else if(a==0 && b!=0 && c!=0){
            for(int  i = b; i>=0; i--){
                for(int j = c; j>=0; j--){
                    if((100*i)+(50*j)==x) solution++;
                }
            }
        }else if(a==0 && b!=0 && c==0){
            for(int  i = b; i>=0; i--){
                if((100*i)==x) solution++;
            }
        }else if(a==0 && b==0 && c!=0){
            for(int  i = c; i>=0; i--){
                if(50*i==x) solution++;
            }
        }else{
            System.out.println(solution); 
        }
        System.out.println(solution);
    }
}

Measured memory_bytes: 22228
/*
問題文
今、日本は 9 月 9 日です。 二桁の整数 N が与えられるので、十進法で N に 9 が含まれるか答えてください。
*/

//#9月9日はチルノの日


#include<iostream>

const int digit = 2; //今回は2桁なので　digit=2; 何桁でも対応するプログラムが書きたい

int main() {
	bool flag=false;
	int num;
	std::cin >> num;

	for (int i = 0; i < digit; i++) {
		if (((num % 10) % 9 == 0 )&& (num%10)) {
			flag = true;
			break;
		}
		num /= 10;
	}

	std::cout << (flag ? "Yes" : "No") << std::endl;

	return 0;
}

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

int main() {
  double W,H,x,y;
  cin >> W>>H>>x>>y;
  double Area;
  char flag_non_c;
  if((x==0||x==W)&&(y==0||y==H)){
    flag_non_c='0';
  }else if(x==W/2&&y==H/2){
    flag_non_c='1';
  }else{
    flag_non_c='0';
  }
  Area=W*H/2;
  cout<< Area <<" " <<flag_non_c <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    string s;
    cin>>s;
    ll n=s.size();
    rep(i,n/2+1){
        if(s[i]!=s[n-2-i]){
            cout<<-1<<endl;
            return 0;
        }
    }
    if(s[0]=='0'||s[n-1]=='1'){
        cout<<-1<<endl;
        return 0;
    }
    ll now=2;
    ll nowroot=1;
    rep(i,n-1){
        cout<<now<<' '<<nowroot<<endl;
        if(s[i]=='1')nowroot=now;
        now++;
    }
}

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

int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i * 4 + j * 7 == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s, t;
  cin >> s;
  cin >> t;
  int k = (int)s.size() - (int)t.size();
  int ans = 1e9;
  for(int i = 0; i <= k; i++){
    int x = 0;
    for(int j = 0; j < (int)t.size(); j++){
      if(s[i+j] != t[j]){
        x++;
      }
    }
    if(x < ans) ans = x;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

struct edge{
    int to,cost;
    edge(int to,int cost):
        to(to),cost(cost){}
    edge(){}
};
struct visit{
    int pos,total,b;
    visit(int pos,int total,int b):
        pos(pos),total(total),b(b){}
    visit(){}
    bool operator<(const visit &v)const{
        return total>v.total;
    }
};
int N,M,L,K,A,H;
vector<edge>G[100];
bool ice[100];

void solve(){
    bool used[100][101]={{0}};
    priority_queue<visit>Q;
    Q.push(visit(A,0,M));

    while(!Q.empty()){
        visit v=Q.top();Q.pop();
        if(used[v.pos][v.b])continue;
        used[v.pos][v.b]=true;
        if(v.pos==H){
            printf("%d\n",v.total);
            return;
        }
        for(int i=0;i<G[v.pos].size();i++){
            edge &e=G[v.pos][i];
            int tb=v.b-e.cost;
            if(tb<0)continue;
            if(used[e.to][tb])continue;
            Q.push(visit(e.to,v.total+e.cost,tb));
        }
        if(!ice[v.pos])continue;
        for(int i=v.b+1;i<=M;i++){
            if(used[v.pos][i])continue;
            Q.push(visit(v.pos,v.total+i-v.b,i));
        }
    }
    puts("Help!");
}
int main(){
    while(scanf("%d%d%d%d%d%d",&N,&M,&L,&K,&A,&H),N||M||L||K||A||H){
        fill_n(G,N,vector<edge>(0));
        fill_n(ice,N,false);
        for(int i=0;i<L;i++){
            int pos;scanf("%d",&pos);
            ice[pos]=true;
        }
        for(int i=0;i<K;i++){
            int a,b,c;
            scanf("%d%d%d",&a,&b,&c);
            G[a].push_back(edge(b,c));
            G[b].push_back(edge(a,c));
        }

        solve();
    }
    return 0;
}

Measured memory_bytes: 2548
#include<stdio.h>
#include<string.h>
int main()
{
	int sx,sy,tx,ty,i,ans=0,m,n;
	scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
	//while(sx!=tx||sy!=ty)
	// {
	 	if(tx>sx)
	 	{
	 		m=tx-sx;
	 		for(i=0;i<m;i++)
	 		printf("R");
		}
		 if(tx<sx)
	 	{
	 		m=sx-tx;
	 		for(i=0;i<m;i++)
	 		printf("L");
		}
		if(ty>sy)
	 	{
	 		m=ty-sy;
	 		for(i=0;i<m;i++)
	 		printf("U");
		}
		if(ty<sy)
	 	{
	 		m=sy-ty;
	 		for(i=0;i<m;i++)
	 		printf("D");
		}
	//}	//////////////////////////////
		if(tx>sx)
	 	{
	 		m=tx-sx;
	 		for(i=0;i<m;i++)
	 		printf("L");
		}
		 if(tx<sx)
	 	{
	 		m=sx-tx;
	 		for(i=0;i<m;i++)
	 		printf("R");
		}
		if(ty>sy)
	 	{
	 		m=ty-sy;
	 		for(i=0;i<m+1;i++)
	 		printf("D");
		}
		if(ty<sy)
	 	{
	 		m=sy-ty;
	 		for(i=0;i<m+1;i++)
	 		printf("U");
		}
		//////////////////////////////////
		if(tx>sx)
	 	{
	 		m=tx-sx;
	 		for(i=0;i<m+1;i++)
	 		printf("R");
		}
		 if(tx<sx)
	 	{
	 		m=sx-tx;
	 		for(i=0;i<m+1;i++)
	 		printf("L");
		}
		if(ty>sy)
	 	{
	 		m=ty-sy;
	 		for(i=0;i<m+1;i++)
	 		printf("U");
		}
		if(ty<sy)
	 	{
	 		m=sy-ty;
	 		for(i=0;i<m+1;i++)
	 		printf("D");
		}
		///
		if(tx>sx)
	 	printf("L");
		if(tx<sx)
	 	printf("R");
	 	//////////////////////////
	 	if(ty>sy)
	 	printf("U");
		if(ty<sy)
	 	printf("D");
	 	//////////////////
	 	if(sx>tx)
	 	{
	 		m=sx-tx;
	 		for(i=0;i<m+1;i++)
	 		printf("R");
		}
		 if(sx<tx)
	 	{
	 		m=tx-sx;
	 		for(i=0;i<m+1;i++)
	 		printf("L");
		}
		/////////////
		if(sy>ty)
	 	{
	 		m=sy-ty;
	 		for(i=0;i<m+1;i++)
	 		printf("U");
		}
		if(sy<ty)
	 	{
	 		m=ty-sy;
	 		for(i=0;i<m+1;i++)
	 		printf("D");
		}
		/////////
		if(tx<sx)
	 	printf("L");
		if(tx>sx)
	 	printf("R");
	 	printf("\n");
	return 0;
}

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

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

    	long long n,i,j,k,count=0,ans=0,l,r,x,y,mx=0,sum=0,a,b,c,d;
    cin>>n;
    string s[n];
    set<string>s2;
    for(i=0;i<n;i++)
    {
        cin>>s[i];
        s2.insert(s[i]);
    }
    cout<<s2.size();
	return 0;
}

Measured memory_bytes: 25492
X=input()
k=0 # これまでに現れたSの数-Tの数 ただし0が下限
cnt=0 # k=0のときに現れたTの数
for c in X:
    if c=='S':
        k+=1
    else:
        if k==0:
            cnt+=1
        else:
            k-=1
print(cnt*2)

Measured memory_bytes: 3500
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

ll vs[100];

int main(void) {
  vs[0] = 2;
  vs[1] = 1;
  int n;
  scanf("%d", &n);
  for(int i = 2; i <= n; ++i) {
    vs[i] = vs[i-1] + vs[i-2];
  }
  printf("%lld\n", vs[n]);
  return 0;
}


Measured memory_bytes: 128
n,k = map(int,input().split())
dlist = list(range(1,n+1))

d = []
for i in range(k):
    d.append(int(input()))
    a = list(map(int,input().split()))
    for j in range(len(a)):
        if a[j] in dlist:
            dlist.remove(a[j])
print(len(dlist))

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



struct Edge { int to, id; };

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n;
    cin >> n;
    vector<vector<Edge> > g(n);
    // vector<int> ans(n - 1);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].eb((Edge){ b, i });
        g[b].eb((Edge){ a, i });
    }
    
    queue<pii> q;
    vector<int> used(n - 1);
    q.push(pii(0, -1));
    while (!q.empty()) {
        pii v = q.front();
        // cout << v << " ";
        q.pop();
        
        int k = 1;
        
        for (auto e : g[v.F]) {
            if (used[e.id]) continue;
            if (k == v.S) ++k;
            used[e.id] = k++;
            q.push(pii(e.to, used[e.id]));
        }
    }
    
    int mx = 0;
    rep(i, n) chmax(mx, sz(g[i]));
    cout << mx << endl;
    rep(i, n - 1) cout << used[i] << endl;
    
}




Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
int n;
int a[200005];
ll mem[200005][3];
ll dp(int id, int remw){
    if (remw < 0) return -INF;
    if (id >= n+1) return remw == 0 ? 0 : -INF;
    if (mem[id][remw] != -1) return mem[id][remw];
    mem[id][remw] = max(dp(id+2,remw)+a[id],dp(id+1,remw-1));
    //printf("%d %d = %lld\n",id,remw,mem[id][remw]);
    return mem[id][remw];

}
int main(){
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    memset(mem,-1,sizeof(mem));
    if (n % 2 == 0){
        printf("%lld",dp(0,1));
    }
    else{
        printf("%lld",dp(0,2));
    }
}


Measured memory_bytes: 12348
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};



int main(){
  int a,b;cin>>a>>b;
  int c=a+b;
  if(a+b>=10)
  puts("error");
  else
  cout<<c<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long n, b, c, d = 0, e = 0;
	cin >> n >> b;
	for (int h = 1; h <= n; h++) {
		cin >> c;
		if (e <= c) {
			d += b;
		}
		else {
			d += c - (e - b);
		}
		e = c + b;
	}
	cout << d << endl;
	cin >> e;
}

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

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    string s = "Yes";
    
    if(a == b && a == c) s = "No";
    if(a != b && a != c && b != c) s = "No";
    
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt_ls, wa_cnt = [0] * N, 0
for i in range(M):
    p, s = input().split(' ')
    idx = int(p) - 1
    if not idx in ac_set:
        if s == 'AC':
            wa_cnt += wa_cnt_ls[idx]
            ac_set.add(idx)
        else:
            wa_cnt_ls[idx] += 1
print(len(ac_set), wa_cnt)

Measured memory_bytes: 18040
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
typedef long double f80;

signed main()
{
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    f80 ans = 0;
    fr(i, 1, n) {
        f80 x;
        cin >> x;
        ans += 1 / x;
    }
    cout << setprecision(10) << fixed << 1 / ans << endl;
    return 0;
}

Measured memory_bytes: 256
s = input().strip()
k = int(input())
ss = []
n = len(s)
for i in range(n):
    for j in range(1, 6):
        if i + j <= n:
            ss.append(s[i:i + j])
ss = list(set(ss))
ss.sort()
print(ss[k - 1])

Measured memory_bytes: 5068
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

string add(string a, string b){
//    cout << a << endl;
//    cout << b << endl;
    while(a.size() < b.size()) a.insert(0, "0");
    while(b.size() < a.size()) b.insert(0, "0");
//    cout << a << endl;
//    cout << b << endl;
    int n = a.size();
    string res(n, ' ');
    for (int i = n - 1, d = 0; i >= 0; --i){
        int p = a[i] - '0';
        int q = b[i] - '0';
        int r = p + q + d;
        d = r / 10;
        res[i] = r % 10 + '0';
        if (i == 0 && d != 0) res.insert(0, string(1, d + '0'));
//        cout << res << endl;
    }
    return res;
}

int main(){
    int Tc;
    cin >> Tc;
    while(Tc--) {
        string a, b;
        cin >> a >> b;
        string tmp = add(a, b);
        if(tmp.size() > 80) cout << "overflow" << endl;
        else cout << tmp << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int n,m;
    cin>>n>>m;
    mp[s1]=n;
    mp[s2]=m;
    string res;
    cin>>res;
    mp[res]--;
    cout<<mp[s1]<<' '<<mp[s2];
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    //freopen("b.in","r",stdin);
    int n,ans=0;
    scanf("%d",&n);
    for (int i=1; i<=n; i++)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        ans+=r-l+1;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()

using namespace std;

int main()
{
    IOS;
    int n;
    cin>>n;
    int d[n];
    repf(i,0,n) cin>>d[i];
    sort(d,d+n);
    cout<<d[n/2]-d[n/2-1]<<endl;
}
 

Measured memory_bytes: 640
#include<stdio.h>
int coin[6]={500,100,50,10,5,1};
int answer=0;

int calc(int c,int q){
	while(c>=coin[q]){
	//	printf("%d %d\n",c,answer);
		c-=coin[q];
		answer++;
	}
	q++;
	if(q!=6){
		calc(c,q);
	}
	return answer;
}
int main(){
	int value,a=0;
	while(1){
		scanf("%d",&value);
		if(value==0){
			break;
		}
		answer=0;a=0;
		printf("%d\n",calc(1000-value,a));
		
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        int min = x*2;
        int max = x*4;
        
        String output = "Yes";
        
        if(y%2 != 0) output = "No";
        if(y < min || y > max) output= "No";
        
        System.out.println(output);
    }
}


Measured memory_bytes: 35828
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {

	ll n,a,b;
	cin >> n >> a >> b;
	ll ans = 0;
	ans += (n / (a+b)) * a;
	if(n % (a+b) > a) ans += a;
	else ans += n % (a+b);
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 764
K = input()
l = len(K)
D = int(input())
MOD = 10**9+7

dp = [[[0]*D for _ in range(2)] for _ in range(l+1)]
dp[0][0][0] = 1

for i in range(l):
    for j in range(D):
        nd = int(K[i])
        for d in range(10):
            dp[i+1][1][(j+d)%D] += dp[i][1][j%D]%MOD #smaller->smaller
            if d < nd:
                dp[i+1][1][(j+d)%D] += dp[i][0][j%D]%MOD #exact->smaller
        dp[i+1][0][(j+int(K[i]))%D] += dp[i][0][j%D]%MOD #exact->exact


ans = (dp[l][0][0] + dp[l][1][0]-1) % MOD
print(ans)

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

#define int long long
#define S second
#define F first

typedef long long ll;
typedef long double ld;

using namespace std;

const int INF = 1e9;
const int maxn = 2e5+10;
const int mod = 1e9+7;

int n;
int A[maxn];
string s;
vector<int> v;
int dp[maxn];

signed main()
{
    cin>> s; n = s.size();
    if(s[0] == 'A') A[0] = 1;
    for(int i = 1; i < s.size(); i++)
    {
        if(s[i] == 'C' && s[i-1] == 'B')
            v.push_back(i);
        if(s[i] == 'A')
            A[i] = A[i-1] + 1;
    }

    if(v.empty())
        return cout<< 0, 0;

    ll ans = 0;
    dp[0] = A[v[0]-2];
    ans += dp[0];
    for(int i = 1; i < v.size(); i++)
    {
        dp[i] = A[v[i]-2];
        if(A[v[i]-2] == v[i] - v[i-1] - 2)
            dp[i] += dp[i-1];
        ans += dp[i];
    }

    cout<< ans;
}




Measured memory_bytes: 3196
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(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 modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
const int M=2001*2001;
void solve()
{
    ll n;
    cin>>n;
    vl v;
    v.pb(0);
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
    }
    bitset<M> dp;
    dp.reset();
    dp[0]=1;
    ll total=0;
    for(int i=1;i<=n;i++)
    {
        int c=v[i];
        auto dp2=dp;
        dp<<=c;
        dp=(dp|dp2);
        total+=c;
    }
    if((total%2)==0)
        total/=2;
    else
        total=(total+1)/2;
    for(int i=total;;i++)
    {
        if(dp.test(i))
        {
            cout<<i<<'\n';
            return;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 13440
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

int result = 0;
int DD[200000] = {};

int Func(int k, int N, int A[]) {
    int pow2k = pow(2,k);
    int pow2k_1 = pow(2,k-1);
    int C_index = 0;
    while (A[C_index]<pow2k_1) {
        C_index += 1;
    }
    int N_b = C_index;
    int N_c = N - C_index;
    //cout << C_index << endl;
    
    int index = 0;
    vector<int> D{};
    int N_d = 0;
    
    int temp_0 = 0;
    for (int i=0;i<N;i++) {
        if (A[i]==pow2k_1) temp_0 += 1;
    }
    result += temp_0/2;
    //cout << result << endl;
    
    for (int i=0;i<N_c;i++) {
        int target = pow2k - A[N-1-i];
        while (A[index]<target) {
            if (index==C_index) {A[index]=target+1; break;}
            D.push_back(A[index]);
            N_d += 1;
            index += 1;
        }
        if (index==C_index) {break;}
        if (A[index]==target) {
            result += 1;
            index += 1;
        }
    }
    for (int i=index;i<N_b;i++) {
        D.push_back(A[i]);
        N_d += 1;
    }
    
    //cout << k << " " << result << endl;
    //cout << result << endl;
    //cout << "DD=[";
    for (int i=0;i<N_d;i++) {
        DD[i] = D[i];
        //cout << DD[i] << " ";
    }
    //cout << "]" << endl;
    
    return N_d;
}


int main(){
    int N;
    cin >> N;
    int A[N];
    for (int i=0;i<N;i++) cin >> A[i];
    sort(A, A+N);
    
    int now = A[N-1];
    int k = 0;
    while (now>=pow(2,k)) {k += 1;}
    
    for (int i=0;i<N;i++) {
        DD[i] = A[i];
    }
    //cout << k << endl;
    
    while (k>0) {
        N = Func(k, N, DD);
        k = 0;
        now = DD[N-1];
        while (now>=pow(2,k)) {k += 1;}
    }
    
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 2936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while (!(line = br.readLine()).equals("0")) {
            String[] lines = br.readLine().split(" ");
            double[] list = new double[lines.length];
            int n = lines.length;
            double total = 0.0; //????¨????
            double average = 0.0; //?????????
            double var = 0.0; //?????£
            while (n-- > 0) {
                list[n] = Double.parseDouble(lines[n]);
                total+=list[n];
            }
            n=lines.length;
            average=total/n;
            for(int i=0;i<n;i++){
                var+=((list[i]-average)*(list[i]-average));
            }
            System.out.printf("%f\n",Math.sqrt(var/n));
        }
    }
}

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

int main()
{
  int a, b, c, d, l, r;

  cin >> a >> b >> c >> d;
  l = a + b;
  r = c + d;
  if (l > r)
    cout << "Left" << endl;
  if (l < r)
    cout << "Right" << endl;
  if (l == r)
    cout << "Balanced" << endl;
}


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

int main(){
  int r, D, x2000;
  cin >> r >> D >> x2000;
  for(int i = 0; i < 10; i++){
    x2000 *= r;
    x2000 -= D;
    cout << x2000 << endl;
  }
}

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

DP = [0]*(N+1)
DP[1] = 1

S = []
for i in range(K):
    S.append(list(map(int, input().split())))

for i in range(2, N+1):
    for l, r in S:
            DP[i] += (DP[max(i-l, 0)] - DP[max(i-r-1, 0)])
    DP[i] += DP[i-1]
    DP[i] %= 998244353

print((DP[N] - DP[N-1])%998244353)

Measured memory_bytes: 16900
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str1,str2;
    cin>>n;
    vector<double> v(n);
    rep(i,n)cin>>v[i];
    sort(v.begin(),v.end());
    rep(i,n-1) v[i+1]=(v[i]+v[i+1])/2;
    cout<<v[n-1];
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>


using namespace std;


int main(void)
{
	vector<char> s(100+2);

	while(scanf("%100[a-z]\n", &s[0])==1)
	{
		int l=strlen(&s[0]);
		vector<char> t(l+1), t_(l+1);
		int c, ans;

		ans=l;
		for(int i=1;i<l;i++)
		{
			if(s[i]!=s[i-1]) break;
			if(i==l-1) ans=0;
		}
		if(l==1) ans=0;

		t=s;
		for(int i=0;i<l;i++)
		{
			int x=s[i];
			t_=s;
			for(int l_=l;l_>1;l_--)
			{
				c=0;
				t=t_;
				for(int j=0;j<l_-1;j++)
				{
					if(t[j]==x)
					{
						t_[j]=x;
						c++;
					}
					else if(t[j+1]==x)
					{
						t_[j]=x;
						c++;
					}
					else
					{
						t_[j]=t[j];
					}
				}
				t[l_-1]='\0';
				if(c>=l_-1)
				{
					ans=min(ans, l-l_+1);
					break;
				}
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}


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

int main()
{
    double x = 0, y = 0;            //x座標y座標
    double d, a = 0, b = 0;         //d距離a角度b角度
    char c;

    double pi = acos(-1);           //cos(pi) = -1より acos(-1) = pi;

    //最初は必ずy軸正の方向にdだけ進むので、bの初期値は0とする。cos(0) = 1
    while( cin >> d >> c >> a )
    {
        if( d == 0 && a == 0 )  //終了処理
            break;

        double si, co;
        si = sin(b*pi/180);
        co = cos(b*pi/180);

        //x軸の処理
        if( b >= 0 || b <= 180 )    // 0 <= θ <= 180のときx軸正の方向に動く
            x += d * si;
        else                        // -180 <= θ < 0のときx軸負の方向に動く
            x -= d * si;

        //y軸の処理
        if( b >= -90 || b <= 90 )   //y軸正の方向に動く時の条件
            y += d * co;
        else
            y -= d * co;
        b += a;
    }


    cout << (int)x << endl << (int)y << endl;   //int型でキャスト

    return 0;
}
// b>=0やabs(b)<=90という条件が相応しくなかった理由は、角度aという値が0°から360°の範囲を取るから。
// 対して180°までの範囲しか頭になかったので反省。


Measured memory_bytes: 3388
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prinp(p) cout<<p.first<<" "<<p.second<<endl
#define prinv(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9+7,MAX = 1e6+5;
const ll INF = 1e18+5;

int main()
{
	int n,x,t;
	cin>>n>>x>>t;
	cout<<(n/x)*t + (n%x!=0)*t<<endl;
}	

Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{   ll n;
    cin>>n;
    ll a[n+1],dp[n+1];
    a[0]=0;
    for(ll i=1;i<=n;i++){
            cin>>a[i];
    dp[i]=1e9+7;}
    //memset(dp,1e5,sizeof(dp));
    dp[0]=0;
    dp[1]=0;
    for(ll i=1;i<=n;i++){

          for(ll j=i+1;j<=i+2;j++){
            if(j<=n)dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
            //cout<<dp[j]<<endl;
            }

    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const bool DEBUG = 0;
const int MAXQ = 210;

vector<int> A;

int sw;

int tot = 0;

int query(vector<int> Q) {
	tot++;
	assert(tot <= MAXQ);
	if (DEBUG) {
		int s = 0;
		for (auto x : Q) {
			s += A[x];
		}
		if (sw) s *= -1;
		if (s < 0) {
			return -1;
		} else {
			return 1;
		}
	} else {
		cout << "? ";
		for (auto i : Q) {
			cout << i + 1 << ' ';
		}
		cout << endl;
		string res;
		cin >> res;
		int x = 0;
		if (res == "Red") {
			x = 1;
		} else {
			x = -1;
		}
		if (sw) x *= -1;
		return x;
	}
}

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

	int n;
	if (DEBUG) {
		string s;
		cin >> s;
		for (auto t : s) {
			if (t == 'R') {
				A.push_back(1);
			} else {
				A.push_back(-1);
			}
		}
		n = (int)A.size() / 2;
	} else {
		cin >> n;
	}
	auto gt = [&](int l, int r) {
		vector<int> a;
		for (int i = l; i < r; i++) {
			a.push_back(i);
		}
		return a;
	};
	if (query(gt(0, n)) < 0) sw = 1;
	assert(query(gt(0, n)) > 0);
	assert(query(gt(n, 2 * n)) < 0);
	int l = -1;
	int r = -1;
	{
		int L = 0;
		int R = n;
		while (R - L > 1) {
			int m = (R + L) >> 1;
			if (query(gt(m, m + n)) > 0) {
				L = m;
			} else {
				R = m;
			}
		}
		l = R;
		r = R + n - 2;
	}
	vector<int> ans(2 * n, -2);
	for (int i = 0; i < 2 * n; i++) {
		if (l <= i && i <= r) {
			//
		} else {
			vector<int> c;
			for (int j = l; j <= r; j++) {
				c.push_back(j);
			}
			c.push_back(i);
			ans[i] = query(c);
		}
	}
	vector<int> F;
	vector<int> S;
	for (int i = 0; i < 2 * n; i++) {
		if (ans[i] == -1) {
			if ((int)F.size() < (n - 1) / 2) {
				F.push_back(i);
			}
		}
		if (ans[i] == 1) {
			if ((int)S.size() < (n - 1) / 2) {
				S.push_back(i);
			}
		}
	}
	vector<int> all;
	for (auto i : F) {
		all.push_back(i);
	}
	for (auto i : S) {
		all.push_back(i);
	}
	for (int i = 0; i < 2 * n; i++) {
		if (l <= i && i <= r) {
			vector<int> c = all;
			c.push_back(i);
			ans[i] = query(c);
		}
	}
	cout << "! ";
	for (auto x : ans) {
		if (sw) x *= -1;
		if (x == 1) {
			cout << 'R';
		} else {
			cout << 'B';
		}
	}
	cout << endl;
	cerr << "tot: " << tot << endl;
}

Measured memory_bytes: 3848
n, p = map(int, input().split())

def prime_factorize(num):
    """
    This function performs prime factorization on the input natural number.
    The result is returned in the form of a dictionary with the prime number as the key
    and its number as the value.
    :param num:
    :return prime_factor: Dictionary with the prime number as the key and its number as the value.
    """
    prime_factor = {}
    i = 2
    while i ** 2 <= num:
        while num % i == 0:
            num //= i
            if i in prime_factor.keys():
                prime_factor[i] += 1
            else:
                prime_factor[i] = 1
        i += 1
    if num > 1:
        prime_factor[num] = 1
    return prime_factor


prime_fac = prime_factorize(p)
counts = []
for k, v in prime_fac.items():
    if v >= n:
        counts.append(k**(v//n))

counts.sort(reverse=True)
#print(prime_fac)
#print(counts)
if len(counts) == 0:
    print(1)
elif n == 1:
    print(p)
else:
    r = 1
    num = 0
    for c in counts:
        if num >= n:
            break
        r *= c
        num += 1
    print(r)


Measured memory_bytes: 3064
n, m, k = map(int, input().split())
mat = [list(input()) for _ in range(n)]
t = 0
for b in range(1<<(n+m)):
    c = 0
    for i in range(n):
        for j in range(m):
            if mat[i][j] == "#" and not ((1<<i & b) or (1<<(j+n) & b)):
                c += 1
    if c == k:
        t += 1
print(t)


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if( a == b ){
    cout << c << endl;
  } else if ( a == c ) {
    cout << b << endl;
  } else {
    cout << a << endl;
  }
  
}


Measured memory_bytes: 3580
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e18;

int main(){
    ll a,b;
    cin >> a >> b;
    ll diff=b-a;
    ll sum=0;
    for(ll i=1;i<=diff-1;i++){
        sum+=i;
    }
    cout << sum-a << endl;
} 


Measured memory_bytes: 256
//Krunal_Mathukiya
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define li long int
#define pb push_back
#define mkp make_pair
#define nikalL return
#define umap unordered_map
#define fr(i,s,n) for(int i=s;i<=n;++i)
#define frr(i,s,n) for(int i=s;i>=n;--i)
#define jaldiKarNe ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
int arr[100007];
int dp[100007];
int vis[100007];
int n;
lli fn(int i) {
	if (i >= n) return 0;
	if(vis[i]) return dp[i];
	vis[i]=1;
	lli tmp=10000000000;
	if((i+1)<=n) tmp=abs(arr[i]-arr[i+1])+fn(i+1);
	lli tmp2=10000000000;
	if((i+2)<=n) tmp2=abs(arr[i]-arr[i+2])+fn(i+2);
	return dp[i]=min(tmp,tmp2);
}
void TestingChaluKarEyy() {
	cin >> n;
	fr(i, 1, n) cin >> arr[i],vis[i]=0;
	cout << fn(1);
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	jaldiKarNe;
	int TestingKaravvuChhe = 1;
	// cin >> TestingKaravvuChhe;
	while (TestingKaravvuChhe--) {
		TestingChaluKarEyy();
	}
}


Measured memory_bytes: 9512
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

struct UnionFind{
    vector<int> par,num;
    vector<bool> done;
    UnionFind(int n):par(n),num(n,1),done(n,false){
        iota(par.begin(),par.end(),0);  //include<numeric>
    }
    int find(int v){
        return (par[v]==v)?v:(par[v]=find(par[v]));
    }
    void unite(int u,int v){
        u=find(u),v=find(v);
        if(u==v)return;
        if(num[u]<num[v])swap(u,v);
        num[u]+=num[v];
        par[v]=u;
        done[u]=done[u]|done[v];
    }
    bool same(int u,int v){
        return find(u) == find(v);
    }
    bool ispar(int v){
        return v=find(v);
    }
    int size(int v){
        return num[find(v)];
    }
};

int main(){
    int n,m; cin >> n >> m;
    UnionFind uf(n);
    for(int i=0;i<m;i++){
        int c,x,y; cin >> c >> x >> y;
        if(c==0){
            uf.unite(x,y);
        }
        else{
            cout << uf.same(x,y) << endl;
        }
    }
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

const int INF = 1001001001;

int main() {

    int n;

    cin >> n;
    int n2 = 1 << n;

    vector<int> a(n2);

    rep(i, n2) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());

    vector<int> s;
    s.push_back(a.back());
    a.back() = -1;

    rep(i, n) {
        vector<int> p = s;
        sort(p.begin(), p.end());
        int ai = n2 - 1;
        while (p.size() > 0 && ai >= 0) {
            if (a[ai] == -1) {
                ai--;
                continue;
            }
            if (a[ai] < p.back()) {
                s.push_back(a[ai]);
                p.pop_back();
                a[ai] = -1;
            }
            ai--;
        }
        if (p.size() > 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 2932
#include<cstdio>
#include<cstring>
int main(){
	int a,b,d;
	while(~scanf("%d",&a)){
		int c[a+1];
		memset(c,0,sizeof(c));
		d=0;
		for(b=2;b<=a;b++){
			if(c[b]==0){
				d++;
				for(int i=b;i<a+1;i+=b)	c[i]=1;
			}
		}
		printf("%d\n",d);
	}
}

Measured memory_bytes: 4668
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()

ans = 100
cnt = 0
while ans < X:
    ans = ans * 1.01
    ans = int(ans)
    cnt += 1
print(cnt)    

Measured memory_bytes: 10048
#include<stdio.h>
#include<stdlib.h>

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

Node root;

void Insert(int k){
  Node y = NULL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;

  while( x != NULL ){
    y = x;
    if( z->key < x->key ){
      x = x->left;
    }else{
      x = x->right;
    }
  }

  z->parent = y;

  if( y == NULL ){
    root = z;
  }else if( z->key < y->key ){
    y->left = z;
  }else{
    y->right = z;
  }

}

void Order1(Node u){
  if( u == NULL ){
    return;
  }
  Order1(u->left);
  printf(" %d" ,u->key);
  Order1(u->right);
}

void Order2(Node u){
  if( u == NULL ){
    return;
  }
  printf(" %d" ,u->key);
  Order2(u->left);
  Order2(u->right);
}

Node Search(Node u, int k){
  if( u == NULL || k == u->key){
    return u;
  }
  if( k < u->key ){
    return Search( u->left, k);
  }else {
    return Search( u->right, k);
  }
}



int main(){

  char c[20];
  int n, i, x;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", c);
    if ( c[0] == 'f' ){
      scanf("%d", &x);
      Node t = Search(root, x);
      if ( t != NULL ) printf("yes\n");
      else printf("no\n");
    } else if ( c[0] == 'i' ){
      scanf("%d", &x);
      Insert(x);
    } else if ( c[0] == 'p' ){
      Order1(root);
      printf("\n");
      Order2(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 19364