akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

typedef int Flow;
struct Edge{
  int src;int dst;int rev;
  Flow cap;
  Edge(int s=0,int d=0,Flow c=0,int r=0):
  src(s),dst(d),cap(c),rev(r){}
};
using Graph = vector<vector<Edge>>;
Graph g;
bool used[100000];
int m,n;

void add(int src,int dst,int cap){
  g[src].emplace_back(src,dst,cap,g[dst].size());
  g[dst].emplace_back(dst,src,0,g[src].size()-1);
}
int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v]=true;
  REP(i,g[v].size()){
    Edge &e=g[v][i];
    if(!used[e.dst]&&e.cap>0){
      int d=dfs(e.dst,t,min(f,e.cap));
      if(d>0){
        e.cap-=d;
        g[e.dst][e.rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}
int maximum_flow(int s,int t){
  int flow=0;
  for(;;){
    fill(used,used+1111,0);
    int f=dfs(s,t,INF);
    if(!f)return flow;
    flow+=f;
  }
}

int gcd(int a,int b){
  if(a<b)swap(a,b);
  if(b==0)return a;
  return gcd(b,a%b);
}

signed main(){
  while(cin>>m>>n,m){
    g=Graph(1111);

    vector<pair<int,int>> B(m),R(n);
    REP(i,m){
      int b;
      cin>>b;
      B[i]=MP(b,i+1);
    }
    REP(i,n){
      int r;
      cin>>r;
      R[i]=MP(r,i+1+m);
    }
    REP(i,m)add(0,i+1,1);
    REP(i,n)add(m+i+1,n+m+1,1);

    REP(i,m){
      REP(j,n){
        if(gcd(B[i].FIR,R[j].FIR)>1){
          add(B[i].SEC,R[j].SEC,1);
        }
      }
    }
    cout<<maximum_flow(0,n+m+1)<<endl;
  }

  return 0;
}

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

int c=0;
vector<bool> seen;
vector<vector<int>> s;

void dfs(const Graph &G, int v) {
    seen.at(v) = 1;
    for(auto nv : G.at(v)) {
        if(seen.at(nv))
            continue;
        s.at(c).push_back(nv);
        dfs(G, nv);
    }
}

int main() {
    int N,M,x,y,r=0;
    cin >> N >> M;
    vector<int> p(N);
    Graph G(N);
    vector<set<int>> st(N);

    rep(i,N)
        cin >> p.at(i);

    rep(i,M) {
        cin >> x >> y;
        --x, --y;
        G.at(x).push_back(y);
        G.at(y).push_back(x);
    }

    seen.assign(N, 0);
    s.assign(N, vector<int>());
    rep(i,N) {
        if(seen.at(i))
            continue;
        s.at(c).push_back(i);
        dfs(G, i);
        ++c;
    }

    // rep(i,N) {
    //     if(s.at(i).size() == 0)
    //         break;
    //     rep(j,s.at(i).size())
    //         cout << s.at(i).at(j) << " ";
    //     cout << endl;
    // }

    rep(i,N) {
        if(s.at(i).size() == 0)
            break;
        rep(j,s.at(i).size())
            st.at(i).insert(p.at(s.at(i).at(j)));
    }
    
    rep(i,N) {
        if(s.at(i).size() == 0)
            break;
        rep(j,s.at(i).size())
            if(st.at(i).count(s.at(i).at(j)+1))
                ++r;
    }

    cout << r << endl;
}

Measured memory_bytes: 22264
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

inline void solve(){

    int n;
    cin >> n;
    vector<int> a(n);

    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(ALL(a));
    a.erase(unique(ALL(a)),a.end());
    
    cout << a.size() -  (a.size()%2==0) << endl;
    
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 640
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    A.insert(0, 0)
    A.append(0)
    # print(A)
    sum_A = 0
    for i in range(N + 1):
        sum_A += abs(A[i + 1] - A[i])

    # print(sum_A)

    for i in range(1, N + 1):
        if A[i - 1] <= A[i] <= A[i + 1] or A[i + 1] <= A[i] <= A[i - 1]:
            print(sum_A)
            continue

        print(sum_A - (abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1]) - abs(A[i + 1] - A[i - 1])))


Measured memory_bytes: 14044
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/
int n;
string s;
int ruiseki1[3*100000+5];
int ruiseki2[3*100000+5];
/**********************************************/

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

    cin >> n >> s;
    ruiseki1[0] = 0;
    ruiseki2[0] = 0;
    REP(i, n){
        if(s[i] == 'E'){
            ruiseki1[i+1] = ruiseki1[i] + 1;
        }else{
            ruiseki1[i+1] = ruiseki1[i];
        }
    }
    REP(i, n){
        if(s[i] == 'W'){
            ruiseki2[i+1] = ruiseki2[i] + 1;
        }else{
            ruiseki2[i+1] = ruiseki2[i];
        }
    }

    int ans = INF;
    REP(i, n){
        ans = min(ans, ruiseki1[n] - ruiseki1[i+1] + ruiseki2[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2964
local n = io.read("*n")
local c = 0
local f = true
for i = 1, n do
  local a = io.read("*n")
  if a < c then f = false
  else
    if c < a then
      a = a - 1
      c = a
    end
  end
end
print(f and "Yes" or "No")


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

using namespace std;

int main() {
    long long S;
    cin >> S;

    vector<pair<long long, long long>> p;
    p.emplace_back(0, 0);
    // S == abs( x1 * y2 - x2 * y1 )
    p.emplace_back(1, (long long)1e9);
    // S == abs( y2 - x2 * 1e9 )
    // y2 = 0, x2 = 1 : 1e9
    // y2 = 1e9, x2 = 1 : 0
    // y2 = 0, x2 = 1e9 : 1e18
    const auto x2 = (S + (long long)1e9 - 1) / (long long)1e9;
    const auto y2 = x2 * (long long)1e9 - S;
    p.emplace_back(x2, y2);

    for (auto el : p) {
        printf("%lld %lld ", el.first, el.second);
    }
    puts("");
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
        int a,b,d,r;
        double f;
        
        scanf("%d %d",&a,&b);
        
            //a/b
            d = a / b;
            //余り
            r = a % b;
            //浮動小数点数
            f = (double)a / b;
            
            printf("%d %d %lf\n", d, r, f);
        return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			200011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
}
map<pii,ll> m1,m2;
ll dp[2][10001];

int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n>>s1;m=s1.size();
    dp[0][0]=1;

    for(i=1;i<=n;++i){
      ll s=0,o=1;
      if(i%2)swap(s,o);
      ll ans;
      for(j=0;j<=i;++j){
        ans=0;
        ans=ans+dp[o][max(0ll,j-1)]%md;ans%=md;
        ans=ans+2*dp[o][j+1]%md;
        ans%=md;
        dp[s][j]=ans;
      }

    }
    p=dp[n%2][m];
    cout<<p<<"\n";







}



Measured memory_bytes: 384
import java.util.*;

import javax.lang.model.util.ElementScanner6;
/**
 * test
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        if (s.equals("AAA")){
            System.out.println("No");
        } else if(s.equals("BBB")){
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
}
}


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

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

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A') {
            if (i + 1 != s.size() && s[i + 1] == 'C') {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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

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

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////


#define LL long long
const int MAXN = 212345;
const int INF  = 0x3f3f3f3f;




int main () {

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

	int a, b, c;
	cin >> a >> b >> c;

	while (b < a && c > 0) {
		++b;
		--c;
	}

	cout << c << '\n';




	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
        int cnt = 0;
        int x = i;
        while(x < k){
            x *= 2;
            cnt++;
        }
        double sum = n * (1<<cnt);
        ans += 1 / sum;
    }
    cout << fixed << setprecision(10) << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	string s, t;
	cin >> s >> t;
	
	int ans = inf;
	for(int i = 0; i + t.size() <= s.size(); i++) {
		int cnt = 0;
		for(int j = 0; j < t.size(); j++) {
			if(s[i + j] != t[j])
			++cnt;
		}
		ans = min(ans, cnt);
	}
	cout << ans;
}


Measured memory_bytes: 3620
////////////////////////////////////////
///  tu3 pro-con template            ///
////////////////////////////////////////
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <regex>
using namespace std;

//// MACRO ////
#define countof(a) (sizeof(a)/sizeof(a[0]))

#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define RFOR(i,s,n) for (int i = (n)-1; i >= (s); i--)
#define pos(c,i) c.being() + (i)
#define allof(c) c.begin(), c.end()
#define aallof(a) a, countof(a)
#define partof(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define apartof(a,i,n) a + (i), a + (i) + (n)
#define long long long

#define EPS 1e-9
#define INF (1L << 30)
#define LINF (1LL << 60)

//// i/o helper ////

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
struct _Writer { bool f; _Writer() : f(false) { } template <class T> _Writer operator ,(const T &rhs) { cout << (f ? " " : "") << rhs; f = true; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__
#define WRITE(...) _Writer(), __VA_ARGS__; cout << endl

//// start up ////
void solve();
int main()
{
	solve();
	return 0;
}

////////////////////
/// template end ///
////////////////////

void solve()
{
	int testcases = INF;
	REP(testcase, testcases)
	{
		READ(int, N, M);
		if (!(N | M)) { break; }
		READ(int, r);
		struct entry { int t, n, m, s; };
		vector<entry> log;
		REP(i, r)
		{
			READ(int, t, n, m, s);
			log.push_back({ t, n, m, s });
		}

		READ(int, q);
		REP(i, q)
		{
			int ret = 0;

			READ(int, ts, te, m);
			int stack = 0, first;
			for (entry e : log)
			{
				if (e.m == m)
				{
					if (e.s) { if (!stack) { first = e.t; } stack++; }
					else { stack--; if (!stack) { ret += max(0, min(e.t, te) - max(first, ts)); } }
				}
			}
			WRITE(ret);
		}
	}
}

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

int main()
{
    long long int a, b;
    cin >> a >> b;
    int k;
    if(a * b > 0){
        if(a > 0 && b > 0) k = 0;
        else{
            if((b - a) % 2 == 1) k = 0;
            else k = 1; 
        }
    
    }else{
        k = 2;
    }

    if(k == 0) cout << "Positive" << endl;
    else if(k == 1) cout << "Negative" << endl;
    else cout << "Zero" << endl;
}

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

int main(){
	int n;
	int ans = 0;
	cin>>n;
	vector<int> t(n);
	for(int i = 0;i<n;i++){
		cin>>t[i];
		ans+=t[i];
	}
	int m;
	cin>>m;
	vector<int> p(m);
	vector<int> x(m);
	for(int i = 0;i<m;i++){
		cin>>p[i]>>x[i];
		p[i]--;
		cout<<ans-t[p[i]]+x[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
	static final long MOD = 1000000007L;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		int X = sc.ni();
		pw.println(10-(X/200));
		pw.close();
	}
	
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            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 ni() { 
            return Integer.parseInt(next()); 
        }
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() {
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

Measured memory_bytes: 32884
def main():
    n = input().split()

    w = int(n[0])
    h = int(n[1])
    x = int(n[2])
    y = int(n[3])
    r = int(n[4])
    L = x - r
    T = y - r
    R = x + r
    B = y + r

    x_ans = (L >= 0 and R <= w)
    y_ans = (T >= 0 and B <= h)

    if x_ans and y_ans:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+21;
int n,A[N],In[N],rez;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&A[i]);
        In[A[i]]++;
    }
    for(int i=0;i<N;i++){
        int cnt=0;
        cnt+=(In[i]+In[i+1]);
        if(i>0){
            cnt+=In[i-1];
        }
        rez=max(rez,cnt);
    }
    printf("%d",rez);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  char c;
  vector<int> t(N, 0);
  vector<vector<char>> table(N, vector<char>(M));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> c;
      table.at(i).at(j) = c;
    }
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (table.at(i).at(j) == '.') {
        count++;
      }
    }
    if (count == M) {
      t.at(i) = 1;
      for (int j = 0; j < M; j++) {
        table.at(i).at(j) = ' ';
      }
    }
    count = 0;
  }
  for (int j = 0; j < M; j++) {
    for (int i = 0; i < N; i++) {
      if (table.at(i).at(j) == '.' || table.at(i).at(j) == ' ') {
        count++;
      }
    }
    if (count == N) {
      for (int i = 0; i< N; i++) {
        table.at(i).at(j) = ' ';
      }
    }
    count = 0;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (table.at(i).at(j) != ' ') {
        cout << table.at(i).at(j);
      }
      if (j == M-1 && t.at(i) == 0) {
        cout << endl;
      }
    }
  }
}


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

int main(){
	char a,b;
  	cin>>a>>b;
  	int n,m;
  	n=(int)(a+'0');
  	m=(int)(b+'0');
  	if(n>m)cout<<">"<<endl;
  	else if(n==m)cout<<"="<<endl;
  	else cout<<"<"<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int mod = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
typedef vector<ll> vv;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n1, k1;
int fact[2001];
int gcd(int a, int b)
{
    return b != 0 ? gcd(b, a % b) : a;
}
int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}
// a x + b y = gcd(a, b)
int extgcd(int a, int b, int &x, int &y)
{
    int g = a;
    x = 1;
    y = 0;
    if (b != 0)
        g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}
int mod_inverse(int a, int m)
{
    int x, y;
    if (extgcd(a, m, x, y) == 1)
        return (x + m) % m;
    else
        return 0; // unsolvable
}
int mod_fact(int n, int p, int &e)
{
    e = 0;
    if (n == 0)
        return 1;
    int res = mod_fact(n / p, p, e);
    e += n / p;
    if (n / p % 2 != 0)
        return res * (p - fact[n % p] % p);
    return res * fact[n % p] % p;
}
int mod_comb(int n, int k, int p)
{
    if (n < 0 || k < 0 || n < k)
        return 0;
    int e1, e2, e3;
    int a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
    if (e1 > e2 + e3)
        return 0;
    return a1 * mod_inverse(a2 * a3 % p, p) % p;
}
ll modinv(ll a)
{
    ll b = mod, u = 1, v = 0, t;
    while (b)
    {
        t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    return (u + mod) % mod;
}

ll moddevide(ll a, ll b) { return (a * modinv(b)) % mod; }

ll modncr(ll n, ll r)
{
    ll i, plus = 1;
    for (i = 0; i < r; i++)
    {
        plus = (plus * (n - i)) % mod;
        plus = moddevide(plus, i + 1);
    }
    return plus;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n1 >> k1;
    for (int i = 1; i <= k1; i++)
    {
        cout << modncr(k1 - 1, i - 1) * modncr(n1 - k1 + 1, i)%mod << "\n";
    }
}


Measured memory_bytes: 256
#include <stack>
#include <string>
#include <cstdlib>
#include <cstdio>

using namespace std;

int main() {
    char s[100];
    stack<int> St;
    int l, r;
    while (scanf("%s", &s) != EOF) {
        switch (s[0]) {
            case '+':
                l = St.top();St.pop();
                r = St.top();St.pop();
                St.push(l + r);
                break;
            case '-':
                l = St.top();St.pop();
                r = St.top();St.pop();
                St.push(r - l);
                break;
            case '*':
                l = St.top();St.pop();
                r = St.top();St.pop();
                St.push(l * r);
                break;
            default:
                St.push(atoi(s));
                break;
        }
    }

    printf("%d\n", St.top());

    return 0;
}


Measured memory_bytes: 2728
# C
s = list(input())

x_list = []
x_cnt = 0
nonx_list = []

for i in range(len(s)):
    if s[i] == 'x':
        x_cnt += 1
    else:
        nonx_list.append(s[i])
        x_list.append(x_cnt)
        x_cnt = 0

x_list.append(x_cnt)

if "".join(nonx_list) == "".join(reversed(nonx_list)):    
    res = 0
    for i in range(len(x_list) // 2):
        res += max(x_list[i], x_list[len(x_list)-i-1]) - min(x_list[i], x_list[len(x_list)-i-1])
    print(res)
else:
    print(-1)

Measured memory_bytes: 6352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N, long[][] robots)
        {
            Array.Sort(robots, (a, b) => a[0].CompareTo(b[0]));
            long R = robots[0][0] + robots[0][1];
            int count = 0;
            for (int i = 1; i < N; ++i)
            {
                if (robots[i][0] - robots[i][1] < R)
                {
                    ++count;
                    R = Math.Min(robots[i][0] + robots[i][1], R);
                }
                else
                {
                    R = robots[i][0] + robots[i][1];
                }
            }
            return N - count;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            var robots = new long[N][];
            for (int i = 0; i < N; ++i) { robots[i] = ReadLongs(); }
            Console.WriteLine(Solve(N, robots));
        }
    }
}


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

int main(){
    int R,G,B,N;
    cin  >> R >> G >> B >> N;

    int Rbox = N/R;
    int ans = 0;

    for(int i=0; i<=Rbox; i++){
        for(int j=0; j<=(N-i*R)/G; j++){
            if(((N - i*R - j*G) % B) == 0){
                ans++;
            }
        }
    }
    
    
    cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N, X;
  IN(N,X);
  vll L(N);
  REP(i,N) IN(L[i]);

  ll D = 0;
  ll ans = 0;
  while(D<=X){
    if(ans>=N){
      ans++;
      break;
    }
    D += L[ans];
    ans++;
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  string s;
  cin >> s;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      cout << i+1<<" "<<i+2<<endl;
      return 0;
    }else if(i!=0&&s[i-1]==s[i+1]){
      cout << i<<" "<<i+2<<endl;
      return 0;
    }
  }
  cout << "-1 -1\n";
}


Measured memory_bytes: 512
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
//#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
//using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	ios::sync_with_stdio(false);
	llint n,m,i,bi,j;cin>>n>>m;
	static llint a[20]={0};
	static double p[20]={0};
	for(i=0;i<n;i++){cin>>a[i];}
	for(i=0;i<n;i++){cin>>p[i];p[i]/=100;}
	static double dp[1<<20];
	dp[0]=0;
	for(bi=1;bi<(1<<n);bi++){
		llint alc=1;
		bool flow=false;
		int ki=0;
		for(i=0;i<n;i++){
			if(!(bi&(1<<i))){continue;}
			ki++;
			llint gc=gcd(alc,a[i]);
			double miru=((double)(alc))*a[i]/gc;
			if(miru>m*1.5){flow=true;break;}
			alc/=gc;alc*=a[i];
		}
		if(flow){continue;}
		dp[bi]=m/alc;
		if(ki%2==0){dp[bi]*=-1;}
	}
	for(i=0;i<n;i++){
		for(bi=0;bi<(1<<n);bi++){
			if(bi&(1<<i)){continue;}
			dp[bi+(1<<i)]+=dp[bi];
		}
	}
	double ans=0;
	for(bi=0;bi<(1<<n);bi++){
		double gen=dp[bi];
		for(i=0;i<n;i++){
			if(bi&(1<<i)){gen*=p[i];}
			else{gen*=1-p[i];}
		}
		ans+=gen;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 11496
#include <stdio.h>
int main(void)
{
    int in_second;//??\??????????????????s
    int out_hour, out_minute, out_second;//?????????h:m:s
    
    //??\???
    scanf("%d", &in_second);
    
    //?????????????¨????
    out_second = in_second % 60;
    out_minute = (in_second / 60) % 60;
    out_hour = (in_second / 60) / 60;
    
    //??????
    printf("%d:%d:%d\n", out_hour, out_minute, out_second);
    
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef pair<ll,ll> pl;
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()
//#define max(a,b) (a>b ? a : b)
//#define min(a,b) (a<b ? a : b)
 
const int MOD = 998244353;
const int INF = 100000002;
const double PI =4*atan(1);
const double eps = 1e-7;
const long long oo = 1e18;

int main(){
  ll a, b ,c;
  cin >> a >> b >> c;
  ll d = c-a-b;
  
  if(d>0 && d*d > 4*a*b) cout << "Yes" << endl;
  else cout << "No" << endl;

}

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

using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
//#pragma GCC target ("avx,tune=native")
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

const double pi = acos(-1);
const int INF = 1e9 + 5;
const int N = 2e5 + 20;


void solve()
{
	char c;
	cin >> c;
	if(c >= 'a') cout << "a";else cout << "A";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 3516
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/



int main(){
  ll R,G,B,r,g,b,n;
  cin>>R>>G>>B>>n;
  ll ans=0;
  for(int i=0;i*R<=n;i++){
    for(int j=0;(i*R+j*G)<=n;j++){
      if((n-(i*R+j*G))%B==0)ans++;
    }
  }
  op(ans);
  return 0;
}

Measured memory_bytes: 256
cat<<EOF>Source.cpp
#include <iostream>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int max(int a,int b){
	return a>b?a:b;
}
int x[100000],y[100000],x_mod_k[100000],x_div_k[100000];
char s[100000][2];
int n,k;

void add(int*cnt,int x,int t){
	if((x_div_k[x]&1)==0){
		if(t==0){
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
		else{
			cnt[k-x_mod_k[x]]++;
		}
	}
	else{
		if(t==0){
			cnt[k-x_mod_k[x]]++;
		}
		else{
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
	}
}
int ans[2000];
int main(){
	scanf("%d%d",&n,&k);
	rep(i,n){
		scanf("%d%d%s",&x[i],&y[i],s[i]);
		x_mod_k[i]=y[i]%k;
		x_div_k[i]=y[i]/k;
	}
	int Max=0;
	#pragma omp parallel for num_threads(2)
	rep(i,k){
		int cnt[max(n,k)];
		rep(j,max(n,k))cnt[j]=0;
		rep(j,n){
			if(s[j][0]=='B'){
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,0);
				}
				else{
					add(cnt,j,1);
				}
			}
			else{
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,1);
				}
				else{
					add(cnt,j,0);
				}
			}
		}
		rep(j,k){
			if(j)cnt[j]+=cnt[j-1];
			ans[i]=max(ans[i],max(cnt[j],n-cnt[j]));
		}
	}
	rep(i,k)Max=max(Max,ans[i]);
	cout<<Max<<endl;
}
EOF
g++ -Ofast Source.cpp -o Source -fopenmp -std=c++11
./Source

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  
  int count = 0;
  
  for(int i=0; i<A+1; i++){
    for(int j=0; j<B+1; j++){
      for(int k=0; k<C+1; k++){
        if(X == 500*i+100*j+50*k){
          count++;
        }      
      }
    }
  }
  
  cout << count <<endl;
}

Measured memory_bytes: 3520
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e18
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

int main(){
	int n,m;
	cin >> n;
	VI t(n);
	rep(i, n)cin >> t[i];
	
	cin >> m;
	VI P(m), X(m);
	rep(i, m) cin >> P[i] >> X[i];

	int sum=0;
	rep(i, m) {
		sum = 0;
		rep(j, n) {
			if (j == P[i]-1) {
				sum += X[i];
			} else {
				sum += t[j];
			}
		}
		cout << sum << endl;
	}
	return 0;
}






Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = [0]*N
answer = []
for i in range(N, 0, -1):
  if A[i-1] == 1:
    count = 1
    number = 0
    while count*i <= N:
      number += B[count*i-1]
      count+=1
    if number%2 == 0:
      B[i-1] = 1
      answer.append(i)
  else:
    count = 1
    number = 0
    while count*i <= N:
      number +=B[count*i-1]
      count+=1
    if number%2==1:
      B[i-1] = 1
      answer.append(i)
print(B.count(1))
print(*answer)

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

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

int dp[101][100100];

int main(void) {
	int N,K;
	cin >> N >> K;
	dp[0][0] = 1;
	REP(i,N) {
		int x;
		cin >> x;
		int sum=0;
		for(int j=0; j<=K; j++) {
			sum = (sum+dp[i][j]) % 1000000007;
			if(j > x)
				sum = (sum+1000000007-dp[i][j-x-1]) % 1000000007;
			dp[i+1][j] = sum;
		}
	}
	cout << dp[N][K] << endl;
	return 0;
}

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

typedef long long ll;
static const ll MOD = 1e9+7;

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

    ll dif = abs(N-M);
    ll ans;

    if(dif >= 2){
        ans = 0;
    }

    else if(dif == 0){
        ans = 1;
        ans *= 2;

        for(int i=2; i<=M; i++){
            ans *= i;
            ans %= MOD;
        }

        for(int i=2; i<=N; i++){
            ans *= i;
            ans %= MOD;
        }
    }

    else if(dif == 1){
        ans = 1;
        for(int i=2; i<=M; i++){
            ans *= i;
            ans %= MOD;
        }

        for(int i=2; i<=N; i++){
            ans *= i;
            ans %= MOD;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3560
a,b,c,d=map(int, input().split())

if b<=c or d<=a:
    print(0)
elif a<c and c<b and b<d:
    print(b-c)
elif c<a and a<d and d<b:
    print(d-a)
else:
    print(min(b,d)-(max(a,c)))


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;
// 9  3 9
//    2 4 8
bool check(ll x, ll k) {
    while (x%k==0) x /= k;
    return (x%k) == 1;
}

int main(void) {
    ll n;
    cin >> n;
    
    vector<ll> v1, v2;

    for (ll i=1; i*i<=n-1; i++) {
        if ((n-1)%i==0) {
            if (i!=1) v1.pb(i);
            if (i*i!=n-1) v1.pb((n-1)/i);
        }
    }

    ans += (ll)sz(v1);

    for (ll i=1; i*i<=n; i++) {
        if (n%i==0) {
            if (i!=1) v2.pb(i);
            if (i*i!=n) v2.pb(n/i);
        }
    }

    for (ll x : v2) if (x!=1 && check(n, x)) ans++; 

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef pair <int,int> pr;
#define fr(i, n) for(int i = 0; i < n; i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c)(c).begin(), (c).end()
#define tr(c, i) for (typeof ((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x)((c).find(x) != (c).end())
#define cpresent(c, x)(find(all(c), x) != (c).end())
// for mod power a^b%m use power<lli> (a,b,m)
template < class mytype >
mytype power(mytype a, mytype b, mytype m){if (b == 1) return a % m;if (b == 0) return 1;
mytype root = power < lli > (a, b / 2, m);mytype ans = (root * root) % m;if (b % 2) ans = (ans * a) % m;
return ans;
}
// for gcd use gcd<int> (a,b)
template < class type >type gcd(type a, type b){if (a == 0) return b;else return gcd(b % a, a);}
template < class type >type mod_inv(type a, type p) {return power(a, p - 2, p);}
const lli MOD = 1e9 + 7;
int n, k;
vector<int> a(101);

int main()
{
   cin >> n >> k;
   for(int i = 0 ; i < n ;i++) cin >> a[i];
   vector<bool> dp(k+1 , false);
   for(int i = 0 ; i <= k ; i++){
    if(dp[i]) continue;
    for(int j = 0 ; j < n ; j++) {
        if(i+ a[j] <= k) dp[i + a[j]] = true;
    }
   }
   if(dp[k]) cout << "First";
   else cout << "Second";
   return 0;
}











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

int ans = 0;
vector<vector<int>> field;
vector<bool> visited;

void dfs(int x, int p);

int main() {
    int n, m, a, b;
    cin >> n >> m;
    vector<vector<int>> path(n);
    visited.resize(n);
    fill(visited.begin(), visited.end(), false);
    rep(i, m) {
        cin >> a >> b;
        path.at(a - 1).push_back(b - 1);
        path.at(b - 1).push_back(a - 1);
    }
    field = path;
    dfs(0, n - 1);
    cout << ans << endl;
}

void dfs(int x, int p) {
    if(p == 0) {
        ans++;
        return;
    }
    visited.at(x) = true;
    rep(i, field.at(x).size()) {
        if(!visited.at(field.at(x).at(i))) dfs(field.at(x).at(i), p - 1);
    }
    visited.at(x) = 0;
    return;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define pii              pair <int,int>
#define DEBUG(x) cerr << '>' << #x << ':' << x << endl;
typedef long long ll;
//#pragma comment(linker, "/STACK:667772160")
#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))

const double eps=1e-9;
const int MOD=1e9+7;
const int N=1e5+30;
const int inf = 1e17+995;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <typename T> T exp(T b, T p){T x = 1;while(p){if(p&1)x=(x*b);b=(b*b);p=p>>1;}return x;}
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
void boostIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int mem[N][3],cost[N][3],n;
int32_t main() {
boostIO();
cin>>n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin>>cost[i][j];
        }
    }
    for (int i = 0; i < 3; ++i) {
        mem[0][i]=0;
    }
    for (int i = 0; i < n   ; ++i) {
        mem[i][0]=cost[i][0]+max(mem[i-1][1],mem[i-1][2]);
        mem[i][1]=cost[i][1]+max(mem[i-1][0],mem[i-1][2]);
        mem[i][2]=cost[i][2]+max(mem[i-1][0],mem[i-1][1]);
    }
    cout<<max({mem[n-1][1],mem[n-1][0],mem[n-1][2]});
}

Measured memory_bytes: 4992
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,t=MI()
    tt=LI()
    ans=n*t
    for t0,t1 in zip(tt,tt[1:]):
        ans-=max(t-t1+t0,0)
    print(ans)

main()

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

int main(){
  long long A, B,s=0,i;
  cin >> A >> B;
  long long int ar[A];
  for(int i = 0; i < A; i++){
    cin>>ar[i];
  }
  sort(ar,ar+A);
  for(i=0; i<B; i++)
  {
    s+=ar[i];
  }
  cout<<s;
  return 0;
}


Measured memory_bytes: 3640
H, W, K = map(int, input().split())
choco = [list(map(int, list(input().strip()))) for i in range(H)]

ans = (H-1) * (W-1)

for i in range(2**(H-1)):
    cut = 0

    yoko = [choco[0]]
    for j in range(H-1):
        if (i>>j) & 1 == 1:
            # 折った
            cut += 1
            yoko.append(choco[j+1])
        else:
            # 折らない -> まとめる
            yoko[-1] = [a + b for a, b in zip(yoko[-1], choco[j+1])]

    count = [yoko[i][0] for i in range(cut+1)]

    if max(count) > K:
        continue

    for x in range(1, W):
        now_count = [yoko[y][x] for y in range(len(count))]
        next_count = [a + b for a, b in zip(now_count, count)]
        if max(next_count) > K:
            # 折る
            count = now_count
            cut += 1
        else:
            # 折らない
            count = next_count

    ans = min(ans, cut)

print(ans)

Measured memory_bytes: 3188
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順

using namespace std;
using ll = long long int;

int main(){
    int N;cin>>N;
    vector<int> A(N+1);
    for(int i=1;i<N;i++){
        int a;cin>>a;
        A[a-1]++;
    }
    for(int i=0;i<N;i++){
        cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4004
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
int n;
LL a[100005], sum[100005], num1, num2;

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	for(int i = 1; i <= n; i++){
		sum[i] = sum[i - 1] + a[i];
		if(i & 1){
			if(sum[i] <= 0){
				num1 += 1 - sum[i];
				sum[i] = 1;
			}
		}
		else{
			if(sum[i] >= 0){
				num1 += sum[i] + 1;
				sum[i] = -1;
			}
		}
	}
	memset(sum, 0, sizeof(sum));
	for(int i = 1; i <= n; i++){
		sum[i] = sum[i - 1] + a[i];
		if(i & 1){
			if(sum[i] >= 0){
				num2 += 1 + sum[i];
				sum[i] = -1;
			}
		}
		else{
			if(sum[i] <= 0){
				num2 += 1 - sum[i];
				sum[i] = 1;
			}
		}
	}
	printf("%lld\n", min(num1, num2));
	return 0;
}





Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int n,t,a[100010];
int leftmin[100010],rightmax[100010];

int main()
{
	int i,j;
	
	scanf("%d %d",&n,&t);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	
	leftmin[0] = a[0];
	for(i=1;i<n;i++)
	{
		if(a[i] < leftmin[i-1])
		{
			leftmin[i] = a[i];
		}
		else leftmin[i] = leftmin[i-1];
	}
	
	rightmax[n-1] = a[n-1];
	for(i=n-2;i>=0;i--)
	{
		if(a[i] > rightmax[i+1])
		{
			rightmax[i] = a[i];
		}
		else rightmax[i] = rightmax[i+1];
	}
	
	int maxdif=0,cou=0,right,left;
	for(i=0;i<n;i++)
	{
//		printf("leftmin[%d] = %d		rightmax[%d] = %d\n",i,leftmin[i],i,rightmax[i]);
		if(maxdif < rightmax[i]-leftmin[i])
		{
			maxdif = rightmax[i]-leftmin[i];
			cou=1;
			right = rightmax[i];
			left = leftmin[i];
		}
		else if(maxdif == rightmax[i]-leftmin[i] && right!=rightmax[i] && left!=leftmin[i])
		{
			right = rightmax[i];
			left = leftmin[i];
			cou++;
		}
	}
	printf("%d\n",cou);
}

Measured memory_bytes: 5024