akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
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<string> vs;
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<<27;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
//const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll mod;

vvl mul(vvl A,vvl B){
	vvl C(A.size(),vl(B[0].size()));
	for(int i=0;i<A.size();i++) for(int k=0;k<B.size();k++) for(int j=0;j<B[0].size();j++) (C[i][j]+=A[i][k]*B[k][j])%=mod;
	return C;
}

// 行列の最小二乗法
vvl pow(vvl A,ll n){
	vvl B(A.size(),vl(A.size()));
	for(int i=0;i<A.size();i++) B[i][i]=1;
	while(n>0){
		if(n&1) B=mul(B,A);
		A=mul(A,A);
		n>>=1;
	}
	return B;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int n,m,a,b,c,t;
		cin>>n>>m>>a>>b>>c>>t;
		if(n==0) break;
		mod=m;
		vi d(n);
		for(int i=0;i<n;i++) cin>>d[i];
		vvl A(n,vl(n));
		for(int i=0;i<n;i++){
			if(i+1<n) A[i+1][i]=a;
			A[i][i]=b;
			if(i) A[i-1][i]=c;
		}
		A=pow(A,t);
		for(int i=0;i<n;i++){
			if(i) cout<<' ';
			ll res=0;
			for(int j=0;j<n;j++) (res+=A[i][j]*d[j])%=mod;
			cout<<res;
		}
		cout<<endl;
	}
}


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

int main() {
    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n+2,0),b(m+2,0);
    REP(i,n) cin >> a[i];
    REP(i,m) cin >> b[i];

    
    //aを取れるだけ取る
    ll sum_time = 0;
    ll a_num = 0;
    if(sum_time+a[1]<=k){
        while(1){
            sum_time+=a[a_num+1];
            a_num++;
            if(a_num==n) break;
            if(sum_time+a[a_num+1]>k) break;
        }
    }

    //さらにbを取りきる
    ll b_num = 0;
    if(sum_time+b[1]<=k){
        while(1){
            sum_time+=b[b_num+1];
            b_num++;
            if(b_num==m) break;
            if(sum_time+b[b_num+1]>k) break;
        }
    }

    ll ans = a_num + b_num;
    while(a_num>0){
        sum_time-=a[a_num];
        a_num--;
        while(b_num<m&&sum_time+b[b_num+1]<=k){
            sum_time+=b[b_num+1];
            b_num++;
        }
        ans = max(ans,a_num+b_num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6412
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define LL long long
using namespace std;
LL read() {
    LL k = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9')
        k = k * 10 + c - 48, c = getchar();
    return k * f;
}
int a[51], b[51];
int main() {
    int n = read();
    for(int i = 1; i <= n; ++i) a[i] = b[i] = read();
    sort(a+1, a+n+1);
    int tot = 0;
    for(int i = 1; i <= n; ++i)
        if(a[i] != b[i]) ++tot;
    if(tot == 2 || tot == 0) printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 105
struct in{
 char ch;
 int  val;
};
in a[maxn];
in b[maxn];
int n;
bool compareStable()
{
    for(int i=0;i<n;i++)
    {
        if(a[i].ch!=b[i].ch)
            return false;

    }
    return true;
}
void bubbleSort()
{
      bool flag=1;
      for(int i=0;flag;i++)
      {
          flag=0;
          for(int j=n-1;j>=i+1;j--)
          {
              if(a[j].val<a[j-1].val)
              {
                    swap(a[j],a[j-1]);
                    flag=1;
              }
          }
      }
    for(int i=0;i<n;i++)
    {
        if(i!=n-1)
            cout<<a[i].ch<<a[i].val<<" ";
        else
            cout<<a[i].ch<<a[i].val<<endl;
    }
    cout<<"Stable"<<endl;

}

void selectionSort()
{
    for(int i=0;i<n;i++)
    {
        int minj=i;
        for(int j=i;j<n;j++)
        {
            if(b[j].val<b[minj].val)
                minj=j;
        }
        swap(b[i],b[minj]);
    }
     for(int i=0;i<n;i++)
    {
         if(i!=n-1)
            cout<<b[i].ch<<b[i].val<<" ";
        else
            cout<<b[i].ch<<b[i].val<<endl;
    }
    if(compareStable())
        cout<<"Stable"<<endl;
    else
        cout<<"Not stable"<<endl;
}
int main()
{
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
            cin>>a[i].ch>>a[i].val;
        for(int i=0;i<n;i++)
        {
            b[i].ch=a[i].ch;
            b[i].val=a[i].val;
        }

        bubbleSort();
        selectionSort();
    }
    return 0;
}

Measured memory_bytes: 3112
S = list(input())
T = list(input())
ma = dict()
yes = True
for i in range(len(S)):
    if S[i] not in ma:
        ma[S[i]] = T[i]
    else:
        if ma[S[i]] != T[i]:
            yes = False
            break
ma.clear()
for i in range(len(S)):
    if T[i] not in ma:
        ma[T[i]] = S[i]
    else:
        if ma[T[i]] != S[i]:
            yes = False
            break
            
if yes:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 6704
#include <iostream>
using namespace std;
int main()
{
  int h,w;
  while(1)
  {
    cin>>h>>w;
    if((h==0)&&(w==0)) break;
    for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
        cout<<(((i==0)||(i==h-1)||(j==0)||(j==w-1))?'#':'.');
      cout<<endl;
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x,t;
    int p;
    cin>>n>>x>>t;
    if(n<x)
        cout<<t<<"\n";
    else{
        if(n%x==0)
            p=(int)n/x;
        else
            p=(int)n/x  +1;
        cout<<p*t<<"\n";
    }

    return 0;
}

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

ll N, K, t, d, sum, ans;
vector<ll> F, S;
vector<pair<ll, ll>> v;
map<ll, ll> mp;

main() {
    cin >> N >> K;
    for (ll i = 0; i < N; i++) {
        cin >> t >> d;
        v.push_back(make_pair(t, d));
    }
    sort(v.rbegin(), v.rend());
    for (ll i = 0; i < v.size(); i++) {
        pair<ll, ll> p = v[i];
        if (mp[p.first] == 0) F.push_back(p.second);
        else S.push_back(p.second);
        mp[p.first]++;
    }
    sort(F.rbegin(), F.rend());
    sort(S.rbegin(), S.rend());
    ll L = F.size(), M = S.size();
    for (ll i = 0; i < min(K, L); i++) sum += F[i];
    if (K > L) {
        ll check = 0;
        for (ll i = 0; i < K - L; i++) sum += S[i], check = i;
        check++, ans = sum + L * L;
        for (ll j = L - 1; j > 0 && check < M; j--) {
            sum = sum - F[j] + S[check];
            check++;
            ans = max(ans, sum + j * j);
        }
        cout << ans << endl;
    }
    else {
        ans = sum + K * K;
        for (ll i = 0; i < K - 1 && i < M; i++) {
            sum -= F[K - 1 - i];
            sum += S[i];
            ans = max(ans, sum + (K - i - 1) * (K - i - 1));
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 8816
n=int(input())
ans=[0]*n
t=3
import math
while t**2-((math.ceil(t/3))**2)*3<=n:
  for i in range(1,t-1):
    for j in range(1,t-i):
      k=t-i-j
      if t**2-i*j-j*k-k*i-1<n:
        ans[t**2-i*j-j*k-k*i-1]=ans[t**2-i*j-j*k-k*i-1]+1
  t=t+1
for i in range(n):
  print(ans[i])

Measured memory_bytes: 9172
N = int(input())
MOD = 10 ** 9 + 7
fact, fact_inv, inv = [0] * (N+1), [0] * (N+1), [0] * (N+1)


def main():
    a = list(map(int, input().split()))

    fact[0] = 1
    for i in range(1, N+1):
        fact[i] = fact[i-1] * i % MOD

    fact_inv[N] = pow(fact[N], MOD-2, MOD)
    for i in range(N-1, 0, -1):
        fact_inv[i] = fact_inv[i+1] * (i+1) % MOD

    for i in range(1, N+1):
        inv[i] = fact_inv[i] * fact[i-1] % MOD

    b, s = [0] * N, [0] * (N+1)
    for i in range(1, N+1):
        s[i] = (s[i-1]+inv[i]) % MOD

    for i in range(N):
        b[i] = (s[i+1]+s[N-i]-1) % MOD

    ans = 0
    for i in range(N):
        ans = (ans+a[i]*b[i]) % MOD

    ans = ans * fact[N] % MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26924
#include<stdio.h>
#include<string.h>


int main(void){

	int i;
	char s;
	int sum[26];

	for(i=0;i<26;i++)
		sum[i] = 0;


	while(scanf("%c",&s)!=EOF){

		if( s>='a' && s<='z')
			sum[ s%'a' ]++;

		else if(s>='A' && s<='Z')
			sum[ s%'A' ]++;

	}


	for(i=0;i<26;i++)
		printf("%c : %d\n",'a'+i , sum[i]);


	return 0;

}

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

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

inline ll ceil(ll num, ll den){
	if(den < 0){
		num = -num;
		den = -den;
	}
	if(num > 0)return (num + den - 1)/den;
	return -((-num)/den);
}

inline ll floor(ll num, ll den){
	if(den < 0){
		num = -num;
		den = -den;
	}
	if(num > 0)return num/den;
	return -((-num + den - 1)/den);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; ll k;
	cin>>n>>k;
	vector<ll> a(n);
	for(auto &x : a){
		cin>>x;
	}
	sort(a.begin(), a.end());
	ll lo = -1e18, hi = 1e18;
	while(lo < hi){
		ll mi = lo + (hi - lo)/2;
		ll cnt = 0;
		for(auto x : a){
			if(x == 0){
				if(mi >= 0)cnt += n;
			}else if(x > 0){
				cnt += upper_bound(a.begin(), a.end(), floor(mi, x)) - a.begin();
			}else{
				cnt += n - (lower_bound(a.begin(), a.end(), ceil(mi, x)) - a.begin());
			}
			if(x*x <= mi)cnt--;
		}
		// cout<<mi<<" "<<cnt<<endl;
		cnt /= 2;
		if(cnt >= k)hi = mi;
		else lo = mi + 1;
	}
	cout<<lo<<endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n;
	map<int, int> M;
	cin >> n;
	for (int i = 1;;i++)
	{
		if (M[n] != 0)
		{
			cout << i << endl;
			break;
		}
		M[n] = i;
		n = (n%2==0?n/2:3*n+1);
	}
	return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
if abs(x)==abs(y):
    print(1)
elif x*y==0:
    if x==0:
        if 0<y:
            print(y)
        elif y<0:
            print(abs(y)+1)
    elif y==0:
        if 0<x:
            print(abs(x)+1)
        elif x<0:
            print(abs(x))
elif 0<x*y:
    if x<y:
        print(y-x)
    else:
        print(abs(abs(y)-abs(x))+2)
elif x*y<0:
    print(abs(abs(y)-abs(x))+1)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int iN;

int maxX;
int maxY;

void init() {
  scanf("%d", &iN);
}

bool input() {
  if (!iN--) return false;

  return true;
}

int getDis(int x0, int y0, int x1, int y1) {
  return (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);
}

void manage() {
  int x = 0, y = 0;
  maxX = 0;
  maxY = 0;
  int maxD = 0;
  int dx, dy;
  while (1) {
    scanf("%d %d", &dx, &dy);
    if (!dx && !dy) break;
    x += dx;
    y += dy;
    if (maxD < getDis(0, 0, x, y)) {
      maxD = getDis(0, 0, x, y);
      maxX = x;
      maxY = y;
    } else
    if (maxD == getDis(0, 0, x, y) && maxX <= x) {
      maxD = getDis(0, 0, x, y);
      maxX = x;
      maxY = y;
    }
  }
}

void output() {
  printf("%d %d\n", maxX, maxY);
}

int main() {
  init();
  while (1) {
    if (!input()) break;
    manage();
    output();
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.math.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int count;
	static BigInteger sum = new BigInteger("0");
	static BigInteger numSum = new BigInteger("0");
	static BigInteger val, num;
	public static void main(String[] args) {
		while(read()){
			
		}
		solve();
	}
	static boolean read(){
		if(!sc.hasNext())return false;
		String line;
		String[]dev = new String[2];
		line = sc.next();
		dev = line.split(",");
		val = BigInteger.valueOf(Integer.parseInt(dev[0]));
		num = BigInteger.valueOf(Integer.parseInt(dev[1]));
		//System.out.println("num = " + num);
		sum = sum.add(val.multiply(num));
		numSum = numSum.add(num);
		//System.out.println("numSum = " + numSum);
		count++;
		//System.out.println("count = " + count);
		return true;
	}
	static void solve(){
		System.out.println(sum);
		int intnum = numSum.intValue();
		System.out.println(Math.round((double)intnum/count));
	}

}

Measured memory_bytes: 12000
n = int(input(), 10) 
v = list(map(int, input().split())) 
c = list(map(int, input().split())) 
otoku = []
 
for i in range(n):
  otoku.append(v[i] - c[i])
 
res = 0
for j in range(n):
  if otoku[j] > 0:
    res += otoku[j]
    
print(res)

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> degree(n+1);
	vector<vector<int>> edge(n+1), in(n+1);
	int x, y;
	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		degree[y]++;
		edge[x].push_back(y);
		in[y].push_back(x);
	}
	
	vector<int> ver;
	queue<int> Q;
	for (int i = 1; i <= n; i++) {
		if (degree[i] == 0) {
			Q.push(i);
		}
	}
	
	while (!Q.empty()) {
		int u = Q.front(); Q.pop();
		ver.push_back(u);
		for (int v : edge[u]) {
			degree[v]--;
			if (degree[v] == 0) {
				Q.push(v);
			}
		}
	}
	
	vector<int> dp(n+1, 0);
	int res = 0;
	for (int i = 0; i < n; i++) {
		int u = ver[i];
		for (int v : in[u]) {
			dp[u] = max(dp[u], dp[v]+1);
		}
		res = max(res, dp[u]);
	}
	
	cout << res << endl;
}

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

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

  dp[0][0] = 1.0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= N; j++) {
      double prob = p[i];
      dp[i + 1][j + 1] += dp[i][j] * prob;
      dp[i + 1][j]     += dp[i][j] * (1 - prob);
    }
  }

  double ret = 0;
  for (int i = N / 2 + 1; i <= N; i++) {
    ret += dp[N][i];
    // cerr << i << " : " << dp[N][i] << endl;
  }
  cout << fixed << setprecision(10) << ret << endl;

  return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>

using namespace std;

typedef pair<int,int>pii;
#define INF 0x3f3f3f3f
#define fi first
#define se second

int mcos[105];
vector <pii> G[105];
int N;


void dijkstra(int start){
  priority_queue<pii,vector<pii>,greater<pii> > pq;

  pq.push( pii(0,start) );
  memset( mcos,INF,sizeof(mcos));
  mcos[start]=0;

  
  while(!pq.empty() ){
    const pii tmp=pq.top();
    pq.pop();
    
    const int now=tmp.se;
    
    if(mcos[now] < tmp.fi) continue;
    
    for(int i=0;i<G[now].size();++i){
      const int newcost = G[now][i].fi + tmp.fi;
      const int next= G[now][i].se;
      
      if(newcost < mcos[next] ){
	mcos[next]=newcost;
	pq.push( pii(newcost,next) );
      }
    }
  }
  return ;
  
}

int main (){
  cin>>N;
  int k,u,v,c;

  for(int i=0;i<N;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      G[u].push_back(make_pair(c,v));
    }
  }
  dijkstra(0);
  for(int i=0;i<N;i++){
    cout<<i<<" "<<mcos[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define int long long
#define P pair<int,int>

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

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int m;
    cin >> m;
    vector<int> b(m);
    rep(i,m) cin >> b[i];

    int ans = 0;
    for(int i = 0; i < m; i++){
        int x = b[i];

        if(binary_search(all(a),x)) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3768
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#define rg register
using namespace std;
struct node
{
	long long a,b;
}e[200010];
inline bool comp(node a,node b)
{
	return a.a<b.a;
}
signed main()
{
	long long n,m;
	cin>>n>>m;
	for(long long i=1;i<=n;i++)
	  scanf("%lld%lld",&e[i].a,&e[i].b);
	sort(1+e,1+e+n,comp);
	long long ans=0;
	for(long long i=1;i<=n;i++)
	{
		if(m<e[i].b)
		{
			ans+=e[i].a*m;
			break;
		}
		ans+=e[i].a*e[i].b;
		m-=e[i].b;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define    ll   long long int
#define    sz   200010
#define    md   1000000007
#define    py   printf("YES\n")
#define    pn   printf("NO\n")

using namespace std;


ll num[sz];


int main()
{

    ll mx=0,mn=0,i,j,k,s=0,d,p,n,m;

    cin>>n;

    for(i=1;i<=n;i++)
    {
        cin>>num[i];
    }
    mx=num[1];
    mn=num[1];
    d=0;
    ll f=0;

    for(i=2;i<=n;i++)
    {
        if(num[i]<num[i-1])
        {
            if(f==0)mn=0;
            f=1;
            s+=(mx-mn);
          //  cout<<s<<endl;

            mx=num[i];
            mn=num[i];

        }
        else
        {
            mx=max(mx,num[i]);
            mn=min(mn,num[i]);
        }
    }

    if(f==0)mn=0;
    s+=(mx-mn);



    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int p(string v){string w(v);reverse(w.begin(),w.end());return w==v?0:1;}
int main(){string s;cin>>s;int n=s.size()/2;string a=s.substr(0,n),b=s.substr(n+1,n);puts(p(s)+p(a)+p(b)?"No":"Yes");}


Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main() {

	int a[3][3];
	int a2[3][3] = { 0 };

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}

	int n;
	int b[10];
	cin >> n;
	int ans=0;
	for (int k = 0; k < n; k++) {
		cin >> b[k];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (a[i][j] == b[k])a2[i][j] = 1;

			}
		}
	}
	for (int i = 0; i < 3; i++) {
		if (a2[i][0] == 1 && a2[i][1] == 1 && a2[i][2] == 1)ans = 1;
		if (a2[0][i] == 1 && a2[1][i] == 1 && a2[2][i] == 1)ans = 1;

	}
	if (a2[0][0] == 1 && a2[1][1] == 1 && a2[2][2] == 1)ans = 1;
	if (a2[2][0] == 1 && a2[1][1] == 1 && a2[0][2] == 1)ans = 1;

	if (ans == 1)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 256
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        PriorityQueue<Integer> a = new PriorityQueue<>(Comparator.reverseOrder());
        for(int i = 0; i < n; i++){
            a.offer(Integer.parseInt(sc.next()));
        }
        
        for(int i = 0; i < m; i++){
            a.offer(a.poll()/2);
        }
        
        long ans = 0;
        for(int i = 0; i < n; i++){
            ans += a.poll();
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 48396
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <cmath>
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 ALL(v) v.begin(),v.end()
#define mod 1000000007


int main(){
  string s;
  ll n;
  ll a,b,t;
  cin >> a >> b >> t;
  ll ans=0;

  cout << t/a*b<< endl;
}


Measured memory_bytes: 764
def main(argv)
  s = gets.chomp

  flag = false
  (s.size - 1).times do |i|
    if s[i] + s[i + 1] == 'AC' then
      flag = true
    end
  end

  puts (flag ? 'Yes' : 'No')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
#include<algorithm>
using std::pair;
using std::make_pair;
#include<iostream>
using std::cin;
using std::cout;
using std::endl;
#include<vector>
using std::vector;
#include<set>
using std::set;
#define reg register

const int MAXN=1000+5;
const int MAXM=2000+5;

bool vis[MAXN];
int n,m;
int cnt,head[MAXN],to[MAXM],Next[MAXM];
vector<pair<int,int>/**/> E;
set<int> S;

inline void Add_Edge(reg int,reg int);
inline bool DFS1(reg int,reg int);
inline void DFS2(reg int,reg int);
inline void Check(reg int);

int main(void){
	reg int i;
	cin>>n>>m;
	//scanf("%d%d",&n,&m);
	for(i=1;i<=m;++i){
		int a,b;
		cin>>a>>b;
		//scanf("%d%d",&a,&b);
		Add_Edge(a,b);
		E.push_back(make_pair(a,b));
	}
	for(i=1;i<=n;++i){
		memset(vis,false,sizeof(vis));
		S.clear();
		vis[i]=true;
		if(DFS1(i,i)){
			memset(vis,false,sizeof(vis));
			DFS2(i,i);
		}
	}
	cout<<-1<<endl;
	//puts("-1");
	return 0;
}

inline void Add_Edge(reg int u,reg int v){
	Next[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
	return;
}

inline bool DFS1(reg int ID,reg int aim){
	reg bool flag=false;
	reg int i;
	for(i=head[ID];i;i=Next[i]){
		if(!vis[to[i]]){
			vis[to[i]]=true;
			if(DFS1(to[i],aim))
				flag=true;
		}
		if(to[i]==aim)
			return true;
	}
	return flag;
}

inline void DFS2(reg int ID,reg int aim){
	reg int i;
	for(i=head[ID];i;i=Next[i]){
		if(!vis[to[i]]){
			vis[to[i]]=true;
			S.insert(to[i]);
			DFS2(to[i],aim);
			S.erase(to[i]);
		}
		if(to[i]==aim)
			Check(to[i]);
	}
	return;
}

inline void Check(reg int aim){
	reg int i,cnt=0;
	S.insert((int)aim);
	for(i=0;i<(int)E.size();++i)
		if(S.find(E[i].first)!=S.end()&&S.find(E[i].second)!=S.end())
			++cnt;
	if(cnt!=(int)S.size())
		return;
	cout<<S.size()<<endl;
	//printf("%d\n",(int)S.size());
	for(set<int>::iterator it=S.begin();it!=S.end();++it)
		cout<<*it<<endl;
		//printf("%d\n",*it);
	exit(0);
	return;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll a;
  scanf("%lld",&a);
  ll b;
  scanf("%lld",&b);
  ll c;
  scanf("%lld",&c);
  set<int> st;
  st.insert(a);
  st.insert(b);
  st.insert(c);
  cout << st.size() << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
static const int white = 0;
static const int gray = 1;
static const int black = 2;

int n,t = 0;
int color[100],d[100],f[100],M[100][100];
int nt[100];

int next(int u) {
  for(int v = nt[u];v < n;v++) {
    nt[u] = v+1;
    if(M[u][v]) return v;
  }
  return -1;
}

void dfs_visit(int r) {

  for(int i = 0;i < n;i++) {
    nt[i] = 0;
  }

  stack<int> S;
  S.push(r);
  color[r] = gray;
  d[r] = ++t;

  while(!S.empty()) {
    int u = S.top();
    int v = next(u);
    if(v != -1) {
      if(color[v] == white) {
        color[v] = gray;
        d[v] = ++t;
        S.push(v);
      }
    }else {
      color[u] = black;
      f[u] = ++t;
      S.pop();
    }
  }

}

void dfs() {
  for(int i = 0;i < n;i++) {
    if(color[i] == white) dfs_visit(i);
  }

  for(int i = 0;i < n;i++) {
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }
}



int main() {


cin >> n;

for(int i = 0;i < 100;i++) {
  for(int j = 0;j < 100;j++) {
    M[i][j] = 0;
  }
}

for(int i = 0;i < 100;i++) {
  color[i] = white;
  nt[i] = 0;
  d[i] = 0;
  f[i] = 0;
}

for(int i = 0;i < n;i++) {
  int u,k;
  cin >> u >> k;
  u--;
  for(int j = 0;j < k;j++) {
    int v;
    cin >> v;
    v--;
    M[u][v] = 1;
  }

}

dfs();

}





Measured memory_bytes: 3148
Scanf.scanf "%d" (fun n ->
    let sz = n * (n - 1) / 2 in
    let nei = Array.make sz [] in
    let count = Array.make sz 0 in
    let rec game a b = if a < b then game b a else a * (a - 1) / 2 + b in

    let arr = Array.init n (fun _ ->
        Array.init (n - 1) (fun _ -> Scanf.scanf " %d" (fun a -> a - 1))
    )
    in
    for i = 0 to n - 1 do
        for j = 0 to n - 3 do
            let g1 = game i arr.(i).(j) in
            let g2 = game i arr.(i).(j + 1) in
            nei.(g1) <- g2 :: nei.(g1);
            count.(g2) <- count.(g2) + 1
        done
    done;

    Printf.printf "%d\n" @@
    let days = Array.make sz (-1) in
    try
        for i = 0 to sz - 1 do
            let rec dfs k =
                if days.(k) > 0 then days.(k) else
                    if days.(k) = 0 then failwith "loop" else (
                        days.(k) <- 0;
                        let r = List.fold_left (fun acc v -> max acc (dfs v)) 0 nei.(k) in
                        days.(k) <- r + 1;
                        r + 1
                    )
            in
            if count.(i) = 0 then ignore (dfs i)
        done;
        Array.fold_left max (-1) days
    with _ -> -1
)

Measured memory_bytes: 53760
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define hell 1000000007  
#define hell2 998244353 

int solve(){
    int a,b;
    cin>>a>>b;
    cout<<a*b;
    //cout<<p;
    return 0;
}   
     
signed main(){
    IOS;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
      // cout<<" * "<<t<<"\n";
    }
//    return 0;
} 

Measured memory_bytes: 3576
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	long long a,b;
	scanf("%lld%lld",&a,&b);
	if(a==0||b==0) printf("Zero");
	if(a>0&&b>0) printf("Positive");
	if(a<0&&b>0) printf("Zero");
	if(a<0&&b<0)
	{
		if((b-a)%2==0) printf("Negative");
		else printf("Positive");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 62);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

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

	ll zorome_cnt = 0;
	REP(i, n){
		ll d, e;
		cin >> d >> e;
		if(d == e){
			zorome_cnt ++;
		}else{
			zorome_cnt = 0;
		}
		if(zorome_cnt >= 3){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3632
import math

a, b, h, m = map(int, input().split())
# h: a, m: b

H =  ((h + m / 60) / 12) * (2 * math.pi)
M = (m / 60) * (2 * math.pi)

if M - H >= 0:
  print('{:.10f}'.format(math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(M - H))))
else:
  print('{:.10f}'.format(math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(H - M))))


Measured memory_bytes: 9452
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cassert>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<utility>
using namespace std;


#define INF (INT_MAX/3-10)

long n;

/*
input data
*/

void init(){
	n=0;
}

bool input(){
	cin>>n;
	if(n==0){
		return false;
	}
	return true;
}


/*素数*/
vector<int> prime;//prime[n];
vector<int> prime_list;
void prime_set(int n){
	n+=100;
	prime.resize(n);
	for(int i=0;i<n;i++){
		prime[i]=1;
	}
	prime[0]=prime[1]=0;
	for(int i=0;i*i<n;i++){
		if(prime[i]){
			for(int j=i*2;j<n;j+=i){
				prime[j]=0;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(prime[i])prime_list.push_back(i);
	}
}


/*
dp とか
*/
void init_solve(){
}

void q_input(){
}

int solve(){
	int count=0;
	for(int i=n+1; i<=2*n && i<prime.size(); i++){
		if(prime[i])
			count++;
	}
 	
	return count;
}


int main(){
	prime_set(123456*2);
	while(init(), input()){
		cout<<solve()<<endl;
	}
}

Measured memory_bytes: 2328
// ref: https://qiita.com/tubo28/items/e6076e9040da57368845
use std::io::{stdin, Read};
use std::str::FromStr;
use std::collections::BTreeSet;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut set: BTreeSet<i32> = BTreeSet::new();
    set.insert(read());
    set.insert(read());
    set.insert(read());
    println!("{}", set.len());
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, y;
  scanf("%d", &n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &x, &y);
    sum += y - x + 1;
  }
  printf("%d\n", sum);
  return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

int n;


int main(){
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	vector<int> temp(n);
	temp = a;
	sort(all(temp));
	int maxA = temp[n-1];
	int secondA = temp[n-2];

	for(int i=0; i < n; i++){
		if (maxA == a[i]){
			cout << secondA << endl;
		}else{
			cout << maxA << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int n;
	int *a;
	int i;
	int ans,temp;
	
	cin >> n;
	a = new int[n];
	
	temp=0;
	for(i=1;i<n;i++){
		if(i%10==0){
			temp -= 9;
		}
		if(i%100==0){
			temp -= 9;
		}
		if(i%1000==0){
			temp -= 9;
		}
		if(i%10000==0){
			temp -= 9;
		}
		temp++;
		a[i]=temp;
	}
	// for(i=0;i<n;i++){
		// cout<<a[i]<<" "<<i<<endl;
	// }
	// cout << endl;
	ans = a[1]+a[n-1];
	for(i=2;i<n-1;i++){
		temp = a[i]+a[n-i];
		if(temp<ans){
			ans=temp;
		}
	}
	cout << ans<<endl;
	
	return 0;
}

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

using namespace std;
typedef long long ll;

#define floop(i, N) for (ll i = 0; i < N; i++)
#define floop1(i, N) for (ll i = 1; i <= N; i++)
#define out(ans) cout << ans << endl
#define in(n) cin >> n

constexpr ll inf = 1e18;

void solve();

int main()
{
    solve();
}

void solve()
{
    ll n, k;
    in(n);
    in(k);
    vector<ll> h(n);
    floop(i, n)
    {
        in(h[i]);
    }
    //floop(i, n) out(h[i]);
    sort(h.begin(), h.end());
    //floop(i, n) out(h[i]);
    ll ans = inf;
    //out(ans);
    floop(i, n - k + 1)
    {
        if (h[i + k - 1] - h[i] < ans)
        {
            ans = h[i + k - 1] - h[i];
            //out(ans);
        }
    }
    out(ans);
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

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

typedef long long ll;
typedef vector<int> VI;


int a[200010];
int b[200010];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    ll t=n;
    vector<int> v;
    for(int i=0; i<32; ++i){
        v.push_back(t&1);
        t>>=1;
    }
    reverse(v.begin(), v.end());
    for(auto e: v) cout << e;
    cout << endl;
    
    v.clear();
    t=~n;
    for(int i=0; i<32; ++i){
        v.push_back(t&1);
        t>>=1;
    }
    reverse(v.begin(), v.end());
    for(auto e: v) cout << e;
    cout << endl;
    
    v.clear();
    t=n; t<<=1;
    for(int i=0; i<32; ++i){
        v.push_back(t&1);
        t>>=1;
    }
    reverse(v.begin(), v.end());
    for(auto e: v) cout << e;
    cout << endl;
    
    v.clear();
    t = n; t>>=1;
    for(int i=0; i<32; ++i){
        v.push_back(t&1);
        t>>=1;
    }
    reverse(v.begin(), v.end());
    for(auto e: v) cout << e;
    cout << endl;
    
	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N, K; cin >> N >> K;
    string S; cin >> S;
    ll unhappies = 0;
    rep(i, N - 1) {
        if (S[i] == 'R' && S[i + 1] == 'L') unhappies += 2;
    }
    if (S[0] == 'L') unhappies++;
    if (S[S.size()-1] == 'R') unhappies++;

    unhappies = unhappies - 2 * K <= 0 ? 1 : unhappies - 2 * K;
    cout << N - unhappies << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
   int n;
   cin >> n;
   vector<double> a(n);
   for(int i = 0;i < n;i++){
       cin >> a[i];
   }
   sort(a.begin(),a.end());
   double ans = a[0];
   for(int i = 1;i < n;i++){
       ans = (ans + a[i]) / 2;
   }
   cout << ans << endl;
   
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N-1);
  for(int i=0;i<N-1;++i) cin >> B.at(i);

  ll ans=0;
  A.at(N-1)=B.at(N-2);
  for(int i=N-2;i>=0;--i){
    A.at(i)=B.at(i);
    A.at(i+1)=min(B.at(i),A.at(i+1));
  }

  for(int i=0;i<N;++i){
    ans+=A.at(i);
    //cout << A.at(i) << " ";
  }
  //cout << endl;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef double db;

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

const int N=2005;
const ll oo=1ll<<62;
ll a[N],x,ans=oo,ret,b[N]; int n;

int main() {
//	file_put();
	
	scanf("%d%lld",&n,&x);
	rep(i,0,n) scanf("%lld",&a[i]),b[i]=a[i];
	rep(i,0,n) {
		ret=i*x;
		rep(j,0,n) ret+=b[j];
		ans=min(ans,ret);
		rep(j,0,n) b[j]=min(b[j],a[(j+i+1)%n]);
	}
	printf("%lld\n",ans);
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int char_to_int(char c){
  switch(c){
    case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
  }
}


int main(){
  ll N;
  cin >> N;
  vector <ll> A(N+1);
  rep(i, N) cin >> A.at(i);
  A.at(N) = -5;
  
  ll res = 0;
  int inc_or_dec = 0;
  
  
  if(N <=2){
    res = 1;
  }else{
    int i = 0;
    while(i+1 < N){
      while(A.at(i) == A.at(i+1)) i++;
      inc_or_dec = 0;
      if(i+1 < N){
        if(A.at(i) < A.at(i+1)){
          inc_or_dec = 1;
          //さっきまでの解答は、イコールがなかった。だからWAになっている。
          while(A.at(i) <= A.at(i+1)) i++;
        }else{
          inc_or_dec = -1;
          //さっきまでの解答は、イコールがなかった。だからWAになっている。
          while(A.at(i) >= A.at(i+1) && i+1 < N) i++;
        }
      }
      res++;
      //cout << i << " " << A.at(i) << endl;
      i++;
      if (i == N-1){
        if((inc_or_dec = 1 && A.at(i-1) > A.at(i)) || (inc_or_dec = -1 && A.at(i-1) < A.at(i))){
          res++;
        }
      }
    }
  }
    
  
  cout << res;
      
  
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define maxn 120
#define maxk 120000
using namespace std;
bool f[maxk];
int a[maxn];
int main(){
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	for(int i = 1; i <= N; i += 1) cin >> a[i];
	for(int i = 1; i <= K; i += 1)
		for(int j = 1; j <= N && a[j] <= i; j += 1){
			f[i] |= !f[i - a[j]];
		}
	cout << (f[K] ? "First" : "Second");
} 

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    int i = 1;
    int cnt = 0;
    while(true){
        if(i >= b){
            break;
        }
        i += a-1;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

// 二項係数計算
long long COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
  COMinit(); //前処理
  int n;
  cin>>n;
  ll ans=0;
  for(int i=1;i<=5000;i++){
    int x=n-3*i;
    if(x<0){
      continue;
    }
    ans+=COM(x+i-1,x);
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 15560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 105;
int n,m;
char str[MAXN][MAXN];
int f[MAXN][MAXN];

int main()
{
    cin >> n >> m;
    for(int i = 1; i<=n; i++)
        cin >> str[i]+1;
    f[1][1] = str[1][1]=='#';
    for(int i = 2; i<=n; i++)
	    f[i][1] = f[i-1][1]+(str[i][1]=='#'&&str[i-1][1]=='.');
	for(int i = 2; i<=m; i++)
	    f[1][i] = f[1][i-1]+(str[1][i]=='#'&&str[1][i-1]=='.');
	for(int i = 2; i<=n; i++)
	    for(int j = 2; j<=m; j++)
		    f[i][j] = min(f[i-1][j]+(str[i][j]=='#'&&str[i-1][j]=='.'),
			   			  f[i][j-1]+(str[i][j]=='#'&&str[i][j-1]=='.'));
	cout << f[n][m] << endl; 
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>

using namespace std;

class Stack {
private:
	long idx;
	long stk[100];

public:
	Stack() {
		idx = -1;
	}
	void push(long l) {
		stk[++idx] = l;
	}
	long pop() {
		return stk[idx--];
	}
	bool size() {
		return idx + 1;
	}
};

int main(){
	Stack stk;
	char token[10];
	while (scanf("%s", token) != EOF) {
		if (*token == '+') {
			long b = stk.pop();
			long a = stk.pop();
			stk.push(a + b);
		} else if (*token == '-') {
			long b = stk.pop();
			long a = stk.pop();
			stk.push(a - b);
		} else if (*token == '*') {
			long b = stk.pop();
			long a = stk.pop();
			stk.push(a * b);
		} else {
			stk.push(atoi(token));
		}
	}

	while (stk.size()) {
		cout << stk.pop() << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int a = 0, b = 0, c = 0;
  string s;
  cin >> s;
  rep(i,3)
    if (s[i] == 'a') {
      a++;
    } else if (s[i] == 'b') {
      b++;
    } else {
      c++;
    }
  if (a == 1 && b == 1 && c == 1)
    cout << "Yes";
  else
    cout << "No";
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

    string a, b;
    cin >> a >> b;
    int c = stoi(a+b);

    REP(i, 400) {
        if (i*i >= c) {
            cout << (i*i == c ? "Yes" : "No") << '\n';
            break;
        }
    }

    return 0;
}

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

#define ll long long
#define M 1000000007
using namespace std;
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
	int n,k;
    cin>>n>>k;
    int arr[k];
    long long sum=0,prod=1;
    for(int i=0;i<k;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    if(n-sum>=0)
    {
        cout<<n-sum;
    }else
    {
         cout<<-1;
    }
    
}

Measured memory_bytes: 3680
from math import factorial

x = input().split()
N = int(x[0])
M = int(x[1])

if N <= 1 and M <= 1:
  print(0)
elif N >= 2 and M <= 1:
  print(factorial(N) // factorial(2) // factorial(N - 2))
elif N <=1 and M >=2:
  print(factorial(M) // factorial(2) // factorial(M - 2))
else:
  print(factorial(N) // factorial(2) // factorial(N - 2) + factorial(M) // factorial(2) // factorial(M - 2))

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    int k;
    string s;

    cin >> k >> s;

    if(s.length() > k) {
        cout << s.substr(0, k) + "...";
    }else cout << s;

}








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

using namespace std;

#define p 1000000000000000000

int main()

{

    unsigned long long a,b,c,x,y,one=p,two=p,three=p,four=p,five=p;
    cin>>a>>b>>c>>x>>y;
    one=x*a+y*b;
    if(x>=y){
    two=(2*y)*c+(x-y)*a;
    four=(2*x)*c;
    }
    if(x<=y){
        three=(2*x)*c+(y-x)*b;
        five=(2*y)*c;
    }
    cout<<min(one,min(two,min(three,min(four,five))))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

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

    int n;
    cin >> n;
    int flag[n];
    for (int i=0;i<=n-1;i++)
    {
        flag[i]=0;
    }

    for (int i=0;i<=n-2;i++)
    {
        int a;
        cin >> a;
        flag[a-1]++;
    }

    for (int i=0;i<=n-1;i++)
    {
        cout << flag[i] << endl;
    }

    return 0;
}

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

using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = 200000;

int n;
int a[N + 5];
ll s[N + 5];
ll ans = LLONG_MAX;

using namespace std;
int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n);
    for(int i = 1; i <= n; ++i) s[i] = s[i-1] + read(a[i]);

    int x = 1, y = 3;
    for(int i = 2; i < n; ++i) {

        while(x+1 < i && abs(s[x+1]-(s[i]-s[x+1])) <= abs(s[x]-(s[i]-s[x]))) {
            ++ x;
        }
        chkmax(y, i + 1);
        while(y+1 < n && abs(s[n]-s[y+1]-(s[y+1]-s[i])) < abs(s[n]-s[y]-(s[y]-s[i]))) {
            ++ y;
        }

        ll mx = max(max(s[x], s[i]-s[x]), max(s[y]-s[i], s[n]-s[y]));
        ll mn = min(min(s[x], s[i]-s[x]), min(s[y]-s[i], s[n]-s[y]));

        chkmin(ans, mx - mn); 
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 2560
import java.io.*
import java.util.*

fun solve(N: Int, T: Int, A: Int, H: IntArray){
    println(H.map{ Math.abs(T - 0.006 * it - A) }.withIndex().minBy{ it.value }!!.index + 1)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val T = sc.next().toInt()
    val A = sc.next().toInt()
    val H = IntArray(N)
    for (i in 0 until N) {
        H[i] = sc.next().toInt()
    }
    solve(N, T, A, H)
}



Measured memory_bytes: 31504
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int r,g;
  cin >> r >> g;
  cout << 2 * g - r << endl;
}


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

using namespace std;

long long a[200005];
long long b[200005];
int main(){
    int n, flag = 0;
    long long sum = 0, mn = 0x3f3f3f3f;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d%d", &a[i], &b[i]);
        if(a[i] != b[i]){
            flag = 1;
        }
        sum += a[i];
        if(a[i] > b[i]){
            mn = min(mn, b[i]);
        }
    }
    if(!flag){
        printf("0\n");
    }
    else{
        printf("%lld\n", sum - mn);
    }
}

Measured memory_bytes: 512