akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize(2)
//#pragma GCC optimize("Ofast,unroll-loops")

#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
#define rrep(i, beg, end) for (int i = (beg); i >= (end); i--)
#define sp(i) setprecision(i) << fixed
typedef long long ll;
typedef pair<ll, ll> P;
typedef unsigned long long ull;
const int INF = 2e9;
const int mod = 1e9 + 7;
const int N = 1010;
ull p_hash(ull x, ull y) { return (x + y) * (x + y + 1) / 2 + y; } //NxN->N
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int h, w, ch, cw, dh, dw;
char s[N][N];
bool mark[N][N];
int link[N][N];
set<int> g[N * N];
int cnt = 1;
void dfs1(int x, int y)
{
    int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
    link[x][y] = cnt;
    rep(i, 0, 4)
    {
        int xx = x + dx[i], yy = y + dy[i];

        if (xx >= 1 && xx <= h && yy >= 1 && yy <= w && s[xx][yy] == '.' && !mark[xx][yy])
        {
            mark[xx][yy] = true;
            dfs1(xx, yy);
        }
    }
}

void dfs2(int x, int y)
{
    int dx[] = {-2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2};
    int dy[] = {-2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2};

    rep(k, 0, 24)
    {
        int xx = x + dx[k], yy = y + dy[k];
        if (xx >= 1 && xx <= h && yy >= 1 && yy <= w && s[xx][yy] == '.' && link[xx][yy] != link[x][y])
        {
            g[link[xx][yy]].insert(link[x][y]);
            g[link[x][y]].insert(link[xx][yy]);
        }
    }

    int dxx[] = {0, 1, 0, -1}, dyy[] = {1, 0, -1, 0};

    rep(i, 0, 4)
    {
        int xx = x + dxx[i], yy = y + dyy[i];

        if (xx >= 1 && xx <= h && yy >= 1 && yy <= w && s[xx][yy] == '.' && !mark[xx][yy])
        {
            mark[xx][yy] = true;
            dfs2(xx, yy);
        }
    }
}

int dis[N * N];
int bfs(int s)
{
    memset(dis, -1, sizeof dis);
    dis[s] = 0;
    queue<int> q;
    q.push(s);
    while (!q.empty())
    {
        int now = q.front();
        q.pop();
        for (int v : g[now])
        {
            if (dis[v] == -1)
            {
                q.push(v);
                dis[v] = dis[now] + 1;
                if (v == link[dh][dw])
                    return dis[v];
            }
        }
    }
    return dis[link[dh][dw]];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> h >> w;
    cin >> ch >> cw;
    cin >> dh >> dw;
    rep(i, 1, h + 1)
    {
        string in;
        cin >> in;
        rep(j, 1, w + 1)
        {
            s[i][j] = in[j - 1];
        }
    }

    rep(i, 1, h + 1)
    {
        rep(j, 1, w + 1)
        {
            if (s[i][j] == '.' && !mark[i][j])
            {
                mark[i][j] = true;
                dfs1(i, j);
                cnt++;
            }
        }
    }

    memset(mark, 0, sizeof mark);
    rep(i, 1, h + 1)
    {
        rep(j, 1, w + 1)
        {
            if (s[i][j] == '.' && !mark[i][j])
            {
                mark[i][j] = true;
                dfs2(i, j);
            }
        }
    }
    cout << bfs(link[ch][cw]) << endl;

    return 0;
}

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

int n, a[100010][3], dp[100010][3];
int main(){
  cin>>n;
  
  for(int i=0;i<n;i++)for(int j=0;j<3;j++)cin>>a[i][j];
  
  
  for(int i=0;i<n;i++)for(int j=0;j<3;j++)for(int k=0;k<3;k++){
    if(j!=k){
      dp[i+1][j]=max(dp[i][k]+a[i][j], dp[i+1][j]);
    }
  }
  
  cout<<max({dp[n][0], dp[n][1], dp[n][2]})<<endl;
  return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(int i=cc;i>=n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>>left(h,vector<int>(w)),right(h,vector<int>(w)),
    up(h,vector<int>(w)),down(h,vector<int>(w));
    vector<string>board(h);
    rep(i, 0, h)cin >> board[i];
    rep(i, 0, h){
        int cnt = 0; 
        rep(j, 0, w){
            if(board[i][j]=='#')cnt = 0;
            else cnt++;
            left[i][j] = cnt;
        }
    }
    rep(i, 0, h){
        int cnt = 0; 
        rrep(j, w-1, 0){
            if(board[i][j]=='#')cnt = 0;
            else cnt++;
            right[i][j] = cnt;
        }
    }
    rep(j, 0, w){
        int cnt = 0; 
        rep(i, 0, h){
            if(board[i][j]=='#')cnt = 0;
            else cnt++;
            up[i][j] = cnt;
        }
    }
    rep(j, 0, w){
        int cnt = 0; 
        rrep(i, h-1, 0){
            if(board[i][j]=='#')cnt = 0;
            else cnt++;
            down[i][j] = cnt;
        }
    }
    int ans = 0;
    rep(i, 0, h){
        rep(j, 0, w){
            chmax(ans, left[i][j]+right[i][j]+up[i][j]+down[i][j]-3);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 73964
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;

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



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

    int H,W;
    cin>>H>>W;

    string S[H];
    rep(i,H) cin>>S[i];

    int sh=0,sw=0,gh=H-1,gw=W-1;

    vector<vector<int>> dist(H,vector<int>(W,-1) );
    queue<pair<int,int>> que;
    que.push(make_pair(sh,sw));
    dist[sh][sw]=0;
    while(!que.empty()){
        pair<int,int> v=que.front();
        que.pop();
        int h=v.first;
        int w=v.second;
        rep(j,4){
            int nh=h+dx[j];
            int nw=w+dy[j];

            if(nh<0||nw<0||nh>=H||nw>=W) continue;
            if(S[nh][nw]=='#') continue;
            if(dist[nh][nw]==-1){
                dist[nh][nw]=dist[h][w]+1;
                que.push(make_pair(nh,nw));
            }
        }

    }
    int ans=0;
    rep(i,H){
        rep(j,W){
            if(i==0&&j==0) continue;
            if(S[i][j]=='.') ans++;
        }
    }
    if(dist[gh][gw]==-1) ans=-1;
    else ans-=dist[gh][gw];
    cout << ans << endl;

    





}


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
x3 = x2+y1-y2
y3 = y2+x2-x1
x4 = x1+y1-y2
y4 = y1+x2-x1
print("{0} {1} {2} {3}".format(x3,y3,x4,y4))

Measured memory_bytes: 2940
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let n = s.len() as usize;

    let mut dp = vec![vec![0i64; 13]; n];

    for i in 0..n {
        if i == 0 {
            if s[i] == '?' {
                for j in 0..10 {
                    dp[i][j] = 1;
                }
            } else {
                let c = s[i] as usize - '0' as usize;
                for j in 0..13 {
                    if j == c {
                        dp[i][j] = 1;
                    }
                }
            }
        } else {
            if s[i] == '?' {
                for j in 0..10 {
                    for k in 0..13 {
                        if dp[i - 1][k] != -1 {
                            dp[i][(k * 10 + j) % 13] += dp[i - 1][k]
                        }
                    }
                }
            } else {
                let c = s[i] as usize - '0' as usize;
                for k in 0..13 {
                    if dp[i - 1][k] != -1 {
                        dp[i][(k * 10 + c) % 13] += dp[i - 1][k];
                    }
                }
            }
        }

        for j in 0..13 {
            dp[i][j] %= 1000000007;
            //println!("({}, {}): {}", i, j, dp[i][j]);
        }
    }
    println!("{}", dp[n - 1][5]);
}


Measured memory_bytes: 18684
import math
N,M,K=map(int,input().split())
mod=10**9+7
ans=0
for i in range(1,N):
  l=(N+1-i)*(N-i)//2%mod 
  ans+=l*M*M
  ans%mod
for i in range(1,M):
  l=(M+1-i)*(M-i)//2%mod 
  ans+=l*N*N
  ans%mod
  
def c_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
                                 
ans*=c_count(M*N-2,K-2)%mod
print(ans%mod)

Measured memory_bytes: 74588
n = int(input())
s = []
for _ in range(n):
    s.append(input())
s = sorted(s)
s.append('')
tmp_max = []
tmp = ''
cnt_max = 0
cnt = 0
for ss in s:
    if tmp == ss:
        cnt += 1
    else:
        if cnt > cnt_max:
            cnt_max = cnt
            tmp_max = []
        if cnt == cnt_max:
            tmp_max.append(tmp)
        tmp = ss
        cnt = 1
tmp_max = sorted(tmp_max)
for t in tmp_max:
    print(t)

Measured memory_bytes: 21544
#include <stdio.h>

int r(char in);
void quick_sort (int array[], int left, int right);
int partition (int array[], int left, int right);
void swap (int *x,  int *y);

int main(){
    char s[200001] = {'0'};
    char t[200001] = {'0'};

    int ar_s[26] = {0};
    int ar_[26] = {0};

    scanf("%s",s);
    scanf("%s",t);


    for (int i = 0; i < 200001; i++) {
        if (r(s[i]) != -1) {
            ar_s[r(s[i])]++;
        }
        if (r(t[i]) != -1) {
            ar_[r(t[i])]++;
        }
    }

/*
    for (int i = 0; i < 26; i++) {
        printf("%d ",ar_s[i]);
    }
    printf("\n");

    for (int i = 0; i < 26; i++) {
        printf("%d ",ar_[i]);
    }
    printf("\n");
    */


    quick_sort(ar_s,0,25);
    quick_sort(ar_,0,25);

/*    for (int i = 0; i < 26; i++) {
        printf("%d ",ar_s[i]);
    }
    */

   int buf = 0;
    for (int i = 0; i < 26; i++) {
        if (ar_s[i] != ar_[i]) {
            buf = 1;
        }
    }

    if (buf == 1) {
        printf("No");
    } else {
        printf("Yes");
    }
    
    return 0; 
    
	
}

int r(char in){
    switch (in) {
        case 'a':
        return 0;
        case 'b':
        return 1;
        case 'c':
        return 2;
        case 'd':
        return 3;
        case 'e':
        return 4;
        case 'f':
        return 5;
        case 'g':
        return 6;
        case 'h':
        return 7;
        case 'i':
        return 8;
        case 'j':
        return 9;
        case 'k':
        return 10;
        case 'l':
        return 11;
        case 'm':
        return 12;
        case 'n':
        return 13;
        case 'o':
        return 14;
        case 'p':
        return 15;
        case 'q':
        return 16;
        case 'r':
        return 17;
        case 's':
        return 18;
        case 't':
        return 19;
        case 'u':
        return 20;
        case 'v':
        return 21;
        case 'w':
        return 22;
        case 'x':
        return 23;
        case 'y':
        return 24;
        case 'z':
        return 25;

        default:
        return -1;
    }

}



 
void swap (int *x,  int *y) {
  int temp;    // 値を一時保存する変数
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする
 
  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]);}
  } while (i < j);
 
  swap(&array[pivot], &array[j]);   //pivotを更新
 
  return j;
}
 
/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;
 
  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int O[26];
string A;
bool V;

int main(void){
	//IO("test.in", "test.out");
	cin >> A;
	V = true;
	for(int i = 0; i < A.length(); i++)
		if(A[i] - 'a' > -1 && A[i] - 'a' < 26) O[A[i] - 'a']++;
	for(int i = 0; i < 26; i++)
		if(O[i] % 2 != 0) V = false;
	if(V) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    static int N;
    static int T;
    static int A;
    static int []elevations;
    public static void main(String[] args) {
        N = sc.nextInt();
        T = sc.nextInt();
        A = sc.nextInt();
        //how to convert tokenized string to int array? 
        elevations = new int[N];
        for(int i = 0; i < N; ++i) {
            elevations[i] = sc.nextInt();
        }
        double minDiff = Math.abs(A - avgTemp(0));
        int minIndex = 0;
        for(int i = 0; i< N;++i) {
            double diff = Math.abs(A - avgTemp(i));
            if(diff < minDiff) {
                minDiff = diff;
                minIndex = i;
            }
          /*System.out.println(i+" "+diff);
          System.out.println("minDiff="+minDiff);
          System.out.println("minIndex="+minIndex);*/
        }
        System.out.println(minIndex + 1);
    }
    public static double avgTemp(int index) {
        double res = 0.0;
        res = T - (elevations[index] * 0.006);
      //System.out.println("avgTemp="+res);
        return res;
    }

}


Measured memory_bytes: 24020
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;

  vector<int> h(n);
  REP(i,n){
    cin >> h[i];
  }

  int dp[100010];
  REP(i,n+1){
    dp[i] = INF;
  }
  dp[0] = 0;
  REP(i,n){
    if(i + 1 < n){
      dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
    }
    if(i + 2 < n){
      dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }
  }

  cout << dp[n-1] << endl;
  return 0;
}



Measured memory_bytes: 1024
///                ..:: In The Name Of God ::..
#include <bits/stdc++.h>
using namespace std;
//配列の要素数は　sizeof(ar)/sizeof(ar[0]) で求める
int N,M;
double X;
signed main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    X = ceil(N/(1.08));
    M = floor(X*(1.08));
    if(M == N){
        cout << X;
    }
    else{
        cout << ":(";
    }
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int cnt[100000];
  rep(i,0,100000) cnt[i]=0;
  rep(i,0,n){
    int a;
    cin>>a;
    cnt[a]++;
  }
  int ans=0;
  rep(i,1,100000-1){
    int cur=cnt[i-1]+cnt[i]+cnt[i+1];
    ans=max(ans,cur);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())
d={'r':p,'s':r,'p':s}
#r:グー、s:チョキ、p:パー
ans=t.count('r')*d['r']+t.count('s')*d['s']+t.count('p')*d['p']
#print(ans)
for i in range(k,n):
  if t[i]==t[i-k]:
    ans-=d[t[i]]
    t[i]='x'
print(ans)



Measured memory_bytes: 4084
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}
struct edge {
	int from, to;
	ll a, b;
};

struct state {
	int cur;
	ll silver, time;
	int buyIdx;
	state(int cur, ll silver, ll time) :
			cur(cur), silver(silver), time(time) {
	}
	bool operator<(const state &o) const {
		return time > o.time;
	}
};

const int N = 51, MAX = 51 * 109;
vector<edge> adj[N];
pair<ll, ll> cost[N];
ll dis[N][MAX + 1];
int s;
void dijkstra() {
	memset(dis, INF, sizeof(dis));
	priority_queue<state> q;
	q.push(state(1, s, 0));
	dis[1][s] = 0;
	while (sz(q)) {
		int cur = q.top().cur;
		ll silver = q.top().silver;
		ll time = q.top().time;
		int buyIdx = q.top().buyIdx;
		q.pop();
		if (dis[cur][silver] < time)
			continue;
		ll nxtTime = (time + cost[cur].second);
		ll nxtSilver = min(1LL * MAX, silver + cost[cur].first);
		if (dis[cur][nxtSilver] > nxtTime) {
			dis[cur][nxtSilver] = nxtTime;
			q.push(state(cur, nxtSilver, nxtTime));
		}
		for (auto ch : adj[cur]) {
			ll nxtTime = (time + ch.b);
			ll nxtSilver = (silver - ch.a);
			if (nxtSilver < 0)
				continue;
			if (dis[ch.to][nxtSilver] > nxtTime) {
				dis[ch.to][nxtSilver] = nxtTime;
				q.push(state(ch.to, nxtSilver, nxtTime));
			}
		}
	}
}
int main() {
	run();
	int n, m;
	cin >> n >> m >> s;
	s = min(s, MAX);
	while (m--) {
		edge e;
		cin >> e.from >> e.to >> e.a >> e.b;
		adj[e.from].push_back(e);
		swap(e.from, e.to);
		adj[e.from].push_back(e);
	}
	for (int i = 1; i <= n; i++)
		cin >> cost[i].first >> cost[i].second;
	dijkstra();
	for (int i = 2; i <= n; i++) {
		ll mn = INF;
		for (int si = 0; si <= MAX; si++)
			mn = min(mn, dis[i][si]);
		cout << mn << "\n";
	}
}


Measured memory_bytes: 13772
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N, K;

int main()
{
    cin >> N >> K;
    ll ans = 0;
    for (ll i = K; i <= N + 1; i++)
    {
        ll minsum = i * (i - 1) / 2;
        minsum %= MOD;
        ll maxsum = (N + (N - i + 1)) * i / 2;
        maxsum %= MOD;
        ans += (MOD + maxsum - minsum + 1) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


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

int main() {
	long long N, ANS = 0;
	string S;
	char NOW = ' ';
	cin >> N >> S;
	for (int i = 0; i < N; i++) {
		if (NOW != S[i]) {
			ANS++;
			NOW = S[i];
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
int main(){
    ll n,x,ans;
    ans = 0;
    cin >> n;
    vector<ll> a;
    vector<ll> b;
    vector<ll> c;
    for(int i = 0;i < n;i++){
        cin >> x;
        a.push_back(x);
    }
    for(int i = 0;i < n;i++){
        cin >> x;
        b.push_back(x);
    }
    for(int i = 0;i < n;i++){
        cin >> x;
        c.push_back(x);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    for(int i = 0;i < n;i++){
        ans += (lower_bound(ALL(a),b[i])-a.begin())*(c.end()-upper_bound(ALL(c),b[i]));
    }  
    cout << ans << endl;  
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string O, E; cin >> O >> E;
    string res;
    range(i, 0, O.size() + E.size()) {
        if (i % 2 == 0) res.push_back(O.at(i / 2));
        else res.push_back(E.at(i / 2));
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mk make_pair
#define pb push_back
#define vi vector<int>
#define x first
#define y second
#define ms(a,b)  memset(a, b, sizeof(a))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define M 100005
int dp[M];
signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i-a[j]>=0)
                dp[i]=dp[i-a[j]]^1;
            if(dp[i]==1)break;    
        }
    }
    if(dp[k])cout<<"First";
    else
        cout<<"Second";
    return 0;
}

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

#include<cmath>
#define PI 3.1415926535898

int main(){

  int step,dir;

  double x=0.0,y=0.0,angle=0.0;

  while(1){
    scanf("%d,%d",&step,&dir);
    if(step == 0 && dir == 0)break;

    x+=(double)(step)*sin(angle/180.0*PI);
    y+=(double)(step)*cos(angle/180.0*PI);

    angle +=(double)dir;
    
  }

  cout << (int)x << endl << (int)y << endl;

  return 0;

}

Measured memory_bytes: 0
def digit_sum(i):
    return sum(map(int, list(str(i))))

def score(head, tail):
    return num(head, tail)/digit_sum(num(head, tail))

def num(head, tail):
    return int(str(head)+tail)

k = int(input())
tail = ''
head = 0
cnt = 0
last = 0
while True:
    head += 1
    if score(head, tail) <= score(head+1, tail):
        if num(head, tail) > last:
            print(str(head)+tail)
            last = num(head, tail)
            cnt += 1
            if cnt == k:
                break
    else:
        head = 0
        tail += '9'

Measured memory_bytes: 3188
n,m=map(int,input().split())
a=[]
total=0
for i in range(n):
    k=list(input().split())
    ''.join(k)
    a.extend(k[1:len(k)])
for i in range(1,m+1):
    if a.count(str(i))==n:
        total+=1
print(total)

Measured memory_bytes: 38256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<int Modulo = MOD> struct Mint {
	lint val;
	constexpr Mint(lint v = 0) noexcept : val(v % Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		lint a = r.val, b = Modulo, u = 1, v = 0, t;
		while (b) {
			t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream &operator << (ostream &os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream &is, Mint<Modulo>& x) noexcept {
		lint tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo> &a, lint n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	string s1, s2;
	cin >> s1 >> s2;

	bool vert = (s1[0]!=s2[0]);
	mint ans = vert ? 6 : 3;
	for (int i = vert ? 2 : 1; i < N; i++) {

		if (s1[i] == s2[i]) {
			if (!vert) ans *= 2;
			vert = false;
		}
		else {
			if (vert) ans *= 3;
			else ans *= 2;
			i++;
			vert = true;
		}

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(void){
	int n;
	int min = 100;			//10の倍数でない、一番小さい数	
	cin >> n;
	int t_ten = 0;		//試験の合計点

	int *s = new int[n];		//要素数nの動的生成配列
	for(int i=0; i < n; i++){
		cin >> s[i];
		t_ten += s[i];

		if(min > s[i] && (s[i] % 10 != 0)  ){
			min = s[i];
		}
	}

	
	if( (t_ten % 10 ) == 0 ){
		t_ten -= min;
		if( (t_ten % 10 ) == 0 ){
			t_ten = 0;
		}
	}
	cout << t_ten;
	cout << "\n";
	return 0;
}

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

int n;
int p[20+10];

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

    int cnt = 0;
    for (int i = 1; i < n-1; i++) {
        if (p[i-1] < p[i] && p[i] < p[i+1]) {
            cnt++;
        }
        else if (p[i+1] < p[i] && p[i] < p[i-1]) {
            cnt++;
        }
    }

    cout << cnt << endl;
    

    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left


def check(x, m):
    # 幸福度が x 以上となる握手が m 通り以上か
    cnt = 0
    for i in range(N):
        y = x - A[i]
        p = bisect_left(A, y)
        cnt += N - p
    return cnt >= m


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

S = [0] * (N + 1)
for i, a in enumerate(A):
    S[i + 1] = S[i] + a

ok = 0
ng = 2 * 10 ** 5 + 1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if check(mid, M):
        ok = mid
    else:
        ng = mid

X = ok
ans = 0
cnt = 0
amari = 2 * 10 ** 5 + 1
for i in range(N):
    Aj = X - A[i]
    j = bisect_left(A, Aj)
    ans += S[N] - S[j] + A[i] * (N - j)
    cnt += N - j
    if j < N:
        amari = min(amari, A[i] + A[j])

print(ans - (cnt - M) * amari)


Measured memory_bytes: 14428
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <iostream>

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

using namespace std;


int main() {
    int N, K;
    int D[10];
    scanf("%d %d", &N, &K);
    REP(i, K) scanf(" %d", &D[i]);
    string str_i;
    bool flag=false;
    FOR(i, N, 100001){
        flag = false;
        str_i = std::to_string(i);
        REP(j, str_i.length()){
            REP(k, K){
                if((int)str_i[j]-48==D[k]){
                    flag = true;
                    break;
                }
            }
            if(flag) break;
        }
        //printf("%d\n", (int)str_i[0]);
        if(flag) continue;

        printf("%d\n", i);
        break;
    }
    return 0;
}

Measured memory_bytes: 256
a,b,w,n,i,t[31];
main(){
    for(i=0;i<=30;t[i]=++i);
    for(scanf("%d%d",&w,&n);~scanf("%d,%d",&a,&b);t[a]^=t[b]^=t[a]^=t[b]);
    for(i=0;i<w;printf("%d\n",t[++i]));
}

Measured memory_bytes: 1844
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, K;
ll S[200009];
vector<ll> V;

template<class V, int ME> class BIT{
public:
    V bit[1<<ME], val[1<<ME];
    V total(int e) {V s=0;e++;while(e) s+=bit[e-1],e-=e&-e;return s;}
    V add(int e,V v) {val[e++]+=v;while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
    V set(int e,V v) {add(e,v-val[e]);}
    int lower_bound(V val) {
        V tv=0; int ent=0;
        rrep(i,ME-1) if(tv+bit[ent+(1<<i)-1]<val) tv+=bit[ent+(1<<i)-1],ent+=(1<<i);
        return ent;
    }
};

BIT<int,20> bit;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>K;
    V.push_back(-LLINF);
    V.push_back(0);
    rep(i,N){
        int a; cin>>a;
        a-=K;
        S[i+1] = S[i]+a;
        V.push_back(S[i+1]);
    }
    sort(all(V));
    ll ret=0;
    int added=0;
    rrep(i,N-1){
        int x=lower_bound(all(V),S[i+1])-V.begin();
        added++;
        bit.add(x,1);
        int y=lower_bound(all(V),S[i])-V.begin();
        ret+=added-bit.total(y-1);
    }
    cout1(ret);
}

Measured memory_bytes: 8432
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>
using namespace std;

int main() {
	string A, B;
	cin >> A >> B;
	if (A.size() > B.size()) {
		cout << "GREATER" << endl;
		return 0;	
	}
	if (A.size() < B.size()) {
		cout << "LESS" << endl;
		return 0;
	}	
	if (A.size() == B.size()) {
		for (int i = 0; i < A.size(); i++) {
			if (A[i] > B[i]) {
				cout << "GREATER" << endl;
				return 0;
			}
			if (A[i] < B[i]) {
				cout << "LESS" << endl;
				return 0;
			}
		}
	}
	cout << "EQUAL" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
f = sys.stdin


n = int(f.readline())

for line in f:
    x, y, b, p = map(int, line.split())
    regular = x * b + y * p
    discount = int(x * 0.8) * max(b, 5) + int(y * 0.8) * max(p, 2)
    print(min(regular, discount))

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

int main(){
    vector<vector<int>> m;
    vector<int> k;
    int n, q, t, c, cnt;
    bitset<64> x(0uL);
    cin >> n;
    rep(i, n){
        cin >> t;
        k.push_back(t);
        m.push_back(vector<int>());
        rep(j ,k.at(i)){
            cin >> t;
            m.at(i).push_back(t);
        }
    }
    cin >> q;
    bool flag;
    rep(i, q){
        cin >> c;
        switch(c){
            case 0:
                cin >> t;
                cout << (x.test(t) ? "1" : "0") << endl;
                break;
            case 1:
                cin >> t;
                for(auto i = m.at(t).begin(); i != m.at(t).end(); i++){
                    x.set(*i, true);
                }
                break;
            case 2:
                cin >> t;
                for(auto i = m.at(t).begin(); i != m.at(t).end(); i++){
                    x.reset(*i);
                }
                break;
            case 3:
                cin >> t;
                for(auto i = m.at(t).begin(); i != m.at(t).end(); i++){
                    x.flip(*i);
                }
                break;
            case 4:
                cin >> t;
                flag = true;
                for(auto i = m.at(t).begin(); i != m.at(t).end(); i++){
                    flag = flag && x.test(*i);
                }
                cout << (flag ? "1" : "0") << endl;
                break;
            case 5:
                cin >> t;
                flag = false;
                for(auto i = m.at(t).begin(); i != m.at(t).end(); i++){
                    flag = flag || x.test(*i);
                }
                cout << (flag ? "1" : "0") << endl;
                break;
            case 6:
                cin >> t;
                flag = true;
                for(auto i = m.at(t).begin(); i != m.at(t).end(); i++){
                    flag = flag && (!x.test(*i));
                }
                cout << (flag ? "1" : "0") << endl;
                break;
            case 7:
                cin >> t;
                cnt = 0;
                for(auto i = m.at(t).begin(); i != m.at(t).end(); i++){
                    cnt += (x.test(*i) ? 1 : 0);
                }
                cout << cnt << endl;
                break;
            case 8:
                cin >> t;
                bitset<64> tt(0uL);
                for(int i = 0; i < k.at(t); i++){
//                    tt.set(i, x.test(m.at(t).at(i)));
                    tt.set(m.at(t).at(i), x.test(m.at(t).at(i)));
                }
                cout << tt.to_ullong() << endl;
                break;
        }
    }
    return 0;
}


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

#define   REP(i, n) for(int i = 0;            i <  (int)(n); i++)
#define  CREP(i, n) for(int i = 1;            i <= (int)(n); i++)
#define  RREP(i, n) for(int i = (int)(n) - 1; i >= 0;        i++)
#define RCREP(i, n) for(int i = (int)(n);     i >  0;        i++)

#define INF  std::numeric_limits<int>::max()
#define NINF std::numeric_limits<int>::min()

using namespace std;
using ll = long long;

int N, Y;

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

    std::cin >> N >> Y;

    int a = -1, b = -1, c = -1;
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= N - i; j++) {
            int total_val = 10000 * i + 5000 * j + 1000 * (N - i - j);
            if(total_val == Y) {
                a = i;
                b = j;
                c = N - i - j;
            }
        }
    }

    std::cout << a
              << " "
              << b
              << " "
              << c
              << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
int main() {
  string s;
  cin >> s;
  int n = s.size();
  ll res = 0;
  int start = -1;
  vector<string> ans;
  for(int i=0;i<n;i++) {
    if(s[i] == 'A') {
      if(start == -1) start = i;
      else continue;
    }
    else if(s[i] == 'B') {
      if(start == -1) continue;
      else if(i == n-1) {
        ans.emplace_back(s.substr(start, i-start));
        start = -1;
      }
      else if(s[i+1] == 'C') i++;
      else {
        ans.emplace_back(s.substr(start, i-start));
        start = -1;
      }
    }
    else if(s[i] == 'C') {
      if(start == -1) continue;
      else {
        ans.emplace_back(s.substr(start, i-start));
        start = -1;
      }
    }
  }
  if(start != -1) {
    ans.emplace_back(s.substr(start, n-start));
    start = -1;
  }
  for(int i=0;i<ans.size();i++) {
    string ss = ans[i];
    int bcNum = 0;
    for(auto it=ss.rbegin();it!=ss.rend();it++) {
      if(*it == 'C') {
        bcNum++;
        it++;
      }
      else if(*it == 'A') res += bcNum;
    }
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2684
#include <stdio.h>

void StartProgram()
{
    int tMonsterHP, tMonsterAP, aMonsterHP, aMonsterAP;
    scanf("%d %d %d %d",&tMonsterHP, &tMonsterAP, &aMonsterHP, &aMonsterAP);
    
    while(1)
    {
        aMonsterHP = aMonsterHP - tMonsterAP;
        if(aMonsterHP <=0)
        {
            printf("Yes \n");
            break;
        }
        tMonsterHP = tMonsterHP - aMonsterAP;
        if(tMonsterHP <= 0)
        {
            printf("No \n");
            break;
        }
    }
        
    return ;
}

int main(int argc, const char * argv[])
{
    StartProgram();
    
    return 0;
}


Measured memory_bytes: 1660
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static int N, A, B;

        public static void Input()
        {
            var cin = new Solve();

            var input = cin.SplitReader();
            N = input[0];
            A = input[1];
            B = input[2];
           
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            long ans = 0;
            for(var i = 1; i <= N; i++)
            {
                if (DSum(i) >= A && DSum(i) <= B)
                {
                    ans += i;
                }
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
        }

        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

        public static int DSum(int n)
        {
            int sum = 0;
            while (n > 0)
            {
                sum += n % 10;
                n /= 10;
            }
            return sum;
        }
    }
}

    



Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define maxi INT_MAX
#define mini INT_MIN
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};

vector<vector<int>> g;
vector<int> parent, depth, subsize;

ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // cout<<fixed;
    // cout<<setprecision(18);
    ll n;
    cin>>n;
    ll temp = n-1;
    ll ans = 1;
    for(int i=2;i<=sqrt(n-1);i++)
    {
        int count = 0;
        while(temp%i == 0)
        {
            temp/=i;
            count++;
        }
        ans*= (count+1);
    }
    if(temp>1)
    ans*=2;
    for(int i=2;i<=sqrt(n);i++)
    {
        temp = n;
        while(temp%i == 0)
        temp/=i;
        if(n%i == 0 && temp%i == 1)
        ans++;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int f(int i, int j) {
    int i_dgt = 1, t = i;
    while (t / 10) {
        t /= 10;
        i_dgt++;
    }
    int j_dgt = 1;
    t = j;
    while (t / 10) {
        t /= 10;
        j_dgt++;
    }
    return max(i_dgt, j_dgt);
}

int main() {
    ll n;
    cin >> n;
    int ans = 1e9;
    double x = sqrt(n);
    for (int i = 1; i <= x; i++) {
        if (n % i == 0) {
            int t = f(i, n / i);
            ans = min(ans, t);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int cnt[100000];
int main()
{
    //freopen("input.txt", "r", stdin);

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

    int t;
    long long int sum = 0;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &t);
        cnt[t]++;
        sum += t;
    }

    int q, b, c;
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        scanf("%d %d", &b, &c);
        cnt[c] += cnt[b];
        sum += (-cnt[b] * b + cnt[b] * c);
        cnt[b] = 0;

        printf("%lld\n", sum);
    }

    return 0;
}

Measured memory_bytes: 4148
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

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

  if(a-2*b >= 0)
    cout << a-2*b << endl;
  else cout << 0 << endl;
}


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

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[] = br.readLine().split(" ");

		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);

		int c = a - b * 2;

		if (c <= 0) {
			System.out.println("0");
		} else {
			System.out.println(c);
		}
	}
}

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

int main() {
    string o, e;
    cin >> o >> e;

    rep(i, e.size()) cout << o[i] << e[i];
    if (o.size() > e.size()) {
        cout << o[o.size() - 1];
    }
    cout << endl;
}

Measured memory_bytes: 256
import numpy as np

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

X = []
ans = 0

for i in range(N):
    x = list(map(int, input().split()))
    X.append(x)

np_X = np.array(X)


for i in range(1, N):
    for k in range(i,N):
        a = np_X[(i-1),:] - np_X[k,:]
        ad = 0
        for j in a:
            ad += j**2
        if np.sqrt(ad) - int(np.sqrt(ad)) == 0:
            ans += 1

print(ans)

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

int main() {
	int N;
	cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
	rep(i,N) cin >> A[i];
	rep(i,N) cin >> B[i];
	rep(i,N-1) cin >> C[i];

	int ans = 0;
	rep(i,N){
 		ans += B[i];
		if(i == 0) continue;
		if(A[i] - A[i-1] == 1){
			ans+=C[A[i-1]-1];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static System.Console;

namespace AtCoder.Probrems.Solvers.ABC119
{
    public class _C
    {
        static void Main(string[] args)
        {
            WriteLine(Solve());
        }

        static int N, A, B, C;
        static int[] L;

        public static long Solve()
        {
            var _ = ReadLine().Split().Select(int.Parse).ToArray();
            N = _[0]; A = _[1]; B = _[2]; C = _[3];
            L = new int[N];
            for (int i = 0; i < N; i++)
            {
                L[i] = int.Parse(ReadLine());
            }
            return R();
        }

        static int R(int n = 0, int a = 0, int b = 0, int c = 0, int mp = 0)
        {
            if (n == N)
                return (a == 0 || b == 0 || c == 0)
                    ? int.MaxValue
                    : Math.Abs(a - A) + Math.Abs(b - B) + Math.Abs(c - C) + mp;

            return new[]{
                R(n + 1, a, b, c, mp),
                R(n + 1, a + L[n], b, c, mp + (a == 0 ? 0 : 10)),
                R(n + 1, a, b + L[n], c, mp + (b == 0 ? 0 : 10)),
                R(n + 1, a, b, c + L[n], mp + (c == 0 ? 0 : 10))
            }.Min();
        }

        private const int MOD = 1000000007;
    }
}


Measured memory_bytes: 13268
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static final int M = 3;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		long n = parseLong(sc.next());
		long a = parseLong(sc.next());
		long b = parseLong(sc.next());
		sc.close();
		long c = n / (a+b);
		long d = n % (a+b);
		out.println(c*a+Math.min(a, d));
	}
}


Measured memory_bytes: 21972