akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  double r;
  cin >> r;
  printf("%.6f %.6f\n", M_PI * r * r, M_PI * 2 * r);
  return 0;
}


Measured memory_bytes: 3292
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef float fl;
#define input ll t;cin>>t;while(t--)
#define fast() ios_base::sync_with_stdio(false),cin.tie(NULL);
#define mod 1000000007
#define pb push_back

ll n;

void dijkstra(vector<pair<ll,ll>> adj[],ll source,ll len[]) {
    ll dist[n+1];
    ll i,x,wei,e,w;
    bool vis[n+1]={false};
    for(i=0;i<=n;++i) dist[i]=INT_MAX;
    dist[source]=0;
    multiset<pair<ll,ll>> s;
    s.insert({0,source});
    pair<ll,ll> p;
    while(!s.empty()) {
        p=*s.begin();
        s.erase(s.begin());
        x=p.second;
        wei=p.first;
        if(vis[x]) continue;
        vis[x]=true;
        for(i=0;i<adj[x].size();++i) {
            e=adj[x][i].second;
            w=adj[x][i].first;
            if(dist[x]+w<dist[e]) {
                dist[e]=dist[x]+w;
                s.insert({dist[e],e});
            }
        }
    }
    //cout<<"This is from dijkstra -> ";
    //for(i=1;i<=n;++i) cout<<dist[i]<<" ";
    //cout<<endl;
    for(i=1;i<=n;++i) {
        len[dist[i]]++;
    }
    //cout<<"This is len vector -> ";
    //for(i=1;i<=n;++i) cout<<len[i]<<" ";
    //cout<<endl;
}

int main(void) {
    fast();
    /*ll n,k,i,x;
    cin>>k>>n;
    vector<ll> v;
    for(i=0;i<n;++i) {
        cin>>x;
        v.pb(x);
    }*/
    ll x,i,j,k,y;
    cin>>n>>x>>y;
    vector<pair<ll,ll>> adj[n+1];
    for(i=1;i<n;++i) {
        adj[i].pb(make_pair(1,i+1));
        adj[i+1].pb(make_pair(1,i));
    }
    adj[x].pb(make_pair(1,y));
    adj[y].pb(make_pair(1,x));
    ll len[n+1];
    for(i=0;i<=n;++i) len[i]=0;
    for(i=1;i<=n;++i) {
        dijkstra(adj,i,len);
    }
    for(i=1;i<n;++i) {
        cout<<len[i]/2<<endl;
    }
    /*ll dist[n+1][n+1];
    ll graph[n+1][n+1];
    for(i=0;i<=n;++i) {
        for(j=0;j<=n;++j) {
            if(i==j) graph[i][j]=0;
            else if(i+1==j||i==j+1) graph[i][j]=1;
            else if((i==x&&j==y)||(i==y&&j==x)) graph[i][j]=1;
            else graph[i][j]=INT_MAX;
        }
    }
    for(i=0;i<=n;++i) {
        for(j=0;j<=n;++j)
            dist[i][j]=graph[i][j];
    }
    for (k = 1; k <=n; k++)
    {
        for (i = 1; i <=n; i++)
        {
            for (j = 1; j <=n; j++)
            {
                if (dist[i][k] + dist[k][j] < dist[i][j])
                    dist[i][j] = dist[i][k] + dist[k][j];
            }
        }
    }
    vector<ll> len;
    for(i=0;i<=n;++i) len.pb(0);
    for(i=1;i<=n;++i) {
        for(j=1;j<=n;++j) {
            len[dist[i][j]]++;
        }
    }
    for(i=1;i<n;++i) {
        cout<<len[i]/2<<endl;
    }*/
    return 0;
}


Measured memory_bytes: 384
def minCost(i):
  cost1 = cost[i-1] + abs(h[i] - h[i-1])
  cost2 = cost[i-2] + abs(h[i] - h[i-2])
  return min(cost1, cost2)              

n = int(input())
h = [int(i) for i in input().split()]

cost = [0] * n
#cost[0] = 0
cost[1] = abs(h[1] - h[0])

for i in range(2, n):
  cost[i] = minCost(i)

#print(cost)  
print(cost[-1])

Measured memory_bytes: 13800
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_N = 2010;
int N, M;
vector<int> S;
vector<int> T;
int dp[MAX_N][MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    S.resize(N);
    T.resize(M);
    for (auto &val : S)
    {
        cin >> val;
    }
    for (auto &val : T)
    {
        cin >> val;
    }
    dp[0][0] = 1;
    for (int i = 0; i <= S.size(); i++)
    {
        dp[i][0] = 1;
    }
    for (int i = 0; i <= T.size(); i++)
    {
        dp[0][i] = 1;
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            if (S[i] == T[j])
            {
                dp[i + 1][j + 1] += dp[i][j];
            }
            dp[i + 1][j + 1] += dp[i][j + 1];
            dp[i + 1][j + 1] %= MOD;
            dp[i + 1][j + 1] += dp[i + 1][j];
            dp[i + 1][j + 1] %= MOD;
            dp[i + 1][j + 1] += MOD - dp[i][j];
            dp[i + 1][j + 1] %= MOD;
        }
    }
    cout << dp[N][M] << endl;
    return 0;
}


Measured memory_bytes: 16000
//gcc -std=gnu11 -O2 -o a.out Main.c -lm
//http://abc049.contest.atcoder.jp/tasks/abc049_b
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdint.h>
#include <math.h>
#include <string.h>

int main(void)
{
#define N_MAX 100  //

	int i,j;
	int H,W;
	int ret;
	char str[200][101];

	//-------------------------------------
	//Input process
	//-------------------------------------
	memset(&str[0][0], 0x00, sizeof(str));
	ret = scanf("%d%d", &H, &W);
	for(i=0;i<H;i++){
		ret = scanf("%s", str[(i*2)+0]);
		memcpy(&str[(i*2)+1][0], &str[(i*2)+0][0], 101);
	}

	//-------------------------------------
	//Calc process
	//-------------------------------------


	//-------------------------------------
	//Output process
	//-------------------------------------
//	printf("--\n");
	for(i=0;i<(H*2);i++){
		printf("%s\n", str[i]);
	}
	return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,sum=0,i,j,min,max,mid;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    
    sort(a,a+n);
    for(i=0;i<n;i++){
       for(j=i+1;j<n;j++){
           min=j;
           max=n;
           while(max-min>1){
               mid=(min+max)/2;
               if((a[i]+a[j])>a[mid]){
                   min=mid;
                   
               }
               else {
                   max=mid;
               }
           }
           sum=sum+min-j;
       }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
//**KEEP IT SHORT AND SIMPLE**
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a)* (b)).imag()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
typedef tuple<ll, ll, ll> line;
typedef complex<double> point;
const double pi = 2 * acos(0.0);
const int OO = 0x3f3f3f3f;
int main()
{
    IO
    ll n, t = 0;
    cin >> n;
    vector<pll>v(n);
    REP(i, 0, n)
        cin >> v[i].S >> v[i].F;
    sort(v.begin(), v.end());
    REP(i, 0, n)
    {
        t += v[i].S;
        if(t > v[i].F)
            return cout << "No", 0;
    }
    cout << "Yes";
    return 0;
}



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

vector<pair<int,int> > e[100001];
int vis[100001];
vector<int> w;
bool dfs(int x){
	bool res=false;
	w.emplace_back(x);
	for(auto it:e[x]){
		if(vis[it.first]!=-1){
			int y;
			if(it.second)
				y=(vis[x]+2)%3;
			else
				y=(vis[x]+1)%3;
			if(y!=vis[it.first])
				res=true;
		}
		else{
			if(it.second)
				vis[it.first]=(vis[x]+2)%3;
			else
				vis[it.first]=(vis[x]+1)%3;
			res|=dfs(it.first);
		}
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1,u,v;i<=m;i++){
		cin>>u>>v;
		e[u].emplace_back(v,0);
		e[v].emplace_back(u,1);
	}
	for(int i=1;i<=n;i++)
		vis[i]=-1;
	long long int ans=0;
	for(int i=1;i<=n;i++)
		if(vis[i]==-1){
			w.clear();
			vis[i]=0;
			bool type=dfs(i);
			if(type)
				ans+=1LL*w.size()*w.size();
			else{
				int ww[3]={0,0,0};
				for(int it:w)
					ww[vis[it]]++;
				if(!ww[0]||!ww[1]||!ww[2]){
					long long int cnt=0;
					for(int it:w)
						cnt+=e[it].size();
					ans+=cnt/2;
				}
				else
					ans+=1LL*ww[0]*ww[1]+1LL*ww[1]*ww[2]+1LL*ww[2]*ww[0];
			}
		}
	cout<<ans<<endl;
}


Measured memory_bytes: 12920
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll x[110000];
int main(){
  ll n,a,b,ans=0;
  cin>>n>>a>>b;
  rep(i,0,n)cin>>x[i];
  sort(x,x+n);
  rep(i,0,n-1){
    ans+=min((x[i+1]-x[i])*a,b);
  }
  cout<<ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

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

  if(a < c) {
    if(b < c) ans = 0;
    else {
      if(b < d) ans = b-c;
      else ans = d-c;
    }
  } else {
    if(d < a) ans = 0;
    else {
      if(d < b) ans = d-a;
      else ans = b-a;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int n,m;
string s;

//monoid,結合律が成り立ち,単位元が存在するものに対しての演算をクエリに対してO(logn)で
//1-indexed  n(親)->2n,2n+1(子)  k(子)->k/2(親)
template<typename Monoid>
struct SegmentTree{
    using F = function< Monoid(Monoid, Monoid) >;
    //sz:size->完全二分木なのでszはnよりも大きい最小の2のべき乗数
    int sz;
    vector<Monoid> seg;
 
    const F f;
    const Monoid M1;
    SegmentTree(int n,const F f,const Monoid &M1) : f(f), M1(M1) {

    sz=1;
    while(sz<n) sz<<=1;
    seg.assign(2*sz, M1);
    }
 
    void set(int k, const Monoid &x){
        seg[k+sz] = x;
    }
 
    void build(){
        for(int k=sz-1;k>0;k--){
        seg[k]=f(seg[2*k+0], seg[2*k+1]);
        }
    }
 
    void update(int k,const Monoid &x){
        k+=sz;
        seg[k]=x;
        
    while(k>>=1){
        seg[k]=f(seg[2*k+0],seg[2*k+1]);
        }
    }
    //query聞くときは区間は[a,b)で(a<=x<b)
    Monoid query(int a, int b) {
        Monoid L=M1,R=M1;
        for(a+=sz,b+=sz;a<b;a>>=1,b>>=1){
            if(a&1) L=f(L, seg[a++]);
            if(b&1) R=f(seg[--b], R);
        }
        return f(L,R);
    }   
    Monoid operator[](const int &k) const{
        return seg[k+sz];
    }
};


pair<ll,int> f(pair<ll,int> a,pair<ll,int> b){
    if(a.first<b.first) return a;
    else if(a.first==b.first){
        if(a.second>b.second) return b;
        else return a;
    }
    else return b;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    cin>>n>>m;
    cin>>s;

    SegmentTree<pair<ll,int>> seg(n+1,f,pair<ll,int>(LINF,0));


    seg.set(0,make_pair(0ll,0));
    seg.build();
    for(int i=1;i<=n;i++){
        seg.set(i,make_pair(LINF,i));
    }


    vector<int> frm(n+1,-1);
    for(int i=1;i<=n;i++){
        if(s[i]=='1') continue;
        auto x=seg.query(max(0,i-m),i);
        frm[i]=x.second;
        seg.update(i,make_pair(x.first+1,i));
        // debug(frm);
    }


    // debug(frm);
    ll ans=seg[n].first;

    // rep(i,n+1) cout<<seg[i].first<<' ';cout<<endl;

    if(ans>=LINF){
        cout<<-1<<endl;
        return 0;
    }

    vector<int> way;
    int pos=n;
    while(pos!=0){
        int nxt=frm[pos];
        way.push_back(pos-nxt);
        pos=nxt;
    }
    reverse(ALL(way));
    // debug(way);

    rep(i,way.size()){
        cout<<way[i];
        cout<<(i==way.size()-1?'\n':' ');
    }
    return 0;
}


Measured memory_bytes: 5576
input = gets.split(" ").map(&:to_i)

x = input[0]
min = input[1]
max = input[2]
total = 0

(1..x).each do |num|
                sum = 0 #init sum=0
                str = num.to_s
                #puts str.length #if num is N digit number , return N
                (0..str.length).each do |inum|
                                sum += str[inum].to_i   # add 1~N per digit
                end

                if (sum >= min && sum <= max) then
                                total += num
                end

end

puts total


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using ll = long long;
const ll mod = 1e9 + 7;
ll pw(ll a, ll b) {
  if (b == 0) {
    return 1LL;
  }
  if (b % 2 == 1) {
    return a * pw(a, b - 1) % mod;
  }
  ll c = pw(a, b / 2);
  return c * c % mod;
}
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll s1 = 0, s2 = 0;
  REP(i, n) {
    cin >> a[i];
    s1 = (s1 + a[i]) % mod;
    s2 = (s2 + a[i] * a[i] % mod) % mod;
  }
  ll ans = (s1 * s1 - s2 + mod) % mod;
  ans = ans * pw(2, mod - 2) % mod;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main (void) {
    string S;
    cin >> S;

    bool can = true;
    int s_len = S.size();
    string t_rev;
    for ( int i = s_len-1; i >=0; i-- ) {
        t_rev += S.at(i);
        if ( t_rev.size() > 7 ) {
            can = false;
            break;
        }
        if ( t_rev == "maerd" || t_rev == "esare" ||
             t_rev == "remaerd" || t_rev == "resare" ) {
            t_rev = "";
        }
    }

    if ( can ) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3744
for e in iter(input,'0 0'):
    a,b=map(int,e.split())
    m=[[0]*b for _ in[0]*a]
    for _ in[0]*int(input()):
        i,j=map(int,input().split())
        m[~-i][~-j]=-1
    for s in range(a):
        for t in range(b):
            u,v=m[s-1][t],m[s][t-1]
            m[s][t]=(u*(u>0)+v*(v>0))*(m[s][t]!=-1)+(s+t==0)
    print(m[~-a][~-b])


Measured memory_bytes: 5596
#include "bits/stdc++.h"
using namespace std;
using ll = long long;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int s = 0;
    int z = a;
    for (int i = 1; i < 105; ++i) {
        s += a;
        z = z * a;
        s %= b;
        z %= b;
        if (s == c) return !printf("YES\n");
    }

    puts("NO");

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
#include<iomanip>
#include<bitset>
#define mod 1000000007
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mad(a,b) a=(a+b)%mod
#define mul(a,b) a=a*b%mod

#define N 310
ll n;
bitset<4000010> bi;
int main(){
    bi[0]=1;
    cin>>n;
    for(int i=0;i<n;i++){
	ll a; cin>>a;
	bi|=(bi<<a);
    }
    vector<ll> v;
    for(int i=1;i<4000010;i++){
	if(bi[i])v.push_back(i);
    }
    cout<<v[(v.size()-1)/2]<<endl;
}




Measured memory_bytes: 20200
H,W=gets.chomp.split(" ").map(&:to_i)
C=[]
(0..9).each do |i|
    c = gets.chomp.split(" ").map(&:to_i)
    C.push(c)
end
min_c = Array.new(10, 10**4)
min_c[1] = 0
nows = [1]
while !nows.empty? do
    nexts = []
    nows.each do |n|
        (0..9).each do |i|
            c = C[i][n] + min_c[n]
            if min_c[i] > c
                min_c[i] = c
                nexts.push(i)
            end
        end
    end
    nows = nexts
end
ret = 0
H.times do
    array = gets.chomp.split(" ").map(&:to_i)
    array.each do |a|
        next if a == 1 || a == -1
        ret += min_c[a]
    end
end
puts ret


Measured memory_bytes: 14440
// 21:36
#include <cstdio>
#include <cstring>

using namespace std;

int H,W,N;
int map[100][100];
int currentR=0,currentC=0;
void paintNext(int c) {
  map[currentR][currentC]=c;
  if (currentR%2==0) {
    if (currentC==W-1) {
      currentR++;
    } else {
      currentC++;
    }
  } else {
    if (currentC==0) {
      currentR++;
    } else {
      currentC--;
    }
  }
}
int main() {
  memset(map,0,sizeof(map));
  scanf("%d%d%d", &H,&W,&N);
  for(int i=0;i<N;++i) {
    int a;
    scanf("%d", &a);
    for(int j=0;j<a;++j) {
      paintNext(i + 1);
    }
  }
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      printf("%d ", map[i][j]);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;
 
/**
 * 解説通りに実装したソースコード
 */
public class Main {
 
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int r = scanner.nextInt(), c = scanner.nextInt(), k = scanner.nextInt();
			long[][] v = new long[r][c];
			IntStream.range(0, r).forEach(i -> Arrays.fill(v[i], 0L));
			IntStream.range(0, k).forEach(i -> v[scanner.nextInt() - 1][scanner.nextInt() - 1] = scanner.nextLong());
			long[][][] dp = new long[4][r][c];
			dp[0][0][0] = 0L;
			dp[1][0][0] = v[0][0];
			IntStream.range(0, r).forEach(i -> IntStream.range(0, c).forEach(j -> {
				if (i > 0) {
					dp[0][i][j] = max(dp[0][i][j],
							IntStream.range(0, 4).mapToLong(l -> dp[l][i - 1][j]).max().getAsLong());
					if (v[i][j] > 0) {
						dp[1][i][j] = max(dp[1][i][j],
								IntStream.range(0, 4).mapToLong(l -> dp[l][i - 1][j]).max().getAsLong() + v[i][j]);
					}
				}
				if (j > 0) {
					if (v[i][j] > 0) {
						IntStream.range(1, 4).forEach(
								l -> dp[l][i][j] = max(dp[l][i][j], dp[l - 1][i][j - 1] + v[i][j], dp[l][i][j - 1]));
					} else {
						IntStream.range(0, 4).forEach(l -> dp[l][i][j] = max(dp[l][i][j], dp[l][i][j - 1]));
					}
				}
			}));
			System.out.println(IntStream.range(0, 4).mapToLong(l -> dp[l][r - 1][c - 1]).max().getAsLong());
		}
	}
 
	/**
	 * 複数のlongのmaxを取得する
	 * 
	 * @param a 一つ目のlong
	 * @param b 二つ目以降のlong
	 * @return 複数のlongのmax
	 */
	private static long max(long a, long... b) {
		long result = a;
		for (long l : b) {
			result = Math.max(result, l);
		}
		return result;
	}
}


Measured memory_bytes: 634796
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  map<char, int> amap;
  vector<char> arr;
  for(int i=0;i<S.size();++i) {
    if(amap[S[i]]==0) arr.push_back(S[i]);
    amap[S[i]]++;
  }
  if(arr.size()==2 && amap[arr[0]]==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3548
words = {}

N = int(input())
for _ in range(N):
    s = input()
    if s in words.keys():
        words[s] += 1
    else:
        words[s] = 1

M = int(input())
for _ in range(M):
    t = input()
    if t in words.keys():
        words[t] -= 1
    else:
        words[t] = -1

print(max(0, max(words.values())))


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  string s;
  cin >> s;
  sort(all(s));
  cout << (s == "abc" ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define lowbit(x) ((x)&(-(x)))
#define mid ((l+r)>>1)
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
using namespace std;
const int maxn = 1e5 + 50;
char s[maxn];
int main()
{
    int n;
    cin>>n;
    scanf("%s", s);
    int ans = 0;
    for(int i = 0; i < n; ++i){
        ans++;
        while(i+1 < n && s[i+1] == s[i]) i++;
    }cout<<ans<<endl;
}


Measured memory_bytes: 384
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc129_a.cpp
 * time   : Sat May  2 00:35:48 2020
 * quest  : A - Airplane
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int p, q, r;
  cin >> p >> q >> r;
  cout << min(p + q, min(q + r, p + r)) << "\n";
  return 0;
}


Measured memory_bytes: 256
def is_prime(x)
  (2..x-1).each do |n|
    if x % n == 0
      return false
    end
  end
  return true
end

x = gets.to_i

if is_prime(x)
  puts x
else
  x += 1
  while !is_prime(x)
    x += 1
  end
  puts x
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int x1,y1,x2,y2;
    int x3,y3,x4,y4;
    cin >> x1 >> y1 >> x2 >> y2;
    x3=x2-(y2-y1);y3=y2+(x2-x1);
    x4=x3-(y3-y2);y4=y3+(x3-x2);
    cout << x3 << " " << y3 <<" " << x4 <<" " << y4 << endl;
    
    return 0;
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int max = 0;
    rep(i,n-1) {
        string s1 = s.substr(0,i+1);
        string s2 = s.substr(i+1, n-i-1);
        set<char> set1,set2;
        rep(j,s1.size()) set1.insert(s1[j]);
        rep(j,s2.size()) set2.insert(s2[j]);
        set<char> product;
        set_intersection(set1.begin(), set1.end(),set2.begin(), set2.end(), inserter(product,product.begin()));
        chmax(max, (int)product.size());
        
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;
ll n,q,m,k,l,ans;
string s;
vll a,b;
map<ll, vll> bits;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    
    cin >> n >> s;

    ans = 0;
    rng(i,1,n){
        ll cnt = 0;
        string sl = s.substr(0,i);
        string sr = s.substr(i);
        // cout << sl << " : " << sr << endl;
        for(char c='a';c<='z';c++){
            bool left = false;
            for(auto e:sl) if(e==c) left = true;
            bool right = false;
            for(auto e:sr) if(e==c) right = true;
            if(left&&right) cnt++;
        }
        ans = max(cnt, ans);
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template <typename H> void print(H head) { std::cout << head << std::endl; }
template <typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N = 5;
  std::vector< std::pair<ll, ll> > vp(N);
  for (ll i = 0; i < N; i++) {
    std::cin >> vp[i].second;
    vp[i].first = vp[i].second % 10 == 0 ? INF : vp[i].second % 10;
  }

  std::sort(vp.begin(), vp.end(), std::greater<>());

  ll sum = 0LL;
  ll span = 10;
  for (ll i = 0; i < N; i++) {
    sum = ((sum + (span - 1)) / span) * span;
    sum += vp[i].second;
  }

  print(sum);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<iostream>

using namespace std;

char a[11],b[11],c[11];

int main(){
	scanf("%s %s %s",a,b,c);
	int lena = strlen(a),lenb = strlen(b),lenc = strlen(c);
	if(a[lena - 1] == b[0] && b[lenb - 1] == c[0]) printf("YES\n");
	else printf("NO\n");
	}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $c);
 
$array_string = array($a, $b, $c);
$dem_5 = 0;
$dem_7 = 0;
foreach ($array_string as $string) {
     if ($string == 5) {
           $dem_5++;
     }
     if ($string == 7) {
           $dem_7++;
     }
}
# output
if ($dem_5 == 2 && $dem_7 == 1) {
     echo " YES\n";
} else {
    echo "NO\n";
}
?>

Measured memory_bytes: 3576
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

/*
 * n秒待てばnまで1回で行けるので最大n.
 * nをすぎて戻ることがあるか？距離はより大きいので、一度すぎるとnにはつかない.
 * 1 + 2 + 3 = 6 のようにn未満で戻れるケースが考察が必要.
 * 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5
 * 1  2  3  4  5  6  7  8  9  10 11
 */
int main() {
  int n; cin >> n;
  // 1, 3, 6, 10, 15, 21, 28, 36
  // 2, 3, 4, 5, 6, 7
  // n + a{n-1}
  int a = 1;
  int cnt = 1;
  while (a < n) {
    cnt++;
    a += cnt;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3516
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

max = int(input())
i = 0
strings = []
while True:
  if i == max:
    break
  strings.append(input())
  i+=1

#print(strings) # ['acornistnt', 'peanutbomb', 'constraint']

strings2 = [list(str) for str in strings]
[str.sort() for str in strings2] # 配列の中身を副作用でソートする
# print(strings2)
strs3 = [''.join(str) for str in strings2] # ソートした文字のリストを文字列に戻す

#print(strs3)

c = collections.Counter(strs3)
# print(c)
counts = list(c.values()) # 組み合わせの数のリスト
counts2 = [ c for c in counts if c > 1] # 2個以上の重複がないものは除外
#print(counts2)

# nC2 の組み合わせを計算して、合計する
print(sum([int(cmb(n, 2)) for n in counts2]))

Measured memory_bytes: 49800
#define Z(x,i)(x[i]+x[n/2+i])
float x[99],y[99],X,Y;
n,i;main(){
	for(gets(x);~scanf("%f %f",x+n,y+n);n++);
	if(!(n&1))for(X=Z(x,0),Y=Z(y,0);
		i<n/2&&fabsf(Z(x,i)-X)<1e-7&&fabsf(Z(y,i)-Y)<1e-7;
	i++);
	printf(i==n/2?"%f %f\n":"NA\n",X/2,Y/2);exit(0);
}

Measured memory_bytes: 652
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

ans = 0
for i in range(n):
    tmp = min(a[i], b[i])
    ans += tmp
    a[i] -= tmp
    tmp2 = min(a[i+1], b[i] - tmp)
    ans += tmp2
    a[i+1] -= tmp2
print(ans)

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

int main(){
	int k;
  cin>>k;
  	long long sum=0;
  	for(int i=1;i<=k;i++){
    	for(int j=1;j<=k;j++){
        	for(int n=1;n<=k;n++){
            	int g=__gcd(i,j);
              	long long s=__gcd(g,n);
              	sum+=s;
            }
          
        }          

    }
  
  cout<<sum;
}


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

int main() {
    string S, T;
    cin >> S >> T;

    int ans = T.length();
    
    for (int i = 0; i <= S.length() - T.length(); ++i) {
        int tmp = 0;
        for (int j = 0; j < T.length(); ++j) {
            if (T[j] != S[i + j]) tmp++ ;
        }
        ans = min(ans, tmp);
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  int oddc = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;

    oddc += x % 2;
  }

  if (oddc % 2 == 1) {
    cout << "NO" << endl;
  } else{
    cout << "YES" << endl;
  }
}


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

using namespace std;
#define int long long 
#define N 666666
int arr[N],a[N],b[N];
#define pi 6.28318530717958623200
signed main(){
	int n,m;
	cin>>n>>m;
	int s=0;
	for(int i=1;i<=m;i++){
		int t;cin>>t;s+=t;
	}
	if(n>=s){
		cout<<n-s;
	}else{
		cout<<-1;
	}
	return 0;
}



Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(all(a));
	int count = 1;
	int ans = 0;
	rep(i, n-1) {
		if (a[i] == a[i + 1]) {
			count++;
		}
		else {
			if (count >= a[i]) {
				ans += count - a[i];
			}
			else {
				ans +=count;
			}
			count = 1;
		}
	}
	if (count >= a[n-1]) {
		ans += count - a[n-1];
	}
	else {
		ans += count;
	}
	cout << ans << endl;

}



Measured memory_bytes: 640
import java.util.Scanner

fun main(args:Array<String>){
    val cin = Scanner(System.`in`)
    val r = cin.nextDouble()
    val pi = 3.141592653589
    
    val area = r*r*pi
    val cir = 2*r*pi

    println("%f %f".format(area,cir))
}



Measured memory_bytes: 26840
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define dl double long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N-1){
    ll a;
    cin >> a;
    --a;
    A[a]++;
  }
  rep(i, N) cout << A[i] << "\n";
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string n;
    cin >> n;
    int len = n.length();
    int k;
    cin >> k;
    if (len < k) {
        cout << 0 << endl;
        return 0;
    }
    long long ans = 0;
    if (k == 1) {
        for (int i = 1; i < len; ++i) {
            ans += 9;
        }
        ans += n[0] - '0';
    } else {
        if (k == 2) {
            for (int i = 2; i < len; ++i) {
                ans += 9 * (i - 1) * 9;
            }
            ans += (n[0] - '0' - 1) * (len - 1) * 9;
            bool small = false;
            for (int i = 1; i < len; ++i) {
                if (small == true) {
                    ans += 9;
                    continue;
                }
                ans += n[i] - '0';
                if (n[i] != '0') {
                    small = true;
                }
            }
        } else {
            for (int i = 3; i < len; ++i) {
                ans += 9 * (i - 1) * (i - 2) / 2 * 81;
            }
            ans += (n[0] - '0' - 1) * (len - 1) * (len - 2) / 2 * 81;
            bool small = false;
            for (int i = 1; i < len - 1; ++i) {
                if (small == true) {
                    ans += 9 * (len - i - 1) * 9;
                    continue;
                }
                if (n[i] > '0') {
                    ans += (n[i] - '0' - 1) * (len - i - 1) * 9;
                    bool small2 = false;
                    for (int j = i + 1; j < len; ++j) {
                        if (small2 == true) {
                            ans += 9;
                            continue;
                        }
                        ans += n[j] - '0';
                        if (n[j] != '0') small2 = true;
                    }
                }
                if (n[i] != '0') {
                    small = true;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

const string YES = "Yes";
const string NO = "No";

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long a, long long b, long long c){
    set<int> s;
    s.emplace(a);
    s.emplace(b);
    s.emplace(c);
    cout << (s.size() == 2 ? "Yes" : "No") << endl;
}


signed main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

int main() {
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.size()) {
        if(s.at(i) != t.at(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3920
import sys
input = sys.stdin.readline

N, Z, W = map(int, input().split())
a = list(map(int, input().split()))
dp = [[0]*(2) for _ in range(N)]

for i in range(N-1, -1, -1):
    if i==0:
        dp[i][0] = abs(a[N-1]-W)
    else:
        dp[i][0] = abs(a[N-1]-a[i-1])
    
    for j in range(i+1, N):
        dp[i][0] = max(dp[i][0], dp[j][1])
    
    if i==0:
        dp[i][1] = abs(a[N-1]-Z)
    else:
        dp[i][1] = abs(a[N-1]-a[i-1])
    
    for j in range(i+1, N):
        dp[i][1] = min(dp[i][1], dp[j][0])

print(dp[0][0])

Measured memory_bytes: 74484
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		// 計算&出力
		if((n-1)*(n-2)/2 < k){
		    System.out.println(-1);
		    return;
		}
		int m = n-1 + (n-1)*(n-2)/2 - k;
		System.out.println(m);
		for(int i = 1; i <= n-1; i++){
		    System.out.println(n + " " + i);
		}
		int cnt = 1;
		for(int i = 1; i <= n-1; i++){
		    for(int j = i+1; j <= n-1; j++){
		        if(cnt > (n-1)*(n-2)/2 - k) return;
		        System.out.println(i + " " + j);
		        cnt++;
		    }
		}
	}
}


Measured memory_bytes: 24532
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] d  = new int[n];
			for (int i = 0; i < n; i++) {
				d[i] = sc.nextInt();
			}

			int result = 0;
			for (int i = 0;i < n - 1; i++) {
				for (int j = i + 1; j < n; j++) {
					result += d[i] * d[j];
				}
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int N, M; cin >> N >> M;
  vector<int> A(M); rep(i, M) cin >> A[i];
  sort(A.begin(), A.end(), greater<int>());
  int m[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  
  int dp[10100]; //dp[i]はi本ちょうどマッチを使った時に作れる最大桁数
  rep(i, N + 1) dp[i] = -100000; 
  dp[0] = 0;

  rep1(i, N) {
      rep(j, M) {
          if(i - m[A[j]] >= 0) {
            dp[i] = max(dp[i], dp[i - m[A[j]]] + 1);
          }
      }
  }
  
  int k = dp[N];
  rep(i, k) {
        rep(j, M) {
            if (dp[N - m[A[j]]] + 1 == dp[N] && N - m[A[j]] >= 0) {
                cout << A[j];
                N -= m[A[j]];
                break;
            }
        }
  }
  cout << "\n";
        


  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    cout << (a-1)*(b-1) << endl;   
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int size = 1e3+100;



int main()
{	
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	int a[n+1][2];
	int b[n+1][2];
	for(int i=0;i<n;i++)
		cin >> a[i][0];
	for(int i=0;i<n;i++)
		cin >> a[i][1];

	b[0][0]=a[0][0];
	b[0][1]=a[0][0]+a[0][1];
	for(int i=1;i<n;i++)
		b[i][0]=a[i][0]+b[i-1][0];
	for(int i=1;i<n;i++)
		b[i][1]=a[i][1]+max(b[i-1][1],b[i][0]);
	cout << b[n-1][1];

}


Measured memory_bytes: 256
#include<cstdio>

char str[1048576];

int main(void){
	register int i;
	scanf("%s",str);
	for(i=0;str[i];++i){
		if(i==4)
			putchar(' ');
		putchar(str[i]);
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

struct Edge{
  int from;
  int to;
  long cost;
};

vvl dp(100010,vl(2,-1));

vector<vector<Edge>> Graph(100010);

long dfs(int v, int pv, int w){
  if(dp[v][w] != -1) return dp[v][w];
  long res = 1;
  for(Edge ed : Graph.at(v)){
    int nv = ed.to;
    if(pv == nv) continue;
    if(w) res = (res * (dfs(nv,v,1) + dfs(nv,v,0)) % MOD) % MOD;
    else res = (res * dfs(nv,v,1)) % MOD;
  }
  return dp[v][w] = res;
}

int main(){
  int n;
  cin >> n;
  rep(i,n-1){
    int x,y;
    cin >> x >> y;
    x--;y--;
    Graph.at(x).push_back({x,y,1});
    Graph.at(y).push_back({y,x,1});
  }
  cout << (dfs(0,-1,0) + dfs(0,-1,1)) % MOD << endl;
}


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

#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

#define ll long long
#define ld long double

const ld EPS = 10e-9;
const int INF = 1e9 + 5;
const long long INFLL = (ll)INF * (ll)INF;
const ll MOD = 1e9 + 7;
const ld PI = 3.14159265358979323846;

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

template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const unordered_set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const unordered_map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

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

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define debug(...)
#endif


// __gcd(x, y)

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

    int n;
    cin>>n;
    vector<ld> a(n);

//    cout << setprecision(30) << (ll)1e25 << endl;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(a[i] == (ld)0)
        {
            cout << 0 << endl;
            return 0;
        }
    }


    ld res = 1;

    for(int i = 0; i < n; i++)
    {
//        if(res > 1000)
        res *= a[i];
        if(res > (ld)1e18)
        {
            res = -1;
            break;
        }
    }

    if(res > (ld)1e18)
        res = -1;



    cout << (ll)res << endl;



    return 0;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cou1=0;
    int cou2=0;
    rep(i,s.size()){
        if(s.at(i)=='R') cou1++;
    }
    rep(i,cou1){
        if(s.at(i)=='R') cou2++;
    }
    cout<<cou1-cou2;
}

Measured memory_bytes: 3720
# include <bits/stdc++.h>
using namespace std ;
int main () {
int N , M ; cin >> N >> M ;
vector <int > cnt (M , 0);
for ( int i = 0; i < N ; ++ i ) {
int K; cin >> K ;
for ( int j = 0; j < K ; ++ j ) {
int A; cin >> A ; --A ;
++ cnt [ A ];
}
}
int ans = 0;
for ( int i = 0; i < M ; ++ i ) {
if ( cnt [ i ] == N ) {
++ ans ;
}
}
cout << ans << endl ;
}


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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

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

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()
#define FIND(s, n) (s.find(n) != s.end())
#define SORT(a) sort(all(a))

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int N, M, res;
int G[100][100];
int c[100], m[100];

int dfs(int b, int n) {
	c[n] = 1;
	for (int i = 0; i < N; i++) {
		if (b == i || n == i) continue;
		if (G[n][i]) {
			if (c[i] == 1) return 0;
			if (!dfs(n, i)) return 0;
		}
	}
	return 1;
}

int isPrime(int x){
  int i;
  if(x < 2) return 0;
  else if(x == 2) return 1;
  if( x%2 == 0) return 0;
  for(i = 3; i*i <= x; i += 2){
    if(x%i == 0) return 0;
  }
  return 1;
}

const int pmax = 1000000;
bool isPrime_table[pmax];
//const is necessary;
void eratos(void){
  int i, j;
  double sqrtmax=sqrt(pmax);

  REP(k, pmax) isPrime_table[k] = true; /* Initialization */

  /* Sieve process  */
  isPrime_table[0] = false;
  isPrime_table[1] = false;
          /* 0 and 1 are not prime. */
  for (i=2; i <= sqrtmax; i++){
    if (isPrime_table[i]==true){   /* i is prime. */
      for (j=i; i*j<pmax; j++){
        isPrime_table[i*j] = false; /* multiples of i are not prime. */
      }
    }
  }
}

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

	int N;
	cin >> N;

	vint(v, 2*N);
	sort(all(v));
	int tot = 0;
	for(int i = 0; i < 2*N; i += 2) tot += v[i];

	cout << tot << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char t[1010];
int main(){
	int i;
	int n;
	int ans;
	while(scanf("%s",&t)){
		n=strlen(t);
		ans=0;
		if(n==1&&t[0]=='0') break;
		for(i=0;i<n;i++){
			ans+=t[i]-'0';
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 536