akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int h, w, k, g, f, t, d, e;
char s[400][400];
int x[400][400];
int main() {
	scanf("%d%d%d", &h, &w, &k);
	for (int i = 0; i < h; i++) {
		scanf(" %s", s[i]);
	}
	for (int i = 0; i < h; i++) {
		g = 1;
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				g = 0;
			}
		}
		if (g == 0) {
			d = i;
			break;
		}
	}
	for (int i = d; i < h; i++) {
		g = 1;
		e = 0;
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				g = 0;
				e++;
			}
		}
		if (g) {
			for (int j = 0; j < w; j++) {
				x[i][j] = x[i - 1][j];
			}
		}
		else {
			for (int j = 0; j < w; j++) {
				if (e && (j == 0 || s[i][j - 1] == '#')) {
					t++;
					x[i][j] = t;
					e--;
				}
				else x[i][j] = x[i][j - 1];
			}
		}
	}
	for (int i = d - 1; i >= 0; i--) {
		for (int j = 0; j < w; j++) {
			x[i][j] = x[i + 1][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w - 1; j++) {
			printf("%d ", x[i][j]);
		}
		printf("%d\n", x[i][w - 1]);
	}
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
//#define int long long 
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	int n;
	cin>>n;
	vi vec(n);
	cin>>vec;
	set<int> st(all(vec));
//	rep(i,0,n) st.insert(vec[i]);
	if((st.size())==n) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
 
 
 
 
 
 
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<string> v(m);
	REP(i, m)cin >> v[i];
	vi E(n + 1, 0), W(n + 1, 0);
	REP(i, m) {
		REP(j, n) {
			if (v[i][j] == 'E')E[j+1]++;
			else W[j]++;
		}
	}
	REP(i, n) {
		E[i + 1] += E[i];
	}
	RREP(i, n) {
		W[i] += W[i + 1];
	}
	int ans, cmin = INF;
	REP(i, n + 1) {
		if (cmin > abs(E[i] + W[i])) {
			ans = i;
			cmin = abs(E[i] + W[i]);
		}
	}
	cout << ans <<" "<<ans+1<< endl;
	return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> C(N);
  for(int i = 0; i < K; ++i){
    int d;
    cin >> d;
    for(int j = 0; j < d; ++j){
      int a;
      cin >> a;
      --a;
      ++C[a];
    }
  }
  int ans = count(C.begin(), C.end(), 0);
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  std::string s;
  std::cin >> s;

  ll ans = 0;
  int w = 0;
  rep(i,s.size()) {
    if(s[i] == 'W'){
      ans += i - w;
      w++;
    }
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef double ld;
#define X first
#define Y second
#define mk make_pair
#define pb push_back
#define Rep(i, n) for(int i = 0; i < int(n); i ++)
#define Rep1(i, n) for(int i = 1; i <= int(n); i ++)
#define all(x) (x).begin(), (x).end()
const int MOD = (int) 1e9 + 7;
const ll base =  31;
void MAIN();
int main(){
    //freopen("input.txt", "r", stdin);
    ios:: sync_with_stdio(false); cin.tie(0);
    MAIN();
    return 0;
}
////////////////////////////////////////////////////////////////////////

const int N = 5004;

int n, m, h[N];
vector <ii> V[N];

void MAIN(){
    cin >> n >> m;
    while(m --){
        int a, b, x;
        cin >> a >> b >> x;
        V[a + x].pb(ii(b, x+1));
    }
    int ans = 0;
    for(int i = n; i >= 1; i --){
        Rep(j, V[i].size()) h[V[i][j].X] = max(h[V[i][j].X], V[i][j].Y);
        for(int j = 1; j <= i; j ++){
            h[j] = max(h[j], max(0, h[j-1] - 1));
            if(h[j]) ans ++;
        }
        for(int j = 1; j <= i; j ++) h[j] --;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7604
#include <stdio.h>
#include <math.h>

int main(){
	int n,a[110]={0};
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=n-1;i>=0;i--){
		printf("%d",a[i]);
		if(i!=0) printf(" ");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1028
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.*;
/**
 *
 * @author arvin
 */
public class Main {
    
    static int n,a[][];
    static long dp[][];
    
    static long rec(int x,int y)
    {
        if(x==n)
            return 0l;
        long ch,ab;
        if(dp[x+1][(y+1)%3]==0)
            ch=rec(x+1,(y+1)%3);
        else
            ch=dp[x+1][(y+1)%3];
        if(dp[x+1][(y+2)%3]==0)
            ab=rec(x+1,(y+2)%3);
        else
            ab=dp[x+1][(y+2)%3];
        dp[x][y]=a[x][y]+Math.max(ab,ch);
        return dp[x][y];
    }
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        a=new int[n+5][4];
        dp=new long[n+5][4];
        for(int i=0;i<n;i++)
        {
            a[i][0]=sc.nextInt();
            a[i][1]=sc.nextInt();
            a[i][2]=sc.nextInt();
        }
        System.out.println(Math.max(rec(0,0),Math.max(rec(0,1),rec(0,2))));
        sc.close();
    }
}


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

#define debug(x) cout << '[' << #x << " is: " << x << "] " <<"\n";
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;

using namespace std;
int n,m;

map<int,map<int,int>> maxx;
char mat[25][25];
map<pair<int,int>, bool> visited;
map<pair<int,int>, int> levels;

int xd[4] = {-1,1,0,0};
int yd[4] = {0,0,-1,1};



void getmax(int xx, int yy){


    queue<pair<int,int>> q;
    q.push({xx,yy});
    maxx[xx][yy] = 0;
    visited[{xx,yy}] = true;

    while(q.size()){
        pair<int,int> p = q.front();
        q.pop();
        int x = p.first;
        int y = p.second;
        for (int i = 0 ; i < 4 ; i++){
            int xnow = x + xd[i];
            int ynow = y + yd[i];
            if ((xnow >= n)||(xnow < 0)||(ynow >= m)||(ynow < 0)||(mat[xnow][ynow] == '#')||(visited[{xnow,ynow}]))continue ;
            visited[{xnow,ynow}] = true;
            maxx[xnow][ynow] = maxx[x][y] + 1;
            q.push({xnow,ynow});
        }

    }



}





int main()
{
	FAST;
/*
    char a;
    cin >> a;
    cout << char(a + 1) <<endl;


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

    double sum = 0;
    for(int i = 0 ; i < n-1 ; i++){
        int in;
        cin >> in;
        sum+=in;
    }

    for (int i  = 0 ; i <= k ; i++){
        double ans = (sum + i)/n;
        if (ans >= m){cout << i <<endl;return 0;}
    }

    cout << -1 <<endl;




    int n,m;
    cin >> n >> m;
    map<int,int> sub;
    map<int,bool> accpted;

    int accptedd = 0;
    int p = 0;

    for (int i = 0 ; i < m ; i++){
        int pro;
        string res;
        cin >> pro >> res;
        if (accpted[pro])continue;
        if (res == "WA")sub[pro]++;
        else {
            accptedd++;
            accpted[pro] = true;
            p += sub[pro];
        }
    }

    cout << accptedd << " " << p <<endl;

    */


    cin >> n >> m;

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

    int ans = 0;

    //cout << "AAAAA" <<endl;


    for (int i = 0 ; i < n ; i++){
        for (int j = 0 ; j < m ; j++){
            maxx.clear();
            visited.clear();
            if (mat[i][j] == '#')continue;
            getmax(i,j);
            for (int h = 0 ; h < n ; h++){
                for (int g = 0 ; g < m ; g++){ans = max(ans, maxx[h][g]); }//cout << maxx[h][g];}
                //cout << "\n";
            }
            //cout << "\n\n\n";
        }
    }
    //cout << "AAAAA" <<endl;

    cout << ans <<endl;

	return 0;
}


Measured memory_bytes: 256
while True:
    try:
        t=str(input())
    except EOFError:
        break
    p="JOI"
    for i in range(2):
        if i==1:
            p="IOI"
        a=int(0)
        for i in range(len(t)):
            f=t[i:i+len(p)]
            if f.find(p)!=-1:
                a+=1
        print(a)


Measured memory_bytes: 5572
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #ifdef ONLINE_JUDGE
        #pragma GCC target ("avx512f")
    #else
        #pragma GCC target ("avx")
    #endif
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 998244353;

//--------------------------------------------

int n,s;
int a[3000];
int dp[3001][6001];

signed main(){
    I(n); I(s);
    REP(i,n) I(a[i]);
    dp[0][0] = 1;
    REPS(i,n){
        dp[i][0]++;
        REP(j,s+1){
            dp[i][j] += dp[i-1][j];
            dp[i][j + a[i-1]] += dp[i-1][j];
        }
        REP(j,s+1) dp[i][j] %= mod;
    }
    int ret = 0;
    REPS(i,n) ret = (ret + dp[i][s]) % mod;
    cout << ret << endl;
}

Measured memory_bytes: 139776
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
 
ll GCD(ll a,ll b)
{
    if(b==0)
    {
        return a;
    }
 
    return GCD(b,a%b);
}
 
bool gcd(vector<ll> &v)
{
    int ans=0;
 
    for(auto &x:v)
    {
        ans=GCD(ans,x);
    }
 
    return (ans==1);
}
 
vector<ll> primes(ll n)
{
    vector<ll> ans;
 
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ans.push_back(i);
            while(n%i==0)
            {
                n/=i;
            }
        }
    }
 
    if(n>1)
    {
        ans.push_back(n);
    }
 
    return ans;
}
 
void solve()
{
    unordered_set<ll> s;
    ll n,i,count_pairwise=1;
    bool all;
    cin>>n;
    vector<ll> v(n);
 
    for(i=0;i<n;i++)
    {
        cin>>v[i];
    }
 
    all=gcd(v);
 
    vector<ll> prime=primes(v[n-1]);
 
    for(auto x:prime)
    {
        s.insert(x);
    }
 
    
 
    for(i=n-2;i>=0;i--)
    {
        if(v[i]==1)
        {
            count_pairwise++;
            continue;
        }

        prime=primes(v[i]);
        bool temp=true;
        for(auto x:prime)
        {
            if(s.count(x))
            {
                temp=false;
            }
 
            else
            {
                s.insert(x);
            }
        }
 
        if(temp==true)
        {
            count_pairwise++;
        }
    }
 
    if(count_pairwise==n)
    {
        cout<<"pairwise coprime";
    }

    else if(all)
    {
        cout<<"setwise coprime";
    }

    else
    {
        cout<<"not coprime";
    }
}
 
int main()
{
    solve();
}

Measured memory_bytes: 14280
#include <iostream>

int main(int argc, char *argv[])
{
	int R;
	std::cin >> R;

	if (R < 1200) {
		std::cout << "ABC" << std::endl;
	}
	else if (R < 2800) {
		std::cout << "ARC" << std::endl;
	}
	else {
		std::cout << "AGC" << std::endl;
	}

	return 0;
}



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

using namespace std;

int count(const std::vector<int>& v)
{
    int t = 0;
    
    for(int i = 0; i < v.size()-1; i++){
	t += v.at(i);
	if(t % 10 > 0){
	    t = ((t / 10) + 1) * 10;
	}
    }
    t += v.at(v.size()-1);
    return t;
}

int main(){

    vector<int> a(5);

    cin >> a.at(0) >> a.at(1) >> a.at(2) >> a.at(3) >> a.at(4);
    
    sort(a.begin(), a.end());

    int min = 20000000;
    do {
	int t = count(a);
	if(min > t){
	    min = t;
	}
    } while (std::next_permutation(a.begin(), a.end()));
    cout << min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int i;
	int sum=0,num=0;
	char ch[10005];
	scanf("%[^\n]",ch);
	for(i=0;i<strlen(ch);i++)
	{
		if(ch[i]=='A')
		sum++;
		if(ch[i]=='B')
		num++;
	}
	if(sum>0&&num>0)
	printf("Yes");
	else
	printf("No");
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toLong() }
    val sumAll = a.sum()
    var sum = 0L
    println(a.map { sum += it; Math.max(sum, sumAll - sum) - Math.min(sum, sumAll - sum) }.min())
}

Measured memory_bytes: 82896
def main() -> None:
    N = int(input())
    H = [int(i) for i in input().split()]
    m = H[0]
    t = []
    ans = 0
    for i in range(0, len(H)):
        t.append(H[i])
        if max(t) <= H[i]:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cassert>
#include <cctype>
using namespace std;

string S;
size_t cur;

int parse();
int expression();

int digit(){
  assert(isdigit(S[cur]));
  int n = S[cur] - '0';
  cur++;
  return n;
}

int number(){
  int n = digit();
  while(cur < S.size() && isdigit(S[cur])){
    n = n * 10 + digit();
  }
  return n;
}

int factor(){
  if(S[cur] != '(') return number();
  cur++;
  int n = expression();
  assert(S[cur] == ')');
  cur++;
  return n;
}

int term(){
  int a = factor();
  while(cur < S.size() && (S[cur] == '*' || S[cur] == '/')){
    char op = S[cur++];
    int b = factor();
    if(op == '*') a *= b;
    else {
      assert(b != 0);
      a /= b;
    };
  }
  return a;
}


int expression(){
  int sum = term();
  while(S[cur] == '+' || S[cur] == '-'){
    char op = S[cur];
    cur++;
    int b = term();
    if (op == '+') sum += b;
    else sum -= b;
  }
  return sum;
}
int parse() { return expression(); }

int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> S;
    S.resize(S.size()-1);
    cur = 0;
    cout << expression() << endl;
  }
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
LL dp[101][100001];
int main() {
    ios_base::sync_with_stdio(false);
    LL n,w;
    cin >> n >> w;
    LL wgt[w+1],val[n+1];
    for(int i=1; i<=n; i++) cin >> wgt[i] >> val[i];
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=w; j++) {
            if(wgt[i]>j) dp[i][j] = dp[i-1][j];
            else dp[i][j]=max(val[i]+dp[i-1][j-wgt[i]],dp[i-1][j]);
        }
    }
    cout << dp[n][w] << "\n";
}


Measured memory_bytes: 78464
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var hwab = Input.ar;
        var com = new Modulo.Combination(hwab[0] + hwab[1]);
        var res = 0L;
        for(var i = hwab[3]; i < hwab[1]; i++)
        {
            var calc = (long)com.Comb(hwab[0] - hwab[2] + i-1, i) * com.Comb(hwab[1]  - i-2 + hwab[2], hwab[2]-1) % Input.MOD;
            res += calc;
            res %= Input.MOD;
        }
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

public class Modulo
{
    private static int Multiple(int num1, int num2)
        => (int)(BigMul(num1, num2) % Input.MOD);

    public static int Pow(int m, int n)
    {
        if (n == 0) return 1;
        if (n % 2 == 0) return Pow(Multiple(m, m), n / 2);
        else return Multiple(Pow(Multiple(m, m), n / 2), m);
    }

    public static int Div(int a, int b)
        => Multiple(a, Pow(b, Input.MOD - 2));

    public class Combination
    {
        private int[] _fac;
        public Combination(int num)//階乗をメモ化
        {
            _fac = new int[num + 1];
            _fac[0] = 1;
            for (var i = 1; i <= num; i++)
                _fac[i] = Multiple(_fac[i - 1], i);
        }
        public int Comb(int n, int r)
        {
            if (n < r) return 0;
            if (n == r) return 1;
            var calc = _fac[n];
            calc = Div(calc, _fac[r]);
            calc = Div(calc, _fac[n - r]);
            return calc;
        }
        public int fac(int num)
            => _fac[num];
    }

}


Measured memory_bytes: 13244
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  string s; cin>>s;
  sort(s.begin(), s.end());

  string ans = "Yes";
  char now = 'z' + 1;
  int cnt = 0;
  if(s.size() == 1) { cout << "No"<<endl; exit(0);}
  for(auto c : s) {
    if(c != now) {
      now = c;
      if(cnt % 2 != 0) {
        ans = "No";
        break;
      }
      cnt = 0;
    }
    cnt++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll isP(ll n)
{
    for (ll i = 2; i*i <= n; i++) {
        if (n % i == 0) {
            return i;
        }
    }
    return 1;
}
int main()
{
    ll n, k, c = 0, d, t = 0;
    cin >> n;
    k = n;
    while((d = isP(k)) != 1) {
        while (k % d == 0) {
            t++;
            k /= d;
        }
        for (int u = 1; ; u++) {
            if (t - u >= 0) {
                t -= u;
                c++;
            }
            else {
                t = 0;
                break;
            }
        }
    }
    if (k != 1) c++;
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll = long long;
const ll INF = 10e9;

int main(){
  string s,t; cin>>s>>t;
  if (s.size() > t.size()){
    cout << "GREATER" << endl;
    return 0;
  }
  else if (t.size() > s.size()){
    cout << "LESS" << endl;
    return 0;
  }
  else{
    if (s>t){
    cout << "GREATER" << endl;
    return 0;
    }
    else if(t>s){
    cout << "LESS" << endl;
    return 0;
    }
    else{
      cout << "EQUAL" << endl;
      return 0;
    }
  }
}

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

int main() {
    int A1, A2, B1, B2, C1, C2, D1, D2, E1, E2;
    while (cin >> A1 >> A2, (A1 || A2)) {
        cin >> B1 >> B2 >> C1 >> C2 >> D1 >> D2 >> E1 >> E2;
        int mx = 0;
        string res = "";
        if (mx < A1 + A2) {
            mx = A1 + A2;
            res = "A";
        }
        if (mx < B1 + B2) {
            mx = B1 + B2;
            res = "B";
        }
        if (mx < C1 + C2) {
            mx = C1 + C2;
            res = "C";
        }
        if (mx < D1 + D2) {
            mx = D1 + D2;
            res = "D";
        }
        if (mx < E1 + E2) {
            mx = E1 + E2;
            res = "E";
        }
        cout << res << " " << mx << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


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

        string s;
        cin >> s;
        int i,ans=0;
        for(i=0; i<s.size()-1; i++){
            if(s[i]!=s[i+1]){
                cout << "Yes";
                return 0;
            }
        }
        cout << "No";
    

}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var list = new List<char>();
            list.Add(s[0]);
            for (var i = 1; i < s.Length; i++)
            {
                if (s[i] != s[i - 1])
                    list.Add(s[i]);
            }

            Console.WriteLine(list.Count - 1);
        }
    }
}


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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int n;

void dfs(string s, char mx) {
    if(s.size()==n) {
        cout << s << endl;
    }
    else {
        for(char c='a';c<=mx;c++) {
            dfs(s+c, ((c==mx) ? (char)(mx+1) : mx));
        }
    }
}

int main(void) {
    cin >> n;
    dfs("", 'a');
    return 0;
}


Measured memory_bytes: 1536
/*
  Reference:-
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
#define all(vec) vec.begin(),vec.end()
ll mod=1000000007;

int main(){
    std::ios::sync_with_stdio(false);
    int n,w;
    cin>>n>>w;
    ll ar[n+1][2];
    forn(i,n)cin>>ar[i+1][0]>>ar[i+1][1];
    ll dp[w+1][n+1];
    memset(dp,0,sizeof(dp));
    forn1(i,w+1){
        //dp[i][0]=dp[i-1][n];
        forn1(j,n+1){
            int dif=i-ar[j][0];
            if(dif>-1)dp[i][j]=max(dp[i][j-1],dp[i-ar[j][0]][j-1]+ar[j][1]);
            else dp[i][j]=dp[i][j-1];
        }
    }
    cout<<dp[w][n];

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int h, w; cin >> h >> w;
    if (h == 0) return;
    int target = h * h + w * w;
    int ansx = -1, ansy = -1;
    for (int mem = target; ; mem++) {
      for (int x = (mem == target ? h + 1 : 1); ; x++) {
        int y = 0;
        while (++y) if (x * x + (y + 1) * (y + 1) > mem) break;
        if (x >= y) break;
        if (x * x + y * y != mem) continue;
        ansx = x, ansy = y;
        break;
      }
      if (ansx != -1) break;
    }
    cout << ansx << " " << ansy << '\n';
  }
}



Measured memory_bytes: 3140
# 約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())
A = list(map(int, input().split()))

cnt_list = [0] * N
M = 0
ans_list = []
for i in range(N-1, -1, -1):
    if A[i] == 1 and cnt_list[i] % 2 == 0:
        M += 1
        ans_list.append(i+1)
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1
    elif A[i] == 1 and cnt_list[i] % 2 == 1:
        pass
    elif A[i] == 0 and cnt_list[i] % 2 == 0:
        pass
    else:
        M += 1
        ans_list.append(i+1)
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1
print(M)
if M == 0:
    exit()
print(" ".join(map(str, ans_list)))

Measured memory_bytes: 86896
import numpy as np
N = int(input())
queue = [list(map(int, input().split())) for _ in range(N)]


max_N = 100100
prime = np.ones(max_N, dtype=int)
a = np.zeros(max_N, dtype=int)
b = np.zeros(max_N+1, dtype=int)

prime[0], prime[1] = 0, 0
for i in range(2, max_N):
    if i == 0:
        continue
    for j in range(i*2, max_N, i):
        prime[j] = 0

for i in range(1, max_N):
    if i % 2 == 0:
        continue
    if prime[i] == 1 and prime[int((i + 1) / 2)] == 1:
        a[i] = 1
for i in range(0, max_N):
    b[i + 1] = a[i] + b[i]

for i in queue:
    print(b[i[1]+1]-b[i[0]])


Measured memory_bytes: 39520
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int i, j;
  for (i = 1; i < 101; i++) {
    if (C - B*i <= 0) {
      break;
    }
  } 
  for (j = 1; j < 101; j++) {
    if (A - D*j <= 0) {
      break;
    }
  } 
  if (i <= j) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}

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

#define ff              first
#define ss              second
//#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int, int>
#define mci             map<char,int>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1e18+1
//#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            long x; cin>>x; while(x--)
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--)
#define ll unsigned long long

using namespace std;
signed main()
{

    ios_base::sync_with_stdio(false);cin.tie(NULL);

int x, y;
cin>>x>>y;
cout<<x*y;


 cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;





  
return 0;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n;i>=0;i--)
#define rep_a(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define debug(x) do { std::cerr << #x << ": " << x << std::endl; } while (0);
#define debugg(x,y) do { std::cerr << #x << ": " << x << "  "<< #y << ": " << y << std::endl; } while (0);
#define debugggg(i,j,k,ans) std::cerr << #i << ": " << i << "  "<< #j << ": " << j <<#k << ": " << k <<#ans << ": " << ans << std::endl;
const long long mod = 998244353;
const long long MOD = 1000000007;
typedef vector<ll>              vll;
typedef vector<string>          vstr;
typedef vector<char>            vchar;
typedef vector<pair<ll,ll> >    vpll;
typedef set<ll>                 sll;
typedef set<string>             sstr;
typedef set<pair<ll,ll> >       spll;
typedef map<ll,ll>              mllll;
typedef map<string,ll>          mstrll;
typedef queue<ll>               qll;
map<ll,ll>mp; 
int solve()
{
  int n,k;cin>>n>>k;
  vll a(n+1);
  rep(i,n)cin>>a[i+1];
  sort(all(a));
  vll dp(k+1,0);
  //if ist wins 1 else 0;
  rep_a(i,1,k+1)
  {
    rep_a(j,1,n+1)
    {
      bool win = false;
      if(i>=a[j])
      win = 1 - dp[i -a[j]];
      if(win)dp[i] = 1; 
    }  
  }
  if(dp[k])cout<<"First"<<endl;
  else cout<<"Second"<<endl;
  return 0;
}
 
int main()
{
  fast;
	/* #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#else
	#endif */
	solve();
	/* #ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC <<" Sec\n";
	#endif */
	return 0;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define MOD 10000000070
#define DEBUG 0
#define REP(i,n) for(int i=0;i<n;i++)


 int main(){

 	lli n;
 	cin>>n;
 	vector<lli> h(n);
 	REP(i,n)cin>>h[i];

 	lli tmp=0;
 	lli ans=0;
 	REP(i,n){
 		if(tmp <= h[i]){
 			ans++;
 			tmp = h[i];
 		}
 	}
 	cout<<ans<<endl;
 
	return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<int> s(3);
    int a;
    cin>>s.at(0)>>s.at(1)>>s.at(2)>>a;
    sort(s.begin(),s.end());
    for(int i=0;i<a;i++){
        s.at(2)*=2;
    }
        cout<<s.at(2)+s.at(1)+s.at(0)<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

int main() {
	int a, b;
	cin >> a >> b;
	cout << (6 - a - b) << endl;
	return 0;
}

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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = 100 + 10;
int n, m, a[10];
char S[MAXN][MAXN];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) scanf("%s", S[i] + 1);

	for (int i = 1; i <= (n + 1) / 2; ++i)
	for (int j = 1; j <= (m + 1) / 2; ++j) {
		set<II> S;
		S.insert(II(i, j));
		S.insert(II(n - i + 1, j));
		S.insert(II(i, m - j + 1));
		S.insert(II(n - i + 1, m - j + 1));
		a[(int) S.size()]++;
	}

	int cnt[26] = {0};
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			cnt[S[i][j] - 'a']++;
	
	if (n % 2 == 1 && m % 2 == 1) {
		int c = 0;
		for (int i = 0; i < 26; ++i) c += cnt[i] % 2;
		if (c != 1) {
			cout << "No\n";
			return 0;
		}
		for (int i = 0; i < 26; ++i)
			if (cnt[i] & 1) cnt[i]--;
	}
	for (int i = 0; i < 26; ++i) {
		int d = min(cnt[i] / 4, a[4]);
		cnt[i] -= d * 4;
		a[4] -= d;
	}
	if (a[4] > 0) {
		cout << "No\n";
		return 0;
	}
	for (int i = 0; i < 26; ++i) {
		int d = min(cnt[i] / 2, a[2]);
		cnt[i] -= d * 2;
		a[2] -= d;
	}
	cout << (a[2] == 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

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

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
	ll N, K;
	cin >> N >> K;
	struct Number {
		ll A;
		ll B;
	};
	vector<Number> numbers(N);
	for (ll i = 0; i < N; i++) {
		cin >> numbers[i].A >> numbers[i].B;
	}
	vector<ll> masks;
	masks.push_back(K);
	for (ll i = 0; i < 32; i++) {
		if ((K & ((ll)1 << i)) != 0) {
			ll mask = K;
			mask &= ~((ll)1 << i);
			mask |= (((ll)1 << i) - 1);
			masks.push_back(mask);
		}
	}
	ll ans = numeric_limits<ll>::min();
	for (ll mask : masks) {
		ll sum = 0;
		for (Number num : numbers) {
			if ((num.A & (~mask)) == 0) {
				sum += num.B;
			}
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}


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

int c[11][11], c2[11][11], h, w, a[205][205];

int main()
{
    cin >> h >> w;

    for (int i = 0; i < 10; ++i)
        for (int j = 0; j < 10; ++j)
            cin >> c[i][j];

    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            cin >> a[i][j];

    for (int i = 0; i < 10; ++i)
        c[i][i] = 0;

    for (int k = 0; k < 10; ++k)
        for (int i = 0; i < 10; ++i)
            for (int j = 0; j < 10; ++j)
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);

    int rj = 0;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            if (a[i][j] != -1)
                rj += c[a[i][j]][1];
    cout << rj << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

struct graph_t {
	int n;           // |V|, index begins with 0
	int m;           // |E|
	vector<P> edges; // E
	vector<ll> cost; // cost or distance
	vector<ll> cap;  // capacity
};

class _01Bfs {
private:
	struct node {
		int id; bool done; vi to_eid; vi to; vll cost; int from_eid; int from; ll d;
		bool operator<(const node & another) const {
			return !(d != another.d ? d < another.d : id < another.id);
		}
	};
	vector<node> nodes;
	int n, source;
public:
	_01Bfs(graph_t G, int start) {
		n = G.n;
		nodes.resize(n);
		Loop(i, n) nodes[i] = { i, false,{},{},{}, -1, -1, INFLL };
		Loop(i, G.edges.size()) {
			nodes[G.edges[i].first].to_eid.push_back(i);
			nodes[G.edges[i].first].to.push_back(G.edges[i].second);
			nodes[G.edges[i].first].cost.push_back(G.cost[i]);
		}
		source = start;
		nodes[source].d = 0;
		deque<int> deq;
		deq.push_front(source);
		while (deq.size()) {
			int a = deq.front(); deq.pop_front();
			Loop(j, nodes[a].to.size()) {
				int b = nodes[a].to[j];
				ll buf = nodes[a].d + nodes[a].cost[j];
				if (buf < nodes[b].d) {
					nodes[b].d = buf;
					nodes[b].from_eid = nodes[a].to_eid[j];
					nodes[b].from = nodes[a].id;
					if(nodes[a].cost[j]) deq.push_back(b);
					else deq.push_front(b);
				}
			}
		}
		return;
	}
	vi get_path(int v) {
		stack<int> stk;
		stk.push(v);
		int a = v;
		while (nodes[a].from != -1) {
			stk.push(nodes[a].from);
			a = nodes[a].from;
		}
		if (a != source) return{ -1 };
		vi ret;
		while (stk.size()) {
			ret.push_back(stk.top());
			stk.pop();
		}
		return ret;
	}
	vi get_path_eid(int v) {
		stack<int> stk;
		int a = v;
		while (nodes[a].from != -1) {
			stk.push(nodes[a].from_eid);
			a = nodes[a].from;
		}
		if (a != source) return{ -1 };
		vi ret;
		while (stk.size()) {
			ret.push_back(stk.top());
			stk.pop();
		}
		return ret;
	}
	ll get_dist(int v) {
		return nodes[v].d;
	}
};

int main() {
	int n; cin >> n;
	graph_t G;
	G.n = n;
	Loop1(i, n - 1) {
		if (i % 10 != 9) {
			G.edges.push_back({ i, (i + 1) % n });
			G.cost.push_back(1);
		}
		G.edges.push_back({ i, i * 10 % n });
		G.cost.push_back(0);
	}
	_01Bfs _01bfs(G, 1);
	cout <<  _01bfs.get_dist(0) + 1 << endl;
	return 0;
}

Measured memory_bytes: 25188
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int taka = sc.nextInt();
    int ao = sc.nextInt();
    int cnt = sc.nextInt();
    for(int i = 1; i <= cnt; i++){
        if(i % 2 == 1){
            if(taka % 2 == 1){
                taka--;
            }
            taka = taka / 2;
            ao += taka;
        }else{
            if(ao % 2 == 1){
                ao--;
            }
            ao = ao / 2;
            taka += ao;
        }
    }
    System.out.println(taka + " " + ao);
  }
}

Measured memory_bytes: 23124
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<math.h>
#define Max 1000000
#define INF 1000000000000000000
#define getMax(a,b) a<b?b:a
#define getMin(a,b) a<b?a:b
using namespace std;

int dp[Max];

/*long long int noOfAttack(long long int x){
  if(x == 1)
    return 1;
  else if(x < Max && dp[x] != -1)
    return dp[x];
  long long int tmp = 2*noOfAttack(x/2)+1;
  if(x < Max)
    dp[x] = tmp;
  return tmp;
}*/


int main(){

  long long int x;
  scanf("%lld",&x);
  dp[1] = 1;
  for(int i=2;i<Max;i++)
    dp[i] = 2*dp[i/2]+1;
  if(x < Max)
    printf("%d\n",dp[x]);
  else{
      long long int tmp = x,level=0;
      while(tmp >= Max){
        tmp /= 2;
        level++;
      }
      long long int temp = dp[tmp];
      while(level > 0){
        temp = (2*temp)+1;
        level--;
      }
    printf("%lld\n",temp);
  }
  
  return 0;
}

Measured memory_bytes: 4096
a = input()
ju = True
n=len(a)
for i in range(n):
	if a[i] != a[-i-1]:
		ju=False
		
m=int((n-1)/2)
for i in range(m):
	if a[i] != a[m-1-i]:
		ju=False
		
l=int((n+3)/2)
l2= n-l+1
for i in range(l2):
	if a[l-1+i] != a[-i-1]:
		ju=False

if ju==False:
	print("No")
else:
	print("Yes")
	


Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), K = sc.nextInt();
		int ans = 0;
		for(int i = Math.min(A, B); i >= 0; i--) {
			if(A % i == 0 && B % i == 0) {
				K--;
				if(K == 0) {
					ans = i;
					break;
				}
			}
		}
		System.out.println(ans);
	}
}

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

int main(){
    int n, sum = 0, re = 100;
    cin >> n;
    for(int i = 0; i < n; i++){
        int m;
        cin >> m;
        sum += m;
        if(m%10 != 0 && m <= re) re = m;
    }
    if(re == 100) re = sum;
    if(sum%10 == 0) cout << sum - re << endl;
    else cout << sum << endl;
}

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

int main()
{
	int n;
	while( cin >> n ){
		if(!n) break;
		
		int cnt2 = 0, cnt5 = 0;
		for( int i = 1; i <= n; i++ ){
			bool flag = true; int t = i;
			while( flag ){
				flag = false;
				if( t % 2 == 0 ){ flag = true; cnt2++; t /= 2; }
				if( t % 5 == 0 ){ flag = true; cnt5++; t /= 5; }
			}
		}
		cout << min(cnt2, cnt5) << endl;
	}
	return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<long long Mod = mod>
constexpr long long MOD(long long in) {
    return in % Mod;
}

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

    std::cin >> n >> d;

    std::cout << (n + 2 * d + 1 - 1) / (2 * d + 1) << std::endl;

    return 0;
}


Measured memory_bytes: 256
function Main(input) {
	const [r, d, x] = input.split(" ").map(n => Number(n));
	const result = [];
	let prevNum = x;
	for (let i = 0; i < 10; i++) {
		const num = r * prevNum - d;
		result.push(num);
		prevNum = num;
	}
	console.log(result.join("\n"));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7628
#!python3

LI = lambda: list(map(int, input().split()))

# input
N, P = LI()
S = input()


def solve2():
    ans = 0
    for i in range(N):
        if int(S[i]) % 2 == 0:
            ans += i + 1
    return ans


def solve5():
    ans = 0
    for i in range(N):
        if int(S[i]) % 5 == 0:
            ans += i + 1
    return ans


def solve():
    d = [0] * P
    d[0] = 1
    w = 0
    ans = 0
    m = 1
    for s in S[::-1]:
        x = int(s)
        v = x * m % P
        w = (w + v) % P
        ans += d[w]
        d[w] += 1
        m = 10 * m % P
    return ans


def main():
    if P == 2:
        ans = solve2()
    elif P == 5:
        ans = solve5()
    else:
        ans = solve()
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	string s; cin >> s;
	list<char> l; rep(i,s.size()) l.push_back(s[i]);
	bool rev = false;
	int q; cin >> q;
	rep(i,q){
		int t; cin >> t;
		if(t==1){
			rev = !rev;
		}else{
			int f; char c; cin >> f >> c;
			if(f==1){
				if(!rev)l.push_front(c);
				else l.push_back(c);
			}else{
				if(rev)l.push_front(c);
				else l.push_back(c);				
			}

		}
	}
	if(rev) REV(l);
	for(auto tx: l)cout << tx;
	cout << endl;
}




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

using namespace std;

#define int long long 
#define INF 21000000000

signed main(){
		int n;
		cin >> n;
		double ans = 0;
		for(int i=0;i<n;i++){
				double tmp;
				string tuka;
				cin >> tmp >> tuka;
				if(tuka == "JPY") ans += tmp;
				else ans += tmp * 380000;
		}
		cout << ans << endl;
}



Measured memory_bytes: 256