akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
struct edge{int to,cost;};
int n,m,k;
vector<edge> g[3050];
vector<int> shop;
int d[3050];
int dist[3050];
int L[3002][3002];
void input()
{
	memset(L,-1,sizeof(L));
	fill(dist,dist+3050,INF);
	cin >> n >> m >> k;
	for(int i=0;i<m;i++)
	{
		int a,b,l;
		cin >> a >> b >> l;
		edge in;
		in.to=b;
		in.cost=l;
		g[a].pb(in);
		in.to=a;
		g[b].pb(in);
		L[a][b]=l;
		L[b][a]=l;
	}
	for(int i=0;i<k;i++)
	{
		int s;
		cin >> s;
		shop.pb(s);
	}
	return;
}
void update()
{
	for(int i=1;i<=n;i++)
	{
		dist[i]=min(dist[i],d[i]);
	}
	return;
}
void dijkstra(int s)
{
	fill(d,d+n+1,INF);
	priority_queue<P,vector<P>,greater<P> > q;
	d[s]=0;
	q.push(P(0,s));
	while(!q.empty())
	{
		P a=q.top();
		q.pop();
		if(d[a.sec]<a.fi)continue;
		for(int i=0;i<g[a.sec].size();i++)
		{
			edge e=g[a.sec][i];
			if(d[e.to]>d[a.sec]+e.cost)
			{
				d[e.to]=d[a.sec]+e.cost;
				q.push(P(d[e.to],e.to));
			}
		}
	}
	//cout << d[3] << endl;
	update();
	return;
}
int main()
{
	input();
	for(int i=0;i<shop.size();i++)
	{
		dijkstra(shop[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(L[i][j]==-1)continue;
			int k=L[i][j]-abs(dist[i]-dist[j]);
			if(k<=0)
			{
				ans=max(ans,max(dist[i],dist[j]));
				continue;
			}
			ans=max(ans,max(dist[i],dist[j])+(k+1)/2);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 39432
#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() {
  ll N, K;
  cin>>N>>K;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  ll ans = 0;
  ll tmp;
  for(int i=42;i>=0;--i) {
    if(ans+(1ull<<i)>K) continue;
    tmp = 0;
    for(int j=0;j<N;++j) {
      if((A[j]&(1ull<<i))==0) tmp++;
    }
    if(tmp*2>N) ans += (1ull<<i);
  }
  ll ans1 = 0;
  for(int i=0;i<N;++i) {
    ans1 += A[i]^ans;
  }
  cout<<ans1<<endl;
}



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

int main(){
  const int N = 5;
  int a[N];
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  int i = 0;
  while(a[i] != 0){
    i++;
  }
  cout << i+1;
  return 0;
}

Measured memory_bytes: 3544
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
		bool answer = true;

    for(int i = 0; i < n; i++)
    {
      if(nums[i] % 2 == 0 && nums[i] % 3 != 0 && nums[i] % 5 != 0)
      {
        answer = false;
        break;
      }
    }

		if(answer) Console.WriteLine("APPROVED");
    else Console.WriteLine("DENIED");
	}
}

Measured memory_bytes: 11092
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const ll INF = 10000000000;//INFinity
using namespace std;//namespace

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}//transform
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//#define int long long // yabai

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    int n;
    cin>>n;
    vector<int>c(n-1);
    vector<int>s(n-1);
    vector<int>f(n-1);

    REP(i,n-1)cin>>c[i]>>s[i]>>f[i];
    vector<int> ans(n,0);
    
    REP(i,n){
        int now_time=0;
        FOR(j,i,n-1){// j banme no eki
            int count=0;
            for(;now_time>s[j]+f[j]*count;++count);
            now_time=c[j]+s[j]+f[j]*count;
        }
        ans[i]=now_time;
    }
    
    REP(i,n)cout<<ans[i]<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

ll dp[55][55][3000]; 
// dp[i][k][s] : iまで見てk枚選んで合計をsにするような選び方の総数

int main() {
    ll n, a; cin >> n >> a;
    Vl x(n);
    rep(i, 0, n) cin >> x[i];

    dp[0][0][0] = 1;
    rep(i, 0, n){
        Rep(k, 0, n){
            Rep(s, 0, a*n){
                if(dp[i][k][s] == 0) continue;
                dp[i+1][k][s] += dp[i][k][s];
                dp[i+1][k+1][s+x[i]] += dp[i][k][s];
            }
        }
    }

    ll ans = 0;
    Rep(k, 1, n) ans += dp[n][k][a*k];
    co(ans);

    return 0;
}


Measured memory_bytes: 12864
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            long ans = 1;
            int[] cnt = new int[26];
            for (int i = 0; i < s.length(); i++) {
                int c = s.charAt(i) - 'a';
                for (int j = 0; j < 26; j++) {
                    if (j != c) {
                        ans += cnt[j];
                    }
                }
                cnt[c]++;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



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

int Balls[10];

bool fork(int balls[], int i, int b, int c) {
  if (i == 10) return true;
  if (b > balls[i] && c > balls[i]) return false;
  if (b < balls[i] && fork(balls, i + 1, balls[i], c)) return true;
  if (c < balls[i] && fork(balls, i + 1, b, balls[i])) return true;
  return false;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> Balls[j];
    }
    if(fork(Balls, 0, 0, 0)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

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

using namespace std;

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

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


int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    // top1 and top2
    int max1 = 0;
    int max2 = 0;
    for(int i=0; i<N; i++){
        if( A[i] >= max2 ){ 
            max2 = A[i];
            if( A[i] >= max1 ){ 
                max2 = max1;
                max1 = A[i];
            }
        }
    }
    // print
    for(int i=0; i<N; i++){
        if( A[i] != max1 ){
            cout << max1 << endl;
        }else{
            cout << max2 << endl;
       }
    }
} 

Measured memory_bytes: 2432
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include<iomanip>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 1001001001;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}


int main() {
    string S;
    cin >> S;
    ll s = S.size();
    ll ans = 0;
    rep(i, s - 1) {
        if (S[i] != S[i + 1])ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
N = int(input())

i = 1
T = 26
ans = ""
while True:
    if N <= T ** i:
        N -= 1
        while i > 0:
            N, r = divmod(N, T)
            ans += chr(r + ord('a'))
            i -= 1
        break
    else:
        N -= T ** i
        i += 1
print(ans[::-1])


Measured memory_bytes: 9172
package main

import (
	"fmt"
)

func main() {
	var l, r, d int
	fmt.Scan(&l, &r, &d)

	cnt := 0
	for i := l; i <= r; i++ {
    	if i % d == 0 {
    		cnt++
    	}
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 1768
#include <stdio.h>
#define MAX 4
int main(void) {
    int i, j, k, a[4], tmp;
    char s[4], m[3];
    scanf("%s", s);
    
    for(i=0; i<4; i++) {
        a[i] = s[i] - '0';
    }
    
    for(i=0; i<1<<3; i++) {
        tmp=a[0];
        for(k=0; k<3; k++)
            m[k]='\0';
        k=0;
        for(j=0; j<3; j++) {
            if(1&i>>j) {
                tmp += a[j+1];
                m[k] = '+';
                k++;
            }else {
                tmp -= a[j+1];
                m[k] = '-';
                k++;
            }
        }
        if(tmp==7) {
            printf("%d%c%d%c%d%c%d=7\n", a[0], m[0], a[1], m[1], a[2], m[2], a[3]);
            return 0;
        }
    }
}


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

int main () {
  string n;
  cin >> n;
  if (n[0] == n[1] && n[1] == n[2] || n[1] == n[2] && n[2] == n[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]
es = [[0]*N for _ in range(N)]
for a,b in AB:
    a,b = a-1,b-1
    es[a][b] = es[b][a] = 1

ans = 0
import itertools
for ptn in itertools.permutations(range(1,N)):
    ptn = list(ptn)
    for a,b in zip([0]+ptn, ptn):
        if not es[a][b]: break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 9120
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
using namespace std;
int main() {
	int n, a[101];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	int count = 0, memo = 0;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1])memo++;
		else {
			if (memo % 2 == 0)count += memo / 2;
			else if (memo != 0)count += memo / 2 + 1;
			memo = 0;
		}
	}
	if (memo % 2 == 0)count += memo / 2;
	else if (memo != 0)count += memo / 2 + 1;
	cout << count << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
def main():
    n,a,b = map(int,input().split())
    mod = 10**9+7
    s = pow(2,n,mod)
    nCa,nCb = 1,1
    for i in range(n-a+1, n+1):
        nCa *= i
        nCa %= mod

    for i in range(1,a+1):
        nCa *= pow(i,mod-2,mod)
        nCa %= mod

    for i in range(n-b+1, n+1):
        nCb *= i
        nCb %= mod

    for i in range(1,b+1):
        nCb *= pow(i,mod-2,mod)
        nCb %= mod
    print((s-nCa-nCb-1)%mod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9200
#include <bits/stdc++.h> 
 
using namespace std;
 
 
int main() {
	int n;
	string s;
 
	cin >> n; cin >> s;
	long long sa,sb,sc;
	sa = 0; sb=0; sc=0;
	s = " " + s;
	for (int i=1; i<=n; i++) {
		if (s[i]=='R') sa++;
		if (s[i]=='G') sb++;
		if (s[i]=='B') sc++;
	}
	long long  ans;
	ans = sa * sb * sc;
 
	for (int i=1; i<=n; i++) 
		for (int j=1; i -j >=1 && i+j <=n ; j++) 
			if (s[i]!=s[i-j] && s[i]!=s[i+j] && s[i-j] != s[i+j]) ans--;
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<sstream>


using namespace std;
string tmp;
int num,ans[2];

string i2s(int num){
  string str;
  stringstream s;
  s<<num;
  s>>str;
  return str;

}
  
void dfs(string str,int cnt){
  //cout<<str<<' '<<cnt;
  //if(str.size()==1)cout<<"-----"<<endl;
  //else cout<<endl;
  if(str.size()==1){
    ans[cnt%2]=1;
  }


  if(str.size()>1){
    for(int i=0;i<1;i++){
      tmp="";
      tmp+=str.substr(0,i);
      num=(str[i]-'0')+(str[i+1]-'0');
      tmp+=i2s(num);
      tmp+=str.substr(i+2,str.size()-(i+2));
      dfs(tmp,cnt+1);
    }
  }
}
int main(){
  int n;
  cin>>n;
  while(n--){
    ans[0]=ans[1]=0;
    string str;
    cin>>str;
    dfs(str,0);
    //cout<<ans[0]<<' '<<ans[1]<<endl;
    if(ans[0]==0){
      cout<<"Fabre wins."<<endl;
    }else{
      cout<<"Audrey wins."<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2440
n,q=map(int,input().split())
s=input()
l=[0,0]
cnt=0
for i in range(1,n):
    if "AC" == s[i-1]+s[i]:
        cnt+=1
    l.append(cnt)
for i in range(q):
    a,b=map(int,input().split())
    print(l[b]-l[a])


Measured memory_bytes: 6096
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	ll f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e5+10,inf=0x3f3f3f3f;
int f[maxn];
int sum0[maxn],sum1[maxn];
struct point{
	int x,y;
	bool operator <(const point &rhs) const{
		return x<rhs.x || (x==rhs.x && y<rhs.y);
	}
}a[maxn];
inline void chkmin(int &x,int y){
	if(y<x) x=y;
}
inline void chkmax(int &x,int y){
	if(y>x) x=y;
}
struct Seg{
	int Min[maxn<<2];
	void clean(){
		memset(Min,inf,sizeof(Min));
	}
	int query(int x,int L,int R,int ql,int qr){
		if(ql<=L && R<=qr)
			return Min[x];
		int Mid=(L+R)>>1,tmp=inf;
		if(ql<=Mid) chkmin(tmp,query(x<<1,L,Mid,ql,qr));
		if(qr>Mid) chkmin(tmp,query(x<<1|1,Mid+1,R,ql,qr));
		return tmp;
	}
	void update(int x,int L,int R,int q,int v){
		if(L==R){
			Min[x]=v;
			return;
		}
		int Mid=(L+R)>>1;
		if(q<=Mid) update(x<<1,L,Mid,q,v);
		else update(x<<1|1,Mid+1,R,q,v);
		Min[x]=min(Min[x<<1],Min[x<<1|1]);
	}
}Seg1,Seg2;
int main(){
	memset(f,inf,sizeof(f));
	int n=read();
	REP(i,1,n){
		int x=read();
		sum0[i]=sum0[i-1]+(x==0);
		sum1[i]=sum1[i-1]+(x==1);
	}
	f[0]=0;
	int m=read();
	REP(i,1,m) a[i].x=read(),a[i].y=read();
	a[++m]=(point){n+1,n};
	sort(a+1,a+m+1);
	Seg1.clean();
	Seg2.clean();
	Seg1.update(1,0,n,0,0);
	Seg2.update(1,0,n,0,0);
	REP(i,1,m){
		if(a[i].x<a[i].y) chkmin(f[a[i].y],Seg1.query(1,0,n,a[i].x,a[i].y-1)+sum0[a[i].y]);
		chkmin(f[a[i].y],Seg2.query(1,0,n,0,a[i].x-1)+sum1[a[i].x-1]+sum0[a[i].y]-sum0[a[i].x-1]);
//		DREP(j,a[i].y-1,0){
//			if(j>=a[i].x) chkmin(f[a[i].y],f[j]+sum0[a[i].y]-sum0[j]);
//			else chkmin(f[a[i].y],f[j]+sum1[a[i].x-1]-sum1[j]+sum0[a[i].y]-sum0[a[i].x-1]);
//		}
		if(i==m) break;
		Seg1.update(1,0,n,a[i].y,f[a[i].y]-sum0[a[i].y]);
		Seg2.update(1,0,n,a[i].y,f[a[i].y]-sum1[a[i].y]);
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 10368
#include <stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	if(n<2)printf("1");
	else if(n<4)printf("2");
	else if(n<8)printf("4");
	else if(n<16)printf("8");
	else if(n<32)printf("16");
	else if(n<64)printf("32");
	else if(n<=100)printf("64");
	return 0;
}

Measured memory_bytes: 128
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

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

using namespace std;

typedef long long ll;

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    ll N;
    cin >> N;
    string S[10010];
    string aS[10010],zS[10010];
    repeat(i, N){
        cin >> S[i];
        aS[i]=S[i];
        zS[i]=S[i];
        repeat(s, S[i].length()){
            if(S[i][s]=='?'){
                aS[i][s] = 'a';
                zS[i][s] = 'z';
            }
        }
    }
    string T;
    cin >> T;
    int onlyfront = 0;
    int both=0;
    repeat(i, N){
        if(aS[i]<=T){
            if(zS[i]>=T){
                both++;
            }
            else{
                onlyfront++;
            }
        }
    }
    for(int i=onlyfront+1;i<=onlyfront+both+1;i++){
        cout << i;
        if(i==onlyfront+both+1)
            cout << endl;
        else
            cout << " ";
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n, m;
  cin >> n >> m;
  vector<vi32> edges(n);
  rep(i, m) {
    int s, t;
    cin >> s >> t;
    s--, t--;
    edges[s].push_back(t);
  }
  f80 ans = 1e18;
  rep(i, n - 1) {
    vf80 memo(n, -1e18);
    memo[n - 1] = 0;
    function<f80(int)> dfs = [&](int v) {
      if (memo[v] != -1e18) return memo[v];
      f80 ret = 0;
      f80 ma = -1e18;
      int cnt = edges[v].size();
      for (auto u : edges[v]) {
        f80 temp = dfs(u);
        amax(ma, temp);
        ret += temp;
      }
      if (v == i && cnt >= 2) {
        ret -= ma;
        return memo[v] = (ret / (cnt - 1)) + 1;
      }
      return memo[v] = (ret / cnt) + 1;
    };
    amin(ans, dfs(0));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
use std::io::*;
use std::str::FromStr;

const MOD: usize = 1e9 as usize + 7;

fn main() {
	let (taka_h, taka_a): (f32, f32) = (read(), read());
	let (aoki_h, aoki_a): (f32, f32) = (read(), read());
	let ans = if (taka_h/aoki_a).ceil() >= (aoki_h/taka_a).ceil() { "Yes" } else { "No" };
	println!("{}", ans);
}

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


Measured memory_bytes: 2568
#include <iostream>
using namespace std;
int p[200005],n,x;
bool used[200005];
void set(int i,int j)
{
	if (j<1 || j>=2*n || used[j])
	return;
	p[i]=j;
	used[j]=1;
}
int main()
{
	scanf("%d%d",&n,&x);
	if (x==1 || x==2*n-1)
	{
		printf("No");
		return 0;
	}
	printf("Yes\n");
	if (n==2)
	{
		printf("1 2 3");
		return 0;
	}
	set(n,x);
	set(n-1,x-1);
	set(n+1,x+1);
	set(n-2,x+2);
	set(n+2,x-2);
	int cur=1;
	for (int i=1;i<2*n;i++)
	{
		if (!p[i])
		{
			while (used[cur])
			cur++;
			set(i,cur);
		}
		printf("%d ",p[i]);
	}
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define inf 1e15
vector<vector<long long>>dp;
vector<long long >slimes,sum;
long ans=0;

long solve(int s,int e){
    if(s==e) return 0;
    if(dp[s][e]!=inf) return dp[s][e];
    else{
        // for(int i=s;i<=e;i++){
	       // for(int j=e;j>=s;j--){
	            for(int k=s;k<e;k++){
                    dp[s][e]=min(sum[e]-((s-1<0)?0:sum[s-1])+solve(s,k)+solve(k+1,e),dp[s][e]);
                    //  cout<<"x"<<i<<"x"<<j<<"x"<<dp[i][j];
                    // return dp[i][j];
	            }
	       // }
        // }
        // ans+=dp[s][e];
        // cout<<"x"<<s<<"x"<<e<<"x"<<dp[s][e];
        return dp[s][e];
    }
}
int main() {
	int n;
	cin>>n;
	dp.resize(n,vector<long long>(n,inf));
	slimes.resize(n);
	sum.resize(n);
	for(int i=0;i<n;i++){
	    cin>>slimes[i];
	    dp[i][i]=slimes[i];
	    sum[i]=((i-1<0)?0:sum[i-1])+slimes[i];   
	}
// 	for(int i=0;i<n;i++){
// 	    for(int j=i;j<n;j++){
// 	        for(int k=i;k<j;k++){
// 	            dp[i][j]=min(dp[i][k]+dp[k+1][j],dp[i][j]);
// 	            cout<<"x"<<i<<"x"<<j<<"x"<<dp[i][j];
// 	        }
// 	    }
// 	}
ans=	solve(0,n-1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
inline int newline() { putchar('\n'); return 0; }

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

    string s[n];
    rep2(i, n) cin(s[i]);

    ll max = 1;
    map<string, ll> dic;

    rep2(i, n) {
        string temp = s[i];

        if (dic.find(temp) != dic.end()) {
            ll count = dic.at(temp);
            count++;
            dic.erase(temp);
            dic.emplace(temp, count);
            if (count > max) max = count;
        } else {
            dic.emplace(temp, 1);
        }
    }

    for (const auto x : dic){
        if (x.second == max) print(x.first);
    }

    return 0;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
vector<vector<int>>g(1e5+10);
int h[100005];
int n,m;
// bool dfs(int v,int h)
// {
// 	if(vis[v])
// 	return false;
	
// 	for(int i=g[v].begin();i<g[v].size();i++)
	
// }
int main() {
	// your code goes here

	cin>>n>>m;
	//int h[n];
	for(int i=0;i<n;i++)
	cin>>h[i];
	g.resize(n);
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	vector<int>vis(n,0);
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		 if(vis[i]==1)
		 continue;
		 int flag=1;
	     for(int j=0;j<g[i].size();j++)
	     {
	     	if(h[g[i][j]]>=h[i])
	     	{
	     		flag=0;
	     		break;
	     	}
	     	
	     	
	     }
	     if(flag)
	     {
	     	cnt++;
	     	//cout<<i<<"\n";
	     	for(int j=0;j<g[i].size();j++)
	     	{
	     		vis[g[i][j]]=1;
	     	}
	    
	     	
	     }
	}
	cout<<cnt;
	
	
	
	return 0;
}

Measured memory_bytes: 9000
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;
typedef pair<int, int> P;
static const int INF = 99999999;
struct SEdge
{
	int To;
	int Cost;
};
vector<int> d;
vector< vector<SEdge> > G;

void Dijkstra(int s)
{
	fill(d.begin(), d.end(), INF);
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P> > PQue;
	PQue.push(P(0, s));
	while(!PQue.empty())
	{
		P p = PQue.top();
		PQue.pop();
		int v = p.second;
		if(d[v] < p.first)
		{
			continue;
		}
		for(int i = 0; i < G[v].size(); ++i)
		{
			SEdge e = G[v][i];
			if(d[e.To] > d[v] + e.Cost)
			{
				d[e.To] = d[v] + e.Cost;
				PQue.push(P(d[e.To], e.To));
			}
		}
	}
}

void solve()
{
	int n;
	cin >> n;
	d.resize(n);
	G.resize(n);
	for(int i = 0; i < n; ++i)
	{
		int From, To_Size;
		cin >> From >> To_Size;
		--From;
		vector<int> Vec(To_Size);
		for(int j = 0; j < To_Size; ++j)
		{
			cin >> Vec[j];
			--Vec[j];
			SEdge e;
			e.To = Vec[j];
			e.Cost = 1;
			G[From].push_back(e);
		}
	}
	int p;
	cin >> p;
	for(int i = 0; i < p; ++i)
	{
		int s, g, vp;
		cin >> s >> g >> vp;
		--s;
		--g;
		Dijkstra(s);
		if(d[g] + 1 <= vp)
		{
			cout << d[g] + 1 << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
}

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

Measured memory_bytes: 0
#include <stdio.h>

int main(void){
  int N,i,flag=0;
  int H[100000];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&H[i]);
  }
  for(i=N-1; i>0; i--){
    if(H[i]-H[i-1]==-1){
      H[i-1]--;
    }
    else if(H[i]-H[i-1]>=0){
      continue;
    }
    else{
      flag=1;
      break;
    }
  }
  if(flag==0){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int dfs(int u, vector<int> &longestPath, vector<vector<int> > &graph) {
    if (longestPath[u] != -1)
        return longestPath[u];
    int maxm = 0;
    for (auto v : graph[u]) {
        maxm = max (maxm, 1+dfs(v, longestPath, graph));
    }
    return longestPath[u] = maxm;
}
int main() {
    int n, m;
    cin>>n>>m;
    vector<vector<int> >graph(n+1);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin>>u>>v;
        graph[u].push_back(v);
    }
    vector<int> longestPath(n+1, -1);
    int ans = 0;
    for (int vertex = 1; vertex <= n; vertex++) {
        if (longestPath[vertex] == -1)
            dfs(vertex, longestPath, graph);
        ans = max (ans, longestPath[vertex]);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 11780
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */


int main(){
  fastio;
  ll N;
  cin >> N;
  auto baisuu = mvec<ll>(N+1);
  auto DP = mvec<ll>(N+1);
  map<ll, ll> ret;
  rep(soln, 2, N+1){
    ll n = soln;
    for(ll i{2}; i <= n; i++){
      while(n % i == 0){
        ret[i]++;
        n /= i;
      }
    }
  }
  ll mt14{}, mt74{}, mt24{}, mt4{}, mt2{};
  for(auto&& i : ret){
    if(i.second >= 2){
      mt2++;
    }
    if(i.second >= 4){
      mt4++;
    }
    if(i.second >= 14){
      mt14++;
    }
    if(i.second >= 24){
      mt24++;
    }
    if(i.second >= 74){
      mt74++;
    }
  }
  cout <<
  combpm(mt4, 2LL) * combpm(mt2 - 2, 1LL) +
  combpm(mt14, 1LL) * combpm(mt4 - 1, 1LL) +
  combpm(mt24, 1LL) * combpm(mt2 - 1, 1LL) +
  combpm(mt74, 1LL) << rt;
}

Measured memory_bytes: 9600
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,ii ) for( typeof(gg.begin()) ii=gg.begin();ii!=gg.end();ii++)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define sz(a) int((a).size())
#define N 1000010
#define MAX 30
#define mod 1000000007
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define all(a) a.begin(),a.end()
const ll INF = 1e18+1;

ll a[N];
vector <ll> G[N];

int dfs(int v){
	int w,z=0;
	vector <int> x;
	REP(i,sz(G[v])){
		w=G[v][i];
		x.pb(dfs(w));
	}
	sort(all(x),greater<int>());
	REP(i,sz(x)){
		x[i]+=(i+1);
		z=max(z,x[i]);
	}
	return z;
}

int main()
{
	ll n,x=0,y;
	scanf("%lld",&n);
	REP(i,n-1){
		scanf("%lld",&x);
		x--;
		G[x].pb(i+1);
	}
	printf("%d\n",dfs(0));
return 0;
}

Measured memory_bytes: 36224
#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() {
    int x;
    cin >> x;
    if(x<=599) cout << 8 << endl;
    else if(x<800) cout << 7 << endl;
    else if(x<1000) cout << 6 << endl;
    else if(x<1200) cout << 5 << endl;
    else if(x<1400) cout << 4 << endl;
    else if(x<1600) cout << 3 << endl;
    else if(x<1800) cout << 2 << endl;
    else if(x<2000) cout << 1 << endl;
}


Measured memory_bytes: 3632
l=sorted(map(int,input().split()))
a=(l[2]-l[0])//2
b=(l[2]-l[1])//2
l[0]+=a*2
l[1]+=b*2
if sum(l)==l[2]*3:
  print(a+b)
elif sum(l)==l[2]*3-1:
  print(a+b+2)
elif sum(l)==l[2]*3-2:
  print(a+b+1)

Measured memory_bytes: 3064
#pragma GCC target("arch=cascadelake")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>

int32_t n;
int32_t a[200000];
int32_t b[200000];

int main(void) {
    scanf("%" SCNd32, &n);
    for (int32_t i = 0; i < n; ++i) {
        scanf("%" SCNd32, &a[i]);
        b[i] = a[i] + n - i - 1;
    }
    int64_t cnt = 0;
    for (int32_t i = 0; i < n; ++i) {
        int32_t c = n - i - 1 - a[i];
        for (int32_t j = i + 1; j < n; ++j) {
            if (b[j] == c) {
                ++cnt;
            }
        }
    }
    printf("%" PRId64 "\n", cnt);
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
int INF = 100;
int main(){
  int n;
  cin >> n;
  vector<string> S(n);
  for (int i = 0; i < n; i++){
    cin >> S[i];
  }
  vector<vector<int>> count(n, vector<int>(26, 0));
  for (int i = 0; i < n; i++){
    for (int j = 0; j < S[i].size(); j++){
      count[i][S[i][j] - 'a']++;
    }
  }
  vector<int> res(26, INF);
  for (int i = 0; i < n; i++){
    for (int j = 0; j < 26; j++){
      res[j] = min(res[j], count[i][j]);
    }
  }
  string ans;
  for (int i = 0; i < 26; i++){
    for (int j = 0; j < res[i]; j++){
      ans += 'a' + i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class ANumberOfMultiples {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int l,r,d;
        cin>>l>>r>>d;
        int a[101]={0};
        for (int i=d;i<=r;i+=d)
            a[i]=1;
        int count=0;
        for (int i=l;i<=r;i++)
            if(a[i])
                count++;
        cout<<count;
	}
};


int main() {
	ANumberOfMultiples solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3540
loop do
  wd = gets.chomp
  w, d = wd.split.map(&:to_i)
  break if w.zero? && d.zero?
  widths = Array.new(21, 0)
  heights = Array.new(21, 0)
  gets.split.map(&:to_i).each do |i|
    widths[i] += 1
  end
  gets.split.map(&:to_i).each do |i|
    heights[i] += 1
  end

  answer = 0
  0.upto(20).each do |i|
    answer += [widths[i], heights[i]].max * i
  end

  puts answer
end

Measured memory_bytes: 6120
import sys
from collections.abc import Iterable


def read():
    return sys.stdin.buffer.readline().rstrip()


class FenwickTree:
    def __init__(self, arg):
        if isinstance(arg, int):
            self._n = arg
            self._a = [0] * arg
        elif isinstance(arg, Iterable):
            a = list(arg)
            self._n = len(a)
            self._a = [0] * self._n
            self.set(a)

    def set(self, a):
        for i, ai in enumerate(a):
            self.add(i, ai)

    def add(self, i, x):
        i += 1
        while i <= self._n:
            self._a[i - 1] += x
            i += i & -i

    def update(self, i, x):
        self.add(i, x - self.sum(i, i + 1))

    def sum(self, l, r):
        return self._sum(r) - self._sum(l)

    def _sum(self, r):
        s = 0
        while r > 0:
            s += self._a[r - 1]
            r -= r & -r
        return s


def main():
    n, q = map(int, read().split())
    fw = FenwickTree(map(int, read().split()))
    for _ in range(q):
        query = [int(i) for i in read().split()]
        if query[0] == 0:
            fw.add(query[1], query[2])
        else:
            print(fw.sum(query[1], query[2]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 57048
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int rem=n%10;
    if(rem==2 || rem==4 || rem==5 || rem==7 || rem==9)
        cout<<"hon";
    else if(rem==0 || rem==1 || rem==6 || rem==8)
        cout<<"pon";
    else
        cout<<"bon";
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){

    string s="";
    getline(cin,s);
    int x=s.length();
        for(int i=0;i<x;i++){
            if(s[i]==','){
            s[i]=' ';
            }
        }
      cout<<s;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
  int i, n;
  int *a;
  
  scanf("%d", &n);
  a = (int *)malloc(n * sizeof(int));
  
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }

  for(i = 0; i < n; i++){
    printf("node %d: key = %d, ", i+1, a[i]);
    if(i == 0){
      if((2*(i+1)-1 < n) && (2*(i+1)-1 >= 0)){
	printf("left key = %d, ", a[2*(i+1)-1]);
      }
      if((2*(i+1) < n) && (2*(i+1) >= 0)){
	printf("right key = %d, ", a[2*(i+1)]);
      }
      printf("\n");
      continue;
    }
    printf("parent key = %d, ", a[(i+1)/2-1]);
    if((2*(i+1)-1 < n) && (2*(i+1)-1 >= 0)){
      printf("left key = %d, ", a[2*(i+1)-1]);
    }
    if((2*(i+1) < n) && (2*(i+1) >= 0)){
      printf("right key = %d, ", a[2*(i+1)]);
    }
    printf("\n");
  }
  
  return 0;
}


Measured memory_bytes: 1852
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);
  
  public void solve() {
    int n = in.ni(), W = in.ni();
    int[] weight = new int[n];
    long[] value = new long[n];
    for (int i = 0; i < n; i++) {
      weight[i] = in.ni();
      value[i] = in.nl();
    }
    out.println(dp(n, W, weight, value));
  }
  
  private long dp(int n, int W, int[] weight, long[] value) {
    long[] last = new long[W + 1];
    for (int current = 0; current <= W; current++) {
      if (current + weight[n - 1] <= W) {
        last[current] = value[n - 1];
      }
    }
    for (int idx = n - 2; idx >= 0; idx--) {
      long[] dp = new long[W + 1];
      for (int current = 0; current <= W; current++) {
        dp[current] = last[current];
        if (current + weight[idx] <= W) {
          dp[current] = Math.max(dp[current], value[idx] + last[current + weight[idx]]);
        }
      }
      last = dp;
    }
    return last[0];
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


Measured memory_bytes: 59476
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cmath>
#include<complex>
#include<utility>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define mp         make_pair
#define pb         push_back

const int N = 10010;

class st{
public:
  short beg,end;
  bool operator<(const st & a)const{
    if (beg != a.beg)return beg < a.beg;
    return end < a.end;
  }
};

short  isexist[N]={0};
short testcase=0;
int x[N];
vector<st> inx[N];

int req[N];

void makedata(int n,int *x1,int *x2,int *y1,int *y2,
	      int &px,int *xd,vector<st> *IN){
  testcase++;
  rep(i,n){
    isexist[x1[i]]=testcase;
    isexist[x2[i]]=testcase;
  }
  rep(i,N)if (isexist[i]==testcase)x[px]=i,IN[px++].clear();

  rep(i,n){
    int j=lower_bound(xd,xd+px,x1[i])-xd;
    while(j < px && xd[j] < x2[i]){
      bool isin=false;
      rep(k,IN[j].size()){
	short Y1 = y1[i],Y2=y2[i];
	short &Y3=IN[j][k].beg;
	short &Y4=IN[j][k].end;
	if (Y4 <= Y1 || Y2 <= Y3)continue;
	isin=true;
	Y3=min(Y1,Y3);
	Y4=max(Y2,Y4);
	break;
      }
      if (!isin)IN[j].pb((st){y1[i],y2[i]});
      j++;
    }
  }
}

pair<int,int> solve(int n,vector<st> *in,int *c){
  int area=0;
  int len=0;
  rep(i,n-1){
    if (in[i].size() == 0)continue;
    sort(in[i].begin(),in[i].end());
    short l=-1,h=-1;
    short width;
    width=c[i+1]-c[i];
    rep(j,in[i].size()){
      short &nowl=in[i][j].beg,&nowh=in[i][j].end;
      if (nowl > h){
	len+=2*width;
	area+=(nowh-nowl)*width;
      }else if (nowl == h){
	area+=(nowh-nowl)*width;
      }else if (nowh > h){
	area+=(nowh-h)*width;
      }
      l=nowl;
      h=max(h,nowh);
    }
  }
  return mp(area,len);
}

main(){
  int n,q;
  static int x1[N],y1[N],x2[N],y2[N];
  while(cin>>n>>q && n){
    rep(i,n){
      cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];
    }
    int px=0,py=0;
    makedata(n,x1,x2,y1,y2,px,x,inx);
    pair<int,int> ansx=solve(px,inx,x);

    cout << ansx.first << endl;
    if (q == 2){
      px=0;
      makedata(n,y1,y2,x1,x2,px,x,inx);
      pair<int,int> ansy= solve(px,inx,x);      
      cout << ansx.second+ansy.second << endl;
    }
    rep(i,px)inx[i].clear();
  }
  return false;
}

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

int main()
{
    int s;
    cin >> s;
    int check=0;
    
    long ans[1000000];
    ans[0] = s;
    
    for(int i=0;i<999999;i++)
    {
        if(ans[i]%2 == 0)
        {
            ans[i+1]=ans[i]/2;
        }
        else
        {
            ans[i+1]=3*ans[i]+1;
        }
        
        for(int k=0;k<i;k++){
            if(ans[i] == ans[k])
            {
                cout << i+1 << endl;
                check++;
                break;
            }
        } 
        if(check==1) break;
    }
    return 0;
}

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

using namespace std;


int main(){

    int n;
    cin>>n;
    long sum=0;


    for (int i = 1; i <= n; i++) {
          if (i % 3 == 0){
              ;;
          }else if (i % 5 == 0){
              ;;
          }else{
              sum+=i;
          }
    }
    cout<<sum<<endl;

    return 0;

}



Measured memory_bytes: 3624
N, Q = map(int, input().split())
S = input()
cons = [0] * (N + 1)

for i in range(N - 1):
  #隣り合う2文字(S[i] + S[i + 1])が"AC"である数の累積和を予め記録しておく
  #愚直に計算すると最悪でN * Q = 10 ** 6となるため、下準備をして再計算を防ぐ
  ##ACACTACGなら[0,1,1,2,2,2,3,3]
  cons[i + 1] = cons[i] + (1 if S[i] + S[i + 1] == 'AC' else 0)

for i in range(Q):
  l,r = map(int, input().split())
  #予め記録してあるACの累積数を引けば範囲内のACの数が求められる
  #ACと単位が2文字であるためrを1つ左にずらしておく(1引かないとCがはみ出てしまう)
  print(cons[r - 1] - cons[l - 1])

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


if n%2 == 0:
    for i in range(n-1,-1,-2): print( a[i], end=' ' )
    for i in range(  0, n, 2): print( a[i], end=' ' )
else:
    for i in range(n-1,-1,-2): print( a[i], end=' ' )
    for i in range( 1 , n, 2): print( a[i], end=' ' )

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define ZERO(a) memset(a,0,sizeof(a))

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll n;
ll dp[2][3010][3010];
ll a[3010];

ll rec(ll man, ll l, ll r){

  if(dp[man][l][r]!=LLINF)
    return dp[man][l][r];

  if(l>r)
    return dp[man][l][r]=0;

  if(man==0)
    return dp[man][l][r] = max(rec((man+1)%2,l+1,r)+a[l], rec((man+1)%2,l,r-1)+a[r]);
  else
    return dp[man][l][r] = min(rec((man+1)%2,l+1,r)-a[l], rec((man+1)%2,l,r-1)-a[r]);
}

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

  cin>>n;
  REP(i,n)cin>>a[i];
  REP(i,2)REP(j,3010)REP(k,3010)dp[i][j][k]=LLINF;

  ll ans = rec(0, 0, n-1);
  cout<<ans<<endl;

}


Measured memory_bytes: 142080