akhauriyash/Code-Regression huggingface dataset:
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

int n;
int data[200005];
map<int,int> ada;

int main()
{
  scanf("%d",&n);
  int risan = 0;
  REP(i,n) 
  {
    scanf("%d",&data[i]);
    ++ada[data[i]];
  }
  FORD(i,30,0)
  {
    int tot = 1 << i;
    REP(i,n) if (ada.count(tot - data[i]))
    {
      int x = min(ada[data[i]],ada[tot-data[i]]);
      if (data[i] == tot - data[i]) x /= 2;
      risan += x;
      ada[data[i]] -= x;
      ada[tot-data[i]] -= x;
    }
  }
  printf("%d\n",risan);
  return 0;
}











Measured memory_bytes: 10368
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
auto f(pii a,pii b){return a.second < b.second;}
signed main(){
    int n,m; cin >> n >> m;
    vector<pii>v(m);
    erep(e,v) cin >> e.first >> e.second;
    sort(all(v),f);
    int ans = 0, maxi = 0;
    erep(e, v){
        if (e.first <= maxi){
        } else {
            ans++;
            cmax(maxi,e.second - 1);
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>

using namespace std;

int A,B,ans;
int data[4];

void solve(){
  for(int i = 1; i*i <= A; i++)
    if(A%i == 0)
      for(int j = 1; j*j <= B; j++)
	if(B%j == 0){
	  data[0] = i;
	  data[1] = A/i;
	  data[2] = j;
	  data[3] = B/j;
	  sort(data,data+4);


	  int sum = 0;
	  for(int i = 1; i < 4; i++)
	    sum += (data[i]-data[i-1])*(data[i]-data[i-1]);
	  
	  if(ans == -1) ans = sum; 
	  else ans = min(ans,sum);
	  
	}

  cout << ans << endl;
}

int main(){
  while(cin >> A >> B && A+B){
    ans = -1;
    solve();
  }

  return 0;
}

Measured memory_bytes: 1176
import java.io.*;
import java.util.ArrayList;
import java.util.LinkedList;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int n = Integer.parseInt(line[0]);
        int x = Integer.parseInt(line[1])-1;
        int y = Integer.parseInt(line[2])-1;
        ArrayList<Integer>[] arr = new ArrayList[n];
        arr[0] = new ArrayList<Integer>();
        for(int i = 0; i+1 < n; i++){
            arr[i+1] = new ArrayList<Integer>();
            arr[i].add(i+1);
            arr[i+1].add(i);
        }
        arr[x].add(y);
        arr[y].add(x);
        int ans[] = new int[n];
        for(int i = 0; i < n; i++){
            int dis[] = new int[n];
            LinkedList<Integer> l = new LinkedList<Integer>();
            l.add(i);
            while(!l.isEmpty()){
                int s = l.poll();
                ans[dis[s]]++;
                for(int b : arr[s]){
                    if(b == i || dis[b] > 0)    continue;
                    dis[b] = dis[s]+1;
                    l.add(b);
                }
            }
        }
        for(int i = 1; i < n; i++)  System.out.println(ans[i]/2);
    }
}


Measured memory_bytes: 53648
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
    	// Solution sol = new Solution();
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String s = br.readLine();
    	int N = s.length();
    	if(N%2==0)
    		System.out.println("No");
    	else if(checkPal(s)&&checkPal(s.substring(0,(N-1)/2))&&checkPal(s.substring((N+3)/2-1,N)))
    		System.out.println("Yes");
    	else
    		System.out.println("No");

    }

    public static boolean checkPal(String s){

    	for(int i=0; i<=s.length()/2; i++){
    		if(s.charAt(i)!=s.charAt(s.length()-1-i))
    			return false;
    	}
    	return true;
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const map<char, int> m = {{'U', 1}, {'D', 0}, {'L', 3}, {'R', 2}};

int h, w, n, sr, sc;
string s, t;
int bbox[4];

bool in(int x, int ub) {
  return x >= 0 && x < ub;
}
int clamp(int x, int l, int u) {
  return min(u-1, max(x, l));
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> h >> w >> n >> sr >> sc >> s >> t; sr--; sc--;
  bbox[0] = bbox[1] = sr;
  bbox[2] = bbox[3] = sc;
  for (int i = 0; i < n; i++) {
    int j = m.at(s[i]);
    bbox[j] += j & 1 ? -1 : 1;
    if (!in(bbox[j], j & 2 ? w : h)) {
      puts("NO");
      return 0;
    }
    j = m.at(t[i]);
    bbox[j ^ 1] += j & 1 ? -1 : 1;
    bbox[j ^ 1] = clamp(bbox[j ^ 1], 0, j & 2 ? w : h);
  }
  puts("YES");
  return 0;
}


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

int main() {
    int K;
    int A,B;
    cin >> K >> A >> B;

    bool flg = false;
    int i;
    for(int i=A; i<=B; i++){
        if(i%K == 0){
            flg = true;
            break;
        }
    }

    if(flg)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  
  char c;
  cin >> c;
  bool isUpper = 0;
  for(char i='A';i <= 'Z';i++){
    if(c == i){
      isUpper = 1;
    }
  }
  if (isUpper) cout << "A" << endl;
  else cout << "a" << endl;
}

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

class Main{
    public void run() throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        if(str.length() <= 3){
            System.out.println("No");
            return;
        }


        if(Objects.equals(str.substring(0, 4),"YAKI"))
            System.out.println("Yes");
        else
            System.out.println("No");
    }

    public static void main(String... args) throws Exception{
        new Main().run();
    }
}


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

int main () {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if ((A + B ) > ( C + D )) {
    cout << "Left" << endl;
  }
  else if (( A + B ) == ( C + D )) {
    cout << "Balanced" << endl;
  }
  
  else if (( A + B ) < (C + D)) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;


int n[100];
unsigned long long  DP[100][21];
int main(){
int N, s;

  cin >> N;

   for(int i = 0; i < N; i++){
	   cin >> n[i];
   }

   DP[0][n[0]] = 1;
   for(int i = 1; i < N-1; i++){
    for(int j = 0; j < 21; j++){
		if(DP[i-1][j] >= 1 && j+n[i] <= 20){
			DP[i][j+n[i]] += DP[i-1][j];
		}

		if(DP[i-1][j] >= 1 && j-n[i] >= 0){
			DP[i][j-n[i]] += DP[i-1][j];
		}
	}
   }

   cout << DP[N-2][n[N-1]] << endl;
	return 0;
}

Measured memory_bytes: 1172
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
static const int MAX_N = 300;

int N;
int num[3];
double memo[MAX_N + 1][MAX_N + 1][MAX_N + 1];

double rec(int a, int b, int c){
	if(a == 0 && b == 0 && c == 0) return 0.0;
	if(memo[a][b][c] > -1.0) return memo[a][b][c];
	double add = (double)N / (double)(a + b + c);
	double ret = 0.0;
	if(a > 0) ret += rec(a - 1, b, c) * (double)a / (double)(a + b + c);
	if(b > 0) ret += rec(a + 1, b - 1, c) * (double)b / (double)(a + b + c);
	if(c > 0) ret += rec(a, b + 1, c - 1) * (double)c / (double)(a + b + c);
	return memo[a][b][c] = ret + add;
}
int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
		a--;
		num[a]++;
	}
	fill(memo[0][0], memo[N + 1][0], -1.0);
	printf("%.10lf\n", rec(num[0], num[1], num[2]));
	return 0;
}


Measured memory_bytes: 213376
// B - 1 Dimensional World's Tale
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N,M,X,Y; cin>>N>>M>>X>>Y;
	int maxX = X, minY = Y, a;
	rp(i, 0, N){ cin>>a; maxX = max(maxX, a); }
	rp(i, 0, M){ cin>>a; minY = min(minY, a); }
	puts(maxX < minY? "No War":"War");
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int main() {
    int N;cin >> N;
    vector<int> retu(N-1);
    for(int i = 0;i<N-1;i++) cin >> retu.at(i);
    vector<int> ans(N,0);
    for(int i = 0;i<N-1;i++){
        ans.at(retu.at(i)-1)++;
    }

    for(int i = 0;i<N;i++)cout << ans.at(i) << endl;

    // PLEASE GIVE ME THE "ACCEPTED" !
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
int64_t a, b, x;
 
cin >> a >> b >> x;

int64_t count = 0;

if (a == 0) {
    count = b / x + 1;    
} else {
    count = (b / x) - ((a - 1) / x);
}
 
cout << count << endl;
 
return 0;
}

Measured memory_bytes: 3604
sx, sy, tx, ty = map(int, input().split(" "))

x_d = tx - sx
y_d = ty - sy

print("R"*x_d + "U"*y_d + "L"*x_d + "D"*(y_d + 1) + "R"*(x_d + 1) +
     "U"*(y_d + 1) + "L" + "U" + "L"*(x_d + 1) + "D"*(y_d + 1) + "R")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    int N, K;
    cin >> N >> K;
    cout << N-K+1 << endl;
    return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr int zeller(int y, int m, const int &d) {
  if (m == 1 || m == 2) y--, m += 12;
  int k = y % 100, j = y / 100;
  return (d + 13 * (m + 1) / 5 + k + k / 4 + j / 4 + 5 * j + 6) % 7;
}

void solve() {
  int m, d;
  string t[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
  while (cin >> m >> d, m) cout << t[zeller(2004, m, d)] << endl;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int test_cases = 1;
        Solver s = new Solver();
        for (int i = 1; i <= test_cases; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }
}

class Solver {
    void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
        String s = in.next();
        for (int i = 0; i < s.length() - 8; i++) {
            out.print(s.charAt(i));
        }
    }
}


class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException  e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    ll n,k,inf;
    inf=1000000000+7;
    cin>>n>>k;
    vector<ll> a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    ll ans=0;
    for(ll i=0;i<n;i++){
          for(ll j=i+1;j<n;j++){
            if(a[i]<a[j])ans+=((k*(k-1))/2)%inf;
           else if(a[i]>a[j])ans+=((k*(k+1))/2)%inf;
    	}
    }
    cout<<ans%inf<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <string>

using namespace std;
#define MAX_N 2000
#define DIV 998244353
typedef long long ll;
int N;
string str;
int arr[MAX_N*2+10][2];
ll dp[MAX_N*2+10][MAX_N*2+10];
ll ans;

int main(){
	cin>>str;
	N = str.size();
	for(int i=1; i<=N; i++){
		arr[i][0]+=arr[i-1][0]; arr[i][1] += arr[i-1][1];	
		if(str[i-1]=='0'){
			arr[i][0]+=2;
		}else if(str[i-1]=='1'){
			arr[i][0]++; arr[i][1]++;
		}else{
			arr[i][1]+=2;
		}
	}
	dp[0][0] = 1;
	for(int i=1; i<=N*2; i++){
		for(int j=0; j<=N*2; j++){
			if(i<=N){
				if(arr[i][0] < j || arr[i][1] < i-j)	continue;
				dp[i][j] = (dp[i-1][j] + (j==0?0:dp[i-1][j-1]))%DIV;
				
			}else{
				if(arr[N][0]<j || arr[N][1] < i-j)	continue;
				dp[i][j] = (dp[i-1][j] + (j==0?0:dp[i-1][j-1]))%DIV;
			}
			//cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
		}
	}
	for(int i=0; i<=N*2; i++){
		ans+=dp[N*2][i];
		ans = ans%DIV;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 123520
#include"iostream"
#include"algorithm"
using namespace std;

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	int a[110];
	int p = 0;
	for (int i = 0; i < m; i++)
	{
		cin >> a[i];
		if (a[i] < x)p++;
	}
	cout << min({ p,m - p }) << endl;
}

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

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] counts = br.readLine().split(" ");
            int catsCount = Integer.parseInt(counts[0]);
            int catsOrDogsCount = Integer.parseInt(counts[1]);
            int hopeCatsCount = Integer.parseInt(counts[2]);

            String isCatsCountPossible = "NO";
            if (catsCount == hopeCatsCount) {
                isCatsCountPossible = "YES";
            } else if (catsCount < hopeCatsCount && hopeCatsCount - catsCount <= catsOrDogsCount) {
                isCatsCountPossible = "YES";
            }
            System.out.println(isCatsCountPossible);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21076
#set
n = gets.chomp.to_i
s = gets.chomp.split("")

#main
(0 .. n - 2).each do |i|
    if s[n - 1 - i] == s[n - 2 -i] then 
        s.delete_at(n - 1 -i)
    end
end
print ("#{s.join.length}\n")

Measured memory_bytes: 7036
N, M = [int(x) for x in input().split()]

obj = {}
ii = 0
jj = 0

for i in range(M):
    p = [x for x in input().split()]
    key = p[0]
    res = p[1]
    if key not in obj:
        obj[key] = {'AC': 0, 'WA': 0}
    if res == 'WA' and obj[key]['AC'] == 0:
        obj[key]['WA'] = obj[key]['WA'] + 1
    if res == 'AC':
        obj[key]['AC'] = 1

for k in obj:
    ii = ii + obj[k]['AC']
    if obj[k]['AC'] > 0:
        jj = jj + obj[k]['WA']


print(ii, jj)

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

int main()
{
    ll h;
    cin >> h;
    ll ans = 1;
    ll flag = 0;
    while (h > 0)
    {
        h = h / 2;
        flag++;
    }
    for (int i = 0; i < flag; i++)
    {
        ans = ans * 2;
    }
    cout << ans - 1 << endl;
    return 0;
}

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

#define MOD_1_000_000_007 (1000000007LL)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  static const ll MAX = 10LL;
  ll N;
  ll ps[MAX], qs[MAX];

  void init() {
    scanf("%d", &N);
    rep(i, N) scanf("%d", &ps[i]);
    rep(i, N) scanf("%d", &qs[i]);
  }

  void solve() {
    vector<int> v;
    rep(i, N) v.push_back(i+1);
    int pi = -1, qi = -1, ci = 0;
    do {
      ci++;
      bool pm = true, qm = true;
      rep(i, N) {
        if(ps[i] != v[i]) pm = false;
        if(qs[i] != v[i]) qm = false;
      }
      if(pm) pi = ci;
      if(qm) qi = ci;
    } while(next_permutation(v.begin(), v.end()));
    printf("%d\n", abs(pi - qi));
  }
}


int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll n;
  cin >> n;
  vll a(n);
  rep(i, n) cin >> a[i];
  ll ans = INF;
  rep2(i, -100, 101) {
    ll t = 0;
    rep(j, n) {
      t += (i - a[j]) * (i - a[j]);
    }
    ans = min(ans, t);
  }
  ANS;

  return 0;
}

Measured memory_bytes: 3616
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val g = Array(n) {ArrayList<Pair<Int,Int>>()}
    repeat(n - 1){
        val (u,v,w) = readLine()!!.split(" ").map{it.toInt()}
        g[u - 1].add(Pair(v - 1, w))
        g[v - 1].add(Pair(u - 1, w))
    }
    var a = IntArray(n)
    var b = BooleanArray(n)
    a[0] = 1
    b[0] = true
    var que = ArrayDeque<Int>()
    que.addLast(0)
    while(que.isNotEmpty()){
        val cur = que.getFirst()
        que.pollFirst()
        for(i in 0 until g[cur].size){
            if(b[g[cur][i].first]) continue
            if(g[cur][i].second % 2 == 0){
                a[g[cur][i].first] = a[cur]
                que.addLast(g[cur][i].first)
                b[g[cur][i].first] = true
            }
            else{
                a[g[cur][i].first] = (a[cur] xor 1)
                que.addLast(g[cur][i].first)
                b[g[cur][i].first] = true
            }
        }
    }
    for(i in 0 until n){
        println(a[i])
    }
}



Measured memory_bytes: 97616
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

def warshall_floyd(d):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j]=min(d[i][j],d[i][k]+d[k][j])
    return d
h,w=MI()
d=[LI() for i in range(10)]
d=warshall_floyd(d)
lis=[LI() for i in range(h)]
ans=0
for i in range(h):
    for j in range(w):
        if lis[i][j]>=0:
            ans+=d[lis[i][j]][1]
print(ans)

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

struct node
{
    int index;     // index number.
    int parent;    // who is parent(if nobody, -1).
    int depth;     // the depth of node.
    int degree;    // how many child he has.
    int* child;    // who are the children(if nobody, NULL).
};

int main()
{
    node* N;
    int i, n, j, d, p;
    cin >> n;

    N = new node [n];
    if(N == NULL) return 0;

    // initialize.
    for(i = 0; i < n; i++){ N[i].parent = -1; N[i].depth = -1; }

	while(cin >> i){
        N[i].index = i;
        cin >> d;
        N[i].degree = d;
        if(d == 0){
            N[i].child = NULL;
        }else{
            N[i].child = new int [d];
            if(N[i].child == NULL){ delete [] N; return 0; }
            for(j = 0; j < d; j++){
                cin >> p;
                N[i].child[j] = p;   // node i's the 'j'th child is p.
                N[p].parent = i;     // parent of p is i.
            }
        }
    };

    for(i = 0; i < n; i++){
        p = N[i].parent;
        if(p < 0){
            N[i].depth = 0;
        }else if(N[p].depth >= 0){
            N[i].depth = N[p].depth + 1;  // if already determined, easy.
        }else{
            while(1){
                N[i].depth += 1;
                if(p < 0) break;
                p = N[p].parent;
            };
        }
    }

    for(i = 0; i < n; i++){
        cout << "node " << N[i].index << ": parent = ";
        p = N[i].parent;
        cout << p << ", depth = " << N[i].depth << ", ";
        if(p < 0){
            cout << "root";
        }else if(N[i].degree == 0){
            cout << "leaf";
        }else{
           cout << "internal node";
        }
        cout << ", [";
            d = N[i].degree;
            if(d > 0){
                cout << N[i].child[0];
                for(j = 1; j < d; j++) cout << ", " << N[i].child[j];
            }
        cout << "]" << endl;
    }

    for(i = 0; i < n; i++) delete [] N[i].child;
    delete [] N;

    return 0;
}

Measured memory_bytes: 3908
import sys

input = sys.stdin.readline
print = sys.stdout.write

a = int(input())

trains = []
for i in range(a-1):
    trains.append([int(i) for i in input().split()])

for start in range(a):
    time = 0
    for i in range(start,a-1):
        if i == 0:
            time += trains[i][1] + trains[i][0]
        else:
            if time < trains[i][1]:
                time = trains[i][1]
            elif time % trains[i][2] > 0:
                time += trains[i][2] - (time % trains[i][2])
            time += trains[i][0]
    print(str(time)+"\n")

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

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

    vector<long long> H(N);
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }

    bool ans = true;
    for (int i = H.size()-1; i > 0; --i) {
        if (H[i-1] <= H[i]) continue;
        else {
            H[i-1] -= 1;
            if (H[i-1] == H[i]) continue;
            ans = false;
        }
    }

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

Measured memory_bytes: 1024
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] + l[j] > l[k] and l[i] != l[j] and l[j] != l[k]:
                ans += 1
print(ans)

Measured memory_bytes: 9192
v = [100000 for i in range(100001)]
v[0] = 0
C = [1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
for i in range(1,100001):
    for j in C:
        if j > i: break
        v[i] = min(v[i],v[i-j]+1)
print(v[int(input())])

Measured memory_bytes: 3956
// Example program
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < b; i++)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const int INF = ~(1<<31);



int main() {
   int n;
cin >> n;
cout << 48-n << endl;
}


Measured memory_bytes: 256
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000

int n;
long a[MAXN];

int input() {
	if (scanf("%d", &n) < 0) return 0;
	for (int i=0; i<n; i++) scanf("%ld", &a[i]);
	return 1;
}

void init() {
}

int sig(long x) {
	return x>0? 1: x<0? -1: 0;
}

long solve() {
	long r = LONG_MAX;
	for (int k=-1; k<=1; k+=2) {
		int p = k;
		long x = 0, s = 0;
		for (int i=0; i<n; i++) {
			s += a[i];
			if (sig(s) != sig(p)) {
				x += abs(p-s);
				s = p;
			}
			p = -p;
		}
		r = min(r, x);
	}
	return r;
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





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

int main(){
	string s;
	int k;

	cin>>k>>s;

	if(s.size()<=k){
		cout<<s<<endl;
	}
	else{
		string front_s=s.substr(0,k);
		cout<<front_s<<"..."<<endl;
	}


	return 0;
}

Measured memory_bytes: 3628
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
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

K = INT()
A = LIST()

def f(N):
	left = N
	for a in A:
		left = left//a*a
	return left

l_N_max = 0
r_N_max = K*max(A)+2
while l_N_max+1 < r_N_max:
	m = (l_N_max+r_N_max)//2
	if f(m) <= 2:
		l_N_max = m
	else:
		r_N_max = m

N_max = l_N_max

l_N_min = 0
r_N_min = K*max(A)+2
while l_N_min+1 < r_N_min:
	m = (l_N_min+r_N_min)//2
	if f(m) < 2:
		l_N_min = m
	else:
		r_N_min = m
N_min = r_N_min

if N_min > N_max:
	print(-1)
else:
	print(N_min, N_max)


Measured memory_bytes: 21480
using System;

class main{
  public static void Main(string[] args){
    int passers = 0;
    int forPassers = 0;
    string[] s = Console.ReadLine().Split(" ");
    int a = int.Parse(s[1]);
    int b = int.Parse(s[2]);
    int limit = a + b;
    string parts = Console.ReadLine();
    
    for(int i = 0; i < parts.Length; i++){
      if(parts[i] == 'a' && passers < limit){
        Console.WriteLine("Yes");
        passers++;
      }
      else if(parts[i] == 'b' && passers < limit && forPassers < b){
        Console.WriteLine("Yes");
        passers++;
        forPassers++;
      }
      else Console.WriteLine("No");
    }
  }
}

Measured memory_bytes: 27692
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
string a,b,str="OI";
int dp[5005][5005][2];
int main(){
  cin>>n>>m>>a>>b;
  a+='$',b+='$';  
  for(int i=n;i>=0;i--){
    for(int j=m;j>=0;j--){
      for(int k=0;k<2;k++){
        dp[i][j][k]=0;
        if(a[i]==str[k])dp[i][j][k]=max(dp[i][j][k],dp[i+1][j][1-k]+1);
        if(b[j]==str[k])dp[i][j][k]=max(dp[i][j][k],dp[i][j+1][1-k]+1);
      }
      dp[i][j][0]/=2;
      dp[i][j][0]*=2;
      ans=max(ans,dp[i][j][1]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 80076
#include <bits/stdc++.h>
#define ll long long int
#define mod 998244353 
#define pb push_back
//#define mp make_pair
#define eps 1e-9
#define pp pair < pair<ll,ll> , ll> 
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define foll(i,j,k) for(ll i=j;i<=k;i++)
#define clr(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vll vector<ll>
#define sz(a) a.size()
#define len(a) a.length()
#define all(a) a.begin(),a.end()
#define io_file freopen("Contest/input_file.in", "r", stdin); freopen("Contest/output_file.in", "w", stdout)


const int MAXN = 2e5+5;
using namespace std;
ll power(ll x, ll y)
{
  ll res = 1;
  while(y>0)
  {
    if(y&1)
       {
         res = (res*x)%mod;
        }
     x = (x*x)%mod;
     y = y>>1;
  }
    return res;
}
// std::vector<ll> divi[100004];
// void divisor(int n)
// {
//    for(ll i=1;i<=n;i++)
//    {
//      for(ll j=i;j<=n;j+=i)
//      {
//        divi[j].pb(i);
//      }
//    }
// }

ll a[105];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,x;
    cin>>n>>x;
    ll t = 0;
    for(int i=1;i<=n;i++)
    {
      cin>>a[i];
      t = t+a[i];
    }
    if(t==x){
      cout<<n<<endl;
      return 0;
    }
    if(t < x)
    {
      cout<<n-1<<endl;
      return 0;
    }

    sort(a+1,a+n+1);
    ll sum = 0;
    int cnt = 0;
    for(int i=1;i<=n;i++)
    {
      if(sum + a[i] <=x)
      {
        cnt++;
        sum = sum + a[i];
      }
    }

    cout<<cnt<<endl;
    
    return 0;

}



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

using ll = long long int;
using P = pair<ll,int>;

struct BIT{
    int N = 0;
    vector<ll> bit;
    void init(int n){
        N = 1;
        while(N<=n) N<<=1;
        bit.resize(N+1);
    }
    void add(int i, ll x){
        while(i<=N){
            bit[i] += x;
            i += i&-i;
        }
    }
    ll sum(int i){
        ll res = 0;
        while(i>0){
            res += bit[i];
            i -= i&-i;
        }
        return res;
    }
};

int main(){
    ll N, K;
    cin >> N >> K;
    vector<P> a(N+1);
    for(int i=0;i<N;i++){
        cin >> a[i+1].first;
        a[i+1].first -= K;
        a[i+1].second = (i+2);
    }
    a[0].second = 1;
    for(int i=0;i<N;i++){
        a[i+1].first += a[i].first;
    }
    sort(a.begin(), a.end());
    BIT bit;
    bit.init(N+1);
    ll ans = 0;
    for(int i=0;i<=N;i++){
        int idx = abs(a[i].second);
        ans += bit.sum(idx);
        bit.add(idx, 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5504
#include<stdio.h>

int main(){
	int s = 0;
	scanf("%d",&s);
	if( s == 25 ) {
		printf("Christmas\n");
	} else if( s == 24 ) {
		printf("Christmas Eve\n");
	} else if( s == 23 ) {
		printf("Christmas Eve Eve\n");
	} else if( s == 22 ) {
		printf("Christmas Eve Eve Eve\n");
	}
}


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

int main(){
	int x, h;
	double s, a;
	while(true){
		cin>>x>>h;
		if(x==0 && h==0)break;
		a = (x*x)/(double)4 + h*h; 
		a= sqrt(a);
		s = a*x*2;
		s += x*x;
		printf("%.6f\n", s);
	}
	return 0;
}

Measured memory_bytes: 1192
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
    read_value!($iter, usize) -1
};

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        X: i32,
        Y: i32,
    }
    let mut money:i32 = 0;
    for rank in [X, Y].iter() {
        if (*rank <= 3) {
            money += (4-*rank)*100000;
        }
    }
    if X==1 && Y==1 {
        money += 400000;
    }
    println!("{}",money )
}


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

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

  int sum = 0;
  for (int i = 0; i < 2; i++) {
    if (a > b) {
      sum += a--;
    } else {
      sum += b--;
    }
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a,b = LI()
    p = LI()
    c = len([k for k in p if k <= a])
    d = len([k for k in p if k > a and k <= b])
    e = len([k for k in p if k > b])

    return min([c,d,e])



print(main())




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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 1e9;
const LL LLINF = 1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

struct problem
{
    int score;
    int num;
    int comp;

    problem(int s, int n, int c)
    : score(s), num(n), comp(c) {};

    int solveAll() { return num * score + comp; };
};

void solve()
{
    int D, G; cin >> D >> G;
    vector<problem> P; P.reserve(D);
    REP1(i, G)
    {
        int p, c; cin >> p >> c;
        problem prob(100*i, p, c);
        P.push_back(prob);
    }
    int ptns = (1 << D);
    int result = INTINF;

    REP0(bit, ptns)
    {
        int score = 0;
        int trial = 0;
        int remain_i = 0;
        REP0(i, D)
        { // bit で示された問題パタンを完全に解く
            if (bit & (1 << i)) 
            { 
                score += P[i].solveAll();
                trial += P[i].num;
            }
            else remain_i = i;
        }

        if (score + (P[remain_i].num - 1) * P[remain_i].score < G) continue;
        else 
        {
            while (score < G)
            {
                score += P[remain_i].score;
                trial++;
            }
        }

        result = min(result, trial);
    }
    cout << result << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 247388
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: usize, w: usize,
        a: [chars; h],
    }
    let mut h_v = vec![false; h];
    let mut w_v = vec![false; w];

    for i in 0..h {
        for j in 0..w {
            if a[i][j] == '#' {
                h_v[i] = true;
                w_v[j] = true;
            }
        }
    }

    for i in 0..h {
        let mut p_flag = false;
        for j in 0..w {
            if h_v[i] && w_v[j] {
                p_flag = true;
                print!("{}", a[i][j]);
            }
        }
        if p_flag {
            println!("");
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
    using namespace std;
    
    int main()
    {
    	//#ifndef ONLINE_JUDGE
    		//freopen("input.txt","r",stdin);
    		//freopen("output.txt","w",stdout);
    	//#endif
    		ios_base::sync_with_stdio(0);
    		cin.tie(0);
    	   int a,b,c,i,j,sum=0;
           cin>>a;
           int art[a];
           for(i=0;i<a-1;i++){
            cin>>art[i];
           }
           sum=art[0]+art[a-2];

           for(i=0;i<a-2;i++){
            sum+=min(art[i],art[i+1]);
            
           }
     cout<<sum;
    } 

Measured memory_bytes: 256
S = input()

not_agct = "BDEFHIJKLMNOPQRSUVWXYZ"

head = 0
tail = 0
length = len(S)

candi = []

for head in range(length):
    for tail in range(length,head,-1):
        candi.append(S[head:tail])        

#candi_sort = sorted(candi)

ans = 0
for txt in candi:
    for judge in txt:
        if judge in not_agct:
            break
    else:
        if ans < len(txt):
            ans = len(txt) 

print(ans)

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

const int INF = 1e9+5;

int main() {

    int n;
    scanf("%d", &n);

    vector<int> h(n);
    for (int& x: h)
        scanf("%d", &x);

    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i=0; i<n; i++) {
        for (int j: {i+1, i+2}) {
            if (j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//#include <map> #include <algorithm> #include <vector> #include <string.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <chrono> #include <thread> #include <iomanip>
using namespace std;

#define endl "\n"
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define re(i,a) for(int i=0; i<a; ++i)
#define tr(i,v) for(auto &i: v)
#define mem(a,val) memset(a,val,sizeof(a))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define in(v,n) vi v(n);re(i,n) cin>>v[i]
#define printVec(v,s) cout << s; tr(i, v) cout << i << " ";
#define sz(a) int((a).size())
#define dbgv(c, v) cout << c << " = " << v << endl;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef vector< pii > vii;
typedef vector< ll > vll;
typedef complex<double> point;

const long long MOD = 1000000007;
const long long inf = 1e18;

void solve(){
	
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif 
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    int n, k;
    cin>>n>>k;

    vb vis(n + 1, false );

    re(i, k){
        int d; cin>>d;
        re(j, d){
            int a; cin>>a;
            vis[a]=1;
        }
    }

    int cnt=0;

    rep(i,1,n+1){
        if(!vis[i]) cnt++;
    }

    cout << cnt;
    return 0;
}


Measured memory_bytes: 3644