akhauriyash/Code-Regression huggingface dataset:
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int a, b, c;
	cin >> a >> b >> c;
	print((a*100+b*10+c) % 4 == 0 ? "YES" : "NO");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int N){
    vector<int>S;
    rep(i,N)if(bit & (1<<i))S.push_back(i);
    return S;
}

int main(){
    int n;cin>>n;
    VEC(int,a,n);
    vector<int>b(n+1,0);
    for(int i=n;i>=1;i--){
        int j = 1;int cnt = 0;
        while(i*j<=n){
            cnt += b[i*j];
            j++;
        }
        cnt %= 2;
        if(cnt != a[i-1])b[i]++; 
    }
    vector<int>c;
    int m = 0;
    rep(i,n+1){
        m += b[i];
        if(b[i])c.push_back(i);
    }
      cout<<m<<endl;
    for(auto d : c)cout<<d<<" ";
}



Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;


public class Main{
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	
	static class Pair
	{
		int p;
		int q;
		Pair(int p,int q)
		{
			this.p = p;
			this.q = q;
		}
	}
	
	static int gcd(int a,int b)
	{
		if(a == 0) return b;
		if(b == 0) return a;
		
		return gcd(b,a%b);
	}
	static long gcd(long a,long b)
	{
		if(a == 0) return b;
		if(b == 0) return a;
		
		return gcd(b,a%b);
	}
	static void preCompute(long fact[])
	{
		fact[0] = 1;
		for(int i = 1; i < fact.length; i++)
		{
			fact[i] = i*fact[i-1]%rem;
		}
	}
	static long power(long x, long y, long p) 
    { 
        long res = 1; 
        x = x % p; 
                      
        while (y > 0) 
        {
            if (y % 2 == 1) 
                res = (res * x) % p; 
 
            y = y >> 1; 
            x = (x * x) % p; 
        }
        return res; 
    } 
	static long modInverse(long n, long p) 
    { 
        return power(n, p-2, p); 
    }
	
	static long nCrModPFermat(int n, int r, long p) 
	{ 

		if (r == 0) 
			return 1; 

		return (fact[n]* modInverse(fact[r], p) % p * modInverse(fact[n-r], p) % p) % p; 
	}
	static long rem = (long)(1e9)+7;
	static long fact[];
	public static void main(String[] args) 
	{
		OutputStream outputStream = System.out;
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(outputStream);
        
        int h = sc.nextInt();
        int a = sc.nextInt();
        
        if(h%a == 0)
        {
        	out.println(h/a);
        }
        else
        {
        	out.println(((h/a) + 1));
        }
        out.close();
	}

}


Measured memory_bytes: 21076
use num::integer::gcd;
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let a_max = a.iter().max().unwrap();
    let mut v = vec![0; a_max + 2];

    for na in &a {
        v[*na] += 1;
    }

    if *v.iter().skip(2).max().unwrap() > 1 {
        if check_setwise_coprime(&a) {
            println!("setwise coprime");
        } else {
            println!("not coprime");
        }
        return;
    }

    for i in 2..a_max + 1 {
        let mut j = i;
        let mut count = 0;
        while j < a_max + 1 {
            if v[j] > 0 {
                count += 1;
            }
            j += i;
        }
        if count > 1 {
            if check_setwise_coprime(&a) {
                println!("setwise coprime");
            } else {
                println!("not coprime");
            }
            return;
        }
    }

    println!("pairwise coprime");
}

fn check_setwise_coprime(a: &Vec<usize>) -> bool {
    let mut ans = gcd(a[0], a[1]);
    for na in a.iter().skip(2) {
        ans = gcd(*na, ans);
    }

    if ans == 1 {
        return true;
    } else {
        return false;
    }
}


Measured memory_bytes: 20468
from itertools import combinations_with_replacement as cw
N,M,Q = map(int, input().split())
cand = cw([i+1 for i in range(M)],N)
fs = [list(map(int, input().split())) for i in range(Q)]

def calc(fs,As):
  count = 0
  for a,b,c,d in fs:
    if As[b-1] - As[a-1] == c:
      count += d
  return count
ans = 0
for As in cand:
  ans = max(ans,calc(fs,As))

print(ans)

Measured memory_bytes: 9160
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    int n,i,z=0;cin>>n;
    ll A[n];
    fo(i,0,n){cin>>A[i];if(A[i]==0)z++;}
    ll res=1;
    ll limit=(ll)1e18;
    
    if(z){cout<<"0\n";return;}
    fo(i,0,n)
    {
       if(A[i]<=limit/res)res*=A[i];
      else{res=-1;break;}
        
    }
    cout<<res<<"\n";
    
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 4432
#include <bits/stdc++.h>     
using namespace std;
typedef long long int ll;
typedef long long int lli;
typedef vector < ll > vi;
typedef vector<vi> vvi;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DBG(c) cout << #c << " = " << c << endl;
#define Mod 1000000007
#define INF 1e18L+5
lli find_min(lli a,lli b){if(a>b) return b; return a;}
lli find_max(lli a,lli b){if(a<b) return b; return a;}

int main()
{
    fastio
    lli n,w;
    cin>>n>>w;
    lli val[n],wt[n];
    lli sum = 0;
    for(lli i = 0; i < n; i++)
    {
        cin>>wt[i]>>val[i];
        sum += val[i];
    }
    vi dp(sum+1 ,INF);
    dp[0] = 0;
    //dp[i] = the minimum total weight of items with total value exactly i
    for(lli i = 0 ; i < n ; i++)
    {
      for(lli j = sum - val[i];j>=0;j--)
     // for(lli j = 0; j < sum - val[i]; j++)
        dp[j + val[i]] = find_min(dp[j + val[i]] , dp[j] + wt[i]); 
    }
    lli ans = 0;
    for(lli i = 0;i <= sum;i++){
        if(dp[i] <= w)
        ans = find_max(ans,i);
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

int main() {
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i) cin >> a[i];
	sort(a.begin(), a.end()); reverse(a.begin(), a.end());
	int sum = a[0] - a.back();
	for(int i = 1; i < n - 1; ++i) sum += max(a[i], -a[i]);
	printf("%d\n", sum);
	for(int i = 1; i < n - 1; ++i) {
		if(a[i] >= 0) printf("%d %d\n", a.back(), a[i]), a.back() -= a[i];
		else printf("%d %d\n", a[0], a[i]), a[0] -= a[i];
	}
	printf("%d %d\n", a[0], a.back()); a[0] -= a.back();
	assert(a[0] == sum);
	return 0;
}


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


int main(){
	unsigned int c[110][110],t[110][110];	
	
	int n,v;
	
	int a,b;
	
	while(cin>>n>>v,n){
		for(int i=0;i<v+1;i++){
			for(int j=0;j<v+1;j++){
				int tmp;
				if(i==j){
					tmp=0;
				}else{
					tmp=2000000;
				}
				c[i][j]=tmp;
				t[i][j]=tmp;
			}
		}
		
		for(int i=0;i<n;i++){
			cin>>a>>b;
			cin>>c[a][b];
			c[b][a]=c[a][b];
			cin>>t[a][b];
			t[b][a]=t[a][b];
		}
		
		
		for(int k=1;k<v+1;k++){
			for(int i=1;i<v+1;i++){
				for(int j=1;j<v+1;j++){
					c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
					t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
				}
			}
		}
		
		
		cin>>n;
		bool r;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			cin>>r;
			if(r){
				cout<<t[a][b]<<endl;
			}else{
				cout<<c[a][b]<<endl;
			}
		}
		
		
	}
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
          if(n/i==i)
            c++;
          else
            c+=2;
        }

    }

    
    return  c;
}
int func(int n)
{
    return (n*(n+1))/2;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   
   int n,m;
   cin>>n;
   map<string,int> mp;
   while(n--)
   {
      string str;
      cin>>str;
      mp[str]++;
   }
   cin>>m;
   while(m--)
   { 
      string str;
      cin>>str;
      mp[str]--;
   }
   map<string,int> :: iterator itr;
   int cmax=0;
   for(itr=mp.begin();itr!=mp.end();itr++)
   {
     if(itr->second > cmax)
     {
        cmax= itr-> second;
     }
   }
   cout<<cmax;


 return 0;
}








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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  sort(ALL(p));
  cout << accumulate(p.begin(), p.begin()+k, 0) << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  string s;
  cin>>s;
  string strs[]={
    "dream",
    "dreamer",
    "erase",
    "eraser"
  };
  reverse(begin(s),end(s));
  for(auto &e:strs){
    reverse(begin(e),end(e));
  }
  int i;
  for(i=0;;){
    bool updated=false;
    for(auto e:strs){
      if(i+e.size()<=s.size()&&s.compare(i,e.size(),e)==0){
	i+=e.size();
	updated=true;
      }
    }
    if(!updated)break;
  }
  cout<<((i==s.size())?"YES":"NO")<<endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  sort(a,a+n);
  int ans = 2e9;
  REP(i,n-1){
    CHMIN(ans, (int)__gcd(a[i],a[i+1]));
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 640
import java.util.*;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[N];
        int[] b = new int[N];
        int[] c = new int[M];
        int[] d = new int[M];
        long[] min = new long[N];
        int[] ans = new int[N];

        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        for(int i=0; i<M; i++){
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }

        for(int i=0; i<N; i++){
            min[i] = (long)Math.pow(10, 16);
            for(int j=0; j<M; j++){
                if(min[i]!=Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j])){
                    min[i] = Math.min(min[i], Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]));
                    if(min[i]==Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j])){
                        ans[i] = j+1;
                    }
                }
            }
        }
        for(int i=0; i<N; i++){
            System.out.println(ans[i]);
        }
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(){
    char x[1001]={'0'};
    int sum,i;
    while(1){
        sum=0;
        scanf("%s",x);
        if(x[0]=='0'){
            break;
        }
        for(i=0;i<1001;i++){
            if(x[i]!='\0'){
                sum+=x[i]-'0';
            }else{
                break;
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 2104
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int T = sc.nextInt();
   
   List<Integer> cost = new ArrayList<>();
   int c = 0;
   int t = 0;
   for(int i =0;i<N;i++) 
   {
     c = sc.nextInt();
     t = sc.nextInt();
     
     if(t<=T) cost.add(c);
   }
   
   if(cost.size() == 0) System.out.println("TLE");
   else 
   {
     Collections.sort(cost);
     System.out.println(cost.get(0));
   }
 }
}

Measured memory_bytes: 23764
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
using namespace std;

int main(){
  
  int n,k; cin >> n >> k;
  vector<vector<int>> nCk(n+1, vector<int>(n+1,0));

  for (int i=0; i<=n; i++){
    nCk[i][0]=1;
    nCk[i][i]=1;
    for (int j=1; j<=i-1; j++){
      nCk[i][j]=(nCk[i-1][j-1]+nCk[i-1][j]) % 1000000007;
    }
  }
  
  for (int i=1; i<=k; i++) cout << (long long)nCk[k-1][i-1]*nCk[n-k+1][i] % 1000000007 << endl;
 
  return 0;
}


Measured memory_bytes: 16000
dic = {}
for s in raw_input().split():
	dic[s] = dic.get(s, 0) + 1
val = dic.items()
most = sorted(val, key=lambda i:i[1], reverse=True)[0][0]
length = sorted(val, key=lambda i:len(i[0]), reverse=True)[0][0]
print '{0} {1}'.format(most, length)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n,k;
ll a[101];
int dp[100011];

bool dfs(int r){
  if(r==0)return false;
  if(dp[r]!=-1)return dp[r];
  bool res=false;
  rep(i,n){
    if(r-a[i]>=0&&!dfs(r-a[i]))res=true;
  }
  return dp[r]=res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  rep(i,n)cin>>a[i];
  memset(dp,-1,sizeof(dp));
  if(dfs(k))cout<<"First"<<endl;
  else cout<<"Second"<<endl;

  return 0;
}


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

int main() {
  // 入力
  string s;
  cin >> s;
  int size = s.size();

  bool ub = false;
  // 2連続探索
  for(int i=0; i<size-1; i++) {
    if(s[i] == s[i+1]) {
      printf("%d %d\n", i+1, i+2);
      return 0;
    }
  }
  // ABA型探索
  for(int i=0; i<size-2; i++) {
    if(s[i] == s[i+2]) {
      printf("%d %d\n", i+1, i+3);
      return 0;
    }
  }

  // アンバランスな部分文字列が存在しない
  printf("-1 -1\n");
  return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

int dp[1005][10005];

int main() {
  int h, n;
  cin >> h >> n;
  vi a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, 1005) rep(j, 10005) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i, n) rep(j, h+1) {
    chmin(dp[i+1][j], dp[i][j]);
    chmin(dp[i+1][min(j+a[i], h)], dp[i+1][j] + b[i]);
  }
  cout << dp[n][h] << endl;
}

Measured memory_bytes: 42888
from collections import deque
K=int(input())
lunlun=[]
q=deque(list(range(1,10)))
while 1:
    r=q.popleft()
    lunlun.append(r)
    n=str(r)[-1]
    if n!='0':
        q.append(r*10+int(n)-1)
    q.append(r*10+int(n))
    if n!='9':
        q.append(r*10+int(n)+1)
    if len(lunlun)>K:
        break
print(lunlun[K-1])

Measured memory_bytes: 76328
#include <vector>
#include <iostream>
using namespace std;
//S
struct SieveEratos{
  vector<bool> t;
  SieveEratos(int n):t(n+1,true){
    //素数だったらTrue
    t[0] = false;
    t[1] = false;
    for(int i = 2; n >= i; i++){
      if(t[i]){
        for(int j = i+i; n >= j; j+=i){
          t[j] = false;
        }
      }
    }
  }
  bool operator[](int x){
    return t[x];
  }
};
//E
int main(){
  int q;cin>>q;
  SieveEratos a(100010);
  vector<int> r;
  r.push_back(0);
  for(int i = 1; 100000 >= i; i++){
    
    r.push_back(r[r.size()-1]+(a[i] && a[(i+1)/2]));
  }
  for(int i = 0; q > i; i++){
    int y,z;cin>>y>>z;
    cout << r[z]-r[y-1] << endl;
  }

}


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

using namespace std;

typedef long long ll;

#define siz 100001
#define mod 1000000001

int main(){
	
	ll n;
	cin >> n;
	
	if(n%1000 != 0){
		cout << 1000 - (n%1000) << "\n";
	}else {
		cout << 0 << "\n";
	}
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 100000
#define maxv 10000

using namespace std;

int v[maxn+5], d[maxn+5];
multiset<int> ss1[maxv+5], ss2[maxv+5];

struct sgtree {
  sgtree () {}
  int yy[4*maxv+5];
  void rest () {
    for (int i = 1; i <= 4*maxv+1; i++) yy[i] = inf;
  }
  void update (int p, pii itv, int ok, int val) {
    if (ok < itv.fi || ok > itv.se) return;
    if (itv.fi == itv.se) { yy[p] = val; return; }
    int mid = (itv.fi + itv.se) / 2;
    update (p*2, {itv.fi, mid}, ok, val);
    update (p*2+1, {mid+1, itv.se}, ok, val);
    yy[p] = min(yy[p*2], yy[p*2+1]);
  }
  void preupdate (int ok, int val) { update (1, {1, maxv}, ok, val); }
  int q_query;
  void query (int p, pii itv, pii ok) {
    if (ok.fi > itv.se || itv.fi > ok.se) return;
    if (itv.fi >= ok.fi && itv.se <= ok.se) {
      q_query = min(q_query, yy[p]);
      return;
    }
    int mid = (itv.fi + itv.se) / 2;
    query (p*2, {itv.fi, mid}, ok);
    query (p*2+1, {mid+1, itv.se}, ok);
  }
  int prequery (pii ok) {
    q_query = inf;
    query(1, {1, maxv}, ok);
    return q_query;
  }
};

sgtree aint1, aint2;

void ryu (int i) {
  aint1.preupdate(v[i], d[i]-v[i]); ss1[v[i]].insert(d[i]-v[i]);
  aint2.preupdate(v[i], d[i]+v[i]); ss2[v[i]].insert(d[i]+v[i]);
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n, k; cin >> n >> k;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> v[i];
  fill(all(d), inf); aint1.rest(); aint2.rest();
  d[1] = 0; ryu(1);
  for (i = 1; i <= maxv; i++) {
    ss1[i].insert(inf);
    ss2[i].insert(inf);
  }
  for (i = 2; i <= n; i++) {
    d[i] = min(v[i]+aint1.prequery({1, v[i]}), -v[i]+aint2.prequery({v[i], maxv}));
    ryu(i);
    if (i > k) {
      ss1[v[i-k]].erase(ss1[v[i-k]].find(d[i-k]-v[i-k]));
      aint1.preupdate(v[i-k], (*ss1[v[i-k]].begin()));
      ss2[v[i-k]].erase(ss2[v[i-k]].find(d[i-k]+v[i-k]));
      aint2.preupdate(v[i-k], (*ss2[v[i-k]].begin()));
    }
  }
  cout << d[n];
  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    int a, b, c;
    string ans = "NO";
    cin >> a >> b >> c;
    for (int i = 1; i <= b; i++) {
        int d = a*i;
        if(d%b == c){
            ans = "YES";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
if n<600:
    print(8)
elif n<800:
    print(7)
elif n<1000:
    print(6)
elif n<1200:
    print(5)
elif n<1400:
    print(4)
elif n<1600:
    print(3)
elif n<1800:
    print(2)
else:
    print(1)


Measured memory_bytes: 61592
#coding:utf-8
def jyu_waru(a):
    x = a
    b = 0
    while x>10:
        x = x//10
        if x%10 ==3:
            b = a
            break
    return b

n = int(input().rstrip())
kazu =[]
x = 0
for i in range(1,n+1):
    if i%3==0:
        kazu.append(i)
        
    elif i%10 ==3:
        kazu.append(i)

    else:
        x = jyu_waru(i)
        if x != 0:
            kazu.append(i)

print(" " +" ".join(list(map(str,kazu))))

Measured memory_bytes: 8172
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b<c+d) cout<<"Right"<<endl;
    if(a+b>c+d) cout<<"Left"<<endl;
    if(a+b==c+d) cout<<"Balanced"<<endl;
}


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

int main(){

  int x, y;

  while(1){
    cin >> x >> y;
    if (x*x+y*y==0) break;
    cout << (x<=y)*x+(y<x)*y <<
      ' ' << (x>=y)*x+(y>x)*y << endl;
  }

  return 0;
}

Measured memory_bytes: 3112
import numpy as np
N, M = map(int, input().split())
AB = np.empty((N, 2), dtype=np.int64)
for n in range(N):
    AB[n, :] = list(map(int, input().split()))
AB = AB[AB[:, 0].argsort(), :]
n = 0
ans = 0
while M > 0:
    if M > AB[n, 1]:
        ans += AB[n, 0] * AB[n, 1]
        M -= AB[n, 1]
    else:
        ans += AB[n, 0] * M
        M = 0
    n += 1
print(ans)

Measured memory_bytes: 16372
N = int(input())
A = list(map(int, input().split()))
ans = 0
isEnd = False
while not isEnd:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i] // 2
        else:
            isEnd = True
            break
    if not isEnd:
        ans += 1
print(ans)


Measured memory_bytes: 9168
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
ll dp[51][51][3000] = {};
main(){
    int N,A;
    cin >> N >> A;
    vector<int> X(N);
    for(int i = 0;i < N;i++)cin >> X[i];
    dp[0][0][0] = 1;
    for(int i = 0;i < N;i++){
        for(int j = 0;j < 3000;j++){
            for(int k = 0;k < N;k++){
                dp[i+1][k][j] += dp[i][k][j];
                if(j - X[i] < 0)continue;
                dp[i+1][k+1][j] += dp[i][k][j - X[i] ];
            }
        }
    }
    ll sum = 0;
    for(int i = 1;i <= N;i++){
        sum += dp[N][i][A * i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 60032
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

const long long int MOD = 1e9 + 7;

long long int mypow(long long int a,long long int n)
{
	long long int res = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			res = ((res%MOD)*(a%MOD) % MOD) % MOD;
			res %= MOD;
		}
		a = ((a%MOD)*(a%MOD) % MOD) % MOD;
		a %= MOD;
		n /= 2;
	}
	return res;
}

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

	long long int n, a, b;

	cin >> n >> a >> b;

	long long int res = mypow(2,n);
	res -= 1;
	if (res < 0)
	{
		res += MOD;
	}

	long long int A = 1;

	if (a <= n - a)
	{
		long long int temp2 = a;
		long long int temp1 = n;
		while (temp2 > 0)
		{
			A = ((A%MOD)*(temp1%MOD) % MOD) % MOD;
			A %= MOD;
			A = ((A%MOD)*(mypow(temp2,MOD-2)%MOD) % MOD) % MOD;
			A %= MOD;
			temp1--;
			temp2--;
		}
		res -= A;
		if (res < 0)
		{
			res += MOD;
		}
	}
	else
	{
		long long int temp2 = n - a;
		long long int temp1 = n;
		while (temp2 > 0)
		{
			A = ((A%MOD)*(temp1%MOD) % MOD) % MOD;
			A %= MOD;
			A = ((A%MOD)*(mypow(temp2, MOD - 2) % MOD) % MOD) % MOD;
			A %= MOD;
			temp1--;
			temp2--;
		}
		res -= A;
		if (res < 0)
		{
			res += MOD;
		}
	}

	long long int B = 1;

	if (b <= n - b)
	{
		long long int temp2 = b;
		long long int temp1 = n;
		while (temp2 > 0)
		{
			B = ((B%MOD)*(temp1%MOD) % MOD) % MOD;
			B %= MOD;
			B = ((B%MOD)*(mypow(temp2, MOD - 2) % MOD) % MOD) % MOD;
			B %= MOD;
			temp1--;
			temp2--;
		}
		res -= B;
		if (res < 0)
		{
			res += MOD;
		}
	}
	else
	{
		long long int temp2 = n - b;
		long long int temp1 = n;
		while (temp2 > 0)
		{
			B = ((B%MOD)*(temp1%MOD) % MOD) % MOD;
			B %= MOD;
			B = ((B%MOD)*(mypow(temp2, MOD - 2) % MOD) % MOD) % MOD;
			B %= MOD;
			temp1--;
			temp2--;
		}
		res -= B;
		if (res < 0)
		{
			res += MOD;
		}
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 3568
import sys
from collections import deque

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N, M = in_nn()
    d = dict()

    for i in range(M):
        a, b = in_nn()
        if a in d:
            d[a] = min(d[a], b)
        else:
            d[a] = b

    edge = list(sorted(d.items(), key=lambda x: x[0], reverse=True))

    remove = deque()
    for a, b in edge:
        if remove:
            if b <= remove[0]:
                remove.appendleft(a)
        else:
            remove.appendleft(a)

    print(len(remove))


if __name__ == '__main__':
    main()


Measured memory_bytes: 29372
#include<stdio.h>
#include<string.h>
 
int main()
{
  	char inp[11];
  	scanf("%s", inp);
 
  	int j = 0;
  	char a[11] = {'\0'};
  	int n = strlen(inp);
  	int i;
  	for(i = 0; i < n; i++)
	{
	    if(inp[i] == '0')
		{
      		a[j]='0';
      		j++;
    	}
		else if (inp[i] == '1')
		{
	      	a[j]='1';
	      	j++;
    	}
		else if (inp[i] == 'B')
		{
      		if(j != 0)
		  	{
	        	j--;
	        	a[j]='\0';
	      	}
    	}
  	}
	  
  	printf("%s", a);
  	return 0;
}

Measured memory_bytes: 1700
use std::io::BufRead;

fn main() {
    let s = std::io::stdin();
    let mut buf = s.lock();
    let mut s = String::new();
    let (n, m) = {
        buf.read_line(&mut s).unwrap();
        let mut it = s.split_whitespace();
        let n: usize = it.next().unwrap().parse().unwrap();
        let m: usize = it.next().unwrap().parse().unwrap();
        (n, m)
    };
    let mut a = vec![(false, false); n];
    for _ in 0..m {
        s.clear();
        buf.read_line(&mut s).unwrap();
        let mut it = s.split_whitespace();
        let x: usize = it.next().unwrap().parse().unwrap();
        let y: usize = it.next().unwrap().parse().unwrap();
        if x == 1 {
            a[y - 1].0 = true;
        }
        if y == n {
            a[x - 1].1 = true;
        }
    }
    for (a, b) in a {
        if a && b {
            println!("POSSIBLE");
            return;
        }
    }
    println!("IMPOSSIBLE");
}


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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    priority_queue<int> pq;
    REPI(i, 3){
        int x; cin >> x;
        pq.push(x);
    }pq.pop();
    int ans = 0;
    REPJ(i, 2){
        ans += pq.top();
        pq.pop();
    }cout << ans;
}


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

#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define FILL(v,p) memset(v,p,sizeof v)
#define FIO ios::sync_with_stdio(NULL); cin.tie(NULL)
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define PI acos(-1.0)

const ll MOD = 1000000007;
const ll INF = 2000000000000000001LL;
const ld EPS = 1e-9;

int main()
{
    FIO;
    
    ll n;
    cin >> n;
    
    ll  x[n];
    for(int i=0;i<n;i++) cin >> x[i];
    
    ll ans= INF;
    for(int i=1;i<=100;i++)
    {
        ll tot=0;
        for(int j=0;j<n;j++)
        {
            ll val= x[j]-i;
            val*=val;
            tot+=val;
        }
        ans=min(tot,ans);
    }
    
    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>

using namespace std;
using llint = long long int;
#define int long long int

signed main()
{
  string str;
  string res = "";
  int n;
  cin >> str >> n;

  for (int i = 0; i < str.length(); i += n)
  {
    res.push_back(str.at(i));
  }

  cout << res << endl;

  return 0;
}


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

#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void input(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}

void solveTest(){


}

int main(){
	fastio();
	//input();

	/*int t;
	cin>>t;
	while(t--){
		solveTest();
	}*/
	ll w,h;
	cin>>w>>h;
	ll ans=0;
	if(w==1||h==1) cout<<1<<endl;
	else{
		cout<<(w*h+1)/2<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int H, W, ok = 1; char s[52][52];
int main() {
  scanf("%d %d", &H, &W);
  for(int i = 1; i <= H; i++) scanf("%s", &s[i][1]);
  for(int i = 1; i <= H && ok; i++) {
    for(int j = 1; j <= W && ok; j++) {
      if(s[i][j] == '.') continue;
      if(s[i-1][j] != '#' && s[i+1][j] != '#'
        && s[i][j-1] != '#' && s[i][j+1] != '#') {
        ok = 0;
      }
    }
  }
  printf("%s", ok?"Yes":"No");
}

Measured memory_bytes: 128
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; } return x; }
long lcm(long x, long y) { return (x / gcd(x, y) * y); }

int main(void) {

	long res = 1;
	long N; cin >> N;
	string S; cin >> S;

	for (int i = 1; i < N; i++) if (S[i - 1] != S[i]) res++;

	cout << res << endl;
}

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

signed main(){
  const int INF=1e9+7;
  string s;
  cin>>s;
  int N=s.size();
  std::vector<int> a(N,0),c(N,0),q(N,0);
  for(int i=0;i<N;i++){
    if(s[i]=='A')a[i]++;
    if(s[i]=='C')c[i]++;
    if(s[i]=='?')q[i]++;
  }
  for(int i=1;i<N;i++){
    a[i]+=a[i-1];
    q[i]+=q[i-1];
  }
  int Q=q[N-1];
  int ans=0;
  for(int i=N-2;i>=0;i--)c[i]+=c[i+1];
  if(Q<=4){
    for(int i=1;i<N-1;i++){
      if(s[i]=='B'){
        int k;
        k=a[i-1]*c[i+1];
        k%=INF;
        for(int i=0;i<Q;i++){k*=3;k%=INF;}
        ans+=k;ans%=INF;
        k=q[i-1]*c[i+1];
        k%=INF;
        for(int i=0;i<Q-1;i++){k*=3;k%=INF;}
        ans+=k;ans%=INF;
        k=a[i-1]*(Q-q[i-1]);
        k%=INF;
        for(int i=0;i<Q-1;i++){k*=3;k%=INF;}
        ans+=k;ans%=INF;
        k=q[i-1]*(Q-q[i-1]);
        k%=INF;
        for(int i=0;i<Q-2;i++){k*=3;k%=INF;}
        ans+=k;ans%=INF;
      }
      if(s[i]=='?'){
        int k;
        k=a[i-1]*c[i+1];
        k%=INF;
        for(int i=0;i<Q-1;i++){k*=3;k%=INF;}
        ans+=k;ans%=INF;
        k=q[i-1]*c[i+1];
        k%=INF;
        for(int i=0;i<Q-2;i++){k*=3;k%=INF;}
        ans+=k;ans%=INF;
        k=a[i-1]*(Q-q[i]);
        k%=INF;
        for(int i=0;i<Q-2;i++){k*=3;k%=INF;}
        ans+=k;ans%=INF;
        k=q[i-1]*(Q-q[i]);
        k%=INF;
        for(int i=0;i<Q-3;i++){k*=3;k%=INF;}
        ans+=k;ans%=INF;
      }
    }
    cout<<ans<<endl;
  }
  else{
    int jk=1;
    for(int i=0;i<Q-3;i++){jk*=3;jk%=INF;}
    for(int i=1;i<N-1;i++){
      if(s[i]=='B'){
        int k;
        k=a[i-1]*c[i+1];
        k%=INF;
        k*=jk*27;k%=INF;
        ans+=k;ans%=INF;
        k=q[i-1]*c[i+1];
        k%=INF;
        k*=jk*9;k%=INF;
        ans+=k;ans%=INF;
        k=a[i-1]*(Q-q[i-1]);
        k%=INF;
        k*=jk*9;k%=INF;
        ans+=k;ans%=INF;
        k=q[i-1]*(Q-q[i-1]);
        k%=INF;
        k*=jk*3;k%=INF;
        ans+=k;ans%=INF;
      }
      if(s[i]=='?'){
        int k;
        k=a[i-1]*c[i+1];
        k%=INF;
        k*=jk*9;k%=INF;
        ans+=k;ans%=INF;
        k=q[i-1]*c[i+1];
        k%=INF;
        k*=jk*3;k%=INF;
        ans+=k;ans%=INF;
        k=a[i-1]*(Q-q[i]);
        k%=INF;
        k*=jk*3;k%=INF;
        ans+=k;ans%=INF;
        k=q[i-1]*(Q-q[i]);
        k%=INF;
        k*=jk;k%=INF;
        ans+=k;ans%=INF;
      }
    }
    cout<<ans<<endl;
  }
  }


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int w,h;
  cin >> h >> w;
  vector<vector<char>> a(w,vector<char>(h));
  rep(i,h){
    rep(j,w) cin >> a[j][i];
  }
  rep(i,h*2){
    rep(j,w) cout << a[j][i/2];
    cout << endl;
  }
}


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

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	int k=a;
	bool d[101]={};
	bool l=false;
	while(1){
		if(d[k%b]){
			l=true;
			break;
		}
		d[k%b]=true;
		if(k%b==c)break;
		k+=a;
	}
	if(l)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}


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

int main(){
	string s;
    cin >> s;
    if(s.substr(0, 4) == "2019"){
        if(s[5] == '0' && s[6] < '5') {
            cout << "Heisei" << "\n";
        }else{
            cout << "TBD" << "\n";
        }
    }else{
        if(stoi(s.substr(0, 4)) < 2019){
            cout << "Heisei" << "\n";
        }else{
            cout << "TBD" << "\n";
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)

{
 int a,b,d,r;
 double f;
 scanf("%d",&a);
 scanf("%d",&b);

 d=a/b;
 r=a%b;
 f=(double)a/b;
 
 printf("%d %d %f\n",d,r,f);
 
 return 0;
}


 

Measured memory_bytes: 632
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

bool yearsort(vector<ll> a, vector<ll> b){
	return a[2] < b[2];
}

int main(){
	ll n, m, pr[100005], ans[100005][2], p, y;
	
	cin >> n >> m;
	
	vector<vector<ll> > cities(m);
	REP(i,m){
		cin >> p >> y;
		cities[i].push_back(i);
		cities[i].push_back(p);
		cities[i].push_back(y);
	}
	sort(cities.begin(), cities.end(), yearsort);
	
	REP(i,100005){
		pr[i] = 0;
	}
	
	REP(i,m){
		pr[cities[i][1]]++;
		ans[cities[i][0]][0] = cities[i][1];
		ans[cities[i][0]][1] = pr[cities[i][1]];
 	}
	REP(i,m){
		printf("%06lld%06lld\n", ans[i][0], ans[i][1]);
	}
	return 0;
}


Measured memory_bytes: 11512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, d, x, *a = map(int, read().split())

cnt = 0
for i in a:
    if i == 1:
        cnt += d
    elif d % i == 0:
        cnt += d//i
    else:
        cnt += d // i + 1
print(cnt+x)


Measured memory_bytes: 9116
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=1005,M=1e5+5;
int p[N],vis[M];ll a[N][N];
int n,m;
void init(int n=1e5){
	for(R int i=2;i<=n;++i){
		if(!vis[i])p[++m]=i;
		if(m==1000)return;
		for(R int j=1;j<=m&&i*p[j]<=n;++j){
			vis[i*p[j]]=1;
			if(i%p[j]==0)break;
		}
	}
}
inline ll lcm(R ll x,R ll y){return x&&y?x/__gcd(x,y)*y:x+y;}
inline ll calc(R int i,R int j){
	return lcm(lcm(a[i-1][j],a[i+1][j]),lcm(a[i][j-1],a[i][j+1]))+1;
}
int main(){
//	freopen("testdata.in","r",stdin); 
	init();
	scanf("%d",&n);
	if(n==2)return puts("4 7\n23 10\n"),0;
	fp(i,1,n)fp(j,1,n)if((i+j)&1^1)a[i][j]=1ll*p[(i+j)>>1]*p[n+((i-j)>>1)+((n+1)>>1)];
	fp(i,1,n)fp(j,1,n)if(!a[i][j])a[i][j]=calc(i,j);
	fp(i,1,n)fp(j,1,n)printf("%lld%c",a[i][j]," \n"[j==n]);
	return 0;
}

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

typedef long long ll;

int main () {

    string s;
    string res = "";
    cin >> s;
    for(auto& e : s) {
	if(e == '0') res += "0";
	else if(e == '1') res += "1";
	else {
	    if( res.size() >0 )
		res = res.substr(0,res.size()-1);
	}
    }
    cout << res << endl;
    

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

A, B = map(int, input().split())

C = A + B

if A%3 == 0:
    print('Possible')
elif B%3 == 0:
    print('Possible')
elif C%3 == 0:
    print('Possible')
else:
    print('Impossible')

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int gcd(int x, int y) {
    if(x<y) return gcd(y,x);
    if(y==0) return x;
    return gcd(y, x%y);
}


int main() {
    int a, b;
    while(true) {
        cin >> a;
        if(cin.eof()) break;
        cin >> b;
        int g=gcd(a, b);
        cout << g << " " << (a/g)*b << endl;
    }
    return 0;
}


Measured memory_bytes: 3000
#include<iostream>
#include<vector>
#include<utility>

int main(){
	int n, m;
	std::cin >> n >> m;
	std::vector<std::pair<int, int> > ans;

	if(n % 2){
		for(int l = 1, r = n-1; l < r; l++, r--){
			ans.emplace_back(l, r);
		}
	}else{
		bool flag = false;
		for(int l = 1, r= n-1; l < r; l++, r--){
			if(!flag && r-l <= n/2){
				--r;
				flag = true;
			}
			ans.emplace_back(l, r);
		}
	}

	for(int i=0; i<m; i++){
		std::cout << ans[i].first << " " << ans[i].second << std::endl;
	}
	return 0;
}

Measured memory_bytes: 4312