akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    static class Reader 
    { 
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} 
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];} 
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;} 
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();} 
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;} 
        public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;} 
        public double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } 
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } 
    }
    
    
    ///////////////////////////////////////////////////////////////////////////////////////////
    //    RRRRRRRRR            AAA             HHH     HHH     IIIIIIIIIIIII   LLL           //
    //    RR    RRR           AAAAA            HHH     HHH      IIIIIIIIIII    LLL           //
    //    RR   RRR           AAAAAAA           HHH     HHH          III        LLL           //
    //    RR  RRR           AAA   AAA          HHHHHHHHHHH          III        LLL           //
    //    RRRRRR           AAA     AAA         HHHHHHHHHHH          III        LLL           //
    //    RR  RRR         AAAAAAAAAAAAA        HHH     HHH          III        LLL           //
    //    RR    RRR      AAA         AAA       HHH     HHH      IIIIIIIIIII    LLLLLLLLLLLL  //
    //    RR     RRR    AAA           AAA      HHH     HHH     IIIIIIIIIIIII   LLLLLLLLLLLL  //
    ///////////////////////////////////////////////////////////////////////////////////////////
    
    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        int n=sc.i();
        if(n<1000)
        System.out.println("ABC");
        else
        System.out.println("ABD");
    }
}
    

Measured memory_bytes: 21076
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll x;
	cin>>x;
	for(ll i=-2000; i<=2000; i++){
		for(ll j=-2000; j<=2000; j++){
			ll ii=1,jj=1;
			for(int k=0; k<5; k++){
				ii*=i;
				jj*=j;
			}
			if(ii-jj==x){
				cout<<i<<" "<<j;
				return 0;
			}
		}
	}

    return 0;
}


Measured memory_bytes: 3652
#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>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int n, m, q;
vector<int> a, b, c, d;
int ans = 0;

void dfs(vector<int> A) {
    if (A.size() == n+1) {
        int now = 0;
        rep(i,q) {
            if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }
    A.push_back(A.back());
    while (A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(vector<int>(1,1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3540
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        long N=sc.nextLong();
        long K=sc.nextLong();
        
        long ans=N%K;
        long ans2=K-ans;
        
        if(ans<ans2){
            System.out.println(ans);
        }else{
            System.out.println(ans2);
        }
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void integerFactorization(long long n, vector<long long>& base, vector<long long>& exp)
{
    base.clear();
    exp.clear();
    long long a = 2;
    while(a * a <= n){
        long long b = 0;
        while(n % a == 0){
            ++ b;
            n /= a;
        }
        if(b > 0){
            base.push_back(a);
            exp.push_back(b);
        }
        ++ a;
    }
    if(n > 1){
        base.push_back(n);
        exp.push_back(1);
    }
}

long long solve(long long n)
{
    vector<long long> base, exp;
    integerFactorization(n, base, exp);
    int m = exp.size();

    long long ret = 1;
    for(int i=0; i<m; ++i)
        ret *= 2 * exp[i] + 1;
    ++ ret;
    ret /= 2;
    return ret;
}

int main()
{
    for(;;){
        long long n;
        cin >> n;
        if(n == 0)
            return 0;
        cout << solve(n) << endl;
    }
}

Measured memory_bytes: 904
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#define Max 1005
using namespace std;


vector<int>vec[Max*Max];
int map[Max][Max],indegree[Max*Max];
pair<int,int>edge[Max*Max];
queue<int>q;
bool check[Max*Max][Max];

void init(){
	int i,j;
	for(i=0;i<Max;i++){
		for(j=0;j<Max;j++){
			map[i][j] = -1;
			
		}	
	}

	for(i=0;i<Max*Max;i++){
		indegree[i] = 0;
		
	}
}

int main(){
	
	int n,i,j,x;
	
	init();

	scanf("%d",&n);
	int node = 1,prev_node;
	for(i=1;i<=n;i++){
		for(j=0;j<n-1;j++){
			scanf("%d",&x);
			if(map[i][x] == -1){
				map[i][x] = node;
				map[x][i] = node;
				edge[node].first = i;
				edge[node].second = x;
				node++;
			}

			if(j>0){
				vec[prev_node].push_back(map[i][x]);
				indegree[map[i][x]]++;
			}

			prev_node = map[i][x];

		}
	}

	int day = 1;
	
	for(i=1;i<node;i++){
		if(indegree[i] == 0){
			q.push(i);
			
		}
	}


	int src,totalMatch=0;
	while(!q.empty()){
		src = q.front();
		q.pop();
		totalMatch++;
		if(check[day][edge[src].first] == true || check[day][edge[src].second] == true){
			day++;
		}

		check[day][edge[src].first] = true;
		check[day][edge[src].second] = true;

		for(i=0;i<vec[src].size();i++){
			indegree[vec[src][i]]--;
			if(indegree[vec[src][i]] == 0){
				q.push(vec[src][i]);
			}
		}

	}
	
	x = n*(n-1)/2;
	
	if(totalMatch == x)
		printf("%d\n",day);
	else
		printf("-1\n");

	return 0;
}

Measured memory_bytes: 544768
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vi64 = vector<int64_t>;
using vvi64 = vector<vi64>;
#define rep(i, n) for (int64_t i = 0; i < (n); ++i)
#define repe(i, n) for (int64_t i = 0; i <= (n); ++i)
#define reps(i, s, n) for (int64_t i = (s); i < (n); ++i)
#define repse(i, s, n) for (int64_t i = (s); i <= (n); ++i)
#define repr(i, n) for (int64_t i = (n); i >= 0; --i)
#define all(xs) (xs).begin(), (xs).end()
#define pp_vec(xs) rep (i, (xs).size()) if { (i) cout << endl; cout << (xs)[i] << " "; };
const int64_t inf = (int64_t)1e18;
const int64_t mod = (int64_t)1e9 + 7;


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

  int N, M; cin >> N >> M;
  priority_queue<int, vi, greater<int>> pq;
  rep (i, N) {
    int A; cin >> A;
    pq.push(A);
  }
  vector<pii> CB(M);
  rep (i, M) {
    int B, C; cin >> B >> C;
    CB[i] = make_pair(C, B);
  }
  sort(all(CB), greater<pii>());
  rep (i, M) {
    int B, C; tie(C, B) = CB[i];
    int cnt = 0;
    rep (j, B) {
      int x = pq.top();
      if (x >= C) break;
      else {
        pq.pop();
        cnt++;
      }
    }
    rep (j, cnt) pq.push(C);
  }
  int64_t ans = 0;
  assert(pq.size() == N);
  while (!pq.empty()) {
    ans += pq.top(); pq.pop();
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1528
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
using namespace std;

int main(void){
    long long count=0,ans=0;
    string s;
    cin >> s;
    for(int i=0; i<s.length(); i++){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
            count++;
        }else {
            ans=max(ans,count);
            count=0;
        }
    }
    cout << max(ans,count) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    map<int , int>mp;
    int arr[n+1][n+1];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(j>i)
                arr[i][j]=j-i;
            else if(j==i)
                arr[i][j]=0;
            else
                arr[i][j]=arr[j][i];
        }
    }
    arr[x][y]=1;
    arr[y][x]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(j>i)
                arr[i][j]=min(arr[i][j],arr[i][x]+1+arr[j][y]);
            else
                arr[i][j]=arr[j][i];
        }
    }
    /*for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
            cout<<arr[i][j]<<" ";
        cout<<"\n";
    }*/
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
            mp[arr[i][j]]++;
    }
    for(int i=1;i<=n-1;i++)
        cout<<mp[i]<<"\n";
    return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };
#define all(u) begin(u),end(u)
#define mp make_pair
#define pb push_back
typedef pair<pi, pi> cake;

vector<cake> G;
ivec ans;
int n,w,d;
int p, s;
int main()
{
  while(true)
    {
      scanf("%d%d%d", &n, &w, &d);
      if(n == 0 && w == 0 && d == 0)break;
      G.clear();
      G.pb(cake(pi(-1, w*d),pi(w, d)));
      rep(i,n)
	{
	  scanf("%d%d",&p,&s);
	  p--;
	  cake v = G[p];
	  G.erase(G.begin()+p);
	  int C = v.second.first;
	  int R = v.second.second;
	  s %= C+R;
	  int x1, x2, y1, y2; 
	  if(s <= C)
	    {
	      x1 = s;
	      x2 = C -s;
	      y1 = R;
	      y2 =R;
	    }
	  else
	    {
	      s -= C;
	      x1 = C;
	      x2 = C;
	      y1 = s;
	      y2 = R - s;
	    }
	  G.pb(cake(pi(i, x1*y1),pi(x1,y1)));
	  G.pb(cake(pi(i, x2*y2),pi(x2,y2)));
	  sort(G.begin(),G.end());
	}
      ans.clear();
      rep(i, G.size())
	{
	  ans.pb(G[i].first.second);
	}
      sort(ans.begin(),ans.end());
      rep(i, ans.size())
	{
	  printf("%d", ans[i]);
	  if(i == ans.size() - 1)continue;
	  printf(" ");
	}
      printf("\n");
    }
  return 0;
}

Measured memory_bytes: 3208
#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;

LL n,d,x,y;
int main()
{
	int cnt=0;
	scanf("%lld%lld",&n,&d);
	d*=d;
	while(n--)
	{
		scanf("%lld%lld",&x,&y);
		cnt+=(x*x+y*y<=d);
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
char a[10];
int n,k;
int main()
{
	cin >>n>>k;
	for(int i=0;i<k;i++)
	{
		char f;
		cin >>f;
		a[f-'0']=1;
	}
	for(int i=n;i<100000;i++)
	{
		string s=to_string(i);
		for(int j=0;j<s.size();j++)
		if(a[(s[j]-'0')]==1)
		goto E;
		cout <<i<<endl;
		break;
		E:;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=2e5+5;
const ld pi=3.14159265359;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()
void SRAND(){auto duration = std::chrono::system_clock::now().time_since_epoch();auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();srand(millis);}

ll n,u[N],ru[N],ans,c;
pll nxt[N],lst[N];
multiset<ll> s;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	REP1(i,n)cin>>u[i],ru[u[i]]=i;
	for(ll i=n;i>=1;i--){
		auto j=s.lwb(ru[i]);
		nxt[ru[i]].X=(j==s.end()?n+1:*j);
		nxt[ru[i]].Y=(j==s.end()?n+1:(next(j)==s.end()?n+1:*next(j)));
		s.insert(ru[i]);
	}
	s.clear();
	for(ll i=n;i>=1;i--){
		auto j=s.lwb(ru[i]);
		lst[ru[i]].X=(j==s.begin()?0:*prev(j));
		lst[ru[i]].Y=(j==s.begin()?0:(prev(j)==s.begin()?0:*prev(prev(j))));
		s.insert(ru[i]);
	}
	nxt[n+1]=mp(n+1,n+1);
	REP1(i,n){
		ans+=u[i]*(min(nxt[nxt[i].X].X,nxt[i].Y)-nxt[i].X)*(i-lst[i].X);
		ans+=u[i]*(lst[i].X-max(lst[lst[i].X].X,lst[i].Y))*(nxt[i].X-i);
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 13184
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var S = Console.ReadLine();
            Console.WriteLine(S.Replace(",", " "));
        }
    }
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int a, b, x;
	cin >> a >> b >> x;
	double theta;
	if(a*a*b<=2*x) theta=atan(2.0*((double)(a*a*b-x))/(a*a*a));
	else theta=atan((double)(a*b*b)/(2.0*x));
	printf("%.9f\n", 180.0*theta/M_PI);
	return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
S = input()
out = S.count('R') * S.count('G') * S.count('B')

RGBs = list(itertools.permutations(['R', 'G', 'B'], 3))

for i in range(1, N):
  for j in range(N-i*2):
    if (S[j], S[j+i], S[j+i*2]) in RGBs:
      out -= 1
print(out)

Measured memory_bytes: 9172
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String ns =String.valueOf(n);
        int len = ns.length();
        int num = 0;

        for(int i = 0;i<len;i++){
            num = num + (Character.getNumericValue(ns.charAt(i)));
            //System.out.println(Character.getNumericValue(ns.charAt(i)));
        }
        //System.out.println(num);
        if(n%num==0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        
    }
}


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

int main() {
  int N;
  long K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i = 0; i < N; ++i){
    cin >> A.at(i);
    --A.at(i);
  }
  vector<int> cntA(N, -1);
  int here = 0;
  cntA.at(here) = 0;
  long cnt = 0;
  while(cnt < K){
    ++cnt;
    here = A.at(here);

    if(cntA.at(here) == -1){
      cntA.at(here) = cnt;
    } else {
      break;
    }
  }
  long mod = cnt - cntA.at(here);
  int zanki = (K - cnt) % mod;

  for(int i = 0; i < zanki; ++i){
    here = A.at(here);
  }

  cout << here + 1 << endl;
}

// 同じマスにとまるまでの回数をmodとしその地点から(K - cnt) % mod回テレポート。

Measured memory_bytes: 4840
#include<stdio.h>
int main(){
  int dice[6];
  int temp1,temp2;
  char move;
  char kg;
  scanf("%d %d %d %d %d %d",&dice[0],&dice[1],&dice[2],&dice[3],&dice[4],&dice[5]);
  scanf("%c",&kg);
  while(1){
    scanf("%c",&move);
    if(move == '\n')break;
    if(move == 'N'){
      temp1 = dice[0];
      dice[0] = dice[1];
      temp2 = dice[4];
      dice[4] = temp1;
      temp1 = dice[5];
      dice[5] = temp2;
      dice[1] = temp1;
    }
    if(move == 'S'){
      temp1 = dice[0];
      dice[0] = dice[4];
      temp2 = dice[1];
      dice[1] = temp1;
      temp1 = dice[5];
      dice[5] = temp2;
      dice[4] = temp1;
    }
    if(move == 'W'){
      temp1 = dice[0];
      dice[0] = dice[2];
      temp2 = dice[3];
      dice[3] = temp1;
      temp1 = dice[5];
      dice[5] = temp2;
      dice[2] = temp1;
    }
    if(move == 'E'){
      temp1 = dice[0];
      dice[0] = dice[3];
      temp2 = dice[2];
      dice[2] = temp1;
      temp1 = dice[5];
      dice[5] = temp2;
      dice[3] = temp1;
    }
  }
  printf("%d\n",dice[0]);
  return 0;
}

Measured memory_bytes: 596
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,count=0;
  cin>>n;
  vint p(n,0);
  rep(i,n){
    cin>>p[i];
  }
  sort(all(p));
  p[n-1]=p[n-1]/2;
  rep(i,n){
    count+=p[i];
  }
  cout<<count<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);


int main() {
    int n, m;
    cin >> n >> m;
    int ans = 0;
    if (n >= 2) ans += n*(n-1)/2;
    if (m >= 2) ans += m*(m-1)/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;cin>>n;
    bool flag = false;
    int ans = -1;
    rep(i,50010)
    {
        if (n == floor(1.08 * i))
        {
            flag = true;
            ans = i;
            break;
        }
    }
    if (flag)
    {
        cout << ans << endl;
    }
    else
    {
        cout << ":(" << endl;
    }
    
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main() {
    long long n, r;
    scanf ("%lld %lld", &n, &r);
    if (n >= 10) printf ("%lld\n", r);
    else printf ("%lld\n", r + 100 * (10 - n));
    return 0;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

count = 0
line =[]
line2 =[False] * N
max_h =max(h)
for i in range(1,max_h+1)[::-1]:
    line = [x == i for x in h]
    line2 = line = [x|y for x,y in zip(line,line2)]
    flag = False
    for j in range(N):
        if flag == False:
            if line[j] == True:
                count += 1
                flag = True
            else:
                continue
        else:
            if line[j] == False:
                flag = False

print(count)
                
            
            

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

int A[500000],count=0;

void merge(int,int,int);
void mergeSort(int,int);
  
void merge(int left,int mid,int right){
  int i,j,k,n1,n2,L[500000],R[500000];
  n1 = mid - left;
  n2 = right - mid;
  
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = (int)INFINITY;
  R[n2] = (int)INFINITY;
  i=0;
  j=0;
  
  for(k=left;k<right;k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{ 
      A[k] = R[j];
      j = j + 1;
    }
  }
}

void mergeSort(int left,int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(left,mid);
    mergeSort(mid,right);
    merge(left,mid,right);
  }
}

int main(){
  int i,n,left=0,right;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  right=n;

  mergeSort(left,right);
  
  for(i=0;i<n;i++){
    if(i!=0) printf(" ");
  printf("%d",A[i]);
  }
  printf("\n%d\n",count);

  return 0;
}



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

int main() {
  int N;
  cin>>N;
  int a=0,b=0,c=0,d=0;
  string j;
  for(int i=0;i<N;i++){
    cin>>j;
    if(j=="AC"){
      a++;
    }
    if(j=="WA"){
      b++;
    }
    if(j=="TLE"){
      c++;
    }
    if(j=="RE"){
      d++;
    }
  }
 cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<b<<endl;
  cout<<"TLE x "<<c<<endl;
  cout<<"RE x "<<d<<endl;
}


Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 2000005;
const int K = 50;
set < int > g1[N], g2[N];
int s1[N], s2[N], a[N], b[N], x[N];
bool snuke(int x){
    int s = 0;
    int z = x;
    int p = 1;
    int f = 1;
    while(z){
        s += z % 10;
        if (z % 10 == 9 && f) p = 10 * p;
        if (z % 10 != 9) f = 0;
        z /= 10;
    }
    if (x <= p * s) return 1;
    return 0;

}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int k;
    cin >> k;
    set < int > sn;
    int p = 1;
    int d = 0;
    for (int i = 0; i < 15; i++){
        for (int j = 1; j <= 999; j++){
            sn.insert(j * p + d);
           // cout << j * p + d << endl;
        }
        p = p * 10;
        d = 10 * d + 9;
    }
    while(k){
        if (snuke(*sn.begin())){
            k--;
            cout << *sn.begin() << endl;
        }
        sn.erase(sn.begin());
    }
}


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

int main(){
  string s,t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  
  if(s<t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
s = input()
t = input()

S = len(s)
T = len(t)

x = len(t)
for i in range(S - T + 1):
    y = 0
    for j in range(T):
        if t[j] != s[i + j]:
            y += 1
    x = min(x, y)

print(x)

Measured memory_bytes: 9004
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
	int N, M, C, count = 0;
	cin >> N >> M >> C;
  	int A[N][M];
  	int B[M];
  	int sum[N] = {0};
  
  	REP(i, M) cin >> B[i];
	REP(i, N) REP(j, M) cin >> A[i][j];
  
  	REP(i, N){
      	REP(j, M) sum[i] += A[i][j] * B[j];
      if(sum[i] + C > 0) count++;
    }
    cout << count << endl;
}

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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,M;
const int max_n = 100000+10;
vector<int> G[max_n];

int main(void) {
    cin>>N>>M;

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

    for(int i = 0;i < M;i++) {
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans = 0;
    for(int i = 1;i <= N;i++) {
        bool flag = true;
        for(auto u: G[i]) {
            if(H[i] <= H[u]) {
                flag = false;
                break;
            }
        }

        if(flag) {
            ans++;
        }
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 8428
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=((a-1)/d);
  int y=((c-1)/b);
  if(x>=y)
    cout<<"Yes";
  else
    cout<<"No";

// -------------------------------------Code ends here------------------------------------------------------------------
    clock_t clk;
  clk = clock();

    clk = clock() - clk;
  cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
  return 0;
}


Measured memory_bytes: 3780
a = []
3.times do
  a << gets.split.map(&:to_i).to_a
end

N = gets.to_i
ans = Array.new(3) { Array.new(3, false) }

N.times do
  b = gets.to_i
  3.times do |i|
    3.times do |j|
      if a[i][j] == b
        ans[i][j] = true 
      end
    end
  end
end

3.times do |i|
  mark = 0
  3.times do |j|
    next unless ans[i][j]
    mark += 1
    if mark == 3
      puts 'Yes'
      exit
    end
  end
end

3.times do |j|
  mark = 0
  3.times do |i|
    next if ans[i][j] != true
    mark += 1
    if mark == 3
      puts 'Yes'
      exit
    end
  end
end

if ans[0][0] && ans[1][1] && ans[2][2]
  puts 'Yes'
  exit
end

if ans[0][2] && ans[1][1] && ans[2][0]
  puts 'Yes'
  exit
end

puts 'No'

Measured memory_bytes: 14380
#include <iostream>
#include <cstdlib> 
using namespace std;
//A - Five Antennas
int main(void){
    int antena[5];
    for (int i = 0; i < 5; i++) {
        std::cin >> antena[i];
    }
    int k;
    std::cin >> k;
    bool ans=true;
    for (int i = 0; i < 5; i++) {
        for (int j = i+1; j < 5; j++) {
            if(abs(antena[i]-antena[j])>k){
                ans=false;
            }
        }
    }
    if(ans)
        std::cout << "Yay!" << std::endl;
    else
        std::cout << ":(" << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    int ans = 0;
    string s; cin >> s;
    rep(i,n){
        int cnt = 0;
        VI x(26,0),y(26,0);
        rep(j,i) x[s[j]-'a']++;
        FOR(j,i,n) y[s[j]-'a']++;
        rep(j,26) if(x[j] > 0 && y[j] > 0) cnt++;
        ans = max(ans,cnt);
    }
    ANS;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  ll n,m;
  cin>>n>>m;
  vector<pair<ll,ll>> a(n);
  rep(i,n) cin>>a[i].first>>a[i].second; //値段　個数
  sort(all(a));
  ll ans=0;
  for(int i=0;m>0;i++){
    if(m-a[i].second<0){
      ans+=m*a[i].first;
      m=0;
    }
    if(m-a[i].second>=0){
      ans+=a[i].second*a[i].first;
      m-=a[i].second;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4844
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N;
  scanf("%d", &N);

  // create graph
  vector<int> as, bs;
  for (int i = 1; i <= N; i++) {
    for (int j = i + 1; j <= N; j++) {
      if (N % 2 == 0 && i + j == N + 1) {
        continue;
      }
      if (N % 2 == 1 && i + j == N) {
        continue;
      }
      as.push_back(i);
      bs.push_back(j);
    }
  }
  const int num = as.size();
  printf("%d\n", num);
  for (int i = 0; i < num; i++) {
    printf("%d %d\n", as[i], bs[i]);
  }
  
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << "\n"; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " <<to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve(){
  int n,m;
  cin>>n>>m;
  cout<<(1800*m+100*n)*(int)pow(2,m)<<endl;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


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

int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0) return 0;
    int order[n];
    int dise[m];
    for (int i = 0; i < n; i++) {
      cin >> order[i];
    }
    for (int i = 0; i < m; i++) {
      cin >> dise[i];
    }
    
    int point = 1;
    int pd = 0;
    int count = 0;
    while (point < n) {
      point += dise[pd++];
      point += order[point - 1];
      count++;
    }
    
    cout << count << endl;
  }
}

Measured memory_bytes: 3016
// file creato da gio il 2020-03-25 09:50:14.760425

#include <bits/stdc++.h>
#define FAST 

#ifdef FAST
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

#define S second
#define F first
#define PB push_back
using namespace std;

int done[10000];
int distances[10000][10];
vector<pair<int,int>> adj[10000];
int biglietti[10];
int main(){
	//freopen("output","w",stdout);
	//freopen("input","r",stdin);
#ifdef FAST
	ios::sync_with_stdio(0);
  	cin.tie(0);
#endif

	int N;
	cin >> N;
	double c=N;
	printf("%.6f",N/3.0*N/3.0*N/3.0); 
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

  int ans = 0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(i*500 + j*100 + k*50 == x) ans++;
      }
    }
  }

  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <class T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

void usaco(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(name.size())
    {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

signed main()
{
    usaco();
    long long x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if (x/d >= k) cout << x-k*d << '\n';
    else {
        long long s = x/d;
        k -= s;
        x -= s*d;
        cout << (k & 1 ? abs(x-d) : x) << '\n';
    }
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c,i,ans;
   double n[110]={};
   double d,cnt;
   while(~scanf("%d%d",&a,&b))
   {
      d=0;ans=0;c=0;
      for(i=0;i<a;i++)
      {
          scanf("%lf",&n[i]);
          d+=n[i];
      }
      cnt=d/4.0/b;
     for(i=0;i<a;i++)
     {
         if(n[i]>=cnt)
         {
             ans++;
         }
         if(ans==b)
         {
             c=1;
             break;
         }
     }
     if(c)
        printf("Yes\n");
     else
        printf("No\n");
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <cstdlib>
#define rep(i, N) for (long i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(A + B, max(A - B, A * B)) << endl;
}


Measured memory_bytes: 256
def divisor(n)
  res = []
  (1..Math.sqrt(n)).each do |i|
    if (n % i).zero?
      res << i
      res << n/i
    end
  end
  res.sort
end

def gcd(x, y)
  (divisor(x) & divisor(y)).max
end

x, y = gets.split.map(&:to_i)
puts gcd(x, y)


Measured memory_bytes: 6892
def main():
    import sys
    input = sys.stdin.readline
    isprime = [True if i % 2 else False for i in range(55555+1)]
    isprime[1] = False
    rem = 1
    ans = []
    for i, j in enumerate(isprime[2:], start=2):
        if not j:
            continue
        ind = i * 2
        while ind <= 55555:
            isprime[ind] = False
            ind += i

    for i, j in enumerate(isprime):
        if not j:
            continue
        if i % 5 == rem:
            ans.append(i)
    
    print(*ans[:int(input())])

if __name__ == '__main__':
    main()

Measured memory_bytes: 9740
import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        int N = scan.nextInt();
        int i = scan.nextInt();
        Task tsk = new Task();
        System.out.println(tsk.solve(N, i));
    }

    static class Task{
        public int solve(int n, int i) {
            return n + 1 - i;
        }
    }
}


Measured memory_bytes: 21844
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;
template <typename T = vii>
using vec = vector<T>;

const ll INF = 1e18, MOD = 1e9 + 7;

const int MAX = 1e6;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);

    int n;
    cin >> n;
    vec<queue<int> > v(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 1; j++) {
            int x;
            cin >> x;
            x--;
            v[i].push(x);
        }
    }
    set<int> cur;
    auto add = [&] (const int i) {
        if (v[i].empty()) return;
        const int j = v[i].front();
        const int k = min(i, j);
        if (v[j].front() == i and cur.find(k) == cur.end())
            cur.insert(k);
    };
    for (int i = 0; i < n; i++) {
        add(i);
    }
    int res = 0;
    while (not cur.empty()) {
        res++;
        vii aux;
        for (int i : cur) {
            const int j = v[i].front();
            v[i].pop();
            v[j].pop();
            aux.push_back(i);
            aux.push_back(j);
        }
        cur.clear();
        for (int i : aux) {
            add(i);
        }
    }
    if (all_of(v.begin(), v.end(), [](auto &q) { return q.empty(); })) {
        cout << res << '\n';
    }
    else {
        cout << "-1\n";
    }
}

Measured memory_bytes: 4736
#include <iostream>
using namespace std;
int64_t solve(int64_t n,int64_t x){
    if(n<0) return 0;
    return n/x+1;
}

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

int64_t a,b,x,ans=0;
cin >> a >> b >> x;
ans=solve(b,x)-solve(a-1,x);
cout << ans << endl;

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
def printlexsmaller(n,m):
  str1 = "".join([str(n) for x in range(m)])
  str2 = "".join([str(m) for x in range(n)])
  return str1 if str1 < str2 else str2

input = list(map(int, input().rstrip().split()))
print(printlexsmaller(*input))

Measured memory_bytes: 38312
//恶意评分++

#include<cstdio>
#include<cstring>

#define mian int main()

char c[100007];

int min(int a,int b){return a>b?b:a;}

mian{
    scanf("%s",c);
    int l=strlen(c),g=0;
    for(int i=0;i<l;++i) if(c[i]=='g') g++;
    printf("%d\n",min(l/2,g)-min(l-l/2,l-g));
    return 0;
}

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

int main(int argc, char** argv) {
	char s[4], t[4];
	int same = 0;

	cin >> s >> t;

	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i]) {
			same++;
		}
	}

	cout << same << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
using ll = long long;

int main(){
    std::string s; std::cin >> s;
    std::cout << s.substr(0,3);
    return 0;
}


Measured memory_bytes: 3640
dic = {}
dic.setdefault('a',str(input())+'A')
dic.setdefault('b',str(input())+'B')
dic.setdefault('c',str(input())+'C')
dare = dic['a'][0]
dic['a'] = dic['a'][1:]
while len(dic['a'])>0 and len(dic['b'])>0 and len(dic['c'])>0:
    tmp = dic[dare][0]
    dic[dare] = dic[dare][1:]
    dare = tmp
print(dare)


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

int main(){
  char x;
  cin >> x;
  if(x == 'A'){
    cout << 'T' << endl;
  }
  else if(x == 'T'){
    cout << 'A' << endl;
  }
  else if(x == 'C'){
    cout << 'G' << endl;
  }
  else{
  	cout << 'C' << endl;
  }
}

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

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

using ll = long long;

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  ll r=0LL,g=0LL,b=0LL;
  for(int i = 0; i < N; i++) {
    if(S[i]=='R') r++;
    if(S[i]=='G') g++;
    if(S[i]=='B') b++;
  }
  ll cnt = 0LL;
  for(int i = 0; i < N-2; i++) {
    for(int j = 1; i + 2*j< N; j++) {
      if(S[i]!=S[i+j]&&S[i+j]!=S[i+2*j]&&S[i+2*j]!=S[i]) cnt++;
    }
  }
  cout<<r*g*b - cnt <<endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c == 17) {
    if (a == 7 || b == 7 || c == 7) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<57;
const double pi=acos(-1);
const double eps=1e-6;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

int n;

int main(){
	cin>>n;
	int sum=0;
	set<int> s;
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		sum^=A;
		s.insert(A&(-A));
	}
	int res=0;
	for(int i=0;i<31;i++){
		bool A=sum&1<<i,B=sum&1<<(i+1);
		if(A^B){
			if(s.find(1<<i)!=s.end()) res++;
			else{
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	cout<<res<<endl;
}

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

public class MainClass
{
	public static void Main(string[] args)
	{
		string[] inputs = Console.ReadLine().Split(' ');
		int a = int.Parse(inputs[0]);
		int b = int.Parse(inputs[1]);
		int c = int.Parse(inputs[2]);
		
		Console.WriteLine(Math.Min(c,b / a));
	}
}

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

const int MOD=1000000007;

int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  rep(i,60){
    ll X=0, Y=0;
    rep(j,n){
      if((a[j]>>i)&1){
        X++;
      }else{
        Y++;
      }
    }
    ll now=X*Y%MOD;
    rep(j,i){
      now=now*2%MOD;
    }
    ans+=now;
    ans%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5572
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-9
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n,k,r,s,p;
string t;
int dp[N][3];

int main(){
    read2i(n,k);
    read3i(r,s,p);
    cin >>t;

    lp(i,0,n-1){
        dp[i][0] = r * (t[i] == 's') + (i >= k ? max(dp[i-k][1], dp[i-k][2]) : 0);
        dp[i][1] = s * (t[i] == 'p') + (i >= k ? max(dp[i-k][0], dp[i-k][2]) : 0);
        dp[i][2] = p * (t[i] == 'r') + (i >= k ? max(dp[i-k][0], dp[i-k][1]) : 0);
    }

    int ans = 0;
    lpd(i,n-1,max(0,n-k)) ans += max({dp[i][0], dp[i][1], dp[i][2]});
    cout <<ans;
}

/*
uniform_int_distribution<type>(l, r)(rng)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
*/


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	vector<ll>arr(n);
	vector<ll>rel(100001,0);//change this
	ll sum=0;
	for(int i=0; i<n; i++){
	 cin>>arr[i];
	 sum+=arr[i];
	 rel[arr[i]]++;
    }
    int q;
    cin>>q;
    while(q--)
    {
    	int a,b;
    	cin>>a>>b;
    	sum-=a*rel[a];
    	sum+=b*rel[a];
    	rel[b]+=rel[a];
    	rel[a]=0;
    	cout<<sum<<"\n";
	}
	return 0;
	
	
}



Measured memory_bytes: 4780
N = int(input())
A = list(map(int, input().split()))
S = [0 for i in range(N+1)]
for s in range(N):
    S[s+1] = S[s] + A[s]

import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

S.sort()
S = S + [S[-1]+1]
c = 1
s = 0
for i in range(N+1):
    if S[i] == S[i+1]:
        c += 1
    else:
        if c > 1:
            s += comb(c, 2)
        c = 1
print(s)


Measured memory_bytes: 25976