akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long

#define ff first
#define ss second
// #define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}

#define MX 200000
int u[MX+5];
int p[MX+5]; //p[] stores list of prime numbers u[i] stores the smallest prime factor of i
int pn; //strores number of prime numbers

void sieve() {
	//p[2]=2; p[0]=0;
	for(int i = 2; i <= MX; i++) {
		if(!u[i]) {
			u[i]=p[++pn]=i;
		}
		for(int j = 1; i*p[j] <= MX; j++) {
			u[i*p[j]]=p[j];
			if(i%p[j]==0)
				break;
		}
	}	
}
signed main(void)
{
	IOS;
	sieve();
	vi pp;
	for(int i = 0; i < pn-10; i++) {
		pp.pb(p[i]);
	}
	int x;
	cin>>x;
	int vv=*lower_bound(all(pp),x);
	cout<<vv<<endl;
	time();
	return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a - b > 1) {
		cout << (a * 2) - 1 << endl;
	}
	else if (b - a > 1) {
		cout << (b * 2) - 1 << endl;
	}
	else {
		cout << a + b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

#include <bits/stdc++.h>
using namespace std;



int main() {
    int N,M;
    cin >> N >> M;
    vector<vector<int>> v(N+1);
    vector<int> H(N+1);
    for(int i=1; i<=N; i++){
        cin >> H.at(i);
    }
    int n1,n2;

    for(int i=0; i<M; i++){
        cin >> n1 >> n2;
        v.at(n1).push_back(n2);
        v.at(n2).push_back(n1);
    }
    int cnt = 0;
    for(int i=1; i<=N; i++){
        bool f = true;//最大がh.at(i)の状態->false
        for(int j=0; j<v.at(i).size(); j++){
            if(H.at(i) <= H.at(v.at(i).at(j))){
                f = false;
                break;
            }
        }
        if(f == true){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 11896
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

int power(int x, unsigned int y, int p)  
{  
    int res = 1;     
  
    x = x % p;   
                 
  
    while (y > 0)  
    {  
        
        if (y & 1)  
            res = (res*x) % p;  
  
        
        y = y>>1;   
        x = (x*x) % p;  
    }  
    return res;  
}  

int main()
{




  int t;
  //cin>>t;
 t=1;

  while(t--)
{
     int k,n;
     cin>>k>>n;

    vector<int> arr;

    for(int i=0;i<n;i++)
{
    int a;
     cin>>a;
    arr.push_back(a);
 }

  vector<int> dis;

  for(int i=0;i<n-1;i++)
  {
    dis.push_back(arr[i+1]-arr[i]);
  }

  int x= k-arr[n-1];
   dis.push_back(arr[0]+x);

   sort(dis.begin(),dis.end());

   cout<<k-dis[n-1];
}

return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
#include <boost/functional/hash.hpp>
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)
using LL = long long;
using ULL = unsigned long long;

struct pair_hash {
    template <class T1, class T2>
    size_t operator () (const pair<T1, T2> &p) const {
        auto h1 = hash<T1>{}(p.first);
        auto h2 = hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};

const int mod = 1000000007;

LL gcd(LL x, LL y) {
	return y ? gcd(y, x%y) : x;
}

LL p2[200123]{1};

int main()
{
	Rep(i, 200000) {
		p2[i] = p2[i-1] * 2;
		if(p2[i] >= mod) p2[i] -= mod;
	}
	int n, sum = 0;
	cin >> n;
	unordered_map<pair<LL, LL>, int, boost::hash<pair<LL, LL>>> p, q;
	p.reserve(4e5); q.reserve(4e5);
	LL x, y;
	rep(i, n) {
		scanf("%lld%lld", &x, &y);
		if(x == 0 && y == 0) continue;
		LL t = gcd(x, y);
		x /= t; y /= t;
		if(y < 0) x = -x, y = -y;
		if(x == 1 && y == 0) x = -1;
		if(x >= 0) ++q[{x, y}];
		else ++p[{y, -x}];
		++sum;
	}
	LL ans = 1, z = n - sum;
	for(auto& kv: p) {
		auto it = q.find(kv.first);
		if(it == q.end()) continue;
		sum -= it->second + kv.second;
		ans = ans * (p2[it->second] + p2[kv.second] - 1) % mod;
	}
	ans = ans * p2[sum] % mod;
	--ans;
	ans += z;
	if(ans < 0) ans += mod;
	if(ans >= mod) ans -= mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 20748
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
    int n;
    cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    rep(i,n-1)a[i+1]+=a[i];
    ll ans=longinf;
    rep(i,n-2){
        vector<ll> v[4];
        if(i==0)continue;
        int j=lower_bound(a,a+n,a[i]/2)-a;
        if(j<i){
            v[0].push_back(a[j]);v[0].push_back(a[i]-a[j]);
            v[1].push_back(a[j]);v[1].push_back(a[i]-a[j]);
        }
        if(j>0){
            v[2].push_back(a[j-1]);v[2].push_back(a[i]-a[j-1]);
            v[3].push_back(a[j-1]);v[3].push_back(a[i]-a[j-1]);
        }
        j=lower_bound(a,a+n,(a[i]+a[n-1])/2)-a;
        if(n-1!=j){
            v[0].push_back(a[j]-a[i]);v[0].push_back(a[n-1]-a[j]);
            v[2].push_back(a[j]-a[i]);v[2].push_back(a[n-1]-a[j]);
        }
        if(j-1>i){
            j--;
            v[3].push_back(a[j]-a[i]);v[3].push_back(a[n-1]-a[j]);
            v[1].push_back(a[j]-a[i]);v[1].push_back(a[n-1]-a[j]);
        }
        ll res=longinf;
        rep(k,4){
            sort(v[k].begin(),v[k].end());
            if((int)v[k].size()==4)res=min(v[k][3]-v[k][0],res);
        }
        ans=min(res,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
int main(){
	int n;
	scanf("%d",&n);
	int a[n]={};
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int ans=0;
	std::sort(a,a+n);
	int k=0;
	int l=0;
	for(int i=0;i<n;i++){
		if(k!=a[i]){
			ans+=l%2;
			k=a[i];
			l=1;
		}else{
			l++;
		}
	}
	ans+=l%2;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll par[100005];
ll sz[100005];
ll ans;
int findd(int x)
{
    if(par[x]==x)
        return x;
    return par[x]=findd(par[x]);
}
void unionn(int x,int y)
{
    int u=findd(x);
    int v=findd(y);
    if(u!=v)
    {
        if (sz[u] < sz[v])
            swap(u, v);
        par[v] = u;
        //ans += (sz[u]*(sz[u]-1))/2LL;
        //ans += (sz[v]*(sz[v]-1))/2LL;
        ans -= (sz[u]*(sz[v]));
        sz[u] += sz[v];
    }
}
int main()
{
    ll n,m;
    cin>>n>>m;
    vector<pair<int,int> > arr;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        arr.push_back(make_pair(x,y));
    }
    for(int i=1;i<=n;i++)
    {
        par[i]=i;
        sz[i]=1LL;
    }
    ll res[m+1];
    ans=(n*(n-1LL))/2LL;
    for(int i=m-1;i>=0;i--)
    {
        res[i+1]=ans;
        int x=arr[i].first;
        int y=arr[i].second;
        unionn(x,y);
    }
    for(int i=1;i<=m;i++)
    {
        cout<<res[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 4596
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

import org.omg.Messaging.SyncScopeHelper;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new Test_100().doIt();
	}
	class Test_100{
		void doIt() {
			int N = sc.nextInt();
			int A = sc.nextInt();
			int B = sc.nextInt();
			int PlanA = N * A;
			int PlanB = B;
			if(PlanA < PlanB)System.out.println(PlanA);
			else System.out.println(PlanB);
		}
	}
}


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

dp=[]
dp.append(0)
dp.append(abs(h[0]-h[1]))

for i in range (2,N):
    dp.append(min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1])))

print(dp[N-1])


Measured memory_bytes: 54760
import sys

n = int(input())
r0 = int(input())
r1 = int(input())
p = r1 - r0
r = min(r0,r1)
for i in map(int, sys.stdin.readlines()):
    if p < i - r:
        p = i - r
    if r > i:
        r = i

print(p)

Measured memory_bytes: 21716
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <time.h>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int x,a,b,c;
	cin>>a>>b>>c>>x;
	int tot=0;
	for(int i=0;i<=a;i++)
	{
		for(int j=0;j<=b;j++)
		
		{
			for(int k=0;k<=c;k++)
			{
				if(500*i+100*j+50*k==x)
				{
					tot++;
				}
			}
		}
	}
	cout<<tot;
	return 0;
}


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

using namespace std;

typedef long long LL;
const LL inf=0x3f3f3f3f3f3f3f3fLL;
const int MX=200011;
struct It{
	int x[2];
	It(int _x0=0,int _x1=0){x[0]=_x0,x[1]=_x1;}
}s[MX];
inline bool operator<(const It &a,const It &b){return a.x[0]<b.x[0];}
int n;
LL solvesame(int mxit){
	int d=s[mxit].x[1]-s[1].x[0];
	LL ans=inf;
	int mx=max(s[mxit].x[0],s[1].x[1]),mn=min(s[mxit].x[0],s[1].x[1]);
	mx=max(mx,s[n].x[0]);
	for(int i=2;i<=n;i++)if(i!=mxit){
		ans=min(ans,(LL)d*(mx-min(mn,s[i].x[0])));
		mx=max(mx,s[i].x[1]),mn=min(mn,s[i].x[1]);
	}
	ans=min(ans,(LL)d*(mx-mn));
	return ans;
}
LL solvediff(int mxit){
	int mn=s[mxit].x[1],mx=s[1].x[0];
	if(mxit!=1){
		mn=s[1].x[1],mx=s[mxit].x[0];
	}
	for(int i=2;i<=n;i++)if(i!=mxit)mn=min(mn,s[i].x[1]),mx=max(mx,s[i].x[0]);
	return (LL)(s[mxit].x[1]-mn)*(mx-s[1].x[0]);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&s[i].x[0],&s[i].x[1]);
		if(s[i].x[0]>s[i].x[1])swap(s[i].x[0],s[i].x[1]);
	}
	sort(s+1,s+n+1);
	int mxit=0,mxx=0;
	for(int i=1;i<=n;i++)if(s[i].x[1]>mxx)mxx=s[i].x[1],mxit=i;
	LL ans=inf;
	if(mxit>1)ans=min(ans,solvesame(mxit));
	ans=min(ans,solvediff(mxit));
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>

int main()
{
 long long x;
  
  scanf("%lld",&x);
  
  long long ans=0;
  
  long long y=100;
  
  while(1)
  {
    if(x<=y)
    {
      break;
    }
    y+=y/100;
    ans++;
  }
  

  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>

int main(){
    char S[3];
    scanf("%s",S);

    int i,j=0;

    for(i=0;i<3;i++){
        if(S[i]=='A')j++;
    }

    if(j==3||j==0){printf("No");}
    else{printf("Yes");}

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fast ios::base_sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define M 1000000007
#define pie 3.141592653589793238
using namespace std;
 


signed main(){
    int n,k;cin>>n>>k;
    int r,s,p;cin>>r>>s>>p;
    string t;cin>>t;
    int ans = 0;
    for(int i=0;i<k;i++){
        if(t[i] == 'r'){
            t[i] = 'p';
            ans += p;
        }
        else if(t[i] == 's'){
            t[i] = 'r';
            ans += r;
        }
        else if(t[i] == 'p'){
            t[i] = 's';
            ans += s;
        }
    }
    for(int i = k;i<n;i++){
        if(t[i] == 'r'){
            if(t[i-k] == 'p'){
                t[i] = '@';
            }
            else{ 
                t[i] = 'p';
                ans += p;
            }
        }
        else if(t[i] == 's'){
            if(t[i-k] == 'r'){
                t[i] = '@';
            }
            else{
                t[i] = 'r';
                ans += r;
            }
        }
        else if(t[i] == 'p'){
            if(t[i-k] == 's'){
                t[i] = '@';
            }
            else{
                t[i] = 's';
                ans += s;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rei register int
#define int long long
using namespace std;
int n;
int a[200010];
signed main(){
	cin >> n;
	for(rei i = 1;i <= n;++i) scanf("%lld",&a[i]);
	int ans(0),maxx(0);
	for(rei i = 1;i <= n;++i){
		if(maxx > a[i]) ans += maxx - a[i];
		maxx = max(maxx,a[i]);
	} cout << ans ; return 0;
}

Measured memory_bytes: 5208
#include <stdio.h>

int ball[3] = {1,0,0};

void change(char x, char y);

int main(void)
{
    char x,y;

    while(scanf("%c,%c", &x, &y) != EOF){
        change(x, y);
    }
    if (ball[0] == 1){
        printf("A\n");
    }else if (ball[1] == 1){
        printf("B\n");
    }else{
        printf("C\n");
    }
    return (0);
}
void change(char x, char y)
{
    int temp;

    if ((x == 'A' && y == 'B') || (x == 'B' && y == 'A')){
        if (ball[0] == 1){
            ball[0] = 0;
            ball[1] = 1;
        }else if (ball[1] == 1){
            ball[0] = 1;
            ball[1] = 0;
        }
    }else if ((x == 'A' && y == 'C') || (x == 'C' && y == 'A')){
        if (ball[0] == 1){
            ball[0] = 0;
            ball[2] = 1;
        }else if (ball[2] == 1){
            ball[0] = 1;
            ball[2] = 0;
        }
    }else if ((x == 'B' && y == 'C') || (x == 'C' && y == 'B')){
        if (ball[1] == 1){
            ball[1] = 0;
            ball[2] = 1;
        }else if (ball[2] == 1){
            ball[1] = 1;
            ball[2] = 0;
        }
    }
}


Measured memory_bytes: 2048
#include <bits/stdc++.h> 
using namespace std; 
  
// function to determine the edge colors 
void colorEdges(int ptr, vector<vector<pair<int, int> > >& gra, 
                vector<int>& edgeColors, bool isVisited[]) 
{ 
    queue<int> q; 
    int c = 0; 
  
    set<int> colored; 
  
    // return if isVisited[ptr] is true 
    if (isVisited[ptr]) 
        return; 
  
    // Mark the current node visited 
    isVisited[ptr] = 1; 
  
    // Traverse all edges of current vertex 
    for (int i = 0; i < gra[ptr].size(); i++) { 
        // if already colored, insert it into the set 
        if (edgeColors[gra[ptr][i].second] != -1) 
            colored.insert(edgeColors[gra[ptr][i].second]); 
    } 
  
    for (int i = 0; i < gra[ptr].size(); i++) { 
        // if not visited, inset into the queue 
        if (!isVisited[gra[ptr][i].first]) 
            q.push(gra[ptr][i].first); 
  
        if (edgeColors[gra[ptr][i].second] == -1) { 
            // if col vector -> negative 
            while (colored.find(c) != colored.end()) 
  
                // increment the color 
                c++; 
  
            // copy it in the vector 
            edgeColors[gra[ptr][i].second] = c; 
  
            // then add it to the set 
            colored.insert(c); 
            c++; 
        } 
    } 
  
    // while queue's not empty 
    while (!q.empty()) { 
        int temp = q.front(); 
        q.pop(); 
  
        colorEdges(temp, gra, edgeColors, isVisited); 
    } 
  
    return; 
} 
  
// Driver Function 
int main() 
{ 
    set<int> empty; 
  
    // declaring vector of vector of pairs, to define Graph 
    vector<vector<pair<int, int> > > gra; 
  
    vector<int> edgeColors; 
  
    bool isVisited[100000 + 5] = { 0 }; 
  
    // Enter the Number of Vertices 
    // and the number of edges 
    int ver; cin >> ver;
    gra.resize(ver); 
    for(int i = 1; i < ver; i++) {
      int u, v; cin >> u >> v;
      u--, v--;
      gra[u].push_back({v, i - 1});
      gra[v].push_back({u, i - 1});
    }
    int edges = ver - 1;
    edgeColors.resize(edges, -1); 
  
  
    colorEdges(0, gra, edgeColors, isVisited); 
  
    // printing all the edge colors 
    set <int> c;
    for (int i = 0; i < edges; i++) {
      c.insert(edgeColors[i]);
    }
    cout << c.size() << '\n';
    for(int i = 0; i < edges; i++) cout << edgeColors[i] + 1 << '\n';
  
    return 0; 
} 

Measured memory_bytes: 60416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005;
const double eps=1e-9;
int read(){
	int f=1,g=0;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n;
ll m,a[N],ans;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();m=read();
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=1;i<=n;i++)a[i]+=a[i-1];
	ans=1000000000000000000;
	for (int i=1;i<=n;i++){
		ll t=n*m+i*m+a[n]*5;bool fl=0;
		for (int j=n-i*2;j>0;j-=i){
			t+=a[j]*2;
			if (t<0) fl=1;
		}
		if (!fl) ans=min(ans,t);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
import sys
input = lambda: sys.stdin.readline().rstrip()

N, M = map(int,input().split())

ans = []

flg = 0
for i in range(N):
    if flg == 0:
        K = list(map(int, input().split()))
        K = K[1:]
        ans += K
        flg = 1
    else:
        K = list(map(int, input().split()))
        K = K[1:]
        
        ans = set(ans)&set(K)

print(len(ans))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//Get the highest value and key from a map.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  double n;
  int k;
  cin >> n >> k;
  ll total = 0;
  vector<double> p(n);
  for (int i = 1; i <= n; i++) {
    int c_t = 0;
    int v = i;
    while (v <= k - 1) {
      v *= 2;
      ++c_t;
    }
    p[i - 1] = (1 / n * pow(0.5, c_t));
  }

  double ans = 0;
  for (double d : p) {
    ans += d;
  }

  cout << fixed << setprecision(15) <<  ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define print(x) cout << #x << " = " << x << endl;

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;


int main() {
  int A, B;
  cin >> A >> B;

  int ans = 0;
  for (int i = A; i <= B; ++i) {
    string str = to_string(i);
    bool bCheck = true;
    for (int j = 0; j < str.size() / 2; j++) {
      if (str[j] != str[str.size() - j - 1]) {
        bCheck = false;
        break;
      }
    }
    if (bCheck) ans++;
  }

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

Measured memory_bytes: 3704
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            String s = in.next();
            String t = in.next();
            out.println(s.equals(t.substring(0, s.length())) ? "Yes" : "No");
        }

    }
}



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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n; cin>>n;
  string s; cin>>s;
  int q;cin>>q;

  map<int, set<int>> m;
  rep(i, n)m[s[i]-'a'].insert(i);

  rep(i, q){
    int t;cin>>t;
    if(t==1){
      int idx; char c; cin>>idx>>c; idx--;
      int ci = c - 'a';
      int pci = s[idx]-'a';
      s[idx]=c;
      m[pci].erase(idx);
      m[ci].insert(idx);

    }else{
      int l,r; cin>>l>>r; l--;r--;
      int cc=0;
      rep(j, 26){
        auto it = m[j].lower_bound(l);
        if(it!=m[j].end() && *it<=r)cc++;
      }
      cout<<cc<<endl;
    }
  }

  return 0;
}


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

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

void dfs(int val,int n, int m, int q, vector<int> A) {
    if (val != 0) A.push_back(val);
    if (A.size() == n) {
        int tmpAns = 0;
        for (int i = 0; i < q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                tmpAns += d[i];
            }
        }
        ans = max(ans, tmpAns);
        return;
    }
    int start = max(1, val);
    for (int i = start; i <= m; i++) {
        dfs(i, n, m, q, A);
        //A.pop_back();
    }
    return;
}

int main() {

    int n, m, q; cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    vector<int> A;
    dfs(0, n, m, q, A);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  for(int i = 0; i < K; i++){
    if(A == max(max(A, B), C)){
      A = 2 * A;
    }
    else if(B == max(max(A, B), C)){
      B = 2 * B;
    }
    else{
      C = 2 * C;
    }
  }
  cout <<  A + B + C << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <vector>
#include <numeric>
#include <algorithm>
#define lli long long int
using namespace std;


int main(){
    int n, m, l;
    cin >> n >> m >> l;
    
    vector<vector<lli>> A(n, vector<lli>(m)), B(m, vector<lli>(l)), C(n, vector<lli>(l));
    
    for(auto &vec : A){
        for(auto &val : vec){
            cin >> val;
        }
    }
    
    for(auto &vec : B){
        for(auto &val : vec){
            cin >> val;
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            for(int k = 0; k < m; k++){
                C[i][j] += A[i][k] * B[k][j];
            }
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            cout << C[i][j];
            if(j != l-1) cout << " ";
            else cout << endl;
        }
    }
    
    return 0;
}

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

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

    vector<int> a(n);
    for(int i = 0 ; i < n ; ++i){
        cin >> a[i];
        for(int j = 0 ; j < i ; ++j){
            if(abs(a[i] - a[j]) % (n - 1) == 0){
                cout << a[i] << " " << a[j] << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>

int main()
{
    int N,i,x,y,count=0,check=0;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d %d",&x,&y);
        if(x==y)
        {
            count++;
            if(count==3)
            {
                check=1;
            }
        }
        else
        {
            count=0;
        }
    }
    if(check==1)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s;
    cin>>s;
    if(s.substr(2,1)==s.substr(3,1)&&s.substr(4,1)==s.substr(5,1)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
ll mod=1000000007;
typedef pair<int, int> P;

int main()
{
    int N;
    cin >> N;
    vector<ll> a(3*N);
    priority_queue<ll, vector<ll>, greater<ll> > pque1;//
    priority_queue<ll> pque2;//
    ll ans1=0, ans2=0;
    for(int i=0; i<N; i++){
        cin >> a[i];
        pque1.push(a[i]);
        ans1+=a[i];
    }
    for(int i=N; i<2*N; i++){
        cin >> a[i];
    }
    for(int i=2*N; i<3*N; i++){
        cin >> a[i];
        pque2.push(a[i]);
        ans2+=a[i];
    }

    vector<ll> nums(N+1);
    nums[0]=ans1;
    for(int i=N; i<2*N; i++){
        pque1.push(a[i]); ll tmp=pque1.top(); pque1.pop();
        nums[i-N+1]=nums[i-N]-tmp+a[i];
    }
    ll ans=nums[N]-ans2;
    //for(int i=0; i<=N; i++) cout << nums[i] << ',';
    for(int i=2*N-1; i>=N; i--){
        pque2.push(a[i]); ll tmp=pque2.top(); pque2.pop();
        ans2=ans2+a[i]-tmp;
        ans=max(ans, nums[i-N]-ans2);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5108
n, m = map(int, input().split())
stu = []
chp = []
for _ in range(n):
    a, b = map(int, input().split())
    stu.append([a, b])
for _ in range(m):
    c, d = map(int, input().split())
    chp.append([c, d])

ans = [] 
for i in range(n):
    mn = 10**9
    idx = 0
    for j in range(m):
        p = abs(stu[i][0] - chp[j][0]) + abs(stu[i][1] - chp[j][1])
        if p < mn:
            mn = p
            idx = j + 1
    print(idx)

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

int max(int a, int b) {

	if (a >= b)return a;
	else return b;

}
int min(int a, int b) {

	if (a <= b)return a;
	else return b;

}
int main() {

	string str;
	int str_half_long = 0;
	int tmp_long = 0;
	int ans_long = 0;
	cin >> str;
	str_half_long = str.size()/2;
	
	//cout << str_half_long << endl;

	for (int i = str_half_long - 1; i > 0; i--) {

		//cout << str.substr(0, i) << " , " << str.substr(i, i) << endl;

		if (str.substr(0, i) == str.substr(i, i)) {

			ans_long = i * 2;
			break;

		}

	}

	cout << ans_long << endl;

	//cout << str_half_long << " " << str << endl;
	//cout << str.substr(0, str_half_long) << " " << str.substr(str_half_long, str_half_long) << endl;

	return 0;
}

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

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int d[10];


int main() {
    for (int i = 1; i < 4; ++i) {
        int u = read(), v = read();
        d[u]++, d[v]++;
        if (d[u] > 2 || d[v] > 2) {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
S = input()[:-1]

if S[0]=='W':
    print(0)
    exit()
    
l = [0]
ans = 1
MOD = 10**9+7

for i in range(1, 2*N):
    if S[i]==S[i-1]:
        l.append(1^l[-1])
    else:
        l.append(l[-1])

if l.count(0)!=N:
    print(0)
    exit()
    
zero = 0

for li in l:
    if li==0:
        zero += 1
    else:
        ans *= zero
        ans %= MOD
        zero -= 1
        
for i in range(1, N+1):
    ans *= i
    ans %= MOD

print(ans)

Measured memory_bytes: 53728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;

        public void Run()
        {
            N = Input.ReadInt();
            if (N == 1)
            {
                Console.WriteLine("Hello World");
            }
            else
            {
                int a = Input.ReadInt();
                int b = Input.ReadInt();
                Console.WriteLine(a+b);
            }

        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

cnt=[0]*(n+1)
s=0

for x in a:
    cnt[x]+=1

for i in range(1,n+1):
    if cnt[i]>=2:
        s+=cnt[i]*(cnt[i]-1)//2

for k in range(1,n+1):
    if cnt[a[k-1]]>=2:
        print(s-cnt[a[k-1]]+1)
    else:
        print(s)


Measured memory_bytes: 83532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}


pair<int, int> E[200001];
int H[200001];
int kotae[100001];
int Vis[100001];
void sagasu(int P, int D, int C) {
	if (D == 0 && kotae[P] == 0) kotae[P] = C;
	else if (Vis[P] < D) {
		Vis[P] = D;
		if (kotae[P] == 0) kotae[P] = C;
		for (int p = H[P]; p; p = E[p].second) {
			sagasu(E[p].first, D - 1, C);
		}
	}
}

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


	int N, M, Q;
	N = getint();
	M = getint();
	for (int i = 1; i < 2 * M; i += 2) {
		int a = getint(), b = getint();
		E[i] = mp(a, H[b]);
		H[b] = i;
		E[i + 1] = mp(b, H[a]);
		H[a] = i + 1;
	}
	Q = getint();
	int v[100000], d[100000], c[100000];
	rep(i, Q) {
		v[i] = getint();
		d[i] = getint();
		c[i] = getint();
	}
	for (int i = Q - 1; i >= 0; i--) {
		sagasu(v[i], d[i], c[i]);
	}
	rep1(i, N) {
		putint(kotae[i]);
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}


Measured memory_bytes: 5632
import sys
H,W,M=map(int, input().split())
h=[]
w=[]
Hcount=[0 for _ in range(H)]
Wcount=[0 for _ in range(W)]
B=set()

for i in range(M):
    hi,wi=map(int, input().split())
    #h.append(hi)
    #w.append(wi)
    B.add((hi,wi))
    Hcount[hi-1]+=1
    Wcount[wi-1]+=1
Hcountmax=max(Hcount)
Wcountmax=max(Wcount)
h_max=[i for i, v in enumerate(Hcount) if v == Hcountmax]
w_max=[i for i, v in enumerate(Wcount) if v == Wcountmax]
#print(h_max,w_max)
for ii in range(len(h_max)):
    for jj in range(len(w_max)):
        if (h_max[ii]+1,w_max[jj]+1) not in B:
            print(max(Hcount)+max(Wcount))
            sys.exit()
print(max(Hcount)+max(Wcount)-1)

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

string Solve(const string& s) {
  int n = s.size();
  if ((s[0] == s[n - 1]) == (n % 2 == 1))
    return "Second";
  return "First";
}

int main() {
  string s;
  cin >> s;
  cout << Solve(s) << "\n";
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#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--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int intceil(int a, int b) {
    return (a + (b - 1)) / b;
}

signed main() {
    cin >> A >> B;
    cout << intceil(B - 1, A - 1) << endl;
}

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

void InputNumbers(int& Count,std::vector<int>& Numbers);
void OutputNumbers(const std::vector<int>& Numbers);
void InsertionSort(std::vector<int>& Numbers,const int Interval,int& InsertCount);
int ShellSort(std::vector<int>& Numbers, const std::vector<int>& Intervals);
void CreateIntervals(std::vector<int>& Intervals,const int Count);

int main()
{
	int Count = 0;
	std::vector<int> Numbers;
	InputNumbers(Count,Numbers);
	
	std::vector<int> Intervals;
	CreateIntervals(Intervals,Count);
	
	std::cout << Intervals.size() << std::endl;
	OutputNumbers(Intervals);
	
	int InsertCount = ShellSort(Numbers,Intervals);
	
	std::cout << InsertCount << std::endl;
	
	for(unsigned int i=0;i<Numbers.size();i++)
	{
		std::cout << Numbers[i] << std::endl;
	}
	
	return 0;
}

void InputNumbers(int& Count,std::vector<int>& Numbers)
{
	std::cin >> Count;
	for(int i=0;i<Count;i++)
	{
		int Input = 0;
		std::cin >> Input;
		Numbers.push_back(Input);
	}
}

void OutputNumbers(const std::vector<int>& Numbers)
{
	for(unsigned int i=0;i<Numbers.size();i++)
	{
		std::cout << Numbers[i] << std::flush;
		if(i != Numbers.size() - 1)
		{
			std::cout << " " << std::flush;
		}else{
			std::cout << std::endl;
		}
	}
}


void InsertionSort(std::vector<int>& Numbers,const int Interval,int& InsertCount)
{
	for(unsigned int i = Interval;i<Numbers.size();i++)
	{
		int v = Numbers[i];
		int j = i - Interval;
		while(j >= 0 && Numbers[j] > v)
		{
			Numbers[j+Interval] = Numbers[j];
			j -= Interval;
			InsertCount++;
		}
		Numbers[j+Interval] = v;
	}
}

int ShellSort(std::vector<int>& Numbers, const std::vector<int>& Intervals)
{
	int InsertCount = 0;
	for(unsigned int i = 0;i<Intervals.size();i++)
	{
		InsertionSort(Numbers,Intervals[i],InsertCount);
	}
	return InsertCount;
}

void CreateIntervals(std::vector<int>& Intervals,const int Count)
{
	int h = 1;
	while(h<Count || h==1)
	{
		Intervals.push_back(h);
		h = 3*h + 1;
	}
	std::reverse(Intervals.begin(),Intervals.end());
}

Measured memory_bytes: 6992
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#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;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n; 

int fac(int x, int p){
  int res = 0;
  int c = p;
  while( p<=x  ){
    res+= x/p;
    p*=c;
  }
  return res;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  cin >> n;
  if(n%2){
  int two = fac(n, 2) -  fac( n/2 , 2 ) - (n/2);
  int five = fac(n, 5) - fac(n/2, 5) ;
  //cout << fac(n,5) << " " << two << " " << five << endl;
  cout << min(two,five) << endl;       
  }
  else {
    int ans = fac(n/2, 5);
    cout << ans << endl;
  }

return 0;
}
///....


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

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

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

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

  cout << cnt << endl;
  
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void chmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void chmin(T& a, U b) { if (a>b) a = b; }

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

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

  sort(a.begin(), a.end());
  int ans = 0;
  int cnt = 0;
  while (cnt < n) {
    int start = cnt;
    while (cnt < n && a[cnt] == a[cnt+1]) cnt++;
    if ((cnt-start+1) % 2 == 1) ans++;
    cnt++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
long n,a,b,c,dp[200000][5];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a>>b>>c;
		if(i==1){
			dp[i][1]=a;
			dp[i][2]=b;
			dp[i][3]=c;
		}else{
			dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a;
			dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b;
			dp[i][3]=max(dp[i-1][2],dp[i-1][1])+c;
		}
	}
	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
}

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

struct rock
{
  int x, d;
};

const int INF = 2e9;
int n, m;
int dp[150][10][76];
vector<rock> rocks[150];
int main()
{
  while(cin >> n >> m && (n || m)){

    //chap1
    for(int i = 0; i < n; i++){
      rocks[i].clear();
      for(int j = 0; j < 10; j++)
	for(int k = 0; k <= m; k++)
	  dp[i][j][k] = INF;
    }

    for(int i = 0; i < 10; i++)
      dp[0][i][0] = dp[1][i][1] = 0;
    
    //chap2
    for(int i = 0; i < n; i++){
      int kk;
      cin >> kk;
      for(int j = 0; j < kk; j++){
	rock in;
	cin >> in.x >> in.d;
	rocks[i].push_back(in);
      }
    }

    //chap3
    for(int i = 0; i < n - 1; i++){
      for(int j = 0; j < rocks[i].size(); j++){
	for(int k = 0; k < rocks[i + 1].size(); k++){
	  for(int l = 0; l <= m; l++){
	    dp[i + 1][k][l] = min(dp[i + 1][k][l], dp[i][j][l] + (rocks[i][j].d + rocks[i + 1][k].d) * (int)abs(rocks[i][j].x - rocks[i + 1][k].x));
	  }
	}

	if(i < n - 2){
	  for(int k = 0; k < rocks[i + 2].size(); k++){
	    for(int l = 0; l < m; l++){
	      dp[i + 2][k][l + 1] = min(dp[i + 2][k][l + 1], dp[i][j][l] + (rocks[i][j].d + rocks[i + 2][k].d) * (int)abs(rocks[i][j].x - rocks[i + 2][k].x));
	    }
	  }
	}
      }
    }

    //chap4
    int ans = INF;
    
    for(int i = 0; i < rocks[n - 1].size(); i++)
      for(int j = 0; j <= m; j++)
	ans = min(ans, dp[n - 1][i][j]);

    for(int i = 0; i < rocks[n - 2].size(); i++)
      for(int j = 0; j < m; j++)
	ans = min(ans, dp[n - 2][i][j]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1692
def get(text,n):
    ans = [""]*n
    i = 0
    for x in text:
        if x==" ":
            i = i + 1
        else:
            ans[i] = ans[i]+x
    return ans

N = int(input())
text = input()
P = get(text,N)
for i in range(N):
    P[i]= int(P[i])

def solve(P,N):
    ans = 1
    m = P[0]
    for i in range(1,N):
        if P[i] <= m:
            ans = ans + 1
            m = P[i]
    return ans

print(solve(P,N))

Measured memory_bytes: 18196
from collections import Counter
N = int(input())
A = Counter(list(map(int,input().split(' '))))
ans = 0
m = max(A.keys())
L = [1]*(10**6+1)
for i in sorted(A.keys()):
    if not L[i]:
        continue
    if A[i] == 1:
        ans += 1
    for j in range(i,m+1,i):
        L[j] = 0
print(ans)

Measured memory_bytes: 38692
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt(); int b=sc.nextInt();int[] array = new int[3];
        array[0]=a+b;array[1]=a-b;array[2]=a*b;
        Arrays.sort(array);
        System.out.println(array[2]);
    };
}

Measured memory_bytes: 22740
#include <stdio.h>
int n;
int a[100005];

int max(int x, int y) {
	return (x >= y) ? x : y;
}

int main(void) {
	//freopen("in.txt", "r", stdin);
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i]);
	}
	int ans = 0, tmp = 0;
	int pos = 1;
	while(pos < n) {
		if(a[pos] <= a[pos-1]) {
			tmp ++;
		}else {
			ans = max(ans, tmp);
			tmp = 0;
		}
		pos ++;
	}
	ans = max(ans, tmp);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{	
	int i,a,b,c,count=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<b+1;i++){
		if(c%i==0){
			count ++;
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main()
{
	c_p_c();
	int t, p, sum = 0; // int a[3];
	cin >> t >> p;
	int a[p];
	for (int i = 0; i < p; i++)
	{cin >> a[i]; sum += a[i];}

	if (t - sum > 0)
	{cout << t - sum;}
	else if (t - sum == 0)
	{cout << "0"; }
	else {cout << "-1";}

	return 0;



}

Measured memory_bytes: 3680
x, y, a, b, c = map(int, input().split())
pa = sorted(list(map(int, input().split())), reverse=True) # 赤
qb = sorted(list(map(int, input().split())), reverse=True) # 緑
rc = list(map(int, input().split())) # 透明

ans = []
ans += pa[:x]
ans += qb[:y]
ans += rc

print(sum(sorted(ans, reverse=True)[:x+y]))


Measured memory_bytes: 23968
import math

a,b,c,d=map(int,input().split())

x=(a-1)//c

y=b//c
z=(a-1)//d
w=b//d

e=(c * d) // math.gcd(c, d)

p=(a-1)//e

q=b//e

print(b-a+1-y+x-w+z+q-p)


Measured memory_bytes: 62096
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
	int n, m;
	while(cin >> n >> m, n || m) {
		double gr[128][128] = {0};
		double dptab[128][128] = {0};
		for(int i = 0; i < 128; i++) {
			dptab[0][i] = 1.0;
		}
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				cin >> gr[i][j];
			}
		}

		for(int i = 1; i < m; i++) {
			for(int j = 0; j < n; j++) {
				for(int k = 0; k < n; k++) {
					dptab[i][j] = max(dptab[i][j], dptab[i - 1][k] * gr[k][j]);
				}
			}
		}

		double ans = -1;
		for(int i = 0; i < n; i++) {
			ans = max(dptab[m-1][i], ans);
		}

		printf("%.2f\n", ans);
	}
}

Measured memory_bytes: 1504
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
H = np.array(lr())
X = np.minimum.accumulate(H[::-1])[::-1]
Y = H - X
answer = np.any(Y>=2)
print('No' if answer else 'Yes')


Measured memory_bytes: 23228
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String c1 = sc.next();
        String c2 = sc.next();
        String c3 = sc.next();
        
        String[] C = {c1, c2, c3};
        for (int i = 0; i < C.length ;i++) {
            System.out.print(C[i].subSequence(i, i+1));
        }
        System.out.println();
        
    }
    
}

Measured memory_bytes: 35528
import collections
N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for _ in range(M)]
ans = [None] * (N + 1)
G = collections.defaultdict(set)
for a, b in AB:
    G[a].add(b)
    G[b].add(a)
Q = collections.deque([1])
while Q:
    i = Q.popleft()
    for j in G[i]:
        if ans[j] is None:
            Q += [j]
            ans[j] = i
print('Yes')
print('\n'.join(map(str, ans[2:])))


Measured memory_bytes: 94432
surplus :: (Int, Int) -> Int
surplus (value, cost)
    | value > cost = value - cost
    | value <= cost = 0


main = do
  args0 <- getLine
  args1 <- getLine
  args2 <- getLine
  let values = map read $ words args1 :: [Int]
  let costs = map read $ words args2 :: [Int]
  let result = sum $ map surplus $ zip values costs
  putStr $ show result

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

int main() {
  int h, w;
  cin >> h >> w;
  
  string board[60];
  for (int i = 0; i < h; i++) cin >> board[i];
  
  int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (board[i][j] == '.') {
        int cnt = 0;
        for (int k = 0; k < 8; k++) {
          int x = i + dx[k];
          int y = j + dy[k];
          if (x >= 0 && x < h && y >= 0 && y < w) {
            if (board[x][y] == '#') 
              cnt++;
          }    
        }
        board[i][j] = '0' + cnt;
      } 
    }  
  }  
  
  for (int i = 0; i < h; i++) cout << board[i] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	cout << (a - 1) / (b*2+1) +1;
}


Measured memory_bytes: 256