akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < n;i++)
typedef long long ll;
using namespace std;

int main() {
  int a; int b;
  cin >> a >> b;
  if ((a == 1 && b == 2) || (a == 2 && b == 1)) cout << 3 << endl;
  else if ((a == 2 && b == 3) || (a == 3 && b == 2)) cout << 1 << endl;
  else if ((a == 3 && b == 1) || (a == 1 && b == 3)) cout << 2 << endl;
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();
		int n = s.length;

		StringBuilder ret = new StringBuilder();
		for (int i = 0; i < n; i += 2) {
			ret.append(s[i]);
		}

		pr.println(ret);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 25612
import sys
input = sys.stdin.buffer.readline

def main():
    K,T = map(int,input().split())
    a = list(map(int,input().split()))
    
    between = max(a)-1
    use = sum(a)-max(a)

    print(max(0,between-use))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("text1.in","r",stdin);
	//freopen("text1.out","w",stdout);
	ll a,b,n;
	cin>>a>>b>>n;
	ll maxn=0;
	maxn=max((a*(min(b-1,n)))/b,maxn);
	cout<<maxn<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll INFll = 1e18;
#define put(n) cout<<(n)<<endl
#define Cout(n) cout<<(n)
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define MP make_pair
#define pb(q) push_back(q)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


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

    int N;
    int i;
    cin>>N>>i;
    put(N-i+1);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  string s, t;
  cin >> s >> t;
  int len = t.size();
  int n = s.size();
  int mincnt = 100000000;
  REP(i,n - len +1){
    int cnt = 0;
    REP2(j,i,i+len){
      if(s[j] != t[j-i]) cnt++;
    }
    mincnt = min(cnt,mincnt);
  }

  cout << mincnt << endl;
  return 0;
}

Measured memory_bytes: 3632
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    map<string,ll> mp;
    ll reg = 0;
    rep(i,n){
        string s;
        cin>>s;
        ll t;
        cin >> t;
        reg += t;
        mp[s] = reg;
    }
    string s;
    cin >> s;
    cout << reg - mp[s] << endl;
}


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

int main(){
	string s,s1,s2;
	int m1,m2,i,fl=1;
	cin>>s;
	m1=(s.length()-1)/2-1;
	m2=(s.length()-1)/2+1;
	s1=s.substr(0,m1+1);
	s2=s.substr(m2,m1+1);


	
	if(s.length()>3) {
			for(i=0;i<=s1.length()/2-1;i++) {
		if(s1[i]!=s1[s1.length()-1-i]) {
			fl=0;
			break;
		}
	}	for(i=0;i<=s2.length()/2-1;i++) {
		if(s2[i]!=s2[s2.length()-1-i]) {
			fl=0;
			break;
		}
	}
	}
	
	

	
	if(s1!=s2) fl=0;

	if(fl==1) cout<<"Yes";
	else cout<<"No";
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m, q, sum[502][502], sum1[502][502];
struct node{
    int x, y;
}a[200002];
int main()
{
    scanf("%d %d %d", &n, &m, &q);
    for(int i = 1; i <= m; i++){
        scanf("%d %d", &a[i].x, &a[i].y);
    }
    for(int i = 1; i <= m; i++){
        sum[a[i].x][a[i].y]++; 
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            sum1[i][j] = sum1[i][j-1] + sum[i][j];
        }
    }
    for(int i = 1; i <= q; i++){
        int x, y;
        int res = 0;
        scanf("%d %d", &x, &y);
        for(int j = x; j <= y ; j++){
            res += sum1[j][y];
        }
        printf("%d\n", res);
    }
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define P std::pair<int,int>
#define double long double
#define prique priority_queue<int,vector<int>,greater<int>>
#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define moder 100000
typedef long long ll;
using namespace std;
signed main() {
	int a,b;
	cin>>a>>b;
	cout<<a+b/2<<endl;
	return 0;
}

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

using namespace std;

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

const ll INF=1e15;

int main(){
    double x;
    cin >> x;
    double d=100;
    ll ans=0;
    while(x>d){
        d*=1.01;
        ll y=(ll)(floor(d));
        d=(double)y;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3864
n, k = gets.split.map(&:to_i)
pp = gets.split.map{|e| (e.to_f + 1) / 2}

max = pp[0..k-1].inject(:+)
x = max
(n-k).times do |i|
    x += pp[i+k] - pp[i]
    max = x if max < x
end

puts max


Measured memory_bytes: 14980
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
const static ll MOD = 1e9 + 7;
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

int main() {
	int N, M; cin >> N >> M;
	int cnt = 0; double sum = 0;
	vi A(N);
	for (int& elem : A) {
		cin >> elem;
		sum += elem;
	}

	for (int i = 0; i < N; i++) {
		if (A[i] >= sum / (4 * static_cast<double>(M))) {
			cnt++;
		}
	}

	if (cnt >= M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define fi first
#define se second
#define pb(i) push_back(i)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mes(a,b) memset(a,b,sizeof(a))
#define sbs(i,j) substr(i,j)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 2e3+10;
const int INF = 0x3f3f3f3f;
const int inf = - INF;
const int mod = 1e9+7;
const double pi = acos(-1.0);
int ans[N];
int main(){
    int n,x,y;
    cin>>n>>x>>y;
    rep(i,1,n){
        rep(j,i+1,n){
            int dist =abs(i-j);
            dist=min(dist,min(abs(i-y)+abs(j-x),abs(i-x)+abs(j-y)+1));
            ans[dist]++;
        }
    }
    rep(i,1,n-1)
        cout<<ans[i]<<endl;
    getchar();
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

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

int main() {

	int a, b;

	scanf("%d%d", &a, &b);

	int n = 0;
	rep(i, b - a) n += i;

	printf("%d\n", n - a);

	return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> p(n);
    int a, b;
    
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }
    sort(p.begin(), p.end());
    
    priority_queue<int> q;
    int ind = 0;
    int ans = 0;
    
    for (int i = 1; i < m+1; i++) {
        while (p[ind].first <= i && ind < n) {
            q.push(p[ind].second);
            ind += 1;
        }
        if (!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1660
/*
    Only way to go is UP 
    H1s3nb3rg's Here !!
*/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h> 
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<int,int> pi;
typedef uint64_t i64;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<vector<ll>> v2ll;
const int MOD = 1e9+7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAIN int main(){FAST_IO;ll tc;cin>>tc;while(tc--){solver();}ret0;}
#define MAIN1 int main(){FAST_IO;solver();ret0;}
#define rep(i,b,e) for(__typeof(e)i=(b)-((b)>(e));i!=(e)-((b)>(e));i+=1-2*((b)>(e)))
#define repa(i,x)  for(auto i:x)
#define vin(x) for(auto &i:x){cin>>i;}
#define vin1(x) for(ll i=1;i<x.size();i++){cin>>x[i];}
#define dbg(x) for(auto i:x){cout<<i<<" ";}cout<<ENDL;
#define dbg2(x) for(auto &i:x){for(auto j:i){cout<<j<<" ";}cout<<endl;}
#define dbgp(x) for(auto i:x){cout<<i.ff<<" "<<i.ss<<endl;}
#define ENDL "\n"
#define VALL(a) a.begin(),a.end()
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define MP(a,b) make_pair(a,b)
#define ff first
#define ss second
#define ret0 return 0;
#define ret return;
#define pb(x) push_back(x)
/*----------------------------*/


void solver(){
    string s,t;
    cin>>s>>t;
    ll mm=LLONG_MAX;
    for(ll i=0;i<s.length()-t.length()+1;i++){
        ll err=0;
        for(ll j=0;j<t.length();j++){
            if(t[j]!=s[i+j])
                err++;
        }
      //  cout<<err<<" ";
        mm=min(err,mm);
    }
    cout<<mm<<endl;
    ret;
}

MAIN1


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <climits>
#include <cmath>
#include <algorithm>

#define TEST_ASSERT(msg, cond) do { if (cond) { cout << msg << " => pass" << endl;} else { cout << msg << " => failed" << endl;} } while(0)

using namespace std;

int main() {

  int n, m;
  cin >> n;
  cin >> m;

  double elapsedTime = (n - m) * 100 + m * 1900;
  //cout << "elapsedTime = " << elapsedTime << endl;
  double succeed = std::pow(0.5, static_cast<double>(m));
  double failed = 1.0 - succeed;

  double lastExpectation = 0.0;
  double expectation = 0.0;
  for (int i = 1; ; ++i) {
	  double probability = succeed * std::pow(failed, static_cast<double>(i - 1));
	  //cout << "probability = " << probability << endl;
	  expectation += probability * elapsedTime * static_cast<double>(i);
	  //cout << expectation << endl;
	  if (static_cast<int>(lastExpectation * 100) == static_cast<int>(expectation * 100)) {
		  break;
	  }
	  lastExpectation = expectation;
  }

  cout << static_cast<int>(expectation + 0.5) << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
template <class T>
bool chmax(T &a, const T &b){if (a < b){a = b;return 1;}return 0;}
template <class T>bool chmin(T &a, const T &b){if (b < a){a = b;return 1;}return 0;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


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

  string s;
  cin >> s;
  rep(i,s.length()){
    if(s[i]=='7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

int main() {
    string s,t="Yes";
    cin >> s;
    for(int i=0; i<s.size(); i++) {
        if(i%2==0 && s.at(i)=='L') {
            t="No";
            break;
        }
        if(i%2==1 && s.at(i)=='R') {
            t="No";
            break;
        }
    }
    cout << t << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let a: Vec<i32> = (0..n).map(|_| read()).collect();

    let ans = a.iter().map(|x| x.trailing_zeros()).min().unwrap();

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)
#define MP make_pair
typedef long long LL;
#define EPS (1e-6)
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef pair<int,int> P;


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);
  int INF = 1000000;

  map<string,int> data;
  string str;
  while(cin >> str){
    data[str]++;
  }

  map<string,int>::iterator freq=data.begin();
  map<string,int>::iterator len=data.begin();

  for(map<string,int>::iterator it=data.begin(); it!=data.end(); ++it){
    if( (*freq).second < (*it).second )
      freq = it;
    if( (*len).first.length() < (*it).first.length() )
      len = it;
  }

  cout << (*freq).first << " " << (*len).first << endl;

  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline void LB(vector<T>& v, T& a) { return *lower_bound(ALL(v),a); }
template <typename T> inline void LBP(vector<T>& v, T& a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline void UB(vector<T>& v, T& a) { return *upper_bound(ALL(v),a); }
template <typename T> inline void UBP(vector<T>& v, T& a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) os << v[i] << " \n"[i+1==v.size()]; return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N;
  cin >> N;
  vector<int> C(N);
  cin >> C;
  vector<int> v;
  REP(i,N) if (v.empty() || C[i] != v.back()) v.push_back(C[i]);
  N = v.size();
  vector<int> dp(N+1,0),cum(200010,0);
  dp[0] = 1;
  REP(i,N) {
    dp[i+1] = (dp[i] + cum[v[i]]) % MOD;
    (cum[v[i]] += dp[i]) %= MOD;
  }
  cout << dp[N] << endl;

  return 0;
}

Measured memory_bytes: 6640
#include<stdio.h>
int main()
{
    long long int i,j=0,h,n,s=0;
    scanf("%lld%lld", &h,&n);
    long long int a[n+5];
    for(i=0;i<n;i++)
    {
        scanf("%lld", &a[i]);
    }
    for(i=0;i<n;i++)
    {
        s=s+a[i];
        if(s>=h)
        {
            j=1;
            break;
        }
    }
    if(j==1)
        printf("Yes\n");
    else
        printf("No\n");
}


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



int main()
{
    int h, w;
    cin >> h >> w;
    char a[h][w];
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> a[i][j];
        }
    }

    ll mod = 1000000007;
    int dp[h][w];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    for (int  i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (a[i][j] == '#')
            {
                continue;
            }
            if (i == 0 && j == 0)
            {
                continue;
            }
            if (i == 0)
            {
                dp[i][j] = dp[i][j - 1];
            }
            else if (j == 0)
            {
                dp[i][j] = dp[i - 1][j];
            }
            else
            {
                dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]) % mod;
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
    return 0;
}

Measured memory_bytes: 8516
s = str(input())

ans = "AC"

if s[0] != "A":
    ans = "WA"

if 3 <= s.find('C')+1 <= len(s)-1:
    pass
else:
    ans = "WA"

# C が無いときはこっちで弾ける
if s.find('C') != s.rfind('C'):
    ans = "WA"


index_c = s.find('C')
tmp = s.replace("A", "a")

lower_cases = tmp.replace("C", "c")
if lower_cases != s.lower():
    ans = "WA"




print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using ll  = long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? 1e9:1e18)
using namespace std;
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using pii = pair<int,int>;
using piii = pair<int,pii>;

int bit [1000] = {},n;
int sum(int i){
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add (int i,int x){
    while (i <= n) {
        bit[i] += x;
        i += i & -i;
    }
}
signed main(){
    int m,q; cin >> n >> m >> q;
    vector<piii>v( m + q);
    rep(i,m+q) {
        int a,b; cin >> a >> b;
        piii temp;
        temp.first = a, temp.second.first = b;
        temp.second.second = i;
        v[i] = temp;
    }
    sort (all(v),[](auto const x,auto const y) {
        return (
                x.second.first < y.second.first  or
                (x.second.first == y.second.first and x.second.second < y.second.second)
                );
    });
    int ans[100000] = {};
    erep(e,v){
        int left = e.first;
        int right = e.second.first;
        bool isQuery = e.second.second >= m;
        int index = e.second.second - m;
        if (isQuery){
            ans[index] =  sum(right) - sum (left - 1);
        } else {
            add(left, 1);
        }
    }
    rep(i,q) cout << ans[i] << endl;
}





Measured memory_bytes: 4864
#include <iostream>
#include <cstdio>
#include <cstring>
const int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,-1},{1,-1},{-1,1}};
using namespace std;

int main()
{
    int n,m;
    char ch[55][55];
    int b[55][55];
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        memset(b,0,sizeof(b));
        for (int i=0;i<n;i++) scanf("%s",ch[i]);
        for (int i=0;i<n;i++)
            for (int j=0;j<m;j++)
            if (ch[i][j]=='#') b[i][j]=-1;
        for (int i=0;i<n;i++)
            for (int j=0;j<m;j++)
            {
                if (b[i][j]==-1)
                  {
                      for (int k=0;k<8;k++)
                        if (i+dir[k][0]>=0&&i+dir[k][0]<n&&j+dir[k][1]>=0&&j+dir[k][1]<m)
                        if (b[i+dir[k][0]][j+dir[k][1]]!=-1) b[i+dir[k][0]][j+dir[k][1]]++;
                  }
            }
        for (int i=0;i<n;i++)
            {for (int j=0;j<m;j++)
                if (b[i][j]==-1) printf("#");
                else printf("%d",b[i][j]);
                printf("\n");
            }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n; cin >>n;
  vector<char>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  bool p=false;
  bool w=false;
  bool g=false;
  bool y=false;
  for(int i=0;i<n;i++){
    if(a[i]=='P')p=true;
    if(a[i]=='W')w=true;
    if(a[i]=='Y')y=true;
    if(a[i]=='G')g=true;
  }
  if(p+w+y+g==4)cout<<"Four"<<endl;
  if(p+w+y+g==3)cout<<"Three"<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		 Scanner scan = new Scanner(System.in);
	     String str = scan.nextLine();
	     String[] chars = str.split(" ");
	     long N= Long.valueOf(chars[0]);
	     long M;
	     long rootN = (int)Math.sqrt(N);
	     for(long i=rootN;i>0;i--) {
	    	 if(N%i==0) {
	    		M = N/i;
	    			System.out.println(i+M-2);
	    			return;
	    	 }
	     }
	}

}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int N;
    ll sum = 0;
    cin >> N;
    vector<ll> A(N);
    vector<ll> X(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum += A[i];
    }
    for(int i = 1; i < N - 1; i+=2)sum -= 2 * A[i];
    X[0] = sum;
    for(int i = 1; i < N; i++) X[i] = 2 * A[i - 1] - X[i - 1];
    for(int i = 0; i < N; i++) cout << X[i] << ' ';
}

Measured memory_bytes: 2944
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <iterator>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long LL;
const int maxn = 2020000;
const LL INF = 100000000000000LL;
const LL mod = 1e9 + 9;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define For(i,a,b) for(int i=a;i<=b;++i)

char s[maxn];
int pre[maxn] = {0};
int suf[maxn] = {0};

void solve() {
	int n;
	cin >> n;
	cin >> s + 1;
	for(int i = 1;i <= n;i++) {
		pre[i] += pre[i - 1];
		suf[i] += suf[i - 1];
		if(s[i] == 'E') pre[i] += 1;
		else suf[i] += 1;
	}
	int ans = n + 1;
	for(int i = 1;i <= n;i++) {
		int temp = suf[i - 1] + pre[n] - pre[i];
		ans = min(ans, temp);
	}
	cout << ans << endl;
}

int main() {
	int t = 1;
	while(t--) {
		solve();
	}
	int mark_EOF;
	if(scanf("%d", &mark_EOF) == EOF) return 0;
    return 0;
}

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

int main(){
	int Hit , Blow ;
	char a[4],b[4];
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
		Hit = 0;
		Blow = 0;
		for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                if (a[i] == b[j]) {
                    if (i == j) Hit++;
                    else Blow++;
                }
            }
        }

		cout << Hit << " " << Blow << "\n";
	}

}

Measured memory_bytes: 1140
#include <iostream>
#include <vector>

using namespace std;

class DisjointSet {
 public:
  vector<int> rank, p;

  DisjointSet() {}
  DisjointSet(int size) {
    rank.resize(size, 0);
    p.resize(size, 0);
    for (int i = 0; i < size; ++i) {
      makeSet(i);
    }
  }

  void makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
  }

  bool same(int x, int y) {
    return findSet(x) == findSet(y);
  }

  void unite(int x, int y) {
    link(findSet(x), findSet(y));
  }

  void link(int x, int y) {
    if (rank[x] > rank[y]) {
      p[y] = x;
    } else {
      p[x] = y;
      if (rank[x] == rank[y]) {
        rank[y]++;
      }
    }
  }

  int findSet(int x) {
    if (x != p[x]) {
      p[x] = findSet(p[x]);
    }
    return p[x];
  }
};


int main() {
  int n, a, b, q;
  int t;

  cin >> n >> q;
  DisjointSet ds = DisjointSet(n);

  for (int i = 0; i < q; i++) {
    cin >> t >> a >> b;
    switch(t) {
    case 0:
      ds.unite(a, b);
      break;
    case 1:
      if(ds.same(a, b)) {
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3208
import math
n=int(input())
sqn=int(math.sqrt(n))
p=[1]*int(2*sqn+20)
p[0]=0;p[1]=0
for i in range(2,sqn):
    if p[i]:
        for j in range(2,sqn//i+1):
            p[i*j]=0

p=[i for i in range(sqn+7) if p[i]]
f={}
for pi in p:
    if n%pi==0:
        cnt=1
        n//=pi
        while n%pi==0:
            cnt+=1
            n//=pi
        f[pi]=cnt
    
#print(f)
if n>1:
    f[n]=1
ans=0
for k in f:
    tmp=1
    while (tmp+1)*(tmp+2)//2<=f[k]:
        tmp+=1
    ans+=tmp
    #print(ans,tmp,k,f[k])
print(ans)
    
    
    
        

Measured memory_bytes: 27836
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int K = s.nextInt();
        int N=s.nextInt();
        int [] arr = new int[N];
        for(int i=0;i<N;i++)
            arr[i]=s.nextInt();
        int [] arrCost = new int[N];
        for(int i=0;i<N-1;i++){
            arrCost[i]=arr[i+1]-arr[i];
        }
         arrCost[N-1]=K+arr[0]-arr[N-1];
        int max=Integer.MIN_VALUE;
        int totalCost=0;
        for(int i=0;i<N;i++){
            if(arrCost[i]>=max)
                max=arrCost[i];
            totalCost+=arrCost[i];
        }
        System.out.println(totalCost-max);
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            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: 47824
//dile a la jardinera que traigo flores
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(0);cin.tie(0)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define For(i,a,b) for(int i = int(a); i < int(b); i++)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int N=2e5+100;
ll n,mm[N],sum[N];

ll uwu(int l,int r){
	ll ans=sum[r];
	if(l)ans-=sum[l-1];
	//trace(l);
	//trace(r);
	//trace(ans);
	return ans;
}

ll go(int l,int m,int r){
	//cout<<"in go"<<endl;
	//cout<<"L "<<l<<" M "<<m<<" R "<<r<<endl;
	return abs(uwu(l,m)-uwu(m+1,r-1));
}

ii eval(int ini,int fin){//es en intervalo semiabiuerto
	ll dif=LLONG_MAX;
	//cout<<"start eval function"<<endl;
	//trace(ini);
	//trace(fin);
	int L=ini,R=fin-2;
	while(R-L>7){
		int mid1=L+(R-L)/3;
		int mid2=R-(R-L)/3;
		if(go(ini,mid1,fin)<=go(ini,mid2,fin))R=mid2;
		else L=mid1;
	}
	//trace(L);
	//trace(R);
	ii ans;
	For(i,L,R+1){
		//trace(i);
		ll val=go(ini,i,fin);
		//trace(val);
		if(val>dif)continue;
		dif=val;
		ll bloq1=uwu(ini,i);
		ll bloq2=uwu(i+1,fin-1);
		ans={max(bloq1,bloq2),min(bloq1,bloq2)};
	}
	return ans;
}

int main(){
	scanf("%lld",&n);
	For(i,0,n)scanf("%lld",&mm[i]);
	sum[0]=mm[0];
	For(i,1,n)sum[i]=sum[i-1]+mm[i];
	ll ans=LLONG_MAX;
	For(i,2,n-1){
		ii par1=eval(0,i);
		ii par2=eval(i,n);
		//cout<<"estando en "<<i<<endl;
		//cout<<par1.ff<<" "<<par1.ss<<endl;
		//cout<<par2.ff<<" "<<par2.ss<<endl;
		ll mx=max(par1.ff,par2.ff);
		ll mn=min(par1.ss,par2.ss);
		ans=min(ans,mx-mn);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> isPair;
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
#define Pll pair<ll,ll>
#define vpll vector<pll>
#define sll set<ll>
#define mll map<ll,ll>

const ll inf=(ll)1e18;
const ll maxs = (ll)100+5;
const ll mod = (ll)1e9+7;
const ll oo = (ll) 1e18;

#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define LB lower_bound
#define UB upper_bound
#define line cout<<endl;
#define fr(i,a,b) for(int i=a;i<=b;++i)
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mst(x,a) memset(x,a,sizeof(x))

const ll MAX=1e4+4;
const ll M = 1e2+5;
string s;
ll d,n;
ll dp[MAX][M][2];

ll go(ll pos,ll sum,ll isFree)
{
    if(pos==n)
        return sum==0;
    if(dp[pos][sum][isFree]!=-1)
        return dp[pos][sum][isFree];
    ll ans=0;
    for(ll i=0;i<10;i++)
    {
        if(isFree)
        {
            ans = ( ans + go(pos+1,(sum+i)%d,1) )%mod ;
        }
        else
        {
            if(i < s[pos]-'0')
                ans = ( ans + go(pos+1,(sum+i)%d,1) )%mod;
            if(i==s[pos]-'0')
                ans = ( ans + go(pos+1,(sum+i)%d,0) )%mod;
        }
    }
    return dp[pos][sum][isFree] = ans;
}

void solve()
{
    n=s.size();
    memset(dp,-1,sizeof dp);
    cout<<(go(0,0,0)-1+mod)%mod;
}

int main() {
    fastio();
	cin>>s>>d;
	solve();
	return 0;
}

Measured memory_bytes: 17536
#include <iostream>
#include <vector>
 
using namespace std;
 
int main(){
    unsigned long long n,atl=2,ans=0;
    
    cin >> n;
 
    for(unsigned long long i=0;i<n;i++){
        unsigned long long t;
        cin >> t;
        if(i==0){
            ans=t-1;
        }else if(atl==t){
            atl++;
        }else if(atl<t){
            ans+=(t/atl);
            if(t%atl==0){
                ans--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, K);
    IN(ll, A);
    IN(ll, B);
    YES(A <= K * (B / K), "OK", "NG");
}

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

int main(){
  long int n,a[200001],b[200000]={0};
  cin >> n;
  for(long int i=0; i<n-1; i++){
    cin >> a[i];
    b[a[i]-1] ++;
  }
  
  for(long int i=0; i<n; i++){
    cout << b[i] << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 6744
N,M = map(int,input().split())
if N == 1 or M == 1 :
    if max(N,M) >= 2 :
        print(max(N,M)-2)
    else :
        print(1)
elif N == 2 or M == 2 :
    print(0)
else :
    print((N-2)*(M-2))
    

Measured memory_bytes: 3060
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int x;
    cin >> x;
    int ans = 1;
    for (int i = 2; i <= 1000; ++i) {
        int num = i * i;
        while(1) {
            if (num > x) break;
            ans = max(ans, num);
            num = num * i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
module main;
import std.stdio;
import std.string;

void main()
{
  string s;
  while((s = chomp(readln())).length)
  {
    char s2[] = new char[s.length];
    for(auto i = 0; i < 26; i++)
    {
      for(auto j = 0; j < s.length; j++)
      {
        s2[j] = s[j];
        if(!(s[j] == ' ' || s[j] == '\n' || s[j] == '.'))
          s2[j] = 'a' + ((s[j] - 'a') + i) % 26;
      }

      if(s2.indexOf("the") != -1 || s2.indexOf("this") != -1 || s2.indexOf("that") != -1)
      {
        writef("%s\n", s2);
        break;
      }
    }
  }
}

Measured memory_bytes: 1084
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        Set<Integer> set1 = new HashSet<>();
        Set<Integer> set2 = new HashSet<>();
        Set<Integer> set3 = new HashSet<>();
        set1.add(1);
        set1.add(3);
        set1.add(5);
        set1.add(7);
        set1.add(8);
        set1.add(10);
        set1.add(12);

        set2.add(4);
        set2.add(6);
        set2.add(9);
        set2.add(11);


        set3.add(2);
        if(set1.contains(x) && set1.contains(y)){
            System.out.println("Yes");
            return;
        }
        if(set2.contains(x) && set2.contains(y)){
            System.out.println("Yes");
            return;
        }
        if(set3.contains(x) && set3.contains(y)){
            System.out.println("Yes");
            return;
        }
            System.out.println("No");
    }
}


Measured memory_bytes: 21588
#include <iostream>
#include <sstream>

using namespace std;

int main(){
	string result[3]={"HIT", "HOMERUN" , "OUT"};
	string eventlist;
	int inning,run;
	int count = 0;
	int score;
	while(cin >> inning){
		for(int i=0;i<inning;i++){
			run = 0; score = 0;
			for(count=0;count < 3;){
				cin >> eventlist;
//				cout << eventlist << endl;
				if(eventlist == result[0]){
					score += (run/4);
					run = (2 * run + 1) % 8;
//					cout << run << "H" << score << endl;
				}
				else if(eventlist == result[1]){
					for(int j = 0;j < 3;j++){
						score += run % 2;
						run = run /2;
					}
					run = 0;
					score++;
//					cout << " " << score << endl;
				}
				else{
					count++;
//					cout << "o" << count << endl;
				}
			}
			cout << score << endl;
		}
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner  sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m =  sc.nextInt();
		
		if( n == m ) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

struct modint {
    static const int MOD = 998244353;

    ll v;
    modint(const int _v = 0): v(_v % MOD) {
        if (v < 0) v += MOD;
    }

    bool operator==(const modint& other) const {
        return v == other.v;
    }

    modint& operator+=(const modint& other) {
        v += other.v;
        if (v >= MOD)
            v -= MOD;
        return *this;
    }

    modint& operator-=(const modint& other) {
        v -= other.v;
        if (v < 0)
            v += MOD;
        return *this;
    }

    modint& operator*=(const modint& other) {
        v = 1LL * v * other.v % MOD;
        return *this;
    }

    modint& operator/=(const modint& other) {
        *this *= other.inv();
        return *this;
    }

    modint operator+(const modint& other) const {
        return modint(v) += other;
    }

    modint operator-(const modint& other) const {
        return modint(v) -= other;
    }

    modint operator*(const modint& other) const {
        return modint(v) *= other;
    }

    modint operator/(const modint& other) const {
        return modint(v) /= other;
    }

    static modint pow(modint b, ll e) {
        modint res = 1;
        for (ll p = 1; p <= e; p <<= 1) {
            if (p & e)
                res *= b;
            b *= b;
        }

        return res;
    }

    modint pow(ll e) const {
        return pow(*this, e);
    }

    modint inv() const {
        return pow(MOD - 2);
    }

    friend ostream& operator<<(ostream& os, modint m) {
        return os << m.v;
    }
};

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

    int n;
    cin >> n;

    modint ans = modint::pow(3, n);
    modint cur = 0;
    modint term = 1;
    modint p = 2;
    // n choose k * 2^k for k in range()
    for (int k = n; k > n / 2; --k) {
        cur += term * p;
        // going from n!/k!(n-k)! to n!/(k-1)!(n-k+1)!
        // multiply by k/(n-k+1)
        term /= (n - k + 1);
        term *= k;
        p += p;
    }

    cout << ans - cur << '\n';
 
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  int _0 = 0,_1 = 0;
  for(int n = 0;n < S.size();n++){
    if(S[n] == '0')_0++;
    else _1++;
  }
  cout << 2*min(_1,_0) << endl;
  return 0;
}

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

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


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

    int n;
    cin >> n;
    vector <ll> monster(n + 1);
    vector <ll> saver(n);
    ll          hunt = 0;
    rep(i, n + 1) {
        cin >> monster.at(i);
    }
    rep(i, n) {
        cin >> saver.at(i);
    }
    rep(i, n) {
        ll buf;
        if (saver.at(i) - monster.at(i) >= 0) {
            hunt += monster.at(i);
            buf   = saver.at(i) - monster.at(i);
            if (monster.at(i + 1) - buf >= 0) {
                hunt             += buf;
                monster.at(i + 1) = monster.at(i + 1) - buf;
            } else {
                hunt += monster.at(i + 1);
                monster.at(i + 1) = 0;
            }
        } else {
            hunt += saver.at(i);
        }
    }
    cout << hunt << endl;



    return 0;
}


Measured memory_bytes: 1792
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,M = imn()
ans = 0
if N > 1: ans += comb_count(N,2)
if M > 1: ans += comb_count(M,2)
print(ans)

Measured memory_bytes: 5556
import math
N = int(input())

sqrt_N = int(math.sqrt(N))
min_F = float('inf')

for i in range(1,sqrt_N + 1):
    if N % i == 0:
        A = i
        B = N // i
        if min_F > max(len(str(A)),len(str(B))):
            min_F = max(len(str(A)),len(str(B)))

print(min_F)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> S(1 << N);
    for(int i = 0; i < 1 << N; ++i) cin >> S[i];
    sort(S.rbegin(), S.rend());
    
    int prev_val = S[0];
    S[0] = 0;
    multiset<int> st;
    for(int i = 1; i < 1 << N; ++i){
        if(S[i] == prev_val)    S[i] = S[i - 1];
        else{
            prev_val = S[i];
            S[i] = S[i - 1] + 1;
        }
        st.insert(S[i]);
    }
    
    vector<int> vs(1, 0);
    for(int k = 0; k < N; ++k){
        vector<int> que;
        for(int v : vs){
            auto it = st.upper_bound(v);
            if(it == st.end()){
                cout << "No\n";
                return 0;
            }
            que.push_back(*it);
            st.erase(it);
        }
        for(int v : que)    vs.emplace_back(v);
    }
    cout << "Yes\n";
}

Measured memory_bytes: 16676
#include<bits/stdc++.h>
#define lli long long int
#define FILE_IN freopen("input.txt", "r", stdin);
#define FILE_OUT freopen("output.txt", "w", stdout);
#define PI acos(-1)
using namespace std;
void fastio()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);
  cout. tie(0);

}
int main() {
 fastio();
  int f,t,x,y;
    set<int>s;
 set<int>::iterator it1,it2;
    cin>>t;
    while(t--) {
        cin>>f>>x;
        if(f==0) {
            s.insert(x);
            cout<<s.size()<<endl;
        }
        else if(f==1)
            cout<<s.count(x)<<endl;

       else if(f==2)
          s.erase(x);

       else{
          cin>>y;

         it1=s.lower_bound(x);
         it2=s.upper_bound(y);
         for(;it1 != it2;it1++)
          cout<<*it1<<endl;
       }

}
    return 0;
}


Measured memory_bytes: 12512