akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a= input()
b= input()
c= input()
ans=0
for i in range(n):
  if a[i]!=b[i] and b[i]!=c[i] and c[i]!=a[i]:
    ans=ans+2
  elif a[i]==b[i] and b[i]==c[i]:
    ans=ans+0
  else:
    ans = ans+1
    
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n;double p[200001];int k;double sum[200001];int a[200001];
int main()
{
	scanf("%d%d",&n,&k);for(int i=1;i<=n;++i){int x;scanf("%d",&x);p[i]=(x+1)/2.0;}double ans=0;for(int i=1;i<=n;++i)sum[i]=sum[i-1]+p[i];
	for(int i=1;i+k-1<=n;++i)ans=max(ans,sum[i+k-1]-sum[i-1]);printf("%.9lf\n",ans);return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll n, m; cin >> n >> m; ll sum = 0;
  rep(i, m){
    ll a; cin >> a; sum+=a;
  }
  if(sum>=n) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
N = input()
S = input()

count = 0
result = 0
for s in S:
  if s == "A":
    count = 1
  elif count == 1 and s == "B":
    count += 1
  elif count == 2 and s == "C":
    count = 0
    result += 1
  else:
    count = 0
print(result)

Measured memory_bytes: 3060
#include <stdio.h>
/*int hoge(int a) {
	if (a == 2)
	{
		
	}
}*/
int main(void) {
	int a[3] = {}, b[3] = {};
	int one = 0,two = 0,three = 0,four = 0;
	bool ans = false;
	for (int i = 0; i < 3; i++)
	{
		scanf("%d%d", &a[i], &b[i]);
	}
	for (int i = 0; i < 3; i++)
	{
		switch (a[i])
		{
		case 1: one++;
			break;
		case 2: two++;
			break;
		case 3: three++;
			break;
		case 4: four++;
			break;
		}
		switch (b[i])
		{
		case 1: one++;
			break;
		case 2: two++;
			break;
		case 3: three++;
			break;
		case 4: four++;
			break;
		}
	}
	
	if (one == 1) {
		if (two == 2 && three == 2 && four == 1)ans = true;
		if (two == 2 && three == 1 && four == 2)ans = true;
		if (two == 1 && three == 2 && four == 2)ans = true;
	}
	if (ans)printf("YES");
	else printf("NO");
	return 0;
}


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

bool graph[55][55];
bool seen[55];

void dfs(int i,int n){
  seen[i] = true;
  for(int j = 0;j < n;j++){
    if(graph[i][j] == false) continue;
    if(seen[j] == true) continue;
    dfs(j,n);
  }
  return;
}

int main(){
  int n;cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(),a.rend());
  ll ans = 0;
  ll sum = 0;
  if(n%2==1){
    rep(i,n/2) ans += 2*a[i];
    for(int i = n/2;i<n;i++) ans -= 2*a[i];
    ans += a[n/2] + a[n/2+1];

    rep(i,n/2+1) sum += 2*a[i];
    for(int i = n/2+1;i<n;i++) sum -= 2*a[i];
    sum -= a[n/2-1] + a[n/2];
    ans = max(ans,sum);
  }else{
    rep(i,n/2) ans += 2*a[i];
    for(int i = n/2;i<n;i++) ans -= 2*a[i];
    ans -= a[n/2-1];
    ans += a[n/2]; 
  }
  cout << ans << endl;

}

Measured memory_bytes: 3952
#include<iostream>
#include<algorithm>

using namespace std;

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

int main(){
    long int n, k;
    cin >> n >> k;
    pair<long int, long int> p[n];
    rep(i, n) cin >> p[i].first >> p[i].second;
    sort(p, p + n);
    long int ans;
    long int sm = 0;
    for (int i = 0; sm < k; i++){
        ans = p[i].first;
        sm += p[i].second;
    }
    cout << ans << endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=105,K=1e5+5,mod=1e9+7;
ll dp[N][K],a[N],n,k;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>k;
    for(ll i=0;i<n;i++)cin>>a[i];
    dp[0][0]=1;
    for(ll i=0;i<n;i++){
        for(ll j=1;j<=k;j++)dp[i][j]+=dp[i][j-1],dp[i][j]%=mod;
        for(ll j=0;j<=k;j++){
            dp[i+1][j]=dp[i][j];
            if(j-a[i]>0)dp[i+1][j]=dp[i+1][j]-dp[i][j-a[i]-1]+mod;
            dp[i+1][j]%=mod;
        }
    }
    cout<<dp[n][k];
}

Measured memory_bytes: 80128
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int v = in.nextInt();
        int e = in.nextInt();
        Prim prim = new Prim(v);
        for (int i = 0; i < e; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            int w = in.nextInt();

            prim.addEdge(a, b, w);
        }

        ArrayList<Triplet> mst = prim.getMinimumSpanningTree();
        int sum = 0;
        for (Triplet edge: mst)
            sum += edge.w;
        System.out.println(sum);
    }
}

class Prim {
    private int size;
    private ArrayList<ArrayList<Triplet>> adl;

    public Prim(int size) {
        this.size = size;
        adl = new ArrayList<>();
        for (int i = 0; i < size; i++)
        	adl.add(new ArrayList<>());
    }

    public void addEdge(int u, int v, int w) {
    	adl.get(u).add(new Triplet(u, v, w));
    	adl.get(v).add(new Triplet(v, u, w));
    }

    public ArrayList<Triplet> getMinimumSpanningTree() {
    	ArrayList<Triplet> mst = new ArrayList<>();
    	PriorityQueue<Triplet> nearest = new PriorityQueue<>((a, b) -> a.w - b.w);
    	boolean[] visit = new boolean[this.size];

    	nearest.offer(new Triplet(-1, 0, 0));
    	while (nearest.size() > 0) {
    		Triplet cur = nearest.poll();
    		if (visit[cur.v])
    			continue;

    		visit[cur.v] = true;
    		if (cur.u != -1)
	    		mst.add(cur);

    		for (Triplet ng: this.adl.get(cur.v))
    			nearest.offer(ng);
    	}
    	return mst;
    }
}

class Triplet {
    public int u;
    public int v;
    public int w;

    public Triplet(int u, int v, int w) {
        this.u = u;
        this.v = v;
        this.w = w;
    }

    public String toString() {
        return "("
                + Integer.toString(u) + ", "
                + Integer.toString(v) + ", "
                + Integer.toString(w) + ")";
    }
}



Measured memory_bytes: 113988
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
// other libs

signed main(int argc, char* argv[]) {
	int n, memo, ans = 0;
	cin >> n;
	int cnt = 0;
	rep(i, n) {
		int it;
		cin >> it;
		if (i) {
			if (memo >= it) {
				cnt++;
			}
			else {
				ans = max(ans, cnt);
				cnt = 0;
			}
		}
		memo = it;
	}
	ans = max(ans, cnt);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using P = pair<int, int>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int k; cin >> k;
  VI d(k, 1e9);
  d[1] = 1;
  deque<P> dq;
  dq.emplace_back(1, 1);
  while (not dq.empty()) {
    P p = dq.front(); dq.pop_front();
    int v = p.first;
    if (p.second > d[v]) continue;
    int u = (v + 1) % k;
    if (d[u] > d[v] + 1) {
      d[u] = d[v] + 1;
      dq.emplace_back(u, d[u]);
    }
    u = 10 * v % k;
    if (d[u] > d[v]) {
      d[u] = d[v];
      dq.emplace_front(u, d[u]);
    }
  }
  cout << d[0] << '\n';
  return 0;
}

Measured memory_bytes: 1024
<?php /*atcoder.php*/

$t = new temp(fgets(STDIN));

$t->stdin();

unset($t);

class temp{
	private $max = 0;
	private $mochi = array();
	
	public function __construct($data = null){
		$this->max = $data;
	}

	public function stdin(){	
		for($i = 0; $i < $this->max; $i++){
			$this->mochi[] = fgets(STDIN);
		}
		$this->mochi = array_unique($this->mochi);
		echo (count($this->mochi));
	}
	
}

?>


Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {
	static Scanner scn = new Scanner(System.in);

	public static void main(String[] args) {
		int n = scn.nextInt();
		int m = scn.nextInt();
		int ans1 = 0;
		if (n > 1) {
			ans1 = n * (n - 1) / 2;
		}
		int ans2 = 0;
		if (m > 1) {
			ans2 = m * (m - 1) / 2;
		}
		System.out.println(ans1 + ans2);
	}
}


Measured memory_bytes: 21972
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
int n,c[200000+10],a[200000+10];
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>a[i];
    	c[a[i]]++;
    }
    ll sum=0;
    for(int i=0;i<=n;i++){
    	if(c[i]>=2){
    		sum+=1ll*c[i]*(c[i]-1)/2;
    	}
    }
    for(int i=1;i<=n;i++){
    	cout<<sum-c[a[i]]+1<<"\n";
    }
}

Measured memory_bytes: 3712
#include <stdio.h>

int main (void)
{
	int a;
	int b;
	int c;
	
	scanf("%d %d %d", &a ,&b, &c);
	
	if (a < b&& b < c){
		printf("%d %d %d\n", a, b, c);
	}
	else if(a < c&& c < b){
		printf("%d %d %d\n", a, c, b);
	}
	else if(b < a&& a < c){
		printf("%d %d %d\n", b, a, c);
	}
	else if(b < c&& c < a){
		printf("%d %d %d\n", b, c, a);
	}
	else if(c < a&& a < b){
		printf("%d %d %d\n", c, a, b);
	}
	else if(c < b&& b < a){
		printf("%d %d %d\n", c, b, a);
	}
	else if(a==b&&a < c){
		printf("%d %d %d\n", a ,b,c);
	}
	else if(a==b&&a>c){
		printf("%d %d %d\n",c,a,b);
	}
	else if(a==c&&a<b){
		printf("%d %d %d\n",a ,c ,b);
	}
	else if(a==c&&a>b){
		printf("%d %d %d\n",b,a,c);
	}
	else if(b==c&&c<a){
		printf("%d %d %d\n",b,c,a);
	}
	else if(b==c&&c>a){
		printf("%d %d %d\n",a,b,c);
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;


int main() {

    int N;
    cin >> N;
    int A;
    vector<int> original;
    vector<int> AS;
    for (int i = 0; i < N; ++i) {
        cin >> A;
        original.push_back(A);
        AS.push_back(A);
    }

    sort(AS.begin(), AS.end(), greater<int>());

    for (int i = 0; i < N; ++i) {
        if (original[i] < AS[0]) {
            cout << AS[0] << endl;
        } else {
            cout << AS[1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3436
#include<iostream>
#include<cstdio>
#define ll long long
#define MAX(A,B) ((A>B)?A:B)
#define MIN(A,B) ((A<B)?A:B)
using namespace std;

ll n,a[110],minn,maxn,ans;

ll check(ll x){
	ll tot=0;
	for(int i=1;i<=n;i++)
		tot+=(a[i]-x)*(a[i]-x);
	return tot;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	minn=maxn=a[1];
	for(int i=2;i<=n;i++){
		minn=MIN(minn,a[i]);
		maxn=MAX(maxn,a[i]);
	}
	
	ans=check(minn);
	for(int i=minn+1;i<=maxn;i++)
		ans=MIN(ans,check(i));
	cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(int argc, char *argv[])
{
  const int BIG = 1000000;
  const int CMAX = 25000;
  for(;;) {
    int n;
    cin >> n;
    if(n == 0) break;
    vector<int> ps;
    for(int i = 0; i < n; i++) {
      int p; cin >> p; ps.push_back(p);
    }
    // shop : at most 100
    // change : at most 49900... too much?
    // # of 500 got so far : at most 100
    // value : minimum payment
    
    vector<vector<int>> dp(CMAX+1, vector<int>(101, BIG));
    vector<vector<int>> dpnew(CMAX+1, vector<int>(101, BIG));
    dpnew[0][0] = 0;
    int cmax = 0;
    int kmax = 0;
    for(int i = 0; i < n; i++) {
      int kmax2 = kmax;
      const int ii = i + 1;
      // not buying
      for(int j = 0; j <= cmax; j++) {
        for(int k = max(0, kmax - (n-i)); k <= i; k++) {
          dp[j][k] = dpnew[j][k];
        }
      }
      // buying
      for(int j = 0; j <= cmax; j++) {
        const int p = ps[i] % 1000;
        if(p != 0 && p <= 500) { // got 500!
          const int jj = min(j + 500 - p, CMAX);
          cmax = min(max(cmax, jj), CMAX);
          for(int k = max(0, kmax - (n-i)); k <= kmax; k++) {
            const int kk = k + 1;
            if(dpnew[jj][kk] > dp[j][k] + ps[i]) {
              dpnew[jj][kk] = dp[j][k] + ps[i];
              kmax2 = max(kmax2, kk);
            }
          }
        } else {
          // get 500 if possible!
          const int q = (p == 0 ? 1000 : p) - 500;
          if(j >= q) {
            const int jj = j - q;
            for(int k = max(0, kmax - (n-i)); k <= kmax; k++) {
              const int kk = k + 1;
              if(dpnew[jj][kk] > dp[j][k] + ps[i]) {
                dpnew[jj][kk] = dp[j][k] + ps[i];
                kmax2 = max(kmax2, kk);
              }
            }
          } else { // get change
            const int jj = j + 1000 - p;
            cmax = min(max(cmax, jj), CMAX);
            if( jj < 1000) {
              for(int k = max(0, kmax - (n-i)); k <= kmax; k++) {
                const int kk = k;
                if(dpnew[jj][kk] > dp[j][k] + ps[i]) {
                  dpnew[jj][kk] = dp[j][k] + ps[i];
                  kmax2 = max(kmax2, kk);
                }
              }
            }
          }
        }
      }
      kmax = kmax2;
    }
    for(int k = 100; k >= 0; k--) {
      int p = BIG;
      for(int j = 0; j <= cmax; j++) {
        p = min(p, dpnew[j][k]);
      }
      if(p != BIG) {
        cout << k << " " << p << endl;
        break;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 24324
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> p(N+1);
    for(int i=1; i<=N; i++) {
        cin >> p[i];
    }

    int ans = 0;
    for(int i=1; i<N; i++) {
        if(p[i] == i && p[i+1] == i+1) {
            ans++;
            swap(p[i], p[i+1]);
        }
    }

    for(int i=1; i<=N; i++) {
        if(p[i] == i) {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    rep(i,n){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

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

bool pred(int mid, const vector<int>& a, int n)
{
  vector<bool> b;
  each (i, a) b.push_back(mid <= i);
  const int k = n - 1;
  int idx = -1;
  for (int i = 0; 0 <= k - i - 1; ++i) {
    if (b[k - i] == b[k - i - 1]) idx = k - i;
    if (b[k + i] == b[k + i + 1]) idx = k + i;
    if (idx != -1) break;
  }
  return idx == -1 ? b[0] : b[idx];
};

int main(int argc, char *argv[])
{
  int n;
  while (cin >> n) {
    vector<int> a(2 * n - 1);
    each (i, a) cin >> i;
    int small = 1;
    int large = n * 2;
    while (small + 1 < large) {
      int mid = (small + large) / 2;
      if (pred(mid, a, n)) small = mid;
      else large = mid;
    }
    if (pred(large, a, n)) cout << large << endl;
    else if (pred(small, a, n)) cout << small << endl;
    else assert(false);
  }
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    int a=0, b=0, ans=0;
    scanf("%d %d", &a, &b);
    for (int i = 0; i < 2 ; ++i) {
        if(a >= b){
            ans += a;
            a--;
        }else{
            ans += b;
            b--;
        }
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    vector<ll>a(3);
    rep(i,3)cin>>a[i];
    sort(a.begin(),a.end());
    if(a[0]==5&&a[1]==5&&a[2]==7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}








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

using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    ll a,b,t,n,m,k;
    cin>>n>>k;
    ll cost[n+1];
    for(int i=0;i<=n;i++){
        cost[i]=1000000000;
    }
    cost[1]=0;
    cost[0]=0;
    vector<ll> v;
    v.push_back(0);
    cin>>a;
    v.push_back(a);
    cin>>a;
    v.push_back(a);
    cost[2]=abs(v[2]-v[1]);
    for(int i=3;i<=n;i++){
        cin>>a;
        for(int j=1;j<=k;j++){
            if(i-j>=1){
                cost[i]=min(cost[i],cost[i-j]+abs(a-v[i-j]));
            }
        }
        v.push_back(a);
    }
    cout<<cost[n];
    return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
typedef pair<double,double> pdd;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

struct point{
	double x,y;
	point operator+(point Gep){
		return point{x+Gep.x,y+Gep.y};
	}
	point operator-(point Gep){
		return point{x-Gep.x,y-Gep.y};
	}
	point operator*(double Gex){
		return point{x*Gex,y*Gex};
	}
	point operator/(double Gex){
		if(!Gex) return point{0,0}; 
		return point{x/Gex,y/Gex};
	}
	bool operator==(point Gep){
		return fabs(x-Gep.x)<eps&&fabs(y-Gep.y)<eps;
	}
};

class Geom{
	public:
	vector<point> Ge;
	vector<pair<point,point> > Geseg,Geline;
	void line_push(point Gex,point Gey){
		Geline.push_back(make_pair(Gex,Gey));
	}
	pdd POI(pdd Gea,pdd Geb,pdd Gec,pdd Ged){
		return pdd(3,4);
	}
	double IP(point Gex,point Gey){
		return Gex.x*Gey.x+Gex.y*Gey.y;
	}
	double LEN(point Gex){
		return sqrt(Gex.x*Gex.x+Gex.y*Gex.y);
	}
	point PRO(pair<point,point> Gea,point Gex){
		point Ge1=Gex-Gea.second,Ge2=Gea.first-Gea.second;
		return Ge2*(IP(Ge1,Ge2)/(LEN(Ge2)*LEN(Ge2)))+Gea.second;
	}
	point REF(pair<point,point> Gea,point Gex){
		point Ge1=PRO(Gea,Gex);
		return Ge1*2-Gex;
	}
	pair<point,point> line_open(int Gex){
		return Geline[Gex];
	}
};

int q;
double x,xx,y,yy,xxx,yyy;

int main(){
	cout<<shosu(10);
	cin>>x>>y>>xx>>yy>>q;
	for(int i=0;i<q;i++){
		cin>>xxx>>yyy;
		Geom geo;
		geo.line_push(point{x,y},point{xx,yy});
		point ans=geo.REF(geo.line_open(0),point{xxx,yyy});
		cout<<ans.x<<' '<<ans.y<<endl;
	}
}

Measured memory_bytes: 1300
def inpl():
    return list(map(int, input().split()))


def cmb(n, r):
    # combination
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    return (over[n] * under[r] * under[n - r]) % MOD


# 互いに素なx, yについて、a * x + b * y = 1の解の一つを求める。
def extGCD(x, y):
    r = [1, 0, x]
    w = [0, 1, y]
    # print(r, w)
    while w[2] != 1:
        # print(r, w)
        q = r[2] // w[2]
        w_tmp = [r[0] - q * w[0], r[1] - q * w[1], r[2] % w[2]]
        r, w = w, w_tmp

    return w[:2]


def mod_inv(a, m):
    _, x = extGCD(m, a)
    return (x + m) % m


def g(x, y):
    return (cmb(x + y + 2, x + 1) - 1 + MOD) % MOD


r1, c1, r2, c2 = inpl()

MOD = 10**9 + 7

over = [0 for i in range(r2 + c2 + 3)]
under = [0 for i in range(r2 + c2 + 3)]
over[0] = 1
for i in range(r2 + c2 + 2):
    over[i + 1] = over[i] * (i + 1) % MOD

under[r2 + c2 + 2] = mod_inv(over[r2 + c2 + 2], MOD)
for i in range(r2 + c2 + 1, 0, -1):
    under[i] = under[i + 1] * (i + 1) % MOD

print((g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1)) % MOD)


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

int main()
{
	int n, k, x, y;
  	cin >> n >> k >> x >> y;
  
  	int res = 0;
  	for (int i=0; i<k; i++) {
      res += x;
      if (i == n-1) break;
    }
  
  	if (n>k) {
 	for (int i=0; i<n-k; i++)
      res += y;
    }
  
  	cout << res << endl;
}


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

int N = pow(10,9)+7;

ll pow_mod(ll p,ll n){
    if(n==1){
        return p%N;
    }
    if(n%2==0){
        return (pow_mod(p, n/2)*pow_mod(p, n/2))%N;
    }
    else{
        return(pow_mod(p, (n-1)/2) * pow_mod(p, (n+1)/2)) %N;
    }
}

ll combi_mod(ll n, ll k){
    ll up=1;
    ll down =1;
    for(ll i=0; i<k; i++){
        up = (up*(n-i))%N;
    }
    for(ll i=1; i<=k; i++){
        down = (down*i)%N;
    }
    ll ans;
    ans = (up*pow_mod(down, N-2))%N;
    return ans;
}

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans=1;
    ans = pow_mod(2, n);
    ans--;
    ans -= combi_mod(n,a) + combi_mod(n,b);
    while(ans<0){
        ans += N;
    }
    cout << ans%N << endl;
}


Measured memory_bytes: 3568
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		int S,h,m,s;
		Scanner scan = new Scanner(System.in);
	     S = Integer.parseInt(scan.next());
		if((S>=0)&&(S<86400)){
		h=S/(60*60);
		m=(S%(60*60))/60;
		s=(S%(60*60))%60;
		System.out.println(h+":"+m+":"+s);
		}
		
	}
}

Measured memory_bytes: 26084
#include <cstdio>
#include <cmath>
#include <limits>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdint>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;

const ll mod = 1000000000 + 7; //10^9

int main() {
    int n,x,t;
    cin >> n >> x >> t;
    int ans = 0;
    while(n>0) {
        n -= x;
        ans += t;
    }
    cout <<  ans << endl;

}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;

struct leaves {
    int up;
    vector<int> down;
    int point = 0;
};
int N, Q;

int ans[250000];
leaves tree[250000];

void dfs(int direct, int point) {
    tree[direct].point += point;
    for (int i = 0; i < tree[direct].down.size(); i++) {
        dfs(tree[direct].down[i], tree[direct].point);
    }
}

signed main() {
    cin >> N >> Q;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        tree[a].down.push_back(b);
        tree[b].up = a;
    }
    for (int i = 0; i < Q; i++) {
        int a, b;
        cin >> a >> b;
        tree[a].point += b;
    }
    dfs(1, 0);
    for (int i = 1; i <= N; i++) {
        if (i != N) cout << tree[i].point << " ";
        else cout << tree[i].point << endl;
    }

    return 0;
}

Measured memory_bytes: 25088
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//よくわかんなくなってきた
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline ll getint() {
	ll A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	ll N = getint(), M = getint();
	int A[100002] = {};
	rep(i, N) A[getint()]++;	
	for (int i = 100000; i > 1; i--) {
		A[i - 1] += A[i];
	}

	int L = 0;
	int R = 200001;
	while (L + 1 < R) {
		int m = (L + R) / 2;

		ll kazu = 0;
		for (int i = 100000; i >= 1; i--) {
			ll k = A[i] - A[i + 1];
			if (k) {
				int k2 = m - i;
				if (k2 <= 1) kazu += N * k;
				else if (k2 <= 100000) kazu += A[k2] * k;
			}
		}

		if (kazu >= M) L = m;
		else R = m;
	}

	ll S[100002];
	S[100001] = 0;
	for (int i = 100000; i >= 1; i--) {
		S[i] = S[i + 1] + ll(A[i] - A[i + 1]) * i;
	}
	ll kotae = 0;
	ll kazu = 0;
	for (int i = 100000; i >= 1; i--) {
		ll k = A[i] - A[i + 1];
		if (k) {
			int k2 = L - i;
			if (k2 <= 1) {
				kotae += S[1] * k;
				kotae += N * k * i;
				kazu += N * k;
			}
			else if (k2 <= 100000) {
				kotae += S[k2] * k;
				kotae += A[k2] * k * i;
				kazu += A[k2] * k;
			}
		}
	}

	kotae -= ll(kazu - M) * L;

	printf("%lld", kotae);


	Would you please return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int n,t,a,h,r;
double m=1e9;
int main()
{
    cin>>n>>t>>a;
    for(int i=1;i<=n;i++){
        cin>>h;
        if(m>abs((t-h*0.006)-a)){
            r=i;m=abs((t-h*0.006)-a);
        }
    }
    cout<<r;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
ans = 0

for i in range(K+1,N+1):
    ans += (N // i) * (i - K)
    if N >= N // i * i + K:
        ans += N - (N // i * i + K) + 1
    if K == 0:
        ans -= 1

print(ans)

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

// n!の約数個数　o(n * √n)

vector<pair<ll, ll> > prime_factorize(ll n) {
  vector<pair<ll, ll> > res;
  for (ll a = 2; a * a <= n; ++a) {
    if (n % a != 0) continue;
    ll ex = 0;
    while (n % a == 0) {
      ++ex;
      n /= a;
    }
    res.push_back({a, ex});
  }
  if (n != 1) res.push_back({n, 1});
  return res;
}

int main() {
  ll n;
  cin >> n;

  const int MOD = 1000000007;
  vector<ll> ex(n + 1, 0);  // exp[p] := p の指数
  for (ll i = 2; i <= n; ++i) {
    const auto &res = prime_factorize(i);  // n の素因数分解
    for (auto p : res) ex[p.first] += p.second;
  }
  ll res = 1;
  for (int p = 2; p <= n; ++p) {
    res *= ex[p] + 1;  // 約数の個数は (exp + 1) の積
    res %= MOD;
  }
  cout << res << endl;
}

Measured memory_bytes: 3612
import java.io.*;

public class Main {

  static int a, b;

  static int gcd(int a, int b){
    if(b > a) return gcd(b, a);
    if(b == 0) return a;

    return gcd(b, a%b);
  }
  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] in = br.readLine().split(" ");
    a = Integer.parseInt(in[0]);
    b = Integer.parseInt(in[1]);
    br.close();

    System.out.println(gcd(a,b));

  }
}


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

int main() {
    int h,n;
    cin>>h>>n;
    vector<int> a(n),b(n),dp(h+1,1e9);
    for(int i=0; i<n; i++) cin>>a[i]>>b[i];
    dp[0] = 0;
    for(int i=0; i<n; i++) {
        for(int j=0; j<h+1; j++) {
            dp[min(j+a[i],h)] = min(dp[min(j+a[i],h)],dp[j]+b[i]);
        }
    }
    cout<<dp[h]<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <sys/stat.h>
using namespace std;
using ll = int64_t;

int main(int , char **)
{
#ifdef LOCAL_DEBUG
	struct stat sb;
	ifstream in("/dev/shm/input.txt");
	if (stat("/dev/shm/input.txt",&sb)==0){ cin.rdbuf(in.rdbuf()); }
#endif

	int A,B,C;
	cin >> A >> B >> C;

	if (A==B){printf("%d\n",C);}
	else if (A==C){printf("%d\n",B);}
	else {printf("%d\n",A);}

	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;



int n, m;
long long a[5];
long long dp[100005][3];

int main(int argc, const char * argv[]) {
//    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[0] >> a[1] >> a[2];
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) if (k != j) {
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[j]);
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i < 3; ++i)
        ans = max(ans, dp[n][i]);
    cout << ans << endl;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }


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

  long double a, b;
  cin >> a >> b;
  long double ans = a * b;
  cout << (ll)ans << endl;
  return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>

using namespace std;



int capa[8] = {4, 1, 4, 1, 2, 1, 2, 1};
int p[8];


int calcRest(void)
{
	int rest = 0;
	
	for (int i=0; i<8; i++)
	{
		if (p[i] > capa[i])
		{
			rest += p[i] - capa[i];
		}
	}
	
	return rest;
}


void rotateCapa(void)
{
	int temp = capa[0];
	for (int i=0; i<7; i++)
	{
		capa[i] = capa[i+1];
	}
	capa[7] = temp;
}


int main()
{
	int rest, minRest = 100000;
	string minRestStr, restStr;
	stringstream ss;
	
	while (cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7])
	{
		minRest = 10000000;
		for (int i=0; i<8; i++)
		{
			rotateCapa();
			rest = calcRest();
			ss.str("");
			if (rest == minRest)
			{
				ss << capa[0] << " " << capa[1] << " " << capa[2] << " " << capa[3] << " " << capa[4] << " " << capa[5] << " " << capa[6] << " " << capa[7];
				restStr = ss.str();
				if (restStr < minRestStr)
				{
					minRestStr = restStr;
				}
			}
			if (rest < minRest)
			{
				minRest = rest;
				ss << capa[0] << " " << capa[1] << " " << capa[2] << " " << capa[3] << " " << capa[4] << " " << capa[5] << " " << capa[6] << " " << capa[7];
				minRestStr = ss.str();
			}
		}
		cout << minRestStr << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1224
n, m = map(int, input().split())
a = list(map(int, input().split()))

sum_a = sum(a)
l = []
for i in range(n):
    if a[i] < sum_a / (4*m):
        continue
    else:
        l.append(a[i])
if len(l) >= m:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, l, sum = 0, mi = 1e9, ans;

int main() {
	cin >> n >> l;
	
	inc(i, n) { sum += l + i; }
	
	inc(i, n) {
		if(setmin(mi, SC<int>(abs(l + i)))) { ans = sum - (l + i); }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int a;
    cin >> a;
    for (int i = a; ; i++) {
        int p = i;
        for (int j = 2; j <= sqrt(p); j++) {
            if (p % j == 0) {
                p = 0;
                break;
            }
        }
        if (p == i) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => { trace!(($($args),*)) }
}

#[allow(unused_macros)]
macro_rules! put {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stdout(), "{}", $var);
    };
    ($var:expr, $($args:expr),*) => {
        let _ = write!(&mut std::io::stdout(), "{} ", $var);
        put!($($args),*);
    };
}

const M: usize = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let d: u32 = sc.cin();
    let mut n: usize = sc.cin();
    let m0 = 100u64.pow(d);
    let m1 = 100u64.pow(d+1);
    // trace!(m0, m1);
    for i in 1..2000000 {
        if i % m0 == 0 && i % m1 != 0 {
            n -= 1;
            if n == 0 {
                put!(i);
                return;
            }
        }
    }
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}


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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io(); 
    int n; cin >> n;
    vector<pair<int,int>> vp;
    int dist[n];
    int fs = 0;
    for(int i = 0; i < n; ++i){
        int x; cin >> x;
        pair<int,int> p = {x,0};
        vp.push_back(p);
        dist[x - 1] = i;
    }
    for(int i = 0; i < n; ++i){
        int x; cin >> x;
        fs += x;
    }
    for(int i = 0; i < n - 1; ++i){
        int x; cin >> x;
        vp[dist[i]].second += x;
    }
    
    for(int i = 1; i < (int)vp.size(); ++i){
        if(vp[i].first == vp[i - 1].first + 1){
            fs += vp[i - 1].second;
        }
    }
    return cout << fs << '\n', 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    int n , x = 0;
    cin >> n;
    int a[n];
    for( int i = 0 ; i < n ; i++ ) cin >> a[i];
    sort( a , a + n );
    int b[100005];
    for( int i = 1 ; i <= min(n, a[n - 1]) ; i++ ) b[i] = 0;
    for(int i = 0; i < n; i++) if ( a[i] > n) x++;
    for( int i = 0 ; i < n ; i++ ) if (a[i] <= n) {
        b[a[i]]++;
    }
    for( int i = 1 ; i <= min(n, a[n - 1]) ; i++ ) {
        if( b[i] > 0 ) {
            if( i != b[i] ) {
                if( b[i] > i ) x += b[i] - i;
                else x += b[i];
            }
        }
    }
    cout << x;
}

Measured memory_bytes: 4448
A,B,C,D = gets.chomp.split("").map(&:to_i)
s = ["+","-"]
s.product(s).product(s).each{ |a|
  x = sprintf("#{A}%s#{B}%s#{C}%s#{D}", *a.flatten)
  if eval(x) == 7
    puts "#{x}=7"; exit
  end
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
	bool isUpper (char c){
		return (c >=65&& c<97);
	}
 int main (){
	string s;
	getline (cin,s);
	int len = s.length();
	if(isUpper(s[0]))
	   cout<<s[0];
	for(int i=1;i<len;++i){
		if( isUpper(s[i])&& s[i-1]==' ')
		     cout<<s[i];
	}   
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
std::vector<int>A['   '];int N,M,S['   '],B,L,R,I;void U(int z,int u){while(z<=N)S[z]+=u,z+=z&-z;}main(){std::cin>>M>>N;for(I=1;I<=M;I++)std::cin>>L>>R,A[R-L+1].push_back(L);for(L=1;L<=N;L++){B=M;for(I=L;I<=N;I+=L){R=I;while(R)B+=S[R],R-=R&-R;}for(int u:A[L])U(u,1),U(u+L,-1),M--;std::cout<<B<<"\n";}}

Measured memory_bytes: 53760
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int count = 0;
    for(int i=a; i<=b; i++){
        if(c % i == 0) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <random>

using namespace std;

const long long mod = 998244353;
const long long nmax = 3e5;
long long d[nmax][2][3][3];

bool same(string &s) {
    long long c = s[0];
    for (long long i = 0; i < s.size(); i++)
        if (s[i] != c)
            return false;
    return true;
}

long long Sum(string &s) {
    long long res = 0;
    for (long long i = 0; i < s.size(); i++)
        res += s[i] - 'a';
    return (res % 3);
}

bool is_adj(string &s) {
    for (long long i = 0; i + 1 < s.size(); i++)
        if (s[i] == s[i + 1])
            return true;
    return false;
}

void solve() {
    string s;
    cin>>s;
    if (same(s)) {
        cout<<1<<"\n";
        return;
    }
    if (s.size() <= 4) {
        set < string > curr, used;
        curr.insert(s);
        while (!curr.empty()) {
            string t = *curr.begin();
            curr.erase(t);
            used.insert(t);
            for (long long i = 0; i + 1 < t.size(); i++) {
                if (t[i] != t[i + 1]) {
                    char val = 'a' + (3 - (t[i] - 'a') - (t[i + 1] - 'a'));
                    char c = t[i], cc = t[i + 1];
                    t[i] = val;
                    t[i + 1] = val;
                    if (used.count(t) == 0)
                        curr.insert(t);
                    t[i] = c;
                    t[i + 1] = cc;
                }
            }
        }
        cout<<used.size()<<"\n";
        return;
    }
    long long sum = Sum(s);

    //d[0][0][0][0] = 1;
    for (long long let = 0; let < 3; let++)
        d[1][0][let][let] = 1;
    for (long long i = 1; i < s.size(); i++) {
        for (long long adj = 0; adj < 2; adj++) {
            for (long long let = 0; let < 3; let++) {
                for (long long md = 0; md < 3; md++) {
                    for (long long add = 0; add < 3; add++) {
                        d[i + 1][adj || (add == let)][add][(md + add) % 3] += d[i][adj][let][md];
                        d[i + 1][adj || (add == let)][add][(md + add) % 3] %= mod;
                    }
                }
            }
        }
    }
    long long res = !is_adj(s);
    for (long long let = 0; let < 3; let++)
        res += d[s.size()][1][let][sum];
    cout<<((res + mod) % mod)<<"\n";
}

int main() {
    ios::sync_with_stdio(false);
    long long t = 1;
    while (t--)
        solve();
}


Measured memory_bytes: 31908
<?php
fscanf(STDIN,'%s',$S);
$c=0;
$array=str_split($S);
for ($i=97; $i <=122 ; $i++) { 
    # code...
    $Moji=chr($i);
    if(in_array($Moji,$array)){

    }else{
      $c=1;
      break;
    }
}
if($c==0){
    echo 'None';

}else{
    echo $Moji;
}
echo "\n";
?>

Measured memory_bytes: 21132
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

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

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N;
string S1, S2;

int main(){
  cin >> N;
  cin >> S1 >> S2;

  vi vec;
  int i = 0;
  while(i < N) {
    if(i == N - 1) {
      vec.pb(1);
      break;
    }
    if(S1[i] == S1[i + 1]) {
      vec.pb(2);
      i += 2;
    } else {
      vec.pb(1);
      i++;
    }
  }

  ll ans = 0;
  if(vec[0] == 1) {
    ans = 3;
  } else {
    ans = 6;
  }

  REP(i, vec.size() - 1) {
    if(vec[i] == 1) {
      ans = ans * 2 % MOD;      
    } else {
      if(vec[i + 1] == 2) {
        ans = ans * 3 % MOD;
      }
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=[]
for i in range(2):
    A_ = list(map(int, input().split()))
    A.append(A_)
    A[i].append(0)
A.append([0]*(N+1))
# A=[[0]*(N+1),[0]*(N+1),[0]*(N+1)]
# A[0]=list(map(int,input().split()))
# A[1]=list(map(int,input().split()))

max_candidate=[]
x=0
y=0
ans=A[0][0]
for i in range(N):
  if A[y][x+1]>=A[y+1][x]:
    ans+=A[0][x+1]
    x+=1
  #下方向移動の方が値が大きい場合、最大値の候補としてリストに追加
  else:
    ans_can=ans
    for j in range(x,N):
      ans_can+=A[1][j]
    max_candidate.append(ans_can)
    ans+=A[0][x+1]
    x+=1
print(max(max_candidate))


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  int d[n];
  int num[n];
  for(int i = 0; i < n; i++){
    scanf("%d", &d[i]);
    num[i] = 0;
  }
  int max = 0;
  int zr = 0;
  for(int i = 0; i < n; i++){
    num[d[i]]++;
    if(d[i] > max){
      max = d[i];
    }
    if(d[i] == 0){
      zr++;
    }
  }
  long long int ans = 1;
  for(int i = 0; i < max; i++){
    for(int j = 0; j < num[i + 1]; j++){
      ans = ans * num[i] % 998244353;
    }
  }
  if((zr == 1) && (d[0] == 0)){
    printf("%lld\n", ans);
  }else{
    printf("0\n");
  }

  return 0;
}


Measured memory_bytes: 896
import sys

def main():
    N, M, S, T = map(int, input().split())
    A = [[] for _ in range(N+1)]
    B = [[] for _ in range(N+1)]
    for u, v, a, b in zip(*[iter(map(int, sys.stdin.read().split()))]*4):
        A[u].append((v, a))
        A[v].append((u, a))
        B[u].append((v, b))
        B[v].append((u, b))

    def dijkstra(E, start):
        from heapq import heappush, heappop
        N = len(E)
        inf = float("inf")
        dist = [inf] * N
        dist[start] = 0
        q = [(0, start)]
        while q:
            dist_v, v = heappop(q)
            if dist[v] != dist_v:
                continue
            for u, dist_vu in E[v]:
                dist_u = dist_v + dist_vu
                if dist_u < dist[u]:
                    dist[u] = dist_u
                    heappush(q, (dist_u, u))
        return dist

    dist_A = dijkstra(A, S)
    dist_B = dijkstra(B, T)
    init = 10**15
    Ans = []
    ans = float("inf")
    for a, b in zip(dist_A[:0:-1], dist_B[:0:-1]):
        ans = min(ans, a+b)
        Ans.append(init-ans)
    Ans.reverse()
    print("\n".join(map(str, Ans)))

main()


Measured memory_bytes: 91668
void main() {
  problem();
}

void problem() {
  const MAX = BigInt(10L.pow(18));
  auto N = scan!int;
  auto A = scan!ulong(N).map!(i => BigInt(i)).array;

  long solve() {
    if (A.any!(a => a == 0)) return 0;
    
    BigInt multi = 1;
    foreach(a; A) {
      multi *= a;
      if (multi > MAX) return -1;
    }

    return multi.toLong;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");
import std.bigint, std.functional;

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


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

int main(){
	int a, b;
	cin >> a >> b;
	string s;
	if((a == 4 || a == 6 || a == 9) && (b == 6 || b == 9 || b == 11)){
		s = "Yes";
	} 
	else if((a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 ) && (b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12)){
		s = "Yes";
	} else{
		s = "No";
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  string s;
  cin >> s;
  int cur = 0, mi = 0;
  REP(i, 0, s.length()) {
    if (s[i] == 'T') {
      cur--;
    } else {
      cur++;
    }
    mi = min(mi, cur);
  }
  cout << cur - 2 * mi << endl;
}


Measured memory_bytes: 640