akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define all(v) (v).begin(),(v).end()
 
#define PII pair<int,int>
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream &os, vector<T> V){
  os<<"[";for(auto vv:V)os<<vv<<",";return os<<"]";
} 

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}


#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
 
#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue
 
#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb fflush(stdout)

const int max_n = 2e5+5;

int n;
char s[max_n];
int best[max_n][30];
int nxt[max_n][30];
int naj[max_n];

int main () {
	scanf("%s", s);
	n = strlen(s);
	int last = n;
	FOR(i,0,26) {
		last = n;
		FORD(j,n-1,0) {
			if (s[j] == 'a' + i) last = j;
			nxt[j][i] = last;
		}
	}
	FOR(j,0,26) {
		if (s[n-1]=='a'+j) best[n-1][j] = 2;
		else best[n-1][j] = 1;
	}
	naj[n-1] = 1;
	naj[n] = 1;
	naj[n+1] = 1;
	FORD(j,n-2,0) {
		naj[j] = max_n;
		FOR(i,0,26) {
			int a = nxt[j][i];
			if (a == n) {
				best[j][i] = 1;
			} else {
				best[j][i] = 1 + naj[a+1];
			}
			naj[j] = min(naj[j], best[j][i]);
		}
	}
	int len = naj[0];
	int x = 0;
	FOR(i,0,len) {
		FOR(u,0,26) {
			if (x > n-1) {
				putchar('a');
				break;
			} else if (best[x][u] == len - i) {
				putchar(u+'a');
				x = nxt[x][u]+1;
				break;
			}
		}
	}
	putchar('\n');
}



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

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef double ld;
int main() {
	ld a, b, h; cin >> a >> b >> h;
	h = h / (a*a);
	ld t, beta, alpha;
	if (h < b / 2) {
		t = h * a * 2.0 / b;
		beta = atan(t / b) * 180 / acos(-1.0);
		alpha = 90.0 - beta;
	}
	else {
		t = b - h; 
		alpha = atan(2.0 * t / a) * 180 / acos(-1.0);
	}
	cout.precision(20);
	cout << alpha << endl;
}

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

#define int long long

const int N = 2e4 + 5;

int A[N], B[N], P[N], n;

main() {
	cin >> n;
	for(int i = 1; i <= n; ++ i) scanf("%lld", &P[i]);
	for(int i = 1; i <= n; ++ i) A[i] = B[n - i + 1] = N * i;
	for(int i = 1; i <= n; ++ i) 
	A[P[i]] += i;
	for(int i = 1; i <= n; ++ i) printf("%lld ", A[i]);
	puts("");
	for(int i = 1; i <= n; ++ i) printf("%lld ", B[i]);
	puts("");
}

Measured memory_bytes: 4224
X,K,D=map(int,input().split())
min_=X-D*K
max_=X+D*K
if min_>=0:
  print(min_)
elif max_<=0:
  print(-max_)
else:
  c1=max_%(2*D)
  c2=c1-2*D
  print(min(abs(c1), abs(c2)))


Measured memory_bytes: 9036
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define yes puts("YES")
#define no puts("NO")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

string s;

string tgt="keyence";

signed main(){

    in(s);
    
    rep(i,s.size()){
        rep(j,s.size()){
            string tmp=s;
            tmp.erase(tmp.begin()+i,tmp.begin()+j);
            if(tgt==tmp){
                yes;
                return 0;
            }
        }
    }
    no;
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main(void){
    int n;
    int a[100000];
    int sum = 0;
    
    std::cin >> n;
    
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
        sum += a[i] - 1;
    }
    
    std::cout << sum << std::endl;
}


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

long long N, K;
vector<long long> A;

map<long long, long long>pmap;

void prime_factor(long long num){
	long long bak = num;
	for(int i = 2; i*i <= num; i++){
		while(bak % i == 0){
			//i is prime
			pmap[i]++;
			bak /= i;
		}
	}
	if(bak > 1){
		pmap[bak]++;
	}
}

void prime_factor2(long long num){
	long long bak = num;

	for(auto pm: pmap){
		long long div = pm.first;
		long long num = pm.second;
		for(long long i = 0; i < num; i++){
			if(bak%div != 0){
				pmap[div] = i;
				break;
			}
			bak /= div;
		}
	}
}


int main(){
	cin >> N >> K;
	bool have = false;

	for(long long i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		if(K == tmp){
			have = true;
		}
		A.push_back(tmp);
	}
	sort(A.begin(), A.end(), greater<long long>());

	//既にある
	if(have){
		cout << "POSSIBLE" << endl;
		return 0;
	}

	if(N == 1){
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	//最大のより大きい
	if(A[0] < K){
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	prime_factor(A[0]);
	for(long long i = 1; i < A.size(); i++){
		prime_factor2(A[i]);
	}

	long long cur = 1;
	for(auto pm: pmap){
		for(long long i = 0; i < pm.second; i++){
			cur *= pm.first;
		}
	}

	if(K%cur == 0){
		cout << "POSSIBLE" << endl;
		return 0;
	}else{
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
}


Measured memory_bytes: 1400
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.nextLine();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < s.length(); i++) {
                if (i % 2 == 0) {
                    sb.append(s.charAt(i));
                }
            }
            out.println(sb.toString());
        }

    }
}

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

int main () {
    string s; cin >> s;
    char start = s[0], end = s[s.size() - 1];
    printf("%c%d%c", start, s.size() - 2, end);
    return 0;
}

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

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);
}
 
int main() {
  int64_t N;
  cin>>N;
  
  vector<int64_t> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  
  if(N==1){
    cout<<vec.at(0)<<endl;
    return 0;
  }
  int64_t X=lcm(vec.at(0),vec.at(1));
  if(N==2) cout<<X<<endl;
  else{
    for(int i=2;i<N;i++){
      X=lcm(X,vec.at(i));
    }
    cout<<X<<endl;
  }
    
}

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

typedef long long ll;
typedef long double ld;
#define pb push_back
#define pll pair<ll,ll>
#define vl vector<ll>
#define vll vector < pll >
#define sl set<ll>
#define mll map<ll,ll>
#define itr :: iterator
#define pf push_front
#define ff first
#define ss second
#define stkl stack <ll>
#define quel queue <ll>
#define pquel priority_queue <ll>
#define rep(i,n) for(i=0;i<n;i++)
#define MOD 1000000007
#define SIZE 100005
#define PI 3.14159265358979323846

#define debug(var) cout << "[" << __LINE__ << "] " << #var << " = " << (var) << endl;

struct edge {
    ll A;
    ll B; 
};

// Implementation of DSU (Union by Rank)
/*
ll parent[SIZE],rank[SIZE];

ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void make_set(ll v) {
    parent[v] = v;
    rank[v] = 0;
}

void union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rank[a] < rank[b])
            swap(a, b);
        parent[b] = a;
        if (rank[a] == rank[b])
            rank[a]++;
    }
}
*/
//*********************************************

ll power(ll a, ll b, ll mod){
    ll x = 1, y = a;
    while (b > 0){
        if (b%2){
            x = (x*y)%mod;
        }
        y = (y*y)%mod;
        b /= 2;
    }
    return x%mod;
}   
 
// FOR FINDING MODULAR INVERSE 

ll modular_inverse(ll n, ll mod){
    return power(n, mod-2, mod);
}


bool edgecompare(edge lhs, edge rhs) { if(lhs.B!=rhs.B)return lhs.B < rhs.B;
else return lhs.A<rhs.A;}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<setprecision(25);

    ll i,n,l;
    ld a[SIZE];
    cin>>n>>l;

    ll sum = 0;
    sum += n*l;
    sum += n*(n-1)/2;

    if(l>=0){
        sum-=l;
    }
    else{
        if(l+n-1 >= 0){

        }else{
            sum-=(l+n-1);    
        }
    }

    cout<<sum;

    /*ll n,m,i,j,k,flag=0,x;
    ll *a;//[SIZE];
    
    cin>>n;
    a = new ll[n];
    rep(i,n)
    {
        cin>>a[i];
    }

    delete a;*/

   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int f(long long a, long long b){
  string sa = to_string(a), sb = to_string(b);
  return max(sa.size(), sb.size());
}

void solve(){
  long long int n; cin >> n;
  double x = pow(n, 0.5) + 1;
  int ans = 100000;
  for(int i = x; i >= 1; i--){
    if(n % i == 0){
      ans = min(f(i, n / i), ans);
    }
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
string a;
int ans=0;
int main(){
    cin>>a;
	if(a[0]!='C')
		ans++;
    if(a[1]!='O')
		ans++;
    if(a[2]!='D')
		ans++;
    if(a[3]!='E')
		ans++;
    if(a[4]!='F')
		ans++;
    if(a[5]!='E')
		ans++;
    if(a[6]!='S')
		ans++;
    if(a[7]!='T')
		ans++;
    if(a[8]!='I')
		ans++;
    if(a[9]!='V')
		ans++;
    if(a[10]!='A')
		ans++;
    if(a[11]!='L')
		ans++;
    if(a[12]!='2')
		ans++;
    if(a[13]!='0')
		ans++;
    if(a[14]!='1')
		ans++;
    if(a[15]!='6')
		ans++;
    cout<<ans<<endl;
    return 0;
}

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

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;


int main(){
  IO; int N; cin >> N;
  int ma = 0, mb = 0, mc = 0;
  int a, b, c, ta, tb, tc;
  while(N --){
    cin >> a >> b >> c;
    ta = max(mb, mc) + a;
    tb = max(ma, mc) + b;
    tc = max(ma, mb) + c;
    ma = ta, mb = tb, mc = tc;
  }
  cout << max(ma, max(mb, mc)) << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

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

    int a, b;
    cin >> a >> b;
    cout << (max(a, b) > 8 ? ":(" : "Yay!") << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
string a, b;
cin >> a >> b;
if (a == "H" && b == "H"){
	cout << "H" << endl;
}else if (a == "H" && b == "D"){
	cout << "D" << endl;
}else if (a == "D" && b == "H"){
	cout << "D" << endl;
}else if (a == "D" && b == "D"){
	cout << "H" << endl;
}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
    cin >> n >> m;
    vector<vector<char>> a(n, vector<char>(n));
    vector<vector<char>> b(m, vector<char>(m));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            cin >> a.at(i).at(j);
        }
    }
    for(int i = 0; i < m; ++i) {
        for(int j = 0; j < m; ++j) {
            cin >> b.at(i).at(j);
        }
    }

    bool exist = false;

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            if(i+m-1 >= n || j+m-1 >= n) {
                continue;
            }else {
                int flgin = 0;
                for(int k = 0; k < m; ++k) {
                    for(int l = 0; l < m; ++l) {
                        if(a.at(i+k).at(j+l) != b.at(k).at(l)) {
                            flgin = 1;
                        }
                    }
                }
                if(flgin == 0) exist = true;
            }
        }
    }

    if(exist) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

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

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

    for(int i=0;i<=n;i++){
        if(y<i*10000)break;

        for(int j=0;j<=n;j++){
            if(n<i+j)break;
            if(y<i*10000+j*5000)break;

            int k=n-i-j;

            if(10000*i+5000*j+1000*k==y){
                printf("%d %d %d",i,j,k);
                return 0;
            }

            
        }
    }
    printf("-1 -1 -1");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;

ll comb[5001][5001];


int main(){
	ll k,n;
	cin >> n >> k;

	for(int i=0;i<=5000;i++){
		for(int j=0;j<=i;j++){
			if(j==0 || j==i) comb[i][j] = 1;
			else {
				comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
				comb[i][j] %= mod;
			}
		}
	}

	for(ll i=1;i<=k;i++){
		if(i>n-i+1&&k!=n){
			cout << "0" << endl;
			continue;
		}
		ll ans = 1;
		ans *= comb[k-1][i-1];
		ans %= mod;
		ans *= comb[n-k+1][i];
		ans %= mod;
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 193920
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	int ans = 0;
	int socket = 1;

	while (!(socket >= b)) {
		socket--;
		socket += a;
		ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  
  string s;
  int k;
  cin >> s;
  cin >> k;

  for(int i=0; i<s.size(); i++){
    if(k == 0){
      break;
    }else if(i == s.size()-1){
      s[i] = 'a' + (((s[i] - 'a') + k) + 26) % 26;
      k = 0;
//      break;
    }else if(s[i] != 'a' && 26 - (s[i] - 'a') <= k){
      k -= (26 - (s[i] - 'a'));
      s[i] = 'a';
    }
  }

  cout << s << endl;

  return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  
  int ans = s.size();
  for (int i = 0; i <= s.size() - t.size(); i++) {
    int cnt = 0;
    
    for (int j = 0; j < t.size(); j++) {
      if (s.at(j + i) != t.at(j)) {
        cnt++;
      }
    }
    ans = min(ans, cnt);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
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();
		
		if(a > 2 * b) {
			System.out.println(a - 2*b);
		}
		else {
			System.out.println(0);
		}

	}

}


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

string S;
bool ok[200010] = {0};
vector<vector<int>> v(200010);
int N,M,visited[200010] = {0};

bool dfs(int n){
	visited[n] = 1;
	bool j = true;
	if(!ok[n]) j = false;
	for(int i=0;i<v[n].size();i++){
		if(visited[v[n][i]]==0 && ok[v[n][i]]) j = (j | dfs(v[n][i]));
	}
	return j;
}

int main(){
	cin  >> N >> M >> S;
	int a,b;
	int A[200010] = {0},B[200010] = {0};
	for(int i=0;i<M;i++){
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	queue<int> Q;
	int count = 0;
	for(int i=1;i<=N;i++){
		for(int j=0;j<v[i].size();j++){
			if(S[v[i][j]-1]=='A') A[i]++;
			if(S[v[i][j]-1]=='B') B[i]++;
		}
		if(A[i]==0 || B[i]==0){
			Q.push(i);
			visited[i] = 1;
			count++;
		}
		if(A&&B) ok[i] = true;
	}
	while(!Q.empty()){
		int t = Q.front();
		Q.pop();
		for(int i=0;i<v[t].size();i++){
			if(S[t-1]=='A') A[v[t][i]]--;
			if(S[t-1]=='B') B[v[t][i]]--;
			if((A[v[t][i]]==0 || B[v[t][i]]==0) && visited[v[t][i]]==0){
				Q.push(v[t][i]);
				count++;
				visited[v[t][i]] = 1;
			}
		}
	}
/*	bool judge = false;
	for(int i=1;i<=N;i++){
		if(visited[i]==0 && dfs(i)) judge = true;
	}
*/	cout << (count<N? "Yes":"No") << endl;
}

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

const ll BR = 200, AR = 201;
ll x;

ll X(ll a) {
	return a * a * a * a * a;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> x;
	for(ll b = -BR; b <= BR; ++b) {
		for(ll a = b; a <= AR; ++a) {
			if(X(a) - X(b) == x) {
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
	return 0;
}


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

class Pg
{
    static void Main()
    {
        var num = Console.ReadLine().Split().Select(double.Parse).ToArray();
        double x = num[2] - num[0];
        double y = num[3] - num[1];
        double ANSxANS = Math.Pow(x, 2) + Math.Pow(y, 2);
        Console.WriteLine(Math.Sqrt(ANSxANS));
    }
}


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

int main(void){
    int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
    long long min = 10e10;
    long long tmp=0;
    for(int i=0;i<=x+y;i++){tmp=2*c*i+a*max(0, x-i)+b*max(0, y-i);if(tmp<min)min=tmp;}
    cout<<min<<endl;
}

Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
using namespace std;
int main(){
    int n,m; cin>>n>>m;
    vector<long int> P(m),Y(m);
    vector<int> P_Y[100001];
    for(int i=0;i<m;i++){
        cin >> P[i] >> Y[i];
        P_Y[P[i]].push_back(Y[i]);   
    }

    for(int i=0;i<100001;i++){
        sort(P_Y[i].begin(),P_Y[i].end());
    }
    //cout << "hoge" <<endl;
    for(int i=0;i<m;i++){
        cout<< setfill('0') << right << setw(12)<<P[i]*1000000+upper_bound(P_Y[P[i]].begin(),P_Y[P[i]].end(),Y[i]) - P_Y[P[i]].begin() <<endl;
    }

    return 0;
}


Measured memory_bytes: 8576
N,M = map(int,input().split())
K = [[int(i) for i in input().split()][1:] for j in range(N)]
que = [0]*(M+1)
ans = 0

for i in K:
    for j in i:
        que[j] += 1
for i in que:
    if i == N:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define ld long double
typedef pair<ll,ll> pll;
typedef pair<pll,pll> ppll;
typedef vector <ll> vi;
#define out(x) return cout<<x,0;
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define lc(n) 2*n+1
#define rc(n) 2*n+2
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL)); 
const ll M = 1e9 + 7;

int main() {
    FAST;
    ll n, x = 0, y = 0, k, i, t, ans = 0, j, c = 0, z = 0, m;
    cin >> n >> k;
    ld a[n];
    ld p;
    for ( i = 0 ; i < n ; i ++ ){
    	cin >> p;
    	ld X = (p*(p + 1)) / 2;
    	a[i] = X / p;
    }
    ld sum = 0 , A;
    for ( i = 0; i < k ; i ++ ){
    	sum += a[i];
    }
    A = sum;
    for ( i = k ; i < n ; i ++ ){
    	sum += a[i] - a[i - k];
    	A = max( A , sum );
    }
    precision(A , 12);
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;

long long dp[100010][4];
string t = "ABC";

int main(){
    string s;
    cin >> s;
    int n = s.size();
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= 3; j++){
            if(s[i] != '?') dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
            else dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * 3) % mod;
            if(j < 3 && (s[i] == '?' || s[i] == t[j])) dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % mod;
        }
    }
    cout << dp[n][3] << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
using vi = vector<int>;
using vvi = vector<vi>;

using qvi = queue<vi>;
using vqv = vector<qvi>;

void bfs_step(vvi& g, vi& col, qvi& q)
{
    if(q.empty()) return;

    int cur = q.front()[1];

    while(!q.empty())
    {
        auto e = q.front();

        int k = e[0];
        int m = e[1];

        if(m != cur) return;

        q.pop();

        for(auto x : g[k]) if(!col[x])
        {
            q.push({x, m + 1});
            col[x] = col[k];
        }
    }
}
 
int main()
{
    ios_base::sync_with_stdio(0);
 
    int n; cin >> n;
 
    vvi g(n + 1);
 
    for(int i = 0; i < n; i++)
    {
        int a, b; cin >> a >> b;
 
        g[a].push_back(b);
        g[b].push_back(a);
    }
 
    vi col(n + 1);
 
    col[1] = 1;
    col[n] = 2;
 
    int move = 0;
    vqv q(2);

    q[0].push({1, 0});
    q[1].push({n, 0});

    for(; !q[0].empty() || !q[1].empty(); move = !move)
        bfs_step(g, col, q[move]);

    vi cnt(2);

    for(int i = 1; i <= n; i++) cnt[col[i] - 1]++;

    if(cnt[0] > cnt[1]) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
 
    return 0;
}

Measured memory_bytes: 7424
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, n, m, sx = 0, sy = 0, x, y;
  scanf("%lld%lld", &n, &m);
  for(i = 0; i < n; ++i) {
    scanf("%lld", &x);
    sx -= (n - 2 * i - 1) * x;
    sx %= 1000000007;
  }
  sx = (sx + 2000000014) % 1000000007;
  for(i = 0; i < m; ++i) {
    scanf("%lld", &y);
    sy -= (m - 2 * i - 1) * y;
    sy %= 1000000007;
  }
  sy = (sy + 2000000014) % 1000000007;
  printf("%lld", (sx * sy) % 1000000007);
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(vector<int>& X, vector<int>& D) {
        const int MOD = 998244353;

        int n = X.size();
        vector<pair<int,int>> P;
        for (int i = 0; i < n; ++i) {
            P.emplace_back(X[i], D[i]);
        }
        sort(P.begin(), P.end());

        vector<int> next(n, n);
        vector<int> que;
        for (int i = n - 1; i >= 0; --i) {
            int d = P[i].first + P[i].second;
            while (!que.empty()) {
                int x = que.back();
                int j = que.back();

                if (P[x].first < d) {
                    que.pop_back();
                } else {
                    break;
                }
            }
            if (que.empty()) {
                next[i] = n;
            } else {
                next[i] = que.back();
            }
            que.push_back(i);
        }
    

        vector<long long> dp(n + 2, 0);
        dp[0] = 1;

        for (int i = 0; i < n; ++i) {
            int j = next[i];
            dp[j] += dp[i];
            if (dp[j] >= MOD) {
                dp[j] -= MOD;
            }
            dp[i + 1] += dp[i];
            if (dp[i + 1] >= MOD) {
                dp[i + 1] -= MOD;
            }
        }

        return dp[n];
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> X(n);
    vector<int> D(n);
    for (int i = 0; i < n; ++i) {
        cin >> X[i] >> D[i];
    }
    Solution sol;
    cout << sol.solve(X, D) << "\n";

    return 0;
}

Measured memory_bytes: 6640
def solve(diagram)
  area = 0
  froms = []
  layers = []
  (0...diagram.size).each do |x|
    c = diagram[x]
    case c
    when '\\' then
      froms.push x
    when '/' then
      next if froms.empty?
      from = froms.pop
      area += 1
      area += x - from - 1
      layers << [from, x]
    end
  end
  return area, layers
end

diagram = STDIN.readline
area, layers = solve(diagram)

puts area

area = 0
areas = []
last = diagram.size
layers.reverse.each do |layer|
  if last < layer[0]
    areas[-1] += (layer[1] - layer[0])
  else
    areas << layer[1] - layer[0]
    last = layer[0]
  end
end
puts "#{areas.size} #{areas.reverse.join(' ')}".strip

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

int main(){
	while(1){
		long L[10], v1, v2, s=0;
		bool end=false;
		for(int i=0; i<10; ++i){
			if(scanf(" %ld,", &L[i])==EOF){
				end=true;
				break;
			}	
			s+=L[i];
		}
		if(end) break;
		scanf(" %ld,%ld", &v1, &v2);
		
		s*=v1+v2;
		for(int i=0; i<10; ++i) L[i]*=v1+v2;
		
		int ans=1;
		long now=0;
		long v1t=v1*s/(v1+v2);
		while(now<v1t){
			now+=L[ans-1];
			++ans;	
		}
		
		printf("%d\n", ans-1);
	}
}

Measured memory_bytes: 1188
N = int(input())
ans = 0
dictionary = {}
for i in range(N):
	s = input()
	sorted_s = "".join(sorted([char for char in s]))
	if not sorted_s in dictionary:
		dictionary[sorted_s] = 0
	ans += dictionary[sorted_s]
	dictionary[sorted_s] += 1
print(ans)


Measured memory_bytes: 69208
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
 
 
int main() {
    ios_base::sync_with_stdio(false);
 
    string s;
    cin >> s;
    string t;
    int flag=0;
    invrep(i,s.size()) {
        if (s[i]=='B') ++flag;
        else {
            if (flag==0) t.push_back(s[i]);
            else --flag;
        }
    }
    reverse(t.begin(),t.end());
    cout << t << endl;
 
    return 0;   
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    string s;cin>>s;
    int n = SIZE(s);

    string s_r = s;
    reverse(s_r.begin(),s_r.end());

    if(s_r != s){
        cout<<"No"<<endl;
        return;
    }

    string s2;
    FOR(i,0,(n-1)/2){
        s2 += s[i];
    }
    string s2_r = s2;
    reverse(s2_r.begin(),s2_r.end());

    if(s2_r != s2){
        cout<<"No"<<endl;
        return;
    }

    string s3;
    FOR(i,(n+3)/2-1,n){
        s3 += s[i];
    }
    string s3_r = s3;
    reverse(s3_r.begin(),s3_r.end());

    if(s3_r != s3){
        cout<<"No"<<endl;
        return;
    }

    cout << "Yes" << endl;
    




	return;
}

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

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

namespace ARC065C{
    public class Program{
        public static void Main(string[] args){
            var search = new[]{"dream", "dreamer", "erase", "eraser"};
            var S = Console.ReadLine();

            Func<string, int, bool> isOk = (s, x) =>{
                if(S.Length - x < s.Length) return false;
                var ret = true;
                for(var i = 0; i < s.Length; i++) ret &= S[i + x] == s[i];
                return ret;
            };

            Func<int, bool> dfs = null;
            dfs = x =>{
                if(x == S.Length) return true;
                var ret = false;
                foreach(var s in search) if(isOk(s, x)) ret |= dfs(x + s.Length);
                return ret;
            };

            Console.WriteLine(dfs(0) ? "YES" : "NO");
        }
    }
}

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

const int INF = 1 << 30;
const int dx[] = { 0, 0, 1, -1 };
const int dy[] = { 1, -1, 0, 0 };

int W, H;
int B[32][32];

int dfs(int x, int y, int times) {
  if(times == 10) return INF;

  int best = INF;

  for(int i = 0; i < 4; i++) {
    int j = 1;

    for(; ; j++) {
      int ny = y + dy[i] * j, nx = x + dx[i] * j;

      if(nx < 0 || W <= nx || ny < 0 || H <= ny) {
        break;
      }

      if(B[ny][nx] == 1) {
        if(j == 1) {
          break;
        }
        
        B[ny][nx] = 0;
        best = min(best, dfs(nx - dx[i], ny - dy[i], times + 1));
        B[ny][nx] = 1;
        break;
      }

      if(B[ny][nx] == 3) {
        return times + 1;
      }
    }
  }

  return best;
}

int main() {
  for(; cin >> W >> H && W; ) {
    int sx = -1, sy = -1;

    for(int y = 0; y < H; y++) {
      for(int x = 0; x < W; x++) {
        cin >> B[y][x];

        if(B[y][x] == 2) {
          sx = x;
          sy = y;
        }
      }
    }

    int res = dfs(sx, sy, 0);
    cout << (res == INF ? -1 : res) << endl;
  }
}

Measured memory_bytes: 2992
n=int(input())
a=list(map(int,input().split()))
q=int(input())
b=[0]*q
c=[0]*q
for i in range(q):
    b[i],c[i]=map(int,input().split())
N=[0]*(10**5)
s=0
for i in range(n):
    N[a[i]-1]+=1
    s+=a[i]
for i in range(q):
    s+=(c[i]-b[i])*N[b[i]-1]
    N[c[i]-1]+=N[b[i]-1]
    N[b[i]-1]=0
    print(s)

Measured memory_bytes: 85484
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const ll N = 1e6, inf = 1e9;

ll ar[N], br[N];
vector<ll>v, ans;
map<ll, ll>mp;
int main()
{
    ll n, k, s;
    cin>>n>>k>>s;
    for(int i = 0; i < k; i++) cout<<s<<" ";
    for(int i = k; i < n; i++)
    {
        if(s <= 100) cout<<s+1<<" ";
        else cout<<s-1<<" ";

    }
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main()
{
    int n, k, x, y;

    cin >> n >> k >> x >> y;

    int ans;  
    if (n <= k) {
        ans = n * x;
    } else {        
        ans = k * x;
        ans += (n - k) * y;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = input()
b = [int(t)-1 for t in raw_input().split()]
ans = []
for i in range(N):
  for j in range(len(b)-1, -1, -1):
    if b[j]==j:
      ans += [j]
      del b[j]
      break
  else:
    print -1
    exit(0)

for a in ans[::-1]:
  print a+1


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+10;
int main()
{
	long long n,k,q;
	cin >> n >> k >> q;
	long long a[maxn];
	for(int i = 1;i <= q;i ++){
		int x;
		cin >> x;
		a[x]++;
	}
/*	for(int i = 1;i <= q;i ++){
		cout << a[i];
	}cout << endl;*/
	for(int i = 1;i <= n;i ++){
		if( k-(q-a[i]) <= 0) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 2688
/*
[abc099] D - Good Grid
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 500;
const int MAX_C = 30;
const int K = 3;
const int INF = 1e9;

int N, C;
int d[MAX_C][MAX_C];
int c[MAX_N][MAX_N];
int pat[K];
bool used[MAX_C];
int cnt[K][MAX_C];

int calc() {
    int sum_d = 0;
    for (int k = 0; k < K; k++) {
        for (int i = 0; i < C; i++) {
            sum_d += d[i][pat[k]] * cnt[k][i];
        }
    }
    return sum_d;
}

int dfs(int k) {
    if (k >= K) {
        return calc();
    }

    int ans = INF;
    for (int i = 0; i < C; i++) {
        if (used[i]) {
            continue;
        }
        used[i] = true;
        pat[k] = i;
        ans = min(ans, dfs(k + 1));
        used[i] = false;
    }
    return ans;
}

int solve() {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cnt[(i + j) % K][c[i][j]]++;
        }
    }

    return dfs(0);
}

int main() {
    cin >> N >> C;
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            cin >> d[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> c[i][j];
            c[i][j]--;
        }
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	int N, D, X;
	int ans = 0;
	cin >> N >> D >> X;

	int a;
	for (int i = 0; i < N; i++)
	{
		cin >> a;

		for (int j = 1; j <= D; j += a)
		{
			ans++;
		}
	}

	cout << ans + X << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <vector>

using namespace std;
using namespace chrono;

#ifdef DEBUG
	//~ #define LOCAL_INPUT_FILE
#else
	//~ #define USE_FILE_IO
#endif

#ifdef USE_FILE_IO
	#define INPUT_FILE "input.txt"
	#define OUTPUT_FILE "output.txt"
	#define cin ____cin
	#define cout ____cout
	ifstream cin(INPUT_FILE);
	ofstream cout(OUTPUT_FILE);
#else
	#ifdef LOCAL_INPUT_FILE
		#define cin ____cin
		ifstream cin("input.txt");
	#endif
#endif

const int infinity = (int)1e9 + 42;
const int64_t llInfinity = (int64_t)1e18 + 256;
const int module = (int)1e9 + 7; 
const long double eps = 1e-8;

mt19937_64 randGen(system_clock().now().time_since_epoch().count());

inline void raiseError(string errorCode) {
	cerr << "Error : " << errorCode << endl;
	exit(42);
}

signed main() {
	#ifndef USE_FILE_IO
		ios_base::sync_with_stdio(false);
	#endif
	
	int n, m; cin >> n >> m;
	static int ssq[1024][1024] = {};
	for (int i = 0; i < (1 << n); ++i) {
		for (int j = 0; j < (1 << m); ++j) {
			ssq[i][j] = __builtin_popcount(i & j) & 1;
		}
	}
	
	for (int i = 1; i < (1 << n); ++i) {
		for (int j = 1; j < (1 << m); ++j) {
			cout << (ssq[i-1][j] ^ ssq[i-1][j-1] ^ ssq[i][j-1] ^ ssq[i][j]);
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 5376
n, m = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
dp = [100000] * (n + 1)
dp[0] = 0
for k in C:
    for j in range(k, n + 1):
        if dp[j] > dp[j - k] + 1:
            dp[j] = dp[j - k] + 1
print(dp[n])

Measured memory_bytes: 9572
program redistribution
  implicit none
  integer(8), parameter :: modu = 1000000007
  integer :: s
  integer(8) :: m(3, 3) = 0
  read(*,*) s
  if (s < 3) then
    write(*,'(i0)') 0
    stop
  end if
  m(1, 1) = 1
  m(2, 1) = 1
  m(3, 2) = 1
  m(1, 3) = 1
  m = modmatpow(m, s - 3)
  write(*,'(i0)') m(1, 1)
contains
  function modmatmul(x, y) result(res)
    integer(8), intent(in) :: x(3, 3), y(3, 3)
    integer(8) :: tmp, res(3, 3)
    integer :: i, j, k
    do j = 1, 3
      do i = 1, 3
        res(i, j) = 0
      end do
      do k = 1, 3
        tmp = y(k, j)
        do i = 1, 3
          res(i, j) = mod(res(i, j) + x(i, k) * tmp, modu)
        end do
      end do
    end do
  end
  function modmatpow(x, n) result(res)
    integer(8), intent(in) :: x(3, 3)
    integer, intent(in) :: n
    integer(8) :: res(3, 3), tmp(3, 3)
    integer :: m, i
    res = 0
    do i = 1, 3
      res(i, i) = 1
    end do
    tmp = x
    m = n
    do while (m > 0)
      if (btest(m, 0)) res = modmatmul(res, tmp)
      tmp = modmatmul(tmp, tmp)
      m = rshift(m, 1)
    end do
  end
end program redistribution

Measured memory_bytes: 2912
n = int(input())
inlis = list(map(int,input().split()))
donelis =[]
numlis=[]

for i in inlis:
    donelis.append(i+1)
    donelis.append(i)
    donelis.append(i-1)

estc =0
donelis.sort()
a = -2
count=0
for i in donelis:
    if a != i:
        if count > estc:
            estc = count
        count = 1
        a = i
    else:
        count +=1
if count >estc:
    estc =count
print(estc)

Measured memory_bytes: 17620
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

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

using namespace std;

int N,M,C;
int B[300];
int A[300];
int kotae;

int main(){
  kotae = 0;
  cin >> N >> M >> C;
  REP(i,M) cin >> B[i];
  REP(i,N){
    int k = 0;
    REP(j,M){
      cin >> A[j];
      k += A[j] * B[j];
    }
    if(k+C>0) kotae++;
  }
  cout << kotae << endl;
  return 0;
}



Measured memory_bytes: 256
Imports System

Module Program
    Sub Main(args As String())
        Dim N As Integer = Console.ReadLine()
        Dim tmpA As String() = Split(Console.ReadLine(), " ")


        Dim A(N) As Integer
        Dim i As Integer = 1
        For i = 1 To N
            A(i) = CInt(tmpA(i - 1))
        Next

        For i = 1 To N
            If A(i) Mod 2 = 0 Then
                If A(i) Mod 3 = 0 Or A(i) Mod 5 = 0 Then
                Else
                    Console.WriteLine("DENIED")
                    Exit Sub
                End If
            End If
        Next
        Console.WriteLine("APPROVED")
    End Sub
End Module


Measured memory_bytes: 13408
a,b,n=map(int,input().split())
def f(x):
    return int(a*x//b)-a*int(x//b)
if n<b:
    print(f(n))
elif n==b:
    print(f(n-1))
elif n>b:
    t = n
    u = n - (n%b+1)
    print(max(f(t),f(u)))

Measured memory_bytes: 79192
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    map<char,ll> mp;

    rep(i,s.size()){
        //cout << s[i] << endl;
        mp[s[i]]++;
    }


    ll ans = 0;

    ans = mp['R'] * mp['G'] * mp['B'];

    rep(i,n){
        char tmp = s[i];
        ll itr = i;
        ll left = i-1;
        ll right = i+1;

        while(true){
            if(left < 0){
                break;
            }
            if(right >= s.size()){
                break;
            }
            if(s[i] != s[left] && s[i] != s[right] && s[left] != s[right]){
                ans--;
            }
            left--;
            right++;
        }
    }

    cout << ans << endl;



}

Measured memory_bytes: 3632
YEN_1000 = 1000
YEN_5000 = 5000
YEN_10000 = 10000

inputs = gets.chomp.split(' ').map(&:to_i)
numbers = inputs[0]
amount = inputs[1]
ans_i, ans_j, ans_k = -1, -1, -1

(0..numbers).each do |i|
  (0..numbers - i).each do |j|
    k = numbers - i - j
    sum = i * YEN_10000 + j * YEN_5000 + k * YEN_1000
    if i + j + k == numbers && sum == amount
      ans_i, ans_j, ans_k = i, j, k
    end
  end
end

puts "#{ans_i} #{ans_j} #{ans_k}"


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

using namespace std;

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

    int n;

    cin >> n;

    long long ans = 0;

    for(int i=1; i<=n; i++){
        if(i%3 != 0 and i%5 !=0) ans+=i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################


class UnionFind:
    def __init__(self, N):
        self.rank = [0] * N
        self.parent = [i for i in range(N)]
        self.n = N
        self.size = [1 for i in range(N)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if (x == y):
            return

        if (self.rank[x] < self.rank[y]):
            self.parent[x] = y
            self.size[y] += self.size[x]
        else:
            self.parent[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def get_parents(self):
        count = 0
        for i in range(self.n):
            if self.find(i) == i:
                count += 1

        return count

    def get_size(self, x):
        root = self.find(x)
        return self.size[root]


N, M = map(int, input().split())
A = []
B = []
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    A.append(a)
    B.append(b)

uf = UnionFind(N)

ans = [0] * M
huben = (N*(N-1)) // 2

i = M-1
while i >= 0:
    ans[i] = huben

    if not uf.same(A[i], B[i]):
        huben -= uf.get_size(A[i]) * uf.get_size(B[i])
        uf.unite(A[i], B[i])

    i -= 1

print(*ans, sep="\n")


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

int main(){
    int x, y;
    cin >> x >> y;
    // i: tsuri, k: turtle
    rep(i, x+1){
        for (int j = 0; i+j <= x; j++){
            if (i+j == x && 2*i + 4*j == y){
                cout << "Yes" << endl;
                return 0;
            } 
        }
    }
    cout << "No" << endl;
}   


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
    int H, W;
    cin >> H >> W;
    
    string A[100];
    for (int i = 0; i < H + 2; i++) {
        if (i == 0 || i == H + 1) {
            A[i] = "";
            for (int a = 0; a < W; a++) {
                A[i] += '.';
            }
        } 
        else {
            cin >> A[i];
        }
        A[i] = "." + A[i] + ".";
    }
        
    for (int i = 0; i < H + 2; i++) {    
        for (int j = 0; j < W + 2; j++) {
            
            if (i != 0 && i != H + 1 && j != 0 && j != W + 1) {
                if (A[i].at(j) == '#') {
                    cout << '#';
                }
                else {
                    int count = 0;
                    for (int b = i - 1; b < i + 2; b++) {
                        for (int c = j - 1; c < j + 2; c++) {
                            if (A[b].at(c) == '#') {
                                count++;
                            }
                        }
                    }
                    cout << count;
                }
            }
        }
        if (i != 0 && i != H + 1)
        cout << endl;
    }    
}


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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main()
{
	int k;
	cin>>k;
	cout<<1ll*(k/2)*((k+1)/2)<<endl;
}

Measured memory_bytes: 256